Manual Reference Pages - BESTFIT (1)

CONTENTS

This manual page document describes the bestfit command.
Bestfit is a small program to determine which files that should be put
on a CD (or other media), so that as little space as possible is wasted.
It is very easy to use: you specify files on the command line, and bestfit
prints the names of those that were selected. Alternatively, bestfit
can execute a command for each selected file (e.g. to move them to a
different directory).

This problem is also known as the 0-1 knapsack problem. The algorithm
implemented by bestfit solves instances of it optimally in theta(n*W)
time, where n is number of files to choose between and W the amount of
free space. This may sound bad but since W is number of blocks and not
bytes, this algorithm is not that inefficient. Try it yourself and see.

Due to the nature of this algorithm, bestfit uses a lot of memory -
approximately 1.5M per file specified on command line. As long as
you have enough swap space, this is usually not a problem since
bestfit doesnt use all at the same time.

Bestfit does (at this time) not use any external program such as mkisofs
or mkhybrid to calculate the size of files. Instead the file and directory
sizes and rounded up towards the nearest 2048-byte multiple and added
together. (2048 bytes is the block size on ISO images.)

Bestfit can not account for all oddities with ISO images (for instance,
there are multiple path tables, padding, etc which is not easy to
calculate), therefore exact results can not always be produced. Bestfit
may waste more space than necessary, or even tell you that files that
wont fit actually fits. (I consider the latter to be a bug though.
If you encounter it, please mail me.) In other words, manually selecting
files and checking that they fit using mkisofs may in some cases give
you better results than using bestfit.

These programs follow the usual GNU command line syntax, with long
options starting with two dashes (-).
A summary of options is included below.

-8, --80min

Space is that of an empty 80 min CD. This is the default.

-7, --74min

Space is that of an empty 74 min CD.

-d, --dirs-only

Ignore all non-directory arguments. (This is useful when including
files using wildcard/glob patterns.)

-s, --space=BLOCKS

The maximum amount of space allowed to use, in blocks.

-r, --reserve=BLOCKS

The number of blocks to reserve (usually 200 by default). This
value is simple substracted from the space value before the
algorithm is started.

-e, --execute COMMAND...

Execute a command for each selected file, instead of printing
the name on screen. All following arguments after --execute (or -e) are
taken to be arguments to the command to execute for each selected
file. The string {} is replaced by the current file name being
processed, and can be used multiple times.

If --invert is used as well as --execute, the command is executed
for files that werent selected instead.

-i, --invert

Print names of those files that werent selected (i.e. did not fitting)
instead.

-v, --verbose

Explain what is being done.

-q, --quiet

Output no diagnostic/information messages. (Error messages are still
printed.)

The -i option was added to make move interactive, so that
we wont overwrite files by mistake. Note that we dont need
to terminate bestfits options using --, because -e stops
bestfit from reading further options.