delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/12/07/12:55:51

X-Spam-Check-By: sourceware.org
MIME-Version: 1.0
Subject: RE: Error reported dd'ing close of end of block device with skip
Date: Wed, 7 Dec 2005 11:55:38 -0600
Message-ID: <E05F1FD208D5AA45B78B3983479ECF0856C0F7@saturn.p3corpnet.pivot3.com>
From: "Loh, Joe" <joel AT pivot3 DOT com>
To: <cygwin AT cygwin DOT com>
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
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
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id jB7Hto0E032003

> Searching the archive 
>
>  http://cygwin.com/cgi-bin/htsearch?config=htdig&words=dd+eom
>
> reveals a thread "Bug in dd ?? at EOM" which starts here:
>
>  http://sourceware.org/ml/cygwin/2005-09/msg00878.html
>
> Btw, have you tried the latest snapshot from
http://cygwin.com/snapshots/ ?
>
>
> Corinna

We tried with the cygwin-inst-20051207.tar.bz2 snapshot.  Using the same
"dd" commands we no longer observed the problem.  

QUESTION:  

Is there a way in Cygwin to do a read of a block device using "C" that
does not do a read-ahead?  We needed to develop an application that will
issue the exact transfer size to the target device as requested.
Looking at the strace, it appears that read() less than 61440-bytes gets
translated to reading 61440 bytes into buffer and then a subset of that
read is returned to the caller.

Here're the outputs:

dd if=/dev/sda count=1 bs=1024 skip=`expr 78125000 - 60` > /dev/null
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0 seconds, Infinity B/s

dd if=/dev/sda count=1 bs=1024 skip=`expr 78125000 - 59` > /dev/null
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0 seconds, Infinity B/s

Looking at the strace for the command that used to failed, we noticed
that the read ahead transfer size is adjusted to not overshoot the end
of device:

 3260   25940 [main] dd 3660 lseek64: 79999939584 = lseek (0,
79999939584, 1)
   61   26001 [main] dd 3660 readv: readv (0, 0x22ED80, 1) blocking,
sigcatchers 4
   45   26046 [main] dd 3660 readv: no need to call ready_for_read
   49   26095 [main] dd 3660 fhandler_dev_floppy::raw_read: read 60416
bytes into buffer
  567   26662 [main] dd 3660 fhandler_dev_floppy::read_file: 1 (err 0) =
ReadFile (1640, 268507896, to_read 60416, read 60416, 0)
   47   26709 [main] dd 3660 fhandler_dev_floppy::raw_read: read 1024
bytes from buffer (rest 59392)



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