home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 3
/
PDCD_3.iso
/
utilities
/
utilsf
/
fsck
/
hard_help
< prev
next >
Wrap
Text File
|
1995-01-31
|
11KB
|
260 lines
hardfix (1.01) - heavily damaged disc fixer
NOTE: this program is SHAREWARE. Read the !SHAREWARE file for more info.
hardfix is a disc utility that fixes the errors that can affect the boot
block, the 2 copies of the map and the root directory without having to scan
the whole directory tree. These sort of errors generally make the disc
un-readable or un-writable!
hardfix can also be used to write the bootblock, map and root directory to a
file, so that you can always try to restore them in case they are totally
damaged (ie. absolutely unfixable).
Usage
-----
hardfix [-options] [-[s|r] savefile] [-l logfile] pathname
-l print the results in "logfile"
-s save bootblock/map/root sectors to "savefile"
-r restore bootblock/map/root sectors from "savefile"
-Q ask before fixing
-1/-2 force to fix the first/second copy of the map
If the disc is readable, pathname can contain the disc name (eg.
IDEFS::IDEDisc4.$), otherwise it must contain the disc number (eg.
IDEFS::4.$).
When you need to use it
-----------------------
hardfix should not be used regularly like fsck, since the errors it fixes are
usually really uncommon. Moreover fsck recognises most of the errors hardfix
cures and tells you when it is needed.
Anyway, you can use it regularly to save the important disc data (ie.
bootblock, map and root) to a file, so that you will be able to restore them
if they are completely destroyed for some mysterious reason. Moreover, you
are adviced to save them before trying to fix the map with fsck or with
hardfix itself: if the fix is wrong (especially if it aggravates the
situation!), you can always restore your old data.
Remember that restoring old maps generally causes many file corruptions! In
fact, the map is costantly updated while files are saved/deleted, and even
files that are not updated can be automatically moved around by RISC OS.
If your map is broken, try to fix it with fsck and hardfix and eventually
restore an old one only if you are sure there is nothing better to do!
The fixable errors
------------------
hardfix is able to fix the following errors:
- bootblock checksum wrong
- bootblock defect list end marker missing
- bootblock defect list checksum wrong
- map cross check wrong
- map copies different
- zone checksum wrong (this is the typical cause of unreadable discs)
- zone free chunk offset wrong
- zone free linked list wrong (this is the typical cause of unwritable discs)
- zone not correctly terminated
- ID too high for the disc shape
- not sector-aligned object
- root directory identifiers wrong
- root checksum wrong
- root master sequence numbers different
- root endmarker wrong
- root reserved bytes not cleared
- root address wrong
The bootblock errors should never appear, unless your disc is *really*
damanged or badly formatted, and will probably be useless to try to fix it.
Moreover it seems that some some disc have been made completely unreadable
after hardfix 'cured' the bootblock checksum (anyway, reformatting and
restoring the map and the root directory using hardfix fixed everything!).
Considering this bad experience I removed the possibility to save the
bootblock. If you really need it (for example because the disc is unreadable)
you *must* contact me (sending the saved disc data) and I will try to
investigate. In old versions of this file I said "you *should* contact the
author" but someone didn't and...
The map errors are the most common, especially the ones about free lists, but
can usually be successfully cured.
The root directory errors are generally serious since they usually imply that
the directory has been completely overwritten. In this case the only choice
is to restore it from a previously saved file (only the root should be
restored, not the bootblock and map, too!).
Using the -Q option you will be asked to choose if the error(s) has to be
fixed or left intact. So you can choose to fix only the map and not the
bootblock, for example.
You will always be asked if the fixes has to be applied to the disc (ie. if
you really want to save the fixed bootblock, map and root directory).
The logfile
-----------
Using the logfile (-l) option is generally really useful: if something
strange happens, the author will be more helpful if he can see exactly what
happened and you don't even have to try to explain what happened when you run
hardfix, the logfile and the saved disc data is usually enough!
The logfile contains exactly what it is printed to the screen, so it should
be really small (nearly 1K on a good disc or nearly 5K on a quite corrupted
one).
You cannot save the logfile to the disc to fix!
If a file with the same name of the logfile already exists, the new data will
be attached at the end of it: in this way, you can attach together two or
more logfiles.
Notes
-----
If the two copies of the map are different, hardfix tries to fix the less
damaged. If they are apparently damaged at the same level, hardfix will ask
you which map to fix. In normal cases, you are adviced to fix the map that
hardfix suggests or, by default, choose the first one.
The -1 and -2 options can be used to force hardfix to try to fix the first or
the second copy, regardless of their state.
Saved file format
-----------------
This is only of interest to people who wants to access to the saved file in
their own programs (probably nobody!).
The saved file has a header that contains the filesystem informations
followed by a series of tagged object.
The header consists of the filesystem name followed by a newline and then the
disc number followed by another newline.
Each tagged object consists of a textual tag of 4 bytes followed by the
object itself. The currently recognised tags are:
"BOOT" - bootblock (512 bytes)
"MAP1" - the first copy of the map (the length can be calculated from the
bootblock data)
"MAP2" - the second copy of the map (the same length as the first copy)
"ROOT" - the root directory (2048 bytes)
"RSiX" - the RISCiX partition table (only if RISCiX partitioned!) (256 bytes)
The bootblock must always come before the map, otherwise the length of the
map cannot be calculated. Only 800K floppies have no bootblock: in this case
the length of the map is 1024 bytes.
The second copy of the map must always follow the first one.
Any other tag is ignored and the file is scanned until a recognised tag is
found. The tags should be word aligned (the alignement refers to the first
tag even if it isn't actually word aligned inside the file because of the
filesystem name).
Disclaimer
----------
hardfix can be considered a really dangerous program since it can directly
write to the bootblock, map and root directory: these are the key sectors of
a disc, damaging them can result in the complete or partial loss of the data
on the disc.
I tried most of the features of hardfix on my disc and on some floppies but I
cannot be completely sure it will work on your disc, too. Always save the
data using the -s option before trying to fix the disc and remember that it's
generally better not to fix the bootblock (actually it isn't possible...).
Anyway, if something goes wrong, I am sorry for you but I AM NOT RESPONSIBLE
for any loss of data on your discs, so use hardfix at your own risk.
Limitations
-----------
I think that hardfix is able to cure almost every 'fixable' error: this means
that it cannot fix a completely damaged disc (ie. if both copies of the map
are overwritten by some random data it can't do nothing apart from restoring
a saved file).
hardfix cannot join two adjacent free chunks but I don't think this is a
problem.
This limitation could be fixed in future versions.
Bugs
----
hardfix may have problems with RISCiX partitioned drives: if you have such a
drive and if hardfix wants to fix a map that seems to be good (try CheckMap
and fsck on it) don't let it write the map back to disc!
Results achieved up to now
--------------------------
If you run hardfix on your corrupted HD, please let me know! If it wasn't
able to fix it, I'll try to modify it to cope with your problem. If you want
to stay anonymous tell me not to include your name.
Positive results:
1) some 800K ADFS floppy