]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Add "fsp" to SMB_VFS_SET_QUOTA
authorVolker Lendecke <vl@samba.org>
Wed, 11 Feb 2026 11:29:54 +0000 (12:29 +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>
12 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_default.c
source3/modules/vfs_default_quota.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_time_audit.c
source3/smbd/ntquotas.c
source3/smbd/vfs.c

index ea54fd79bd14812cbc9439ff32a758f3865dfb65..9571eb9244d7fad2e66f74b54856578b952fafa9 100644 (file)
@@ -67,8 +67,11 @@ static int skel_get_quota(vfs_handle_struct *handle,
        return -1;
 }
 
-static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
-                         unid_t id, SMB_DISK_QUOTA *dq)
+static int skel_set_quota(vfs_handle_struct *handle,
+                         struct files_struct *fsp,
+                         enum SMB_QUOTA_TYPE qtype,
+                         unid_t id,
+                         SMB_DISK_QUOTA *dq)
 {
        errno = ENOSYS;
        return -1;
index da3897d0e9eaace58d42ebf5959d76954104b580..aa186d7ef17cb3aa1cf747433d1e8c3bee3bc106 100644 (file)
@@ -66,10 +66,13 @@ static int skel_get_quota(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
 }
 
-static int skel_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype,
-                         unid_t id, SMB_DISK_QUOTA *dq)
+static int skel_set_quota(vfs_handle_struct *handle,
+                         struct files_struct *fsp,
+                         enum SMB_QUOTA_TYPE qtype,
+                         unid_t id,
+                         SMB_DISK_QUOTA *dq)
 {
-       return SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq);
+       return SMB_VFS_NEXT_SET_QUOTA(handle, fsp, qtype, id, dq);
 }
 
 static int skel_get_shadow_copy_data(vfs_handle_struct *handle,
index c17e41fa0ee53a014e22bfe3845de3df98c40fa7..92142cf81842c09136c9eaee47880db6d9a9037f 100644 (file)
  * Version 53 - Add fstatvfs
  * Version 53 - Remove statvfs
  * Version 53 - Change GET_QUOTA to take a fsp instead of a name
+ * Version 53 - Add fsp to SET_QUOTA
  */
 
 #define SMB_VFS_INTERFACE_VERSION 53
@@ -997,7 +998,11 @@ struct vfs_fn_pointers {
                            enum SMB_QUOTA_TYPE qtype,
                            unid_t id,
                            SMB_DISK_QUOTA *qt);
-       int (*set_quota_fn)(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt);
+       int (*set_quota_fn)(struct vfs_handle_struct *handle,
+                           struct files_struct *fsp,
+                           enum SMB_QUOTA_TYPE qtype,
+                           unid_t id,
+                           SMB_DISK_QUOTA *qt);
        int (*get_shadow_copy_data_fn)(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels);
        int (*fstatvfs_fn)(struct vfs_handle_struct *handle,
                           struct files_struct *fsp,
@@ -1453,7 +1458,9 @@ int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
                           unid_t id,
                           SMB_DISK_QUOTA *qt);
 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
-                          enum SMB_QUOTA_TYPE qtype, unid_t id,
+                          struct files_struct *fsp,
+                          enum SMB_QUOTA_TYPE qtype,
+                          unid_t id,
                           SMB_DISK_QUOTA *qt);
 int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
                                      struct files_struct *fsp,
