debuggers.hg

view tools/blktap2/drivers/blk_netbsd.c @ 22848:6341fe0f4e5a

Added tag 4.1.0-rc2 for changeset 9dca60d88c63
author Keir Fraser <keir@xen.org>
date Tue Jan 25 14:06:55 2011 +0000 (2011-01-25)
parents b7f73a7f3078
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 }