ldlinux: handle "first byte E5 change to 05" rule in FAT
authorH. Peter Anvin <hpa@zytor.com>
Wed, 25 Jun 2008 20:50:50 +0000 (13:50 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 25 Jun 2008 20:50:50 +0000 (13:50 -0700)
FAT has a somewhat obnoxious rule: byte E5 in the first position is
encoded as 05.  If it was *always* that case we could simply fold it
into the codepage tables, but that rule applies only to the first
character.

Note that in the common codepages (incl. 437), E5 is lower-case sigma
(σ), which we currently upper case to upper case sigma (Σ, E4)
preventing a match -- which DOS *doesn't* do (it thinks of the Greek
characters as symbols, not subject to case distinctions.)  Putting
that special case in the codepage-generation scripts seems too ugly,
though.

core/ldlinux.asm

index 5a205c0..9cf1c03 100644 (file)
@@ -1394,7 +1394,11 @@ mangle_dos_name:
                cmp al,'.'                      ; Period -> space-fill
                je .is_period
                xlatb                           ; Convert to upper case
-               stosb
+               mov ah,cl                       ; If the first byte (only!)...
+               cmp ax,0BE5h                    ; ... equals E5 hex ...
+               jne .charok
+               mov al,05h                      ; ... change it to 05 hex
+.charok:       stosb
                loop .loop                      ; Don't continue if too long
                ; Find the end for the benefit of longname search
 .find_end: