FAT12 - Microsoft file system??

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Sentient

FAT12 - Microsoft file system??

Post by Sentient »

I am probably mistaken, but I was under the impression Microsoft was responsible for giving us FAT12.

I went to the Microsoft Knowledge Base to find out all about this lovely *cough* filesystem, and found an interesting article.

KB140418 - Detailed Explanation of FAT Boot Sectors

It details the BPB and EBPB etc.. but I have come across a small booboo.

Page 5 of this article details the EBPB. It is described as being 26 bytes long (which matched some other articles I read), and included the drive number, volume label, and systemid (or filesystem).

If I follow the Microsoft article, setup the EBPB as they describe, Windows 2000 tells me the disk is not formated. Err, bugga :)

Looking at my previously working boot sector, I noticed that the EBPB that worked for me contained only 19 bytes. A field (ID 4 bytes) was missing, and the Volume label was only 8 bytes (instead of MS's 11 bytes).

I realise the obvious answer is "go with what works" but I'm wondering.. Is Microsoft's article wrong? or am I just hackin my way to imminent doom.
Stefan

RE:FAT12 - Microsoft file system??

Post by Stefan »

I'd say Microsoft is wrong. It wouldn't be the first time. Anyways, better to have something that works but doesn't follow standards then something that follows standards but doesn't work...
Robert Lee

RE:FAT12 - Microsoft file system??

Post by Robert Lee »

The volume label is 11 bytes. I don't know why 8 is working for you enless something in your structure is messing up the alignment of that field by 3 bytes.

Once you have a disk with your new boot sector with a known 8-byte label ("01234567"), use an early dos version to read make the label. You may find that the label DOS reads is prefixed by 3 garbage bytes.

Basically, just double-check all your data types.

-Robert
Sentient

RE:FAT12 - Microsoft file system??

Post by Sentient »

JMP FAR PTR Code_Area    ; Yes this compiles to 3 bytes

;===============================================================================
; OEM NAME AND VERSION (8 bytes) [0000:7C03]
;===============================================================================
OEM_ID DB "NEXUS1.0"

;===============================================================================
; BIOS Parameter Block [BPB] (25 bytes) [0000:7C0B]
;===============================================================================
SECTOR_SIZE DW 512 ; Bytes Per Sector
CLUSTER_SIZE DB 1 ; Sectors Per Cluster
RESERVED_SECTORS DW 1 ; Sectors Before first FAT
NUM_FATs DB 1 ; Number of FAT's
ROOT_ENTRIES DW 128 ; Number of entries in root directory
MEDIA_SECTORS DW 2880 ; Number of sectors on media (<32Mb)
MEDIA_DESC DB 0F0h ; Media Descriptor
SECTORS_FAT DW 9 ; Number of sectors in each FAT
SECTORS_TRACK DW 18 ; Number of sectors per track
MEDIA_HEADS DW 2 ; Number of heads
HIDDEN_SECTORS DD 0 ; Number of hidden sectors
MEDIA_SECTORS_L DD 0 ; Number of sectors on media (>=32Mb)

;===============================================================================
; Extended BIOS Parameter Block [EBPB] (19 bytes) [0000:7C24]
;===============================================================================
BOOT_DRIVE DB 0 ; Boot Drive Number
CURRENT_HEAD DB 0 ; UNUSED
SIGNATURE DB 29h ; Extended Boot Record Signature
VOLUME_LABEL DB "        " ; Volume Label (Obsolete)
SYSTEM_ID DB "FAT12   " ; Filesystem on media

This is my 'working' boot BPB/EBPB

According to Microsoft, after Signature there should be a 4-byte Serial number, then VOLUME_LABEL should be 11 bytes (mine is 8)

Another thing I have seen in some different boot sectors, is that sometimes "FAT12" is left-aligned, and other times it is right-aligned. Microsoft simply says that it is 8-bytes (either "FAT12" or "FAT16") so I assume padding on the right.
Xenos

RE:FAT12 - Microsoft file system??

Post by Xenos »

There seem to be many opinions about this... I had a similar problem and examined an original Microsoft bootsector from a Win98 bootdisk. There was one difference, when I fixed it, Windows said my disk is formatted:

...
vollabel db 'XenoBootDsk' ;volume label
fatlabel db 'FAT12',20h,20h,'3'

The '3' at the end seems to be important, but I don't know why.
DR

RE:FAT12 - Microsoft file system??

Post by DR »

Sorry but I think Microsoft whitepapers are RIGHT. Mine works fine with the "standard" BPB. Probably an alignment mistake instead.
Sentient

RE:FAT12 - Microsoft file system??

Post by Sentient »

I will apologize, although I have no idea what the problem is/was.

I went through and checked the Win2k 'format' bootsector, and it was as stated in the Microsoft whitepaper (with the '3' (0x33) character as mentioned in another post).

I changed my code back to the Microsoft spec, and it worked fine. I have been messing with it for the last 2 hours and I honestly can not see any difference between the original code which didnt work, and the new code which does.

I can only assume that I made one of those silly gremlin mistakes.

Following the MS spec to the letter seems to work just fine.
Ready4Dis

RE:FAT12 - Microsoft file system??

Post by Ready4Dis »

My FAT 12 works fine... and yes, I use an 11-byte volume label :).  Important section posted below, as you can see, my BPB is 33 bytes, while the Extended BPB section is 26 bytes.  Let me know if this helps, and if not, post your EBPB, maybe you've got something messed up (or possibly something messed up in your BPB).


jmp short Start
nop

OsName db 'BootProg' ;0x03 ; 8 bytes
; BPB Starts Here ;
BytesPerSector          dw      512             ;0x0B ; 2 bytes  - 10 total
SectorsPerCluster       db      1               ;0x0D ; 1 byte   - 11 total
ReservedSectors         dw      128             ;0x0E ; 2 bytes  - 13 total
NumberOfFATs            db      2               ;0x10 ; 1 byte   - 14 total
RootEntries             dw      224             ;0x11 ; 2 bytes  - 16 total
TotalSectors            dw      2880            ;0x13 ; 2 bytes  - 18 total
Media                   db      240             ;0x15 ; 1 byte   - 19 total
SectorsPerFAT           dw      9               ;0x16 ; 2 bytes  - 21
SectorsPerTrack         dw      18              ;0x18 ; 2 bytes  - 23
HeadsPerCylinder        dw      2               ;0x1A ; 2 bytes  - 25
HiddenSectors         dd 0               ;0x1C ; 4 bytes  - 29
TotalSectorsBig       dd 0               ;0x20 ; 4 bytes  - 33
; BPB Ends Here ;

BootDrive db 0 ;0x24 ; 1 byte   - 1
Unused                 db      0               ;0x25 ; 1 byte   - 2
ExtBootSignature       db      0               ;0x26 ; 1 byte   - 3
SerialNumber           dd      0               ;0x27 ; 4 bytes  - 7
VolumeLabel           db      "NO NAME    "   ;0x2B ; 11 bytes - 18
FileSystem             db      "FAT12   "      ;0x36 ; 8 bytes  - 26
Ready4Dis

RE:FAT12 - Microsoft file system??

Post by Ready4Dis »

Why are you using a 29h for the signature, i use 0h for mine (and it works properly).  Well, glad you've got it fixed, didn't realize that before I posted my other response, so... oh well :).
Post Reply