]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Change SMB_VFS_GET_QUOTA to take a fsp instead of a name
authorVolker Lendecke <vl@samba.org>
Wed, 28 Jan 2026 14:57:37 +0000 (15:57 +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>
19 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_cap.c
source3/modules/vfs_ceph_snapshots.c
source3/modules/vfs_default.c
source3/modules/vfs_default_quota.c
source3/modules/vfs_fake_dfq.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_time_audit.c
source3/smbd/ntquotas.c
source3/smbd/quotas.c
source3/smbd/vfs.c

index 891f28427d68b3a7bd16749b62ae57f6ab07d6e5..ea54fd79bd14812cbc9439ff32a758f3865dfb65 100644 (file)
@@ -58,10 +58,10 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle,
 }
 
 static int skel_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq)
+                         struct files_struct *fsp,
+                         enum SMB_QUOTA_TYPE qtype,
+                         unid_t id,
+                         SMB_DISK_QUOTA *dq)
 {
        errno = ENOSYS;
        return -1;
index 091c738886045cc052756a86bd63af2741dcc948..da3897d0e9eaace58d42ebf5959d76954104b580 100644 (file)
@@ -58,12 +58,12 @@ static uint64_t skel_disk_free(vfs_handle_struct *handle,
 }
 
 static int skel_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq)
+                         struct files_struct *fsp,
+                         enum SMB_QUOTA_TYPE qtype,
+                         unid_t id,
+                         SMB_DISK_QUOTA *dq)
 {
-       return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
+       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,
index 9d8e1af6575dbfeb6849c51bcb3ceaa619300b31..c17e41fa0ee53a014e22bfe3845de3df98c40fa7 100644 (file)
  * Version 53 - Change DISK_FREE to take a fsp instead of a name
  * Version 53 - Add fstatvfs
  * Version 53 - Remove statvfs
+ * Version 53 - Change GET_QUOTA to take a fsp instead of a name
  */
 
 #define SMB_VFS_INTERFACE_VERSION 53
@@ -992,10 +993,10 @@ struct vfs_fn_pointers {
                                 uint64_t *dfree,
                                 uint64_t *dsize);
        int (*get_quota_fn)(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               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 (*set_quota_fn)(struct vfs_handle_struct *handle, 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,
@@ -1447,10 +1448,10 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
                                uint64_t *dfree,
                                uint64_t *dsize);
 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_filename,
-                               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 smb_vfs_call_set_quota(struct vfs_handle_struct *handle,
                           enum SMB_QUOTA_TYPE qtype, unid_t id,
                           SMB_DISK_QUOTA *qt);
@@ -1880,10 +1881,10 @@ uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
                                       uint64_t *dfree,
                                       uint64_t *dsize);
 int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq);
+                                 struct files_struct *fsp,
+                                 enum SMB_QUOTA_TYPE qtype,
+                                 unid_t id,
+                                 SMB_DISK_QUOTA *dq);
 int vfs_not_implemented_set_quota(vfs_handle_struct *handle,
                                  enum SMB_QUOTA_TYPE qtype,
                                  unid_t id, SMB_DISK_QUOTA *dq);
index f6c14338ad532ffc3abeeba0d96b91f1137f0d78..5d41b16033eff3ece496ee5f2bbda1b2fa8b457c 100644 (file)
        smb_vfs_call_disk_free(                                  \
                (handle)->next, (fsp), (bsize), (dfree), (dsize))
 
-#define SMB_VFS_GET_QUOTA(conn, smb_fname, qtype, id, qt)                           \
-       smb_vfs_call_get_quota((conn)->vfs_handles, (smb_fname), (qtype), (id), (qt))
-#define SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt)                    \
-       smb_vfs_call_get_quota((handle)->next, (smb_fname), (qtype), (id), (qt))
+#define SMB_VFS_GET_QUOTA(fsp, qtype, id, qt) \
+       smb_vfs_call_get_quota(               \
+               (fsp)->conn->vfs_handles, (fsp), (qtype), (id), (qt))
+#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))
index 9957998d2d9cb1eab9c521cb0c77396c39d73c57..b6e9b748bd8f6a5543946ec5d3eab74ae1b03124 100644 (file)
@@ -66,30 +66,42 @@ static uint64_t cap_disk_free(vfs_handle_struct *handle,
 }
 
 static int cap_get_quota(vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname,
-                       enum SMB_QUOTA_TYPE qtype,
-                       unid_t id,
-                       SMB_DISK_QUOTA *dq)
+                        struct files_struct *fsp,
+                        enum SMB_QUOTA_TYPE qtype,
+                        unid_t id,
+                        SMB_DISK_QUOTA *dq)
 {
+       struct smb_filename *smb_fname = fsp->fsp_name;
        char *cappath = capencode(talloc_tos(), smb_fname->base_name);
        struct smb_filename *cap_smb_fname = NULL;
+       NTSTATUS status;
+       int ret;
 
        if (!cappath) {
                errno = ENOMEM;
                return -1;
        }
-       cap_smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       cappath,
-                                       NULL,
-                                       NULL,
-                                       smb_fname->twrp,
-                                       smb_fname->flags);
-       if (cap_smb_fname == NULL) {
-               TALLOC_FREE(cappath);
-               errno = ENOMEM;
+       status = synthetic_pathref(talloc_tos(),
+                                  fsp->conn->cwd_fsp,
+                                  cappath,
+                                  NULL,
+                                  NULL,
+                                  smb_fname->twrp,
+                                  smb_fname->flags,
+                                  &cap_smb_fname);
+       TALLOC_FREE(cappath);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
                return -1;
        }
