]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3:vfs: add vfs_rename_how to SMB_VFS_RENAMEAT()
authorStefan Metzmacher <metze@samba.org>
Tue, 6 Aug 2024 11:21:34 +0000 (13:21 +0200)
committerStefan Metzmacher <metze@samba.org>
Wed, 21 Aug 2024 08:02:30 +0000 (08:02 +0000)
This will support renameat2-like operations in future.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15693

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
33 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_audit.c
source3/modules/vfs_cap.c
source3/modules/vfs_catia.c
source3/modules/vfs_ceph.c
source3/modules/vfs_ceph_new.c
source3/modules/vfs_ceph_snapshots.c
source3/modules/vfs_crossrename.c
source3/modules/vfs_default.c
source3/modules/vfs_extd_audit.c
source3/modules/vfs_fruit.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_glusterfs.c
source3/modules/vfs_media_harmony.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_recycle.c
source3/modules/vfs_shadow_copy2.c
source3/modules/vfs_snapper.c
source3/modules/vfs_streams_depot.c
source3/modules/vfs_streams_xattr.c
source3/modules/vfs_syncops.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_unityed_media.c
source3/modules/vfs_virusfilter.c
source3/modules/vfs_virusfilter_utils.c
source3/modules/vfs_worm.c
source3/smbd/open.c
source3/smbd/smb2_reply.c
source3/smbd/vfs.c
source3/torture/cmd_vfs.c

