aboutsummaryrefslogtreecommitdiffstats
path: root/tools/blktap2/drivers/block-ram.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/blktap2/drivers/block-ram.c')
-rw-r--r--tools/blktap2/drivers/block-ram.c19
1 files changed, 3 insertions, 16 deletions
diff --git a/tools/blktap2/drivers/block-ram.c b/tools/blktap2/drivers/block-ram.c
index 16b4ec9dc7..fdf6ace25c 100644
--- a/tools/blktap2/drivers/block-ram.c
+++ b/tools/blktap2/drivers/block-ram.c
@@ -34,9 +34,9 @@
#include <sys/statvfs.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <linux/fs.h>
#include <string.h>
+#include "blk.h"
#include "tapdisk.h"
#include "tapdisk-driver.h"
#include "tapdisk-interface.h"
@@ -69,10 +69,8 @@ static int get_image_info(int fd, td_disk_info_t *info)
if (S_ISBLK(stat.st_mode)) {
/*Accessing block device directly*/
info->size = 0;
- if (ioctl(fd,BLKGETSIZE,&info->size)!=0) {
- DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
+ if (blk_getimagesize(fd, &info->size) != 0)
return -EINVAL;
- }
DPRINTF("Image size: \n\tpre sector_shift [%llu]\n\tpost "
"sector_shift [%llu]\n",
@@ -80,19 +78,8 @@ static int get_image_info(int fd, td_disk_info_t *info)
(long long unsigned)info->size);
/*Get the sector size*/
-#if defined(BLKSSZGET)
- {
- int arg;
+ if (blk_getsectorsize(fd, &info->sector_size) != 0)
info->sector_size = DEFAULT_SECTOR_SIZE;
- ioctl(fd, BLKSSZGET, &info->sector_size);
-
- if (info->sector_size != DEFAULT_SECTOR_SIZE)
- DPRINTF("Note: sector size is %ld (not %d)\n",
- info->sector_size, DEFAULT_SECTOR_SIZE);
- }
-#else
- info->sector_size = DEFAULT_SECTOR_SIZE;
-#endif
} else {
/*Local file? try fstat instead*/