This is the mail archive of the
cygwin
mailing list for the Cygwin project.
Wrong file position after writing 65537 bytes to block device
- From: Ivan Kozik <ivan at ludios dot org>
- To: cygwin at cygwin dot com
- Date: Sat, 16 Dec 2017 02:07:45 +0000
- Subject: Wrong file position after writing 65537 bytes to block device
- Authentication-results: sourceware.org; auth=none
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