ia64/xen-unstable

view tools/blktap2/drivers/blk_netbsd.c @ 19817:b7f73a7f3078

blktap2: portability fixes for NetBSD

- Use standard off_t and lseek() instead of non-portable off64_t and
lseek64()
- Use uuid API as documented in DCE 1.1 RPC specification
- Add NetBSD implementation for blk_getimagesize() and
blk_getsectorsize()
- Use blk_getimagesize() and blk_getsectorsize()
- Fix uuid header check

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jun 23 17:24:14 2009 +0100 (2009-06-23)
parents
children
line source
1 #include <sys/param.h>
2 #include <sys/ioctl.h>
3 #include <sys/disklabel.h>
4 #include <errno.h>
5 #include <inttypes.h>
6 #include "tapdisk.h"
7 #include "blk.h"
9 int blk_getimagesize(int fd, uint64_t *size)
10 {
11 int rc;
12 struct disklabel dl;
14 *size = 0;
15 rc = ioctl(fd, DIOCGDINFO, &dl);
16 if (rc) {
17 DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
18 return -EINVAL;
19 }
21 *size = dl.d_secsize * dl.d_secpercyl;
23 return 0;
24 }
26 int blk_getsectorsize(int fd, uint64_t *sector_size)
27 {
28 int rc;
29 struct disklabel dl;
31 *sector_size = DEV_BSIZE;
32 rc = ioctl(fd, DIOCGDINFO, &dl);
33 if (rc) {
34 DPRINTF("ERR: DIOCGDINFO failed, couldn't stat image");
35 return 0; /* fallback to DEV_BSIZE */
36 }
38 *sector_size = dl.d_secsize;
39 return 0;
40 }