1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

s3:vfs: add vfs_rename_how to SMB_VFS_RENAMEAT()

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>
This commit is contained in:
Stefan Metzmacher 2024-08-06 13:21:34 +02:00
parent f6550e804e
commit 5b305d1fbb
33 changed files with 177 additions and 68 deletions

View File

@ -298,7 +298,8 @@ static int skel_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; errno = ENOSYS;
return -1; return -1;

View File

@ -384,13 +384,15 @@ static int skel_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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, return SMB_VFS_NEXT_RENAMEAT(handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
} }
struct skel_fsync_state { struct skel_fsync_state {

View File

@ -381,9 +381,11 @@
* Change to Version 49 - will ship with 4.19 * Change to Version 49 - will ship with 4.19
* Version 49 - remove seekdir and telldir * Version 49 - remove seekdir and telldir
* Version 49 - remove "sbuf" argument from readdir_fn() * 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 All intercepted VFS operations must be declared as static functions inside module source
@ -918,6 +920,10 @@ struct vfs_open_how {
uint64_t resolve; uint64_t resolve;
}; };
struct vfs_rename_how {
int flags;
};
/* /*
Available VFS operations. These values must be in sync with vfs_ops struct 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). (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, struct files_struct *srcdir_fsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
struct files_struct *dstdir_fsp, 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, struct tevent_req *(*fsync_send_fn)(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx,
struct tevent_context *ev, struct tevent_context *ev,
@ -1535,7 +1542,8 @@ int smb_vfs_call_renameat(struct vfs_handle_struct *handle,
struct files_struct *srcfsp, struct files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
struct files_struct *dstfsp, 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, struct tevent_req *smb_vfs_call_fsync_send(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx,
@ -1970,7 +1978,8 @@ int vfs_not_implemented_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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, struct tevent_req *vfs_not_implemented_fsync_send(struct vfs_handle_struct *handle,
TALLOC_CTX *mem_ctx, TALLOC_CTX *mem_ctx,
struct tevent_context *ev, struct tevent_context *ev,

View File

@ -194,10 +194,10 @@
#define SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, count) \ #define SMB_VFS_NEXT_RECVFILE(handle, fromfd, tofsp, offset, count) \
smb_vfs_call_recvfile((handle)->next, (fromfd), (tofsp), (offset), (count)) smb_vfs_call_recvfile((handle)->next, (fromfd), (tofsp), (offset), (count))
#define SMB_VFS_RENAMEAT(conn, oldfsp, old, newfsp, new) \ #define SMB_VFS_RENAMEAT(conn, oldfsp, old, newfsp, newname, how) \
smb_vfs_call_renameat((conn)->vfs_handles, (oldfsp), (old), (newfsp), (new)) smb_vfs_call_renameat((conn)->vfs_handles, (oldfsp), (old), (newfsp), (newname), (how))
#define SMB_VFS_NEXT_RENAMEAT(handle, oldfsp, old, newfsp, new) \ #define SMB_VFS_NEXT_RENAMEAT(handle, oldfsp, old, newfsp, newname, how) \
smb_vfs_call_renameat((handle)->next, (oldfsp), (old), (newfsp), (new)) smb_vfs_call_renameat((handle)->next, (oldfsp), (old), (newfsp), (newname), (how))
#define SMB_VFS_FSYNC_SEND(mem_ctx, ev, fsp) \ #define SMB_VFS_FSYNC_SEND(mem_ctx, ev, fsp) \
smb_vfs_call_fsync_send((fsp)->conn->vfs_handles, (mem_ctx), (ev), \ smb_vfs_call_fsync_send((fsp)->conn->vfs_handles, (mem_ctx), (ev), \

View File

@ -246,7 +246,8 @@ static int audit_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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_src = NULL;
struct smb_filename *full_fname_dst = NULL; struct smb_filename *full_fname_dst = NULL;
@ -272,7 +273,8 @@ static int audit_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
if (result == -1) { if (result == -1) {
saved_errno = errno; saved_errno = errno;
} }

View File

@ -192,7 +192,8 @@ static int cap_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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 *capold = NULL;
char *capnew = NULL; char *capnew = NULL;
@ -245,7 +246,8 @@ static int cap_renameat(vfs_handle_struct *handle,
srcfsp->conn->cwd_fsp, srcfsp->conn->cwd_fsp,
smb_fname_src_tmp, smb_fname_src_tmp,
dstfsp->conn->cwd_fsp, dstfsp->conn->cwd_fsp,
smb_fname_dst_tmp); smb_fname_dst_tmp,
how);
out: out:

View File

@ -541,7 +541,8 @@ static int catia_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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(); TALLOC_CTX *ctx = talloc_tos();
struct smb_filename *smb_fname_src_tmp = NULL; struct smb_filename *smb_fname_src_tmp = NULL;
@ -591,7 +592,8 @@ static int catia_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src_tmp, smb_fname_src_tmp,
dstfsp, dstfsp,
smb_fname_dst_tmp); smb_fname_dst_tmp,
how);
out: out:
TALLOC_FREE(src_name_mapped); TALLOC_FREE(src_name_mapped);

View File

@ -713,7 +713,8 @@ static int cephwrap_renameat(struct vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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_src = NULL;
struct smb_filename *full_fname_dst = NULL; struct smb_filename *full_fname_dst = NULL;
@ -725,6 +726,11 @@ static int cephwrap_renameat(struct vfs_handle_struct *handle,
return result; return result;
} }
if (how->flags != 0) {
errno = EINVAL;
return -1;
}
full_fname_src = full_path_from_dirfsp_atname(talloc_tos(), full_fname_src = full_path_from_dirfsp_atname(talloc_tos(),
srcfsp, srcfsp,
smb_fname_src); smb_fname_src);

View File

@ -1874,7 +1874,8 @@ static int vfs_ceph_renameat(struct vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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 *src_dircfh = NULL;
struct vfs_ceph_fh *dst_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; return result;
} }
if (how->flags != 0) {
errno = EINVAL;
return -1;
}
result = vfs_ceph_fetch_fh(handle, srcfsp, &src_dircfh); result = vfs_ceph_fetch_fh(handle, srcfsp, &src_dircfh);
if (result != 0) { if (result != 0) {
goto out; goto out;

View File

@ -753,7 +753,8 @@ static int ceph_snap_gmt_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int ret;
time_t timestamp_src, timestamp_dst; time_t timestamp_src, timestamp_dst;
@ -784,7 +785,8 @@ static int ceph_snap_gmt_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
} }
/* block links from writeable shares to snapshots for now, like other modules */ /* block links from writeable shares to snapshots for now, like other modules */

View File

@ -144,7 +144,8 @@ static int crossrename_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int result = -1;
@ -159,7 +160,8 @@ static int crossrename_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
if ((result == -1) && (errno == EXDEV)) { if ((result == -1) && (errno == EXDEV)) {
/* Rename across filesystems needed. */ /* Rename across filesystems needed. */

View File

@ -1287,7 +1287,8 @@ static int vfswrap_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; 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_src));
SMB_ASSERT(!is_named_stream(smb_fname_dst)); 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), result = renameat(fsp_get_pathref_fd(srcfsp),
smb_fname_src->base_name, smb_fname_src->base_name,
fsp_get_pathref_fd(dstfsp), fsp_get_pathref_fd(dstfsp),

View File

@ -277,7 +277,8 @@ static int audit_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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_src = NULL;
struct smb_filename *full_fname_dst = NULL; struct smb_filename *full_fname_dst = NULL;
@ -305,7 +306,8 @@ static int audit_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
if (result == -1) { if (result == -1) {
saved_errno = errno; saved_errno = errno;
} }

View File

@ -1895,7 +1895,8 @@ static int fruit_renameat(struct vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int rc = -1;
struct fruit_config_data *config = NULL; struct fruit_config_data *config = NULL;
@ -1915,7 +1916,8 @@ static int fruit_renameat(struct vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
if (rc != 0) { if (rc != 0) {
return -1; return -1;
} }
@ -1944,7 +1946,8 @@ static int fruit_renameat(struct vfs_handle_struct *handle,
srcfsp, srcfsp,
src_adp_smb_fname, src_adp_smb_fname,
dstfsp, dstfsp,
dst_adp_smb_fname); dst_adp_smb_fname,
how);
if (errno == ENOENT) { if (errno == ENOENT) {
rc = 0; rc = 0;
} }

View File

@ -1402,7 +1402,8 @@ static int smb_full_audit_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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 result;
int saved_errno; int saved_errno;
@ -1429,7 +1430,8 @@ static int smb_full_audit_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
if (result == -1) { if (result == -1) {
saved_errno = errno; saved_errno = errno;

View File

@ -1231,7 +1231,8 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int ret;
@ -1241,6 +1242,12 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
START_PROFILE(syscall_renameat); START_PROFILE(syscall_renameat);
if (how->flags != 0) {
END_PROFILE(syscall_renameat);
errno = EINVAL;
return -1;
}
src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp); src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp);
if (src_pglfd == NULL) { if (src_pglfd == NULL) {
END_PROFILE(syscall_renameat); END_PROFILE(syscall_renameat);
@ -1263,6 +1270,12 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
START_PROFILE(syscall_renameat); 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(), full_fname_src = full_path_from_dirfsp_atname(talloc_tos(),
srcfsp, srcfsp,
smb_fname_src); smb_fname_src);

View File

@ -1195,7 +1195,8 @@ static int mh_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int status = -1;
struct smb_filename *full_fname_src = NULL; struct smb_filename *full_fname_src = NULL;
@ -1217,7 +1218,8 @@ static int mh_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
goto out; goto out;
} }
@ -1256,7 +1258,8 @@ static int mh_renameat(vfs_handle_struct *handle,
srcfsp->conn->cwd_fsp, srcfsp->conn->cwd_fsp,
srcClientFname, srcClientFname,
dstfsp->conn->cwd_fsp, dstfsp->conn->cwd_fsp,
dstClientFname); dstClientFname,
how);
err: err:
TALLOC_FREE(full_fname_src); TALLOC_FREE(full_fname_src);
TALLOC_FREE(full_fname_dst); TALLOC_FREE(full_fname_dst);

