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