index 255fa830402e5e854ec8771bfc74609a36eab1d2..a3521982f1697912d461cd30e0af193a66ee29be 100644 (file)
@@ -298,7 +298,8 @@ static int skel_renameat(vfs_handle_struct *handle,
                       files_struct *srcfsp,
                       const struct smb_filename *smb_fname_src,
                       files_struct *dstfsp,
-                      const struct smb_filename *smb_fname_dst)
+                      const struct smb_filename *smb_fname_dst,
+                      const struct vfs_rename_how *how)
 {
        errno = ENOSYS;
        return -1;
index 461228f09afd617cfce94da8ae2d687da0b58bfd..4d1312414a063c3a734c5dfeacc212839c6a7df6 100644 (file)
@@ -384,13 +384,15 @@ static int skel_renameat(vfs_handle_struct *handle,
                       files_struct *srcfsp,
                       const struct smb_filename *smb_fname_src,
                       files_struct *dstfsp,
-                      const struct smb_filename *smb_fname_dst)
+                      const struct smb_filename *smb_fname_dst,
+                      const struct vfs_rename_how *how)
 {
        return SMB_VFS_NEXT_RENAMEAT(handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
 }
 
 struct skel_fsync_state {
index 374d7e03c33aa40c8c2e3254bca8fb2139409d0d..29451b081b1ff82d94db9fd04e6c47e61c6f3090 100644 (file)
  * Change to Version 49 - will ship with 4.19
  * Version 49 - remove seekdir and telldir
  * Version 49 - remove "sbuf" argument from readdir_fn()
+ * Change to Version 50 - will ship with 4.22
+ * Version 50 - Change SMB_VFS_RENAMEAT() add vfs_rename_how
  */
 
-#define SMB_VFS_INTERFACE_VERSION 49
+#define SMB_VFS_INTERFACE_VERSION 50
 
 /*
     All intercepted VFS operations must be declared as static functions inside module source
@@ -918,6 +920,10 @@ struct vfs_open_how {
        uint64_t resolve;
 };
 
+struct vfs_rename_how {
+       int flags;
+};
+
 /*
     Available VFS operations. These values must be in sync with vfs_ops struct
     (struct vfs_fn_pointers and struct vfs_handle_pointers inside of struct vfs_ops).
@@ -1029,7 +1035,8 @@ struct vfs_fn_pointers {
                         struct files_struct *srcdir_fsp,
                         const struct smb_filename *smb_fname_src,
                         struct files_struct *dstdir_fsp,
-                        const struct smb_filename *smb_fname_dst);
+                        const struct smb_filename *smb_fname_dst,
+                        const struct vfs_rename_how *how);
        struct tevent_req *(*fsync_send_fn)(struct vfs_handle_struct *handle,
                                            TALLOC_CTX *mem_ctx,
                                            struct tevent_context *ev,
@@ -1535,7 +1542,8 @@ int smb_vfs_call_renameat(struct vfs_handle_struct *handle,
                        struct files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        struct files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst);
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how);
 
 struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
                                           TALLOC_CTX *mem_ctx,
@@ -1970,7 +1978,8 @@ int vfs_not_implemented_renameat(vfs_handle_struct *handle,
                               files_struct *srcfsp,
                               const struct smb_filename *smb_fname_src,
                               files_struct *dstfsp,
-                              const struct smb_filename *smb_fname_dst);
+                              const struct smb_filename *smb_fname_dst,
+                              const struct vfs_rename_how *how);
 struct tevent_req *vfs_not_implemented_fsync_send(struct vfs_handle_struct *handle,
                                                  TALLOC_CTX *mem_ctx,
                                                  struct tevent_context *ev,
index 9196f6e5e405f26cd8fbed8af77cf841b70fbb38..723fd48635a853f1dd50324e29c5d51354221066 100644 (file)
 #define SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, count) \
        smb_vfs_call_recvfile((handle)->next, (fromfd), (tofsp), (offset), (count))
 
-#define SMB_VFS_RENAMEAT(conn, oldfsp, old, newfsp, new) \
-       smb_vfs_call_renameat((conn)->vfs_handles, (oldfsp), (old), (newfsp), (new))
-#define SMB_VFS_NEXT_RENAMEAT(handle, oldfsp, old, newfsp, new) \
-       smb_vfs_call_renameat((handle)->next, (oldfsp), (old), (newfsp), (new))
+#define SMB_VFS_RENAMEAT(conn, oldfsp, old, newfsp, newname, how) \
+       smb_vfs_call_renameat((conn)->vfs_handles, (oldfsp), (old), (newfsp), (newname), (how))
+#define SMB_VFS_NEXT_RENAMEAT(handle, oldfsp, old, newfsp, newname, how) \
+       smb_vfs_call_renameat((handle)->next, (oldfsp), (old), (newfsp), (newname), (how))
 
 #define SMB_VFS_FSYNC_SEND(mem_ctx, ev, fsp) \
        smb_vfs_call_fsync_send((fsp)->conn->vfs_handles, (mem_ctx), (ev), \
index 2b01a6a8d91ff35b336d2cc528b4ecb12db306fa..50050f8f2574d7f26a9a62e1a85b339917add614 100644 (file)
@@ -246,7 +246,8 @@ static int audit_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        struct smb_filename *full_fname_src = NULL;
        struct smb_filename *full_fname_dst = NULL;
@@ -272,7 +273,8 @@ static int audit_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
        if (result == -1) {
                saved_errno = errno;
        }
index 3553e118cc2cfcd6fce559e8bbe45ba71ff56885..83792d59fb506410876aab2d86a77a3106c12d97 100644 (file)
@@ -192,7 +192,8 @@ static int cap_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        char *capold = NULL;
        char *capnew = NULL;
@@ -245,7 +246,8 @@ static int cap_renameat(vfs_handle_struct *handle,
                                srcfsp->conn->cwd_fsp,
                                smb_fname_src_tmp,
                                dstfsp->conn->cwd_fsp,
-                               smb_fname_dst_tmp);
+                               smb_fname_dst_tmp,
+                               how);
 
  out:
 
index 36aa43123fd4c510a0ba511ae6e9a36442115803..935d978d7a303bae680f5750c77950c75764e6b3 100644 (file)
@@ -541,7 +541,8 @@ static int catia_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        TALLOC_CTX *ctx = talloc_tos();
        struct smb_filename *smb_fname_src_tmp = NULL;
@@ -591,7 +592,8 @@ static int catia_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        smb_fname_src_tmp,
                        dstfsp,
-                       smb_fname_dst_tmp);
+                       smb_fname_dst_tmp,
+                       how);
 
 out:
        TALLOC_FREE(src_name_mapped);
index 20e1c204f18ea9f1203786fda6f3b11b4a829c31..26b51ac78c583381b1901d1eae95abb97b256ea5 100644 (file)
@@ -713,7 +713,8 @@ static int cephwrap_renameat(struct vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        struct smb_filename *full_fname_src = NULL;
        struct smb_filename *full_fname_dst = NULL;
@@ -725,6 +726,11 @@ static int cephwrap_renameat(struct vfs_handle_struct *handle,
                return result;
        }
 
+       if (how->flags != 0) {
+               errno = EINVAL;
+               return -1;
+       }
+
        full_fname_src = full_path_from_dirfsp_atname(talloc_tos(),
                                                  srcfsp,
                                                  smb_fname_src);
index 25e78444fb53f60a73c28b0d0051740153bfc09c..18506e68f070d0fe83cbd8d5f030b45caae36fd9 100644 (file)
@@ -1874,7 +1874,8 @@ static int vfs_ceph_renameat(struct vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        struct vfs_ceph_fh *src_dircfh = NULL;
        struct vfs_ceph_fh *dst_dircfh = NULL;
@@ -1886,6 +1887,11 @@ static int vfs_ceph_renameat(struct vfs_handle_struct *handle,
                return result;
        }
 
+       if (how->flags != 0) {
+               errno = EINVAL;
+               return -1;
+       }
+
        result = vfs_ceph_fetch_fh(handle, srcfsp, &src_dircfh);
        if (result != 0) {
                goto out;
index 98b8f5f6b5d9744ad069cf9cc0ba57f18d97232d..9514b489237050cebae894935da08f1a4024db8f 100644 (file)
@@ -753,7 +753,8 @@ static int ceph_snap_gmt_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        int ret;
        time_t timestamp_src, timestamp_dst;
@@ -784,7 +785,8 @@ static int ceph_snap_gmt_renameat(vfs_handle_struct *handle,
                                srcfsp,
                                smb_fname_src,
                                dstfsp,
-                               smb_fname_dst);
+                               smb_fname_dst,
+                               how);
 }
 
 /* block links from writeable shares to snapshots for now, like other modules */
index 042144bfc4df9264a0f968fd9ca1a5c413316bf6..79f13c28da59ec2446fb47e10f63d35090baf972 100644 (file)
@@ -144,7 +144,8 @@ static int crossrename_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        int result = -1;
 
@@ -159,7 +160,8 @@ static int crossrename_renameat(vfs_handle_struct *handle,
                                       srcfsp,
                                       smb_fname_src,
                                       dstfsp,
-                                      smb_fname_dst);
+                                      smb_fname_dst,
+                                      how);
 
        if ((result == -1) && (errno == EXDEV)) {
                /* Rename across filesystems needed. */
index eac64f28326e7789748d32b3ee02b01d882c230e..ec46596ac6280f07d02b0448a8748abdc7b92d98 100644 (file)
@@ -1287,7 +1287,8 @@ static int vfswrap_renameat(vfs_handle_struct *handle,
                          files_struct *srcfsp,
                          const struct smb_filename *smb_fname_src,
                          files_struct *dstfsp,
-                         const struct smb_filename *smb_fname_dst)
+                         const struct smb_filename *smb_fname_dst,
+                         const struct vfs_rename_how *how)
 {
        int result = -1;
 
@@ -1296,6 +1297,12 @@ static int vfswrap_renameat(vfs_handle_struct *handle,
        SMB_ASSERT(!is_named_stream(smb_fname_src));
        SMB_ASSERT(!is_named_stream(smb_fname_dst));
 
+       if (how->flags != 0) {
+               END_PROFILE(syscall_renameat);
+               errno = EINVAL;
+               return -1;
+       }
+
        result = renameat(fsp_get_pathref_fd(srcfsp),
                        smb_fname_src->base_name,
                        fsp_get_pathref_fd(dstfsp),
index ea784ff6eba99da531212c4402bd0a220dbd18e7..c12c24adbb16c461ae896ef590480b67885ae43e 100644 (file)
@@ -277,7 +277,8 @@ static int audit_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        struct smb_filename *full_fname_src = NULL;
        struct smb_filename *full_fname_dst = NULL;
@@ -305,7 +306,8 @@ static int audit_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
        if (result == -1) {
                saved_errno = errno;
        }
index c3867f8b2f429efaabcdf7f05bfd050b52f56e88..f8b12c09594531263d2c4a62a2f2b10033683c6f 100644 (file)
@@ -1895,7 +1895,8 @@ static int fruit_renameat(struct vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        int rc = -1;
        struct fruit_config_data *config = NULL;
@@ -1915,7 +1916,8 @@ static int fruit_renameat(struct vfs_handle_struct *handle,
                                srcfsp,
                                smb_fname_src,
                                dstfsp,
-                               smb_fname_dst);
+                               smb_fname_dst,
+                               how);
        if (rc != 0) {
                return -1;
        }
@@ -1944,7 +1946,8 @@ static int fruit_renameat(struct vfs_handle_struct *handle,
                        srcfsp,
                        src_adp_smb_fname,
                        dstfsp,
-                       dst_adp_smb_fname);
+                       dst_adp_smb_fname,
+                       how);
        if (errno == ENOENT) {
                rc = 0;
        }
index 9fd8a7515720eec4a3ad229d180991190ec93f42..187e6dd76c9e361c1d5aef89ea763211c548312b 100644 (file)
@@ -1402,7 +1402,8 @@ static int smb_full_audit_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *smb_fname_src,
                                files_struct *dstfsp,
-                               const struct smb_filename *smb_fname_dst)
+                               const struct smb_filename *smb_fname_dst,
+                               const struct vfs_rename_how *how)
 {
        int result;
        int saved_errno;
@@ -1429,7 +1430,8 @@ static int smb_full_audit_renameat(vfs_handle_struct *handle,
                                srcfsp,
                                smb_fname_src,
                                dstfsp,
-                               smb_fname_dst);
+                               smb_fname_dst,
+                               how);
 
        if (result == -1) {
                saved_errno = errno;
index 5729766a8d762519241633432a6562f1b22a405d..2ac978eed8cc874f05874351347cbc31a5fdfd6a 100644 (file)
@@ -1231,7 +1231,8 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        int ret;
 
@@ -1241,6 +1242,12 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
 
        START_PROFILE(syscall_renameat);
 
+       if (how->flags != 0) {
+               END_PROFILE(syscall_renameat);
+               errno = EINVAL;
+               return -1;
+       }
+
        src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp);
        if (src_pglfd == NULL) {
                END_PROFILE(syscall_renameat);
@@ -1263,6 +1270,12 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
 
        START_PROFILE(syscall_renameat);
 
+       if (how->flags != 0) {
+               END_PROFILE(syscall_renameat);
+               errno = EINVAL;
+               return -1;
+       }
+
        full_fname_src = full_path_from_dirfsp_atname(talloc_tos(),
                                                      srcfsp,
                                                      smb_fname_src);
index a027254c6b384d986af5e638d3f37062987108fa..10406f556fb8cd29d8518b04192e79be0a222448 100644 (file)
@@ -1195,7 +1195,8 @@ static int mh_renameat(vfs_handle_struct *handle,
                files_struct *srcfsp,
                const struct smb_filename *smb_fname_src,
                files_struct *dstfsp,
-               const struct smb_filename *smb_fname_dst)
+               const struct smb_filename *smb_fname_dst,
+               const struct vfs_rename_how *how)
 {
        int status = -1;
        struct smb_filename *full_fname_src = NULL;
@@ -1217,7 +1218,8 @@ static int mh_renameat(vfs_handle_struct *handle,
                                srcfsp,
                                smb_fname_src,
                                dstfsp,
-                               smb_fname_dst);
+                               smb_fname_dst,
+                               how);
                goto out;
        }
 
