VFS: shadow_copy2: Add SMB_VFS_FCHFLAGS implementation
authorNoel Power <noel.power@suse.com>
Fri, 11 Jun 2021 14:46:30 +0000 (15:46 +0100)
committerNoel Power <npower@samba.org>
Tue, 29 Jun 2021 08:21:38 +0000 (08:21 +0000)
Signed-off-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_shadow_copy2.c

index d45b76950d10bd00c7dff0936f94554f22bd9115..252ea3b46972b4a294cd59a15f81d92de1469092 100644 (file)
@@ -2185,6 +2185,26 @@ static int shadow_copy2_chflags(vfs_handle_struct *handle,
        return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
 }
 
+static int shadow_copy2_fchflags(vfs_handle_struct *handle,
+                               struct files_struct *fsp,
+                               unsigned int flags)
+{
+       time_t timestamp = 0;
+
+       if (!shadow_copy2_strip_snapshot(talloc_tos(),
+                                       handle,
+                                       fsp->fsp_name,
+                                       &timestamp,
+                                       NULL)) {
+               return -1;
+       }
+       if (timestamp != 0) {
+               errno = EROFS;
+               return -1;
+       }
+       return SMB_VFS_NEXT_FCHFLAGS(handle, fsp, flags);
+}
+
 static ssize_t shadow_copy2_getxattr(vfs_handle_struct *handle,
                                const struct smb_filename *smb_fname,
                                const char *aname,
@@ -3205,6 +3225,7 @@ static struct vfs_fn_pointers vfs_shadow_copy2_fns = {
        .getxattrat_recv_fn = vfs_not_implemented_getxattrat_recv,
        .fsetxattr_fn = shadow_copy2_fsetxattr,
        .chflags_fn = shadow_copy2_chflags,
+       .fchflags_fn = shadow_copy2_fchflags,
        .get_real_filename_fn = shadow_copy2_get_real_filename,
        .pwrite_fn = shadow_copy2_pwrite,
        .pwrite_send_fn = shadow_copy2_pwrite_send,