Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 May 2015 13:29:34 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org
Subject:   svn commit: r283233 - stable/10/usr.sbin/autofs
Message-ID:  <201505211329.t4LDTYJ5098971@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Thu May 21 13:29:34 2015
New Revision: 283233
URL: https://svnweb.freebsd.org/changeset/base/283233

Log:
  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

Modified:
  stable/10/usr.sbin/autofs/common.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/usr.sbin/autofs/common.c
==============================================================================
--- stable/10/usr.sbin/autofs/common.c	Thu May 21 13:26:52 2015	(r283232)
+++ stable/10/usr.sbin/autofs/common.c	Thu May 21 13:29:34 2015	(r283233)
@@ -661,23 +661,25 @@ node_find_x(struct node *node, const cha
 	char *tmp;
 	size_t tmplen;
 
-	//log_debugx("looking up %s in %s", path, node->n_key);
+	//log_debugx("looking up %s in %s", path, node_path(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.
-		 */
+	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 cha
 			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 
 {
 	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);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201505211329.t4LDTYJ5098971>