home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / hpfsut02.zip / readme.txt < prev    next >
Text File  |  1999-11-27  |  13KB  |  296 lines

  1. HPFSUtil v0.02 by Mike Ruskai <thannymeister@yahoo.com>
  2.  
  3. This program is a consolidation of various test programs I put together
  4. while investigating the structure of HPFS, with the original purpose of
  5. discovering just how much space HPFS takes up for itself, and how that
  6. amount correlates with drive size.
  7.  
  8. The program usage:
  9.  
  10. Usage: hpfsutil.exe <drive letter> <options>
  11.  
  12. <drive letter> - letter of HPFS drive to process
  13.  
  14. Options:
  15.  
  16. /GD - report current dirty bit status
  17. /DT - toggle dirty bit
  18. /SD:<T/F> - set dirty status to True or False
  19. /FS - compare actual and reported free space
  20. /SU - show HPFS system space usage
  21. /BS - show bad sector count
  22. /SHSU - display contents of SuperBlock
  23. /SHSP - display contents of SpareBlock
  24. /SHSPFD - display SpareBlock with full spare DirBlk list
  25. /DS:<sect>[-<sect>] - dump sector(s) to file
  26. /FN:<filename> - filename to dump sectors to; default sectdata.dat
  27. /NL - don't use IBM linedraw characters
  28.  
  29. Argument order is unimportant.
  30.  
  31. You may specify as many different options as you want on the same
  32. commandline.  They will be executed in a set order (not the order you
  33. specify them).  Duplicate options aren't permitted (including duplicate
  34. sector dumps - you'll have to run the program multiple times for multiple
  35. sector ranges).  Also, the DT and SD options are mutually exclusive.
  36.  
  37. Explanation of the options:
  38.  
  39. GD - Get the current dirty status of the drive.  This just checks bit 0 of
  40. the partition status byte (the 9th byte in the HPFS SpareBlock), and
  41. reports accordingly (1 = dirty; 0 = clean).
  42.  
  43. ***
  44.  
  45. DT - Toggle the dirty status of the drive.  If it's dirty, it's set clean.
  46. If it's clean, it's set dirty.  The program reports which action was taken.
  47.  
  48. SD:<T/F> - This sets the dirty status to True or False (/SD:T or /SD:F),
  49. regardless of what the current status is.  If no errors are encountered, it
  50. reports the change.
  51.  
  52. ***
  53.  
  54. ** Note **
  55.  
  56. The above two options write directly to your drive.  I am in no way
  57. responsible for any data loss you may have due to any problems coinciding
  58. with using this program with either of these options.  Use them at your own
  59. peril.
  60.  
  61. That said, they work fine here, and should work fine anywhere.  But if bad
  62. information is given by OS/2 to the program, there's no guarantee that the
  63. correct sector is read and written back to disk.
  64.  
  65. **
  66.  
  67. FS - This traverses all of the freespace bitmaps on the drive, tallying up
  68. free sectors, and compares the results with what DosQueryFSInfo() reports.
  69. The implementation of HPFS on Warp 4 (and possibly others) has a bug which
  70. reports 4096 fewer sectors free than are actually free, on drives from
  71. 120MB to 3GB (the range I tested).  A 10MB drive had a discrepancy of 443
  72. sectors.  This space is free, but unreachable in OS/2.
  73.  
  74. SU - Display an itemized list of the amount of space reserved by HPFS.
  75. This doesn't include any HPFS structures created for the purpose of
  76. allocating data files (FNodes, ALSECs, etc.).
  77.  
  78. BS - Display the bad sector count, as reported by HPFS (time to replace the
  79. drive if any are found).
  80.  
  81. SHSU - Output a formatted display of the HPFS SuperBlock sector.  The
  82. offset field is in the format hex/decimal.  The hex is logical (0-based),
  83. and the decimal is absolute (1-based).  The size of the data can be
  84. determined by noting the length of the hex value.  Each two hex digits
  85. indicate one byte of data.  See further on in this file for detailed info
  86. on each item.
  87.  
  88. SHSP<FD> - Output a formatted display of the HPFS SpareBlock sector.  The
  89. format is the same as for the SuperBlock display.  The addition of FD
  90. prompts a complete list of the spare DirBlk locations.  By default, only
  91. the first is listed (the SpareBlock contains the entire list).  See further
  92. on in this file for detailed info on each item.
  93.  
  94. DS:<sect>-[<sect>] - Dump the sector or sector range to file (default
  95. sectdata.dat - see next option for how to change this).  The <sect> value
  96. must be a decimal number from 0 to the number of sectors on the drive
  97. (exceeding the boundary will report an error).  There are three macros that
  98. can be used in place of a decimal value: "boot", "super", and "spare"
  99. (without the quotes).  These correspond to the locations of the BootBlock
  100. (LSN 0), SuperBlock (LSN 16), and SpareBlock (LSN 17), respectively.
  101.  
  102. FN:<filename> - This specifies an alternate sector data filename (default
  103. is sectdata.dat).  If the file can't be opened, an error will be reported.
  104.  
  105. NL - This tells the program to not use IBM linedraw characters, in the
  106. event that your codepage makes those character values into something other
  107. than lines.  They are replaced with standard ASCII characters.
  108.  
  109. The HPFS SuperBlock:
  110.  
  111. 64-bit SuperBlock signature - self explanatory.
  112.  
  113. HPFS version - reports 2 for HPFS and HPFS386.
  114.  
  115. Vol size (2:<=4GB; 3:>4GB) - indicates whether or not drive is larger than
  116.     4GB - a value of 2 means less than or equal to 4GB, while 3 means
  117.     larger than 4GB.
  118.  
  119. Root dir FNode location - self explanatory.
  120.  
  121. Total sector count  - total number of sectors on the drive, including those
  122.     taken up by system structures.
  123.  
  124. Bad sector count - actually *known* bad sector count, which should be 0,
  125.     unless your drive is failing.
  126.  
  127. Free space bitmap list - location of the list, which consists of
  128.     consecutive 4-byte sector numbers, indicating the location of one
  129.     four-sector bitmap each.  The size of the list depends on the size of
  130.     the drive - it's a minimum of four sectors, and increases four sectors
  131.     at a time as needed to accomodate larger drives.
  132.  
  133. Spare bitmap list - probably originally for accomodating larger drives that
  134.     need more freespace bitmaps than four sectors could list, but is unused
  135.     now, and always 0, since the main bitmap list is larger when necessary.
  136.  
  137. Bad sector list - location of a four-sector list of bad sectors.
  138.  
  139. Spare bad sector list - If you need more than four sectors to list the
  140.     number of bad sectors, this would be used (and your drive would really
  141.     be shot).
  142.  
  143. Date CHKDSK /F last run - in the form of a 4-byte Unix timestamp.
  144.  
  145. Date last optimized - presumably for application use, but GammaTech's
  146.     optimizer doesn't use it.
  147.  
  148. Dir band sector count - number of sectors in the directory band.
  149.  
  150. Directory band start - location of first sector of directory band.
  151.  
  152. Directory band end - location of last sector of directory band.
  153.  
  154. Directory band bitmap - four sectors covering the allocation of the
  155.     directory band.
  156.  
  157. First ACL block location - location of eight-sector block of ACL's, which
  158.     are only used by HPFS386.
  159.  
  160. The HPFS SpareBlock:
  161.  
  162. 64-bit SpareBlock signature - self explanatory.
  163.  
  164. Partition status byte - a bitmask, with the following definitions:
  165.  
  166.     0: Dirty flag
  167.     1: Spare DirBlk's used
  168.     2: Hotfix sectors used
  169.     3: Bad sectors exist
  170.     4: Bad bitmaps exist
  171.     5: Fast formatted
  172.     6: Unknown
  173.     7: Written by old IFS
  174.  
  175.     In each case, 1 means true, 0 means false.
  176.  
  177. Hotfix list location - location of four-sector list of hotfix sector
  178.     numbers.  The first 400 bytes of the first sector are empty, and used
  179.     to store the locations of any sectors which have been hotfixed (the
  180.     position of the sector number says which hotfix sector contains the
  181.     data).
  182.  
  183. Hotfix sectors in use - the count of hotfix sectors in use.
  184.  
  185. Total hotfix sectors - the total number of hotfix sectors, which is always
  186.     100 (which is why only 400 bytes in the list are reserved).
  187.  
  188. Spare DirBlk count - the number of spare directory blocks there are, which
  189.     exist in the event that space runs out while making directory
  190.     adjustments.  The default count is 20.
  191.  
  192. Free spare DirBlk's - the number of spare DirBlks not in use.
  193.  
  194. Code page list location - the sector address of the code page list, which
  195.     contains the code page numbers, and some other info.  The next sector
  196.     contains the code pages themselves.
  197.  
  198. Number of code pages - number of installed code pages, which is always 2.
  199.  
  200. HPFS SuperBlock 32-bit CRC - cyclic redundancy check of the SuperBlock,
  201.     which is used by HPFS386 to determine when the SuperBlock has been
  202.     altered.
  203.  
  204. HPFS SpareBlock 32-bit CRC - cyclic redundancy check of the SpareBlock,
  205.     used by HPFS386 to determine when the SpareBlock has been altered.
  206.  
  207. Spare DirBlk #1-#20 location - sector addresses of the 20 spare directory
  208.     blocks.  Each address is four sectors apart, since a directory block is
  209.     four sectors long.
  210.  
  211. Disclaimer:
  212.  
  213. The author is in no way responsible for anything bad happening to you or
  214. your computer after you run this program.  The /SD and /DT options are the
  215. only ones which directly write information to your drive (/DS uses the
  216. standard file system methods of writing), but for all I know, loading this
  217. program into memory may be the last straw that breaks your power supply's
  218. fuse, while you were in the middle of using Partition Magic on your
  219. sensitive data partition with no backup.
  220.  
  221. Source:
  222.  
  223. The source code to this program is included in the archive, in a separate
  224. archive entitled source.zip.  This source may be freely modified and
  225. compiled, but credit where credit is due would be nice.  Each C file should
  226. be compiled separately, and all the objects linked together.
  227.  
  228. There are few source comments, but the code should be self-explanatory
  229. (since I don't use obscure variable names or bad structure, unlike a
  230. disconcerting number of programmers out there).
  231.  
  232. Acknowledgements:
  233.  
  234. Virtually all information about the structure of HPFS was obtained from the
  235. EDM/2 articles about HPFS by Dan Bridges.  Additional info was provided by
  236. Jan Van Wijk, author of the DFSEE utility program.
  237.  
  238. In addition, some of the OS/2-specific programming tasks were accomplished
  239. with the indirect help of various people on UseNet (by reading their posts
  240. from a Deja.com search), most notably Peter Fitzsimmons, who seems to have
  241. answered virtually every OS/2 programming question conceivable at one time
  242. or another.
  243.  
  244. Known problems/limitations:
  245.  
  246. There exists the possibility that a bad sector turn up where a freespace
  247. bitmap should be.  I don't yet know how to deal with this situation
  248. properly, so if the bad bitmap bit is set in the partition status, the free
  249. space discrepancy option won't run.  No check is currently done to see if
  250. there are any bad sectors in the range specified to dump to file.  Either
  251. the read will succeed (meaning the bad sector either isn't bad, or only bad
  252. some of the time), or it'll fail, stopping the sector dump.
  253.  
  254. Caveats:
  255.  
  256. If you use the current drive for the sector data dump file, and you choose
  257. a sector range that includes free sectors, there's a decent chance that
  258. what you're reading will overlap what's being written to the dump file.
  259. This won't cause any errors, but it'll make the utility of the dump file
  260. rather specious.
  261.  
  262. Questions/comments/bug reports:
  263.  
  264. Send them all to thannymeister@yahoo.com, and I'll ignore them or act on
  265. them at my discretion.
  266.  
  267. History:
  268.  
  269. 11-22-1999  -   Original release.
  270.  
  271. 11-27-1999  -   Changed sector read function to only read one sector at a
  272.                 time, since garbage would be returned if a track boundary
  273.                 is reached during a multiple-sector read.  This slows
  274.                 things down a bit during the free space discrepancy scan.
  275.  
  276.                 Changed checking of freespace bitmap data to increase
  277.                 performance, so much of the performance loss above is
  278.                 regained here.
  279.  
  280.                 Changed loops in display routines to memset() calls, which
  281.                 speeds them up a bit.
  282.  
  283.                 Fixed an error in the calculation of how many bitmap list
  284.                 sectors are required, which hopefully is what caused the
  285.                 problems people have been pointing out.
  286.  
  287.                 Compile this time with VACPP 3.08's Compact optimization.
  288.                 Had Speed optimization bug pointed out by someone else,
  289.                 which no longer affects the program (the loops in the
  290.                 display functions were being incorrectly optimized, but
  291.                 have been removed).  Other VACPP 3.08 users might want to
  292.                 look out for this type of error, which can be worked around
  293.                 by making the loop counter variable 'volatile'.
  294.  
  295.                 This is version 0.02
  296.