Fix tar's handling of links.
[rsc] --rw-rw-r-- M 23749 glenda sys 22453 Jan 31 07:50 sys/src/cmd/tar.c
/n/sourcesdump/2006/0131/plan9/sys/src/cmd/tar.c:56,62 -
/n/sourcesdump/2006/0201/plan9/sys/src/cmd/tar.c:56,62
LF_PLAIN2 = '0',
LF_LINK = '1',
LF_SYMLINK1 = '2',
- LF_SYMLINK2 = 's',
+ LF_SYMLINK2 = 's', /* 4BSD used this */
LF_CHR = '3',
LF_BLK = '4',
LF_DIR = '5',
/n/sourcesdump/2006/0131/plan9/sys/src/cmd/tar.c:459,470 -
/n/sourcesdump/2006/0201/plan9/sys/src/cmd/tar.c:459,471
return name(hp)[0] == '\0';
}
+ /* return the size from the header block, or zero for links, dirs, etc. */
Off
hdrsize(Hdr *hp)
{
Off bytes = strtoull(hp->size, nil, 8);
- if(isdir(hp))
+ if(isdir(hp) || islink(hp->linkflag))
bytes = 0;
return bytes;
}
/n/sourcesdump/2006/0131/plan9/sys/src/cmd/tar.c:934,939 -
/n/sourcesdump/2006/0201/plan9/sys/src/cmd/tar.c:935,942
} else
print("%s\n", fname);
+ if (blksleft == 0)
+ bytes = 0;
for (; blksleft > 0; blksleft -= blksread) {
hbp = getblkrd(ar, (fd >= 0? Alldata: Justnxthdr));
if (hbp == nil)
/n/sourcesdump/2006/0131/plan9/sys/src/cmd/tar.c:940,945 -
/n/sourcesdump/2006/0201/plan9/sys/src/cmd/tar.c:943,951
sysfatal("unexpected EOF on archive extracting %s",
fname);
blksread = gothowmany(blksleft);
+ if (blksread <= 0)
+ fprint(2, "%s: got %ld blocks reading %s!\n",
+ argv0, blksread, fname);
wrbytes = Tblock*blksread;
if(wrbytes > bytes)
wrbytes = bytes;
/n/sourcesdump/2006/0131/plan9/sys/src/cmd/tar.c:948,953 -
/n/sourcesdump/2006/0201/plan9/sys/src/cmd/tar.c:954,963
putreadblks(ar, blksread);
bytes -= wrbytes;
}
+ if (bytes > 0)
+ fprint(2,
+ "%s: %lld bytes uncopied at eof; %s not fully extracted\n",
+ argv0, bytes, fname);
if (fd >= 0) {
/*
* directories should be wstated after we're done
|