X-Git-Url: https://git.kernel.dk/?p=fio.git;a=blobdiff_plain;f=os%2Fos-linux.h;h=e7d600dd58cbb3f6ffd1e43f5516fdd6fc0bd18a;hp=8c1e93be067c9e0cd702ed23b4e8baba5a7f5ef7;hb=2c3e17be4c7c9a737317ada414b98929652fec15;hpb=5283741f7be708fbbb3feb2cd5ca5187f3a964d1 diff --git a/os/os-linux.h b/os/os-linux.h index 8c1e93be..e7d600dd 100644 --- a/os/os-linux.h +++ b/os/os-linux.h @@ -392,4 +392,22 @@ static inline int shm_attach_to_open_removed(void) return 1; } +#ifdef CONFIG_LINUX_FALLOCATE +#define FIO_HAVE_NATIVE_FALLOCATE +static inline bool fio_fallocate(struct fio_file *f, uint64_t offset, + uint64_t len) +{ + int ret; + ret = fallocate(f->fd, 0, 0, len); + if (ret == 0) + return true; + + /* Work around buggy old glibc versions... */ + if (ret > 0) + errno = ret; + + return false; +} +#endif + #endif