The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=e4d63c5d5ff85d1eb84501d60806651adb552159
commit e4d63c5d5ff85d1eb84501d60806651adb552159 Author: Kyle Evans <kev...@freebsd.org> AuthorDate: 2021-03-02 21:15:17 +0000 Commit: Kyle Evans <kev...@freebsd.org> CommitDate: 2021-03-02 21:22:05 +0000 Remove fmtree(8) fmtree(8) deprecation was announced on February 12, 2021, and no longer built by default as of that date. The deprecation notice was merged back to stable/12 and stable/13 + releng/13.0. Continue with the plan by finishing the removal. Relnotes: yes --- ObsoleteFiles.inc | 4 + share/mk/src.opts.mk | 1 - tools/build/mk/OptionalObsoleteFiles.inc | 5 - tools/build/options/WITHOUT_FMTREE | 3 - tools/build/options/WITH_FMTREE | 5 - usr.sbin/Makefile | 1 - usr.sbin/fmtree/Makefile | 21 -- usr.sbin/fmtree/Makefile.depend | 18 -- usr.sbin/fmtree/compare.c | 389 ---------------------------- usr.sbin/fmtree/create.c | 431 ------------------------------- usr.sbin/fmtree/excludes.c | 111 -------- usr.sbin/fmtree/extern.h | 59 ----- usr.sbin/fmtree/misc.c | 124 --------- usr.sbin/fmtree/mtree.8 | 408 ----------------------------- usr.sbin/fmtree/mtree.c | 191 -------------- usr.sbin/fmtree/mtree.h | 98 ------- usr.sbin/fmtree/spec.c | 323 ----------------------- usr.sbin/fmtree/specspec.c | 256 ------------------ usr.sbin/fmtree/test/test00.sh | 67 ----- usr.sbin/fmtree/test/test01.sh | 40 --- usr.sbin/fmtree/test/test02.sh | 36 --- usr.sbin/fmtree/test/test03.sh | 60 ----- usr.sbin/fmtree/test/test04.sh | 51 ---- usr.sbin/fmtree/test/test05.sh | 25 -- usr.sbin/fmtree/verify.c | 261 ------------------- 25 files changed, 4 insertions(+), 2984 deletions(-) diff --git a/ObsoleteFiles.inc b/ObsoleteFiles.inc index 61c8d3dba2fe..5821e9f04e89 100644 --- a/ObsoleteFiles.inc +++ b/ObsoleteFiles.inc @@ -36,6 +36,10 @@ # xargs -n1 | sort | uniq -d; # done +# 20210302: fmtree removed +OLD_FILES+=usr/sbin/fmtree +OLD_FILES+=usr/share/man/man8/fmtree.8.gz + # 20210201: bump shared libraries which link against ncurses OLD_LIBS+=lib/libedit.so.7 OLD_LIBS+=usr/lib/libdialog.so.8 diff --git a/share/mk/src.opts.mk b/share/mk/src.opts.mk index 9e7a0c88f8af..619aa8f4a1d8 100644 --- a/share/mk/src.opts.mk +++ b/share/mk/src.opts.mk @@ -201,7 +201,6 @@ __DEFAULT_NO_OPTIONS = \ CLANG_FORMAT \ DTRACE_TESTS \ EXPERIMENTAL \ - FMTREE \ HESIOD \ LIBSOFT \ LOADER_FIREWIRE \ diff --git a/tools/build/mk/OptionalObsoleteFiles.inc b/tools/build/mk/OptionalObsoleteFiles.inc index 87fab14e45e7..5984645cbc14 100644 --- a/tools/build/mk/OptionalObsoleteFiles.inc +++ b/tools/build/mk/OptionalObsoleteFiles.inc @@ -1684,11 +1684,6 @@ OLD_FILES+=usr/sbin/uefisign OLD_FILES+=usr/share/examples/uefisign/uefikeys .endif -.if ${MK_FMTREE} == no -OLD_FILES+=usr/sbin/fmtree -OLD_FILES+=usr/share/man/man8/fmtree.8.gz -.endif - .if ${MK_FTP} == no OLD_FILES+=etc/ftpusers OLD_FILES+=etc/newsyslog.conf.d/ftp.conf diff --git a/tools/build/options/WITHOUT_FMTREE b/tools/build/options/WITHOUT_FMTREE deleted file mode 100644 index f8225c1e90c0..000000000000 --- a/tools/build/options/WITHOUT_FMTREE +++ /dev/null @@ -1,3 +0,0 @@ -.\" $FreeBSD$ -Set to not build and install -.Pa /usr/sbin/fmtree . diff --git a/tools/build/options/WITH_FMTREE b/tools/build/options/WITH_FMTREE deleted file mode 100644 index e384ff426774..000000000000 --- a/tools/build/options/WITH_FMTREE +++ /dev/null @@ -1,5 +0,0 @@ -.\" $FreeBSD$ -Set to build and install -.Pa /usr/sbin/fmtree . -This option is deprecated, and will be gone in -.Fx 14.0 . diff --git a/usr.sbin/Makefile b/usr.sbin/Makefile index 259ab72f2281..ae568746119a 100644 --- a/usr.sbin/Makefile +++ b/usr.sbin/Makefile @@ -137,7 +137,6 @@ SUBDIR.${MK_FLOPPY}+= fdcontrol SUBDIR.${MK_FLOPPY}+= fdformat SUBDIR.${MK_FLOPPY}+= fdread SUBDIR.${MK_FLOPPY}+= fdwrite -SUBDIR.${MK_FMTREE}+= fmtree SUBDIR.${MK_FREEBSD_UPDATE}+= freebsd-update SUBDIR.${MK_GSSAPI}+= gssd SUBDIR.${MK_GPIO}+= gpioctl diff --git a/usr.sbin/fmtree/Makefile b/usr.sbin/fmtree/Makefile deleted file mode 100644 index c1ba3737b258..000000000000 --- a/usr.sbin/fmtree/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -# From: @(#)Makefile 8.1 (Berkeley) 6/6/93 -# $FreeBSD$ - -.include <bsd.own.mk> - -.PATH: ${SRCTOP}/usr.bin/cksum - -PROG= fmtree -MAN= fmtree.8 -SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c -SRCS+= specspec.c - -CFLAGS+= -DWITH_MD5 -DWITH_SHA1 -DWITH_RMD160 -DWITH_SHA256 -LIBADD= md - -CLEANFILES+= fmtree.8 - -fmtree.8: mtree.8 - ${CP} ${.ALLSRC} ${.TARGET} - -.include <bsd.prog.mk> diff --git a/usr.sbin/fmtree/Makefile.depend b/usr.sbin/fmtree/Makefile.depend deleted file mode 100644 index 31fbf9bc2f9f..000000000000 --- a/usr.sbin/fmtree/Makefile.depend +++ /dev/null @@ -1,18 +0,0 @@ -# $FreeBSD$ -# Autogenerated - do NOT edit! - -DIRDEPS = \ - gnu/lib/csu \ - include \ - include/xlocale \ - lib/${CSU_DIR} \ - lib/libc \ - lib/libcompiler_rt \ - lib/libmd \ - - -.include <dirdeps.mk> - -.if ${DEP_RELDIR} == ${_DEP_RELDIR} -# local dependencies - needed for -jN in clean tree -.endif diff --git a/usr.sbin/fmtree/compare.c b/usr.sbin/fmtree/compare.c deleted file mode 100644 index c59d01e651d4..000000000000 --- a/usr.sbin/fmtree/compare.c +++ /dev/null @@ -1,389 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)compare.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/stat.h> -#include <sys/time.h> - -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <fts.h> -#ifdef WITH_MD5 -#include <md5.h> -#endif -#ifdef WITH_RMD160 -#include <ripemd.h> -#endif -#ifdef WITH_SHA1 -#include <sha.h> -#endif -#ifdef WITH_SHA256 -#include <sha256.h> -#endif -#include <stdint.h> -#include <stdio.h> -#include <time.h> -#include <unistd.h> -#include <vis.h> - -#include "mtree.h" -#include "extern.h" - -#define INDENTNAMELEN 8 -#define LABEL \ - if (!label++) { \ - len = printf("%s changed\n", RP(p)); \ - tab = "\t"; \ - } - -int -compare(char *name __unused, NODE *s, FTSENT *p) -{ - struct timeval tv[2]; - uint32_t val; - int fd, label; - off_t len; - char *cp; - const char *tab = ""; - char *fflags; - - label = 0; - switch(s->type) { - case F_BLOCK: - if (!S_ISBLK(p->fts_statp->st_mode)) - goto typeerr; - break; - case F_CHAR: - if (!S_ISCHR(p->fts_statp->st_mode)) - goto typeerr; - break; - case F_DIR: - if (!S_ISDIR(p->fts_statp->st_mode)) - goto typeerr; - break; - case F_FIFO: - if (!S_ISFIFO(p->fts_statp->st_mode)) - goto typeerr; - break; - case F_FILE: - if (!S_ISREG(p->fts_statp->st_mode)) - goto typeerr; - break; - case F_LINK: - if (!S_ISLNK(p->fts_statp->st_mode)) - goto typeerr; - break; - case F_SOCK: - if (!S_ISSOCK(p->fts_statp->st_mode)) { -typeerr: LABEL; - (void)printf("\ttype expected %s found %s\n", - ftype(s->type), inotype(p->fts_statp->st_mode)); - return (label); - } - break; - } - /* Set the uid/gid first, then set the mode. */ - if (s->flags & (F_UID | F_UNAME) && s->st_uid != p->fts_statp->st_uid) { - LABEL; - (void)printf("%suser expected %lu found %lu", - tab, (u_long)s->st_uid, (u_long)p->fts_statp->st_uid); - if (uflag) - if (chown(p->fts_accpath, s->st_uid, -1)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); - else - (void)printf("\n"); - tab = "\t"; - } - if (s->flags & (F_GID | F_GNAME) && s->st_gid != p->fts_statp->st_gid) { - LABEL; - (void)printf("%sgid expected %lu found %lu", - tab, (u_long)s->st_gid, (u_long)p->fts_statp->st_gid); - if (uflag) - if (chown(p->fts_accpath, -1, s->st_gid)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); - else - (void)printf("\n"); - tab = "\t"; - } - if (s->flags & F_MODE && - !S_ISLNK(p->fts_statp->st_mode) && - s->st_mode != (p->fts_statp->st_mode & MBITS)) { - LABEL; - (void)printf("%spermissions expected %#o found %#o", - tab, s->st_mode, p->fts_statp->st_mode & MBITS); - if (uflag) - if (chmod(p->fts_accpath, s->st_mode)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); - else - (void)printf("\n"); - tab = "\t"; - } - if (s->flags & F_NLINK && s->type != F_DIR && - s->st_nlink != p->fts_statp->st_nlink) { - LABEL; - (void)printf("%slink_count expected %ju found %ju\n", - tab, (uintmax_t)s->st_nlink, - (uintmax_t)p->fts_statp->st_nlink); - tab = "\t"; - } - if (s->flags & F_SIZE && s->st_size != p->fts_statp->st_size && - !S_ISDIR(p->fts_statp->st_mode)) { - LABEL; - (void)printf("%ssize expected %jd found %jd\n", tab, - (intmax_t)s->st_size, (intmax_t)p->fts_statp->st_size); - tab = "\t"; - } - /* - * XXX - * Catches nano-second differences, but doesn't display them. - */ - if ((s->flags & F_TIME) && - ((s->st_mtimespec.tv_sec != p->fts_statp->st_mtim.tv_sec) || - (s->st_mtimespec.tv_nsec != p->fts_statp->st_mtim.tv_nsec))) { - LABEL; - (void)printf("%smodification time expected %.24s ", - tab, ctime(&s->st_mtimespec.tv_sec)); - (void)printf("found %.24s", - ctime(&p->fts_statp->st_mtim.tv_sec)); - if (uflag) { - tv[0].tv_sec = s->st_mtimespec.tv_sec; - tv[0].tv_usec = s->st_mtimespec.tv_nsec / 1000; - tv[1] = tv[0]; - if (utimes(p->fts_accpath, tv)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); - } else - (void)printf("\n"); - tab = "\t"; - } - if (s->flags & F_CKSUM) { - if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0) { - LABEL; - (void)printf("%scksum: %s: %s\n", - tab, p->fts_accpath, strerror(errno)); - tab = "\t"; - } else if (crc(fd, &val, &len)) { - (void)close(fd); - LABEL; - (void)printf("%scksum: %s: %s\n", - tab, p->fts_accpath, strerror(errno)); - tab = "\t"; - } else { - (void)close(fd); - if (s->cksum != val) { - LABEL; - (void)printf("%scksum expected %lu found %lu\n", - tab, s->cksum, (unsigned long)val); - tab = "\t"; - } - } - } - if ((s->flags & F_FLAGS) && s->st_flags != p->fts_statp->st_flags) { - LABEL; - fflags = flags_to_string(s->st_flags); - (void)printf("%sflags expected \"%s\"", tab, fflags); - free(fflags); - - fflags = flags_to_string(p->fts_statp->st_flags); - (void)printf(" found \"%s\"", fflags); - free(fflags); - - if (uflag) - if (chflags(p->fts_accpath, s->st_flags)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); - else - (void)printf("\n"); - tab = "\t"; - } -#ifdef WITH_MD5 - if (s->flags & F_MD5) { - char *new_digest, buf[33]; - - new_digest = MD5File(p->fts_accpath, buf); - if (!new_digest) { - LABEL; - printf("%sMD5: %s: %s\n", tab, p->fts_accpath, - strerror(errno)); - tab = "\t"; - } else if (strcmp(new_digest, s->md5digest)) { - LABEL; - printf("%sMD5 expected %s found %s\n", tab, s->md5digest, - new_digest); - tab = "\t"; - } - } -#endif /* MD5 */ -#ifdef WITH_SHA1 - if (s->flags & F_SHA1) { - char *new_digest, buf[41]; - - new_digest = SHA1_File(p->fts_accpath, buf); - if (!new_digest) { - LABEL; - printf("%sSHA-1: %s: %s\n", tab, p->fts_accpath, - strerror(errno)); - tab = "\t"; - } else if (strcmp(new_digest, s->sha1digest)) { - LABEL; - printf("%sSHA-1 expected %s found %s\n", - tab, s->sha1digest, new_digest); - tab = "\t"; - } - } -#endif /* SHA1 */ -#ifdef WITH_RMD160 - if (s->flags & F_RMD160) { - char *new_digest, buf[41]; - - new_digest = RIPEMD160_File(p->fts_accpath, buf); - if (!new_digest) { - LABEL; - printf("%sRIPEMD160: %s: %s\n", tab, - p->fts_accpath, strerror(errno)); - tab = "\t"; - } else if (strcmp(new_digest, s->rmd160digest)) { - LABEL; - printf("%sRIPEMD160 expected %s found %s\n", - tab, s->rmd160digest, new_digest); - tab = "\t"; - } - } -#endif /* RMD160 */ -#ifdef WITH_SHA256 - if (s->flags & F_SHA256) { - char *new_digest, buf[65]; - - new_digest = SHA256_File(p->fts_accpath, buf); - if (!new_digest) { - LABEL; - printf("%sSHA-256: %s: %s\n", tab, p->fts_accpath, - strerror(errno)); - tab = "\t"; - } else if (strcmp(new_digest, s->sha256digest)) { - LABEL; - printf("%sSHA-256 expected %s found %s\n", - tab, s->sha256digest, new_digest); - tab = "\t"; - } - } -#endif /* SHA256 */ - - if (s->flags & F_SLINK && - strcmp(cp = rlink(p->fts_accpath), s->slink)) { - LABEL; - (void)printf("%slink_ref expected %s found %s\n", - tab, s->slink, cp); - } - return (label); -} - -const char * -inotype(u_int type) -{ - switch(type & S_IFMT) { - case S_IFBLK: - return ("block"); - case S_IFCHR: - return ("char"); - case S_IFDIR: - return ("dir"); - case S_IFIFO: - return ("fifo"); - case S_IFREG: - return ("file"); - case S_IFLNK: - return ("link"); - case S_IFSOCK: - return ("socket"); - default: - return ("unknown"); - } - /* NOTREACHED */ -} - -const char * -ftype(u_int type) -{ - switch(type) { - case F_BLOCK: - return ("block"); - case F_CHAR: - return ("char"); - case F_DIR: - return ("dir"); - case F_FIFO: - return ("fifo"); - case F_FILE: - return ("file"); - case F_LINK: - return ("link"); - case F_SOCK: - return ("socket"); - default: - return ("unknown"); - } - /* NOTREACHED */ -} - -char * -rlink(char *name) -{ - static char lbuf[MAXPATHLEN * 4]; - int len; - char tbuf[MAXPATHLEN]; - - if ((len = readlink(name, tbuf, sizeof(tbuf) - 1)) == -1) - err(1, "line %d: %s", lineno, name); - tbuf[len] = '\0'; - strvis(lbuf, tbuf, VIS_WHITE | VIS_OCTAL); - return (lbuf); -} diff --git a/usr.sbin/fmtree/create.c b/usr.sbin/fmtree/create.c deleted file mode 100644 index edfb09ebd2f2..000000000000 --- a/usr.sbin/fmtree/create.c +++ /dev/null @@ -1,431 +0,0 @@ -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * 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. 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. - */ - -#if 0 -#ifndef lint -static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; -#endif /* not lint */ -#endif -#include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - -#include <sys/param.h> -#include <sys/stat.h> -#include <dirent.h> -#include <err.h> -#include <errno.h> -#include <fcntl.h> -#include <fts.h> -#include <grp.h> -#ifdef MD5 -#include <md5.h> -#endif -#ifdef SHA1 -#include <sha.h> -#endif -#ifdef RMD160 -#include <ripemd.h> -#endif -#ifdef SHA256 -#include <sha256.h> -#endif -#include <pwd.h> -#include <stdint.h> -#include <stdio.h> -#include <time.h> -#include <unistd.h> -#include <vis.h> -#include "mtree.h" -#include "extern.h" - -#define INDENTNAMELEN 15 -#define MAXLINELEN 80 - -static gid_t gid; -static uid_t uid; -static mode_t mode; -static u_long flags = 0xffffffff; - -static int dsort(const FTSENT * const *, const FTSENT * const *); -static void output(int, int *, const char *, ...) __printflike(3, 4); -static int statd(FTS *, FTSENT *, uid_t *, gid_t *, mode_t *, u_long *); -static void statf(int, FTSENT *); - -void -cwalk(void) -{ - FTS *t; - FTSENT *p; - time_t cl; - char *argv[2], host[MAXHOSTNAMELEN]; - char dot[] = "."; - int indent = 0; - - if (!nflag) { - (void)time(&cl); - (void)gethostname(host, sizeof(host)); - (void)printf( - "#\t user: %s\n#\tmachine: %s\n", - getlogin(), host); - (void)printf( - "#\t tree: %s\n#\t date: %s", - fullpath, ctime(&cl)); - } - - argv[0] = dot; - argv[1] = NULL; - if ((t = fts_open(argv, ftsoptions, dsort)) == NULL) - err(1, "fts_open()"); - while (errno = 0, (p = fts_read(t))) { - if (iflag) - indent = p->fts_level * 4; - if (check_excludes(p->fts_name, p->fts_path)) { - fts_set(t, p, FTS_SKIP); - continue; - } - switch(p->fts_info) { - case FTS_D: - if (!dflag) - (void)printf("\n"); - if (!nflag) - (void)printf("# %s\n", p->fts_path); - statd(t, p, &uid, &gid, &mode, &flags); - statf(indent, p); - break; - case FTS_DP: - if (!nflag && (p->fts_level > 0)) - (void)printf("%*s# %s\n", indent, "", p->fts_path); - (void)printf("%*s..\n", indent, ""); - if (!dflag) - (void)printf("\n"); - break; - case FTS_DNR: - case FTS_ERR: - case FTS_NS: - warnx("%s: %s", p->fts_path, strerror(p->fts_errno)); - break; - default: - if (!dflag) - statf(indent, p); - break; - - } - } - if (errno != 0) - err(1, "fts_read()"); - (void)fts_close(t); - if (sflag && keys & F_CKSUM) - warnx("%s checksum: %lu", fullpath, (unsigned long)crc_total); -} - -static void -statf(int indent, FTSENT *p) -{ - struct group *gr; - struct passwd *pw; - uint32_t val; - off_t len; - int fd, offset; - char *fflags; - char *escaped_name; - - escaped_name = calloc(1, p->fts_namelen * 4 + 1); - if (escaped_name == NULL) - errx(1, "statf(): calloc() failed"); - strvis(escaped_name, p->fts_name, VIS_WHITE | VIS_OCTAL | VIS_GLOB); - - if (iflag || S_ISDIR(p->fts_statp->st_mode)) - offset = printf("%*s%s", indent, "", escaped_name); - else - offset = printf("%*s %s", indent, "", escaped_name); - - free(escaped_name); - - if (offset > (INDENTNAMELEN + indent)) - offset = MAXLINELEN; - else - offset += printf("%*s", (INDENTNAMELEN + indent) - offset, ""); - - if (!S_ISREG(p->fts_statp->st_mode) && !dflag) - output(indent, &offset, "type=%s", inotype(p->fts_statp->st_mode)); - if (p->fts_statp->st_uid != uid) { - if (keys & F_UNAME) { - pw = getpwuid(p->fts_statp->st_uid); - if (pw != NULL) - output(indent, &offset, "uname=%s", pw->pw_name); - else if (wflag) - warnx("Could not get uname for uid=%u", - p->fts_statp->st_uid); - else - errx(1, - "Could not get uname for uid=%u", - p->fts_statp->st_uid); - } - if (keys & F_UID) - output(indent, &offset, "uid=%u", p->fts_statp->st_uid); - } - if (p->fts_statp->st_gid != gid) { - if (keys & F_GNAME) { - gr = getgrgid(p->fts_statp->st_gid); - if (gr != NULL) - output(indent, &offset, "gname=%s", gr->gr_name); - else if (wflag) - warnx("Could not get gname for gid=%u", - p->fts_statp->st_gid); - else - errx(1, - "Could not get gname for gid=%u", - p->fts_statp->st_gid); - } - if (keys & F_GID) - output(indent, &offset, "gid=%u", p->fts_statp->st_gid); - } - if (keys & F_MODE && (p->fts_statp->st_mode & MBITS) != mode) - output(indent, &offset, "mode=%#o", p->fts_statp->st_mode & MBITS); - if (keys & F_NLINK && p->fts_statp->st_nlink != 1) - output(indent, &offset, "nlink=%ju", - (uintmax_t)p->fts_statp->st_nlink); - if (keys & F_SIZE && S_ISREG(p->fts_statp->st_mode)) - output(indent, &offset, "size=%jd", - (intmax_t)p->fts_statp->st_size); - if (keys & F_TIME) - output(indent, &offset, "time=%ld.%09ld", - (long)p->fts_statp->st_mtim.tv_sec, - p->fts_statp->st_mtim.tv_nsec); - if (keys & F_CKSUM && S_ISREG(p->fts_statp->st_mode)) { - if ((fd = open(p->fts_accpath, O_RDONLY, 0)) < 0 || - crc(fd, &val, &len)) - err(1, "%s", p->fts_accpath); - (void)close(fd); - output(indent, &offset, "cksum=%lu", (unsigned long)val); - } -#ifdef MD5 - if (keys & F_MD5 && S_ISREG(p->fts_statp->st_mode)) { - char *digest, buf[33]; - - digest = MD5File(p->fts_accpath, buf); - if (!digest) - err(1, "%s", p->fts_accpath); - output(indent, &offset, "md5digest=%s", digest); - } -#endif /* MD5 */ -#ifdef SHA1 - if (keys & F_SHA1 && S_ISREG(p->fts_statp->st_mode)) { - char *digest, buf[41]; - - digest = SHA1_File(p->fts_accpath, buf); - if (!digest) - err(1, "%s", p->fts_accpath); - output(indent, &offset, "sha1digest=%s", digest); - } -#endif /* SHA1 */ -#ifdef RMD160 - if (keys & F_RMD160 && S_ISREG(p->fts_statp->st_mode)) { - char *digest, buf[41]; - - digest = RIPEMD160_File(p->fts_accpath, buf); - if (!digest) - err(1, "%s", p->fts_accpath); - output(indent, &offset, "ripemd160digest=%s", digest); - } -#endif /* RMD160 */ -#ifdef SHA256 - if (keys & F_SHA256 && S_ISREG(p->fts_statp->st_mode)) { - char *digest, buf[65]; - - digest = SHA256_File(p->fts_accpath, buf); - if (!digest) - err(1, "%s", p->fts_accpath); - output(indent, &offset, "sha256digest=%s", digest); - } -#endif /* SHA256 */ - if (keys & F_SLINK && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) - output(indent, &offset, "link=%s", rlink(p->fts_accpath)); - if (keys & F_FLAGS && p->fts_statp->st_flags != flags) { - fflags = flags_to_string(p->fts_statp->st_flags); - output(indent, &offset, "flags=%s", fflags); - free(fflags); - } - (void)putchar('\n'); -} - -#define MAXGID 5000 -#define MAXUID 5000 -#define MAXMODE MBITS + 1 -#define MAXFLAGS 256 -#define MAXS 16 - -static int -statd(FTS *t, FTSENT *parent, uid_t *puid, gid_t *pgid, mode_t *pmode, u_long *pflags) -{ - FTSENT *p; - gid_t sgid; - uid_t suid; - mode_t smode; - u_long sflags; - struct group *gr; - struct passwd *pw; - gid_t savegid = *pgid; - uid_t saveuid = *puid; - mode_t savemode = *pmode; - u_long saveflags = *pflags; - u_short maxgid, maxuid, maxmode, maxflags; - u_short g[MAXGID], u[MAXUID], m[MAXMODE], f[MAXFLAGS]; - char *fflags; - static int first = 1; - - if ((p = fts_children(t, 0)) == NULL) { - if (errno) - err(1, "%s", RP(parent)); - return (1); - } - - bzero(g, sizeof(g)); - bzero(u, sizeof(u)); - bzero(m, sizeof(m)); - bzero(f, sizeof(f)); - - maxuid = maxgid = maxmode = maxflags = 0; - for (; p; p = p->fts_link) { - if (!dflag || (dflag && S_ISDIR(p->fts_statp->st_mode))) { - smode = p->fts_statp->st_mode & MBITS; - if (smode < MAXMODE && ++m[smode] > maxmode) { - savemode = smode; - maxmode = m[smode]; - } - sgid = p->fts_statp->st_gid; - if (sgid < MAXGID && ++g[sgid] > maxgid) { - savegid = sgid; - maxgid = g[sgid]; - } - suid = p->fts_statp->st_uid; - if (suid < MAXUID && ++u[suid] > maxuid) { - saveuid = suid; - maxuid = u[suid]; - } - - /* - * XXX - * note that the below will break when file flags - * are extended beyond the first 4 bytes of each - * half word of the flags - */ -#define FLAGS2IDX(f) ((f & 0xf) | ((f >> 12) & 0xf0)) - sflags = p->fts_statp->st_flags; - if (FLAGS2IDX(sflags) < MAXFLAGS && - ++f[FLAGS2IDX(sflags)] > maxflags) { - saveflags = sflags; - maxflags = f[FLAGS2IDX(sflags)]; - } - } - } - /* - * If the /set record is the same as the last one we do not need to output - * a new one. So first we check to see if anything changed. Note that we - * always output a /set record for the first directory. - */ - if ((((keys & F_UNAME) | (keys & F_UID)) && (*puid != saveuid)) || - (((keys & F_GNAME) | (keys & F_GID)) && (*pgid != savegid)) || - ((keys & F_MODE) && (*pmode != savemode)) || - ((keys & F_FLAGS) && (*pflags != saveflags)) || - (first)) { - first = 0; - if (dflag) - (void)printf("/set type=dir"); - else - (void)printf("/set type=file"); - if (keys & F_UNAME) { - pw = getpwuid(saveuid); - if (pw != NULL) - (void)printf(" uname=%s", pw->pw_name); - else if (wflag) - warnx( "Could not get uname for uid=%u", saveuid); - else - errx(1, "Could not get uname for uid=%u", saveuid); - } - if (keys & F_UID) - (void)printf(" uid=%lu", (u_long)saveuid); - if (keys & F_GNAME) { - gr = getgrgid(savegid); - if (gr != NULL) - (void)printf(" gname=%s", gr->gr_name); - else if (wflag) - warnx("Could not get gname for gid=%u", savegid); - else - errx(1, "Could not get gname for gid=%u", savegid); - } - if (keys & F_GID) - (void)printf(" gid=%lu", (u_long)savegid); - if (keys & F_MODE) - (void)printf(" mode=%#o", savemode); - if (keys & F_NLINK) - (void)printf(" nlink=1"); - if (keys & F_FLAGS) { - fflags = flags_to_string(saveflags); - (void)printf(" flags=%s", fflags); - free(fflags); - } - (void)printf("\n"); - *puid = saveuid; - *pgid = savegid; - *pmode = savemode; - *pflags = saveflags; - } - return (0); -} - -static int -dsort(const FTSENT * const *a, const FTSENT * const *b) -{ - if (S_ISDIR((*a)->fts_statp->st_mode)) { - if (!S_ISDIR((*b)->fts_statp->st_mode)) - return (1); - } else if (S_ISDIR((*b)->fts_statp->st_mode)) - return (-1); - return (strcmp((*a)->fts_name, (*b)->fts_name)); -} *** 2218 LINES SKIPPED *** _______________________________________________ dev-commits-src-all@freebsd.org mailing list https://lists.freebsd.org/mailman/listinfo/dev-commits-src-all To unsubscribe, send any mail to "dev-commits-src-all-unsubscr...@freebsd.org"