s3: VFS: Change SMB_VFS_STATVFS to use const struct smb_filename * instead of const...
authorJeremy Allison <jra@samba.org>
Fri, 2 Jun 2017 22:26:06 +0000 (15:26 -0700)
committerJeremy Allison <jra@samba.org>
Sun, 18 Jun 2017 00:49:25 +0000 (02:49 +0200)
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>
13 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_ceph.c
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_media_harmony.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_unityed_media.c
source3/smbd/trans2.c
source3/smbd/vfs.c

index 371caef..ec81bdc 100644 (file)
@@ -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;
index bcd4a44..db3ec35 100644 (file)
@@ -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,
index f54d9ea..2f434ba 100644 (file)
                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);
 /*
index d49d340..3404c8c 100644 (file)
 #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))
index 1d9bf13..638118b 100644 (file)
@@ -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 {
index 0aba405..4f86537 100644 (file)
@@ -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,
index 15ab13f..609ef37 100644 (file)
@@ -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, "");
 
index 870983e..7a42d86 100644 (file)
@@ -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;
        }
 
index 2659b29..420b51f 100644 (file)
@@ -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;
 }
 
index f07bd29..b1bf59e 100644 (file)
@@ -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;
index aefe2b3..b1c459a 100644 (file)
@@ -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;
 }
 
index 33908f0..ae41f19 100644 (file)
@@ -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;
index c747bde..acfc705 100644 (file)
@@ -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,