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). Joliet support was added by
9 * Joachim Kuebart (joki@kuebart.stuttgart.netsurf.de).
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 * 3. All advertising materials mentioning features or use of this software
20 * must display the following acknowledgement:
21 * This product includes software developed by the University of
22 * California, Berkeley and its contributors.
23 * 4. Neither the name of the University nor the names of its contributors
24 * may be used to endorse or promote products derived from this software
25 * without specific prior written permission.
27 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * @(#)cd9660_util.c 8.3 (Berkeley) 12/5/94
43 #include <sys/param.h>
44 #include <sys/mount.h>
45 #include <sys/vnode.h>
47 #include <isofs/cd9660/iso.h>
50 * Get one character out of an iso filename
52 * Return number of bytes consumed
55 isochar(isofn, isoend, joliet_level, c)
62 if (joliet_level == 0 || isofn == isoend)
63 /* (00) and (01) are one byte in Joliet, too */
66 /* No Unicode support yet :-( */
79 * translate and compare a filename
80 * returns (fn - isofn)
81 * Note: Version number plus ';' may be omitted.
84 isofncmp(fn, fnlen, isofn, isolen, joliet_level)
92 u_char c, *fnend = fn + fnlen, *isoend = isofn + isolen;
94 for (; fn != fnend; fn++) {
97 isofn += isochar(isofn, isoend, joliet_level, &c);
101 for (i = 0; fn != fnend; i = i * 10 + *fn++ - '0') {
102 if (*fn < '0' || *fn > '9') {
106 for (j = 0; isofn != isoend; j = j * 10 + c - '0')
107 isofn += isochar(isofn, isoend,
112 if (c >= 'A' && c <= 'Z') {
113 if (c + ('a' - 'A') != *fn) {
114 if (*fn >= 'a' && *fn <= 'z')
115 return *fn - ('a' - 'A') - c;
123 if (isofn != isoend) {
124 isofn += isochar(isofn, isoend, joliet_level, &c);
129 if (isofn != isoend) {
130 isochar(isofn, isoend, joliet_level, &c);
143 * translate a filename of length > 0
146 isofntrans(infn, infnlen, outfn, outfnlen, original, assoc, joliet_level)
156 u_char c, d = '\0', *infnend = infn + infnlen;
159 *outfn++ = ASSOCCHAR;
162 for (; infn != infnend; fnidx++) {
163 infn += isochar(infn, infnend, joliet_level, &c);
165 if (!original && !joliet_level && c >= 'A' && c <= 'Z')
166 *outfn++ = c + ('a' - 'A');
167 else if (!original && c == ';') {