diff options
author | rsc <devnull@localhost> | 2005-07-22 18:46:26 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-07-22 18:46:26 +0000 |
commit | 14f06f6792b50ad91f86c08b3a72e9d57ed98330 (patch) | |
tree | 828f2ba36d2b14543aacfa29b2b1ea389a5aeb5a /src/cmd/tar.c | |
parent | 8824e122a3e9a4ec6ecd5d241bc7d74581300a29 (diff) | |
download | plan9port-14f06f6792b50ad91f86c08b3a72e9d57ed98330.tar.gz plan9port-14f06f6792b50ad91f86c08b3a72e9d57ed98330.tar.bz2 plan9port-14f06f6792b50ad91f86c08b3a72e9d57ed98330.zip |
more tar changes
Diffstat (limited to 'src/cmd/tar.c')
-rw-r--r-- | src/cmd/tar.c | 55 |
1 files changed, 27 insertions, 28 deletions
diff --git a/src/cmd/tar.c b/src/cmd/tar.c index d030b0b4..c468fcb6 100644 --- a/src/cmd/tar.c +++ b/src/cmd/tar.c @@ -16,7 +16,9 @@ * keyletters and options. */ #define TARGBEGIN {\ - (argv0 || (argv0 = *argv)), argv++, argc--;\ + if (argv0 == nil)\ + argv0 = *argv;\ + argv++, argc--;\ if (argv[0]) {\ char *_args, *_argt;\ Rune _argc;\ @@ -69,28 +71,25 @@ 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 { + 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 */ } Hdr; typedef struct { @@ -318,7 +317,7 @@ getblkz(int ar) Hdr *hp = getblke(ar); if (hp != nil) - memset(hp->data, 0, Tblock); + memset(hp, 0, Tblock); return hp; } @@ -391,7 +390,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); @@ -664,7 +663,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); /* @@ -672,7 +671,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); @@ -883,7 +882,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; |