bug-ddrescue
[Top][All Lists]
Advanced

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

[Bug-ddrescue] Patch to support -d on Darwin and Mac OS X


From: Rob Terrell
Subject: [Bug-ddrescue] Patch to support -d on Darwin and Mac OS X
Date: Mon, 27 Aug 2007 20:52:18 -0400

I made a modification to main.cc so to support ddrescue's direct mode ("-d") when running on Mac OS X or Darwin systems. It seems to work-- in my test case, without -d a volume copy (with around 300 errors) took more than twice as long.

I don't know enough about configure to make this compile in automatically; just use this to configure with O_DIRECT for Darwin/OSX:

        ./configure CPPFLAGS="-DO_DIRECT -DDARWIN"

Patch against 1.6 pre 2:

@@ -265,8 +265,19 @@
   if( check_identical ( iname, oname ) )
     { show_error( "infile and outfile are identical" ); return 1; }
+#ifdef DARWIN
+  // darwin doesn't support o_direct as an option to open() but
+ // you can turn the cache off for a file descriptor with fnctl and F_NOCACHE
+  const int ides = open( iname, O_RDONLY );
+ if( ides < 0 ) { show_error( "cannot open input file", errno ); return 1; }
+  if( o_direct ) {
+       const int fcntlerr = fcntl( ides, F_NOCACHE, 1 );
+ if( fcntlerr < 0 ) { show_error("cannot disable file caching", errno); return 1;}
+  }
+#else
   const int ides = open( iname, O_RDONLY | o_direct );
if( ides < 0 ) { show_error( "cannot open input file", errno ); return 1; }
+#endif
   const long long isize = lseek( ides, 0, SEEK_END );
if( isize < 0 ) { show_error( "input file is not seekable" ); return 1; }






reply via email to

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