summaryrefslogtreecommitdiffstats
path: root/usr.sbin/mtree
diff options
context:
space:
mode:
authorjoe <joe@FreeBSD.org>2000-06-17 14:19:33 +0000
committerjoe <joe@FreeBSD.org>2000-06-17 14:19:33 +0000
commit8de98cc2fa7b119cc8deb33c61c9496d25825b49 (patch)
tree33363d4028bb162e624a3a2c5257ab020378f6e0 /usr.sbin/mtree
parent3e8b2c512359fd536c5f66fbd9e265064d461886 (diff)
downloadFreeBSD-src-8de98cc2fa7b119cc8deb33c61c9496d25825b49.zip
FreeBSD-src-8de98cc2fa7b119cc8deb33c61c9496d25825b49.tar.gz
Switch over to using the new fflagstostr and strtofflags library calls.
Diffstat (limited to 'usr.sbin/mtree')
-rw-r--r--usr.sbin/mtree/Makefile5
-rw-r--r--usr.sbin/mtree/compare.c13
-rw-r--r--usr.sbin/mtree/create.c18
-rw-r--r--usr.sbin/mtree/extern.h3
-rw-r--r--usr.sbin/mtree/misc.c18
-rw-r--r--usr.sbin/mtree/spec.c2
6 files changed, 43 insertions, 16 deletions
diff --git a/usr.sbin/mtree/Makefile b/usr.sbin/mtree/Makefile
index f6b46ef..8213854 100644
--- a/usr.sbin/mtree/Makefile
+++ b/usr.sbin/mtree/Makefile
@@ -2,10 +2,9 @@
# $FreeBSD$
PROG= mtree
-SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c \
- setflags.c
+SRCS= compare.c crc.c create.c excludes.c misc.c mtree.c spec.c verify.c
MAN8= mtree.8
-.PATH: ${.CURDIR}/../../usr.bin/cksum ${.CURDIR}/../../lib/libc/gen
+.PATH: ${.CURDIR}/../../usr.bin/cksum
.if !defined(WORLD)
DPADD+= ${LIBMD}
diff --git a/usr.sbin/mtree/compare.c b/usr.sbin/mtree/compare.c
index 007edb7..4168121 100644
--- a/usr.sbin/mtree/compare.c
+++ b/usr.sbin/mtree/compare.c
@@ -88,6 +88,7 @@ compare(name, s, p)
u_long len, val;
int fd, label;
char *cp, *tab = "";
+ char *fflags;
label = 0;
switch(s->type) {
@@ -224,10 +225,14 @@ typeerr: LABEL;
*/
if ((s->flags & F_FLAGS) && s->st_flags != p->fts_statp->st_flags) {
LABEL;
- (void)printf("%sflags (\"%s\" is not ", tab,
- getflags(s->st_flags, "none"));
- (void)printf("\"%s\"",
- getflags(p->fts_statp->st_flags, "none"));
+ fflags = flags_to_string(s->st_flags);
+ (void)printf("%sflags (\"%s\" is not ", tab, fflags);
+ free(fflags);
+
+ fflags = flags_to_string(p->fts_statp->st_flags);
+ (void)printf("\"%s\"", fflags);
+ free(fflags);
+
if (uflag)
if (chflags(p->fts_accpath, s->st_flags))
(void)printf(", not modified: %s)\n",
diff --git a/usr.sbin/mtree/create.c b/usr.sbin/mtree/create.c
index bc1ae0d..6a2d005 100644
--- a/usr.sbin/mtree/create.c
+++ b/usr.sbin/mtree/create.c
@@ -153,6 +153,7 @@ statf(indent, p)
struct passwd *pw;
u_long len, val;
int fd, offset;
+ char *fflags;
char *escaped_name;
escaped_name = calloc(1, p->fts_namelen * 4 + 1);
@@ -256,9 +257,11 @@ 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 && p->fts_statp->st_flags != flags)
- output(indent, &offset, "flags=%s",
- getflags(p->fts_statp->st_flags, "none"));
+ 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');
}
@@ -290,6 +293,7 @@ statd(t, parent, puid, pgid, pmode, pflags)
u_long saveflags = 0;
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) {
@@ -374,9 +378,11 @@ statd(t, parent, puid, pgid, pmode, pflags)
(void)printf(" mode=%#o", savemode);
if (keys & F_NLINK)
(void)printf(" nlink=1");
- if (keys & F_FLAGS && saveflags)
- (void)printf(" flags=%s",
- getflags(saveflags, "none"));
+ if (keys & F_FLAGS && saveflags) {
+ fflags = flags_to_string(saveflags);
+ (void)printf(" flags=%s", fflags);
+ free(fflags);
+ }
(void)printf("\n");
*puid = saveuid;
*pgid = savegid;
diff --git a/usr.sbin/mtree/extern.h b/usr.sbin/mtree/extern.h
index c57a338..54dafdf 100644
--- a/usr.sbin/mtree/extern.h
+++ b/usr.sbin/mtree/extern.h
@@ -37,8 +37,7 @@
int compare __P((char *, NODE *, FTSENT *));
int crc __P((int, u_long *, u_long *));
void cwalk __P((void));
-char *flags_to_string __P((u_long, char *));
-int string_to_flags __P((char **, u_long *, u_long *));
+char *flags_to_string __P((u_long));
char *inotype __P((u_int));
u_int parsekey __P((char *, int *));
diff --git a/usr.sbin/mtree/misc.c b/usr.sbin/mtree/misc.c
index ea413dd..7721ff4 100644
--- a/usr.sbin/mtree/misc.c
+++ b/usr.sbin/mtree/misc.c
@@ -44,6 +44,7 @@ static const char rcsid[] =
#include <err.h>
#include <fts.h>
#include <stdio.h>
+#include <unistd.h>
#include "mtree.h"
#include "extern.h"
@@ -109,3 +110,20 @@ keycompare(a, b)
{
return (strcmp(((KEY *)a)->name, ((KEY *)b)->name));
}
+
+char *
+flags_to_string(fflags)
+ u_long fflags;
+{
+ char *string;
+
+ string = fflagstostr(fflags);
+ if (string != NULL && *string == '\0') {
+ free(string);
+ string = strdup("none");
+ }
+ if (string == NULL)
+ err(1, NULL);
+
+ return string;
+}
diff --git a/usr.sbin/mtree/spec.c b/usr.sbin/mtree/spec.c
index 10c3704..4cbf80b 100644
--- a/usr.sbin/mtree/spec.c
+++ b/usr.sbin/mtree/spec.c
@@ -214,7 +214,7 @@ set(t, ip)
case F_FLAGS:
if (strcmp("none", val) == 0)
ip->st_flags = 0;
- else if (setflags(&val, &ip->st_flags, NULL) != 0)
+ else if (strtofflags(&val, &ip->st_flags, NULL) != 0)
errx(1, "line %d: invalid flag %s",lineno, val);
break;
case F_GID:
OpenPOWER on IntegriCloud