From aa5e69b26d16ae4c1680d05b25149f3198036714 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 24 Jun 2010 09:25:15 +0200 Subject: [PATCH 1/1] Add real blockdev_size() for FreeBSD Signed-off-by: Jens Axboe --- os/os-freebsd.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/os/os-freebsd.h b/os/os-freebsd.h index 44b60606..3115b605 100644 --- a/os/os-freebsd.h +++ b/os/os-freebsd.h @@ -3,16 +3,28 @@ #include #include +#include #define FIO_HAVE_POSIXAIO #define FIO_HAVE_ODIRECT -#define FIO_USE_GENERIC_BDEV_SIZE #define FIO_USE_GENERIC_RAND #define OS_MAP_ANON MAP_ANON typedef off_t off64_t; +static inline int blockdev_size(int fd, unsigned long long *bytes) +{ + off_t size; + + if (!ioctl(fd, DIOCGMEDIASIZE, &size)) { + *bytes = size; + return 0; + } + + return errno; +} + static inline int blockdev_invalidate_cache(int fd) { return EINVAL; -- 2.25.1