more fat fs type checks

This commit is contained in:
2025-09-18 11:50:27 -04:00
parent d8a89cfd2b
commit 8002d1cb54
2 changed files with 12 additions and 5 deletions

View File

@@ -65,11 +65,11 @@ struc FAT32_bpb_t
.u16_RootEntryCount16 resw 1 ; Root dir entry count field, 0 on fat32
.u16_TotalSectors16 resw 1 ; total number of sectors size, 0 on fat32
.u8_MediaDesc resb 1
.u16_FatSize16 resw 1 ; FAT size 16, 0 on fat32
.u16_FATSize16 resw 1 ; FAT size 16, 0 on fat32
.u16_SectorsPerTrack resw 1
.u16_HeadCount resw 1
.u32_HiddenSectors resd 1
.u32_TotalSectors resd 1
.u32_TotalSectors32 resd 1
endstruc
; EBPB Information (FAT32)
@@ -89,7 +89,7 @@ endstruc
; 8 System identifier string. Always "FAT32 ". The spec says never to trust the contents of this string for any use.
struc FAT32_ebpb_t
.u32_FATSz resd 1 ; size of *each* fat in sectors, total = FATSz * (# of FATs)
.u32_FATSize32 resd 1 ; size of *each* fat in sectors, total = FATSz * (# of FATs)
.u16_ExtFlags resw 1
.u16_FSVersion resw 1
.u32_RootDirCluster resd 1

View File

@@ -257,8 +257,15 @@ ReadVbrData:
mov bx, [bp + 6]
cmp word [bx + 0x1FE], 0xAA55 ; check for bytes at end
jne ReadVbrData.error_nosign
.check_FAT_size:
test word [bx + FAT32_bpb_t.u16_TotalSectors16], 0 ; TotSectors16 will not be set if FAT32
.check_FAT_sanity:
; we only quickly validate that this is *probably* a FAT32 volume
test word [bx + FAT32_bpb_t.u16_TotalSectors16], 0 ; TotalSectors16 should be 0 (use TotalSectors32 in bpb)
jnz ReadVbrData.error_badfatfs
test word [bx + FAT32_bpb_t.u16_FATSize16], 0 ; FatSize16 will be 0 if FAT32 (use FATSize32 in ebpb)
jnz ReadVbrData.error_badfatfs
test word [bx + FAT32_bpb_t.u16_RootEntryCount16], 0 ; root dir info is in data clusters on fat32
jnz ReadVbrData.error_badfatfs
.endp:
__CDECL16_PROC_EXIT