Hi,

on Wed, 10 Jan 2024 15:47:46 +0200, Zibri wrote:
Hello!
I am writing you to inform you that I compiled ddrescue-1.25, 1.26 and
1.27 under cygwin.

For some reason, 1.25 works but 1.26 and 1.27 give "Permission denied" error:
ddrescue: /dev/sdg1: Fatal error reading the input file: Permission denied
this does not happen in version 1.25.
What can I change to make it work?

"Thanks" to an USB flash drive with bad blocks, I found a Windows+Cygwin specific behavior which could further explain the above issue.

I added a workaround (attached) and uploaded a new Cygwin package ddrescue-1.28-2:
https://cygwin.com/packages/summary/ddrescue.html

See the package announcement for more details about the interesting behavior of Windows on read errors:
https://sourceware.org/pipermail/cygwin-announce/2024-February/011568.html


This leads to the following suggestion for a ddrescue enhancement to handle platform/controller/driver specific values of errno after read errors:

- If ddrescue is aborted due to a read error, also print the errno value (EACCES and EPERM may result in the same message text).

- Print the "Error of last failed read" with error text and errno value in a high verbosity level and possibly also as a comment in the map file.

- Add options --abort-on-errno=N and --continue-on-errno=N (or --no-abort-on-errno=N) to allow the user to override the hard coded decision whether ddrescue aborts after a read error or not.

--
Regards,
Christian

From c21050f20256c4b4160b903260d2d8762e0a6cc0 Mon Sep 17 00:00:00 2001
From: Christian Franke <christian.fra...@t-online.de>
Date: Tue, 13 Feb 2024 16:50:01 +0100
Subject: [PATCH] Cygwin: Don't abort read on EACCES

Cygwin uses EACCES as a fallback for unknown errors.
---
 rescuebook.cc | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/rescuebook.cc b/rescuebook.cc
index 2d114f4..7186c77 100644
--- a/rescuebook.cc
+++ b/rescuebook.cc
@@ -135,7 +135,13 @@ int Rescuebook::copy_block( const Block & b, int & 
copied_size, int & error_size
     error_size = errno ? b.size() - copied_size : 0;
     if( copied_size <= 0 ) switch( errno )
       {
-      case EACCES: case EBADF: case EBUSY: case EISDIR: case ENOBUFS:
+       // Cygwin maps unknown Windows errors to EACCESS.  This includes
+       // ERROR_MEDIA_CHANGED(1110) which may be returned on read errors
+       // from USB devices.
+#ifndef __CYGWIN__
+      case EACCES:
+#endif
+      case EBADF: case EBUSY: case EISDIR: case ENOBUFS:
       case ENODEV: case ENOENT: case ENOMEM: case ENOSYS: case ENXIO:
       case EPERM: case ESPIPE:
         final_msg( iname_, "Fatal error reading the input file", errno );
-- 
2.43.0

Reply via email to