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