SYSLINUX: fix handling of .bss files for FAT12/FAT16
authorH. Peter Anvin <hpa@linux.intel.com>
Mon, 16 Mar 2009 23:16:39 +0000 (16:16 -0700)
committerH. Peter Anvin <hpa@linux.intel.com>
Mon, 16 Mar 2009 23:16:39 +0000 (16:16 -0700)
The size of the superblock is different for FAT12/FAT16 and FAT32.  We
should only copy the relevant portions of the superblock over.
Technically speaking, it is possible for FAT12/FAT16 to have an older,
smaller superblock as well (without the 0x29 boot signature); we don't
handle that at the moment.

NEWS
core/bootsect.inc
core/ldlinux.asm

diff --git a/NEWS b/NEWS
index 1fcb3ab..a5aa891 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ Changes in 3.74:
        * MEMDISK: enable automatic determination of the disk geometry
          for a large floppy disk image if (and only if) it is
          formatted with a FAT filesystem.
+       * SYSLINUX: fix the handling of .bss files on FAT12/16.
 
 Changes in 3.73:
        * Upgrade gPXE to release version 0.9.5.
index 7e8f416..45fb7a8 100644 (file)
@@ -1,6 +1,6 @@
 ;; -----------------------------------------------------------------------
 ;;
-;;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
+;;   Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
 ;;
 ;;   This program is free software; you can redistribute it and/or modify
 ;;   it under the terms of the GNU General Public License as published by
 is_bootsector:
 %if IS_SYSLINUX || IS_MDSLINUX
                ; Transfer zero bytes
-               mov byte [CopySuper],0
+               push word 0
                jmp short load_bootsec
 
 is_bss_sector:
                ; Transfer the superblock
-               mov byte [CopySuper],superblock_len
+SuperSize      equ $+1
+               push word superblock_len_fat16
 %endif
 load_bootsec:
                mov edi, 100000h
@@ -49,15 +50,13 @@ load_bootsec:
                mov [EntryPoint],eax    ; Jump to this address when done
 
 %if IS_SYSLINUX || IS_MDSLINUX
-               movzx ecx,byte [CopySuper]
-               jcxz .not_bss
+               xchg eax,ecx            ; ECX[31:16] <- 0
+               pop cx
 
                ; For a BSS boot sector we have to patch.
                mov esi,superblock
                mov edi,100000h+(superblock-bootsec)
                call bcopy
-
-.not_bss:
 %endif
 
                xor edx,edx
index a24f396..2219d5f 100644 (file)
@@ -11,7 +11,7 @@
 ;  from MS-LOSS, and can be especially useful in conjunction with the
 ;  umsdos filesystem.
 ;
-;   Copyright 1994-2008 H. Peter Anvin - All Rights Reserved
+;   Copyright 1994-2009 H. Peter Anvin - All Rights Reserved
 ;
 ;  This program is free software; you can redistribute it and/or modify
 ;  it under the terms of the GNU General Public License as published by
@@ -211,9 +211,13 @@ superinfo_size     equ ($-superblock)-1    ; How much to expand
                ;
                ; This is as far as FAT12/16 and FAT32 are consistent
                ;
-               zb 54                   ; FAT12/16 need 26 more bytes,
-                                       ; FAT32 need 54 more bytes
-superblock_len equ $-superblock
+               ; FAT12/16 need 26 more bytes,
+               ; FAT32 need 54 more bytes
+               ;
+superblock_len_fat16   equ $-superblock+26
+superblock_len_fat32   equ $-superblock+54
+               zb 54                   ; Maximum needed size
+superblock_max equ $-superblock
 
 SecPerClust    equ bxSecPerClust
 ;
@@ -865,6 +869,7 @@ getfattype:
                add eax,[DataArea]
                mov [RootDir],eax
                mov cl,nextcluster_fat28-(nextcluster+2)
+               mov byte [SuperSize],superblock_len_fat32
 .setsize:
                mov byte [nextcluster+1],cl