[PATCH] preallocate result for glfs_realpath in vfs_glusterfs

Michael Adam obnox at samba.org
Thu Oct 20 22:57:11 UTC 2016


Hi all,

due to a recent change in glusterfs
https://review.gluster.org/#/c/15332/ ,
it is now wrong to just free the result
of glfs_realpath(). This needs to be discussed,
but here is a patch that makes us indedpendent
of the allocation mechanism used by glfs_realpath()
by handing in a pre-malloced result string.

This is based on discussions I had with
Rajesh and Anoop today.

Reviews appreciated!
Rajesh/Anoop, please also confirm this approach!

Cheers - Michael
-------------- next part --------------
From 0c28ab96a862554261b0038dbdeaaa4a13e395c0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Fri, 21 Oct 2016 00:15:06 +0200
Subject: [PATCH] vfs:glusterfs: preallocate result for glfs_realpath

This makes us independent of the allocation
method used inside glfs_realpath.

Signed-off-by: Michael Adam <obnox at samba.org>
---
 source3/modules/vfs_glusterfs.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/source3/modules/vfs_glusterfs.c b/source3/modules/vfs_glusterfs.c
index 3e15ce6..66408bb 100644
--- a/source3/modules/vfs_glusterfs.c
+++ b/source3/modules/vfs_glusterfs.c
@@ -1140,7 +1140,14 @@ static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
 static char *vfs_gluster_realpath(struct vfs_handle_struct *handle,
 				  const char *path)
 {
-	return glfs_realpath(handle->data, path, 0);
+	char *result = SMB_MALLOC_ARRAY(char, PATH_MAX+1);
+
+	if (result == NULL) {
+		errno = ENOMEM;
+		return NULL;
+	}
+
+	return glfs_realpath(handle->data, path, result);
 }
 
 static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
-- 
2.7.4

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 163 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20161021/79dcd4d8/signature.sig>


More information about the samba-technical mailing list