Cygwin 1.7: O_DIRECT read from raw devices returns EOF
Christian Franke
Christian.Franke@t-online.de
Fri Nov 21 15:53:00 GMT 2008
On cygwin 1.7.0-32, read() from raw devices returns 0 always if device
was opened with O_DIRECT.
Testcase:
$ dd if=/dev/sdb of=/dev/null count=1
1+0 records in
1+0 records out
512 bytes (512 B) copied, 0.027 s, 19.0 kB/s
$ dd if=/dev/sdb of=/dev/null count=1 iflag=direct
0+0 records in
0+0 records out
0 bytes (0 B) copied, 0 s, Infinity B/s
Same for /dev/scd0, /dev/fd0.
Bug was probably introduced in fhandler_dev_floppy.cc 1.51:
void
fhandler_dev_floppy::raw_read (void *ptr, size_t& ulen)
{
...
DWORD bytes_to_read = 0;
...
if (devbuf)
{ /* !O_DIRECT ... */ }
else
{
_off64_t current_position = get_current_position ();
if (current_position + bytes_to_read >= drive_size)
bytes_to_read = drive_size - current_position;
if (bytes_to_read && !read_file (p, len, &bytes_read, &ret))
...
In the O_DIRECT case, bytes_to_read is always 0.
Christian
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Problem reports: http://cygwin.com/problems.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
More information about the Cygwin
mailing list