Files
xen/tools/blktap2/drivers/blk_linux.c
T
Ian Campbell a4f86af3e4 tools/blktap, blktap2: include <sys/mount.h> instead of <linux/fs.h>
The former is a userspace sanitised header which contains the
definitions we need. In some distros linux/fs.h defines WRITE which
conflicts with blktaps own use of that name.

Also there is no reason to use <linux/errno.h> over the more normal
<errno.h>.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
2011-01-17 17:14:20 +00:00

44 lines
832 B
C

#include <inttypes.h>
#include <errno.h>
#include <sys/ioctl.h>
#include <sys/mount.h>
#include "tapdisk.h"
#include "blk.h"
int blk_getimagesize(int fd, uint64_t *size)
{
int rc;
*size = 0;
rc = ioctl(fd, BLKGETSIZE, size);
if (rc) {
DPRINTF("ERR: BLKGETSIZE failed, couldn't stat image");
return -EINVAL;
}
return 0;
}
int blk_getsectorsize(int fd, uint64_t *sector_size)
{
#if defined(BLKSSZGET)
int rc;
*sector_size = DEFAULT_SECTOR_SIZE;
rc = ioctl(fd, BLKSSZGET, sector_size);
if (rc) {
DPRINTF("ERR: BLKSSZGET failed. Falling back to use default sector size");
*sector_size = DEFAULT_SECTOR_SIZE;
}
if (*sector_size != DEFAULT_SECTOR_SIZE)
DPRINTF("Note: sector size is %"PRIu64" (not %u)\n",
*sector_size, DEFAULT_SECTOR_SIZE);
#else
*sector_size = DEFAULT_SECTOR_SIZE;
#endif
return 0;
}