Commit Graph

30 Commits

Author SHA1 Message Date
he 0a97c3f688 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
2006-12-14 20:09:35 +00:00
lukem 9cc32040b1 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.
2004-07-22 16:51:45 +00:00
lukem 171d653219 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).
2003-10-27 00:12:41 +00:00
agc 326b2259b7 Move UCB-licensed code from 4-clause to 3-clause licence.
Patches provided by Joel Baker in PR 22366, verified by myself.
2003-08-07 11:25:11 +00:00
lukem 3cbfaf0af4 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).
2002-12-23 04:40:19 +00:00
lukem 6e980262a4 Remove convoluted code to work around missing lch{flags,mod,own}();
instead, rely upon libnbcompat to provide a workaround (which returns
an error if the target is a symlink).
Should fix another MacOS X build issue due to missing lchown(2).
2002-10-08 00:34:08 +00:00
lukem 64beaeafc8 - Check HAVE_LCHFLAGS for lchflags(2) support, rather than assuming
that HAVE_STRUCT_STAT_ST_FLAGS implies this.
- Set HAVE_LCHFLAGS for native builds
- Clean up {CLEAR,SET,CHANGE}FLAGS macros, and only provide if
  HAVE_STRUCT_STAT_ST_FLAGS is set.

(Fixes compilation as a tool on MacOS X, noted by Allen Briggs.)
2002-10-06 01:36:09 +00:00
tv 3fdf5a9991 Funtion appropriately in the absence of a lchmod call on the host. 2002-02-08 18:15:12 +00:00
tv 9fbd88883c 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.
2002-01-31 22:43:33 +00:00
tv a328e34106 Make almost all tools compile and run properly on non-NetBSD hosts. (In
particular, most tools now run correctly on Solaris 7.)
2002-01-29 10:20:28 +00:00
tv fcae5f73b7 Add hooks to make mtree compilable from src/tools. 2002-01-29 00:07:27 +00:00
lukem e8b2f3326f 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.
2001-11-07 08:01:51 +00:00
lukem c55aa0f9cb - 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)
2001-11-03 12:51:40 +00:00
lukem 1e617f29fb Add -W: don't attempt to change the perms/time/flags on existing entries, nor
set them when creating new directories. (AKA the ``don't whack'' option).
Concept suggested by Todd Vierling.
2001-10-25 14:47:39 +00:00
lukem 68a03bad5d - add lineno field to NODE
- move inotype() prototype into mtree.h from extern.h
2001-10-25 03:00:14 +00:00
lukem 57566f70f8 - 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)
2001-10-22 07:07:46 +00:00
lukem 4da22cb499 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)
2001-10-05 01:03:24 +00:00
lukem 7c30045cef 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.
2001-10-04 04:51:27 +00:00
lukem 0c2c66fb9a - 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.
2001-10-01 02:30:40 +00:00
lukem c0e6fdedfc - 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 *"
2001-07-18 04:51:54 +00:00
simonb 7cbb4e05a0 ANSIfy, KNF, in preperation for more work. 2001-03-09 03:09:45 +00:00
hubertf 1156c833f6 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.
2001-02-20 19:45:51 +00:00
is d8302e2d73 More format string cleanups by sommerfeld. 2000-10-11 20:23:46 +00:00
wennmach 914178b225 code.c is no longer used, we use strsvis instead. Removed prototypes
from extern.h
1999-12-07 18:42:06 +00:00
drochner 68062ca8dc prototype encode()/decode() 1999-11-09 10:16:55 +00:00
mrg f2fb63efda 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.
1998-10-10 07:50:27 +00:00
wsanchez c45946d27c Use u_int32_t rather than Sys-V u_long.
Rename err() to mtree_err(), to avoid conflict with libc.
1998-10-08 02:04:55 +00:00
cgd 94f5a7441c add NetBSD id's 1995-03-07 21:12:04 +00:00
cgd 82f956cd93 from 4.4-Lite 1995-03-07 14:44:05 +00:00
cgd 476023b5bb 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...)
1993-11-02 07:51:06 +00:00