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