From: Eric Blake <eblake@redhat.com>
To: cygwin@cygwin.com
Subject: Re: Wrong file position after writing 65537 bytes to block device
Date: Tue, 19 Dec 2017 17:43:00 -0000 [thread overview]
Message-ID: <9f29d418-10af-1dc7-2636-89cae1eb16f4@redhat.com> (raw)
In-Reply-To: <CAKyntiLyTBGcAx3iwhq7dX0wqiE3S685kwmhMg+U2A3huXVzUQ@mail.gmail.com>
On 12/19/2017 09:46 AM, Ivan Kozik wrote:
> Thanks, I can confirm that the 2017-12-18 snapshot fixed the test
> program I posted.
>
> What about the harder case where the program calls fflush, though?
>
> #include <stdio.h>
>
> int main(int argc, char *argv[]) {
> FILE *f = fopen(argv[1], "w");
> char x[65536 + 1];
> fwrite(x, 1, 65536 + 1, f);
> fflush(f);
> printf("%ld", ftell(f));
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).
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
next prev parent reply other threads:[~2017-12-19 16:13 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-16 6:13 Ivan Kozik
2017-12-18 16:32 ` Corinna Vinschen
2017-12-19 5:03 ` Steven Penny
2017-12-19 10:20 ` Corinna Vinschen
2017-12-19 16:36 ` Ivan Kozik
2017-12-19 17:43 ` Eric Blake [this message]
2017-12-19 18:18 ` Ivan Kozik
2017-12-19 18:36 ` Corinna Vinschen
2017-12-20 5:47 ` Ivan Kozik
2017-12-20 23:59 ` Kaz Kylheku
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9f29d418-10af-1dc7-2636-89cae1eb16f4@redhat.com \
--to=eblake@redhat.com \
--cc=cygwin@cygwin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).