2 * Copyright (c) 1992, 1993, 1994
3 * The Regents of the University of California. All rights reserved.
4 * Copyright (c) 2002 Scott Long
6 * This code is derived from software contributed to Berkeley
7 * by Pace Willisson (pace@blitz.com). The Rock Ridge Extension
8 * Support code is derived from software contributed to Berkeley
9 * by Atsushi Murai (amurai@spec.co.jp).
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * This is just a rip-off of mount_iso9660.c. It's been vastly simplified
40 * because UDF doesn't take any options at this time.
45 #include <sys/iconv.h>
46 #include <sys/param.h>
47 #include <sys/linker.h>
48 #include <sys/module.h>
49 #include <sys/mount.h>
52 #include <fs/udf/udf_mount.h>
64 static struct mntopt mopts[] = {
70 int set_charset(char **, char **, const char *);
74 main(int argc, char **argv)
76 char mntpath[MAXPATHLEN];
77 char fstype[] = "udf";
79 char *cs_disk, *cs_local, *dev, *dir;
80 int ch, iovlen, mntflags, udf_flags, verbose;
82 iovlen = mntflags = udf_flags = verbose = 0;
83 cs_disk = cs_local = NULL;
85 while ((ch = getopt(argc, argv, "o:vC:")) != -1)
88 getmntopts(optarg, mopts, &mntflags, NULL);
94 if (set_charset(&cs_disk, &cs_local, optarg) == -1)
95 err(EX_OSERR, "udf_iconv");
96 udf_flags |= UDFMNT_KICONV;
112 * Resolve the mountpoint with realpath(3) and remove unnecessary
113 * slashes from the devicename if there are any.
115 if (checkpath(dir, mntpath) != 0)
116 err(EX_USAGE, "%s", mntpath);
117 (void)rmslashes(dev, dev);
120 * UDF file systems are not writeable.
122 mntflags |= MNT_RDONLY;
124 build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1);
125 build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1);
126 build_iovec(&iov, &iovlen, "from", dev, (size_t)-1);
127 build_iovec(&iov, &iovlen, "flags", &udf_flags, sizeof(udf_flags));
128 if (udf_flags & UDFMNT_KICONV) {
129 build_iovec(&iov, &iovlen, "cs_disk", cs_disk, (size_t)-1);
130 build_iovec(&iov, &iovlen, "cs_local", cs_local, (size_t)-1);
132 if (nmount(iov, iovlen, mntflags) < 0)
138 set_charset(char **cs_disk, char **cs_local, const char *localcs)
142 if (modfind("udf_iconv") < 0)
143 if (kldload("udf_iconv") < 0 || modfind("udf_iconv") < 0) {
144 warnx( "cannot find or load \"udf_iconv\" kernel module");
148 if ((*cs_disk = malloc(ICONV_CSNMAXLEN)) == NULL)
150 if ((*cs_local = malloc(ICONV_CSNMAXLEN)) == NULL)
152 strncpy(*cs_disk, ENCODING_UNICODE, ICONV_CSNMAXLEN);
153 strncpy(*cs_local, localcs, ICONV_CSNMAXLEN);
154 error = kiconv_add_xlat16_cspairs(*cs_disk, *cs_local);
164 (void)fprintf(stderr,
165 "usage: mount_udf [-v] [-o options] [-C charset] special node\n");