Files
systemd/src/shared/varlink-io.systemd.FactoryReset.c
T
Lennart Poettering 41d9ed93d9 factory-reset: revamp infrastructure
This introduces a bunch of facilities:

1. The factory-reset.target unit that requests a factory reset is now
   complemented by factory-reset-now.target that executes it at next
   boot.

2. This latter is added to the initial transaction via the new trivial
   systemd-factory-reset-generator.

3. A tool systemd-factory-reset has been added to query, request,
   cancel, complete factory reset operations (via EFI variables). Two of
   these are wrapped into units that are plugged into
   factory-reset.target and factory-reset-now.target respectively. The
   tool also provides a simple Varlink API.

This should make things a lot cleaner, and both be useful as explicit
implementation on UEFI, and as template + hookpoints for alternative
implementations on non-UEFI.
2025-03-05 12:37:26 +01:00

40 lines
2.0 KiB
C

/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "varlink-io.systemd.FactoryReset.h"
#include "sd-varlink-idl.h"
static SD_VARLINK_DEFINE_ENUM_TYPE(
FactoryResetMode,
SD_VARLINK_FIELD_COMMENT("Factory reset is not supported on this OS."),
SD_VARLINK_DEFINE_ENUM_VALUE(unsupported),
SD_VARLINK_FIELD_COMMENT("Factory reset not requested."),
SD_VARLINK_DEFINE_ENUM_VALUE(unspecified),
SD_VARLINK_FIELD_COMMENT("Factory reset explicitly turned off."),
SD_VARLINK_DEFINE_ENUM_VALUE(off),
SD_VARLINK_FIELD_COMMENT("Factory reset is currently being executed."),
SD_VARLINK_DEFINE_ENUM_VALUE(on),
SD_VARLINK_FIELD_COMMENT("Factory reset has been completed during the current boot."),
SD_VARLINK_DEFINE_ENUM_VALUE(complete),
SD_VARLINK_FIELD_COMMENT("Factory reset has been requested for the next boot."),
SD_VARLINK_DEFINE_ENUM_VALUE(pending));
static SD_VARLINK_DEFINE_METHOD(
GetFactoryResetMode,
SD_VARLINK_FIELD_COMMENT("The current factory reset mode"),
SD_VARLINK_DEFINE_OUTPUT_BY_TYPE(mode, FactoryResetMode, 0));
static SD_VARLINK_DEFINE_METHOD(
CanRequestFactoryReset,
SD_VARLINK_DEFINE_OUTPUT(supported, SD_VARLINK_BOOL, 0));
SD_VARLINK_DEFINE_INTERFACE(
io_systemd_FactoryReset,
"io.systemd.FactoryReset",
SD_VARLINK_INTERFACE_COMMENT("APIs to query factory reset status"),
SD_VARLINK_SYMBOL_COMMENT("Encodes the current factory reset status"),
&vl_type_FactoryResetMode,
SD_VARLINK_SYMBOL_COMMENT("Report the current factory reset status"),
&vl_method_GetFactoryResetMode,
SD_VARLINK_SYMBOL_COMMENT("Returns whether requesting a factory reset is available (by invoking the factory-reset.target unit)."),
&vl_method_CanRequestFactoryReset);