From 9a78b6fac1a2c403a9fcf5c5343d79279f70ab3f Mon Sep 17 00:00:00 2001 From: Peter Collinson Date: Tue, 11 Aug 1987 23:56:07 -0800 Subject: [PATCH] Revise the way label reading is done SCCS-vsn: local/ukc/dump/dumplab.c 1.3 SCCS-vsn: local/ukc/dump/dumptape.c 1.4 --- usr/src/local/ukc/dump/dumplab.c | 52 ++++++++++++++++++++++++------- usr/src/local/ukc/dump/dumptape.c | 25 +++------------ 2 files changed, 44 insertions(+), 33 deletions(-) diff --git a/usr/src/local/ukc/dump/dumplab.c b/usr/src/local/ukc/dump/dumplab.c index 6ee0949307..565223ab45 100644 --- a/usr/src/local/ukc/dump/dumplab.c +++ b/usr/src/local/ukc/dump/dumplab.c @@ -1,5 +1,5 @@ #ifndef lint -static char *sccsid = "@(#)dumplab.c 1.2 (UKC) %G%"; +static char *sccsid = "@(#)dumplab.c 1.3 (UKC) %G%"; #endif not lint /* * This file included by Peter Collinson @@ -60,6 +60,10 @@ int labchk; /* check labels - set by t(est) flag */ */ char dumpvolumes[] = "/etc/dumpvolumes"; +#ifdef RDUMP +extern char *host; +#endif RDUMP + /* * Called from argument decoding to store the * basic label format @@ -248,7 +252,7 @@ initialtape() if (labchk == 0) return; if (firstpr == 0) - msg("Mount tape %s for reel 1 of the dump\n", createlabel(0)); + msg("Mount tape %s for reel 1 of the dump\n", createlabel(1)); firstpr = 1; } @@ -272,34 +276,58 @@ labelest(etapes) * labelcheck * read a dump header and check that the tape header contains * the label we expected - * close the fd on error to allow upper levels to loop + * close the tape after use */ -labelcheck(fd, tno) - int fd; +labelcheck(tno) int tno; { - union u_spcl uin; /* lots on the stack but that should be OK */ + register fd; + union u_spcl uin; register char *label; register char *ontape = uin.s_spcl.c_label; - + if (labchk == 0 || pipeout) return(0); label = createlabel(tno); + +#ifdef RDUMP + /* doing it this way to make it easier to read */ + if (host) { + while (rmtopen(tape, 0) < 0) + if (!query("Cannot open tape. Do you want to retry the open?")) + dumpabort(); + if (rmtread((char *)&uin, sizeof uin) != sizeof uin) { + msg("Tape does not start with the correctly sized record\n"); + (void)rmtclose(); + return(-1); + } + if (ontape[0] == '\0' || + strcmp(ontape, "none") == 0 || + strcmp(ontape, label) == 0) { + (void)rmtclose(); + return(0); + } + msg("Tape labels do not match should be `%s' is `%s'\n", label, ontape); + (void)rmtclose(); + return(-1); + } +#endif RDUMP + while ((fd = open(tape, 0)) < 0) + if (!query("Cannot open tape. Do you want to retry the open?")) + dumpabort(); if (read(fd, (char *)&uin, sizeof uin) != sizeof uin) { msg("Tape does not start with the correctly sized record\n"); - close(fd); + (void)close(fd); return(-1); } if (ontape[0] == '\0' || strcmp(ontape, "none") == 0 || strcmp(ontape, label) == 0) { - /* skip back one record */ - if (backone(fd) < 0) - labfatal("Label check cannot backspace tape\n"); + (void)close(fd); return(0); } msg("Tape labels do not match should be `%s' is `%s'\n", label, ontape); - close(fd); + (void)close(fd); return(-1); } diff --git a/usr/src/local/ukc/dump/dumptape.c b/usr/src/local/ukc/dump/dumptape.c index 7a67aac551..684eb73f9f 100644 --- a/usr/src/local/ukc/dump/dumptape.c +++ b/usr/src/local/ukc/dump/dumptape.c @@ -5,7 +5,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)dumptape.c 1.3 (UKC) %G% 5.8 (Berkeley) 2/23/87"; +static char sccsid[] = "@(#)dumptape.c 1.4 (UKC) %G% 5.8 (Berkeley) 2/23/87"; #endif not lint #include "dump.h" @@ -313,6 +313,9 @@ otape() msg("Child on Tape %d has parent %d, my pid = %d\n", tapeno+1, parentpid, getpid()); #endif TDEBUG + while (labelcheck(tapeno+1) < 0) + if (!query("Problem with tape label. Do you want to retry the open?")) + dumpabort(); #ifdef RDUMP while ((to = (host ? rmtopen(tape, 2) : pipeout ? 1 : creat(tape, 0666))) < 0) @@ -322,10 +325,6 @@ otape() if (!query("Cannot open tape. Do you want to retry the open?")) dumpabort(); - if (labelcheck(to, tapeno+1) < 0) - if (!query("Problem with tape label. Do you want to retry the open?")) - dumpabort(); - enslave(); /* Share open tape file descriptor with slaves */ asize = 0; @@ -534,22 +533,6 @@ atomic(func, fd, buf, count) buf += got; return (got < 0 ? got : count - need); } - -/* - * Added by Peter C to backspace one record after a label read - */ -backone(fd) -{ - struct mtop mtop; - - mtop.mt_op = MTBSR; - mtop.mt_count = 1; -#ifdef RDUMP - if (host) - return(rmtioctl(fd, MTIOCTOP, &mtop)); -#endif RDUMP - return(ioctl(fd, MTIOCTOP, &mtop)); -} /* * Added by Peter C -- 2.20.1