return 0;
}
+static int boot_entry_show(const BootEntry *e, bool show_as_default) {
+ assert(e);
+
+ printf(" title: %s%s%s%s%s%s\n",
+ ansi_highlight(),
+ boot_entry_title(e),
+ ansi_normal(),
+ ansi_highlight_green(),
+ show_as_default ? " (default)" : "",
+ ansi_normal());
+
+ if (e->id)
+ printf(" id: %s\n", e->id);
+ if (e->version)
+ printf(" version: %s\n", e->version);
+ if (e->machine_id)
+ printf(" machine-id: %s\n", e->machine_id);
+ if (e->architecture)
+ printf(" architecture: %s\n", e->architecture);
+ if (e->kernel)
+ printf(" linux: %s\n", e->kernel);
+ if (!strv_isempty(e->initrd)) {
+ _cleanup_free_ char *t;
+
+ t = strv_join(e->initrd, " ");
+ if (!t)
+ return log_oom();
+
+ printf(" initrd: %s\n", t);
+ }
+ if (!strv_isempty(e->options)) {
+ _cleanup_free_ char *t;
+
+ t = strv_join(e->options, " ");
+ if (!t)
+ return log_oom();
+
+ printf(" options: %s\n", t);
+ }
+ if (e->device_tree)
+ printf(" devicetree: %s\n", e->device_tree);
+
+ return 0;
+}
+
static int status_entries(const char *esp_path, sd_id128_t partition) {
_cleanup_(boot_config_free) BootConfig config = {};
int r;
if (config.default_entry < 0)
printf("%zu entries, no entry could be determined as default.\n", config.n_entries);
else {
- const BootEntry *e = &config.entries[config.default_entry];
-
printf("Default Boot Loader Entry:\n");
- printf(" title: %s\n", boot_entry_title(e));
- if (e->version)
- printf(" version: %s\n", e->version);
- if (e->kernel)
- printf(" linux: %s\n", e->kernel);
- if (!strv_isempty(e->initrd)) {
- _cleanup_free_ char *t;
-
- t = strv_join(e->initrd, " ");
- if (!t)
- return log_oom();
-
- printf(" initrd: %s\n", t);
- }
- if (!strv_isempty(e->options)) {
- _cleanup_free_ char *t;
-
- t = strv_join(e->options, " ");
- if (!t)
- return log_oom();
-
- printf(" options: %s\n", t);
- }
- if (e->device_tree)
- printf(" devicetree: %s\n", e->device_tree);
- puts("");
+ boot_entry_show(config.entries + config.default_entry, false);
}
return 0;
static int verb_list(int argc, char *argv[], void *userdata) {
_cleanup_(boot_config_free) BootConfig config = {};
sd_id128_t uuid = SD_ID128_NULL;
- unsigned n;
int r;
/* If we lack privileges we invoke find_esp_and_warn() in "unprivileged mode" here, which does two things: turn
if (r < 0)
return r;
- printf("Boot Loader Entries:\n");
-
- for (n = 0; n < config.n_entries; n++) {
- const BootEntry *e = &config.entries[n];
-
- printf(" title: %s%s%s%s%s%s\n",
- ansi_highlight(),
- boot_entry_title(e),
- ansi_normal(),
- ansi_highlight_green(),
- n == (unsigned) config.default_entry ? " (default)" : "",
- ansi_normal());
- if (e->id)
- printf(" id: %s\n", e->id);
- if (e->version)
- printf(" version: %s\n", e->version);
- if (e->machine_id)
- printf(" machine-id: %s\n", e->machine_id);
- if (e->architecture)
- printf(" architecture: %s\n", e->architecture);
- if (e->kernel)
- printf(" linux: %s\n", e->kernel);
- if (!strv_isempty(e->initrd)) {
- _cleanup_free_ char *t;
-
- t = strv_join(e->initrd, " ");
- if (!t)
- return log_oom();
+ if (config.n_entries == 0)
+ log_info("No boot loader entries found.");
+ else {
+ size_t n;
- printf(" initrd: %s\n", t);
- }
- if (!strv_isempty(e->options)) {
- _cleanup_free_ char *t;
+ printf("Boot Loader Entries:\n");
- t = strv_join(e->options, " ");
- if (!t)
- return log_oom();
+ for (n = 0; n < config.n_entries; n++) {
+ r = boot_entry_show(config.entries + n, n == (size_t) config.default_entry);
+ if (r < 0)
+ return r;
- printf(" options: %s\n", t);
+ puts("");
}
- if (e->device_tree)
- printf(" devicetree: %s\n", e->device_tree);
-
- puts("");
}
return 0;