Importing NetBSD mtree(8)

FreeBSD and NetBSD have developed mtree(8) separately for quite some time. NetBSD's mtree has a number of useful features that would be useful to our installation process. Specifically NetBSD's mtree supports full paths to file system objects rather than implying them from a prior series of directory names and ..'s. This syntax is understood by libarchive and thus bsdtar as well as makefs to allow file systems to be generated from collections of files that were installed with permissions settable by ordinary users. With the addition of NetBSD's install these can be generated during the installworld process and then applied to an image, all without root permissions.

Missing FreeBSD features in NetBSD mtree

The following features have been implemented in FreeBSD's mtree. They most likley need to be added to NetBSD's mtree before it can be imported:

Option or Field




-f spec1 -f spec2

Compare two spec files


Indent the output 4 spaces each time a directory level is descended when creating a specification with the -c option.

Mostly useless and conflicts with the NetBSD option to "set the schg and/or sappnd flags."


Don't emit comments

In projects/mtree branch. r240748


Quiet mode

In projects/mtree branch. r240749


Make some errors non-fatal warnings

NetBSD's default behavior is like -w but without the warnings. Make -w a no-op.

In projects/mtree branch. r240751


The RIPEMD160 message digest of the file

seems to be spelled rmd160(digest)

In projects/mtree branch. r240746


Make sure this file or directory exists but otherwise ignore all attributes.

Missing FreeBSD library functions






Trivial wrapper around fflagstostr()

In util.h in NetBSD vis libc in FreeBSD. Probably just add a wrapper for mtree's internal use, but could add to libc and unistd.h.

Implemented wrapper functions in mtree source directory.


Identical to strtofflags()

same issues as flags_to_string

Implemented wrapper function in mtree source directory.


Allow encoding other character sets

probably just pull the vis.3 set from NetBSD

In projects/mtree branch. Compat wrapper for unvis().


allow alternative lookups for m/uid_from_user

Grab the lot from NetBSD.

In projects/mtree branch.


reverse of user_from_uid

projects/mtree branch


allow alternative lookups for group_from_gid/gid_from_user

projects/mtree branch


reverse of group_from_gid()

projects/mtree branch

Things to verify

NetBSDMtree (last edited 2012-09-20T15:20:03+0000 by BrooksDavis)