home *** CD-ROM | disk | FTP | other *** search
/ Falcon 030 Power 2 / F030_POWER2.iso / ST_STE / MAGS / ICTARI05.ARJ / ictari.05 / MISC / DISK_STR.TXT
Text File  |  1993-06-21  |  4KB  |  132 lines

  1. A Disk (or other) Volume normally consists of:
  2.     Boot Sector
  3.     File Allocation Table 1
  4.     File Allocation Table 2
  5.     Root Directory
  6.     Cluster (Data) Area
  7.  
  8. Getbpb - Get Bios Parameter Block
  9. ---------------------------------
  10.     This call returns a pointer to a nine word structure that can be used to 
  11. locate all parts of the disk structure.
  12.  
  13.     Bios Parameter Block
  14.     ====================
  15.  
  16. name    value    function
  17. ----    -----    --------
  18. Recsiz    512    Physical sector size in Bytes
  19. Clsiz    2    Cluster Size in Sectors
  20. Clsizb    1024    Cluster Size in Bytes
  21. Rdlen        Root Directory Length in Sectors
  22. Fsiz        FAT Size in Sectors
  23. Fatrec        Start Sector of 2nd FAT
  24. Datrec        Start Sector of Data
  25. Numcl        Number of Data Clusters on Disk
  26. Bflags        Flags
  27.  
  28. Notes:    Values shown must be used to work with GemDos.
  29.  
  30.     Boot Sectors start from Logical Sector zero
  31.     and end at (Fatrec-Fsiz-1)
  32.  
  33.     If Bflags=0     FAT entries are 12 bit
  34.     If Bflags=1    FAT entries are 16 bit
  35.  
  36.     FAT 1 goes from Fatrec-Fsiz to Fatrec-1
  37.     FAT 2 goes from Fatrec to Fatrec+Fsiz-1
  38.  
  39.     Root Directory starts at Fatrec+Fsiz
  40.     
  41.     Directory Entry = 32 bytes
  42. =>     Files Available in Root = (Rdlen * 512)/32
  43.  
  44.     Datrec is the Sector Number of Cluster 0
  45.  
  46.     All File Data is kept in the Data Clusters
  47.     from Cluster 2 (Datrec) to Numcl-1
  48.  
  49. DIRECTORY ENTRIES
  50. -----------------
  51. Filename     8 bytes    1st byte = $E5 if deleted
  52. Extension     3 bytes
  53. Attributes     1 byte
  54. Reserved    10 bytes
  55. Create Time     2 bytes    Low byte, High byte
  56. Create Date     2 bytes    Low byte, High byte
  57. Start Cluster     2 bytes    Low byte, High byte
  58. File Length     4 bytes    LowLow, LowHigh, HighLow, HighHigh
  59.  
  60. Sub-directories are files that contain directory information.
  61. The first two entries in a sub-dir have filenames "." & ".."
  62. "." has its Start Cluster point to the Start Cluster of the file that it is in
  63. ".." has its Start Cluster point to the Start Cluster of the file that its 
  64. parent is in.
  65.  
  66. FAT ENTRIES
  67. -----------
  68. The Fat Table is a list of 12 or 16 bit values.
  69. If the Start Cluster of a file is indexed into this table, the contents of that
  70. record should be either the next cluster number or an end-of-file marker.
  71.  
  72.     12 bit FAT Values
  73.     =================
  74.  
  75.     Cluster Value    Means
  76.     -------------    -----
  77.            $000    Free (unused) Cluster
  78.            $001    NOT VALID
  79.     $002 - $fef    Next Cluster in Chain
  80.     $ff0 - $ff7    Bad Cluster
  81.     $ff8 - $fff    End Of File
  82.     
  83.     16 bit FAT Values
  84.     =================
  85.  
  86.     Cluster Value    Means
  87.     -------------    -----
  88.             $0000    Free (unused) Cluster
  89.             $0001    NOT VALID
  90.     $0002 - $7fff    Next Cluster in Chain
  91.     $8000 - $ffef    NOT VALID
  92.     $fff0 - $fff7    Bad Cluster
  93.     $fff8 - $ffff    End Of File
  94.     
  95. FOLLOWING A FILE'S CLUSTERS IN 12 BIT FATS
  96. ==========================================
  97.  1] Put Start Cluster in CL
  98.  2] Swap High byte and Low byte to get 68000 type number in CL
  99.  3] NCL = Contents of [FAT + (CL + INT(CL/2))] - NOT ON WORD BOUNDARY!
  100.  4] Swap High byte and Low byte to get 68000 type number in NCL
  101.  5] If CL is odd, divide NCL by 16 (NCL>>4) to get correct 12 bits
  102.  6] AND NCL with $FFF to get correct 12 bit value
  103.  7] If NCL>$ff8, then at End-Of-File
  104.  8] If NCL = 0 or 1, then file chain is corrupted
  105.  9] If (NCL <= $ff7) AND (NCL >= $ff0), then bad cluster in file
  106. 10] If (NCL <= $fef) AND (NCL >= $002), then this is next Cluster in chain
  107.     Put NCL into CL and Goto Step 3].
  108.  
  109. FOLLOWING A FILE'S CLUSTERS IN 16 BIT FATS
  110. ==========================================
  111.  1] Put Start Cluster in CL
  112.  2] Swap High byte and Low byte to get 68000 type number in CL
  113.  3] NCL = Contents of [FAT + (CL * 2)]
  114.  4] Swap High byte and Low byte to get 68000 type number in NCL
  115.  5] If NCL>$fff8, then at End-Of-File
  116.  6] If NCL = 0 or 1 or between $8000-$ffef, then file chain is corrupted
  117.  7] If (NCL <= $fff7) AND (NCL >= $fff0), then bad cluster in file
  118.  8] If (NCL <= $7fff) AND (NCL >= $0002), then this is next Cluster in chain
  119.     Put NCL into CL and Goto Step 3].
  120.  
  121. CLUSTER NUMBER TO LOGICAL SECTOR
  122. ================================
  123.  1] Swap High byte and Low byte to get 68000 type number
  124.  2] Subtract 2 as 0 and 1 are reserved cluster numbers
  125.  3] Multiply by sectors-per-cluster (Clsiz)
  126.  4] Add logical sector of first cluster (Datrec)
  127.  
  128.  
  129.  
  130.  
  131.  
  132.