X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Fmain.c;h=0d1f4fd19adb082e7ec6ec376db9ce1b6009f15a;hb=651fb4a593dfd7a31129b7feb8d5dbd57c6f145d;hp=3f114c9e921ada33c97ab6ab10f1685f46abb649;hpb=a94ecd1155631b9f88488a19268874c0e3c6601c;p=dump.git diff --git a/dump/main.c b/dump/main.c index 3f114c9..0d1f4fd 100644 --- a/dump/main.c +++ b/dump/main.c @@ -41,10 +41,11 @@ #ifndef lint static const char rcsid[] = - "$Id: main.c,v 1.43 2001/04/10 13:42:22 stelian Exp $"; + "$Id: main.c,v 1.52 2001/07/18 13:12:33 stelian Exp $"; #endif /* not lint */ #include +#include #include #include #include @@ -57,10 +58,14 @@ static const char rcsid[] = #include #include +#include #ifdef __linux__ +#ifdef HAVE_EXT2FS_EXT2_FS_H +#include +#else #include +#endif #include -#include #include #include #elif defined sunos @@ -91,7 +96,7 @@ int ntrec = NTREC; /* # tape blocks in each tape record */ int cartridge = 0; /* Assume non-cartridge tape */ #ifdef USE_QFA int tapepos = 0; /* assume no QFA tapeposition needed by user */ -#endif /* USA_QFA */ +#endif /* USE_QFA */ int dokerberos = 0; /* Use Kerberos authentication */ long dev_bsize = 1; /* recalculated below */ long blocksperfile; /* output blocks per file */ @@ -124,8 +129,8 @@ main(int argc, char *argv[]) register int ch; int i, anydirskipped, bflag = 0, Tflag = 0, honorlevel = 1; dump_ino_t maxino; - struct stat statbuf; - dev_t filedev; + struct STAT statbuf; + dev_t filedev = 0; #ifdef __linux__ errcode_t retval; char directory[MAXPATHLEN]; @@ -160,7 +165,7 @@ main(int argc, char *argv[]) #ifdef USE_QFA gTapeposfd = -1; -#endif /* USA_QFA */ +#endif /* USE_QFA */ while ((ch = getopt(argc, argv, "0123456789aB:b:cd:e:f:F:h:L:" @@ -282,7 +287,7 @@ main(int argc, char *argv[]) gTapeposfile = optarg; tapepos = 1; break; -#endif /* USA_QFA */ +#endif /* USE_QFA */ case 's': /* tape size, feet */ unlimited = 0; @@ -348,7 +353,7 @@ main(int argc, char *argv[]) tapeprefix = "standard output"; } - if (blocksperfile) + if (blocksperfile && !compressed) blocksperfile = blocksperfile / ntrec * ntrec; /* round down */ else if (!unlimited) { /* @@ -514,10 +519,18 @@ main(int argc, char *argv[]) strncpy(tape, tapeprefix, MAXPATHLEN); tape[MAXPATHLEN - 1] = '\0'; + if (!pipeout) { + if (STAT(tape, &statbuf) != -1) + fifoout= statbuf.st_mode & S_IFIFO; + } + if (!sizest) { msg("Date of this level %c dump: %s", level, ctime4(&spcl.c_date)); +#ifdef USE_QFA + gThisDumpDate = spcl.c_date; +#endif if (spcl.c_ddate) msg("Date of last level %c dump: %s", lastlevel, ctime4(&spcl.c_ddate)); @@ -543,7 +556,7 @@ main(int argc, char *argv[]) msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); } - if ((diskfd = open(disk, O_RDONLY)) < 0) { + if ((diskfd = OPEN(disk, O_RDONLY)) < 0) { msg("Cannot open %s\n", disk); msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); @@ -604,10 +617,13 @@ main(int argc, char *argv[]) nonodump = spcl.c_level < honorlevel; - msg("Label: %s\n", spcl.c_label); + if (!sizest) { + msg("Label: %s\n", spcl.c_label); - if (compressed) - msg("Compressing output at compression level %d\n", compressed); + if (compressed) + msg("Compressing output at compression level %d\n", + compressed); + } #if defined(SIGINFO) (void)signal(SIGINFO, statussig); @@ -619,7 +635,7 @@ main(int argc, char *argv[]) if (directory[0] == 0) anydirskipped = mapfiles(maxino, &tapesize); else { - if (stat(pathname, &statbuf) == -1) { + if (STAT(pathname, &statbuf) == -1) { msg("File cannot be accessed (%s).\n", pathname); msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); @@ -636,7 +652,7 @@ main(int argc, char *argv[]) int anydirskipped2; char *p = *argv; /* check if file is available */ - if (stat(p, &statbuf) == -1) { + if (STAT(p, &statbuf) == -1) { msg("File cannot be accessed (%s).\n", p); msg("The ENTIRE dump is aborted.\n"); exit(X_STARTUP); @@ -812,7 +828,7 @@ main(int argc, char *argv[]) tnow = trewind(); - if (pipeout) + if (pipeout || fifoout) msg("%ld tape blocks (%.2fMB)\n", spcl.c_tapea, ((double)spcl.c_tapea * TP_BSIZE / 1048576)); else @@ -915,9 +931,9 @@ sig(int signo) case SIGHUP: case SIGTERM: case SIGTRAP: - if (pipeout) + if (pipeout || fifoout) quit("Signal on pipe: cannot recover\n"); - msg("Rewriting attempted as response to unknown signal.\n"); + msg("Rewriting attempted as response to unknown signal: %d.\n", signo); (void)fflush(stderr); (void)fflush(stdout); close_rewind();