[uClibc]fseek(3) idempotency

Manuel Novoa III mjn3 at uclibc.org
Tue Sep 25 14:35:37 UTC 2001


Matt and Erik,

On Mon, Sep 24, 2001 at 09:23:32PM -0600, Erik Andersen wrote:
> On Tue Sep 25, 2001 at 02:05:55AM -0700, Matt Kraai wrote:
> > Since is_seekable only calls lseek(), it shouldn't matter what C
> > library you are using (unless fileno does something quite weird).
> > 
> > That said, I think we should fix fseek() to behave sanely.
> > The code in question works fine with glibc, and it makes a lot
> > more sense than forcing people to rely on lseek() to determine
> > whether seeking is supported (since its behavior is also
> > implementation defined).
> 
> Ok -- I'm ok with you committing your patch.  I'll grant that
> apps should do a stat or something before randomly trying to seek
> on pipes.  But we shouldn't be hosing up the readahead buffer
> just because the programmer is being dumb.

A couple of notes:

1) I agree that there is no need in this case to invalidate the
   readahead buffer.  Regarding Matt's patch though, the
   "if (READING(fp))" test is unnecessary.  The assignment works
   for both reading or writing (although redundant here).

2) Even with this change, seek_sub_file() is still broken as fseek()
   will set the error flag for the FILE if it corresponds to a pipe
   or fifo, and subsequent reads should fail.  A clearerr() call
   needs to be done too.

Manuel






More information about the uClibc mailing list