summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2012-09-12 16:08:56 +0530
committerAnand Avati <avati@redhat.com>2012-09-13 13:23:07 -0700
commitdf731a50f222fdf3a25e48a0f9ff6d97fc8772b1 (patch)
tree4e69ac511d6850b808454aa4083e96578df046a1 /xlators/mgmt
parent3e2057542da6a0f182243b527bc7f1fd43d1fd3c (diff)
glusterd: Fixed _is_prefix check for two file paths
Change-Id: Iad1f7c865c4ce5092d85379257ba7a5ec95f7ebc BUG: 764890 Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/3937 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Kaushal M <kaushal@redhat.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/mgmt')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-utils.c b/xlators/mgmt/glusterd/src/glusterd-utils.c
index 427c9e27..efae2b51 100644
--- a/xlators/mgmt/glusterd/src/glusterd-utils.c
+++ b/xlators/mgmt/glusterd/src/glusterd-utils.c
@@ -777,18 +777,34 @@ _is_prefix (char *str1, char *str2)
GF_ASSERT (str2);
int i = 0;
+ int len1 = 0;
+ int len2 = 0;
int small_len = 0;
+ char *bigger = NULL;
gf_boolean_t prefix = _gf_true;
- small_len = min (strlen (str1), strlen (str2));
+ len1 = strlen (str1);
+ len2 = strlen (str2);
+ small_len = min (len1, len2);
for (i = 0; i < small_len; i++) {
if (str1[i] != str2[i]) {
prefix = _gf_false;
break;
}
-
}
+ if (len1 < len2)
+ bigger = str2;
+
+ else if (len1 > len2)
+ bigger = str1;
+
+ else
+ return prefix;
+
+ if (bigger[small_len] != '/')
+ prefix = _gf_false;
+
return prefix;
}
@@ -817,8 +833,13 @@ glusterd_is_brickpath_available (uuid_t uuid, char *path)
if (uuid_compare (uuid, brickinfo->uuid))
continue;
- if (!realpath (brickinfo->path, tmp_brickpath))
+ if (!realpath (brickinfo->path, tmp_brickpath)) {
+ if (errno == ENOENT)
+ strncpy (tmp_brickpath, brickinfo->path,
+ PATH_MAX);
+ else
goto out;
+ }
if (_is_prefix (tmp_brickpath, tmp_path))
goto out;
@@ -4440,7 +4461,7 @@ glusterd_is_uuid_present (char *path, char *xattr, gf_boolean_t *present)
ret = 0;
goto out;
}
-
+
switch (errno) {
#if defined(ENODATA)
case ENODATA: /* FALLTHROUGH */