]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect: show more information in output
authorLennart Poettering <lennart@poettering.net>
Tue, 28 Jul 2020 21:49:35 +0000 (23:49 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 11 Aug 2020 20:26:48 +0000 (22:26 +0200)
Let's show size and image filename.

src/dissect/dissect.c

index 0ccb603b5d3031d93bdc98f45807e219bfa1716c..f1f323b131716f06a8dd9457ff3f70d62428cd26 100644 (file)
@@ -4,11 +4,14 @@
 #include <getopt.h>
 #include <linux/loop.h>
 #include <stdio.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
 
 #include "architecture.h"
 #include "copy.h"
 #include "dissect-image.h"
 #include "fd-util.h"
+#include "format-util.h"
 #include "fs-util.h"
 #include "hexdecoct.h"
 #include "log.h"
@@ -342,6 +345,7 @@ static int run(int argc, char *argv[]) {
         switch (arg_action) {
 
         case ACTION_DISSECT: {
+                uint64_t size;
                 unsigned i;
 
                 for (i = 0; i < _PARTITION_DESIGNATOR_MAX; i++) {
@@ -375,6 +379,15 @@ static int run(int argc, char *argv[]) {
                         putchar('\n');
                 }
 
+                printf("      Name: %s\n", basename(arg_image));
+
+                if (ioctl(d->fd, BLKGETSIZE64, &size) < 0)
+                        log_debug_errno(errno, "Failed to query size of loopback device: %m");
+                else {
+                        char t[FORMAT_BYTES_MAX];
+                        printf("      Size: %s\n", format_bytes(t, sizeof(t), size));
+                }
+
                 r = dissected_image_acquire_metadata(m);
                 if (r < 0)
                         return log_error_errno(r, "Failed to acquire image metadata: %m");