delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2005/12/07/13:36:05

X-Spam-Check-By: sourceware.org
Date: Wed, 7 Dec 2005 19:35:55 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Error reported dd'ing close of end of block device with skip
Message-ID: <20051207183555.GD2999@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <E05F1FD208D5AA45B78B3983479ECF0856C0F7 AT saturn DOT p3corpnet DOT pivot3 DOT com>
Mime-Version: 1.0
In-Reply-To: <E05F1FD208D5AA45B78B3983479ECF0856C0F7@saturn.p3corpnet.pivot3.com>
User-Agent: Mutt/1.4.2i
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT 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 Dec  7 11:55, Loh, Joe wrote:
> 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.

There's a non-portable (only Cygwin) way to set the buffer size after
opening a device:

  #include <cygwin/rdevio.h>

  struct rdop rd;

  fd = open ("dev/sda", ...);

  rd.rd_op = RDSETBLK;
  rd.rd_parm = 0;	/* Unbuffered reading */
  rd.rd_parm = 1;	/* Unbuffered reading */
  rd.rd_parm = n;	/* Buffered reading with buffer size n */

  ioctl (fd, RDIOCDOP, &rd);

Note that the ioctl fails if the buffer already contains data, so ioctl
should be called before the first read.  Also note that in unbuffered
mode the usual Windows blocking rule applies, the length given to read
must be a multiple of 512.

Sigh, it seems that I introduced a bug into this ioctl also not long ago.
I fixed this in CVS.  Recent code will probably not work very well when
setting it to unbuffered mode.  Please wait for the next developers
snapshot.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat, Inc.

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