diff options
author | H. Peter Anvin <hpa@zytor.com> | 2010-01-25 09:41:53 -0800 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2010-01-25 09:41:53 -0800 |
commit | 9ce3e9ca7775032be2bad8ce80fd72eb60af7d69 (patch) | |
tree | fa9d109149de405dfc2051635a8710b05e0c8e13 | |
parent | dbbff6e3ff4ce7e2c1fd84b42559c312656c2d69 (diff) | |
download | syslinux-9ce3e9ca7775032be2bad8ce80fd72eb60af7d69.tar.gz |
FAT: generate EOF depending on exceeding the number of clusters
Generate EOF by comparing to the actual number of clusters. We have
to compute the number of clusters in the filesystem anyway during
setup, so save the number and use it for the EOF computation.
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r-- | core/ldlinux.asm | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/core/ldlinux.asm b/core/ldlinux.asm index 70f9c715..0808e6e8 100644 --- a/core/ldlinux.asm +++ b/core/ldlinux.asm @@ -116,6 +116,7 @@ RootDirSize resd 1 ; Root dir size in sectors TotalSectors resd 1 ; Total number of sectors ClustSize resd 1 ; Bytes/cluster ClustMask resd 1 ; Sectors/cluster - 1 +Clusters resd 1 ; Total number of clusters CopySuper resb 1 ; Distinguish .bs versus .bss DriveNumber resb 1 ; BIOS drive number ClustShift resb 1 ; Shift count for sectors/cluster @@ -183,24 +184,31 @@ getfattype: sub eax,[DataArea] shr eax,cl ; cl == ClustShift mov cl,nextcluster_fat12-(nextcluster+2) - cmp eax,4085 ; FAT12 limit - jb .setsize + cmp eax,0xFF4 ; FAT12 limit + jbe .setsize mov cl,nextcluster_fat16-(nextcluster+2) - cmp eax,65525 ; FAT16 limit - jb .setsize + cmp eax,0xFFF4 ; FAT16 limit + jbe .setsize ; ; FAT32, root directory is a cluster chain ; + mov ecx,0x0FFFFFF4 ; Max possible cluster count + cmp eax,ecx + jb .oksize + mov eax,ecx +.oksize: + mov cl,[ClustShift] - mov eax,[bootsec+44] ; Root directory cluster - sub eax,2 - shl eax,cl - add eax,[DataArea] - mov [RootDir],eax + mov edx,[bootsec+44] ; Root directory cluster + sub edx,2 + shl edx,cl + add edx,[DataArea] + mov [RootDir],edx mov cl,nextcluster_fat28-(nextcluster+2) mov byte [SuperSize],superblock_len_fat32 .setsize: mov byte [nextcluster+1],cl + mov [Clusters],eax ; Total clusters ; ; Common initialization code @@ -1243,7 +1251,7 @@ nextcluster_fat12: .even: and cx,0FFFh movzx edi,cx lea ax,[di-2] - cmp ax,0FF5h + cmp ax,[Clusters] pop si pop cx pop bx @@ -1266,7 +1274,7 @@ nextcluster_fat16: and bx,1FEh movzx edi,word [gs:si+bx] lea ax,[di-2] - cmp ax,0FFF5h + cmp ax,[Clusters] pop bx pop si pop eax @@ -1288,7 +1296,7 @@ nextcluster_fat28: mov edi,dword [gs:si+bx] and edi,0FFFFFFFh ; 28 bits only lea eax,[edi-2] - cmp eax,0FFFFFF5h + cmp eax,[Clusters] pop bx pop si pop eax |