fseeko: fix bug on glibc
authorEric Blake <eblake@redhat.com>
Tue, 9 Aug 2011 21:18:31 +0000 (15:18 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 9 Aug 2011 21:49:05 +0000 (15:49 -0600)
commita769adbf87bdfe54b94da0a285fa9b8db45d5aa5
treed8d3b9a22171e32c0f7c4d85f53c0a17a5a3c477
parent30b5bd2f22154ae7b9f81b91632830d82a4f1fb3
fseeko: fix bug on glibc

Commit 1074f45959f had a bug on glibc that caused the unit test to
fail, but instead of figuring why the failure was happening, we
instead added a partial hack to avoid the problem in the scenario
covered by the testsuite.
https://lists.gnu.org/archive/html/bug-gnulib/2009-01/msg00171.html

But that hack doesn't cover all scenarios, and papers over the
real issue: if you fopen()/ftell()/fseek(,0,SEEK_END)/ftell(),
then the stream should be positioned at the same place as the
underlying fd, even though no I/O occurred, and without requiring
an fflush() in the middle.

* lib/fseeko.c (fseeko): Set stream offset to match fd offset.
Reported by John W. Eaton.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
lib/fseeko.c