Home | History | Annotate | Download | only in mtree
History log of /src/usr.sbin/mtree/mtree.c
RevisionDateAuthorComments
 1.51  05-Dec-2024  christos PR/58875: Jose Luis Duran: Produce consistent checksums in verification
by scanning directories in the same order as usual. While here, fix some
incorrect types.
 1.50  23-Jan-2015  christos branches: 1.50.28;
attempt to reset file flags when -rr
 1.49  24-Apr-2014  christos Pass a file pointer to write data instead of writing to stdout.
No functional change.
 1.48  08-Apr-2013  christos branches: 1.48.4;
move flags only used in main() inside main(), from Ed Schouten
 1.47  03-Feb-2013  christos add the ability to only output paths included in a spec file when creating
from a directory (-c)
 1.46  20-Dec-2012  christos move flavor to misc.c because pax needs it.
 1.45  20-Dec-2012  mlelstv joerg@: just use unsigned int please
 1.44  20-Dec-2012  christos Implement the "flavor" output discussed in tech-userlevel@, by Brooks Davis
 1.43  12-Dec-2012  christos - No "j" in the getopt string. (Brooks Davis)
 1.42  05-Oct-2012  wiz Sync usage with man page.
 1.41  05-Oct-2012  christos Implement FreeBSD's -f spec1 -f spec2 spec comparision function. This
is more useful than -C and diff because it highlights the keys that have
changed value so for example, you can see that the size of a file has
not changed but the contents have. (brooks)
 1.40  05-Oct-2012  christos add -j flag to indent directory blocks (from brooks)
 1.39  05-Oct-2012  christos add -q flag to silence warnings about symlinks to existing dirs (from OpenBSD
via brooks)
 1.38  05-Oct-2012  christos add -n flag to disable comments (brook)
 1.37  29-Aug-2011  joerg branches: 1.37.2; 1.37.8;
Use __dead and __printflike
 1.36  08-Apr-2009  wiz Sync usage with man page.
 1.35  08-Apr-2009  apb The recent addition of sorting to "mtree -C" broke some third party
scripts. Now make sorting optional, controled by the "-S" flag.
 1.34  21-Jul-2008  lukem branches: 1.34.6;
Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.33  20-Jan-2007  perry branches: 1.33.12;
Fix a typo in a boolean test, which used & instead of &&.
 1.32  22-Jul-2004  lukem Implement -M to "merge" entries, even with different types.
This can be used in /etc/security to allow special.local to override
types of entries in special (e.g, replacing a dir with a link).

Rename Wflag to mtree_Wflag, to be more "external namespace" friendly.
 1.31  20-Jun-2004  jmc Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')

Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).

Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.

Fixes PR's: PR#17762 PR#25944
 1.30  07-Aug-2003  agc branches: 1.30.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.29  23-Dec-2002  lukem Add -C, which dumps the specification with the full path name first,
and then all the other fields. (I.e, like -D except with the name
first instead of last).
Consistenly strsvis(3) encode path names (even for -C and -D).
 1.28  31-Jan-2002  tv Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.27  29-Jan-2002  tv Add hooks to make mtree compilable from src/tools.
 1.26  24-Jan-2002  lukem Add '-N dbdir', to specify that user & group lookups (via pwcache(3)) are to
be done from dbdir/master.passwd and dbdir/group, using simple text file
parsing routines.
 1.25  09-Nov-2001  lukem Generally don't need the extra byte in MAXPATHLEN sized buffers, because
pathnames are guaranteed by POSIX to be MAXPATHLEN-1 bytes long.
Kindly pointed out by Warner Losh in private email.
 1.24  07-Nov-2001  lukem User interface changes from (or inspired by) FreeBSD:
- Add -L to walk the tree `logically', by following symbolic links in
the heirarchy.
- Add -P to walk the tree `physically'. This is the current behaviour,
and the default.
- Add "-X excludes-file" to give mtree the ability to exclude files and
directories from its traversal. excludes-file contains fnmatch(3)
patterns to exclude from the walk.
- Add "md5digest" synonym for "md5".
- Add "rmd160" keyword for RMD-160 message digest, and "rmd160digest" synonym.
- Add "sha1" keyword for SHA-1 message digest, and "sha1digest" synonym.
- Don't try to compare() other attributes if the type doesn't match;
it's nothing but trouble, and no use anyway.
- In -c, only emit "/set" records if something has changed since the
previous one.

