NetBSD/usr.sbin/mtree/verify.c

292 lines
7.1 KiB
C
Raw Normal View History

/* $NetBSD: verify.c,v 1.34 2003/01/04 13:10:52 lukem Exp $ */
1995-03-08 00:12:04 +03:00
1993-03-21 12:45:37 +03:00
/*-
1995-03-07 18:28:32 +03:00
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
1993-03-21 12:45:37 +03:00
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
1997-10-17 15:46:30 +04:00
#include <sys/cdefs.h>
#if defined(__RCSID) && !defined(lint)
1995-03-08 00:12:04 +03:00
#if 0
1995-03-07 18:28:32 +03:00
static char sccsid[] = "@(#)verify.c 8.1 (Berkeley) 6/6/93";
1995-03-08 00:12:04 +03:00
#else
__RCSID("$NetBSD: verify.c,v 1.34 2003/01/04 13:10:52 lukem Exp $");
1995-03-08 00:12:04 +03:00
#endif
1993-03-21 12:45:37 +03:00
#endif /* not lint */
#include <sys/param.h>
#include <sys/stat.h>
#if !HAVE_CONFIG_H
1993-03-21 12:45:37 +03:00
#include <dirent.h>
#endif
1993-03-21 12:45:37 +03:00
#include <errno.h>
#include <fnmatch.h>
1993-03-21 12:45:37 +03:00
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "extern.h"
1993-03-21 12:45:37 +03:00
static NODE *root;
static char path[MAXPATHLEN];
1993-03-21 12:45:37 +03:00
static void miss(NODE *, char *);
static int vwalk(void);
int
verify(void)
1993-03-21 12:45:37 +03:00
{
int rval;
root = spec(stdin);
rval = vwalk();
1993-03-21 12:45:37 +03:00
miss(root, path);
return (rval);
1993-03-21 12:45:37 +03:00
}
static int
vwalk(void)
1993-03-21 12:45:37 +03:00
{
1997-10-17 15:46:30 +04:00
FTS *t;
FTSENT *p;
NODE *ep, *level;
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 11:01:51 +03:00
int specdepth, rval;
char *argv[2];
char dot[] = ".";
argv[0] = dot;
argv[1] = NULL;
1993-03-21 12:45:37 +03:00
if ((t = fts_open(argv, ftsoptions, NULL)) == NULL)
mtree_err("fts_open: %s", strerror(errno));
1993-03-21 12:45:37 +03:00
level = root;
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 11:01:51 +03:00
specdepth = rval = 0;
while ((p = fts_read(t)) != NULL) {
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 11:01:51 +03:00
if (check_excludes(p->fts_name, p->fts_path)) {
fts_set(t, p, FTS_SKIP);
continue;
}
1993-03-21 12:45:37 +03:00
switch(p->fts_info) {
case FTS_D:
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 11:01:51 +03:00
case FTS_SL:
1993-03-21 12:45:37 +03:00
break;
case FTS_DP:
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 11:01:51 +03:00
if (specdepth > p->fts_level) {
1993-03-21 12:45:37 +03:00
for (level = level->parent; level->prev;
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 11:01:51 +03:00
level = level->prev)
continue;
--specdepth;
1993-03-21 12:45:37 +03:00
}
continue;
case FTS_DNR:
case FTS_ERR:
case FTS_NS:
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 11:01:51 +03:00
warnx("%s: %s", RP(p), strerror(p->fts_errno));
1993-03-21 12:45:37 +03:00
continue;
default:
if (dflag)
continue;
}
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 11:01:51 +03:00
if (specdepth != p->fts_level)
goto extra;
1993-03-21 12:45:37 +03:00
for (ep = level; ep; ep = ep->next)
if ((ep->flags & F_MAGIC &&
!fnmatch(ep->name, p->fts_name, FNM_PATHNAME)) ||
1993-03-21 12:45:37 +03:00
!strcmp(ep->name, p->fts_name)) {
ep->flags |= F_VISIT;
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 11:01:51 +03:00
if (compare(ep, p))
rval = MISMATCHEXIT;
if (!(ep->flags & F_IGN) &&
ep->child && ep->type == F_DIR &&
1993-03-21 12:45:37 +03:00
p->fts_info == FTS_D) {
level = ep->child;
++specdepth;
} else
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 11:01:51 +03:00
fts_set(t, p, FTS_SKIP);
1993-03-21 12:45:37 +03:00
break;
}
if (ep)
continue;
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 11:01:51 +03:00
extra:
1993-03-21 12:45:37 +03:00
if (!eflag) {
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 11:01:51 +03:00
printf("extra: %s", RP(p));
1993-03-21 12:45:37 +03:00
if (rflag) {
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 11:01:51 +03:00
if ((S_ISDIR(p->fts_statp->st_mode)
? rmdir : unlink)(p->fts_accpath)) {
printf(", not removed: %s",
1993-03-21 12:45:37 +03:00
strerror(errno));
} else
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 11:01:51 +03:00
printf(", removed");
1993-03-21 12:45:37 +03:00
}
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 11:01:51 +03:00
putchar('\n');
1993-03-21 12:45:37 +03:00
}
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 11:01:51 +03:00
fts_set(t, p, FTS_SKIP);
1993-03-21 12:45:37 +03:00
}
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 11:01:51 +03:00
fts_close(t);
if (sflag)
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 11:01:51 +03:00
warnx("%s checksum: %u", fullpath, crc_total);
return (rval);
1993-03-21 12:45:37 +03:00
}
static void
miss(NODE *p, char *tail)
1993-03-21 12:45:37 +03:00
{
1997-10-17 15:46:30 +04:00
int create;
char *tp;
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 11:01:51 +03:00
const char *type;
u_int32_t flags;
1993-03-21 12:45:37 +03:00
for (; p; p = p->next) {
if (p->flags & F_OPT && !(p->flags & F_VISIT))
continue;
1993-03-21 12:45:37 +03:00
if (p->type != F_DIR && (dflag || p->flags & F_VISIT))
continue;
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 11:01:51 +03:00
strcpy(tail, p->name);
1993-03-21 12:45:37 +03:00
if (!(p->flags & F_VISIT))
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 11:01:51 +03:00
printf("missing: %s", path);
switch (p->type) {
case F_BLOCK:
case F_CHAR:
type = "device";
break;
case F_DIR:
type = "directory";
break;
case F_LINK:
type = "symlink";
break;
default:
1993-03-21 12:45:37 +03:00
putchar('\n');
continue;
}
create = 0;
1998-08-27 22:03:42 +04:00
if (!(p->flags & F_VISIT) && uflag) {
if (Wflag || p->type == F_LINK)
goto createit;
if (!(p->flags & (F_UID | F_UNAME)))
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 11:01:51 +03:00
printf(
" (%s not created: user not specified)", type);
else if (!(p->flags & (F_GID | F_GNAME)))
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 11:01:51 +03:00
printf(
" (%s not created: group not specified)", type);
else if (!(p->flags & F_MODE))
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 11:01:51 +03:00
printf(
" (%s not created: mode not specified)", type);
else
createit:
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 11:01:51 +03:00
switch (p->type) {
case F_BLOCK:
case F_CHAR:
if (Wflag)
continue;
if (!(p->flags & F_DEV))
printf(
" (%s not created: device not specified)",
type);
else if (mknod(path,
p->st_mode | nodetoino(p->type),
p->st_rdev) == -1)
printf(" (%s not created: %s)\n",
type, strerror(errno));
else
create = 1;
break;
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 11:01:51 +03:00
case F_LINK:
if (!(p->flags & F_SLINK))
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 11:01:51 +03:00
printf(
" (%s not created: link not specified)\n",
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 11:01:51 +03:00
type);
else if (symlink(p->slink, path))
printf(
" (%s not created: %s)\n",
type, strerror(errno));
else
create = 1;
break;
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 11:01:51 +03:00
case F_DIR:
if (mkdir(path, S_IRWXU|S_IRWXG|S_IRWXO))
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 11:01:51 +03:00
printf(" (not created: %s)",
strerror(errno));
else
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 11:01:51 +03:00
create = 1;
break;
default:
mtree_err("can't create create %s",
nodetype(p->type));
1993-03-21 12:45:37 +03:00
}
1998-08-27 22:03:42 +04:00
}
if (create)
printf(" (created)");
if (p->type == F_DIR) {
if (!(p->flags & F_VISIT))
putchar('\n');
for (tp = tail; *tp; ++tp)
continue;
*tp = '/';
miss(p->child, tp + 1);
*tp = '\0';
} else
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 11:01:51 +03:00
putchar('\n');
1993-03-21 12:45:37 +03:00
if (!create || Wflag)
1993-03-21 12:45:37 +03:00
continue;
if ((p->flags & (F_UID | F_UNAME)) &&
(p->flags & (F_GID | F_GNAME)) &&
(lchown(path, p->st_uid, p->st_gid))) {
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 11:01:51 +03:00
printf("%s: user/group/mode not modified: %s\n",
1993-03-21 12:45:37 +03:00
path, strerror(errno));
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 11:01:51 +03:00
printf("%s: warning: file mode %snot set\n", path,
(p->flags & F_FLAGS) ? "and file flags " : "");
1993-03-21 12:45:37 +03:00
continue;
}
if (p->flags & F_MODE) {
if (lchmod(path, p->st_mode))
printf("%s: permissions not set: %s\n",
path, strerror(errno));
}
#if HAVE_STRUCT_STAT_ST_FLAGS
if ((p->flags & F_FLAGS) && p->st_flags) {
if (iflag)
flags = p->st_flags;
else
flags = p->st_flags & ~SP_FLGS;
if (lchflags(path, flags))
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 11:01:51 +03:00
printf("%s: file flags not set: %s\n",
path, strerror(errno));
}
#endif /* HAVE_STRUCT_STAT_ST_FLAGS */
1993-03-21 12:45:37 +03:00
}
}