chiark / gitweb /
some fixes; debug for missing
[inn-innduct.git] / doc / man / fastrm.1
1 .\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
2 .\"
3 .\" Standard preamble:
4 .\" ========================================================================
5 .de Sh \" Subsection heading
6 .br
7 .if t .Sp
8 .ne 5
9 .PP
10 \fB\\$1\fR
11 .PP
12 ..
13 .de Sp \" Vertical space (when we can't use .PP)
14 .if t .sp .5v
15 .if n .sp
16 ..
17 .de Vb \" Begin verbatim text
18 .ft CW
19 .nf
20 .ne \\$1
21 ..
22 .de Ve \" End verbatim text
23 .ft R
24 .fi
25 ..
26 .\" Set up some character translations and predefined strings.  \*(-- will
27 .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
28 .\" double quote, and \*(R" will give a right double quote.  \*(C+ will
29 .\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
30 .\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
31 .\" nothing in troff, for use with C<>.
32 .tr \(*W-
33 .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
34 .ie n \{\
35 .    ds -- \(*W-
36 .    ds PI pi
37 .    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
38 .    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
39 .    ds L" ""
40 .    ds R" ""
41 .    ds C` ""
42 .    ds C' ""
43 'br\}
44 .el\{\
45 .    ds -- \|\(em\|
46 .    ds PI \(*p
47 .    ds L" ``
48 .    ds R" ''
49 'br\}
50 .\"
51 .\" If the F register is turned on, we'll generate index entries on stderr for
52 .\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
53 .\" entries marked with X<> in POD.  Of course, you'll have to process the
54 .\" output yourself in some meaningful fashion.
55 .if \nF \{\
56 .    de IX
57 .    tm Index:\\$1\t\\n%\t"\\$2"
58 ..
59 .    nr % 0
60 .    rr F
61 .\}
62 .\"
63 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
64 .\" way too many mistakes in technical documents.
65 .hy 0
66 .if n .na
67 .\"
68 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
69 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
70 .    \" fudge factors for nroff and troff
71 .if n \{\
72 .    ds #H 0
73 .    ds #V .8m
74 .    ds #F .3m
75 .    ds #[ \f1
76 .    ds #] \fP
77 .\}
78 .if t \{\
79 .    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
80 .    ds #V .6m
81 .    ds #F 0
82 .    ds #[ \&
83 .    ds #] \&
84 .\}
85 .    \" simple accents for nroff and troff
86 .if n \{\
87 .    ds ' \&
88 .    ds ` \&
89 .    ds ^ \&
90 .    ds , \&
91 .    ds ~ ~
92 .    ds /
93 .\}
94 .if t \{\
95 .    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
96 .    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
97 .    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
98 .    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
99 .    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
100 .    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
101 .\}
102 .    \" troff and (daisy-wheel) nroff accents
103 .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
104 .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
105 .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
106 .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
107 .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
108 .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
109 .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
110 .ds ae a\h'-(\w'a'u*4/10)'e
111 .ds Ae A\h'-(\w'A'u*4/10)'E
112 .    \" corrections for vroff
113 .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
114 .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
115 .    \" for low resolution devices (crt and lpr)
116 .if \n(.H>23 .if \n(.V>19 \
117 \{\
118 .    ds : e
119 .    ds 8 ss
120 .    ds o a
121 .    ds d- d\h'-1'\(ga
122 .    ds D- D\h'-1'\(hy
123 .    ds th \o'bp'
124 .    ds Th \o'LP'
125 .    ds ae ae
126 .    ds Ae AE
127 .\}
128 .rm #[ #] #H #V #F C
129 .\" ========================================================================
130 .\"
131 .IX Title "FASTRM 1"
132 .TH FASTRM 1 "2008-04-06" "INN 2.4.5" "InterNetNews Documentation"
133 .SH "NAME"
134 fastrm \- Quickly remove a list of files
135 .SH "SYNOPSIS"
136 .IX Header "SYNOPSIS"
137 \&\fBfastrm\fR [\fB\-de\fR] [\fB\-u\fR|\fB\-u\fR\fIN\fR] [\fB\-s\fR|\fB\-s\fR\fIM\fR] [\fB\-c\fR|\fB\-c\fR\fII\fR]
138 \&\fIbase-directory\fR
139 .SH "DESCRIPTION"
140 .IX Header "DESCRIPTION"
141 \&\fBfastrm\fR reads a list of either file names or storage \s-1API\s0 tokens, one per
142 line, from its standard input and removes them.  Storage \s-1API\s0 tokens are
143 removed via the \fISMcancel()\fR interface.  \fBfastrm\fR does not delete files
144 safely or with an eye to security, but rather cuts every corner it can to
145 delete files as fast as it can.  It should therefore never be run on
146 publically writable directories, or in any other environment where a
147 hostile party may control the directory structure in which it is working.
148 .PP
149 If a file name is not an absolute path name, it is considered to be
150 relative to \fIbase-directory\fR as given on the command line.  The
151 \&\fIbase-directory\fR parameter must be a simple absolute pathname (it must
152 not contain multiple consecutive slashes or references to the special
153 directories \f(CW\*(C`.\*(C'\fR or \f(CW\*(C`..\*(C'\fR).
154 .PP
155 \&\fBfastrm\fR is designed to be faster than the typical \f(CW\*(C`| xargs rm\*(C'\fR pipeline
156 when given a sorted list of file names as input.  For example, \fBfastrm\fR
157 will usually \fIchdir\fR\|(2) into a directory before removing files from it,
158 meaning that if its input is sorted, most names passed to \fIunlink\fR\|(2) will
159 be simple names.  This can substantially reduce the operating system
160 overhead from directory lookups.
161 .PP
162 \&\fBfastrm\fR assumes that its input is valid and that it is safe to call
163 \&\fIunlink\fR\|(2) on every file name it is given.  As a safety measure, however,
164 \&\fBfastrm\fR when running as root will check with \fIstat\fR\|(2) that a file name
165 doesn't specify a directory before removing it.  (In some operating
166 systems, root is allowed to unlink directories, even directories which
167 aren't empty, which can cause file system corruption.)
168 .PP
169 The input to \fBfastrm\fR should always be sorted \*(-- or even better be in the
170 order file names are output by \fIfind\fR\|(1) \*(-- if speed is an issue and the
171 input isn't solely storage \s-1API\s0 tokens.  (It deals fine with unsorted
172 input, but is unlikely to be any faster in that case than a simple \f(CW\*(C`xargs
173 rm\*(C'\fR command.)  Sorting may even slightly speed up the removal of storage
174 \&\s-1API\s0 tokens due to caching effects, since sorting will tend to keep all of
175 the tokens from a particular storage method together.
176 .PP
177 Various additional optimizations for removing files can be turned on
178 and/or tuned with options (see below).  Which options will be most
179 effective depends heavily on the underlying structure of the file system,
180 the way in which directories are stored and searched, and similar, often
181 underdocumented, operating system implementation details.  The more
182 sophisticated the underlying operating system and file system, the more
183 likely that it will already perform the equivalent of these optimizations
184 internally.
185 .SH "OPTIONS"
186 .IX Header "OPTIONS"
187 .IP "\fB\-d\fR" 4
188 .IX Item "-d"
189 Don't remove any files.  Instead, print a list of the files that would be
190 removed to standard output.  Each line contains either the current
191 directory of \fBfastrm\fR at the time it would do the unlink and the relative
192 path name it would pass to \fIunlink\fR\|(2) as two fields separated by whitespace
193 and a \f(CW\*(C`/\*(C'\fR, the absolute path name (as a single field) that would be
194 passed to \fIunlink\fR\|(2), or the string \f(CW\*(C`Token\*(C'\fR and the storage \s-1API\s0 token that
195 would be removed.
196 .IP "\fB\-e\fR" 4
197 .IX Item "-e"
198 Treat an empty input file as an error.  This is most useful when \fBfastrm\fR
199 is last in a pipeline after a preceding \fIsort\fR\|(1) command, ensuring that
200 \&\fBfastrm\fR will fail if the sort fails.
201 .IP "\fB\-c\fR\fII\fR" 4
202 .IX Item "-cI"
203 Controls when \fBfastrm\fR calls \fIchdir\fR\|(2).  If the number of files to be
204 unlinked from a given directory is at least \fII\fR, then \fBfastrm\fR will
205 change to that directory before unlinking those files.  Otherwise, it will
206 use either the absolute path names or a path name relative to the current
207 directory (whichever is likely more efficient).  The \fII\fR parameter is
208 optional; if just \fB\-c\fR is given, \fB\-c1\fR is assumed, which will cause
209 \&\fBfastrm\fR to always chdir before calling \fIunlink\fR\|(2).  The default is
210 \&\fB\-c3\fR.  Use \fB\-c0\fR to prevent \fBfastrm\fR from ever using \fIchdir\fR\|(2).
211 .IP "\fB\-s\fR\fIM\fR" 4
212 .IX Item "-sM"
213 When \fB\-s\fR is given and the number of files to remove in a directory is
214 greater than \fIM\fR, rather than remove files in the order given, \fBfastrm\fR
215 will open the directory and read it, unlinking files in the order that
216 they appear in the directory.  On systems with a per-process directory
217 cache or that use a linear search to find files in a directory, this
218 should make directory lookups faster.  The \fIM\fR parameter is optional; if
219 just \fB\-s\fR is given, \fB\-s5\fR is assumed.
220 .Sp
221 When this option is in effect, \fBfastrm\fR won't attempt to remove files
222 that it doesn't see in the directory, possibly significantly speeding it
223 up if most of the files to be removed have already been deleted.  However,
224 using this option requires \fBfastrm\fR to do more internal work and it also
225 assumes that the order of directory listings is stable in the presence of
226 calls to \fIunlink\fR\|(2) between calls to \fIreaddir\fR\|(3).  This may be a dangerous
227 assumption with some sophisticated file systems (and in general this
228 option is only useful with file systems that use unindexed linear searches
229 to find files in directories or when most of the files to be removed have
230 already been deleted).
231 .Sp
232 This optimization is off by default.
233 .IP "\fB\-u\fR\fIN\fR" 4
234 .IX Item "-uN"
235 Specifying this option promises that there are no symbolic links in the
236 directory tree from which files are being removed.  This allows \fBfastrm\fR
237 to make an additional optimization to its calls to \fIchdir\fR\|(2), constructing
238 a relative path using \f(CW\*(C`../..\*(C'\fR and the like to pass to \fIchdir\fR\|(2) rather
239 than always using absolute paths.  Since this reduces the number of
240 directory lookups needed with deeply nested directory structures (such as
241 that typically created by traditional news spool storage), it can be a
242 significant optimization, but it breaks horribly in the presence of
243 symbolic links to directories.
244 .Sp
245 When \fB\-u\fR is given, \fBfastrm\fR will use at most \fIN\fR levels of \f(CW\*(C`..\*(C'\fR
246 segments to construct paths.  \fIN\fR is optional; if just \fB\-u\fR is given,
247 \&\fB\-u1\fR is assumed.
248 .Sp
249 This optimization is off by default.
250 .PP
251 \&\fBfastrm\fR also accepts \fB\-a\fR and \fB\-r\fR options, which do nothing at all
252 except allow you to say \f(CW\*(C`fastrm \-usa\*(C'\fR, \f(CW\*(C`fastrm \-ussr\*(C'\fR, or \f(CW\*(C`fastrm
253 \&\-user\*(C'\fR.  These happen to often be convenient sets of options to use.
254 .SH "EXIT STATUS"
255 .IX Header "EXIT STATUS"
256 \&\fBfastrm\fR exits with a status of zero if there were no problems, and an
257 exit status of 1 if something went wrong.  Attempting to remove a file
258 that does not exist is not considered a problem.
259 .SH "EXAMPLES"
260 .IX Header "EXAMPLES"
261 \&\fBfastrm\fR is typically invoked by \s-1INN\s0 via \fIexpirerm\fR\|(8) using a command
262 like:
263 .PP
264 .Vb 1
265 \&    fastrm \-e /usr/local/news/spool/articles < expire.list
266 .Ve
267 .PP
268 To enable all optimizations and see the affect on the order of removal
269 caused by \fB\-s\fR, use:
270 .PP
271 .Vb 1
272 \&    fastrm \-d \-s \-e \-u ~news/spool/articles < expire.list
273 .Ve
274 .PP
275 If your file system has indexed directory lookups, but you have a deeply
276 nested directory structure, you may want to use a set of flags like:
277 .PP
278 .Vb 1
279 \&    fastrm \-e \-u3 ~news/spool/articles < expire.list
280 .Ve
281 .PP
282 to strongly prefer relative paths but not to use \fIreaddir\fR\|(2) to order the
283 calls to \fIunlink\fR\|(2).
284 .PP
285 You may want to edit \fIexpirerm\fR\|(8) to change the flags passed to \fBfastrm\fR.
286 .SH "WARNINGS"
287 .IX Header "WARNINGS"
288 \&\fBfastrm\fR cuts corners and does not worry about security, so it does not
289 use \fIchdir\fR\|(2) safely and could be tricked into removing files other than
290 those that were intended if run on a specially constructed file tree or a
291 file tree that is being modified while it is running.  It should therefore
292 never be used with world-writable directories or any other directory that
293 might be controlled or modified by an attacker.
294 .SH "NOTES"
295 .IX Header "NOTES"
296 \&\fBfastrm\fR defers opening the storage subsystem or attempting to parse any
297 \&\s-1INN\s0 configuration files until it encounters a token in the list of files
298 to remove.  It's therefore possible to use \fBfastrm\fR outside of \s-1INN\s0 as a
299 general fast file removal program.
300 .SH "HISTORY"
301 .IX Header "HISTORY"
302 \&\fBfastrm\fR was originally written by kre@munnari.oz.au.  This manual page
303 rewritten in \s-1POD\s0 by Russ Allbery <rra@stanford.edu> for InterNetNews.
304 .PP
305 $Id: fastrm.1 7880 2008-06-16 20:37:13Z iulius $
306 .SH "SEE ALSO"
307 .IX Header "SEE ALSO"
308 \&\fIexpirerm\fR\|(8)