aboutsummaryrefslogtreecommitdiff
path: root/sys/msdosfs
diff options
context:
space:
mode:
authorAndrey A. Chernov <ache@FreeBSD.org>1998-02-22 17:26:27 +0000
committerAndrey A. Chernov <ache@FreeBSD.org>1998-02-22 17:26:27 +0000
commit4d63452f4ed7d28eb97a03388274cd04018fe9a3 (patch)
tree72a446ca192d906f87b65ee6b17fe4695a7572af /sys/msdosfs
parent4e3e206ed798750411687761894d9ecaaa14f2da (diff)
downloadsrc-4d63452f4ed7d28eb97a03388274cd04018fe9a3.tar.gz
src-4d63452f4ed7d28eb97a03388274cd04018fe9a3.zip
Add Unicode support to winChkName, now lookup works!
Notes
Notes: svn path=/head/; revision=33750
Diffstat (limited to 'sys/msdosfs')
-rw-r--r--sys/msdosfs/direntry.h4
-rw-r--r--sys/msdosfs/msdosfs_conv.c63
-rw-r--r--sys/msdosfs/msdosfs_lookup.c6
3 files changed, 51 insertions, 22 deletions
diff --git a/sys/msdosfs/direntry.h b/sys/msdosfs/direntry.h
index 933596160537..e4151ab8dd2d 100644
--- a/sys/msdosfs/direntry.h
+++ b/sys/msdosfs/direntry.h
@@ -1,4 +1,4 @@
-/* $Id: direntry.h,v 1.5 1998/02/18 09:28:27 jkh Exp $ */
+/* $Id: direntry.h,v 1.6 1998/02/22 15:09:36 ache Exp $ */
/* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */
/*-
@@ -133,7 +133,7 @@ void dos2unixtime __P((u_int dd, u_int dt, u_int dh, struct timespec *tsp));
int dos2unixfn __P((u_char dn[11], u_char *un, int lower));
int unix2dosfn __P((const u_char *un, u_char dn[12], int unlen, u_int gen));
int unix2winfn __P((const u_char *un, int unlen, struct winentry *wep, int cnt, int chksum, int table_loaded, u_int16_t *u2w));
-int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum));
+int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, int table_loaded, u_int16_t *u2w));
int win2unixfn __P((struct winentry *wep, struct dirent *dp, int chksum, int table_loaded, u_int16_t *u2w));
u_int8_t winChksum __P((u_int8_t *name));
int winSlotCnt __P((const u_char *un, int unlen));
diff --git a/sys/msdosfs/msdosfs_conv.c b/sys/msdosfs/msdosfs_conv.c
index 031ec451f085..e8d5d4e57dea 100644
--- a/sys/msdosfs/msdosfs_conv.c
+++ b/sys/msdosfs/msdosfs_conv.c
@@ -1,4 +1,4 @@
-/* $Id: msdosfs_conv.c,v 1.17 1998/02/22 12:22:23 ache Exp $ */
+/* $Id: msdosfs_conv.c,v 1.18 1998/02/22 15:09:39 ache Exp $ */
/* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */
/*-
@@ -645,19 +645,35 @@ done:
return 0;
}
+static inline u_int8_t
+find_lcode(code, u2w)
+ u_int16_t code;
+ u_int16_t *u2w;
+{
+ int i;
+
+ for (i = 0; i < 128; i++)
+ if (u2w[i] == code)
+ return (i | 0x80);
+ return '?';
+}
+
/*
* Compare our filename to the one in the Win95 entry
* Returns the checksum or -1 if no match
*/
int
-winChkName(un, unlen, wep, chksum)
+winChkName(un, unlen, wep, chksum, table_loaded, u2w)
const u_char *un;
int unlen;
struct winentry *wep;
int chksum;
+ int table_loaded;
+ u_int16_t *u2w;
{
u_int8_t *cp;
int i;
+ u_int16_t code;
/*
* First compare checksums
@@ -688,8 +704,16 @@ winChkName(un, unlen, wep, chksum)
return chksum;
return -1;
}
- if (u2l[*cp++] != u2l[*un++] || *cp++)
+ code = (cp[1] << 8) | cp[0];
+ if (code & 0xff80) {
+ if (table_loaded)
+ code = find_lcode(code, u2w);
+ else if (code & 0xff00)
+ code = '?';
+ }
+ if (u2l[code] != u2l[*un++])
return -1;
+ cp += 2;
}
for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) {
if (--unlen < 0) {
@@ -697,8 +721,16 @@ winChkName(un, unlen, wep, chksum)
return chksum;
return -1;
}
- if (u2l[*cp++] != u2l[*un++] || *cp++)
+ code = (cp[1] << 8) | cp[0];
+ if (code & 0xff80) {
+ if (table_loaded)
+ code = find_lcode(code, u2w);
+ else if (code & 0xff00)
+ code = '?';
+ }
+ if (u2l[code] != u2l[*un++])
return -1;
+ cp += 2;
}
for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) {
if (--unlen < 0) {
@@ -706,25 +738,20 @@ winChkName(un, unlen, wep, chksum)
return chksum;
return -1;
}
- if (u2l[*cp++] != u2l[*un++] || *cp++)
+ code = (cp[1] << 8) | cp[0];
+ if (code & 0xff80) {
+ if (table_loaded)
+ code = find_lcode(code, u2w);
+ else if (code & 0xff00)
+ code = '?';
+ }
+ if (u2l[code] != u2l[*un++])
return -1;
+ cp += 2;
}
return chksum;
}
-static inline u_int8_t
-find_lcode(code, u2w)
- u_int16_t code;
- u_int16_t *u2w;
-{
- int i;
-
- for (i = 0; i < 128; i++)
- if (u2w[i] == code)
- return (i | 0x80);
- return '?';
-}
-
/*
* Convert Win95 filename to dirbuf.
* Returns the checksum or -1 if impossible
diff --git a/sys/msdosfs/msdosfs_lookup.c b/sys/msdosfs/msdosfs_lookup.c
index 3d7992ca3e96..5653ad3372fc 100644
--- a/sys/msdosfs/msdosfs_lookup.c
+++ b/sys/msdosfs/msdosfs_lookup.c
@@ -1,4 +1,4 @@
-/* $Id: msdosfs_lookup.c,v 1.15 1998/02/18 09:28:41 jkh Exp $ */
+/* $Id: msdosfs_lookup.c,v 1.16 1998/02/22 15:09:42 ache Exp $ */
/* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */
/*-
@@ -255,7 +255,9 @@ msdosfs_lookup(ap)
chksum = winChkName((const u_char *)cnp->cn_nameptr,
cnp->cn_namelen,
(struct winentry *)dep,
- chksum);
+ chksum,
+ pmp->pm_flags & MSDOSFSMNT_U2WTABLE,
+ pmp->pm_u2w);
continue;
}