kern/86655
Maxim Konovalov
maxim at macomnet.ru
Sun Nov 26 10:40:15 PST 2006
The following reply was made to PR kern/86655; it has been noted by GNATS.
From: Maxim Konovalov <maxim at macomnet.ru>
To: Micah <micahjon at ywave.com>
Cc: bug-followup at freebsd.org, mato <gamato at users.sourceforge.net>
Subject: Re: kern/86655
Date: Sun, 26 Nov 2006 21:36:57 +0300 (MSK)
On Sun, 26 Nov 2006, 10:25-0800, Micah wrote:
> Maxim Konovalov wrote:
> > Hi Micah,
> >
> > I failed to see how your patch changes dos2unixchr() code path. It
> > seems it does the same things for any combinations of LCASE_* flags.
> > Perhaps I'm just blind. Could you explain your patch further?
> >
> > --
> > Maxim Konovalov
>
> Oh, it's been a while, let me examine it...
>
> In dos2unixfn, lower comes from direntry.deLowerCase. deLowerCase is
> byte 0x0c in the FAT dir entry that has two flags. One flag (bit 3)
> determines the "case" of the 8 character filename, the other flag
> (bit 4) determines the "case" of the 3 character extension.
> Wikipedia has a good summary of this:
> http://en.wikipedia.org/wiki/File_Allocation_Table#Directory_table
>
> Now for the code path: dos2unixchr will convert to lower case if
> LCASE_BASE or LCASE_EXT or both are set. But dos2unixfn uses
> dos2unixchr separately for the basename and the extension. So if
> either LCASE_BASE or LCASE_EXT is set, dos2unixfn will convert both
> the basename and extension to lowercase because it is blindly
> passing in the state of both flags to dos2unixchr. The bit masks I
> used ensure that only the state of LCASE_BASE gets passed to
> dos2unixchr when the basename is converted, and only the state of
> LCASE_EXT is passed in when the extension is converted.
>
> Here's an example run:
>
> In the original:
> dosfn=TEST.TXT
> lower=LCASE_EXT (meaning the filename should be TEST.txt)
> unixfn=""
> When dos2unixfn executes the first call to dos2unixchr, dos2unixchr will see
> that LCASE_EXT is set and convert the basename to lowercase:
> unixfn="test"
> When dos2unixfn executes the second call to dos2unixchr, dos2unixchr will see
> that LCASE_EXT is set and convert the extension to lowercase:
> unixfn="test.txt" != "TEST.txt"
>
> In the patch:
> dosfn=TEST.TXT
> lower=LCASE_EXT (meaning the filename should be TEST.txt)
> unixfn=""
> When dos2unixfn executes the first call to dos2unixchr, dos2unixfn will mask
> out all bits of lower but LCASE_BASE, dos2unixchr will see that no bits are
> set and leave the basename as uppercase:
> unixfn="TEST"
> When dos2unixfn executes the second call to dos2unixchr, dos2unixfn will mask
> out all bits of lower but LCASE_EXT, dos2unixchr will see that LCASE_EXT is
> set and convert the extension to lowercase:
> unixfn="TEST.txt" == "TEST.txt"
>
> Does that help, or did I miss something completely when I wrote the
> patch?
Yes, everything is clear now. Thanks, Micah!
--
Maxim Konovalov
More information about the freebsd-bugs
mailing list