From: Anoop C S Date: Fri, 13 May 2022 11:16:01 +0000 (+0530) Subject: vfs_glusterfs: Fix fdopendir implementation X-Git-Tag: talloc-2.3.4~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0633d8837ce4ddcf7f46c5f320e8d0b3142177fa;p=thirdparty%2Fsamba.git vfs_glusterfs: Fix fdopendir implementation Directory stream returned for fdopendir() within vfs_glusterfs doesn't correctly point to required directory fd. Since GlusterFS still don't support *at() variant syscalls we will have to rely on full path/name constructed out of fsp. Signed-off-by: Anoop C S Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Tue May 17 20:20:05 UTC 2022 on sn-devel-184 --- diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 4c369c20103..c06829a1799 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -625,12 +625,39 @@ static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle, files_struct *fsp, const char *mask, uint32_t attributes) { - glfs_fd_t *glfd = vfs_gluster_fetch_glfd(handle, fsp); + glfs_fd_t *glfd = NULL; + struct smb_filename *full_fname = NULL; + struct smb_filename *smb_fname_dot = NULL; + + smb_fname_dot = synthetic_smb_fname(fsp->fsp_name, + ".", + NULL, + NULL, + 0, + 0); + + if (smb_fname_dot == NULL) { + return NULL; + } + + full_fname = full_path_from_dirfsp_atname(talloc_tos(), + fsp, + smb_fname_dot); + if (full_fname == NULL) { + TALLOC_FREE(smb_fname_dot); + return NULL; + } + + glfd = glfs_opendir(handle->data, full_fname->base_name); if (glfd == NULL) { - DBG_ERR("Failed to fetch gluster fd\n"); + TALLOC_FREE(full_fname); + TALLOC_FREE(smb_fname_dot); return NULL; } + TALLOC_FREE(full_fname); + TALLOC_FREE(smb_fname_dot); + return (DIR *)glfd; }