s3: VFS: Change SMB_VFS_CHFLAGS to use const struct smb_filename * instead of const...
authorJeremy Allison <jra@samba.org>
Fri, 19 May 2017 23:15:55 +0000 (16:15 -0700)
committerJeremy Allison <jra@samba.org>
Sun, 18 Jun 2017 00:49:24 +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>
16 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_catia.c
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_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_unityed_media.c
source3/smbd/trans2.c
source3/smbd/vfs.c

index ae0d4dc2b621da26fde90389a06429867ec6c2ce..aeb1ff37b5f8703eab3f493418580b0992355406 100644 (file)
@@ -507,7 +507,8 @@ static char *skel_realpath(vfs_handle_struct *handle, const char *path)
        return NULL;
 }
 
-static int skel_chflags(vfs_handle_struct *handle, const char *path,
+static int skel_chflags(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
                        uint flags)
 {
        errno = ENOSYS;
index 30f2b4e6f03641f8bab413ef7387d72dcecfc890..f3adae3978fada2cfa69993b0e9527cc22150cce 100644 (file)
@@ -596,10 +596,11 @@ static char *skel_realpath(vfs_handle_struct *handle, const char *path)
        return SMB_VFS_NEXT_REALPATH(handle, path);
 }
 
-static int skel_chflags(vfs_handle_struct *handle, const char *path,
+static int skel_chflags(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
                        uint flags)
 {
-       return SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
+       return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
 }
 
 static struct file_id skel_file_id_create(vfs_handle_struct *handle,
index ec7f0d0a731d99bfaf1b6ad1bb679d0ceae9085c..93ec6e8f49a58344640de1f822c648323eb6634b 100644 (file)
 /* Version 37 - Change getxattr from const char *
                to const struct smb_filename * */
 /* Version 37 - Change mknod from const char * to const struct smb_filename * */
+/* Version 37 - Change chflags from const char *
+               to const struct smb_filename * */
 
 #define SMB_VFS_INTERFACE_VERSION 37
 
@@ -734,7 +736,9 @@ struct vfs_fn_pointers {
                                mode_t mode,
                                SMB_DEV_T dev);
        char *(*realpath_fn)(struct vfs_handle_struct *handle, const char *path);
-       int (*chflags_fn)(struct vfs_handle_struct *handle, const char *path, unsigned int flags);
+       int (*chflags_fn)(struct vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               unsigned int flags);
        struct file_id (*file_id_create_fn)(struct vfs_handle_struct *handle,
                                            const SMB_STRUCT_STAT *sbuf);
        struct tevent_req *(*copy_chunk_send_fn)(struct vfs_handle_struct *handle,
@@ -1231,8 +1235,9 @@ int smb_vfs_call_mknod(struct vfs_handle_struct *handle,
                        mode_t mode,
                        SMB_DEV_T dev);
 char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path);
-int smb_vfs_call_chflags(struct vfs_handle_struct *handle, const char *path,
-                        unsigned int flags);
+int smb_vfs_call_chflags(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags);
 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,
                                           const SMB_STRUCT_STAT *sbuf);
 NTSTATUS smb_vfs_call_streaminfo(struct vfs_handle_struct *handle,
index 30271a6fc3a30d4e24571fc09dcb6f24c73c99d9..701dc534984798610b98c1a6343f6fc06785ce42 100644 (file)
 #define SMB_VFS_NEXT_REALPATH(handle, path) \
        smb_vfs_call_realpath((handle)->next, (path))
 
-#define SMB_VFS_CHFLAGS(conn, path, flags) \
-       smb_vfs_call_chflags((conn)->vfs_handles, (path), (flags))
-#define SMB_VFS_NEXT_CHFLAGS(handle, path, flags) \
-       smb_vfs_call_chflags((handle)->next, (path), (flags))
+#define SMB_VFS_CHFLAGS(conn, smb_fname, flags) \
+       smb_vfs_call_chflags((conn)->vfs_handles, (smb_fname), (flags))
+#define SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags) \
+       smb_vfs_call_chflags((handle)->next, (smb_fname), (flags))
 
 #define SMB_VFS_FILE_ID_CREATE(conn, sbuf) \
        smb_vfs_call_file_id_create((conn)->vfs_handles, (sbuf))
index 2592367ed2b3d2a86c2c97a3f98157e2482675a2..ed16e43aa38f4198d811d7ad14ed6cc776b3c4d0 100644 (file)
@@ -1062,21 +1062,36 @@ catia_realpath(vfs_handle_struct *handle, const char *path)
 }
 
 static int catia_chflags(struct vfs_handle_struct *handle,
-                        const char *path, unsigned int flags)
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
-       char *mapped_name = NULL;
+       char *name = NULL;
+       struct smb_filename *catia_smb_fname = NULL;
        NTSTATUS status;
        int ret;
 
-       status = catia_string_replace_allocate(handle->conn, path,
-                                       &mapped_name, vfs_translate_to_unix);
+       status = catia_string_replace_allocate(handle->conn,
+                               smb_fname->base_name,
+                               &name,
+                               vfs_translate_to_unix);
        if (!NT_STATUS_IS_OK(status)) {
                errno = map_errno_from_nt_status(status);
                return -1;
        }
+       catia_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       name,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
+       if (catia_smb_fname == NULL) {
+               TALLOC_FREE(name);
+               errno = ENOMEM;
+               return -1;
+       }
 
-       ret = SMB_VFS_NEXT_CHFLAGS(handle, mapped_name, flags);
-       TALLOC_FREE(mapped_name);
+       ret = SMB_VFS_NEXT_CHFLAGS(handle, catia_smb_fname, flags);
+       TALLOC_FREE(name);
+       TALLOC_FREE(catia_smb_fname);
 
        return ret;
 }
index d88ceacee334ae6461abd172a99c722ba93607f1..d936738ff5a81184f595a7a7f54ce80c4be7ae3e 100644 (file)
@@ -1189,8 +1189,9 @@ static char *cephwrap_realpath(struct vfs_handle_struct *handle,  const char *pa
        return result;
 }
 
-static int cephwrap_chflags(struct vfs_handle_struct *handle, const char *path,
-                          unsigned int flags)
+static int cephwrap_chflags(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        errno = ENOSYS;
        return -1;
index 6de5d641c3e1bf7bfde926b83f5dca4723c4be62..b2c6c28f87b5dbd3cc37692c140676d68b1fd0d8 100644 (file)
@@ -2465,11 +2465,12 @@ static char *vfswrap_realpath(vfs_handle_struct *handle, const char *path)
        return result;
 }
 
-static int vfswrap_chflags(vfs_handle_struct *handle, const char *path,
-                          unsigned int flags)
+static int vfswrap_chflags(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
 #ifdef HAVE_CHFLAGS
-       return chflags(path, flags);
+       return chflags(smb_fname->base_name, flags);
 #else
        errno = ENOSYS;
        return -1;
index af165dd4b697db23bec1aec8af1ccfd73f8003ec..634caf09a6145d6658ad54c707e59491408c6fee 100644 (file)
@@ -1686,13 +1686,15 @@ static char *smb_full_audit_realpath(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_chflags(vfs_handle_struct *handle,
-                           const char *path, unsigned int flags)
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        int result;
 
-       result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
+       result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
 
-       do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s", path);
+       do_log(SMB_VFS_OP_CHFLAGS, (result != 0), handle, "%s",
+               smb_fname->base_name);
 
        return result;
 }
index 7c727773a6445db0f666b3be9c449eced06ef7e6..878c5078c588e249292d125bfa4288f2250eed64 100644 (file)
@@ -1257,7 +1257,8 @@ static int vfs_gluster_mknod(struct vfs_handle_struct *handle,
 }
 
 static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
-                              const char *path, unsigned int flags)
+                               const struct smb_filename *smb_fname,
+                               unsigned int flags)
 {
        errno = ENOSYS;
        return -1;
index 99a5e9b6979bb74f3bf48ba56f48dece856678e0..37b396a5bea8a8713c57e91f6bb2cbdedda1c2d4 100644 (file)
@@ -1923,33 +1923,30 @@ out:
  * Failure: set errno, return -1
  */
 static int mh_chflags(vfs_handle_struct *handle,
-               const char *path,
+               const struct smb_filename *smb_fname,
                unsigned int flags)
 {
        int status;
-       char *clientPath;
+       struct smb_filename *clientFname = NULL;
        TALLOC_CTX *ctx;
 
        DEBUG(MH_INFO_DEBUG, ("Entering mh_chflags\n"));
-       if (!is_in_media_files(path))
-       {
-               status = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               status = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
                goto out;
        }
 
-       clientPath = NULL;
        ctx = talloc_tos();
 
-       if ((status = alloc_get_client_path(handle, ctx,
-                               path,
-                               &clientPath)))
-       {
+       if ((status = alloc_get_client_smb_fname(handle, ctx,
+                               smb_fname,
+                               &clientFname))) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_CHFLAGS(handle, clientPath, flags);
+       status = SMB_VFS_NEXT_CHFLAGS(handle, clientFname, flags);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        return status;
 }
index 1fb492ba71eb7aaf1bbbd8deaa121ba93a43d6f0..35c08549afa60c2e211f3939c1d0b18255b888de 100644 (file)
@@ -2309,7 +2309,8 @@ static int shadow_copy2_rmdir(vfs_handle_struct *handle,
        return ret;
 }
 
-static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
+static int shadow_copy2_chflags(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
                                unsigned int flags)
 {
        time_t timestamp = 0;
@@ -2317,23 +2318,37 @@ static int shadow_copy2_chflags(vfs_handle_struct *handle, const char *fname,
        int saved_errno = 0;
        int ret;
        char *conv;
+       struct smb_filename *conv_smb_fname = NULL;
 
-       if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
-                                        &timestamp, &stripped)) {
+       if (!shadow_copy2_strip_snapshot(talloc_tos(),
+                                       handle,
+                                       smb_fname->base_name,
+                                       &timestamp,
+                                       &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
+               return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
        }
        conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
+       if (conv_smb_fname == NULL) {
+               TALLOC_FREE(conv);
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
        if (ret == -1) {
                saved_errno = errno;
        }
+       TALLOC_FREE(conv_smb_fname);
        TALLOC_FREE(conv);
        if (saved_errno != 0) {
                errno = saved_errno;
index 61e7496f95ed0e885329010b60fd69694e44ec0d..ec23c616aae045cfe60bf4fc9d71dbcfc6310168 100644 (file)
@@ -2654,30 +2654,47 @@ static int snapper_gmt_rmdir(vfs_handle_struct *handle,
        return ret;
 }
 
-static int snapper_gmt_chflags(vfs_handle_struct *handle, const char *fname,
-                              unsigned int flags)
+static int snapper_gmt_chflags(vfs_handle_struct *handle,
+                               const struct smb_filename *smb_fname,
+                               unsigned int flags)
 {
-       time_t timestamp;
-       char *stripped;
-       int ret, saved_errno;
-       char *conv;
+       time_t timestamp = 0;
+       char *stripped = NULL;
+       int ret = -1;
+       int saved_errno = 0;
+       char *conv = NULL;
+       struct smb_filename *conv_smb_fname = NULL;
 
-       if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, fname,
-                                       &timestamp, &stripped)) {
+       if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
+                               smb_fname->base_name, &timestamp, &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_CHFLAGS(handle, fname, flags);
+               return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
        }
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
        TALLOC_FREE(stripped);
        if (conv == NULL) {
                return -1;
        }
-       ret = SMB_VFS_NEXT_CHFLAGS(handle, conv, flags);
-       saved_errno = errno;
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
        TALLOC_FREE(conv);
-       errno = saved_errno;
+       if (conv_smb_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
+       ret = SMB_VFS_NEXT_CHFLAGS(handle, conv_smb_fname, flags);
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(conv_smb_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }
 
index 3bbe2d961498ecc8e91cb05b23631041af62c2eb..aa882bb7700cc513db68d5b4168760382b06e5f8 100644 (file)
@@ -1512,19 +1512,20 @@ static char *smb_time_audit_realpath(vfs_handle_struct *handle,
 }
 
 static int smb_time_audit_chflags(vfs_handle_struct *handle,
-                                 const char *path, unsigned int flags)
+                               const struct smb_filename *smb_fname,
+                               unsigned int flags)
 {
        int result;
        struct timespec ts1,ts2;
        double timediff;
 
        clock_gettime_mono(&ts1);
-       result = SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
+       result = SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
        if (timediff > audit_timeout) {
-               smb_time_audit_log_fname("chflags", timediff, path);
+               smb_time_audit_log_smb_fname("chflags", timediff, smb_fname);
        }
 
        return result;
index cda6ad635a8ac8f5a5810ea20246b959126bfb79..aa06ea361fac4b0018cbefcd047cb333d83215ce 100644 (file)
@@ -1464,27 +1464,27 @@ err:
 }
 
 static int um_chflags(vfs_handle_struct *handle,
-                     const char *path,
-                     unsigned int flags)
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        int status;
-       char *client_path = NULL;
-
-       DEBUG(10, ("Entering um_chflags\n"));
+       struct smb_filename *client_fname = NULL;
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
+       DEBUG(10, ("Entering um_mknod\n"));
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle, talloc_tos(),
+                                           smb_fname, &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_CHFLAGS(handle, client_path, flags);
+       status = SMB_VFS_NEXT_CHFLAGS(handle, client_fname, flags);
+
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
index 758644bc2304f526cebf9294e0ab959b1016aa62..3e1cfa8ca968c9023e57b376fbc98a9cfcca00d2 100644 (file)
@@ -7905,7 +7905,7 @@ static NTSTATUS smb_set_file_unix_info2(connection_struct *conn,
                        /* XXX: we should be  using SMB_VFS_FCHFLAGS here. */
                        return NT_STATUS_NOT_SUPPORTED;
                } else {
-                       if (SMB_VFS_CHFLAGS(conn, smb_fname->base_name,
+                       if (SMB_VFS_CHFLAGS(conn, smb_fname,
                                            stat_fflags) != 0) {
                                return map_nt_error_from_unix(errno);
                        }
index b129bb1ce0539d45d93909f3ef681f55065a885f..9248091153aef66e1dbe9e56d42d0bdc296dcfee 100644 (file)
@@ -2182,11 +2182,12 @@ char *smb_vfs_call_realpath(struct vfs_handle_struct *handle, const char *path)
        return handle->fns->realpath_fn(handle, path);
 }
 
-int smb_vfs_call_chflags(struct vfs_handle_struct *handle, const char *path,
-                        unsigned int flags)
+int smb_vfs_call_chflags(struct vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        VFS_FIND(chflags);
-       return handle->fns->chflags_fn(handle, path, flags);
+       return handle->fns->chflags_fn(handle, smb_fname, flags);
 }
 
 struct file_id smb_vfs_call_file_id_create(struct vfs_handle_struct *handle,