Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Aug 2002 15:00:31 +0200
From:      Erik Trulsson <ertr1013@student.uu.se>
To:        Bill Vermillion <bv@wjv.com>
Cc:        stable@freebsd.org, ports@freebsd.org
Subject:   Re: A but in Zoo
Message-ID:  <20020814130031.GA58489@falcon.midgard.homeip.net>
In-Reply-To: <20020814114442.GA77130@wjv.com>
References:  <bulk.34340.20020814013822@hub.freebsd.org> <20020814114442.GA77130@wjv.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Aug 14, 2002 at 07:44:42AM -0400, Bill Vermillion wrote:
> > Date: Tue, 13 Aug 2002 16:02:26 +0200
> > From: <Danny.Carroll@mail.ing.nl>
> > Subject: RE: Bug in Zoo? Or is it in ls or ffs?
> 
> > Is this not a bug in ls or ffs as well then?
> > Regardless of what Zoo does, should not the OS remain sane?
> 
> > - -----Original Message-----
> > From: Michael Burke [mailto:mburke@isn.net]
> 
> > On Tue, 2002-08-13 at 10:43, Danny Carroll wrote:
> > > As you can see the size is not taken up in disk space so I suspect the
> > > bug is in ls.  DU, DF and the left hand column of LS looks OK.
> 
> > > --output--
> 
> > Looks like you're getting a sparse file -- a large file that actually
> > takes up little space. It's created by a program seeking beyond the end
> > of the file but not writing anything (I may be off a bit, but this is
> > how I understand it). The reported size of the file is large, but it
> > doesn't take up that much space, which is why df suggests that it's not
> > significant.
> 
> > Although I've never used zoo, it's probably a bug there.
> 
> Hm.  I've been using zoo since about 1989 - the old 1.x days.
> I've always had it on a system here as I had many old files
> I'd pull apart.  I've used it dating back to Sys V.2's and I use
> it for working under MS things too.   It works for easily
> transporting files from a multitude of OSes.  
> 
> I just checked on about 6 systems I have access to, 4.6, 4.5, 4.2
> and a 4.0, and they all exhibit the same behaviour.  I don't know
> when it changed, but the sources to zoo have not changed since
> the early 1990s, and the sources when extracted all show
> a day of May 1, 1993.
> 
> So I'm suspecting that something changed in the 4.x series.
> I don't have anything prior to 4.x to check on.
> 
> I've not created any zoo archives in the past couple of years but
> it used to work, and I've used it on many platforms. 
> Since the code is the same and has not changed since Rahul Dhesi
> wrote the last version in 1991 - would it not stand to reason then
> that something has changed in FreeBSD since the 4.x came out.
> 
> Could someone who has a pre 4.x system check this?

A quick investigation indicates that this is a bug in zoo.  
It presumably was not exposed on earlier versions of FreeBSD.
To be more precise the function zootrunc() which can be found at the
end of the file bsd.c contains a line

        seekpos = lseek(fd, 0L, SEEK_CUR);

This should be changed to

        seekpos = lseek(fd, (off_t) 0L, SEEK_CUR);

The second argument to lseek should be a 64-bit value on FreeBSD, but
here it is called with a long which is a 32-bit value on the i386.
This means that the upper 32 bits of the argument that lseek sees will
contain garbage.  In this case they always seem to have the value
0x00000001  which leads to the observed behaviour of a sparse file with
size ~4GB.


The following patch to the port should fix this problem , but I would
not be surprised if there are other, similar, bugs in zoo.  Older code
often has problems with 64-bit arguments.

cvs diff: Diffing .
cvs diff: Diffing files
Index: files/patch-aa
===================================================================
RCS file: /ncvs/ports/archivers/zoo/files/patch-aa,v
retrieving revision 1.4
diff -u -r1.4 patch-aa
--- files/patch-aa	24 Apr 1997 02:12:23 -0000	1.4
+++ files/patch-aa	14 Aug 2002 12:54:52 -0000
@@ -48,7 +48,7 @@
 ! 	extern long lseek();
 ! 	long seekpos;
   	int fd = fileno(f);
-  	seekpos = lseek(fd, 0L, SEEK_CUR);
+!  	seekpos = lseek(fd, 0L, SEEK_CUR);
   	if (seekpos >= 0)
 --- 96,114 ----
   /* Standard UNIX-specific file attribute routines */
@@ -68,7 +68,7 @@
 ! 	extern off_t lseek();
 ! 	off_t seekpos;
   	int fd = fileno(f);
-  	seekpos = lseek(fd, 0L, SEEK_CUR);
+!  	seekpos = lseek(fd, (off_t)0L, SEEK_CUR);
   	if (seekpos >= 0)
 *** misc2.c.old	Thu Aug  8 09:34:48 1991
 --- misc2.c	Thu Jan  5 05:37:06 1995





-- 
<Insert your favourite quote here.>
Erik Trulsson
ertr1013@student.uu.se

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020814130031.GA58489>