mirror of
https://github.com/samba-team/samba.git
synced 2025-01-12 09:18:10 +03:00
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 <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
This commit is contained in:
parent
fc92d451cf
commit
4ad426a7c6
@ -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;
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
/*
|
||||
|
@ -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))
|
||||
|
@ -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 {
|
||||
|
@ -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,
|
||||
|
@ -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, "");
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user