]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Add sys_fstatvfs()
authorVolker Lendecke <vl@samba.org>
Sun, 23 Nov 2025 06:59:55 +0000 (07:59 +0100)
committerAnoop C S <anoopcs@samba.org>
Sun, 15 Feb 2026 10:42:34 +0000 (10:42 +0000)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/proto.h
source3/smbd/statvfs.c

index 26a6b6d91764370a98452ec08bf7579d5374ff51..509c3019644c5bd25d4c184aeffd258f8d0ecf46 100644 (file)
@@ -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  */
 
index 064c6ac02f8d27b5bed0616d988c54eb64d5a82a..0c45f3c238d3107f00c639968f3d6da9a82a68d4 100644 (file)
@@ -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 */
+}