]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: show partition output even if os-release is missing 17093/head
authorLennart Poettering <lennart@poettering.net>
Thu, 17 Sep 2020 15:52:00 +0000 (17:52 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 17 Sep 2020 16:02:49 +0000 (18:02 +0200)
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

index 14cdad82b5f53baed34e22866ba9ddaeadbec957..dd80e86feeeadcbf220c702a9f7660ec56480a1d 100644 (file)
@@ -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();