Module Name:    src
Committed By:   erh
Date:           Mon Jul 25 04:40:51 UTC 2016

Modified Files:
        src/sbin/mount_null: mount_null.c

Log Message:
Eliminate the distinct path check, since the paths don't actually need to be
 distinct and allowing this makes certain useful tasks possible, such as
 fixing an unpopulated /dev while a tmpfs is mounted over it.
However, require the paths to be different, as mounting a path directly over
 itself has the side effect of causing any other mount points within that path
 to no longer be accessible, and is difficult to unmount when done on /.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/mount_null/mount_null.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/mount_null/mount_null.c
diff -u src/sbin/mount_null/mount_null.c:1.19 src/sbin/mount_null/mount_null.c:1.20
--- src/sbin/mount_null/mount_null.c:1.19	Mon Aug 29 14:35:02 2011
+++ src/sbin/mount_null/mount_null.c	Mon Jul 25 04:40:51 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: mount_null.c,v 1.19 2011/08/29 14:35:02 joerg Exp $	*/
+/*	$NetBSD: mount_null.c,v 1.20 2016/07/25 04:40:51 erh Exp $	*/
 
 /*
  * Copyright (c) 1992, 1993, 1994
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 19
 #if 0
 static char sccsid[] = "@(#)mount_null.c	8.6 (Berkeley) 4/26/95";
 #else
-__RCSID("$NetBSD: mount_null.c,v 1.19 2011/08/29 14:35:02 joerg Exp $");
+__RCSID("$NetBSD: mount_null.c,v 1.20 2016/07/25 04:40:51 erh Exp $");
 #endif
 #endif /* not lint */
 
@@ -65,7 +65,6 @@ static const struct mntopt mopts[] = {
 };
 
 int	mount_null(int argc, char **argv);
-static int	subdir(const char *, const char *);
 __dead static void	usage(void);
 
 #ifndef MOUNT_NOMAIN
@@ -117,8 +116,8 @@ mount_null(int argc, char *argv[])
 		warnx("using \"%s\" instead.", canon_dir);
 	}
 
-	if (subdir(target, canon_dir) || subdir(canon_dir, target))
-		errx(1, "%s (%s) and %s (%s) are not distinct paths",
+	if (strcmp(target, canon_dir) == 0)
+		errx(1, "%s (%s) and %s (%s) are identical paths",
 		    argv[0], target, argv[1], canon_dir);
 
 	args.la.target = target;
@@ -128,21 +127,6 @@ mount_null(int argc, char *argv[])
 	exit(0);
 }
 
-static int
-subdir(const char *p, const char *dir)
-{
-	int l;
-
-	l = strlen(dir);
-	if (l <= 1)
-		return (1);
-
-	if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
-		return (1);
-
-	return (0);
-}
-
 static void
 usage(void)
 {

Reply via email to