]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-tool: show sector/image size from DissectedImage object
authorLennart Poettering <lennart@poettering.net>
Mon, 4 Dec 2023 17:25:54 +0000 (18:25 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 13 Dec 2023 16:35:22 +0000 (17:35 +0100)
The information is provided to us already in the structure now, hence
use it.

src/dissect/dissect.c

index 92432b6fedeb03b828c758bc8ba9aecd2ad142f7..aea3d6234ec3c5f0539c67f2833eeead6c394ac2 100644 (file)
@@ -827,16 +827,15 @@ static int action_dissect(DissectedImage *m, LoopDevice *d) {
         if (arg_json_format_flags & (JSON_FORMAT_OFF|JSON_FORMAT_PRETTY|JSON_FORMAT_PRETTY_AUTO))
                 pager_open(arg_pager_flags);
 
-        if (arg_json_format_flags & JSON_FORMAT_OFF)
-                printf("      Name: %s%s%s\n", ansi_highlight(), bn, ansi_normal());
+        if (arg_json_format_flags & JSON_FORMAT_OFF) {
+                printf("      Name: %s%s%s\n",
+                       ansi_highlight(), bn, ansi_normal());
 
-        if (ioctl(d->fd, BLKGETSIZE64, &size) < 0)
-                log_debug_errno(errno, "Failed to query size of loopback device: %m");
-        else if (arg_json_format_flags & JSON_FORMAT_OFF)
-                printf("      Size: %s\n", FORMAT_BYTES(size));
+                printf("      Size: %s\n",
+                       FORMAT_BYTES(m->image_size));
 
-        if (arg_json_format_flags & JSON_FORMAT_OFF) {
-                printf(" Sec. Size: %" PRIu32 "\n", m->sector_size);
+                printf(" Sec. Size: %" PRIu32 "\n",
+                       m->sector_size);
 
                 printf("     Arch.: %s\n",
                        strna(architecture_to_string(dissected_image_architecture(m))));