drm - Stabilize broadwell and improve skylake
[dragonfly.git] / sbin / mount_udf / mount_udf.c
blob46f9e3b8780f5345a55fbb12667882c5b29b1bd0
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. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
36 * @(#) Copyright (c) 1992, 1993, 1994 The Regents of the University of California. All rights reserved.
37 * @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
38 * $FreeBSD: src/sbin/mount_cd9660/mount_cd9660.c,v 1.15.2.3 2001/03/14 12:05:01 bp Exp $
41 #include <sys/cdio.h>
42 #include <sys/file.h>
43 #include <sys/param.h>
44 #include <sys/mount.h>
45 #include <vfs/udf/udf_mount.h>
47 #include <err.h>
48 #include <errno.h>
49 #include <mntopts.h>
50 #include <stdlib.h>
51 #include <stdio.h>
52 #include <string.h>
53 #include <sysexits.h>
54 #include <unistd.h>
56 struct mntopt mopts[] = {
57 MOPT_STDOPTS,
58 MOPT_UPDATE,
59 { NULL, 0, 0, 0 }
62 void usage(void);
64 int
65 main(int argc, char **argv)
67 struct udf_args args;
68 int ch, mntflags, opts;
69 char *dev, *dir, mntpath[MAXPATHLEN];
70 struct vfsconf vfc;
71 int error, verbose;
73 mntflags = opts = verbose = 0;
74 memset(&args, 0, sizeof args);
75 while ((ch = getopt(argc, argv, "o:v")) != -1)
76 switch (ch) {
77 case 'o':
78 getmntopts(optarg, mopts, &mntflags, &opts);
79 break;
80 case 'v':
81 verbose++;
82 break;
83 case '?':
84 default:
85 usage();
87 argc -= optind;
88 argv += optind;
90 if (argc != 2)
91 usage();
93 dev = argv[0];
94 dir = argv[1];
97 * Resolve the mountpoint with realpath(3) and remove unnecessary
98 * slashes from the devicename if there are any.
100 checkpath(dir, mntpath);
101 rmslashes(dev, dev);
103 #define DEFAULT_ROOTUID -2
105 * UDF filesystems are not writeable.
107 mntflags |= MNT_RDONLY;
108 args.export.ex_flags = MNT_EXRDONLY;
109 args.fspec = dev;
110 args.export.ex_root = DEFAULT_ROOTUID;
111 args.flags = opts;
113 error = getvfsbyname("udf", &vfc);
114 if (error && vfsisloadable("udf")) {
115 if (vfsload("udf"))
116 err(EX_OSERR, "vfsload(udf)");
117 endvfsent(); /* flush cache */
118 error = getvfsbyname("udf", &vfc);
120 if (error)
121 errx(1, "UDF filesystem is not available");
123 if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
124 err(1, "%s", args.fspec);
125 exit(0);
128 void
129 usage(void)
131 fprintf(stderr, "usage: mount_udf [-o options] special node\n");
132 exit(EX_USAGE);