                +----------------------------------------+
                |                                        |
                |            Partition saving            |
                |                                        |
                | http://perso.club-internet.fr/guiboure |
                |  Copyright (c) 1999-2000 D. Guibouret  |
                +----------------------------------------+

Table of contents
-----------------

  0- Preamble
  1- Presentation
  2- Needed configuration
  3- Evolutions
     a) V1.00 -> V2.00:
  4- Interface running
     a) Command buttons:
     b) Entry lines:
     c) Listboxes:
  5- Savepart.exe
     a) Disk choice:
     b) Partition choice:
     c) Deflating choice:
     d) File choice:
     e) File size choice:
     f) Saving window:
  6- Restpart.exe
     a) File choice:
     b) Partition choice:
     c) Restoring window:
  7- Errors
     a) Fatal errors:
     b) Not fatal errors:
  8- What is not supported
  9- What could not be tested
 10- Ackwnoledgments


0- Preamble
------------

This program could be copied and freely redistributed. It could not be sold in
any way either alone or included into another program. All what is in this
package must be kept together into its original shape.

This program is afforded as it is without any guarantee. No pursuit could be
engaged against its author in case of damages due to this program.

All remarks are welcome.


1- Presentation
---------------

This program has as goal to realize saving and restoring of partitions. This
allows saving hard disk contents to restore it later in case of a problem and
this without loosing time with installation and configuration of all softwares.
This program is divided into 2 executables:
 - savepart.exe which does saving.
 - restpart.exe which does restoring.

For all informations about partitioning or program please read partinfo.txt
file.


2- Needed configuration
-----------------------

Hardware:
  - 386 or better.
  - 4 Mb of memory (could work with less, but data compression could potentially
not be done).
Software:
  - DOS (version >= 3.3).

This program does not work on Windows (see partinfo.txt file) and it is
advised against using it with an emulator (mostly if it works into a
multi-tasking environment).


3- Evolutions
-------------

  a) V1.00 -> V2.00:
Evolutions made are:
  - add of management of more than 8 Gb hard disk.
  - add of data compression.
  - add of several files saving capability.
  - interface change.
Remark:
All these modifications do that it is not possible to restore with V2.00
version files created with V1.00 version (and reciprocally).


4- Interface running
--------------------

Interface must be used with keyboard. Keys common to all windows are:
  - Tab to go from one element to another.
  - Maj+Tab to go from one element to another in reverse order.
In case no element seems to be selected, press Tab key to select first one.
In general, Enter key activates Ok button (in case no other button is
selected) and Escape key activates Cancel button.
All elements of windows are presented below.

  a) Command buttons:
To activate them, you have to press Enter key when they are selected, or on
Alt+<red letter into button name> (even if button is not selected).
A button has a black background if it is selected, else it has a green
background.
 
  b) Entry lines:
It is the element that permits to enter data. You have just to press character
to add them where the cursor is. Delete and BackSpace keys are used to
suppress characters (respectively character that is on cursor and character
before cursor). Right and left arrows are used to move cursor and Home and End
keys are used to go to begin or end of string.
At last Insert key is used to switch from insert mode (default mode: cursor is
underlined cursor) to replacement mode (cursor is block-cursor) and
reciprocal.
An entry line is selected when it has the cursor that appears in it.

  c) Listboxes:
They are used to choose an element into a list. Up and bottom arrows are used to
move from one element to another, Page-Up and Page-Down keys are used to go to
begin and end of list.
If right column is with a different color and contains a # character, it is
because all elements could not be seen and the # character is used to locate
current selected element into list.
A selected item has a grey background if its listbox is not selected, and has
a black background if its listbox is selected.


5- Savepart.exe
---------------------------------

It is the program used to save a partition.

Use: savepart.exe

Execution follows below diagram:

                disk choice
                     |
                     V
             partition choice
                     |
                     V
             deflating choice
                     |<-------------------------+---+
                     V                          |   |
                file choice                     |   |
                     |                          |   |
                     V                          |   |
              file size choice                  |   |
                     +--------------------------+   |
                     V                              |
               saving window                        |
                     +------------------------------+
                     V
                    end

  a) Disk choice:
You have to choose the disk where the partition to save is.
Disk access mode is given:
  - standard access: with this access mode disk is accessed with its physical
definition (cylinder, sector, head). With this access mode sector size could
not been known (it is taken to 512 bytes which is most common value) and disk
size is at most of 8 Gb.
  - extended access: it is a new access mode which becomes the standard one.
In this case hard disk is seen as an unique lead (it does not care of physical
definition). This mode allows to use more than 8 Gb hard disk. Nevertheless
size reported could be wrong (without any consequence). Sector size could be
different from 512 bytes (but this value is always the most common).
In case no hard disk is found, message is displayed and program exits.

  b) Partition choice:
