exe = executable(
'bootctl',
- 'src/boot/bootctl.c',
+ ['src/boot/bootctl.c',
+ 'src/boot/bootctl-reboot-to-firmware.c',
+ 'src/boot/bootctl-reboot-to-firmware.h'],
include_directories : includes,
link_with : [boot_link_with],
dependencies : [libblkid,
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+#include "bootctl-reboot-to-firmware.h"
+#include "efi-api.h"
+#include "parse-util.h"
+
+int verb_reboot_to_firmware(int argc, char *argv[], void *userdata) {
+ int r;
+
+ if (argc < 2) {
+ r = efi_get_reboot_to_firmware();
+ if (r > 0) {
+ puts("active");
+ return EXIT_SUCCESS; /* success */
+ }
+ if (r == 0) {
+ puts("supported");
+ return 1; /* recognizable error #1 */
+ }
+ if (r == -EOPNOTSUPP) {
+ puts("not supported");
+ return 2; /* recognizable error #2 */
+ }
+
+ log_error_errno(r, "Failed to query reboot-to-firmware state: %m");
+ return 3; /* other kind of error */
+ } else {
+ r = parse_boolean(argv[1]);
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse argument: %s", argv[1]);
+
+ r = efi_set_reboot_to_firmware(r);
+ if (r < 0)
+ return log_error_errno(r, "Failed to set reboot-to-firmware option: %m");
+
+ return 0;
+ }
+}
--- /dev/null
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+
+int verb_reboot_to_firmware(int argc, char *argv[], void *userdata);
#include "alloc-util.h"
#include "blkid-util.h"
+#include "bootctl-reboot-to-firmware.h"
#include "bootspec.h"
#include "build.h"
#include "chase-symlinks.h"
return 0;
}
-static int verb_reboot_to_firmware(int argc, char *argv[], void *userdata) {
- int r;
-
- if (argc < 2) {
- r = efi_get_reboot_to_firmware();
- if (r > 0) {
- puts("active");
- return EXIT_SUCCESS; /* success */
- }
- if (r == 0) {
- puts("supported");
- return 1; /* recognizable error #1 */
- }
- if (r == -EOPNOTSUPP) {
- puts("not supported");
- return 2; /* recognizable error #2 */
- }
-
- log_error_errno(r, "Failed to query reboot-to-firmware state: %m");
- return 3; /* other kind of error */
- } else {
- r = parse_boolean(argv[1]);
- if (r < 0)
- return log_error_errno(r, "Failed to parse argument: %s", argv[1]);
-
- r = efi_set_reboot_to_firmware(r);
- if (r < 0)
- return log_error_errno(r, "Failed to set reboot-to-firmware option: %m");
-
- return 0;
- }
-}
-
static int bootctl_main(int argc, char *argv[]) {
static const Verb verbs[] = {
{ "help", VERB_ANY, VERB_ANY, 0, help },