Tar EOT bug and fix (with correction)

Bill Vaughn bill at ur-cvsvax.UUCP
Thu Mar 21 15:36:49 AEST 1985


Sorry, I screwed up my first bug-fix posting. No excuses.
Here it is again. (Actually, this is not exactlly the way I fixed
my version. But the way I did it works.  This method should work also.)
Corrections are noted by !!--->  .

*** tar.org.c
--- tar.fix.c	Tue Mar 19 16:25:19 1985
***************
*** 1092,1101
  {
  	first = 1;
  	if (recno >= nblock) {
! 		if (write(mt, tbuf, TBLOCK*nblock) < 0) {
! 			fprintf(stderr, "tar: tape write error\n");
! 			done(2);
! 		}
  		recno = 0;
  	}
  	bcopy(buffer, (char *)&tbuf[recno++], TBLOCK);

--- 1092,1098 -----
  {
  	first = 1;
  	if (recno >= nblock) {
! 		flushtape();
  		recno = 0;
  	}
  	bcopy(buffer, (char *)&tbuf[recno++], TBLOCK);
***************
*** 1100,1109
  	}
  	bcopy(buffer, (char *)&tbuf[recno++], TBLOCK);
  	if (recno >= nblock) {
! 		if (write(mt, tbuf, TBLOCK*nblock) < 0) {
! 			fprintf(stderr, "tar: tape write error\n");
! 			done(2);
! 		}
  		recno = 0;
  	}
  	return (TBLOCK);

--- 1097,1103 -----
  	}
  	bcopy(buffer, (char *)&tbuf[recno++], TBLOCK);
  	if (recno >= nblock) {
! 		flushtape();
  		recno = 0;
  	}
  	return (TBLOCK);
***************
*** 1129,1135
  
  flushtape()
  {
! 	write(mt, tbuf, TBLOCK*nblock);
  }
  
  bread(fd, buf, size)

--- 1123,1147 -----
  
  flushtape()
  {
! 	register int n;
! 
! 	if ((n=write(mt, tbuf, TBLOCK*nblock)) != TBLOCK*nblock) {
! 		if (n)
! 			fprintf(stderr, "tar: tape write error\n");
!!---> 		else {
! 			fprintf(stderr, "tar: EOT mark encountered. ");
! 			/*
! 			 * With a little work one could decide if the
! 			 * following is really true. Be conservative.
! 			 */
! 			fprintf(stderr, "Last file is incomplete.\n");
! 			/*
! 			 * The following keeps subsequent reads happy.
! 			 */
! 			bzero(tbuf, TBLOCK*nblock);
! 			write(mt, tbuf, TBLOCK*nblock);
!!--->		}
! 		done(2);
! 	}
  }
  
  bread(fd, buf, size)
***********************

 Bill Vaughn, U. of Rochester
 {allegra,seismo,decvax}!rochester!ur-cvsvax!bill

"Hey, you're going to love this program now that
 I've added all of these new bu ... er, features."
					Anonymous Hacker



More information about the Net.bugs mailing list