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 static char sccsid[] = "@(#)mount_cd9660.c 8.4 (Berkeley) 3/27/94"; 49 #endif /* not lint */ 50 51 #include <sys/param.h> 52 #define CD9660 53 #include <sys/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 { "extatt", 0, ISOFSMNT_EXTATT, 1 }, 67 { "gens", 0, ISOFSMNT_GENS, 1 }, 68 { "rrip", 1, ISOFSMNT_NORRIP, 1 }, 69 { NULL } 70 }; 71 72 void usage __P((void)); 73 74 int 75 main(argc, argv) 76 int argc; 77 char **argv; 78 { 79 struct iso_args args; 80 int ch, mntflags, opts; 81 char *dev, *dir; 82 struct vfsconf *vfc; 83 84 mntflags = opts = 0; 85 while ((ch = getopt(argc, argv, "ego:r")) != EOF) 86 switch (ch) { 87 case 'e': 88 opts |= ISOFSMNT_EXTATT; 89 break; 90 case 'g': 91 opts |= ISOFSMNT_GENS; 92 break; 93 case 'o': 94 getmntopts(optarg, mopts, &mntflags, &opts); 95 break; 96 case 'r': 97 opts |= ISOFSMNT_NORRIP; 98 break; 99 case '?': 100 default: 101 usage(); 102 } 103 argc -= optind; 104 argv += optind; 105 106 if (argc != 2) 107 usage(); 108 109 dev = argv[0]; 110 dir = argv[1]; 111 112 #define DEFAULT_ROOTUID -2 113 args.fspec = dev; 114 args.export.ex_root = DEFAULT_ROOTUID; 115 116 /* 117 * ISO 9660 filesystems are not writeable. 118 */ 119 mntflags |= MNT_RDONLY; 120 args.export.ex_flags = MNT_EXRDONLY; 121 122 args.flags = opts; 123 124 vfc = getvfsbyname("cd9660"); 125 if(!vfc && vfsisloadable("cd9660")) { 126 if(vfsload("cd9660")) { 127 err(1, "vfsload(cd9660)"); 128 } 129 endvfsent(); /* flush cache */ 130 vfc = getvfsbyname("cd9660"); 131 } 132 133 if (mount(vfc ? vfc->vfc_index : MOUNT_CD9660, dir, mntflags, &args) < 0) 134 err(1, NULL); 135 exit(0); 136 } 137 138 void 139 usage() 140 { 141 (void)fprintf(stderr, 142 "usage: mount_cd9660 [-egrt] [-o options] special node\n"); 143 exit(1); 144 } 145