docs: insert meta data into password server parameter
[Samba.git] / libcli / util / errmap_unix.c
blob8f9f89835edbf7357371ffdddf0fdc9a410b1177
1 /*
2 * Unix SMB/CIFS implementation.
3 * error mapping functions
4 * Copyright (C) Andrew Tridgell 2001
5 * Copyright (C) Andrew Bartlett 2001
6 * Copyright (C) Tim Potter 2000
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 3 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
24 /* Mapping between Unix, and NT error numbers */
26 static const struct {
27 int unix_error;
28 NTSTATUS nt_error;
29 } unix_nt_errmap[] = {
30 { EAGAIN, STATUS_MORE_ENTRIES },
31 { EINTR, STATUS_MORE_ENTRIES },
32 { ENOBUFS, STATUS_MORE_ENTRIES },
33 #ifdef EWOULDBLOCK
34 { EWOULDBLOCK, STATUS_MORE_ENTRIES },
35 #endif
36 { EINPROGRESS, NT_STATUS_MORE_PROCESSING_REQUIRED },
37 { EPERM, NT_STATUS_ACCESS_DENIED },
38 { EACCES, NT_STATUS_ACCESS_DENIED },
39 { ENOENT, NT_STATUS_OBJECT_NAME_NOT_FOUND },
40 { ENOTDIR, NT_STATUS_NOT_A_DIRECTORY },
41 { EIO, NT_STATUS_IO_DEVICE_ERROR },
42 { EBADF, NT_STATUS_INVALID_HANDLE },
43 { EINVAL, NT_STATUS_INVALID_PARAMETER },
44 { EEXIST, NT_STATUS_OBJECT_NAME_COLLISION},
45 { ENFILE, NT_STATUS_TOO_MANY_OPENED_FILES },
46 { EMFILE, NT_STATUS_TOO_MANY_OPENED_FILES },
47 { ENOSPC, NT_STATUS_DISK_FULL },
48 { ENOTSOCK, NT_STATUS_INVALID_HANDLE },
49 { EFAULT, NT_STATUS_INVALID_PARAMETER },
50 { EMSGSIZE, NT_STATUS_INVALID_BUFFER_SIZE },
51 { ENOMEM, NT_STATUS_NO_MEMORY },
52 { EISDIR, NT_STATUS_FILE_IS_A_DIRECTORY},
53 #ifdef EPIPE
54 { EPIPE, NT_STATUS_CONNECTION_DISCONNECTED },
55 #endif
56 { EBUSY, NT_STATUS_SHARING_VIOLATION },
57 { ENOSYS, NT_STATUS_INVALID_SYSTEM_SERVICE },
58 #ifdef EOPNOTSUPP
59 { EOPNOTSUPP, NT_STATUS_NOT_SUPPORTED},
60 #endif
61 { EMLINK, NT_STATUS_TOO_MANY_LINKS },
62 { ENOSYS, NT_STATUS_NOT_SUPPORTED },
63 #ifdef ELOOP
64 { ELOOP, NT_STATUS_OBJECT_PATH_NOT_FOUND },
65 #endif
66 #ifdef ENODATA
67 { ENODATA, NT_STATUS_NOT_FOUND },
68 #endif
69 #ifdef EFTYPE
70 { EFTYPE, NT_STATUS_OBJECT_PATH_NOT_FOUND },
71 #endif
72 #ifdef EDQUOT
73 { EDQUOT, NT_STATUS_DISK_FULL }, /* Windows apps need this, not NT_STATUS_QUOTA_EXCEEDED */
74 #endif
75 #ifdef ENOTEMPTY
76 { ENOTEMPTY, NT_STATUS_DIRECTORY_NOT_EMPTY },
77 #endif
78 #ifdef EXDEV
79 { EXDEV, NT_STATUS_NOT_SAME_DEVICE },
80 #endif
81 #ifdef EROFS
82 { EROFS, NT_STATUS_MEDIA_WRITE_PROTECTED },
83 #endif
84 #ifdef ENAMETOOLONG
85 { ENAMETOOLONG, NT_STATUS_NAME_TOO_LONG },
86 #endif
87 #ifdef EFBIG
88 { EFBIG, NT_STATUS_DISK_FULL },
89 #endif
90 #ifdef EADDRINUSE
91 { EADDRINUSE, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
92 #endif
93 #ifdef ENETUNREACH
94 { ENETUNREACH, NT_STATUS_NETWORK_UNREACHABLE},
95 #endif
96 #ifdef EHOSTUNREACH
97 { EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE},
98 #endif
99 #ifdef ECONNREFUSED
100 { ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED},
101 #endif
102 #ifdef EADDRNOTAVAIL
103 { EADDRNOTAVAIL,NT_STATUS_ADDRESS_NOT_ASSOCIATED },
104 #endif
105 #ifdef ETIMEDOUT
106 { ETIMEDOUT, NT_STATUS_IO_TIMEOUT},
107 #endif
108 #ifdef ESOCKTNOSUPPORT
109 { ESOCKTNOSUPPORT,NT_STATUS_INVALID_PARAMETER_MIX },
110 #endif
111 #ifdef EAFNOSUPPORT
112 { EAFNOSUPPORT, NT_STATUS_INVALID_PARAMETER_MIX },
113 #endif
114 #ifdef ECONNABORTED
115 { ECONNABORTED, NT_STATUS_CONNECTION_ABORTED},
116 #endif
117 #ifdef ECONNRESET
118 { ECONNRESET, NT_STATUS_CONNECTION_RESET},
119 #endif
120 #ifdef ENOPROTOOPT
121 { ENOPROTOOPT, NT_STATUS_INVALID_PARAMETER_MIX },
122 #endif
123 #ifdef ENODEV
124 { ENODEV, NT_STATUS_NO_SUCH_DEVICE },
125 #endif
126 #ifdef ENOATTR
127 { ENOATTR, NT_STATUS_NOT_FOUND },
128 #endif
129 #ifdef ECANCELED
130 { ECANCELED, NT_STATUS_CANCELLED},
131 #endif
132 #ifdef ENOTSUP
133 { ENOTSUP, NT_STATUS_NOT_SUPPORTED},
134 #endif
136 { 0, NT_STATUS_UNSUCCESSFUL }
140 /*********************************************************************
141 Map an NT error code from a Unix error code.
142 *********************************************************************/
143 NTSTATUS map_nt_error_from_unix_common(int unix_error)
145 int i;
147 /* Look through list */
148 for (i=0;i<ARRAY_SIZE(unix_nt_errmap);i++) {
149 if (unix_nt_errmap[i].unix_error == unix_error) {
150 return unix_nt_errmap[i].nt_error;
154 /* Default return */
155 return NT_STATUS_UNSUCCESSFUL;