Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 26 Nov 2006 18:30:20 GMT
From:      Micah <micahjon@ywave.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/86655
Message-ID:  <200611261830.kAQIUK1s073408@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/86655; it has been noted by GNATS.

From: Micah <micahjon@ywave.com>
To: Maxim Konovalov <maxim@macomnet.ru>
Cc: bug-followup@freebsd.org
Subject: Re: kern/86655
Date: Sun, 26 Nov 2006 10:25:50 -0800

 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?
 
 - Micah



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611261830.kAQIUK1s073408>