]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: update dissect tool to show image metadata
authorLennart Poettering <lennart@poettering.net>
Tue, 14 Nov 2017 22:24:13 +0000 (23:24 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 20 Nov 2017 15:43:15 +0000 (16:43 +0100)
Pretty straight-forward: just use the new metadata dissection API to
figure out what an image contains.

src/dissect/dissect.c

index 42957766eaa75240695c717a128529a88c62f4e6..0210e463720d39cd259796bda4f3190d81555a59 100644 (file)
@@ -28,6 +28,7 @@
 #include "log.h"
 #include "loop-util.h"
 #include "string-util.h"
+#include "strv.h"
 #include "util.h"
 
 static enum {
@@ -264,6 +265,36 @@ int main(int argc, char *argv[]) {
                         putchar('\n');
                 }
 
+                r = dissected_image_acquire_metadata(m);
+                if (r < 0) {
+                        log_error_errno(r, "Failed to acquire image metadata: %m");
+                        goto finish;
+                }
+
+                if (m->hostname)
+                        printf("  Hostname: %s\n", m->hostname);
+
+                if (!sd_id128_is_null(m->machine_id))
+                        printf("Machine ID: " SD_ID128_FORMAT_STR "\n", SD_ID128_FORMAT_VAL(m->machine_id));
+
+                if (!strv_isempty(m->machine_info)) {
+                        char **p, **q;
+
+                        STRV_FOREACH_PAIR(p, q, m->machine_info)
+                                printf("%s %s=%s\n",
+                                       p == m->machine_info ? "Mach. Info:" : "           ",
+                                       *p, *q);
+                }
+
+                if (!strv_isempty(m->os_release)) {
+                        char **p, **q;
+
+                        STRV_FOREACH_PAIR(p, q, m->os_release)
+                                printf("%s %s=%s\n",
+                                       p == m->os_release ? "OS Release:" : "           ",
+                                       *p, *q);
+                }
+
                 break;
         }