X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=dump%2Ftape.c;h=5a50ff95aaf66e814efad447026639090b8814e9;hb=92a9bf12543aadfcc46e7ab9c2729b4d4d1f22ee;hp=741f2de25ad442a1fcf58cd183beea2945662556;hpb=8d4197bb9ba5bbcef21409231ed8903b0cac353a;p=dump.git diff --git a/dump/tape.c b/dump/tape.c index 741f2de..5a50ff9 100644 --- a/dump/tape.c +++ b/dump/tape.c @@ -2,8 +2,7 @@ * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit * Remy Card , 1994-1997 - * Stelian Pop , 1999 - * + * Stelian Pop , 1999-2000 */ /*- @@ -40,11 +39,8 @@ */ #ifndef lint -#if 0 -static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95"; -#endif static const char rcsid[] = - "$Id: tape.c,v 1.4 1999/10/11 13:08:08 stelian Exp $"; + "$Id: tape.c,v 1.14 2000/03/01 10:16:05 stelian Exp $"; #endif /* not lint */ #ifdef __linux__ @@ -85,9 +81,10 @@ static const char rcsid[] = int write(), read(); #endif -#ifdef __linux__ +#ifdef __linux__ #include #endif + #include "dump.h" int writesize; /* size of malloc()ed buffer for tape */ @@ -99,6 +96,7 @@ extern int ntrec; /* blocking factor on tape */ extern int cartridge; extern char *host; char *nexttape; +extern pid_t rshpid; static ssize_t atomic_read __P((int, void *, size_t)); static ssize_t atomic_write __P((int, const void *, size_t)); @@ -313,6 +311,8 @@ statussig(int notused) #else (void) time((time_t *) &tnow); #endif + if (blockswritten > tapesize) + tapesize = blockswritten; deltat = tstart_writing - tnow + (1.0 * (tnow - tstart_writing)) / blockswritten * tapesize; (void)snprintf(msgbuf, sizeof(msgbuf), @@ -460,7 +460,7 @@ close_rewind(void) { trewind(); (void)do_stats(); - if (nexttape) + if (nexttape || Mflag) return; if (!nogripe) { msg("Change Volumes: Mount volume #%d\n", tapeno+1); @@ -665,7 +665,8 @@ restore_check_point: tapeno+1, parentpid, childpid); #endif /* TDEBUG */ while ((waitpid = wait(&status)) != childpid) - msg("Parent %d waiting for child %d has another child %d return\n", + if (waitpid != rshpid) + msg("Parent %d waiting for child %d has another child %d return\n", parentpid, childpid, waitpid); if (status & 0xFF) { msg("Child %d returns LOB status %o\n", @@ -713,21 +714,29 @@ restore_check_point: * the remaining names for subsequent volumes. */ tapeno++; /* current tape sequence */ - if (nexttape || strchr(tape, ',')) { + if (Mflag) { + snprintf(tape, MAXPATHLEN, "%s%03d", tapeprefix, tapeno); + tape[MAXPATHLEN - 1] = '\0'; + msg("Dumping volume %d on %s\n", tapeno, tape); + } + else if (nexttape || strchr(tapeprefix, ',')) { if (nexttape && *nexttape) - tape = nexttape; - if ((p = strchr(tape, ',')) != NULL) { + tapeprefix = nexttape; + if ((p = strchr(tapeprefix, ',')) != NULL) { *p = '\0'; nexttape = p + 1; } else nexttape = NULL; + strncpy(tape, tapeprefix, MAXPATHLEN); + tape[MAXPATHLEN - 1] = '\0'; msg("Dumping volume %d on %s\n", tapeno, tape); } #ifdef RDUMP - while ((tapefd = (host ? rmtopen(tape, 2) : - pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) < 0) + while ((tapefd = (host ? rmtopen(tape, 2) : pipeout ? + fileno(stdout) : + open(tape, O_WRONLY|O_CREAT, 0666))) < 0) #else - while ((tapefd = (pipeout ? 1 : + while ((tapefd = (pipeout ? fileno(stdout) : open(tape, O_WRONLY|O_CREAT, 0666))) < 0) #endif { @@ -910,9 +919,9 @@ doslave(int cmd, int slave_number) quit("slave couldn't reopen disk: %s\n", strerror(errno)); #ifdef __linux__ ext2fs_close(fs); - retval = ext2fs_open(disk, 0, 0, 0, unix_io_manager, &fs); + retval = dump_fs_open(disk, &fs); if (retval) - quit("slave couldn't reopen disk: %s\n", strerror(errno)); + quit("slave couldn't reopen disk: %s\n", error_message(retval)); #endif /* __linux__ */ /* @@ -1023,8 +1032,10 @@ atomic_read(int fd, void *buf, size_t count) { int got, need = count; - while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0) - (char *)buf += got; + do { + while ((got = read(fd, buf, need)) > 0 && (need -= got) > 0) + (char *)buf += got; + } while (got == -1 && errno == EINTR); return (got < 0 ? got : count - need); } @@ -1038,7 +1049,9 @@ atomic_write(int fd, const void *buf, size_t count) { int got, need = count; - while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0) - (char *)buf += got; + do { + while ((got = write(fd, buf, need)) > 0 && (need -= got) > 0) + (char *)buf += got; + } while (got == -1 && errno == EINTR); return (got < 0 ? got : count - need); }