This is the mail archive of the
mailing list for the Cygwin project.
Re: Wrong file position after writing 65537 bytes to block device
- From: Steven Penny <svnpenn at gmail dot com>
- To: cygwin at cygwin dot com
- Date: Mon, 18 Dec 2017 16:27:25 -0800 (PST)
- Subject: Re: Wrong file position after writing 65537 bytes to block device
- Authentication-results: sourceware.org; auth=none
- References: <20171218131035.GB11285@calimero.vinschen.de>
On Mon, 18 Dec 2017 14:10:35, Corinna Vinschen wrote:
In general, the writes on disk devices is sector-oriented. Howewver,
in this case ftell should have returned 65536. The problem here is
that the newlib implmentation of ftell/ftello performs an fflush
when called on a write stream since about 2008 to adjust for appending
streams. Given your example (thanks for the testcase!) this seems
pretty wrong. Looking further it turns out that neither glibc nor BSD
actually calls fflush in this case. There's only a special case for
appending streams, but this calls lseek, not fflush.
Looks like a patch is required. Stay tuned.
is it though? he says "write 65536 + 1 bytes", but as far as i can tell, you
cant do that. quoting myself:
Seeking, reading and writing must all be done in multiples of sector size, in
my case 512 bytes
so it would make sense that the position becomes "65536 + 512"
Problem reports: http://cygwin.com/problems.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple