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