-       return SMB_VFS_NEXT_GET_QUOTA(handle, cap_smb_fname, qtype, id, dq);
+       ret = SMB_VFS_NEXT_GET_QUOTA(
+               handle, cap_smb_fname->fsp, qtype, id, dq);
+       {
+               int err = errno;
+               TALLOC_FREE(cap_smb_fname);
+               errno = err;
+       }
+       return ret;
 }
 
 static struct dirent *
index 7fa03ceb5fc6704af70bfbf771d9788ca428a903..cf2dfdc2d5d629944e2bc1670f17e536a1cc48a8 100644 (file)
@@ -1402,16 +1402,18 @@ static uint64_t ceph_snap_gmt_disk_free(vfs_handle_struct *handle,
 }
 
 static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle,
-                       const struct smb_filename *csmb_fname,
-                       enum SMB_QUOTA_TYPE qtype,
-                       unid_t id,
-                       SMB_DISK_QUOTA *dq)
+                                  struct files_struct *fsp,
+                                  enum SMB_QUOTA_TYPE qtype,
+                                  unid_t id,
+                                  SMB_DISK_QUOTA *dq)
 {
+       struct smb_filename *csmb_fname = fsp->fsp_name;
        time_t timestamp = 0;
        char stripped[PATH_MAX + 1];
        char conv[PATH_MAX + 1];
        int ret;
        struct smb_filename *new_fname;
+       NTSTATUS status;
        int saved_errno;
 
        ret = ceph_snap_gmt_strip_snapshot(handle,
@@ -1422,7 +1424,7 @@ static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle,
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GET_QUOTA(handle, csmb_fname, qtype, id, dq);
+               return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
        }
        ret = ceph_snap_gmt_convert(handle, stripped,
                                        timestamp, conv, sizeof(conv));
@@ -1430,14 +1432,21 @@ static int ceph_snap_gmt_get_quota(vfs_handle_struct *handle,
                errno = -ret;
                return -1;
        }
-       new_fname = cp_smb_filename(talloc_tos(), csmb_fname);
-       if (new_fname == NULL) {
-               errno = ENOMEM;
+
+       status = synthetic_pathref(talloc_tos(),
+                                  fsp->conn->cwd_fsp,
+                                  conv,
+                                  csmb_fname->stream_name,
+                                  NULL,
+                                  csmb_fname->twrp,
+                                  csmb_fname->flags,
+                                  &new_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
                return -1;
        }
-       new_fname->base_name = conv;
 
-       ret = SMB_VFS_NEXT_GET_QUOTA(handle, new_fname, qtype, id, dq);
+       ret = SMB_VFS_NEXT_GET_QUOTA(handle, new_fname->fsp, qtype, id, dq);
        saved_errno = errno;
        TALLOC_FREE(new_fname);
        errno = saved_errno;
index 5fcddbdc47448dbc7b17ac8d963f917e0747884c..da41eefaa5d56e419c72ba1db91cf0bf706d9669 100644 (file)
@@ -120,12 +120,13 @@ static uint64_t vfswrap_disk_free(vfs_handle_struct *handle,
 }
 
 static int vfswrap_get_quota(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               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)
 {
 #ifdef HAVE_SYS_QUOTAS
+       struct smb_filename *smb_fname = fsp->fsp_name;
        int result;
 
        START_PROFILE_X(SNUM(handle->conn), syscall_get_quota);
index 2365f9d196ba1ebb7aff2118578898170150e32e..612a65f28b46e54fa5a9e535733e489416b31682 100644 (file)
        lp_parm_bool(SNUM((handle)->conn),DEFAULT_QUOTA_NAME,"gid nolimit",DEFAULT_QUOTA_GID_NOLIMIT_DEFAULT)
 
 static int default_quota_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq)
+                                  struct files_struct *fsp,
+                                  enum SMB_QUOTA_TYPE qtype,
+                                  unid_t id,
+                                  SMB_DISK_QUOTA *dq)
 {
        int ret = -1;
 
-       if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
-                               qtype, id, dq)) != 0) {
+       if ((ret = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq)) != 0) {
                return ret;
        }
 
@@ -127,8 +126,11 @@ static int default_quota_get_quota(vfs_handle_struct *handle,
                                unid_t qid;
                                uint32_t qflags = dq->qflags;
                                qid.uid = DEFAULT_QUOTA_UID(handle);
-                               SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
-                                       SMB_USER_QUOTA_TYPE, qid, dq);
+                               SMB_VFS_NEXT_GET_QUOTA(handle,
+                                                      fsp,
+                                                      SMB_USER_QUOTA_TYPE,
+                                                      qid,
+                                                      dq);
                                dq->qflags = qflags;
                        }
                        break;
@@ -138,9 +140,11 @@ static int default_quota_get_quota(vfs_handle_struct *handle,
                                unid_t qid;
                                uint32_t qflags = dq->qflags;
                                qid.gid = DEFAULT_QUOTA_GID(handle);
-                               SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
+                               SMB_VFS_NEXT_GET_QUOTA(handle,
+                                                      fsp,
                                                       SMB_GROUP_QUOTA_TYPE,
-                                                      qid, dq);
+                                                      qid,
+                                                      dq);
                                dq->qflags = qflags;
                        }
                        break;
index 92b0e6e3be76ddc98caf4bb4f9fe0006d2883349..84aace8b92f442f0762b56609d405171c9f5a431 100644 (file)
 #define DBGC_CLASS DBGC_VFS
 
 static int dfq_get_quota(struct vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname,
-                       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);
 
 static uint64_t dfq_load_param(int snum, const char *path, const char *section,
                               const char *param, uint64_t def_val)
@@ -95,11 +95,12 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle,
 }
 
 static int dfq_get_quota(struct vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname,
-                       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)
 {
+       struct smb_filename *smb_fname = fsp->fsp_name;
        int rc = 0;
        int save_errno;
        char *section = NULL;
@@ -178,7 +179,7 @@ static int dfq_get_quota(struct vfs_handle_struct *handle,
        goto out;
 
 dflt:
-       rc = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
+       rc = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt);
 
 out:
        save_errno = errno;
index 1cb66b03dc0226fb814463c23cb0fb80665192b4..1c46d32dec5f0c48a6a7df689d37bb964ff6775f 100644 (file)
@@ -834,20 +834,20 @@ static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_get_quota(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               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_GET_QUOTA(handle, smb_fname, qtype, id, qt);
+       result = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt);
 
        do_log(SMB_VFS_OP_GET_QUOTA,
               errmsg_unix(result),
               handle,
               "%s",
-              smb_fname_str_do_log(handle->conn, smb_fname));
+              smb_fname_str_do_log(handle->conn, fsp->fsp_name));
 
        return result;
 }
index 765baf6dd49196a53a82ab289eba24904842d991..1adf62e9ff1be4f1a362fb2d9d742c24b3b9b5d9 100644 (file)
@@ -546,10 +546,10 @@ static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_get_quota(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               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)
 {
        errno = ENOSYS;
        return -1;
index 9b92eb97446de8725dd7eeede61498eb76b4cf38..75c87ef159bdb04f64ea7adc0ce39c2b70a01e0c 100644 (file)
@@ -2391,10 +2391,10 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
 }
 
 static int vfs_gpfs_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq)
+                             struct files_struct *fsp,
+                             enum SMB_QUOTA_TYPE qtype,
+                             unid_t id,
+                             SMB_DISK_QUOTA *dq)
 {
        switch(qtype) {
                /*
@@ -2412,8 +2412,8 @@ static int vfs_gpfs_get_quota(vfs_handle_struct *handle,
                        errno = ENOSYS;
                        return -1;
                default:
-                       return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname,
-                                       qtype, id, dq);
+                       return SMB_VFS_NEXT_GET_QUOTA(
+                               handle, fsp, qtype, id, dq);
        }
 }
 
index a60b262941cb922524c35921117ecc695d36ac35..33d610d3d49f1f5a0d6664243ee4c1cabe2853fb 100644 (file)
@@ -55,10 +55,10 @@ uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
 
 _PUBLIC_
 int vfs_not_implemented_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq)
+                                 struct files_struct *fsp,
+                                 enum SMB_QUOTA_TYPE qtype,
+                                 unid_t id,
+                                 SMB_DISK_QUOTA *dq)
 {
        errno = ENOSYS;
        return -1;
index 5a386f98191e94d258e7001c9f8aabcdc6a96e15..2c1d3072d49024d5b8b8804cc44bcb08e5cb4b26 100644 (file)
@@ -2678,17 +2678,19 @@ static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
 }
 
 static int shadow_copy2_get_quota(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               enum SMB_QUOTA_TYPE qtype,
-                               unid_t id,
-                               SMB_DISK_QUOTA *dq)
+                                 struct files_struct *fsp,
+                                 enum SMB_QUOTA_TYPE qtype,
+                                 unid_t id,
+                                 SMB_DISK_QUOTA *dq)
 {
+       struct smb_filename *smb_fname = fsp->fsp_name;
        time_t timestamp = 0;
        char *stripped = NULL;
        int ret;
        int saved_errno = 0;
        char *conv;
        struct smb_filename *conv_smb_fname = NULL;
+       NTSTATUS status;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(),
                                handle,
@@ -2698,25 +2700,31 @@ static int shadow_copy2_get_quota(vfs_handle_struct *handle,
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
+               return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
        }
 
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
+               errno = ENOMEM;
                return -1;
        }
-       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       conv,
-                                       NULL,
-                                       NULL,
-                                       0,
-                                       smb_fname->flags);
-       if (conv_smb_fname == NULL) {
+
+       status = synthetic_pathref(talloc_tos(),
+                                  fsp->conn->cwd_fsp,
+                                  conv,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  smb_fname->flags,
+                                  &conv_smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(conv);
+               errno = map_errno_from_nt_status(status);
                return -1;
        }
-       ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
+       ret = SMB_VFS_NEXT_GET_QUOTA(
+               handle, conv_smb_fname->fsp, qtype, id, dq);
 
        if (ret == -1) {
                saved_errno = errno;
index f66659f57955acf751e79dbbb8922c5999e60d4f..3c4f19abcd7a06743c09ae17b279a496fc32850d 100644 (file)
@@ -2529,24 +2529,26 @@ static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
 }
 
 static int snapper_gmt_get_quota(vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname,
-                       enum SMB_QUOTA_TYPE qtype,
-                       unid_t id,
-                       SMB_DISK_QUOTA *dq)
+                                struct files_struct *fsp,
+                                enum SMB_QUOTA_TYPE qtype,
+                                unid_t id,
+                                SMB_DISK_QUOTA *dq)
 {
+       struct smb_filename *smb_fname = fsp->fsp_name;
        time_t timestamp = 0;
        char *stripped = NULL;
        int ret;
        int saved_errno = 0;
        char *conv = NULL;
        struct smb_filename *conv_smb_fname = NULL;
+       NTSTATUS status;
 
        if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
                                smb_fname, &timestamp, &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
+               return SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, dq);
        }
 
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
@@ -2554,19 +2556,23 @@ static int snapper_gmt_get_quota(vfs_handle_struct *handle,
        if (conv == NULL) {
                return -1;
        }
-       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       conv,
-                                       NULL,
-                                       NULL,
-                                       0,
-                                       smb_fname->flags);
+
+       status = synthetic_pathref(talloc_tos(),
+                                  fsp->conn->cwd_fsp,
+                                  conv,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  smb_fname->flags,
+                                  &conv_smb_fname);
        TALLOC_FREE(conv);
-       if (conv_smb_fname == NULL) {
-               errno = ENOMEM;
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
                return -1;
        }
 
-       ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
+       ret = SMB_VFS_NEXT_GET_QUOTA(
+               handle, conv_smb_fname->fsp, qtype, id, dq);
 
        if (ret == -1) {
                saved_errno = errno;
index ae01a02e108a03e952149bab28902eea30b04a85..73594c4bebfeccc0b6fa55d60e6f7da1d935ea84 100644 (file)
@@ -199,24 +199,24 @@ static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_get_quota(struct vfs_handle_struct *handle,
-                                       const struct smb_filename *smb_fname,
-                                       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;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, qt);
+       result = SMB_VFS_NEXT_GET_QUOTA(handle, fsp, qtype, id, qt);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
                smb_time_audit_log_fname("get_quota",
-                               timediff,
-                               smb_fname->base_name);
+                                        timediff,
+                                        fsp->fsp_name->base_name);
        }
        return result;
 }
index affd7d58f818938a5c44a8a8a8aaa3d8849a7e23..0b8675d0ec5a8dddade63ed6b8a803784bc661c6 100644 (file)
@@ -66,6 +66,7 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype,
        unid_t id;
        struct smb_filename *smb_fname_cwd = NULL;
        int saved_errno = 0;
+       NTSTATUS status;
 
        ZERO_STRUCT(D);
 
@@ -84,12 +85,18 @@ NTSTATUS vfs_get_ntquota(files_struct *fsp, enum SMB_QUOTA_TYPE qtype,
                return NT_STATUS_NO_SUCH_USER;
        }
 
-       smb_fname_cwd = cp_smb_basename(talloc_tos(), ".");
-       if (smb_fname_cwd == NULL) {
-               return NT_STATUS_NO_MEMORY;
+       /*
+        * SMB_VFS_GET_QUOTA needs a "real" fsp, not a fake file one.
+        */
+       status = openat_pathref_fsp_dot(talloc_tos(),
+                                       fsp->conn->cwd_fsp,
+                                       0,
+                                       &smb_fname_cwd);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
-       ret = SMB_VFS_GET_QUOTA(fsp->conn, smb_fname_cwd, qtype, id, &D);
+       ret = SMB_VFS_GET_QUOTA(smb_fname_cwd->fsp, qtype, id, &D);
        if (ret == -1) {
                saved_errno = errno;
        }
index e73e2982c1c3591e4468a973aa7b6912192d69e1..e9f11cfb9b7998d234109d5d8de2d5314c41ae46 100644 (file)
@@ -383,8 +383,7 @@ bool disk_quotas(connection_struct *conn,
         */
        ZERO_STRUCT(D);
        id.uid = -1;
-       r = SMB_VFS_GET_QUOTA(conn, fname, SMB_USER_FS_QUOTA_TYPE,
-                             id, &D);
+       r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_FS_QUOTA_TYPE, id, &D);
        if (r == -1 && errno != ENOSYS) {
                goto try_group_quota;
        }
@@ -405,14 +404,12 @@ bool disk_quotas(connection_struct *conn,
 
                id.uid = fname->st.st_ex_uid;
                become_root();
-               r = SMB_VFS_GET_QUOTA(conn, fname,
-                                     SMB_USER_QUOTA_TYPE, id, &D);
+               r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_QUOTA_TYPE, id, &D);
                save_errno = errno;
                unbecome_root();
                errno = save_errno;
        } else {
-               r = SMB_VFS_GET_QUOTA(conn, fname,
-                                     SMB_USER_QUOTA_TYPE, id, &D);
+               r = SMB_VFS_GET_QUOTA(fsp, SMB_USER_QUOTA_TYPE, id, &D);
        }
 
        if (r == -1) {
@@ -449,8 +446,7 @@ try_group_quota:
         */
        ZERO_STRUCT(D);
        id.gid = -1;
-       r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_FS_QUOTA_TYPE,
-                             id, &D);
+       r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_FS_QUOTA_TYPE, id, &D);
        if (r == -1 && errno != ENOSYS) {
                return false;
        }
@@ -470,13 +466,11 @@ try_group_quota:
            fname->st.st_ex_mode & S_ISGID) {
                id.gid = fname->st.st_ex_gid;
                become_root();
-               r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id,
-                                     &D);
+               r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_QUOTA_TYPE, id, &D);
                unbecome_root();
        } else {
                id.gid = getegid();
-               r = SMB_VFS_GET_QUOTA(conn, fname, SMB_GROUP_QUOTA_TYPE, id,
-                                     &D);
+               r = SMB_VFS_GET_QUOTA(fsp, SMB_GROUP_QUOTA_TYPE, id, &D);
        }
 
        if (r == -1) {
index 07997472c9803eaa69d3d409fdd8b50aa1207068..f6a36eab2d876b0f7ce5cce531fa29f4df56f684 100644 (file)
@@ -1452,13 +1452,13 @@ uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
 }
 
 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               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)
 {
        VFS_FIND(get_quota);
-       return handle->fns->get_quota_fn(handle, smb_fname, qtype, id, qt);
+       return handle->fns->get_quota_fn(handle, fsp, qtype, id, qt);
 }
 
 int smb_vfs_call_set_quota(struct vfs_handle_struct *handle,