]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs: Change SMB_VFS_DISK_FREE to take a fsp
authorVolker Lendecke <vl@samba.org>
Tue, 27 Jan 2026 17:15:53 +0000 (18:15 +0100)
committerAnoop C S <anoopcs@samba.org>
Sun, 15 Feb 2026 10:42:33 +0000 (10:42 +0000)
The modules that change the pathname need a synthetic_pathref now for
the SMB_VFS_NEXT_DISK_FREE() call. I think this is the right thing to
do anyway, as this goes through all the path scrutiny and does not
depend on direct multi-component paths anymore.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
21 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.c
source3/modules/vfs_ceph_new.c
source3/modules/vfs_ceph_snapshots.c
source3/modules/vfs_default.c
source3/modules/vfs_fake_dfq.c
source3/modules/vfs_fruit.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/dfree.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index 92574b30348d106e23eeda5acebffebb0d6c186a..31aff0c1273b454e1ee4b223825ef80c6c9406d1 100644 (file)
@@ -46,10 +46,10 @@ static void skel_disconnect(vfs_handle_struct *handle)
 }
 
 static uint64_t skel_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                              struct files_struct *fsp,
+                              uint64_t *bsize,
+                              uint64_t *dfree,
+                              uint64_t *dsize)
 {
        *bsize = 0;
        *dfree = 0;
index c28963fa5dd856b9927af6823310daead58ff9ec..50cbb5c90a5479e4937e21c21d60f56260335d80 100644 (file)
@@ -49,12 +49,12 @@ static void skel_disconnect(vfs_handle_struct *handle)
 }
 
 static uint64_t skel_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                              struct files_struct *fsp,
