summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorfjoe <fjoe@FreeBSD.org>2003-12-08 08:32:20 +0000
committerfjoe <fjoe@FreeBSD.org>2003-12-08 08:32:20 +0000
commitab0bce9d34117f8a7b96ec8a3c86ed0e86d58ef8 (patch)
tree6ebbe6155fc751cdfa161e601e91e193cd383576 /sys
parent8a088743dbd2835567a01e9f13b69c3dc4b0d8a9 (diff)
downloadFreeBSD-src-ab0bce9d34117f8a7b96ec8a3c86ed0e86d58ef8.zip
FreeBSD-src-ab0bce9d34117f8a7b96ec8a3c86ed0e86d58ef8.tar.gz
Make msdosfs long filenames matching case insensitive again.
PR: 59765 Submitted by: Ryuichiro Imura <imura@ryu16.org>
Diffstat (limited to 'sys')
-rw-r--r--sys/fs/msdosfs/msdosfs_conv.c8
-rw-r--r--sys/libkern/iconv_xlat16.c21
-rw-r--r--sys/sys/iconv.h1
3 files changed, 19 insertions, 11 deletions
diff --git a/sys/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c
index 5c663c8..728c983 100644
--- a/sys/fs/msdosfs/msdosfs_conv.c
+++ b/sys/fs/msdosfs/msdosfs_conv.c
@@ -800,10 +800,12 @@ winChkName(un, unlen, chksum, pmp)
for (np = dirbuf.d_name; unlen > 0 && len > 0;) {
/*
- * Should comparison be case insensitive?
+ * Comparison must be case insensitive, because FAT disallows
+ * to look up or create files in case sensitive even when
+ * it's a long file name.
*/
- c1 = unix2winchr((const u_char **)&np, (size_t *)&len, 0, pmp);
- c2 = unix2winchr(&un, (size_t *)&unlen, 0, pmp);
+ c1 = unix2winchr((const u_char **)&np, (size_t *)&len, LCASE_BASE, pmp);
+ c2 = unix2winchr(&un, (size_t *)&unlen, LCASE_BASE, pmp);
if (c1 != c2)
return -2;
}
diff --git a/sys/libkern/iconv_xlat16.c b/sys/libkern/iconv_xlat16.c
index 6793159..68d468a 100644
--- a/sys/libkern/iconv_xlat16.c
+++ b/sys/libkern/iconv_xlat16.c
@@ -96,11 +96,11 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
struct iconv_xlat16 *dp = (struct iconv_xlat16*)d2p;
const char *src;
char *dst;
- int ret = 0;
+ int nullin, ret = 0;
size_t in, on, ir, or, inlen;
uint32_t code;
u_char u, l;
- u_int16_t c1, c2;
+ uint16_t c1, c2;
if (inbuf == NULL || *inbuf == NULL || outbuf == NULL || *outbuf == NULL)
return (0);
@@ -146,7 +146,8 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
}
}
- if ((inlen == 1) && (code & XLAT16_ACCEPT_NULL_IN)) {
+ nullin = (code & XLAT16_ACCEPT_NULL_IN) ? 1 : 0;
+ if (inlen == 1 && nullin) {
/*
* XLAT16_ACCEPT_NULL_IN requires inbuf has 2byte
*/
@@ -157,6 +158,14 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
/*
* now start translation
*/
+ if ((casetype == KICONV_FROM_LOWER && code & XLAT16_HAS_FROM_LOWER_CASE) ||
+ (casetype == KICONV_FROM_UPPER && code & XLAT16_HAS_FROM_UPPER_CASE)) {
+ c2 = (u_char)(code >> 16);
+ c1 = c2 & 0x80 ? 0x100 : 0;
+ c2 = c2 & 0x80 ? c2 & 0x7f : c2;
+ code = dp->d_table[c1][c2];
+ }
+
u = (u_char)(code >> 8);
l = (u_char)code;
@@ -184,9 +193,6 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
if ((casetype == KICONV_LOWER && code & XLAT16_HAS_LOWER_CASE) ||
(casetype == KICONV_UPPER && code & XLAT16_HAS_UPPER_CASE))
*dst++ = (u_char)(code >> 16);
- else if ((casetype == KICONV_FROM_LOWER && code & XLAT16_HAS_FROM_LOWER_CASE) ||
- (casetype == KICONV_FROM_UPPER && code & XLAT16_HAS_FROM_UPPER_CASE))
- *dst++ = dp->d_table[0][(u_char)(code >> 16)];
else
*dst++ = l;
or--;
@@ -197,8 +203,7 @@ iconv_xlat16_conv(void *d2p, const char **inbuf,
* there is a case that inbuf char is a single
* byte char while inlen == 2
*/
- if ((u_char)*(src+1) == 0 &&
- (code & XLAT16_ACCEPT_NULL_IN) == 0 ) {
+ if ((u_char)*(src+1) == 0 && !nullin ) {
src++;
ir--;
} else {
diff --git a/sys/sys/iconv.h b/sys/sys/iconv.h
index 0ac765c..754bea7 100644
--- a/sys/sys/iconv.h
+++ b/sys/sys/iconv.h
@@ -92,6 +92,7 @@ __BEGIN_DECLS
int kiconv_add_xlat_table(const char *, const char *, const u_char *);
int kiconv_add_xlat16_cspair(const char *, const char *, int);
+int kiconv_add_xlat16_cspairs(const char *, const char *);
int kiconv_add_xlat16_table(const char *, const char *, const void *, int);
const char *kiconv_quirkcs(const char *, int);
OpenPOWER on IntegriCloud