Wrong file position after writing 65537 bytes to block device

Corinna Vinschen corinna-cygwin@cygwin.com
Tue Dec 19 18:36:00 GMT 2017


On Dec 19 16:35, Ivan Kozik wrote:
> On Tue, Dec 19, 2017 at 4:13 PM, Eric Blake <eblake@redhat.com> 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 boundary, and have extra magic in ftell() to track that we
> > are at an unaligned position within the block device?  But that sounds like
> > a lot of nasty overhead; and that it would be better to make sure that block
> > devices can report unaligned lseek() locations (caveat: I haven't tested
> > what Linux does in that regards).
> 
> >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 (e.g. writes going at 64MB/s instead
> of an "expected" 180MB/s).

That's what Cygwin was trying to emulate as well.  Debugging pointed out
that it only works for reading, not for writing, because the latter
neglected to fix up buffer pointers.  Those are used in lseek to report
the Linux-like byte-exact file position.

I pushed a patch and uploaded new developer snapshots to
https://cygwin.com/snapshts/

Please give them a test.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Maintainer                 cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20171219/432c961f/attachment.sig>


More information about the Cygwin mailing list