delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/11/21/07:59:22

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Date: Fri, 21 Nov 2008 13:58:30 +0100
Reply-To: "Christian Franke" <Christian DOT Franke AT t-online DOT de>
To: cygwin AT cygwin DOT com
X-UMS: email
X-Mailer: TOI Kommunikationscenter V9-2-23
Subject: Cygwin 1.7: O_DIRECT read from raw devices returns EOF
From: "Christian Franke" <Christian DOT Franke AT t-online DOT de>
Message-ID: <1L3Vag-0fDPUm0@fwd05.aul.t-online.de>
X-ID: X7UzDYZ6YhXnxfr4SKpRUmfiRRJ6w3GoY3IBXeIE1aAjKvBLpHYyOrt5+B6uyXXgEv AT t-dialin DOT net
X-TOI-MSGID: 988c757d-e147-48d3-9ffe-37b1f6fae879
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019