/*
* Ported to Linux's Second Extended File System as part of the
* dump and restore backup suit
- * Remy Card <card@Linux.EU.Org>, 1994, 1995, 1996
+ * Remy Card <card@Linux.EU.Org>, 1994-1997
+ * Stelian Pop <pop@cybercable.fr>, 1999
*
*/
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/4/95";
+#endif
+static const char rcsid[] =
+ "$Id: main.c,v 1.2 1999/10/11 12:53:23 stelian Exp $";
#endif /* not lint */
#include <sys/param.h>
-#include <sys/time.h>
#include <sys/stat.h>
+#include <errno.h>
#ifdef __linux__
#include <linux/ext2_fs.h>
#include <bsdcompat.h>
+#include <signal.h>
+#include <string.h>
#else /* __linux__ */
#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
#endif /* __linux__ */
#include <protocols/dumprestore.h>
#include <err.h>
-#include <errno.h>
-#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
-#include <string.h>
#include <unistd.h>
#ifdef __linux__
int bflag = 0, cvtflag = 0, dflag = 0, vflag = 0, yflag = 0;
int hflag = 1, mflag = 1, Nflag = 0;
+int uflag = 0;
+int dokerberos = 0;
char command = '\0';
long dumpnum = 1;
long volno = 0;
{
int ch;
ino_t ino;
- char *inputdev = _PATH_DEFTAPE;
+ char *inputdev;
char *symtbl = "./restoresymtable";
char *p, name[MAXPATHLEN];
- if (argc < 2)
- usage();
+ /* Temp files should *not* be readable. We set permissions later. */
+ (void) umask(077);
#ifdef __linux__
__progname = argv[0];
#endif
+ if (argc < 2)
+ usage();
+
+ if ((inputdev = getenv("TAPE")) == NULL)
+ inputdev = _PATH_DEFTAPE;
obsolete(&argc, &argv);
- while ((ch = getopt(argc, argv, "b:CcdD:f:himNRrs:tT:vxy")) != EOF)
+#ifdef KERBEROS
+#define optlist "b:CcdDf:hikmNRrs:tTuvxy"
+#else
+#define optlist "b:CcdDf:himNRrs:tTuvxy"
+#endif
+ while ((ch = getopt(argc, argv, optlist)) != -1)
switch(ch) {
case 'b':
/* Change default tape blocksize. */
case 'h':
hflag = 0;
break;
+#ifdef KERBEROS
+ case 'k':
+ dokerberos = 1;
+ break;
+#endif
case 'C':
case 'i':
case 'R':
if (dumpnum <= 0)
errx(1, "dump number must be greater than 0");
break;
+ case 'u':
+ uflag = 1;
+ break;
case 'v':
vflag = 1;
break;
extractdirs(0);
initsymtable((char *)0);
while (argc--) {
- canon(*argv++, name);
+ canon(*argv++, name, sizeof(name));
ino = dirlookup(name);
if (ino == 0)
continue;
extractdirs(1);
initsymtable((char *)0);
while (argc--) {
- canon(*argv++, name);
+ canon(*argv++, name, sizeof(name));
ino = dirlookup(name);
if (ino == 0)
continue;
}
done(0);
/* NOTREACHED */
+ exit(1); /* gcc shut up */
}
static void
usage()
{
(void)fprintf(stderr, "usage:\t%s\n\t%s\n\t%s\n\t%s\n\t%s\n",
- "restore -i [-chmvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -r [-cvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -R [-cvy] [-b blocksize] [-f file] [-s fileno]",
- "restore -x [-chmvy] [-b blocksize] [-f file] [-s fileno] [file ...]", "restore -t [-chvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
+ "restore -i [-chkmuvy] [-b blocksize] [-f file] [-s fileno]",
+ "restore -r [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
+ "restore -R [-ckuvy] [-b blocksize] [-f file] [-s fileno]",
+ "restore -x [-chkmuvy] [-b blocksize] [-f file] [-s fileno] [file ...]",
+ "restore -t [-chkuvy] [-b blocksize] [-f file] [-s fileno] [file ...]");
done(1);
}
char **argvp[];
{
int argc, flags;
- char *ap, **argv, *flagsp, **nargv, *p;
+ char *ap, **argv, *flagsp=NULL, **nargv, *p=NULL;
/* Setup. */
argv = *argvp;
err(1, NULL);
*nargv++ = *argv;
- argv += 2;
+ argv += 2, argc -= 2;
for (flags = 0; *ap; ++ap) {
switch (*ap) {
}
/* Copy remaining arguments. */
- while (*nargv++ = *argv++);
+ while ((*nargv++ = *argv++));
/* Update argument count. */
*argcp = nargv - *argvp - 1;