iwm: Fix S:N reporting in ifconfig(8)
[dragonfly.git] / sbin / mount_udf / mount_udf.c
CommitLineData
2e2da476
JS
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.
dc71b7ab 18 * 3. Neither the name of the University nor the names of its contributors
2e2da476
JS
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
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.
33 *
34 * @(#)mount_cd9660.c 8.7 (Berkeley) 5/1/95
35 *
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 $
2e2da476
JS
39 */
40
41#include <sys/cdio.h>
42#include <sys/file.h>
43#include <sys/param.h>
44#include <sys/mount.h>
4a77c3ab 45#include <vfs/udf/udf_mount.h>
2e2da476
JS
46
47#include <err.h>
48#include <errno.h>
2dc55a02 49#include <mntopts.h>
2e2da476
JS
50#include <stdlib.h>
51#include <stdio.h>
52#include <string.h>
53#include <sysexits.h>
54#include <unistd.h>
55
5e16e4d0 56static struct mntopt mopts[] = {
2e2da476
JS
57 MOPT_STDOPTS,
58 MOPT_UPDATE,
fa729c86 59 MOPT_NULL
2e2da476
JS
60};
61
a92dccf2 62static void usage(void) __dead2;
2e2da476
JS
63
64int
65main(int argc, char **argv)
66{
67 struct udf_args args;
68 int ch, mntflags, opts;
69 char *dev, *dir, mntpath[MAXPATHLEN];
70 struct vfsconf vfc;
71 int error, verbose;
72
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();
86 }
87 argc -= optind;
88 argv += optind;
89
90 if (argc != 2)
91 usage();
92
93 dev = argv[0];
94 dir = argv[1];
95
96 /*
97 * Resolve the mountpoint with realpath(3) and remove unnecessary
98 * slashes from the devicename if there are any.
99 */
7cee7052
SW
100 checkpath(dir, mntpath);
101 rmslashes(dev, dev);
2e2da476
JS
102
103#define DEFAULT_ROOTUID -2
104 /*
105 * UDF filesystems are not writeable.
106 */
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;
112
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);
119 }
120 if (error)
121 errx(1, "UDF filesystem is not available");
122
123 if (mount(vfc.vfc_name, mntpath, mntflags, &args) < 0)
124 err(1, "%s", args.fspec);
125 exit(0);
126}
127
5e16e4d0 128static void
2e2da476
JS
129usage(void)
130{
7cee7052 131 fprintf(stderr, "usage: mount_udf [-o options] special node\n");
2e2da476
JS
132 exit(EX_USAGE);
133}