Revision d1f6fd8d block/raw-posix.c
b/block/raw-posix.c | ||
---|---|---|
64 | 64 |
#include <sys/dkio.h> |
65 | 65 |
#endif |
66 | 66 |
|
67 |
#ifdef __NetBSD__ |
|
68 |
#include <sys/ioctl.h> |
|
69 |
#include <sys/disklabel.h> |
|
70 |
#include <sys/dkio.h> |
|
71 |
#include <sys/disk.h> |
|
72 |
#endif |
|
73 |
|
|
67 | 74 |
#ifdef __DragonFly__ |
68 | 75 |
#include <sys/ioctl.h> |
69 | 76 |
#include <sys/diskslice.h> |
... | ... | |
665 | 672 |
} else |
666 | 673 |
return st.st_size; |
667 | 674 |
} |
675 |
#elif defined(__NetBSD__) |
|
676 |
static int64_t raw_getlength(BlockDriverState *bs) |
|
677 |
{ |
|
678 |
BDRVRawState *s = bs->opaque; |
|
679 |
int fd = s->fd; |
|
680 |
struct stat st; |
|
681 |
|
|
682 |
if (fstat(fd, &st)) |
|
683 |
return -1; |
|
684 |
if (S_ISCHR(st.st_mode) || S_ISBLK(st.st_mode)) { |
|
685 |
struct dkwedge_info dkw; |
|
686 |
|
|
687 |
if (ioctl(fd, DIOCGWEDGEINFO, &dkw) != -1) { |
|
688 |
return dkw.dkw_size * 512; |
|
689 |
} else { |
|
690 |
struct disklabel dl; |
|
691 |
|
|
692 |
if (ioctl(fd, DIOCGDINFO, &dl)) |
|
693 |
return -1; |
|
694 |
return (uint64_t)dl.d_secsize * |
|
695 |
dl.d_partitions[DISKPART(st.st_rdev)].p_size; |
|
696 |
} |
|
697 |
} else |
|
698 |
return st.st_size; |
|
699 |
} |
|
668 | 700 |
#elif defined(__sun__) |
669 | 701 |
static int64_t raw_getlength(BlockDriverState *bs) |
670 | 702 |
{ |
Also available in: Unified diff