Home | History | Annotate | Download | only in mtree
History log of /src/usr.sbin/mtree/misc.c
RevisionDateAuthorComments
 1.35  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.34  20-Dec-2012  christos branches: 1.34.42;
move flavor to misc.c because pax needs it.
 1.33  12-Dec-2012  christos - two entries for rmd160digest in misc.c (Brooks Davis)
 1.32  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.31  05-Oct-2012  christos account for differences in digest names
 1.30  18-Jan-2009  lukem branches: 1.30.8; 1.30.14;
fix -Wsign-compare issues
 1.29  16-Oct-2006  christos c99 initializers
 1.28  14-Oct-2006  christos PR/34818: rad at twig dot com: Recognize solaris door files.
 1.27  29-Sep-2005  tron The list of keywords must be sorted because it is search with bsearch(3).
Correcting this makes mtree(8) work again under Solaris.
 1.26  24-Aug-2005  elad Add SHA2 support in mtree.
 1.25  20-Jun-2004  jmc branches: 1.25.2;
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.24  07-Aug-2003  agc branches: 1.24.2;
Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.23  19-Feb-2002  lukem inotype() only needs to understand S_ types, not the F_ types
 1.22  31-Jan-2002  tv Protect __RCSID and __COPYRIGHT from being invoked if not defined.
 1.21  29-Jan-2002  tv Add hooks to make mtree compilable from src/tools.
 1.20  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.19  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.18  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.17  18-Oct-2001  lukem make this mostly WARNS=2 safe
 1.16  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.15  05-Oct-2001  lukem - support "all" as a valid keyword for -k, -K and -R.
- parsekey(): support "all" as a keyword which returns a value with all bits
set that pertain to a valid keyword.
- dump_nodes():
- only print out a keyword if it's requested AND it's set in the node
- UNAME falls back to UID if the user name can't be determined
- GNAME falls back to GID if the group name can't be determined
- rework man page:
- use Sy instead of Cm
- use Pq, Dq, Ql, etc instead of ``...''
 1.14  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.13  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.12  11-Sep-2001  thorpej Fix printf format.
 1.11  10-Sep-2001  lukem replace home-grown parser with fparseln()
 1.10  18-Jul-2001  lukem - add parsetype() (a la parsekey()) to parse the "type=xxx" arg. this improves
the error detection for invalid types, as well as shrinking binary size
- implement inotype() using ftype(), rather than duplicating the switch
- change "char *" arguments to "const char *"
 1.9  09-Mar-2001  simonb ANSIfy, KNF, in preperation for more work.
 1.8  06-Dec-1998  jwise Add an `md5' keyword to mtree, which takes as an argument the MD5 cryptographic
checksum of the file in question, optionally preceeded by `0x'.

This has been tested, and does work, AFAICT. There is currently no md5 equivalent
of the '-s' flag for use with checksum.
 1.7  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.6  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.5  17-Oct-1997  lukem WARNSify, getopt returns -1 not EOF
 1.4  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.3  07-Mar-1995  cgd add NetBSD id's
 1.2  07-Mar-1995  cgd clean up import, fix a few bugs, etc.
 1.1  02-Nov-1993  cgd branches: 1.1.1;
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.1.1.1  07-Mar-1995  cgd from 4.4-Lite
 1.24.2.1  22-Jun-2004  tron Pull up revision 1.25 (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.25.2.2  01-Oct-2005  snj Pull up following revision(s) (requested by tron in ticket #839):
usr.sbin/mtree/misc.c: revision 1.27
The list of keywords must be sorted because it is search with bsearch(3).
Correcting this makes mtree(8) work again under Solaris.
 1.25.2.1  12-Sep-2005  tron Apply patch (requested by elad in ticket #755):
Add support for SHA2 in mtree(8).
 1.30.14.2  25-Feb-2013  tls resync with head
 1.30.14.1  20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.30.8.3  23-Jan-2013  yamt sync with head
 1.30.8.2  16-Jan-2013  yamt sync with (a bit old) head
 1.30.8.1  30-Oct-2012  yamt sync with head
 1.34.42.1  02-Aug-2025  perseant Sync with HEAD

RSS XML Feed