[PATCH] Cygwin: Map ERROR_NO_SUCH_DEVICE and ERROR_MEDIA_CHANGED to ENODEV
Christian Franke
Christian.Franke@t-online.de
Sun Feb 25 09:12:37 GMT 2024
Corinna Vinschen wrote:
> On Feb 23 19:14, Christian Franke wrote:
>> Experiments with damaged USB flash drives and ddrescue revealed that the
>> current mapping of these Win32 errors to the fallback EACCES could be
>> improved.
>>
>> BTW: I wonder why EACCES was selected as the fallback. Source code control
>> forensics suggest that this was decided in the last millennium. A related
>> comment from CGF added August 2000 persists until today :-)
>> /* FIXME: what's so special about EACCESS? */
> This goes back until 1997 in pre-CVS times. There's a ChangeLog entry
>
> Wed Oct 29 22:43:57 1997 Geoffrey Noer <noer@cygnus.com>
>
> [...]
> * syscalls.cc (seterrno): on failure, set EACCES instead of EPERM
> which is better for the unknown error case
>
> So the default was EPERM at first and has been changed to EACCES
> because it "is better for the unknown error case".
>
> I'm open to ideas for an improved error mapping.
I have no better suggestion for a default errno. Adding a cygwin
specific one (like ENMFILE, ENOSHARE and ECASECLASH added 2000-2001) is
possibly not desired.
Some thoughts about minor improvements of the errmap.h file:
- Add error number to each /* ERROR_... */ comment, e.g. /* 2:
ERROR_FILE_NOT_FOUND */.
- Update /* NUMBER */ comments using current MinGW-w64's winerror.h
(~850 changes).
- Max errno is 143, so data type size could be reduced from int to
uint8_t aka unsigned char. Could even add a compile time check by using
C++11's braced initializers which do not allow narrowing conversions.
- Remove trailing entries which only map to 0.
- Append a static_assert which checks whether array size matches the
last mapped error number.
I could provide separate patches if desired.
Thanks,
Christian
More information about the Cygwin-patches
mailing list