From 65f4c4e31e4cc60eb9ebca3858275a29f43d5e12 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Fri, 19 Aug 2022 12:16:08 +0530 Subject: [PATCH] vfs_glusterfs: Use glfs_fgetxattr() for SMB_VFS_GET_REAL_FILENAME_AT BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157 Signed-off-by: Anoop C S Reviewed-by: Jeremy Allison --- source3/modules/vfs_glusterfs.c | 46 ++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c index 1ecf21387a2..3c309028c89 100644 --- a/source3/modules/vfs_glusterfs.c +++ b/source3/modules/vfs_glusterfs.c @@ -2235,10 +2235,29 @@ static NTSTATUS vfs_gluster_get_real_filename_at( int ret; char key_buf[GLUSTER_NAME_MAX + 64]; char val_buf[GLUSTER_NAME_MAX + 1]; - NTSTATUS status = NT_STATUS_OK; +#ifdef HAVE_GFAPI_VER_7_11 + glfs_fd_t *pglfd = NULL; +#else struct smb_filename *smb_fname_dot = NULL; struct smb_filename *full_fname = NULL; +#endif + + if (strlen(name) >= GLUSTER_NAME_MAX) { + return NT_STATUS_OBJECT_NAME_INVALID; + } + + snprintf(key_buf, GLUSTER_NAME_MAX + 64, + "glusterfs.get_real_filename:%s", name); +#ifdef HAVE_GFAPI_VER_7_11 + pglfd = vfs_gluster_fetch_glfd(handle, dirfsp); + if (pglfd == NULL) { + DBG_ERR("Failed to fetch gluster fd\n"); + return NT_STATUS_OBJECT_NAME_NOT_FOUND; + } + + ret = glfs_fgetxattr(pglfd, key_buf, val_buf, GLUSTER_NAME_MAX + 1); +#else smb_fname_dot = synthetic_smb_fname(mem_ctx, ".", NULL, @@ -2257,35 +2276,26 @@ static NTSTATUS vfs_gluster_get_real_filename_at( return NT_STATUS_NO_MEMORY; } - if (strlen(name) >= GLUSTER_NAME_MAX) { - status = NT_STATUS_OBJECT_NAME_INVALID; - goto out; - } - - snprintf(key_buf, GLUSTER_NAME_MAX + 64, - "glusterfs.get_real_filename:%s", name); - ret = glfs_getxattr(handle->data, full_fname->base_name, key_buf, val_buf, GLUSTER_NAME_MAX + 1); + + TALLOC_FREE(smb_fname_dot); + TALLOC_FREE(full_fname); +#endif + if (ret == -1) { if (errno == ENOATTR) { errno = ENOENT; } - status = map_nt_error_from_unix(errno); - goto out; + return map_nt_error_from_unix(errno); } *found_name = talloc_strdup(mem_ctx, val_buf); if (found_name[0] == NULL) { - status = NT_STATUS_NO_MEMORY; - goto out; + return NT_STATUS_NO_MEMORY; } -out: - TALLOC_FREE(smb_fname_dot); - TALLOC_FREE(full_fname); - - return status; + return NT_STATUS_OK; } static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle, -- 2.47.3