]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: consolidate fs capabilities code in vfswrap_fs_capabilities()
authorRalph Boehme <slow@samba.org>
Thu, 6 Jun 2024 13:38:16 +0000 (15:38 +0200)
committerJule Anger <janger@samba.org>
Thu, 20 Mar 2025 09:59:09 +0000 (09:59 +0000)
This ensures the values we return via SMB_FS_ATTRIBUTE_INFORMATION is the same
we use internally via conn->fs_capabilities.

This deliberately preserves existing behaviour as much as possible and leaves
possible improvements as a future excercize. Particularily FILE_VOLUME_QUOTAS is
already set insided SMB_VFS_STATVFS() depending on backend filesystem flags
which is probably the correct way to do it instead of just setting the
capability when Samba was built with quota support.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15822

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
(cherry picked from commit deeca8ff176e7e9082cc0fcf48d7f981de2523c5)

source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_glusterfs.c
source3/smbd/smb2_trans2.c

index fd450af16c26c3cb56d7e5efa4efc7625ef0fa67..20e1c204f18ea9f1203786fda6f3b11b4a829c31 100644 (file)
@@ -377,8 +377,9 @@ static uint32_t cephwrap_fs_capabilities(
        struct vfs_handle_struct *handle,
        enum timestamp_set_resolution *p_ts_res)
 {
-       uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+       uint32_t caps;
 
+       caps = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
        *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
 
        return caps;
index e0ebc7bd1a278a3dcb3749faf9aa698cc31982df..752906ba29a95d5084027d4041b39f01ec39491c 100644 (file)
@@ -177,6 +177,16 @@ static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,
                caps = statbuf.FsCapabilities;
        }
 
+#if defined(HAVE_SYS_QUOTAS)
+       caps |= FILE_VOLUME_QUOTAS;
+#endif
+
+       if (lp_nt_acl_support(SNUM(conn))) {
+               caps |= FILE_PERSISTENT_ACLS;
+       }
+
+       caps |= lp_parm_int(SNUM(conn), "share", "fake_fscaps", 0);
+
        *p_ts_res = TIMESTAMP_SET_SECONDS;
 
        /* Work out what timestamp resolution we can
index 00b4cdd4698da6f06f4f751fbd1fd1a1c2016795..5729766a8d762519241633432a6562f1b22a405d 100644 (file)
@@ -594,7 +594,9 @@ static int vfs_gluster_statvfs(struct vfs_handle_struct *handle,
 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct *handle,
                                            enum timestamp_set_resolution *p_ts_res)
 {
-       uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
+       uint32_t caps;
+
+       caps = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
 
 #ifdef HAVE_GFAPI_VER_6
        caps |= FILE_SUPPORTS_SPARSE_FILES;
index b57cb295a7cf0bbd316331c45be94018868e7927..2a253d653619cf5b989f470022f1583c32b284f1 100644 (file)
@@ -2041,7 +2041,6 @@ NTSTATUS smbd_do_qfsinfo(struct smbXsrv_connection *xconn,
        const char *fstype = lp_fstype(SNUM(conn));
        const char *filename = NULL;
        const uint64_t bytes_per_sector = 512;
-       uint32_t additional_flags = 0;
        struct smb_filename smb_fname;
        SMB_STRUCT_STAT st;
        NTSTATUS status = NT_STATUS_OK;
@@ -2172,24 +2171,9 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
                case SMB_QUERY_FS_ATTRIBUTE_INFO:
                case SMB_FS_ATTRIBUTE_INFORMATION:
 
-                       additional_flags = 0;
-#if defined(HAVE_SYS_QUOTAS)
-                       additional_flags |= FILE_VOLUME_QUOTAS;
-#endif
-
-                       if(lp_nt_acl_support(SNUM(conn))) {
-                               additional_flags |= FILE_PERSISTENT_ACLS;
-                       }
-
-                       /* Capabilities are filled in at connection time through STATVFS call */
-                       additional_flags |= conn->fs_capabilities;
-                       additional_flags |= lp_parm_int(conn->params->service,
-                                                       "share", "fake_fscaps",
-                                                       0);
-
                        SIVAL(pdata,0,FILE_CASE_PRESERVED_NAMES|FILE_CASE_SENSITIVE_SEARCH|
                                FILE_SUPPORTS_OBJECT_IDS|FILE_UNICODE_ON_DISK|
-                               additional_flags); /* FS ATTRIBUTES */
+                               conn->fs_capabilities); /* FS ATTRIBUTES */
 
                        SIVAL(pdata,4,255); /* Max filename component length */
                        /* NOTE! the fstype must *not* be null terminated or win98 won't recognise it