History log of /netbsd-current/usr.sbin/mtree/create.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.78 24-Apr-2024 christos

For the NetBSD tools build we provide our own fts.h not FreeBSD's so the
comparator should have the NetBSD signature.


# 1.77 02-Dec-2023 christos

PR/57735: Jose Louis Duran: check if fts_read(3) had an error.
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
2dfa4b66b3d0caaaae6ce2df476b5615f8415a19)


Revision tags: netbsd-9-4-RELEASE netbsd-10-0-RELEASE netbsd-10-0-RC6 netbsd-10-0-RC5 netbsd-10-0-RC4 netbsd-10-0-RC3 netbsd-10-0-RC2 netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.76 18-Nov-2018 sevan

Adjust test, we only want to return the structure member if the result is not NULL.

Heads up by Sascha Wildner @ DragonFly BSD.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.75 31-Dec-2017 christos

branches: 1.75.2; 1.75.4;
factor out common code from Poul-Henning Kamp.


# 1.74 14-Dec-2017 christos

use uintmax_t for nlink_t from FreeBSD


Revision tags: netbsd-7-2-RELEASE netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.73 24-Apr-2014 christos

branches: 1.73.2; 1.73.16;
Pass a file pointer to write data instead of writing to stdout.
No functional change.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.72 17-Oct-2013 christos

branches: 1.72.2;
Our <sys/param.h> ends up calling header files that define intmax_t. This
should not be the case (but >sys/param.h> is not a standard header so all bets
are off). FreeBSD's does not, so explicitly include <stdint.h> to get it.


# 1.71 16-Oct-2013 christos

Restore old behavior of not printing sizes for directories, since it varies
depending on filesystem implementation. (Brooks Davis)


# 1.70 09-Sep-2013 christos

use intmax_t instead of long long. fixes wrong cast for time_t.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.69 03-Feb-2013 christos

add the ability to only output paths included in a spec file when creating
from a directory (-c)


Revision tags: yamt-pagecache-base8
# 1.68 20-Dec-2012 christos

Implement the "flavor" output discussed in tech-userlevel@, by Brooks Davis


# 1.67 15-Dec-2012 christos

make us compatible with FreeBSD (for -n) (Brooks Davies)


Revision tags: yamt-pagecache-base7
# 1.66 12-Dec-2012 christos

-n is incorrectly supressing the ".." lines. (Brooks Davis)


Revision tags: yamt-pagecache-base6
# 1.65 05-Oct-2012 christos

Allow uid and uname or gid and gname to both be printed while
preserving the behavior of falling back to [ug]id when the name is not
resolvable. (brooks)


# 1.64 05-Oct-2012 christos

clarify seconds.09nanoseconds format (brooks)


# 1.63 05-Oct-2012 christos

add -j flag to indent directory blocks (from brooks)


# 1.62 05-Oct-2012 christos

add -n flag to disable comments (brook)


# 1.61 05-Oct-2012 christos

our fts compare routine is less constified.


# 1.60 05-Oct-2012 christos

more const
check if we support SHA384 before using
(brooks)


# 1.59 15-Jul-2012 spz

branches: 1.59.2;
resource leak (Coverity issues 274383 and 274384)


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.58 03-Apr-2009 apb

branches: 1.58.6;
Make "mtree -C" sort its output.

As the input is read from a specfile into a tree of linked lists,
keep each linked list sorted. The sort order is the same as that
already used by "mtree -c": directories sort after non-directories, but
otherwise names are sorted in the order used by strcmp().


# 1.57 01-Feb-2009 hubertf

branches: 1.57.2;
When {MD5,RMD160,SHA1,SHA256_,SHA384_,SHA512_}File fail, use errno
to print what's actually wrong


# 1.56 28-Dec-2008 christos

fix dev_t formats.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.55 05-Dec-2007 christos

PR/37482: Malcolm Herbert: mtree does not check for getlogin() returning null
in spec create


# 1.54 19-Nov-2007 rillig

Renamed dsort to dcmp, since it doesn't sort, it only compares.


# 1.53 19-Nov-2007 rillig

Even on non-BSD systems, the "-R all" option should disable printing of
the "time" attribute. Noticed by Malcolm Herbert on tech-pkg.


# 1.52 18-Oct-2007 christos

cast to long explicitly for the compat build


Revision tags: matt-mips64-base
# 1.51 04-Feb-2007 elad

branches: 1.51.4;
The hashing routines (MD5File() and co.) can do dynamic allocation, so
take advantage of that instead of an ugly hard-coded MAXHASHLEN limit
that needs updating.

I think this was suggested by cube@ years ago.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.50 30-Oct-2006 christos

kill crypto/rmd160.h and crypto/sha2.h, and instead make symlinks to
/usr/include from /usr/include/sys. This makes all the one way hash
header handling identical.


Revision tags: abandoned-netbsd-4-base
# 1.49 24-Sep-2005 elad

Use crypto/rmd160.h.


# 1.48 02-Sep-2005 elad

Use MAXHASHLEN here too.


# 1.47 24-Aug-2005 elad

Add SHA2 support in mtree.


Revision tags: netbsd-3-base
# 1.46 01-Dec-2004 lukem

branches: 1.46.2;
strsvis(3) encode & decode the "link=" value (symlink target).


# 1.45 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


Revision tags: netbsd-2-0-base
# 1.44 27-Oct-2003 lukem

branches: 1.44.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.43 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.


Revision tags: fvdl_fs64_base
# 1.42 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.41 29-Nov-2002 grant

avoid non-constant initializer errors by changing hack to workaround
gcc warning to a slightly different hack.


# 1.40 08-Aug-2002 soren

Remove extraneous \n's in {err,warn}{,x} that used to be printfs.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.39 31-Jan-2002 tv

Protect __RCSID and __COPYRIGHT from being invoked if not defined.


# 1.38 29-Jan-2002 tv

Add hooks to make mtree compilable from src/tools.


# 1.37 10-Nov-2001 lukem

provide the ability to remove support for generating or checking various
digests by #define-ing NO_MD5, NO_RMD160, or NO_SHA1. the keywords are
still parsed.


# 1.36 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.35 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.34 18-Oct-2001 lukem

complete WARNS=2 cleanup (with a bit of ickiness for the fts_open argv issue)


# 1.33 18-Oct-2001 lukem

make this mostly WARNS=2 safe


# 1.32 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.31 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.30 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.29 09-Mar-2001 simonb

ANSIfy, KNF, in preperation for more work.


# 1.28 20-Feb-2001 hubertf

Remove all the "#ifdef __APPLE__" code, to make this actually
build again on Darwin. The code in question is outdated.

OK'd by Wilfredo Sanchez wsanchez@MIT.EDU.


# 1.27 15-Oct-2000 is

LP64 format string cleanup. Problem reported by garbled.


# 1.26 11-Oct-2000 is

More format string cleanups by sommerfeld.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.25 01-Dec-1999 wennmach

branches: 1.25.4;
Now that we have strsvis, use it.


# 1.24 07-Nov-1999 wennmach

Encode file names using strvis(3) when creating a specification.
Escape white space characters and `#' characters. Do the inverse
when reading specs.

This is a temporary fix until we have strzouvis(3) (or some such)
which is an improved version of strvis (taking an additional list
of characters to encode).

Fixes PR 5006 and PR 7663


Revision tags: comdex-fall-1999-base
# 1.23 06-Jul-1999 christos

branches: 1.23.4;
portability fixes:
- don't use timespecs in struct stat on non 4.4BSD systems
- don't assume that tv_sec is a time_t


# 1.22 06-Jul-1999 hubertf

Actually generate MD5 checksums, as reported in PR 7928.
Approved by Dr. Lex Wennmacher <wennmach@geo.Uni-Koeln.DE>


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 11-Feb-1999 mrg

branches: 1.21.2;
- 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.20 19-Dec-1998 christos

Appease gcc-2.8.1, make printf formats more portable.


# 1.19 03-Nov-1998 christos

Namespace protection against MAXUID etc.


# 1.18 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.17 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.16 30-Aug-1998 nathanw

Add braces to satisfy egcs.


# 1.15 27-Aug-1998 ross

Add {} pairs to shut up egcs.


# 1.14 06-Jul-1998 mrg

- use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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 05-Sep-1996 mycroft

Only record sizes for regular files.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.10 01-Feb-1996 jtc

branches: 1.10.4;
Rename struct timespec fields to conform to POSIX.1b


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.9 07-Mar-1995 cgd

add NetBSD id's


# 1.8 07-Mar-1995 cgd

clean up import, fix a few bugs, etc.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 27-Mar-1994 cgd

off_t exp.


# 1.6 17-Nov-1993 cgd

make things a bit more consistent


# 1.5 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.4 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.3 06-Aug-1993 deraadt

update for fts library change


# 1.2 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.77 02-Dec-2023 christos

PR/57735: Jose Louis Duran: check if fts_read(3) had an error.
(FreeBSD commit https://github.com/freebsd/freebsd-src/commit/\
2dfa4b66b3d0caaaae6ce2df476b5615f8415a19)


Revision tags: netbsd-10-0-RC1 netbsd-10-base netbsd-9-3-RELEASE cjep_sun2x-base1 cjep_sun2x-base cjep_staticlib_x-base1 netbsd-9-2-RELEASE cjep_staticlib_x-base netbsd-9-1-RELEASE phil-wifi-20200421 phil-wifi-20200411 is-mlppp-base phil-wifi-20200406 netbsd-9-0-RELEASE netbsd-9-0-RC2 netbsd-9-0-RC1 phil-wifi-20191119 netbsd-9-base phil-wifi-20190609 pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.76 18-Nov-2018 sevan

Adjust test, we only want to return the structure member if the result is not NULL.

Heads up by Sascha Wildner @ DragonFly BSD.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.75 31-Dec-2017 christos

branches: 1.75.2; 1.75.4;
factor out common code from Poul-Henning Kamp.


# 1.74 14-Dec-2017 christos

use uintmax_t for nlink_t from FreeBSD


Revision tags: netbsd-7-2-RELEASE netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.73 24-Apr-2014 christos

branches: 1.73.2; 1.73.16;
Pass a file pointer to write data instead of writing to stdout.
No functional change.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.72 17-Oct-2013 christos

branches: 1.72.2;
Our <sys/param.h> ends up calling header files that define intmax_t. This
should not be the case (but >sys/param.h> is not a standard header so all bets
are off). FreeBSD's does not, so explicitly include <stdint.h> to get it.


# 1.71 16-Oct-2013 christos

Restore old behavior of not printing sizes for directories, since it varies
depending on filesystem implementation. (Brooks Davis)


# 1.70 09-Sep-2013 christos

use intmax_t instead of long long. fixes wrong cast for time_t.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.69 03-Feb-2013 christos

add the ability to only output paths included in a spec file when creating
from a directory (-c)


Revision tags: yamt-pagecache-base8
# 1.68 20-Dec-2012 christos

Implement the "flavor" output discussed in tech-userlevel@, by Brooks Davis


# 1.67 15-Dec-2012 christos

make us compatible with FreeBSD (for -n) (Brooks Davies)


Revision tags: yamt-pagecache-base7
# 1.66 12-Dec-2012 christos

-n is incorrectly supressing the ".." lines. (Brooks Davis)


Revision tags: yamt-pagecache-base6
# 1.65 05-Oct-2012 christos

Allow uid and uname or gid and gname to both be printed while
preserving the behavior of falling back to [ug]id when the name is not
resolvable. (brooks)


# 1.64 05-Oct-2012 christos

clarify seconds.09nanoseconds format (brooks)


# 1.63 05-Oct-2012 christos

add -j flag to indent directory blocks (from brooks)


# 1.62 05-Oct-2012 christos

add -n flag to disable comments (brook)


# 1.61 05-Oct-2012 christos

our fts compare routine is less constified.


# 1.60 05-Oct-2012 christos

more const
check if we support SHA384 before using
(brooks)


# 1.59 15-Jul-2012 spz

branches: 1.59.2;
resource leak (Coverity issues 274383 and 274384)


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.58 03-Apr-2009 apb

branches: 1.58.6;
Make "mtree -C" sort its output.

As the input is read from a specfile into a tree of linked lists,
keep each linked list sorted. The sort order is the same as that
already used by "mtree -c": directories sort after non-directories, but
otherwise names are sorted in the order used by strcmp().


# 1.57 01-Feb-2009 hubertf

branches: 1.57.2;
When {MD5,RMD160,SHA1,SHA256_,SHA384_,SHA512_}File fail, use errno
to print what's actually wrong


# 1.56 28-Dec-2008 christos

fix dev_t formats.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.55 05-Dec-2007 christos

PR/37482: Malcolm Herbert: mtree does not check for getlogin() returning null
in spec create


# 1.54 19-Nov-2007 rillig

Renamed dsort to dcmp, since it doesn't sort, it only compares.


# 1.53 19-Nov-2007 rillig

Even on non-BSD systems, the "-R all" option should disable printing of
the "time" attribute. Noticed by Malcolm Herbert on tech-pkg.


# 1.52 18-Oct-2007 christos

cast to long explicitly for the compat build


Revision tags: matt-mips64-base
# 1.51 04-Feb-2007 elad

branches: 1.51.4;
The hashing routines (MD5File() and co.) can do dynamic allocation, so
take advantage of that instead of an ugly hard-coded MAXHASHLEN limit
that needs updating.

I think this was suggested by cube@ years ago.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.50 30-Oct-2006 christos

kill crypto/rmd160.h and crypto/sha2.h, and instead make symlinks to
/usr/include from /usr/include/sys. This makes all the one way hash
header handling identical.


Revision tags: abandoned-netbsd-4-base
# 1.49 24-Sep-2005 elad

Use crypto/rmd160.h.


# 1.48 02-Sep-2005 elad

Use MAXHASHLEN here too.


# 1.47 24-Aug-2005 elad

Add SHA2 support in mtree.


Revision tags: netbsd-3-base
# 1.46 01-Dec-2004 lukem

branches: 1.46.2;
strsvis(3) encode & decode the "link=" value (symlink target).


# 1.45 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


Revision tags: netbsd-2-0-base
# 1.44 27-Oct-2003 lukem

branches: 1.44.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.43 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.


Revision tags: fvdl_fs64_base
# 1.42 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.41 29-Nov-2002 grant

avoid non-constant initializer errors by changing hack to workaround
gcc warning to a slightly different hack.


# 1.40 08-Aug-2002 soren

Remove extraneous \n's in {err,warn}{,x} that used to be printfs.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.39 31-Jan-2002 tv

Protect __RCSID and __COPYRIGHT from being invoked if not defined.


# 1.38 29-Jan-2002 tv

Add hooks to make mtree compilable from src/tools.


# 1.37 10-Nov-2001 lukem

provide the ability to remove support for generating or checking various
digests by #define-ing NO_MD5, NO_RMD160, or NO_SHA1. the keywords are
still parsed.


# 1.36 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.35 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.34 18-Oct-2001 lukem

complete WARNS=2 cleanup (with a bit of ickiness for the fts_open argv issue)


# 1.33 18-Oct-2001 lukem

make this mostly WARNS=2 safe


# 1.32 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.31 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.30 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.29 09-Mar-2001 simonb

ANSIfy, KNF, in preperation for more work.


# 1.28 20-Feb-2001 hubertf

Remove all the "#ifdef __APPLE__" code, to make this actually
build again on Darwin. The code in question is outdated.

OK'd by Wilfredo Sanchez wsanchez@MIT.EDU.


# 1.27 15-Oct-2000 is

LP64 format string cleanup. Problem reported by garbled.


# 1.26 11-Oct-2000 is

More format string cleanups by sommerfeld.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.25 01-Dec-1999 wennmach

branches: 1.25.4;
Now that we have strsvis, use it.


# 1.24 07-Nov-1999 wennmach

Encode file names using strvis(3) when creating a specification.
Escape white space characters and `#' characters. Do the inverse
when reading specs.

This is a temporary fix until we have strzouvis(3) (or some such)
which is an improved version of strvis (taking an additional list
of characters to encode).

Fixes PR 5006 and PR 7663


Revision tags: comdex-fall-1999-base
# 1.23 06-Jul-1999 christos

branches: 1.23.4;
portability fixes:
- don't use timespecs in struct stat on non 4.4BSD systems
- don't assume that tv_sec is a time_t


# 1.22 06-Jul-1999 hubertf

Actually generate MD5 checksums, as reported in PR 7928.
Approved by Dr. Lex Wennmacher <wennmach@geo.Uni-Koeln.DE>


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 11-Feb-1999 mrg

branches: 1.21.2;
- 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.20 19-Dec-1998 christos

Appease gcc-2.8.1, make printf formats more portable.


# 1.19 03-Nov-1998 christos

Namespace protection against MAXUID etc.


# 1.18 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.17 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.16 30-Aug-1998 nathanw

Add braces to satisfy egcs.


# 1.15 27-Aug-1998 ross

Add {} pairs to shut up egcs.


# 1.14 06-Jul-1998 mrg

- use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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 05-Sep-1996 mycroft

Only record sizes for regular files.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.10 01-Feb-1996 jtc

branches: 1.10.4;
Rename struct timespec fields to conform to POSIX.1b


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.9 07-Mar-1995 cgd

add NetBSD id's


# 1.8 07-Mar-1995 cgd

clean up import, fix a few bugs, etc.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 27-Mar-1994 cgd

off_t exp.


# 1.6 17-Nov-1993 cgd

make things a bit more consistent


# 1.5 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.4 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.3 06-Aug-1993 deraadt

update for fts library change


# 1.2 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


Revision tags: pgoyette-compat-20190127 pgoyette-compat-20190118 pgoyette-compat-1226 pgoyette-compat-1126
# 1.76 18-Nov-2018 sevan

Adjust test, we only want to return the structure member if the result is not NULL.

Heads up by Sascha Wildner @ DragonFly BSD.


Revision tags: pgoyette-compat-1020 pgoyette-compat-0930 pgoyette-compat-0906 pgoyette-compat-0728 phil-wifi-base pgoyette-compat-0625 pgoyette-compat-0521 pgoyette-compat-0502 pgoyette-compat-0422 pgoyette-compat-0415 pgoyette-compat-0407 pgoyette-compat-0330 pgoyette-compat-0322 pgoyette-compat-0315 pgoyette-compat-base
# 1.75 31-Dec-2017 christos

branches: 1.75.2;
factor out common code from Poul-Henning Kamp.


# 1.74 14-Dec-2017 christos

use uintmax_t for nlink_t from FreeBSD


Revision tags: netbsd-7-2-RELEASE netbsd-8-0-RELEASE netbsd-8-0-RC2 netbsd-8-0-RC1 netbsd-7-1-2-RELEASE netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.73 24-Apr-2014 christos

branches: 1.73.2; 1.73.16;
Pass a file pointer to write data instead of writing to stdout.
No functional change.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.72 17-Oct-2013 christos

branches: 1.72.2;
Our <sys/param.h> ends up calling header files that define intmax_t. This
should not be the case (but >sys/param.h> is not a standard header so all bets
are off). FreeBSD's does not, so explicitly include <stdint.h> to get it.


# 1.71 16-Oct-2013 christos

Restore old behavior of not printing sizes for directories, since it varies
depending on filesystem implementation. (Brooks Davis)


# 1.70 09-Sep-2013 christos

use intmax_t instead of long long. fixes wrong cast for time_t.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.69 03-Feb-2013 christos

add the ability to only output paths included in a spec file when creating
from a directory (-c)


Revision tags: yamt-pagecache-base8
# 1.68 20-Dec-2012 christos

Implement the "flavor" output discussed in tech-userlevel@, by Brooks Davis


# 1.67 15-Dec-2012 christos

make us compatible with FreeBSD (for -n) (Brooks Davies)


Revision tags: yamt-pagecache-base7
# 1.66 12-Dec-2012 christos