@@ -1256,7 +1258,8 @@ static int mh_renameat(vfs_handle_struct *handle,
                                srcfsp->conn->cwd_fsp,
                                srcClientFname,
                                dstfsp->conn->cwd_fsp,
-                               dstClientFname);
+                               dstClientFname,
+                               how);
 err:
        TALLOC_FREE(full_fname_src);
        TALLOC_FREE(full_fname_dst);
index b00a4993bc5ff5d906d2833b576bac2f973a7b36..9481e11f53eba856f56bacc14e6d70dcd12b4f0d 100644 (file)
@@ -318,10 +318,11 @@ ssize_t vfs_not_implemented_recvfile(vfs_handle_struct *handle, int fromfd,
 
 _PUBLIC_
 int vfs_not_implemented_renameat(vfs_handle_struct *handle,
-                              files_struct *srcfsp,
-                              const struct smb_filename *smb_fname_src,
-                              files_struct *dstfsp,
-                              const struct smb_filename *smb_fname_dst)
+                                files_struct *srcfsp,
+                                const struct smb_filename *smb_fname_src,
+                                files_struct *dstfsp,
+                                const struct smb_filename *smb_fname_dst,
+                                const struct vfs_rename_how *how)
 {
        errno = ENOSYS;
        return -1;
index ea0417d96498e30c9b1f344c4d1ad175c582db1b..9c0020a8dbe02b1a4da55d47cc4f45adc76e1487 100644 (file)
@@ -487,6 +487,7 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
        bool exist;
        int rc = -1;
        struct recycle_config_data *config = NULL;
+       struct vfs_rename_how rhow = { .flags = 0, };
 
        SMB_VFS_HANDLE_GET_DATA(handle,
                                config,
@@ -706,7 +707,8 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
                        dirfsp,
                        smb_fname,
                        handle->conn->cwd_fsp,
-                       smb_fname_final);
+                       smb_fname_final,
+                       &rhow);
        if (rc != 0) {
                DEBUG(3, ("recycle: Move error %d (%s), purging file %s "
                          "(%s)\n", errno, strerror(errno),
index 9d3f5843f43f1ee7210028db25d92646b27ffe47..b91d5c8242f142257d19167a9cfd94486f964eef 100644 (file)
@@ -1027,7 +1027,8 @@ static int shadow_copy2_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *smb_fname_src,
                                files_struct *dstfsp,
-                               const struct smb_filename *smb_fname_dst)
+                               const struct smb_filename *smb_fname_dst,
+                               const struct vfs_rename_how *how)
 {
        time_t timestamp_src = 0;
        time_t timestamp_dst = 0;
@@ -1069,7 +1070,8 @@ static int shadow_copy2_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
 }
 
 static int shadow_copy2_symlinkat(vfs_handle_struct *handle,
index f12a94befd61c9ed04852c0cbe07055ec52b0791..566d574f0bea3e18bb94100f3ee627f09c1af28b 100644 (file)
@@ -1905,7 +1905,8 @@ static int snapper_gmt_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        time_t timestamp_src, timestamp_dst;
 
@@ -1931,7 +1932,8 @@ static int snapper_gmt_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
 }
 
 static int snapper_gmt_symlinkat(vfs_handle_struct *handle,
index 1221b2c2be220d2c28c92d5b9aa9c8dd9dee7104..566d34996c1fa830edfb1eb1affdb9feb7893a06 100644 (file)
@@ -165,6 +165,7 @@ static char *stream_dir(vfs_handle_struct *handle,
        char *rootdir = NULL;
        struct smb_filename *rootdir_fname = NULL;
        struct smb_filename *tmp_fname = NULL;
+       struct vfs_rename_how rhow = { .flags = 0, };
        int ret;
 
        check_valid = lp_parm_bool(SNUM(handle->conn),
@@ -310,11 +311,13 @@ static char *stream_dir(vfs_handle_struct *handle,
                                goto fail;
                        }
 
-                       if (SMB_VFS_NEXT_RENAMEAT(handle,
+                       ret = SMB_VFS_NEXT_RENAMEAT(handle,
                                        handle->conn->cwd_fsp,
                                        smb_fname_hash,
                                        handle->conn->cwd_fsp,
-                                       smb_fname_new) == -1) {
+                                       smb_fname_new,
+                                       &rhow);
+                       if (ret == -1) {
                                TALLOC_FREE(smb_fname_new);
                                if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
                                        goto again;
@@ -962,7 +965,8 @@ static int streams_depot_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *smb_fname_src,
                                files_struct *dstfsp,
-                               const struct smb_filename *smb_fname_dst)
+                               const struct smb_filename *smb_fname_dst,
+                               const struct vfs_rename_how *how)
 {
        struct smb_filename *smb_fname_src_stream = NULL;
        struct smb_filename *smb_fname_dst_stream = NULL;
@@ -984,7 +988,13 @@ static int streams_depot_renameat(vfs_handle_struct *handle,
                                        srcfsp,
                                        smb_fname_src,
                                        dstfsp,
-                                       smb_fname_dst);
+                                       smb_fname_dst,
+                                       how);
+       }
+
+       if (how->flags != 0) {
+               errno = EINVAL;
+               goto done;
        }
 
        /* for now don't allow renames from or to the default stream */
@@ -1035,7 +1045,8 @@ static int streams_depot_renameat(vfs_handle_struct *handle,
                                handle->conn->cwd_fsp,
                                smb_fname_src_stream,
                                handle->conn->cwd_fsp,
-                               smb_fname_dst_stream);
+                               smb_fname_dst_stream,
+                               how);
 
 done:
        TALLOC_FREE(smb_fname_src_stream);
index 03ff6147cb030bd56829670bbdc72f8c22fd5ba4..4cc69b42a8ad2ac5bbf4c73387550d5867a5e3ea 100644 (file)
@@ -537,7 +537,8 @@ static int streams_xattr_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *smb_fname_src,
                                files_struct *dstfsp,
-                               const struct smb_filename *smb_fname_dst)
+                               const struct smb_filename *smb_fname_dst,
+                               const struct vfs_rename_how *how)
 {
        NTSTATUS status;
        int ret = -1;
@@ -560,7 +561,13 @@ static int streams_xattr_renameat(vfs_handle_struct *handle,
                                        srcfsp,
                                        smb_fname_src,
                                        dstfsp,
-                                       smb_fname_dst);
+                                       smb_fname_dst,
+                                       how);
+       }
+
+       if (how->flags != 0) {
+               errno = EINVAL;
+               goto done;
        }
 
        /* For now don't allow renames from or to the default stream. */
