From owner-freebsd-bugs@FreeBSD.ORG Sun Nov 26 18:30:37 2006 Return-Path: X-Original-To: freebsd-bugs@hub.freebsd.org Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 737C616A4A0 for ; Sun, 26 Nov 2006 18:30:37 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [69.147.83.40]) by mx1.FreeBSD.org (Postfix) with ESMTP id 86E7443DBD for ; Sun, 26 Nov 2006 18:29:34 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.13.4/8.13.4) with ESMTP id kAQIUK0o073410 for ; Sun, 26 Nov 2006 18:30:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.13.4/8.13.4/Submit) id kAQIUK1s073408; Sun, 26 Nov 2006 18:30:20 GMT (envelope-from gnats) Date: Sun, 26 Nov 2006 18:30:20 GMT Message-Id: <200611261830.kAQIUK1s073408@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Micah Cc: Subject: Re: kern/86655 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Micah List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 26 Nov 2006 18:30:37 -0000 The following reply was made to PR kern/86655; it has been noted by GNATS. From: Micah To: Maxim Konovalov 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