Jan-Simon Pendry's and my new mount code
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 Mar 1994 00:13:06 +0000 (16:13 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Mon, 28 Mar 1994 00:13:06 +0000 (16:13 -0800)
SCCS-vsn: sbin/mount_fdesc/Makefile 8.2
SCCS-vsn: sbin/mount_fdesc/mount_fdesc.8 8.2
SCCS-vsn: sbin/mount_fdesc/mount_fdesc.c 8.2
SCCS-vsn: sbin/mount_kernfs/Makefile 8.2
SCCS-vsn: sbin/mount_kernfs/mount_kernfs.8 8.2
SCCS-vsn: sbin/mount_kernfs/mount_kernfs.c 8.2
SCCS-vsn: sbin/mount_lfs/Makefile 8.2
SCCS-vsn: sbin/mount_lfs/mount_lfs.8 8.3
SCCS-vsn: sbin/mount_lfs/mount_lfs.c 8.3
SCCS-vsn: old/mount_lofs/Makefile 8.3
SCCS-vsn: old/mount_lofs/mount_lofs.8 8.2
SCCS-vsn: old/mount_lofs/mount_lofs.c 8.4
SCCS-vsn: sbin/mount_null/Makefile 8.3
SCCS-vsn: sbin/mount_null/mount_null.8 8.3
SCCS-vsn: sbin/mount_null/mount_null.c 8.5

15 files changed:
usr/src/old/mount_lofs/Makefile
usr/src/old/mount_lofs/mount_lofs.8
usr/src/old/mount_lofs/mount_lofs.c
usr/src/sbin/mount_fdesc/Makefile
usr/src/sbin/mount_fdesc/mount_fdesc.8
usr/src/sbin/mount_fdesc/mount_fdesc.c
usr/src/sbin/mount_kernfs/Makefile
usr/src/sbin/mount_kernfs/mount_kernfs.8
usr/src/sbin/mount_kernfs/mount_kernfs.c
usr/src/sbin/mount_lfs/Makefile
usr/src/sbin/mount_lfs/mount_lfs.8
usr/src/sbin/mount_lfs/mount_lfs.c
usr/src/sbin/mount_null/Makefile
usr/src/sbin/mount_null/mount_null.8
usr/src/sbin/mount_null/mount_null.c

index 717c035..29090d8 100644 (file)
@@ -1,7 +1,11 @@
-#      @(#)Makefile    8.2 (Berkeley) %G%
+#      @(#)Makefile    8.3 (Berkeley) %G%
 
 
-CFLAGS+=-I/sys
 PROG=  mount_lofs
 PROG=  mount_lofs
+SRCS=  mount_lofs.c getmntopts.c
 MAN8=  mount_lofs.0
 
 MAN8=  mount_lofs.0
 
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+=-I/sys -I${MOUNT}
+.PATH: ${MOUNT}
+
 .include <bsd.prog.mk>
 .include <bsd.prog.mk>
index db204a4..27703c3 100644 (file)
@@ -1,5 +1,5 @@
 .\"
 .\"
-.\" Copyright (c) 1992, 1993
+.\" Copyright (c) 1992, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
 .\"
 .\"    The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
 .\"
@@ -8,7 +8,7 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"    @(#)mount_lofs.8        8.1 (Berkeley) %G%
+.\"    @(#)mount_lofs.8        8.2 (Berkeley) %G%
 .\"
 .\"
 .Dd 
 .\"
 .\"
 .Dd 
@@ -19,8 +19,9 @@
 .Nd mount a virtual copy of an existing filesystem sub-tree
 .Sh SYNOPSIS
 .Nm mount_lofs
 .Nd mount a virtual copy of an existing filesystem sub-tree
 .Sh SYNOPSIS
 .Nm mount_lofs
-.Op Fl F Ar fsoptions
-.Ar target mount-point
+.Op Fl o Ar options
+.Ar target
+.Ar mount-point
 .Sh DESCRIPTION
 The
 .Nm mount_lofs
 .Sh DESCRIPTION
 The
 .Nm mount_lofs
@@ -37,6 +38,18 @@ may be mounted on the virtual copy without affecting the original.
 A different device number for the virtual copy is returned by
 .Xr stat 2 ,
 but in other respects it is indistinguishable from the original.
 A different device number for the virtual copy is returned by
 .Xr stat 2 ,
 but in other respects it is indistinguishable from the original.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl o
+Options are specified with a
+.Fl o
+flag followed by a comma separated string of options.
+See the
+.Xr mount 8
+man page for possible options and their meanings.
+.Sh SEE ALSO
+.Xr mount 8
 .Sh HISTORY
 The
 .Nm mount_lofs
 .Sh HISTORY
 The
 .Nm mount_lofs
index f494347..fdb7a0c 100644 (file)
@@ -1,28 +1,43 @@
 /*
 /*
- * Copyright (c) 1992, 1993
+ * Copyright (c) 1992, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *     The Regents of the University of California.  All rights reserved.
- * All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
  * %sccs.include.redist.c%
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
  * %sccs.include.redist.c%
- *
- *     @(#)mount_lofs.c        8.3 (Berkeley) %G%
  */
 
  */
 
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1992, 1993, 1994\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)mount_lofs.c       8.4 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <sys/param.h>
 #include <sys/mount.h>
 #include <sys/param.h>
 #include <sys/mount.h>
+
 #include <miscfs/lofs/lofs.h>
 
 #include <miscfs/lofs/lofs.h>
 
-#include <errno.h>
+#include <err.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 
-static int subdir __P((const char *, const char *));
-void usage __P((void));
+#include "mntopts.h"
+
+struct mntopt mopts[] = {
+       MOPT_STDOPTS,
+       { NULL }
+};
+
+int    subdir __P((const char *, const char *));
+void   usage __P((void));
 
 int
 main(argc, argv)
 
 int
 main(argc, argv)
@@ -34,10 +49,10 @@ main(argc, argv)
        char target[MAXPATHLEN];
 
        mntflags = 0;
        char target[MAXPATHLEN];
 
        mntflags = 0;
-       while ((ch = getopt(argc, argv, "F:")) != EOF)
-               switch(ch) {
-               case 'F':
-                       mntflags = atoi(optarg);
+       while ((ch = getopt(argc, argv, "o:")) != EOF)
+               switch (ch) {
+               case 'o':
+                       getmntopts(optarg, mopts, &mntflags);
                        break;
                case '?':
                default:
                        break;
                case '?':
                default:
@@ -49,29 +64,21 @@ main(argc, argv)
        if (argc != 2)
                usage();
 
        if (argc != 2)
                usage();
 
-       if (realpath(argv[0], target) == 0) {
-               (void)fprintf(stderr, "mount_lofs: %s: %s\n",
-                               target, strerror(errno));
-               exit(1);
-       }
+       if (realpath(argv[0], target) == 0)
+               err(1, "%s", target);
 
 
-       if (subdir(target, argv[1]) || subdir(argv[1], target)) {
-               (void)fprintf(stderr,
-                       "mount_lofs: %s (%s) and %s are not distinct paths\n",
-                               argv[0], target, argv[1]);
-               exit(1);
-       }
+       if (subdir(target, argv[1]) || subdir(argv[1], target))
+               errx(1, "%s (%s) and %s are not distinct paths",
+                   argv[0], target, argv[1]);
 
        args.target = target;
 
 
        args.target = target;
 
-       if (mount(MOUNT_LOFS, argv[1], mntflags, &args)) {
-               (void)fprintf(stderr, "mount_lofs: %s\n", strerror(errno));
-               exit(1);
-       }
+       if (mount(MOUNT_LOFS, argv[1], mntflags, &args))
+               err(1, NULL);
        exit(0);
 }
 
        exit(0);
 }
 
-static int
+int
 subdir(p, dir)
        const char *p;
        const char *dir;
 subdir(p, dir)
        const char *p;
        const char *dir;
@@ -92,6 +99,6 @@ void
 usage()
 {
        (void)fprintf(stderr,
 usage()
 {
        (void)fprintf(stderr,
-           "usage: mount_lofs [ -F fsoptions ] target_fs mount_point\n");
+               "usage: mount_lofs [-o options] target_fs mount_point\n");
        exit(1);
 }
        exit(1);
 }
index 49ff25f..143a4a0 100644 (file)
@@ -1,6 +1,11 @@
-#      @(#)Makefile    8.1 (Berkeley) %G%
+#      @(#)Makefile    8.2 (Berkeley) %G%
 
 PROG=  mount_fdesc
 
 PROG=  mount_fdesc
+SRCS=  mount_fdesc.c getmntopts.c
 MAN8=  mount_fdesc.0
 
 MAN8=  mount_fdesc.0
 
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+= -I${MOUNT}
+.PATH: ${MOUNT}
+
 .include <bsd.prog.mk>
 .include <bsd.prog.mk>
index 0cb7304..efc4475 100644 (file)
@@ -1,5 +1,5 @@
 .\"
 .\"
