From: Volker Lendecke Date: Sun, 23 Nov 2025 06:59:55 +0000 (+0100) Subject: smbd: Add sys_fstatvfs() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7d06923eca40889489a4a02fea3f589f073b3531;p=thirdparty%2Fsamba.git smbd: Add sys_fstatvfs() Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 26a6b6d9176..509c3019644 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1049,6 +1049,7 @@ NTSTATUS srvstr_push_fn(const char *base_ptr, uint16_t smb_flags2, void *dest, /* The following definitions come from smbd/statvfs.c */ int sys_statvfs(const char *path, struct vfs_statvfs_struct *statbuf); +int sys_fstatvfs(int fd, struct vfs_statvfs_struct *statbuf); /* The following definitions come from smbd/trans2.c */ diff --git a/source3/smbd/statvfs.c b/source3/smbd/statvfs.c index 064c6ac02f8..0c45f3c238d 100644 --- a/source3/smbd/statvfs.c +++ b/source3/smbd/statvfs.c @@ -127,6 +127,22 @@ static int bsd_statvfs(const char *path, struct vfs_statvfs_struct *statbuf) return 0; } + +static int bsd_fstatvfs(int fd, struct vfs_statvfs_struct *statbuf) +{ + struct statfs sbuf; + int ret; + + ret = fstatfs(fd, &sbuf); + if (ret != 0) { + return ret; + } + + bsd_init_statvfs(&sbuf, statbuf); + + return 0; +} + #elif defined(STAT_STATVFS) && defined(HAVE_FSID_INT) static void posix_init_statvfs(const struct statvfs *src, @@ -181,6 +197,23 @@ static int posix_statvfs(const char *path, struct vfs_statvfs_struct *statbuf) return 0; } + +static int posix_fstatvfs(int fd, struct vfs_statvfs_struct *statbuf) +{ + struct statvfs statvfs_buf; + int ret; + + ret = fstatvfs(fd, &statvfs_buf); + + if (ret != 0) { + return ret; + } + + posix_init_statvfs(&statvfs_buf, statbuf); + + return 0; +} + #endif /* @@ -205,3 +238,19 @@ int sys_statvfs(const char *path, struct vfs_statvfs_struct *statbuf) #endif /* LINUX */ } + +int sys_fstatvfs(int fd, struct vfs_statvfs_struct *statbuf) +{ +#if defined(BSD_STYLE_STATVFS) + return bsd_fstatvfs(fd, statbuf); +#elif defined(STAT_STATVFS) && defined(HAVE_FSID_INT) + return posix_fstatvfs(fd, statbuf); +#else + /* BB change this to return invalid level */ +#ifdef EOPNOTSUPP + return EOPNOTSUPP; +#else + return -1; +#endif /* EOPNOTSUPP */ +#endif /* LINUX */ +}