s3-lib Remove unused dos error codes from errmap_unix
[abartlet/samba.git/.git] / source4 / libcli / util / errormap.c
index 8d088e1e4bfe8b7a6be2e820adf13369726a5c77..962dc24a45c85d819b673b852facbbf978811c96 100644 (file)
@@ -20,7 +20,6 @@
  */
 
 #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 
@@ -179,6 +178,7 @@ static const struct {
         during the session setup }
 */
        {ERRSRV,        ERRbadpw,       NT_STATUS_WRONG_PASSWORD},
+       {ERRSRV,        ERRbaduid,      NT_STATUS_USER_SESSION_DELETED},
        {ERRHRD,        ERRgeneral,     NT_STATUS_ILL_FORMED_PASSWORD},
        {ERRHRD,        ERRgeneral,     NT_STATUS_PASSWORD_RESTRICTION},
        {ERRDOS,        ERRnoaccess,    NT_STATUS_LOGON_FAILURE},
@@ -1156,8 +1156,10 @@ static const struct {
        {NT_STATUS(0x80000025), W_ERROR(0x962)},
        {NT_STATUS(0x80000288), W_ERROR(0x48d)},
        {NT_STATUS(0x80000289), W_ERROR(0x48e)},
-       {NT_STATUS_OK, WERR_OK}};
+       {NT_STATUS_OK, WERR_OK}
+};
 
+bool ntstatus_check_dos_mapping = true;
 
 /*
   check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code
@@ -1168,7 +1170,7 @@ bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2)
           the mapping of dos codes, as we want to catch the cases where
           a forced dos code is needed
        */
-       if (lp_nt_status_support(global_loadparm)) {
+       if (ntstatus_check_dos_mapping) {
                return NT_STATUS_V(status1) == NT_STATUS_V(status2);
        }
 
@@ -1257,14 +1259,12 @@ WERROR ntstatus_to_werror(NTSTATUS error)
        return W_ERROR(NT_STATUS_V(error) & 0xffff);
 }
 
-/* Mapping between Unix, DOS and NT error numbers */
+/* Mapping between Unix, and NT error numbers */
 
-struct unix_error_map {
+static const struct {
        int unix_error;
        NTSTATUS nt_error;
-};
-
-const struct unix_error_map unix_nt_errmap[] = {
+} unix_nt_errmap[] = {
        { EAGAIN,       STATUS_MORE_ENTRIES },
        { EINTR,        STATUS_MORE_ENTRIES },
        { ENOBUFS,      STATUS_MORE_ENTRIES },
@@ -1319,7 +1319,7 @@ const struct unix_error_map unix_nt_errmap[] = {
        { ENODATA,      NT_STATUS_NOT_FOUND },
 #endif
 #ifdef EDQUOT
-       { EDQUOT,       NT_STATUS_QUOTA_EXCEEDED },
+       { EDQUOT,       NT_STATUS_DISK_FULL }, /* Windows does NOT return NT_STATUS_QUOTA_EXCEEDED */
 #endif
 #ifdef ENOTEMPTY
        { ENOTEMPTY,    NT_STATUS_DIRECTORY_NOT_EMPTY },
@@ -1354,6 +1354,10 @@ const struct unix_error_map unix_nt_errmap[] = {
 #ifdef ENOSYS
        { ENOSYS,       NT_STATUS_INVALID_SYSTEM_SERVICE },
 #endif
+#ifdef ECANCELED
+       { ECANCELED,    NT_STATUS_CANCELLED },
+#endif
+
        { 0, NT_STATUS_UNSUCCESSFUL }
 };
 
@@ -1375,3 +1379,9 @@ NTSTATUS map_nt_error_from_unix(int unix_error)
        /* Default return */
        return NT_STATUS_UNSUCCESSFUL;
 }
+
+/* Convert a Unix error code to WERROR */
+WERROR unix_to_werror(int unix_error)
+{
+       return ntstatus_to_werror(map_nt_error_from_unix(unix_error));
+}