SCCS-vsn: sbin/dump/tape.c 1.7
SCCS-vsn: sbin/dump/dump.h 1.8
SCCS-vsn: sbin/dump/main.c 1.12
- * "@(#)dump.h 1.7 (Berkeley) %G%"
+ * "@(#)dump.h 1.8 (Berkeley) %G%"
*/
#define NI 16
#define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
*/
#define NI 16
#define MAXINOPB (MAXBSIZE / sizeof(struct dinode))
int uflag; /* update flag */
int fi; /* disk file descriptor */
int to; /* tape file descriptor */
int uflag; /* update flag */
int fi; /* disk file descriptor */
int to; /* tape file descriptor */
+int pipeout; /* true => output to standard output */
ino_t ino; /* current inumber; used globally */
int nsubdir;
int newtape; /* new tape flag */
ino_t ino; /* current inumber; used globally */
int nsubdir;
int newtape; /* new tape flag */
-static char *sccsid = "@(#)main.c 1.11 (Berkeley) %G%";
+static char *sccsid = "@(#)main.c 1.12 (Berkeley) %G%";
#include "dump.h"
int notify = 0; /* notify operator flag */
#include "dump.h"
int notify = 0; /* notify operator flag */
- printf("bad key '%c%'\n", arg[-1]);
+ fprintf(stderr, "bad key '%c%'\n", arg[-1]);
Exit(X_ABORT);
}
if(argc > 1) {
Exit(X_ABORT);
}
if(argc > 1) {
+ if (strcmp(tape, "-") == 0) {
+ pipeout++;
+ tape = "standard output";
+ }
/*
* Determine how to default tape size and density
/*
* Determine how to default tape size and density
putitime();
#ifndef RDUMP
putitime();
#ifndef RDUMP
+ if (!pipeout) {
+ close(to);
+ rewind();
+ }
broadcast("DUMP IS DONE!\7\7\n");
Exit(X_FINOK);
}
broadcast("DUMP IS DONE!\7\7\n");
Exit(X_FINOK);
}
+ if (pipeout) {
+ msg("Unknown signal, cannot recover\n");
+ dumpabort();
+ }
msg("Rewriting attempted as response to unknown signal.\n");
fflush(stderr);
fflush(stdout);
msg("Rewriting attempted as response to unknown signal.\n");
fflush(stderr);
fflush(stdout);
-static char *sccsid = "@(#)tape.c 1.6 (Berkeley) %G%";
+static char *sccsid = "@(#)tape.c 1.7 (Berkeley) %G%";
#include "dump.h"
char (*tblock)[TP_BSIZE]; /* Pointer to malloc()ed buffer for tape */
#include "dump.h"
char (*tblock)[TP_BSIZE]; /* Pointer to malloc()ed buffer for tape */
trecno = 0;
if (write(to, tblock[0], writesize) != writesize){
trecno = 0;
if (write(to, tblock[0], writesize) != writesize){
+ if (pipeout) {
+ msg("Tape write error on %s\n", tape);
+ msg("Cannot recover\n");
+ dumpabort();
+ /* NOTREACHED */
+ }
msg("Tape write error on tape %d\n", tapeno);
broadcast("TAPE ERROR!\n");
if (query("Do you want to restart?")){
msg("Tape write error on tape %d\n", tapeno);
broadcast("TAPE ERROR!\n");
if (query("Do you want to restart?")){
asize += writesize/density;
asize += 7;
blockswritten += ntrec;
asize += writesize/density;
asize += 7;
blockswritten += ntrec;
+ if (!pipeout && asize > tsize) {
close_rewind();
otape();
}
close_rewind();
otape();
}
+
+ if (pipeout)
+ return;
#ifdef DEBUG
msg("Waiting 10 seconds to rewind.\n");
sleep(10);
#ifdef DEBUG
msg("Waiting 10 seconds to rewind.\n");
sleep(10);
+
+ if (pipeout)
+ return;
close(to);
if (!nogripe){
rewind();
close(to);
if (!nogripe){
rewind();
tapeno+1, parentpid, getpid());
#endif
do{
tapeno+1, parentpid, getpid());
#endif
do{
- to = creat(tape, 0666);
+ if (pipeout)
+ to = 1;
+ else
+ to = creat(tape, 0666);
if (to < 0) {
if (!query("Cannot open tape. Do you want to retry the open?"))
dumpabort();
if (to < 0) {
if (!query("Cannot open tape. Do you want to retry the open?"))
dumpabort();