Home | History | Annotate | Line # | Download | only in mount_cd9660
mount_cd9660.c revision 1.11
      1 /*	$NetBSD: mount_cd9660.c,v 1.11 2000/05/27 16:32:08 jdolecek Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1992, 1993, 1994
      5  *      The Regents of the University of California.  All rights reserved.
      6  *
      7  * This code is derived from software contributed to Berkeley
      8  * by Pace Willisson (pace (at) blitz.com).  The Rock Ridge Extension
      9  * Support code is derived from software contributed to Berkeley
     10  * by Atsushi Murai (amurai (at) spec.co.jp).
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *      @(#)mount_cd9660.c	8.7 (Berkeley) 5/1/95
     41  */
     42 
     43 #include <sys/cdefs.h>
     44 #ifndef lint
     45 __COPYRIGHT("@(#) Copyright (c) 1992, 1993, 1994\n\
     46         The Regents of the University of California.  All rights reserved.\n");
     47 #endif /* not lint */
     48 
     49 #ifndef lint
     50 #if 0
     51 static char sccsid[] = "@(#)mount_cd9660.c	8.7 (Berkeley) 5/1/95";
     52 #else
     53 __RCSID("$NetBSD: mount_cd9660.c,v 1.11 2000/05/27 16:32:08 jdolecek Exp $");
     54 #endif
     55 #endif /* not lint */
     56 
     57 #include <sys/param.h>
     58 #include <sys/mount.h>
     59 
     60 #include <err.h>
     61 #include <stdlib.h>
     62 #include <stdio.h>
     63 #include <string.h>
     64 #include <unistd.h>
     65 
     66 #include <isofs/cd9660/cd9660_mount.h>
     67 
     68 #include "mntopts.h"
     69 
     70 const struct mntopt mopts[] = {
     71 	MOPT_STDOPTS,
     72 	MOPT_UPDATE,
     73 	{ "maplcase", 1, ISOFSMNT_NOCASETRANS, 1 },
     74 	{ NULL }
     75 };
     76 
     77 int	main __P((int, char *[]));
     78 void	usage __P((void));
     79 
     80 int
     81 main(argc, argv)
     82 	int argc;
     83 	char **argv;
     84 {
     85 	struct iso_args args;
     86 	int ch, mntflags, opts;
     87 	char *dev, *dir;
     88 
     89 	mntflags = opts = 0;
     90 	while ((ch = getopt(argc, argv, "egijo:r")) != -1)
     91 		switch (ch) {
     92 		case 'e':
     93 			opts |= ISOFSMNT_EXTATT;
     94 			break;
     95 		case 'g':
     96 			opts |= ISOFSMNT_GENS;
     97 			break;
     98 		case 'j':
     99 			opts |= ISOFSMNT_NOJOLIET;
    100 			break;
    101 		case 'o':
    102 			getmntopts(optarg, mopts, &mntflags, &opts);
    103 			break;
    104 		case 'r':
    105 			opts |= ISOFSMNT_NORRIP;
    106 			break;
    107 		case '?':
    108 		default:
    109 			usage();
    110 		}
    111 	argc -= optind;
    112 	argv += optind;
    113 
    114 	if (argc != 2)
    115 		usage();
    116 
    117 	dev = argv[0];
    118 	dir = argv[1];
    119 
    120 #define DEFAULT_ROOTUID	-2
    121 	/*
    122 	 * ISO 9660 filesystems are not writeable.
    123 	 */
    124 	mntflags |= MNT_RDONLY;
    125 	args.export.ex_flags = MNT_EXRDONLY;
    126 	args.fspec = dev;
    127 	args.export.ex_root = DEFAULT_ROOTUID;
    128 	args.flags = opts;
    129 
    130 	if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0)
    131 		err(1, "%s on %s", dev, dir);
    132 	exit(0);
    133 }
    134 
    135 void
    136 usage()
    137 {
    138 	(void)fprintf(stderr,
    139 		"usage: mount_cd9660 [-egijr] [-o options] special node\n");
    140 	exit(1);
    141 }
    142