-.\" Copyright (c) 1992, 1993
+.\" Copyright (c) 1992, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
 .\"
 .\"    The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
 .\"
@@ -8,7 +8,7 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"    @(#)mount_fdesc.8       8.1 (Berkeley) %G%
+.\"    @(#)mount_fdesc.8       8.2 (Berkeley) %G%
 .\"
 .\"
 .Dd 
 .\"
 .\"
 .Dd 
@@ -19,9 +19,9 @@
 .Nd mount the file-descriptor file system
 .Sh SYNOPSIS
 .Nm mount_fdesc
 .Nd mount the file-descriptor file system
 .Sh SYNOPSIS
 .Nm mount_fdesc
-.Op Fl F Ar fsoptions
-.Pa fdesc
-.Pa mount_point
+.Op Fl o Ar options
+.Ar fdesc
+.Ar mount_point
 .Sh DESCRIPTION
 The
 .Nm mount_fdesc
 .Sh DESCRIPTION
 The
 .Nm mount_fdesc
@@ -36,6 +36,17 @@ This command is normally executed by
 .Xr mount 8
 at boot time.
 .Pp
 .Xr mount 8
 at boot time.
 .Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl o
+Options are specified with a
+.Fl o
+flag followed by a comma separated string of options.
+See the
+.Xr mount 8
+man page for possible options and their meanings.
+.El
+.Pp
 The contents of the mount point are
 .Pa fd ,
 .Pa stderr ,
 The contents of the mount point are
 .Pa fd ,
 .Pa stderr ,
@@ -109,7 +120,8 @@ the real controlling terminal device.
 .Xr mount 2 ,
 .Xr unmount 2 ,
 .Xr tty 4 ,
 .Xr mount 2 ,
 .Xr unmount 2 ,
 .Xr tty 4 ,
-.Xr fstab 5
+.Xr fstab 5 ,
+.Xr mount 8
 .Sh CAVEATS
 No
 .Pa .
 .Sh CAVEATS
 No
 .Pa .
index 02bd5c9..e0816af 100644 (file)
@@ -1,26 +1,41 @@
 /*
  * Copyright (c) 1990, 1992 Jan-Simon Pendry
 /*
  * Copyright (c) 1990, 1992 Jan-Simon Pendry
- * Copyright (c) 1992, 1993
+ * Copyright (c) 1992, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Jan-Simon Pendry.
  *
  * %sccs.include.redist.c%
  *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Jan-Simon Pendry.
  *
  * %sccs.include.redist.c%
- *
- *     @(#)mount_fdesc.c       8.1 (Berkeley) %G%
  */
 
  */
 
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1992, 1993, 1994\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)mount_fdesc.c      8.2 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <sys/param.h>
 #include <sys/mount.h>
 
 #include <sys/param.h>
 #include <sys/mount.h>
 
-#include <errno.h>
+#include <err.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-void usage __P((void));
+#include "mntopts.h"
+
+struct mntopt mopts[] = {
+       MOPT_STDOPTS,
+       { NULL }
+};
+
+void   usage __P((void));
 
 int
 main(argc, argv)
 
 int
 main(argc, argv)
@@ -30,10 +45,10 @@ main(argc, argv)
        int ch, mntflags;
 
        mntflags = 0;
        int ch, mntflags;
 
        mntflags = 0;
-       while ((ch = getopt(argc, argv, "F:")) != EOF)
-               switch(ch) {
-               case 'F':
-                       mntflags = atoi(optarg);
+       while ((ch = getopt(argc, argv, "o:")) != EOF)
+               switch (ch) {
+               case 'o':
+                       getmntopts(optarg, mopts, &mntflags);
                        break;
                case '?':
                default:
                        break;
                case '?':
                default:
@@ -45,10 +60,8 @@ main(argc, argv)
        if (argc != 2)
                usage();
 
        if (argc != 2)
                usage();
 
-       if (mount(MOUNT_FDESC, argv[1], mntflags, NULL)) {
-               (void)fprintf(stderr, "mount_fdesc: %s\n", strerror(errno));
-               exit(1);
-       }
+       if (mount(MOUNT_FDESC, argv[1], mntflags, NULL))
+               err(1, NULL);
        exit(0);
 }
 
        exit(0);
 }
 
@@ -56,6 +69,6 @@ void
 usage()
 {
        (void)fprintf(stderr,
 usage()
 {
        (void)fprintf(stderr,
-           "usage: mount_fdesc [ -F fsoptions ] /dev/fd mount_point\n");
+               "usage: mount_fdesc [-o options] fdesc mount_point\n");
        exit(1);
 }
        exit(1);
 }
