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




_______________________________________________
Bug-ddrescue mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-ddrescue

Reply via email to