kill tsol ("Trusted Solaris") aka TX ("Trusted Extensions")
[unleashed.git] / usr / src / uts / common / fs / smbclnt / netsmb / smb_subrs.c
blobd7197f83f9df787d6a079f441b47cf5df813ce04
1 /*
2 * Copyright (c) 2000-2001 Boris Popov
3 * All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Boris Popov.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
32 * $Id: smb_subr.c,v 1.27.108.1 2005/06/02 00:55:39 lindak Exp $
36 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
39 #include <sys/param.h>
40 #include <sys/systm.h>
41 #include <sys/kmem.h>
42 #include <sys/proc.h>
43 #include <sys/lock.h>
44 #include <sys/socket.h>
45 #include <sys/isa_defs.h>
46 #include <sys/stream.h>
47 #include <sys/strsun.h>
48 #include <sys/sunddi.h>
49 #include <sys/cmn_err.h>
50 #include <sys/sdt.h>
51 #include <sys/priv.h>
52 #include <sys/u8_textprep.h>
54 #include <netsmb/smb_osdep.h>
55 #include <netsmb/smb.h>
56 #include <netsmb/smb_conn.h>
57 #include <netsmb/smb_rq.h>
58 #include <netsmb/smb_subr.h>
61 * XXX:This conversion might not be fully MS-Compatible
62 * for calculating hashes. The output length may differ
63 * for some locales and needs to be handled from where
64 * the call is made.
66 int
67 smb_toupper(const char *inbuf, char *outbuf, size_t outlen)
69 int err = 0;
70 size_t inlen, inrem, outrem;
72 inrem = inlen = strlen(inbuf);
73 outrem = outlen;
74 (void) u8_textprep_str((char *)inbuf, &inrem, outbuf, &outrem,
75 U8_TEXTPREP_TOUPPER, U8_UNICODE_LATEST, &err);
76 /* inrem, outrem are bytes unused, remaining */
77 if (inrem) {
78 SMBSDEBUG("input %d remains: %s\n", (int)inrem, inbuf);
79 inlen -= inrem;
81 if (outrem) {
82 outlen -= outrem;
83 outbuf[outlen] = '\0';
85 if (outlen > inlen) {
86 SMBSDEBUG("outlen > inlen! (%d > %d)\n",
87 (int)outlen, (int)inlen);
88 /* Truncate to inlen here? */
91 return (err);
94 void
95 smb_credinit(struct smb_cred *scred, cred_t *cr)
97 /* cr arg is optional */
98 if (cr == NULL)
99 cr = ddi_get_cred();
100 crhold(cr);
101 scred->scr_cred = cr;
104 void
105 smb_credrele(struct smb_cred *scred)
107 if (scred->scr_cred != NULL) {
108 crfree(scred->scr_cred);
109 scred->scr_cred = NULL;
114 * Helper for the SMBERROR macro, etc.
115 * This is also a good place for a breakpoint
116 * or a dtrace probe, i.e. fbt:nsmb:smb_errmsg
118 void
119 smb_errmsg(int cel, const char *func_name, const char *fmt, ...)
121 va_list adx;
122 char buf[100];
124 va_start(adx, fmt);
125 if (cel == CE_CONT) {
127 * This is one of our xxxDEBUG macros.
128 * Don't bother to log these, but just
129 * fire a dtrace probe with the message.
131 (void) vsnprintf(buf, sizeof (buf), fmt, adx);
132 DTRACE_PROBE2(debugmsg2,
133 (char *), func_name,
134 (char *), buf);
135 } else {
137 * This is one of our xxxERROR macros.
138 * Add a prefix to the fmt string,
139 * then let vcmn_err do the args.
141 (void) snprintf(buf, sizeof (buf), "?%s: %s", func_name, fmt);
142 DTRACE_PROBE3(debugmsg3,
143 (char *), func_name,
144 (char *), buf,
145 va_list, adx);
146 vcmn_err(cel, buf, adx);
148 va_end(adx);
151 #if 1 /* def SMB_SOCKETDATA_DEBUG */
152 void
153 m_dumpm(mblk_t *m)
155 int len, seg;
157 len = msgdsize(m);
158 DTRACE_PROBE2(dsize, int, len, (mblk_t *), m);
160 for (seg = 0; m; seg++) {
161 DTRACE_PROBE2(mblk, int, seg, (mblk_t *), m);
162 m = m->b_cont;
165 #endif
167 #ifndef EPROTO
168 #define EPROTO ECONNABORTED
169 #endif
170 #ifndef ELIBACC
171 #define ELIBACC ENOENT
172 #endif
173 #ifndef ENODATA
174 #define ENODATA EINVAL
175 #endif
176 #ifndef ENOTUNIQ
177 #define ENOTUNIQ EADDRINUSE
178 #endif
179 #ifndef ECOMM
180 #define ECOMM EIO
181 #endif
182 #ifndef ENOMEDIUM
183 #define ENOMEDIUM ENXIO
184 #endif
185 #ifndef ETIME
186 #define ETIME ETIMEDOUT
187 #endif
190 * Log any un-handled NT or DOS errors we encounter.
191 * Make these log NOTICE in a debug build to ensure
192 * they get noticed during tests. In the field these
193 * are unimportant, so just fire a Dtrace probe.
195 static int unknown_err_logpri =
196 #ifdef DEBUG
197 CE_NOTE;
198 #else
199 CE_CONT;
200 #endif
202 typedef struct nt2errno {
203 unsigned int nterr;
204 int errno;
205 } nt2errno_t;
207 static const nt2errno_t nt2errno[] = {
208 /* Alphabetical order. */
209 {NT_STATUS_ACCESS_DENIED, EACCES},
210 {NT_STATUS_ACCESS_VIOLATION, EACCES},
211 {NT_STATUS_ACCOUNT_DISABLED, EACCES},
212 {NT_STATUS_ACCOUNT_EXPIRED, EACCES},
213 {NT_STATUS_ACCOUNT_LOCKED_OUT, EACCES},
214 {NT_STATUS_ACCOUNT_RESTRICTION, EACCES},
215 {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE},
216 {NT_STATUS_BAD_NETWORK_NAME, ENOENT},
217 {NT_STATUS_BUFFER_TOO_SMALL, EMOREDATA},
218 {NT_STATUS_CANNOT_DELETE, EACCES},
219 {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE},
220 {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED},
221 {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED},
222 {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED},
223 {NT_STATUS_CONNECTION_RESET, ENETRESET},
224 {NT_STATUS_DELETE_PENDING, EACCES},
225 {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV},
226 {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO},
227 {NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY},
228 {NT_STATUS_DISK_FULL, ENOSPC},
229 {NT_STATUS_DLL_NOT_FOUND, ELIBACC},
230 {NT_STATUS_DUPLICATE_NAME, EINVAL},
231 {NT_STATUS_END_OF_FILE, ENODATA},
232 {NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR},
233 {NT_STATUS_FILE_LOCK_CONFLICT, EAGAIN},
234 {NT_STATUS_FLOAT_INEXACT_RESULT, ERANGE},
235 {NT_STATUS_FLOAT_OVERFLOW, ERANGE},
236 {NT_STATUS_FLOAT_UNDERFLOW, ERANGE},
237 {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH},
238 {NT_STATUS_ILL_FORMED_PASSWORD, EACCES},
239 {NT_STATUS_INTEGER_OVERFLOW, ERANGE},
240 {NT_STATUS_INVALID_ACCOUNT_NAME, EACCES},
241 {NT_STATUS_INVALID_HANDLE, EBADF},
242 {NT_STATUS_INVALID_LEVEL, ENOTSUP},
243 {NT_STATUS_INVALID_LOGON_HOURS, EACCES},
244 {NT_STATUS_INVALID_OWNER, EINVAL},
245 {NT_STATUS_INVALID_PARAMETER, EINVAL},
246 {NT_STATUS_INVALID_PIPE_STATE, EPIPE},
247 {NT_STATUS_INVALID_PRIMARY_GROUP, EINVAL},
248 {NT_STATUS_INVALID_WORKSTATION, EACCES},
249 {NT_STATUS_IN_PAGE_ERROR, EFAULT},
250 {NT_STATUS_IO_TIMEOUT, ETIMEDOUT},
251 {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ},
252 {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ},
253 {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT},
254 {NT_STATUS_LOCK_NOT_GRANTED, EAGAIN},
255 {NT_STATUS_LOGIN_TIME_RESTRICTION, EACCES},
256 {NT_STATUS_LOGON_FAILURE, EACCES},
257 {NT_STATUS_MEDIA_WRITE_PROTECTED, EROFS},
258 {NT_STATUS_MEMORY_NOT_ALLOCATED, EFAULT},
259 {NT_STATUS_NAME_TOO_LONG, ENAMETOOLONG},
260 {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES},
261 {NT_STATUS_NETWORK_BUSY, EBUSY},
262 {NT_STATUS_NETWORK_UNREACHABLE, ENETUNREACH},
263 {NT_STATUS_NET_WRITE_FAULT, ECOMM},
264 {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE},
265 {NT_STATUS_NONE_MAPPED, EINVAL},
266 {NT_STATUS_NOT_A_DIRECTORY, ENOTDIR},
267 {NT_STATUS_NOT_IMPLEMENTED, ENOTSUP},
268 {NT_STATUS_NOT_MAPPED_VIEW, EINVAL},
269 {NT_STATUS_NOT_SUPPORTED, ENOTSUP},
270 {NT_STATUS_NO_MEDIA, ENOMEDIUM},
271 {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM},
272 {NT_STATUS_NO_MEMORY, ENOMEM},
273 {NT_STATUS_NO_SUCH_DEVICE, ENODEV},
274 {NT_STATUS_NO_SUCH_FILE, ENOENT},
275 {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST},
276 {NT_STATUS_OBJECT_NAME_INVALID, EINVAL},
277 {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT},
278 {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR},
279 {NT_STATUS_OBJECT_PATH_NOT_FOUND, ENOENT},
280 {NT_STATUS_PAGEFILE_QUOTA, EDQUOT},
281 {NT_STATUS_PASSWORD_EXPIRED, EACCES},
282 {NT_STATUS_PASSWORD_MUST_CHANGE, EACCES},
283 {NT_STATUS_PASSWORD_RESTRICTION, EACCES},
284 {NT_STATUS_PATH_NOT_COVERED, ENOENT},
285 {NT_STATUS_PIPE_BROKEN, EPIPE},
286 {NT_STATUS_PIPE_BUSY, EPIPE},
287 {NT_STATUS_PIPE_CONNECTED, EISCONN},
288 {NT_STATUS_PIPE_DISCONNECTED, EPIPE},
289 {NT_STATUS_PIPE_NOT_AVAILABLE, EBUSY},
290 {NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED},
291 {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE},
292 {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH},
293 {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT},
294 {NT_STATUS_QUOTA_EXCEEDED, EDQUOT},
295 {NT_STATUS_RANGE_NOT_LOCKED, EIO},
296 {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT},
297 {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN},
298 {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED},
299 {NT_STATUS_REQUEST_NOT_ACCEPTED, EACCES},
300 {NT_STATUS_RETRY, EAGAIN},
301 {NT_STATUS_SHARING_VIOLATION, EBUSY},
302 {NT_STATUS_TIMER_NOT_CANCELED, ETIME},
303 {NT_STATUS_TOO_MANY_LINKS, EMLINK},
304 {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE},
305 {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE},
306 {NT_STATUS_UNSUCCESSFUL, EINVAL},
307 {NT_STATUS_WRONG_PASSWORD, EACCES},
308 {0, 0}
312 * Table for converting NT STATUS values to DOS class/code.
313 * Rows ordered by integer value of last column (NT STATUS)
315 typedef struct nt2doserr {
316 unsigned short dclass;
317 unsigned short derr;
318 unsigned int nterr;
319 } nt2doserr_t;
321 static const nt2doserr_t nt2doserr[] = {
322 {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL},
323 {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED},
324 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_INFO_CLASS},
325 {ERRDOS, ERROR_BAD_LENGTH, NT_STATUS_INFO_LENGTH_MISMATCH},
326 {ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION},
327 {ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR},
328 {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA},
329 {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE},
330 {ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK},
331 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_BAD_INITIAL_PC},
332 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_CID},
333 {ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED},
334 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER},
335 {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE},
336 {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE},
337 {ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST},
338 {ERRDOS, ERROR_HANDLE_EOF, NT_STATUS_END_OF_FILE},
339 {ERRDOS, ERROR_WRONG_DISK, NT_STATUS_WRONG_VOLUME},
340 {ERRDOS, ERROR_NOT_READY, NT_STATUS_NO_MEDIA_IN_DEVICE},
341 {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA},
342 {ERRDOS, ERROR_SECTOR_NOT_FOUND, NT_STATUS_NONEXISTENT_SECTOR},
343 {ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY},
344 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_CONFLICTING_ADDRESSES},
345 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_NOT_MAPPED_VIEW},
346 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_UNABLE_TO_FREE_VM},
347 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_UNABLE_TO_DELETE_SECTION},
348 {ERRDOS, NERR_InvalidAPI, NT_STATUS_INVALID_SYSTEM_SERVICE},
349 {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION},
350 {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE},
351 {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE},
352 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_FILE_FOR_SECTION},
353 {ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
354 {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED},
355 {ERRDOS, ERROR_BUFFER_OVERFLOW, NT_STATUS_BUFFER_TOO_SMALL},
356 {ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH},
357 {ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION},
358 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION},
359 {ERRHRD, ERRgeneral, NT_STATUS_UNWIND},
360 {ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK},
361 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET},
362 {ERRDOS, ERROR_NOT_LOCKED, NT_STATUS_NOT_LOCKED},
363 {ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR},
364 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_UNABLE_TO_DECOMMIT_VM},
365 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_NOT_COMMITTED},
366 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES},
367 {ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG},
368 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_MIX},
369 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER},
370 {ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR},
371 {ERRDOS, ERROR_INVALID_NAME, NT_STATUS_OBJECT_NAME_INVALID},
372 {ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND},
373 {ERRDOS, ERROR_ALREADY_EXISTS, NT_STATUS_OBJECT_NAME_COLLISION},
374 {ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED},
375 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED},
376 {ERRDOS, ERROR_BAD_PATHNAME, NT_STATUS_OBJECT_PATH_INVALID},
377 {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND},
378 {ERRDOS, ERROR_BAD_PATHNAME, NT_STATUS_OBJECT_PATH_SYNTAX_BAD},
379 {ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN},
380 {ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR},
381 {ERRDOS, ERROR_CRC, NT_STATUS_DATA_ERROR},
382 {ERRDOS, ERROR_CRC, NT_STATUS_CRC_ERROR},
383 {ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG},
384 {ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED},
385 {ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE},
386 {ERRDOS, ERROR_SHARING_VIOLATION, NT_STATUS_SHARING_VIOLATION},
387 {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED},
388 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PAGE_PROTECTION},
389 {ERRDOS, ERROR_NOT_OWNER, NT_STATUS_MUTANT_NOT_OWNED},
390 {ERRDOS, ERROR_TOO_MANY_POSTS, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED},
391 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_PORT_ALREADY_SET},
392 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_SECTION_NOT_IMAGE},
393 {ERRDOS, ERROR_SIGNAL_REFUSED, NT_STATUS_SUSPEND_COUNT_EXCEEDED},
394 {ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING},
395 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_WORKING_SET_LIMIT},
396 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INCOMPATIBLE_FILE_MAP},
397 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_SECTION_PROTECTION},
398 {ERRDOS, ERROR_EAS_NOT_SUPPORTED, NT_STATUS_EAS_NOT_SUPPORTED},
399 {ERRDOS, ERROR_EA_LIST_INCONSISTENT, NT_STATUS_EA_TOO_LARGE},
400 {ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY},
401 {ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE},
402 {ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR},
403 {ERRDOS, ERROR_LOCK_VIOLATION, NT_STATUS_FILE_LOCK_CONFLICT},
404 {ERRDOS, ERROR_LOCK_VIOLATION, NT_STATUS_LOCK_NOT_GRANTED},
405 {ERRDOS, ERRnoaccess, NT_STATUS_DELETE_PENDING},
406 {ERRDOS, ERROR_NOT_SUPPORTED, NT_STATUS_CTL_FILE_NOT_SUPPORTED},
407 {ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION},
408 {ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH},
409 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER},
410 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP},
411 {ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN},
412 {ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY},
413 {ERRDOS, NERR_LogonServerNotFound, NT_STATUS_NO_LOGON_SERVERS},
414 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION},
415 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE},
416 {ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD},
417 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME},
418 {ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
419 {ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER},
420 {ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS},
421 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP},
422 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP},
423 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP},
424 {ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
425 {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD},
426 {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD},
427 {ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION},
428 {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE},
429 {ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION},
430 {ERRSRV, NERR_InvalidLogonHours, NT_STATUS_INVALID_LOGON_HOURS},
431 {ERRSRV, NERR_InvalidWorkstation, NT_STATUS_INVALID_WORKSTATION},
432 {ERRSRV, NERR_PasswordExpired, NT_STATUS_PASSWORD_EXPIRED},
433 {ERRSRV, NERR_AccountExpired, NT_STATUS_ACCOUNT_DISABLED},
434 {ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED},
435 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED},
436 {ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED},
437 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY},
438 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL},
439 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID},
440 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR},
441 {ERRDOS, ERROR_PROC_NOT_FOUND, NT_STATUS_PROCEDURE_NOT_FOUND},
442 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_FORMAT},
443 {ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN},
444 {ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL},
445 {ERRDOS, ERROR_NOT_LOCKED, NT_STATUS_RANGE_NOT_LOCKED},
446 {ERRDOS, ERROR_DISK_FULL, NT_STATUS_DISK_FULL},
447 {ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED},
448 {ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED},
449 {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_GUIDS_REQUESTED},
450 {ERRDOS, ERROR_NO_MORE_ITEMS, NT_STATUS_GUIDS_EXHAUSTED},
451 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY},
452 {ERRDOS, ERROR_NO_MORE_ITEMS, NT_STATUS_AGENTS_EXHAUSTED},
453 {ERRDOS, ERROR_LABEL_TOO_LONG, NT_STATUS_INVALID_VOLUME_LABEL},
454 {ERRDOS, ERROR_OUTOFMEMORY, NT_STATUS_SECTION_NOT_EXTENDED},
455 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_NOT_MAPPED_DATA},
456 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND},
457 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND},
458 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND},
459 {ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED},
460 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND},
461 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO},
462 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT},
463 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION},
464 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW},
465 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK},
466 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW},
467 {ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO},
468 {ERRDOS, ERROR_ARITHMETIC_OVERFLOW, NT_STATUS_INTEGER_OVERFLOW},
469 {ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION},
470 {ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES},
471 {ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID},
472 {ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
473 {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES},
474 {ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND},
475 {ERRDOS, ERROR_CRC, NT_STATUS_DEVICE_DATA_ERROR},
476 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED},
477 {ERRDOS, ERROR_NOT_READY, NT_STATUS_DEVICE_POWER_FAILURE},
478 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_FREE_VM_NOT_AT_BASE},
479 {ERRDOS, ERROR_INVALID_ADDRESS, NT_STATUS_MEMORY_NOT_ALLOCATED},
480 {ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA},
481 {ERRDOS, ERROR_WRITE_PROTECT, NT_STATUS_MEDIA_WRITE_PROTECTED},
482 {ERRDOS, ERROR_NOT_READY, NT_STATUS_DEVICE_NOT_READY},
483 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES},
484 {ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL},
485 {ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS},
486 {ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS},
487 {ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE},
488 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_BAD_MASTER_BOOT_RECORD},
489 {ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT},
490 {ERRDOS, ERROR_PIPE_BUSY, NT_STATUS_INSTANCE_NOT_AVAILABLE},
491 {ERRDOS, ERROR_PIPE_BUSY, NT_STATUS_PIPE_NOT_AVAILABLE},
492 {ERRDOS, ERROR_BAD_PIPE, NT_STATUS_INVALID_PIPE_STATE},
493 {ERRDOS, ERROR_PIPE_BUSY, NT_STATUS_PIPE_BUSY},
494 {ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION},
495 {ERRDOS, ERROR_PIPE_NOT_CONNECTED, NT_STATUS_PIPE_DISCONNECTED},
496 {ERRDOS, ERROR_NO_DATA, NT_STATUS_PIPE_CLOSING},
497 {ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED},
498 {ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING},
499 {ERRDOS, ERROR_BAD_PIPE, NT_STATUS_INVALID_READ_MODE},
500 {ERRDOS, ERROR_SEM_TIMEOUT, NT_STATUS_IO_TIMEOUT},
501 {ERRDOS, ERROR_HANDLE_EOF, NT_STATUS_FILE_FORCED_CLOSED},
502 {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED},
503 {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED},
504 {ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET},
505 {ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY},
506 {ERRDOS, ERROR_NOT_SUPPORTED, NT_STATUS_NOT_SUPPORTED},
507 {ERRDOS, ERROR_REM_NOT_LIST, NT_STATUS_REMOTE_NOT_LISTENING},
508 {ERRDOS, ERROR_DUP_NAME, NT_STATUS_DUPLICATE_NAME},
509 {ERRDOS, ERROR_BAD_NETPATH, NT_STATUS_BAD_NETWORK_PATH},
510 {ERRDOS, ERROR_NETWORK_BUSY, NT_STATUS_NETWORK_BUSY},
511 {ERRDOS, ERROR_DEV_NOT_EXIST, NT_STATUS_DEVICE_DOES_NOT_EXIST},
512 {ERRDOS, ERROR_TOO_MANY_CMDS, NT_STATUS_TOO_MANY_COMMANDS},
513 {ERRDOS, ERROR_ADAP_HDW_ERR, NT_STATUS_ADAPTER_HARDWARE_ERROR},
514 {ERRDOS, ERROR_BAD_NET_RESP, NT_STATUS_INVALID_NETWORK_RESPONSE},
515 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_UNEXPECTED_NETWORK_ERROR},
516 {ERRDOS, ERROR_BAD_REM_ADAP, NT_STATUS_BAD_REMOTE_ADAPTER},
517 {ERRDOS, ERROR_PRINTQ_FULL, NT_STATUS_PRINT_QUEUE_FULL},
518 {ERRDOS, ERROR_NO_SPOOL_SPACE, NT_STATUS_NO_SPOOL_SPACE},
519 {ERRDOS, ERROR_PRINT_CANCELLED, NT_STATUS_PRINT_CANCELLED},
520 {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_NETWORK_NAME_DELETED},
521 {ERRDOS, ERROR_NETWORK_ACCESS_DENIED, NT_STATUS_NETWORK_ACCESS_DENIED},
522 {ERRDOS, ERROR_BAD_DEV_TYPE, NT_STATUS_BAD_DEVICE_TYPE},
523 {ERRDOS, ERROR_BAD_NET_NAME, NT_STATUS_BAD_NETWORK_NAME},
524 {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_NAMES},
525 {ERRDOS, ERROR_TOO_MANY_SESS, NT_STATUS_TOO_MANY_SESSIONS},
526 {ERRDOS, ERROR_SHARING_PAUSED, NT_STATUS_SHARING_PAUSED},
527 {ERRDOS, ERROR_REQ_NOT_ACCEP, NT_STATUS_REQUEST_NOT_ACCEPTED},
528 {ERRDOS, ERROR_REDIR_PAUSED, NT_STATUS_REDIRECTOR_PAUSED},
529 {ERRDOS, ERROR_NET_WRITE_FAULT, NT_STATUS_NET_WRITE_FAULT},
530 {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT},
531 {ERRDOS, ERROR_NOT_SAME_DEVICE, NT_STATUS_NOT_SAME_DEVICE},
532 {ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED},
533 {ERRDOS, ERROR_VC_DISCONNECTED, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED},
534 {ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT},
535 {ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT},
536 {ERRDOS, ERROR_NO_DATA, NT_STATUS_PIPE_EMPTY},
537 {ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO},
538 {ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF},
539 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE},
540 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE},
541 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE},
542 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN},
543 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS},
544 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED},
545 {ERRDOS, ERROR_OPLOCK_NOT_GRANTED, NT_STATUS_OPLOCK_NOT_GRANTED},
546 {ERRDOS, ERROR_INVALID_OPLOCK_PROTOCOL,
547 NT_STATUS_INVALID_OPLOCK_PROTOCOL},
548 {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION},
549 {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR},
550 {ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED},
551 {ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT},
552 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER},
553 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR},
554 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR},
555 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR},
556 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR},
557 {ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS},
558 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS},
559 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_1},
560 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_2},
561 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_3},
562 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_4},
563 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_5},
564 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_6},
565 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_7},
566 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_8},
567 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_9},
568 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_10},
569 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_11},
570 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_INVALID_PARAMETER_12},
571 {ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED},
572 {ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED},
573 {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW},
574 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE},
575 {ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE},
576 {ERRDOS, ERROR_ENVVAR_NOT_FOUND, NT_STATUS_VARIABLE_NOT_FOUND},
577 {ERRDOS, ERROR_DIR_NOT_EMPTY, NT_STATUS_DIRECTORY_NOT_EMPTY},
578 {ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR},
579 {ERRDOS, ERROR_DIRECTORY, NT_STATUS_NOT_A_DIRECTORY},
580 {ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE},
581 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION},
582 {ERRDOS, ERROR_FILENAME_EXCED_RANGE, NT_STATUS_NAME_TOO_LONG},
583 {ERRDOS, NERR_OpenFiles, NT_STATUS_FILES_OPEN},
584 {ERRDOS, NERR_DevInUse, NT_STATUS_CONNECTION_IN_USE},
585 {ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND},
586 {ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING},
587 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE},
588 {ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION},
589 {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE},
590 {ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED},
591 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT},
592 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST},
593 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED},
594 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER},
595 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND},
596 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID},
597 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE},
598 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR},
599 {ERRHRD, ERRgeneral, NT_STATUS_NO_LDT},
600 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE},
601 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET},
602 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR},
603 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_NE_FORMAT},
604 {ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE},
605 {ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE},
606 {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO},
607 {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES},
608 {ERRHRD, ERRgeneral, NT_STATUS_CANCELLED},
609 {ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE},
610 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME},
611 {ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED},
612 {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT},
613 {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP},
614 {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER},
615 {ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP},
616 {ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED},
617 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS},
618 {ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS},
619 {ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE},
620 {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED},
621 {ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT},
622 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_LE_FORMAT},
623 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_NOT_MZ},
624 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_PROTECT},
625 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_INVALID_IMAGE_WIN_16},
626 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT},
627 {ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC},
628 {ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED},
629 {ERRDOS, ERROR_MOD_NOT_FOUND, NT_STATUS_DLL_NOT_FOUND},
630 {ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED},
631 {ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED},
632 {ERRDOS, ERROR_INVALID_ORDINAL, NT_STATUS_ORDINAL_NOT_FOUND},
633 {ERRDOS, ERROR_PROC_NOT_FOUND, NT_STATUS_ENTRYPOINT_NOT_FOUND},
634 {ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT},
635 {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_LOCAL_DISCONNECT},
636 {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_REMOTE_DISCONNECT},
637 {ERRDOS, ERROR_REM_NOT_LIST, NT_STATUS_REMOTE_RESOURCES},
638 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_LINK_FAILED},
639 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_LINK_TIMEOUT},
640 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_INVALID_CONNECTION},
641 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_INVALID_ADDRESS},
642 {ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED},
643 {ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE},
644 {ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION},
645 {ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE},
646 {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED},
647 {ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE},
648 {ERRDOS, ERROR_INVALID_LEVEL, NT_STATUS_INVALID_LEVEL},
649 {ERRDOS, ERROR_INVALID_PASSWORD, NT_STATUS_WRONG_PASSWORD_CORE},
650 {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT},
651 {ERRDOS, ERROR_BROKEN_PIPE, NT_STATUS_PIPE_BROKEN},
652 {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT},
653 {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED},
654 {ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR},
655 {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME},
656 {ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED},
657 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS},
658 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS},
659 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS},
660 {ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS},
661 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED},
662 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS},
663 {ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG},
664 {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR},
665 {ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE},
666 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS},
667 {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED},
668 {ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE},
669 {ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED},
670 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR},
671 {ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER},
672 {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY},
673 {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER},
674 {ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER},
675 {ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER},
676 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME},
677 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND},
678 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER},
679 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR},
680 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS},
681 {ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED},
682 {ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED},
683 {ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED},
684 {ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY},
685 {ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING},
686 {ERRHRD, ERRgeneral,
687 NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT},
688 {ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE},
689 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH},
690 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED},
691 {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA},
692 {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA},
693 {ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW},
694 {ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA},
695 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER},
696 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER},
697 {ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED},
698 {ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE},
699 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS},
700 {ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED},
701 {ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN},
702 {ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE},
703 {ERRDOS, ERROR_INVALID_PARAMETER, NT_STATUS_DEVICE_CONFIGURATION_ERROR},
704 {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR},
705 {ERRDOS, ERROR_BAD_COMMAND, NT_STATUS_INVALID_DEVICE_STATE},
706 {ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR},
707 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR},
708 {ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER},
709 {ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL},
710 {ERRDOS, ERROR_WRITE_PROTECT, NT_STATUS_TOO_LATE},
711 {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
712 {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT},
713 {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE},
714 {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE},
715 {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT},
716 {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START},
717 {ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE},
718 {ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED},
719 {ERRDOS, NERR_NetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED},
720 {ERRSRV, NERR_AccountExpired, NT_STATUS_ACCOUNT_EXPIRED},
721 {ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK},
722 {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT},
723 {ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT},
724 {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED},
725 {ERRDOS, ERRnoaccess,
726 NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT},
727 {ERRDOS, ERRnoaccess,
728 NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT},
729 {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
730 {ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT},
731 {ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED},
732 {ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY},
733 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_USER_SESSION_DELETED},
734 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND},
735 {ERRDOS, ERRnomem, NT_STATUS_INSUFF_SERVER_RESOURCES},
736 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE},
737 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT},
738 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD},
739 {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_ADDRESSES},
740 {ERRDOS, ERROR_DUP_NAME, NT_STATUS_ADDRESS_ALREADY_EXISTS},
741 {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_ADDRESS_CLOSED},
742 {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_CONNECTION_DISCONNECTED},
743 {ERRDOS, ERROR_NETNAME_DELETED, NT_STATUS_CONNECTION_RESET},
744 {ERRDOS, ERROR_TOO_MANY_NAMES, NT_STATUS_TOO_MANY_NODES},
745 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_ABORTED},
746 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_TIMED_OUT},
747 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_NO_RELEASE},
748 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_NO_MATCH},
749 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_RESPONDED},
750 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_INVALID_ID},
751 {ERRDOS, ERROR_UNEXP_NET_ERR, NT_STATUS_TRANSACTION_INVALID_TYPE},
752 {ERRDOS, ERROR_NOT_SUPPORTED, NT_STATUS_NOT_SERVER_SESSION},
753 {ERRDOS, ERROR_NOT_SUPPORTED, NT_STATUS_NOT_CLIENT_SESSION},
754 {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE},
755 {ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED},
756 {ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED},
757 {ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED},
758 {ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND},
759 {ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR},
760 {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT},
761 {ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH},
762 {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT},
763 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_IMAGE_CHECKSUM_MISMATCH},
764 {ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA},
765 {ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID},
766 {ERRSRV, NERR_PasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE},
767 {ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND},
768 {ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM},
769 {ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE},
770 {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ},
771 {ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK},
772 {ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID},
773 {ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS},
774 {ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE},
775 {ERRHRD, ERRgeneral, NT_STATUS_RETRY},
776 {ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE},
777 {ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET},
778 {ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND},
779 {ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW},
780 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT},
781 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND},
782 {ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT},
783 {ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE},
784 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED},
785 {ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT},
786 {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED},
787 {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED},
788 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID},
789 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE},
790 {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE},
791 {ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE},
792 {ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE},
793 {ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE},
794 {ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED},
795 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED},
796 {ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER},
797 {ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE},
798 {ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED},
799 {ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET},
800 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT},
801 {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION},
802 {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION},
803 {ERRDOS, ERROR_BAD_EXE_FORMAT, NT_STATUS_IMAGE_MP_UP_MISMATCH},
804 {ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO},
805 {ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT},
806 {ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT},
807 {ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST},
808 {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1},
809 {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2},
810 {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT},
811 {ERRSRV, ERRbadtype, NT_STATUS_PATH_NOT_COVERED},
812 {ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE},
813 {ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED},
814 {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT},
815 {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT},
816 {ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT},
817 {ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE},
818 {ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION},
819 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE},
820 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH},
821 {ERRDOS, ERROR_INVALID_ORDINAL, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND},
822 {ERRDOS, ERROR_PROC_NOT_FOUND, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND},
823 {ERRDOS, ERROR_NOT_OWNER, NT_STATUS_RESOURCE_NOT_OWNED},
824 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LINKS},
825 {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT},
826 {ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE},
827 {ERRDOS, ERROR_NOT_READY, NT_STATUS_VOLUME_DISMOUNTED},
828 {ERRDOS, ERROR_BAD_PATHNAME, NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT},
829 {ERRDOS, ERRnoaccess, NT_STATUS_ENCRYPTION_FAILED},
830 {ERRDOS, ERRnoaccess, NT_STATUS_DECRYPTION_FAILED},
831 {ERRHRD, ERRgeneral, NT_STATUS_RANGE_NOT_FOUND},
832 {ERRDOS, ERRnoaccess, NT_STATUS_NO_RECOVERY_POLICY},
833 {ERRDOS, ERRnoaccess, NT_STATUS_NO_EFS},
834 {ERRDOS, ERRnoaccess, NT_STATUS_WRONG_EFS},
835 {ERRDOS, ERRnoaccess, NT_STATUS_NO_USER_KEYS},
836 {ERRDOS, ERRbadfunc, NT_STATUS_VOLUME_NOT_UPGRADED},
837 {0, 0, 0}
841 smb_maperr32(uint32_t nterr)
843 const nt2errno_t *nt2e;
844 const nt2doserr_t *nt2d;
846 switch (NT_SC_SEVERITY(nterr)) {
847 case NT_STATUS_SEVERITY_SUCCESS:
848 case NT_STATUS_SEVERITY_INFORMATIONAL:
849 return (0);
852 /* first try direct map to unix */
853 for (nt2e = nt2errno; nt2e->errno; nt2e++)
854 if (nt2e->nterr == nterr)
855 return (nt2e->errno);
856 smb_errmsg(unknown_err_logpri, "smb_maperr32",
857 "No direct map for 32 bit server error (0x%x)\n", nterr);
859 /* ok, then try mapping to dos to unix */
860 for (nt2d = nt2doserr; nt2d->nterr; nt2d++)
861 if (nt2d->nterr == nterr)
862 return (smb_maperror(nt2d->dclass, nt2d->derr));
863 return (EIO);
868 smb_maperror(int eclass, int eno)
870 if (eclass == 0 && eno == 0)
871 return (0);
872 switch (eclass) {
873 case ERRDOS:
874 switch (eno) {
875 case ERROR_INVALID_LEVEL:
876 return (ENOTSUP);
877 case ERRbadfunc:
878 case ERRbadenv:
879 case ERRbadformat:
880 case ERRremcd:
881 case ERRrmuns:
882 return (EINVAL);
883 case ERRbadfile:
884 case ERRbadpath:
885 case ERROR_BAD_DEV_TYPE:
886 case ERROR_BAD_NET_NAME:
887 return (ENOENT);
888 case ERRnofids:
889 return (EMFILE);
890 case ERRnoaccess:
892 * XXX CSM Reported on samba-technical 12/7/2002
894 * There is a case for which server(s) return
895 * ERRnoaccess but should return ERRdiskfull: When
896 * the offset for a write is exactly the server
897 * file size limit then Samba (at least) thinks
898 * the reason for zero bytes having been written
899 * must have been "access denied" from the local
900 * filesystem. This cannot be easily worked
901 * around since the server behaviour is
902 * indistinguishable from actual access denied.
903 * An incomplete workaround: attempt a 2 byte write
904 * from "offset-1". (That may require reading at
905 * offset-1 first.) The flaw is that reading or
906 * writing at offset-1 could cause an
907 * unrelated error (due to a byte range lock
908 * for instance) and we can't presume the
909 * order servers check errors in.
911 case ERRbadaccess:
912 return (EACCES);
913 case ERRbadshare:
914 return (EBUSY);
915 case ERRbadfid:
916 return (EBADF);
917 case ERRbadmcb:
918 return (EIO);
919 case ERRnomem:
920 return (ENOMEM); /* actually remote no mem... */
921 case ERRbadmem:
922 return (EFAULT);
923 case ERRbaddata:
924 return (E2BIG);
925 case ERRbaddrive:
926 case ERRnotready: /* nt */
927 return (ENXIO);
928 case ERRdiffdevice:
929 return (EXDEV);
930 case ERRnofiles:
931 return (0); /* eeof ? */
932 case ERRlock:
933 return (EAGAIN);
934 case ERRfilexists:
935 return (EEXIST);
936 case ERROR_INVALID_NAME:
937 return (ENOENT);
938 case ERROR_DIR_NOT_EMPTY:
939 return (ENOTEMPTY);
940 case ERROR_NOT_LOCKED:
941 return (0); /* we unlock on any close */
942 case ERROR_ALREADY_EXISTS:
943 return (EEXIST);
944 case ERRmoredata:
945 return (EMOREDATA);
947 break;
948 case ERRSRV:
949 switch (eno) {
950 case ERRerror:
951 return (EINVAL);
952 case ERRbadpw:
953 return (EAUTH);
954 case ERRaccess:
955 case ERRbaduid:
956 return (EACCES);
957 case ERRinvnid:
958 return (ENETRESET);
959 case ERRinvnetname:
960 return (ENXIO);
961 case ERRbadtype: /* reserved and returned */
962 return (EIO);
963 case NERR_AccountExpired: /* account exists but disabled */
964 return (EPERM);
966 break;
967 case ERRHRD:
968 switch (eno) {
969 case ERRnowrite:
970 return (EROFS);
971 case ERRbadunit:
972 return (ENODEV);
973 case ERRbadreq:
974 return (EBADRPC);
975 case ERRbadshare:
976 return (ETXTBSY);
977 case ERRlock:
978 return (EAGAIN);
979 case ERRdiskfull:
980 return (EFBIG);
981 case ERRnotready:
982 case ERRbadcmd:
983 case ERRdata:
984 case ERRgeneral:
985 return (EIO);
989 smb_errmsg(unknown_err_logpri, "smb_maperror",
990 "Unknown DOS error %d/%d\n", eclass, eno);
991 return (EIO);
994 #if defined(NOICONVSUPPORT) || defined(lint)
995 extern int iconv_conv(void *handle, const char **inbuf,
996 size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
997 #endif
999 #define SMALL_CONV 256
1001 /*ARGSUSED*/
1003 smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1004 int size, int caseopt, int *lenp)
1006 uint16_t convbuf[SMALL_CONV];
1007 uint16_t *cbuf;
1008 size_t cbufalloc, inlen, outlen;
1009 int error;
1011 if (size <= 0)
1012 return (0);
1015 * Handle the easy case (non-unicode).
1016 * XXX: Technically, we should convert
1017 * the string to OEM codeset first...
1018 * Modern servers all use Unicode, so
1019 * this is good enough.
1021 if (SMB_UNICODE_STRINGS(vcp) == 0) {
1022 error = mb_put_mem(mbp, src, size, MB_MSYSTEM);
1023 if (!error && lenp)
1024 *lenp += size;
1025 return (error);
1029 * Convert to UCS-2 (really UTF-16).
1030 * Use stack buffer if the string is
1031 * small enough, else allocate.
1033 if (size <= SMALL_CONV) {
1034 cbufalloc = 0;
1035 outlen = SMALL_CONV;
1036 cbuf = convbuf;
1037 } else {
1038 outlen = size; /* in utf-16 characters */
1039 cbufalloc = outlen * 2;
1040 cbuf = kmem_alloc(cbufalloc, KM_SLEEP);
1043 inlen = size;
1044 error = uconv_u8tou16((uchar_t *)src, &inlen, cbuf, &outlen,
1045 UCONV_OUT_LITTLE_ENDIAN | UCONV_IGNORE_NULL);
1046 outlen *= 2; /* convert to bytes */
1048 if (!error) {
1049 (void) mb_put_padbyte(mbp); /* align */
1050 error = mb_put_mem(mbp, (char *)cbuf, outlen, MB_MSYSTEM);
1052 if (!error && lenp)
1053 *lenp += outlen;
1055 if (cbufalloc)
1056 kmem_free(cbuf, cbufalloc);
1058 return (error);
1062 smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp, const char *src,
1063 int caseopt)
1065 int error, len;
1068 * Let smb_put_dmem put both the string
1069 * and the terminating null.
1071 len = strlen(src) + 1;
1072 error = smb_put_dmem(mbp, vcp, src, len, caseopt, NULL);
1073 if (error)
1074 return (error);
1076 return (error);