Home | History | Annotate | Download | only in mtree
History log of /src/usr.sbin/mtree/verify.c
RevisionDateAuthorComments
 1.50  11-Dec-2024  christos PR/58885: Jose Luis Duran: Fix output formatting for extra entries for
FreeBSD-9 compatibility.
 1.49  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.48  02-Dec-2023  christos branches: 1.48.2;
PR/57735: Jose Louis Duran: check if fts_read(3) had an error.
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
2dfa4b66b3d0caaaae6ce2df476b5615f8415a19)
 1.47  18-Mar-2021  cheusov mtree: use POSIX type uint32_t instead of u_int32_t
 1.46  23-Jan-2015  christos fix tools build.
 1.45  23-Jan-2015  christos attempt to reset file flags when -rr
 1.44  03-Feb-2013  christos add the ability to only output paths included in a spec file when creating
from a directory (-c)
 1.43  05-Oct-2012  christos Implement FreeBSD's "nochange" keyworld which causes the existance of a
filesystem object to be checked but none of its attiributes.(brooks)
 1.42  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.41  05-Oct-2012  christos add -q flag to silence warnings about symlinks to existing dirs (from OpenBSD
via brooks)
 1.40  25-Mar-2012  christos branches: 1.40.2;
PR/41061: Steven Drake: mtree -d complains about extra symlinks
 1.39  07-Oct-2006  elad branches: 1.39.40;
PR/28786: Jukka Salmi: mtree bug (in verify.c)

Apply patch from Peter Bex, thanks!
 1.38  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.37  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.36  27-Oct-2003  lukem branches: 1.36.2;
Overhaul how `build.sh tools' are used:

* Rename "config.h" to "nbtool_config.h" and
HAVE_CONFIG_H to HAVE_NBTOOL_CONFIG_H.
This makes in more obvious in the source when we're using
tools/compat/config.h versus "standard autoconf" config.h

* Consistently move the inclusion of nbtool_config.h to before
<sys/cdefs.h> so that the former can provide __RCSID() (et al),
and there's no need to protect those macros any more.

These changes should make it easier to "tool-ify" a program by adding:
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
#endif
to the top of the source files (for the general case).
 1.35  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.34  04-Jan-2003  lukem Change default permissions of newly created directories from
"0700, modified by umask", to "0777, modified by umask".
This matches the behaviour of mkdir(1) and just about every other command...

This change is useful when running with '-W', where the mode of the
new directory won't be changed to what's specified in the specfile.
(I.e, an UNPRIVED build, with a umask of 022).
 1.33  29-Nov-2002  grant avoid non-constant initializer errors by changing hack to workaround
gcc warning to a slightly different hack.
 1.32  08-Oct-2002  lukem Remove convoluted code to work around missing lch{flags,mod,own}();
instead, rely upon libnbcompat to provide a workaround (which returns
an error if the target is a symlink).
Should fix another MacOS X build issue due to missing lchown(2).
 1.31  06-Oct-2002  lukem - Check HAVE_LCHFLAGS for lchflags(2) support, rather than assuming
that HAVE_STRUCT_STAT_ST_FLAGS implies this.
- Set HAVE_LCHFLAGS for native builds
- Clean up {CLEAR,SET,CHANGE}FLAGS macros, and only provide if
HAVE_STRUCT_STAT_ST_FLAGS is set.

(Fixes compilation as a tool on MacOS X, noted by Allen Briggs.)
 1.30  08-Feb-2002  tv Funtion appropriately in the absence of a lchmod call on the host.
 1.29  04-Feb-2002  lukem - use lch*() instead of ch*() to change permissions, so that links in
the specfile don't confuse things. doesn't affect the default
(physical) operation, and shouldn't affect logical either.
- slightly rework how miss() is implemented so that duplicated code is
reduced and links may optionally have a mode, uname and/or gname.
 1.28  04-Feb-2002  lukem explicitly chmod(2) newly created devices
 1.27  31-Jan-2002  tv Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.26  29-Jan-2002  tv Add hooks to make mtree compilable from src/tools.
 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  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.22  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.21  18-Oct-2001  lukem complete WARNS=2 cleanup (with a bit of ickiness for the fts_open argv issue)
 1.20  09-Oct-2001  lukem Add "device" keyword, which allows the device number to be specified,
to be later checked and possibly created. Uses parsing and encoding
routines from mknod(8).
 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  09-Mar-2001  simonb ANSIfy, KNF, in preperation for more work.
 1.17  11-Feb-1999  mrg - 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.16  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.15  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.14  27-Aug-1998  ross Add {} pairs to shut up egcs.
 1.13  17-Oct-1997  lukem WARNSify, getopt returns -1 not EOF
 1.12  11-Jul-1997  mikel fix printf() formats, make explicit comparisons to NULL (gcc -Wall)
 1.11  23-Jun-1997  lukem Don't incorrectly warn about a subdirectory of 'foo' called 'bar' when there's
directory at the same level as 'foo' called 'bar'. (e.g, a definition
of usr/obj exists, and a def for usr/bin, but none for usr/obj/bin. don't
warn about usr/obj/bin because of the usr/bin entry).
Fix from enami tsugutomo <enami@ba2.so-net.or.jp> in [bin/3365]
 1.10  07-Mar-1995  cgd add an 'optional' keyword, which allows files to be in the
specification, but _not_ in the file hierarchy. contrib'd by:
Ed Symanzik <zik@enoch.cl.msu.edu>. Man page adjustment to match, and
minor man page cleanup, by me.
 1.9  07-Mar-1995  cgd add NetBSD id's
 1.8  07-Mar-1995  cgd clean up import, fix a few bugs, etc.
 1.7  02-Nov-1993  cgd make it compile...
 1.6  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.5  01-Oct-1993  jtc Use *->fts_errno instead of errno after fts_read(). The fts manpage
indicates that the fts_errno will be set to the correct value, but there
are no guarentees about errno.
 1.4  01-Aug-1993  mycroft Add RCS identifiers.
 1.3  16-Jun-1993  jtc Update source to use posix fnmatch
 1.2  10-Apr-1993  mycroft Reverse sense of fnmatch() to match POSIX.
 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.36.2.1  22-Jun-2004  tron Pull up revision 1.37 (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.39.40.3  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.39.40.2  30-Oct-2012  yamt sync with head
 1.39.40.1  17-Apr-2012  yamt sync with head
 1.40.2.2  25-Feb-2013  tls resync with head
 1.40.2.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.48.2.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed