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