Contents of the PLUG.DOC file
DISK FREE-SPACE DEFRAGMENTER - PLUG.EXE
WITH SOURCE CODE
This document describes the function of the disk free-space
defragmentation program PLUG.EXE written by Larry Himes,
July, 1987. The program was written primarily as an exercise
in handling low-level MS-DOS disk internal structures and is
provided in source and executable form free of charge by the
author. This software carries no warranties, express or im-
plied: USE AT YOUR OUN RISK.
Purpose: PLUG de-fragments free space on hard or floppy disks
by finding files which best fit "holes" of free space in the
disk structure and moving the files into the "holes". Holes
are filled only by files which start at physically higher
locations on the media, thus resulting in most of the used
disk space being packed into the "lower", or outer end of the
. Implementation was done using the Large Memory model (-mls
option of Lattice C version 3.2. The single Assembly
Language routine, _ABSDIO.ASM, was assembled using Micro-
soft MASM version 4.0.
. The Lattice functions getmem() and rlsmem() were used for
dynamic memory management because they are marginally more
efficient than malloc() and free(). Malloc() and free()
may be substituted for re-compilation with compilers which
do not support these functions, provided certain cautions
are exercized (see next item).
. Special care should be taken with the PUTINFO() function if
it is ported to other compiler implementations. Specifically,
the function relies on the fact that the Lattice function
getmem() returns pointers whose offset portions are always
zero in the large data model. If this peculiarity is not
taken into account and adjusted for during a port, DISASTER
. A version of qsort() written by me is included in the
package. It is somewhat more efficient than that supplied
by Lattice and should be quite portable, but any standard
version of qsort() may be used.
Files in archive:
BPB.HHeader file defining the structure of a BIOS
Parameter Block in the boot record of a disk.
DGLOBAL.HGlobal Data element external definitions.
DIR.HHeader file defining directory structures.
DIRUTIL.CFunctions dealing with directory processing.
FATUTIL.CFunctions dealing with FAT processing.
FMOVER.CControls moving of files in PLUG.EXE.
GDATA.C Global data element definitions.
LOADBPB.CFunctions to load and print BPB data.
PLUG.CPLUG Main() function.
PRTBPB.CMain program to print BPB and check FATs.
QSORT.C My own version of QSORT.
ABSDIO.ASMAssembly routine for absolute (logical sector-oriented)