r25068: Older samba3 DCs will return DCERPC_FAULT_OP_RNG_ERROR for every opcode on the
[Samba.git] / source / lib / errmap_unix.c
blob8ec0e5facac7096a1a0616691e82edc1a134a542
1 /*
2 * Unix SMB/CIFS implementation.
3 * map unix to NT errors, an excerpt of libsmb/errormap.c
4 * Copyright (C) Andrew Tridgell 2001
5 * Copyright (C) Andrew Bartlett 2001
6 * Copyright (C) Tim Potter 2000
7 * Copyright (C) Jeremy Allison 2007
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
24 #include "includes.h"
26 /* Mapping from Unix, to NT error numbers */
28 const struct unix_error_map unix_dos_nt_errmap[] = {
29 { EPERM, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
30 { EACCES, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED },
31 { ENOENT, ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND },
32 { ENOTDIR, ERRDOS, ERRbadpath, NT_STATUS_NOT_A_DIRECTORY },
33 { EIO, ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR },
34 { EBADF, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
35 { EINVAL, ERRSRV, ERRsrverror, NT_STATUS_INVALID_HANDLE },
36 { EEXIST, ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION},
37 { ENFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES },
38 { EMFILE, ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES },
39 { ENOSPC, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
40 { ENOMEM, ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY },
41 { EISDIR, ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY},
42 { EMLINK, ERRDOS, ERRgeneral, NT_STATUS_TOO_MANY_LINKS },
43 { EINTR, ERRHRD, ERRgeneral, NT_STATUS_RETRY },
44 #ifdef EDQUOT
45 { EDQUOT, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL }, /* Windows apps need this, not NT_STATUS_QUOTA_EXCEEDED */
46 #endif
47 #ifdef ENOTEMPTY
48 { ENOTEMPTY, ERRDOS, ERRnoaccess, NT_STATUS_DIRECTORY_NOT_EMPTY },
49 #endif
50 #ifdef EXDEV
51 { EXDEV, ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE },
52 #endif
53 #ifdef EROFS
54 { EROFS, ERRHRD, ERRnowrite, NT_STATUS_ACCESS_DENIED },
55 #endif
56 #ifdef ENAMETOOLONG
57 { ENAMETOOLONG, ERRDOS, 206, NT_STATUS_OBJECT_NAME_INVALID },
58 #endif
59 #ifdef EFBIG
60 { EFBIG, ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL },
61 #endif
62 #ifdef ENOBUFS
63 { ENOBUFS, ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES },
64 #endif
65 { EAGAIN, ERRDOS, 111, NT_STATUS_NETWORK_BUSY },
66 #ifdef EADDRINUSE
67 { EADDRINUSE, ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
68 #endif
69 #ifdef ENETUNREACH
70 { ENETUNREACH, ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE},
71 #endif
72 #ifdef EHOSTUNREACH
73 { EHOSTUNREACH, ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE},
74 #endif
75 #ifdef ECONNREFUSED
76 { ECONNREFUSED, ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED},
77 #endif
78 #ifdef ETIMEDOUT
79 { ETIMEDOUT, ERRHRD, 121, NT_STATUS_IO_TIMEOUT},
80 #endif
81 #ifdef ECONNABORTED
82 { ECONNABORTED, ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED},
83 #endif
84 #ifdef ENODEV
85 { ENODEV, ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
86 #endif
87 #ifdef EPIPE
88 { EPIPE, ERRDOS, 109, NT_STATUS_PIPE_BROKEN},
89 #endif
90 #ifdef EWOULDBLOCK
91 { EWOULDBLOCK, ERRDOS, 111, NT_STATUS_NETWORK_BUSY },
92 #endif
94 { 0, 0, 0, NT_STATUS_OK }
97 /*********************************************************************
98 Map an NT error code from a Unix error code.
99 *********************************************************************/
101 NTSTATUS map_nt_error_from_unix(int unix_error)
103 int i = 0;
105 if (unix_error == 0)
106 return NT_STATUS_OK;
108 /* Look through list */
109 while(unix_dos_nt_errmap[i].unix_error != 0) {
110 if (unix_dos_nt_errmap[i].unix_error == unix_error)
111 return unix_dos_nt_errmap[i].nt_error;
112 i++;
115 /* Default return */
116 return NT_STATUS_ACCESS_DENIED;