} else {
/* canonicalized path goes outside of
* prefix, keep the original path instead */
+ free(u);
u = orig;
orig = NULL;
}
assert(path);
if (!isempty(root))
- return strjoin(root, "/",
+ return strjoin(root, endswith(root, "/") ? "" : "/",
path[0] == '/' ? path+1 : path,
- rest ? "/" : NULL,
+ rest ? (endswith(path, "/") ? "" : "/") : NULL,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
else
return strjoin(path,
- rest ? "/" : NULL,
+ rest ? (endswith(path, "/") ? "" : "/") : NULL,
rest && rest[0] == '/' ? rest+1 : rest,
NULL);
}
if (r < 0)
return r;
- r = lstat(parent, &b);
+ r = stat(parent, &b);
if (r < 0)
return -errno;