home *** CD-ROM | disk | FTP | other *** search
/ No Fragments Archive 10: Diskmags / nf_archive_10.iso / MAGS / ST_USER / 1990 / USERJA90.MSA / DISKEDIT.TXT < prev    next >
Text File  |  1989-10-26  |  28KB  |  717 lines

  1. DISKEDIT - A sector editor (Version 1.08) 
  2.  
  3. Instruction Manual...By M.H. Smith 1988
  4.  
  5. Contents:
  6.  
  7.  
  8.  
  9. 1. Using the program
  10.  a. Getting started
  11.  b. Simple editing
  12.  c. More advanced features
  13. 2. Reference section
  14.  a. The FILE menu
  15.  b. The MOVE menu
  16.  c. The CHECK menu
  17.  d. The SHOW menu
  18.  e. The OPTIONS menu
  19.  f. Keyboard menu selections
  20. 3. Atari disk format
  21.  a. Physical disk format
  22.  b. Logical disk format
  23.  c. Root and sub directories
  24.  d. The file allocation table
  25.  
  26. Section 1: Using the program 
  27.  
  28. Subsection a: Getting Started 
  29.  
  30. Current limitations and warnings
  31.  If a single file on the disk is to be edited then it follows that 
  32. the disk must have a correct file allocation table. There are checks 
  33. in the program to prevent this but it is recommended that you do not 
  34. use the Open File menu option on a disk when you know the FAT is 
  35. incorrect.
  36.  
  37. The program is also restricted to editing standard ST disks with 2 
  38. 512 byte sectors per cluster. This should not be much of a limitation 
  39. as I have yet to see a disk that isn't.
  40.  
  41. The program usually assumes that the Bios Parameter block on the 
  42. disk is correct. Because of the way the program works a totally 
  43. scrambled BPB could cause trouble if it indicates that there is a 
  44. ridiculously large number of sectors on the disk. Again I have yet to 
  45. see this happen but I suppose it will occur eventually.
  46.  
  47. Be careful
  48. It goes without saying that you can do tremendous damage by careless 
  49. use of a sector editor. If you have never used one before read the 
  50. section on the Atari disk format first. For experimenting purposes 
  51. set the write protect on a disk and examine it to get used to the 
  52. program. If you ever lose any data follow this procedure:
  53.  
  54. i) Stay very calm, do not format the disk out of frustration. It 
  55.  is very likely that most of the data is still on it.
  56.  
  57. ii) Use a bit or sector copier to make a backup of the corrupt
  58.  disk. This may help to identify physically damaged sectors
  59.  and you can then work on the backup copy in relative safety.
  60.  
  61. iii ) Before making any changes be sure you know what you intend to
  62.  do, how the disk is organised and how you will be able to
  63.  recover if you mess up.
  64.  
  65. iv) If at all possible do not write on the defective disk. Pull
  66.  the sectors containing your data into memory and write them
  67.  as a file onto another disk (this is covered later).
  68.  
  69. Severely damaged disks
  70.  If the sectors on the disk are damaged in such a way that the 
  71. controller can no longer read them then there is obviously very 
  72. little that can be done. Take the advice of the program, open the 
  73. window, grab the disk by its edge and throw, hard.
  74.  
  75. If the file allocation table is defective it makes the job of 
  76. recovery more difficult but not impossible. You must locate the 
  77. sectors on the disk which contain your data and indicate to the 
  78. program the order they should be put in to form the file. You can 
  79. usually spot a defective FAT when you ask to see a file and the drive 
  80. makes a noise like it is about to break out of the case.
  81.  
  82. If you are sensible about keeping backups then you have less 
  83. worries, usually. If you do not realise a disk is corrupt and use a 
  84. sector copier you can back up the corruption (don't laugh I have done 
  85. it!)
  86.  
  87. Subsection b: Simple Editing: 
  88.  
  89. Opening a disk or file 
  90.  
  91. Put the disk in question into the drive and click the Open Disk or 
  92. Open File menu options. When you edit a disk you can move about 
  93. between and edit all the sectors on that disk (1440 on a double sided 
  94. disk). If you open a file you must indicate which one by using the 
  95. file selector. You are then confined to the sectors that make up that 
  96. file.
  97.  
  98. The info line of the window changes to actually give information. 
  99. It shows the sector you are at, the highest number sector available 
  100. and flags which show the state of that sector. These are explained 
  101. later.
  102.  
  103. The window title changes to indicate the disk being edited or the 
  104. full path of the file being edited.
  105.  
  106. Sector zero of the disk or file is brought into memory and displayed 
  107. in the window.
  108.  
  109. Using the editor
  110.  
  111. The square editing cursor can be moved around with the cursor keys 
  112. or you can point and click the mouse where you want the cursor. The 
  113. <Backspace> key acts like a left cursor.
  114.  
  115. To change one of the bytes of the sector either type a character in 
  116. the ascii range (code 32 - 126) if the character display is on or 
  117. type two hex digits. If you change your mind after one digit has been 
  118. typed press the <Backspace> key.
  119.  
  120. If the new value you supply differs from the one that was there 
  121. before then the sector is considered to be changed and an indication 
  122. of this appears on the info line of the window.
  123.  
  124. To move to a different sector press ALT-G or select the Goto Sector 
  125. menu option. Assuming the number of the sector that you then supply 
  126. is in range then that sector will be read from disk for editing.
  127.  
  128. Saving Changes
  129.  
  130. For now ensure that the option Caching To RAM is turned off. When 
  131. you move off of a sector that has been changed or close the disk 
  132. without writing changes to a sector then an alert appears asking if 
  133. you want the changed sector written or not.
  134.  
  135. You can save the sector yourself at any time by pressing ALT-W or 
  136. selecting the Write Sector option. This does not clear the changed 
  137. indication as there is still a copy of the original sector in memory 
  138. and you may recover it with the Undo Changes option or ALT-U if you 
  139. decide that the changes were not really wanted. Then hit ALT-W again. 
  140. this only applies until you move off of a sector. More powerful undo 
  141. is available with the caching option enabled and is explained in the 
  142. next section.
  143.  
  144. Subsection c: More Advanced Features
  145.  
  146. Storing changes in RAM 
  147.  
  148. With the caching option turned on and you move off of a sector that 
  149. has been changed then it is not written to disk but is stored in 
  150. memory, along with a copy of the sector as it was unchanged. If 
  151. you move back to this sector it is not read from the disk again but is 
  152. obtained from memory. An indication of this is the word <CACHED> 
  153. appearing on the info line. Asking for undo changes on such a sector 
  154. causes the display to revert to the sector as it was read from disk, 
  155. not the last time you edited it. Thus you can be sure that the sector 
  156. is then really unchanged.
  157.  
  158. When the disk or file is closed then you are asked if you want all 
  159. the sectors you have changed written back to the disk (if there are 
  160. any changes). If you confirm this then they are written. A failed 
  161. write cancels the close option so you may select it again and retry.
  162.  
  163. The amount of free memory determines the number of sectors that you 
  164. may store. It is up to you to be sensible.
  165.  
  166. You can force an unchanged sector to be cached by pressing ALT-C or 
  167. selecting the Cache Sector option. The indication of this appears 
  168. immediately on the info line.
  169.  
  170. What have I done?
  171.  
  172. If you do have caching switched on then you can get a list of the 
  173. changes you have made by selecting the Show Changes Made option. This 
  174. lists the byte and sector numbers of each change and what the byte 
  175. used to be and what you changed it to.
  176.  
  177. Turn on the hardcopy option to get a printed record of the changes.
  178.  
  179. Should you decide you need a list of the changes after closing the 
  180. disk or file it is still available until the next open which will 
  181. clear out the cache. 
  182.  
  183. File recovery, FAT damage
  184.  
  185. If the disk you are dealing with does not have a damaged FAT then 
  186. you can use the Show File Trace option to get a list of the sectors 
  187. the file occupies. Remember space is allocated 2 sectors at a time 
  188. and these are consecutive logical sectors and note that the show 
  189. option only gives the first sector in each cluster.
  190.  
  191. If the FAT is damaged you must search the disk yourself to find the 
  192. numbers of the sectors holding data. Use the Search for match option. 
  193. A thing to watch for is when you have several deleted copies of a 
  194. file on a disk. There will be several sectors holding similar data so 
  195. make sure you get the right one.
  196.  
  197. So open the disk (don't use open file) and find out where the data 
  198. is. 
  199.  
  200. Once you know which sectors you need visit them in the correct order 
  201. and press ALT-M or click the Mark Sector option on each. The sector 
  202. is brought into the cache and a double indication <CACHED> and 
  203. +MARKED+ appears on the info line.
  204.  
  205. Once all the sectors have been marked then close the disk. You will 
  206. then get a message asking whether you want the marked sectors 
  207. written. Click Yes and supply a file name to the hideous file 
  208. selector. If you only have one drive (shame) change disks first. The 
  209. sectors you marked are then written out to form the file in the order 
  210. that you marked them.
  211.  
  212. It is highly likely that the file will not have had a length of a 
  213. multiple of 512 so you can now load the file into Tempus or some 
  214. inferior editor, chop off the extra garbage and save it again.
  215.  
  216. Sure is easy eh? maybe it will encourage some more backups to be 
  217. made. Seriously: if the FAT is down what did you expect. Automatic 
  218. recognition of which sectors happen to be in your file?
  219.  
  220. Section 2: Reference Section 
  221.  
  222. This section describes all the available menu options and even tells 
  223. you what they are supposed to do. 
  224.  
  225. Subsection a: FILE menu
  226.  
  227. Open Disk 
  228.  
  229. This option opens up a disk for editing. You are asked which drive. 
  230. Sector zero is then read in and displayed and you may start editing. 
  231. This option clears out any cached sectors remaining from a previous 
  232. edit.
  233.  
  234. Open File 
  235.  
  236. This option opens a file. You must specify the path of the file by 
  237. using the file selector and it is then opened. The sectors holding 
  238. the file are located and the first is read into memory for editing. 
  239. It is displayed as being sector zero though its actual sector number 
  240. on the disk will be different. Like the previous option this one 
  241. clears out cached sectors.
  242.  
  243. Cache Sector 
  244.  
  245. This copies the sector being edited into the buffer and indicates 
  246. the fact on the info line. If there is no more memory an error 
  247. message results. Has no effect if the sector is already in the cache. 
  248. Cached sectors may be written back to the disk when the disk or file 
  249. is closed.
  250.  
  251. Mark Sector 
  252.  
  253. This indicates that the sector being edited is the next one in a 
  254. file to be recovered. It is copied into the cache and a message to 
  255. that effect is displayed on the info line. This option has no effect 
  256. if the sector in the buffer has already been marked or you are editing 
  257. a file, when it does not make sense, The marked sectors may be 
  258. written out when the disk is closed.
  259.  
  260. Undo Changes 
  261.  
  262. If the sector in the buffer has been changed then it is restored to 
  263. the state it was in when read from disk. A cached sector is not 
  264. restored to the state before the last edit but back to its original 
  265. state. This option does not affect the disk.
  266.  
  267. Write Sector 
  268.  
  269. This option causes the sector in the edit buffer to be written back 
  270. to its correct place on disk. It does not affect the indication of 
  271. whether the disk was changed. A copy of the sector as it was still 
  272. exists and can be recovered until the sector is left. If caching is 
  273. on then a copy of the original sector remains in the cache until it 
  274. is cleared.
  275.  
  276. Close 
  277.  
  278. This option causes the disk or file to be closed. If you have 
  279. changed the sector in the buffer you will get the option to write to 
  280. disk. Similarly if you have sectors in the cache which are changed or 
  281. have marked some sectors you will be asked whether you want these 
  282. written out as well. The close option does not destroy data in the 
  283. cache so the list of changed sectors is still available until the 
  284. next open disk or file.
  285.  
  286. The same effect as the close menu option can be obtained by clicking 
  287. the window close box. Clicking this box without a disk or file open 
  288. causes the window to be cleared.
  289.  
  290. Quit 
  291.  
  292. Can not be selected unless close has been used. This takes you out 
  293. of the program.
  294.  
  295. Subsection b: The MOVE Menu 
  296.  
  297. Goto Sector 
  298.  
  299. After asking for a sector number then that sector will be fetched in 
  300. for editing. You cannot exceed the maximum sector as displayed at 
  301. the top of the screen. If a file is open then the sector read in will 
  302. be the one at the specified position in the file, sector 1 of the 
  303. file is never logical sector 1 on the disk.
  304.  
  305. Goto Offset 
  306.  
  307. This option is only available when you are editing a file. You must 
  308. type in a hex offset in bytes from the beginning of the file (2,4 or 
  309. 6 digits) and the sector and byte position of this offset is 
  310. calculated and you are moved there. This is useful when you want to 
  311. patch a file you have examined with a monitor. Remember that 
  312. executable files have a header which is removed on loading.
  313.  
  314. Search For Match 
  315.  
  316. If the display selected is character mode then you are asked to 
  317. supply a character string to be searched for. Otherwise you must type 
  318. a hex string, e.g. 0407 to search for 2 bytes.
  319.  
  320. Once this has been done the search of the disk or file starts at the 
  321. editing cursor position and continues until the pattern is found or 
  322. the end of the disk or file is reached.
  323.  
  324. You can stop the search at any time by holding do the right mouse 
  325. button.
  326.  
  327. If the search was successful then the edit cursor is moved to where 
  328. the match was found. If you stopped the search or the pattern was not 
  329. found then the cursor is left where it was before the search.
  330.  
  331. Next Match 
  332.  
  333. This option, available after a successful search, causes the next 
  334. match to be sought. It always continues the search from the byte 
  335. after the one where the last match occurred. i.e. you may move the 
  336. cursor to examine any sectors you like between uses of this option.
  337.  
  338. Subsection c: The CHECK Menu 
  339.  
  340. Check FAT 
  341.  
  342. The file allocation table on the specified drive is read in and 
  343. checked for consistency. Problems detected include chains of clusters 
  344. running through bad disk clusters, cycles of clusters and a chain 
  345. hitting a cluster marked as free.
  346.  
  347. A problem not detected is two files pointing to the same chain of 
  348. clusters as this would mean reading all the sub-directories on the 
  349. disk. This is a rare situation though and should be quite easy to 
  350. spot.
  351.  
  352. Check Boot Sector 
  353.  
  354. This option reads in the boot sector of the specified drive and 
  355. checksums it to see if it will be executed when the disk is booted 
  356. from. This occurs if the word checksum of the disk is 1234 hex. A 
  357. message is printed giving the result.
  358.  
  359. Most disks should not have executable boot sectors. Some protected 
  360. software does for example. You should be suspicious of disks such as 
  361. P.D. software that have executable boot sectors as it is one of the 
  362. means that stupid people could use to try and do your data in. You 
  363. could also try looking for hidden files in the AUTO folder if you are 
  364. really paranoid.
  365.  
  366. Subsection d: The SHOW Menu 
  367.  
  368. The options in this menu have several things in common. They all 
  369. treat the screen as a scrolling text window and display their 
  370. information in it. If the hardcopy option is on then anything printed 
  371. in the window appears on the printer as well.
  372.  
  373. If you are editing a disk or file and you use one of these options 
  374. then the sector display is restored from an internal buffer when the 
  375. output has finished.
  376.  
  377. You can pause the output by holding down the right mouse button or 
  378. by pressing one or more of <SHIFT>, <ALT> or <CONTROL>. Output 
  379. resumes when you release the key or button.
  380.  
  381. Show Disk Info 
  382.  
  383. This option displays the data in the Bios Parameter Block of a disk. 
  384. This includes things like the size and position of the root directory 
  385. and FAT and how many free clusters there are left.
  386.  
  387. If the claimed number of free clusters exceeds the count of the 
  388. number of clusters on the disk then a warning message is printed.
  389.  
  390. Show Directories 
  391.  
  392. After selecting this option you can use the file selector to pick 
  393. the directory you are interested in. After selecting one it is 
  394. searched for files and their name, size, creation date and attributes 
  395. are displayed.
  396.  
  397. Show Sector 
  398.  
  399. This causes the sector being edited to be displayed in character and 
  400. hex form. It is included so a copy of the sector can be printed out.
  401.  
  402. Show FAT 
  403.  
  404. This option reads in a file allocation table and prints it out in a 
  405. relatively easy to read form. The cluster number is given at the left 
  406. hand side of the output then 8 clusters follow on the line. For each 
  407. is printed the contents of that entry and a 3 letter code indicating 
  408. its significance.
  409.  
  410. The display often includes a lot of empty entries as it does not 
  411. believe the count of the number of clusters on disk but always prints 
  412. to the end of the FAT even though most of these entries do not exist.
  413.  
  414.  
  415.  The meaning of the codes is as follows:
  416.  
  417.  
  418.  BAD The cluster was marked bad at format time
  419.  
  420.  RES The cluster is reserved (cluster 1)
  421.  
  422.  EOF The cluster is the last one in a particular file
  423.  
  424.  USE The cluster is allocated.
  425.  
  426. ??? The entry points to a reserved cluster. 
  427.  
  428. nothing The cluster is a free one
  429.  
  430. Reserved clusters should never be allocated so the presence of a 
  431. '???' entry indicates problems. If the symbol is 'USE' then the 
  432. number in that entry is the number of the next sequential cluster in 
  433. the file. Follow that chain to the next one and then see what to do 
  434. next!
  435.  
  436. Show File Trace 
  437.  
  438. This option asks for a filename. As with Open File this option 
  439. interprets a null filename as a request to operate on the directory 
  440. given in the path, this allows you to find where a sub- directory 
  441. occurs on disk.
  442.  
  443. The trace produced lists each cluster of the file in order, the 
  444. logical sector number on disk of the first sector in the cluster is 
  445. printed in brackets following the cluster number.
  446.  
  447. Show Changes Made 
  448.  
  449. This option scans the sectors held in the cache. For any of them 
  450. that have been changed a record of the changes is printed. This gives 
  451. the byte and sector number of the change and what the byte was 
  452. changed from and to.
  453.  
  454. A printed copy of this can be very useful if you find you have done 
  455. something very silly. It does happen you know.
  456.  
  457. Subsection e: The OPTIONS Menu 
  458.  
  459. Character Display 
  460.  
  461. This changes mode of display of the program between hexadecimal and 
  462. character mode. It affects the sector display, the entry of data and 
  463. the form in which you are asked to specify a search string.
  464.  
  465. Caching To RAM 
  466.  
  467. This option turns the caching of sectors on and off. With this 
  468. option on changed sectors are not written straight back to disk but 
  469. are stored in memory. You may make as many changes to as many sectors 
  470. that will fit in memory as you like.
  471.  
  472. When you close the disk you can then have all the changed sectors 
  473. written at once.
  474.  
  475. Hardcopy Of Show 
  476.  
  477. When this option is turned on then all output from the options in 
  478. the SHOW menu is sent to the printer as well as to the screen.
  479.  
  480. Should you select a SHOW option with hardcopy enabled and the 
  481. printer is not present or not on line then an error message is 
  482. produced.
  483.  
  484.  
  485.  Subsection f: Keyboard Menu Selections 
  486.  
  487. Certain menu options can also be accessed from the keyboard. These 
  488. will only be accepted in cases where the menu option would be 
  489. allowed. The keys to press are as follows:
  490.  
  491.  
  492.  ALT-U Undo Changes
  493.  ALT-W Write Sector
  494.  ALT-C Cache Sector
  495.  ALT-M Mark Sector
  496.  
  497.  ALT-G Goto Sector
  498.  ALT-O Goto Offset
  499.  
  500.  ALT-F Search For Match
  501.  ALT-N Next Match
  502.  
  503. Section 3: Atari Disk Format 
  504.  
  505. Subsection a: Physical Format 
  506.  
  507. Tracks And Sectors 
  508.  
  509. An Atari disk is either single or double sided, rumours of a triple 
  510. sided disk under development are completely untrue!
  511.  
  512. Each side of the disk is formatted into concentric rings, called 
  513. tracks, on standard disks there are 80 tracks, protected disks 
  514. sometimes use more.
  515.  
  516. Each track is divided into sectors, the standard format has 9 
  517. sectors, each holding 512 bytes per track.
  518.  
  519. So on a double sided disk this results in 2x80x9x512 bytes of 
  520. storage space = 737280. This is known as the formatted capacity, when 
  521. you bought the drive they will have quoted the unformatted capacity 
  522. of 1Mb as it is bigger.
  523.  
  524. The Boot Sector 
  525.  
  526. You do not get all the above space to yourself however. To start 
  527. with sector 0 track 0 of the first side is known as the boot sector. 
  528. It sometimes contains boot code and always contains the Bios 
  529. Parameter Block. This is a description of the disk indicating the 
  530. areas reserved by the operating system and the area you may store 
  531. data in. The block occupies 9 words in the boot sector and contains 
  532. the following information:
  533.  
  534.  
  535. Name Use 
  536.  
  537.  recsiz Size of sectors in bytes
  538.  clsiz Size of a cluster in sectors
  539.  clsizb Cluster size in bytes
  540.  rdlen Length of root directory
  541.  fsiz Size of FAT in sectors
  542.  fatrec No of 1st sector of 2nd FAT copy
  543.  datrec No of 1st sector for users data
  544.  numcl No of data clusters on disk
  545.  flags Indicates FAT format
  546.  
  547. clsizb has always seemed a little superfluous. I assume it is because 
  548. the format was borrowed from the bad old 8086 which finds 2x512 a 
  549. little arduous.
  550.  
  551. rdlen is the size of the root directory in sectors. This is 
  552. described more fully later.
  553.  
  554. There are two consecutive copies of the FAT held on disk. I am not 
  555. sure why as it has never seemed to prevent the OS screwing the disk 
  556. up.
  557.  
  558. If bit zero of flags is set it indicates that the FAT has 16 bit 
  559. entries. This occurs on a hard disk. The program will at present 
  560. refuse to edit disks with a 16 bit FAT. Floppy disks have 12 bit 
  561. entries.
  562.  
  563. If the boot sector word checksums to 1234 hex then the code it 
  564. contains is executed when the disk is booted from. This code can then 
  565. do absolutely anything you like. Early model ST computers had their 
  566. operating systems loaded from disk in such a manner.
  567.  
  568. Subsection b: Logical Format 
  569.  
  570. Logical Sectors and Mappings 
  571.  
  572. In practice the physical format of the disk can be abstracted away. 
  573. Rather than referring to the side,track and sector of a disk you can 
  574. refer to a logical sector. This is a number from 0 to the number of 
  575. sectors on the disk-1. It is so arranged that logical sector 0 
  576. corresponds to the boot sector. The device driver is responsible for 
  577. translating the logical sector numbers into the physical disk sector 
  578. you are referring to. Any kind of weird mapping scheme could be used 
  579. transparently to the user.
  580.  
  581. The sector numbers in the BPB refer to logical sectors. So if the 
  582. value of 'datrec' is 18 then it means that logical sector 18 holds 
  583. the first data block. It may or may not be side 0,track 2 sector 1.
  584.  
  585. Clusters 
  586.  
  587. Sectors are not allocated to files one at a time but in clusters. A 
  588. cluster is a group of sectors. On the ST the cluster size is 2 so 
  589. each cluster holds 1K of data.
  590.  
  591. If the value of 'datrec' is 18 the first cluster occupies logical 
  592. sectors 18 and 19. The file allocation table, described later, 
  593. indicates which clusters belong to which files and which are free for 
  594. use. 
  595.  
  596. Subsection c: Root and Sub Directories 
  597.  
  598.  
  599. Where Is the Root Directory? 
  600.  
  601. The root directory can be found from the information in the BPB by 
  602. calculating fatrec+fsiz. This area is fixed at format time thus 
  603. implying that is a limit to the number of files that can be created 
  604. in the root directory. 
  605.  
  606. If 7 sectors are allocated to it and each entry is 32 bytes long 
  607. then the number of files you can have in the root directory is 
  608. 512x7/32 = 112.
  609.  
  610. Where are Sub Directories 
  611.  
  612. Sub directories are treated in much the same way as files. Instead 
  613. of holding data they hold directory entries. They can grow 
  614. dynamically as can files and so the limit for the number of files in 
  615. a subdirectory depends on the size of the disk.
  616.  
  617. To find a file several levels down you start at the root and look 
  618. for the subdirectory, say AUTO. When this is found you have the start 
  619. cluster of the AUTO subdirectory and can search this for the next 
  620. one. A chain of clusters exists for AUTO in the same way as an 
  621. ordinary file and can be followed to find all the entries in it.
  622.  
  623. Sub-directories have two extra entries '.' and '..' which refer to 
  624. the current directory and its parent directory respectively.
  625.  
  626. The Format Of a Directory Entry 
  627.  
  628. Both root and sub directories have the same format. They are a list 
  629. of entries each of which is 32 bytes long. Values in the various 
  630. fields are held in backwards 8086 format. To see one open up a disk 
  631. and goto sector 11. The format of a directory entry is:
  632.  
  633.  
  634.  Size and Type Usage 
  635.  
  636.  8 characters File name
  637.  3 characters File extension
  638.  1 byte File attributes
  639.  10 bytes Unused
  640.  word Creation time
  641.  word Creation date
  642.  word No of first cluster
  643.  long, Length of file in bytes
  644.  
  645. If a file is deleted the first byte of the entry is set to E5 hex 
  646. (you remember CP\M too eh?)
  647.  
  648. The start cluster number can be converted to a sector number given 
  649. the BPB and the additional knowledge that clusters 0 and 1 do not 
  650. exist on the disk.
  651.  
  652. You calculate ((cluster no-2 for reserved clusters) x clsiz) + 
  653. datrec
  654.  
  655. The file attribute byte has bits set depending on what attributes 
  656. the file has. The layout is as follows:
  657.  
  658. Bit No Usage 
  659.  
  660.  0 If set file is read only
  661.  1 If set file is hidden from dir search
  662.  2 If set file is a system file
  663.  3 If set file is 11 byte volume label
  664.  4 If set file is a subdirectory
  665.  5 Archive bit
  666.  6 Unused
  667.  7 Unused
  668.  
  669. The archive bit is supposed to indicate whether a file has been 
  670. altered since the last backup but does not seem to work on floppy 
  671. disks. I imagine it does on hard disks or the storm of protest would 
  672. have been pretty big.
  673.  
  674. Subsection d: The File Allocation Table 
  675.  
  676. Where Is it?
  677.  
  678. There are two copies of this on the disk. The second copy can be 
  679. found by looking at the value of datrec in the BPB. The first copy is 
  680. at datrec-fsiz. The FAT normally occupies 5 sectors.
  681.  
  682. For each cluster on the disk the FAT records its state. Whether it 
  683. is allocated to a file, free, bad etc.
  684.  
  685. Format Of Entries 
  686.  
  687. The entry for each cluster occupies 12 bits. So each group of 3 
  688. bytes in the FAT holds the data for 2 clusters.
  689.  
  690. Extracting the correct 12 bits for each entry (you can deduce how to 
  691. do this by looking at the output of Show FAT, remember : Show FAT 
  692. compensates for the 8086!) gives a number between 000 and FFF hex.
  693.  
  694. If the number is 000 then that cluster is free for use.
  695.  
  696. If the number is 001 then there is a problem. Cluster 1 is a 
  697. reserved cluster and does not actually appear on the disk. The FAT 
  698. entries for 0 and 1 are supposed to contain information about the 
  699. disk.
  700.  
  701. If the number is 002 to FEF then it means that this number is the 
  702. cluster number of the next cluster in the file.
  703.  
  704. If the number is FF0 to FF7 then it means that one or both of the 
  705. sectors in that cluster were found bad at format time and the cluster 
  706. cannot therefore be used.
  707.  
  708. If the number is FF8 to FFF it means that this cluster holds the 
  709. last one for a file.
  710.  
  711. So by finding the start cluster of a file you can follow the chain 
  712. of clusters in that file until you reach the last one. This might go 
  713. something like: 003 004 005 006 FFF.
  714.  
  715. If the FAT ever gets damaged then you are in trouble!
  716.  
  717.