Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Mar 2015 15:20:13 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r279812 - head/usr.sbin/autofs
Message-ID:  <201503091520.t29FKDrG069695@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Mon Mar  9 15:20:12 2015
New Revision: 279812
URL: https://svnweb.freebsd.org/changeset/base/279812

Log:
  Remove some particularly bad code; no functional changes.
  
  MFC after:	1 month
  Sponsored by:	The FreeBSD Foundation

Modified:
  head/usr.sbin/autofs/auto_master.5
  head/usr.sbin/autofs/common.c

Modified: head/usr.sbin/autofs/auto_master.5
==============================================================================
--- head/usr.sbin/autofs/auto_master.5	Mon Mar  9 14:46:10 2015	(r279811)
+++ head/usr.sbin/autofs/auto_master.5	Mon Mar  9 15:20:12 2015	(r279812)
@@ -260,6 +260,11 @@ when they are automatically created.
 .It Li -media
 Query devices that are not yet mounted, but contain valid filesystems.
 Generally used to access files on removable media.
+.It Li -noauto
+Mount filesystems configured in
+.Xr fstab 5
+as "noauto".
+This needs to be set up as a direct map.
 .It Li -null
 Prevent
 .Xr automountd 8

Modified: head/usr.sbin/autofs/common.c
==============================================================================
--- head/usr.sbin/autofs/common.c	Mon Mar  9 14:46:10 2015	(r279811)
+++ head/usr.sbin/autofs/common.c	Mon Mar  9 15:20:12 2015	(r279812)
@@ -86,46 +86,7 @@ checked_strdup(const char *s)
 }
 
 /*
- * Take two pointers to strings, concatenate the contents with "/" in the
- * middle, make the first pointer point to the result, the second pointer
- * to NULL, and free the old strings.
- *
- * Concatenate pathnames, basically.
- */
-static void
-concat(char **p1, char **p2)
-{
-	int ret;
-	char *path;
-
-	assert(p1 != NULL);
-	assert(p2 != NULL);
-
-	if (*p1 == NULL)
-		*p1 = checked_strdup("");
-
-	if (*p2 == NULL)
-		*p2 = checked_strdup("");
-
-	ret = asprintf(&path, "%s/%s", *p1, *p2);
-	if (ret < 0)
-		log_err(1, "asprintf");
-
-	/*
-	 * XXX
-	 */
-	//free(*p1);
-	//free(*p2);
-
-	*p1 = path;
-	*p2 = NULL;
-}
-
-/*
  * Concatenate two strings, inserting separator between them, unless not needed.
- *
- * This function is very convenient to use when you do not care about freeing
- * memory - which is okay here, because we are a short running process.
  */
 char *
 separated_concat(const char *s1, const char *s2, char separator)
@@ -151,7 +112,7 @@ separated_concat(const char *s1, const c
 	if (ret < 0)
 		log_err(1, "asprintf");
 
-	//log_debugx("separated_concat: got %s and %s, returning %s", s1, s2, result);
+	//log_debugx("%s: got %s and %s, returning %s", __func__, s1, s2, result);
 
 	return (result);
 }
@@ -159,7 +120,7 @@ separated_concat(const char *s1, const c
 void
 create_directory(const char *path)
 {
-	char *component, *copy, *tofree, *partial;
+	char *component, *copy, *tofree, *partial, *tmp;
 	int error;
 
 	assert(path[0] == '/');
@@ -169,12 +130,14 @@ create_directory(const char *path)
 	 */
 	copy = tofree = checked_strdup(path + 1);
 
-	partial = NULL;
+	partial = checked_strdup("");
 	for (;;) {
 		component = strsep(&copy, "/");
 		if (component == NULL)
 			break;
-		concat(&partial, &component);
+		tmp = separated_concat(partial, component, '/');
+		free(partial);
+		partial = tmp;
 		//log_debugx("creating \"%s\"", partial);
 		error = mkdir(partial, 0755);
 		if (error != 0 && errno != EEXIST) {



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