vfs_glusterfs: Fix fdopendir implementation master
authorAnoop C S <anoopcs@samba.org>
Fri, 13 May 2022 11:16:01 +0000 (16:46 +0530)
committerJeremy Allison <jra@samba.org>
Tue, 17 May 2022 20:20:05 +0000 (20:20 +0000)
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 <anoopcs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue May 17 20:20:05 UTC 2022 on sn-devel-184

source3/modules/vfs_glusterfs.c

index 4c369c20103c055f17d826521d1f0da6b7ab27e1..c06829a1799b00d821980ae657b2e73c62be0b87 100644 (file)
@@ -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;
 }