This window allows you to select partition to save.
All partitions founded on disk are given. You could choose anyone except all
marked empty.
Partitions category is used to know if partition is a main partition (it is
the 4 first and are always given) or if it is a partition defined into an
extended partition (in this case category is given only for the first
partition of this category and could be applied until a new category is
given).
Partition number is the number as given into Linux.
Drive name is the DOS drive name that corresponds to partition (if it is a DOS
partition). This could be wrong because some new partition type could be
defined (for example with Windows95 several new partition types have been
defined for VFAT16 and FAT32 partitions).
Partition type is used to identify OS install on. As this type is not
normalized, list is not exhaustive.

Remark:
If you save a main partition of extended type, you will save all partitions
defined into this extended partition (all that have "Extended partition n
<extended partition chosen> as category).

  c) Deflating choice:
If you have enough memory, a window asking if you want to deflate data is
opened (in other case, a window saying that you do not have enough memory is
opened).
Deflating algorithm used is the gzip one.

  d) File choice:
In this window you could choose name and location of file where to save
partition data.
A second window give you the list of DOS drive that have enough free space to
save all the partition data (minimum free size is size of data considering
they are not deflated).

Remarks:
  - if a drive does not appear into drives list, it is because it could not be
detected. Nevertheless, you could enter its letter into file name line (in
this case drive list would not give the right name, but there was no
consequence).
  - if selected file already exists, a window is opened to confirm selection
(if file is read-only, the window will inform you that it could not be
removed).
  - if you save a DOS partition, it is not advised to create the file on saved
partition. If you have no choice, perform a scandisk after each restoration to
check that file allocation table is not corrupted (if it was, you would not
have lost data, but it was the saving file that was in process during saving
that is unfinished when the partition is restored (the file used for restoring
is valid, it is the one on restored partition that is not)).

  e) File size choice:
With this window you could choose the maximum size you want the file does.
This maximum size could not be bigger than the minimum between drive free size
and 2047 Mb.
If you enter 0, you go back to the file choice window.

  f) Saving window:
This window gives you advancement of saving. 
Errors list is the list of errors detected when reading sectors on disk. If
you have the same errors when restoring and if, when you use disk checking
program (like surface checking of scandisk), bad sectors appear, these errors
have no consequence (if there was no data on these sectors before saving, but
it is OS rules to do that).
If the maximum file size you give is not enough to save all data, a new file
name is asked to you with its maximum size.


6- Restpart.exe
---------------------------------

It is the program used to restore a partition.

Use:    restpart.exe
     or resptart.exe -t
If "-t" option is given, no data is written on disk: file(s) is(are) checked
(check of checksum and if data are compressed, check of compressed data).

Execution follows below diagram:

                file choice
                     |
                     V
             partition choice
                     |<--------------------------------+
                     V                                 |
             restoring window                          |
                     +-----------> file choice --------+
                     V
                    end

  a) File choice:
It the same window as the one used for file choice when saving. Selected file
header is checked and an error is given if this one is not correct.

  b) Partition choice:
Switch header of file, a partition that could corresponds is searched (it must
be on a disk that has the same format, and it must be on the same location and
has the same type).
If no partition is found, a message is reported to you and program ends.

!!!!! Warning !!!!!:
Restoring data on a partition erases all data currently on this partition.
Moreover, you must no choose the partition on which a file used for this 
restoration is (indeed it will be erased during restoration and so would no
more be accessible and it will result into an error and the end of the
restoration).

Remark:
If you used "-t" option, this window does not appear.

  c) Restoring window:
This window permits you to follow restoration advancement.
Errors list contains list of errors that were detected when writing sectors on
disk. If errors are the same that these on saving, there was no consequence
(if they are not the same, or if they are fewer or more, you could have lost
data: run a program like scandisk to try to resolve this problem).
If the partition has been saved into several files, you must give them when
they are asked to you.

!!!!! Warning !!!!!:
  - when choosing next file, you must not access to the drive corresponding to
the partition being restored (if it is a DOS partition). Indeed this drive is
being written and so the file allocation table is wrong (as if you want to
access a file when a drive is being formatted).
  - once the partition is restored, reset your computer if you have restored a
DOS partition (or a partition that could be accessed under DOS). This is
needed for DOS to update informations about this partition.
  - if you cancel a running restoration, you have to format it (or do a new
restoration).

Remark:
If you use "-t" option, as no data is written on disk, errors list is
obligatory empty and the 3 previous remarks do not apply.


7- Errors
---------

  a) Fatal errors:

  - Error when initializing deflating/inflating algorithm
There was something wrong when initializing deflating/inflating algorithm. You
can try again without deflating data (in case of save).

  - Error when deflating/inflating data
There was something wrong when running deflating/inflating algorithm. If it is
when deflating (when saving), you could try again without deflating data. If
it is when inflating (when restoring), perhaps is the file erroneous.

  - Error when reading partition table
Partition could not be read or has a wrong format. Perhaps the disk has a
partition table with a format that is not recognized.

  - Partition does not need the same size correction that the one saved
Some BIOSes keep the last cylinder of disk as test zone or to have some
sectors in case of bad sectors. Switch OSes, these sectors are used or not. So
it is necessary sometimes to correct the last cylinder number if the partition
size seems wrong. The error appears if needed correction is not the same
between restoration and saving. This error could only appear in case disk is
accessed with standard mode.

  - Error creating file: <message>
  - Error opening file: <message>
