diff options
author | ache <ache@FreeBSD.org> | 1998-02-23 09:39:29 +0000 |
---|---|---|
committer | ache <ache@FreeBSD.org> | 1998-02-23 09:39:29 +0000 |
commit | 5722f302dc8dc00ef8dd862807a8a4881cbbb694 (patch) | |
tree | 4e70d6939b2cc2251e826c2c822dfa7506bc1a30 | |
parent | d7649e6694bb1f964cc790ef1cddf475e8b855a9 (diff) | |
download | FreeBSD-src-5722f302dc8dc00ef8dd862807a8a4881cbbb694.zip FreeBSD-src-5722f302dc8dc00ef8dd862807a8a4881cbbb694.tar.gz |
Implement loadable upper->lower local conversion table
-rw-r--r-- | sys/fs/msdosfs/direntry.h | 6 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_conv.c | 52 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_lookup.c | 6 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfs_vnops.c | 6 | ||||
-rw-r--r-- | sys/fs/msdosfs/msdosfsmount.h | 7 | ||||
-rw-r--r-- | sys/msdosfs/direntry.h | 6 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_conv.c | 52 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_lookup.c | 6 | ||||
-rw-r--r-- | sys/msdosfs/msdosfs_vnops.c | 6 | ||||
-rw-r--r-- | sys/msdosfs/msdosfsmount.h | 7 |
10 files changed, 110 insertions, 44 deletions
diff --git a/sys/fs/msdosfs/direntry.h b/sys/fs/msdosfs/direntry.h index 573eef2..1e7c8a8 100644 --- a/sys/fs/msdosfs/direntry.h +++ b/sys/fs/msdosfs/direntry.h @@ -1,4 +1,4 @@ -/* $Id: direntry.h,v 1.7 1998/02/22 17:26:21 ache Exp $ */ +/* $Id: direntry.h,v 1.8 1998/02/22 18:00:47 ache Exp $ */ /* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */ /*- @@ -130,10 +130,10 @@ struct dirent; void unix2dostime __P((struct timespec *tsp, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp)); 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 dos2unixfn __P((u_char dn[11], u_char *un, int lower, u_int8_t *ul)); 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, u_int16_t *u2w)); -int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, u_int16_t *u2w)); +int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, u_int16_t *u2w, u_int8_t *ul)); int win2unixfn __P((struct winentry *wep, struct dirent *dp, int chksum, 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 8a713a9..526e396 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.19 1998/02/22 17:26:24 ache Exp $ */ +/* $Id: msdosfs_conv.c,v 1.20 1998/02/22 18:00:49 ache Exp $ */ /* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */ /*- @@ -351,14 +351,16 @@ u2l[256] = { * null. */ int -dos2unixfn(dn, un, lower) +dos2unixfn(dn, un, lower, ul) u_char dn[11]; u_char *un; int lower; + u_int8_t *ul; { int i; int thislong = 1; u_char c; + int table_loaded = (ul != NULL); /* * If first char of the filename is SLOT_E5 (0x05), then the real @@ -370,7 +372,9 @@ dos2unixfn(dn, un, lower) c = dos2unix[0xe5]; else c = dos2unix[*dn]; - *un++ = lower ? u2l[c] : c; + *un++ = lower ? + (table_loaded && (c & 0x80) ? + ul[c & 0x7f] : u2l[c]) : c; dn++; /* @@ -378,7 +382,9 @@ dos2unixfn(dn, un, lower) */ for (i = 1; i < 8 && *dn != ' '; i++) { c = dos2unix[*dn++]; - *un++ = lower ? u2l[c] : c; + *un++ = lower ? + (table_loaded && (c & 0x80) ? + ul[c & 0x7f] : u2l[c]) : c; thislong++; } dn += 8 - i; @@ -392,7 +398,9 @@ dos2unixfn(dn, un, lower) thislong++; for (i = 0; i < 3 && *dn != ' '; i++) { c = dos2unix[*dn++]; - *un++ = lower ? u2l[c] : c; + *un++ = lower ? + (table_loaded && (c & 0x80) ? + ul[c & 0x7f] : u2l[c]) : c; thislong++; } } @@ -663,17 +671,20 @@ find_lcode(code, u2w) * Returns the checksum or -1 if no match */ int -winChkName(un, unlen, wep, chksum, u2w) +winChkName(un, unlen, wep, chksum, u2w, ul) const u_char *un; int unlen; struct winentry *wep; int chksum; u_int16_t *u2w; + u_int8_t *ul; { u_int8_t *cp; int i; u_int16_t code; - int table_loaded = (u2w != NULL); + int u2w_loaded = (u2w != NULL); + int ul_loaded = (ul != NULL); + u_int8_t c1, c2; /* * First compare checksums @@ -706,14 +717,19 @@ winChkName(un, unlen, wep, chksum, u2w) } code = (cp[1] << 8) | cp[0]; if (code & 0xff80) { - if (table_loaded) + if (u2w_loaded) code = find_lcode(code, u2w); else if (code & 0xff00) code = '?'; } - if (u2l[code] != u2l[*un++]) + c1 = ul_loaded && (code & 0x80) ? + ul[code & 0x7f] : u2l[code]; + c2 = ul_loaded && (*un & 0x80) ? + ul[*un & 0x7f] : u2l[*un]; + if (c1 != c2) return -1; cp += 2; + un++; } for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) { if (--unlen < 0) { @@ -723,14 +739,19 @@ winChkName(un, unlen, wep, chksum, u2w) } code = (cp[1] << 8) | cp[0]; if (code & 0xff80) { - if (table_loaded) + if (u2w_loaded) code = find_lcode(code, u2w); else if (code & 0xff00) code = '?'; } - if (u2l[code] != u2l[*un++]) + c1 = ul_loaded && (code & 0x80) ? + ul[code & 0x7f] : u2l[code]; + c2 = ul_loaded && (*un & 0x80) ? + ul[*un & 0x7f] : u2l[*un]; + if (c1 != c2) return -1; cp += 2; + un++; } for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) { if (--unlen < 0) { @@ -740,14 +761,19 @@ winChkName(un, unlen, wep, chksum, u2w) } code = (cp[1] << 8) | cp[0]; if (code & 0xff80) { - if (table_loaded) + if (u2w_loaded) code = find_lcode(code, u2w); else if (code & 0xff00) code = '?'; } - if (u2l[code] != u2l[*un++]) + c1 = ul_loaded && (code & 0x80) ? + ul[code & 0x7f] : u2l[code]; + c2 = ul_loaded && (*un & 0x80) ? + ul[*un & 0x7f] : u2l[*un]; + if (c1 != c2) return -1; cp += 2; + un++; } return chksum; } diff --git a/sys/fs/msdosfs/msdosfs_lookup.c b/sys/fs/msdosfs/msdosfs_lookup.c index dec491c..4d0663a 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.17 1998/02/22 17:26:27 ache Exp $ */ +/* $Id: msdosfs_lookup.c,v 1.18 1998/02/22 18:00:52 ache Exp $ */ /* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */ /*- @@ -257,7 +257,9 @@ msdosfs_lookup(ap) (struct winentry *)dep, chksum, (pmp->pm_flags & MSDOSFSMNT_U2WTABLE) ? - pmp->pm_u2w : NULL); + pmp->pm_u2w : NULL, + (pmp->pm_flags & MSDOSFSMNT_ULTABLE) ? + pmp->pm_ul : NULL); continue; } diff --git a/sys/fs/msdosfs/msdosfs_vnops.c b/sys/fs/msdosfs/msdosfs_vnops.c index 2319a19..c559eb0 100644 --- a/sys/fs/msdosfs/msdosfs_vnops.c +++ b/sys/fs/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.57 1998/02/22 15:09:50 ache Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.58 1998/02/22 18:00:54 ache Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- @@ -1743,7 +1743,9 @@ msdosfs_readdir(ap) if (chksum != winChksum(dentp->deName)) dirbuf.d_namlen = dos2unixfn(dentp->deName, (u_char *)dirbuf.d_name, - pmp->pm_flags & MSDOSFSMNT_SHORTNAME); + pmp->pm_flags & MSDOSFSMNT_SHORTNAME, + (pmp->pm_flags & MSDOSFSMNT_ULTABLE) ? + pmp->pm_ul : NULL); else dirbuf.d_name[dirbuf.d_namlen] = 0; chksum = -1; diff --git a/sys/fs/msdosfs/msdosfsmount.h b/sys/fs/msdosfs/msdosfsmount.h index 35dc7d9..4095ffc 100644 --- a/sys/fs/msdosfs/msdosfsmount.h +++ b/sys/fs/msdosfs/msdosfsmount.h @@ -1,4 +1,4 @@ -/* $Id: msdosfsmount.h,v 1.13 1998/02/18 09:28:47 jkh Exp $ */ +/* $Id: msdosfsmount.h,v 1.14 1998/02/22 15:09:54 ache Exp $ */ /* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */ /*- @@ -94,6 +94,7 @@ struct msdosfsmount { u_int pm_flags; /* see below */ struct netexport pm_export; /* export information */ u_int16_t pm_u2w[128]; /* Local->Unicode table */ + u_int8_t pm_ul[128]; /* Local upper->lower table */ }; /* Byte offset in FAT on filesystem pmp, cluster cn */ #define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv) @@ -204,6 +205,7 @@ struct msdosfs_args { int flags; /* see below */ int magic; /* version number */ u_int16_t u2w[128]; /* Local->Unicode table */ + u_int8_t ul[128]; /* Local upper->lower table */ }; /* @@ -216,10 +218,11 @@ struct msdosfs_args { #define MSDOSFSMNT_GEMDOSFS 8 /* This is a gemdos-flavour */ #endif #define MSDOSFSMNT_U2WTABLE 0x10 /* Local->Unicode table is loaded */ +#define MSDOSFSMNT_ULTABLE 0x20 /* Local upper->lower table is loaded */ /* All flags above: */ #define MSDOSFSMNT_MNTOPT \ (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \ - /*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_U2WTABLE) + /*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_U2WTABLE|MSDOSFSMNT_ULTABLE) #define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */ #define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */ #define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */ diff --git a/sys/msdosfs/direntry.h b/sys/msdosfs/direntry.h index 573eef2..1e7c8a8 100644 --- a/sys/msdosfs/direntry.h +++ b/sys/msdosfs/direntry.h @@ -1,4 +1,4 @@ -/* $Id: direntry.h,v 1.7 1998/02/22 17:26:21 ache Exp $ */ +/* $Id: direntry.h,v 1.8 1998/02/22 18:00:47 ache Exp $ */ /* $NetBSD: direntry.h,v 1.14 1997/11/17 15:36:32 ws Exp $ */ /*- @@ -130,10 +130,10 @@ struct dirent; void unix2dostime __P((struct timespec *tsp, u_int16_t *ddp, u_int16_t *dtp, u_int8_t *dhp)); 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 dos2unixfn __P((u_char dn[11], u_char *un, int lower, u_int8_t *ul)); 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, u_int16_t *u2w)); -int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, u_int16_t *u2w)); +int winChkName __P((const u_char *un, int unlen, struct winentry *wep, int chksum, u_int16_t *u2w, u_int8_t *ul)); int win2unixfn __P((struct winentry *wep, struct dirent *dp, int chksum, 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 8a713a9..526e396 100644 --- a/sys/msdosfs/msdosfs_conv.c +++ b/sys/msdosfs/msdosfs_conv.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_conv.c,v 1.19 1998/02/22 17:26:24 ache Exp $ */ +/* $Id: msdosfs_conv.c,v 1.20 1998/02/22 18:00:49 ache Exp $ */ /* $NetBSD: msdosfs_conv.c,v 1.25 1997/11/17 15:36:40 ws Exp $ */ /*- @@ -351,14 +351,16 @@ u2l[256] = { * null. */ int -dos2unixfn(dn, un, lower) +dos2unixfn(dn, un, lower, ul) u_char dn[11]; u_char *un; int lower; + u_int8_t *ul; { int i; int thislong = 1; u_char c; + int table_loaded = (ul != NULL); /* * If first char of the filename is SLOT_E5 (0x05), then the real @@ -370,7 +372,9 @@ dos2unixfn(dn, un, lower) c = dos2unix[0xe5]; else c = dos2unix[*dn]; - *un++ = lower ? u2l[c] : c; + *un++ = lower ? + (table_loaded && (c & 0x80) ? + ul[c & 0x7f] : u2l[c]) : c; dn++; /* @@ -378,7 +382,9 @@ dos2unixfn(dn, un, lower) */ for (i = 1; i < 8 && *dn != ' '; i++) { c = dos2unix[*dn++]; - *un++ = lower ? u2l[c] : c; + *un++ = lower ? + (table_loaded && (c & 0x80) ? + ul[c & 0x7f] : u2l[c]) : c; thislong++; } dn += 8 - i; @@ -392,7 +398,9 @@ dos2unixfn(dn, un, lower) thislong++; for (i = 0; i < 3 && *dn != ' '; i++) { c = dos2unix[*dn++]; - *un++ = lower ? u2l[c] : c; + *un++ = lower ? + (table_loaded && (c & 0x80) ? + ul[c & 0x7f] : u2l[c]) : c; thislong++; } } @@ -663,17 +671,20 @@ find_lcode(code, u2w) * Returns the checksum or -1 if no match */ int -winChkName(un, unlen, wep, chksum, u2w) +winChkName(un, unlen, wep, chksum, u2w, ul) const u_char *un; int unlen; struct winentry *wep; int chksum; u_int16_t *u2w; + u_int8_t *ul; { u_int8_t *cp; int i; u_int16_t code; - int table_loaded = (u2w != NULL); + int u2w_loaded = (u2w != NULL); + int ul_loaded = (ul != NULL); + u_int8_t c1, c2; /* * First compare checksums @@ -706,14 +717,19 @@ winChkName(un, unlen, wep, chksum, u2w) } code = (cp[1] << 8) | cp[0]; if (code & 0xff80) { - if (table_loaded) + if (u2w_loaded) code = find_lcode(code, u2w); else if (code & 0xff00) code = '?'; } - if (u2l[code] != u2l[*un++]) + c1 = ul_loaded && (code & 0x80) ? + ul[code & 0x7f] : u2l[code]; + c2 = ul_loaded && (*un & 0x80) ? + ul[*un & 0x7f] : u2l[*un]; + if (c1 != c2) return -1; cp += 2; + un++; } for (cp = wep->wePart2, i = sizeof(wep->wePart2)/2; --i >= 0;) { if (--unlen < 0) { @@ -723,14 +739,19 @@ winChkName(un, unlen, wep, chksum, u2w) } code = (cp[1] << 8) | cp[0]; if (code & 0xff80) { - if (table_loaded) + if (u2w_loaded) code = find_lcode(code, u2w); else if (code & 0xff00) code = '?'; } - if (u2l[code] != u2l[*un++]) + c1 = ul_loaded && (code & 0x80) ? + ul[code & 0x7f] : u2l[code]; + c2 = ul_loaded && (*un & 0x80) ? + ul[*un & 0x7f] : u2l[*un]; + if (c1 != c2) return -1; cp += 2; + un++; } for (cp = wep->wePart3, i = sizeof(wep->wePart3)/2; --i >= 0;) { if (--unlen < 0) { @@ -740,14 +761,19 @@ winChkName(un, unlen, wep, chksum, u2w) } code = (cp[1] << 8) | cp[0]; if (code & 0xff80) { - if (table_loaded) + if (u2w_loaded) code = find_lcode(code, u2w); else if (code & 0xff00) code = '?'; } - if (u2l[code] != u2l[*un++]) + c1 = ul_loaded && (code & 0x80) ? + ul[code & 0x7f] : u2l[code]; + c2 = ul_loaded && (*un & 0x80) ? + ul[*un & 0x7f] : u2l[*un]; + if (c1 != c2) return -1; cp += 2; + un++; } return chksum; } diff --git a/sys/msdosfs/msdosfs_lookup.c b/sys/msdosfs/msdosfs_lookup.c index dec491c..4d0663a 100644 --- a/sys/msdosfs/msdosfs_lookup.c +++ b/sys/msdosfs/msdosfs_lookup.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_lookup.c,v 1.17 1998/02/22 17:26:27 ache Exp $ */ +/* $Id: msdosfs_lookup.c,v 1.18 1998/02/22 18:00:52 ache Exp $ */ /* $NetBSD: msdosfs_lookup.c,v 1.37 1997/11/17 15:36:54 ws Exp $ */ /*- @@ -257,7 +257,9 @@ msdosfs_lookup(ap) (struct winentry *)dep, chksum, (pmp->pm_flags & MSDOSFSMNT_U2WTABLE) ? - pmp->pm_u2w : NULL); + pmp->pm_u2w : NULL, + (pmp->pm_flags & MSDOSFSMNT_ULTABLE) ? + pmp->pm_ul : NULL); continue; } diff --git a/sys/msdosfs/msdosfs_vnops.c b/sys/msdosfs/msdosfs_vnops.c index 2319a19..c559eb0 100644 --- a/sys/msdosfs/msdosfs_vnops.c +++ b/sys/msdosfs/msdosfs_vnops.c @@ -1,4 +1,4 @@ -/* $Id: msdosfs_vnops.c,v 1.57 1998/02/22 15:09:50 ache Exp $ */ +/* $Id: msdosfs_vnops.c,v 1.58 1998/02/22 18:00:54 ache Exp $ */ /* $NetBSD: msdosfs_vnops.c,v 1.68 1998/02/10 14:10:04 mrg Exp $ */ /*- @@ -1743,7 +1743,9 @@ msdosfs_readdir(ap) if (chksum != winChksum(dentp->deName)) dirbuf.d_namlen = dos2unixfn(dentp->deName, (u_char *)dirbuf.d_name, - pmp->pm_flags & MSDOSFSMNT_SHORTNAME); + pmp->pm_flags & MSDOSFSMNT_SHORTNAME, + (pmp->pm_flags & MSDOSFSMNT_ULTABLE) ? + pmp->pm_ul : NULL); else dirbuf.d_name[dirbuf.d_namlen] = 0; chksum = -1; diff --git a/sys/msdosfs/msdosfsmount.h b/sys/msdosfs/msdosfsmount.h index 35dc7d9..4095ffc 100644 --- a/sys/msdosfs/msdosfsmount.h +++ b/sys/msdosfs/msdosfsmount.h @@ -1,4 +1,4 @@ -/* $Id: msdosfsmount.h,v 1.13 1998/02/18 09:28:47 jkh Exp $ */ +/* $Id: msdosfsmount.h,v 1.14 1998/02/22 15:09:54 ache Exp $ */ /* $NetBSD: msdosfsmount.h,v 1.17 1997/11/17 15:37:07 ws Exp $ */ /*- @@ -94,6 +94,7 @@ struct msdosfsmount { u_int pm_flags; /* see below */ struct netexport pm_export; /* export information */ u_int16_t pm_u2w[128]; /* Local->Unicode table */ + u_int8_t pm_ul[128]; /* Local upper->lower table */ }; /* Byte offset in FAT on filesystem pmp, cluster cn */ #define FATOFS(pmp, cn) ((cn) * (pmp)->pm_fatmult / (pmp)->pm_fatdiv) @@ -204,6 +205,7 @@ struct msdosfs_args { int flags; /* see below */ int magic; /* version number */ u_int16_t u2w[128]; /* Local->Unicode table */ + u_int8_t ul[128]; /* Local upper->lower table */ }; /* @@ -216,10 +218,11 @@ struct msdosfs_args { #define MSDOSFSMNT_GEMDOSFS 8 /* This is a gemdos-flavour */ #endif #define MSDOSFSMNT_U2WTABLE 0x10 /* Local->Unicode table is loaded */ +#define MSDOSFSMNT_ULTABLE 0x20 /* Local upper->lower table is loaded */ /* All flags above: */ #define MSDOSFSMNT_MNTOPT \ (MSDOSFSMNT_SHORTNAME|MSDOSFSMNT_LONGNAME|MSDOSFSMNT_NOWIN95 \ - /*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_U2WTABLE) + /*|MSDOSFSMNT_GEMDOSFS*/|MSDOSFSMNT_U2WTABLE|MSDOSFSMNT_ULTABLE) #define MSDOSFSMNT_RONLY 0x80000000 /* mounted read-only */ #define MSDOSFSMNT_WAITONFAT 0x40000000 /* mounted synchronous */ #define MSDOSFS_FATMIRROR 0x20000000 /* FAT is mirrored */ |