Lines Matching defs:??

1 /*	$NetBSD: compare.c,v 1.58 2013/11/21 18:39:50 christos Exp $	*/
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #if HAVE_NBTOOL_CONFIG_H
37 #if defined(__RCSID) && !defined(lint)
38 #if 0
39 static char sccsid[] = "@(#)compare.c 8.1 (Berkeley) 6/6/93";
41 __RCSID("$NetBSD: compare.c,v 1.58 2013/11/21 18:39:50 christos Exp $");
74 do { \
75 if (flavor == F_FREEBSD9) { \
76 len = printf("%s changed\n", RP(p)); \
79 len = printf("%s: ", RP(p)); \
80 if (len > INDENTNAMELEN) { \
89 #define LABEL if (!label++) MARK
91 #if HAVE_STRUCT_STAT_ST_FLAGS
95 if (flags != p->fts_statp->st_flags) { \
96 char *sf; \
97 if (!label) { \
99 sf = flags_to_string(p->fts_statp->st_flags, "none"); \
100 printf("%sflags (\"%s\"", tab, sf); \
101 free(sf); \
103 if (lchflags(p->fts_accpath, flags)) { \
108 sf = flags_to_string(flags, "none"); \
109 printf(", modified to \"%s\")\n", sf); \
110 free(sf); \
115 * given pflags, additionally set those flags specified in s->st_flags and
116 * selected by mask (the other flags are left unchanged).
119 do { \
125 * given pflags, reset the flags specified in s->st_flags and selected by mask
129 do { \
139 int fd, label;
140 const char *cp, *tab;
141 #if !defined(NO_MD5) || !defined(NO_RMD160) || !defined(NO_SHA1) || !defined(NO_SHA2)
149 if (!S_ISBLK(p->fts_statp->st_mode))
153 if (!S_ISCHR(p->fts_statp->st_mode))
157 if (!S_ISDIR(p->fts_statp->st_mode))
161 if (!S_ISFIFO(p->fts_statp->st_mode))
165 if (!S_ISREG(p->fts_statp->st_mode))
169 if (!S_ISLNK(p->fts_statp->st_mode))
174 if (!S_ISSOCK(p->fts_statp->st_mode))
184 if (mtree_Wflag)
186 #if HAVE_STRUCT_STAT_ST_FLAGS
187 if (iflag && !uflag) {
188 if (s->flags & F_FLAGS)
192 if (mflag && !uflag) {
193 if (s->flags & F_FLAGS)
198 if (s->flags & F_DEV &&
203 "%sdevice expected %#jx found %#jx" :
204 "%sdevice (%#jx, %#jx",
207 if (uflag) {
208 if ((unlink(p->fts_accpath) == -1) ||
225 if (s->flags & (F_UID | F_UNAME) && s->st_uid != p->fts_statp->st_uid) {
228 "%suser expected %lu found %lu" : "%suser (%lu, %lu",
230 if (uflag) {
231 if (lchown(p->fts_accpath, s->st_uid, -1))
242 if (s->flags & (F_GID | F_GNAME) && s->st_gid != p->fts_statp->st_gid) {
245 "%sgid expected %lu found %lu" : "%sgid (%lu, %lu",
247 if (uflag) {
248 if (lchown(p->fts_accpath, -1, s->st_gid))
260 if (s->flags & F_MODE &&
262 if (lflag) {
268 * if none of the suid/sgid/etc bits are set,
269 * then if the mode is a subset of the target,
272 if (!((tmode & ~(S_IRWXU|S_IRWXG|S_IRWXO)) ||
274 if ((mode | tmode) == tmode)
280 "%spermissions expcted %#lo found %#lo" :
281 "%spermissions (%#lo, %#lo",
284 if (uflag) {
285 if (lchmod(p->fts_accpath, s->st_mode))
298 if (s->flags & F_NLINK && s->type != F_DIR &&
302 "%slink count expected %lu found %lu\n" :
303 "%slink count (%lu, %lu)\n",
307 if (s->flags & F_SIZE && s->st_size != p->fts_statp->st_size) {
310 "%ssize expected %ju found %ju\n" : "%ssize (%ju, %ju)\n",
317 * Since utimes(2) only takes a timeval, there's no point in
318 * comparing the low bits of the timespec nanosecond field. This
319 * will only result in mismatches that we can never fix.
323 if (s->flags & F_TIME) {
324 struct timeval tv[2];
325 struct stat *ps = p->fts_statp;
328 #if defined(BSD4_4) && !defined(HAVE_NBTOOL_CONFIG_H)
329 time_t pmtime = ps->st_mtimespec.tv_sec;
331 TIMESPEC_TO_TIMEVAL(&tv[0], &s->st_mtimespec);
332 TIMESPEC_TO_TIMEVAL(&tv[1], &ps->st_mtimespec);
334 time_t pmtime = (time_t)ps->st_mtime;
336 tv[0].tv_sec = smtime;
337 tv[0].tv_usec = 0;
338 tv[1].tv_sec = pmtime;
339 tv[1].tv_usec = 0;
342 if (tv[0].tv_sec != tv[1].tv_sec ||
343 tv[0].tv_usec != tv[1].tv_usec) {
346 "%smodification time expected %.24s found " :
347 "%smodification time (%.24s, ",
349 printf("%.24s", ctime(&pmtime));
350 if (tflag) {
351 tv[1] = tv[0];
352 if (utimes(p->fts_accpath, tv))
364 #if HAVE_STRUCT_STAT_ST_FLAGS
368 * may have been useless! oh well, we'd rather have correct
371 if ((s->flags & F_FLAGS) && ((s->st_flags != p->fts_statp->st_flags)
373 if (s->st_flags != p->fts_statp->st_flags) {
379 "%sflags (\"%s\" is not ", tab, f_s);
385 if (uflag) {
386 if (iflag)
388 else if (mflag)
399 * from this point, no more permission checking or whacking
400 * occurs, only checking of stuff like checksums and symlinks.
403 if (s->flags & F_CKSUM) {
404 if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0) {
409 } else if (crc(fd, &val, &len)) {
410 close(fd);
416 close(fd);
417 if (s->cksum != val) {
420 "%scksum expected %lu found %lu\n" :
421 "%scksum (%lu, %lu)\n",
428 if (s->flags & F_MD5) {
429 if ((digestbuf = MD5File(p->fts_accpath, NULL)) == NULL) {
435 if (strcmp(s->md5digest, digestbuf)) {
448 if (s->flags & F_RMD160) {
449 if ((digestbuf = RMD160File(p->fts_accpath, NULL)) == NULL) {
455 if (strcmp(s->rmd160digest, digestbuf)) {
468 if (s->flags & F_SHA1) {
469 if ((digestbuf = SHA1File(p->fts_accpath, NULL)) == NULL) {
475 if (strcmp(s->sha1digest, digestbuf)) {
488 if (s->flags & F_SHA256) {
489 if ((digestbuf = SHA256_File(p->fts_accpath, NULL)) == NULL) {
495 if (strcmp(s->sha256digest, digestbuf)) {
507 if (s->flags & F_SHA384) {
508 if ((digestbuf = SHA384_File(p->fts_accpath, NULL)) == NULL) {
514 if (strcmp(s->sha384digest, digestbuf)) {
526 if (s->flags & F_SHA512) {
527 if ((digestbuf = SHA512_File(p->fts_accpath, NULL)) == NULL) {
533 if (strcmp(s->sha512digest, digestbuf)) {
545 if (s->flags & F_SLINK &&
546 strcmp(cp = rlink(p->fts_accpath), s->slink)) {
550 "%slink ref (%s, %s", tab, cp, s->slink);
551 if (uflag) {
552 if ((unlink(p->fts_accpath) == -1) ||
572 if ((len = readlink(name, lbuf, sizeof(lbuf) - 1)) == -1)