]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Call FSTATVFS instead of STATVFS
authorVolker Lendecke <vl@samba.org>
Tue, 27 Jan 2026 17:46:30 +0000 (18:46 +0100)
committerAnoop C S <anoopcs@samba.org>
Sun, 15 Feb 2026 10:42:34 +0000 (10:42 +0000)
To get the fs capabilities we do an openat_pathref_fsp_dot(), which
also avoids a call to SMB_VFS_STAT there.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
source3/smbd/smb2_trans2.c
source3/smbd/vfs.c

index b29fcbcca79ef03703bd41283b7d3bc49cd69673..ed8d2595d964dca6a3e61504224e1a889c75bbec 100644 (file)
@@ -2495,7 +2495,7 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
-                       rc = SMB_VFS_STATVFS(conn, &smb_fname, &svfs);
+                       rc = SMB_VFS_FSTATVFS(conn, fsp, &svfs);
 
 #ifdef EOPNOTSUPP
                        if (rc == EOPNOTSUPP) {
index 4778edfef59b0f999cea026aec7683bbf7f392b8..473e0ccddd54aacdb3ec81c65d8d077bce39b6f2 100644 (file)
@@ -1317,14 +1317,30 @@ uint32_t vfs_get_fs_capabilities(struct connection_struct *conn,
        uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
        struct smb_filename *smb_fname_cpath = NULL;
        struct vfs_statvfs_struct statbuf = {};
-       int ret;
+       NTSTATUS status;
+       int dirfd, ret;
 
-       smb_fname_cpath = cp_smb_basename(talloc_tos(), conn->connectpath);
-       if (smb_fname_cpath == NULL) {
+       dirfd = fsp_get_pathref_fd(conn->cwd_fsp);
+
+       if (dirfd == -1) {
+               /*
+                * This happens in create_conn_struct_as_root()
+                */
+               status = openat_pathref_fsp_rootdir(talloc_tos(),
+                                                   conn,
+                                                   &smb_fname_cpath);
+       } else {
+               status = openat_pathref_fsp_dot(talloc_tos(),
+                                               conn->cwd_fsp,
+                                               0,
+                                               &smb_fname_cpath);
+       }
+
+       if (!NT_STATUS_IS_OK(status)) {
                return caps;
        }
 
-       ret = SMB_VFS_STATVFS(conn, smb_fname_cpath, &statbuf);
+       ret = SMB_VFS_FSTATVFS(conn, smb_fname_cpath->fsp, &statbuf);
        if (ret == 0) {
                caps = statbuf.FsCapabilities;
        }
@@ -1340,12 +1356,6 @@ uint32_t vfs_get_fs_capabilities(struct connection_struct *conn,
        /* Work out what timestamp resolution we can
         * use when setting a timestamp. */
 
-       ret = SMB_VFS_STAT(conn, smb_fname_cpath);
-       if (ret == -1) {
-               TALLOC_FREE(smb_fname_cpath);
-               return caps;
-       }
-
        if (smb_fname_cpath->st.st_ex_mtime.tv_nsec ||
                        smb_fname_cpath->st.st_ex_atime.tv_nsec ||
                        smb_fname_cpath->st.st_ex_ctime.tv_nsec) {