Revision 191c2890 qemu-io.c
b/qemu-io.c | ||
---|---|---|
1443 | 1443 |
}; |
1444 | 1444 |
|
1445 | 1445 |
static int |
1446 |
map_f(int argc, char **argv) |
|
1447 |
{ |
|
1448 |
int64_t offset; |
|
1449 |
int64_t nb_sectors; |
|
1450 |
char s1[64]; |
|
1451 |
int num, num_checked; |
|
1452 |
int ret; |
|
1453 |
const char *retstr; |
|
1454 |
|
|
1455 |
offset = 0; |
|
1456 |
nb_sectors = bs->total_sectors; |
|
1457 |
|
|
1458 |
do { |
|
1459 |
num_checked = MIN(nb_sectors, INT_MAX); |
|
1460 |
ret = bdrv_is_allocated(bs, offset, num_checked, &num); |
|
1461 |
retstr = ret ? " allocated" : "not allocated"; |
|
1462 |
cvtstr(offset << 9ULL, s1, sizeof(s1)); |
|
1463 |
printf("[% 24" PRId64 "] % 8d/% 8d sectors %s at offset %s (%d)\n", |
|
1464 |
offset << 9ULL, num, num_checked, retstr, s1, ret); |
|
1465 |
|
|
1466 |
offset += num; |
|
1467 |
nb_sectors -= num; |
|
1468 |
} while(offset < bs->total_sectors); |
|
1469 |
|
|
1470 |
return 0; |
|
1471 |
} |
|
1472 |
|
|
1473 |
static const cmdinfo_t map_cmd = { |
|
1474 |
.name = "map", |
|
1475 |
.argmin = 0, |
|
1476 |
.argmax = 0, |
|
1477 |
.cfunc = map_f, |
|
1478 |
.args = "", |
|
1479 |
.oneline = "prints the allocated areas of a file", |
|
1480 |
}; |
|
1481 |
|
|
1482 |
|
|
1483 |
static int |
|
1446 | 1484 |
close_f(int argc, char **argv) |
1447 | 1485 |
{ |
1448 | 1486 |
bdrv_close(bs); |
... | ... | |
1680 | 1718 |
add_command(&length_cmd); |
1681 | 1719 |
add_command(&info_cmd); |
1682 | 1720 |
add_command(&alloc_cmd); |
1721 |
add_command(&map_cmd); |
|
1683 | 1722 |
|
1684 | 1723 |
add_args_command(init_args_command); |
1685 | 1724 |
add_check_command(init_check_command); |
Also available in: Unified diff