diff options
author | Lennart Poettering <lennart@poettering.net> | 2010-04-21 22:15:06 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2010-04-21 22:15:06 +0200 |
commit | 15ae422b7471cf6f41ccf450243d8afd8ea0a054 (patch) | |
tree | 4d44b599571defe496890db757dfe987942594bd /util.c | |
parent | 020379a7f7d2cca3ab37942db3d67d06c45083fe (diff) |
execute: support basic filesystem namespacing
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -1140,6 +1140,39 @@ bool path_startswith(const char *path, const char *prefix) { } } +bool path_equal(const char *a, const char *b) { + assert(a); + assert(b); + + if ((a[0] == '/') != (b[0] == '/')) + return false; + + for (;;) { + size_t j, k; + + a += strspn(a, "/"); + b += strspn(b, "/"); + + if (*a == 0 && *b == 0) + return true; + + if (*a == 0 || *b == 0) + return false; + + j = strcspn(a, "/"); + k = strcspn(b, "/"); + + if (j != k) + return false; + + if (memcmp(a, b, j) != 0) + return false; + + a += j; + b += k; + } +} + char *ascii_strlower(char *t) { char *p; |