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