Use u_int32_t rather than Sys-V u_long.

Rename err() to mtree_err(), to avoid conflict with libc.
This commit is contained in:
wsanchez 1998-10-08 02:04:55 +00:00
parent 3e7294fa8d
commit c45946d27c
8 changed files with 77 additions and 49 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: compare.c,v 1.15 1998/08/27 18:03:45 ross Exp $ */
/* $NetBSD: compare.c,v 1.16 1998/10/08 02:04:55 wsanchez Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)compare.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: compare.c,v 1.15 1998/08/27 18:03:45 ross Exp $");
__RCSID("$NetBSD: compare.c,v 1.16 1998/10/08 02:04:55 wsanchez Exp $");
#endif
#endif /* not lint */
@ -76,7 +76,7 @@ compare(name, s, p)
NODE *s;
FTSENT *p;
{
u_long len, val;
u_int32_t len, val;
int fd, label;
char *cp, *tab;
@ -222,7 +222,7 @@ typeerr: LABEL;
if (s->cksum != val) {
LABEL;
(void)printf("%scksum (%lu, %lu)\n",
tab, s->cksum, val);
tab, s->cksum, (unsigned long)val);
}
tab = "\t";
}
@ -292,7 +292,7 @@ rlink(name)
int len;
if ((len = readlink(name, lbuf, sizeof(lbuf))) == -1)
err("%s: %s", name, strerror(errno));
mtree_err("%s: %s", name, strerror(errno));
lbuf[len] = '\0';
return (lbuf);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: create.c,v 1.16 1998/08/30 03:20:09 nathanw Exp $ */
/* $NetBSD: create.c,v 1.17 1998/10/08 02:04:56 wsanchez Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)create.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: create.c,v 1.16 1998/08/30 03:20:09 nathanw Exp $");
__RCSID("$NetBSD: create.c,v 1.17 1998/10/08 02:04:56 wsanchez Exp $");
#endif
#endif /* not lint */
@ -92,7 +92,7 @@ cwalk()
argv[0] = ".";
argv[1] = NULL;
if ((t = fts_open(argv, ftsoptions, dsort)) == NULL)
err("fts_open: %s", strerror(errno));
mtree_err("fts_open: %s", strerror(errno));
while ((p = fts_read(t)) != NULL)
switch(p->fts_info) {
case FTS_D:
@ -128,7 +128,7 @@ statf(p)
{
struct group *gr;
struct passwd *pw;
u_long len, val;
u_int32_t len, val;
int fd, indent;
if (S_ISDIR(p->fts_statp->st_mode))
@ -161,14 +161,21 @@ statf(p)
output(&indent, "nlink=%u", p->fts_statp->st_nlink);
if (keys & F_SIZE && S_ISREG(p->fts_statp->st_mode))
output(&indent, "size=%qd", p->fts_statp->st_size);
#ifndef __APPLE__
if (keys & F_TIME)
output(&indent, "time=%ld.%ld",
p->fts_statp->st_mtimespec.tv_sec,
p->fts_statp->st_mtimespec.tv_nsec);
#else
if (keys & F_TIME)
output(&indent, "time=%ld.%ld",
p->fts_statp->st_mtimespec.ts_sec,
p->fts_statp->st_mtimespec.ts_nsec);
#endif
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("%s: %s", p->fts_accpath, strerror(errno));
mtree_err("%s: %s", p->fts_accpath, strerror(errno));
(void)close(fd);
output(&indent, "cksum=%lu", val);
}
@ -206,7 +213,7 @@ statd(t, parent, puid, pgid, pmode)
savemode = 0;
if ((p = fts_children(t, 0)) == NULL) {
if (errno)
err("%s: %s", RP(parent), strerror(errno));
mtree_err("%s: %s", RP(parent), strerror(errno));
return (1);
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: extern.h,v 1.3 1995/03/07 21:12:07 cgd Exp $ */
/* $NetBSD: extern.h,v 1.4 1998/10/08 02:04:56 wsanchez Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -35,10 +35,16 @@
* @(#)extern.h 8.1 (Berkeley) 6/6/93
*/
#include "mtree.h"
#ifdef __APPLE__
#include <fts.h>
#endif
int compare __P((char *, NODE *, FTSENT *));
int crc __P((int, u_long *, u_long *));
int crc __P((int, u_int32_t *, u_int32_t *));
void cwalk __P((void));
void err __P((const char *, ...));
void mtree_err __P((const char *, ...));
char *inotype __P((u_int));
u_int parsekey __P((char *, int *));
char *rlink __P((char *));

View File

@ -1,4 +1,4 @@
/* $NetBSD: misc.c,v 1.5 1997/10/17 11:46:40 lukem Exp $ */
/* $NetBSD: misc.c,v 1.6 1998/10/08 02:04:56 wsanchez Exp $ */
/*-
* Copyright (c) 1991, 1993
@ -37,7 +37,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: misc.c,v 1.5 1997/10/17 11:46:40 lukem Exp $");
__RCSID("$NetBSD: misc.c,v 1.6 1998/10/08 02:04:56 wsanchez Exp $");
#endif /* not lint */
#include <sys/types.h>
@ -87,7 +87,7 @@ parsekey(name, needvaluep)
k = (KEY *)bsearch(&tmp, keylist, sizeof(keylist) / sizeof(KEY),
sizeof(KEY), keycompare);
if (k == NULL)
err("unknown keyword %s", name);
mtree_err("unknown keyword %s", name);
if (needvaluep)
*needvaluep = k->flags & NEEDVALUE ? 1 : 0;
@ -109,9 +109,9 @@ keycompare(a, b)
void
#if __STDC__
err(const char *fmt, ...)
mtree_err(const char *fmt, ...)
#else
err(fmt, va_alist)
mtree_err(fmt, va_alist)
char *fmt;
va_dcl
#endif

View File

@ -1,4 +1,4 @@
/* $NetBSD: mtree.c,v 1.9 1997/10/17 11:46:51 lukem Exp $ */
/* $NetBSD: mtree.c,v 1.10 1998/10/08 02:04:56 wsanchez Exp $ */
/*-
* Copyright (c) 1989, 1990, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1989, 1990, 1993\n\
#if 0
static char sccsid[] = "@(#)mtree.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: mtree.c,v 1.9 1997/10/17 11:46:51 lukem Exp $");
__RCSID("$NetBSD: mtree.c,v 1.10 1998/10/08 02:04:56 wsanchez Exp $");
#endif
#endif /* not lint */
@ -90,7 +90,7 @@ main(argc, argv)
break;
case 'f':
if (!(freopen(optarg, "r", stdin)))
err("%s: %s", optarg, strerror(errno));
mtree_err("%s: %s", optarg, strerror(errno));
break;
case 'K':
while ((p = strsep(&optarg, " \t,")) != NULL)
@ -113,7 +113,7 @@ main(argc, argv)
sflag = 1;
crc_total = ~strtol(optarg, &p, 0);
if (*p)
err("illegal seed value -- %s", optarg);
mtree_err("illegal seed value -- %s", optarg);
break;
case 't':
tflag = 1;
@ -138,10 +138,10 @@ main(argc, argv)
usage();
if (dir && chdir(dir))
err("%s: %s", dir, strerror(errno));
mtree_err("%s: %s", dir, strerror(errno));
if ((cflag || sflag) && !getwd(fullpath))
err("%s", fullpath);
mtree_err("%s", fullpath);
if (cflag) {
cwalk();

View File

@ -1,4 +1,4 @@
/* $NetBSD: mtree.h,v 1.7 1995/03/07 21:26:27 cgd Exp $ */
/* $NetBSD: mtree.h,v 1.8 1998/10/08 02:04:56 wsanchez Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -35,8 +35,12 @@
* @(#)mtree.h 8.1 (Berkeley) 6/6/93
*/
#ifndef _MTREE_H_
#define _MTREE_H_
#include <string.h>
#include <stdlib.h>
#include <sys/time.h>
#define KEYDEFAULT \
(F_GID | F_MODE | F_NLINK | F_SIZE | F_SLINK | F_TIME | F_UID)
@ -89,3 +93,5 @@ typedef struct _node {
#define RP(p) \
((p)->fts_path[0] == '.' && (p)->fts_path[1] == '/' ? \
(p)->fts_path + 2 : (p)->fts_path)
#endif /* _MTREE_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: spec.c,v 1.12 1998/09/23 19:46:00 itohy Exp $ */
/* $NetBSD: spec.c,v 1.13 1998/10/08 02:04:57 wsanchez Exp $ */
/*-
* Copyright (c) 1989, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)spec.c 8.2 (Berkeley) 4/28/95";
#else
__RCSID("$NetBSD: spec.c,v 1.12 1998/09/23 19:46:00 itohy Exp $");
__RCSID("$NetBSD: spec.c,v 1.13 1998/10/08 02:04:57 wsanchez Exp $");
#endif
#endif /* not lint */
@ -82,7 +82,7 @@ spec()
/* Find end of line. */
if ((p = strchr(buf, '\n')) == NULL)
err("line %d too long", lineno);
mtree_err("line %d too long", lineno);
/* See if next line is continuation line. */
if (p[-1] == '\\') {
@ -110,7 +110,7 @@ spec()
/* Grab file name, "$", "set", or "unset". */
if ((p = strtok(p, "\n\t ")) == NULL)
err("missing field");
mtree_err("missing field");
if (p[0] == '/')
switch(p[1]) {
@ -127,7 +127,7 @@ spec()
}
if (strchr(p, '/'))
err("slash character in file name");
mtree_err("slash character in file name");
if (!strcmp(p, "..")) {
/* Don't go up, if haven't gone down. */
@ -141,11 +141,11 @@ spec()
last->flags |= F_DONE;
continue;
noparent: err("no parent node");
noparent: mtree_err("no parent node");
}
if ((centry = calloc(1, sizeof(NODE) + strlen(p))) == NULL)
err("%s", strerror(errno));
mtree_err("%s", strerror(errno));
*centry = ginfo;
(void)strcpy(centry->name, p);
#define MAGIC "?*["
@ -185,21 +185,21 @@ set(t, ip)
for (; (kw = strtok(t, "= \t\n")) != NULL; t = NULL) {
ip->flags |= type = parsekey(kw, &value);
if (value && (val = strtok(NULL, " \t\n")) == NULL)
err("missing value");
mtree_err("missing value");
switch(type) {
case F_CKSUM:
ip->cksum = strtoul(val, &ep, 10);
if (*ep)
err("invalid checksum %s", val);
mtree_err("invalid checksum %s", val);
break;
case F_GID:
ip->st_gid = (gid_t)strtoul(val, &ep, 10);
if (*ep)
err("invalid gid %s", val);
mtree_err("invalid gid %s", val);
break;
case F_GNAME:
if ((gr = getgrnam(val)) == NULL)
err("unknown group %s", val);
mtree_err("unknown group %s", val);
ip->st_gid = gr->gr_gid;
break;
case F_IGN:
@ -207,33 +207,42 @@ set(t, ip)
break;
case F_MODE:
if ((m = setmode(val)) == NULL)
err("invalid file mode %s", val);
mtree_err("invalid file mode %s", val);
ip->st_mode = getmode(m, 0);
free(m);
break;
case F_NLINK:
ip->st_nlink = (nlink_t)strtoul(val, &ep, 10);
if (*ep)
err("invalid link count %s", val);
mtree_err("invalid link count %s", val);
break;
case F_SIZE:
ip->st_size = (off_t)strtoq(val, &ep, 10);
if (*ep)
err("invalid size %s", val);
mtree_err("invalid size %s", val);
break;
case F_SLINK:
if ((ip->slink = strdup(val)) == NULL)
err("%s", strerror(errno));
mtree_err("%s", strerror(errno));
break;
case F_TIME:
#ifndef __APPLE__
ip->st_mtimespec.tv_sec =
(time_t)strtoul(val, &ep, 10);
#else
ip->st_mtimespec.ts_sec =
(time_t)strtoul(val, &ep, 10);
#endif
if (*ep != '.')
err("invalid time %s", val);
mtree_err("invalid time %s", val);
val = ep + 1;
#ifndef __APPLE__
ip->st_mtimespec.tv_nsec = strtol(val, &ep, 10);
#else
ip->st_mtimespec.ts_nsec = strtol(val, &ep, 10);
#endif
if (*ep)
err("invalid time %s", val);
mtree_err("invalid time %s", val);
break;
case F_TYPE:
switch(*val) {
@ -264,17 +273,17 @@ set(t, ip)
ip->type = F_SOCK;
break;
default:
err("unknown file type %s", val);
mtree_err("unknown file type %s", val);
}
break;
case F_UID:
ip->st_uid = (uid_t)strtoul(val, &ep, 10);
if (*ep)
err("invalid uid %s", val);
mtree_err("invalid uid %s", val);
break;
case F_UNAME:
if ((pw = getpwnam(val)) == NULL)
err("unknown user %s", val);
mtree_err("unknown user %s", val);
ip->st_uid = pw->pw_uid;
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: verify.c,v 1.14 1998/08/27 18:03:45 ross Exp $ */
/* $NetBSD: verify.c,v 1.15 1998/10/08 02:04:57 wsanchez Exp $ */
/*-
* Copyright (c) 1990, 1993
@ -38,7 +38,7 @@
#if 0
static char sccsid[] = "@(#)verify.c 8.1 (Berkeley) 6/6/93";
#else
__RCSID("$NetBSD: verify.c,v 1.14 1998/08/27 18:03:45 ross Exp $");
__RCSID("$NetBSD: verify.c,v 1.15 1998/10/08 02:04:57 wsanchez Exp $");
#endif
#endif /* not lint */
@ -86,7 +86,7 @@ vwalk()
argv[0] = ".";
argv[1] = NULL;
if ((t = fts_open(argv, ftsoptions, NULL)) == NULL)
err("fts_open: %s", strerror(errno));
mtree_err("fts_open: %s", strerror(errno));
level = root;
ftsdepth = specdepth = rval = 0;
while ((p = fts_read(t)) != NULL) {