From: Volker Lendecke Date: Tue, 27 Jan 2026 17:15:53 +0000 (+0100) Subject: vfs: Change SMB_VFS_DISK_FREE to take a fsp X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce3fb69a6bf06cde0652a5c9700833857e8f058e;p=thirdparty%2Fsamba.git vfs: Change SMB_VFS_DISK_FREE to take a fsp 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 Reviewed-by: Anoop C S --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 92574b30348..31aff0c1273 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -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; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index c28963fa5dd..50cbb5c90a5 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -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, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index 3922b638323..09cab759bb5 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -397,9 +397,11 @@ * 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, diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index 4c98862f039..7f583586b12 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -39,10 +39,12 @@ #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)) diff --git a/source3/modules/vfs_cap.c b/source3/modules/vfs_cap.c index acb0ed04aa3..9957998d2d9 100644 --- a/source3/modules/vfs_cap.c +++ b/source3/modules/vfs_cap.c @@ -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, diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 04d7433c1e0..1c84059b184 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -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; diff --git a/source3/modules/vfs_ceph_new.c b/source3/modules/vfs_ceph_new.c index 4a91f55b612..4b92c3f7215 100644 --- a/source3/modules/vfs_ceph_new.c +++ b/source3/modules/vfs_ceph_new.c @@ -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; diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index 46d45c84dc6..7fa03ceb5fc 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -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, - ×tamp, stripped, sizeof(stripped)); + ret = ceph_snap_gmt_strip_snapshot( + handle, smb_fname, ×tamp, 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; diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index a4a5b54ecb7..0bfdaef4998 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -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; } diff --git a/source3/modules/vfs_fake_dfq.c b/source3/modules/vfs_fake_dfq.c index 8bec9e0b954..92b0e6e3be7 100644 --- a/source3/modules/vfs_fake_dfq.c +++ b/source3/modules/vfs_fake_dfq.c @@ -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; diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index c8af698e483..9ffece1fb0c 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -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(), diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 4935cdbce26..e0cdf2718f4 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -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; } diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 247564f91f8..a2a98995b8a 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -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; diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c index edd01ddabc4..aa297cfe0d8 100644 --- a/source3/modules/vfs_gpfs.c +++ b/source3/modules/vfs_gpfs.c @@ -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); diff --git a/source3/modules/vfs_not_implemented.c b/source3/modules/vfs_not_implemented.c index 20ee1ff4658..964edad47d4 100644 --- a/source3/modules/vfs_not_implemented.c +++ b/source3/modules/vfs_not_implemented.c @@ -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; diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 8e9b6701cb1..5a386f98191 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -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; } diff --git a/source3/modules/vfs_snapper.c b/source3/modules/vfs_snapper.c index d116c7db3cd..f66659f5795 100644 --- a/source3/modules/vfs_snapper.c +++ b/source3/modules/vfs_snapper.c @@ -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, ×tamp, &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; diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index 3ff87a2a414..cdb08ee169c 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -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; diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 420fdce08df..15db88adbd6 100644 --- a/source3/smbd/dfree.c +++ b/source3/smbd/dfree.c @@ -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; diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 9322221940e..bac4b38112c 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -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, diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index a6069cdc3b4..70c3dc493bf 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -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 \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,