-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstatic-info.c
65 lines (56 loc) · 1.6 KB
/
static-info.c
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
#include "vhd.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include <glib.h>
/* Display static information about a disk and its base disk (if any) */
int main(int argc, char **argv)
{
struct vhd_file *vhd = vhd_open(argv + 1, argc - 1);
int i = 0, j = 0;
int n = vhd_n_blocks(vhd);
int64_t total;
total = 0;
for (i = 0; i < n; i++) {
if (vhd_is_block_allocated(vhd, i)) {
for (j = 0; j < MT_SECS_PER_BLOCK; j++) {
if (vhd_is_sector_allocated(vhd, i, j))
total++;
}
}
}
printf("allocated = %" PRId64 "\n", total);
total = 0;
for (i = 0; i < n; i++) {
if (vhd_is_block_allocated(vhd, i)) {
for (j = 0; j < MT_SECS_PER_BLOCK; j++) {
if (vhd_is_sector_deferred(vhd, i, j))
total++;
}
}
}
printf("deferred = %" PRId64 "\n", total);
total = 0;
for (i = 0; i < n; i++) {
if (vhd_is_block_allocated(vhd, i)) {
for (j = 0; j < MT_SECS_PER_BLOCK; j++) {
if (vhd_is_sector_leaf_allocated(vhd, i, j))
total++;
}
}
}
printf("leaf_allocated = %" PRId64 "\n", total);
total = 0;
for (i = 0; i < n; i++) {
if (vhd_is_block_allocated(vhd, i)) {
for (j = 0; j < MT_SECS_PER_BLOCK; j++) {
if (vhd_is_sector_overridden(vhd, i, j))
total++;
}
}
}
printf("overridden = %" PRId64 "\n", total);
vhd_close(vhd);
return 0;
}