An
mtree file consists of a series of lines, each providing information about a single filesystem object. Leading whitespace is always ignored.
When encoding file or pathnames, any backslash character or character outside of the 95 printable ASCII characters must be encoded as a a backslash followed by three octal digits. When reading mtree files, any appearance of a backslash followed by three octal digits should be converted into the corresponding character.
Each line is interpreted independently as one of the following types:
Signature
The first line of any mtree file must begin with “#mtree”. If a file contains any full path entries, the first line should begin with “#mtree v2.0”, otherwise, the first line should begin with “#mtree v1.0”.
Blank
Blank lines are ignored.
Comment
Lines beginning with # are ignored.
Special
Lines beginning with / are special commands that influence the interpretation of later lines.
Relative
If the first whitespace-delimited word has no / characters, it is the name of a file in the current directory. Any relative entry that describes a directory changes the current directory.
dot-dot
As a special case, a relative entry with the filename .. changes the current directory to the parent directory. Options on dot-dot entries are always ignored.
Full
If the first whitespace-delimited word has a / character after the first character, it is the pathname of a file relative to the starting directory. There can be multiple full entries describing the same file.
Some tools that process
mtree files may require that multiple lines describing the same file occur consecutively. It is not permitted for the same file to be mentioned using both a relative and a full file specification.