Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/make Linux filemon only records D some/dir for rm -rf
details: https://anonhg.NetBSD.org/src/rev/5e913f8938e2
branches: trunk
changeset: 347010:5e913f8938e2
user: sjg <sjg%NetBSD.org@localhost>
date: Wed Aug 10 18:25:00 2016 +0000
description:
Linux filemon only records D some/dir for rm -rf
rather than D entries for each file removed.
Thus we need a loop to remove all matching missingFiles entries
diffstat:
usr.bin/make/meta.c | 46 +++++++++++++++++++++++++++++++++++++++-------
1 files changed, 39 insertions(+), 7 deletions(-)
diffs (74 lines):
diff -r 62b5cbdf4852 -r 5e913f8938e2 usr.bin/make/meta.c
--- a/usr.bin/make/meta.c Wed Aug 10 18:08:14 2016 +0000
+++ b/usr.bin/make/meta.c Wed Aug 10 18:25:00 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.63 2016/06/29 22:10:08 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.64 2016/08/10 18:25:00 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -865,6 +865,7 @@
return 0;
}
+/* Lst_ForEach wants 1 to stop search */
static int
prefix_match(void *p, void *q)
{
@@ -875,6 +876,32 @@
return (0 == strncmp(path, prefix, n));
}
+/*
+ * looking for exact or prefix/ match to
+ * Lst_Find wants 0 to stop search
+ */
+static int
+path_match(const void *p, const void *q)
+{
+ const char *prefix = q;
+ const char *path = p;
+ size_t n = strlen(prefix);
+ int rc;
+
+ if ((rc = strncmp(path, prefix, n)) == 0) {
+ switch (path[n]) {
+ case '\0':
+ case '/':
+ break;
+ default:
+ rc = 1;
+ break;
+ }
+ }
+ return rc;
+}
+
+/* Lst_Find wants 0 to stop search */
static int
string_match(const void *p, const void *q)
{
@@ -1166,12 +1193,17 @@
/* FALLTHROUGH */
case 'D': /* unlink */
if (*p == '/' && !Lst_IsEmpty(missingFiles)) {
- /* remove p from the missingFiles list if present */
- if ((ln = Lst_Find(missingFiles, p, string_match)) != NULL) {
- char *tp = Lst_Datum(ln);
- Lst_Remove(missingFiles, ln);
- free(tp);
- ln = NULL; /* we're done with it */
+ /* remove any missingFiles entries that match p */
+ if ((ln = Lst_Find(missingFiles, p,
+ path_match)) != NULL) {
+ char *tp;
+
+ do {
+ tp = Lst_Datum(ln);
+ Lst_Remove(missingFiles, ln);
+ free(tp);
+ } while ((ln = Lst_Find(missingFiles, p,
+ path_match)) != NULL);
}
}
if (buf[0] == 'M') {
Home |
Main Index |
Thread Index |
Old Index