From: Jeremy Allison Date: Thu, 12 Sep 2019 17:03:05 +0000 (-0700) Subject: s3: VFS: vfs_ceph. Implement unlinkat(). X-Git-Tag: talloc-2.3.1~645 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=797f24fd4df288d9dee98c3bfdc0df1dd410931c;p=thirdparty%2Fsamba.git s3: VFS: vfs_ceph. Implement unlinkat(). 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 Reviewed-by: Ralph Boehme --- diff --git a/source3/modules/vfs_ceph.c b/source3/modules/vfs_ceph.c index d90e4ab3987..16ba3365b19 100644 --- a/source3/modules/vfs_ceph.c +++ b/source3/modules/vfs_ceph.c @@ -32,6 +32,7 @@ #include "includes.h" #include "smbd/smbd.h" +#include "system/filesys.h" #include #include #include "cephfs/libcephfs.h" @@ -951,6 +952,30 @@ static int cephwrap_unlink(struct vfs_handle_struct *handle, WRAP_RETURN(result); } +static int cephwrap_unlinkat(struct vfs_handle_struct *handle, + struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + int flags) +{ + int result = -1; + + DBG_DEBUG("[CEPH] unlink(%p, %s)\n", + handle, + smb_fname_str_dbg(smb_fname)); + SMB_ASSERT(dirfsp == dirfsp->conn->cwd_fsp); + if (smb_fname->stream_name) { + errno = ENOENT; + return result; + } + if (flags & AT_REMOVEDIR) { + result = ceph_rmdir(handle->data, smb_fname->base_name); + } else { + result = ceph_unlink(handle->data, smb_fname->base_name); + } + DBG_DEBUG("[CEPH] unlink(...) = %d\n", result); + WRAP_RETURN(result); +} + static int cephwrap_chmod(struct vfs_handle_struct *handle, const struct smb_filename *smb_fname, mode_t mode) @@ -1455,6 +1480,7 @@ static struct vfs_fn_pointers ceph_fns = { .fstat_fn = cephwrap_fstat, .lstat_fn = cephwrap_lstat, .unlink_fn = cephwrap_unlink, + .unlinkat_fn = cephwrap_unlinkat, .chmod_fn = cephwrap_chmod, .fchmod_fn = cephwrap_fchmod, .chown_fn = cephwrap_chown,