Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option to use backup footer when vhd-util query is called #417

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}