An error appears when creating or opening a saving file. A message could
explain the reason.

  - Seeking file error
  - Error when seeking into file
  - Reading file error
  - Writing file error
An error appears when seeking, reading or writing file. Perhaps is it
erroneous.

  - Sector size is superior to 32256 bytes
Sector size is too big (or is erroneous). Common size is 512 bytes (some disks
have a size of sectors of 1024 bytes).

  - Error when accessing disk informations
An error appears when reading format of disk.

  - Calculated CRC is not equal to saved CRC
When restoring, saved CRC into file is not equal to calculated CRC. Perhaps is
the file erroneous.

  - Bad flag marking last file
Into header is an element to mark last file. Current state of restoration does
not correspond to read header. Perhaps is the file erroneous.

  - Size of read data is not equal to saved size
Into header an element save data size into file. Current restoration state
does not correspond to read header. Perhaps is the file erroneous.

  - Error when allocating memory with DPMI interface
DPMI server could not allocate memory. If you are saving with deflating data,
try to not use compression to save memory space.

  - Error when calling interruption with DPMI interface
DPMI server could not call an interruption. Try to load into memory a DPMI
server that will replace the one used (CWSDPMI integrated into program).

  - Not enough memory
Memory could not be allocated. If you are saving with deflating data, try to 
not use compression to save memory space.

  - Number of sectors saved differs from number of sectors written into 
partition table (<n1> against <n2> calculated)
Partition size read into partition table does not correspond to calculated
partition (despite a prospective correction of size due to last cylinder that
could be not used). This error could only appear in case disk is accessed with 
standard mode.

  - No partition agrees with one saved into file
No partition has been found which could correspond to saved one. For a
partition to correspond, it must be on a disk with the same format, is on the
same place and has the same type. This last restraint does that if you want to
save a partition, then install a new OS on, then want to restore the
partition, you must set the partition type to this of the previous OS before
(with fdisk under Linux by example) (but you do not need to format or install
something on it).

  - This program could not be executed under Windows
This program could not be executed on multi6tasking environment.

  b) Not fatal errors:

  - This file does not exist
When restoring, you give the name on a non existing file.

  - This file already exist and could not be overwritten (read-only)
When saving, you try to save into a read-only file.

  - Given file is incorrect: <message>
When restoring, you select a file that seems to be erroneous. Perhaps it is
not a file created with savepart.
Messages could be following:
    * Accessing file error
File could not be opened.
    * Header not found
Header could not be found. It is not a file created with savepart or it is
erroneous.
    * Bad header version
Header version is not known. This file could have been created with a more
recent version of savepart.
    * Bad file size
Size of file does not correspond to size saved into header.
    * Bad header CRC
A CRC is used to check header. Calculated CRC is not equal to saved one.
    * Bad compression format
Compression algorithm is not known.
    * Bad file number
Given file is not the one waited when restoring must be done with several files.
Perhaps you have inverted two files.
    * Bad disk format
When restoring from several files, disk format of given file does not
correspond to disk format of previous file.
    * Bad partition format
When restoring from several files, partition format of given file does not 
correspond to partition format of previous file.


8- What is not supported
------------------------

Following elements are not supported:
  - partitions for OSes that does no follow partition format as it is
described (notably Solaris x86).
  - disk manager programs (do not confuse with boot manager programs that are
supported). These programs allow to access to more than 8 Gb disks with
standard mode (if you use one, there are some probability that you know it).
If you see only one partition when you know that there were several, such a
program could be installed.
  - extended partition with OS2 could not be all detected: into extended
partition chain, the most common is to use only two partitions by node (the
two others having wrong informations), but OS2 seems to use the four
partitions.


9- What could not be tested
---------------------------

Following elements could not be tested:
  - use of SCSI disk.
  - use of disk with a sector size not equal to 512 bytes.
  - partitions for others OSes than DOS, Windows (9x) and Linux.
  - creating saving file on partition which is saved.

If somebody use this program with one of above element, I will be pleased to
know how it works (and trouble encountered if there were).
For these persons, I want to indicate that: 
  - savepart.exe only read the disk physically (writing is done into file with
standard DOS functions).
  - restpart.exe when used with "-t" option does not write anything on disk.


10- Acknowledgments
-----------------

  - my father for asking me such a program (without what it would be never 
written), to have read this document (the french version, all mistakes into 
english one is due to my poor english) and to have tested this program.

  - DJ Delorie for DJGPP environment (http://www.delorie.com/djgpp). This
includes also everybody who have helped him.

  - Jean-Loup Gailly and Mark Adler for zlib compression library 
(http://www.cdrom.com/pub/infozip/zlib/).

  - Ralf Brown all the documentation that he has gathered on interruptions
(http://www.pobox.com/~ralf).

  - Simon P. Bullen for fortify (a library to check memory use).


Hope this program will be useful,

D. Guibouret <guiboure@club-internet.fr>

All trademarks and registered trademarks are ownership of their respective
holders.
