summaryrefslogtreecommitdiff
path: root/sbin/restore/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/restore/main.c')
-rw-r--r--sbin/restore/main.c42
1 files changed, 25 insertions, 17 deletions
diff --git a/sbin/restore/main.c b/sbin/restore/main.c
index edc60dcfdf7..ef4b043b8b8 100644
--- a/sbin/restore/main.c
+++ b/sbin/restore/main.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: main.c,v 1.8 1997/06/25 18:34:30 kstailey Exp $ */
-/* $NetBSD: main.c,v 1.11 1996/03/15 22:39:39 scottr Exp $ */
+/* $OpenBSD: main.c,v 1.9 1997/07/05 20:51:23 millert Exp $ */
+/* $NetBSD: main.c,v 1.13 1997/07/01 05:37:51 lukem Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -49,6 +49,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.11 1996/03/15 22:39:39 scottr Exp $";
#endif /* not lint */
#include <sys/param.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <ufs/ffs/fs.h>
@@ -56,7 +57,6 @@ static char rcsid[] = "$NetBSD: main.c,v 1.11 1996/03/15 22:39:39 scottr Exp $";
#include <protocols/dumprestore.h>
#include <err.h>
-#include <errno.h>
#include <paths.h>
#include <signal.h>
#include <stdio.h>
@@ -78,6 +78,7 @@ ino_t maxino;
time_t dumptime;
time_t dumpdate;
FILE *terminal;
+char *tmpdir;
static void obsolete __P((int *, char **[]));
static void usage __P((void));
@@ -94,13 +95,19 @@ main(argc, argv)
char *p, name[MAXPATHLEN];
/* Temp files should *not* be readable. We set permissions later. */
- (void) umask(077);
+ (void)umask(077);
if (argc < 2)
usage();
if ((inputdev = getenv("TAPE")) == NULL)
inputdev = _PATH_DEFTAPE;
+ if ((tmpdir = getenv("TMPDIR")) == NULL)
+ tmpdir = _PATH_TMP;
+ if ((tmpdir = strdup(tmpdir)) == NULL)
+ err(1, NULL);
+ for (p = tmpdir + strlen(tmpdir) - 1; p >= tmpdir && *p == '/'; p--)
+ ;
obsolete(&argc, &argv);
while ((ch = getopt(argc, argv, "b:cdf:himNRrs:tvxy")) != -1)
switch(ch) {
@@ -166,9 +173,9 @@ main(argc, argv)
errx(1, "none of i, R, r, t or x options specified");
if (signal(SIGINT, onintr) == SIG_IGN)
- (void) signal(SIGINT, SIG_IGN);
+ (void)signal(SIGINT, SIG_IGN);
if (signal(SIGTERM, onintr) == SIG_IGN)
- (void) signal(SIGTERM, SIG_IGN);
+ (void)signal(SIGTERM, SIG_IGN);
setlinebuf(stderr);
atexit(cleanup);
@@ -199,11 +206,11 @@ main(argc, argv)
/*
* This is an incremental dump tape.
*/
- vprintf(stdout, "Begin incremental restore\n");
+ Vprintf(stdout, "Begin incremental restore\n");
initsymtable(symtbl);
extractdirs(1);
removeoldleaves();
- vprintf(stdout, "Calculate node updates.\n");
+ Vprintf(stdout, "Calculate node updates.\n");
treescan(".", ROOTINO, nodeupdates);
findunreflinks();
removeoldnodes();
@@ -211,10 +218,10 @@ main(argc, argv)
/*
* This is a level zero dump tape.
*/
- vprintf(stdout, "Begin level 0 restore\n");
+ Vprintf(stdout, "Begin level 0 restore\n");
initsymtable(NULL);
extractdirs(1);
- vprintf(stdout, "Calculate extraction list.\n");
+ Vprintf(stdout, "Calculate extraction list.\n");
treescan(".", ROOTINO, nodeupdates);
}
createleaves(symtbl);
@@ -222,7 +229,7 @@ main(argc, argv)
setdirmodes(FORCE);
checkrestore();
if (dflag) {
- vprintf(stdout, "Verify the directory structure\n");
+ Vprintf(stdout, "Verify the directory structure\n");
treescan(".", ROOTINO, verifyfile);
}
dumpsymtable(symtbl, (long)1);
@@ -286,11 +293,11 @@ static void
usage()
{
- (void)fprintf(stderr, "usage: restore -i [-chmvy] [-b blocksize] [-f file] [-s fileno]\n");
- (void)fprintf(stderr, " restore -R [-cvy] [-b blocksize] [-f file] [-s fileno]\n");
- (void)fprintf(stderr, " restore -r [-cvy] [-b blocksize] [-f file] [-s fileno]\n");
- (void)fprintf(stderr, " restore -t [-chvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n");
- (void)fprintf(stderr, " restore -x [-chmvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n");
+ (void)fprintf(stderr, "usage: %s -i [-chmvy] [-b blocksize] [-f file] [-s fileno]\n", __progname);
+ (void)fprintf(stderr, " %s -R [-cvy] [-b blocksize] [-f file] [-s fileno]\n", __progname);
+ (void)fprintf(stderr, " %s -r [-cvy] [-b blocksize] [-f file] [-s fileno]\n", __progname);
+ (void)fprintf(stderr, " %s -t [-chvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n", __progname);
+ (void)fprintf(stderr, " %s -x [-chmvy] [-b blocksize] [-f file] [-s fileno] [file ...]\n", __progname);
exit(1);
}
@@ -358,7 +365,8 @@ obsolete(argcp, argvp)
}
/* Copy remaining arguments. */
- while (*nargv++ = *argv++);
+ while ((*nargv++ = *argv++))
+ ;
/* Update argument count. */
*argcp = nargv - *argvp - 1;