dissect: show more information in output

Let's show size and image filename.
This commit is contained in:
Lennart Poettering 2020-07-28 23:49:35 +02:00
parent 33973b841d
commit 16b7459280
1 changed files with 13 additions and 0 deletions

View 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");