From 5771c7d5a2986661487d1b37cfdce0645bb93f98 Mon Sep 17 00:00:00 2001 From: Xavier Hernandez Date: Mon, 9 Jan 2017 13:10:19 +0100 Subject: libglusterfs: fix statvfs in FreeBSD FreeBSD interprets statvfs' f_bsize field in a different way than Linux. This fix modifies the value returned by statvfs() on FreeBSD to match the expected value by Gluster. > Change-Id: I930dab6e895671157238146d333e95874ea28a08 > BUG: 1356076 > Signed-off-by: Xavier Hernandez > Reviewed-on: http://review.gluster.org/16361 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > Reviewed-by: Kaleb KEITHLEY > CentOS-regression: Gluster Build System > Reviewed-by: Jeff Darcy Change-Id: I3c470eaa326fd975ac26ff5917c7c01580f86676 BUG: 1411901 Signed-off-by: Xavier Hernandez Reviewed-on: http://review.gluster.org/16401 Smoke: Gluster Build System NetBSD-regression: NetBSD Build System Reviewed-by: Kaleb KEITHLEY CentOS-regression: Gluster Build System --- libglusterfs/src/syscall.c | 35 ++++++++++++++++++++++++++++++++++- libglusterfs/src/syscall.h | 3 +++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/libglusterfs/src/syscall.c b/libglusterfs/src/syscall.c index 0828b8a64fa..3683488edb6 100644 --- a/libglusterfs/src/syscall.c +++ b/libglusterfs/src/syscall.c @@ -283,7 +283,40 @@ sys_lseek (int fd, off_t offset, int whence) int sys_statvfs (const char *path, struct statvfs *buf) { - return statvfs (path, buf); + int ret; + + ret = statvfs (path, buf); +#ifdef __FreeBSD__ + /* FreeBSD doesn't return the expected vaule in buf->f_bsize. It + * contains the optimal I/O size instead of the file system block + * size. Gluster expects that this field contains the block size. + */ + if (ret == 0) { + buf->f_bsize = buf->f_frsize; + } +#endif /* __FreeBSD__ */ + + return ret; +} + + +int +sys_fstatvfs (int fd, struct statvfs *buf) +{ + int ret; + + ret = fstatvfs (fd, buf); +#ifdef __FreeBSD__ + /* FreeBSD doesn't return the expected vaule in buf->f_bsize. It + * contains the optimal I/O size instead of the file system block + * size. Gluster expects this field to contain the block size. + */ + if (ret == 0) { + buf->f_bsize = buf->f_frsize; + } +#endif /* __FreeBSD__ */ + + return ret; } diff --git a/libglusterfs/src/syscall.h b/libglusterfs/src/syscall.h index bbf23bef07b..a9f6a7eb1cc 100644 --- a/libglusterfs/src/syscall.h +++ b/libglusterfs/src/syscall.h @@ -141,6 +141,9 @@ sys_lseek (int fd, off_t offset, int whence); int sys_statvfs (const char *path, struct statvfs *buf); +int +sys_fstatvfs (int fd, struct statvfs *buf); + int sys_close (int fd); -- cgit