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@blitz.com). The Rock Ridge Extension 7 * Support code is derived from software contributed to Berkeley 8 * by Atsushi Murai (amurai@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.4 (Berkeley) 3/27/94 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 /* 49 static char sccsid[] = "@(#)mount_cd9660.c 8.4 (Berkeley) 3/27/94"; 50 */ 51 static const char rcsid[] = 52 "$Id$"; 53 #endif /* not lint */ 54 55 #include <sys/param.h> 56 #define CD9660 57 #include <sys/mount.h> 58 59 #include <err.h> 60 #include <stdlib.h> 61 #include <stdio.h> 62 #include <string.h> 63 #include <sysexits.h> 64 #include <unistd.h> 65 66 #include "mntopts.h" 67 68 struct mntopt mopts[] = { 69 MOPT_STDOPTS, 70 MOPT_UPDATE, 71 { "extatt", 0, ISOFSMNT_EXTATT, 1 }, 72 { "gens", 0, ISOFSMNT_GENS, 1 }, 73 { "rrip", 1, ISOFSMNT_NORRIP, 1 }, 74 { NULL } 75 }; 76 77 void usage __P((void)); 78 79 int 80 main(argc, argv) 81 int argc; 82 char **argv; 83 { 84 struct iso_args args; 85 int ch, mntflags, opts; 86 char *dev, *dir; 87 struct vfsconf *vfc; 88 89 mntflags = opts = 0; 90 while ((ch = getopt(argc, argv, "ego:r")) != EOF) 91 switch (ch) { 92 case 'e': 93 opts |= ISOFSMNT_EXTATT; 94 break; 95 case 'g': 96 opts |= ISOFSMNT_GENS; 97 break; 98 case 'o': 99 getmntopts(optarg, mopts, &mntflags, &opts); 100 break; 101 case 'r': 102 opts |= ISOFSMNT_NORRIP; 103 break; 104 case '?': 105 default: 106 usage(); 107 } 108 argc -= optind; 109 argv += optind; 110 111 if (argc != 2) 112 usage(); 113 114 dev = argv[0]; 115 dir = argv[1]; 116 117 #define DEFAULT_ROOTUID -2 118 args.fspec = dev; 119 args.export.ex_root = DEFAULT_ROOTUID; 120 121 /* 122 * ISO 9660 filesystems are not writeable. 123 */ 124 mntflags |= MNT_RDONLY; 125 args.export.ex_flags = MNT_EXRDONLY; 126 127 args.flags = opts; 128 129 vfc = getvfsbyname("cd9660"); 130 if(!vfc && vfsisloadable("cd9660")) { 131 if(vfsload("cd9660")) { 132 err(EX_OSERR, "vfsload(cd9660)"); 133 } 134 endvfsent(); /* flush cache */ 135 vfc = getvfsbyname("cd9660"); 136 } 137 if (!vfc) 138 errx(EX_OSERR, "cd9660 filesystem not available"); 139 140 if (mount(vfc->vfc_index, dir, mntflags, &args) < 0) 141 err(EX_OSERR, "%s", dev); 142 exit(0); 143 } 144 145 void 146 usage() 147 { 148 (void)fprintf(stderr, 149 "usage: mount_cd9660 [-egrt] [-o options] special node\n"); 150 exit(EX_USAGE); 151 } 152