diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-08-10 02:33:47 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-08-10 02:33:47 +0000 |
commit | 5750940275ee45e548ad1a04573ecc745d6bb077 (patch) | |
tree | 796a18be9775928c677a6b28349a057627e43159 /usr.sbin/mtree/compare.c | |
parent | 9dfada6aaa5bbdeae95706bad70116b9ea08fa7a (diff) |
Add file flag support to mtree from henning@crackinghacking.de
with man page update and minor tweaks by me.
Diffstat (limited to 'usr.sbin/mtree/compare.c')
-rw-r--r-- | usr.sbin/mtree/compare.c | 50 |
1 files changed, 48 insertions, 2 deletions
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c index dcca39f9e9a..5d0c57828a2 100644 --- a/usr.sbin/mtree/compare.c +++ b/usr.sbin/mtree/compare.c @@ -1,5 +1,5 @@ /* $NetBSD: compare.c,v 1.11 1996/09/05 09:56:48 mycroft Exp $ */ -/* $OpenBSD: compare.c,v 1.10 1998/05/18 19:10:06 deraadt Exp $ */ +/* $OpenBSD: compare.c,v 1.11 2001/08/10 02:33:46 millert Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)compare.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: compare.c,v 1.10 1998/05/18 19:10:06 deraadt Exp $"; +static char rcsid[] = "$OpenBSD: compare.c,v 1.11 2001/08/10 02:33:46 millert Exp $"; #endif #endif /* not lint */ @@ -73,6 +73,15 @@ static char *ftype __P((u_int)); } \ } +#define REPLACE_COMMA(x) \ + do { \ + char *l; \ + for (l = x; *l; l++) { \ + if (*l == ',') \ + *l = ' '; \ + } \ + } while (0) \ + int compare(name, s, p) char *name; @@ -279,6 +288,43 @@ typeerr: LABEL; LABEL; (void)printf("%slink ref (%s, %s)\n", tab, cp, s->slink); } + if (s->flags & F_FLAGS && s->file_flags != p->fts_statp->st_flags) { + char *db_flags = NULL; + char *cur_flags = NULL; + + if ((db_flags = fflagstostr(s->file_flags)) == NULL || + (cur_flags = fflagstostr(p->fts_statp->st_flags)) == NULL) { + LABEL; + (void)printf("%sflags: %s %s\n", tab, p->fts_accpath, + strerror(errno)); + tab = "\t"; + if (db_flags != NULL) + free(db_flags); + if (cur_flags != NULL) + free(cur_flags); + } else { + LABEL; + REPLACE_COMMA(db_flags); + REPLACE_COMMA(cur_flags); + printf("%sflags (%s, %s", tab, (*db_flags == '\0') ? + "-" : db_flags, + (*cur_flags == '\0') ? + "-" : cur_flags); + tab = "\t"; + if (uflag) + if (chflags(p->fts_accpath, s->file_flags)) + (void)printf(", not modified: %s)\n", + strerror(errno)); + else + (void)printf(", modified)\n"); + else + (void)printf(")\n"); + tab = "\t"; + + free(db_flags); + free(cur_flags); + } + } return (label); } |