Blame view
fs/isofs/joliet.c
1.36 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 6 7 8 |
/* * linux/fs/isofs/joliet.c * * (C) 1996 Gordon Chaffee * * Joliet: Microsoft's Unicode extensions to iso9660 */ |
94f2f7157 [PATCH] isofs inc... |
9 |
#include <linux/types.h> |
1da177e4c Linux-2.6.12-rc2 |
10 |
#include <linux/nls.h> |
94f2f7157 [PATCH] isofs inc... |
11 |
#include "isofs.h" |
1da177e4c Linux-2.6.12-rc2 |
12 13 |
/* |
4de151d8c It's UTF-8 |
14 |
* Convert Unicode 16 to UTF-8 or ASCII. |
1da177e4c Linux-2.6.12-rc2 |
15 16 |
*/ static int |
d02d48d86 [PATCH] isofs end... |
17 |
uni16_to_x8(unsigned char *ascii, __be16 *uni, int len, struct nls_table *nls) |
1da177e4c Linux-2.6.12-rc2 |
18 |
{ |
d02d48d86 [PATCH] isofs end... |
19 |
__be16 *ip, ch; |
1da177e4c Linux-2.6.12-rc2 |
20 21 22 23 24 25 26 |
unsigned char *op; ip = uni; op = ascii; while ((ch = get_unaligned(ip)) && len) { int llen; |
d02d48d86 [PATCH] isofs end... |
27 28 |
llen = nls->uni2char(be16_to_cpu(ch), op, NLS_MAX_CHARSET_SIZE); if (llen > 0) |
1da177e4c Linux-2.6.12-rc2 |
29 30 31 32 33 34 35 36 37 38 |
op += llen; else *op++ = '?'; ip++; len--; } *op = 0; return (op - ascii); } |
1da177e4c Linux-2.6.12-rc2 |
39 40 41 42 43 44 45 46 47 48 49 |
int get_joliet_filename(struct iso_directory_record * de, unsigned char *outname, struct inode * inode) { unsigned char utf8; struct nls_table *nls; unsigned char len = 0; utf8 = ISOFS_SB(inode->i_sb)->s_utf8; nls = ISOFS_SB(inode->i_sb)->s_nls_iocharset; if (utf8) { |
74675a585 NLS: update handl... |
50 51 52 |
len = utf16s_to_utf8s((const wchar_t *) de->name, de->name_len[0] >> 1, UTF16_BIG_ENDIAN, outname, PAGE_SIZE); |
1da177e4c Linux-2.6.12-rc2 |
53 |
} else { |
d02d48d86 [PATCH] isofs end... |
54 |
len = uni16_to_x8(outname, (__be16 *) de->name, |
c3ed85a36 isofs: fix up Cod... |
55 |
de->name_len[0] >> 1, nls); |
1da177e4c Linux-2.6.12-rc2 |
56 |
} |
c3ed85a36 isofs: fix up Cod... |
57 |
if ((len > 2) && (outname[len-2] == ';') && (outname[len-1] == '1')) |
1da177e4c Linux-2.6.12-rc2 |
58 |
len -= 2; |
1da177e4c Linux-2.6.12-rc2 |
59 60 61 62 63 |
/* * Windows doesn't like periods at the end of a name, * so neither do we */ |
c3ed85a36 isofs: fix up Cod... |
64 |
while (len >= 2 && (outname[len-1] == '.')) |
1da177e4c Linux-2.6.12-rc2 |
65 |
len--; |
1da177e4c Linux-2.6.12-rc2 |
66 67 68 |
return len; } |