SCCS-vsn: sbin/restore/tape.c 3.9
/* Copyright (c) 1983 Regents of the University of California */
#ifndef lint
/* Copyright (c) 1983 Regents of the University of California */
#ifndef lint
-static char sccsid[] = "@(#)tape.c 3.8 (Berkeley) 83/03/08";
+static char sccsid[] = "@(#)tape.c 3.9 (Berkeley) 83/03/27";
#endif
#include "restore.h"
#endif
#include "restore.h"
struct stat stbuf;
extern char *ctime();
extern int xtrmap(), xtrmapskip();
struct stat stbuf;
extern char *ctime();
extern int xtrmap(), xtrmapskip();
fprintf(stderr, "%s: cannot open tape\n", magtape);
done(1);
}
fprintf(stderr, "%s: cannot open tape\n", magtape);
done(1);
}
- if (dumpnum != 1) {
- if (pipein) {
- fprintf(stderr,
- "Cannot have multiple dumps on pipe input\n");
- done(1);
- }
- tcom.mt_op = MTFSF;
- tcom.mt_count = dumpnum - 1;
-#ifdef RRESTOR
- rmtioctl(MTFSF, dumpnum - 1);
-#else
- if (ioctl(mt, MTIOCTOP, &tcom) < 0)
- perror("ioctl MTFSF");
-#endif
- }
+ volno = 1;
+ setdumpnum();
flsht();
if (gethead(&spcl) == FAIL) {
bct--; /* push back this block */
flsht();
if (gethead(&spcl) == FAIL) {
bct--; /* push back this block */
fprintf(stderr, "Tape is not volume 1 of the dump\n");
done(1);
}
fprintf(stderr, "Tape is not volume 1 of the dump\n");
done(1);
}
if (readhdr(&spcl) == FAIL)
panic("no header after volume mark!\n");
findinode(&spcl, 1);
if (readhdr(&spcl) == FAIL)
panic("no header after volume mark!\n");
findinode(&spcl, 1);
done(1);
}
maxino = (spcl.c_count * TP_BSIZE * NBBY) + 1;
done(1);
}
maxino = (spcl.c_count * TP_BSIZE * NBBY) + 1;
- dprintf(stderr, "maxino = %d\n", maxino);
+ dprintf(stdout, "maxino = %d\n", maxino);
map = calloc((unsigned)1, (unsigned)howmany(maxino, NBBY));
if (map == (char *)NIL)
panic("no memory for file removal list\n");
map = calloc((unsigned)1, (unsigned)howmany(maxino, NBBY));
if (map == (char *)NIL)
panic("no memory for file removal list\n");
union u_spcl tmpspcl;
# define tmpbuf tmpspcl.s_spcl
union u_spcl tmpspcl;
# define tmpbuf tmpspcl.s_spcl
- if (dumpnum > 1) {
- /*
- * if this is a multi-dump tape we always start with
- * volume 1, so as to avoid accidentally restoring
- * from a different dump!
- */
- if (volno != 1)
- panic("multiple dump at volno %d\n", volno);
- dumpnum = 1;
- }
if (pipein) {
if (nextvol != 1)
panic("Changing volumes on pipe input?\n");
if (pipein) {
if (nextvol != 1)
panic("Changing volumes on pipe input?\n");
}
gethdr:
volno = newvol;
}
gethdr:
volno = newvol;
flsht();
if (readhdr(&tmpbuf) == FAIL) {
fprintf(stderr, "tape is not dump tape\n");
flsht();
if (readhdr(&tmpbuf) == FAIL) {
fprintf(stderr, "tape is not dump tape\n");
+/*
+ * handle multiple dumps per tape by skipping forward to the
+ * appropriate one.
+ */
+setdumpnum()
+{
+ struct mtop tcom;
+
+ if (dumpnum == 1 || volno != 1)
+ return;
+ if (pipein) {
+ fprintf(stderr, "Cannot have multiple dumps on pipe input\n");
+ done(1);
+ }
+ tcom.mt_op = MTFSF;
+ tcom.mt_count = dumpnum - 1;
+#ifdef RRESTOR
+ rmtioctl(MTFSF, dumpnum - 1);
+#else
+ if (ioctl(mt, MTIOCTOP, &tcom) < 0)
+ perror("ioctl MTFSF");
+#endif
+}
+
extractfile(name)
char *name;
{
extractfile(name)
char *name;
{
skipfile();
return (FAIL);
}
skipfile();
return (FAIL);
}
- chown(name, curfile.dip->di_uid, curfile.dip->di_gid);
- chmod(name, mode);
+ (void) chown(name, curfile.dip->di_uid, curfile.dip->di_gid);
+ (void) chmod(name, mode);
skipfile();
utime(name, timep);
return (GOOD);
skipfile();
utime(name, timep);
return (GOOD);
skipfile();
return (FAIL);
}
skipfile();
return (FAIL);
}
- fchown(ofile, curfile.dip->di_uid, curfile.dip->di_gid);
- fchmod(ofile, mode);
+ (void) fchown(ofile, curfile.dip->di_uid, curfile.dip->di_gid);
+ (void) fchmod(ofile, mode);
getfile(xtrfile, xtrskip);
getfile(xtrfile, xtrskip);
utime(name, timep);
return (GOOD);
}
utime(name, timep);
return (GOOD);
}
if (readhdr(&spcl) == GOOD && size > 0) {
if (checktype(&spcl, TS_ADDR) == GOOD)
goto loop;
if (readhdr(&spcl) == GOOD && size > 0) {
if (checktype(&spcl, TS_ADDR) == GOOD)
goto loop;
- fprintf(stderr, "Missing address (header) block for %s\n",
+ dprintf(stdout, "Missing address (header) block for %s\n",
curfile.name);
}
if (curblk > 0)
curfile.name);
}
if (curblk > 0)
#ifdef RRESTOR
rmtclose();
#else
#ifdef RRESTOR
rmtclose();
#else
{
if (gethead(b) == FAIL) {
{
if (gethead(b) == FAIL) {
- dprintf(stderr, "readhdr fails at %d blocks\n", blksread);
+ dprintf(stdout, "readhdr fails at %d blocks\n", blksread);
return(FAIL);
}
return(GOOD);
return(FAIL);
}
return(GOOD);