index 5401120..4ea49d8 100644 (file)
@@ -1,6 +1,11 @@
-#      @(#)Makefile    8.1 (Berkeley) %G%
+#      @(#)Makefile    8.2 (Berkeley) %G%
 
 PROG=  mount_kernfs
 
 PROG=  mount_kernfs
+SRCS=  mount_kernfs.c getmntopts.c
 MAN8=  mount_kernfs.0
 
 MAN8=  mount_kernfs.0
 
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+= -I${MOUNT}
+.PATH: ${MOUNT}
+
 .include <bsd.prog.mk>
 .include <bsd.prog.mk>
index 593aaa6..7b00dc1 100644 (file)
@@ -1,5 +1,5 @@
 .\"
 .\"
-.\" Copyright (c) 1992, 1993
+.\" Copyright (c) 1992, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
 .\"
 .\"    The Regents of the University of California.  All rights reserved.
 .\" All rights reserved.
 .\"
@@ -8,7 +8,7 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"    @(#)mount_kernfs.8      8.1 (Berkeley) %G%
+.\"    @(#)mount_kernfs.8      8.2 (Berkeley) %G%
 .\"
 .\"
 .Dd 
 .\"
 .\"
 .Dd 
@@ -19,9 +19,9 @@
 .Nd mount the /kern file system
 .Sh SYNOPSIS
 .Nm mount_kernfs
 .Nd mount the /kern file system
 .Sh SYNOPSIS
 .Nm mount_kernfs
-.Op Fl F Ar fsoptions
-.Pa /kern
-.Pa mount_point
+.Op Fl o Ar options
+.Ar /kern
+.Ar mount_point
 .Sh DESCRIPTION
 The
 .Nm mount_kern
 .Sh DESCRIPTION
 The
 .Nm mount_kern
@@ -38,6 +38,17 @@ some of which can also be written.
 The contents of the files is in a machine-independent format,
 either a string, or an integer in decimal ASCII.
 Where numbers are returned, a trailing newline character is also added.
 The contents of the files is in a machine-independent format,
 either a string, or an integer in decimal ASCII.
 Where numbers are returned, a trailing newline character is also added.
+.Pp
+The options are as follows:
+.Bl -tag -width indent
+.It Fl o
+Options are specified with a
+.Fl o
+flag followed by a comma separated string of options.
+See the
+.Xr mount 8
+man page for possible options and their meanings.
+.El
 .Sh FILES
 .Bl -tag -width copyright -compact
 .It Pa boottime
 .Sh FILES
 .Bl -tag -width copyright -compact
 .It Pa boottime
@@ -84,7 +95,8 @@ can be generated by running:
 .Sh SEE ALSO
 .Xr mount 2 ,
 .Xr unmount 2 ,
 .Sh SEE ALSO
 .Xr mount 2 ,
 .Xr unmount 2 ,
-.Xr fstab 5
+.Xr fstab 5 ,
+.Xr mount 8
 .Sh CAVEATS
 This filesystem may not be NFS-exported.
 .Sh HISTORY
 .Sh CAVEATS
 This filesystem may not be NFS-exported.
 .Sh HISTORY
index 64206cd..79f6c4f 100644 (file)
@@ -1,26 +1,41 @@
 /*
  * Copyright (c) 1990, 1992 Jan-Simon Pendry
 /*
  * Copyright (c) 1990, 1992 Jan-Simon Pendry
- * Copyright (c) 1992, 1993
+ * Copyright (c) 1992, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Jan-Simon Pendry.
  *
  *     The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley by
  * Jan-Simon Pendry.
  *
- * %sccs.redist.c.%
- *
- *     @(#)mount_kernfs.c      8.1 (Berkeley) %G%
+ * %sccs.include.redist.c%
  */
 
  */
 
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1992, 1993, 1994\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)mount_kernfs.c     8.2 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <sys/param.h>
 #include <sys/mount.h>
 
 #include <sys/param.h>
 #include <sys/mount.h>
 
-#include <errno.h>
+#include <err.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-void usage __P((void));
+#include "mntopts.h"
+
+struct mntopt mopts[] = {
+       MOPT_STDOPTS,
+       { NULL }
+};
+
+void   usage __P((void));
 
 int
 main(argc, argv)
 
 int
 main(argc, argv)
@@ -30,10 +45,10 @@ main(argc, argv)
        int ch, mntflags;
 
        mntflags = 0;
        int ch, mntflags;
 
        mntflags = 0;
