s3: VFS: vfs_posix_eadb. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2019 19:01:42 +0000 (12:01 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:45 +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_posix_eadb.c

index 44bef9f9d82e6b2a647e736079a31c345b3684a4..e60c39a5e6a62ff6f6162965978963d4394d94cc 100644 (file)
@@ -385,6 +385,22 @@ static int posix_eadb_rmdir(vfs_handle_struct *handle,
        return ret;
 }
 
+static int posix_eadb_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 = posix_eadb_rmdir(handle, smb_fname);
+       } else {
+               ret = posix_eadb_unlink(handle, smb_fname);
+       }
+       return ret;
+}
+
 /*
  * Destructor for the VFS private data
  */
@@ -441,6 +457,7 @@ static struct vfs_fn_pointers vfs_posix_eadb_fns = {
        .removexattr_fn = posix_eadb_removexattr,
        .fremovexattr_fn = posix_eadb_fremovexattr,
        .unlink_fn = posix_eadb_unlink,
+       .unlinkat_fn = posix_eadb_unlinkat,
        .rmdir_fn = posix_eadb_rmdir,
        .connect_fn = posix_eadb_connect,
 };