[NETFILTER]: nf_conntrack: add helper function for expectation initialization
[hh.org.git] / fs / cifs / netmisc.c
blob992e80edc720bb782cc13d5dcb1843691a240adf
1 /*
2 * fs/cifs/netmisc.c
4 * Copyright (c) International Business Machines Corp., 2002
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 * Error mapping routines from Samba libsmb/errormap.c
8 * Copyright (C) Andrew Tridgell 2001
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
19 * the GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include <linux/net.h>
27 #include <linux/string.h>
28 #include <linux/in.h>
29 #include <linux/ctype.h>
30 #include <linux/fs.h>
31 #include <asm/div64.h>
32 #include <asm/byteorder.h>
33 #include "cifsfs.h"
34 #include "cifspdu.h"
35 #include "cifsglob.h"
36 #include "cifsproto.h"
37 #include "smberr.h"
38 #include "cifs_debug.h"
39 #include "nterr.h"
41 struct smb_to_posix_error {
42 __u16 smb_err;
43 int posix_code;
46 static const struct smb_to_posix_error mapping_table_ERRDOS[] = {
47 {ERRbadfunc, -EINVAL},
48 {ERRbadfile, -ENOENT},
49 {ERRbadpath, -ENOTDIR},
50 {ERRnofids, -EMFILE},
51 {ERRnoaccess, -EACCES},
52 {ERRbadfid, -EBADF},
53 {ERRbadmcb, -EIO},
54 {ERRnomem, -ENOMEM},
55 {ERRbadmem, -EFAULT},
56 {ERRbadenv, -EFAULT},
57 {ERRbadformat, -EINVAL},
58 {ERRbadaccess, -EACCES},
59 {ERRbaddata, -EIO},
60 {ERRbaddrive, -ENXIO},
61 {ERRremcd, -EACCES},
62 {ERRdiffdevice, -EXDEV},
63 {ERRnofiles, -ENOENT},
64 {ERRbadshare, -ETXTBSY},
65 {ERRlock, -EACCES},
66 {ERRunsup, -EINVAL},
67 {ERRnosuchshare,-ENXIO},
68 {ERRfilexists, -EEXIST},
69 {ERRinvparm, -EINVAL},
70 {ERRdiskfull, -ENOSPC},
71 {ERRinvname, -ENOENT},
72 {ERRinvlevel,-EOPNOTSUPP},
73 {ERRdirnotempty, -ENOTEMPTY},
74 {ERRnotlocked, -ENOLCK},
75 {ERRcancelviolation, -ENOLCK},
76 {ERRalreadyexists, -EEXIST},
77 {ERRmoredata, -EOVERFLOW},
78 {ERReasnotsupported,-EOPNOTSUPP},
79 {ErrQuota, -EDQUOT},
80 {ErrNotALink, -ENOLINK},
81 {ERRnetlogonNotStarted,-ENOPROTOOPT},
82 {ErrTooManyLinks,-EMLINK},
83 {0, 0}
86 static const struct smb_to_posix_error mapping_table_ERRSRV[] = {
87 {ERRerror, -EIO},
88 {ERRbadpw, -EACCES}, /* was EPERM */
89 {ERRbadtype, -EREMOTE},
90 {ERRaccess, -EACCES},
91 {ERRinvtid, -ENXIO},
92 {ERRinvnetname, -ENXIO},
93 {ERRinvdevice, -ENXIO},
94 {ERRqfull, -ENOSPC},
95 {ERRqtoobig, -ENOSPC},
96 {ERRqeof, -EIO},
97 {ERRinvpfid, -EBADF},
98 {ERRsmbcmd, -EBADRQC},
99 {ERRsrverror, -EIO},
100 {ERRbadBID, -EIO},
101 {ERRfilespecs, -EINVAL},
102 {ERRbadLink, -EIO},
103 {ERRbadpermits, -EINVAL},
104 {ERRbadPID, -ESRCH},
105 {ERRsetattrmode, -EINVAL},
106 {ERRpaused, -EHOSTDOWN},
107 {ERRmsgoff, -EHOSTDOWN},
108 {ERRnoroom, -ENOSPC},
109 {ERRrmuns, -EUSERS},
110 {ERRtimeout, -ETIME},
111 {ERRnoresource, -ENOBUFS},
112 {ERRtoomanyuids, -EUSERS},
113 {ERRbaduid, -EACCES},
114 {ERRusempx, -EIO},
115 {ERRusestd, -EIO},
116 {ERR_NOTIFY_ENUM_DIR, -ENOBUFS},
117 {ERRaccountexpired, -EACCES},
118 {ERRbadclient, -EACCES},
119 {ERRbadLogonTime, -EACCES},
120 {ERRpasswordExpired, -EACCES},
121 {ERRnosupport, -EINVAL},
122 {0, 0}
125 static const struct smb_to_posix_error mapping_table_ERRHRD[] = {
126 {0, 0}
129 /* Convert string containing dotted ip address to binary form */
130 /* returns 0 if invalid address */
132 /* BB add address family, change rc to status flag and return union or for ipv6 */
133 /* will need parent to call something like inet_pton to convert ipv6 address BB */
135 cifs_inet_pton(int address_family, char *cp,void *dst)
137 int value;
138 int digit;
139 int i;
140 char temp;
141 char bytes[4];
142 char *end = bytes;
143 static const int addr_class_max[4] =
144 { 0xffffffff, 0xffffff, 0xffff, 0xff };
146 if(address_family != AF_INET)
147 return -EAFNOSUPPORT;
149 for (i = 0; i < 4; i++) {
150 bytes[i] = 0;
153 temp = *cp;
155 while (TRUE) {
156 if (!isdigit(temp))
157 return 0;
159 value = 0;
160 digit = 0;
161 for (;;) {
162 if (isascii(temp) && isdigit(temp)) {
163 value = (value * 10) + temp - '0';
164 temp = *++cp;
165 digit = 1;
166 } else
167 break;
170 if (temp == '.') {
171 if ((end > bytes + 2) || (value > 255))
172 return 0;
173 *end++ = value;
174 temp = *++cp;
175 } else if (temp == ':') {
176 cFYI(1,("IPv6 addresses not supported for CIFS mounts yet"));
177 return -1;
178 } else
179 break;
182 /* check for last characters */
183 if (temp != '\0' && (!isascii(temp) || !isspace(temp)))
184 if (temp != '\\') {
185 if (temp != '/')
186 return 0;
187 else
188 (*cp = '\\'); /* switch the slash the expected way */
190 if (value > addr_class_max[end - bytes])
191 return 0;
193 *((__be32 *)dst) = *((__be32 *) bytes) | htonl(value);
194 return 1; /* success */
197 /*****************************************************************************
198 convert a NT status code to a dos class/code
199 *****************************************************************************/
200 /* NT status -> dos error map */
201 static const struct {
202 __u8 dos_class;
203 __u16 dos_code;
204 __u32 ntstatus;
205 } ntstatus_to_dos_map[] = {
207 ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {
208 ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {
209 ERRDOS, ERRinvlevel, NT_STATUS_INVALID_INFO_CLASS}, {
210 ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {
211 ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {
212 ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {
213 ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, {
214 ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, {
215 ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, {
216 ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, {
217 ERRDOS, 87, NT_STATUS_INVALID_CID}, {
218 ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {
219 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {
220 ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, {
221 ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {
222 ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {
223 ERRDOS, 38, NT_STATUS_END_OF_FILE}, {
224 ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, {
225 ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {
226 ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, {
227 ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
228 /* { This NT error code was 'sqashed'
229 from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK
230 during the session setup } */
232 ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, {
233 ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, {
234 ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, {
235 ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, {
236 ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, {
237 ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, {
238 ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, {
239 ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, {
240 ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, {
241 ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, {
242 ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
243 /* { This NT error code was 'sqashed'
244 from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
245 during the session setup } */
247 ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, {
248 ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, {
249 ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, {
250 ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, {
251 ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, {
252 ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, {
253 ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, {
254 ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, {
255 ERRDOS, 158, NT_STATUS_NOT_LOCKED}, {
256 ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, {
257 ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, {
258 ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, {
259 ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, {
260 ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, {
261 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {
262 ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {
263 ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {
264 ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, { /* mapping changed since shell does lookup on * and expects file not found */
265 ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {
266 ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {
267 ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {
268 ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {
269 ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, {
270 ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, {
271 ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, {
272 ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, {
273 ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, {
274 ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, {
275 ERRDOS, 23, NT_STATUS_DATA_ERROR}, {
276 ERRDOS, 23, NT_STATUS_CRC_ERROR}, {
277 ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, {
278 ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, {
279 ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, {
280 ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, {
281 ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, {
282 ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, {
283 ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, {
284 ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, {
285 ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, {
286 ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, {
287 ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, {
288 ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, {
289 ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {
290 ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {
291 ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {
292 ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED}, {
293 ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {
294 ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {
295 ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {
296 ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {
297 ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {
298 ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {
299 ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {
300 ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {
301 ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {
302 ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {
303 ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, {
304 ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, {
305 ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, {
306 ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, {
307 ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, {
308 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, {
309 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, {
310 ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD}, {
311 ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, {
312 ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
313 /* { This NT error code was 'sqashed'
314 from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
315 during the session setup } */
317 ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, {
318 ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, {
319 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, {
320 ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, {
321 ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, {
322 ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
323 /* { This NT error code was 'sqashed'
324 from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE
325 during the session setup } */
327 ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, {
328 ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, {
329 ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, {
330 ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, {
331 ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, {
332 ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS}, {
333 ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION}, {
334 ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, {
335 ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED}, {
336 ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, {
337 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, {
338 ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, {
339 ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, {
340 ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, {
341 ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, {
342 ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, {
343 ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, {
344 ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, {
345 ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, {
346 ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, {
347 ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, {
348 ERRDOS, 112, NT_STATUS_DISK_FULL}, {
349 ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, {
350 ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, {
351 ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, {
352 ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, {
353 ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, {
354 ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, {
355 ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, {
356 ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, {
357 ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, {
358 ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, {
359 ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, {
360 ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, {
361 ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, {
362 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, {
363 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, {
364 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, {
365 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, {
366 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, {
367 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, {
368 ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, {
369 ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, {
370 ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, {
371 ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, {
372 ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, {
373 ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, {
374 ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
375 /* { This NT error code was 'sqashed'
376 from NT_STATUS_INSUFFICIENT_RESOURCES to NT_STATUS_INSUFF_SERVER_RESOURCES
377 during the session setup } */
379 ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES}, {
380 ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, {
381 ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, {
382 ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, {
383 ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, {
384 ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, {
385 ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, {
386 ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, {
387 ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, {
388 ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, {
389 ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, {
390 ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, {
391 ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, {
392 ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, {
393 ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, {
394 ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, {
395 ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, {
396 ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, {
397 ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, {
398 ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, {
399 ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, {
400 ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, {
401 ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, {
402 ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, {
403 ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, {
404 ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, {
405 ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, {
406 ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, {
407 ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, {
408 ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, {
409 ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, {
410 ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, {
411 ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, {
412 ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, {
413 ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, {
414 ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, {
415 ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, {
416 ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, {
417 ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, {
418 ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, {
419 ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, {
420 ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, {
421 ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, {
422 ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, {
423 ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, {
424 ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, {
425 ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, {
426 ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, {
427 ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, {
428 ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, {
429 ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, {
430 ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, {
431 ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, {
432 ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, {
433 ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, {
434 ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, {
435 ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, {
436 ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, {
437 ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, {
438 ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, {
439 ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, {
440 ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, {
441 ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, {
442 ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, {
443 ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, {
444 ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, {
445 ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, {
446 ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, {
447 ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, {
448 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, {
449 ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, {
450 ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, {
451 ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, {
452 ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, {
453 ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, {
454 ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, {
455 ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, {
456 ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, {
457 ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, {
458 ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, {
459 ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, {
460 ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, {
461 ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, {
462 ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, {
463 ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, {
464 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, {
465 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, {
466 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, {
467 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, {
468 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, {
469 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, {
470 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, {
471 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, {
472 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, {
473 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, {
474 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, {
475 ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, {
476 ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, {
477 ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, {
478 ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, {
479 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, {
480 ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, {
481 ERRDOS, 203, 0xc0000100}, {
482 ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, {
483 ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, {
484 ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, {
485 ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, {
486 ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, {
487 ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, {
488 ERRDOS, 2401, NT_STATUS_FILES_OPEN}, {
489 ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, {
490 ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, {
491 ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, {
492 ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, {
493 ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, {
494 ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, {
495 ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, {
496 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, {
497 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, {
498 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, {
499 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, {
500 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, {
501 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, {
502 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, {
503 ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, {
504 ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, {
505 ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, {
506 ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, {
507 ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, {
508 ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, {
509 ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, {
510 ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, {
511 ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, {
512 ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, {
513 ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, {
514 ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, {
515 ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, {
516 ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, {
517 ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, {
518 ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, {
519 ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, {
520 ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, {
521 ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, {
522 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, {
523 ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, {
524 ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, {
525 ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, {
526 ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, {
527 ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, {
528 ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, {
529 ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, {
530 ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, {
531 ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, {
532 ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, {
533 ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, {
534 ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, {
535 ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, {
536 ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, {
537 ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, {
538 ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, {
539 ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, {
540 ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, {
541 ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, {
542 ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, {
543 ERRDOS, 59, NT_STATUS_LINK_FAILED}, {
544 ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, {
545 ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, {
546 ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, {
547 ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, {
548 ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, {
549 ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, {
550 ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, {
551 ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, {
552 ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, {
553 ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, {
554 ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, {
555 ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, {
556 ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, {
557 ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, {
558 ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, {
559 ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, {
560 ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, {
561 ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, {
562 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, {
563 ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, {
564 ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, {
565 ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, {
566 ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, {
567 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, {
568 ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, {
569 ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, {
570 ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, {
571 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, {
572 ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, {
573 ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, {
574 ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, {
575 ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, {
576 ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, {
577 ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, {
578 ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, {
579 ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, {
580 ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, {
581 ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, {
582 ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, {
583 ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, {
584 ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, {
585 ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, {
586 ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, {
587 ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, {
588 ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, {
589 ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, {
590 ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, {
591 ERRHRD, ERRgeneral, 0xc000016e}, {
592 ERRHRD, ERRgeneral, 0xc000016f}, {
593 ERRHRD, ERRgeneral, 0xc0000170}, {
594 ERRHRD, ERRgeneral, 0xc0000171}, {
595 ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, {
596 ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, {
597 ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, {
598 ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, {
599 ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, {
600 ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, {
601 ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, {
602 ERRHRD, ERRgeneral, 0xc0000179}, {
603 ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, {
604 ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, {
605 ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, {
606 ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, {
607 ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, {
608 ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, {
609 ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, {
610 ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, {
611 ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, {
612 ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, {
613 ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, {
614 ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, {
615 ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, {
616 ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, {
617 ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, {
618 ERRDOS, 19, NT_STATUS_TOO_LATE}, {
619 ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
620 /* { This NT error code was 'sqashed'
621 from NT_STATUS_NO_TRUST_SAM_ACCOUNT to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
622 during the session setup } */
624 ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, {
625 ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, {
626 ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, {
627 ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, {
628 ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, {
629 ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, {
630 ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, {
631 ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, {
632 ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED}, {
633 ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, {
634 ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, {
635 ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, {
636 ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, {
637 ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, {
638 ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, {
639 ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
640 /* { This NT error code was 'sqashed'
641 from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE
642 during the session setup } */
644 ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, {
645 ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, {
646 ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, {
647 ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, {
648 ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, {
649 ERRDOS, ERRnomem, NT_STATUS_INSUFF_SERVER_RESOURCES}, {
650 ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, {
651 ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, {
652 ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, {
653 ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, {
654 ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, {
655 ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, {
656 ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, {
657 ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, {
658 ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, {
659 ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, {
660 ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, {
661 ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, {
662 ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, {
663 ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, {
664 ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, {
665 ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, {
666 ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, {
667 ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, {
668 ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, {
669 ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, {
670 ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, {
671 ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, {
672 ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, {
673 ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, {
674 ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, {
675 ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, {
676 ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, {
677 ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, {
678 ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, {
679 ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, {
680 ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE}, {
681 ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, {
682 ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, {
683 ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, {
684 ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, {
685 ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, {
686 ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, {
687 ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, {
688 ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, {
689 ERRHRD, ERRgeneral, NT_STATUS_RETRY}, {
690 ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, {
691 ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, {
692 ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, {
693 ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, {
694 ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, {
695 ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, {
696 ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, {
697 ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, {
698 ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, {
699 ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, {
700 ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, {
701 ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, {
702 ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, {
703 ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, {
704 ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, {
705 ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, {
706 ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, {
707 ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, {
708 ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, {
709 ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, {
710 ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, {
711 ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, {
712 ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, {
713 ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, {
714 ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, {
715 ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, {
716 ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, {
717 ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, {
718 ERRHRD, ERRgeneral, 0xc000024a}, {
719 ERRHRD, ERRgeneral, 0xc000024b}, {
720 ERRHRD, ERRgeneral, 0xc000024c}, {
721 ERRHRD, ERRgeneral, 0xc000024d}, {
722 ERRHRD, ERRgeneral, 0xc000024e}, {
723 ERRHRD, ERRgeneral, 0xc000024f}, {
724 ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, {
725 ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, {
726 ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, {
727 ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, {
728 ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, {
729 ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, {
730 ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, {
731 ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, {
732 ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, {
733 ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, {
734 ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, {
735 ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, {
736 ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, {
737 ERRHRD, ERRgeneral, 0xc000025d}, {
738 ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, {
739 ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, {
740 ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, {
741 ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, {
742 ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {
743 ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {
744 ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {
745 ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {
746 ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {
747 ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {
748 ERRDOS, 21, 0xc000026e}, {
749 ERRDOS, 161, 0xc0000281}, {
750 ERRDOS, ERRnoaccess, 0xc000028a}, {
751 ERRDOS, ERRnoaccess, 0xc000028b}, {
752 ERRHRD, ERRgeneral, 0xc000028c}, {
753 ERRDOS, ERRnoaccess, 0xc000028d}, {
754 ERRDOS, ERRnoaccess, 0xc000028e}, {
755 ERRDOS, ERRnoaccess, 0xc000028f}, {
756 ERRDOS, ERRnoaccess, 0xc0000290}, {
757 ERRDOS, ERRbadfunc, 0xc000029c}, {
758 ERRDOS, ERRinvlevel, 0x007c0001}, };
760 /*****************************************************************************
761 Print an error message from the status code
762 *****************************************************************************/
763 static void
764 cifs_print_status(__u32 status_code)
766 int idx = 0;
768 while (nt_errs[idx].nt_errstr != NULL) {
769 if (((nt_errs[idx].nt_errcode) & 0xFFFFFF) ==
770 (status_code & 0xFFFFFF)) {
771 printk(KERN_NOTICE "Status code returned 0x%08x %s\n",
772 status_code,nt_errs[idx].nt_errstr);
774 idx++;
776 return;
780 static void
781 ntstatus_to_dos(__u32 ntstatus, __u8 * eclass, __u16 * ecode)
783 int i;
784 if (ntstatus == 0) {
785 *eclass = 0;
786 *ecode = 0;
787 return;
789 for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) {
790 if (ntstatus == ntstatus_to_dos_map[i].ntstatus) {
791 *eclass = ntstatus_to_dos_map[i].dos_class;
792 *ecode = ntstatus_to_dos_map[i].dos_code;
793 return;
796 *eclass = ERRHRD;
797 *ecode = ERRgeneral;
801 map_smb_to_linux_error(struct smb_hdr *smb)
803 unsigned int i;
804 int rc = -EIO; /* if transport error smb error may not be set */
805 __u8 smberrclass;
806 __u16 smberrcode;
808 /* BB if NT Status codes - map NT BB */
810 /* old style smb error codes */
811 if (smb->Status.CifsError == 0)
812 return 0;
814 if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
815 /* translate the newer STATUS codes to old style errors and then to POSIX errors */
816 __u32 err = le32_to_cpu(smb->Status.CifsError);
817 if(cifsFYI & CIFS_RC)
818 cifs_print_status(err);
819 ntstatus_to_dos(err, &smberrclass, &smberrcode);
820 } else {
821 smberrclass = smb->Status.DosError.ErrorClass;
822 smberrcode = le16_to_cpu(smb->Status.DosError.Error);
825 /* old style errors */
827 /* DOS class smb error codes - map DOS */
828 if (smberrclass == ERRDOS) { /* one byte field no need to byte reverse */
829 for (i = 0;
831 sizeof (mapping_table_ERRDOS) /
832 sizeof (struct smb_to_posix_error); i++) {
833 if (mapping_table_ERRDOS[i].smb_err == 0)
834 break;
835 else if (mapping_table_ERRDOS[i].smb_err == smberrcode) {
836 rc = mapping_table_ERRDOS[i].posix_code;
837 break;
839 /* else try the next error mapping one to see if it will match */
841 } else if (smberrclass == ERRSRV) { /* server class of error codes */
842 for (i = 0;
844 sizeof (mapping_table_ERRSRV) /
845 sizeof (struct smb_to_posix_error); i++) {
846 if (mapping_table_ERRSRV[i].smb_err == 0)
847 break;
848 else if (mapping_table_ERRSRV[i].smb_err == smberrcode) {
849 rc = mapping_table_ERRSRV[i].posix_code;
850 break;
852 /* else try the next error mapping one to see if it will match */
855 /* else ERRHRD class errors or junk - return EIO */
857 cFYI(1, (" !!Mapping smb error code %d to POSIX err %d !!", smberrcode,rc));
859 /* generic corrective action e.g. reconnect SMB session on ERRbaduid could be added */
861 return rc;
865 * calculate the size of the SMB message based on the fixed header
866 * portion, the number of word parameters and the data portion of the message
868 unsigned int
869 smbCalcSize(struct smb_hdr *ptr)
871 return (sizeof (struct smb_hdr) + (2 * ptr->WordCount) +
872 2 /* size of the bcc field */ + BCC(ptr));
875 unsigned int
876 smbCalcSize_LE(struct smb_hdr *ptr)
878 return (sizeof (struct smb_hdr) + (2 * ptr->WordCount) +
879 2 /* size of the bcc field */ + le16_to_cpu(BCC_LE(ptr)));
882 /* The following are taken from fs/ntfs/util.c */
884 #define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)
887 * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units)
888 * into Unix UTC (based 1970-01-01, in seconds).
890 struct timespec
891 cifs_NTtimeToUnix(u64 ntutc)
893 struct timespec ts;
894 /* BB what about the timezone? BB */
896 /* Subtract the NTFS time offset, then convert to 1s intervals. */
897 u64 t;
899 t = ntutc - NTFS_TIME_OFFSET;
900 ts.tv_nsec = do_div(t, 10000000) * 100;
901 ts.tv_sec = t;
902 return ts;
905 /* Convert the Unix UTC into NT UTC. */
907 cifs_UnixTimeToNT(struct timespec t)
909 /* Convert to 100ns intervals and then add the NTFS time offset. */
910 return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;
913 static int total_days_of_prev_months[] =
914 {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
917 __le64 cnvrtDosCifsTm(__u16 date, __u16 time)
919 return cpu_to_le64(cifs_UnixTimeToNT(cnvrtDosUnixTm(date, time)));
922 struct timespec cnvrtDosUnixTm(__u16 date, __u16 time)
924 struct timespec ts;
925 int sec, min, days, month, year;
926 SMB_TIME * st = (SMB_TIME *)&time;
927 SMB_DATE * sd = (SMB_DATE *)&date;
929 cFYI(1,("date %d time %d",date, time));
931 sec = 2 * st->TwoSeconds;
932 min = st->Minutes;
933 if((sec > 59) || (min > 59))
934 cERROR(1,("illegal time min %d sec %d", min, sec));
935 sec += (min * 60);
936 sec += 60 * 60 * st->Hours;
937 if(st->Hours > 24)
938 cERROR(1,("illegal hours %d",st->Hours));
939 days = sd->Day;
940 month = sd->Month;
941 if((days > 31) || (month > 12))
942 cERROR(1,("illegal date, month %d day: %d", month, days));
943 month -= 1;
944 days += total_days_of_prev_months[month];
945 days += 3652; /* account for difference in days between 1980 and 1970 */
946 year = sd->Year;
947 days += year * 365;
948 days += (year/4); /* leap year */
949 /* generalized leap year calculation is more complex, ie no leap year
950 for years/100 except for years/400, but since the maximum number for DOS
951 year is 2**7, the last year is 1980+127, which means we need only
952 consider 2 special case years, ie the years 2000 and 2100, and only
953 adjust for the lack of leap year for the year 2100, as 2000 was a
954 leap year (divisable by 400) */
955 if(year >= 120) /* the year 2100 */
956 days = days - 1; /* do not count leap year for the year 2100 */
958 /* adjust for leap year where we are still before leap day */
959 if(year != 120)
960 days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
961 sec += 24 * 60 * 60 * days;
963 ts.tv_sec = sec;
965 /* cFYI(1,("sec after cnvrt dos to unix time %d",sec)); */
967 ts.tv_nsec = 0;
968 return ts;