-       while ((ch = getopt(argc, argv, "F:")) != EOF)
-               switch(ch) {
-               case 'F':
-                       mntflags = atoi(optarg);
+       while ((ch = getopt(argc, argv, "o:")) != EOF)
+               switch (ch) {
+               case 'o':
+                       getmntopts(optarg, mopts, &mntflags);
                        break;
                case '?':
                default:
                        break;
                case '?':
                default:
@@ -45,10 +60,8 @@ main(argc, argv)
        if (argc != 2)
                usage();
 
        if (argc != 2)
                usage();
 
-       if (mount(MOUNT_KERNFS, argv[1], mntflags, NULL)) {
-               (void)fprintf(stderr, "mount_kernfs: %s\n", strerror(errno));
-               exit(1);
-       }
+       if (mount(MOUNT_KERNFS, argv[1], mntflags, NULL))
+               err(1, NULL);
        exit(0);
 }
 
        exit(0);
 }
 
@@ -56,6 +69,6 @@ void
 usage()
 {
        (void)fprintf(stderr,
 usage()
 {
        (void)fprintf(stderr,
-           "usage: mount_kernfs [ -F fsoptions ] /kern mount_point\n");
+               "usage: mount_kernfs [-o options] /kern mount_point\n");
        exit(1);
 }
        exit(1);
 }
index a6064c2..e75d00c 100644 (file)
@@ -1,6 +1,11 @@
-#      @(#)Makefile    8.1 (Berkeley) %G%
+#      @(#)Makefile    8.2 (Berkeley) %G%
 
 PROG=  mount_lfs
 
 PROG=  mount_lfs
+SRCS=  mount_lfs.c getmntopts.c
 MAN8=  mount_lfs.0
 
 MAN8=  mount_lfs.0
 
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+= -I${MOUNT}
+.PATH: ${MOUNT}
+
 .include <bsd.prog.mk>
 .include <bsd.prog.mk>
