X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/3d66b39b32b8b465f4c9b38ef8eafb31f307a538..eb997e376a27bf1c371d33c69ea90d5c5624519b:/usr/src/sbin/dump/tape.c diff --git a/usr/src/sbin/dump/tape.c b/usr/src/sbin/dump/tape.c index bab7e3fd0d..85f231fdc4 100644 --- a/usr/src/sbin/dump/tape.c +++ b/usr/src/sbin/dump/tape.c @@ -6,7 +6,7 @@ */ #ifndef lint -static char sccsid[] = "@(#)tape.c 5.22 (Berkeley) %G%"; +static char sccsid[] = "@(#)tape.c 5.23.1.1 (Berkeley) %G%"; #endif /* not lint */ #ifdef sunos @@ -14,17 +14,14 @@ static char sccsid[] = "@(#)tape.c 5.22 (Berkeley) %G%"; #include #include #include -#include -#include -#include -#include #include #else #include #include -#include #include #endif +#include +#include #include #include #include @@ -119,9 +116,10 @@ alloctape() * Align tape buffer on page boundary to speed up tape write(). */ for (i = 0; i <= SLAVES; i++) { - buf = (char *) malloc(reqsiz + writesize + pgoff + TP_BSIZE); + buf = (char *) + malloc((unsigned)(reqsiz + writesize + pgoff + TP_BSIZE)); if (buf == NULL) - return(0); + return(0); slaves[i].tblock = (char (*)[TP_BSIZE]) (((long)&buf[ntrec + 1] + pgoff) &~ pgoff); slaves[i].req = (struct req *)slaves[i].tblock - ntrec - 1; @@ -213,7 +211,7 @@ flushtape() slp->req[trecno].count = 0; /* Sentinel */ - if (atomic(write, slp->fd, slp->req, siz) != siz) + if (atomic(write, slp->fd, (char *)slp->req, siz) != siz) quit("error writing command pipe: %s\n", strerror(errno)); slp->sent = 1; /* we sent a request, read the response later */ @@ -224,7 +222,8 @@ flushtape() /* Read results back from next slave */ if (slp->sent) { - if (atomic(read, slp->fd, &got, sizeof got) != sizeof got) { + if (atomic(read, slp->fd, (char *)&got, sizeof got) + != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(); } @@ -240,8 +239,9 @@ flushtape() */ for (i = 0; i < SLAVES; i++) { if (slaves[i].sent) { - if (atomic(read, slaves[i].fd, &got, - sizeof got) != sizeof got) { + if (atomic(read, slaves[i].fd, + (char *)&got, sizeof got) + != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(); } @@ -284,8 +284,6 @@ trewind() int f; int got; - if (pipeout) - return; for (f = 0; f < SLAVES; f++) { /* * Drain the results, but unlike EOT we DO (or should) care @@ -296,7 +294,7 @@ trewind() * fixme: punt for now. */ if (slaves[f].sent) { - if (atomic(read, slaves[f].fd, &got, sizeof got) + if (atomic(read, slaves[f].fd, (char *)&got, sizeof got) != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(); @@ -308,10 +306,14 @@ trewind() quit("or use no size estimate at all.\n"); } } - close(slaves[f].fd); + (void) close(slaves[f].fd); } while (wait((int *)NULL) >= 0) /* wait for any signals from slaves */ /* void */; + + if (pipeout) + return; + msg("Closing %s\n", tape); #ifdef RDUMP @@ -323,10 +325,10 @@ trewind() return; } #endif - close(tapefd); + (void) close(tapefd); while ((f = open(tape, 0)) < 0) sleep (10); - close(f); + (void) close(f); } void @@ -366,7 +368,7 @@ rollforward() { register struct req *p, *q, *prev; register struct slave *tslp; - int i, next, size, savedtapea, got; + int i, size, savedtapea, got; union u_spcl *ntb, *otb; #ifdef ROLLDEBUG int j; @@ -425,7 +427,7 @@ rollforward() lastspclrec = savedtapea - 1; } size = (char *)ntb - (char *)q; - if (atomic(write, slp->fd, q, size) != size) { + if (atomic(write, slp->fd, (char *)q, size) != size) { perror(" DUMP: error writing command pipe"); dumpabort(); } @@ -476,7 +478,8 @@ rollforward() * worked ok, otherwise the tape is much too short! */ if (slp->sent) { - if (atomic(read, slp->fd, &got, sizeof got) != sizeof got) { + if (atomic(read, slp->fd, (char *)&got, sizeof got) + != sizeof got) { perror(" DUMP: error reading command pipe in master"); dumpabort(); } @@ -505,20 +508,19 @@ startnewtape(top) int childpid; int status; int waitpid; - int i; char *p; #ifdef sunos - void (*interrupt)(); + void (*interrupt_save)(); char *index(); #else - sig_t interrupt; + sig_t interrupt_save; #endif - interrupt = signal(SIGINT, SIG_IGN); + interrupt_save = signal(SIGINT, SIG_IGN); parentpid = getpid(); restore_check_point: - (void)signal(SIGINT, interrupt); + (void)signal(SIGINT, interrupt_save); /* * All signals are inherited... */ @@ -626,7 +628,7 @@ startnewtape(top) spcl.c_volume++; spcl.c_type = TS_TAPE; spcl.c_flags |= DR_NEWHEADER; - writeheader(slp->inode); + writeheader((ino_t)slp->inode); spcl.c_flags &=~ DR_NEWHEADER; if (tapeno > 1) msg("Volume %d begins with blocks from inode %d\n", @@ -639,7 +641,8 @@ dumpabort() { if (master != 0 && master != getpid()) - kill(master, SIGTERM); /* Signals master to call dumpabort */ + /* Signals master to call dumpabort */ + (void) kill(master, SIGTERM); else { killall(); msg("The ENTIRE dump is aborted.\n"); @@ -655,7 +658,7 @@ Exit(status) #ifdef TDEBUG msg("pid = %d exits with status %d\n", getpid(), status); #endif TDEBUG - exit(status); + (void) exit(status); } /* @@ -699,7 +702,7 @@ enslave() slaves[i].sent = 0; if (slaves[i].pid == 0) { /* Slave starts up here */ for (j = 0; j <= i; j++) - close(slaves[j].fd); + (void) close(slaves[j].fd); signal(SIGINT, SIG_IGN); /* Master handles this */ doslave(cmd[0], i); Exit(X_FINOK); @@ -707,8 +710,9 @@ enslave() } for (i = 0; i < SLAVES; i++) - atomic(write, slaves[i].fd, &slaves[(i + 1) % SLAVES].pid, - sizeof slaves[0].pid); + (void) atomic(write, slaves[i].fd, + (char *) &slaves[(i + 1) % SLAVES].pid, + sizeof slaves[0].pid); master = 0; } @@ -720,7 +724,7 @@ killall() for (i = 0; i < SLAVES; i++) if (slaves[i].pid > 0) - kill(slaves[i].pid, SIGKILL); + (void) kill(slaves[i].pid, SIGKILL); } /* @@ -749,14 +753,14 @@ doslave(cmd, slave_number) /* * Need our own seek pointer. */ - close(diskfd); + (void) close(diskfd); if ((diskfd = open(disk, O_RDONLY)) < 0) quit("slave couldn't reopen disk: %s\n", strerror(errno)); /* * Need the pid of the next slave in the loop... */ - if ((nread = atomic(read, cmd, &nextslave, sizeof nextslave)) + if ((nread = atomic(read, cmd, (char *)&nextslave, sizeof nextslave)) != sizeof nextslave) { quit("master/slave protocol botched - didn't get pid of next slave.\n"); } @@ -768,13 +772,12 @@ doslave(cmd, slave_number) /* * Get list of blocks to dump, read the blocks into tape buffer */ - while ((nread = atomic(read, cmd, slp->req, reqsiz)) == reqsiz) { + while ((nread = atomic(read, cmd, (char *)slp->req, reqsiz)) == reqsiz) { register struct req *p = slp->req; - int j; - struct req *rover; - char (*orover)[TP_BSIZE]; +#ifdef ROLLDEBUG + int req_count = 0; +#endif - j = 0; for (trecno = 0; trecno < ntrec; trecno += p->count, p += p->count) { if (p->dblk) { @@ -782,15 +785,16 @@ doslave(cmd, slave_number) p->count * TP_BSIZE); } else { if (p->count != 1 || atomic(read, cmd, - slp->tblock[trecno], TP_BSIZE) != TP_BSIZE) - quit("master/slave protocol botched.\n"); + (char *)slp->tblock[trecno], + TP_BSIZE) != TP_BSIZE) + quit("master/slave protocol botched.\n"); } #ifdef ROLLDEBUG if (dodump) { - fprintf(out, " req %d count %d dblk %d\n", - j++, p->count, p->dblk); + (void) fprintf(out, " req %d count %d dblk %d\n", + req_count++, p->count, p->dblk); if (p->dblk == 0) { - fprintf(out, "\tsum %x\n", + (void) fprintf(out, "\tsum %x\n", do_sum(slp->tblock[trecno])); } } @@ -798,16 +802,16 @@ doslave(cmd, slave_number) } #ifdef ROLLDEBUG if (dodump) { - fprintf(out, "\n"); + (void) fprintf(out, "\n"); } if (--dodump == 0) { - fclose(out); + (void) fclose(out); } #endif if (setjmp(jmpbuf) == 0) { ready = 1; if (!caught) - pause(); + (void) pause(); } ready = 0; caught = 0; @@ -849,22 +853,22 @@ doslave(cmd, slave_number) * at EOT on 1/2 inch drives. */ if (size < 0) { - kill(master, SIGUSR1); + (void) kill(master, SIGUSR1); for (;;) - sigpause(0); + (void) sigpause(0); } else { /* * pass size of write back to master * (for EOT handling) */ - atomic(write, cmd, &size, sizeof size); + (void) atomic(write, cmd, (char *)&size, sizeof size); } /* * If partial write, don't want next slave to go. * Also jolts him awake. */ - kill(nextslave, SIGUSR2); + (void) kill(nextslave, SIGUSR2); } if (nread != 0) quit("error reading command pipe: %s\n", strerror(errno));