.\" Copyright (c) 1989, 1990 The Regents of the University of California.
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\" must display the following acknowledgement:
.\" This product includes software developed by the University of
.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" @(#)mtree.1 5.10 (Berkeley) 7/30/91
.Nd map a directory hierarchy
compares a directory hierarchy against a specification for a
By default, the specification is read from the standard input.
verifies that the tree rooted in the current directory matches the
Messages are written to standard output for any files whose
characteristics do not match those of the specification, or which are
missing from either the specification or the tree.
The options are as follows:
Print a specification for the tree to standard output.
Ignore everything except directory type files.
Don't object to files that are in the tree but not in the specification.
Read the specification from
instead of from standard input.
Traverse the tree rooted in
instead of the current directory.
Remove any files in the tree that are not described in the
Modify the owner, group, and permissions of existing files to match
the specification, as well as create any missing directories.
Owner, group, and permissions must all be specified for missing
directories to be created.
Don't descend below any mount points.
Specifications are mostly composed of ``keywords'', i.e. strings that
that specify values relating to files.
No keywords have default values, and if a keyword has no set value no
checks based on it are performed.
Currently supported keywords are as follows:
The checksum of the file using the algorithm specified by
Causes the hierarchy below the file to be ignored.
The group of the file; may be either numeric or symbolic.
The current file's permissions as an absolute (octal) or symbolic
The number of hard links the file is expected to have.
The owner of the file; may be either numeric or symbolic.
The size, in bytes, of the file.
The file a symbolic link is expected to reference.
The last modification time of the file.
The type of the file; may be set to any one of the following:
.Bl -tag -width Cm -compact
There are four types of lines in a specification.
The first type of line sets a ``global'' value for a keyword, and
consists of a leading ``/set'' followed by whitespace, followed by
sets of keyword/value pairs, separated by whitespace.
Keyword/value pairs consist of a keyword, followed by a equals sign
(``=''), followed by a value, without intervening whitespace.
Once a keyword has been set, its value remains unchanged until either
The second type of line unsets keywords and consists of a leading
``/unset'', followed by whitespace, followed by one or more keywords,
The third type of line is a file specification and consists of a file
name, followed by whitespace, followed by zero or more whitespace
separated keyword/value pairs.
The file name may be preceded by any number of whitespace characters.
The file name may contain any of the standard file name matching
characters (``['', ``]'', ``?'' or ``*''), in which case files
in the hierarchy will be associated with the first pattern that
Each of the keyword/value pairs consist of a keyword, followed by an
equals sign (``=''), followed by the keyword's value, without intervening
These values override, without changing, the global value of the
Specifying a directory will cause subsequent files to be searched
for in that directory hierarchy.
Which brings us to the last type of line in a specification: a line
containing only the string
causes the current directory
path to ascend one level.
Empty lines and lines whose first non-whitespace character is a hash
mark (``#'') are ignored.
exits with a status of 0 on success and >0 if an error occurred or the
tree did not match the specification.
.Bl -tag -width /etc/mtree -compact
system specification directory
keyword is not yet implemented.
keyword should be specifiable in human readable terms.
.Bd -literal -offset indent -compact
# fs: /a/staff/rick/mybin
# date: Fri May 25 12:26:57 1990
/set group=staff mode=0555 nlink=1 owner=rick type=file
df group=operator mode=02555 size=20480
ps group=kmem mode=02555 size=54272
rcp owner=root mode=04555 size=79872
/set group=wheel mode=0444 nlink=1 owner=rick type=file
manpages type=dir mode=0775 nlink=2 size=1024