lib/canonicalize: always remove tailing slash
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
8a0f727bf2
commit
28074a0952
|
@ -174,9 +174,16 @@ canonicalize_path(const char *path)
|
|||
if (path == NULL)
|
||||
return NULL;
|
||||
|
||||
if (!myrealpath(path, canonical, PATH_MAX+1))
|
||||
return strdup(path);
|
||||
|
||||
if (!myrealpath(path, canonical, PATH_MAX+1)) {
|
||||
char *res = strdup(path);
|
||||
if (res) {
|
||||
p = strrchr(res, '/');
|
||||
/* delete trailing slash */
|
||||
if (p && p > res && *(p + 1) == '\0')
|
||||
*p = '\0';
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
p = strrchr(canonical, '/');
|
||||
if (p && strncmp(p, "/dm-", 4) == 0 && isdigit(*(p + 4))) {
|
||||
|
|
Loading…
Reference in New Issue