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