]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
boot-entry: Add boot_entry_token_type_to_string()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 23 Oct 2023 09:18:19 +0000 (11:18 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 6 Nov 2023 13:39:01 +0000 (14:39 +0100)
src/shared/boot-entry.c
src/shared/boot-entry.h

index 0595ac6238addd55b1a923c6ab1472552debd664..e726073b646a51f74f0a8c833c49c619f26066a3 100644 (file)
@@ -7,6 +7,7 @@
 #include "id128-util.h"
 #include "os-util.h"
 #include "path-util.h"
+#include "string-table.h"
 #include "string-util.h"
 #include "utf8.h"
 
@@ -260,3 +261,13 @@ int parse_boot_entry_token_type(const char *s, BootEntryTokenType *type, char **
         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                "Unexpected parameter for --entry-token=: %s", s);
 }
+
+static const char *const boot_entry_token_type_table[] = {
+        [BOOT_ENTRY_TOKEN_MACHINE_ID]  = "machine-id",
+        [BOOT_ENTRY_TOKEN_OS_IMAGE_ID] = "os-image-id",
+        [BOOT_ENTRY_TOKEN_OS_ID]       = "os-id",
+        [BOOT_ENTRY_TOKEN_LITERAL]     = "literal",
+        [BOOT_ENTRY_TOKEN_AUTO]        = "auto",
+};
+
+DEFINE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_token_type, BootEntryTokenType);
index 1d20db602adcebeec5090032067b800d9782770c..f3a6f28417668520fa01094c83571bd448db9b09 100644 (file)
@@ -31,3 +31,5 @@ int boot_entry_token_ensure_at(
                 char **token);
 
 int parse_boot_entry_token_type(const char *s, BootEntryTokenType *type, char **token);
+
+const char* boot_entry_token_type_to_string(BootEntryTokenType t);