From: Jeremy Allison Date: Fri, 9 Aug 2019 22:03:44 +0000 (-0700) Subject: s3: VFS: vfs_netatalk. Implement renameat(). X-Git-Tag: tdb-1.4.2~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9193cd402ff33caa853f341b90c7a9e25ebb5785;p=thirdparty%2Fsamba.git s3: VFS: vfs_netatalk. Implement renameat(). Currently identical to rename(). Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_netatalk.c b/source3/modules/vfs_netatalk.c index ebdf8d249b6..14ace3b67fd 100644 --- a/source3/modules/vfs_netatalk.c +++ b/source3/modules/vfs_netatalk.c @@ -296,6 +296,52 @@ exit_rename: return ret; } +static int atalk_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) +{ + int ret = 0; + char *oldname = NULL; + char *adbl_path = NULL; + char *orig_path = NULL; + SMB_STRUCT_STAT adbl_info; + SMB_STRUCT_STAT orig_info; + NTSTATUS status; + + ret = SMB_VFS_NEXT_RENAMEAT(handle, + srcfsp, + smb_fname_src, + dstfsp, + smb_fname_dst); + + status = get_full_smb_filename(talloc_tos(), smb_fname_src, &oldname); + if (!NT_STATUS_IS_OK(status)) { + return ret; + } + + if (atalk_build_paths(talloc_tos(), + handle->conn->cwd_fsp->fsp_name->base_name, + oldname, + &adbl_path, &orig_path, &adbl_info, + &orig_info) != 0) + goto exit_renameat; + + if (S_ISDIR(orig_info.st_ex_mode) || S_ISREG(orig_info.st_ex_mode)) { + DEBUG(3, ("ATALK: %s has passed..\n", adbl_path)); + goto exit_renameat; + } + + atalk_unlink_file(adbl_path); + +exit_renameat: + TALLOC_FREE(oldname); + TALLOC_FREE(adbl_path); + TALLOC_FREE(orig_path); + return ret; +} + static int atalk_unlink(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname) { @@ -477,6 +523,7 @@ static struct vfs_fn_pointers vfs_netatalk_fns = { .fdopendir_fn = atalk_fdopendir, .rmdir_fn = atalk_rmdir, .rename_fn = atalk_rename, + .renameat_fn = atalk_renameat, .unlink_fn = atalk_unlink, .chmod_fn = atalk_chmod, .chown_fn = atalk_chown,