auth/ntlmssp: Remove reference to struct ntlmssp_state
[Samba/gebeck_regimport.git] / source3 / libsmb / errormap.c
blob22daee4c5c573c0ee34468f01634b98537e39ddc
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 /* dos -> nt status error map */
25 static const struct {
26 uint8 dos_class;
27 uint32 dos_code;
28 NTSTATUS ntstatus;
29 } dos_to_ntstatus_map[] = {
30 {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED},
31 {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE},
32 {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND},
33 {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES},
34 {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED},
35 {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE},
36 {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES},
37 {ERRDOS, ERRbadaccess, NT_STATUS_ACCESS_DENIED},
38 {ERRDOS, ERRbaddata, NT_STATUS_DATA_ERROR},
39 {ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED},
40 {ERRDOS, ERRremcd, NT_STATUS_DIRECTORY_NOT_EMPTY},
41 {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE},
42 {ERRDOS, ERRnofiles, STATUS_NO_MORE_FILES},
43 {ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED},
44 {ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE},
45 {ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE},
46 {ERRDOS, 23, NT_STATUS_DATA_ERROR},
47 {ERRDOS, 24, NT_STATUS_DATA_ERROR},
48 {ERRDOS, 26, NT_STATUS_DISK_CORRUPT_ERROR},
49 {ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
50 {ERRDOS, 28, NT_STATUS(0x8000000e)},
51 {ERRDOS, 31, NT_STATUS_UNSUCCESSFUL},
52 {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION},
53 {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT},
54 {ERRDOS, 34, NT_STATUS_WRONG_VOLUME},
55 {ERRDOS, 38, NT_STATUS_END_OF_FILE},
56 {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
57 {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING},
58 {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME},
59 {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH},
60 {ERRDOS, 54, NT_STATUS_NETWORK_BUSY},
61 {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
62 {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS},
63 {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR},
64 {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE},
65 {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
66 {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER},
67 {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL},
68 {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE},
69 {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED},
70 {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED},
71 {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED},
72 {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE},
73 {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME},
74 {ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
75 {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS},
76 {ERRDOS, 70, NT_STATUS_SHARING_PAUSED},
77 {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED},
78 {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED},
79 {ERRDOS, ERRfilexists, NT_STATUS_OBJECT_NAME_COLLISION},
80 {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD},
81 {ERRDOS, 87, NT_STATUS_INVALID_INFO_CLASS},
82 {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT},
83 {ERRDOS, 109, NT_STATUS_PIPE_BROKEN},
84 {ERRDOS, 111, STATUS_MORE_ENTRIES},
85 {ERRDOS, 112, NT_STATUS_DISK_FULL},
86 {ERRDOS, 121, NT_STATUS_IO_TIMEOUT},
87 {ERRDOS, 122, NT_STATUS_BUFFER_TOO_SMALL},
88 {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID},
89 {ERRDOS, ERRunknownlevel, NT_STATUS_INVALID_LEVEL},
90 {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND},
91 {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND},
92 {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY},
93 {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL},
94 {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
95 {ERRDOS, 158, NT_STATUS_NOT_LOCKED},
96 {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID},
97 {ERRDOS, 170, NT_STATUS(0x80000011)},
98 {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND},
99 {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION},
100 {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC},
101 {ERRDOS, 203, NT_STATUS(0xc0000100)},
102 {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG},
103 {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_INFO_CLASS},
104 {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE},
105 {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING},
106 {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED},
107 {ERRDOS, ERRmoredata, NT_STATUS_MORE_PROCESSING_REQUIRED},
108 {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
109 {ERRDOS, 254, NT_STATUS(0x80000013)},
110 {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE},
111 {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED},
112 {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY},
113 {ERRDOS, 275, NT_STATUS_EA_TOO_LARGE},
114 {ERRDOS, 276, NT_STATUS_NONEXISTENT_EA_ENTRY},
115 {ERRDOS, 277, NT_STATUS_NONEXISTENT_EA_ENTRY},
116 {ERRDOS, 278, NT_STATUS_NONEXISTENT_EA_ENTRY},
117 {ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED},
118 {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED},
119 {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
120 {ERRDOS, 299, NT_STATUS(0x8000000d)},
121 {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED},
122 {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL},
123 {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES},
124 {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW},
125 {ERRDOS, 535, NT_STATUS_PIPE_CONNECTED},
126 {ERRDOS, 536, NT_STATUS_PIPE_LISTENING},
127 {ERRDOS, 995, NT_STATUS_CANCELLED},
128 {ERRDOS, 997, NT_STATUS(0x00000103)},
129 {ERRDOS, 998, NT_STATUS_ACCESS_VIOLATION},
130 {ERRDOS, 999, NT_STATUS_IN_PAGE_ERROR},
131 {ERRDOS, 1001, NT_STATUS_BAD_INITIAL_STACK},
132 {ERRDOS, 1005, NT_STATUS_UNRECOGNIZED_VOLUME},
133 {ERRDOS, 1006, NT_STATUS_FILE_INVALID},
134 {ERRDOS, 1007, NT_STATUS_FULLSCREEN_MODE},
135 {ERRDOS, 1008, NT_STATUS_NO_TOKEN},
136 {ERRDOS, 1009, NT_STATUS_REGISTRY_CORRUPT},
137 {ERRDOS, 1016, NT_STATUS_REGISTRY_IO_FAILED},
138 {ERRDOS, 1017, NT_STATUS_NOT_REGISTRY_FILE},
139 {ERRDOS, 1018, NT_STATUS_KEY_DELETED},
140 {ERRDOS, 1019, NT_STATUS_NO_LOG_SPACE},
141 {ERRDOS, 1020, NT_STATUS_KEY_HAS_CHILDREN},
142 {ERRDOS, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE},
143 {ERRDOS, 1022, NT_STATUS(0x0000010c)},
144 {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD},
145 {ERRSRV, ERRbaduid, NT_STATUS_USER_SESSION_DELETED},
146 {ERRSRV, ERRbadtype, NT_STATUS_BAD_DEVICE_TYPE},
147 {ERRSRV, ERRaccess, NT_STATUS_NETWORK_ACCESS_DENIED},
148 {ERRSRV, ERRinvnid, NT_STATUS_NETWORK_NAME_DELETED},
149 {ERRSRV, ERRinvnetname, NT_STATUS_BAD_NETWORK_NAME},
150 {ERRSRV, ERRinvdevice, NT_STATUS_BAD_DEVICE_TYPE},
151 {ERRSRV, ERRqfull, NT_STATUS_PRINT_QUEUE_FULL},
152 {ERRSRV, ERRqtoobig, NT_STATUS_NO_SPOOL_SPACE},
153 {ERRSRV, ERRinvpfid, NT_STATUS_PRINT_CANCELLED},
154 {ERRSRV, ERRsmbcmd, NT_STATUS_NOT_IMPLEMENTED},
155 {ERRSRV, ERRbadpermits, NT_STATUS_NETWORK_ACCESS_DENIED},
156 {ERRSRV, ERRpaused, NT_STATUS_SHARING_PAUSED},
157 {ERRSRV, ERRmsgoff, NT_STATUS_REQUEST_NOT_ACCEPTED},
158 {ERRSRV, ERRnoroom, NT_STATUS_DISK_FULL},
159 {ERRSRV, ERRnoresource, NT_STATUS_REQUEST_NOT_ACCEPTED},
160 {ERRSRV, ERRtoomanyuids, NT_STATUS_TOO_MANY_SESSIONS},
161 {ERRSRV, ERRunknownsmb, NT_STATUS_NOT_IMPLEMENTED},
162 {ERRSRV, 123, NT_STATUS_OBJECT_NAME_INVALID},
163 {ERRSRV, 206, NT_STATUS_OBJECT_NAME_INVALID},
164 {ERRHRD, 1, NT_STATUS_NOT_IMPLEMENTED},
165 {ERRHRD, 2, NT_STATUS_NO_SUCH_DEVICE},
166 {ERRHRD, 3, NT_STATUS_OBJECT_PATH_NOT_FOUND},
167 {ERRHRD, 4, NT_STATUS_TOO_MANY_OPENED_FILES},
168 {ERRHRD, 5, NT_STATUS_INVALID_LOCK_SEQUENCE},
169 {ERRHRD, 6, NT_STATUS_INVALID_HANDLE},
170 {ERRHRD, 8, NT_STATUS_INSUFFICIENT_RESOURCES},
171 {ERRHRD, 12, NT_STATUS_INVALID_LOCK_SEQUENCE},
172 {ERRHRD, 13, NT_STATUS_DATA_ERROR},
173 {ERRHRD, 14, NT_STATUS_SECTION_NOT_EXTENDED},
174 {ERRHRD, 16, NT_STATUS_DIRECTORY_NOT_EMPTY},
175 {ERRHRD, 17, NT_STATUS_NOT_SAME_DEVICE},
176 {ERRHRD, 18, NT_STATUS(0x80000006)},
177 {ERRHRD, ERRnowrite, NT_STATUS_MEDIA_WRITE_PROTECTED},
178 {ERRHRD, ERRnotready, NT_STATUS_NO_MEDIA_IN_DEVICE},
179 {ERRHRD, ERRbadcmd, NT_STATUS_INVALID_DEVICE_STATE},
180 {ERRHRD, ERRdata, NT_STATUS_DATA_ERROR},
181 {ERRHRD, ERRbadreq, NT_STATUS_DATA_ERROR},
182 {ERRHRD, ERRbadmedia, NT_STATUS_DISK_CORRUPT_ERROR},
183 {ERRHRD, ERRbadsector, NT_STATUS_NONEXISTENT_SECTOR},
184 {ERRHRD, ERRnopaper, NT_STATUS(0x8000000e)},
185 {ERRHRD, ERRgeneral, NT_STATUS_UNSUCCESSFUL},
186 {ERRHRD, ERRbadshare, NT_STATUS_SHARING_VIOLATION},
187 {ERRHRD, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT},
188 {ERRHRD, ERRwrongdisk, NT_STATUS_WRONG_VOLUME},
189 {ERRHRD, 38, NT_STATUS_END_OF_FILE},
190 {ERRHRD, ERRdiskfull, NT_STATUS_DISK_FULL},
191 {ERRHRD, 50, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
192 {ERRHRD, 51, NT_STATUS_REMOTE_NOT_LISTENING},
193 {ERRHRD, 52, NT_STATUS_DUPLICATE_NAME},
194 {ERRHRD, 53, NT_STATUS_BAD_NETWORK_PATH},
195 {ERRHRD, 54, NT_STATUS_NETWORK_BUSY},
196 {ERRHRD, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST},
197 {ERRHRD, 56, NT_STATUS_TOO_MANY_COMMANDS},
198 {ERRHRD, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR},
199 {ERRHRD, 58, NT_STATUS_INVALID_NETWORK_RESPONSE},
200 {ERRHRD, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
201 {ERRHRD, 60, NT_STATUS_BAD_REMOTE_ADAPTER},
202 {ERRHRD, 61, NT_STATUS_PRINT_QUEUE_FULL},
203 {ERRHRD, 62, NT_STATUS_NO_SPOOL_SPACE},
204 {ERRHRD, 63, NT_STATUS_PRINT_CANCELLED},
205 {ERRHRD, 64, NT_STATUS_NETWORK_NAME_DELETED},
206 {ERRHRD, 65, NT_STATUS_NETWORK_ACCESS_DENIED},
207 {ERRHRD, 66, NT_STATUS_BAD_DEVICE_TYPE},
208 {ERRHRD, 67, NT_STATUS_BAD_NETWORK_NAME},
209 {ERRHRD, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
210 {ERRHRD, 69, NT_STATUS_TOO_MANY_SESSIONS},
211 {ERRHRD, 70, NT_STATUS_SHARING_PAUSED},
212 {ERRHRD, 71, NT_STATUS_REQUEST_NOT_ACCEPTED},
213 {ERRHRD, 72, NT_STATUS_REDIRECTOR_PAUSED},
214 {ERRHRD, 80, NT_STATUS_OBJECT_NAME_COLLISION},
215 {ERRHRD, 86, NT_STATUS_WRONG_PASSWORD},
216 {ERRHRD, 87, NT_STATUS_INVALID_INFO_CLASS},
217 {ERRHRD, 88, NT_STATUS_NET_WRITE_FAULT},
218 {ERRHRD, 109, NT_STATUS_PIPE_BROKEN},
219 {ERRHRD, 111, STATUS_MORE_ENTRIES},
220 {ERRHRD, 112, NT_STATUS_DISK_FULL},
221 {ERRHRD, 121, NT_STATUS_IO_TIMEOUT},
222 {ERRHRD, 122, NT_STATUS_BUFFER_TOO_SMALL},
223 {ERRHRD, 123, NT_STATUS_OBJECT_NAME_INVALID},
224 {ERRHRD, 124, NT_STATUS_INVALID_LEVEL},
225 {ERRHRD, 126, NT_STATUS_DLL_NOT_FOUND},
226 {ERRHRD, 127, NT_STATUS_PROCEDURE_NOT_FOUND},
227 {ERRHRD, 145, NT_STATUS_DIRECTORY_NOT_EMPTY},
228 {ERRHRD, 154, NT_STATUS_INVALID_VOLUME_LABEL},
229 {ERRHRD, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
230 {ERRHRD, 158, NT_STATUS_NOT_LOCKED},
231 {ERRHRD, 161, NT_STATUS_OBJECT_PATH_INVALID},
232 {ERRHRD, 170, NT_STATUS(0x80000011)},
233 {ERRHRD, 182, NT_STATUS_ORDINAL_NOT_FOUND},
234 {ERRHRD, 183, NT_STATUS_OBJECT_NAME_COLLISION},
235 {ERRHRD, 193, NT_STATUS_BAD_INITIAL_PC},
236 {ERRHRD, 203, NT_STATUS(0xc0000100)},
237 {ERRHRD, 206, NT_STATUS_NAME_TOO_LONG},
238 {ERRHRD, 230, NT_STATUS_INVALID_INFO_CLASS},
239 {ERRHRD, 231, NT_STATUS_INSTANCE_NOT_AVAILABLE},
240 {ERRHRD, 232, NT_STATUS_PIPE_CLOSING},
241 {ERRHRD, 233, NT_STATUS_PIPE_DISCONNECTED},
242 {ERRHRD, 234, STATUS_MORE_ENTRIES},
243 {ERRHRD, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
244 {ERRHRD, 254, NT_STATUS(0x80000013)},
245 {ERRHRD, 255, NT_STATUS_EA_TOO_LARGE},
246 {ERRHRD, 259, NT_STATUS_GUIDS_EXHAUSTED},
247 {ERRHRD, 267, NT_STATUS_NOT_A_DIRECTORY},
248 {ERRHRD, 275, NT_STATUS_EA_TOO_LARGE},
249 {ERRHRD, 276, NT_STATUS_NONEXISTENT_EA_ENTRY},
250 {ERRHRD, 277, NT_STATUS_NONEXISTENT_EA_ENTRY},
251 {ERRHRD, 278, NT_STATUS_NONEXISTENT_EA_ENTRY},
252 {ERRHRD, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED},
253 {ERRHRD, 288, NT_STATUS_MUTANT_NOT_OWNED},
254 {ERRHRD, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
255 {ERRHRD, 299, NT_STATUS(0x8000000d)},
256 {ERRHRD, 300, NT_STATUS_OPLOCK_NOT_GRANTED},
257 {ERRHRD, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL},
258 {ERRHRD, 487, NT_STATUS_CONFLICTING_ADDRESSES},
259 {ERRHRD, 534, NT_STATUS_INTEGER_OVERFLOW},
260 {ERRHRD, 535, NT_STATUS_PIPE_CONNECTED},
261 {ERRHRD, 536, NT_STATUS_PIPE_LISTENING},
262 {ERRHRD, 995, NT_STATUS_CANCELLED},
263 {ERRHRD, 997, NT_STATUS(0x00000103)},
264 {ERRHRD, 998, NT_STATUS_ACCESS_VIOLATION},
265 {ERRHRD, 999, NT_STATUS_IN_PAGE_ERROR},
266 {ERRHRD, 1001, NT_STATUS_BAD_INITIAL_STACK},
267 {ERRHRD, 1005, NT_STATUS_UNRECOGNIZED_VOLUME},
268 {ERRHRD, 1006, NT_STATUS_FILE_INVALID},
269 {ERRHRD, 1007, NT_STATUS_FULLSCREEN_MODE},
270 {ERRHRD, 1008, NT_STATUS_NO_TOKEN},
271 {ERRHRD, 1009, NT_STATUS_REGISTRY_CORRUPT},
272 {ERRHRD, 1016, NT_STATUS_REGISTRY_IO_FAILED},
273 {ERRHRD, 1017, NT_STATUS_NOT_REGISTRY_FILE},
274 {ERRHRD, 1018, NT_STATUS_KEY_DELETED},
275 {ERRHRD, 1019, NT_STATUS_NO_LOG_SPACE},
276 {ERRHRD, 1020, NT_STATUS_KEY_HAS_CHILDREN},
277 {ERRHRD, 1021, NT_STATUS_CHILD_MUST_BE_VOLATILE},
278 {ERRHRD, 1022, NT_STATUS(0x0000010c)},
281 /*****************************************************************************
282 convert a dos eclas/ecode to a NT status32 code
283 *****************************************************************************/
284 NTSTATUS dos_to_ntstatus(uint8 eclass, uint32 ecode)
286 int i;
287 if (eclass == 0) return NT_STATUS_OK;
288 for (i=0; NT_STATUS_V(dos_to_ntstatus_map[i].ntstatus); i++) {
289 if (eclass == dos_to_ntstatus_map[i].dos_class &&
290 ecode == dos_to_ntstatus_map[i].dos_code) {
291 return dos_to_ntstatus_map[i].ntstatus;
294 return NT_STATUS_UNSUCCESSFUL;