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