
  Contig V1.21

  Copyright  1998 Mark Russinovich

  Last Updated January 19, 1997

          Introduction There are a number of NT disk defraggers on the
                       market. These tools are useful for performing a
                       general defragmentation of disks, but while most
                       files are defragmented on drives processed by
                       these utilities, some files may not be. In
                       addition, it is difficult to ensure that
                       particular files that are frequently used are
                       defragmented - they may remain fragmented for
                       reasons that are specific to the defragmentation
                       algorithms used by the defragging product that has
                       been applied. Finally, even if all files have been
                       defragmented, subsequent changes to critical files
                       could cause them to become fragmented. Only by
                       running an entire defrag operation can one hope
                       that they might be defragmented again.

                       Contig is a single-file defragmenter that attempts
                       to make files contiguous on disk. Its perfect for
                       quickly optimizing files that are continuously
                       becoming fragmented, or that you want to ensure
                       are in as few fragments as possible.

  Installation and Use Contig works on NT 4.0 and higher. Contig can be
                       used to defrag an existing file, or to create a
                       new file of a specified size and name, optimizing
                       its placement on disk. To make an existing file
                       contiguous use Contig as follows:

                       Usage: contig [-v] [-q] [-s] [filename]

                       Use the -v switch to have Contig print out
                       information about the file defrag operations that
                       are performed. Use the -s switch to perform a
                       recursive processing of subdirectories when you
                       specify a filename with wildcards. For instance,
                       to defragment all DLLs under c:\winnt you could
                       enter "contig -s c:\winnt\*.dll". The -q switch,
                       which over-rides the -v switch, makes Contig run
                       in "quiet" mode, where the only thing it prints
                       during a defrag run is summary information.

                       To make a new file that is defragmented upon
                       creation, use Contig like this:

                       Usage: contig [-v] [-n filename length]

          How It Works Contig uses the native Windows NT defragmentation
                       support that was introduced with NT 4.0 (see my
                       documentation of the defrag APIs for more
                       information). It first scans the disk collecting
                       the locations and sizes of free areas. Then it
                       determines where the file in question is located.
                       Next, Contig decides whether the file can be
                       optimized, based on free areas and the number of
                       fragments the file currently consists of. If the
                       file can be optimized, it is moved into the free
                       spaces of the disk.

                       A significant amount of code is present in Contig
                       to deal with NTFS files, which can be compressed.
                       In addition, Contig must only move 16-cluster
                       aligned portions of a NTFS file, and must not
                       move, in one call to NT's defrag engine, a NTFS
                       file segment that straddles a 256KB boundary in
                       the file. Note that Contig does not move other
                       files in an effort to make contiguous space on the
                       disk for the target file.

  ------------------------------------------------------------------------
