Deleted Added
full compact
tape.c (128073) tape.c (128175)
1/*-
2 * Copyright (c) 1980, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30#ifndef lint
31#if 0
32static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95";
33#endif
34static const char rcsid[] =
1/*-
2 * Copyright (c) 1980, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 18 unchanged lines hidden (view full) ---

27 * SUCH DAMAGE.
28 */
29
30#ifndef lint
31#if 0
32static char sccsid[] = "@(#)tape.c 8.4 (Berkeley) 5/1/95";
33#endif
34static const char rcsid[] =
35 "$FreeBSD: head/sbin/dump/tape.c 128073 2004-04-09 19:58:40Z markm $";
35 "$FreeBSD: head/sbin/dump/tape.c 128175 2004-04-13 02:58:06Z green $";
36#endif /* not lint */
37
38#include <sys/param.h>
39#include <sys/socket.h>
40#include <sys/time.h>
41#include <sys/wait.h>
42#include <sys/stat.h>
43

--- 18 unchanged lines hidden (view full) ---

62int64_t lastspclrec = -1; /* tape block number of last written header */
63int trecno = 0; /* next record to write in current block */
64extern long blocksperfile; /* number of blocks per output file */
65long blocksthisvol; /* number of blocks on current output file */
66extern int ntrec; /* blocking factor on tape */
67extern int cartridge;
68extern char *host;
69char *nexttape;
36#endif /* not lint */
37
38#include <sys/param.h>
39#include <sys/socket.h>
40#include <sys/time.h>
41#include <sys/wait.h>
42#include <sys/stat.h>
43

--- 18 unchanged lines hidden (view full) ---

62int64_t lastspclrec = -1; /* tape block number of last written header */
63int trecno = 0; /* next record to write in current block */
64extern long blocksperfile; /* number of blocks per output file */
65long blocksthisvol; /* number of blocks on current output file */
66extern int ntrec; /* blocking factor on tape */
67extern int cartridge;
68extern char *host;
69char *nexttape;
70FILE *popenfp = NULL;
70
71static int atomic(ssize_t (*)(), int, char *, int);
72static void doslave(int, int);
73static void enslave(void);
74static void flushtape(void);
75static void killall(void);
76static void rollforward(void);
77

--- 253 unchanged lines hidden (view full) ---

331 while (wait((int *)NULL) >= 0) /* wait for any signals from slaves */
332 /* void */;
333
334 if (pipeout)
335 return;
336
337 msg("Closing %s\n", tape);
338
71
72static int atomic(ssize_t (*)(), int, char *, int);
73static void doslave(int, int);
74static void enslave(void);
75static void flushtape(void);
76static void killall(void);
77static void rollforward(void);
78

--- 253 unchanged lines hidden (view full) ---

332 while (wait((int *)NULL) >= 0) /* wait for any signals from slaves */
333 /* void */;
334
335 if (pipeout)
336 return;
337
338 msg("Closing %s\n", tape);
339
340 if (popenout) {
341 tapefd = -1;
342 (void)pclose(popenfp);
343 popenfp = NULL;
344 return;
345 }
339#ifdef RDUMP
340 if (host) {
341 rmtclose();
342 while (rmtopen(tape, 0) < 0)
343 sleep(10);
344 rmtclose();
345 return;
346 }

--- 148 unchanged lines hidden (view full) ---

