From 2b334a49ae0e8b26c49fe2545a6a17c59e11cd7b Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 1 Sep 2009 05:45:03 +0000 Subject: libglusterfsclient: handle intermediate path components which are symlinks properly in glusterfs_glh_realpath. - while building the realpath, if the intermediate path happens to be a symbolic link, the content of link was being appended at dirname (path), instead of appending to intermediate path. Signed-off-by: Anand V. Avati BUG: 237 (If any of the path component other than the last one, happens to be a symbolic link glusterfs_glh_realpath does not construct correct path.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=237 --- libglusterfsclient/src/libglusterfsclient.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'libglusterfsclient/src/libglusterfsclient.c') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 58a8017d3..448a8b81e 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -6862,8 +6862,8 @@ glusterfs_glh_realpath (glusterfs_handle_t handle, const char *path, } ret = glusterfs_glh_readlink (handle, rpath, - buf, - path_max - 1); + buf, + path_max - 1); if (ret < 0) { gf_log ("libglusterfsclient", GF_LOG_ERROR, @@ -6876,7 +6876,7 @@ glusterfs_glh_realpath (glusterfs_handle_t handle, const char *path, buf[ret] = '\0'; if (buf[0] != '/') { - tmppath = strdup (path); + tmppath = strdup (rpath); tmppath = dirname (tmppath); sprintf (absolute_path, "%s/%s", tmppath, buf); @@ -6885,9 +6885,14 @@ glusterfs_glh_realpath (glusterfs_handle_t handle, const char *path, FREE (tmppath); } - rpath = glusterfs_glh_realpath (handle, buf, rpath); + rpath = glusterfs_glh_realpath (handle, buf, + rpath); FREE (buf); - goto out; + if (rpath == NULL) { + goto out; + } + dest = rpath + strlen (rpath); + } else if (!S_ISDIR (stbuf.st_mode) && *end != '\0') { errno = ENOTDIR; goto err; -- cgit