-n is incorrectly supressing the ".." lines. (Brooks Davis)


Revision tags: yamt-pagecache-base6
# 1.65 05-Oct-2012 christos

Allow uid and uname or gid and gname to both be printed while
preserving the behavior of falling back to [ug]id when the name is not
resolvable. (brooks)


# 1.64 05-Oct-2012 christos

clarify seconds.09nanoseconds format (brooks)


# 1.63 05-Oct-2012 christos

add -j flag to indent directory blocks (from brooks)


# 1.62 05-Oct-2012 christos

add -n flag to disable comments (brook)


# 1.61 05-Oct-2012 christos

our fts compare routine is less constified.


# 1.60 05-Oct-2012 christos

more const
check if we support SHA384 before using
(brooks)


# 1.59 15-Jul-2012 spz

branches: 1.59.2;
resource leak (Coverity issues 274383 and 274384)


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.58 03-Apr-2009 apb

branches: 1.58.6;
Make "mtree -C" sort its output.

As the input is read from a specfile into a tree of linked lists,
keep each linked list sorted. The sort order is the same as that
already used by "mtree -c": directories sort after non-directories, but
otherwise names are sorted in the order used by strcmp().


# 1.57 01-Feb-2009 hubertf

branches: 1.57.2;
When {MD5,RMD160,SHA1,SHA256_,SHA384_,SHA512_}File fail, use errno
to print what's actually wrong


# 1.56 28-Dec-2008 christos

fix dev_t formats.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.55 05-Dec-2007 christos

PR/37482: Malcolm Herbert: mtree does not check for getlogin() returning null
in spec create


# 1.54 19-Nov-2007 rillig

Renamed dsort to dcmp, since it doesn't sort, it only compares.


# 1.53 19-Nov-2007 rillig

Even on non-BSD systems, the "-R all" option should disable printing of
the "time" attribute. Noticed by Malcolm Herbert on tech-pkg.


# 1.52 18-Oct-2007 christos

cast to long explicitly for the compat build


Revision tags: matt-mips64-base
# 1.51 04-Feb-2007 elad

branches: 1.51.4;
The hashing routines (MD5File() and co.) can do dynamic allocation, so
take advantage of that instead of an ugly hard-coded MAXHASHLEN limit
that needs updating.

I think this was suggested by cube@ years ago.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.50 30-Oct-2006 christos

kill crypto/rmd160.h and crypto/sha2.h, and instead make symlinks to
/usr/include from /usr/include/sys. This makes all the one way hash
header handling identical.


Revision tags: abandoned-netbsd-4-base
# 1.49 24-Sep-2005 elad

Use crypto/rmd160.h.


# 1.48 02-Sep-2005 elad

Use MAXHASHLEN here too.


# 1.47 24-Aug-2005 elad

Add SHA2 support in mtree.


Revision tags: netbsd-3-base
# 1.46 01-Dec-2004 lukem

branches: 1.46.2;
strsvis(3) encode & decode the "link=" value (symlink target).


# 1.45 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


Revision tags: netbsd-2-0-base
# 1.44 27-Oct-2003 lukem

branches: 1.44.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.43 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.


Revision tags: fvdl_fs64_base
# 1.42 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.41 29-Nov-2002 grant

avoid non-constant initializer errors by changing hack to workaround
gcc warning to a slightly different hack.


# 1.40 08-Aug-2002 soren

Remove extraneous \n's in {err,warn}{,x} that used to be printfs.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.39 31-Jan-2002 tv

Protect __RCSID and __COPYRIGHT from being invoked if not defined.


# 1.38 29-Jan-2002 tv

Add hooks to make mtree compilable from src/tools.


# 1.37 10-Nov-2001 lukem

provide the ability to remove support for generating or checking various
digests by #define-ing NO_MD5, NO_RMD160, or NO_SHA1. the keywords are
still parsed.


# 1.36 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.35 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.34 18-Oct-2001 lukem

complete WARNS=2 cleanup (with a bit of ickiness for the fts_open argv issue)


# 1.33 18-Oct-2001 lukem

make this mostly WARNS=2 safe


# 1.32 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.31 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.30 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.29 09-Mar-2001 simonb

ANSIfy, KNF, in preperation for more work.


# 1.28 20-Feb-2001 hubertf

Remove all the "#ifdef __APPLE__" code, to make this actually
build again on Darwin. The code in question is outdated.

OK'd by Wilfredo Sanchez wsanchez@MIT.EDU.


# 1.27 15-Oct-2000 is

LP64 format string cleanup. Problem reported by garbled.


# 1.26 11-Oct-2000 is

More format string cleanups by sommerfeld.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.25 01-Dec-1999 wennmach

branches: 1.25.4;
Now that we have strsvis, use it.


# 1.24 07-Nov-1999 wennmach

