diff options
-rw-r--r-- | usr.sbin/mtree/compare.c | 50 | ||||
-rw-r--r-- | usr.sbin/mtree/create.c | 16 | ||||
-rw-r--r-- | usr.sbin/mtree/misc.c | 3 | ||||
-rw-r--r-- | usr.sbin/mtree/mtree.8 | 13 | ||||
-rw-r--r-- | usr.sbin/mtree/mtree.h | 4 | ||||
-rw-r--r-- | usr.sbin/mtree/spec.c | 16 |
6 files changed, 90 insertions, 12 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); } diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c index 26e046aa6a1..12a2ab0fdaa 100644 --- a/usr.sbin/mtree/create.c +++ b/usr.sbin/mtree/create.c @@ -1,5 +1,5 @@ /* $NetBSD: create.c,v 1.11 1996/09/05 09:24:19 mycroft Exp $ */ -/* $OpenBSD: create.c,v 1.11 1997/11/05 20:31:26 flipk Exp $ */ +/* $OpenBSD: create.c,v 1.12 2001/08/10 02:33:46 millert Exp $ */ /*- * Copyright (c) 1989, 1993 @@ -38,7 +38,7 @@ #if 0 static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: create.c,v 1.11 1997/11/05 20:31:26 flipk Exp $"; +static char rcsid[] = "$OpenBSD: create.c,v 1.12 2001/08/10 02:33:46 millert Exp $"; #endif #endif /* not lint */ @@ -227,6 +227,18 @@ statf(indent, p) 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 && !S_ISLNK(p->fts_statp->st_mode)) { + char *file_flags; + + file_flags = fflagstostr(p->fts_statp->st_flags); + if (file_flags == NULL) + error("%s", strerror(errno)); + if (*file_flags != '\0') + output(indent, &offset, "flags=%s", file_flags); + else + output(indent, &offset, "flags=none"); + free(file_flags); + } (void)putchar('\n'); } diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c index a5c09e21c65..2a033f7aace 100644 --- a/usr.sbin/mtree/misc.c +++ b/usr.sbin/mtree/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.8 1997/07/25 20:12:14 mickey Exp $ */ +/* $OpenBSD: misc.c,v 1.9 2001/08/10 02:33:46 millert Exp $ */ /* $NetBSD: misc.c,v 1.4 1995/03/07 21:26:23 cgd Exp $ */ /*- @@ -56,6 +56,7 @@ typedef struct _key { /* NB: the following table must be sorted lexically. */ static KEY keylist[] = { {"cksum", F_CKSUM, NEEDVALUE}, + {"flags", F_FLAGS, NEEDVALUE}, {"gid", F_GID, NEEDVALUE}, {"gname", F_GNAME, NEEDVALUE}, {"ignore", F_IGN, 0}, diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8 index aa19937cf48..4df52045208 100644 --- a/usr.sbin/mtree/mtree.8 +++ b/usr.sbin/mtree/mtree.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: mtree.8,v 1.16 2001/04/18 14:39:24 aaron Exp $ +.\" $OpenBSD: mtree.8,v 1.17 2001/08/10 02:33:46 millert Exp $ .\" $NetBSD: mtree.8,v 1.4 1995/03/07 21:26:25 cgd Exp $ .\" .\" Copyright (c) 1989, 1990, 1993 @@ -145,12 +145,19 @@ The checksum of the file using the default algorithm specified by the .Xr cksum 1 utility. -.It Cm ignore -Ignore any file hierarchy below this file. +.It Cm flags +The current file's flags (whitespace or comma separated) in symbolic form +as specified by +.Xr chflags 1 . +The string +.Dq none +may be used to indicate that no flags should be set on the file. .It Cm gid The file group as a numeric value. .It Cm gname The file group as a symbolic name. +.It Cm ignore +Ignore any file hierarchy below this file. .It Cm md5digest The MD5 message digest of the file. .It Cm mode diff --git a/usr.sbin/mtree/mtree.h b/usr.sbin/mtree/mtree.h index f0f8a025140..7bcdf048b0d 100644 --- a/usr.sbin/mtree/mtree.h +++ b/usr.sbin/mtree/mtree.h @@ -1,4 +1,4 @@ -/* $OpenBSD: mtree.h,v 1.6 1997/07/18 05:46:13 millert Exp $ */ +/* $OpenBSD: mtree.h,v 1.7 2001/08/10 02:33:46 millert Exp $ */ /* $NetBSD: mtree.h,v 1.7 1995/03/07 21:26:27 cgd Exp $ */ /*- @@ -59,6 +59,7 @@ typedef struct _node { #define MBITS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) mode_t st_mode; /* mode */ nlink_t st_nlink; /* link count */ + u_int32_t file_flags; /* file flags */ #define F_CKSUM 0x00001 /* check sum */ #define F_DONE 0x00002 /* directory done */ @@ -79,6 +80,7 @@ typedef struct _node { #define F_UID 0x10000 /* uid */ #define F_UNAME 0x20000 /* user name */ #define F_VISIT 0x40000 /* file visited */ +#define F_FLAGS 0x80000 /* file flags */ u_int32_t flags; /* items set */ #define F_BLOCK 0x001 /* block special */ diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c index 83631ec3e03..c1672acc81f 100644 --- a/usr.sbin/mtree/spec.c +++ b/usr.sbin/mtree/spec.c @@ -1,5 +1,5 @@ /* $NetBSD: spec.c,v 1.6 1995/03/07 21:12:12 cgd Exp $ */ -/* $OpenBSD: spec.c,v 1.10 1998/09/24 02:42:38 millert Exp $ */ +/* $OpenBSD: spec.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[] = "@(#)spec.c 8.1 (Berkeley) 6/6/93"; #else -static char rcsid[] = "$OpenBSD: spec.c,v 1.10 1998/09/24 02:42:38 millert Exp $"; +static char rcsid[] = "$OpenBSD: spec.c,v 1.11 2001/08/10 02:33:46 millert Exp $"; #endif #endif /* not lint */ @@ -171,11 +171,12 @@ set(t, ip) register NODE *ip; { register int type; - register char *kw, *val = NULL; + char *kw, *val = NULL; struct group *gr; struct passwd *pw; mode_t *m; int value; + u_int32_t fset, fclr; char *ep; for (; (kw = strtok(t, "= \t\n")); t = NULL) { @@ -193,6 +194,15 @@ set(t, ip) if (!ip->md5digest) error("%s", strerror(errno)); break; + case F_FLAGS: + if (!strcmp(val, "none")) { + ip->file_flags = 0; + break; + } + if (strtofflags(&val, &fset, &fclr)) + error("%s", strerror(errno)); + ip->file_flags = fset; + break; case F_GID: ip->st_gid = strtoul(val, &ep, 10); if (*ep) |