[comp.sources.d] pax on 16 bit machine, tar filesize field

root@libove.UUCP (Jay M. Libove) (02/27/89)

In "pax" on my 16 bit Xenix (80286) machine, it seems that the filesize
field (in tar listings anyway, haven't tried cpio or pax format) is
a 16 bit signed integer, because:

% ls -l /tmp/test[123]
-rw-------   1 root     root       33456 Feb 26 12:05 /tmp/test1
-rw-r--r--   1 root     root        3057 Feb 25 22:54 /tmp/test2
-rw-r--r--   1 root     root       69969 Feb 26 12:05 /tmp/test3
% ls -il /usr/local/bin/{tar,pax}
 5318 -rwxr-xr-x   3 bin      bin       183004 Feb 16 21:57 /usr/local/bin/pax
 5318 -rwxr-xr-x   3 bin      bin       183004 Feb 16 21:57 /usr/local/bin/tar
% which tar
/usr/local/bin/tar
% tar cvf /tmp/test.tar /tmp/test[123]
a /tmp/test1 66 Blocks
a /tmp/test2 6 Blocks
a /tmp/test3 137 Blocks
% tar tvf /tmp/test.tar
Tar: blocksize = 20
rw------- 0/0 -32080 Feb 26 12:05 1989 /tmp/test1
rw-r--r-- 0/0   3057 Feb 25 22:54 1989 /tmp/test2
rw-r--r-- 0/0   4433 Feb 26 12:05 1989 /tmp/test3

Obviously, there's a problem here. I looked at the list function
(tar_entry in list.c) and that's not the trouble - it printf's a
long integer directly from a stat structure, so I guess the problem
is in the archiving section of the utility.

Does someone have a fix for this? I've applied the posted patches
1, 2, and 3, to the posted source. I posess, but have not applied,
the "tar append bug in MSDOS" unofficial patch from Harold Waters
at OK State, since this isn't running on DOS.

Thanks for any suggestions...
------------- 
Jay Libove		jl42@andrew.cmu.edu, libove@cs.cmu.edu,
5731 Centre Ave, Apt 3	gateway.sei.cmu.edu!libove!libove, jl42@andrew.BITnet,
Pittsburgh, PA 15206	jl42@drycas.BITnet, psuvax1!pitt!darth!libove!libove,
(412) 362-8983		or uunet!nfsun!libove!libove

wietse@wzv.UUCP (Wietse Z. Venema) (03/02/89)

In article <228@libove.UUCP> root@libove.UUCP (Jay M. Libove) writes:
>
>In "pax" on my 16 bit Xenix (80286) machine, it seems that the filesize
>field (in tar listings anyway, haven't tried cpio or pax format) is
>a 16 bit signed integer, 

Recently, I posted a patch in comp.sources.bugs for 16-bit systems
(change a %6d into %6ld).  With this patch, the problem you described
does not occur on my 80286 Microport SV/AT 2.3 system:

$ ls -li /usr/local/bin/pax /usr/local/bin/tar
 1374 -rwxr-xr-x   3 root     sys        51990 Feb 25 14:58 /usr/local/bin/pax
 1374 -rwxr-xr-x   3 root     sys        51990 Feb 25 14:58 /usr/local/bin/tar
$ ls -l /tmp/test[123]
-rwxr-xr-x   1 wietse   users      51990 Mar  1 21:03 /tmp/test1
-rwxr-xr-x   1 wietse   users      46254 Mar  1 21:03 /tmp/test2
-rwxr-xr-x   1 wietse   users      15374 Mar  1 21:04 /tmp/test3
$ /usr/local/bin/tar cvf /tmp/test.tar /tmp/test[132]
a /tmp/test1 102 Blocks
a /tmp/test2 91 Blocks
a /tmp/test3 31 Blocks
$ /usr/local/bin/tar tvf /tmp/test.tar
Tar: blocksize = 20
rwxr-xr-x 100/13  51990 Mar  1 21:03 1989 /tmp/test1
rwxr-xr-x 100/13  46254 Mar  1 21:03 1989 /tmp/test2
rwxr-xr-x 100/13  15374 Mar  1 21:04 1989 /tmp/test3
-- 
work:	wswietse@eutrc3.uucp	| Eindhoven University of Technology
work:	wswietse@heitue5.bitnet	| Mathematics and Computing Science
home:	wietse@wzv.uucp		| 5600 MB Eindhoven, The Netherlands

jim@tiamat.fsc.com (Jim O'Connor) (03/02/89)

In article <228@libove.UUCP>, root@libove.UUCP (Jay M. Libove) writes:
> 
> In "pax" on my 16 bit Xenix (80286) machine, it seems that the filesize
> field (in tar listings anyway, haven't tried cpio or pax format) is
> a 16 bit signed integer, because:
> 

pax seems to use "int" in contexts where very large numbers are expected
on a consistent basis.  The routines in buffer.c that set up and manage the
buffers use int or unsigned int for most of their arguments, but I'm probably
not wrong in assuming the author did not intend to restrict buffering on
large machines to <= 64K-1, so "int" was probably assumed to be > 16 bits.

Short of changing several int definitions to long's, I'm not sure what else
could be done.

--jim
------------- 
James B. O'Connor			jim@tiamat.fsc.com
Filtration Sciences Corporation		615/821-4022 x. 651

*** Altos users unite! mail to "info-altos-request@tiamat.fsc.com" ***

pcng@cad.jmrc.eecs.unsw.oz (Po Cheung Ng ) (03/03/89)

From article <228@libove.UUCP>, by root@libove.UUCP (Jay M. Libove):
> 
> In "pax" on my 16 bit Xenix (80286) machine, it seems that the filesize
> field (in tar listings anyway, haven't tried cpio or pax format) is
> a 16 bit signed integer, because:
> 
	Check the source, I couldn't remember exactly, but I did patch one
public domain program to fix something like this. Locate where it prints
the file size (probably occurs in more that one place), the format string
should be %lu not %ld. I just checked my version of tar (linked to pax) and
worked fine with file size up to ~70K.

       _   _. __   _,
---   /_)_(__/) )_(_)_		[ Also known as Andrew ]
     /              /|
    '              |/

----------------
Po Cheung NG                               ISD:  +61 2 697-4056
JMRC, School of Elec. Eng. and Comp. Sci., STD:  (02) 697-4056
The University of New South Wales,         FAX:  +61 2 662-2087
PO Box 1, Kensington,         ARPA: pcng%cad.jmrc.eecs.unsw.oz.au@uunet.uu.net
Sydney, NSW 2033,             JANET: cad.jmrc.eecs.unsw.oz!pcng@ukc
AUSTRALIA.                    ACSnet: pcng@cad.jmrc.eecs.unsw.oz

UUCP:  {enea,hplabs,mcvax,prlb2,uunet,ubc-vision,ukc}!munnari!cad.jmrc.eecs.unsw.oz!pcng

pcng@cad.jmrc.eecs.unsw.oz (Po Cheung Ng ) (03/03/89)

From article <397@limpet.cad.jmrc.eecs.unsw.oz>, by pcng@cad.jmrc.eecs.unsw.oz (Po Cheung Ng ):
> From article <228@libove.UUCP>, by root@libove.UUCP (Jay M. Libove):
>> 
>> In "pax" on my 16 bit Xenix (80286) machine, it seems that the filesize
>> field (in tar listings anyway, haven't tried cpio or pax format) is
>> a 16 bit signed integer, because:
>> 
> 	Check the source, I couldn't remember exactly, but I did patch one
> public domain program to fix something like this. Locate where it prints
> the file size (probably occurs in more that one place), the format string
> should be %lu not %ld. I just checked my version of tar (linked to pax) and
> worked fine with file size up to ~70K.

Sorry, with Wietse Venema's article, now I remember the format string should be
%6ld (or I prefer %6lu), not %6d. It is because printf will treat the number
in the argument list as an int rather than long and mis-interpret the rest of
the arguments.

       _   _. __   _,
---   /_)_(__/) )_(_)_		[ Also known as Andrew ]
     /              /|
    '              |/

----------------
Po Cheung NG                               ISD:  +61 2 697-4056
JMRC, School of Elec. Eng. and Comp. Sci., STD:  (02) 697-4056
The University of New South Wales,         FAX:  +61 2 662-2087
PO Box 1, Kensington,         ARPA: pcng%cad.jmrc.eecs.unsw.oz.au@uunet.uu.net
Sydney, NSW 2033,             JANET: cad.jmrc.eecs.unsw.oz!pcng@ukc
AUSTRALIA.                    ACSnet: pcng@cad.jmrc.eecs.unsw.oz

UUCP:  {enea,hplabs,mcvax,prlb2,uunet,ubc-vision,ukc}!munnari!cad.jmrc.eecs.unsw.oz!pcng