]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: vfs_ceph_snapshots. Implement linkat().
authorJeremy Allison <jra@samba.org>
Wed, 14 Aug 2019 18:38:23 +0000 (11:38 -0700)
committerJeremy Allison <jra@samba.org>
Tue, 20 Aug 2019 21:09:28 +0000 (21:09 +0000)
Currently identical to link().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/modules/vfs_ceph_snapshots.c

index 5b4296f0caf44b094aa7739696f5c54fa6e7cd38..bf7ce804ae7d7b9fb409fde8306167878f003368 100644 (file)
@@ -857,6 +857,45 @@ static int ceph_snap_gmt_link(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_LINK(handle, old_smb_fname, new_smb_fname);
 }
 
+static int ceph_snap_gmt_linkat(vfs_handle_struct *handle,
+                               files_struct *srcfsp,
+                               const struct smb_filename *old_smb_fname,
+                               files_struct *dstfsp,
+                               const struct smb_filename *new_smb_fname,
+                               int flags)
+{
+       int ret;
+       time_t timestamp_old = 0;
+       time_t timestamp_new = 0;
+
+       ret = ceph_snap_gmt_strip_snapshot(handle,
+                               old_smb_fname->base_name,
+                               &timestamp_old,
+                               NULL, 0);
+       if (ret < 0) {
+               errno = -ret;
+               return -1;
+       }
+       ret = ceph_snap_gmt_strip_snapshot(handle,
+                               new_smb_fname->base_name,
+                               &timestamp_new,
+                               NULL, 0);
+       if (ret < 0) {
+               errno = -ret;
+               return -1;
+       }
+       if ((timestamp_old != 0) || (timestamp_new != 0)) {
+               errno = EROFS;
+               return -1;
+       }
+       return SMB_VFS_NEXT_LINKAT(handle,
+                       srcfsp,
+                       old_smb_fname,
+                       dstfsp,
+                       new_smb_fname,
+                       flags);
+}
+
 static int ceph_snap_gmt_stat(vfs_handle_struct *handle,
                            struct smb_filename *smb_fname)
 {
@@ -1602,6 +1641,7 @@ static struct vfs_fn_pointers ceph_snap_fns = {
        .get_quota_fn = ceph_snap_gmt_get_quota,
        .renameat_fn = ceph_snap_gmt_renameat,
        .link_fn = ceph_snap_gmt_link,
+       .linkat_fn = ceph_snap_gmt_linkat,
        .symlink_fn = ceph_snap_gmt_symlink,
        .stat_fn = ceph_snap_gmt_stat,
        .lstat_fn = ceph_snap_gmt_lstat,