diff options
author | ache <ache@FreeBSD.org> | 1998-02-22 17:26:27 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1998-02-22 17:26:27 +0000 |
commit | fd40b7783843d8c0232cf4d2776a529fe4d683cb (patch) | |
tree | 56b36005cc1b5397e362dc9c0cc3e99aafc230dc | |
parent | 95bf5e413f062cd563385e46551e7268ad66a3b1 (diff) | |
download | FreeBSD-src-fd40b7783843d8c0232cf4d2776a529fe4d683cb.zip FreeBSD-src-fd40b7783843d8c0232cf4d2776a529fe4d683cb.tar.gz |
Add Unicode support to winChkName, now lookup works!
-rw-r--r-- | sys/fs/msdosfs/direntry.h | 4 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_conv.c | 63 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_lookup.c | 6 | ||||
-rw-r--r-- | sys/msdosfs/direntry.h | 4 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_conv.c | 63 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_lookup.c | 6 |
6 files changed, 102 insertions, 44 deletions
diff --git a/sys/fs/msdosfs/direntry.h b/sys/fs/msdosfs/direntry.h index 9335961..e4151ab 100644 --- a/sys/fs/msdosfs/direntry.h +++ b/sys/fs/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/fs/msdosfs/msdosfs_conv.c b/sys/fs/msdosfs/msdosfs_conv.c index 031ec45..e8d5d4e 100644 --- a/sys/fs/msdosfs/msdosfs_conv.c +++ b/sys/fs/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/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index 3d7992c..5653ad3 100644 --- a/sys/fs/msdosfs/msdosfs_lookup.c +++ b/sys/fs/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; } diff --git a/sys/msdosfs/direntry.h b/sys/msdosfs/direntry.h index 9335961..e4151ab 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 031ec45..e8d5d4e 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 3d7992c..5653ad3 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; } |