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