aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/tar.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2006-03-31 14:37:04 +0000
committerrsc <devnull@localhost>2006-03-31 14:37:04 +0000
commit613093289d311dd241b92c15892be270493cb32f (patch)
treef782111bbb8639a4b556b96a4843cb6a5e15e047 /src/cmd/tar.c
parent6019a96c7867a30b6968c9ebe9276b1025e157df (diff)
downloadplan9port-613093289d311dd241b92c15892be270493cb32f.tar.gz
plan9port-613093289d311dd241b92c15892be270493cb32f.tar.bz2
plan9port-613093289d311dd241b92c15892be270493cb32f.zip
no anon union
Diffstat (limited to 'src/cmd/tar.c')
-rw-r--r--src/cmd/tar.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/cmd/tar.c b/src/cmd/tar.c
index 576db677..1306ed41 100644
--- a/src/cmd/tar.c
+++ b/src/cmd/tar.c
@@ -78,31 +78,30 @@ enum {
#define isreallink(lf) ((lf) == LF_LINK)
#define issymlink(lf) ((lf) == LF_SYMLINK1 || (lf) == LF_SYMLINK2)
-typedef union {
- uchar data[Tblock];
- struct {
- char name[Namsiz];
- char mode[8];
- char uid[8];
- char gid[8];
- char size[12];
- char mtime[12];
- char chksum[8];
- char linkflag;
- char linkname[Namsiz];
-
- /* rest are defined by POSIX's ustar format; see p1003.2b */
- char magic[6]; /* "ustar" */
- char version[2];
- char uname[32];
- char gname[32];
- char devmajor[8];
- char devminor[8];
- char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
- };
+typedef struct Hdr {
+ char name[Namsiz];
+ char mode[8];
+ char uid[8];
+ char gid[8];
+ char size[12];
+ char mtime[12];
+ char chksum[8];
+ char linkflag;
+ char linkname[Namsiz];
+
+ /* rest are defined by POSIX's ustar format; see p1003.2b */
+ char magic[6]; /* "ustar" */
+ char version[2];
+ char uname[32];
+ char gname[32];
+ char devmajor[8];
+ char devminor[8];
+ char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
+
+ char pad[12];
} Hdr;
-typedef struct {
+typedef struct Compress {
char *comp;
char *decomp;
char *sfx[4];
@@ -115,7 +114,7 @@ static Compress comps[] = {
".tar.bz2",".tbz2" },
};
-typedef struct {
+typedef struct Pushstate {
int kid;
int fd; /* original fd */
int rfd; /* replacement fd */
@@ -327,7 +326,7 @@ getblkz(int ar)
Hdr *hp = getblke(ar);
if (hp != nil)
- memset(hp->data, 0, Tblock);
+ memset(hp, 0, Tblock);
return hp;
}
@@ -400,7 +399,7 @@ chksum(Hdr *hp)
{
int n = Tblock;
long i = 0;
- uchar *cp = hp->data;
+ uchar *cp = (uchar*)hp;
char oldsum[sizeof hp->chksum];
memmove(oldsum, hp->chksum, sizeof oldsum);
@@ -736,7 +735,7 @@ addtoar(int ar, char *file, char *shortf)
hbp = getblke(ar);
blksread = gothowmany(blksleft);
bytes = blksread * Tblock;
- n = readn(fd, hbp->data, bytes);
+ n = readn(fd, hbp, bytes);
if (n < 0)
sysfatal("error reading %s: %r", file);
/*
@@ -744,7 +743,7 @@ addtoar(int ar, char *file, char *shortf)
* compression and emergency recovery of data.
*/
if (n < Tblock)
- memset(hbp->data + n, 0, bytes - n);
+ memset((uchar*)hbp + n, 0, bytes - n);
putblkmany(ar, blksread);
}
close(fd);
@@ -1008,7 +1007,7 @@ extract1(int ar, Hdr *hp, char *fname)
wrbytes = Tblock*blksread;
if(wrbytes > bytes)
wrbytes = bytes;
- if (fd >= 0 && write(fd, hbp->data, wrbytes) != wrbytes)
+ if (fd >= 0 && write(fd, hbp, wrbytes) != wrbytes)
sysfatal("write error on %s: %r", fname);
putreadblks(ar, blksread);
bytes -= wrbytes;
@@ -1097,6 +1096,8 @@ main(int argc, char *argv[])
fmtinstall('M', dirmodefmt);
+ if(sizeof(Hdr) != Tblock)
+ sysfatal("padding in hdr should be %d", Tblock-sizeof(Hdr)+sizeof(curblk->pad));
TARGBEGIN {
case 'c':
docreate++;