summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2017-11-14 23:24:13 +0100
committerLennart Poettering <lennart@poettering.net>2017-11-20 16:43:15 +0100
commita1edd22e67f077b8a7b4fce3f4905f35078a701a (patch)
treebe21cdc0e65d972f925a9859f6f6729763589e0c /src
parentdissect: add an API that can read various metadata bits out of a dissected image (diff)
downloadsystemd-a1edd22e67f077b8a7b4fce3f4905f35078a701a.tar.xz
systemd-a1edd22e67f077b8a7b4fce3f4905f35078a701a.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/dissect/dissect.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index 42957766ea..0210e46372 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;
}