home *** CD-ROM | disk | FTP | other *** search
/ ARM Club 3 / TheARMClub_PDCD3.iso / hensa / documentation / documents / discmaps < prev    next >
Internet Message Format  |  1999-04-27  |  13KB

  1. From: sergio@g386bsd.first.gmd.de
  2. Newsgroups: comp.sys.acorn.tech,comp.sys.acorn
  3. Subject: Disc map: explanation + FAQ
  4. Summary: An easy explanation of E-Format map and map FAQ
  5. Keywords: map, checkmap, compact, corruption
  6. Message-ID: <5238@bigfoot.first.gmd.de>
  7. Date: 24 Jun 94 07:42:57 GMT
  8.  
  9.  
  10. This file is aimed at all the people who want to understand more about HD maps
  11. without going deeply into technical speech. If you have just some questions you
  12. can try to read the "Possible Questions" section and ignore the rest.
  13.  
  14. This file will only deal with new format maps (E-Format) since the old ones
  15. (D-Format) are completely out-of-date.
  16.  
  17.  
  18. E-Format map, an easy explanation (I hope!)
  19. -------------------------------------------
  20.  
  21. Before starting with the map itself, we have to speak about files and disc
  22. structure.
  23.  
  24. Each file on a disc (including directories) can be identified from a SIN
  25. (System Internal Number) that is stored together with all the other file
  26. informations (name, filetype, size, etc.) in the directory that contains the
  27. file. The SIN is made up by two parts, the file number and the sector offset
  28. (more on this next).
  29.  
  30. The disc (HD or floppy) is physically made up by a number of heads (2 for
  31. floppies), tracks and sectors per track. RISC OS will generally ignore this and
  32. will consider the disc as a consecutive sequence of sectors.
  33.  
  34. The map of an E-Format disc is divided into zones: each zone represents a
  35. number of consecutive sectors and can be considered as a stand-alone entity.
  36. So, unless specified, the map format can be applied in the same way to both
  37. single-zone discs (like 800K floppies) and multi-zone ones. Note that there are
  38. no relations between the physical disc structure (ie. number of heads, tracks,
  39. etc.) and the zones subdivision.
  40.  
  41. On each disc there are 2 copies of the map (one is taken as a backup): quite
  42. ironically the 2 maps are (obviously!) always identical, so if the first is
  43. corrupted the second is of no use. The second map can be useful only if the
  44. first one has been physically damaged but (apparently) RISC OS always read the
  45. first and ignores the other...
  46.  
  47. Each zone consists of a list of blocks of variable length, each one
  48. representing an occupied or a free part of the disc; the formers contain the
  49. file numbers (ie. the first part of a SIN) and the latters contain a link to
  50. the next free-space block. if you know the SIN of a file, you can easily find
  51. out where it is located in the zone and so you can know the exact position of
  52. the file on the disc (ie. the disc address). The same file number can appear in
  53. more than one block, in the same or in different zones, if a file is fragmented
  54. in small chunks; this way you can also have files that straddle across two or
  55. more zones.
  56.  
  57. Sometimes two or more files have the same file number but different sector
  58. offset (ie. the second part of a SIN): this means that in the map they appear
  59. to be a single file (occupying only one block) but, knowing the SIN, it is
  60. possible to find out the right address of each one. This trick is useful to
  61. avoid a lot of disc space wasting: because of the organization of the map, each
  62. block must occupy a minimum fixed length (that generally depends on the size of
  63. the HD) and so, even if the file is really short, it has to use up some extra
  64. disc space. Thanks to the sector offsets, a lot of small files can share the
  65. same block (thus the same file number) but each one could only use the size of
  66. a physical sector.
  67.  
  68. I tried to explain the map structure in a simplified way, without going deeply
  69. into the real data structure (bit streams, checksums, etc.), but I think I said
  70. enough to allow you to understand:
  71.  
  72.  
  73. What can go wrong
  74. -----------------
  75.  
  76. Obviously the above structure is really rigid and there is no place for
  77. errors! Unfortunately errors always occur because of unexpected power down,
  78. system crashes, physical damages, (errors in FileCore module itself?), etc;
  79. this is a list of possible problems:
  80.  
  81. - different file lengths in map and directory: if the allocated length in the
  82.   map is more than the one in the directory you can ignore this (but you have
  83.   some lost space) but in the opposite case RISC OS generally crashes if you
  84.   try to load the file.
  85.  
  86. - a file number is allocated in the map but not in the directory structure:
  87.   you have some space occupied in the map by an inexistent file.
  88.  
  89. - a file has a file number that isn't allocated in the map: generally RISC OS
  90.   hangs the computer if you try to load the file.
  91.  
  92. - the free space linked list is broken: there is some free space that isn't
  93.   linked with the others, thus it is lost (it is no more free...).
  94.  
  95. In these cases (except in the ones that make RISC OS to crash) *CheckMap
  96. reports an inconsistency.
  97. Unfortunately there is a worse case:
  98.  
  99. - the checksum of one or more zones is wrong: in this case (apparently easy
  100.   to fix) RISC OS isn't able to recognise the disc properly. Using a Disc
  101.   Doctor tool it should be possible to manually fix the problem.
  102.  
  103. Another quite common error (not directly related to the map) is:
  104.  
  105. - broken directory: this error is issued when RISC OS finds a directory that
  106.   has some 'strange' data in it (no directory identifier, wrong checksum,
  107.   etc.). The only way to cure this is to remove the directory from its parent
  108.   but unfortunately this is impossible using standard commands (wipe, delete,
  109.   remove). Broken directories usually lead to inconsistent maps because all
  110.   the files contained in them disappear from the directory structure but not
  111.   from the map (see above).
  112.  
  113.  
  114. What can be wasted
  115. ------------------
  116.  
  117. Because of the disc structure and the map organization, some space can be 
  118. 'naturally' wasted.
  119.  
  120. First of all, the sector bounds are a physical limit and so all the files must
  121. be 'sector aligned'. So, on a 512 bytes sector sized HD, a 1 byte file  always
  122. uses (at least) 512 bytes, while a 513 bytes one uses 1024 bytes.
  123.  
  124. But the real waste of space is caused by the map organization: as I already
  125. said, there is a minimun length for each map block (from now I will consider it
  126. to be 4K but note that this is only an example).
  127.  
  128. This is not so bad because more than one file can share it, hence 4*1K files
  129. can fill up the same block wasting no space. The bad point is that only files
  130. in the same directory can share blocks, so 4*1K files in 4 different
  131. directories will use 16K.
  132.  
  133. A directory always needs 2K of disc space to keep its data. Since a directory
  134. from the map point of view is just a file, it will still use 4K: fortunately it
  135. can share the remaining 2K with files contained in it (not with files from its
  136. parent). If a directory contains a 2K file or 2*1K files all the space is used
  137. but if it contains only files longer than 2K the space will be wasted.
  138.  
  139. Wasted space isn't lost space: if you have an empty directory you will waste
  140. 2K. But when you delete it you will regain the whole 4K, no loss. If you save a
  141. 1K file in it, the free space on your disc will remain the same and the wasted
  142. space will be just 1K.
  143.  
  144. During normal operations, there is no way to avoid wasting space: RISC OS does
  145. all the work and you don't have to worry about the file allocation strategy.
  146. Anyway, sometimes you can recover some wasted space by simply copying a file,
  147. deleting the original one and renaming the new one as the old one (usually it
  148. is better to copy the whole content of a directory to another and then rename
  149. the whole directory back) but don't expect too much gain...
  150.  
  151.  
  152. *CheckMap and *Compact
  153. ----------------------
  154.  
  155. CheckMap performs quite a simple task: it just scans the directory tree and
  156. checks that all the file numbers in the map are actually contained in a
  157. directory. Considering that CheckMap should be used when something went wrong,
  158. it seems to be a very poorly written piece of code: sometimes it hangs the
  159. whole computer, sometimes it just prints the cryptic message "Map inconsistent
  160. with directory tree" and the only action that it should do to fix the situation
  161. is the swapping between the 2 copies of the map (but see above to understand
  162. why nobody has never been able to use this facility...).
  163.  
  164. Compact has been a very useful command when the only way to format discs was
  165. D-Format: in fact with E-Format discs it is almost useless. Its function is to
  166. collect together fragmented files or fragmented free space inside zones (but
  167. not from one zone to another). With E-Format discs this operation is performed
  168. automatically when a new file is saved in that zone, but you can anyway use it
  169. 'manually' to speed up future savings (actually the speed gain is almost
  170. irrelevant). With D-Format discs the 'auto-compaction' doesn't exist and files
  171. cannot be fragmented: if there is enough space on the disc for the file that
  172. has to be saved but this free space is fragmented in small chunks, the error
  173. "Compaction required" is issued.
  174.  
  175.  
  176. Possible Questions
  177. ------------------
  178.  
  179.  1) Is *Compact useful or it is dangerous?
  180.  2) Can I trust *CheckMap?
  181.  3) What can I do with a broken directory or an undeletable file?
  182.  4) What can I do if *CheckMap doesn't work or tells me that the map is
  183.     inconsistent?
  184.  5) Are there some dangerous actions that can lead to a map corruption?
  185.  6) Does a map corruption imply that some data on the disc has been corrupted
  186.     too?
  187.  
  188. Possible Answers...
  189. -------------------
  190.  
  191.  1) Is *Compact useful or it is dangerous?
  192.  
  193. On E-Format discs *Compact isn't really useful but it can be used safely if the
  194. map is good. If the map is inconsistent I can't assure you of its behaviour
  195. (ie. I can't exclude that it can cause worse corruptions). Note that RISC OS
  196. can automatically run a 'subset' of Compact when it has to save a file
  197. (especially if the file is large and the free space is limited and fragmented).
  198.  
  199.  2) Can I trust *CheckMap?
  200.  
  201. I have to admit that CheckMap isn't a very well written command but if it says
  202. that the map is good, the map IS good and you have no lost space on your disc.
  203. If it crashes the computer or if it says "Map inconsistent with directory
  204. tree", your map or directory structure IS damaged and the damage can worsen if
  205. not cured soon.
  206.  
  207.  3) What can I do with a broken directory or an undeletable file?
  208.  
  209. A broken directory cannot be deleted using standard OS commands and it can just
  210. be considered as a 'normal' undeletable file. To remove it you must use some
  211. directory manipulation program (like Look System's Disc Doctor?) or the
  212. shareware program 'eliminate' (distributed with 'fsck').
  213.  
  214.  4) What can I do if *CheckMap doesn't work or tells me that the map is
  215.     inconsistent?
  216.  
  217. Apparently the only thing you can do is to try the shareware program 'fsck'
  218. that performs the same task as *CheckMap but also tries to fix the damage.
  219.  
  220.  5) Are there some dangerous actions that can lead to a map corruption?
  221.  
  222. I am not the only person who thinks that having a nearly full HD (say, less
  223. than 1Mb free) can be dangerous, especially if you handle very large files.
  224. Using bugged programs that sometimes can crash the computer while it is writing
  225. to the HD is REALLY dangerous but fortunately there are very few programs of
  226. this kind around...
  227.  
  228.  6) Does a map corruption imply that some data on the disc has been corrupted
  229.     too?
  230.  
  231. Generally no. For example if the corruption was caused by a delete operation
  232. that was interrupted after it removed the file from the directory but before
  233. the removal from the map, the map will be inconsistent but no data has been
  234. lost/overwritten. On the other hand, a 'Broken Directory' can be the evident
  235. sign that something actually has been corrupted on the disc, so you can find
  236. that some other files are damaged. In fact, RISC OS can easily notice the wrong
  237. directory header/checksum but it cannot really understand if a text file has
  238. been corrupted!
  239.  
  240. ------------------------------------------------------------------------------
  241. I'd like to thank all the people who contributed to produce a 'working'
  242. version of this document.
  243. ------------------------------------------------------------------------------
  244. If you have any other question related to HD map, structure, directories, etc.
  245. you can contact me or post to comp.sys.acorn. Any interesting question will be
  246. added to the "Possible questions". Note that I can be wrong, inexact and vague,
  247. so any correction is welcome. If you think that this file is useless ignore it,
  248. if you think it is badly written, vague, etc. please contact me, possibly with
  249. some amendment.
  250.  
  251. I can be contacted at the following address:
  252. pel0015@cdc8g5.cdc.polimi.it
  253. If you don't receive a reply (or if the message is bounced) I can also be
  254. contacted at:
  255. sergio@phantom.com
  256. or:
  257. sergio@g386bsd.first.gmd.de
  258.  
  259.