mtree(8) reporting of file modes

Lowell Gilbert lgfbsd at be-well.ilk.org
Tue Mar 6 23:29:56 UTC 2012


David Wolfskill <david at catwhisker.org> writes:

> * mode is set to the (masked) mode of the (immediately) enclosing
>   directory when it is visited in pre-order.  (This is done in statd().)

Not quite. It looks like when statd() is called on the enclosing
directory itself, it walks all of the children to find the most common
values, and issues a "/set" line to establish defaults. When it is
subsequently called for each of the children in their own right, it only
needs to list the properties that differ.

Which isn't really illogical: it substantially reduces the size of the
output (and vastly improves the readability-by-humans) in exchange for
having to traverse the list of file entries twice.

> Maybe I'm confused, but certainly for my present purposes, and likely in
> general, I'd think it would make sense to just always report the file
> mode.

> Another alternative, in case there are use cases for the existing
> behavior, would be to provide either another "key" or a command-line
> flag that says "give me all the modes".

> Am I the only one who would find such a change useful?

Well, it's definitely only useful if you're using something besides
mtree itself to parse the output file. I like having the defaults,
because most of the time all of the files in a directory have the same
permissions, and there are fewer distractions for my eye.

I guess the question is why do *you* find the "/set" lines to (even just
occasionally) not be useful?

Be well.


More information about the freebsd-hackers mailing list