1 /* $NetBSD: mount_cd9660.c,v 1.15 2002/09/21 18:43:33 christos 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@blitz.com). The Rock Ridge Extension 9 * Support code is derived from software contributed to Berkeley 10 * by Atsushi Murai (amurai@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.15 2002/09/21 18:43:33 christos 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 #include <util.h> 66 67 #include <isofs/cd9660/cd9660_mount.h> 68 69 #include "mntopts.h" 70 71 static const struct mntopt mopts[] = { 72 MOPT_STDOPTS, 73 MOPT_UPDATE, 74 MOPT_GETARGS, 75 { "extatt", 0, ISOFSMNT_EXTATT, 1 }, 76 { "gens", 0, ISOFSMNT_GENS, 1 }, 77 { "maplcase", 1, ISOFSMNT_NOCASETRANS, 1 }, 78 { "nrr", 0, ISOFSMNT_NORRIP, 1 }, 79 { "rrip", 1, ISOFSMNT_NORRIP, 1 }, 80 { "joliet", 1, ISOFSMNT_NOJOLIET, 1 }, 81 { "rrcaseins", 0, ISOFSMNT_RRCASEINS, 1 }, 82 { NULL } 83 }; 84 85 int main __P((int, char *[])); 86 int mount_cd9660 __P((int argc, char **argv)); 87 static void usage __P((void)); 88 89 #ifndef MOUNT_NOMAIN 90 int 91 main(argc, argv) 92 int argc; 93 char **argv; 94 { 95 return mount_cd9660(argc, argv); 96 } 97 #endif 98 99 int 100 mount_cd9660(argc, argv) 101 int argc; 102 char **argv; 103 { 104 struct iso_args args; 105 int ch, mntflags, opts; 106 char *dev, *dir; 107 108 mntflags = opts = 0; 109 while ((ch = getopt(argc, argv, "egijo:r")) != -1) 110 switch (ch) { 111 case 'e': 112 /* obsolete, retained for compatibility only, use 113 * -o extatt */ 114 opts |= ISOFSMNT_EXTATT; 115 break; 116 case 'g': 117 /* obsolete, retained for compatibility only, use 118 * -o gens */ 119 opts |= ISOFSMNT_GENS; 120 break; 121 case 'j': 122 /* obsolete, retained fo compatibility only, use 123 * -o nojoliet */ 124 opts |= ISOFSMNT_NOJOLIET; 125 break; 126 case 'o': 127 getmntopts(optarg, mopts, &mntflags, &opts); 128 break; 129 case 'r': 130 /* obsolete, retained for compatibility only, use 131 * -o norrip */ 132 opts |= ISOFSMNT_NORRIP; 133 break; 134 case '?': 135 default: 136 usage(); 137 } 138 argc -= optind; 139 argv += optind; 140 141 if (argc != 2) 142 usage(); 143 144 dev = argv[0]; 145 dir = argv[1]; 146 147 #define DEFAULT_ROOTUID -2 148 /* 149 * ISO 9660 filesystems are not writeable. 150 */ 151 mntflags |= MNT_RDONLY; 152 args.export.ex_flags = MNT_EXRDONLY; 153 args.fspec = dev; 154 args.export.ex_root = DEFAULT_ROOTUID; 155 args.flags = opts; 156 157 if (mount(MOUNT_CD9660, dir, mntflags, &args) < 0) 158 err(1, "%s on %s", dev, dir); 159 if (mntflags & MNT_GETARGS) { 160 char buf[2048]; 161 (void)snprintb(buf, sizeof(buf), ISOFSMNT_BITS, args.flags); 162 printf("%s\n", buf); 163 } 164 exit(0); 165 } 166 167 static void 168 usage() 169 { 170 (void)fprintf(stderr, 171 "usage: mount_cd9660 [-o options] special node\n"); 172 exit(1); 173 } 174