summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2015-05-21 13:29:34 +0000
committertrasz <trasz@FreeBSD.org>2015-05-21 13:29:34 +0000
commit9a9f3ecf67ce721e3bd874099c068de29df1d597 (patch)
tree81c1d090ca0fe341ec0d07b57aa180c72092ccb9
parentb8ffded4a645a74822620d7c8c2f29c89ed42ea6 (diff)
downloadFreeBSD-src-9a9f3ecf67ce721e3bd874099c068de29df1d597.zip
FreeBSD-src-9a9f3ecf67ce721e3bd874099c068de29df1d597.tar.gz
MFC r279845:
Fix handling of direct maps, broken in r275756. Previously, running automount(8) would unmount direct map trigger nodes every second time. Sponsored by: The FreeBSD Foundation
-rw-r--r--usr.sbin/autofs/common.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c
index 7dccdee..d725eab 100644
--- a/usr.sbin/autofs/common.c
+++ b/usr.sbin/autofs/common.c
@@ -661,23 +661,25 @@ node_find_x(struct node *node, const char *path)
char *tmp;
size_t tmplen;
- //log_debugx("looking up %s in %s", path, node->n_key);
-
- tmp = node_path(node);
- tmplen = strlen(tmp);
- if (strncmp(tmp, path, tmplen) != 0) {
- free(tmp);
- return (NULL);
- }
- if (path[tmplen] != '/' && path[tmplen] != '\0') {
- /*
- * If we have two map entries like 'foo' and 'foobar', make
- * sure the search for 'foobar' won't match 'foo' instead.
- */
+ //log_debugx("looking up %s in %s", path, node_path(node));
+
+ if (!node_is_direct_key(node)) {
+ tmp = node_path(node);
+ tmplen = strlen(tmp);
+ if (strncmp(tmp, path, tmplen) != 0) {
+ free(tmp);
+ return (NULL);
+ }
+ if (path[tmplen] != '/' && path[tmplen] != '\0') {
+ /*
+ * If we have two map entries like 'foo' and 'foobar', make
+ * sure the search for 'foobar' won't match 'foo' instead.
+ */
+ free(tmp);
+ return (NULL);
+ }
free(tmp);
- return (NULL);
}
- free(tmp);
TAILQ_FOREACH(child, &node->n_children, n_next) {
found = node_find_x(child, path);
@@ -685,6 +687,9 @@ node_find_x(struct node *node, const char *path)
return (found);
}
+ if (node->n_parent == NULL || node_is_direct_key(node))
+ return (NULL);
+
return (node);
}
@@ -693,9 +698,12 @@ node_find(struct node *root, const char *path)
{
struct node *node;
+ assert(root->n_parent == NULL);
+
node = node_find_x(root, path);
- if (node == root)
- return (NULL);
+ if (node != NULL)
+ assert(node != root);
+
return (node);
}
OpenPOWER on IntegriCloud