From: Tomohiro Kusumi Date: Fri, 21 Oct 2016 17:07:32 +0000 (+0900) Subject: Add blockdev_size() support for NetBSD X-Git-Tag: fio-2.16~30 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=fc0aa68abd51f312f0b609ea0aef4524a8652316 Add blockdev_size() support for NetBSD This commit is NetBSD version of 1116dc04 in 2015. NetBSD still has block device as a file type, thus it differs from FreeBSD/DragonFlyBSD regarding FIO_HAVE_CHARDEV_SIZE. Signed-off-by: Tomohiro Kusumi Signed-off-by: Jens Axboe --- diff --git a/os/os-netbsd.h b/os/os-netbsd.h index 1ef58667..2133d7a1 100644 --- a/os/os-netbsd.h +++ b/os/os-netbsd.h @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include /* XXX hack to avoid confilcts between rbtree.h and */ #define rb_node _rb_node #include @@ -17,7 +20,6 @@ #include "../file.h" #define FIO_HAVE_ODIRECT -#define FIO_USE_GENERIC_BDEV_SIZE #define FIO_USE_GENERIC_RAND #define FIO_USE_GENERIC_INIT_RANDOM_STATE #define FIO_HAVE_FS_STAT @@ -37,6 +39,19 @@ typedef off_t off64_t; +static inline int blockdev_size(struct fio_file *f, unsigned long long *bytes) +{ + struct disklabel dl; + + if (!ioctl(f->fd, DIOCGDINFO, &dl)) { + *bytes = ((unsigned long long)dl.d_secperunit) * dl.d_secsize; + return 0; + } + + *bytes = 0; + return errno; +} + static inline int blockdev_invalidate_cache(struct fio_file *f) { return EINVAL;