1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-24 13:57:43 +03:00

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 <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jeremy Allison 2019-09-12 10:03:05 -07:00 committed by Ralph Boehme
parent f372f2f58c
commit 797f24fd4d

View File

@ -32,6 +32,7 @@
#include "includes.h"
#include "smbd/smbd.h"
#include "system/filesys.h"
#include <dirent.h>
#include <sys/statvfs.h>
#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,