- count_error = 0;
- while(count_error < 10) {
- if(file.type == F_TAPEEND) break;
- found_match = 0;
- if(file.type == F_DUMPFILE || file.type == F_SPLIT_DUMPFILE) {
- amfree(filename);
- filename = make_filename(&file);
- 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: " OFF_T_FMT ": %s ",
- get_pname(),
- (OFF_T_FMT_TYPE)file_number,
- found_match ? "restoring" : "skipping");
- if(file.type != F_DUMPFILE && file.type != F_SPLIT_DUMPFILE) {
- print_header(stderr, &file);
- } else {
- fprintf(stderr, "%s\n", filename);
- }
- }
- if(found_match) {
- count_error=0;
- read_result = restore(&file, filename,
- tapedev, isafile, rst_flags);
- if(comp_enc_pid > 0) {
- waitpid(comp_enc_pid, &compress_status, 0);
- comp_enc_pid = -1;
- }
- if(rst_flags->pipe_to_fd != -1) {
- 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(read_result == 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));
- /*NOTREACHED*/
- }
- count_error++;
- } 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, (off_t)1) < 0) {
- error("could not fsf %s: %s", tapename, strerror(errno));
- /*NOTREACHED*/
- }
- count_error=0;
- }
- file_number++;
- read_result = read_file_header(&file, tapedev, isafile, rst_flags);
- }
- if(isafile) {
- close(tapedev);
- } else {
- /*
- * See the notes above about advancing to the next file.
- */
- if(read_result == 0) {
- tapefd_close(tapedev);
- if((tapedev = tape_open(tapename, 0)) < 0) {
- error("could not open %s: %s", tapename, strerror(errno));
- /*NOTREACHED*/
- }
- } else {
- if(tapefd_fsf(tapedev, (off_t)1) < 0) {
- error("could not fsf %s: %s", tapename, strerror(errno));
- /*NOTREACHED*/
- }
- }
- tapefd_close(tapedev);
- }
-
- if((read_result <= 0 || file.type == F_TAPEEND) && !isafile) {
- fprintf(stderr, "%s: " OFF_T_FMT ": reached ",
- get_pname(), (OFF_T_FMT_TYPE)file_number);
- if(read_result <= 0) {
- fprintf(stderr, "end of information\n");
- } else {
- print_header(stderr,&file);
- }
- r = 1;
- }
- return r;