495 * everything continues as if nothing had happened.
496 */
497void
498startnewtape(int top)
499{
500 int parentpid;
501 int childpid;
502 int status;
346#ifdef RDUMP
347 if (host) {
348 rmtclose();
349 while (rmtopen(tape, 0) < 0)
350 sleep(10);
351 rmtclose();
352 return;
353 }

--- 148 unchanged lines hidden (view full) ---

502 * everything continues as if nothing had happened.
503 */
504void
505startnewtape(int top)
506{
507 int parentpid;
508 int childpid;
509 int status;
503 int waitpid;
504 char *p;
505 sig_t interrupt_save;
506
507 interrupt_save = signal(SIGINT, SIG_IGN);
508 parentpid = getpid();
509
510restore_check_point:
511 (void)signal(SIGINT, interrupt_save);

--- 13 unchanged lines hidden (view full) ---

525 * until the child doing all of the work returns.
526 * don't catch the interrupt
527 */
528 signal(SIGINT, SIG_IGN);
529#ifdef TDEBUG
530 msg("Tape: %d; parent process: %d child process %d\n",
531 tapeno+1, parentpid, childpid);
532#endif /* TDEBUG */
510 char *p;
511 sig_t interrupt_save;
512
513 interrupt_save = signal(SIGINT, SIG_IGN);
514 parentpid = getpid();
515
516restore_check_point:
517 (void)signal(SIGINT, interrupt_save);

--- 13 unchanged lines hidden (view full) ---

531 * until the child doing all of the work returns.
532 * don't catch the interrupt
533 */
534 signal(SIGINT, SIG_IGN);
535#ifdef TDEBUG
536 msg("Tape: %d; parent process: %d child process %d\n",
537 tapeno+1, parentpid, childpid);
538#endif /* TDEBUG */
533 while ((waitpid = wait(&status)) != childpid)
534 msg("Parent %d waiting for child %d has another child %d return\n",
535 parentpid, childpid, waitpid);
539 if (waitpid(childpid, &status, 0) == -1)
540 msg("Waiting for child %d: %s\n", childpid,
541 strerror(errno));
536 if (status & 0xFF) {
537 msg("Child %d returns LOB status %o\n",
538 childpid, status&0xFF);
539 }
540 status = (status >> 8) & 0xFF;
541#ifdef TDEBUG
542 switch(status) {
543 case X_FINOK:

--- 40 unchanged lines hidden (view full) ---

584 tape = nexttape;
585 if ((p = strchr(tape, ',')) != NULL) {
586 *p = '\0';
587 nexttape = p + 1;
588 } else
589 nexttape = NULL;
590 msg("Dumping volume %d on %s\n", tapeno, tape);
591 }
542 if (status & 0xFF) {
543 msg("Child %d returns LOB status %o\n",
544 childpid, status&0xFF);
545 }
546 status = (status >> 8) & 0xFF;
547#ifdef TDEBUG
548 switch(status) {
549 case X_FINOK:

--- 40 unchanged lines hidden (view full) ---

590 tape = nexttape;
591 if ((p = strchr(tape, ',')) != NULL) {
592 *p = '\0';
593 nexttape = p + 1;
594 } else
595 nexttape = NULL;
596 msg("Dumping volume %d on %s\n", tapeno, tape);
597 }
598 if (pipeout) {
599 tapefd = STDOUT_FILENO;
600 } else if (popenout) {
601 char volno[sizeof("2147483647")];
602
603 (void)sprintf(volno, "%d", spcl.c_volume + 1);
604 if (setenv("DUMP_VOLUME", volno, 1) == -1) {
605 msg("Cannot set $DUMP_VOLUME.\n");
606 dumpabort(0);
607 }
608 popenfp = popen(popenout, "w");
609 if (popenfp == NULL) {
610 msg("Cannot open output pipeline \"%s\".\n",
611 popenout);
612 dumpabort(0);
613 }
614 tapefd = fileno(popenfp);
615 } else {
592#ifdef RDUMP
616#ifdef RDUMP
593 while ((tapefd = (host ? rmtopen(tape, 2) :
594 pipeout ? 1 : open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
617 while ((tapefd = (host ? rmtopen(tape, 2) :
618 open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
595#else
619#else
596 while ((tapefd = (pipeout ? 1 :
597 open(tape, O_WRONLY|O_CREAT, 0666))) < 0)
620 while ((tapefd =
621 open(tape, O_WRONLY|O_CREAT, 0666)) < 0)
598#endif
622#endif
599 {
600 msg("Cannot open output \"%s\".\n", tape);
601 if (!query("Do you want to retry the open?"))
602 dumpabort(0);
623 {
624 msg("Cannot open output \"%s\".\n", tape);
625 if (!query("Do you want to retry the open?"))
626 dumpabort(0);
627 }
603 }
604
605 enslave(); /* Share open tape file descriptor with slaves */
628 }
629
630 enslave(); /* Share open tape file descriptor with slaves */
631 if (popenout)
632 close(tapefd); /* Give up our copy of it. */
606 signal(SIGINFO, infosch);
607
608 asize = 0;
609 blocksthisvol = 0;
610 if (top)
611 newtape++; /* new tape signal */
612 spcl.c_count = slp->count;
613 /*

--- 240 unchanged lines hidden ---
633 signal(SIGINFO, infosch);
634
635 asize = 0;
636 blocksthisvol = 0;
637 if (top)
638 newtape++; /* new tape signal */
639 spcl.c_count = slp->count;
640 /*

--- 240 unchanged lines hidden ---