]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: vfs_recycle. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2019 19:55:49 +0000 (12:55 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:46 +0000 (17:20 +0000)
Note this isn't identical to unlink() as
this must cope with (flags & AT_REMOVEDIR),
which is identical to rmdir(). It calls
either unlink or rmdir depending on the
flags parameter.

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

index 77e1afc308c79b6b8f9920f6dd88c16dd8b239fa..cb582acd9764205454257479040e64470d8f03d2 100644 (file)
@@ -670,8 +670,29 @@ done:
        return rc;
 }
 
+static int recycle_unlinkat(vfs_handle_struct *handle,
+               struct files_struct *dirfsp,
+               const struct smb_filename *smb_fname,
+               int flags)
+{
+       int ret;
+
+       if (flags & AT_REMOVEDIR) {
+               ret = SMB_VFS_NEXT_UNLINKAT(handle,
+                                       dirfsp,
+                                       smb_fname,
+                                       flags);
+       } else {
+               SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+               ret = recycle_unlink(handle,
+                                       smb_fname);
+       }
+       return ret;
+}
+
 static struct vfs_fn_pointers vfs_recycle_fns = {
-       .unlink_fn = recycle_unlink
+       .unlink_fn = recycle_unlink,
+       .unlinkat_fn = recycle_unlinkat
 };
 
 static_decl_vfs;