public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* Wrong file position after writing 65537 bytes to block device
@ 2017-12-16  6:13 Ivan Kozik
  2017-12-18 16:32 ` Corinna Vinschen
  0 siblings, 1 reply; 10+ messages in thread
From: Ivan Kozik @ 2017-12-16  6:13 UTC (permalink / raw)
  To: cygwin

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 running 64-bit cygwin 2.9.0 on an updated Windows 8.1.  I saw the
same results with an 8TB drive and a 512MB USB stick.

Best regards,

Ivan


cygwin_write.c:

#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);
    printf("%ld", ftell(f));
    return 0;
}

--
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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-12-20 23:33 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-16  6:13 Wrong file position after writing 65537 bytes to block device 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
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

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).