Commit | Line | Data |
---|---|---|
25f14064 KB |
1 | .\" Copyright (c) 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms are permitted | |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
2dd8a2d1 | 16 | .\" @(#)mtree.8 5.3 (Berkeley) %G% |
25f14064 KB |
17 | .\" |
18 | .TH MTREE 8 "" | |
19 | .UC 7 | |
20 | .SH NAME | |
21 | mtree \- map a directory hierarchy | |
22 | .SH SYNOPSIS | |
23 | .B mtree | |
24 | [ | |
25 | .B \-cderux | |
26 | ] [ | |
27 | .B \-f | |
28 | spec ] [ | |
29 | .B \-p | |
30 | path ] | |
31 | .SH DESCRIPTION | |
32 | .I Mtree | |
33 | maps a directory hierarchy, or tree, to a specification. | |
34 | The | |
35 | specification is read from the standard input by default, or from | |
36 | the file | |
37 | .I spec | |
38 | if the | |
f504b637 | 39 | .I \-f |
25f14064 KB |
40 | option is provided. |
41 | .I Mtree | |
42 | then walks the tree specified by the | |
f504b637 | 43 | .I \-p |
25f14064 KB |
44 | option, or by default, the tree rooted in the current directory, and |
45 | verifies that the tree matches the specification. | |
46 | Messages are written to standard output for any nodes which exist | |
47 | only in the specification or the tree and for any nodes whose | |
48 | characteristics do not match those of the specification. | |
49 | .PP | |
50 | The options are as follows: | |
51 | .TP | |
f504b637 | 52 | \-c |
25f14064 KB |
53 | Print to standard output a specification for the tree. |
54 | .TP | |
f504b637 | 55 | \-d |
25f14064 KB |
56 | Ignore everything except directory type nodes. |
57 | .TP | |
f504b637 | 58 | \-e |
25f14064 KB |
59 | Stops |
60 | .I mtree | |
61 | from objecting to nodes that are in the tree but not in the | |
62 | specification. | |
63 | .TP | |
f504b637 | 64 | \-r |
25f14064 KB |
65 | Remove any nodes in the tree that are not described in the |
66 | specification. | |
67 | .TP | |
f504b637 | 68 | \-u |
25f14064 | 69 | The |
f504b637 | 70 | .I \-u |
25f14064 KB |
71 | option causes |
72 | .I mtree | |
73 | to modify the owner, group, and permissions of existing nodes to | |
74 | match the specification. | |
75 | Missing directories are also created. | |
76 | .TP | |
f504b637 | 77 | \-x |
25f14064 KB |
78 | Don't traverse any mount points when creating a specification. |
79 | .PP | |
80 | Specifications consist of ``keywords'', i.e. special strings that specify | |
81 | values relating to nodes. | |
82 | No keywords have default values, and if a keyword has no set value no | |
83 | checks on it are performed. | |
84 | The only keyword which | |
85 | .B must | |
f504b637 KB |
86 | be set is |
87 | .BR type . | |
25f14064 KB |
88 | Currently supported keywords are as follows: |
89 | .TP | |
f504b637 | 90 | .B cksum |
25f14064 KB |
91 | The checksum of the file using the algorithm specified by |
92 | the program | |
93 | .IR cksum (1). | |
f504b637 KB |
94 | Ignored for any nodes other than type |
95 | .BR file . | |
25f14064 | 96 | .TP |
f504b637 | 97 | .B dmode |
25f14064 KB |
98 | The directory type node's permissions as an octal value. |
99 | This keyword may only be used globally, i.e. not as part of a node | |
100 | specification line. | |
101 | .TP | |
f504b637 | 102 | .B fmode |
25f14064 KB |
103 | The file type node's permissions as an octal value. |
104 | This keyword may only be used globally, i.e. not as part of a node | |
105 | specification line. | |
106 | .TP | |
f504b637 | 107 | .B group |
25f14064 KB |
108 | The group of the node; may be either numeric or symbolic. |
109 | .TP | |
f504b637 | 110 | .B mode |
25f14064 KB |
111 | The current node's permissions as an octal value. |
112 | This keyword may only be used locally, i.e. not for setting a value | |
113 | to be retained for future node specifications. | |
114 | .TP | |
f504b637 | 115 | .B nlink |
25f14064 | 116 | The number of hard links the node is expected to have. |
f504b637 KB |
117 | Ignored for nodes of type |
118 | .BR directory . | |
25f14064 | 119 | .TP |
f504b637 | 120 | .B owner |
25f14064 KB |
121 | The owner of the node; may be either numeric or symbolic. |
122 | .TP | |
f504b637 | 123 | .B size |
25f14064 | 124 | The size, in bytes, of the node. |
f504b637 KB |
125 | Ignored for any nodes other than type |
126 | .BR file . | |
25f14064 | 127 | .TP |
f504b637 | 128 | .B slink |
25f14064 | 129 | The file a symbolic link is expected to reference. |
f504b637 KB |
130 | Ignored for any nodes other than type |
131 | .BR link . | |
25f14064 | 132 | .TP |
f504b637 | 133 | .B type |
25f14064 | 134 | The type of the node; may be set to one of the following: |
2dd8a2d1 | 135 | .IP |
f504b637 | 136 | \fBblock\fP block special device |
2dd8a2d1 KB |
137 | .IP |
138 | \fBchar\fP character special device | |
139 | .IP | |
140 | \fBdir\fP directory | |
141 | .IP | |
142 | \fBfile\fP regular file | |
143 | .IP | |
144 | \fBlink\fP symbolic link | |
145 | .IP | |
f504b637 | 146 | \fBsocket\fP socket |
25f14064 KB |
147 | .PP |
148 | There are five types of lines in a specification. | |
149 | .PP | |
150 | The first type sets the value of a keyword and consists of three fields: | |
f504b637 KB |
151 | the string |
152 | .BR /set , | |
153 | a keyword, an equals sign, and the keyword's value. | |
154 | Whitespace is required between the | |
155 | .B set | |
156 | and the keyword, but no whitespace is allowed in the rest of the line. | |
25f14064 KB |
157 | Once a key word is set, the value remains unchanged until either |
158 | reset or unset. | |
159 | .PP | |
160 | The second type of line unsets keywords and consists of two fields: | |
f504b637 KB |
161 | the string |
162 | .B /unset | |
163 | and a keyword, separated by whitespace. | |
25f14064 | 164 | .PP |
f504b637 KB |
165 | The third type of line consists of two fields: the string |
166 | .B /ignore | |
167 | and a name, separated by whitespace. | |
25f14064 KB |
168 | This causes |
169 | .I mtree | |
170 | to ignore the referenced file as well as all files below it in the tree. | |
171 | .PP | |
172 | The fourth type of line is a node specification and consists of the name | |
173 | of a file followed by zero or more whitespace separated fields. | |
f504b637 | 174 | The name may be preceded by any amount of whitespace characters. |
25f14064 KB |
175 | Each of these fields consists of a keyword, followed by an equals |
176 | sign (=), followed by the keyword's value, without intervening whitespace. | |
177 | The values override, without changing, the current value of the | |
178 | corresponding keyword. | |
179 | .PP | |
180 | The node name may contain any of the standard file name matching characters. | |
181 | In this case, any file in the current directory with a name matching the | |
182 | pattern will have the specification applied to it. | |
183 | .PP | |
184 | All paths are relative. | |
185 | Any directory specification will cause the current directory path to | |
186 | descend one level. | |
187 | Any non-directory will be presumed to be below the current directory | |
188 | path. | |
189 | Which brings us to the last type of line in a specification: a line | |
f504b637 KB |
190 | containing just the string |
191 | .B .. | |
192 | causes the current directory path to ascend one level. | |
25f14064 | 193 | .PP |
f504b637 KB |
194 | Empty lines and lines whose first non-whitespace character is a hash mark |
195 | (``#'') are ignored. | |
25f14064 KB |
196 | .PP |
197 | .I Mtree | |
198 | exits 0 on success and >0 if an error occurred or the tree did not | |
199 | match the specification. | |
200 | .SH "SEE ALSO" | |
201 | find(1), stat(2), ftwalk(3), mkproto(8) | |
202 | .SH EXAMPLE | |
203 | .TS | |
204 | l l l l l l. | |
205 | # BSD root file system | |
206 | # | |
f504b637 KB |
207 | /set type=file |
208 | /set owner=bin | |
209 | /set group=bin | |
210 | /set dmode=755 | |
211 | /set fmode=555 | |
212 | /set links=1 | |
25f14064 KB |
213 | |
214 | bin type=directory | |
215 | adb | |
216 | cat | |
217 | \.. | |
f504b637 | 218 | /set fmode=640 |
25f14064 KB |
219 | dev |
220 | MAKEDEV | |
221 | kmem type=char group=kmem | |
222 | null type=char group=kmem | |
223 | rdk* type=char group=operator | |
224 | dk* type=block group=operator | |
225 | \.. | |
226 | etc type=directory | |
227 | disklabels type=directory | |
228 | * mode=444 | |
229 | \.. | |
230 | \.. | |
231 | .TE |