User interface changes by me:
- Check a device's parameters before checking uid/gid/mode.
- If updating (-u), modify the following to match the specification:
- Device type (retaining existing ownership).
- Symlink target.

Fixes from (or inspired by) FreeBSD:
- Use p->ftslevel instead of own code to keep track of the level ourself.
The previous code got majorly confused if fts(3) couldn't descend
into a subdir, resulting in leaf nodes getting attached to the wrong
directory.
XXX: This new method is much much more robust, even though it's not 100%
perfect; it might result in a couple of following entries in the spec
to be incorrectly tagged as missing.
- Pass a useful pathname to rlink(), so that logical (-L) traversal
doesn't confuse symlink checking.
- Consistently use MAXPATHLEN+1 sized buffers for pathnames, so that
there's room for the NUL.
- Use mtree_err() and strerror(p->fts_errno) to report errors during
the fts(3) walk.

Fixes by me:
- Remove now-unused `const char *name' argument from compare().
- Change crc_total from an int to a u_int32_t, to match usr.bin/cksum/crc.c.
- Remove trailing whitespace.
- Remove unnecessary (void) casts on functions.
- Reorder entries in the getopt() switch.
- Replace strtoq() with strtoll(), and use strtoul() appropriately.
- Renumber F_ flags to be in alphabetical order.
 1.23  03-Nov-2001  lukem - move "Wflag" global from mtree.c to spec.c, and reinstate the functionality
of tv's previous code, which skips uname or gname parsing if -W is enabled.
- rename "lineno" to "mtree_lineno", to reduce possibility of name
clashes in code that yanks in spec.c & misc.c (unlikely, but you never know)
 1.22  25-Oct-2001  lukem Add -W: don't attempt to change the perms/time/flags on existing entries, nor
set them when creating new directories. (AKA the ``don't whack'' option).
Concept suggested by Todd Vierling.
 1.21  22-Oct-2001  lukem - enforce the top-most entry must be "." and must be a directory; avoids
various potential problems when intermixing full and relative paths
- changes to make it much easier to use spec() - the specfile parser - in
other programs (via .PATHing spec.c and misc.c):
- move excludetags, includetags and keys from mtree.c to misc.c
- implement mtree_err() using vwarnx() instead of assuming name is
"mtree"
- move inotype() and nodetype() from compare.c to misc.c
- add nodetoinode(), to convert from an mtree F_* type to a
mode_t S_IF* type
- clean up #include use; don't assume "mtree.h" pulls in some
standard includes
- change spec() to take a FILE * arg (where the specfile is read from)
 1.20  05-Oct-2001  lukem cleanup tags support;
- create a typedef struct slist_t to hold stuff in (avoid stringlist(3)
because it's less portable)
- move the tag manipulate stuff into misc.c
- add matchtags(), which returns 0 if the node is explicitly excluded,
or not included if an include list is given; or 1 otherwise
- in -D, change tags support from files-only to all-non-directories

(xxx; still considering implementing tags support for -c and !-D)
 1.19  04-Oct-2001  lukem features:
- add a new keyword - "tags" - which is a comma separated list of tags
associated with that file.
- add "-E tags"; exclude files in -D output with matching tags
- add "-I tags"; only include files in -D output with matching tags
(default is to list all)

fixes:
- move all extern variable references from individual files into extern.h
- `quote' some more user-specified strings in error messages
- man page: list an options arguments in the description, and sort xrefs.
 1.18  01-Oct-2001  lukem - implement -D - dump the specfile out in a manner that's parseable
