summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-04-21 22:15:06 +0200
committerLennart Poettering <lennart@poettering.net>2010-04-21 22:15:06 +0200
commit15ae422b7471cf6f41ccf450243d8afd8ea0a054 (patch)
tree4d44b599571defe496890db757dfe987942594bd /util.c
parent020379a7f7d2cca3ab37942db3d67d06c45083fe (diff)
execute: support basic filesystem namespacing
Diffstat (limited to 'util.c')
-rw-r--r--util.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/util.c b/util.c
index 49f5b4be13..e9f7813b8b 100644
--- a/util.c
+++ b/util.c
@@ -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;