]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/modules: VFS: ceph_snapshots: Add new fchmod_fn implementation
authorNoel Power <noel.power@suse.com>
Fri, 9 Apr 2021 13:49:15 +0000 (15:49 +0200)
committerNoel Power <npower@samba.org>
Sun, 11 Apr 2021 22:27:34 +0000 (22:27 +0000)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_ceph_snapshots.c

index 7b2307b19ee07db36d2117c8bad81132fa1a788d..0e72aae574adafa39cf972d6fdb8e368ef96ffb9 100644 (file)
@@ -960,6 +960,29 @@ static int ceph_snap_gmt_chmod(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_CHMOD(handle, csmb_fname, mode);
 }
 
+static int ceph_snap_gmt_fchmod(vfs_handle_struct *handle,
+                               struct files_struct *fsp,
+                               mode_t mode)
+{
+       const struct smb_filename *csmb_fname = NULL;
+       time_t timestamp = 0;
+       int ret;
+
+       csmb_fname = fsp->fsp_name;
+       ret = ceph_snap_gmt_strip_snapshot(handle,
+                                       csmb_fname,
+                                       &timestamp, NULL, 0);
+       if (ret < 0) {
+               errno = -ret;
+               return -1;
+       }
+       if (timestamp != 0) {
+               errno = EROFS;
+               return -1;
+       }
+       return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
+}
+
 static int ceph_snap_gmt_chdir(vfs_handle_struct *handle,
                        const struct smb_filename *csmb_fname)
 {
@@ -1461,6 +1484,7 @@ static struct vfs_fn_pointers ceph_snap_fns = {
        .openat_fn = ceph_snap_gmt_openat,
        .unlinkat_fn = ceph_snap_gmt_unlinkat,
        .chmod_fn = ceph_snap_gmt_chmod,
+       .fchmod_fn = ceph_snap_gmt_fchmod,
        .chdir_fn = ceph_snap_gmt_chdir,
        .ntimes_fn = ceph_snap_gmt_ntimes,
        .readlinkat_fn = ceph_snap_gmt_readlinkat,