summaryrefslogtreecommitdiff
path: root/os/os-netbsd.h
diff options
context:
space:
mode:
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>2016-10-22 02:07:32 +0900
committerJens Axboe <axboe@fb.com>2016-10-26 07:59:59 -0600
commitfc0aa68abd51f312f0b609ea0aef4524a8652316 (patch)
tree164d72d76e673dbb3d551806623746dca602a566 /os/os-netbsd.h
parenta0290964d9e15aa9faa5a139effc14cfa5bcd3f1 (diff)
downloadfio-fc0aa68abd51f312f0b609ea0aef4524a8652316.tar.gz
fio-fc0aa68abd51f312f0b609ea0aef4524a8652316.tar.bz2
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 <kusumi.tomohiro@gmail.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'os/os-netbsd.h')
-rw-r--r--os/os-netbsd.h17
1 files changed, 16 insertions, 1 deletions
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 <lwp.h>
#include <sys/param.h>
#include <sys/statvfs.h>
+#include <sys/ioctl.h>
+#include <sys/dkio.h>
+#include <sys/disklabel.h>
/* XXX hack to avoid confilcts between rbtree.h and <sys/rb.h> */
#define rb_node _rb_node
#include <sys/sysctl.h>
@@ -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;