s3: VFS: vfs_unityed_media. Implement renameat().
authorJeremy Allison <jra@samba.org>
Fri, 9 Aug 2019 22:36:52 +0000 (15:36 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 16 Aug 2019 19:52:34 +0000 (19:52 +0000)
Currently identical to rename().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_unityed_media.c

index cc531d46701e15e19e1a1b21601ddc4ffd30182b..27c6e5cb8285e28977013d95d67f13009ead4eec 100644 (file)
@@ -1040,6 +1040,64 @@ err:
        return status;
 }
 
+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)
+{
+       int status;
+       struct smb_filename *src_client_fname = NULL;
+       struct smb_filename *dst_client_fname = NULL;
+
+       DEBUG(10, ("Entering with "
+                  "smb_fname_src->base_name '%s', "
+                  "smb_fname_dst->base_name '%s'\n",
+                  smb_fname_src->base_name,
+                  smb_fname_dst->base_name));
+
+       if (!is_in_media_files(smb_fname_src->base_name)
+           &&
+           !is_in_media_files(smb_fname_dst->base_name)) {
+               return SMB_VFS_NEXT_RENAMEAT(handle,
+                                       srcfsp,
+                                       smb_fname_src,
+                                       dstfsp,
+                                       smb_fname_dst);
+       }
+
+       status = alloc_get_client_smb_fname(handle, talloc_tos(),
+                                           smb_fname_src,
+                                           &src_client_fname);
+       if (status != 0) {
+               goto err;
+       }
+
+       status = alloc_get_client_smb_fname(handle, talloc_tos(),
+                                           smb_fname_dst,
+                                           &dst_client_fname);
+
+       if (status != 0) {
+               goto err;
+       }
+
+       status = SMB_VFS_NEXT_RENAMEAT(handle,
+                               srcfsp,
+                               src_client_fname,
+                               dstfsp,
+                               dst_client_fname);
+
+err:
+       TALLOC_FREE(dst_client_fname);
+       TALLOC_FREE(src_client_fname);
+       DEBUG(10, ("Leaving with smb_fname_src->base_name '%s',"
+                  " smb_fname_dst->base_name '%s'\n",
+                  smb_fname_src->base_name,
+                  smb_fname_dst->base_name));
+       return status;
+}
+
+
 /*
  * Success: return 0
  * Failure: set errno, return -1
@@ -1882,6 +1940,7 @@ static struct vfs_fn_pointers vfs_um_fns = {
        .open_fn = um_open,
        .create_file_fn = um_create_file,
        .rename_fn = um_rename,
+       .renameat_fn = um_renameat,
        .stat_fn = um_stat,
        .lstat_fn = um_lstat,
        .fstat_fn = um_fstat,