1FASTRM(1)                 InterNetNews Documentation                 FASTRM(1)
2
3
4

NAME

6       fastrm - Quickly remove a list of files
7

SYNOPSIS

9       fastrm [-de] [-c|-cI] [-s|-sM] [-u|-uN] base-directory
10

DESCRIPTION

12       fastrm reads a list of either file names or storage API tokens, one per
13       line, from its standard input and removes them.  Storage API tokens are
14       removed via the SMcancel() interface.  fastrm does not delete files
15       safely or with an eye to security, but rather cuts every corner it can
16       to delete files as fast as it can.  It should therefore never be run on
17       publically writable directories, or in any other environment where a
18       hostile party may control the directory structure in which it is
19       working.
20
21       If a file name is not an absolute path name, it is considered to be
22       relative to base-directory as given on the command line.  The base-
23       directory parameter must be a simple absolute pathname (it must not
24       contain multiple consecutive slashes or references to the special
25       directories "." or "..").
26
27       fastrm is designed to be faster than the typical "| xargs rm" pipeline
28       when given a sorted list of file names as input.  For example, fastrm
29       will usually chdir(2) into a directory before removing files from it,
30       meaning that if its input is sorted, most names passed to unlink(2)
31       will be simple names.  This can substantially reduce the operating
32       system overhead from directory lookups.
33
34       fastrm assumes that its input is valid and that it is safe to call
35       unlink(2) on every file name it is given.  As a safety measure,
36       however, fastrm when running as root will check with stat(2) that a
37       file name doesn't specify a directory before removing it.  (In some
38       operating systems, root is allowed to unlink directories, even
39       directories which aren't empty, which can cause file system
40       corruption.)
41
42       The input to fastrm should always be sorted -- or even better be in the
43       order file names are output by find(1) -- if speed is an issue and the
44       input isn't solely storage API tokens.  (It deals fine with unsorted
45       input, but is unlikely to be any faster in that case than a simple "|
46       xargs rm" command.)  Sorting may even slightly speed up the removal of
47       storage API tokens due to caching effects, since sorting will tend to
48       keep all of the tokens from a particular storage method together.
49
50       Various additional optimizations for removing files can be turned on
51       and/or tuned with options (see below).  Which options will be most
52       effective depends heavily on the underlying structure of the file
53       system, the way in which directories are stored and searched, and
54       similar, often underdocumented, operating system implementation
55       details.  The more sophisticated the underlying operating system and
56       file system, the more likely that it will already perform the
57       equivalent of these optimizations internally.
58

OPTIONS

60       -c[I]
61           Controls when fastrm calls chdir(2).  If the number of files to be
62           unlinked from a given directory is at least I, then fastrm will
63           change to that directory before unlinking those files.  Otherwise,
64           it will use either the absolute path names or a path name relative
65           to the current directory (whichever is likely more efficient).  The
66           I parameter is optional; if just -c is given, -c1 is assumed, which
67           will cause fastrm to always chdir before calling unlink(2).  The
68           default is -c3.  Use -c0 to prevent fastrm from ever using
69           chdir(2).
70
71       -d  Don't remove any files.  Instead, print a list of the files that
72           would be removed to standard output.  Each line contains either the
73           current directory of fastrm at the time it would do the unlink and
74           the relative path name it would pass to unlink(2) as two fields
75           separated by whitespace and a "/", the absolute path name (as a
76           single field) that would be passed to unlink(2), or the string
77           "Token" and the storage API token that would be removed.
78
79       -e  Treat an empty input file as an error.  This is most useful when
80           fastrm is last in a pipeline after a preceding sort(1) command,
81           ensuring that fastrm will fail if the sort fails.
82
83       -s[M]
84           When -s is given and the number of files to remove in a directory
85           is greater than M, rather than remove files in the order given,
86           fastrm will open the directory and read it, unlinking files in the
87           order that they appear in the directory.  On systems with a per-
88           process directory cache or that use a linear search to find files
89           in a directory, this should make directory lookups faster.  The M
90           parameter is optional; if just -s is given, -s5 is assumed.
91
92           When this option is in effect, fastrm won't attempt to remove files
93           that it doesn't see in the directory, possibly significantly
94           speeding it up if most of the files to be removed have already been
95           deleted.  However, using this option requires fastrm to do more
96           internal work and it also assumes that the order of directory
97           listings is stable in the presence of calls to unlink(2) between
98           calls to readdir(3).  This may be a dangerous assumption with some
99           sophisticated file systems (and in general this option is only
100           useful with file systems that use unindexed linear searches to find
101           files in directories or when most of the files to be removed have
102           already been deleted).
103
104           This optimization is off by default.
105
106       -u[N]
107           Specifying this option promises that there are no symbolic links in
108           the directory tree from which files are being removed.  This allows
109           fastrm to make an additional optimization to its calls to chdir(2),
110           constructing a relative path using "../.." and the like to pass to
111           chdir(2) rather than always using absolute paths.  Since this
112           reduces the number of directory lookups needed with deeply nested
113           directory structures (such as that typically created by traditional
114           news spool storage), it can be a significant optimization, but it
115           breaks horribly in the presence of symbolic links to directories.
116
117           When -u is given, fastrm will use at most N levels of ".."
118           segments to construct paths.  N is optional; if just -u is given,
119           -u1 is assumed.
120
121           This optimization is off by default.
122
123       fastrm also accepts -a and -r options, which do nothing at all except
124       allow you to say "fastrm -usa", "fastrm -usr", or "fastrm -user".
125       These happen to often be convenient sets of options to use.
126

EXIT STATUS

128       fastrm exits with a status of zero if there were no problems, and an
129       exit status of 1 if something went wrong.  Attempting to remove a file
130       that does not exist is not considered a problem.
131

EXAMPLES

133       fastrm is typically invoked by INN via expirerm(8) using a command
134       like:
135
136           fastrm -e <patharticles in inn.conf> < expire.list
137
138       To enable all optimizations and see the affect on the order of removal
139       caused by -s, use:
140
141           fastrm -d -s -e -u <patharticles> < expire.list
142
143       If your file system has indexed directory lookups, but you have a
144       deeply nested directory structure, you may want to use a set of flags
145       like:
146
147           fastrm -e -u3 <patharticles> < expire.list
148
149       to strongly prefer relative paths but not to use readdir(2) to order
150       the calls to unlink(2).
151
152       You may want to edit expirerm(8) to change the flags passed to fastrm.
153

WARNINGS

155       fastrm cuts corners and does not worry about security, so it does not
156       use chdir(2) safely and could be tricked into removing files other than
157       those that were intended if run on a specially constructed file tree or
158       a file tree that is being modified while it is running.  It should
159       therefore never be used with world-writable directories or any other
160       directory that might be controlled or modified by an attacker.
161

NOTES

163       fastrm defers opening the storage subsystem or attempting to parse any
164       INN configuration files until it encounters a token in the list of
165       files to remove.  It's therefore possible to use fastrm outside of INN
166       as a general fast file removal program.
167

HISTORY

169       fastrm was originally written by <kre@munnari.oz.au>.  This manual page
170       was rewritten in POD by Russ Allbery <eagle@eyrie.org> for
171       InterNetNews.
172
173       $Id: fastrm.pod 9767 2014-12-07 21:13:43Z iulius $
174

SEE ALSO

176       expirerm(8).
177
178
179
180INN 2.6.3                         2015-09-12                         FASTRM(1)
Impressum