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