diff options
Diffstat (limited to 'tools/blktap2/drivers/tapdisk-utils.c')
-rw-r--r-- | tools/blktap2/drivers/tapdisk-utils.c | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/tools/blktap2/drivers/tapdisk-utils.c b/tools/blktap2/drivers/tapdisk-utils.c index 560f3bf6cc..4304ecf0f2 100644 --- a/tools/blktap2/drivers/tapdisk-utils.c +++ b/tools/blktap2/drivers/tapdisk-utils.c @@ -29,12 +29,12 @@ #include <stdio.h> #include <string.h> #include <unistd.h> -#include <linux/fs.h> #include <sys/stat.h> #include <sys/mman.h> #include <sys/ioctl.h> #include <sys/resource.h> +#include "blk.h" #include "tapdisk.h" #include "disktypes.h" #include "blktaplib.h" @@ -150,7 +150,7 @@ tapdisk_get_image_size(int fd, uint64_t *_sectors, uint32_t *_sector_size) int ret; struct stat stat; uint64_t sectors; - uint32_t sector_size; + uint64_t sector_size; sectors = 0; sector_size = 0; @@ -164,26 +164,12 @@ tapdisk_get_image_size(int fd, uint64_t *_sectors, uint32_t *_sector_size) if (S_ISBLK(stat.st_mode)) { /*Accessing block device directly*/ - if (ioctl(fd, BLKGETSIZE, §ors)) { - DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image"); + if (blk_getimagesize(fd, §ors) != 0) return -EINVAL; - } /*Get the sector size*/ -#if defined(BLKSSZGET) - { - int arg; + if (blk_getsectorsize(fd, §or_size) != 0) sector_size = DEFAULT_SECTOR_SIZE; - ioctl(fd, BLKSSZGET, §or_size); - - if (sector_size != DEFAULT_SECTOR_SIZE) - DPRINTF("Note: sector size is %u (not %d)\n", - sector_size, DEFAULT_SECTOR_SIZE); - } -#else - sector_size = DEFAULT_SECTOR_SIZE; -#endif - } else { /*Local file? try fstat instead*/ sectors = (stat.st_size >> SECTOR_SHIFT); |