From a1edd22e67f077b8a7b4fce3f4905f35078a701a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 14 Nov 2017 23:24:13 +0100 Subject: [PATCH] dissect: update dissect tool to show image metadata Pretty straight-forward: just use the new metadata dissection API to figure out what an image contains. --- src/dissect/dissect.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 4295776..0210e46 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -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; } -- 2.7.4