From: Lennart Poettering Date: Mon, 4 Dec 2023 17:25:54 +0000 (+0100) Subject: dissect-tool: show sector/image size from DissectedImage object X-Git-Tag: v256-rc1~1490^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5b1b37c86aa7bfebcb80c4ef98db9eecc5dff2e3;p=thirdparty%2Fsystemd.git dissect-tool: show sector/image size from DissectedImage object The information is provided to us already in the structure now, hence use it. --- diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 92432b6fede..aea3d6234ec 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -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))));