@@ -1886,8 +1893,10 @@ int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
                                  unid_t id,
                                  SMB_DISK_QUOTA *dq);
 int vfs_not_implemented_set_quota(vfs_handle_struct *handle,
+                                 struct files_struct *fsp,
                                  enum SMB_QUOTA_TYPE qtype,
-                                 unid_t id, SMB_DISK_QUOTA *dq);
+                                 unid_t id,
+                                 SMB_DISK_QUOTA *dq);
 int vfs_not_implemented_get_shadow_copy_data(vfs_handle_struct *handle,
                                files_struct *fsp,
                                struct shadow_copy_data *shadow_copy_data,
index 5d41b16033eff3ece496ee5f2bbda1b2fa8b457c..70c780f679fd2a542cc9805fe70ce41c81d826a5 100644 (file)
 #define SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt) \
        smb_vfs_call_get_quota((handle)->next, (fsp), (qtype), (id), (qt))
 
-#define SMB_VFS_SET_QUOTA(conn, qtype, id, qt) \
-       smb_vfs_call_set_quota((conn)->vfs_handles, (qtype), (id), (qt))
-#define SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt) \
-       smb_vfs_call_set_quota((handle)->next, (qtype), (id), (qt))
+#define SMB_VFS_SET_QUOTA(fsp, qtype, id, qt) \
+       smb_vfs_call_set_quota(               \
+               (fsp)->conn->vfs_handles, (fsp), (qtype), (id), (qt))
+#define SMB_VFS_NEXT_SET_QUOTA(handle, fsp, qtype, id, qt) \
+       smb_vfs_call_set_quota((handle)->next, (fsp), (qtype), (id), (qt))
 
 #define SMB_VFS_GET_SHADOW_COPY_DATA(fsp,shadow_copy_data,labels) \
        smb_vfs_call_get_shadow_copy_data((fsp)->conn->vfs_handles, (fsp), (shadow_copy_data), (labels))
index da41eefaa5d56e419c72ba1db91cf0bf706d9669..d17462d6f6764c1b8c497e0c7cf4f016deccc065 100644 (file)
@@ -139,13 +139,18 @@ static int vfswrap_get_quota(struct vfs_handle_struct *handle,
 #endif
 }
 
-static int vfswrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+static int vfswrap_set_quota(struct vfs_handle_struct *handle,
+                            struct files_struct *fsp,
+                            enum SMB_QUOTA_TYPE qtype,
+                            unid_t id,
+                            SMB_DISK_QUOTA *qt)
 {
 #ifdef HAVE_SYS_QUOTAS
+       struct smb_filename *smb_fname = fsp->fsp_name;
        int result;
 
        START_PROFILE_X(SNUM(handle->conn), syscall_set_quota);
-       result = sys_set_quota(handle->conn->connectpath, qtype, id, qt);
+       result = sys_set_quota(smb_fname->base_name, qtype, id, qt);
        END_PROFILE_X(syscall_set_quota);
        return result;
 #else
index 612a65f28b46e54fa5a9e535733e489416b31682..3f66264c38e3d3c0daaa386c732a45cde6f99946 100644 (file)
@@ -158,7 +158,11 @@ static int default_quota_get_quota(vfs_handle_struct *handle,
        return ret;
 }
 
-static int default_quota_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dq)
+static int default_quota_set_quota(vfs_handle_struct *handle,
+                                  struct files_struct *fsp,
+                                  enum SMB_QUOTA_TYPE qtype,
+                                  unid_t id,
+                                  SMB_DISK_QUOTA *dq)
 {
        int ret = -1;
 
@@ -191,7 +195,8 @@ static int default_quota_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
                        break;
        }
 
-       if ((ret=SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, dq))!=0) {
+       ret = SMB_VFS_NEXT_SET_QUOTA(handle, fsp, qtype, id, dq);
+       if (ret != 0) {
                return ret;
        }
 
@@ -206,7 +211,12 @@ static int default_quota_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
                        {
                                unid_t qid;
                                qid.uid = DEFAULT_QUOTA_UID(handle);
-                               ret = SMB_VFS_NEXT_SET_QUOTA(handle, SMB_USER_QUOTA_TYPE, qid, dq);
+                               ret = SMB_VFS_NEXT_SET_QUOTA(
+                                       handle,
+                                       fsp,
+                                       SMB_USER_QUOTA_TYPE,
+                                       qid,
+                                       dq);
                        }
                        break;
 #ifdef HAVE_GROUP_QUOTA
@@ -214,7 +224,12 @@ static int default_quota_set_quota(vfs_handle_struct *handle, enum SMB_QUOTA_TYP
                        {
                                unid_t qid;
                                qid.gid = DEFAULT_QUOTA_GID(handle);
-                               ret = SMB_VFS_NEXT_SET_QUOTA(handle, SMB_GROUP_QUOTA_TYPE, qid, dq);
+                               ret = SMB_VFS_NEXT_SET_QUOTA(
+                                       handle,
+                                       fsp,
+                                       SMB_GROUP_QUOTA_TYPE,
+                                       qid,
+                                       dq);
                        }
                        break;
 #endif /* HAVE_GROUP_QUOTA */
index 1c46d32dec5f0c48a6a7df689d37bb964ff6775f..f2aea7e6a7444063802f488331b72e8aba7e93ce 100644 (file)
@@ -853,12 +853,14 @@ static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_set_quota(struct vfs_handle_struct *handle,
-                          enum SMB_QUOTA_TYPE qtype, unid_t id,
-                          SMB_DISK_QUOTA *qt)
+                                   struct files_struct *fsp,
+                                   enum SMB_QUOTA_TYPE qtype,
+                                   unid_t id,
+                                   SMB_DISK_QUOTA *qt)
 {
        int result;
 
-       result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
+       result = SMB_VFS_NEXT_SET_QUOTA(handle, fsp, qtype, id, qt);
 
        do_log(SMB_VFS_OP_SET_QUOTA, errmsg_unix(result), handle, "");
 
index 1adf62e9ff1be4f1a362fb2d9d742c24b3b9b5d9..212cd081e8c4d225a6894173afbd6b439079419a 100644 (file)
@@ -555,9 +555,11 @@ static int vfs_gluster_get_quota(struct vfs_handle_struct *handle,
        return -1;
 }
 
-static int
-vfs_gluster_set_quota(struct vfs_handle_struct *handle,
-                     enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
+static int vfs_gluster_set_quota(struct vfs_handle_struct *handle,
+                                struct files_struct *fsp,
+                                enum SMB_QUOTA_TYPE qtype,
+                                unid_t id,
+                                SMB_DISK_QUOTA *qt)
 {
        errno = ENOSYS;
        return -1;
index 33d610d3d49f1f5a0d6664243ee4c1cabe2853fb..839844cd352f375693752b37bd4a6b01ff31b49f 100644 (file)
@@ -66,8 +66,10 @@ int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
 
 _PUBLIC_
 int vfs_not_implemented_set_quota(vfs_handle_struct *handle,
+                                 struct files_struct *fsp,
                                  enum SMB_QUOTA_TYPE qtype,
-                                 unid_t id, SMB_DISK_QUOTA *dq)
+                                 unid_t id,
+                                 SMB_DISK_QUOTA *dq)
 {
        errno = ENOSYS;
        return -1;
index 73594c4bebfeccc0b6fa55d60e6f7da1d935ea84..2b1ae2587e620ac92ef152819069b81f89d53344 100644 (file)
@@ -222,7 +222,9 @@ static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
-                                   enum SMB_QUOTA_TYPE qtype, unid_t id,
+                                   struct files_struct *fsp,
+                                   enum SMB_QUOTA_TYPE qtype,
+                                   unid_t id,
                                    SMB_DISK_QUOTA *qt)
 {
        int result;
@@ -230,7 +232,7 @@ static int smb_time_audit_set_quota(struct vfs_handle_struct *handle,
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_SET_QUOTA(handle, qtype, id, qt);
+       result = SMB_VFS_NEXT_SET_QUOTA(handle, fsp, qtype, id, qt);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
index 0b8675d0ec5a8dddade63ed6b8a803784bc661c6..786c48cbc2bdd49be98ce0319bdf7bb144e32d04 100644 (file)
@@ -144,7 +144,7 @@ int vfs_set_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype, struct dom_sid
                         dom_sid_str_buf(psid, &buf)));
        }
 
-       ret = SMB_VFS_SET_QUOTA(fsp->conn, qtype, id, &D);
+       ret = SMB_VFS_SET_QUOTA(fsp, qtype, id, &D);
 
        return ret;
 }
index f6a36eab2d876b0f7ce5cce531fa29f4df56f684..06601fb90f8465ff7521917beaa93383ef481d2b 100644 (file)
@@ -1462,11 +1462,13 @@ int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
-                          enum SMB_QUOTA_TYPE qtype, unid_t id,
+                          struct files_struct *fsp,
+                          enum SMB_QUOTA_TYPE qtype,
+                          unid_t id,
                           SMB_DISK_QUOTA *qt)
 {
        VFS_FIND(set_quota);
-       return handle->fns->set_quota_fn(handle, qtype, id, qt);
+       return handle->fns->set_quota_fn(handle, fsp, qtype, id, qt);
 }
 
 int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,