X-Git-Url: https://git.wh0rd.org/?p=dump.git;a=blobdiff_plain;f=restore%2Ftape.c;h=08bb3757e7b638ece4d9f09048abb9d9072df6a5;hp=f7a8a10211379408d6e58d4b5d2f5668b911fd78;hb=651fb4a593dfd7a31129b7feb8d5dbd57c6f145d;hpb=5bbb0926a5e765575c199573ea3b3d0f5ecd99a2 diff --git a/restore/tape.c b/restore/tape.c index f7a8a10..08bb375 100644 --- a/restore/tape.c +++ b/restore/tape.c @@ -46,13 +46,14 @@ #ifndef lint static const char rcsid[] = - "$Id: tape.c,v 1.41 2001/07/18 11:46:31 stelian Exp $"; + "$Id: tape.c,v 1.44 2001/07/18 14:57:46 stelian Exp $"; #endif /* not lint */ #include #include #include #include +#include #include #include #include @@ -257,10 +258,18 @@ newcomprbuf(int size) void setup(void) { - int i, j, *ip; + int i, j, *ip, bot_code; struct STAT stbuf; Vprintf(stdout, "Verify tape and initialize maps\n"); + if (bot_script) { + msg("Launching %s\n", bot_script); + bot_code = system_command(bot_script, magtape, 1); + if (bot_code != 0 && bot_code != 1) { + msg("Restore aborted by the beginning of tape script\n"); + exit(1); + } + } #ifdef RRESTORE if (host) mt = rmtopen(magtape, 0); @@ -370,11 +379,12 @@ setup(void) void getvol(long nextvol) { - long newvol = 0, savecnt = 0, wantnext = 0, i; + long newvol = 0, wantnext = 0, i; + long saved_blksread = 0, saved_tpblksread = 0; union u_spcl tmpspcl; # define tmpbuf tmpspcl.s_spcl char buf[TP_BSIZE]; - int haderror = 0; + int haderror = 0, bot_code = 1; if (nextvol == 1) { tapesread = 0; @@ -387,7 +397,8 @@ getvol(long nextvol) return; goto gethdr; } - savecnt = blksread; + saved_blksread = blksread; + saved_tpblksread = tpblksread; again: if (pipein) exit(1); /* pipes do not get a second chance */ @@ -438,7 +449,15 @@ again: snprintf(magtape, MAXPATHLEN, "%s%03ld", magtapeprefix, newvol); magtape[MAXPATHLEN - 1] = '\0'; } - if (!Mflag || haderror) { + if (bot_script && !haderror) { + msg("Launching %s\n", bot_script); + bot_code = system_command(bot_script, magtape, newvol); + if (bot_code != 0 && bot_code != 1) { + msg("Restore aborted by the beginning of tape script\n"); + exit(1); + } + } + if (haderror || (bot_code && !Mflag)) { haderror = 0; fprintf(stderr, "Mount tape volume %ld\n", (long)newvol); fprintf(stderr, "Enter ``none'' if there are no more tapes\n"); @@ -482,12 +501,16 @@ gethdr: fprintf(stderr, "tape is not dump tape\n"); volno = 0; haderror = 1; + blksread = saved_blksread; + tpblksread = saved_tpblksread; goto again; } if (tmpbuf.c_volume != volno) { fprintf(stderr, "Wrong volume (%d)\n", tmpbuf.c_volume); volno = 0; haderror = 1; + blksread = saved_blksread; + tpblksread = saved_tpblksread; goto again; } if (tmpbuf.c_date != dumpdate || tmpbuf.c_ddate != dumptime) { @@ -496,10 +519,13 @@ gethdr: fprintf(stderr, "\twanted: %s", ctime(&dumpdate)); volno = 0; haderror = 1; + blksread = saved_blksread; + tpblksread = saved_tpblksread; goto again; } tapesread |= 1 << volno; - blksread = savecnt; + blksread = saved_blksread; + tpblksread = saved_tpblksread; /* * If continuing from the previous volume, skip over any * blocks read already at the end of the previous volume.