[BusyBox] seek_sub_file in unarchive.c broken?
Stefan Soucek
ssoucek at coactive.com
Fri Sep 21 16:47:06 UTC 2001
Thanks for the tip!
I am using uClibc (CVS as of 9/18) together with Linux 2.4.6 (i386).
It seems that uClibc implements lseek as a direct syscall. The C
library shouldn't have an effect here.
I am not sure, however, if one can use lseek with a pipe at all.
The man page says the following:
RETURN VALUE
Upon successful completion, lseek returns the resulting
offset location as measured in bytes from the beginning of
the file. Otherwise, a value of (off_t)-1 is returned and
errno is set to indicate the error.
ERRORS
EBADF Fildes is not an open file descriptor.
ESPIPE Fildes is associated with a pipe, socket, or FIFO.
EINVAL Whence is not a proper value.
The error occurs when you lseek beyond what's actually in the stream
buffer of the pipe. Then it throws the ESPIPE error. Judging from the
man page, this error tells that one should not use lseek with
pipes. Maybe the man page is not detailled enough on this. Any ideas?
-Stefan
> On Fri, Sep 21, 2001 at 11:12:39AM -0700, Stefan Soucek wrote:
> > It tries to optimize the pipe read by skipping 'count'
> characters using
> > lseek on the pipe. I am not sure what happens exactly, but
> it looks like
> > lseek positions the stream somewhere further on even when it gets
> > ESPIPE. Then the for loop consumes another 'count'
> characters from the
> > pipe, which screws up the intended positioning.
>
> I think this is a bug in your fseek(3) implementation. What C
> library are you using?
>
> Matt
>
More information about the busybox
mailing list