Skip to content

Commit 81687cb

Browse files
committed
Add an option to use backup footer when vhd-util query is called
This option already exists on td-util but it was not implemented on vhd-util. Signed-off-by: Ronan Abhamon <[email protected]>
1 parent 8450aed commit 81687cb

File tree

1 file changed

+20
-16
lines changed

1 file changed

+20
-16
lines changed

Diff for: vhd/lib/vhd-util-query.c

+20-16
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@
4343
int
4444
vhd_util_query(int argc, char **argv)
4545
{
46-
char *name;
4746
vhd_context_t vhd;
4847
off64_t currsize;
49-
int ret, err, c, size, physize, parent, fields, depth, fastresize, marker, allocated, resolve_parent;
50-
51-
name = NULL;
52-
size = 0;
53-
physize = 0;
54-
parent = 0;
55-
fields = 0;
56-
depth = 0;
57-
fastresize = 0;
58-
marker = 0;
59-
allocated = 0;
60-
resolve_parent = 1;
61-
48+
int ret, err, c;
49+
50+
char *name = NULL;
51+
int size = 0;
52+
int physize = 0;
53+
int parent = 0;
54+
int fields = 0;
55+
int depth = 0;
56+
int fastresize = 0;
57+
int marker = 0;
58+
int allocated = 0;
59+
int resolve_parent = 1;
60+
int flags = VHD_OPEN_RDONLY | VHD_OPEN_IGNORE_DISABLED;
61+
6262
if (!argc || !argv) {
6363
err = -EINVAL;
6464
goto usage;
6565
}
6666

6767
optind = 0;
68-
while ((c = getopt(argc, argv, "n:vspfdSmauh")) != -1) {
68+
while ((c = getopt(argc, argv, "n:vspfdSmaubh")) != -1) {
6969
switch (c) {
7070
case 'n':
7171
name = optarg;
@@ -97,6 +97,9 @@ vhd_util_query(int argc, char **argv)
9797
case 'u':
9898
resolve_parent = 0;
9999
break;
100+
case 'b':
101+
flags |= VHD_OPEN_USE_BKP_FOOTER;
102+
break;
100103
case 'h':
101104
err = 0;
102105
goto usage;
@@ -111,7 +114,7 @@ vhd_util_query(int argc, char **argv)
111114
goto usage;
112115
}
113116

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

0 commit comments

Comments
 (0)