Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/mount_null Eliminate the distinct path check, since the...



details:   https://anonhg.NetBSD.org/src/rev/de3e1fb20c01
branches:  trunk
changeset: 346644:de3e1fb20c01
user:      erh <erh%NetBSD.org@localhost>
date:      Mon Jul 25 04:40:51 2016 +0000

description:
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 /.

diffstat:

 sbin/mount_null/mount_null.c |  24 ++++--------------------
 1 files changed, 4 insertions(+), 20 deletions(-)

diffs (59 lines):

diff -r 89f17be8d99b -r de3e1fb20c01 sbin/mount_null/mount_null.c
--- a/sbin/mount_null/mount_null.c      Mon Jul 25 04:21:19 2016 +0000
+++ b/sbin/mount_null/mount_null.c      Mon Jul 25 04:40:51 2016 +0000
@@ -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 @@
 #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 @@
 };
 
 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 @@
                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 @@
        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)
 {



Home | Main Index | Thread Index | Old Index