From 4f309abb3e91d001b79deb79732f8032e5025be0 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 17 Sep 2020 17:52:00 +0200 Subject: [PATCH] dissect: show partition output even if os-release is missing It's just too useful to immediately see with "systemd-dissect" what "systemd-repart" generated for us without having to populate it with /etc/os-release. Hence let's log a message if /etc/os-release is missing, but proceed otherwise and show the partition table. --- src/dissect/dissect.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 14cdad82b5..dd80e86fee 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -369,11 +369,11 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) { r = dissected_image_acquire_metadata(m); if (r == -ENXIO) return log_error_errno(r, "No root partition discovered."); - if (r == -EMEDIUMTYPE) - return log_error_errno(r, "Not a valid OS image, no os-release file included."); if (r == -EUCLEAN) return log_error_errno(r, "File system check of image failed."); - if (r == -EUNATCH) + if (r == -EMEDIUMTYPE) + log_warning_errno(r, "Not a valid OS image, no os-release file included. Proceeding anyway."); + else if (r == -EUNATCH) log_warning_errno(r, "OS image is encrypted, proceeding without showing OS image metadata."); else if (r == -EBUSY) log_warning_errno(r, "OS image is currently in use, proceeding without showing OS image metadata."); @@ -403,9 +403,13 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) { p == m->os_release ? "OS Release:" : " ", *p, *q); } - } - if (arg_json) { + if (m->hostname || + !sd_id128_is_null(m->machine_id) || + !strv_isempty(m->machine_info) || + !strv_isempty(m->os_release)) + putc('\n', stdout); + } else { _cleanup_(json_variant_unrefp) JsonVariant *mi = NULL, *osr = NULL; if (!strv_isempty(m->machine_info)) { @@ -431,9 +435,6 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) { return log_oom(); } - if (!arg_json) - putc('\n', stdout); - t = table_new("rw", "designator", "partition uuid", "fstype", "architecture", "verity", "node", "partno"); if (!t) return log_oom();