X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-mac.h;h=a1536c70fabaf9e2de907eab9ffec0740f2bb3db;hp=7de36ea79aa7b43a7f962796526cf000a2458527;hb=2c3e17be4c7c9a737317ada414b98929652fec15;hpb=5283741f7be708fbbb3feb2cd5ca5187f3a964d1 diff --git a/os/os-mac.h b/os/os-mac.h index 7de36ea7..a1536c70 100644 --- a/os/os-mac.h +++ b/os/os-mac.h @@ -20,6 +20,7 @@ #define FIO_USE_GENERIC_INIT_RANDOM_STATE #define FIO_HAVE_GETTID #define FIO_HAVE_CHARDEV_SIZE +#define FIO_HAVE_NATIVE_FALLOCATE #define OS_MAP_ANON MAP_ANON @@ -101,4 +102,15 @@ static inline int gettid(void) */ extern int fdatasync(int fd); +static inline bool fio_fallocate(struct fio_file *f, uint64_t offset, uint64_t len) +{ + fstore_t store = {F_ALLOCATEALL, F_PEOFPOSMODE, offset, len}; + if (fcntl(f->fd, F_PREALLOCATE, &store) != -1) { + if (ftruncate(f->fd, len) == 0) + return true; + } + + return false; +} + #endif