Mathias Michaelis writes:
 > > dd if='\\.\A:' of=/tmp/adrive bs=1k
 > > works and reads 1440 kilobytes.

 > But not for me with gnuwin32 dd (fileutils) 4.1.1 within a cmd shell
 > of WinXP SP2 professional. 

Ah, but I used Cygwin's dd... Maybe the gnuwin32 dd has some extra
pathname-mangling magic that in this case means that the filename
actually passed to CreateFile() gets mangled, while Cygwin's dd passes
it untouched. Or something else. For instance, as the documentation
for CreateFile() says, "It is recommended on all file systems that you
open volume handles as noncached and follow the noncached I/O
restrictions." That means that the buffers must be
sector-aligned. Maybe gnuwin32's dd's buffers aren't. Also the share
mode must be FILE_SHARE_WRITE, which you do get with a plain open() in
MSVCRT, but dunno what C library gnuwin32's dd uses.

For instance the following throwaway program succeeds in reading both
floppy and hard disk volumes. Yeah, the alignment logic is
unnecessarily wasteful of space.

#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>

#define BUFFERSIZE (512*512)

int
main (int argc, char **argv)
{
  int f;
  char buf[2*BUFFERSIZE];
  char *aligned_bufp = (char *) ((((int) buf) + BUFFERSIZE-1) & 
(~(BUFFERSIZE-1)));
  int k;
  __int64 n;

  printf ("Reading %s\n", argv[1]); 

  if ((f = open (argv[1], O_RDONLY|O_BINARY)) == -1)
    perror ("open"), exit (1);

  n = 0;
  while ((k = read (f, aligned_bufp, BUFFERSIZE)) > 0)
    n += k;

  close (f);

  printf ("Got %I64d bytes\n", n);

  return 0;
}




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
GnuWin32-Users mailing list
GnuWin32-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnuwin32-users

Reply via email to