Add real blockdev_size() for FreeBSD
authorJens Axboe <jaxboe@fusionio.com>
Thu, 24 Jun 2010 07:25:15 +0000 (09:25 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Thu, 24 Jun 2010 07:25:15 +0000 (09:25 +0200)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
os/os-freebsd.h

index 44b60606327ec1d28f1a974047bdac90c8805a1e..3115b605064bc7a55b5d162ab59c872475f4c8ee 100644 (file)
@@ -3,16 +3,28 @@
 
 #include <errno.h>
 #include <sys/sysctl.h>
+#include <sys/disk.h>
 
 #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;