index a0d9809329683a6c94866e54b5b6944d233f3b9e..a909e2162f55d910209525d332f9f3826826640b 100644 (file)
@@ -144,7 +144,8 @@ static int syncops_renameat(vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
 
        int ret;
@@ -160,7 +161,8 @@ static int syncops_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
        if (ret == -1) {
                return ret;
        }
index 59bc68861b46645cc173d06a10970670c6193456..856486bc5c4c9dae65c0fb0ffbfe3ca916f5968f 100644 (file)
@@ -918,7 +918,8 @@ static int smb_time_audit_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *oldname,
                                files_struct *dstfsp,
-                               const struct smb_filename *newname)
+                               const struct smb_filename *newname,
+                               const struct vfs_rename_how *how)
 {
        int result;
        struct timespec ts1,ts2;
@@ -937,7 +938,8 @@ static int smb_time_audit_renameat(vfs_handle_struct *handle,
                        srcfsp,
                        oldname,
                        dstfsp,
-                       newname);
+                       newname,
+                       how);
        clock_gettime_mono(&ts2);
        timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;
 
index c848cf5f623b93d6f00610c2e81154435451f643..cf1447e8325f124e1aa35e0e4ba95a50eaf9a189 100644 (file)
@@ -926,7 +926,8 @@ static int um_renameat(vfs_handle_struct *handle,
                files_struct *srcfsp,
                const struct smb_filename *smb_fname_src,
                files_struct *dstfsp,
-               const struct smb_filename *smb_fname_dst)
+               const struct smb_filename *smb_fname_dst,
+               const struct vfs_rename_how *how)
 {
        int status;
        struct smb_filename *src_full_fname = NULL;
@@ -965,7 +966,8 @@ static int um_renameat(vfs_handle_struct *handle,
                                        srcfsp,
                                        smb_fname_src,
                                        dstfsp,
-                                       smb_fname_dst);
+                                       smb_fname_dst,
+                                       how);
        }
 
        status = alloc_get_client_smb_fname(handle, talloc_tos(),
@@ -987,7 +989,8 @@ static int um_renameat(vfs_handle_struct *handle,
                                handle->conn->cwd_fsp,
                                src_client_fname,
                                handle->conn->cwd_fsp,
-                               dst_client_fname);
+                               dst_client_fname,
+                               how);
 
 err:
        TALLOC_FREE(dst_client_fname);
