History log of /netbsd-current/usr.sbin/mtree/spec.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.90 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.89 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.88 17-Oct-2013 christos

branches: 1.88.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.87 16-Oct-2013 christos

Default a bare "." with no type to F_DIR. For FreeBSD compatibility (Brooks
Davis)


# 1.86 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 yamt-pagecache-base8
# 1.85 20-Dec-2012 christos

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


Revision tags: yamt-pagecache-base7 yamt-pagecache-base6
# 1.84 07-Oct-2012 christos

disable encoding of globbing characters for now.


# 1.83 05-Oct-2012 christos

Encode literal global characters in files. Otherwise the results of
updating a directory using the resulting spec will be surprising.

See http://svnweb.freebsd.org/base/head/usr.sbin/mtree/test/test00.sh
for test cases.
(brooks)


# 1.82 05-Oct-2012 christos

clarify seconds.09nanoseconds format (brooks)


# 1.81 05-Oct-2012 christos

account for differences in digest names


Revision tags: yamt-pagecache-base5 yamt-pagecache-base4
# 1.80 15-Mar-2012 joerg

branches: 1.80.2;
Add __printflike attribution to use vprintf and friends with an argument
as format string.


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 netbsd-6-base yamt-pagecache-base3 yamt-pagecache-base2 yamt-pagecache-base cherry-xenmp-base bouyer-quota2-nbase bouyer-quota2-base
# 1.79 14-Feb-2011 uebayasi

branches: 1.79.4;
Suppress a superfluous whitespace after "time=..." in the output.


Revision tags: matt-mips64-premerge-20101231 matt-premerge-20091211
# 1.78 22-Sep-2009 apb

branches: 1.78.2;
Fix errors in previous: "optional" and "ignore" keywords also need the
appendfield treatment.


# 1.77 19-Sep-2009 apb

Do not print a trailing space on each line with "mtree -C".


# 1.76 19-Sep-2009 apb

Fix the "mtree -M" problem reported in PR 42031 by Geoff Wing.
The cause of the problem was that part of the code assumed that
nodecmp() on two nodes with the same name would return 0, but in
fact nodecmp() would return -1 or +1 if one of the nodes was a
directory and the other was not. The fix is to separate the notion
of whether or not a duplicate name was found from the notion of
where the new node should appear in the list.


Revision tags: jym-xensuspend-nbase jym-xensuspend-base
# 1.75 11-Apr-2009 apb

When an mtree spec file omits a parent directory, "missing directory in
specification", instead of "no such file or directory".


# 1.74 08-Apr-2009 apb

The recent addition of sorting to "mtree -C" broke some third party
scripts. Now make sorting optional, controled by the "-S" flag.


# 1.73 07-Apr-2009 apb

fix another missing "prev" link


# 1.72 05-Apr-2009 apb

Fix broken "prev" pointer in one case.


# 1.71 05-Apr-2009 dogcow

Watch one's "p"s and "q"s and fix cast aspersions on alpha ("warning: field
precision should have type 'int', but argument 2 has type 'long int'")


# 1.70 04-Apr-2009 apb

Tags are internally stored with leading and trailing commas, for ease
of using strstr(3) to check them against inclusion or exclusion lists.
Don't output the leading or trailing commas.


# 1.69 03-Apr-2009 apb

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.68 18-Jan-2009 lukem

branches: 1.68.2;
fix -Wsign-compare issues


# 1.67 28-Dec-2008 christos

fix time_t and dev_t formats


# 1.66 04-Nov-2008 dbj

ensure mtree_err gets a format string


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 wrstuden-revivesa-base-3 wrstuden-revivesa-base-2 wrstuden-revivesa-base-1 yamt-pf42-base4 yamt-pf42-base3 hpcarm-cleanup-nbase yamt-pf42-base2 wrstuden-revivesa-base
# 1.65 28-Apr-2008 martin

Remove clause 3 and 4 from TNF licenses


Revision tags: yamt-pf42-baseX yamt-pf42-base keiichi-mipv6-nbase keiichi-mipv6-base matt-armv6-nbase matt-armv6-prevmlocking cube-autoconf-base matt-armv6-base matt-mips64-base hpcarm-cleanup-base
# 1.64 14-Dec-2006 he

branches: 1.64.10;
Complete the move of string_to_flags() and flags_to_string() from the
bin/ls sources to libutil:
o Bump libutil minor version number
o Fix uses to include <util.h> to pick up the function definitions
o Fix most uses of flags_to_string() to release the now-malloc()ed result


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.63 08-Oct-2006 martin

Apply patch from Peter Bex to fix PR bin/31922.


Revision tags: abandoned-netbsd-4-base
# 1.62 12-Apr-2006 dsl

If parameter don't have values, then 'continue' after setting the flag bit.
Fixes coverty CID 776 and removes the need for a 'val = NULL' added to
appease gcc's undefined variable tests.
This parsing code sucks though, it doesn't correctly check for the '='
between a parameter and its value, whitespace can be used instead.


# 1.61 01-Oct-2005 christos

fix setmode error handling.


# 1.60 24-Aug-2005 elad

Add SHA2 support in mtree.


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

branches: 1.59.2;
In replacenode(), don't strunvis() a NULL pointer. (Fixes bug in previous.)


# 1.58 01-Dec-2004 lukem

strsvis(3) encode & decode the "link=" value (symlink target).


# 1.57 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.56 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.55 11-May-2004 christos

foliage from pack_dev change :-)


Revision tags: netbsd-2-0-base
# 1.54 30-Jan-2004 ross

branches: 1.54.2;
Handle new-style error return from mknod/pack_dev.c


# 1.53 17-Nov-2003 dbj

#include <util.h>
this is needed by fparseln on macos/darwin and is harmless on netbsd


# 1.52 10-Oct-2003 dsl

Include filename in:
'existing entry for `sha1.h', type `file' does not match type `link'


# 1.51 19-Sep-2003 itojun

realloc pedant


# 1.50 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.49 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.48 30-Nov-2002 lukem

tweaks for fparseln(3) move from libutil to libc:
- remove #include <util.h> if nothing else needed it
- remove LDFLAGS+=-lutil if nothing else needed it


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.47 11-Feb-2002 lukem

support multiple entries for "." and full paths if the types match; the last
listed entry's settings override the existing settings for that node.


# 1.46 05-Feb-2002 lukem

Support `/unset all', to unset all of the global values set with `/set ...'


# 1.45 31-Jan-2002 tv

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.

* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.


# 1.44 29-Jan-2002 tv

Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)


# 1.43 29-Jan-2002 lukem

add <util.h> back in for native builds.


# 1.42 29-Jan-2002 tv

Add hooks to make mtree compilable from src/tools.


# 1.41 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.40 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.39 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.38 01-Nov-2001 tv

Revert previous until it's fixed a more generic way ... I didn't realize
this was pulled in via reachover from elsewhere.


# 1.37 31-Oct-2001 tv

Don't try to do uid or gid lookups from a supplied spec file if -W is given;
the numerical IDs won't be used anyway.


# 1.36 26-Oct-2001 lukem

fix potential sparc compiler warning (if DEBUG was defined, that is...)


# 1.35 25-Oct-2001 lukem

- add lineno field to NODE
- move inotype() prototype into mtree.h from extern.h


# 1.34 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.33 17-Oct-2001 lukem

convert from strtok() to strsep()


# 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 05-Oct-2001 lukem

* Implement support for absolute paths in the specfile. An absolute path
is one that contains a `/' character that is not the first character.
All parent directories referenced in the path must exist.
* Add copyright for all the work I've done.
* Document the history of various features added since 4.3-Reno.


# 1.30 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.29 05-Oct-2001 lukem

dump_nodes() fixes:
- in F_GID, print the gid not the uid
- support F_GNAME


# 1.28 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.27 04-Oct-2001 lukem

- skip F_OPT entries (recently added diagnostic detected this)
- put F_TAG parsing in the correct alphabetical position


# 1.26 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.25 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.24 10-Sep-2001 lukem

replace home-grown parser with fparseln()


# 1.23 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.22 25-Mar-2001 christos

improve readability of error messages by quoting the string that we
did not understand. Avoids lossage like "unknown group named".


# 1.21 09-Mar-2001 simonb

ANSIfy, KNF, in preperation for more work.


# 1.20 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.19 10-Oct-2000 enami

- The type of return value of setmode is a void * and getmode takes it,
rather than mode_t *.
- Free the storage allocated by setmode unless it is obvious that program
exits immediately.


Revision tags: netbsd-1-5-PATCH003 netbsd-1-5-PATCH002 netbsd-1-5-PATCH001 netbsd-1-5-RELEASE netbsd-1-5-BETA2 netbsd-1-5-BETA netbsd-1-5-ALPHA2 netbsd-1-5-base minoura-xpg4dl-base wrstuden-devbsize-19991221 wrstuden-devbsize-base
# 1.18 01-Dec-1999 wennmach

Use strunvis instead of homebrewed "decode" routine


# 1.17 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 netbsd-1-4-PATCH001 netbsd-1-4-RELEASE netbsd-1-4-base
# 1.16 19-Dec-1998 christos

branches: 1.16.2; 1.16.6;
Appease gcc-2.8.1, make printf formats more portable.


# 1.15 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.14 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.13 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.12 23-Sep-1998 itohy

The return value of setmode(3) is a pointer to malloc()'ed area
and must be freed to avoid memory leaks if called repeatedly.


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.11 17-Oct-1997 lukem

WARNSify, getopt returns -1 not EOF


# 1.10 17-Oct-1997 mrg

merge lite-2


# 1.9 11-Jul-1997 mikel

fix printf() formats, make explicit comparisons to NULL (gcc -Wall)


# 1.8 25-Apr-1997 mikel

use appropriate strto*() functions, and cast results when appropriate;
fixes PR bin/1582.


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

Rename struct timespec fields to conform to POSIX.1b


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

add NetBSD id's


# 1.5 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.4 27-Mar-1994 cgd

off_t exp.


# 1.3 02-Nov-1993 cgd

latest mtree from uunet. doesn't compile, but that'll be fixed soon.
(want to have 'pseudo-virgin' sources, for when fixed fnmatch stuff
is released...)


# 1.2 01-Aug-1993 mycroft

Add RCS identifiers.


# 1.1 21-Mar-1993 cgd

branches: 1.1.1;
Initial revision