xref: /original-bsd/usr.sbin/mtree/mtree.8 (revision 2d1a7683)
1.\" Copyright (c) 1989, 1990 The Regents of the University of California.
2.\" All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)mtree.8	5.8 (Berkeley) 03/14/91
7.\"
8.Vx
9.Vx
10.Dd
11.Dt MTREE 8
12.Os
13.Sh NAME
14.Nm mtree
15.Nd map a directory hierarchy
16.Sh SYNOPSIS
17.Nm mtree
18.Op Fl cderux
19.Op Fl f Ar spec
20.Op Fl p Ar path
21.Sh DESCRIPTION
22.Nm Mtree
23compares a directory hierarchy against a specification for a
24directory hierarchy.
25By default, the specification is read from the standard input.
26.Nm Mtree
27verifies that the tree rooted in the current directory matches the
28specification.
29.Pp
30Messages are written to standard output for any files whose
31characteristics do not match those of the specification, or which are
32missing from either the specification or the tree.
33.Pp
34The options are as follows:
35.Tp Fl c
36Print a specification for the tree to standard output.
37.Tp Fl d
38Ignore everything except directory type files.
39.Tp Fl e
40Don't object to files that are in the tree but not in the specification.
41.Tp Fl f
42Read the specification from
43.Ar file  ,
44instead of from standard input.
45.Tp Fl p
46Traverse the tree rooted in
47.Ar path  ,
48instead of the current directory.
49.Tp Fl r
50Remove any files in the tree that are not described in the
51specification.
52.Tp Fl u
53Modify the owner, group, and permissions of existing files to match
54the specification, as well as create any missing directories.
55Owner, group, and permissions must all be specified for missing
56directories to be created.
57.Tp Fl x
58Don't descend below any mount points.
59.Tp
60.Pp
61Specifications are mostly composed of ``keywords'', i.e. strings that
62that specify values relating to files.
63No keywords have default values, and if a keyword has no set value no
64checks based on it are performed.
65.Pp
66Currently supported keywords are as follows:
67.Tw Cm
68.Tp Cm cksum
69The checksum of the file using the algorithm specified by
70the program
71.Xr cksum  1  .
72.Tp Cm ignore
73Causes the hierarchy below the file to be ignored.
74.Tp Cm group
75The group of the file; may be either numeric or symbolic.
76.Tp Cm mode
77The current file's permissions as an absolute (octal) or symbolic
78value (see
79.Xr chmod  1  ) .
80.Tp Cm nlink
81The number of hard links the file is expected to have.
82.Tp Cm owner
83The owner of the file; may be either numeric or symbolic.
84.Tp Cm size
85The size, in bytes, of the file.
86.Tp Cm link
87The file a symbolic link is expected to reference.
88.Tp Cm time
89The last modification time of the file.
90.Tp Cm type
91The type of the file; may be set to any one of the following:
92.Tw Cm
93.Tp Cm block
94block special device
95.Tp Cm char
96character special device
97.Tp Cm dir
98directory
99.Tp Cm fifo
100fifo
101.Tp Cm file
102regular file
103.Tp Cm link
104symbolic link
105.Tp Cm socket
106socket
107.Tp
108.Tp
109.Pp
110There are four types of lines in a specification.
111.Pp
112The first type of line sets a ``global'' value for a keyword, and
113consists of a leading ``/set'' followed by whitespace, followed by
114sets of keyword/value pairs, separated by whitespace.
115Keyword/value pairs consist of a keyword, followed by a equals sign
116(``=''), followed by a value, without intervening whitespace.
117Once a keyword has been set, its value remains unchanged until either
118set again or unset.
119.Pp
120The second type of line unsets keywords and consists of a leading
121``/unset'', followed by whitespace, followed by one or more keywords,
122separated by whitespace.
123.Pp
124The third type of line is a file specification and consists of a file
125name, followed by whitespace, followed by zero or more whitespace
126separated keyword/value pairs.
127The file name may be preceded by any number of whitespace characters.
128The file name may contain any of the standard file name matching
129characters (``['', ``]'', ``?'' or ``*''), in which case files
130in the hierarchy will be associated with the first pattern that
131they match.
132.Pp
133Each of the keyword/value pairs consist of a keyword, followed by an
134equals sign (``=''), followed by the keyword's value, without intervening
135whitespace.
136These values override, without changing, the global value of the
137corresponding keyword.
138.Pp
139All paths are relative.
140Specifying a directory will cause subsequent files to be searched
141for in that directory hierarchy.
142Which brings us to the last type of line in a specification: a line
143containing only the string
144.Dq Nm \&..
145causes the current directory
146path to ascend one level.
147.Pp
148Empty lines and lines whose first non-whitespace character is a hash
149mark (``#'') are ignored.
150.Pp
151.Nm Mtree
152exits with a status of 0 on success and >0 if an error occurred or the
153tree did not match the specification.
154.Sh FILES
155.Dw /etc/mtree
156.Di L
157.Dp Pa /etc/mtree
158system specification directory
159.Dp
160.Sh SEE ALSO
161.Xr chmod 1 ,
162.Xr chown 1 ,
163.Xr chgrp 1 ,
164.Xr cksum 1 ,
165.Xr find 1 ,
166.Xr stat 2 ,
167.Xr fts 3 ,
168.Xr mkproto 8
169.Sh BUGS
170The
171.Cm cksum
172keyword is not yet implemented.
173.Pp
174The
175.Cm time
176keyword should be specifiable in human readable terms.
177.Sh EXAMPLE
178.Ds I
179#	  fs: /a/staff/rick/mybin
180#	  by: rick
181#	date: Fri May 25 12:26:57 1990
182.sp
183/set group=staff mode=0555 nlink=1 owner=rick type=file
184[ 		nlink=2 size=6144
185adb		size=53248
186df		group=operator mode=02555 size=20480
187ps		group=kmem mode=02555 size=54272
188rcp		owner=root mode=04555 size=79872
189test		nlink=2 size=6144
190.sp
191/set group=wheel mode=0444 nlink=1 owner=rick type=file
192manpages	type=dir mode=0775 nlink=2 size=1024
193adb.man	size=9473
194df.man	size=5263
195tar.man	size=3324
196\&..
197.De
198.Sh HISTORY
1994.3 Reno BSD.
200