From: Jeremy Allison Date: Fri, 9 Aug 2019 20:49:46 +0000 (-0700) Subject: s3: VFS: vfs_ceph_snapshots. Implement renameat(). X-Git-Tag: tdb-1.4.2~95 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4a415f63e6383ef4a293240ab77ec4ba92f25b4e;p=thirdparty%2Fsamba.git s3: VFS: vfs_ceph_snapshots. Implement renameat(). Currently identical to rename(). Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_ceph_snapshots.c b/source3/modules/vfs_ceph_snapshots.c index a70a6adb1f4..3bc89174c7e 100644 --- a/source3/modules/vfs_ceph_snapshots.c +++ b/source3/modules/vfs_ceph_snapshots.c @@ -788,6 +788,44 @@ static int ceph_snap_gmt_rename(vfs_handle_struct *handle, return SMB_VFS_NEXT_RENAME(handle, smb_fname_src, smb_fname_dst); } +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) +{ + int ret; + time_t timestamp_src, timestamp_dst; + + ret = ceph_snap_gmt_strip_snapshot(handle, + smb_fname_src->base_name, + ×tamp_src, NULL, 0); + if (ret < 0) { + errno = -ret; + return -1; + } + ret = ceph_snap_gmt_strip_snapshot(handle, + smb_fname_dst->base_name, + ×tamp_dst, NULL, 0); + if (ret < 0) { + errno = -ret; + return -1; + } + if (timestamp_src != 0) { + errno = EXDEV; + return -1; + } + if (timestamp_dst != 0) { + errno = EROFS; + return -1; + } + return SMB_VFS_NEXT_RENAMEAT(handle, + srcfsp, + smb_fname_src, + dstfsp, + smb_fname_dst); +} + /* block links from writeable shares to snapshots for now, like other modules */ static int ceph_snap_gmt_symlink(vfs_handle_struct *handle, const char *link_contents, @@ -1595,6 +1633,7 @@ static struct vfs_fn_pointers ceph_snap_fns = { .disk_free_fn = ceph_snap_gmt_disk_free, .get_quota_fn = ceph_snap_gmt_get_quota, .rename_fn = ceph_snap_gmt_rename, + .renameat_fn = ceph_snap_gmt_renameat, .link_fn = ceph_snap_gmt_link, .symlink_fn = ceph_snap_gmt_symlink, .stat_fn = ceph_snap_gmt_stat,