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.7 (Berkeley) 5/1/95 39 * 40 * @(#) Copyright (c) 1992, 1993, 1994 The Regents of the University of California. All rights reserved. 41 * @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95 42 * $FreeBSD: src/sbin/mount_cd9660/mount_cd9660.c,v 1.15.2.3 2001/03/14 12:05:01 bp Exp $ 43 */ 44 45 #include <sys/cdio.h> 46 #include <sys/file.h> 47 #include <sys/param.h> 48 #include <sys/mount.h> 49 #include <vfs/udf/udf_mount.h> 50 51 #include <err.h> 52 #include <errno.h> 53 #include <mntopts.h> 54 #include <stdlib.h> 55 #include <stdio.h> 56 #include <string.h> 57 #include <sysexits.h> 58 #include <unistd.h> 59 60 struct mntopt mopts[] = { 61 MOPT_STDOPTS, 62 MOPT_UPDATE, 63 { NULL, 0, 0, 0 } 64 }; 65 66 void usage(void); 67 68 int 69 main(int argc, char **argv) 70 { 71 struct udf_args args; 72 int ch, mntflags, opts; 73 char *dev, *dir, mntpath[MAXPATHLEN]; 74 struct vfsconf vfc; 75 int error, verbose; 76 77 mntflags = opts = verbose = 0; 78 memset(&args, 0, sizeof args); 79 while ((ch = getopt(argc, argv, "o:v")) != -1) 80 switch (ch) { 81 case 'o': 82 getmntopts(optarg, mopts, &mntflags, &opts); 83 break; 84 case 'v': 85 verbose++; 86 break; 87 case '?': 88 default: 89 usage(); 90 } 91 argc -= optind; 92 argv += optind; 93 94 if (argc != 2) 95 usage(); 96 97 dev = argv[0]; 98 dir = argv[1]; 99 100 /* 101 * Resolve the mountpoint with realpath(3) and remove unnecessary 102 * slashes from the devicename if there are any. 103 */ 104 checkpath(dir, mntpath); 105 rmslashes(dev, dev); 106 107 #define DEFAULT_ROOTUID -2 108 /* 109 * UDF filesystems are not writeable. 110 */ 111 mntflags |= MNT_RDONLY; 112 args.export.ex_flags = MNT_EXRDONLY; 113 args.fspec = dev; 114 args.export.ex_root = DEFAULT_ROOTUID; 115 args.flags = opts; 116 117 error = getvfsbyname("udf", &vfc); 118 if (error && vfsisloadable("udf")) { 119 if (vfsload("udf")) 120 err(EX_OSERR, "vfsload(udf)"); 121 endvfsent(); /* flush cache */ 122 error = getvfsbyname("udf", &vfc); 123 } 124 if (error) 125 errx(1, "UDF filesystem is not available"); 126 127 if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0) 128 err(1, "%s", args.fspec); 129 exit(0); 130 } 131 132 void 133 usage(void) 134 { 135 fprintf(stderr, "usage: mount_udf [-o options] special node\n"); 136 exit(EX_USAGE); 137 } 138