From 9849336064f8c48ae17f1e7f1cc7ef3c0610ea4e Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 7 Dec 2005 13:52:34 +0100 Subject: [PATCH] [PATCH] fio: BLKGETSIZE64 is os specific, not arch. --- arch.h | 4 ---- fio.c | 6 ++++-- os-freebsd.h | 8 ++++++++ os-linux.h | 14 ++++++++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/arch.h b/arch.h index da4a6a8..745bf3a 100644 --- a/arch.h +++ b/arch.h @@ -39,8 +39,4 @@ static inline unsigned long generic_ffz(unsigned long word) #define BITS_PER_LONG (__WORDSIZE) -#ifndef BLKGETSIZE64 -#define BLKGETSIZE64 _IOR(0x12,114,size_t) -#endif - #endif diff --git a/fio.c b/fio.c index d7fa0d1..e166f49 100644 --- a/fio.c +++ b/fio.c @@ -1175,9 +1175,11 @@ static int file_size(struct thread_data *td) static int bdev_size(struct thread_data *td) { size_t bytes; + int r; - if (ioctl(td->fd, BLKGETSIZE64, &bytes) < 0) { - td_verror(td, errno); + r = blockdev_size(td->fd, &bytes); + if (r) { + td_verror(td, r); return 1; } diff --git a/os-freebsd.h b/os-freebsd.h index e59822b..a79483b 100644 --- a/os-freebsd.h +++ b/os-freebsd.h @@ -11,4 +11,12 @@ typedef unsigned long os_cpu_mask_t; +/* + * FIXME + */ +static inline int blockdev_size(int fd, size_t *bytes) +{ + return 1; +} + #endif diff --git a/os-linux.h b/os-linux.h index 8d9ad1a..e414364 100644 --- a/os-linux.h +++ b/os-linux.h @@ -1,6 +1,8 @@ #ifndef FIO_OS_LINUX_H #define FIO_OS_LINUX_H +#include + #define FIO_HAVE_LIBAIO #define FIO_HAVE_POSIXAIO #define FIO_HAVE_FADVISE @@ -35,4 +37,16 @@ enum { #define IOPRIO_CLASS_SHIFT 13 +#ifndef BLKGETSIZE64 +#define BLKGETSIZE64 _IOR(0x12,114,size_t) +#endif + +static inline int blockdev_size(int fd, size_t *bytes) +{ + if (!ioctl(fd, BLKGETSIZE64, bytes)) + return 0; + + return errno; +} + #endif -- 2.25.1