Encode file names using strvis(3) when creating a specification.
Escape white space characters and `#' characters. Do the inverse
when reading specs.

This is a temporary fix until we have strzouvis(3) (or some such)
which is an improved version of strvis (taking an additional list
of characters to encode).

Fixes PR 5006 and PR 7663


Revision tags: comdex-fall-1999-base
# 1.23 06-Jul-1999 christos

branches: 1.23.4;
portability fixes:
- don't use timespecs in struct stat on non 4.4BSD systems
- don't assume that tv_sec is a time_t


# 1.22 06-Jul-1999 hubertf

Actually generate MD5 checksums, as reported in PR 7928.
Approved by Dr. Lex Wennmacher <wennmach@geo.Uni-Koeln.DE>


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 11-Feb-1999 mrg

branches: 1.21.2;
- 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.20 19-Dec-1998 christos

Appease gcc-2.8.1, make printf formats more portable.


# 1.19 03-Nov-1998 christos

Namespace protection against MAXUID etc.


# 1.18 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.17 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.16 30-Aug-1998 nathanw

Add braces to satisfy egcs.


# 1.15 27-Aug-1998 ross

Add {} pairs to shut up egcs.


# 1.14 06-Jul-1998 mrg

- use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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 05-Sep-1996 mycroft

Only record sizes for regular files.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.10 01-Feb-1996 jtc

branches: 1.10.4;
Rename struct timespec fields to conform to POSIX.1b


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.9 07-Mar-1995 cgd

add NetBSD id's


# 1.8 07-Mar-1995 cgd

clean up import, fix a few bugs, etc.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 27-Mar-1994 cgd

off_t exp.


# 1.6 17-Nov-1993 cgd

make things a bit more consistent


# 1.5 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.4 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.3 06-Aug-1993 deraadt

update for fts library change


# 1.2 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision


# 1.75 31-Dec-2017 christos

factor out common code from Poul-Henning Kamp.


# 1.74 14-Dec-2017 christos

use uintmax_t for nlink_t from FreeBSD


Revision tags: netbsd-7-1-1-RELEASE matt-nb8-mediatek-base perseant-stdc-iso10646-base netbsd-8-base prg-localcount2-base3 prg-localcount2-base2 prg-localcount2-base1 prg-localcount2-base pgoyette-localcount-20170426 bouyer-socketcan-base1 pgoyette-localcount-20170320 netbsd-7-1-RELEASE netbsd-7-1-RC2 netbsd-7-nhusb-base-20170116 bouyer-socketcan-base pgoyette-localcount-20170107 netbsd-7-1-RC1 pgoyette-localcount-20161104 netbsd-7-0-2-RELEASE localcount-20160914 netbsd-7-nhusb-base pgoyette-localcount-20160806 pgoyette-localcount-20160726 pgoyette-localcount-base netbsd-7-0-1-RELEASE netbsd-7-0-RELEASE netbsd-7-0-RC3 netbsd-7-0-RC2 netbsd-7-0-RC1 netbsd-7-base yamt-pagecache-base9 tls-earlyentropy-base tls-maxphys-base
# 1.73 24-Apr-2014 christos

Pass a file pointer to write data instead of writing to stdout.
No functional change.


Revision tags: riastradh-xf86-video-intel-2-7-1-pre-2-21-15 riastradh-drm2-base3
# 1.72 17-Oct-2013 christos

branches: 1.72.2;
Our <sys/param.h> ends up calling header files that define intmax_t. This
should not be the case (but >sys/param.h> is not a standard header so all bets
are off). FreeBSD's does not, so explicitly include <stdint.h> to get it.


# 1.71 16-Oct-2013 christos

Restore old behavior of not printing sizes for directories, since it varies
depending on filesystem implementation. (Brooks Davis)


# 1.70 09-Sep-2013 christos

use intmax_t instead of long long. fixes wrong cast for time_t.


Revision tags: riastradh-drm2-base2 riastradh-drm2-base1 riastradh-drm2-base agc-symver-base
# 1.69 03-Feb-2013 christos

add the ability to only output paths included in a spec file when creating
from a directory (-c)


Revision tags: yamt-pagecache-base8
# 1.68 20-Dec-2012 christos

Implement the "flavor" output discussed in tech-userlevel@, by Brooks Davis


# 1.67 15-Dec-2012 christos

make us compatible with FreeBSD (for -n) (Brooks Davies)


Revision tags: yamt-pagecache-base7
# 1.66 12-Dec-2012 christos

-n is incorrectly supressing the ".." lines. (Brooks Davis)


Revision tags: yamt-pagecache-base6
# 1.65 05-Oct-2012 christos

Allow uid and uname or gid and gname to both be printed while
preserving the behavior of falling back to [ug]id when the name is not
resolvable. (brooks)


# 1.64 05-Oct-2012 christos

clarify seconds.09nanoseconds format (brooks)


# 1.63 05-Oct-2012 christos

add -j flag to indent directory blocks (from brooks)


# 1.62 05-Oct-2012 christos

add -n flag to disable comments (brook)


# 1.61 05-Oct-2012 christos

our fts compare routine is less constified.


# 1.60 05-Oct-2012 christos

more const
check if we support SHA384 before using
(brooks)


# 1.59 15-Jul-2012 spz

branches: 1.59.2;
resource leak (Coverity issues 274383 and 274384)


Revision tags: netbsd-6-0-6-RELEASE netbsd-6-1-5-RELEASE netbsd-6-1-4-RELEASE netbsd-6-0-5-RELEASE netbsd-6-1-3-RELEASE netbsd-6-0-4-RELEASE netbsd-6-1-2-RELEASE netbsd-6-0-3-RELEASE netbsd-6-1-1-RELEASE netbsd-6-0-2-RELEASE netbsd-6-1-RELEASE netbsd-6-1-RC4 netbsd-6-1-RC3 netbsd-6-1-RC2 netbsd-6-1-RC1 netbsd-6-0-1-RELEASE matt-nb6-plus-nbase netbsd-6-0-RELEASE netbsd-6-0-RC2 matt-nb6-plus-base netbsd-6-0-RC1 yamt-pagecache-base5 yamt-pagecache-base4 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base matt-mips64-premerge-20101231 matt-premerge-20091211 jym-xensuspend-nbase jym-xensuspend-base
# 1.58 03-Apr-2009 apb

branches: 1.58.6;
Make "mtree -C" sort its output.

As the input is read from a specfile into a tree of linked lists,
keep each linked list sorted. The sort order is the same as that
already used by "mtree -c": directories sort after non-directories, but
otherwise names are sorted in the order used by strcmp().


# 1.57 01-Feb-2009 hubertf

branches: 1.57.2;
When {MD5,RMD160,SHA1,SHA256_,SHA384_,SHA512_}File fail, use errno
to print what's actually wrong


# 1.56 28-Dec-2008 christos

fix dev_t formats.


Revision tags: netbsd-5-2-3-RELEASE netbsd-5-1-5-RELEASE netbsd-5-2-2-RELEASE netbsd-5-1-4-RELEASE netbsd-5-2-1-RELEASE netbsd-5-1-3-RELEASE netbsd-5-2-RELEASE netbsd-5-2-RC1 netbsd-5-1-2-RELEASE netbsd-5-1-1-RELEASE matt-nb5-mips64-premerge-20101231 matt-nb5-pq3-base netbsd-5-1-RELEASE netbsd-5-1-RC4 matt-nb5-mips64-k15 netbsd-5-1-RC3 netbsd-5-1-RC2 netbsd-5-1-RC1 netbsd-5-0-2-RELEASE matt-nb5-mips64-premerge-20091211 matt-nb5-mips64-u2-k2-k4-k7-k8-k9 matt-nb4-mips64-k7-u2a-k9b matt-nb5-mips64-u1-k1-k5 netbsd-5-0-1-RELEASE netbsd-5-0-RELEASE netbsd-5-0-RC4 netbsd-5-0-RC3 netbsd-5-0-RC2 netbsd-5-0-RC1 netbsd-5-base matt-mips64-base2 mjf-devfs2-base wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-baseX yamt-pf42-base2 wrstuden-revivesa-base yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase cube-autoconf-base matt-armv6-base hpcarm-cleanup-base
# 1.55 05-Dec-2007 christos

PR/37482: Malcolm Herbert: mtree does not check for getlogin() returning null
in spec create


# 1.54 19-Nov-2007 rillig

Renamed dsort to dcmp, since it doesn't sort, it only compares.


# 1.53 19-Nov-2007 rillig

Even on non-BSD systems, the "-R all" option should disable printing of
the "time" attribute. Noticed by Malcolm Herbert on tech-pkg.


# 1.52 18-Oct-2007 christos

cast to long explicitly for the compat build


Revision tags: matt-mips64-base
# 1.51 04-Feb-2007 elad

branches: 1.51.4;
The hashing routines (MD5File() and co.) can do dynamic allocation, so
take advantage of that instead of an ugly hard-coded MAXHASHLEN limit
that needs updating.

I think this was suggested by cube@ years ago.


Revision tags: netbsd-4-0-1-RELEASE wrstuden-fixsa-newbase wrstuden-fixsa-base-1 netbsd-4-0-RELEASE netbsd-4-0-RC5 netbsd-4-0-RC4 netbsd-4-0-RC3 netbsd-4-0-RC2 netbsd-4-0-RC1 wrstuden-fixsa-base netbsd-4-base
# 1.50 30-Oct-2006 christos

kill crypto/rmd160.h and crypto/sha2.h, and instead make symlinks to
/usr/include from /usr/include/sys. This makes all the one way hash
header handling identical.


Revision tags: abandoned-netbsd-4-base
# 1.49 24-Sep-2005 elad

Use crypto/rmd160.h.


# 1.48 02-Sep-2005 elad

Use MAXHASHLEN here too.


# 1.47 24-Aug-2005 elad

Add SHA2 support in mtree.


Revision tags: netbsd-3-base
# 1.46 01-Dec-2004 lukem

branches: 1.46.2;
strsvis(3) encode & decode the "link=" value (symlink target).


# 1.45 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


Revision tags: netbsd-2-0-base
# 1.44 27-Oct-2003 lukem

branches: 1.44.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.43 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.


Revision tags: fvdl_fs64_base
# 1.42 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.41 29-Nov-2002 grant

avoid non-constant initializer errors by changing hack to workaround
gcc warning to a slightly different hack.


# 1.40 08-Aug-2002 soren

Remove extraneous \n's in {err,warn}{,x} that used to be printfs.


Revision tags: netbsd-1-6-PATCH002-RELEASE netbsd-1-6-PATCH002 netbsd-1-6-PATCH002-RC4 netbsd-1-6-PATCH002-RC3 netbsd-1-6-PATCH002-RC2 netbsd-1-6-PATCH002-RC1 netbsd-1-6-PATCH001 netbsd-1-6-PATCH001-RELEASE netbsd-1-6-PATCH001-RC3 netbsd-1-6-PATCH001-RC2 netbsd-1-6-PATCH001-RC1 netbsd-1-6-RELEASE netbsd-1-6-RC3 netbsd-1-6-RC2 netbsd-1-6-RC1 netbsd-1-6-base
# 1.39 31-Jan-2002 tv

Protect __RCSID and __COPYRIGHT from being invoked if not defined.


# 1.38 29-Jan-2002 tv

Add hooks to make mtree compilable from src/tools.


# 1.37 10-Nov-2001 lukem

provide the ability to remove support for generating or checking various
digests by #define-ing NO_MD5, NO_RMD160, or NO_SHA1. the keywords are
still parsed.


# 1.36 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.35 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.34 18-Oct-2001 lukem

complete WARNS=2 cleanup (with a bit of ickiness for the fts_open argv issue)


# 1.33 18-Oct-2001 lukem

make this mostly WARNS=2 safe


# 1.32 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.31 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.30 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.29 09-Mar-2001 simonb

ANSIfy, KNF, in preperation for more work.


# 1.28 20-Feb-2001 hubertf

Remove all the "#ifdef __APPLE__" code, to make this actually
build again on Darwin. The code in question is outdated.

OK'd by Wilfredo Sanchez wsanchez@MIT.EDU.


# 1.27 15-Oct-2000 is

LP64 format string cleanup. Problem reported by garbled.


# 1.26 11-Oct-2000 is

More format string cleanups by sommerfeld.


Revision tags: netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.25 01-Dec-1999 wennmach

branches: 1.25.4;
Now that we have strsvis, use it.


# 1.24 07-Nov-1999 wennmach

Encode file names using strvis(3) when creating a specification.
Escape white space characters and `#' characters. Do the inverse
when reading specs.

This is a temporary fix until we have strzouvis(3) (or some such)
which is an improved version of strvis (taking an additional list
of characters to encode).

Fixes PR 5006 and PR 7663


Revision tags: comdex-fall-1999-base
# 1.23 06-Jul-1999 christos

branches: 1.23.4;
portability fixes:
- don't use timespecs in struct stat on non 4.4BSD systems
- don't assume that tv_sec is a time_t


# 1.22 06-Jul-1999 hubertf

Actually generate MD5 checksums, as reported in PR 7928.
Approved by Dr. Lex Wennmacher <wennmach@geo.Uni-Koeln.DE>


Revision tags: netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.21 11-Feb-1999 mrg

branches: 1.21.2;
- 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.20 19-Dec-1998 christos

Appease gcc-2.8.1, make printf formats more portable.


# 1.19 03-Nov-1998 christos

Namespace protection against MAXUID etc.


# 1.18 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.17 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.16 30-Aug-1998 nathanw

Add braces to satisfy egcs.


# 1.15 27-Aug-1998 ross

Add {} pairs to shut up egcs.


# 1.14 06-Jul-1998 mrg

- use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames


Revision tags: netbsd-1-3-PATCH003 netbsd-1-3-PATCH003-CANDIDATE2 netbsd-1-3-PATCH003-CANDIDATE1 netbsd-1-3-PATCH003-CANDIDATE0 netbsd-1-3-PATCH002 netbsd-1-3-PATCH001 netbsd-1-3-RELEASE netbsd-1-3-BETA netbsd-1-3-base
# 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 05-Sep-1996 mycroft

Only record sizes for regular files.


Revision tags: netbsd-1-2-RELEASE netbsd-1-2-BETA netbsd-1-2-base
# 1.10 01-Feb-1996 jtc

branches: 1.10.4;
Rename struct timespec fields to conform to POSIX.1b


Revision tags: netbsd-1-1-PATCH001 netbsd-1-1-RELEASE netbsd-1-1-base
# 1.9 07-Mar-1995 cgd

add NetBSD id's


# 1.8 07-Mar-1995 cgd

clean up import, fix a few bugs, etc.


Revision tags: netbsd-1-0-PATCH06 netbsd-1-0-PATCH05 netbsd-1-0-PATCH04 netbsd-1-0-PATCH03 netbsd-1-0-PATCH02 netbsd-1-0-PATCH1 netbsd-1-0-PATCH0 netbsd-1-0-RELEASE netbsd-1-0-base
# 1.7 27-Mar-1994 cgd

off_t exp.


# 1.6 17-Nov-1993 cgd

make things a bit more consistent


# 1.5 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.4 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.3 06-Aug-1993 deraadt

update for fts library change


# 1.2 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision