|
|
1.1 root 1: /*
2: * rp07dump: quick and dirty to copy an entire RP07 to tape
3: * Tape errors are not tolerated. Input errors are handled.
4: * Dumping is to 4 reels; each reel gets exactly 1/4 of the disk.
5: */
6:
7: #include <stdio.h>
8: #include <assert.h>
9:
10: #define TAPE "/dev/rmt2" /* tape to use */
11: #define SECTSIZE 512 /* bytes per sector */
12: #define NSECT 1008000 /* sectors per RP07 */
13: #define TRKSIZE 50 /* sectors per track */
14: #define NREELS 4 /* reels of tape in the dump */
15: #define BPT (NSECT/(NREELS*TRKSIZE)) /* buffer loads per tape */
16:
17: char buf[SECTSIZE*TRKSIZE];
18:
19: main (argc, argv)
20: int argc;
21: char **argv;
22: {
23: register int disk, tape, n, i;
24: int reel;
25: long blockno; /* block number on disk */
26:
27: if (argc != 2) {
28: fprintf (stderr, "arg count");
29: exit (1);
30: }
31:
32: disk = open (argv[1], 0);
33: if (disk < 0) {
34: perror (argv[1]);
35: exit (1);
36: }
37:
38: blockno = 0;
39: for (reel = 1; reel <= NREELS; reel++) {
40:
41: do {
42: char answer[500];
43: do {
44: printf ("Have you mounted volume %d? ", reel);
45: gets (answer);
46: } while (strcmp (answer, "yes") != 0);
47:
48: tape = open (TAPE, 1);
49: if (tape < 0)
50: perror (TAPE);
51: } while (tape < 0);
52:
53: for (i = 0; i < BPT; i++) {
54: n = read (disk, buf, sizeof(buf));
55: if (n != sizeof (buf)) {
56: long boff;
57: long bytebase;
58: fprintf (stderr, "trouble near block %ld\n",
59: blockno);
60: perror (argv[1]);
61:
62: for (n = 0; n < sizeof (buf); n++)
63: buf[n] = '?';
64:
65: bytebase = blockno * SECTSIZE;
66: for (boff=0; boff<sizeof(buf); boff+=SECTSIZE) {
67: if (lseek (disk,bytebase+boff,0) < 0) {
68: perror ("lseek");
69: exit (1);
70: }
71: n = read (disk, buf+boff, SECTSIZE);
72: if (n != SECTSIZE) {
73: fprintf (stderr,
74: "can't read sector %ld\n",
75: blockno + boff / SECTSIZE);
76: }
77: }
78:
79: if (lseek (disk,(blockno+TRKSIZE)*SECTSIZE,0)
80: < 0) {
81: perror ("seek 2");
82: exit (1);
83: }
84: }
85: blockno += TRKSIZE;
86: n = write (tape, buf, sizeof(buf));
87: if (n != sizeof (buf)) {
88: perror (argv[1]);
89: exit (1);
90: }
91: }
92:
93: close (tape);
94: }
95:
96: printf ("End of dump\n");
97: exit (0);
98: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.