mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-02-15 05:57:26 +03:00
bootctl: show report state and type in json output
This commit is contained in:
parent
e144a26306
commit
4bc14b1790
@ -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)),
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user