* Copyright (c) 1983 The Regents of the University of California.
* %sccs.include.redist.c%
"@(#) Copyright (c) 1983 The Regents of the University of California.\n\
static char sccsid
[] = "@(#)main.c 5.11 (Berkeley) %G%";
#include <ufs/ufs/dinode.h>
#include <protocols/dumprestore.h>
int bflag
= 0, cvtflag
= 0, dflag
= 0, vflag
= 0, yflag
= 0;
int hflag
= 1, mflag
= 1, Nflag
= 0;
static void err
__P((const char *, ...));
static void obsolete
__P((int *, char **[]));
static void usage
__P((void));
char *inputdev
= _PATH_DEFTAPE
;
char *symtbl
= "./restoresymtable";
char *p
, name
[MAXPATHLEN
];
while ((ch
= getopt(argc
, argv
, "b:cdf:himNRrs:tvxy")) != EOF
)
/* Change default tape blocksize. */
ntrec
= strtol(optarg
, &p
, 10);
err("illegal blocksize -- %s", optarg
);
err("block size must be greater than 0");
err("%c and %c options are mutually exclusive",
/* Dumpnum (skip to) for multifile dump tapes. */
dumpnum
= strtol(optarg
, &p
, 10);
err("illegal dump number -- %s", optarg
);
err("dump number must be greater than 0");
err("none of i, R, r, t or x options specified");
if (signal(SIGINT
, onintr
) == SIG_IGN
)
(void) signal(SIGINT
, SIG_IGN
);
if (signal(SIGTERM
, onintr
) == SIG_IGN
)
(void) signal(SIGTERM
, SIG_IGN
);
* Incremental restoration of a file system.
* This is an incremental dump tape.
vprintf(stdout
, "Begin incremental restore\n");
vprintf(stdout
, "Calculate node updates.\n");
treescan(".", ROOTINO
, nodeupdates
);
* This is a level zero dump tape.
vprintf(stdout
, "Begin level 0 restore\n");
vprintf(stdout
, "Calculate extraction list.\n");
treescan(".", ROOTINO
, nodeupdates
);
vprintf(stdout
, "Verify the directory structure\n");
treescan(".", ROOTINO
, verifyfile
);
dumpsymtable(symtbl
, (long)1);
* Resume an incremental file system restoration.
dumpsymtable(symtbl
, (long)1);
treescan(name
, ino
, listfile
);
* Batch extraction of tape contents.
treescan(name
, ino
, addfile
);
(void)fprintf(stderr
, "usage:\t%s%s%s%s%s",
"restore tfhsvy [file ...]\n",
"\trestore xfhmsvy [file ...]\n",
* Change set of key letters and ordered arguments into something
char *ap
, **argv
, *flagsp
, **nargv
, *p
;
/* Return if no arguments or first argument has leading dash. */
if (argc
== 1 || *ap
== '-')
/* Allocate space for new arguments. */
if ((*argvp
= nargv
= malloc((argc
+ 1) * sizeof(char *))) == NULL
||
(p
= flagsp
= malloc(strlen(ap
) + 2)) == NULL
)
err("%s", strerror(errno
));
for (flags
= 0; *ap
; ++ap
) {
if ((nargv
[0] = malloc(strlen(*argv
) + 2 + 1)) == NULL
)
err("%s", strerror(errno
));
(void)strcpy(&nargv
[0][2], *argv
);
/* Copy remaining arguments. */
while (*nargv
++ = *argv
++);
err(const char *fmt
, ...)
(void)fprintf(stderr
, "restore: ");
(void)vfprintf(stderr
, fmt
, ap
);
(void)fprintf(stderr
, "\n");