From 21d3084bc6b0ce572fc4136446d45c8ac0f647f8 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Fri, 28 Aug 2009 00:14:38 +0000 Subject: libglusterfsclient: Enhance VMP searching logic Another attempt to enhance searching for VMP entries. There was a problem of returning the longest prefix match from all the VMPs without checking whether the number of matched components were same as the number of components in the candidate VMP. Signed-off-by: Anand V. Avati BUG: 209 (VMP parsing through fstab has issues) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=209 --- libglusterfsclient/src/libglusterfsclient.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libglusterfsclient/src/libglusterfsclient.c') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index 6a4e137cf..e3fdbe4d4 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -1428,8 +1428,9 @@ _libgf_vmp_search_entry (char *path, int searchtype) } list_for_each_entry(entry, &vmplist.list, list) { + vmpcompcount = libgf_count_path_components (entry->vmp); matchcount = libgf_vmp_entry_match (entry, path); - if (matchcount > maxcount) { + if ((matchcount > maxcount) && (matchcount == vmpcompcount)) { maxcount = matchcount; maxentry = entry; } @@ -1439,6 +1440,7 @@ _libgf_vmp_search_entry (char *path, int searchtype) * match, this is used to check whether duplicate entries are present * in the vmplist. */ + vmpcompcount = 0; if ((searchtype == LIBGF_VMP_EXACT) && (maxentry)) { vmpcompcount = libgf_count_path_components (maxentry->vmp); if (vmpcompcount != matchcount) -- cgit