Windows: Ensure consistency of error code mapping
authorJeffrey Altman <jaltman@secure-endpoints.com>
Thu, 20 Aug 2009 13:21:53 +0000 (09:21 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Thu, 20 Aug 2009 13:47:48 +0000 (06:47 -0700)
For Windows, the error mapping table used throughout the system
is located in util/errmap_nt.h.   This table was incomplete and
WINNT/afsd/cm_utils.c added additional mapping locally.  Move
said error mapping to util/errmap_nt.h.

When including afs/unified_afs.h it must be done after including
afs/errmap_nt.h.   Otherwise, undefined errors are mapped to EIO
which should not be.

LICENSE MIT

Reviewed-on: http://gerrit.openafs.org/328
Tested-by: Jeffrey Altman <jaltman@openafs.org>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/cm_utils.c
src/util/errmap_nt.h

index 3011967..3296f24 100644 (file)
 #include <windows.h>
 #include <shlwapi.h>
 #include <winsock2.h>
-#ifndef EWOULDBLOCK
-#define EWOULDBLOCK             WSAEWOULDBLOCK
-#define EINPROGRESS             WSAEINPROGRESS
-#define EALREADY                WSAEALREADY
-#define ENOTSOCK                WSAENOTSOCK
-#define EDESTADDRREQ            WSAEDESTADDRREQ
-#define EMSGSIZE                WSAEMSGSIZE
-#define EPROTOTYPE              WSAEPROTOTYPE
-#define ENOPROTOOPT             WSAENOPROTOOPT
-#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
-#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
-#define EOPNOTSUPP              WSAEOPNOTSUPP
-#define EPFNOSUPPORT            WSAEPFNOSUPPORT
-#define EAFNOSUPPORT            WSAEAFNOSUPPORT
-#define EADDRINUSE              WSAEADDRINUSE
-#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
-#define ENETDOWN                WSAENETDOWN
-#define ENETUNREACH             WSAENETUNREACH
-#define ENETRESET               WSAENETRESET
-#define ECONNABORTED            WSAECONNABORTED
-#define ECONNRESET              WSAECONNRESET
-#define ENOBUFS                 WSAENOBUFS
-#define EISCONN                 WSAEISCONN
-#define ENOTCONN                WSAENOTCONN
-#define ESHUTDOWN               WSAESHUTDOWN
-#define ETOOMANYREFS            WSAETOOMANYREFS
-#define ETIMEDOUT               WSAETIMEDOUT
-#define ECONNREFUSED            WSAECONNREFUSED
-#ifdef ELOOP
-#undef ELOOP
-#endif
-#define ELOOP                   WSAELOOP
-#ifdef ENAMETOOLONG
-#undef ENAMETOOLONG
-#endif
-#define ENAMETOOLONG            WSAENAMETOOLONG
-#define EHOSTDOWN               WSAEHOSTDOWN
-#define EHOSTUNREACH            WSAEHOSTUNREACH
-#ifdef ENOTEMPTY
-#undef ENOTEMPTY
-#endif 
-#define ENOTEMPTY               WSAENOTEMPTY
-#define EPROCLIM                WSAEPROCLIM
-#define EUSERS                  WSAEUSERS
-#define EDQUOT                  WSAEDQUOT
-#define ESTALE                  WSAESTALE
-#define EREMOTE                 WSAEREMOTE
-#endif /* EWOULDBLOCK */
-#include <afs/unified_afs.h>
-
 #include <string.h>
 #include <malloc.h>
+#define STRSAFE_NO_DEPRECATE
+#include <strsafe.h>
+
 #include "afsd.h"
 #include <osi.h>
 #include <rx/rx.h>
 
-#define STRSAFE_NO_DEPRECATE
-#include <strsafe.h>
-
+#include <afs/unified_afs.h>
 
 static osi_once_t cm_utilsOnce;
 
index 8c183eb..4ffdc01 100644 (file)
@@ -23,14 +23,52 @@ extern int nterr_nt2unix(long ntErr, int defaultErr);
 #define EWOULDBLOCK        WSAEWOULDBLOCK
 #endif
 
-#define ETIMEDOUT          WSAETIMEDOUT
-#define EDQUOT            WSAEDQUOT
-#define ELOOP              WSAELOOP
-#define EOPNOTSUPP         WSAEOPNOTSUPP
-#define ENOTSOCK           WSAENOTSOCK
-#define ECONNREFUSED       WSAECONNREFUSED
-#define ESTALE            WSAESTALE
-
+#define EINPROGRESS             WSAEINPROGRESS
+#define EALREADY                WSAEALREADY
+#define ENOTSOCK                WSAENOTSOCK
+#define EDESTADDRREQ            WSAEDESTADDRREQ
+#define EMSGSIZE                WSAEMSGSIZE
+#define EPROTOTYPE              WSAEPROTOTYPE
+#define ENOPROTOOPT             WSAENOPROTOOPT
+#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+#define EOPNOTSUPP              WSAEOPNOTSUPP
+#define EPFNOSUPPORT            WSAEPFNOSUPPORT
+#define EAFNOSUPPORT            WSAEAFNOSUPPORT
+#define EADDRINUSE              WSAEADDRINUSE
+#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+#define ENETDOWN                WSAENETDOWN
+#define ENETUNREACH             WSAENETUNREACH
+#define ENETRESET               WSAENETRESET
+#define ECONNABORTED            WSAECONNABORTED
+#define ECONNRESET              WSAECONNRESET
+#define ENOBUFS                 WSAENOBUFS
+#define EISCONN                 WSAEISCONN
+#define ENOTCONN                WSAENOTCONN
+#define ESHUTDOWN               WSAESHUTDOWN
+#define ETOOMANYREFS            WSAETOOMANYREFS
+#define ETIMEDOUT               WSAETIMEDOUT
+#define ECONNREFUSED            WSAECONNREFUSED
+#ifdef ELOOP
+#undef ELOOP
+#endif
+#define ELOOP                   WSAELOOP
+#ifdef ENAMETOOLONG
+#undef ENAMETOOLONG
+#endif
+#define ENAMETOOLONG            WSAENAMETOOLONG
+#define EHOSTDOWN               WSAEHOSTDOWN
+#define EHOSTUNREACH            WSAEHOSTUNREACH
+#ifdef ENOTEMPTY
+#undef ENOTEMPTY
+#endif 
+#define ENOTEMPTY               WSAENOTEMPTY
+#define EPROCLIM                WSAEPROCLIM
+#define EUSERS                  WSAEUSERS
+#define EDQUOT                  WSAEDQUOT
+#define ESTALE                  WSAESTALE
+#define EREMOTE                 WSAEREMOTE
+#endif /* EWOULDBLOCK */
 
 /* New codes */
 #define AFS_NT_ERRNO_BASE  WSABASEERR + 1000
@@ -41,3 +79,4 @@ extern int nterr_nt2unix(long ntErr, int defaultErr);
 #define ENOTBLK                   (AFS_NT_ERRNO_BASE + 3)
 
 #endif /* OPENAFS_ERRMAP_NT_H  */
+