[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Aug 26 17:34:02 UTC 2022


The branch, master has been updated
       via  b7c460b9028 vfs_glusterfs: Implement SMB_VFS_FSTATAT
       via  65f4c4e31e4 vfs_glusterfs: Use glfs_fgetxattr() for SMB_VFS_GET_REAL_FILENAME_AT
       via  55548d7405c vfs_glusterfs: Use glfs_readlinkat() for SMB_VFS_READ_DFS_PATHAT
       via  310a908098b vfs_glusterfs: Use glfs_symlinkat() for SMB_VFS_CREATE_DFS_PATHAT
       via  a4235200383 vfs_glusterfs: Use glfs_mknodat() for SMB_VFS_MKNODAT
       via  21654af5a5a vfs_glusterfs: Use glfs_linkat() for SMB_VFS_LINKAT
       via  58b6cdabc0c vfs_glusterfs: Use glfs_readlinkat() for SMB_VFS_READLINKAT
       via  b2746eb5fa6 vfs_glusterfs: Use glfs_symlinkat() for SMB_VFS_SYMLINKAT
       via  2fa71202ab3 vfs_glusterfs: Use glfs_unlinkat() for SMB_VFS_UNLINKAT
       via  2b721ff22be vfs_glusterfs: Use glfs_renameat() for SMB_VFS_RENAMEAT
       via  56c4aab1119 vfs_glusterfs: Use glfs_mkdirat() for SMB_VFS_MKDIRAT
       via  184a9913241 vfs_glusterfs: Use glfs_openat() for SMB_VFS_OPENAT
       via  3425fa0daf9 source3/wscript: Detect glusterfs-api with *at() calls support
       via  5f51fa9c07e vfs_glusterfs: Accept fsp with const qualifier
      from  fa3f0499cc1 pyglue:generate_random_[machine]_password: ValueError for bad values

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit b7c460b902800c0156385b2edb82efb07f561c51
Author: Anoop C S <anoopcs at samba.org>
Date:   Wed Aug 24 15:01:31 2022 +0530

    vfs_glusterfs: Implement SMB_VFS_FSTATAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Fri Aug 26 17:33:15 UTC 2022 on sn-devel-184

commit 65f4c4e31e4cc60eb9ebca3858275a29f43d5e12
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:16:08 2022 +0530

    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 <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 55548d7405ceca1d20e788a459e685c56f2ff139
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 13:08:42 2022 +0530

    vfs_glusterfs: Use glfs_readlinkat() for SMB_VFS_READ_DFS_PATHAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 310a908098b4ff3130a61594c15e91d5e561f357
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:51:16 2022 +0530

    vfs_glusterfs: Use glfs_symlinkat() for SMB_VFS_CREATE_DFS_PATHAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit a4235200383fa4dc2f376ce042ed067a45f105d5
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:15:10 2022 +0530

    vfs_glusterfs: Use glfs_mknodat() for SMB_VFS_MKNODAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 21654af5a5a062d831f7cb1efec1f1b1eb333bd2
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:14:29 2022 +0530

    vfs_glusterfs: Use glfs_linkat() for SMB_VFS_LINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 58b6cdabc0c3d788b407d3bfa46570311e910180
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:13:33 2022 +0530

    vfs_glusterfs: Use glfs_readlinkat() for SMB_VFS_READLINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit b2746eb5fa64e0ec58e99eed5be10c98ea4e1c1e
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:12:43 2022 +0530

    vfs_glusterfs: Use glfs_symlinkat() for SMB_VFS_SYMLINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2fa71202ab347fd057bb9b42740e57344e2679e1
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:11:54 2022 +0530

    vfs_glusterfs: Use glfs_unlinkat() for SMB_VFS_UNLINKAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 2b721ff22be04cea90086dde2a50f4287d075326
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:11:02 2022 +0530

    vfs_glusterfs: Use glfs_renameat() for SMB_VFS_RENAMEAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 56c4aab11190b8d48a5b92babea7fc7e78b54b4e
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:10:16 2022 +0530

    vfs_glusterfs: Use glfs_mkdirat() for SMB_VFS_MKDIRAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 184a9913241acd4f69128ced3370d3bf49b95f3b
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:07:08 2022 +0530

    vfs_glusterfs: Use glfs_openat() for SMB_VFS_OPENAT
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 3425fa0daf9e32d09c7716692cdfdffdc09856d7
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 12:17:33 2022 +0530

    source3/wscript: Detect glusterfs-api with *at() calls support
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 5f51fa9c07e194bcc3c4f39a1bfc2e01139c917b
Author: Anoop C S <anoopcs at samba.org>
Date:   Fri Aug 19 11:58:34 2022 +0530

    vfs_glusterfs: Accept fsp with const qualifier
    
    This is in preparation to avoid any `const` qualifier being discarded
    warning with future changes to various *_at() calls which has `const
    file_struct` arguments.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=15157
    
    Signed-off-by: Anoop C S <anoopcs at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/modules/vfs_glusterfs.c | 438 ++++++++++++++++++++++++++++++++--------
 source3/wscript                 |   4 +
 2 files changed, 363 insertions(+), 79 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index dd05da0f9bb..e2f9fbd8bd4 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -606,7 +606,7 @@ static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct *handle,
 }
 
 static glfs_fd_t *vfs_gluster_fetch_glfd(struct vfs_handle_struct *handle,
-					 files_struct *fsp)
+					 const files_struct *fsp)
 {
 	glfs_fd_t **glfd = (glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
 	if (glfd == NULL) {
@@ -737,9 +737,24 @@ static int vfs_gluster_mkdirat(struct vfs_handle_struct *handle,
 			const struct smb_filename *smb_fname,
 			mode_t mode)
 {
-	struct smb_filename *full_fname = NULL;
 	int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *pglfd = NULL;
+
+	START_PROFILE(syscall_mkdirat);
+
+	pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+	if (pglfd == NULL) {
+		END_PROFILE(syscall_mkdirat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_mkdirat(pglfd, smb_fname->base_name, mode);
+#else
+	struct smb_filename *full_fname = NULL;
+
 	START_PROFILE(syscall_mkdirat);
 
 	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
@@ -753,6 +768,7 @@ static int vfs_gluster_mkdirat(struct vfs_handle_struct *handle,
 	ret = glfs_mkdir(handle->data, full_fname->base_name, mode);
 
 	TALLOC_FREE(full_fname);
+#endif
 
 	END_PROFILE(syscall_mkdirat);
 
@@ -765,9 +781,12 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 			      files_struct *fsp,
 			      const struct vfs_open_how *how)
 {
-	struct smb_filename *name = NULL;
+	int flags = how->flags;
+	struct smb_filename *full_fname = NULL;
+	bool have_opath = false;
 	bool became_root = false;
 	glfs_fd_t *glfd;
+	glfs_fd_t *pglfd = NULL;
 	glfs_fd_t **p_tmp;
 
 	START_PROFILE(syscall_openat);
@@ -778,58 +797,103 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 		return -1;
 	}
 
-	/*
-	 * Looks like glfs API doesn't have openat().
-	 */
-	if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
-		name = full_path_from_dirfsp_atname(talloc_tos(),
-						    dirfsp,
-						    smb_fname);
-		if (name == NULL) {
-			END_PROFILE(syscall_openat);
-			return -1;
-		}
-		smb_fname = name;
-	}
-
 	p_tmp = VFS_ADD_FSP_EXTENSION(handle, fsp, glfs_fd_t *, NULL);
 	if (p_tmp == NULL) {
-		TALLOC_FREE(name);
 		END_PROFILE(syscall_openat);
 		errno = ENOMEM;
 		return -1;
 	}
 
+#ifdef O_PATH
+	have_opath = true;
 	if (fsp->fsp_flags.is_pathref) {
-		/*
-		 * ceph doesn't support O_PATH so we have to fallback to
-		 * become_root().
-		 */
+		flags |= O_PATH;
+	}
+#endif
+
+	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+						  dirfsp,
+						  smb_fname);
+	if (full_fname == NULL) {
+		END_PROFILE(syscall_openat);
+		return -1;
+	}
+
+	if (fsp->fsp_flags.is_pathref && !have_opath) {
 		become_root();
 		became_root = true;
 	}
 
-	if (how->flags & O_DIRECTORY) {
-		glfd = glfs_opendir(handle->data, smb_fname->base_name);
-	} else if (how->flags & O_CREAT) {
+	/*
+	 * O_CREAT flag in open is handled differently in a way which is *NOT*
+	 * safe against symlink race situations. We use glfs_creat() instead
+	 * for correctness as glfs_openat() is broken with O_CREAT present
+	 * in open flags.
+	 */
+	if (flags & O_CREAT) {
+		if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+			/*
+			 * Replace smb_fname with full_path constructed above.
+			 */
+			smb_fname = full_fname;
+		}
+
+		/*
+		 * smb_fname can either be a full_path or the same one
+		 * as received from the caller. In the latter case we
+		 * are operating at current working directory.
+		 */
 		glfd = glfs_creat(handle->data,
 				  smb_fname->base_name,
-				  how->flags,
+				  flags,
 				  how->mode);
 	} else {
-		glfd = glfs_open(handle->data,
-				 smb_fname->base_name,
-				 how->flags);
+		if (fsp_get_pathref_fd(dirfsp) != AT_FDCWD) {
+#ifdef HAVE_GFAPI_VER_7_11
+			/*
+			 * Fetch Gluster fd for parent directory using dirfsp
+			 * before calling glfs_openat();
+			 */
+			pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+			if (pglfd == NULL) {
+				END_PROFILE(syscall_openat);
+				DBG_ERR("Failed to fetch gluster fd\n");
+				return -1;
+			}
+
+			glfd = glfs_openat(pglfd,
+					   smb_fname->base_name,
+					   flags,
+					   how->mode);
+#else
+			/*
+			 * Replace smb_fname with full_path constructed above.
+			 */
+			smb_fname = full_fname;
+#endif
+		}
+
+		if (pglfd == NULL) {
+			/*
+			 * smb_fname can either be a full_path or the same one
+			 * as received from the caller. In the latter case we
+			 * are operating at current working directory.
+			 */
+			glfd = glfs_open(handle->data,
+					 smb_fname->base_name,
+					 flags);
+		}
 	}
 
 	if (became_root) {
 		unbecome_root();
 	}
 
+	TALLOC_FREE(full_fname);
+
 	fsp->fsp_flags.have_proc_fds = false;
 
 	if (glfd == NULL) {
-		TALLOC_FREE(name);
 		END_PROFILE(syscall_openat);
 		/* no extension destroy_fn, so no need to save errno */
 		VFS_REMOVE_FSP_EXTENSION(handle, fsp);
@@ -838,7 +902,6 @@ static int vfs_gluster_openat(struct vfs_handle_struct *handle,
 
 	*p_tmp = glfd;
 
-	TALLOC_FREE(name);
 	END_PROFILE(syscall_openat);
 	/* An arbitrary value for error reporting, so you know its us. */
 	return 13371337;
@@ -1242,9 +1305,33 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
 			files_struct *dstfsp,
 			const struct smb_filename *smb_fname_dst)
 {
+	int ret;
+
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *src_pglfd = NULL;
+	glfs_fd_t *dst_pglfd = NULL;
+
+	START_PROFILE(syscall_renameat);
+
+	src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp);
+	if (src_pglfd == NULL) {
+		END_PROFILE(syscall_renameat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	dst_pglfd = vfs_gluster_fetch_glfd(handle, dstfsp);
+	if (dst_pglfd == NULL) {
+		END_PROFILE(syscall_renameat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_renameat(src_pglfd, smb_fname_src->base_name,
+			    dst_pglfd, smb_fname_dst->base_name);
+#else
 	struct smb_filename *full_fname_src = NULL;
 	struct smb_filename *full_fname_dst = NULL;
-	int ret;
 
 	START_PROFILE(syscall_renameat);
 
@@ -1252,24 +1339,28 @@ static int vfs_gluster_renameat(struct vfs_handle_struct *handle,
 						      srcfsp,
 						      smb_fname_src);
 	if (full_fname_src == NULL) {
-		errno = ENOMEM;
 		END_PROFILE(syscall_renameat);
+		errno = ENOMEM;
 		return -1;
 	}
+
 	full_fname_dst = full_path_from_dirfsp_atname(talloc_tos(),
 						      dstfsp,
 						      smb_fname_dst);
 	if (full_fname_dst == NULL) {
+		END_PROFILE(syscall_renameat);
 		TALLOC_FREE(full_fname_src);
 		errno = ENOMEM;
-		END_PROFILE(syscall_renameat);
 		return -1;
 	}
 	ret = glfs_rename(handle->data,
 			  full_fname_src->base_name,
 			  full_fname_dst->base_name);
+
 	TALLOC_FREE(full_fname_src);
 	TALLOC_FREE(full_fname_dst);
+#endif
+
 	END_PROFILE(syscall_renameat);
 
 	return ret;
@@ -1452,6 +1543,55 @@ static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
 	return ret;
 }
 
+static int vfs_gluster_fstatat(struct vfs_handle_struct *handle,
+			       const struct files_struct *dirfsp,
+			       const struct smb_filename *smb_fname,
+			       SMB_STRUCT_STAT *sbuf,
+			       int flags)
+{
+	struct stat st;
+	int ret;
+
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *pglfd = NULL;
+
+	START_PROFILE(syscall_fstatat);
+
+	pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+	if (pglfd == NULL) {
+		END_PROFILE(syscall_fstatat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_fstatat(pglfd, smb_fname->base_name, &st, flags);
+#else
+	struct smb_filename *full_fname = NULL;
+
+	START_PROFILE(syscall_fstatat);
+
+	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
+						  dirfsp,
+						  smb_fname);
+	if (full_fname == NULL) {
+		END_PROFILE(syscall_fstatat);
+		return -1;
+	}
+
+	ret = glfs_stat(handle->data, full_fname->base_name, &st);
+
+	TALLOC_FREE(full_fname->base_name);
+#endif
+
+	if (ret == 0) {
+		smb_stat_ex_from_stat(sbuf, &st);
+	}
+
+	END_PROFILE(syscall_fstatat);
+
+	return ret;
+}
+
 static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
 			     struct smb_filename *smb_fname)
 {
@@ -1490,9 +1630,24 @@ static int vfs_gluster_unlinkat(struct vfs_handle_struct *handle,
 			const struct smb_filename *smb_fname,
 			int flags)
 {
-	struct smb_filename *full_fname = NULL;
 	int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *pglfd = NULL;
+
+	START_PROFILE(syscall_unlinkat);
+
+	pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+	if (pglfd == NULL) {
+		END_PROFILE(syscall_unlinkat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_unlinkat(pglfd, smb_fname->base_name, flags);
+#else
+	struct smb_filename *full_fname = NULL;
+
 	START_PROFILE(syscall_unlinkat);
 
 	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
@@ -1508,7 +1663,10 @@ static int vfs_gluster_unlinkat(struct vfs_handle_struct *handle,
 	} else {
 		ret = glfs_unlink(handle->data, full_fname->base_name);
 	}
+
 	TALLOC_FREE(full_fname);
+#endif
+
 	END_PROFILE(syscall_unlinkat);
 
 	return ret;
@@ -1908,24 +2066,42 @@ static int vfs_gluster_symlinkat(struct vfs_handle_struct *handle,
 				struct files_struct *dirfsp,
 				const struct smb_filename *new_smb_fname)
 {
-	struct smb_filename *full_fname = NULL;
 	int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *pglfd = NULL;
+
+	START_PROFILE(syscall_symlinkat);
+
+	pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+	if (pglfd == NULL) {
+		END_PROFILE(syscall_symlinkat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_symlinkat(link_target->base_name,
+			     pglfd,
+			     new_smb_fname->base_name);
+#else
+	struct smb_filename *full_fname = NULL;
+
 	START_PROFILE(syscall_symlinkat);
 
 	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
-						dirfsp,
-						new_smb_fname);
+						  dirfsp,
+						  new_smb_fname);
 	if (full_fname == NULL) {
 		END_PROFILE(syscall_symlinkat);
 		return -1;
 	}
 
 	ret = glfs_symlink(handle->data,
-			link_target->base_name,
-			full_fname->base_name);
+			   link_target->base_name,
+			   full_fname->base_name);
 
 	TALLOC_FREE(full_fname);
+#endif
 
 	END_PROFILE(syscall_symlinkat);
 
@@ -1938,14 +2114,29 @@ static int vfs_gluster_readlinkat(struct vfs_handle_struct *handle,
 				char *buf,
 				size_t bufsiz)
 {
-	struct smb_filename *full_fname = NULL;
 	int ret;
 
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *pglfd = NULL;
+
+	START_PROFILE(syscall_readlinkat);
+
+	pglfd = vfs_gluster_fetch_glfd(handle, dirfsp);
+	if (pglfd == NULL) {
+		END_PROFILE(syscall_readlinkat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_readlinkat(pglfd, smb_fname->base_name, buf, bufsiz);
+#else
+	struct smb_filename *full_fname = NULL;
+
 	START_PROFILE(syscall_readlinkat);
 
 	full_fname = full_path_from_dirfsp_atname(talloc_tos(),
-						dirfsp,
-						smb_fname);
+						  dirfsp,
+						  smb_fname);
 	if (full_fname == NULL) {
 		END_PROFILE(syscall_readlinkat);
 		return -1;
@@ -1954,6 +2145,7 @@ static int vfs_gluster_readlinkat(struct vfs_handle_struct *handle,
 	ret = glfs_readlink(handle->data, full_fname->base_name, buf, bufsiz);
 
 	TALLOC_FREE(full_fname);
+#endif
 
 	END_PROFILE(syscall_readlinkat);
 
@@ -1968,24 +2160,52 @@ static int vfs_gluster_linkat(struct vfs_handle_struct *handle,
 				int flags)
 {
 	int ret;
+
+#ifdef HAVE_GFAPI_VER_7_11
+	glfs_fd_t *src_pglfd = NULL;
+	glfs_fd_t *dst_pglfd = NULL;
+
+	START_PROFILE(syscall_linkat);
+
+	src_pglfd = vfs_gluster_fetch_glfd(handle, srcfsp);
+	if (src_pglfd == NULL) {
+		END_PROFILE(syscall_linkat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	dst_pglfd = vfs_gluster_fetch_glfd(handle, dstfsp);
+	if (dst_pglfd == NULL) {
+		END_PROFILE(syscall_linkat);
+		DBG_ERR("Failed to fetch gluster fd\n");
+		return -1;
+	}
+
+	ret = glfs_linkat(src_pglfd,
+			  old_smb_fname->base_name,
+			  dst_pglfd,
+			  new_smb_fname->base_name,
+			  flags);
+#else
 	struct smb_filename *full_fname_old = NULL;
 	struct smb_filename *full_fname_new = NULL;
 
 	START_PROFILE(syscall_linkat);
 
 	full_fname_old = full_path_from_dirfsp_atname(talloc_tos(),
-						srcfsp,
-						old_smb_fname);
+						      srcfsp,
+						      old_smb_fname);
 	if (full_fname_old == NULL) {
 		END_PROFILE(syscall_linkat);
 		return -1;
 	}
+
 	full_fname_new = full_path_from_dirfsp_atname(talloc_tos(),
-						dstfsp,
-						new_smb_fname);
+						      dstfsp,
+						      new_smb_fname);
 	if (full_fname_new == NULL) {


-- 
Samba Shared Repository



More information about the samba-cvs mailing list