file_cmds-264.1.1.tar.gz
[apple/file_cmds.git] / mtree / mtree.8
1 .\" Copyright (c) 1989, 1990, 1993
2 .\"     The Regents of the University of California.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\"    notice, this list of conditions and the following disclaimer in the
11 .\"    documentation and/or other materials provided with the distribution.
12 .\" 4. Neither the name of the University nor the names of its contributors
13 .\"    may be used to endorse or promote products derived from this software
14 .\"    without specific prior written permission.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 .\" SUCH DAMAGE.
27 .\"
28 .\"     From: @(#)mtree.8       8.2 (Berkeley) 12/11/93
29 .\" $FreeBSD: src/usr.sbin/mtree/mtree.8,v 1.53 2005/07/31 03:30:47 keramida Exp $
30 .\"
31 .Dd March 29, 2005
32 .Dt MTREE 8
33 .Os
34 .Sh NAME
35 .Nm mtree
36 .Nd map a directory hierarchy
37 .Sh SYNOPSIS
38 .Nm mtree
39 .Op Fl LPUcdeinqruxw
40 .Bk -words
41 .Op Fl f Ar spec
42 .Ek
43 .Bk -words
44 .Op Fl f Ar spec
45 .Ek
46 .Bk -words
47 .Op Fl K Ar keywords
48 .Ek
49 .Bk -words
50 .Op Fl k Ar keywords
51 .Ek
52 .Bk -words
53 .Op Fl p Ar path
54 .Ek
55 .Bk -words
56 .Op Fl s Ar seed
57 .Ek
58 .Bk -words
59 .Op Fl X Ar exclude-list
60 .Ek
61 .Sh DESCRIPTION
62 The
63 .Nm mtree
64 utility compares the file hierarchy rooted in the current directory against a
65 specification read from the standard input.
66 Messages are written to the standard output for any files whose
67 characteristics do not match the specifications, or which are
68 missing from either the file hierarchy or the specification.
69 .Pp
70 The options are as follows:
71 .Bl -tag -width flag
72 .\" ==========
73 .It Fl c
74 Print a specification for the file hierarchy to the standard output.
75 .\" ==========
76 .It Fl d
77 Ignore everything except directory type files.
78 .\" ==========
79 .It Fl e
80 Do not complain about files that are in the file hierarchy, but not in the
81 specification.
82 .\" ==========
83 .It Fl f Ar file
84 Read the specification from
85 .Ar file ,
86 instead of from the standard input.
87 .Pp
88 If this option is specified twice,
89 the two specifications are compared with each other,
90 rather than to the file hierarchy.
91 The specifications be sorted like output generated using
92 .Fl c .
93 The output format in this case is somewhat remniscent of
94 .Xr comm 1 ,
95 having "in first spec only", "in second spec only", and "different"
96 columns, prefixed by zero, one and two TAB characters respectively.
97 Each entry in the "different" column occupies two lines,
98 one from each specification.
99 .\" ==========
100 .It Fl i
101 Indent the output 4 spaces each time a directory level is descended when
102 create a specification with the
103 .Fl c
104 option.
105 This does not affect either the /set statements or the comment before each
106 directory.
107 It does however affect the comment before the close of each directory.
108 .\" ==========
109 .It Fl K Ar keywords
110 Add the specified (whitespace or comma separated)
111 .Ar keywords
112 to the current set of keywords.
113 .\" ==========
114 .It Fl k Ar keywords
115 Use the ``type'' keyword plus the specified (whitespace or comma separated)
116 .Ar keywords
117 instead of the current set of keywords.
118 .\" ==========
119 .It Fl L
120 Follow all symbolic links in the file hierarchy.
121 .\" ==========
122 .It Fl n
123 Do not emit pathname comments when creating a specification.
124 Normally
125 a comment is emitted before each directory and before the close of that
126 directory when using the
127 .Fl c
128 option.
129 .\" ==========
130 .It Fl P
131 Do not follow symbolic links in the file hierarchy, instead consider
132 the symbolic link itself in any comparisons.
133 This is the default.
134 .\" ==========
135 .It Fl p Ar path
136 Use the file hierarchy rooted in
137 .Ar path ,
138 instead of the current directory.
139 .\" ==========
140 .It Fl q
141 Quiet mode.
142 Do not complain when a
143 .Dq missing
144 directory cannot be created because it already exists.
145 This occurs when the directory is a symbolic link.
146 .\" ==========
147 .It Fl r
148 Remove any files in the file hierarchy that are not described in the
149 specification.
150 .\" ==========
151 .It Fl s Ar seed
152 Display a single checksum to the standard error output that represents all
153 of the files for which the keyword
154 .Cm cksum
155 was specified.
156 The checksum is seeded with the specified value.
157 .\" ==========
158 .It Fl U
159 Modify the owner, group, permissions, and modification time of existing
160 files to match the specification and create any missing directories or
161 symbolic links.
162 User, group and permissions must all be specified for missing directories
163 to be created.
164 Corrected mismatches are not considered errors.
165 .\" ==========
166 .It Fl u
167 Same as
168 .Fl U
169 except a status of 2 is returned if the file hierarchy did not match
170 the specification.
171 .\" ==========
172 .It Fl w
173 Make some error conditions non-fatal warnings.
174 .\" ==========
175 .It Fl X Ar exclude-list
176 The specified file contains
177 .Xr fnmatch 3
178 patterns matching files to be excluded from
179 the specification, one to a line.
180 If the pattern contains a
181 .Ql \&/
182 character, it will be matched against entire pathnames (relative to
183 the starting directory); otherwise,
184 it will be matched against basenames only.
185 No comments are allowed in
186 the
187 .Ar exclude-list
188 file.
189 .\" ==========
190 .It Fl x
191 Do not descend below mount points in the file hierarchy.
192 .El
193 .Pp
194 Specifications are mostly composed of ``keywords'', i.e., strings
195 that specify values relating to files.
196 No keywords have default values, and if a keyword has no value set, no
197 checks based on it are performed.
198 .Pp
199 Currently supported keywords are as follows:
200 .Bl -tag -width Cm
201 .It Cm cksum
202 The checksum of the file using the default algorithm specified by
203 the
204 .Xr cksum 1
205 utility.
206 .It Cm flags
207 The file flags as a symbolic name.
208 See
209 .Xr chflags 1
210 for information on these names.
211 If no flags are to be set the string
212 .Dq none
213 may be used to override the current default.
214 .It Cm ignore
215 Ignore any file hierarchy below this file.
216 .It Cm gid
217 The file group as a numeric value.
218 .It Cm gname
219 The file group as a symbolic name.
220 .It Cm md5digest
221 The MD5 message digest of the file.
222 .It Cm sha1digest
223 The
224 .Tn FIPS
225 160-1
226 .Pq Dq Tn SHA-1
227 message digest of the file.
228 .It Cm ripemd160digest
229 The
230 .Tn RIPEMD160
231 message digest of the file.
232 .It Cm mode
233 The current file's permissions as a numeric (octal) or symbolic
234 value.
235 .It Cm nlink
236 The number of hard links the file is expected to have.
237 .It Cm nochange
238 Make sure this file or directory exists but otherwise ignore all attributes.
239 .It Cm uid
240 The file owner as a numeric value.
241 .It Cm uname
242 The file owner as a symbolic name.
243 .It Cm size
244 The size, in bytes, of the file.
245 .It Cm link
246 The file the symbolic link is expected to reference.
247 .It Cm time
248 The last modification time of the file.
249 .It Cm btime
250 The creation (birth) time of the file.
251 .It Cm atime
252 The last access time of the file.
253 .It Cm ctime
254 The last metadata modification time of the file.
255 .It Cm ptime
256 The time the file was added to its parent folder.
257 .It Cm inode
258 The inode number of the file.
259 .It Cm xattrsdigest
260 Digest of the extended attributes of the file.
261 .It Cm acldigest
262 Digest of the access control list of the file.
263 .It Cm type
264 The type of the file; may be set to any one of the following:
265 .Pp
266 .Bl -tag -width Cm -compact
267 .It Cm block
268 block special device
269 .It Cm char
270 character special device
271 .It Cm dir
272 directory
273 .It Cm fifo
274 fifo
275 .It Cm file
276 regular file
277 .It Cm link
278 symbolic link
279 .It Cm socket
280 socket
281 .El
282 .El
283 .Pp
284 The default set of keywords are
285 .Cm flags ,
286 .Cm gid ,
287 .Cm mode ,
288 .Cm nlink ,
289 .Cm size ,
290 .Cm link ,
291 .Cm time ,
292 and
293 .Cm uid .
294 .Pp
295 There are four types of lines in a specification.
296 .Pp
297 The first type of line sets a global value for a keyword, and consists of
298 the string ``/set'' followed by whitespace, followed by sets of keyword/value
299 pairs, separated by whitespace.
300 Keyword/value pairs consist of a keyword, followed by an equals sign
301 (``=''), followed by a value, without whitespace characters.
302 Once a keyword has been set, its value remains unchanged until either
303 reset or unset.
304 .Pp
305 The second type of line unsets keywords and consists of the string
306 ``/unset'', followed by whitespace, followed by one or more keywords,
307 separated by whitespace.
308 .Pp
309 The third type of line is a file specification and consists of a file
310 name, followed by whitespace, followed by zero or more whitespace
311 separated keyword/value pairs.
312 The file name may be preceded by whitespace characters.
313 The file name may contain any of the standard file name matching
314 characters (``['', ``]'', ``?'' or ``*''), in which case files
315 in the hierarchy will be associated with the first pattern that
316 they match.
317 .Pp
318 Each of the keyword/value pairs consist of a keyword, followed by an
319 equals sign (``=''), followed by the keyword's value, without
320 whitespace characters.
321 These values override, without changing, the global value of the
322 corresponding keyword.
323 .Pp
324 All paths are relative.
325 Specifying a directory will cause subsequent files to be searched
326 for in that directory hierarchy.
327 Which brings us to the last type of line in a specification: a line
328 containing only the string
329 .Dq Pa ..\&
330 causes the current directory
331 path to ascend one level.
332 .Pp
333 Empty lines and lines whose first non-whitespace character is a hash
334 mark (``#'') are ignored.
335 .Pp
336 The
337 .Nm mtree
338 utility exits with a status of 0 on success, 1 if any error occurred,
339 and 2 if the file hierarchy did not match the specification.
340 A status of 2 is converted to a status of 0 if the
341 .Fl U
342 option is used.
343 .Sh FILES
344 .Bl -tag -width /etc/mtree -compact
345 .It Pa /etc/mtree
346 system specification directory
347 .El
348 .Sh EXIT STATUS
349 .Ex -std
350 .Sh EXAMPLES
351 The
352 .Fl d
353 and
354 .Fl u
355 options can be used in combination to create directory hierarchies
356 for distributions and other such things; the files in
357 .Pa /etc/mtree
358 were used to create almost all directories in this
359 .Fx
360 distribution.
361 .Sh SEE ALSO
362 .Xr chflags 1 ,
363 .Xr chgrp 1 ,
364 .Xr chmod 1 ,
365 .Xr cksum 1 ,
366 .Xr md5 1 ,
367 .Xr stat 2 ,
368 .Xr fts 3 ,
369 .Xr md5 3 ,
370 .Xr chown 8
371 .Sh HISTORY
372 The
373 .Nm mtree
374 utility appeared in
375 .Bx 4.3 Reno .
376 The
377 .Tn MD5
378 digest capability was added in
379 .Fx 2.1 ,
380 in response to the widespread use of programs which can spoof
381 .Xr cksum 1 .
382 The
383 .Tn SHA-1
384 and
385 .Tn RIPEMD160
386 digests were added in
387 .Fx 4.0 ,
388 as new attacks have demonstrated weaknesses in
389 .Tn MD5 .
390 Support for file flags was added in
391 .Fx 4.0 ,
392 and mostly comes from
393 .Nx .