index 89c823f..dae3847 100644 (file)
@@ -1,9 +1,9 @@
-.\" Copyright (c) 1993
+.\" Copyright (c) 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"    @(#)mount_lfs.8 8.2 (Berkeley) %G%
+.\"    @(#)mount_lfs.8 8.3 (Berkeley) %G%
 .\"
 .Dd ""
 .Dt MOUNT_LFS 8
 .\"
 .Dd ""
 .Dt MOUNT_LFS 8
 .Sh SYNOPSIS
 .Nm mount_lfs
 .Op Fl dns
 .Sh SYNOPSIS
 .Nm mount_lfs
 .Op Fl dns
-.Op Fl F fsoptions
-.Pa device
-.Pa mount_point
+.Op Fl o Ar options
+.Ar special
+.Ar node
 .Sh DESCRIPTION
 The
 .Nm mount_lfs
 .Sh DESCRIPTION
 The
 .Nm mount_lfs
-command attaches the log-structured file system
-residing on the device named by
-.Ar device
-to the global file system namespace.
-The file system is attached at the point
-specified by
-.Ar mount_point .
+command attaches a log-structured file system
+.Ar special
+device on to the file system tree at the point
+.Ar node .
+In addition, the
+.Xr lfs_cleanerd 8
+utility is invoked to clean the file system periodically.
+.Pp
 This command is normally executed by
 .Xr mount 8
 at boot time.
 .Pp
 This command is normally executed by
 .Xr mount 8
 at boot time.
 .Pp
-After the file system is mounted, if the
-.Fl n
-flag is not specified then the
+The options are as follows:
+.Bl -tag -width Ds
+.It Fl d
+Run
+.Xr lfs_cleanerd 8
+in debug mode.
+.It Fl o
+Options are specified with a
+.Fl o
+flag followed by a comma separated string of options.
+See the
+.Xr mount 8
+man page for possible options and their meanings.
+.It Fl n
+Don't start
 .Xr lfs_cleanerd 8
 .Xr lfs_cleanerd 8
-program is invoked to clean the file system periodically.
-If the
-.Fl d
-or
-.Fl s
-flags are given to
-.Nm mount_lfs ,
-they are passed to the cleaner.
+on the file system.
+.It Fl s
+Cause
+.Xr lfs_cleanerd 8
+to read data in small chunks when cleaning the file system.
+.El
 .Sh SEE ALSO
 .Xr mount 2 ,
 .Xr unmount 2 ,
 .Xr fstab 5 ,
 .Sh SEE ALSO
 .Xr mount 2 ,
 .Xr unmount 2 ,
 .Xr fstab 5 ,
-.Xr lfs_cleanerd 8
-.Sh CAVEATS
-.Nm Mount_lfs
-can be run by hand if you wish to use
-the flags, and since the flags are useful
-mainly for debugging this doesn't make much
-of a difference in normal operation.
+.Xr lfs_cleanerd 8 ,
+.Xr mount 8
 .Sh HISTORY
 The
 .Nm mount_lfs
 .Sh HISTORY
 The
 .Nm mount_lfs
index 6090a9f..8ccecbf 100644 (file)
@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright (c) 1993
+ * Copyright (c) 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
  *     The Regents of the University of California.  All rights reserved.
  *
  * %sccs.include.redist.c%
@@ -7,30 +7,34 @@
 
 #ifndef lint
 static char copyright[] =
 
 #ifndef lint
 static char copyright[] =
-"@(#) Copyright (c) 1993\n\
+"@(#) Copyright (c) 1993, 1994\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)mount_lfs.c        8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount_lfs.c        8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/mount.h>
 
 #include <err.h>
 #endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/mount.h>
 
 #include <err.h>
-#include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
 
+#include "mntopts.h"
 #include "pathnames.h"
 
 #include "pathnames.h"
 
-#define DEFAULT_ROOTUID -2     /* copied from mount's UFS code */
+struct mntopt mopts[] = {
+       MOPT_STDOPTS,
+       MOPT_UPDATE,
+       { NULL }
+};
 
 
-void usage __P((void));
-void invoke_cleaner __P((char *));
+void   usage __P((void));
+void   invoke_cleaner __P((char *));
 
 int short_rds, cleaner_debug;
 
 
 int short_rds, cleaner_debug;
 
@@ -40,25 +44,25 @@ main(argc, argv)
        char *argv[];
 {
        struct ufs_args args;
        char *argv[];
 {
        struct ufs_args args;
-       int ch, mntflags;
-       int noclean;
-       char *fs_name;
+       int ch, mntflags, noclean;
+       char *fs_name, *options;
 
 
+       options = NULL;
        mntflags = noclean = 0;
        mntflags = noclean = 0;
-       while ((ch = getopt(argc, argv, "F:nsd")) != EOF)
-               switch(ch) {
-               case 'F':
-                       mntflags = atoi(optarg);
+       while ((ch = getopt(argc, argv, "dno:s")) != EOF)
+               switch (ch) {
+               case 'd':
+                       cleaner_debug = 1;
                        break;
                case 'n':
                        noclean = 1;
                        break;
                        break;
                case 'n':
                        noclean = 1;
                        break;
+               case 'o':
+                       getmntopts(optarg, mopts, &mntflags);
+                       break;
                case 's':
                        short_rds = 1;
                        break;
                case 's':
                        short_rds = 1;
                        break;
-               case 'd':
-                       cleaner_debug = 1;
-                       break;
                case '?':
                default:
                        usage();
                case '?':
                default:
                        usage();
@@ -72,44 +76,30 @@ main(argc, argv)
         args.fspec = argv[0];  /* the name of the device file */
        fs_name = argv[1];      /* the mount point */
 
         args.fspec = argv[0];  /* the name of the device file */
        fs_name = argv[1];      /* the mount point */
 
-       /* copied from mount's UFS code */
+#define DEFAULT_ROOTUID        -2
        args.export.ex_root = DEFAULT_ROOTUID;
        if (mntflags & MNT_RDONLY)
                args.export.ex_flags = MNT_EXRDONLY;
        else
                args.export.ex_flags = 0;
 
        args.export.ex_root = DEFAULT_ROOTUID;
        if (mntflags & MNT_RDONLY)
                args.export.ex_flags = MNT_EXRDONLY;
        else
                args.export.ex_flags = 0;
 
-       if (mount(MOUNT_LFS, fs_name, mntflags, &args)) {
-               (void)fprintf(stderr, "mount_lfs: %s\n", strerror(errno));
-               exit(1);
-       }
+       if (mount(MOUNT_LFS, fs_name, mntflags, &args))
+               err(1, NULL);
 
 
-       if (!noclean) {
-               /*
-                * invoke the lfs_cleanerd for this filesystem as its arg!
-                */
+       if (!noclean)
                invoke_cleaner(fs_name);
                invoke_cleaner(fs_name);
-               /* never returns */
-       }
+               /* NOTREACHED */
 
        exit(0);
 }
 
 
        exit(0);
 }
 
-void
-usage()
-{
-       (void)fprintf(stderr,
-           "usage: mount_lfs [ -nsd ] [ -F fsoptions ] device mount_point\n");
-       exit(1);
-}
-
 void
 invoke_cleaner(name)
        char *name;
 {
        char *args[6], **ap = args;
 
 void
 invoke_cleaner(name)
        char *name;
 {
        char *args[6], **ap = args;
 
-       /* build the argument list */
+       /* Build the argument list. */
        *ap++ = _PATH_LFS_CLEANERD;
        if (short_rds)
                *ap++ = "-s";
        *ap++ = _PATH_LFS_CLEANERD;
        if (short_rds)
                *ap++ = "-s";
@@ -119,5 +109,13 @@ invoke_cleaner(name)
        *ap = NULL;
 
        execv(args[0], args);
        *ap = NULL;
 
        execv(args[0], args);
-       err(1, "exec of %x failed", _PATH_LFS_CLEANERD);
+       err(1, "exec %s", _PATH_LFS_CLEANERD);
+}
+
+void
+usage()
+{
+       (void)fprintf(stderr,
+               "usage: mount_lfs [-dns] [-o options] special node\n");
+       exit(1);
 }
 }
index 88560c2..1c62fd6 100644 (file)
@@ -1,7 +1,11 @@
-#      @(#)Makefile    8.2 (Berkeley) %G%
+#      @(#)Makefile    8.3 (Berkeley) %G%
 
 
-CFLAGS+=-I/sys
 PROG=  mount_null
 PROG=  mount_null
+SRCS=  mount_null.c getmntopts.c
 MAN8=  mount_null.0
 
 MAN8=  mount_null.0
 
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+= -I/sys -I${MOUNT}
+.PATH: ${MOUNT}
+
 .include <bsd.prog.mk>
 .include <bsd.prog.mk>
index 7ecf318..9271b0e 100644 (file)
@@ -1,5 +1,5 @@
 .\"
 .\"
-.\" Copyright (c) 1992, 1993
+.\" Copyright (c) 1992, 1993, 1994
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" This code is derived from software donated to Berkeley by
 .\"    The Regents of the University of California.  All rights reserved.
 .\"
 .\" This code is derived from software donated to Berkeley by
@@ -8,7 +8,7 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"     @(#)mount_null.8       8.2 (Berkeley) %G%
+.\"     @(#)mount_null.8       8.3 (Berkeley) %G%
 .\"
 .\"
 .Dd 
 .\"
 .\"
 .Dd 
 .Nd demonstrate the use of a null file system layer
 .Sh SYNOPSIS
 .Nm mount_null
 .Nd demonstrate the use of a null file system layer
 .Sh SYNOPSIS
 .Nm mount_null
-.Op Fl F Ar fsoptions
-.Ar target mount-point
-.\"
-.\"
+.Op Fl o Ar options
+.Ar target
+.Ar mount-point
 .Sh DESCRIPTION
 The
 .Nm mount_null
 .Sh DESCRIPTION
 The
 .Nm mount_null
@@ -33,7 +32,7 @@ In this respect, it is
 similar to the loopback file system (see
 .Xr mount_lofs 8 ) .
 It differs from
 similar to the loopback file system (see
 .Xr mount_lofs 8 ) .
 It differs from
-the loopback file system in two respects:  it is implemented using
+the loopback file system in two respects: it is implemented using
 a stackable layers techniques, and it's 
 .Do
 null-node
 a stackable layers techniques, and it's 
 .Do
 null-node
@@ -41,11 +40,24 @@ null-node
 stack above
 all lower-layer vnodes, not just over directory vnodes.
 .Pp
 stack above
 all lower-layer vnodes, not just over directory vnodes.
 .Pp
-The null layer has two purposes.  First, it serves as a demonstration
-of layering by proving a layer which does nothing.  (It actually
-does everything the loopback file system does, which is slightly
-more than nothing.)  Second, the null layer can serve as a prototype
-layer.  Since it provides all necessary layer framework,
+The options are as follows:
+.Bl -tag -width indent
+.It Fl o
+Options are specified with a
+.Fl o
+flag followed by a comma separated string of options.
+See the
+.Xr mount 8
+man page for possible options and their meanings.
+.El
+.Pp
+The null layer has two purposes.
+First, it serves as a demonstration of layering by proving a layer
+which does nothing.
+(It actually does everything the loopback file system does,
+which is slightly more than nothing.)
+Second, the null layer can serve as a prototype layer.
+Since it provides all necessary layer framework,
 new file system layers can be created very easily be starting
 with a null layer.
 .Pp
 new file system layers can be created very easily be starting
 with a null layer.
 .Pp
@@ -172,6 +184,8 @@ is that vnodes arguments must be manualy mapped.
 .\"
 .\"
 .Sh SEE ALSO
 .\"
 .\"
 .Sh SEE ALSO
+.Xr mount 8
+.sp
 UCLA Technical Report CSD-910056,
 .Em "Stackable Layers: an Architecture for File System Development" .
 .Sh HISTORY
 UCLA Technical Report CSD-910056,
 .Em "Stackable Layers: an Architecture for File System Development" .
 .Sh HISTORY
index ebf3193..b252d99 100644 (file)
@@ -1,28 +1,42 @@
 /*
 /*
- * Copyright (c) 1992, 1993
+ * Copyright (c) 1992, 1993, 1994
  *     The Regents of the University of California.  All rights reserved.
  *     The Regents of the University of California.  All rights reserved.
- * All rights reserved.
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
  * %sccs.include.redist.c%
  *
  * This code is derived from software donated to Berkeley by
  * Jan-Simon Pendry.
  *
  * %sccs.include.redist.c%
- *
- *     @(#)mount_null.c        8.4 (Berkeley) %G%
  */
 
  */
 
+#ifndef lint
+char copyright[] =
+"@(#) Copyright (c) 1992, 1993, 1994\n\
+       The Regents of the University of California.  All rights reserved.\n";
+#endif /* not lint */
+
+#ifndef lint
+static char sccsid[] = "@(#)mount_null.c       8.5 (Berkeley) %G%";
+#endif /* not lint */
+
 #include <sys/param.h>
 #include <sys/mount.h>
 #include <miscfs/nullfs/null.h>
 
 #include <sys/param.h>
 #include <sys/mount.h>
 #include <miscfs/nullfs/null.h>
 
-#include <errno.h>
+#include <err.h>
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 
 #include <stdio.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <string.h>
 
-static int subdir __P((const char *, const char *));
-void usage __P((void));
+#include "mntopts.h"
+
+struct mntopt mopts[] = {
+       MOPT_STDOPTS,
+       { NULL }
+};
+
+int    subdir __P((const char *, const char *));
+void   usage __P((void));
 
 int
 main(argc, argv)
 
 int
 main(argc, argv)
@@ -34,10 +48,10 @@ main(argc, argv)
        char target[MAXPATHLEN];
 
        mntflags = 0;
        char target[MAXPATHLEN];
 
        mntflags = 0;
-       while ((ch = getopt(argc, argv, "F:")) != EOF)
+       while ((ch = getopt(argc, argv, "o:")) != EOF)
                switch(ch) {
                switch(ch) {
-               case 'F':
-                       mntflags = atoi(optarg);
+               case 'o':
+                       getmntopts(optarg, mopts, &mntflags);
                        break;
                case '?':
                default:
                        break;
                case '?':
                default:
@@ -49,29 +63,21 @@ main(argc, argv)
        if (argc != 2)
                usage();
 
        if (argc != 2)
                usage();
 
-       if (realpath(argv[0], target) == 0) {
-               (void)fprintf(stderr, "mount_null: %s: %s\n",
-                               target, strerror(errno));
-               exit(1);
-       }
+       if (realpath(argv[0], target) == 0)
+               err(1, "%s", target);
 
 
-       if (subdir(target, argv[1]) || subdir(argv[1], target)) {
-               (void)fprintf(stderr,
-                       "mount_null: %s (%s) and %s are not distinct paths\n",
-                               argv[0], target, argv[1]);
-               exit(1);
-       }
+       if (subdir(target, argv[1]) || subdir(argv[1], target))
+               errx(1, "%s (%s) and %s are not distinct paths",
+                   argv[0], target, argv[1]);
 
        args.target = target;
 
 
        args.target = target;
 
-       if (mount(MOUNT_NULL, argv[1], mntflags, &args)) {
-               (void)fprintf(stderr, "mount_null: %s\n", strerror(errno));
-               exit(1);
-       }
+       if (mount(MOUNT_NULL, argv[1], mntflags, &args))
+               err(1, NULL);
        exit(0);
 }
 
        exit(0);
 }
 
-static int
+int
 subdir(p, dir)
        const char *p;
        const char *dir;
 subdir(p, dir)
        const char *p;
        const char *dir;
@@ -92,6 +98,6 @@ void
 usage()
 {
        (void)fprintf(stderr,
 usage()
 {
        (void)fprintf(stderr,
-           "usage: mount_null [ -F fsoptions ] target_fs mount_point\n");
+               "usage: mount_null [-o options] target_fs mount_point\n");
        exit(1);
 }
        exit(1);
 }