r25026: Move param/param.h out of includes.h
[gd/samba-autobuild/.git] / source4 / libcli / util / errormap.c
index 526e9085c9ffe6694c7836e41cf2260377287e57..347d513e9c7a313cb420d67eac00455e5a7b78c6 100644 (file)
@@ -7,7 +7,7 @@
  *  
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
+ *  the Free Software Foundation; either version 3 of the License, or
  *  (at your option) any later version.
  *  
  *  This program is distributed in the hope that it will be useful,
  *  GNU General Public License for more details.
  *  
  *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *  along with this program; if not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "includes.h"
+#include "param/param.h"
 
 /* This map was extracted by the ERRMAPEXTRACT smbtorture command. 
    The setup was a Samba HEAD (2002-01-03) PDC and an Win2k member 
@@ -617,6 +617,11 @@ static const struct {
        NTSTATUS ntstatus;
        WERROR werror;
 } ntstatus_to_werror_map[] = {
+       /*
+        * we add this manualy here, so that W_ERROR(0x5)
+        * gets mapped to NTSTATUS_ACCESS_DENIED
+        */
+       {NT_STATUS_ACCESS_DENIED, WERR_ACCESS_DENIED},
        {NT_STATUS(0x103), W_ERROR(0x3e5)},
        {NT_STATUS(0x105), W_ERROR(0xea)},
        {NT_STATUS(0x106), W_ERROR(0x514)},
@@ -1198,6 +1203,11 @@ void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode)
                *ecode = 0;
                return;
        }
+       if (NT_STATUS_IS_DOS(ntstatus)) {
+               *eclass = NT_STATUS_DOS_CLASS(ntstatus);
+               *ecode  = NT_STATUS_DOS_CODE(ntstatus);
+               return;
+       }
        for (i=0; NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus); i++) {
                if (NT_STATUS_V(ntstatus) == 
                    NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus)) {
@@ -1257,6 +1267,10 @@ struct unix_error_map {
 const struct unix_error_map unix_nt_errmap[] = {
        { EAGAIN,       STATUS_MORE_ENTRIES },
        { EINTR,        STATUS_MORE_ENTRIES },
+       { ENOBUFS,      STATUS_MORE_ENTRIES },
+#ifdef EWOULDBLOCK
+       { EWOULDBLOCK,  STATUS_MORE_ENTRIES },
+#endif
        { EINPROGRESS,  NT_STATUS_MORE_PROCESSING_REQUIRED },
        { EPERM,        NT_STATUS_ACCESS_DENIED },
        { EACCES,       NT_STATUS_ACCESS_DENIED },
@@ -1273,7 +1287,6 @@ const struct unix_error_map unix_nt_errmap[] = {
        { ENOTSOCK,     NT_STATUS_INVALID_HANDLE },
        { EFAULT,       NT_STATUS_INVALID_PARAMETER },
        { EMSGSIZE,     NT_STATUS_INVALID_BUFFER_SIZE },
-       { ENOBUFS,      NT_STATUS_NO_MEMORY },
        { ENOMEM,       NT_STATUS_NO_MEMORY },
        { EPIPE,        NT_STATUS_CONNECTION_DISCONNECTED },
        { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED },
@@ -1284,14 +1297,17 @@ const struct unix_error_map unix_nt_errmap[] = {
 #ifdef ENOTSUP
        { ENOTSUP,      NT_STATUS_NOT_SUPPORTED},
 #endif
+#ifdef EOPNOTSUPP
+       { EOPNOTSUPP,   NT_STATUS_NOT_SUPPORTED},
+#endif
 #ifdef EHOSTUNREACH
        { EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE },
 #endif
 #ifdef ENETUNREACH
-       { ENETUNREACH, NT_STATUS_NETWORK_UNREACHABLE },
+       { ENETUNREACH,  NT_STATUS_NETWORK_UNREACHABLE },
 #endif
 #ifdef ETIMEDOUT
-       { ETIMEDOUT, NT_STATUS_IO_TIMEOUT },
+       { ETIMEDOUT,    NT_STATUS_IO_TIMEOUT },
 #endif
 #ifdef EADDRINUSE
        { EADDRINUSE,   NT_STATUS_ADDRESS_ALREADY_ASSOCIATED },
@@ -1334,6 +1350,9 @@ const struct unix_error_map unix_nt_errmap[] = {
 #endif
 #ifdef ENODEV
        { ENODEV,       NT_STATUS_NO_SUCH_DEVICE },
+#endif
+#ifdef ENOSYS
+       { ENOSYS,       NT_STATUS_INVALID_SYSTEM_SERVICE },
 #endif
        { 0, NT_STATUS_UNSUCCESSFUL }
 };