]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
bootctl: normalize some enum definitions
authorLennart Poettering <lennart@poettering.net>
Wed, 3 Sep 2025 09:48:39 +0000 (11:48 +0200)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 19 Sep 2025 15:47:46 +0000 (00:47 +0900)
src/bootctl/bootctl-install.c
src/bootctl/bootctl.c
src/bootctl/bootctl.h
src/shared/boot-entry.h

index 4eefc715d5e4d608be08a4e4c0015d1184a6ed13..3605b43ef03ea6047cbdecbcf51332ebc2ab0cb1 100644 (file)
@@ -381,7 +381,7 @@ static int update_efi_boot_binaries(const char *esp_path, const char *source_pat
 }
 
 static int copy_one_file(const char *esp_path, const char *name, bool force) {
-        char *root = IN_SET(arg_install_source, ARG_INSTALL_SOURCE_AUTO, ARG_INSTALL_SOURCE_IMAGE) ? arg_root : NULL;
+        char *root = IN_SET(arg_install_source, INSTALL_SOURCE_AUTO, INSTALL_SOURCE_IMAGE) ? arg_root : NULL;
         _cleanup_free_ char *source_path = NULL, *dest_path = NULL, *p = NULL, *q = NULL;
         const char *e;
         char *dest_name, *s;
@@ -398,7 +398,7 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
 
         r = chase(p, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &source_path, NULL);
         /* If we had a root directory to try, we didn't find it and we are in auto mode, retry on the host */
-        if (r == -ENOENT && root && arg_install_source == ARG_INSTALL_SOURCE_AUTO)
+        if (r == -ENOENT && root && arg_install_source == INSTALL_SOURCE_AUTO)
                 r = chase(p, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &source_path, NULL);
         if (r < 0)
                 return log_error_errno(r,
@@ -444,14 +444,14 @@ static int copy_one_file(const char *esp_path, const char *name, bool force) {
 }
 
 static int install_binaries(const char *esp_path, const char *arch, bool force) {
-        char *root = IN_SET(arg_install_source, ARG_INSTALL_SOURCE_AUTO, ARG_INSTALL_SOURCE_IMAGE) ? arg_root : NULL;
+        char *root = IN_SET(arg_install_source, INSTALL_SOURCE_AUTO, INSTALL_SOURCE_IMAGE) ? arg_root : NULL;
         _cleanup_closedir_ DIR *d = NULL;
         _cleanup_free_ char *path = NULL;
         int r;
 
         r = chase_and_opendir(BOOTLIBDIR, root, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &path, &d);
         /* If we had a root directory to try, we didn't find it and we are in auto mode, retry on the host */
-        if (r == -ENOENT && root && arg_install_source == ARG_INSTALL_SOURCE_AUTO)
+        if (r == -ENOENT && root && arg_install_source == INSTALL_SOURCE_AUTO)
                 r = chase_and_opendir(BOOTLIBDIR, NULL, CHASE_PREFIX_ROOT|CHASE_PROHIBIT_SYMLINKS|CHASE_TRIGGER_AUTOFS, &path, &d);
         if (r == -ENOENT && arg_graceful() != ARG_GRACEFUL_NO) {
                 log_debug("Source directory does not exist, ignoring.");
index 0ef17ba501945f5b05ee47627561731d6ef4c4c9..86a51f8f410b0bb9030e1f856185f09916ebdc86 100644 (file)
@@ -67,7 +67,7 @@ sd_json_format_flags_t arg_json_format_flags = SD_JSON_FORMAT_OFF;
 bool arg_arch_all = false;
 char *arg_root = NULL;
 char *arg_image = NULL;
-InstallSource arg_install_source = ARG_INSTALL_SOURCE_AUTO;
+InstallSource arg_install_source = INSTALL_SOURCE_AUTO;
 char *arg_efi_boot_option_description = NULL;
 bool arg_dry_run = false;
 ImagePolicy *arg_image_policy = NULL;
@@ -483,11 +483,11 @@ static int parse_argv(int argc, char *argv[]) {
 
                 case ARG_INSTALL_SOURCE:
                         if (streq(optarg, "auto"))
-                                arg_install_source = ARG_INSTALL_SOURCE_AUTO;
+                                arg_install_source = INSTALL_SOURCE_AUTO;
                         else if (streq(optarg, "image"))
-                                arg_install_source = ARG_INSTALL_SOURCE_IMAGE;
+                                arg_install_source = INSTALL_SOURCE_IMAGE;
                         else if (streq(optarg, "host"))
-                                arg_install_source = ARG_INSTALL_SOURCE_HOST;
+                                arg_install_source = INSTALL_SOURCE_HOST;
                         else
                                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                        "Unexpected parameter for --install-source=: %s", optarg);
@@ -648,7 +648,7 @@ static int parse_argv(int argc, char *argv[]) {
         if (arg_root && arg_image)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Please specify either --root= or --image=, the combination of both is not supported.");
 
-        if (arg_install_source != ARG_INSTALL_SOURCE_AUTO && !arg_root && !arg_image)
+        if (arg_install_source != INSTALL_SOURCE_AUTO && !arg_root && !arg_image)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "--install-from-host is only supported with --root= or --image=.");
 
         if (arg_dry_run && argv[optind] && !STR_IN_SET(argv[optind], "unlink", "cleanup"))
index 7504d5715cfd9fe5dda538aa8f6937ec63c1561b..4f052e67bc181f630e31fa181a73f969a8c9294c 100644 (file)
@@ -4,9 +4,11 @@
 #include "forward.h"
 
 typedef enum InstallSource {
-        ARG_INSTALL_SOURCE_IMAGE,
-        ARG_INSTALL_SOURCE_HOST,
-        ARG_INSTALL_SOURCE_AUTO,
+        INSTALL_SOURCE_IMAGE,
+        INSTALL_SOURCE_HOST,
+        INSTALL_SOURCE_AUTO,
+        _INSTALL_SOURCE_MAX,
+        _INSTALL_SOURCE_INVALID = -EINVAL,
 } InstallSource;
 
 typedef enum GracefulMode {
index 927802e5eeee9dcb58f477dddf55138fb3c3848e..71260d4ff7b35ee2b5fcfa6473ba92411b217032 100644 (file)
@@ -11,6 +11,8 @@ typedef enum BootEntryTokenType {
         BOOT_ENTRY_TOKEN_OS_ID,
         BOOT_ENTRY_TOKEN_LITERAL,
         BOOT_ENTRY_TOKEN_AUTO,
+        _BOOT_ENTRY_TOKEN_TYPE_MAX,
+        _BOOT_ENTRY_TOKEN_TYPE_INVALID = -EINVAL,
 } BootEntryTokenType;
 
 bool boot_entry_token_valid(const char *p);