bug-ddrescue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-ddrescue] Re: ddrescue patch for unsigned/signed compiler warni


From: Christian Franke
Subject: Re: [Bug-ddrescue] Re: ddrescue patch for unsigned/signed compiler warnings
Date: Wed, 03 Mar 2010 11:03:46 +0100

Hi Martin,

Martin Koeppe wrote:
> On Tue, 2 Mar 2010, Christian Franke wrote:
> 
> > 
> > The Cygwin version of ddrescue does not require a Cygwin install. It
> > requires only cygwin1.dll is in same directory or in the PATH. I
> > have successfully run this ddrescue.exe also from a UBCD4Win Live CD
> > without a Cygwin install.
> > 
> 
> Thanks for the info. This could be a usable construction. Does it work
> with raw devices? Did you happen to make a performance test?
> 

Yes, cygwin1.dll provides a very good emulation of /dev/fdN, /dev/sdX,
/dev/scdN.
http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-posixdevices

Overhead is negligible in this case.

> 
> > I've done a quick build of a native Windows ddrescue.exe with MinGW
> > g++.
> > Required only few hacks (attached).
> > ...
> > Did you actually try your code with a raw disk or CD/DVD device?
> > Which MSVC version did you use?
> > 
> 
> Yes, I have approximately the same hacks for the MSVC build. The
> warnings are just warnings, obviously, and don't make the build
> impossible. And you are right, this version also doesn't work with raw
> devices. I need to replace open() etc. and I didn't yet.
> 

Probably not necessary for open(), close(), read(), write(), but for
lseek().

These MSVCRT functions are thin wrappers around CreateFile(),
CloseHandle(), ReadFile(), WriteFile(), and SetFilePointer(). The
problem is that the latter does not support SEEK_END on raw devices.

This works to read sector 100 from HDD1
(Tested with VC9 and MinGW, the latter uses standard msvcrt.dll):

    int fd = open("//./PhysicalDrive1", O_RDONLY|O_BINARY);
    long long pos = _lseeki64(fd, 100*512, SEEK_SET);
    char buf[512];
    int n = read(fd, buf, sizeof(buf));
    close(fd);

But query device size does not work, this returns -1:

    long long size = _lseeki64(fd, 0, SEEK_END);

For working code for the above see drive_size calculation in Cygwin's
raw block /dev/ice emulation layer:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/src/winsup/cygwin/fhandler_floppy.cc?cvsroot=src

Regards,
Christian







reply via email to

[Prev in Thread] Current Thread [Next in Thread]