]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: vfs_ceph_snapshots. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2019 17:05:00 +0000 (10:05 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:45 +0000 (17:20 +0000)
This is identical to unlink(), as there
are no special cases needed for rmdir().

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

index de6b61d8063887a80bed1bc8b81b49782c488231..60a1db07dd6e467f2ac2434b668effab06a4e87b 100644 (file)
@@ -992,6 +992,31 @@ static int ceph_snap_gmt_unlink(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_UNLINK(handle, csmb_fname);
 }
 
+static int ceph_snap_gmt_unlinkat(vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *csmb_fname,
+                       int flags)
+{
+       time_t timestamp = 0;
+       int ret;
+
+       ret = ceph_snap_gmt_strip_snapshot(handle,
+                                       csmb_fname->base_name,
+                                       &timestamp, NULL, 0);
+       if (ret < 0) {
+               errno = -ret;
+               return -1;
+       }
+       if (timestamp != 0) {
+               errno = EROFS;
+               return -1;
+       }
+       return SMB_VFS_NEXT_UNLINKAT(handle,
+                       dirfsp,
+                       csmb_fname,
+                       flags);
+}
+
 static int ceph_snap_gmt_chmod(vfs_handle_struct *handle,
                        const struct smb_filename *csmb_fname,
                        mode_t mode)
@@ -1637,6 +1662,7 @@ static struct vfs_fn_pointers ceph_snap_fns = {
        .lstat_fn = ceph_snap_gmt_lstat,
        .open_fn = ceph_snap_gmt_open,
        .unlink_fn = ceph_snap_gmt_unlink,
+       .unlinkat_fn = ceph_snap_gmt_unlinkat,
        .chmod_fn = ceph_snap_gmt_chmod,
        .chown_fn = ceph_snap_gmt_chown,
        .chdir_fn = ceph_snap_gmt_chdir,