1.5.1: lseek64 woes (was Re: 1.5.1: unzip problems with binary files in archive)

David Rothenberger daveroth@acm.org
Tue Jul 29 17:15:00 GMT 2003


Christopher Faylor wrote:
> 
> On Mon, Jul 28, 2003 at 11:41:43PM -0700, David Rothenberger wrote:
> Content-Description: message body text
> >Charles Wilson writes:
> > > Christopher Faylor wrote:
> > >
> > > >>>>I'm getting a strange error from unzip when trying to extract an
> > > >>>>archive that contains binary files.  Everything works fine if the
> > > >>>>archive contains just text files.
> > > >>>
> > > >>>Can't duplicate it.  Sorry.
> > > >>
> > > I --can-- duplicate it.  But I don't know why it happens; I'll have to
> > > debug it...but not until after I update to 1.5.1.  FWIW, zip does use
> > > fdopen().
> >
> >I've done some debugging and I have a STC.  I have no idea why it
> >fails, and why Chris doesn't see it, but here's the info.
> >
> >The STC is composed of the two attached files: works.c and fails.c.
> >Both files essentially do
> >
> >     int fd = open("works.c", 0);
> >     lseek(fd, 1, 0);
> >
> >but works.c does this directly in main(), while fails.c does this in
> >unzip() called from main().  As you can guess, lseek() returns -1 in
> >fails.c and 1 in works.c.
> 
> And here's why "fails.c" fails:
> 
> --- lseek-fails.c~      2003-07-29 11:43:29.428769079 -0400
> +++ lseek-fails.c       2003-07-29 11:46:01.911652780 -0400
> @@ -1,4 +1,5 @@
>  #include <stdio.h>
> +#include <unistd.h>
> 
>  void unzip()
>  {
> 
> You need to include the prototype for lseek.
> 
> cgf

This is also why unzip fails.

--- unzip-5.50/unzpriv.h        2003-07-29 09:10:41.325502400 -0700
+++ unzip-5.50-fixed/unzpriv.h  2003-07-29 09:08:48.783675200 -0700
@@ -200,6 +200,10 @@
    typedef unsigned int extent;
 #endif /* ?MODERN */
 
+#ifdef __CYGWIN__
+#  include <unistd.h>
+#endif
+
 
 #ifndef MINIX            /* Minix needs it after all the other includes
(?) */
 #  include <stdio.h>


I spent WAY too much time on this for such a simple problem.  Darn! 
Next time I'll know to look for prototypes if the strace output is
strange.

Dave

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list