SCCS-vsn: sbin/dump/tape.c 5.23
#include <stdio.h>
#include <ctype.h>
#include <sys/stat.h>
#include <stdio.h>
#include <ctype.h>
#include <sys/stat.h>
-#include <sys/time.h>
-#include <sys/dir.h>
-#include <sys/vnode.h>
-#include <ufs/inode.h>
#include <ufs/fs.h>
#else
#include <sys/param.h>
#include <sys/wait.h>
#include <ufs/fs.h>
#else
#include <sys/param.h>
#include <sys/wait.h>
-#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
#endif
#include <ufs/ffs/fs.h>
#endif
+#include <sys/time.h>
+#include <ufs/ufs/dinode.h>
#include <signal.h>
#include <fcntl.h>
#include <protocols/dumprestore.h>
#include <signal.h>
#include <fcntl.h>
#include <protocols/dumprestore.h>
* Align tape buffer on page boundary to speed up tape write().
*/
for (i = 0; i <= SLAVES; i++) {
* 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));
slaves[i].tblock = (char (*)[TP_BSIZE])
(((long)&buf[ntrec + 1] + pgoff) &~ pgoff);
slaves[i].req = (struct req *)slaves[i].tblock - ntrec - 1;
slaves[i].tblock = (char (*)[TP_BSIZE])
(((long)&buf[ntrec + 1] + pgoff) &~ pgoff);
slaves[i].req = (struct req *)slaves[i].tblock - ntrec - 1;
slp->req[trecno].count = 0; /* Sentinel */
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 */
quit("error writing command pipe: %s\n", strerror(errno));
slp->sent = 1; /* we sent a request, read the response later */
/* Read results back from next slave */
if (slp->sent) {
/* 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();
}
perror(" DUMP: error reading command pipe in master");
dumpabort();
}
*/
for (i = 0; i < SLAVES; i++) {
if (slaves[i].sent) {
*/
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();
}
perror(" DUMP: error reading command pipe in master");
dumpabort();
}
for (f = 0; f < SLAVES; f++) {
/*
* Drain the results, but unlike EOT we DO (or should) care
for (f = 0; f < SLAVES; f++) {
/*
* Drain the results, but unlike EOT we DO (or should) care
* fixme: punt for now.
*/
if (slaves[f].sent) {
* 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();
!= sizeof got) {
perror(" DUMP: error reading command pipe in master");
dumpabort();
quit("or use no size estimate at all.\n");
}
}
quit("or use no size estimate at all.\n");
}
}
+ (void) close(slaves[f].fd);
}
while (wait((int *)NULL) >= 0) /* wait for any signals from slaves */
/* void */;
}
while (wait((int *)NULL) >= 0) /* wait for any signals from slaves */
/* void */;
+
+ if (pipeout)
+ return;
+
msg("Closing %s\n", tape);
#ifdef RDUMP
msg("Closing %s\n", tape);
#ifdef RDUMP
while ((f = open(tape, 0)) < 0)
sleep (10);
while ((f = open(tape, 0)) < 0)
sleep (10);
-#ifdef ROLLDEBUG
-int do_sum(block)
- union u_spcl *block;
-
-{
- char sum = 0;
- int i;
-
- for (i = 0; i < TP_BSIZE; i++) {
- sum = sum ^ block->dummy[i];
- }
- return(sum);
-}
-#endif
-
void
rollforward()
{
register struct req *p, *q, *prev;
register struct slave *tslp;
void
rollforward()
{
register struct req *p, *q, *prev;
register struct slave *tslp;
- int i, next, size, savedtapea, got;
+ int i, size, savedtapea, got;
-#ifdef ROLLDEBUG
- int j;
-#endif
tslp = &slaves[SLAVES];
ntb = (union u_spcl *)tslp->tblock[1];
tslp = &slaves[SLAVES];
ntb = (union u_spcl *)tslp->tblock[1];
/*
* For each request in the current slave, copy it to tslp.
*/
/*
* For each request in the current slave, copy it to tslp.
*/
-#ifdef ROLLDEBUG
- printf("replaying reqs to slave %d (%d)\n", slp - &slaves[0],
- slp->pid);
- j = 0;
-#endif
for (p = slp->req; p->count > 0; p += p->count) {
for (p = slp->req; p->count > 0; p += p->count) {
-#ifdef ROLLDEBUG
- printf(" req %d count %d dblk %d\n",
- j++, p->count, p->dblk);
- if (p->dblk == 0)
- printf("\tsum %x\n", do_sum(otb));
-#endif
*q = *p;
if (p->dblk == 0)
*ntb++ = *otb++; /* copy the datablock also */
*q = *p;
if (p->dblk == 0)
*ntb++ = *otb++; /* copy the datablock also */
lastspclrec = savedtapea - 1;
}
size = (char *)ntb - (char *)q;
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();
}
slp->sent = 1;
perror(" DUMP: error writing command pipe");
dumpabort();
}
slp->sent = 1;
-#ifdef ROLLDEBUG
- printf("after the shift:\n");
- j = 0;
- for (p = tslp->req; p->count > 0; p += p->count) {
- printf(" req %d count %d dblk %d\n",
- j++, p->count, p->dblk);
- if (p->dblk == 0) {
- /* dump block also */
- }
- }
-#endif
if (++slp >= &slaves[SLAVES])
slp = &slaves[0];
if (++slp >= &slaves[SLAVES])
slp = &slaves[0];
* worked ok, otherwise the tape is much too short!
*/
if (slp->sent) {
* 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();
}
perror(" DUMP: error reading command pipe in master");
dumpabort();
}
int childpid;
int status;
int waitpid;
int childpid;
int status;
int waitpid;
+ void (*interrupt_save)();
- interrupt = signal(SIGINT, SIG_IGN);
+ interrupt_save = signal(SIGINT, SIG_IGN);
parentpid = getpid();
restore_check_point:
parentpid = getpid();
restore_check_point:
- (void)signal(SIGINT, interrupt);
+ (void)signal(SIGINT, interrupt_save);
/*
* All signals are inherited...
*/
/*
* All signals are inherited...
*/
spcl.c_volume++;
spcl.c_type = TS_TAPE;
spcl.c_flags |= DR_NEWHEADER;
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",
spcl.c_flags &=~ DR_NEWHEADER;
if (tapeno > 1)
msg("Volume %d begins with blocks from inode %d\n",
{
if (master != 0 && master != getpid())
{
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");
else {
killall();
msg("The ENTIRE dump is aborted.\n");
#ifdef TDEBUG
msg("pid = %d exits with status %d\n", getpid(), status);
#endif TDEBUG
#ifdef TDEBUG
msg("pid = %d exits with status %d\n", getpid(), status);
#endif TDEBUG
slaves[i].sent = 0;
if (slaves[i].pid == 0) { /* Slave starts up here */
for (j = 0; j <= i; j++)
slaves[i].sent = 0;
if (slaves[i].pid == 0) { /* Slave starts up here */
for (j = 0; j <= i; j++)
+ (void) close(slaves[j].fd);
signal(SIGINT, SIG_IGN); /* Master handles this */
doslave(cmd[0], i);
Exit(X_FINOK);
signal(SIGINT, SIG_IGN); /* Master handles this */
doslave(cmd[0], i);
Exit(X_FINOK);
}
for (i = 0; i < SLAVES; i++)
}
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);
for (i = 0; i < SLAVES; i++)
if (slaves[i].pid > 0)
for (i = 0; i < SLAVES; i++)
if (slaves[i].pid > 0)
- kill(slaves[i].pid, SIGKILL);
+ (void) kill(slaves[i].pid, SIGKILL);
#ifndef __STDC__
int read();
#endif
#ifndef __STDC__
int read();
#endif
-#ifdef ROLLDEBUG
- int dodump = 2;
- FILE *out;
- char name[64];
-#endif
/*
* Need our own seek pointer.
*/
/*
* Need our own seek pointer.
*/
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 ((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");
}
!= sizeof nextslave) {
quit("master/slave protocol botched - didn't get pid of next slave.\n");
}
-#ifdef ROLLDEBUG
- sprintf(name, "slave.%d", slave_number);
- out = fopen(name, "w");
-#endif
/*
* Get list of blocks to dump, read the blocks into tape buffer
*/
/*
* 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;
register struct req *p = slp->req;
- int j;
- struct req *rover;
- char (*orover)[TP_BSIZE];
for (trecno = 0; trecno < ntrec;
trecno += p->count, p += p->count) {
if (p->dblk) {
for (trecno = 0; trecno < ntrec;
trecno += p->count, p += p->count) {
if (p->dblk) {
p->count * TP_BSIZE);
} else {
if (p->count != 1 || atomic(read, cmd,
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");
- }
-#ifdef ROLLDEBUG
- if (dodump) {
- fprintf(out, " req %d count %d dblk %d\n",
- j++, p->count, p->dblk);
- if (p->dblk == 0) {
- fprintf(out, "\tsum %x\n",
- do_sum(slp->tblock[trecno]));
- }
+ (char *)slp->tblock[trecno],
+ TP_BSIZE) != TP_BSIZE)
+ quit("master/slave protocol botched.\n");
-#endif
- }
-#ifdef ROLLDEBUG
- if (dodump) {
- fprintf(out, "\n");
- if (--dodump == 0) {
- fclose(out);
- }
-#endif
if (setjmp(jmpbuf) == 0) {
ready = 1;
if (!caught)
if (setjmp(jmpbuf) == 0) {
ready = 1;
if (!caught)
* at EOT on 1/2 inch drives.
*/
if (size < 0) {
* at EOT on 1/2 inch drives.
*/
if (size < 0) {
+ (void) kill(master, SIGUSR1);
} else {
/*
* pass size of write back to master
* (for EOT handling)
*/
} 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.
*/
}
/*
* 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));
}
if (nread != 0)
quit("error reading command pipe: %s\n", strerror(errno));