ensure mounts use disjoint parts of the namespace
authorJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Tue, 22 Feb 1994 18:02:14 +0000 (10:02 -0800)
committerJan-Simon Pendry <pendry@ucbvax.Berkeley.EDU>
Tue, 22 Feb 1994 18:02:14 +0000 (10:02 -0800)
SCCS-vsn: sbin/mount_union/mount_union.c 8.3
SCCS-vsn: sbin/mount_null/mount_null.c 8.4
SCCS-vsn: old/mount_lofs/mount_lofs.c 8.3

usr/src/old/mount_lofs/mount_lofs.c
usr/src/sbin/mount_null/mount_null.c
usr/src/sbin/mount_union/mount_union.c

index 2259ea2..f494347 100644 (file)
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)mount_lofs.c        8.2 (Berkeley) %G%
+ *     @(#)mount_lofs.c        8.3 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-static int subdir __P((char *, char *));
+static int subdir __P((const char *, const char *));
 void usage __P((void));
 
 int
 void usage __P((void));
 
 int
@@ -55,9 +55,9 @@ main(argc, argv)
                exit(1);
        }
 
                exit(1);
        }
 
-       if (subdir(target, argv[1])) {
+       if (subdir(target, argv[1]) || subdir(argv[1], target)) {
                (void)fprintf(stderr,
                (void)fprintf(stderr,
-                       "mount_lofs: %s (%s) is a sub directory of %s\n",
+                       "mount_lofs: %s (%s) and %s are not distinct paths\n",
                                argv[0], target, argv[1]);
                exit(1);
        }
                                argv[0], target, argv[1]);
                exit(1);
        }
@@ -73,8 +73,8 @@ main(argc, argv)
 
 static int
 subdir(p, dir)
 
 static int
 subdir(p, dir)
-       char *p;
-       char *dir;
+       const char *p;
+       const char *dir;
 {
        int l;
 
 {
        int l;
 
@@ -82,7 +82,7 @@ subdir(p, dir)
        if (l <= 1)
                return (1);
 
        if (l <= 1)
                return (1);
 
-       if ((strncmp(p, dir, l) == 0) && (p[l] == '/'))
+       if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
                return (1);
 
        return (0);
                return (1);
 
        return (0);
index 586ffc7..ebf3193 100644 (file)
@@ -8,7 +8,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)mount_null.c        8.3 (Berkeley) %G%
+ *     @(#)mount_null.c        8.4 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -21,7 +21,7 @@
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-static int subdir __P((char *, char *));
+static int subdir __P((const char *, const char *));
 void usage __P((void));
 
 int
 void usage __P((void));
 
 int
@@ -55,9 +55,9 @@ main(argc, argv)
                exit(1);
        }
 
                exit(1);
        }
 
-       if (subdir(target, argv[1])) {
+       if (subdir(target, argv[1]) || subdir(argv[1], target)) {
                (void)fprintf(stderr,
                (void)fprintf(stderr,
-                       "mount_null: %s (%s) is a sub directory of %s\n",
+                       "mount_null: %s (%s) and %s are not distinct paths\n",
                                argv[0], target, argv[1]);
                exit(1);
        }
                                argv[0], target, argv[1]);
                exit(1);
        }
@@ -73,8 +73,8 @@ main(argc, argv)
 
 static int
 subdir(p, dir)
 
 static int
 subdir(p, dir)
-       char *p;
-       char *dir;
+       const char *p;
+       const char *dir;
 {
        int l;
 
 {
        int l;
 
@@ -82,7 +82,7 @@ subdir(p, dir)
        if (l <= 1)
                return (1);
 
        if (l <= 1)
                return (1);
 
-       if ((strncmp(p, dir, l) == 0) && (p[l] == '/'))
+       if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
                return (1);
 
        return (0);
                return (1);
 
        return (0);
index c9cd373..3c7ef70 100644 (file)
@@ -7,7 +7,7 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *     @(#)mount_union.c       8.2 (Berkeley) %G%
+ *     @(#)mount_union.c       8.3 (Berkeley) %G%
  */
 
 #include <sys/param.h>
  */
 
 #include <sys/param.h>
@@ -20,7 +20,7 @@
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdlib.h>
 #include <string.h>
 
-static int subdir __P((char *, char *));
+static int subdir __P((const char *, const char *));
 void usage __P((void));
 
 int
 void usage __P((void));
 
 int
@@ -89,10 +89,10 @@ main(argc, argv)
                exit(1);
        }
 
                exit(1);
        }
 
-       if (subdir(target, argv[1])) {
+       if (subdir(target, argv[1]) || subdir(argv[1], target)) {
                (void)fprintf(stderr,
                (void)fprintf(stderr,
-                       "mount_union: %s is a sub-directory of %s\n",
-                               argv[0], argv[1]);
+                       "mount_union: %s (%s) and %s are not distinct paths\n",
+                               argv[0], target, argv[1]);
                exit(1);
        }
 
                exit(1);
        }
 
@@ -107,8 +107,8 @@ main(argc, argv)
 
 static int
 subdir(p, dir)
 
 static int
 subdir(p, dir)
-       char *p;
-       char *dir;
+       const char *p;
+       const char *dir;
 {
        int l;
 
 {
        int l;
 
@@ -116,7 +116,7 @@ subdir(p, dir)
        if (l <= 1)
                return (1);
 
        if (l <= 1)
                return (1);
 
-       if ((strncmp(p, dir, l) == 0) && (p[l] == '/'))
+       if ((strncmp(p, dir, l) == 0) && (p[l] == '/' || p[l] == '\0'))
                return (1);
 
        return (0);
                return (1);
 
        return (0);