diff options
author | Brian Feldman <green@FreeBSD.org> | 2004-04-13 02:58:06 +0000 |
---|---|---|
committer | Brian Feldman <green@FreeBSD.org> | 2004-04-13 02:58:06 +0000 |
commit | c51d70c69075e97364f784199a7b9769c811d903 (patch) | |
tree | a1d674955b8c95633685662ea70b1c1e05573efd /sbin/dump/tape.c | |
parent | ae13acf25965848771a6702e4d4fe4d1ca0bfdef (diff) | |
download | src-c51d70c69075e97364f784199a7b9769c811d903.tar.gz src-c51d70c69075e97364f784199a7b9769c811d903.zip |
Notes
Diffstat (limited to 'sbin/dump/tape.c')
-rw-r--r-- | sbin/dump/tape.c | 51 |
1 files changed, 39 insertions, 12 deletions
diff --git a/sbin/dump/tape.c b/sbin/dump/tape.c index 5437e051b84e..490d3d97c351 100644 --- a/sbin/dump/tape.c +++ b/sbin/dump/tape.c @@ -67,6 +67,7 @@ extern int ntrec; /* blocking factor on tape */ extern int cartridge; extern char *host; char *nexttape; +FILE *popenfp = NULL; static int atomic(ssize_t (*)(), int, char *, int); static void doslave(int, int); @@ -336,6 +337,12 @@ trewind(void) msg("Closing %s\n", tape); + if (popenout) { + tapefd = -1; + (void)pclose(popenfp); + popenfp = NULL; + return; + } #ifdef RDUMP if (host) { rmtclose(); @@ -500,7 +507,6 @@ startnewtape(int top) int parentpid; int childpid; int status; - int waitpid; char *p; sig_t interrupt_save; @@ -530,9 +536,9 @@ restore_check_point: msg("Tape: %d; parent process: %d child process %d\n", tapeno+1, parentpid, childpid); #endif /* TDEBUG */ - while ((waitpid = wait(&status)) != childpid) - msg("Parent %d waiting for child %d has another child %d return\n", - parentpid, childpid, waitpid); + if (waitpid(childpid, &status, 0) == -1) + msg("Waiting for child %d: %s\n", childpid, + strerror(errno)); if (status & 0xFF) { msg("Child %d returns LOB status %o\n", childpid, status&0xFF); @@ -589,20 +595,41 @@ restore_check_point: nexttape = NULL; msg("Dumping volume %d on %s\n", tapeno, tape); } + if (pipeout) { + tapefd = STDOUT_FILENO; + } else if (popenout) { + char volno[sizeof("2147483647")]; + + (void)sprintf(volno, "%d", spcl.c_volume + 1); + if (setenv("DUMP_VOLUME", volno, 1) == -1) { + msg("Cannot set $DUMP_VOLUME.\n"); + dumpabort(0); + } + popenfp = popen(popenout, "w"); + if (popenfp == NULL) { + msg("Cannot open output pipeline \"%s\".\n", + popenout); + dumpabort(0); + } + tapefd = fileno(popenfp); + } else { #ifdef RDUMP - while ((tapefd = (host ? rmtopen(tape, 2) : - pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) < 0) + while ((tapefd = (host ? rmtopen(tape, 2) : + open(tape, O_WRONLY|O_CREAT, 0666))) < 0) #else - while ((tapefd = (pipeout ? 1 : - open(tape, O_WRONLY|O_CREAT, 0666))) < 0) + while ((tapefd = + open(tape, O_WRONLY|O_CREAT, 0666)) < 0) #endif - { - msg("Cannot open output \"%s\".\n", tape); - if (!query("Do you want to retry the open?")) - dumpabort(0); + { + msg("Cannot open output \"%s\".\n", tape); + if (!query("Do you want to retry the open?")) + dumpabort(0); + } } enslave(); /* Share open tape file descriptor with slaves */ + if (popenout) + close(tapefd); /* Give up our copy of it. */ signal(SIGINFO, infosch); asize = 0; |