Wrong file position after writing 65537 bytes to block device
Ivan Kozik
ivan@ludios.org
Sat Dec 16 06:13:00 GMT 2017
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
More information about the Cygwin
mailing list