index b566b628ed2fe4e5be90077a4dd7575b77a4bc69..c0cf9ff78db598d5dcf04e4281e98f291c2aacd4 100644 (file)
@@ -1592,13 +1592,15 @@ static int virusfilter_vfs_renameat(
        files_struct *srcfsp,
        const struct smb_filename *smb_fname_src,
        files_struct *dstfsp,
-       const struct smb_filename *smb_fname_dst)
+       const struct smb_filename *smb_fname_dst,
+       const struct vfs_rename_how *how)
 {
        int ret = SMB_VFS_NEXT_RENAMEAT(handle,
                        srcfsp,
                        smb_fname_src,
                        dstfsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       how);
        struct virusfilter_config *config = NULL;
        char *fname = NULL;
        char *dst_fname = NULL;
index b4677799c50b77e9e744a3a4ed3c2b9036c18831..1ad31b8d32ca2002f4b7fca4793df5a5df31f322 100644 (file)
@@ -55,12 +55,14 @@ int virusfilter_vfs_next_move(
        const struct smb_filename *smb_fname_dst)
 {
        int result;
+       struct vfs_rename_how rhow = { .flags = 0, };
 
        result = SMB_VFS_NEXT_RENAMEAT(vfs_h,
                        vfs_h->conn->cwd_fsp,
                        smb_fname_src,
                        vfs_h->conn->cwd_fsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       &rhow);
        if (result == 0 || errno != EXDEV) {
                return result;
        }
index 5c1bc6da650f79463d46241f21716d9325d85cd3..0fcda162cd7406d93e80a8709f5fa6bc51feb55d 100644 (file)
@@ -215,7 +215,8 @@ static int vfs_worm_renameat(vfs_handle_struct *handle,
                             files_struct *srcfsp,
                             const struct smb_filename *smb_fname_src,
                             files_struct *dstfsp,
-                            const struct smb_filename *smb_fname_dst)
+                            const struct smb_filename *smb_fname_dst,
+                            const struct vfs_rename_how *how)
 {
        if (is_readonly(handle, smb_fname_src)) {
                errno = EACCES;
@@ -223,7 +224,7 @@ static int vfs_worm_renameat(vfs_handle_struct *handle,
        }
 
        return SMB_VFS_NEXT_RENAMEAT(
-               handle, srcfsp, smb_fname_src, dstfsp, smb_fname_dst);
+               handle, srcfsp, smb_fname_src, dstfsp, smb_fname_dst, how);
 }
 
 static int vfs_worm_fsetxattr(struct vfs_handle_struct *handle,
index 108a22caa441117c8ba84fe7ea91eae0645946f4..cba43d1a1cd18084c52b93fc7246b308e9df7f7c 100644 (file)
@@ -4681,6 +4681,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
        struct server_id_buf idbuf;
        char *idstr = server_id_str_buf_unique_ex(id, '%', &idbuf);
        struct vfs_open_how how = { .flags = O_RDONLY|O_DIRECTORY, };
+       struct vfs_rename_how rhow = { .flags = 0, };
        int ret;
 
        if (!CAN_WRITE(conn) || (access_mask & ~(conn->share_access))) {
@@ -4933,7 +4934,8 @@ mkdir_first:
                                       parent_dir_fname->fsp,
                                       tmp_atname,
                                       parent_dir_fname->fsp,
-                                      smb_fname_atname);
+                                      smb_fname_atname,
+                                      &rhow);
        }
 
        if (ret != 0) {
index 1248c6f0a75034a995172913fbb024e448c974e3..ab8b989c0a54315ebbb22f9da05fdc5635b06afa 100644 (file)
@@ -1417,6 +1417,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                                true : conn->case_sensitive;
        bool case_preserve = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
                                true : conn->case_preserve;
+       struct vfs_rename_how rhow = { .flags = 0, };
 
        status = parent_dirname_compatible_open(conn, smb_fname_dst_in);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1757,7 +1758,8 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                        parent_dir_fname_src->fsp,
                        parent_dir_fname_src_atname,
                        parent_dir_fname_dst->fsp,
-                       parent_dir_fname_dst_atname);
+                       parent_dir_fname_dst_atname,
+                       &rhow);
        if (ret == 0) {
                uint32_t create_options = fh_get_private_options(fsp->fh);
 
index 13b3ba61ceac49223f0694fee26f3c5d92b612c1..fe90d30f45f9e3c57dfdce4554c355c468746954 100644 (file)
@@ -1721,14 +1721,16 @@ int smb_vfs_call_renameat(struct vfs_handle_struct *handle,
                        files_struct *srcfsp,
                        const struct smb_filename *smb_fname_src,
                        files_struct *dstfsp,
-                       const struct smb_filename *smb_fname_dst)
+                       const struct smb_filename *smb_fname_dst,
+                       const struct vfs_rename_how *how)
 {
        VFS_FIND(renameat);
        return handle->fns->renameat_fn(handle,
                                srcfsp,
                                smb_fname_src,
                                dstfsp,
-                               smb_fname_dst);
+                               smb_fname_dst,
+                               how);
 }
 
 struct smb_vfs_call_fsync_state {
index 95b1e21a22f5d63d12fa32d7ec4e747287cfd548..d9b921b01e80040595e605a90d9d753873889883 100644 (file)
@@ -675,6 +675,7 @@ static NTSTATUS cmd_rename(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
        int ret;
        struct smb_filename *smb_fname_src = NULL;
        struct smb_filename *smb_fname_dst = NULL;
+       struct vfs_rename_how rhow = { .flags = 0, };
 
        if (argc != 3) {
                printf("Usage: rename <old> <new>\n");
@@ -700,7 +701,8 @@ static NTSTATUS cmd_rename(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
                        vfs->conn->cwd_fsp,
                        smb_fname_src,
                        vfs->conn->cwd_fsp,
-                       smb_fname_dst);
+                       smb_fname_dst,
+                       &rhow);
 
        TALLOC_FREE(smb_fname_src);
        TALLOC_FREE(smb_fname_dst);