Jan-Simon Pendry and my new mount code
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 27 Mar 1994 23:31:47 +0000 (15:31 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sun, 27 Mar 1994 23:31:47 +0000 (15:31 -0800)
mount_cd9660 pretty much completely rewritten for cleanliness, KNF, and ANSI

SCCS-vsn: sbin/mount_cd9660/Makefile 8.2
SCCS-vsn: sbin/mount_cd9660/mount_cd9660.8 8.3
SCCS-vsn: sbin/mount_cd9660/mount_cd9660.c 8.4

usr/src/sbin/mount_cd9660/Makefile
usr/src/sbin/mount_cd9660/mount_cd9660.8
usr/src/sbin/mount_cd9660/mount_cd9660.c

index 4bc2280..c39fd74 100644 (file)
@@ -1,6 +1,10 @@
-#      @(#)Makefile    8.1 (Berkeley) %G%
+#      @(#)Makefile    8.2 (Berkeley) %G%
 
 
-PROG = mount_cd9660
+PROG=  mount_cd9660
+SRCS=  mount_cd9660.c getmntopts.c
 MAN8=  ${PROG}.0
 MAN8=  ${PROG}.0
+MOUNT= ${.CURDIR}/../mount
+CFLAGS+= -I${MOUNT}
+.PATH: ${MOUNT}
 
 .include <bsd.prog.mk>
 
 .include <bsd.prog.mk>
index 4963ee1..a0f4ebd 100644 (file)
@@ -7,71 +7,57 @@
 .\"
 .\" %sccs.include.redist.roff%
 .\"
 .\"
 .\" %sccs.include.redist.roff%
 .\"
-.\"     @(#)mount_cd9660.8     8.2 (Berkeley) %G%
+.\"     @(#)mount_cd9660.8     8.3 (Berkeley) %G%
 .Dd 
 .Dt MOUNT_CD9660 8
 .Dd 
 .Dt MOUNT_CD9660 8
-.Os NetBSD 0.9
+.Os BSD 4
 .Sh NAME
 .Nm mount_cd9660
 .Nd mount an ISO-9660 filesystem
 .Sh SYNOPSIS
 .Nm mount_cd9660
 .Sh NAME
 .Nm mount_cd9660
 .Nd mount an ISO-9660 filesystem
 .Sh SYNOPSIS
 .Nm mount_cd9660
-.Op Fl F Ar fsoptions
-.Op Fl norrip
-.Op Fl gen
-.Op Fl extattr
-.Pa special
-.Pa node
+.Op Fl egr
+.Op Fl o Ar options
+.Ar special | node
 .Sh DESCRIPTION
 The
 .Nm mount_cd9660
 .Sh DESCRIPTION
 The
 .Nm mount_cd9660
-command attaches the ISO-9660 filesystem residing on
-the device
+command attaches the ISO-9660 filesystem residing on the device
 .Pa special
 .Pa special
-to the global filesystem namespace at the location
-indicated by
+to the global filesystem namespace at the location indicated by
 .Pa node .
 This command is normally executed by
 .Xr mount 8
 at boot time.
 .Pp
 .Pa node .
 This command is normally executed by
 .Xr mount 8
 at boot time.
 .Pp
-If the filesystem includes Rockridge extensions, they are
-used unless the
-.Fl norrip
-flag is used.  If that option is given to
-.Nm
-then the Rockridge extensions will be ignored.
-.Pp
-Version numbers on files are normally stripped on directory listings.
-If you want to see those, use the
-.Fl gen
-flag.
-Otherwise, if there are files with different version numbers on the disk,
-only the last one will be listed.
-In either case, you may open a file with or without explicitly stating the
+The options are as follows:
+.Bl -tag -width indent
+.It Fl e
+Enable the use of extended attributes.
+.It Fl g
+Do not strip version numbers on files.
+(By default, if there are files with different version numbers on the disk,
+only the last one will be listed.)
+In either case, files may be opened without explicitly stating a
 version number.
 version number.
-.Pp
-If a disk contains extended attributes, they are normally ignored.
-You can enable the usage of extended attributes with the
-.Fl extattr
-flag.
-.Sh EXAMPLES
-.Bd -literal -offset indent -compact
-mount_cd9660 /dev/cd0d /cdrom
-mount_cd9660 \-norrip /dev/cd0d /cdrom
-mount_cd9660 \-norrip \-gen /dev/cd0d /cdrom
-mount \-t cd9660 /dev/cd0d /cdrom
-mount \-t cd9660 \-o \-norrip /dev/cd0d /cdrom
-mount \-t cd9660 \-o \-gen,\-extattr /dev/cd0d /cdrom
-.Ed
+.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 r
+Do not use any Rockridge extensions included in the filesystem.
+.El
 .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 BUGS
 .Sh BUGS
-The cd9660 filesystem should support the original "High Sierra"
-("CDROM001") format;
-it does not.
+The cd9660 filesystem does not support the original "High Sierra"
+("CDROM001") format.
 .Pp
 POSIX device node mapping is currently not supported.
 .Pp
 .Pp
 POSIX device node mapping is currently not supported.
 .Pp
@@ -80,21 +66,8 @@ In this case, accessing files that don't have Rockridge names without
 version numbers gets the one with the lowest version number and not
 the one with the highest.
 .Pp
 version numbers gets the one with the lowest version number and not
 the one with the highest.
 .Pp
-The filesystem name might need some rethinking, and some would
-say it should run as a user process.
-.Pp
 There is no ECMA support.
 .Sh HISTORY
 The
 .Nm mount_cd9660
 There is no ECMA support.
 .Sh HISTORY
 The
 .Nm mount_cd9660
-utility first appeared in NetBSD 0.8.
-Handling of Rockridge extensions was added for NetBSD 0.9.
-.Sh AUTHORS
-.Bl -tag
-Pace Willisson <pace@blitz.com>, <pace@bsdi.com> wrote the
-original version of the ISO-9660 filesystem.
-.Pp
-Atsushi Murai <amurai@spec.co.jp> wrote the Rockridge support.
-.Pp
-Chris Demetriou <cgd@berkeley.edu> wrote the man page.
-.El
+utility first appeared 4.4BSD.
index d8317ab..9e99362 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 contributed to Berkeley
  *      The Regents of the University of California.  All rights reserved.
  *
  * This code is derived from software contributed to Berkeley
@@ -9,88 +9,96 @@
  *
  * %sccs.include.redist.c%
  *
  *
  * %sccs.include.redist.c%
  *
- *      @(#)mount_cd9660.c     8.3 (Berkeley) %G%
+ *      @(#)mount_cd9660.c     8.4 (Berkeley) %G%
  */
 
 #ifndef lint
 static char copyright[] =
  */
 
 #ifndef lint
 static char copyright[] =
-"@(#) Copyright (c) 1992, 1993\n\
+"@(#) Copyright (c) 1992, 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_cd9660.c     8.3 (Berkeley) %G%";
+static char sccsid[] = "@(#)mount_cd9660.c     8.4 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #define CD9660
 #include <sys/mount.h>
 
 #endif /* not lint */
 
 #include <sys/param.h>
 #define CD9660
 #include <sys/mount.h>
 
-#include <errno.h>
+#include <err.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
 
-#define DEFAULT_ROOTUID        -2
+#include "mntopts.h"
 
 
-void
-usage()
-{
+struct mntopt mopts[] = {
+       MOPT_STDOPTS,
+       MOPT_UPDATE,
+       { NULL }
+};
+
+void   usage __P((void));
 
 
-       fprintf(stderr,
-               "usage: mount_cd9660 [-F fsoptions] [-norrip] [-gen] [-extattr] special node\n");
-       exit(1);
-}
-               
 int
 main(argc, argv)
        int argc;
        char **argv;
 {
 int
 main(argc, argv)
        int argc;
        char **argv;
 {
-       char *dev;
-       char *dir;
        struct iso_args args;
        struct iso_args args;
-       int mntflags = 0, opts = 0;
+       int ch, mntflags, opts;
+       char *dev, *dir, *options;
 
 
-       argc--;
-       argv++;
-       while (argc > 2) {
-               if (!strcmp("-F", argv[0])) {
-                       argc--; argv++;
-                       mntflags |= atoi(argv[0]);
-                       argc--; argv++;
-               } else if (!strcmp(argv[0], "-norrip")) {
-                       opts |= ISOFSMNT_NORRIP;
-                       argc--; argv++;
-               } else if (!strcmp(argv[0], "-gen")) {
-                       opts |= ISOFSMNT_GENS;
-                       argc--; argv++;
-               } else if (!strcmp(argv[0], "-extattr")) {
+       options = NULL;
+       mntflags = opts = 0;
+       while ((ch = getopt(argc, argv, "ego:r")) != EOF)
+               switch (ch) {
+               case 'e':
                        opts |= ISOFSMNT_EXTATT;
                        opts |= ISOFSMNT_EXTATT;
-                       argc--; argv++;
-               } else if (!strcmp(argv[0], "-notrans")) {
-                       opts |= ISOFSMNT_NOTRANS;
-                       argc--; argv++;
-               } else
+                       break;
+               case 'g':
+                       opts |= ISOFSMNT_GENS;
+                       break;
+               case 'o':
+                       getmntopts(options, mopts, &mntflags);
+                       break;
+               case 'r':
+                       opts |= ISOFSMNT_NORRIP;
+                       break;
+               case '?':
+               default:
                        usage();
                        usage();
-       }
+               }
+       argc -= optind;
+       argv += optind;
+
+       if (argc != 2)
+               usage();
 
        dev = argv[0];
        dir = argv[1];
 
 
        dev = argv[0];
        dir = argv[1];
 
+#define DEFAULT_ROOTUID        -2
        args.fspec = dev;
        args.export.ex_root = DEFAULT_ROOTUID;
        args.fspec = dev;
        args.export.ex_root = DEFAULT_ROOTUID;
+
        if (mntflags & MNT_RDONLY)
                args.export.ex_flags = MNT_EXRDONLY;
        else
                args.export.ex_flags = 0;
        args.flags = opts;
 
        if (mntflags & MNT_RDONLY)
                args.export.ex_flags = MNT_EXRDONLY;
        else
                args.export.ex_flags = 0;
        args.flags = opts;
 
-       if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0) {
-               (void)fprintf(stderr, "mount_cd9660: %s\n", strerror(errno));
-               exit(1);
-       }
-
+       if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0)
+               err(1, NULL);
        exit(0);
 }
        exit(0);
 }
+
+void
+usage()
+{
+       (void)fprintf(stderr,
+               "usage: mount_cd9660 [-egrt] [-o options] special node\n");
+       exit(1);
+}