summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudwig Nussel <ludwig.nussel@suse.de>2023-04-06 11:45:23 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2023-04-07 10:22:37 +0200
commit4bc14b1790752b6083861d370334ad438d859c54 (patch)
tree82532e3d4ecb256337533a74a18abd8fb597f76a
parente144a26306dbe07fe37f294301421a938b781247 (diff)
downloadsystemd-4bc14b1790752b6083861d370334ad438d859c54.tar.gz
bootctl: show report state and type in json output
-rw-r--r--src/shared/bootspec.c11
-rw-r--r--src/shared/bootspec.h1
2 files changed, 12 insertions, 0 deletions
diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c
index 0d8a8aa0f6..7cc63e8848 100644
--- a/src/shared/bootspec.c
+++ b/src/shared/bootspec.c
@@ -34,6 +34,15 @@ static const char* const boot_entry_type_table[_BOOT_ENTRY_TYPE_MAX] = {
DEFINE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_type, BootEntryType);
+static const char* const boot_entry_type_json_table[_BOOT_ENTRY_TYPE_MAX] = {
+ [BOOT_ENTRY_CONF] = "type1",
+ [BOOT_ENTRY_UNIFIED] = "type2",
+ [BOOT_ENTRY_LOADER] = "loader",
+ [BOOT_ENTRY_LOADER_AUTO] = "auto",
+};
+
+DEFINE_STRING_TABLE_LOOKUP_TO_STRING(boot_entry_type_json, BootEntryType);
+
static void boot_entry_free(BootEntry *entry) {
assert(entry);
@@ -1422,6 +1431,7 @@ int show_boot_entries(const BootConfig *config, JsonFormatFlags json_format) {
}
r = json_append(&v, JSON_BUILD_OBJECT(
+ JSON_BUILD_PAIR("type", JSON_BUILD_STRING(boot_entry_type_json_to_string(e->type))),
JSON_BUILD_PAIR_CONDITION(e->id, "id", JSON_BUILD_STRING(e->id)),
JSON_BUILD_PAIR_CONDITION(e->path, "path", JSON_BUILD_STRING(e->path)),
JSON_BUILD_PAIR_CONDITION(e->root, "root", JSON_BUILD_STRING(e->root)),
@@ -1444,6 +1454,7 @@ int show_boot_entries(const BootConfig *config, JsonFormatFlags json_format) {
* arguments and trigger false positive warnings. Let's not add too many json objects
* at once. */
r = json_append(&v, JSON_BUILD_OBJECT(
+ JSON_BUILD_PAIR("isReported", JSON_BUILD_BOOLEAN(e->reported_by_loader)),
JSON_BUILD_PAIR_CONDITION(e->tries_left != UINT_MAX, "triesLeft", JSON_BUILD_UNSIGNED(e->tries_left)),
JSON_BUILD_PAIR_CONDITION(e->tries_done != UINT_MAX, "triesDone", JSON_BUILD_UNSIGNED(e->tries_done)),
JSON_BUILD_PAIR_CONDITION(config->default_entry >= 0, "isDefault", JSON_BUILD_BOOLEAN(i == (size_t) config->default_entry)),
diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h
index ac4d1890b0..ddd149eadb 100644
--- a/src/shared/bootspec.h
+++ b/src/shared/bootspec.h
@@ -79,6 +79,7 @@ typedef struct BootConfig {
}
const char* boot_entry_type_to_string(BootEntryType);
+const char* boot_entry_type_json_to_string(BootEntryType);
BootEntry* boot_config_find_entry(BootConfig *config, const char *id);