Skip to content

Commit

Permalink
Add an option to use backup footer when vhd-util query is called
Browse files Browse the repository at this point in the history
This option already exists on td-util but it was not implemented
on vhd-util.

Signed-off-by: Ronan Abhamon <[email protected]>
  • Loading branch information
Wescoeur committed Dec 18, 2024
1 parent e371dd8 commit 7c168ec
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions vhd/lib/vhd-util-query.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,29 +43,29 @@
int
vhd_util_query(int argc, char **argv)
{
char *name;
vhd_context_t vhd;
off64_t currsize;
int ret, err, c, size, physize, parent, fields, depth, fastresize, marker, allocated, resolve_parent;

name = NULL;
size = 0;
physize = 0;
parent = 0;
fields = 0;
depth = 0;
fastresize = 0;
marker = 0;
allocated = 0;
resolve_parent = 1;

int ret, err, c;

char *name = NULL;
int size = 0;
int physize = 0;
int parent = 0;
int fields = 0;
int depth = 0;
int fastresize = 0;
int marker = 0;
int allocated = 0;
int resolve_parent = 1;
int flags = VHD_OPEN_RDONLY | VHD_OPEN_IGNORE_DISABLED;

if (!argc || !argv) {
err = -EINVAL;
goto usage;
}

optind = 0;
while ((c = getopt(argc, argv, "n:vspfdSmauh")) != -1) {
while ((c = getopt(argc, argv, "n:vspfdSmaubh")) != -1) {
switch (c) {
case 'n':
name = optarg;
Expand Down Expand Up @@ -97,6 +97,9 @@ vhd_util_query(int argc, char **argv)
case 'u':
resolve_parent = 0;
break;
case 'b':
flags |= VHD_OPEN_USE_BKP_FOOTER;
break;
case 'h':
err = 0;
goto usage;
Expand All @@ -111,7 +114,7 @@ vhd_util_query(int argc, char **argv)
goto usage;
}

err = vhd_open(&vhd, name, VHD_OPEN_RDONLY | VHD_OPEN_IGNORE_DISABLED);
err = vhd_open(&vhd, name, flags);
if (err) {
printf("error opening %s: %d\n", name, err);
return err;
Expand Down Expand Up @@ -218,6 +221,7 @@ vhd_util_query(int argc, char **argv)
"[-S print max virtual size (MB) for fast resize] "
"[-a print allocated block count] "
"[-u don't resolve parent path] "
"[-b don't trust the footer, use the back-up one instead] "
"[-h help]\n");
return err;
}

0 comments on commit 7c168ec

Please sign in to comment.