- while(file.type == F_TAPESTART || file.type == F_DUMPFILE) {
- amfree(filename);
- filename = make_filename(&file);
- found_match = 0;
- for(me = match_list; me; me = me->next) {
- if(disk_match(&file,me->datestamp,me->hostname,me->diskname) != 0) {
- found_match = 1;
- break;
- }
- }
- fprintf(stderr, "%s: %3d: %s ",
- get_pname(),
- file_number,
- found_match ? "restoring" : "skipping");
- if(file.type != F_DUMPFILE) {
- print_header(stderr, &file);
- } else {
- fprintf(stderr, "%s\n", filename);
- }
- if(found_match) {
- restore(&file, filename, isafile);
- if(compress_pid > 0) {
- waitpid(compress_pid, &compress_status, 0);
- compress_pid = -1;
- }
- if(pipeflag) {
- file_number++; /* for the last message */
- break;
- }
- }
- if(isafile) {
- break;
- }
- /*
- * Note that at this point we know we are working with a tape,
- * not a holding disk file, so we can call the tape functions
- * without checking.
- */
- if(bytes_read == 0) {
- /*
- * If the last read got EOF, how to get to the next
- * file depends on how the tape device driver is acting.
- * If it is BSD-like, we do not really need to do anything.
- * If it is Sys-V-like, we need to either fsf or close/open.
- * The good news is, a close/open works in either case,
- * so that's what we do.
- */
- tapefd_close(tapedev);
- if((tapedev = tape_open(tapename, 0)) < 0) {
- error("could not open %s: %s", tapename, strerror(errno));
- }
- } else {
- /*
- * If the last read got something (even an error), we can
- * do an fsf to get to the next file.
- */
- if(tapefd_fsf(tapedev, 1) < 0) {
- error("could not fsf %s: %s", tapename, strerror(errno));
- }
- }
- file_number++;
- read_file_header(&file, isafile);
- }
- if(isafile) {
- close(tapedev);
- } else {
- /*
- * See the notes above about advancing to the next file.
- */
- if(bytes_read == 0) {
- tapefd_close(tapedev);
- if((tapedev = tape_open(tapename, 0)) < 0) {
- error("could not open %s: %s", tapename, strerror(errno));
- }
- } else {
- if(tapefd_fsf(tapedev, 1) < 0) {
- error("could not fsf %s: %s", tapename, strerror(errno));
- }
- }
- tapefd_close(tapedev);
- }