by various tools
- implement -R key - remove the given key(s) from the list of keys to print
(now it's possible with "-k type -R type" to remove all keys :)
- rename ftype() to nodetype(), and make it public
- use pwcache(3) functions instead of get{gr,pw}{nam,uid}(3)
- add dump_nodes(), which provides the guts for -D.
 1.17  22-Sep-2001  perry Add a -l flag which does "loose" permissions checks, i.e. a mode 444
matches a check for mode 644 (though obviously not the reverse). This
can be used by the nightly security run, making the output1 more useful
by having it contain fewer spurious permissions violations.

Note that I did not make -l work if you have a sgid/suid/sticky bit
set. I don't know how you could cause security trouble with more
stringent settings and a suid file, but I don't want to find out the
hard way.
 1.16  21-Mar-2001  cgd use setprogname
 1.15  09-Mar-2001  simonb ANSIfy, KNF, in preperation for more work.
 1.14  11-Feb-1999  mrg branches: 1.14.10;
- add -m and -i to change file flags more usefully.
- fix bugs in fileflags checking

all of the above from dr. lex wennmacher <wennmach@geo.Uni-Koeln.DE>
with some error fixes from egcs via myself.
 1.13  05-Dec-1998  itohy getcwd() is not equivalent of getwd() if you want to print an error message.
 1.12  03-Dec-1998  thorpej Use getcwd(3) instead of getwd(3).
 1.11  10-Oct-1998  mrg add support for 4.4BSD file flags. we take a `flags=xxx' parameter,
using the same style of naming as chflags, ls & xinstall use, plus an
additional `none' to turn off a default setting.
 1.10  08-Oct-1998  wsanchez Use u_int32_t rather than Sys-V u_long.
Rename err() to mtree_err(), to avoid conflict with libc.
 1.9  17-Oct-1997  lukem WARNSify, getopt returns -1 not EOF
 1.8  20-Aug-1997  agc Add -U flag, checking for mismatch. This is the same as the old -u flag,
except that an error which was corrected is deemed not to be an error.

Necessary for use in the FreeBSD ports system.
 1.7  05-Sep-1996  thorpej Add a missing "break;", pointed out by Chris Demetriou.
 1.6  05-Sep-1996  mycroft Add a `-t' option to update time stamps.
 1.5  07-Mar-1995  cgd branches: 1.5.6;
add NetBSD id's
 1.4  07-Mar-1995  cgd clean up import, fix a few bugs, etc.
 1.3  02-Nov-1993  cgd latest mtree from uunet. doesn't compile, but that'll be fixed soon.
(want to have 'pseudo-virgin' sources, for when fixed fnmatch stuff
is released...)
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2  07-Mar-1995  cgd from 4.4-Lite
 1.1.1.1  21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.5.6.1  10-Dec-1996  mycroft From trunk:
Don`t record sizes for things other than regular files.
Add a `-t' option to update time stamps.
 1.14.10.1  09-Dec-2001  he Pull up revision 1.17 (via patch, requested by lukem):
Add an ``-l'' flag which does ``loose'' permission checks.
 1.30.2.1  22-Jun-2004  tron Pull up revision 1.31 (requested by jmc in ticket #527):
Completely rework how tools/compat is done. Purge all uses/references to
_NETBSD_SOURCE as this makes cross building from older/newer versions of
NetBSD harder, not easier (and also makes the resulting tools 'different')
Wrap all required code with the inclusion of nbtool_config.h, attempt to
only use POSIX code in all places (or when reasonable test w. configure and
provide definitions: ala u_int, etc).
Reviewed by lukem. Tested on FreeBSD 4.9, Redhat Linux ES3, NetBSD 1.6.2 x86
NetBSD current (x86 and amd64) and Solaris 9.
Fixes PR's: PR#17762 PR#25944
 1.33.12.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.34.6.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.37.8.4  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.37.8.3  23-Jun-2013  tls resync from head
 1.37.8.2  25-Feb-2013  tls resync with head
 1.37.8.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.37.2.4  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.37.2.3  23-Jan-2013  yamt sync with head
 1.37.2.2  16-Jan-2013  yamt sync with (a bit old) head
 1.37.2.1  30-Oct-2012  yamt sync with head
 1.48.4.1  10-Aug-2014  tls Rebase.
 1.50.28.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed