Mail Archives: djgpp-workers/2003/05/13/12:35:31
lseek(1, 0, SEEK_CUR) always returns 0 on NT/W2K on the initial call, even
when the handle is opened for append to a non zero-length file. This is
only seen for pre-opened handles; if you run from Bash it works.
if I write to the file first, then lseek(1, 0, SEEK_CUR), then the
offset returned is the size of the data I wrote, and still incorrect.
if I call lseek(1, 0, SEEK_END) *FIRST*, then the value returned is
correct on other calls.
Does anyone see harm in adding something like the following to crt1.c as
a workaround/fix?
if (_os_trueversion == 0x532 && !_USE_LFN) {
lseek(1, 0, SEEK_END);
lseek(2, 0, SEEK_END);
}
We maybe should do this even if LFN is available; this code avoids the fstat()
issue but wouldn't fix seeks on WIN2K or XP while forcing the lseek
even with LFN on would..
It's also possible we should do an lseek(0, 0, SEEK_SET) and remove the
code forcing seeks in filelen.c, which was put there to work around the
similar problem on stdin() noticed by Andrew in August 2001.
- Raw text -