Thread (57 messages) 57 messages, 4 authors, 2017-05-25
STALE3330d
Revisions (2)
  1. v1 [diff vs current]
  2. v2 current

[PATCH v2 4/9] dir: add method to check if a dir_entry lexically contains another

From: Samuel Lijin <hidden>
Date: 2017-05-06 18:49:40
Subsystem: the rest · Maintainer: Linus Torvalds

Introduce a method that allows us to check if one dir_entry corresponds
to a path which contains the path corresponding to another dir_entry.

Signed-off-by: Samuel Lijin <redacted>
---
 dir.c | 8 ++++++++
 1 file changed, 8 insertions(+)
diff --git a/dir.c b/dir.c
index 6bd0350e9..4739087f4 100644
--- a/dir.c
+++ b/dir.c
@@ -1852,6 +1852,14 @@ static int cmp_name(const void *p1, const void *p2)
 	return name_compare(e1->name, e1->len, e2->name, e2->len);
 }
 
+/* check if *out lexically contains *in */
+static int check_contains(const struct dir_entry *out, const struct dir_entry *in)
+{
+	return (out->len < in->len) &&
+			(out->name[out->len - 1] == '/') &&
+			!memcmp(out->name, in->name, out->len);
+}
+
 static int treat_leading_path(struct dir_struct *dir,
 			      const char *path, int len,
 			      const struct pathspec *pathspec)
-- 
2.12.2
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help