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 371caef4818f43fff1ae2467be731302a44c7a51..ec81bdc9fef8c62ec5e4003cd006b843609cffb1 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,
 }
 
 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;
 {
        errno = ENOSYS;
        return -1;
index bcd4a44e51da77bda330d50195ee2e90e959bddd..db3ec35bd58b21d1d75d6020e1be272ea4a74b3c 100644 (file)
@@ -81,10 +81,11 @@ static int skel_get_shadow_copy_data(vfs_handle_struct *handle,
                                                 labels);
 }
 
                                                 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)
 {
                        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,
 }
 
 static uint32_t skel_fs_capabilities(struct vfs_handle_struct *handle,
index f54d9ea93b24d10cd6b8f0b70e2862880aab6f13..2f434ba20dcdf550e460d08c762c6eefb034105c 100644 (file)
                to const struct smb_filename * */
 /* Version 37 - Change link from const char *
                to const struct smb_filename * */
                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
 
 
 #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);
                                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);
 
        /*
        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);
                                      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);
 /*
 uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,
                                      enum timestamp_set_resolution *p_ts_res);
 /*
index d49d340b002f95f734bc4d87ffa1965d08f9e89c..3404c8ca7513e26d5d69f8413f692c66cc9739f6 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_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))
 
 #define SMB_VFS_FS_CAPABILITIES(conn, p_ts_res) \
        smb_vfs_call_fs_capabilities((conn)->vfs_handles, (p_ts_res))
index 1d9bf13a28922ff396011c612ffd5b46055455d3..638118b5c5b8797f5ccb9f3a70be2420b3822018 100644 (file)
@@ -244,12 +244,14 @@ static int cephwrap_set_quota(struct vfs_handle_struct *handle,  enum SMB_QUOTA_
 #endif
 }
 
 #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;
 
 {
        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 {
        if (ret < 0) {
                WRAP_RETURN(ret);
        } else {
index 0aba405c374604f7b884262fec39141489fd02dd..4f86537c031d67443b54cafdaf5a0b1df75443f5 100644 (file)
@@ -112,9 +112,11 @@ static int vfswrap_get_shadow_copy_data(struct vfs_handle_struct *handle,
        return -1;  /* Not implemented. */
 }
 
        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,
 }
 
 static uint32_t vfswrap_fs_capabilities(struct vfs_handle_struct *handle,
index 15ab13f859f6761c0aaf34c5927c51e3d05778f9..609ef378fddc0e3abb23881d44b0ad8745ccf4c6 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,
 }
 
 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;
 
                                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, "");
 
 
        do_log(SMB_VFS_OP_STATVFS, (result >= 0), handle, "");
 
index 870983ea8fc5f247551ad8a9dab2f2eb2849b682..7a42d869d40ed2ecfdc385e4ce893f5624880104 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,
 }
 
 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;
 
 {
        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",
        if (ret < 0) {
                DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
-                         path, strerror(errno)));
+                         smb_fname->base_name, strerror(errno)));
                return -1;
        }
 
                return -1;
        }
 
index 2659b29c498e6f86cc2a0f6e2b13ce2e8f260ee4..420b51f991044197d51ffd1db2ce913f60664fbb 100644 (file)
@@ -632,36 +632,35 @@ out:
  * Failure: set errno, return -1
  */
 static int mh_statvfs(struct vfs_handle_struct *handle,
  * 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;
                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;
        }
 
                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;
        }
 
                goto err;
        }
 
-       status = SMB_VFS_NEXT_STATVFS(handle, clientPath, statbuf);
+       status = SMB_VFS_NEXT_STATVFS(handle, clientFname, statbuf);
 err:
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
 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;
 }
 
        return status;
 }
 
index f07bd29f5e349ffb117320c871db3be594089d16..b1bf59ee6a31e293bc99755d6ed1fd515e82ff99 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,
 }
 
 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;
                                  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);
        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) {
        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;
        }
 
        return result;
index aefe2b37ab1076ea42247d43c4215948a52709d6..b1c459ada4cee3a4f2ac47317d034aab84ebdb9e 100644 (file)
@@ -522,28 +522,30 @@ err:
  * Failure: set errno, return -1
  */
 static int um_statvfs(struct vfs_handle_struct *handle,
  * 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;
                      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;
        }
 
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_STATVFS(handle, clientPath, statbuf);
+       status = SMB_VFS_NEXT_STATVFS(handle, client_fname, statbuf);
 err:
 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;
 }
 
        return status;
 }
 
index 33908f0e7e27fb4e3a7c7945cb16623bc55c5cb1..ae41f199cb21856910f356e5ecff71cd0d0b758f 100644 (file)
@@ -3905,7 +3905,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
                                return NT_STATUS_INVALID_LEVEL;
                        }
 
                                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;
 
                        if (!rc) {
                                data_len = 56;
index c747bde5569110fa5df70a2c78a37229f562e248..acfc705a40185e82ae10b765215627d20ceda7d6 100644 (file)
@@ -1506,11 +1506,12 @@ int smb_vfs_call_get_shadow_copy_data(struct vfs_handle_struct *handle,
                                                    shadow_copy_data,
                                                    labels);
 }
                                                    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);
 {
        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,
 }
 
 uint32_t smb_vfs_call_fs_capabilities(struct vfs_handle_struct *handle,