Short:    Save files from damaged PFS2/PFS3 partitions
Uploader: thomas-rapp@t-online.de (Thomas Rapp)
Author:   thomas-rapp@t-online.de (Thomas Rapp)
Type:     disk/salv
Version:  0.8

Requires: Professional File System (PFS) 2 or 3. Does not work with other
          filesystems


WARNING: This program was only tested on my machine with my
         harddisks. There is no guarantee that it runs on
         others. I am not responsible for any damage.
         Use it on your own risk.


PFSsalv reads the directory blocks of a PFS2 or PFS3 partition and
copies any files found to another disk.

You usualy use PFSsalv when you get an DH0:NDOS Icon on the Workbench
or a Requester stating "xxx-Block yyy has an invalid ID" and you don't
want to use an in-place repair tool like PFSdoctor which could delete 
important files.


Installation
============

Copy the PFSsalv executable anywhere in your path.


Usage
=====

PFSsalv can only be used from a Shell window. Type PFSsalv ? to get
the standard DOS syntax.

While PFSsalv is working you can press CTRL-C to stop. Incomplete
files will not be removed.

Saved files will have creation-date and filenotes like found on the
source disk. 

Duplicate files will be saved by adding "-n" to the name (n is a
number, starting with 0). 
Example: disk.info, disk.info-0, disk.info-1, etc.
NOTE: because of this the destination disk might need (much) more
space than the damaged disk.

PFSsalv can access harddisks larger than 4GB if the driver is NSD
or TD64 compatible. It automatically determines which command set
to use unless the TD64 or NSD switches are used.


Parameters
==========

DEVICE/A       The name of the drive or partition to examine.

DESTINATION    The destination path where to save the rescued files.
               If no destination is specified PFSsalv does not save
               anything and only lists the files found.

FORCE/S        If the DOS-type of the partition is not PFS\1 or PFS\2,
               PFSsalv does refuse to work unless you specify force.
               You should be sure what you do, because trying to run
               PFSsalv on a non-PFS disk can lead to crashes !

BLKCNT/K/N     Disk blocks per PFS-Block. Default is 2 because disk
               blocks have usualy 512 bytes and PFS Blocks are 1024
               bytes in size.

BUFFERS/K/N    Number of buffers. Default is 1000. One buffer has
               BlockSize * BLKCNT + 12 bytes. This is usualy 1036.
               PFSsalv will not work correctly if it has too less
               buffers.

MAKEROOT/S     If the current rootblock ist not correct (maybe
               because you accidently quick-formatted the disk)
               PFSsalv can be forced to create his own one with
               this keyword.
               Otherwise PFSsalv uses the pointers from the current
               rootblock to read the directory. This is much faster
               but does not find "hidden" files.

P=PATTERN/K    If specified, PFSsalv only copies files that match
               this pattern. The Pattern is a standard AmigaDOS
               Pattern.
               NOTE: it is compared with the whole filename including
               path and destination. So you usualy want to begin it
               with #?.

LISTALL/S      If specified, PFSsalv will list files that are not
               copied, too. Those files are enclosed in brackets.

NSD/S          Force using NSD style commands.

TD64/S         Force using TD64 style commands.



Examples
========


PFSsalv dh0:

              Will examine drive dh0: and list all files found.
              This should always be the first try.


PFSsalv dh0: ram:

              Will copy all files from drive dh0: to ram:.
              You will usualy use this if you get an
              "xxx-Block nnn has an invalid ID" Requester.


PFSsalv dh0: ram: p #?.jpg

              Will copy all files ending with .jpg (in all directories)
              to ram:.


PFSsalv dh0: ram: makeroot

              Will copy all files from dh0: to ram: after dh0:
              has been quick-formatted.


PFSsalv dh0: ram: force makeroot

              Will copy all files from dh0: to ram: after the
              rootblock of dh0: has been destroyed.



Error Messages
==============


Cannot find device <dev>

             The device or partition name is incorrect. Maybe you
             misspelled it. You must not use the volume name here.


OpenDevice failed

             The partition name was found but the DOS-device cannot
             be opened. Must be an error in the mountlist, if any.


cannot create IORequest
cannot create reply port

             Usualy too less memory. Reboot and retry.


device does not support NSD or TD64 for harddisks >4GB

             Seems that you use a device driver that is not ready
             for Harddisks larger than 4GB but uses SCSI-Direct 
             for them. As I don't know about SCSI-Direct this is 
             not implemented (yet).

cannot read block <n>. rc=<rc> (text)

             Read error on the disk. <rc> is the code returned by 
             the DOS-device. If known, 'text' is a short description
             of the error.


*** not enough buffers for directory ***

             Use the buffers parameter to increase the number of
             buffers. If you have enough memory use 10000 or 20000
             buffers, so PFSsalv can read the whole directory into
             memory.


trying to unlock buffer at <address> (block <n>) which is not locked !
trying to unlock block <n> (buffer <b>) which is not locked !
trying to unlock block <n> which is not in buffer !

            Internal errors. You may try to increase the number of
            buffers. If that doesn't help, mail me.
            You may also ignore this if the result is satisfying.


unable to create directory : <text>

            A directory in the destination path cannot be created.
            <text> describes the reason.


unable to open file : <text>

            A file in the destination path cannot be opened for
            writing. <text> describes the reason.


*** size mismatch !!

            The size of the saved file does not match the size
            shown in the source directory. You should have a
            closer look into this file.


not a pfs2 disk (xxxxxxxx)

            The DOS-Type of the disk does not match PFS\1 or
            PFS\2. xxxxxxxx is the DOS-Type found on the disk. 
            You might want to use the force keyword if you are 
            sure to act on a PFS disk.


Warning: not a pfs2 disk (xxxxxxxx)

            The DOS-Type of the disk does not match PFS\1 or
            PFS\2, but force was specified.
            xxxxxxxx is the DOS-Type found on the disk.



Restrictions / Bugs
===================

- PFSsalv does not check flags in the rootblock. Instead it
  assumes them to be as I saw them on my disks.

- Pattern matching includes the destination path in the
  comparison.

- You should delete any existing files in the destination path
  before using PFSsalv. Otherwise PFSsalv will save all new files 
  as duplicates. (PFSsalv does not replace any files).

- PFSsalv ignores files in the delete directory (.deldir).

- On partitions deleted with 'delete #? all' not all files are
  restored.


History
=======

V0.8

- implemented TD64 commands and NSD/TD64 checking

- fixed progress bar when MAKEROOT is specified

