diff --git a/sbin/restore/dirs.c b/sbin/restore/dirs.c index 7b5d7604804f..4d17e5c6af95 100644 --- a/sbin/restore/dirs.c +++ b/sbin/restore/dirs.c @@ -1,4 +1,4 @@ -/* $NetBSD: dirs.c,v 1.21 1996/11/30 18:04:45 cgd Exp $ */ +/* $NetBSD: dirs.c,v 1.22 1997/03/19 08:42:51 lukem Exp $ */ /* * Copyright (c) 1983, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)dirs.c 8.5 (Berkeley) 8/31/94"; #else -static char rcsid[] = "$NetBSD: dirs.c,v 1.21 1996/11/30 18:04:45 cgd Exp $"; +static char rcsid[] = "$NetBSD: dirs.c,v 1.22 1997/03/19 08:42:51 lukem Exp $"; #endif #endif /* not lint */ @@ -145,8 +145,8 @@ void extractdirs(genmode) int genmode; { - register int i; - register struct dinode *ip; + int i, dfd, mfd; + struct dinode *ip; struct inotab *itp; struct direct nulldir; @@ -156,42 +156,30 @@ extractdirs(genmode) if (command != 'r' && command != 'R') { (void) snprintf(dirfile, sizeof(dirfile), "%s/rstdir%d-XXXXXX", _PATH_TMP, dumpdate); - if (mktemp(dirfile) == NULL) { - fprintf(stderr, - "restore: %s - cannot mktemp directory temporary\n", - dirfile); - exit(1); - } - } - df = fopen(dirfile, "w"); - if (df == NULL) { - fprintf(stderr, - "restore: %s - cannot create directory temporary\n", - dirfile); - fprintf(stderr, "fopen: %s\n", strerror(errno)); - exit(1); + if ((dfd = mkstemp(dirfile)) == -1) + err(1, "cannot mkstemp temporary file %s", dirfile); + df = fdopen(dfd, "w"); } + else + df = fopen(dirfile, "w"); + if (df == NULL) + err(1, "cannot open temporary file %s", dirfile); + if (genmode != 0) { (void) snprintf(modefile, sizeof(modefile), "%s/rstmode%d", _PATH_TMP, dumpdate); if (command != 'r' && command != 'R') { (void) snprintf(modefile, sizeof(modefile), "%s/rstmode%d-XXXXXX", _PATH_TMP, dumpdate); - if (mktemp(modefile) == NULL) { - fprintf(stderr, - "restore: %s - cannot mktemp " - "directory temporary\n", dirfile); - exit(1); - } - } - mf = fopen(modefile, "w"); - if (mf == NULL) { - fprintf(stderr, - "restore: %s - cannot create modefile \n", - modefile); - fprintf(stderr, "fopen: %s\n", strerror(errno)); - exit(1); + if ((mfd = mkstemp(modefile)) == -1) + err(1, "cannot mkstemp temporary file %s", + modefile); + mf = fdopen(mfd, "w"); } + else + mf = fopen(modefile, "w"); + if (mf == NULL) + err(1, "cannot open temporary file %s", modefile); } nulldir.d_ino = 0; nulldir.d_type = DT_DIR; @@ -230,7 +218,7 @@ void skipdirs() { - while ((curfile.dip->di_mode & IFMT) == IFDIR) { + while (curfile.dip && (curfile.dip->di_mode & IFMT) == IFDIR) { skipfile(); } } @@ -245,8 +233,8 @@ treescan(pname, ino, todo) ino_t ino; long (*todo) __P((char *, ino_t, int)); { - register struct inotab *itp; - register struct direct *dp; + struct inotab *itp; + struct direct *dp; int namelen; long bpt; char locname[MAXPATHLEN + 1]; @@ -268,8 +256,7 @@ treescan(pname, ino, todo) * begin search through the directory * skipping over "." and ".." */ - (void) strncpy(locname, pname, MAXPATHLEN); - (void) strncat(locname, "/", MAXPATHLEN); + (void) snprintf(locname, sizeof(locname), "%s/", pname); namelen = strlen(locname); rst_seekdir(dirp, itp->t_seekpt, itp->t_seekpt); dp = rst_readdir(dirp); /* "." */ @@ -289,9 +276,9 @@ treescan(pname, ino, todo) */ while (dp != NULL) { locname[namelen] = '\0'; - if (namelen + dp->d_namlen >= MAXPATHLEN) { + if (namelen + dp->d_namlen >= sizeof(locname)) { fprintf(stderr, "%s%s: name exceeds %d char\n", - locname, dp->d_name, MAXPATHLEN); + locname, dp->d_name, sizeof(locname) - 1); } else { (void) strncat(locname, dp->d_name, (int)dp->d_namlen); treescan(locname, dp->d_ino, todo); @@ -336,8 +323,8 @@ searchdir(inum, name) ino_t inum; char *name; { - register struct direct *dp; - register struct inotab *itp; + struct direct *dp; + struct inotab *itp; int len; itp = inotablookup(inum); @@ -362,9 +349,9 @@ putdir(buf, size) long size; { struct direct cvtbuf; - register struct odirect *odp; + struct odirect *odp; struct odirect *eodp; - register struct direct *dp; + struct direct *dp; long loc, i; if (cvtflag) { @@ -458,11 +445,11 @@ flushent() static void dcvt(odp, ndp) - register struct odirect *odp; - register struct direct *ndp; + struct odirect *odp; + struct direct *ndp; { - memset(ndp, 0, (long)(sizeof *ndp)); + memset(ndp, 0, (size_t)(sizeof *ndp)); ndp->d_ino = odp->d_ino; ndp->d_type = DT_UNKNOWN; (void) strncpy(ndp->d_name, odp->d_name, ODIRSIZ); @@ -479,7 +466,7 @@ dcvt(odp, ndp) */ static void rst_seekdir(dirp, loc, base) - register RST_DIR *dirp; + RST_DIR *dirp; long loc, base; { @@ -499,9 +486,9 @@ rst_seekdir(dirp, loc, base) */ struct direct * rst_readdir(dirp) - register RST_DIR *dirp; + RST_DIR *dirp; { - register struct direct *dp; + struct direct *dp; for (;;) { if (dirp->dd_loc == 0) { @@ -586,8 +573,8 @@ static RST_DIR * opendirfile(name) const char *name; { - register RST_DIR *dirp; - register int fd; + RST_DIR *dirp; + int fd; if ((fd = open(name, O_RDONLY)) == -1) return (NULL); @@ -669,7 +656,7 @@ genliteraldir(name, ino) char *name; ino_t ino; { - register struct inotab *itp; + struct inotab *itp; int ofile, dp, i, size; char buf[BUFSIZ]; @@ -731,7 +718,7 @@ allocinotab(ino, dip, seekpt) struct dinode *dip; long seekpt; { - register struct inotab *itp; + struct inotab *itp; struct modeinfo node; itp = calloc(1, sizeof(struct inotab)); @@ -763,7 +750,7 @@ static struct inotab * inotablookup(ino) ino_t ino; { - register struct inotab *itp; + struct inotab *itp; for (itp = inotab[INOHASH(ino)]; itp != NULL; itp = itp->t_next) if (itp->t_ino == ino) diff --git a/sbin/restore/interactive.c b/sbin/restore/interactive.c index effae85dfe3d..9a2e4143f39d 100644 --- a/sbin/restore/interactive.c +++ b/sbin/restore/interactive.c @@ -1,4 +1,4 @@ -/* $NetBSD: interactive.c,v 1.9 1995/03/18 14:59:44 cgd Exp $ */ +/* $NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $ */ /* * Copyright (c) 1985, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)interactive.c 8.3 (Berkeley) 9/13/94"; #else -static char rcsid[] = "$NetBSD: interactive.c,v 1.9 1995/03/18 14:59:44 cgd Exp $"; +static char rcsid[] = "$NetBSD: interactive.c,v 1.10 1997/03/19 08:42:52 lukem Exp $"; #endif #endif /* not lint */ @@ -100,7 +100,7 @@ static void printlist __P((char *, char *)); void runcmdshell() { - register struct entry *np; + struct entry *np; ino_t ino; struct arglist arglist; char curdir[MAXPATHLEN]; @@ -310,7 +310,7 @@ getcmd(curdir, cmd, name, ap) char *curdir, *cmd, *name; struct arglist *ap; { - register char *cp; + char *cp; static char input[BUFSIZ]; char output[BUFSIZ]; # define rawname input /* save space by reusing input buffer */ @@ -397,7 +397,7 @@ static char * copynext(input, output) char *input, *output; { - register char *cp, *bp; + char *cp, *bp; char quote; for (cp = input; *cp == ' ' || *cp == '\t'; cp++) @@ -447,7 +447,7 @@ void canon(rawname, canonname) char *rawname, *canonname; { - register char *cp, *np; + char *cp, *np; if (strcmp(rawname, ".") == 0 || strncmp(rawname, "./", 2) == 0) (void) strcpy(canonname, ""); @@ -498,8 +498,8 @@ printlist(name, basename) char *name; char *basename; { - register struct afile *fp, *list, *listp; - register struct direct *dp; + struct afile *fp, *list, *listp; + struct direct *dp; struct afile single; RST_DIR *dirp; int entries, len, namelen; @@ -581,7 +581,7 @@ static void mkentry(name, dp, fp) char *name; struct direct *dp; - register struct afile *fp; + struct afile *fp; { char *cp; struct entry *np; @@ -642,10 +642,10 @@ mkentry(name, dp, fp) */ static void formatf(list, nentry) - register struct afile *list; + struct afile *list; int nentry; { - register struct afile *fp, *endlist; + struct afile *fp, *endlist; int width, bigino, haveprefix, havepostfix; int i, j, w, precision, columns, lines; @@ -742,7 +742,7 @@ glob_stat(name, stp) const char *name; struct stat *stp; { - register struct direct *dp; + struct direct *dp; dp = pathsearch(name); if (dp == NULL || (!dflag && TSTINO(dp->d_ino, dumpmap) == 0) || @@ -760,7 +760,7 @@ glob_stat(name, stp) */ static int fcmp(f1, f2) - register const void *f1, *f2; + const void *f1, *f2; { return (strcmp(((struct afile *)f1)->fname, ((struct afile *)f2)->fname)); diff --git a/sbin/restore/restore.c b/sbin/restore/restore.c index 6ae0e53d77ef..eb44ad8f31db 100644 --- a/sbin/restore/restore.c +++ b/sbin/restore/restore.c @@ -1,4 +1,4 @@ -/* $NetBSD: restore.c,v 1.7 1996/09/27 03:23:34 thorpej Exp $ */ +/* $NetBSD: restore.c,v 1.8 1997/03/19 08:42:53 lukem Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)restore.c 8.3 (Berkeley) 9/13/94"; #else -static char rcsid[] = "$NetBSD: restore.c,v 1.7 1996/09/27 03:23:34 thorpej Exp $"; +static char rcsid[] = "$NetBSD: restore.c,v 1.8 1997/03/19 08:42:53 lukem Exp $"; #endif #endif /* not lint */ @@ -83,7 +83,7 @@ addfile(name, ino, type) ino_t ino; int type; { - register struct entry *ep; + struct entry *ep; long descend = hflag ? GOOD : FAIL; char buf[100]; @@ -165,8 +165,8 @@ static struct entry *removelist; void removeoldleaves() { - register struct entry *ep, *nextep; - register ino_t i, mydirino; + struct entry *ep, *nextep; + ino_t i, mydirino; vprintf(stdout, "Mark entries to be removed.\n"); if (ep = lookupino(WINO)) { @@ -221,7 +221,7 @@ nodeupdates(name, ino, type) ino_t ino; int type; { - register struct entry *ep, *np, *ip; + struct entry *ep, *np, *ip; long descend = GOOD; int lookuptype = 0; int key = 0; @@ -525,8 +525,8 @@ keyval(key) void findunreflinks() { - register struct entry *ep, *np; - register ino_t i; + struct entry *ep, *np; + ino_t i; vprintf(stdout, "Find unreferenced names.\n"); for (i = ROOTINO; i < maxino; i++) { @@ -573,7 +573,7 @@ findunreflinks() void removeoldnodes() { - register struct entry *ep, **prev; + struct entry *ep, **prev; long change; vprintf(stdout, "Remove old nodes (directories).\n"); @@ -603,7 +603,7 @@ void createleaves(symtabfile) char *symtabfile; { - register struct entry *ep; + struct entry *ep; ino_t first; long curvol; @@ -682,8 +682,8 @@ createleaves(symtabfile) void createfiles() { - register ino_t first, next, last; - register struct entry *ep; + ino_t first, next, last; + struct entry *ep; long curvol; vprintf(stdout, "Extract requested files\n"); @@ -770,8 +770,8 @@ createfiles() void createlinks() { - register struct entry *np, *ep; - register ino_t i; + struct entry *np, *ep; + ino_t i; char name[BUFSIZ]; if (ep = lookupino(WINO)) { @@ -810,8 +810,8 @@ createlinks() void checkrestore() { - register struct entry *ep; - register ino_t i; + struct entry *ep; + ino_t i; vprintf(stdout, "Check the symbol table.\n"); for (i = WINO; i < maxino; i++) { diff --git a/sbin/restore/symtab.c b/sbin/restore/symtab.c index 44f974ad0b32..2a5ce60b1e1c 100644 --- a/sbin/restore/symtab.c +++ b/sbin/restore/symtab.c @@ -1,4 +1,4 @@ -/* $NetBSD: symtab.c,v 1.9 1996/11/30 18:04:47 cgd Exp $ */ +/* $NetBSD: symtab.c,v 1.10 1997/03/19 08:42:54 lukem Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)symtab.c 8.2 (Berkeley) 9/13/94"; #else -static char rcsid[] = "$NetBSD: symtab.c,v 1.9 1996/11/30 18:04:47 cgd Exp $"; +static char rcsid[] = "$NetBSD: symtab.c,v 1.10 1997/03/19 08:42:54 lukem Exp $"; #endif #endif /* not lint */ @@ -87,7 +87,7 @@ struct entry * lookupino(inum) ino_t inum; { - register struct entry *ep; + struct entry *ep; if (inum < WINO || inum >= maxino) return (NULL); @@ -126,7 +126,7 @@ void deleteino(inum) ino_t inum; { - register struct entry *next; + struct entry *next; struct entry **prev; if (inum < WINO || inum >= maxino) @@ -150,8 +150,8 @@ struct entry * lookupname(name) char *name; { - register struct entry *ep; - register char *np, *cp; + struct entry *ep; + char *np, *cp; char buf[MAXPATHLEN]; cp = name; @@ -198,9 +198,9 @@ lookupparent(name) */ char * myname(ep) - register struct entry *ep; + struct entry *ep; { - register char *cp; + char *cp; static char namebuf[MAXPATHLEN]; for (cp = &namebuf[MAXPATHLEN - 2]; cp > &namebuf[ep->e_namlen]; ) { @@ -230,7 +230,7 @@ addentry(name, inum, type) ino_t inum; int type; { - register struct entry *np, *ep; + struct entry *np, *ep; if (freelist != NULL) { np = freelist; @@ -277,9 +277,9 @@ addentry(name, inum, type) */ void freeentry(ep) - register struct entry *ep; + struct entry *ep; { - register struct entry *np; + struct entry *np; ino_t inum; if (ep->e_flags != REMOVED) @@ -321,7 +321,7 @@ freeentry(ep) */ void moveentry(ep, newname) - register struct entry *ep; + struct entry *ep; char *newname; { struct entry *np; @@ -351,9 +351,9 @@ moveentry(ep, newname) */ static void removeentry(ep) - register struct entry *ep; + struct entry *ep; { - register struct entry *np; + struct entry *np; np = ep->e_parent; if (np->e_entries == ep) { @@ -456,8 +456,8 @@ dumpsymtable(filename, checkpt) char *filename; long checkpt; { - register struct entry *ep, *tep; - register ino_t i; + struct entry *ep, *tep; + ino_t i; struct entry temp, *tentry; long mynum = 1, stroff = 0; FILE *fd; @@ -544,11 +544,11 @@ initsymtable(filename) { char *base; long tblsize; - register struct entry *ep; + struct entry *ep; struct entry *baseep, *lep; struct symtableheader hdr; struct stat stbuf; - register long i; + long i; int fd; vprintf(stdout, "Initialize symbol table.\n"); diff --git a/sbin/restore/tape.c b/sbin/restore/tape.c index 3c18f8e0a65e..993d2f5394ed 100644 --- a/sbin/restore/tape.c +++ b/sbin/restore/tape.c @@ -1,4 +1,4 @@ -/* $NetBSD: tape.c,v 1.24 1996/12/26 17:35:35 cjs Exp $ */ +/* $NetBSD: tape.c,v 1.25 1997/03/19 08:42:55 lukem Exp $ */ /* * Copyright (c) 1983, 1993 @@ -42,7 +42,7 @@ #if 0 static char sccsid[] = "@(#)tape.c 8.6 (Berkeley) 9/13/94"; #else -static char rcsid[] = "$NetBSD: tape.c,v 1.24 1996/12/26 17:35:35 cjs Exp $"; +static char rcsid[] = "$NetBSD: tape.c,v 1.25 1997/03/19 08:42:55 lukem Exp $"; #endif #endif /* not lint */ @@ -659,7 +659,7 @@ getfile(fill, skip) void (*fill) __P((char *, long)); void (*skip) __P((char *, long)); { - register int i; + int i; int curblk = 0; long size = spcl.c_dinode.di_size; static char clearedbuf[MAXBSIZE]; @@ -949,7 +949,7 @@ getmore: static void findtapeblksize() { - register long i; + long i; for (i = 0; i < ntrec; i++) ((struct s_spcl *)&tapebuf[i * TP_BSIZE])->c_magic = 0; @@ -1261,9 +1261,9 @@ findinode(header) static int checksum(buf) - register int *buf; + int *buf; { - register int i, j; + int i, j; j = sizeof(union u_spcl) / sizeof(int); i = 0; @@ -1316,8 +1316,8 @@ msg(fmt, va_alist) static u_char * swabshort(sp, n) - register u_char *sp; - register int n; + u_char *sp; + int n; { char c; @@ -1330,8 +1330,8 @@ swabshort(sp, n) static u_char * swablong(sp, n) - register u_char *sp; - register int n; + u_char *sp; + int n; { char c; @@ -1345,7 +1345,7 @@ swablong(sp, n) void swabst(cp, sp) - register u_char *cp, *sp; + u_char *cp, *sp; { int n = 0; diff --git a/sbin/restore/utilities.c b/sbin/restore/utilities.c index f085d2d86866..2ad4095b93c6 100644 --- a/sbin/restore/utilities.c +++ b/sbin/restore/utilities.c @@ -1,4 +1,4 @@ -/* $NetBSD: utilities.c,v 1.10 1996/09/27 03:23:35 thorpej Exp $ */ +/* $NetBSD: utilities.c,v 1.11 1997/03/19 08:42:56 lukem Exp $ */ /* * Copyright (c) 1983, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)utilities.c 8.4 (Berkeley) 10/18/94"; #else -static char rcsid[] = "$NetBSD: utilities.c,v 1.10 1996/09/27 03:23:35 thorpej Exp $"; +static char rcsid[] = "$NetBSD: utilities.c,v 1.11 1997/03/19 08:42:56 lukem Exp $"; #endif #endif /* not lint */ @@ -63,7 +63,7 @@ void pathcheck(name) char *name; { - register char *cp; + char *cp; struct entry *ep; char *start; @@ -90,7 +90,7 @@ pathcheck(name) */ void mktempname(ep) - register struct entry *ep; + struct entry *ep; { char oldname[MAXPATHLEN]; @@ -164,7 +164,7 @@ newnode(np) */ void removenode(ep) - register struct entry *ep; + struct entry *ep; { char *cp; @@ -187,7 +187,7 @@ removenode(ep) */ void removeleaf(ep) - register struct entry *ep; + struct entry *ep; { char *cp; @@ -257,7 +257,7 @@ addwhiteout(name) */ void delwhiteout(ep) - register struct entry *ep; + struct entry *ep; { char *name; @@ -281,7 +281,7 @@ ino_t lowerbnd(start) ino_t start; { - register struct entry *ep; + struct entry *ep; for ( ; start < maxino; start++) { ep = lookupino(start); @@ -300,7 +300,7 @@ ino_t upperbnd(start) ino_t start; { - register struct entry *ep; + struct entry *ep; for ( ; start > ROOTINO; start--) { ep = lookupino(start); @@ -317,7 +317,7 @@ upperbnd(start) */ void badentry(ep, msg) - register struct entry *ep; + struct entry *ep; char *msg; { @@ -344,7 +344,7 @@ badentry(ep, msg) */ char * flagvalues(ep) - register struct entry *ep; + struct entry *ep; { static char flagbuf[BUFSIZ];