From: Jeremy Allison Date: Fri, 2 Jun 2017 22:26:06 +0000 (-0700) Subject: s3: VFS: Change SMB_VFS_STATVFS to use const struct smb_filename * instead of const... X-Git-Tag: tevent-0.9.32~56 X-Git-Url: http://git.samba.org/samba.git/?p=kamenim%2Fsamba-autobuild%2F.git;a=commitdiff_plain;h=4ad426a7c6c9fffa41df5bcafd9f420c257b6805 s3: VFS: Change SMB_VFS_STATVFS to use const struct smb_filename * instead of const char *. We need to migrate all pathname based VFS calls to use a struct to finish modernising the VFS with extra timestamp and flags parameters. Signed-off-by: Jeremy Allison Reviewed-by: Richard Sharpe --- diff --git a/examples/VFS/skel_opaque.c b/examples/VFS/skel_opaque.c index 371caef4818..ec81bdc9fef 100644 --- a/examples/VFS/skel_opaque.c +++ b/examples/VFS/skel_opaque.c @@ -83,7 +83,8 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle, } static int skel_statvfs(struct vfs_handle_struct *handle, - const char *path, struct vfs_statvfs_struct *statbuf) + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *statbuf) { errno = ENOSYS; return -1; diff --git a/examples/VFS/skel_transparent.c b/examples/VFS/skel_transparent.c index bcd4a44e51d..db3ec35bd58 100644 --- a/examples/VFS/skel_transparent.c +++ b/examples/VFS/skel_transparent.c @@ -81,10 +81,11 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle, labels); } -static int skel_statvfs(struct vfs_handle_struct *handle, const char *path, +static int skel_statvfs(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, struct vfs_statvfs_struct *statbuf) { - return SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + return SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf); } static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle, diff --git a/source3/include/vfs.h b/source3/include/vfs.h index f54d9ea93b2..2f434ba20dc 100644 --- a/source3/include/vfs.h +++ b/source3/include/vfs.h @@ -222,6 +222,8 @@ to const struct smb_filename * */ /* Version 37 - Change link from const char * to const struct smb_filename * */ +/* Version 37 - Change statvfs from const char * + to const struct smb_filename * */ #define SMB_VFS_INTERFACE_VERSION 37 @@ -618,7 +620,9 @@ struct vfs_fn_pointers { 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 (*statvfs_fn)(struct vfs_handle_struct *handle, const char *path, struct vfs_statvfs_struct *statbuf); + int (*statvfs_fn)(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *statbuf); uint32_t (*fs_capabilities_fn)(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res); /* @@ -1085,8 +1089,9 @@ int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle, struct files_struct *fsp, struct shadow_copy_data *shadow_copy_data, bool labels); -int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path, - struct vfs_statvfs_struct *statbuf); +int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *statbuf); uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle, enum timestamp_set_resolution *p_ts_res); /* diff --git a/source3/include/vfs_macros.h b/source3/include/vfs_macros.h index d49d340b002..3404c8ca751 100644 --- a/source3/include/vfs_macros.h +++ b/source3/include/vfs_macros.h @@ -59,10 +59,10 @@ #define SMB_VFS_NEXT_GET_SHADOW_COPY_DATA(handle, fsp, shadow_copy_data ,labels) \ smb_vfs_call_get_shadow_copy_data((handle)->next, (fsp), (shadow_copy_data), (labels)) -#define SMB_VFS_STATVFS(conn, path, statbuf) \ - smb_vfs_call_statvfs((conn)->vfs_handles, (path), (statbuf)) -#define SMB_VFS_NEXT_STATVFS(handle, path, statbuf) \ - smb_vfs_call_statvfs((handle)->next, (path), (statbuf)) +#define SMB_VFS_STATVFS(conn, smb_fname, statbuf) \ + smb_vfs_call_statvfs((conn)->vfs_handles, (smb_fname), (statbuf)) +#define SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf) \ + smb_vfs_call_statvfs((handle)->next, (smb_fname), (statbuf)) #define SMB_VFS_FS_CAPABILITIES(conn, p_ts_res) \ smb_vfs_call_fs_capabilities((conn)->vfs_handles, (p_ts_res)) diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index 1d9bf13a289..638118b5c5b 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -244,12 +244,14 @@ static int cephwrap_set_quota(struct vfs_handle_struct *handle, enum SMB_QUOTA_ #endif } -static int cephwrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf) +static int cephwrap_statvfs(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + vfs_statvfs_struct *statbuf) { struct statvfs statvfs_buf; int ret; - ret = ceph_statfs(handle->data, path, &statvfs_buf); + ret = ceph_statfs(handle->data, smb_fname->base_name, &statvfs_buf); if (ret < 0) { WRAP_RETURN(ret); } else { diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c index 0aba405c374..4f86537c031 100644 --- a/source3/modules/vfs_default.c +++ b/source3/modules/vfs_default.c @@ -112,9 +112,11 @@ static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle, return -1; /* Not implemented. */ } -static int vfswrap_statvfs(struct vfs_handle_struct *handle, const char *path, vfs_statvfs_struct *statbuf) +static int vfswrap_statvfs(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + vfs_statvfs_struct *statbuf) { - return sys_statvfs(path, statbuf); + return sys_statvfs(smb_fname->base_name, statbuf); } static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle, diff --git a/source3/modules/vfs_full_audit.c b/source3/modules/vfs_full_audit.c index 15ab13f859f..609ef378fdd 100644 --- a/source3/modules/vfs_full_audit.c +++ b/source3/modules/vfs_full_audit.c @@ -736,12 +736,12 @@ static int smb_full_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, } static int smb_full_audit_statvfs(struct vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, struct vfs_statvfs_struct *statbuf) { int result; - result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf); do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, ""); diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 870983ea8fc..7a42d869d40 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -420,16 +420,16 @@ vfs_gluster_set_quota(struct vfs_handle_struct *handle, } static int vfs_gluster_statvfs(struct vfs_handle_struct *handle, - const char *path, - struct vfs_statvfs_struct *vfs_statvfs) + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *vfs_statvfs) { struct statvfs statvfs = { 0, }; int ret; - ret = glfs_statvfs(handle->data, path, &statvfs); + ret = glfs_statvfs(handle->data, smb_fname->base_name, &statvfs); if (ret < 0) { DEBUG(0, ("glfs_statvfs(%s) failed: %s\n", - path, strerror(errno))); + smb_fname->base_name, strerror(errno))); return -1; } diff --git a/source3/modules/vfs_media_harmony.c b/source3/modules/vfs_media_harmony.c index 2659b29c498..420b51f9910 100644 --- a/source3/modules/vfs_media_harmony.c +++ b/source3/modules/vfs_media_harmony.c @@ -632,36 +632,35 @@ out: * Failure: set errno, return -1 */ static int mh_statvfs(struct vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, struct vfs_statvfs_struct *statbuf) { int status; - char *clientPath; - TALLOC_CTX *ctx; + struct smb_filename *clientFname = NULL; - DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", path)); + DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", + smb_fname->base_name)); - if (!is_in_media_files(path)) + if (!is_in_media_files(smb_fname->base_name)) { - status = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + status = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf); goto out; } - clientPath = NULL; - ctx = talloc_tos(); - - if ((status = alloc_get_client_path(handle, ctx, - path, - &clientPath))) - { + status = alloc_get_client_smb_fname(handle, + talloc_tos(), + smb_fname, + &clientFname); + if (status != 0) { goto err; } - status = SMB_VFS_NEXT_STATVFS(handle, clientPath, statbuf); + status = SMB_VFS_NEXT_STATVFS(handle, clientFname, statbuf); err: - TALLOC_FREE(clientPath); + TALLOC_FREE(clientFname); out: - DEBUG(MH_INFO_DEBUG, ("Leaving with path '%s'\n", path)); + DEBUG(MH_INFO_DEBUG, ("Leaving with path '%s'\n", + smb_fname->base_name)); return status; } diff --git a/source3/modules/vfs_time_audit.c b/source3/modules/vfs_time_audit.c index f07bd29f5e3..b1bf59ee6a3 100644 --- a/source3/modules/vfs_time_audit.c +++ b/source3/modules/vfs_time_audit.c @@ -247,7 +247,7 @@ static int smb_time_audit_get_shadow_copy_data(struct vfs_handle_struct *handle, } static int smb_time_audit_statvfs(struct vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, struct vfs_statvfs_struct *statbuf) { int result; @@ -255,12 +255,13 @@ static int smb_time_audit_statvfs(struct vfs_handle_struct *handle, double timediff; clock_gettime_mono(&ts1); - result = SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + result = SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf); clock_gettime_mono(&ts2); timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; if (timediff > audit_timeout) { - smb_time_audit_log_fname("statvfs", timediff, path); + smb_time_audit_log_fname("statvfs", timediff, + smb_fname->base_name); } return result; diff --git a/source3/modules/vfs_unityed_media.c b/source3/modules/vfs_unityed_media.c index aefe2b37ab1..b1c459ada4c 100644 --- a/source3/modules/vfs_unityed_media.c +++ b/source3/modules/vfs_unityed_media.c @@ -522,28 +522,30 @@ err: * Failure: set errno, return -1 */ static int um_statvfs(struct vfs_handle_struct *handle, - const char *path, + const struct smb_filename *smb_fname, struct vfs_statvfs_struct *statbuf) { int status; - char *clientPath = NULL; + struct smb_filename *client_fname = NULL; - DEBUG(10, ("Entering with path '%s'\n", path)); + DEBUG(10, ("Entering with path '%s'\n", smb_fname->base_name)); - if (!is_in_media_files(path)) { - return SMB_VFS_NEXT_STATVFS(handle, path, statbuf); + if (!is_in_media_files(smb_fname->base_name)) { + return SMB_VFS_NEXT_STATVFS(handle, smb_fname, statbuf); } - status = alloc_get_client_path(handle, talloc_tos(), - path, &clientPath); + status = alloc_get_client_smb_fname(handle, + talloc_tos(), + smb_fname, + &client_fname); if (status != 0) { goto err; } - status = SMB_VFS_NEXT_STATVFS(handle, clientPath, statbuf); + status = SMB_VFS_NEXT_STATVFS(handle, client_fname, statbuf); err: - TALLOC_FREE(clientPath); - DEBUG(10, ("Leaving with path '%s'\n", path)); + TALLOC_FREE(client_fname); + DEBUG(10, ("Leaving with path '%s'\n", smb_fname->base_name)); return status; } diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 33908f0e7e2..ae41f199cb2 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -3905,7 +3905,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned return NT_STATUS_INVALID_LEVEL; } - rc = SMB_VFS_STATVFS(conn, filename, &svfs); + rc = SMB_VFS_STATVFS(conn, &smb_fname, &svfs); if (!rc) { data_len = 56; diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index c747bde5569..acfc705a401 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1506,11 +1506,12 @@ int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle, shadow_copy_data, labels); } -int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, const char *path, - struct vfs_statvfs_struct *statbuf) +int smb_vfs_call_statvfs(struct vfs_handle_struct *handle, + const struct smb_filename *smb_fname, + struct vfs_statvfs_struct *statbuf) { VFS_FIND(statvfs); - return handle->fns->statvfs_fn(handle, path, statbuf); + return handle->fns->statvfs_fn(handle, smb_fname, statbuf); } uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,