summaryrefslogtreecommitdiffstats
path: root/src/boot/bootctl-reboot-to-firmware.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/boot/bootctl-reboot-to-firmware.c')
-rw-r--r--src/boot/bootctl-reboot-to-firmware.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/boot/bootctl-reboot-to-firmware.c b/src/boot/bootctl-reboot-to-firmware.c
index 91f2597..cdb04f8 100644
--- a/src/boot/bootctl-reboot-to-firmware.c
+++ b/src/boot/bootctl-reboot-to-firmware.c
@@ -2,6 +2,7 @@
#include "bootctl-reboot-to-firmware.h"
#include "efi-api.h"
+#include "errno-util.h"
#include "parse-util.h"
int verb_reboot_to_firmware(int argc, char *argv[], void *userdata) {
@@ -17,7 +18,7 @@ int verb_reboot_to_firmware(int argc, char *argv[], void *userdata) {
puts("supported");
return 1; /* recognizable error #1 */
}
- if (r == -EOPNOTSUPP) {
+ if (ERRNO_IS_NEG_NOT_SUPPORTED(r)) {
puts("not supported");
return 2; /* recognizable error #2 */
}
@@ -36,3 +37,39 @@ int verb_reboot_to_firmware(int argc, char *argv[], void *userdata) {
return 0;
}
}
+
+int vl_method_set_reboot_to_firmware(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
+ static const JsonDispatch dispatch_table[] = {
+ { "state", JSON_VARIANT_BOOLEAN, json_dispatch_boolean, 0, 0 },
+ {}
+ };
+ bool b;
+ int r;
+
+ r = varlink_dispatch(link, parameters, dispatch_table, &b);
+ if (r != 0)
+ return r;
+
+ r = efi_set_reboot_to_firmware(b);
+ if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
+ return varlink_error(link, "io.systemd.BootControl.RebootToFirmwareNotSupported", NULL);
+ if (r < 0)
+ return r;
+
+ return varlink_reply(link, NULL);
+}
+
+int vl_method_get_reboot_to_firmware(Varlink *link, JsonVariant *parameters, VarlinkMethodFlags flags, void *userdata) {
+ int r;
+
+ if (json_variant_elements(parameters) > 0)
+ return varlink_error_invalid_parameter(link, parameters);
+
+ r = efi_get_reboot_to_firmware();
+ if (ERRNO_IS_NEG_NOT_SUPPORTED(r))
+ return varlink_error(link, "io.systemd.BootControl.RebootToFirmwareNotSupported", NULL);
+ if (r < 0)
+ return r;
+
+ return varlink_replyb(link, JSON_BUILD_OBJECT(JSON_BUILD_PAIR_BOOLEAN("state", r)));
+}