tape.c (90573) | tape.c (90608) |
---|---|
1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 27 unchanged lines hidden (view full) --- 36 * SUCH DAMAGE. 37 */ 38 39#ifndef lint 40#if 0 41static char sccsid[] = "@(#)tape.c 8.9 (Berkeley) 5/1/95"; 42#endif 43static const char rcsid[] = | 1/* 2 * Copyright (c) 1983, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 27 unchanged lines hidden (view full) --- 36 * SUCH DAMAGE. 37 */ 38 39#ifndef lint 40#if 0 41static char sccsid[] = "@(#)tape.c 8.9 (Berkeley) 5/1/95"; 42#endif 43static const char rcsid[] = |
44 "$FreeBSD: head/sbin/restore/tape.c 90573 2002-02-12 17:15:45Z iedowse $"; | 44 "$FreeBSD: head/sbin/restore/tape.c 90608 2002-02-13 12:06:58Z iedowse $"; |
45#endif /* not lint */ 46 47#include <sys/param.h> 48#include <sys/file.h> 49#include <sys/mtio.h> 50#include <sys/stat.h> 51#include <sys/time.h> 52 --- 239 unchanged lines hidden (view full) --- 292 * This suggested volume is enforced when doing full 293 * or incremental restores, but can be overridden by 294 * the user when only extracting a subset of the files. 295 */ 296void 297getvol(nextvol) 298 long nextvol; 299{ | 45#endif /* not lint */ 46 47#include <sys/param.h> 48#include <sys/file.h> 49#include <sys/mtio.h> 50#include <sys/stat.h> 51#include <sys/time.h> 52 --- 239 unchanged lines hidden (view full) --- 292 * This suggested volume is enforced when doing full 293 * or incremental restores, but can be overridden by 294 * the user when only extracting a subset of the files. 295 */ 296void 297getvol(nextvol) 298 long nextvol; 299{ |
300 long newvol, savecnt, wantnext, i; | 300 long newvol, savecnt, savetpcnt, i; |
301 union u_spcl tmpspcl; 302# define tmpbuf tmpspcl.s_spcl 303 char buf[TP_BSIZE]; 304 305 if (nextvol == 1) { 306 tapesread = 0; 307 gettingfile = 0; 308 } --- 4 unchanged lines hidden (view full) --- 313 if (yflag || ferror(terminal) || feof(terminal)) 314 done(1); 315 } 316 if (volno == 1) 317 return; 318 goto gethdr; 319 } 320 savecnt = blksread; | 301 union u_spcl tmpspcl; 302# define tmpbuf tmpspcl.s_spcl 303 char buf[TP_BSIZE]; 304 305 if (nextvol == 1) { 306 tapesread = 0; 307 gettingfile = 0; 308 } --- 4 unchanged lines hidden (view full) --- 313 if (yflag || ferror(terminal) || feof(terminal)) 314 done(1); 315 } 316 if (volno == 1) 317 return; 318 goto gethdr; 319 } 320 savecnt = blksread; |
321 savetpcnt = tpblksread; |
|
321again: | 322again: |
323 tpblksread = savetpcnt; |
|
322 if (pipein) 323 done(1); /* pipes do not get a second chance */ | 324 if (pipein) 325 done(1); /* pipes do not get a second chance */ |
324 if (command == 'R' || command == 'r' || curfile.action != SKIP) { | 326 if (command == 'R' || command == 'r' || curfile.action != SKIP) |
325 newvol = nextvol; | 327 newvol = nextvol; |
326 wantnext = 1; 327 } else { | 328 else |
328 newvol = 0; | 329 newvol = 0; |
329 wantnext = 0; 330 } | |
331 while (newvol <= 0) { 332 if (tapesread == 0) { 333 fprintf(stderr, "%s%s%s%s%s", 334 "You have not read any tapes yet.\n", 335 "Unless you know which volume your", 336 " file(s) are on you should start\n", 337 "with the last volume and work", 338 " towards the first.\n"); --- 80 unchanged lines hidden (view full) --- 419 * blocks read already at the end of the previous volume. 420 * 421 * If coming to this volume at random, skip to the beginning 422 * of the next record. 423 */ 424 dprintf(stdout, "read %ld recs, tape starts with %ld\n", 425 tpblksread, tmpbuf.c_firstrec); 426 if (tmpbuf.c_type == TS_TAPE && (tmpbuf.c_flags & DR_NEWHEADER)) { | 330 while (newvol <= 0) { 331 if (tapesread == 0) { 332 fprintf(stderr, "%s%s%s%s%s", 333 "You have not read any tapes yet.\n", 334 "Unless you know which volume your", 335 " file(s) are on you should start\n", 336 "with the last volume and work", 337 " towards the first.\n"); --- 80 unchanged lines hidden (view full) --- 418 * blocks read already at the end of the previous volume. 419 * 420 * If coming to this volume at random, skip to the beginning 421 * of the next record. 422 */ 423 dprintf(stdout, "read %ld recs, tape starts with %ld\n", 424 tpblksread, tmpbuf.c_firstrec); 425 if (tmpbuf.c_type == TS_TAPE && (tmpbuf.c_flags & DR_NEWHEADER)) { |
427 if (!wantnext) { | 426 if (curfile.action != USING) { |
428 tpblksread = tmpbuf.c_firstrec; | 427 tpblksread = tmpbuf.c_firstrec; |
429 for (i = tmpbuf.c_count; i > 0; i--) 430 readtape(buf); | 428 /* 429 * XXX Dump incorrectly sets c_count to 1 in the 430 * volume header of the first tape, so ignore 431 * c_count when volno == 1. 432 */ 433 if (volno != 1) 434 for (i = tmpbuf.c_count; i > 0; i--) 435 readtape(buf); |
431 } else if (tmpbuf.c_firstrec > 0 && 432 tmpbuf.c_firstrec < tpblksread - 1) { 433 /* 434 * -1 since we've read the volume header 435 */ 436 i = tpblksread - tmpbuf.c_firstrec - 1; 437 dprintf(stderr, "Skipping %ld duplicate record%s.\n", 438 i, i > 1 ? "s" : ""); 439 while (--i >= 0) 440 readtape(buf); 441 } 442 } | 436 } else if (tmpbuf.c_firstrec > 0 && 437 tmpbuf.c_firstrec < tpblksread - 1) { 438 /* 439 * -1 since we've read the volume header 440 */ 441 i = tpblksread - tmpbuf.c_firstrec - 1; 442 dprintf(stderr, "Skipping %ld duplicate record%s.\n", 443 i, i > 1 ? "s" : ""); 444 while (--i >= 0) 445 readtape(buf); 446 } 447 } |
443 if (curfile.action == USING || curfile.action == SKIP) { | 448 if (curfile.action == USING) { |
444 if (volno == 1) 445 panic("active file into volume 1\n"); 446 return; 447 } | 449 if (volno == 1) 450 panic("active file into volume 1\n"); 451 return; 452 } |
448 /* 449 * Skip up to the beginning of the next record 450 */ 451 if (tmpbuf.c_type == TS_TAPE && (tmpbuf.c_flags & DR_NEWHEADER)) 452 for (i = tmpbuf.c_count; i > 0; i--) 453 readtape(buf); | |
454 (void) gethead(&spcl); 455 findinode(&spcl); 456 if (gettingfile) { 457 gettingfile = 0; 458 longjmp(restart, 1); 459 } 460} 461 --- 755 unchanged lines hidden (view full) --- 1217 */ 1218static void 1219findinode(header) 1220 struct s_spcl *header; 1221{ 1222 static long skipcnt = 0; 1223 long i; 1224 char buf[TP_BSIZE]; | 453 (void) gethead(&spcl); 454 findinode(&spcl); 455 if (gettingfile) { 456 gettingfile = 0; 457 longjmp(restart, 1); 458 } 459} 460 --- 755 unchanged lines hidden (view full) --- 1216 */ 1217static void 1218findinode(header) 1219 struct s_spcl *header; 1220{ 1221 static long skipcnt = 0; 1222 long i; 1223 char buf[TP_BSIZE]; |
1224 int htype; |
|
1225 1226 curfile.name = "<name unknown>"; 1227 curfile.action = UNKNOWN; 1228 curfile.dip = NULL; 1229 curfile.ino = 0; 1230 do { 1231 if (header->c_magic != NFS_MAGIC) { 1232 skipcnt++; 1233 while (gethead(header) == FAIL || 1234 _time32_to_time(header->c_date) != dumpdate) 1235 skipcnt++; 1236 } | 1225 1226 curfile.name = "<name unknown>"; 1227 curfile.action = UNKNOWN; 1228 curfile.dip = NULL; 1229 curfile.ino = 0; 1230 do { 1231 if (header->c_magic != NFS_MAGIC) { 1232 skipcnt++; 1233 while (gethead(header) == FAIL || 1234 _time32_to_time(header->c_date) != dumpdate) 1235 skipcnt++; 1236 } |
1237 switch (header->c_type) { | 1237 htype = header->c_type; 1238 switch (htype) { |
1238 1239 case TS_ADDR: 1240 /* 1241 * Skip up to the beginning of the next record 1242 */ 1243 for (i = 0; i < header->c_count; i++) 1244 if (header->c_addr[i]) 1245 readtape(buf); --- 23 unchanged lines hidden (view full) --- 1269 panic("unexpected tape header\n"); 1270 /* NOTREACHED */ 1271 1272 default: 1273 panic("unknown tape header type %d\n", spcl.c_type); 1274 /* NOTREACHED */ 1275 1276 } | 1239 1240 case TS_ADDR: 1241 /* 1242 * Skip up to the beginning of the next record 1243 */ 1244 for (i = 0; i < header->c_count; i++) 1245 if (header->c_addr[i]) 1246 readtape(buf); --- 23 unchanged lines hidden (view full) --- 1270 panic("unexpected tape header\n"); 1271 /* NOTREACHED */ 1272 1273 default: 1274 panic("unknown tape header type %d\n", spcl.c_type); 1275 /* NOTREACHED */ 1276 1277 } |
1277 } while (header->c_type == TS_ADDR); | 1278 } while (htype == TS_ADDR); |
1278 if (skipcnt > 0) 1279 fprintf(stderr, "resync restore, skipped %ld blocks\n", 1280 skipcnt); 1281 skipcnt = 0; 1282} 1283 1284static int 1285checksum(buf) --- 125 unchanged lines hidden --- | 1279 if (skipcnt > 0) 1280 fprintf(stderr, "resync restore, skipped %ld blocks\n", 1281 skipcnt); 1282 skipcnt = 0; 1283} 1284 1285static int 1286checksum(buf) --- 125 unchanged lines hidden --- |