Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates to handle old and broken tapes. #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions itstar.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,14 @@ static void extfiles(int argc,char **argv)
scantape(argc,argv,extfile);
}

/* skip a single file */
void skipfile()
{
while (taperead() >= 0)
;
taperead();
}

/* extract a single file (called back by scantape()) */
static void extfile()
{
Expand Down Expand Up @@ -438,7 +446,6 @@ static void extfile()
sprintf(lname,"%s/%s.%s",lufd,lfn1,lfn2); /* combine */
if(symlink(lname,fname)<0) { /* create link */
perror(fname);
exit(1);
}
/* can't apply dates since target may not exist */
taperead(); /* read the EOF mark */
Expand All @@ -454,7 +461,7 @@ static void extfile()
else u.actime=u.modtime; /* use creation date if not */
if(utime(fname,&u)<0) {
perror("?Error setting file dates");
exit(1);
taperead(); /* read the EOF mark */
}
}
}
Expand Down Expand Up @@ -542,9 +549,10 @@ static void scantape(int argc,char **argv,void (*process)())
while(taperead()==0) { /* read file label */
fhead: inword(&l,&r); /* 1: AOBJN ptr giving length */
len=01000000L-l; /* length of record */
if(len<4) { /* must have at least filename */
fprintf(stderr,"?Invalid tape format\n");
exit(1);
if(len<4||len>10) {
fprintf(stderr,"?Invalid tape file header\n");
skipfile();
goto fhead;
}
insix(ufd); /* 2: UFD */
insix(fn1); /* 3: FN1 */
Expand Down
1 change: 1 addition & 0 deletions itstar.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ void save(char *f);
void resetbuf();
void tapeflush();
int taperead();
void skipfile();
void inword(long *l,long *r);
void outword(register unsigned long l,register unsigned long r);
int nextword(long *l,long *r);
Expand Down
3 changes: 2 additions & 1 deletion pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,8 @@ void pack(char *file)
out=fopen(file,"wb"); /* create output file */
if(out==NULL) {
perror(file);
exit(1);
skipfile();
return;
}

if((remaining()==0)&&(taperead()<0)) {
Expand Down