I have a small issue with mtree(8), that I am not quite sure how to fix best.
I would like to create directory hierachies from mtree spec files, but restrict this to selected hierachies (where the mtree files contain a bit more). Example: mkdir /tmp/test && cd /tmp/test && mtree -f /etc/mtree/special -dqUW Now I get this in /tmp/test: drwxr-xr-x 3 root wheel 48 Jun 2 16:04 dev drwxr-xr-x 13 root wheel 528 Jun 2 16:04 etc drwxr-xr-x 2 root wheel 0 Jun 2 16:04 root drwxr-xr-x 2 root wheel 0 Jun 2 16:04 sbin drwxr-xr-x 9 root wheel 336 Jun 2 16:04 usr drwxr-xr-x 14 root wheel 576 Jun 2 16:04 var What if I want to restrict the created subdirectories to /tmp/test/var ? Should be easy, there are -O onlypaths and -X exclude-file options to mtree. The files are supposed to contain lines of fnmatch(3) patters, which are evaluated with FNM_PATHNAME option against the to-be-created file/dir. So in above example I could create a "onlyfile" containing something like: ./var ./var/* ./var/*/* ./var/*/*/* ./var/*/*/*/* ./var/*/*/*/*/* or so I thought - but (a) it does not work and (b) I don't know how deep some future mtree spec file will be below var. Am I missing some easy trick? Anything obvious I did wrong (so it does not work but should if I do it right)? I am considering to add a variant of -O that specifies directory prefixes and skips all files outside of one of the specified dirs, so my invocation above would become: mkdir /tmp/test && cd /tmp/test && \ mtree -f /etc/mtree/special -dqUW -D ./var Martin