View File

@ -318,10 +318,11 @@ ssize_t vfs_not_implemented_recvfile(vfs_handle_struct *handle, int fromfd,
_PUBLIC_ _PUBLIC_
int vfs_not_implemented_renameat(vfs_handle_struct *handle, int vfs_not_implemented_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; errno = ENOSYS;
return -1; return -1;

View File

@ -487,6 +487,7 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
bool exist; bool exist;
int rc = -1; int rc = -1;
struct recycle_config_data *config = NULL; struct recycle_config_data *config = NULL;
struct vfs_rename_how rhow = { .flags = 0, };
SMB_VFS_HANDLE_GET_DATA(handle, SMB_VFS_HANDLE_GET_DATA(handle,
config, config,
@ -706,7 +707,8 @@ static int recycle_unlink_internal(vfs_handle_struct *handle,
dirfsp, dirfsp,
smb_fname, smb_fname,
handle->conn->cwd_fsp, handle->conn->cwd_fsp,
smb_fname_final); smb_fname_final,
&rhow);
if (rc != 0) { if (rc != 0) {
DEBUG(3, ("recycle: Move error %d (%s), purging file %s " DEBUG(3, ("recycle: Move error %d (%s), purging file %s "
"(%s)\n", errno, strerror(errno), "(%s)\n", errno, strerror(errno),

View File

@ -1027,7 +1027,8 @@ static int shadow_copy2_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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_src = 0;
time_t timestamp_dst = 0; time_t timestamp_dst = 0;
@ -1069,7 +1070,8 @@ static int shadow_copy2_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
} }
static int shadow_copy2_symlinkat(vfs_handle_struct *handle, static int shadow_copy2_symlinkat(vfs_handle_struct *handle,

View File

@ -1905,7 +1905,8 @@ static int snapper_gmt_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; time_t timestamp_src, timestamp_dst;
@ -1931,7 +1932,8 @@ static int snapper_gmt_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
} }
static int snapper_gmt_symlinkat(vfs_handle_struct *handle, static int snapper_gmt_symlinkat(vfs_handle_struct *handle,

View File

@ -165,6 +165,7 @@ static char *stream_dir(vfs_handle_struct *handle,
char *rootdir = NULL; char *rootdir = NULL;
struct smb_filename *rootdir_fname = NULL; struct smb_filename *rootdir_fname = NULL;
struct smb_filename *tmp_fname = NULL; struct smb_filename *tmp_fname = NULL;
struct vfs_rename_how rhow = { .flags = 0, };
int ret; int ret;
check_valid = lp_parm_bool(SNUM(handle->conn), check_valid = lp_parm_bool(SNUM(handle->conn),
@ -310,11 +311,13 @@ static char *stream_dir(vfs_handle_struct *handle,
goto fail; goto fail;
} }
if (SMB_VFS_NEXT_RENAMEAT(handle, ret = SMB_VFS_NEXT_RENAMEAT(handle,
handle->conn->cwd_fsp, handle->conn->cwd_fsp,
smb_fname_hash, smb_fname_hash,
handle->conn->cwd_fsp, handle->conn->cwd_fsp,
smb_fname_new) == -1) { smb_fname_new,
&rhow);
if (ret == -1) {
TALLOC_FREE(smb_fname_new); TALLOC_FREE(smb_fname_new);
if ((errno == EEXIST) || (errno == ENOTEMPTY)) { if ((errno == EEXIST) || (errno == ENOTEMPTY)) {
goto again; goto again;
@ -962,7 +965,8 @@ static int streams_depot_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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_src_stream = NULL;
struct smb_filename *smb_fname_dst_stream = NULL; struct smb_filename *smb_fname_dst_stream = NULL;
@ -984,7 +988,13 @@ static int streams_depot_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, 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 */ /* 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, handle->conn->cwd_fsp,
smb_fname_src_stream, smb_fname_src_stream,
handle->conn->cwd_fsp, handle->conn->cwd_fsp,
smb_fname_dst_stream); smb_fname_dst_stream,
how);
done: done:
TALLOC_FREE(smb_fname_src_stream); TALLOC_FREE(smb_fname_src_stream);

View File

@ -537,7 +537,8 @@ static int streams_xattr_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; NTSTATUS status;
int ret = -1; int ret = -1;
@ -560,7 +561,13 @@ static int streams_xattr_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, 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. */ /* For now don't allow renames from or to the default stream. */

View File

@ -144,7 +144,8 @@ static int syncops_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int ret;
@ -160,7 +161,8 @@ static int syncops_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
if (ret == -1) { if (ret == -1) {
return ret; return ret;
} }

View File

@ -918,7 +918,8 @@ static int smb_time_audit_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *oldname, const struct smb_filename *oldname,
files_struct *dstfsp, files_struct *dstfsp,
const struct smb_filename *newname) const struct smb_filename *newname,
const struct vfs_rename_how *how)
{ {
int result; int result;
struct timespec ts1,ts2; struct timespec ts1,ts2;
@ -937,7 +938,8 @@ static int smb_time_audit_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
oldname, oldname,
dstfsp, dstfsp,
newname); newname,
how);
clock_gettime_mono(&ts2); clock_gettime_mono(&ts2);
timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9; timediff = nsec_time_diff(&ts2,&ts1)*1.0e-9;

View File

@ -926,7 +926,8 @@ static int um_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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; int status;
struct smb_filename *src_full_fname = NULL; struct smb_filename *src_full_fname = NULL;
@ -965,7 +966,8 @@ static int um_renameat(vfs_handle_struct *handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
} }
status = alloc_get_client_smb_fname(handle, talloc_tos(), 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, handle->conn->cwd_fsp,
src_client_fname, src_client_fname,
handle->conn->cwd_fsp, handle->conn->cwd_fsp,
dst_client_fname); dst_client_fname,
how);
err: err:
TALLOC_FREE(dst_client_fname); TALLOC_FREE(dst_client_fname);

View File

@ -1592,13 +1592,15 @@ static int virusfilter_vfs_renameat(
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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, int ret = SMB_VFS_NEXT_RENAMEAT(handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
struct virusfilter_config *config = NULL; struct virusfilter_config *config = NULL;
char *fname = NULL; char *fname = NULL;
char *dst_fname = NULL; char *dst_fname = NULL;

View File

@ -55,12 +55,14 @@ int virusfilter_vfs_next_move(
const struct smb_filename *smb_fname_dst) const struct smb_filename *smb_fname_dst)
{ {
int result; int result;
struct vfs_rename_how rhow = { .flags = 0, };
result = SMB_VFS_NEXT_RENAMEAT(vfs_h, result = SMB_VFS_NEXT_RENAMEAT(vfs_h,
vfs_h->conn->cwd_fsp, vfs_h->conn->cwd_fsp,
smb_fname_src, smb_fname_src,
vfs_h->conn->cwd_fsp, vfs_h->conn->cwd_fsp,
smb_fname_dst); smb_fname_dst,
&rhow);
if (result == 0 || errno != EXDEV) { if (result == 0 || errno != EXDEV) {
return result; return result;
} }

View File

@ -215,7 +215,8 @@ static int vfs_worm_renameat(vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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)) { if (is_readonly(handle, smb_fname_src)) {
errno = EACCES; errno = EACCES;
@ -223,7 +224,7 @@ static int vfs_worm_renameat(vfs_handle_struct *handle,
} }
return SMB_VFS_NEXT_RENAMEAT( 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, static int vfs_worm_fsetxattr(struct vfs_handle_struct *handle,

View File

@ -4681,6 +4681,7 @@ static NTSTATUS mkdir_internal(connection_struct *conn,
struct server_id_buf idbuf; struct server_id_buf idbuf;
char *idstr = server_id_str_buf_unique_ex(id, '%', &idbuf); char *idstr = server_id_str_buf_unique_ex(id, '%', &idbuf);
struct vfs_open_how how = { .flags = O_RDONLY|O_DIRECTORY, }; struct vfs_open_how how = { .flags = O_RDONLY|O_DIRECTORY, };
struct vfs_rename_how rhow = { .flags = 0, };
int ret; int ret;
if (!CAN_WRITE(conn) || (access_mask & ~(conn->share_access))) { if (!CAN_WRITE(conn) || (access_mask & ~(conn->share_access))) {
@ -4933,7 +4934,8 @@ mkdir_first:
parent_dir_fname->fsp, parent_dir_fname->fsp,
tmp_atname, tmp_atname,
parent_dir_fname->fsp, parent_dir_fname->fsp,
smb_fname_atname); smb_fname_atname,
&rhow);
} }
if (ret != 0) { if (ret != 0) {

View File

@ -1417,6 +1417,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
true : conn->case_sensitive; true : conn->case_sensitive;
bool case_preserve = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ? bool case_preserve = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
true : conn->case_preserve; true : conn->case_preserve;
struct vfs_rename_how rhow = { .flags = 0, };
status = parent_dirname_compatible_open(conn, smb_fname_dst_in); status = parent_dirname_compatible_open(conn, smb_fname_dst_in);
if (!NT_STATUS_IS_OK(status)) { 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->fsp,
parent_dir_fname_src_atname, parent_dir_fname_src_atname,
parent_dir_fname_dst->fsp, parent_dir_fname_dst->fsp,
parent_dir_fname_dst_atname); parent_dir_fname_dst_atname,
&rhow);
if (ret == 0) { if (ret == 0) {
uint32_t create_options = fh_get_private_options(fsp->fh); uint32_t create_options = fh_get_private_options(fsp->fh);

View File

@ -1721,14 +1721,16 @@ int smb_vfs_call_renameat(struct vfs_handle_struct *handle,
files_struct *srcfsp, files_struct *srcfsp,
const struct smb_filename *smb_fname_src, const struct smb_filename *smb_fname_src,
files_struct *dstfsp, 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); VFS_FIND(renameat);
return handle->fns->renameat_fn(handle, return handle->fns->renameat_fn(handle,
srcfsp, srcfsp,
smb_fname_src, smb_fname_src,
dstfsp, dstfsp,
smb_fname_dst); smb_fname_dst,
how);
} }
struct smb_vfs_call_fsync_state { struct smb_vfs_call_fsync_state {

View File

@ -675,6 +675,7 @@ static NTSTATUS cmd_rename(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc,
int ret; int ret;
struct smb_filename *smb_fname_src = NULL; struct smb_filename *smb_fname_src = NULL;
struct smb_filename *smb_fname_dst = NULL; struct smb_filename *smb_fname_dst = NULL;
struct vfs_rename_how rhow = { .flags = 0, };
if (argc != 3) { if (argc != 3) {
printf("Usage: rename <old> <new>\n"); 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, vfs->conn->cwd_fsp,
smb_fname_src, smb_fname_src,
vfs->conn->cwd_fsp, vfs->conn->cwd_fsp,
smb_fname_dst); smb_fname_dst,
&rhow);
TALLOC_FREE(smb_fname_src); TALLOC_FREE(smb_fname_src);
TALLOC_FREE(smb_fname_dst); TALLOC_FREE(smb_fname_dst);