-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path0001-Add-an-option-to-use-backup-footer-when-vhd-util-que.patch
More file actions
99 lines (93 loc) · 2.61 KB
/
Copy path0001-Add-an-option-to-use-backup-footer-when-vhd-util-que.patch
File metadata and controls
99 lines (93 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
From d8cda8eb7a7404102b10a05e1226129e5c424d0e Mon Sep 17 00:00:00 2001
From: Ronan Abhamon <ronan.abhamon@vates.tech>
Date: Wed, 18 Dec 2024 16:55:26 +0100
Subject: [PATCH] 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 <ronan.abhamon@vates.tech>
---
vhd/lib/vhd-util-query.c | 38 +++++++++++++++++++++-----------------
1 file changed, 21 insertions(+), 17 deletions(-)
diff --git a/vhd/lib/vhd-util-query.c b/vhd/lib/vhd-util-query.c
index 0cd04166..3aca668c 100644
--- a/vhd/lib/vhd-util-query.c
+++ b/vhd/lib/vhd-util-query.c
@@ -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;
@@ -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;
@@ -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;
@@ -207,7 +210,7 @@ vhd_util_query(int argc, char **argv)
max_size = vhd.header.max_bat_size << (VHD_BLOCK_SHIFT - 20);
printf("%"PRIu64"\n", max_size);
}
-
+
vhd_close(&vhd);
return err;
@@ -218,6 +221,7 @@ usage:
"[-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;
}