Revision 4a1d5e1f block/raw-posix.c
b/block/raw-posix.c | ||
---|---|---|
793 | 793 |
} |
794 | 794 |
#endif |
795 | 795 |
|
796 |
static int64_t raw_get_allocated_file_size(BlockDriverState *bs) |
|
797 |
{ |
|
798 |
struct stat st; |
|
799 |
BDRVRawState *s = bs->opaque; |
|
800 |
|
|
801 |
if (fstat(s->fd, &st) < 0) { |
|
802 |
return -errno; |
|
803 |
} |
|
804 |
return (int64_t)st.st_blocks * 512; |
|
805 |
} |
|
806 |
|
|
796 | 807 |
static int raw_create(const char *filename, QEMUOptionParameter *options) |
797 | 808 |
{ |
798 | 809 |
int fd; |
... | ... | |
888 | 899 |
|
889 | 900 |
.bdrv_truncate = raw_truncate, |
890 | 901 |
.bdrv_getlength = raw_getlength, |
902 |
.bdrv_get_allocated_file_size |
|
903 |
= raw_get_allocated_file_size, |
|
891 | 904 |
|
892 | 905 |
.create_options = raw_create_options, |
893 | 906 |
}; |
... | ... | |
1156 | 1169 |
.bdrv_read = raw_read, |
1157 | 1170 |
.bdrv_write = raw_write, |
1158 | 1171 |
.bdrv_getlength = raw_getlength, |
1172 |
.bdrv_get_allocated_file_size |
|
1173 |
= raw_get_allocated_file_size, |
|
1159 | 1174 |
|
1160 | 1175 |
/* generic scsi device */ |
1161 | 1176 |
#ifdef __linux__ |
... | ... | |
1277 | 1292 |
.bdrv_read = raw_read, |
1278 | 1293 |
.bdrv_write = raw_write, |
1279 | 1294 |
.bdrv_getlength = raw_getlength, |
1295 |
.bdrv_get_allocated_file_size |
|
1296 |
= raw_get_allocated_file_size, |
|
1280 | 1297 |
|
1281 | 1298 |
/* removable device support */ |
1282 | 1299 |
.bdrv_is_inserted = floppy_is_inserted, |
... | ... | |
1380 | 1397 |
.bdrv_read = raw_read, |
1381 | 1398 |
.bdrv_write = raw_write, |
1382 | 1399 |
.bdrv_getlength = raw_getlength, |
1400 |
.bdrv_get_allocated_file_size |
|
1401 |
= raw_get_allocated_file_size, |
|
1383 | 1402 |
|
1384 | 1403 |
/* removable device support */ |
1385 | 1404 |
.bdrv_is_inserted = cdrom_is_inserted, |
... | ... | |
1503 | 1522 |
.bdrv_read = raw_read, |
1504 | 1523 |
.bdrv_write = raw_write, |
1505 | 1524 |
.bdrv_getlength = raw_getlength, |
1525 |
.bdrv_get_allocated_file_size |
|
1526 |
= raw_get_allocated_file_size, |
|
1506 | 1527 |
|
1507 | 1528 |
/* removable device support */ |
1508 | 1529 |
.bdrv_is_inserted = cdrom_is_inserted, |
Also available in: Unified diff