diff options
Diffstat (limited to 'qemu-io.c')
-rw-r--r-- | qemu-io.c | 22 |
1 files changed, 14 insertions, 8 deletions
@@ -1170,11 +1170,10 @@ static int alloc_f(int argc, char **argv) { int64_t offset; - int nb_sectors; + int nb_sectors, remaining; char s1[64]; - int num; + int num, sum_alloc; int ret; - const char *retstr; offset = cvtnum(argv[1]); if (offset & 0x1ff) { @@ -1188,16 +1187,23 @@ alloc_f(int argc, char **argv) else nb_sectors = 1; - ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num); + remaining = nb_sectors; + sum_alloc = 0; + while (remaining) { + ret = bdrv_is_allocated(bs, offset >> 9, nb_sectors, &num); + remaining -= num; + if (ret) { + sum_alloc += num; + } + } cvtstr(offset, s1, sizeof(s1)); - retstr = ret ? "allocated" : "not allocated"; if (nb_sectors == 1) - printf("sector %s at offset %s\n", retstr, s1); + printf("sector allocated at offset %s\n", s1); else - printf("%d/%d sectors %s at offset %s\n", - num, nb_sectors, retstr, s1); + printf("%d/%d sectors allocated at offset %s\n", + sum_alloc, nb_sectors, s1); return 0; } |