s3: VFS: vfs_streams_depot. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2019 20:41:10 +0000 (13:41 -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_streams_depot.c

index e90190378690e5e6107180fd516b9dad539cce09..c85e4df6dbfa11a7659d2b2cd38ba9ef4e08228d 100644 (file)
@@ -844,6 +844,21 @@ static int streams_depot_rmdir(vfs_handle_struct *handle,
        return ret;
 }
 
+static int streams_depot_unlinkat(vfs_handle_struct *handle,
+                       struct files_struct *dirfsp,
+                       const struct smb_filename *smb_fname,
+                       int flags)
+{
+       int ret;
+       SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp);
+       if (flags & AT_REMOVEDIR) {
+               ret = streams_depot_rmdir(handle, smb_fname);
+       } else {
+               ret = streams_depot_unlink(handle, smb_fname);
+       }
+       return ret;
+}
+
 static int streams_depot_renameat(vfs_handle_struct *handle,
                                files_struct *srcfsp,
                                const struct smb_filename *smb_fname_src,
@@ -1080,6 +1095,7 @@ static struct vfs_fn_pointers vfs_streams_depot_fns = {
        .stat_fn = streams_depot_stat,
        .lstat_fn = streams_depot_lstat,
        .unlink_fn = streams_depot_unlink,
+       .unlinkat_fn = streams_depot_unlinkat,
        .rmdir_fn = streams_depot_rmdir,
        .renameat_fn = streams_depot_renameat,
        .streaminfo_fn = streams_depot_streaminfo,