libmount: ignore tailing slash in netfs source paths

Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Petr Uzel 2011-11-08 16:25:01 +01:00 committed by Karel Zak
parent 0b14bf7af1
commit b106d05238
6 changed files with 60 additions and 10 deletions

View file

@ -504,6 +504,38 @@ int parse_range(const char *str, int *lower, int *upper, int def)
return 0;
}
/*
* Compare two strings for equality, ignoring at most one trailing
* slash.
*/
int streq_except_trailing_slash(const char *s1, const char *s2)
{
int equal;
if (!s1 && !s2)
return 1;
if (!s1 || !s2)
return 0;
equal = !strcmp(s1, s2);
if (!equal) {
size_t len1 = strlen(s1);
size_t len2 = strlen(s2);
if (len1 && *(s1 + len1 - 1) == '/')
len1--;
if (len2 && *(s2 + len2 - 1) == '/')
len2--;
if (len1 != len2)
return 0;
equal = !strncmp(s1, s2, len1);
}
return equal;
}
#ifdef TEST_PROGRAM