If a file name is not an absolute path name, it is considered to be relative to base-directory as given on the command line. The base-directory parameter must be a simple absolute pathname (it must not contain multiple consecutive slashes or references to the special directories "." or "..").
fastrm is designed to be faster than the typical "| xargs rm" pipeline when given a sorted list of file names as input. For example, fastrm will usually (2) into a directory before removing files from it, meaning that if its input is sorted, most names passed to (2) will be simple names. This can substantially reduce the operating system overhead from directory lookups.
fastrm assumes that its input is valid and that it is safe to call (2) on every file name it is given. As a safety measure, however, fastrm when running as root will check with (2) that a file name doesn't specify a directory before removing it. (In some operating systems, root is allowed to unlink directories, even directories which aren't empty, which can cause file system corruption.)
The input to fastrm should always be sorted --- or even better be in the order file names are output by find(1) --- if speed is an issue and the input isn't solely storage API tokens. (It deals fine with unsorted input, but is unlikely to be any faster in that case than a simple "xargs rm" command.) Sorting may even slightly speed up the removal of storage API tokens due to caching effects, since sorting will tend to keep all of the tokens from a particular storage method together.
Various additional optimizations for removing files can be turned on and/or tuned with options (see below). Which options will be most effective depends heavily on the underlying structure of the file system, the way in which directories are stored and searched, and similar, often underdocumented, operating system implementation details. The more sophisticated the underlying operating system and file system, the more likely that it will already perform the equivalent of these optimizations internally.
When this option is in effect, fastrm won't attempt to remove files that it doesn't see in the directory, possibly significantly speeding it up if most of the files to be removed have already been deleted. However, using this option requires fastrm to do more internal work and it also assumes that the order of directory listings is stable in the presence of calls to (2) between calls to (3). This may be a dangerous assumption with some sophisticated file systems (and in general this option is only useful with file systems that use unindexed linear searches to find files in directories or when most of the files to be removed have already been deleted).
This optimization is off by default.
When -u is given, fastrm will use at most N levels of ".." segments to construct paths. N is optional; if just -u is given, -u1 is assumed.
This optimization is off by default.
fastrm also accepts -a and -r options, which do nothing at all except allow you to say "fastrm -usa", "fastrm -ussr", or "fastrm -user". These happen to often be convenient sets of options to use.
fastrm -e /usr/local/news/spool/articles < expire.list
To enable all optimizations and see the affect on the order of removal caused by -s, use:
fastrm -d -s -e -u ~news/spool/articles < expire.list
If your file system has indexed directory lookups, but you have a deeply nested directory structure, you may want to use a set of flags like:
fastrm -e -u3 ~news/spool/articles < expire.list
to strongly prefer relative paths but not to use (2) to order the calls to (2).
You may want to edit (8)
to change the flags passed to fastrm.
WARNINGS
fastrm cuts corners
and does not worry about security, so it does not use (2)
safely and could be tricked into removing files other than those
that were intended if run on a specially constructed file tree or a
file tree that is being modified while it is running. It should
therefore never be used with world-writable directories or any
other directory that might be controlled or modified by an
attacker.
NOTES
fastrm defers opening the
storage subsystem or attempting to parse any INN configuration files until it encounters a token in
the list of files to remove. It's therefore possible to use
fastrm outside of INN as a general
fast file removal program.
HISTORY
fastrm was originally
written by kre@munnari.oz.au. This manual page
rewritten in POD by Russ Allbery
<rra@stanford.edu> for
InterNetNews.
$Id: fastrm.1 7429 2005-12-11 20:42:43Z eagle $