From: Ralph Boehme Date: Wed, 20 May 2020 19:32:30 +0000 (+0200) Subject: vfs_glusterfs: implement SMB_VFS_OPENAT() X-Git-Tag: ldb-2.2.0~386 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=712cd71f93677adbe7093499f07771ccbf51c6aa;p=thirdparty%2Fsamba.git vfs_glusterfs: implement SMB_VFS_OPENAT() Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index fc9fbb0f646..c4b779a3c1c 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -643,6 +643,53 @@ static int vfs_gluster_open(struct vfs_handle_struct *handle, return 13371337; } +static int vfs_gluster_openat(struct vfs_handle_struct *handle, + const struct files_struct *dirfsp, + const struct smb_filename *smb_fname, + files_struct *fsp, + int flags, + mode_t mode) +{ + glfs_fd_t *glfd; + glfs_fd_t **p_tmp; + + START_PROFILE(syscall_openat); + + /* + * Looks like glfs API doesn't have openat(). + */ + SMB_ASSERT(dirfsp->fh->fd == AT_FDCWD); + + p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL); + if (p_tmp == NULL) { + END_PROFILE(syscall_openat); + errno = ENOMEM; + return -1; + } + + if (flags & O_DIRECTORY) { + glfd = glfs_opendir(handle->data, smb_fname->base_name); + } else if (flags & O_CREAT) { + glfd = glfs_creat(handle->data, smb_fname->base_name, flags, + mode); + } else { + glfd = glfs_open(handle->data, smb_fname->base_name, flags); + } + + if (glfd == NULL) { + END_PROFILE(syscall_openat); + /* no extension destroy_fn, so no need to save errno */ + VFS_REMOVE_FSP_EXTENSION(handle, fsp); + return -1; + } + + *p_tmp = glfd; + + END_PROFILE(syscall_openat); + /* An arbitrary value for error reporting, so you know its us. */ + return 13371337; +} + static int vfs_gluster_close(struct vfs_handle_struct *handle, files_struct *fsp) { @@ -2045,6 +2092,7 @@ static struct vfs_fn_pointers glusterfs_fns = { /* File Operations */ .open_fn = vfs_gluster_open, + .openat_fn = vfs_gluster_openat, .create_file_fn = NULL, .close_fn = vfs_gluster_close, .pread_fn = vfs_gluster_pread,