Properly pass WORLD_CCVER through to buildworld.
[dragonfly.git] / sbin / mount_udf / mount_udf.c
blob99bdac17834d66bb93e10e938fac71ffbce73706
1 /*
2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
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).
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.
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.
38 * @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
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.3 2004/12/18 21:43:39 swildner Exp $
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>
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>
60 #include "mntopts.h"
62 struct mntopt mopts[] = {
63 MOPT_STDOPTS,
64 MOPT_UPDATE,
65 { NULL }
68 void usage(void);
70 int
71 main(int argc, char **argv)
73 struct udf_args args;
74 int ch, mntflags, opts;
75 char *dev, *dir, mntpath[MAXPATHLEN];
76 struct vfsconf vfc;
77 int error, verbose;
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();
93 argc -= optind;
94 argv += optind;
96 if (argc != 2)
97 usage();
99 dev = argv[0];
100 dir = argv[1];
103 * Resolve the mountpoint with realpath(3) and remove unnecessary
104 * slashes from the devicename if there are any.
106 checkpath(dir, mntpath);
107 rmslashes(dev, dev);
109 #define DEFAULT_ROOTUID -2
111 * UDF filesystems are not writeable.
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;
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);
126 if (error)
127 errx(1, "UDF filesystem is not available");
129 if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
130 err(1, "%s", args.fspec);
131 exit(0);
134 void
135 usage(void)
137 fprintf(stderr, "usage: mount_udf [-o options] special node\n");
138 exit(EX_USAGE);