+                              uint64_t *bsize,
+                              uint64_t *dfree,
+                              uint64_t *dsize)
 {
-       return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
+       return SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize);
 }
 
 static int skel_get_quota(vfs_handle_struct *handle,
index 3922b6383236f1818c81b5f7e8a4e443f2bf5fe5..09cab759bb58e6ebb14f41624f9cd5ac631843b9 100644 (file)
  * Version 52 - Remove connectpath
  * Version 52 - Remove audit_file
  * Version 52 - Add VFS_OPEN_HOW_RESOLVE_NO_XDEV for SMB_VFS_OPENAT()
+ * Change to Version 53 - will ship with 4.25
+ * Version 53 - Change DISK_FREE to take a fsp instead of a name
  */
 
-#define SMB_VFS_INTERFACE_VERSION 52
+#define SMB_VFS_INTERFACE_VERSION 53
 
 /*
     All intercepted VFS operations must be declared as static functions inside module source
@@ -983,10 +985,10 @@ struct vfs_fn_pointers {
        int (*connect_fn)(struct vfs_handle_struct *handle, const char *service, const char *user);
        void (*disconnect_fn)(struct vfs_handle_struct *handle);
        uint64_t (*disk_free_fn)(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize);
+                                struct files_struct *fsp,
+                                uint64_t *bsize,
+                                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,
@@ -1468,7 +1470,7 @@ int smb_vfs_call_connect(struct vfs_handle_struct *handle,
                         const char *service, const char *user);
 void smb_vfs_call_disconnect(struct vfs_handle_struct *handle);
 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_filename,
+                               struct files_struct *fsp,
                                uint64_t *bsize,
                                uint64_t *dfree,
                                uint64_t *dsize);
@@ -1901,10 +1903,10 @@ int vfs_not_implemented_connect(
                        const char *user);
 void vfs_not_implemented_disconnect(vfs_handle_struct *handle);
 uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize);
+                                      struct files_struct *fsp,
+                                      uint64_t *bsize,
+                                      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,
index 4c98862f03959253e513e266525a97b4edb67121..7f583586b129210fe48f0f10179052bc12c874cb 100644 (file)
 #define SMB_VFS_NEXT_DISCONNECT(handle) \
        smb_vfs_call_disconnect((handle)->next)
 
-#define SMB_VFS_DISK_FREE(conn, smb_fname, bsize, dfree ,dsize) \
-       smb_vfs_call_disk_free((conn)->vfs_handles, (smb_fname), (bsize), (dfree), (dsize))
-#define SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree ,dsize)\
-       smb_vfs_call_disk_free((handle)->next, (smb_fname), (bsize), (dfree), (dsize))
+#define SMB_VFS_DISK_FREE(conn, fsp, bsize, dfree, dsize) \
+       smb_vfs_call_disk_free(                           \
+               (conn)->vfs_handles, (fsp), (bsize), (dfree), (dsize))
+#define SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize) \
+       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))
index acb0ed04aa390b41753fcffa38c46243cae6c532..9957998d2d9cb1eab9c521cb0c77396c39d73c57 100644 (file)
@@ -30,31 +30,39 @@ static char *capencode(TALLOC_CTX *ctx, const char *from);
 static char *capdecode(TALLOC_CTX *ctx, const char *from);
 
 static uint64_t cap_disk_free(vfs_handle_struct *handle,
-                       const struct smb_filename *smb_fname,
-                       uint64_t *bsize,
-                       uint64_t *dfree,
-                       uint64_t *dsize)
+                             struct files_struct *fsp,
+                             uint64_t *bsize,
+                             uint64_t *dfree,
+                             uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        char *capname = capencode(talloc_tos(), smb_fname->base_name);
        struct smb_filename *cap_smb_fname = NULL;
+       NTSTATUS status;
+       uint64_t ret;
 
        if (!capname) {
                errno = ENOMEM;
                return (uint64_t)-1;
        }
-       cap_smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       capname,
-                                       NULL,
-                                       NULL,
-                                       smb_fname->twrp,
-                                       smb_fname->flags);
-       if (cap_smb_fname == NULL) {
+
+       status = synthetic_pathref(capname,
+                                  handle->conn->cwd_fsp,
+                                  capname,
+                                  NULL,
+                                  NULL,
+                                  smb_fname->twrp,
+                                  smb_fname->flags,
+                                  &cap_smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(capname);
-               errno = ENOMEM;
+               errno = map_errno_from_nt_status(status);
                return (uint64_t)-1;
        }
-       return SMB_VFS_NEXT_DISK_FREE(handle, cap_smb_fname,
-                       bsize, dfree, dsize);
+       ret = SMB_VFS_NEXT_DISK_FREE(
+               handle, cap_smb_fname->fsp, bsize, dfree, dsize);
+       TALLOC_FREE(cap_smb_fname);
+       return ret;
 }
 
 static int cap_get_quota(vfs_handle_struct *handle,
index 04d7433c1e010b4c599e4e03ad1c6f213a3703a7..1c84059b184fe5db5b6512ab435dacb0de28a9c9 100644 (file)
@@ -319,11 +319,12 @@ static void cephwrap_disconnect(struct vfs_handle_struct *handle)
 /* Disk operations */
 
 static uint64_t cephwrap_disk_free(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                  struct files_struct *fsp,
+                                  uint64_t *bsize,
+                                  uint64_t *dfree,
+                                  uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        struct statvfs statvfs_buf = { 0 };
        int ret;
 
index 4a91f55b61276376c15837cfa11534faf92eb7a8..4b92c3f7215835214b670561df675e3d84a57aa4 100644 (file)
@@ -2388,11 +2388,12 @@ out:
 /* Disk operations */
 
 static uint64_t vfs_ceph_disk_free(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                  struct files_struct *fsp,
+                                  uint64_t *bsize,
+                                  uint64_t *dfree,
+                                  uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        struct statvfs statvfs_buf = { 0 };
        int ret;
        struct vfs_ceph_config *config = NULL;
index 46d45c84dc657cb079c68f33b8a115c04c5d96ab..7fa03ceb5fc6704af70bfbf771d9788ca428a903 100644 (file)
@@ -1349,28 +1349,29 @@ static NTSTATUS ceph_snap_gmt_get_real_filename_at(
 }
 
 static uint64_t ceph_snap_gmt_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *csmb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                       struct files_struct *fsp,
+                                       uint64_t *bsize,
+                                       uint64_t *dfree,
+                                       uint64_t *dsize)
 {
+       const struct smb_filename *smb_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,
-                                       csmb_fname,
-                                       &timestamp, stripped, sizeof(stripped));
+       ret = ceph_snap_gmt_strip_snapshot(
+               handle, smb_fname, &timestamp, stripped, sizeof(stripped));
        if (ret < 0) {
                errno = -ret;
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_DISK_FREE(handle, csmb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
        ret = ceph_snap_gmt_convert(handle, stripped,
                                        timestamp, conv, sizeof(conv));
@@ -1378,15 +1379,22 @@ static uint64_t ceph_snap_gmt_disk_free(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(),
+                                  handle->conn->cwd_fsp,
+                                  conv,
+                                  smb_fname->stream_name,
+                                  &smb_fname->st,
+                                  smb_fname->twrp,
+                                  smb_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_DISK_FREE(handle, new_fname,
-                               bsize, dfree, dsize);
+       ret = SMB_VFS_NEXT_DISK_FREE(
+               handle, new_fname->fsp, bsize, dfree, dsize);
        saved_errno = errno;
        TALLOC_FREE(new_fname);
        errno = saved_errno;
index a4a5b54ecb778f46717859ac0fe3454eaa76fd16..0bfdaef49980a0d5350d3d9da2b3da0bd314b1d5 100644 (file)
@@ -98,11 +98,13 @@ static void vfswrap_disconnect(vfs_handle_struct *handle)
 /* Disk operations */
 
 static uint64_t vfswrap_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                 struct files_struct *fsp,
+                                 uint64_t *bsize,
+                                 uint64_t *dfree,
+                                 uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
+
        if (sys_fsusage(smb_fname->base_name, dfree, dsize) != 0) {
                return (uint64_t)-1;
        }
index 8bec9e0b954fcd632bca759290f8f19a2631faa0..92b0e6e3be76ddc98caf4bb4f9fe0006d2883349 100644 (file)
@@ -53,11 +53,12 @@ static uint64_t dfq_load_param(int snum, const char *path, const char *section,
 }
 
 static uint64_t dfq_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                             struct files_struct *fsp,
+                             uint64_t *bsize,
+                             uint64_t *dfree,
+                             uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        uint64_t free_1k;
        int snum = SNUM(handle->conn);
        uint64_t dfq_bsize = 0;
@@ -73,8 +74,8 @@ static uint64_t dfq_disk_free(vfs_handle_struct *handle,
        }
        if (dfq_bsize == 0) {
                TALLOC_FREE(rpath_fname);
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree,
-                                             dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
 
        *bsize = dfq_bsize;
index c8af698e483c3bad2b4e6601968cfb577471f6ca..9ffece1fb0c67510fb477fab5f991e8bbfaa5e40 100644 (file)
@@ -5403,11 +5403,12 @@ static bool fruit_tmsize_do_dirent(vfs_handle_struct *handle,
  * - calculate used size of all bands: band_count * band_size
  **/
 static uint64_t fruit_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
+                               struct files_struct *fsp,
                                uint64_t *_bsize,
                                uint64_t *_dfree,
                                uint64_t *_dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        struct fruit_config_data *config = NULL;
        struct fruit_disk_free_state state = {0};
        struct smb_Dir *dir_hnd = NULL;
@@ -5425,11 +5426,8 @@ static uint64_t fruit_disk_free(vfs_handle_struct *handle,
        if (!config->time_machine ||
            config->time_machine_max_size == 0)
        {
-               return SMB_VFS_NEXT_DISK_FREE(handle,
-                                             smb_fname,
-                                             _bsize,
-                                             _dfree,
-                                             _dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, _bsize, _dfree, _dsize);
        }
 
        status = OpenDir(talloc_tos(),
index 4935cdbce26baf08c3da068f0e3ffeb140a12b84..e0cdf2718f46ec8fdc83c4091d7da934da135be5 100644 (file)
@@ -811,14 +811,14 @@ static void smb_full_audit_disconnect(vfs_handle_struct *handle)
 }
 
 static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                        struct files_struct *fsp,
+                                        uint64_t *bsize,
+                                        uint64_t *dfree,
+                                        uint64_t *dsize)
 {
        uint64_t result;
 
-       result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
+       result = SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize);
 
        /* Don't have a reasonable notion of failure here */
 
@@ -826,7 +826,7 @@ static uint64_t smb_full_audit_disk_free(vfs_handle_struct *handle,
               NULL,
               handle,
               "%s",
-              smb_fname_str_do_log(handle->conn, smb_fname));
+              smb_fname_str_do_log(handle->conn, fsp->fsp_name));
 
        return result;
 }
index 247564f91f8b31664f9f93fb482073751faa03fb..a2a98995b8a032d5944f0b2ba663065ccea7932a 100644 (file)
@@ -517,11 +517,12 @@ static void vfs_gluster_disconnect(struct vfs_handle_struct *handle)
 }
 
 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize_p,
-                               uint64_t *dfree_p,
-                               uint64_t *dsize_p)
+                                     struct files_struct *fsp,
+                                     uint64_t *bsize_p,
+                                     uint64_t *dfree_p,
+                                     uint64_t *dsize_p)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        struct statvfs statvfs = { 0, };
        int ret;
 
index edd01ddabc4a92050a6a315e954d57a700e7e6a2..aa297cfe0d8871faea841cae660338ff9276bb7d 100644 (file)
@@ -2312,11 +2312,12 @@ static void vfs_gpfs_disk_free_quota(struct gpfs_quotaInfo qi, time_t cur_time,
 }
 
 static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                  struct files_struct *fsp,
+                                  uint64_t *bsize,
+                                  uint64_t *dfree,
+                                  uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        struct security_unix_token *utok;
        struct gpfs_quotaInfo qi_user = { 0 }, qi_group = { 0 };
        struct gpfs_config_data *config;
@@ -2326,15 +2327,15 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
        SMB_VFS_HANDLE_GET_DATA(handle, config, struct gpfs_config_data,
                                return (uint64_t)-1);
        if (!config->dfreequota) {
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
 
        err = sys_fsusage(smb_fname->base_name, dfree, dsize);
        if (err) {
                DEBUG (0, ("Could not get fs usage, errno %d\n", errno));
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
 
        /* sys_fsusage returns units of 512 bytes */
@@ -2348,8 +2349,8 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
        err = get_gpfs_quota(smb_fname->base_name,
                        GPFS_USRQUOTA, utok->uid, &qi_user);
        if (err) {
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
 
        /*
@@ -2371,8 +2372,8 @@ static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle,
        }
 
        if (err) {
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
 
        cur_time = time(NULL);
index 20ee1ff46582f4783bd354f279d12b41eff44db4..964edad47d405124db2e9968cc3154688b16b730 100644 (file)
@@ -42,10 +42,10 @@ void vfs_not_implemented_disconnect(vfs_handle_struct *handle)
 
 _PUBLIC_
 uint64_t vfs_not_implemented_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                      struct files_struct *fsp,
+                                      uint64_t *bsize,
+                                      uint64_t *dfree,
+                                      uint64_t *dsize)
 {
        *bsize = 0;
        *dfree = 0;
index 8e9b6701cb1d42c8c4e0a6bf047cfe8894c455f4..5a386f98191e94d258e7001c9f8aabcdc6a96e15 100644 (file)
@@ -2622,17 +2622,19 @@ static NTSTATUS shadow_copy2_parent_pathname(vfs_handle_struct *handle,
 }
 
 static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                      struct files_struct *fsp,
+                                      uint64_t *bsize,
+                                      uint64_t *dfree,
+                                      uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        time_t timestamp = 0;
        char *stripped = NULL;
        int saved_errno = 0;
        char *conv = NULL;
        struct smb_filename *conv_smb_fname = NULL;
        uint64_t ret = (uint64_t)-1;
+       NTSTATUS status;
 
        if (!shadow_copy2_strip_snapshot(talloc_tos(),
                                handle,
@@ -2642,26 +2644,28 @@ static uint64_t shadow_copy2_disk_free(vfs_handle_struct *handle,
                return (uint64_t)-1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return (uint64_t)-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(),
+                                  handle->conn->cwd_fsp,
+                                  conv,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  smb_fname->flags,
+                                  &conv_smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(conv);
                return (uint64_t)-1;
        }
-       ret = SMB_VFS_NEXT_DISK_FREE(handle, conv_smb_fname,
-                               bsize, dfree, dsize);
+       ret = SMB_VFS_NEXT_DISK_FREE(
+               handle, conv_smb_fname->fsp, bsize, dfree, dsize);
        if (ret == (uint64_t)-1) {
                saved_errno = errno;
        }
index d116c7db3cd6c7fb4cf72b397399ee1245f430b6..f66659f57955acf751e79dbbb8922c5999e60d4f 100644 (file)
@@ -2472,25 +2472,27 @@ static NTSTATUS snapper_gmt_get_real_filename_at(
 }
 
 static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
-                               uint64_t *bsize,
-                               uint64_t *dfree,
-                               uint64_t *dsize)
+                                     struct files_struct *fsp,
+                                     uint64_t *bsize,
+                                     uint64_t *dfree,
+                                     uint64_t *dsize)
 {
+       const struct smb_filename *smb_fname = fsp->fsp_name;
        time_t timestamp = 0;
        char *stripped = NULL;
        uint64_t 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 (uint64_t)-1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_DISK_FREE(handle, smb_fname,
-                                             bsize, dfree, dsize);
+               return SMB_VFS_NEXT_DISK_FREE(
+                       handle, fsp, bsize, dfree, dsize);
        }
 
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
@@ -2498,20 +2500,23 @@ static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
        if (conv == NULL) {
                return (uint64_t)-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(),
+                                  handle->conn->cwd_fsp,
+                                  conv,
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  smb_fname->flags,
+                                  &conv_smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(conv);
-               errno = ENOMEM;
+               errno = map_errno_from_nt_status(status);
                return (uint64_t)-1;
        }
 
-       ret = SMB_VFS_NEXT_DISK_FREE(handle, conv_smb_fname,
-                               bsize, dfree, dsize);
+       ret = SMB_VFS_NEXT_DISK_FREE(
+               handle, conv_smb_fname->fsp, bsize, dfree, dsize);
 
        if (ret == (uint64_t)-1) {
                saved_errno = errno;
index 3ff87a2a414d59747a54c0d58afa800dbbb6e586..cdb08ee169c8f158959ac983c5fb3e7d106e14cf 100644 (file)
@@ -174,25 +174,25 @@ static void smb_time_audit_disconnect(vfs_handle_struct *handle)
 }
 
 static uint64_t smb_time_audit_disk_free(vfs_handle_struct *handle,
-                                       const struct smb_filename *smb_fname,
-                                       uint64_t *bsize,
-                                       uint64_t *dfree,
-                                       uint64_t *dsize)
+                                        struct files_struct *fsp,
+                                        uint64_t *bsize,
+                                        uint64_t *dfree,
+                                        uint64_t *dsize)
 {
        uint64_t result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_DISK_FREE(handle, smb_fname, bsize, dfree, dsize);
+       result = SMB_VFS_NEXT_DISK_FREE(handle, fsp, bsize, dfree, dsize);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        /* Don't have a reasonable notion of failure here */
        if (timediff > audit_timeout) {
                smb_time_audit_log_fname("disk_free",
-                               timediff,
-                               smb_fname->base_name);
+                                        timediff,
+                                        fsp->fsp_name->base_name);
        }
 
        return result;
index 420fdce08dfcadb19430b1dbd848c43805bb733e..15db88adbd6ca91d51d5e23dd45df0e4107ad7c0 100644 (file)
@@ -148,8 +148,8 @@ static uint64_t sys_disk_free(struct files_struct *fsp,
                goto dfree_done;
        }
 
-       if (SMB_VFS_DISK_FREE(conn, fname, bsize, dfree, dsize) ==
-           (uint64_t)-1) {
+       if (SMB_VFS_DISK_FREE(conn, fsp, bsize, dfree, dsize) == (uint64_t)-1)
+       {
                DBG_ERR("VFS disk_free failed. Error was : %s\n",
                        strerror(errno));
                return (uint64_t)-1;
index 9322221940e81989a996edc75d51903730143779..bac4b38112c00dee310c03aa808a039e73ba9e81 100644 (file)
@@ -541,7 +541,6 @@ ssize_t vfs_pwrite_data(struct smb_request *req,
 int vfs_allocate_file_space(files_struct *fsp, uint64_t len)
 {
        int ret;
-       connection_struct *conn = fsp->conn;
        uint64_t space_avail;
        uint64_t bsize,dfree,dsize;
        NTSTATUS status;
@@ -1432,14 +1431,13 @@ void smb_vfs_call_disconnect(struct vfs_handle_struct *handle)
 }
 
 uint64_t smb_vfs_call_disk_free(struct vfs_handle_struct *handle,
-                               const struct smb_filename *smb_fname,
+                               struct files_struct *fsp,
                                uint64_t *bsize,
                                uint64_t *dfree,
                                uint64_t *dsize)
 {
        VFS_FIND(disk_free);
-       return handle->fns->disk_free_fn(handle, smb_fname,
-                       bsize, dfree, dsize);
+       return handle->fns->disk_free_fn(handle, fsp, bsize, dfree, dsize);
 }
 
 int smb_vfs_call_get_quota(struct vfs_handle_struct *handle,
index a6069cdc3b41cda8de2df4cf95d0cc3e73f9a4f9..70c3dc493bfd1f8ffd0067120436a200ce25a62a 100644 (file)
@@ -122,22 +122,27 @@ static NTSTATUS cmd_disk_free(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int ar
 {
        struct smb_filename *smb_fname = NULL;
        uint64_t diskfree, bsize, dfree, dsize;
+       NTSTATUS status;
+
        if (argc != 2) {
                printf("Usage: disk_free <path>\n");
                return NT_STATUS_OK;
        }
 
-       smb_fname = synthetic_smb_fname(talloc_tos(),
-                                       argv[1],
-                                       NULL,
-                                       NULL,
-                                       0,
-                                       ssf_flags());
-       if (smb_fname == NULL) {
-               return NT_STATUS_NO_MEMORY;
+       status = synthetic_pathref(talloc_tos(),
+                                  vfs->conn->cwd_fsp,
+                                  argv[1],
+                                  NULL,
+                                  NULL,
+                                  0,
+                                  ssf_flags(),
+                                  &smb_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
-       diskfree = SMB_VFS_DISK_FREE(vfs->conn, smb_fname,
-                               &bsize, &dfree, &dsize);
+       diskfree = SMB_VFS_DISK_FREE(
+               vfs->conn, smb_fname->fsp, &bsize, &dfree, &dsize);
+       TALLOC_FREE(smb_fname);
        printf("disk_free: %" PRIu64 ", bsize = %" PRIu64 ", dfree = %" PRIu64
               ", dsize = %" PRIu64 "\n",
               diskfree,