Re: Wrong file position after writing 65537 bytes to block device

2017-12-19 Thread Ivan Kozik
On Tue, Dec 19, 2017 at 6:19 PM, Corinna Vinschen wrote: > On Dec 19 16:35, Ivan Kozik wrote: >> From what I observe on Linux, it supports writing at any offset to the >> block device because it does a read-modify-write behind the scenes, >> with accompanying nasty overhead

Re: Wrong file position after writing 65537 bytes to block device

2017-12-19 Thread Ivan Kozik
On Tue, Dec 19, 2017 at 4:13 PM, Eric Blake wrote: > Can block devices report an unaligned offset to lseek()? If not, then when > writing an unaligned value to a block device, don't we have to do a > read-modify-write of the larger aligned cluster, and then put lseek() back > to the unaligned bou

Re: Wrong file position after writing 65537 bytes to block device

2017-12-19 Thread Ivan Kozik
On Tue, Dec 19, 2017 at 9:14 AM, Corinna Vinschen wrote: > Neither glibc nor FreeBSD show this behaviour. Keep in mind that stdio > is designed for buffered I/O. What should happen, basically, is that a > multiple of the stdio buffersize is written and the remainder is kept in > the stdio buffer

Wrong file position after writing 65537 bytes to block device

2017-12-15 Thread Ivan Kozik
Hello, I have discovered that if you write 65536 + 1 bytes to a block device in cygwin, the file position can become 65536 + 512. With /dev/sdc as a throwaway USB block device: (cygwin_write.c is pasted below) # gcc -O2 -Wall -o cygwin_write cygwin_write.c # ./cygwin_write /dev/sdc 66048 I am r