]> git.wh0rd.org - dump.git/blobdiff - dump/tape.c
Compatibility between dumps made on little endian machines vs. big endian machines...
[dump.git] / dump / tape.c
index 4aaffb3271e62e17b76a76c6aefe20ef5ba314f1..b3964a8336512054dc957f16524c27003d928ff1 100644 (file)
@@ -2,8 +2,7 @@
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
  *     Remy Card <card@Linux.EU.Org>, 1994-1997
- *      Stelian Pop <pop@cybercable.fr>, 1999 
- *
+ *     Stelian Pop <pop@cybercable.fr>, 1999-2000
  */
 
 /*-
  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
- *
- * $Id: tape.c,v 1.5 1999/10/11 13:31:11 stelian Exp $
  */
 
+#ifndef lint
+static const char rcsid[] =
+       "$Id: tape.c,v 1.12 2000/02/10 09:42:32 stelian Exp $";
+#endif /* not lint */
+
 #ifdef __linux__
 #include <sys/types.h>
 #include <linux/types.h>
 int    write(), read();
 #endif
 
-#ifdef __linux__
+#ifdef __linux__
 #include <ext2fs/ext2fs.h>
 #endif
+
 #include "dump.h"
 
 int    writesize;              /* size of malloc()ed buffer for tape */
@@ -93,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));
@@ -307,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),
@@ -454,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);
@@ -659,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",
@@ -707,14 +714,21 @@ restore_check_point:
                 * the remaining names for subsequent volumes.
                 */
                tapeno++;               /* current tape sequence */
-               if (nexttape || strchr(tape, ',')) {
+               if (Mflag) {
+                       snprintf(tape, NAME_MAX, "%s%03d", tapeprefix, tapeno);
+                       tape[NAME_MAX - 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, NAME_MAX);
+                       tape[NAME_MAX - 1] = '\0';
                        msg("Dumping volume %d on %s\n", tapeno, tape);
                }
 #ifdef RDUMP
@@ -904,9 +918,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__ */
 
        /*
@@ -1017,8 +1031,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);
 }
 
@@ -1032,7 +1048,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);
 }