A Disk (or other) Volume normally consists of: Boot Sector File Allocation Table 1 File Allocation Table 2 Root Directory Cluster (Data) Area Getbpb - Get Bios Parameter Block --------------------------------- This call returns a pointer to a nine word structure that can be used to locate all parts of the disk structure. Bios Parameter Block ==================== name value function ---- ----- -------- Recsiz 512 Physical sector size in Bytes Clsiz 2 Cluster Size in Sectors Clsizb 1024 Cluster Size in Bytes Rdlen Root Directory Length in Sectors Fsiz FAT Size in Sectors Fatrec Start Sector of 2nd FAT Datrec Start Sector of Data Numcl Number of Data Clusters on Disk Bflags Flags Notes: Values shown must be used to work with GemDos. Boot Sectors start from Logical Sector zero and end at (Fatrec-Fsiz-1) If Bflags=0 FAT entries are 12 bit If Bflags=1 FAT entries are 16 bit FAT 1 goes from Fatrec-Fsiz to Fatrec-1 FAT 2 goes from Fatrec to Fatrec+Fsiz-1 Root Directory starts at Fatrec+Fsiz Directory Entry = 32 bytes => Files Available in Root = (Rdlen * 512)/32 Datrec is the Sector Number of Cluster 0 All File Data is kept in the Data Clusters from Cluster 2 (Datrec) to Numcl-1 DIRECTORY ENTRIES ----------------- Filename 8 bytes 1st byte = $E5 if deleted Extension 3 bytes Attributes 1 byte Reserved 10 bytes Create Time 2 bytes Low byte, High byte Create Date 2 bytes Low byte, High byte Start Cluster 2 bytes Low byte, High byte File Length 4 bytes LowLow, LowHigh, HighLow, HighHigh Sub-directories are files that contain directory information. The first two entries in a sub-dir have filenames "." & ".." "." has its Start Cluster point to the Start Cluster of the file that it is in ".." has its Start Cluster point to the Start Cluster of the file that its parent is in. FAT ENTRIES ----------- The Fat Table is a list of 12 or 16 bit values. If the Start Cluster of a file is indexed into this table, the contents of that record should be either the next cluster number or an end-of-file marker. 12 bit FAT Values ================= Cluster Value Means ------------- ----- $000 Free (unused) Cluster $001 NOT VALID $002 - $fef Next Cluster in Chain $ff0 - $ff7 Bad Cluster $ff8 - $fff End Of File 16 bit FAT Values ================= Cluster Value Means ------------- ----- $0000 Free (unused) Cluster $0001 NOT VALID $0002 - $7fff Next Cluster in Chain $8000 - $ffef NOT VALID $fff0 - $fff7 Bad Cluster $fff8 - $ffff End Of File FOLLOWING A FILE'S CLUSTERS IN 12 BIT FATS ========================================== 1] Put Start Cluster in CL 2] Swap High byte and Low byte to get 68000 type number in CL 3] NCL = Contents of [FAT + (CL + INT(CL/2))] - NOT ON WORD BOUNDARY! 4] Swap High byte and Low byte to get 68000 type number in NCL 5] If CL is odd, divide NCL by 16 (NCL>>4) to get correct 12 bits 6] AND NCL with $FFF to get correct 12 bit value 7] If NCL>$ff8, then at End-Of-File 8] If NCL = 0 or 1, then file chain is corrupted 9] If (NCL <= $ff7) AND (NCL >= $ff0), then bad cluster in file 10] If (NCL <= $fef) AND (NCL >= $002), then this is next Cluster in chain Put NCL into CL and Goto Step 3]. FOLLOWING A FILE'S CLUSTERS IN 16 BIT FATS ========================================== 1] Put Start Cluster in CL 2] Swap High byte and Low byte to get 68000 type number in CL 3] NCL = Contents of [FAT + (CL * 2)] 4] Swap High byte and Low byte to get 68000 type number in NCL 5] If NCL>$fff8, then at End-Of-File 6] If NCL = 0 or 1 or between $8000-$ffef, then file chain is corrupted 7] If (NCL <= $fff7) AND (NCL >= $fff0), then bad cluster in file 8] If (NCL <= $7fff) AND (NCL >= $0002), then this is next Cluster in chain Put NCL into CL and Goto Step 3]. CLUSTER NUMBER TO LOGICAL SECTOR ================================ 1] Swap High byte and Low byte to get 68000 type number 2] Subtract 2 as 0 and 1 are reserved cluster numbers 3] Multiply by sectors-per-cluster (Clsiz) 4] Add logical sector of first cluster (Datrec)