Commit 47bf04d2 authored by Pavel Tikhomirov's avatar Pavel Tikhomirov Committed by Andrei Vagin

util: fixup issubpath to handle sub-paths ending with slash

Before fix issubpath("./zdtm/static/mntns_shared_vs_private.test",
"./") returned false, though should return true.
Signed-off-by: 's avatarPavel Tikhomirov <ptikhomirov@virtuozzo.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 70dd6eaa
...@@ -206,12 +206,10 @@ int vaddr_to_pfn(int fd, unsigned long vaddr, u64 *pfn); ...@@ -206,12 +206,10 @@ int vaddr_to_pfn(int fd, unsigned long vaddr, u64 *pfn);
*/ */
static inline bool strstartswith2(const char *str, const char *sub, char *end) static inline bool strstartswith2(const char *str, const char *sub, char *end)
{ {
const char *osub = sub;
while (1) { while (1) {
if (*sub == '\0') /* end of sub -- match */ { if (*sub == '\0') /* end of sub -- match */ {
if (end) { if (end) {
if (sub == osub + 1) /* pure root */ if (*(sub-1) == '/') /* "/", "./" or "path/" */
*end = '/'; *end = '/';
else else
*end = *str; *end = *str;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment