Commit Graph

24 Commits

Author SHA1 Message Date
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 87899d0b72 inotype() only needs to understand S_ types, not the F_ types 2002-02-19 04:54:12 +00:00
tv 76834aef57 Protect __RCSID and __COPYRIGHT from being invoked if not defined. 2002-01-31 19:36:47 +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 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 98df36b3a5 make this mostly WARNS=2 safe 2001-10-18 04:37:56 +00:00
lukem bc1697fc70 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).
2001-10-09 04:50:00 +00:00
lukem d8c78c600b - 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 ``...''
2001-10-05 13:14:56 +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
thorpej 85f032ca45 Fix printf format. 2001-09-11 15:10:45 +00:00
lukem 617a65b6f7 replace home-grown parser with fparseln() 2001-09-10 03:22:24 +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
jwise 2e6cacfae6 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.
1998-12-06 19:07:53 +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
lukem 4eb7653054 WARNSify, getopt returns -1 not EOF 1997-10-17 11:46:30 +00:00
cgd 788c306f2b add an 'optional' keyword, which allows files to be in the
specification, but _not_ in the file hierarchy.  contrib'd by:
Ed Symanzik <zik@enoch.cl.msu.edu>.  Man page adjustment to match, and
minor man page cleanup, by me.
1995-03-07 21:26:23 +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