dd in cygwin vs dd in linux - number of records is always different

Corinna Vinschen corinna-cygwin@cygwin.com
Mon Feb 9 17:19:00 GMT 2009


On Feb  8 16:30, Morph Ex wrote:
> I'm trying to use "dd" to create a md5 checksum of a dvd.  The problem
> is that the number of records read by "dd" is always different
> depending on the OS used.  For example, using the same command below
> in both cygwin and linux displays the following results.
> 
> dd if=/dev/scd0 bs=2048 iflag=direct | md5sum -b
> 
> Linux (ubuntu 8.10 amd64)
> 28446caccede349759e4e9fed8bce862 
> 3025539+0 records in 
> 3025539+0 records out 
> 6196303872 bytes (6.2 GB) copied, 3347.83 s, 1.9 MB/s 
>  
> Cygwin (windows xp pro)
> 15cab8963c4746eca21c014224adefa3 
> 3025538+0 records in 
> 3025538+0 records out 
> 6196301824 bytes (6.2 GB) copied, 3323.91 s, 1.9 MB/s

Just to let you know that I can reproduce a similar result.  In my test
case it's just not 1 block but 200 blocks.  For some reason the Win32
function ReadFile returns EOF prematurely, in my case on XP as well as
on Server 2008, and I have not the faintest idea why.  I created a
non-Cygwin testcase (attached) which uses only native NT functions to
open/seek/read/close the device and it suffers the exact same problem.
Ii doesn't have anything to do with Cygwin, apparently.

If you want to experiment with the native NT testcase, you can build
it with

  $ gcc -g -o ntreadraw ntreadraw.c -lntdll

(with or without -mno-cygwin) and then you can run it like this:

  $ ./ntreadraw \\Device\\CdRom0 2048 3025530

The output for my testcase looks like this:

  $ ./ntreadraw \\Device\\CdRom0 2048 98990
  partition info: offset 0  length 203044864 (99143 blocks)
  Setting offset to: 202731520
  Current offset: 202731520 (block 98990)
  NtReadFile: pos: 202731520 (block 98990), status 0x00000000, bytes read: 2048
  NtReadFile: pos: 202733568 (block 98991), status 0x00000000, bytes read: 2048
  NtReadFile: pos: 202735616 (block 98992), status 0x00000000, bytes read: 2048
  NtReadFile: pos: 202737664 (block 98993), status 0xc0000011, bytes read: 8
  Final offset: 202737664 (block 98993)

So in my case, the DVD has 99143 blocks and Windows stops to read
after block 98993 all the time with status 0xC0000011, which simply
is the native NT status code for EOF (STATUS_END_OF_FILE).

I guess I'll ask on one of the Microsoft newsgroups if this is a known
effect and especially what I'm doing wrong or what I have to do to
get the desired behaviour.

Btw., if anybody has an idea what's going wrong, please speak up :}


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ntreadraw.c
Type: text/x-c++src
Size: 4124 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20090209/65c5740e/attachment.bin>
-------------- next part --------------
--
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