1 /* 2 * Copyright (c) 2000-2001 Boris Popov 3 * All rights reserved. 4 * 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. 19 * 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. 31 * 32 * $Id: smb_subr.c,v 1.27.108.1 2005/06/02 00:55:39 lindak Exp $ 33 */ 34 35 #pragma ident "%Z%%M% %I% %E% SMI" 36 37 #include <sys/param.h> 38 #include <sys/systm.h> 39 #include <sys/kmem.h> 40 #include <sys/proc.h> 41 #include <sys/lock.h> 42 #include <sys/socket.h> 43 #include <sys/isa_defs.h> 44 #include <sys/stream.h> 45 #include <sys/strsun.h> 46 #include <sys/sunddi.h> 47 #include <sys/cmn_err.h> 48 #include <sys/sdt.h> 49 #include <sys/priv.h> 50 #include <sys/u8_textprep.h> 51 52 #include <netsmb/smb_osdep.h> 53 #include <netsmb/smb.h> 54 #include <netsmb/smb_conn.h> 55 #include <netsmb/smb_rq.h> 56 #include <netsmb/smb_subr.h> 57 58 /* 59 * XXX:This conversion might not be fully MS-Compatible 60 * for calculating hashes. The output length may differ 61 * for some locales and needs to be handled from where 62 * the call is made. 63 */ 64 int 65 smb_toupper(const char *inbuf, char *outbuf, size_t outlen) 66 { 67 int err = 0; 68 size_t inlen, inrem, outrem; 69 70 inrem = inlen = strlen(inbuf); 71 outrem = outlen; 72 (void) u8_textprep_str((char *)inbuf, &inrem, outbuf, &outrem, 73 U8_TEXTPREP_TOUPPER, U8_UNICODE_LATEST, &err); 74 /* inrem, outrem are bytes unused, remaining */ 75 if (inrem) { 76 SMBSDEBUG("input %d remains: %s\n", (int)inrem, inbuf); 77 inlen -= inrem; 78 } 79 if (outrem) { 80 outlen -= outrem; 81 outbuf[outlen] = '\0'; 82 } 83 if (outlen > inlen) { 84 SMBSDEBUG("outlen > inlen! (%d > %d)\n", 85 (int)outlen, (int)inlen); 86 /* Truncate to inlen here? */ 87 } 88 89 return (err); 90 } 91 92 void 93 smb_credinit(struct smb_cred *scred, struct proc *p, cred_t *icr) 94 { 95 scred->vc_pid = p->p_pidp->pid_id; 96 if (!icr) 97 icr = p->p_cred; 98 if (is_system_labeled()) { 99 icr = crdup(icr); 100 (void) setpflags(NET_MAC_AWARE, 1, icr); 101 } else { 102 crhold(icr); 103 } 104 scred->vc_ucred = icr; 105 } 106 107 void 108 smb_credrele(struct smb_cred *scred) 109 { 110 crfree(scred->vc_ucred); 111 scred->vc_ucred = NULL; 112 } 113 114 #ifdef APPLE 115 /*ARGSUSED*/ 116 int 117 smb_sigintr(vfs_context_t vfsctx) 118 { 119 /* 120 * I cannot find something to match vfs_context_issignal. 121 * It calls proc_pendingsignals() in Darwin code. 122 */ 123 if (vfsctx && vfs_context_issignal(vfsctx, SMB_SIGMASK)) 124 return (EINTR); 125 return (0); 126 } 127 #endif 128 129 char * 130 smb_strdup(const char *s) 131 { 132 char *p; 133 int len; 134 135 len = s ? strlen(s) + 1 : 1; 136 p = kmem_alloc(len, KM_SLEEP); 137 if (s) 138 bcopy(s, p, len); 139 else 140 *p = 0; 141 return (p); 142 } 143 144 /* 145 * duplicate string from a user space. 146 */ 147 char * 148 smb_strdupin(char *s, int maxlen) 149 { 150 char *p, bt; 151 int len = 0; 152 153 for (p = s; ; p++) { 154 if (copyin(p, &bt, 1)) 155 return (NULL); 156 len++; 157 if (maxlen && len > maxlen) 158 return (NULL); 159 if (bt == 0) 160 break; 161 } 162 p = kmem_alloc(len, KM_SLEEP); 163 copyin(s, p, len); 164 return (p); 165 } 166 167 /* 168 * duplicate memory block from a user space. 169 */ 170 void * 171 smb_memdupin(void *umem, int len) 172 { 173 char *p; 174 175 if (len > 32 * 1024) 176 return (NULL); 177 p = kmem_alloc(len, KM_SLEEP); 178 if (copyin(umem, p, len) == 0) 179 return (p); 180 kmem_free(p, len); 181 return (NULL); 182 } 183 184 /* 185 * duplicate memory block in the kernel space. 186 */ 187 void * 188 smb_memdup(const void *umem, int len) 189 { 190 char *p; 191 192 if (len > 32 * 1024) 193 return (NULL); 194 p = kmem_alloc(len, KM_SLEEP); 195 if (p == NULL) 196 return (NULL); 197 bcopy(umem, p, len); 198 return (p); 199 } 200 201 void 202 smb_strfree(char *s) 203 { 204 kmem_free(s, strlen(s) + 1); 205 } 206 207 void 208 smb_memfree(void *s) 209 { 210 kmem_free(s, strlen(s)); 211 } 212 213 void * 214 smb_zmalloc(unsigned long size) 215 { 216 void *p = kmem_zalloc(size, KM_SLEEP); 217 return (p); 218 } 219 220 size_t 221 smb_strtouni(u_int16_t *dst, const char *src, size_t inlen, int flags) 222 { 223 size_t outlen = 0; 224 225 if (!inlen) 226 inlen = strlen(src); 227 228 /* Force output format to little-endian. */ 229 flags &= ~UCONV_OUT_BIG_ENDIAN; 230 flags |= UCONV_OUT_LITTLE_ENDIAN; 231 232 outlen = inlen * 2; 233 if (uconv_u8tou16((uchar_t *)src, &inlen, dst, &outlen, flags) != 0) { 234 outlen = 0; 235 } 236 return (outlen * 2); 237 } 238 239 /* 240 * Helper for the SMBERROR macro, etc. 241 * This is also a good place for a breakpoint 242 * or a dtrace probe, i.e. fbt:nsmb:smb_errmsg 243 */ 244 void 245 smb_errmsg(int cel, const char *func_name, const char *fmt, ...) 246 { 247 va_list adx; 248 char buf[100]; 249 250 va_start(adx, fmt); 251 if (cel == CE_CONT) { 252 /* 253 * This is one of our xxxDEBUG macros. 254 * Don't bother to log these, but just 255 * fire a dtrace probe with the message. 256 */ 257 vsnprintf(buf, sizeof (buf), fmt, adx); 258 DTRACE_PROBE2(debugmsg2, 259 (char *), func_name, 260 (char *), buf); 261 } else { 262 /* 263 * This is one of our xxxERROR macros. 264 * Add a prefix to the fmt string, 265 * then let vcmn_err do the args. 266 */ 267 snprintf(buf, sizeof (buf), "?%s: %s", func_name, fmt); 268 DTRACE_PROBE3(debugmsg3, 269 (char *), func_name, 270 (char *), buf, 271 va_list, adx); 272 vcmn_err(cel, buf, adx); 273 } 274 va_end(adx); 275 } 276 277 #if 1 /* def SMB_SOCKETDATA_DEBUG */ 278 void 279 m_dumpm(mblk_t *m) 280 { 281 int len, seg; 282 283 len = msgdsize(m); 284 DTRACE_PROBE2(dsize, int, len, (mblk_t *), m); 285 286 for (seg = 0; m; seg++) { 287 DTRACE_PROBE2(mblk, int, seg, (mblk_t *), m); 288 m = m->b_cont; 289 } 290 } 291 #endif 292 293 /* all these need review XXX */ 294 #ifndef EPROTO 295 #define EPROTO ECONNABORTED 296 #endif 297 #ifndef ELIBACC 298 #define ELIBACC ENOENT 299 #endif 300 #ifndef ENODATA 301 #define ENODATA EINVAL 302 #endif 303 #ifndef ENOTUNIQ 304 #define ENOTUNIQ EADDRINUSE 305 #endif 306 #ifndef ECOMM 307 #define ECOMM EIO 308 #endif 309 #ifndef ENOMEDIUM 310 #define ENOMEDIUM EIO 311 #endif 312 #ifndef ETIME 313 #define ETIME ETIMEDOUT 314 #endif 315 316 static struct { 317 unsigned nterr; 318 unsigned errno; 319 } nt2errno[] = { 320 {NT_STATUS_ACCESS_DENIED, EACCES}, 321 {NT_STATUS_ACCESS_VIOLATION, EACCES}, 322 {NT_STATUS_ACCOUNT_DISABLED, EACCES}, 323 {NT_STATUS_ACCOUNT_RESTRICTION, EACCES}, 324 {NT_STATUS_ADDRESS_ALREADY_EXISTS, EADDRINUSE}, 325 {NT_STATUS_BAD_NETWORK_NAME, ENOENT}, 326 {NT_STATUS_BUFFER_TOO_SMALL, EMOREDATA}, 327 {NT_STATUS_CANNOT_DELETE, EACCES}, 328 {NT_STATUS_CONFLICTING_ADDRESSES, EADDRINUSE}, 329 {NT_STATUS_CONNECTION_ABORTED, ECONNABORTED}, 330 {NT_STATUS_CONNECTION_DISCONNECTED, ECONNABORTED}, 331 {NT_STATUS_CONNECTION_REFUSED, ECONNREFUSED}, 332 {NT_STATUS_CONNECTION_RESET, ENETRESET}, 333 {NT_STATUS_DEVICE_DOES_NOT_EXIST, ENODEV}, 334 {NT_STATUS_DEVICE_PROTOCOL_ERROR, EPROTO}, 335 {NT_STATUS_DIRECTORY_NOT_EMPTY, ENOTEMPTY}, 336 {NT_STATUS_DISK_FULL, ENOSPC}, 337 {NT_STATUS_DLL_NOT_FOUND, ELIBACC}, 338 {NT_STATUS_END_OF_FILE, ENODATA}, 339 {NT_STATUS_FILE_IS_A_DIRECTORY, EISDIR}, 340 {NT_STATUS_FLOAT_INEXACT_RESULT, ERANGE}, 341 {NT_STATUS_FLOAT_OVERFLOW, ERANGE}, 342 {NT_STATUS_FLOAT_UNDERFLOW, ERANGE}, 343 {NT_STATUS_HOST_UNREACHABLE, EHOSTUNREACH}, 344 {NT_STATUS_ILL_FORMED_PASSWORD, EACCES}, 345 {NT_STATUS_INTEGER_OVERFLOW, ERANGE}, 346 {NT_STATUS_INVALID_HANDLE, EBADF}, 347 {NT_STATUS_INVALID_LOGON_HOURS, EACCES}, 348 {NT_STATUS_INVALID_PARAMETER, EINVAL}, 349 {NT_STATUS_INVALID_PIPE_STATE, EPIPE}, 350 {NT_STATUS_INVALID_WORKSTATION, EACCES}, 351 {NT_STATUS_IN_PAGE_ERROR, EFAULT}, 352 {NT_STATUS_IO_TIMEOUT, ETIMEDOUT}, 353 {NT_STATUS_IP_ADDRESS_CONFLICT1, ENOTUNIQ}, 354 {NT_STATUS_IP_ADDRESS_CONFLICT2, ENOTUNIQ}, 355 {NT_STATUS_LICENSE_QUOTA_EXCEEDED, EDQUOT}, 356 {NT_STATUS_LOGON_FAILURE, EACCES}, 357 {NT_STATUS_MEDIA_WRITE_PROTECTED, EROFS}, 358 {NT_STATUS_MEMORY_NOT_ALLOCATED, EFAULT}, 359 {NT_STATUS_NAME_TOO_LONG, ENAMETOOLONG}, 360 {NT_STATUS_NETWORK_ACCESS_DENIED, EACCES}, 361 {NT_STATUS_NETWORK_BUSY, EBUSY}, 362 {NT_STATUS_NETWORK_UNREACHABLE, ENETUNREACH}, 363 {NT_STATUS_NET_WRITE_FAULT, ECOMM}, 364 {NT_STATUS_NONEXISTENT_SECTOR, ESPIPE}, 365 {NT_STATUS_NOT_A_DIRECTORY, ENOTDIR}, 366 {NT_STATUS_NOT_IMPLEMENTED, ENOSYS}, 367 {NT_STATUS_NOT_MAPPED_VIEW, EINVAL}, 368 {NT_STATUS_NOT_SUPPORTED, ENOSYS}, 369 {NT_STATUS_NO_MEDIA, ENOMEDIUM}, 370 {NT_STATUS_NO_MEDIA_IN_DEVICE, ENOMEDIUM}, 371 {NT_STATUS_NO_MEMORY, ENOMEM}, 372 {NT_STATUS_NO_SUCH_DEVICE, ENODEV}, 373 {NT_STATUS_NO_SUCH_FILE, ENOENT}, 374 {NT_STATUS_OBJECT_NAME_COLLISION, EEXIST}, 375 {NT_STATUS_OBJECT_NAME_NOT_FOUND, ENOENT}, 376 {NT_STATUS_OBJECT_PATH_INVALID, ENOTDIR}, 377 {NT_STATUS_PAGEFILE_QUOTA, EDQUOT}, 378 {NT_STATUS_PASSWORD_EXPIRED, EACCES}, 379 {NT_STATUS_PASSWORD_RESTRICTION, EACCES}, 380 {NT_STATUS_PATH_NOT_COVERED, ENOENT}, 381 {NT_STATUS_PIPE_BROKEN, EPIPE}, 382 {NT_STATUS_PIPE_BUSY, EPIPE}, 383 {NT_STATUS_PIPE_CONNECTED, EISCONN}, 384 {NT_STATUS_PIPE_DISCONNECTED, EPIPE}, 385 {NT_STATUS_PIPE_NOT_AVAILABLE, ENOSYS}, 386 {NT_STATUS_PORT_CONNECTION_REFUSED, ECONNREFUSED}, 387 {NT_STATUS_PORT_MESSAGE_TOO_LONG, EMSGSIZE}, 388 {NT_STATUS_PORT_UNREACHABLE, EHOSTUNREACH}, 389 {NT_STATUS_PROTOCOL_UNREACHABLE, ENOPROTOOPT}, 390 {NT_STATUS_QUOTA_EXCEEDED, EDQUOT}, 391 {NT_STATUS_REGISTRY_QUOTA_LIMIT, EDQUOT}, 392 {NT_STATUS_REMOTE_DISCONNECT, ESHUTDOWN}, 393 {NT_STATUS_REMOTE_NOT_LISTENING, ECONNREFUSED}, 394 {NT_STATUS_REQUEST_NOT_ACCEPTED, EACCES}, 395 {NT_STATUS_RETRY, EAGAIN}, 396 {NT_STATUS_SHARING_VIOLATION, EBUSY}, 397 {NT_STATUS_TIMER_NOT_CANCELED, ETIME}, 398 {NT_STATUS_TOO_MANY_LINKS, EMLINK}, 399 {NT_STATUS_TOO_MANY_OPENED_FILES, EMFILE}, 400 {NT_STATUS_UNABLE_TO_FREE_VM, EADDRINUSE}, 401 {NT_STATUS_UNSUCCESSFUL, EINVAL}, 402 {NT_STATUS_WRONG_PASSWORD, EACCES}, 403 {0, 0} 404 }; 405 406 static struct { 407 unsigned dclass; 408 unsigned derr; 409 unsigned nterr; 410 } nt2doserr[] = { 411 {ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, 412 {ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, 413 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_INFO_CLASS}, 414 {ERRDOS, ERRbadlength, NT_STATUS_INFO_LENGTH_MISMATCH}, 415 {ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, 416 {ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, 417 {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, 418 {ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, 419 {ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, 420 {ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, 421 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_CID}, 422 {ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, 423 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER}, 424 {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, 425 {ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, 426 {ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, 427 {ERRDOS, ERRhandleeof, NT_STATUS_END_OF_FILE}, 428 {ERRDOS, ERRwrongdisk, NT_STATUS_WRONG_VOLUME}, 429 {ERRDOS, ERRnotready, NT_STATUS_NO_MEDIA_IN_DEVICE}, 430 {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, 431 {ERRDOS, ERRsectornotfound, NT_STATUS_NONEXISTENT_SECTOR}, 432 {ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, 433 {ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, 434 {ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, 435 {ERRDOS, ERRinvalidparam, NT_STATUS_UNABLE_TO_FREE_VM}, 436 {ERRDOS, ERRinvalidparam, NT_STATUS_UNABLE_TO_DELETE_SECTION}, 437 {ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, 438 {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, 439 {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, 440 {ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, 441 {ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, 442 {ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED}, 443 {ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, 444 {ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, 445 {ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, 446 {ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, 447 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, 448 {ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, 449 {ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, 450 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, 451 {ERRDOS, 158, NT_STATUS_NOT_LOCKED}, 452 {ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, 453 {ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, 454 {ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, 455 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, 456 {ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, 457 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_MIX}, 458 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, 459 {ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, 460 {ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID}, 461 {ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, 462 {ERRDOS, 183, NT_STATUS_OBJECT_NAME_COLLISION}, 463 {ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, 464 {ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, 465 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, 466 {ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, 467 {ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, 468 {ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, 469 {ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, 470 {ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, 471 {ERRDOS, ERRcrc, NT_STATUS_DATA_ERROR}, 472 {ERRDOS, ERRcrc, NT_STATUS_CRC_ERROR}, 473 {ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, 474 {ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, 475 {ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, 476 {ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, 477 {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, 478 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PAGE_PROTECTION}, 479 {ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, 480 {ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, 481 {ERRDOS, ERRinvalidparam, NT_STATUS_PORT_ALREADY_SET}, 482 {ERRDOS, ERRinvalidparam, NT_STATUS_SECTION_NOT_IMAGE}, 483 {ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, 484 {ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, 485 {ERRDOS, ERRinvalidparam, NT_STATUS_BAD_WORKING_SET_LIMIT}, 486 {ERRDOS, ERRinvalidparam, NT_STATUS_INCOMPATIBLE_FILE_MAP}, 487 {ERRDOS, ERRinvalidparam, NT_STATUS_SECTION_PROTECTION}, 488 {ERRDOS, 282, NT_STATUS_EAS_NOT_SUPPORTED}, 489 {ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, 490 {ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, 491 {ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, 492 {ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, 493 {ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, 494 {ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, 495 {ERRDOS, ERRnoaccess, NT_STATUS_DELETE_PENDING}, 496 {ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, 497 {ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, 498 {ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, 499 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, 500 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, 501 {ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, 502 {ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, 503 {ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, 504 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, 505 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, 506 {ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD}, 507 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, 508 {ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS}, 509 {ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, 510 {ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, 511 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, 512 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, 513 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, 514 {ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN}, 515 {ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, 516 {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, 517 {ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, 518 {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, 519 {ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, 520 {ERRSRV, 2241, NT_STATUS_INVALID_LOGON_HOURS}, 521 {ERRSRV, 2240, NT_STATUS_INVALID_WORKSTATION}, 522 {ERRSRV, 2242, NT_STATUS_PASSWORD_EXPIRED}, 523 {ERRSRV, 2239, NT_STATUS_ACCOUNT_DISABLED}, 524 {ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, 525 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, 526 {ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, 527 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, 528 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, 529 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, 530 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, 531 {ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, 532 {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, 533 {ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, 534 {ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, 535 {ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, 536 {ERRDOS, 112, NT_STATUS_DISK_FULL}, 537 {ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, 538 {ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, 539 {ERRDOS, ERRtoomanynames, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, 540 {ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, 541 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, 542 {ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, 543 {ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, 544 {ERRDOS, ERRoutofmem, NT_STATUS_SECTION_NOT_EXTENDED}, 545 {ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, 546 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, 547 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, 548 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, 549 {ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, 550 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, 551 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, 552 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, 553 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, 554 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, 555 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, 556 {ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, 557 {ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, 558 {ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, 559 {ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, 560 {ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, 561 {ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, 562 {ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED}, 563 {ERRDOS, ERRnomem, NT_STATUS_INSUFFICIENT_RESOURCES}, 564 {ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, 565 {ERRDOS, ERRcrc, NT_STATUS_DEVICE_DATA_ERROR}, 566 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, 567 {ERRDOS, ERRnotready, NT_STATUS_DEVICE_POWER_FAILURE}, 568 {ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, 569 {ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, 570 {ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, 571 {ERRDOS, ERRwriteprotect, NT_STATUS_MEDIA_WRITE_PROTECTED}, 572 {ERRDOS, ERRnotready, NT_STATUS_DEVICE_NOT_READY}, 573 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, 574 {ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, 575 {ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, 576 {ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, 577 {ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, 578 {ERRDOS, ERRinvalidparam, NT_STATUS_BAD_MASTER_BOOT_RECORD}, 579 {ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, 580 {ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, 581 {ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, 582 {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, 583 {ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, 584 {ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, 585 {ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, 586 {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, 587 {ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, 588 {ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, 589 {ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, 590 {ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, 591 {ERRDOS, ERRhandleeof, NT_STATUS_FILE_FORCED_CLOSED}, 592 {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, 593 {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, 594 {ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, 595 {ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, 596 {ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, 597 {ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, 598 {ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, 599 {ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, 600 {ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, 601 {ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, 602 {ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, 603 {ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, 604 {ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, 605 {ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, 606 {ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, 607 {ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, 608 {ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, 609 {ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, 610 {ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, 611 {ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, 612 {ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, 613 {ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, 614 {ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, 615 {ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, 616 {ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, 617 {ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, 618 {ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, 619 {ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, 620 {ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, 621 {ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, 622 {ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, 623 {ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, 624 {ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, 625 {ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, 626 {ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, 627 {ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, 628 {ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, 629 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, 630 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, 631 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, 632 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, 633 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, 634 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, 635 {ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, 636 {ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, 637 {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, 638 {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, 639 {ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, 640 {ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, 641 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, 642 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, 643 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, 644 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, 645 {ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, 646 {ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, 647 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, 648 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_1}, 649 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_2}, 650 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_3}, 651 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_4}, 652 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_5}, 653 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_6}, 654 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_7}, 655 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_8}, 656 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_9}, 657 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_10}, 658 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_11}, 659 {ERRDOS, ERRinvalidparam, NT_STATUS_INVALID_PARAMETER_12}, 660 {ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, 661 {ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, 662 {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, 663 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, 664 {ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, 665 {ERRDOS, 203, NT_STATUS_VARIABLE_NOT_FOUND}, 666 {ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, 667 {ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, 668 {ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, 669 {ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, 670 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, 671 {ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, 672 {ERRDOS, 2401, NT_STATUS_FILES_OPEN}, 673 {ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, 674 {ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, 675 {ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, 676 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, 677 {ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, 678 {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, 679 {ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, 680 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, 681 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, 682 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, 683 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, 684 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, 685 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, 686 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, 687 {ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, 688 {ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, 689 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, 690 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, 691 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, 692 {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, 693 {ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, 694 {ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, 695 {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, 696 {ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, 697 {ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, 698 {ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, 699 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, 700 {ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, 701 {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, 702 {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, 703 {ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, 704 {ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, 705 {ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, 706 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, 707 {ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, 708 {ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, 709 {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, 710 {ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, 711 {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, 712 {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, 713 {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, 714 {ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, 715 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, 716 {ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, 717 {ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, 718 {ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, 719 {ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, 720 {ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, 721 {ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, 722 {ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, 723 {ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, 724 {ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, 725 {ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, 726 {ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, 727 {ERRDOS, 59, NT_STATUS_LINK_FAILED}, 728 {ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, 729 {ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, 730 {ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, 731 {ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, 732 {ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, 733 {ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, 734 {ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, 735 {ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, 736 {ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, 737 {ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, 738 {ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, 739 {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, 740 {ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, 741 {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, 742 {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, 743 {ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, 744 {ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, 745 {ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, 746 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, 747 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, 748 {ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, 749 {ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, 750 {ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, 751 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, 752 {ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, 753 {ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, 754 {ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, 755 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, 756 {ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, 757 {ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, 758 {ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, 759 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, 760 {ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, 761 {ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, 762 {ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, 763 {ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, 764 {ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, 765 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, 766 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, 767 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, 768 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, 769 {ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, 770 {ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, 771 {ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, 772 {ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, 773 {ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, 774 {ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, 775 {ERRHRD, ERRgeneral, NT_STATUS_BIOS_FAILED_TO_CONNECT_INTERRUPT}, 776 {ERRHRD, ERRgeneral, NT_STATUS_16F}, 777 {ERRHRD, ERRgeneral, NT_STATUS_170}, 778 {ERRHRD, ERRgeneral, NT_STATUS_171}, 779 {ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, 780 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, 781 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, 782 {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, 783 {ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, 784 {ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, 785 {ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, 786 {ERRHRD, ERRgeneral, NT_STATUS_179}, 787 {ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, 788 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, 789 {ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, 790 {ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, 791 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, 792 {ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, 793 {ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, 794 {ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, 795 {ERRDOS, ERRinvalidparam, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, 796 {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, 797 {ERRDOS, ERRbadcmd, NT_STATUS_INVALID_DEVICE_STATE}, 798 {ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, 799 {ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, 800 {ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, 801 {ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, 802 {ERRDOS, ERRwriteprotect, NT_STATUS_TOO_LATE}, 803 {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET}, 804 {ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, 805 {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, 806 {ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, 807 {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, 808 {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, 809 {ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, 810 {ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, 811 {ERRDOS, ERRinvgroup, NT_STATUS_NETLOGON_NOT_STARTED}, 812 {ERRSRV, 2239, NT_STATUS_ACCOUNT_EXPIRED}, 813 {ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, 814 {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, 815 {ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, 816 {ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, 817 {ERRDOS, ERRnoaccess, 818 NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, 819 {ERRDOS, ERRnoaccess, 820 NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, 821 {ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT}, 822 {ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, 823 {ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, 824 {ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, 825 {ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, 826 {ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, 827 {ERRDOS, ERRnomem, NT_STATUS_INSUFF_SERVER_RESOURCES}, 828 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, 829 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, 830 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, 831 {ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, 832 {ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, 833 {ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, 834 {ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, 835 {ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, 836 {ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, 837 {ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, 838 {ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, 839 {ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, 840 {ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, 841 {ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, 842 {ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, 843 {ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, 844 {ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, 845 {ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, 846 {ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, 847 {ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, 848 {ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, 849 {ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, 850 {ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, 851 {ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, 852 {ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, 853 {ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, 854 {ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, 855 {ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, 856 {ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, 857 {ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, 858 {ERRSRV, 2242, NT_STATUS_PASSWORD_MUST_CHANGE}, 859 {ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, 860 {ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, 861 {ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, 862 {ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, 863 {ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, 864 {ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, 865 {ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, 866 {ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, 867 {ERRHRD, ERRgeneral, NT_STATUS_RETRY}, 868 {ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, 869 {ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, 870 {ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, 871 {ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, 872 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, 873 {ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, 874 {ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, 875 {ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, 876 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, 877 {ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, 878 {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, 879 {ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, 880 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, 881 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, 882 {ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, 883 {ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, 884 {ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, 885 {ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, 886 {ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, 887 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, 888 {ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, 889 {ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, 890 {ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, 891 {ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, 892 {ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, 893 {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, 894 {ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, 895 {ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, 896 {ERRHRD, ERRgeneral, 0x000024a}, 897 {ERRHRD, ERRgeneral, 0x000024b}, 898 {ERRHRD, ERRgeneral, 0x000024c}, 899 {ERRHRD, ERRgeneral, 0x000024d}, 900 {ERRHRD, ERRgeneral, 0x000024e}, 901 {ERRHRD, ERRgeneral, 0x000024f}, 902 {ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, 903 {ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, 904 {ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, 905 {ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, 906 {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, 907 {ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, 908 {ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, 909 {ERRSRV, ERRbadtype, NT_STATUS_PATH_NOT_COVERED}, 910 {ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, 911 {ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, 912 {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, 913 {ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, 914 {ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, 915 {ERRHRD, ERRgeneral, 0x000025d}, 916 {ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, 917 {ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, 918 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, 919 {ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, 920 {ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, 921 {ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, 922 {ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, 923 {ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LINKS}, 924 {ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, 925 {ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, 926 {ERRDOS, ERRnotready, NT_STATUS_VOLUME_DISMOUNTED}, 927 {ERRDOS, 161, NT_STATUS_DIRECTORY_IS_A_REPARSE_POINT}, 928 {ERRDOS, ERRnoaccess, NT_STATUS_ENCRYPTION_FAILED}, 929 {ERRDOS, ERRnoaccess, NT_STATUS_DECRYPTION_FAILED}, 930 {ERRHRD, ERRgeneral, NT_STATUS_RANGE_NOT_FOUND}, 931 {ERRDOS, ERRnoaccess, NT_STATUS_NO_RECOVERY_POLICY}, 932 {ERRDOS, ERRnoaccess, NT_STATUS_NO_EFS}, 933 {ERRDOS, ERRnoaccess, NT_STATUS_WRONG_EFS}, 934 {ERRDOS, ERRnoaccess, NT_STATUS_NO_USER_KEYS}, 935 {ERRDOS, ERRbadfunc, NT_STATUS_VOLUME_NOT_UPGRADED}, 936 }; 937 938 u_int32_t 939 smb_maperr32(u_int32_t eno) 940 { 941 int i; 942 unsigned orig = eno; 943 944 /* 945 * Hi two bits are "severity". Ignore "success" (0) and 946 * "informational" (1) values. 947 */ 948 if (!(eno & 0x80000000)) 949 return (0); 950 /* mask off "severity" and the "component" bit */ 951 eno &= ~(0xe0000000); 952 953 /* first try direct map to unix */ 954 for (i = 0; nt2errno[i].errno; i++) 955 if (nt2errno[i].nterr == eno) 956 return (nt2errno[i].errno); 957 SMBERROR("no direct map for 32 bit server error (0x%x)\n", orig); 958 959 /* ok, then try mapping to dos to unix */ 960 for (i = 0; nt2doserr[i].derr; i++) 961 if (nt2doserr[i].nterr == eno) 962 return (smb_maperror(nt2doserr[i].dclass, 963 nt2doserr[i].derr)); 964 return (smb_maperror(ERRHRD, ERRgeneral)); 965 } 966 967 968 int 969 smb_maperror(int eclass, int eno) 970 { 971 if (eclass == 0 && eno == 0) 972 return (0); 973 switch (eclass) { 974 case ERRDOS: 975 switch (eno) { 976 case ERRbadfunc: 977 case ERRbadenv: 978 case ERRbadformat: 979 case ERRremcd: 980 case ERRrmuns: 981 return (EINVAL); 982 case ERRbadfile: 983 case ERRbadpath: 984 case ERRnoipc: 985 case ERRnosuchshare: 986 return (ENOENT); 987 case ERRnofids: 988 return (EMFILE); 989 case ERRnoaccess: 990 /* 991 * XXX CSM Reported on samba-technical 12/7/2002 992 * 993 * There is a case for which server(s) return 994 * ERRnoaccess but should return ERRdiskfull: When 995 * the offset for a write is exactly the server 996 * file size limit then Samba (at least) thinks 997 * the reason for zero bytes having been written 998 * must have been "access denied" from the local 999 * filesystem. This cannot be easily worked 1000 * around since the server behaviour is 1001 * indistinguishable from actual access denied. 1002 * An incomplete workaround: attempt a 2 byte write 1003 * from "offset-1". (That may require reading at 1004 * offset-1 first.) The flaw is that reading or 1005 * writing at offset-1 could cause an 1006 * unrelated error (due to a byte range lock 1007 * for instance) and we can't presume the 1008 * order servers check errors in. 1009 */ 1010 case ERRbadaccess: 1011 return (EACCES); 1012 case ERRbadshare: 1013 return (EBUSY); 1014 case ERRbadfid: 1015 return (EBADF); 1016 case ERRbadmcb: 1017 return (EIO); 1018 case ERRnomem: 1019 return (ENOMEM); /* actually remote no mem... */ 1020 case ERRbadmem: 1021 return (EFAULT); 1022 case ERRbaddata: 1023 return (E2BIG); 1024 case ERRbaddrive: 1025 case ERRnotready: /* nt */ 1026 return (ENXIO); 1027 case ERRdiffdevice: 1028 return (EXDEV); 1029 case ERRnofiles: 1030 return (0); /* eeof ? */ 1031 case ERRlock: 1032 return (EDEADLK); 1033 case ERRfilexists: 1034 return (EEXIST); 1035 case ERRinvalidname: /* samba maps as noent */ 1036 return (ENOENT); 1037 case ERRdirnotempty: /* samba */ 1038 return (ENOTEMPTY); 1039 case ERRnotlocked: 1040 return (0); /* 0 since bsd unlocks on any close */ 1041 case ERRrename: 1042 return (EEXIST); 1043 case ERRmoredata: 1044 return (EMOREDATA); 1045 } 1046 break; 1047 case ERRSRV: 1048 switch (eno) { 1049 case ERRerror: 1050 return (EINVAL); 1051 case ERRbadpw: 1052 return (EAUTH); 1053 case ERRaccess: 1054 case ERRbaduid: 1055 return (EACCES); 1056 case ERRinvnid: 1057 return (ENETRESET); 1058 case ERRinvnetname: 1059 SMBERROR("NetBIOS name is invalid: %d\n", 1060 ERRinvnetname); 1061 return (EAUTH); 1062 case ERRbadtype: /* reserved and returned */ 1063 return (EIO); 1064 case ERRacctexpired: /* NT: account exists but disabled */ 1065 return (EPERM); 1066 } 1067 break; 1068 case ERRHRD: 1069 switch (eno) { 1070 case ERRnowrite: 1071 return (EROFS); 1072 case ERRbadunit: 1073 return (ENODEV); 1074 case ERRbadreq: 1075 return (EBADRPC); 1076 case ERRbadshare: 1077 return (ETXTBSY); 1078 case ERRlock: 1079 return (EDEADLK); 1080 case ERRdiskfull: 1081 return (EFBIG); 1082 case ERRnotready: 1083 case ERRbadcmd: 1084 case ERRdata: 1085 case ERRgeneral: 1086 return (EIO); 1087 default: 1088 SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno); 1089 return (EIO); 1090 } 1091 } 1092 SMBERROR("Unmapped DOS error %d:%d\n", eclass, eno); 1093 return (EBADRPC); 1094 } 1095 1096 #if defined(NOICONVSUPPORT) || defined(lint) 1097 extern int iconv_conv(void *handle, const char **inbuf, 1098 size_t *inbytesleft, char **outbuf, size_t *outbytesleft); 1099 #endif 1100 1101 #define SMALL_CONV 256 1102 1103 /*ARGSUSED*/ 1104 int 1105 smb_put_dmem(struct mbchain *mbp, struct smb_vc *vcp, const char *src, 1106 int size, int caseopt, int *lenp) 1107 { 1108 uint16_t convbuf[SMALL_CONV]; 1109 uint16_t *cbuf; 1110 size_t cbufalloc, inlen, outlen; 1111 int error; 1112 1113 if (size <= 0) 1114 return (0); 1115 1116 /* 1117 * Handle the easy case (non-unicode). 1118 * XXX: Technically, we should convert 1119 * the string to OEM codeset first... 1120 * Modern servers all use Unicode, so 1121 * this is good enough. 1122 */ 1123 if (SMB_UNICODE_STRINGS(vcp) == 0) { 1124 error = mb_put_mem(mbp, src, size, MB_MSYSTEM); 1125 if (!error && lenp) 1126 *lenp += size; 1127 return (error); 1128 } 1129 1130 /* 1131 * Convert to UCS-2 (really UTF-16). 1132 * Use stack buffer if the string is 1133 * small enough, else allocate. 1134 */ 1135 if (size <= SMALL_CONV) { 1136 cbufalloc = 0; 1137 outlen = SMALL_CONV; 1138 cbuf = convbuf; 1139 } else { 1140 outlen = size; /* in utf-16 characters */ 1141 cbufalloc = outlen * 2; 1142 cbuf = kmem_alloc(cbufalloc, KM_SLEEP); 1143 } 1144 1145 inlen = size; 1146 error = uconv_u8tou16((uchar_t *)src, &inlen, cbuf, &outlen, 1147 UCONV_OUT_LITTLE_ENDIAN | UCONV_IGNORE_NULL); 1148 outlen *= 2; /* convert to bytes */ 1149 1150 if (!error) { 1151 (void) mb_put_padbyte(mbp); /* align */ 1152 error = mb_put_mem(mbp, (char *)cbuf, outlen, MB_MSYSTEM); 1153 } 1154 if (!error && lenp) 1155 *lenp += outlen; 1156 1157 if (cbufalloc) 1158 kmem_free(cbuf, cbufalloc); 1159 1160 return (error); 1161 } 1162 1163 int 1164 smb_put_dstring(struct mbchain *mbp, struct smb_vc *vcp, const char *src, 1165 int caseopt) 1166 { 1167 int error, len; 1168 1169 /* 1170 * Let smb_put_dmem put both the string 1171 * and the terminating null. 1172 */ 1173 len = strlen(src) + 1; 1174 error = smb_put_dmem(mbp, vcp, src, len, caseopt, NULL); 1175 if (error) 1176 return (error); 1177 1178 return (error); 1179 } 1180