no anon union

This commit is contained in:
rsc 2006-03-31 14:37:04 +00:00
parent 6019a96c78
commit 613093289d

View file

@ -78,31 +78,30 @@ enum {
#define isreallink(lf) ((lf) == LF_LINK) #define isreallink(lf) ((lf) == LF_LINK)
#define issymlink(lf) ((lf) == LF_SYMLINK1 || (lf) == LF_SYMLINK2) #define issymlink(lf) ((lf) == LF_SYMLINK1 || (lf) == LF_SYMLINK2)
typedef union { typedef struct Hdr {
uchar data[Tblock]; char name[Namsiz];
struct { char mode[8];
char name[Namsiz]; char uid[8];
char mode[8]; char gid[8];
char uid[8]; char size[12];
char gid[8]; char mtime[12];
char size[12]; char chksum[8];
char mtime[12]; char linkflag;
char chksum[8]; char linkname[Namsiz];
char linkflag;
char linkname[Namsiz];
/* rest are defined by POSIX's ustar format; see p1003.2b */ /* rest are defined by POSIX's ustar format; see p1003.2b */
char magic[6]; /* "ustar" */ char magic[6]; /* "ustar" */
char version[2]; char version[2];
char uname[32]; char uname[32];
char gname[32]; char gname[32];
char devmajor[8]; char devmajor[8];
char devminor[8]; char devminor[8];
char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */ char prefix[Maxpfx]; /* if non-null, path= prefix "/" name */
};
char pad[12];
} Hdr; } Hdr;
typedef struct { typedef struct Compress {
char *comp; char *comp;
char *decomp; char *decomp;
char *sfx[4]; char *sfx[4];
@ -115,7 +114,7 @@ static Compress comps[] = {
".tar.bz2",".tbz2" }, ".tar.bz2",".tbz2" },
}; };
typedef struct { typedef struct Pushstate {
int kid; int kid;
int fd; /* original fd */ int fd; /* original fd */
int rfd; /* replacement fd */ int rfd; /* replacement fd */
@ -327,7 +326,7 @@ getblkz(int ar)
Hdr *hp = getblke(ar); Hdr *hp = getblke(ar);
if (hp != nil) if (hp != nil)
memset(hp->data, 0, Tblock); memset(hp, 0, Tblock);
return hp; return hp;
} }
@ -400,7 +399,7 @@ chksum(Hdr *hp)
{ {
int n = Tblock; int n = Tblock;
long i = 0; long i = 0;
uchar *cp = hp->data; uchar *cp = (uchar*)hp;
char oldsum[sizeof hp->chksum]; char oldsum[sizeof hp->chksum];
memmove(oldsum, hp->chksum, sizeof oldsum); memmove(oldsum, hp->chksum, sizeof oldsum);
@ -736,7 +735,7 @@ addtoar(int ar, char *file, char *shortf)
hbp = getblke(ar); hbp = getblke(ar);
blksread = gothowmany(blksleft); blksread = gothowmany(blksleft);
bytes = blksread * Tblock; bytes = blksread * Tblock;
n = readn(fd, hbp->data, bytes); n = readn(fd, hbp, bytes);
if (n < 0) if (n < 0)
sysfatal("error reading %s: %r", file); sysfatal("error reading %s: %r", file);
/* /*
@ -744,7 +743,7 @@ addtoar(int ar, char *file, char *shortf)
* compression and emergency recovery of data. * compression and emergency recovery of data.
*/ */
if (n < Tblock) if (n < Tblock)
memset(hbp->data + n, 0, bytes - n); memset((uchar*)hbp + n, 0, bytes - n);
putblkmany(ar, blksread); putblkmany(ar, blksread);
} }
close(fd); close(fd);
@ -1008,7 +1007,7 @@ extract1(int ar, Hdr *hp, char *fname)
wrbytes = Tblock*blksread; wrbytes = Tblock*blksread;
if(wrbytes > bytes) if(wrbytes > bytes)
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); sysfatal("write error on %s: %r", fname);
putreadblks(ar, blksread); putreadblks(ar, blksread);
bytes -= wrbytes; bytes -= wrbytes;
@ -1097,6 +1096,8 @@ main(int argc, char *argv[])
fmtinstall('M', dirmodefmt); fmtinstall('M', dirmodefmt);
if(sizeof(Hdr) != Tblock)
sysfatal("padding in hdr should be %d", Tblock-sizeof(Hdr)+sizeof(curblk->pad));
TARGBEGIN { TARGBEGIN {
case 'c': case 'c':
docreate++; docreate++;