18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *   fs/cifs/netmisc.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *   Copyright (c) International Business Machines  Corp., 2002,2008
68c2ecf20Sopenharmony_ci *   Author(s): Steve French (sfrench@us.ibm.com)
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci *   Error mapping routines from Samba libsmb/errormap.c
98c2ecf20Sopenharmony_ci *   Copyright (C) Andrew Tridgell 2001
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#include <linux/net.h>
138c2ecf20Sopenharmony_ci#include <linux/string.h>
148c2ecf20Sopenharmony_ci#include <linux/in.h>
158c2ecf20Sopenharmony_ci#include <linux/ctype.h>
168c2ecf20Sopenharmony_ci#include <linux/fs.h>
178c2ecf20Sopenharmony_ci#include <asm/div64.h>
188c2ecf20Sopenharmony_ci#include <asm/byteorder.h>
198c2ecf20Sopenharmony_ci#include <linux/inet.h>
208c2ecf20Sopenharmony_ci#include "cifsfs.h"
218c2ecf20Sopenharmony_ci#include "cifspdu.h"
228c2ecf20Sopenharmony_ci#include "cifsglob.h"
238c2ecf20Sopenharmony_ci#include "cifsproto.h"
248c2ecf20Sopenharmony_ci#include "smberr.h"
258c2ecf20Sopenharmony_ci#include "cifs_debug.h"
268c2ecf20Sopenharmony_ci#include "nterr.h"
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cistruct smb_to_posix_error {
298c2ecf20Sopenharmony_ci	__u16 smb_err;
308c2ecf20Sopenharmony_ci	int posix_code;
318c2ecf20Sopenharmony_ci};
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic const struct smb_to_posix_error mapping_table_ERRDOS[] = {
348c2ecf20Sopenharmony_ci	{ERRbadfunc, -EINVAL},
358c2ecf20Sopenharmony_ci	{ERRbadfile, -ENOENT},
368c2ecf20Sopenharmony_ci	{ERRbadpath, -ENOTDIR},
378c2ecf20Sopenharmony_ci	{ERRnofids, -EMFILE},
388c2ecf20Sopenharmony_ci	{ERRnoaccess, -EACCES},
398c2ecf20Sopenharmony_ci	{ERRbadfid, -EBADF},
408c2ecf20Sopenharmony_ci	{ERRbadmcb, -EIO},
418c2ecf20Sopenharmony_ci	{ERRnomem, -EREMOTEIO},
428c2ecf20Sopenharmony_ci	{ERRbadmem, -EFAULT},
438c2ecf20Sopenharmony_ci	{ERRbadenv, -EFAULT},
448c2ecf20Sopenharmony_ci	{ERRbadformat, -EINVAL},
458c2ecf20Sopenharmony_ci	{ERRbadaccess, -EACCES},
468c2ecf20Sopenharmony_ci	{ERRbaddata, -EIO},
478c2ecf20Sopenharmony_ci	{ERRbaddrive, -ENXIO},
488c2ecf20Sopenharmony_ci	{ERRremcd, -EACCES},
498c2ecf20Sopenharmony_ci	{ERRdiffdevice, -EXDEV},
508c2ecf20Sopenharmony_ci	{ERRnofiles, -ENOENT},
518c2ecf20Sopenharmony_ci	{ERRwriteprot, -EROFS},
528c2ecf20Sopenharmony_ci	{ERRbadshare, -EBUSY},
538c2ecf20Sopenharmony_ci	{ERRlock, -EACCES},
548c2ecf20Sopenharmony_ci	{ERRunsup, -EINVAL},
558c2ecf20Sopenharmony_ci	{ERRnosuchshare, -ENXIO},
568c2ecf20Sopenharmony_ci	{ERRfilexists, -EEXIST},
578c2ecf20Sopenharmony_ci	{ERRinvparm, -EINVAL},
588c2ecf20Sopenharmony_ci	{ERRdiskfull, -ENOSPC},
598c2ecf20Sopenharmony_ci	{ERRinvname, -ENOENT},
608c2ecf20Sopenharmony_ci	{ERRinvlevel, -EOPNOTSUPP},
618c2ecf20Sopenharmony_ci	{ERRdirnotempty, -ENOTEMPTY},
628c2ecf20Sopenharmony_ci	{ERRnotlocked, -ENOLCK},
638c2ecf20Sopenharmony_ci	{ERRcancelviolation, -ENOLCK},
648c2ecf20Sopenharmony_ci	{ERRalreadyexists, -EEXIST},
658c2ecf20Sopenharmony_ci	{ERRmoredata, -EOVERFLOW},
668c2ecf20Sopenharmony_ci	{ERReasnotsupported, -EOPNOTSUPP},
678c2ecf20Sopenharmony_ci	{ErrQuota, -EDQUOT},
688c2ecf20Sopenharmony_ci	{ErrNotALink, -ENOLINK},
698c2ecf20Sopenharmony_ci	{ERRnetlogonNotStarted, -ENOPROTOOPT},
708c2ecf20Sopenharmony_ci	{ERRsymlink, -EOPNOTSUPP},
718c2ecf20Sopenharmony_ci	{ErrTooManyLinks, -EMLINK},
728c2ecf20Sopenharmony_ci	{0, 0}
738c2ecf20Sopenharmony_ci};
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_cistatic const struct smb_to_posix_error mapping_table_ERRSRV[] = {
768c2ecf20Sopenharmony_ci	{ERRerror, -EIO},
778c2ecf20Sopenharmony_ci	{ERRbadpw, -EACCES},  /* was EPERM */
788c2ecf20Sopenharmony_ci	{ERRbadtype, -EREMOTE},
798c2ecf20Sopenharmony_ci	{ERRaccess, -EACCES},
808c2ecf20Sopenharmony_ci	{ERRinvtid, -ENXIO},
818c2ecf20Sopenharmony_ci	{ERRinvnetname, -ENXIO},
828c2ecf20Sopenharmony_ci	{ERRinvdevice, -ENXIO},
838c2ecf20Sopenharmony_ci	{ERRqfull, -ENOSPC},
848c2ecf20Sopenharmony_ci	{ERRqtoobig, -ENOSPC},
858c2ecf20Sopenharmony_ci	{ERRqeof, -EIO},
868c2ecf20Sopenharmony_ci	{ERRinvpfid, -EBADF},
878c2ecf20Sopenharmony_ci	{ERRsmbcmd, -EBADRQC},
888c2ecf20Sopenharmony_ci	{ERRsrverror, -EIO},
898c2ecf20Sopenharmony_ci	{ERRbadBID, -EIO},
908c2ecf20Sopenharmony_ci	{ERRfilespecs, -EINVAL},
918c2ecf20Sopenharmony_ci	{ERRbadLink, -EIO},
928c2ecf20Sopenharmony_ci	{ERRbadpermits, -EINVAL},
938c2ecf20Sopenharmony_ci	{ERRbadPID, -ESRCH},
948c2ecf20Sopenharmony_ci	{ERRsetattrmode, -EINVAL},
958c2ecf20Sopenharmony_ci	{ERRpaused, -EHOSTDOWN},
968c2ecf20Sopenharmony_ci	{ERRmsgoff, -EHOSTDOWN},
978c2ecf20Sopenharmony_ci	{ERRnoroom, -ENOSPC},
988c2ecf20Sopenharmony_ci	{ERRrmuns, -EUSERS},
998c2ecf20Sopenharmony_ci	{ERRtimeout, -ETIME},
1008c2ecf20Sopenharmony_ci	{ERRnoresource, -EREMOTEIO},
1018c2ecf20Sopenharmony_ci	{ERRtoomanyuids, -EUSERS},
1028c2ecf20Sopenharmony_ci	{ERRbaduid, -EACCES},
1038c2ecf20Sopenharmony_ci	{ERRusempx, -EIO},
1048c2ecf20Sopenharmony_ci	{ERRusestd, -EIO},
1058c2ecf20Sopenharmony_ci	{ERR_NOTIFY_ENUM_DIR, -ENOBUFS},
1068c2ecf20Sopenharmony_ci	{ERRnoSuchUser, -EACCES},
1078c2ecf20Sopenharmony_ci/*	{ERRaccountexpired, -EACCES},
1088c2ecf20Sopenharmony_ci	{ERRbadclient, -EACCES},
1098c2ecf20Sopenharmony_ci	{ERRbadLogonTime, -EACCES},
1108c2ecf20Sopenharmony_ci	{ERRpasswordExpired, -EACCES},*/
1118c2ecf20Sopenharmony_ci	{ERRaccountexpired, -EKEYEXPIRED},
1128c2ecf20Sopenharmony_ci	{ERRbadclient, -EACCES},
1138c2ecf20Sopenharmony_ci	{ERRbadLogonTime, -EACCES},
1148c2ecf20Sopenharmony_ci	{ERRpasswordExpired, -EKEYEXPIRED},
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ci	{ERRnosupport, -EINVAL},
1178c2ecf20Sopenharmony_ci	{0, 0}
1188c2ecf20Sopenharmony_ci};
1198c2ecf20Sopenharmony_ci
1208c2ecf20Sopenharmony_ci/*
1218c2ecf20Sopenharmony_ci * Convert a string containing text IPv4 or IPv6 address to binary form.
1228c2ecf20Sopenharmony_ci *
1238c2ecf20Sopenharmony_ci * Returns 0 on failure.
1248c2ecf20Sopenharmony_ci */
1258c2ecf20Sopenharmony_cistatic int
1268c2ecf20Sopenharmony_cicifs_inet_pton(const int address_family, const char *cp, int len, void *dst)
1278c2ecf20Sopenharmony_ci{
1288c2ecf20Sopenharmony_ci	int ret = 0;
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci	/* calculate length by finding first slash or NULL */
1318c2ecf20Sopenharmony_ci	if (address_family == AF_INET)
1328c2ecf20Sopenharmony_ci		ret = in4_pton(cp, len, dst, '\\', NULL);
1338c2ecf20Sopenharmony_ci	else if (address_family == AF_INET6)
1348c2ecf20Sopenharmony_ci		ret = in6_pton(cp, len, dst , '\\', NULL);
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	cifs_dbg(NOISY, "address conversion returned %d for %*.*s\n",
1378c2ecf20Sopenharmony_ci		 ret, len, len, cp);
1388c2ecf20Sopenharmony_ci	if (ret > 0)
1398c2ecf20Sopenharmony_ci		ret = 1;
1408c2ecf20Sopenharmony_ci	return ret;
1418c2ecf20Sopenharmony_ci}
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci/*
1448c2ecf20Sopenharmony_ci * Try to convert a string to an IPv4 address and then attempt to convert
1458c2ecf20Sopenharmony_ci * it to an IPv6 address if that fails. Set the family field if either
1468c2ecf20Sopenharmony_ci * succeeds. If it's an IPv6 address and it has a '%' sign in it, try to
1478c2ecf20Sopenharmony_ci * treat the part following it as a numeric sin6_scope_id.
1488c2ecf20Sopenharmony_ci *
1498c2ecf20Sopenharmony_ci * Returns 0 on failure.
1508c2ecf20Sopenharmony_ci */
1518c2ecf20Sopenharmony_ciint
1528c2ecf20Sopenharmony_cicifs_convert_address(struct sockaddr *dst, const char *src, int len)
1538c2ecf20Sopenharmony_ci{
1548c2ecf20Sopenharmony_ci	int rc, alen, slen;
1558c2ecf20Sopenharmony_ci	const char *pct;
1568c2ecf20Sopenharmony_ci	char scope_id[13];
1578c2ecf20Sopenharmony_ci	struct sockaddr_in *s4 = (struct sockaddr_in *) dst;
1588c2ecf20Sopenharmony_ci	struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) dst;
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci	/* IPv4 address */
1618c2ecf20Sopenharmony_ci	if (cifs_inet_pton(AF_INET, src, len, &s4->sin_addr.s_addr)) {
1628c2ecf20Sopenharmony_ci		s4->sin_family = AF_INET;
1638c2ecf20Sopenharmony_ci		return 1;
1648c2ecf20Sopenharmony_ci	}
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ci	/* attempt to exclude the scope ID from the address part */
1678c2ecf20Sopenharmony_ci	pct = memchr(src, '%', len);
1688c2ecf20Sopenharmony_ci	alen = pct ? pct - src : len;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	rc = cifs_inet_pton(AF_INET6, src, alen, &s6->sin6_addr.s6_addr);
1718c2ecf20Sopenharmony_ci	if (!rc)
1728c2ecf20Sopenharmony_ci		return rc;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ci	s6->sin6_family = AF_INET6;
1758c2ecf20Sopenharmony_ci	if (pct) {
1768c2ecf20Sopenharmony_ci		/* grab the scope ID */
1778c2ecf20Sopenharmony_ci		slen = len - (alen + 1);
1788c2ecf20Sopenharmony_ci		if (slen <= 0 || slen > 12)
1798c2ecf20Sopenharmony_ci			return 0;
1808c2ecf20Sopenharmony_ci		memcpy(scope_id, pct + 1, slen);
1818c2ecf20Sopenharmony_ci		scope_id[slen] = '\0';
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci		rc = kstrtouint(scope_id, 0, &s6->sin6_scope_id);
1848c2ecf20Sopenharmony_ci		rc = (rc == 0) ? 1 : 0;
1858c2ecf20Sopenharmony_ci	}
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci	return rc;
1888c2ecf20Sopenharmony_ci}
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_civoid
1918c2ecf20Sopenharmony_cicifs_set_port(struct sockaddr *addr, const unsigned short int port)
1928c2ecf20Sopenharmony_ci{
1938c2ecf20Sopenharmony_ci	switch (addr->sa_family) {
1948c2ecf20Sopenharmony_ci	case AF_INET:
1958c2ecf20Sopenharmony_ci		((struct sockaddr_in *)addr)->sin_port = htons(port);
1968c2ecf20Sopenharmony_ci		break;
1978c2ecf20Sopenharmony_ci	case AF_INET6:
1988c2ecf20Sopenharmony_ci		((struct sockaddr_in6 *)addr)->sin6_port = htons(port);
1998c2ecf20Sopenharmony_ci		break;
2008c2ecf20Sopenharmony_ci	}
2018c2ecf20Sopenharmony_ci}
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_ci/*****************************************************************************
2048c2ecf20Sopenharmony_ciconvert a NT status code to a dos class/code
2058c2ecf20Sopenharmony_ci *****************************************************************************/
2068c2ecf20Sopenharmony_ci/* NT status -> dos error map */
2078c2ecf20Sopenharmony_cistatic const struct {
2088c2ecf20Sopenharmony_ci	__u8 dos_class;
2098c2ecf20Sopenharmony_ci	__u16 dos_code;
2108c2ecf20Sopenharmony_ci	__u32 ntstatus;
2118c2ecf20Sopenharmony_ci} ntstatus_to_dos_map[] = {
2128c2ecf20Sopenharmony_ci	{
2138c2ecf20Sopenharmony_ci	ERRDOS, ERRgeneral, NT_STATUS_UNSUCCESSFUL}, {
2148c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfunc, NT_STATUS_NOT_IMPLEMENTED}, {
2158c2ecf20Sopenharmony_ci	ERRDOS, ERRinvlevel, NT_STATUS_INVALID_INFO_CLASS}, {
2168c2ecf20Sopenharmony_ci	ERRDOS, 24, NT_STATUS_INFO_LENGTH_MISMATCH}, {
2178c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ACCESS_VIOLATION}, {
2188c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_IN_PAGE_ERROR}, {
2198c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA}, {
2208c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfid, NT_STATUS_INVALID_HANDLE}, {
2218c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_INITIAL_STACK}, {
2228c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_BAD_INITIAL_PC}, {
2238c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_CID}, {
2248c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TIMER_NOT_CANCELED}, {
2258c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER}, {
2268c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_DEVICE}, {
2278c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfile, NT_STATUS_NO_SUCH_FILE}, {
2288c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfunc, NT_STATUS_INVALID_DEVICE_REQUEST}, {
2298c2ecf20Sopenharmony_ci	ERRDOS, 38, NT_STATUS_END_OF_FILE}, {
2308c2ecf20Sopenharmony_ci	ERRDOS, 34, NT_STATUS_WRONG_VOLUME}, {
2318c2ecf20Sopenharmony_ci	ERRDOS, 21, NT_STATUS_NO_MEDIA_IN_DEVICE}, {
2328c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_MEDIA}, {
2338c2ecf20Sopenharmony_ci	ERRDOS, 27, NT_STATUS_NONEXISTENT_SECTOR},
2348c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
2358c2ecf20Sopenharmony_ci	 from NT_STATUS_MORE_PROCESSING_REQUIRED to NT_STATUS_OK
2368c2ecf20Sopenharmony_ci	 during the session setup } */
2378c2ecf20Sopenharmony_ci	{
2388c2ecf20Sopenharmony_ci	ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY}, {
2398c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_CONFLICTING_ADDRESSES}, {
2408c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_NOT_MAPPED_VIEW}, {
2418c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_UNABLE_TO_FREE_VM}, {
2428c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_UNABLE_TO_DELETE_SECTION}, {
2438c2ecf20Sopenharmony_ci	ERRDOS, 2142, NT_STATUS_INVALID_SYSTEM_SERVICE}, {
2448c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_INSTRUCTION}, {
2458c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_INVALID_LOCK_SEQUENCE}, {
2468c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_INVALID_VIEW_SIZE}, {
2478c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_FILE_FOR_SECTION}, {
2488c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_ALREADY_COMMITTED},
2498c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
2508c2ecf20Sopenharmony_ci	 from NT_STATUS_ACCESS_DENIED to NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE
2518c2ecf20Sopenharmony_ci	 during the session setup }   */
2528c2ecf20Sopenharmony_ci	{
2538c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED}, {
2548c2ecf20Sopenharmony_ci	ERRDOS, 111, NT_STATUS_BUFFER_TOO_SMALL}, {
2558c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfid, NT_STATUS_OBJECT_TYPE_MISMATCH}, {
2568c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NONCONTINUABLE_EXCEPTION}, {
2578c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_DISPOSITION}, {
2588c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNWIND}, {
2598c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_STACK}, {
2608c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_UNWIND_TARGET}, {
2618c2ecf20Sopenharmony_ci	ERRDOS, 158, NT_STATUS_NOT_LOCKED}, {
2628c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PARITY_ERROR}, {
2638c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_UNABLE_TO_DECOMMIT_VM}, {
2648c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_NOT_COMMITTED}, {
2658c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_PORT_ATTRIBUTES}, {
2668c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PORT_MESSAGE_TOO_LONG}, {
2678c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_MIX}, {
2688c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_QUOTA_LOWER}, {
2698c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DISK_CORRUPT_ERROR}, {
2708c2ecf20Sopenharmony_ci	 /* mapping changed since shell does lookup on * expects FileNotFound */
2718c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_INVALID}, {
2728c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfile, NT_STATUS_OBJECT_NAME_NOT_FOUND}, {
2738c2ecf20Sopenharmony_ci	ERRDOS, ERRalreadyexists, NT_STATUS_OBJECT_NAME_COLLISION}, {
2748c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_HANDLE_NOT_WAITABLE}, {
2758c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfid, NT_STATUS_PORT_DISCONNECTED}, {
2768c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DEVICE_ALREADY_ATTACHED}, {
2778c2ecf20Sopenharmony_ci	ERRDOS, 161, NT_STATUS_OBJECT_PATH_INVALID}, {
2788c2ecf20Sopenharmony_ci	ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND}, {
2798c2ecf20Sopenharmony_ci	ERRDOS, 161, NT_STATUS_OBJECT_PATH_SYNTAX_BAD}, {
2808c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DATA_OVERRUN}, {
2818c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DATA_LATE_ERROR}, {
2828c2ecf20Sopenharmony_ci	ERRDOS, 23, NT_STATUS_DATA_ERROR}, {
2838c2ecf20Sopenharmony_ci	ERRDOS, 23, NT_STATUS_CRC_ERROR}, {
2848c2ecf20Sopenharmony_ci	ERRDOS, ERRnomem, NT_STATUS_SECTION_TOO_BIG}, {
2858c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_PORT_CONNECTION_REFUSED}, {
2868c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfid, NT_STATUS_INVALID_PORT_HANDLE}, {
2878c2ecf20Sopenharmony_ci	ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION}, {
2888c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_QUOTA_EXCEEDED}, {
2898c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PAGE_PROTECTION}, {
2908c2ecf20Sopenharmony_ci	ERRDOS, 288, NT_STATUS_MUTANT_NOT_OWNED}, {
2918c2ecf20Sopenharmony_ci	ERRDOS, 298, NT_STATUS_SEMAPHORE_LIMIT_EXCEEDED}, {
2928c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_PORT_ALREADY_SET}, {
2938c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_SECTION_NOT_IMAGE}, {
2948c2ecf20Sopenharmony_ci	ERRDOS, 156, NT_STATUS_SUSPEND_COUNT_EXCEEDED}, {
2958c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_THREAD_IS_TERMINATING}, {
2968c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_BAD_WORKING_SET_LIMIT}, {
2978c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INCOMPATIBLE_FILE_MAP}, {
2988c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_SECTION_PROTECTION}, {
2998c2ecf20Sopenharmony_ci	ERRDOS, ERReasnotsupported, NT_STATUS_EAS_NOT_SUPPORTED}, {
3008c2ecf20Sopenharmony_ci	ERRDOS, 255, NT_STATUS_EA_TOO_LARGE}, {
3018c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NONEXISTENT_EA_ENTRY}, {
3028c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_EAS_ON_FILE}, {
3038c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_EA_CORRUPT_ERROR}, {
3048c2ecf20Sopenharmony_ci	ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT}, {
3058c2ecf20Sopenharmony_ci	ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED}, {
3068c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfile, NT_STATUS_DELETE_PENDING}, {
3078c2ecf20Sopenharmony_ci	ERRDOS, ERRunsup, NT_STATUS_CTL_FILE_NOT_SUPPORTED}, {
3088c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNKNOWN_REVISION}, {
3098c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REVISION_MISMATCH}, {
3108c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_OWNER}, {
3118c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_PRIMARY_GROUP}, {
3128c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_IMPERSONATION_TOKEN}, {
3138c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANT_DISABLE_MANDATORY}, {
3148c2ecf20Sopenharmony_ci	ERRDOS, 2215, NT_STATUS_NO_LOGON_SERVERS}, {
3158c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_LOGON_SESSION}, {
3168c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PRIVILEGE}, {
3178c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_PRIVILEGE_NOT_HELD}, {
3188c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACCOUNT_NAME}, {
3198c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_USER_EXISTS},
3208c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
3218c2ecf20Sopenharmony_ci	 from NT_STATUS_NO_SUCH_USER to NT_STATUS_LOGON_FAILURE
3228c2ecf20Sopenharmony_ci	 during the session setup } */
3238c2ecf20Sopenharmony_ci	{
3248c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_NO_SUCH_USER}, { /* could map to 2238 */
3258c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_GROUP_EXISTS}, {
3268c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_GROUP}, {
3278c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_GROUP}, {
3288c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_GROUP}, {
3298c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LAST_ADMIN},
3308c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
3318c2ecf20Sopenharmony_ci	 from NT_STATUS_WRONG_PASSWORD to NT_STATUS_LOGON_FAILURE
3328c2ecf20Sopenharmony_ci	 during the session setup } */
3338c2ecf20Sopenharmony_ci	{
3348c2ecf20Sopenharmony_ci	ERRSRV, ERRbadpw, NT_STATUS_WRONG_PASSWORD}, {
3358c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_PASSWORD}, {
3368c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PASSWORD_RESTRICTION}, {
3378c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_LOGON_FAILURE}, {
3388c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ACCOUNT_RESTRICTION}, {
3398c2ecf20Sopenharmony_ci	ERRSRV, ERRbadLogonTime, NT_STATUS_INVALID_LOGON_HOURS}, {
3408c2ecf20Sopenharmony_ci	ERRSRV, ERRbadclient, NT_STATUS_INVALID_WORKSTATION}, {
3418c2ecf20Sopenharmony_ci	ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_EXPIRED}, {
3428c2ecf20Sopenharmony_ci	ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_DISABLED}, {
3438c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NONE_MAPPED}, {
3448c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_LUIDS_REQUESTED}, {
3458c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LUIDS_EXHAUSTED}, {
3468c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_SUB_AUTHORITY}, {
3478c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_ACL}, {
3488c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_SID}, {
3498c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_SECURITY_DESCR}, {
3508c2ecf20Sopenharmony_ci	ERRDOS, 127, NT_STATUS_PROCEDURE_NOT_FOUND}, {
3518c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_IMAGE_FORMAT}, {
3528c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_TOKEN}, {
3538c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_INHERITANCE_ACL}, {
3548c2ecf20Sopenharmony_ci	ERRDOS, 158, NT_STATUS_RANGE_NOT_LOCKED}, {
3558c2ecf20Sopenharmony_ci	ERRDOS, 112, NT_STATUS_DISK_FULL}, {
3568c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SERVER_DISABLED}, {
3578c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SERVER_NOT_DISABLED}, {
3588c2ecf20Sopenharmony_ci	ERRDOS, 68, NT_STATUS_TOO_MANY_GUIDS_REQUESTED}, {
3598c2ecf20Sopenharmony_ci	ERRDOS, 259, NT_STATUS_GUIDS_EXHAUSTED}, {
3608c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_ID_AUTHORITY}, {
3618c2ecf20Sopenharmony_ci	ERRDOS, 259, NT_STATUS_AGENTS_EXHAUSTED}, {
3628c2ecf20Sopenharmony_ci	ERRDOS, 154, NT_STATUS_INVALID_VOLUME_LABEL}, {
3638c2ecf20Sopenharmony_ci	ERRDOS, 14, NT_STATUS_SECTION_NOT_EXTENDED}, {
3648c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_NOT_MAPPED_DATA}, {
3658c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_DATA_NOT_FOUND}, {
3668c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_TYPE_NOT_FOUND}, {
3678c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_NAME_NOT_FOUND}, {
3688c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ARRAY_BOUNDS_EXCEEDED}, {
3698c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DENORMAL_OPERAND}, {
3708c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_DIVIDE_BY_ZERO}, {
3718c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INEXACT_RESULT}, {
3728c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_INVALID_OPERATION}, {
3738c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_OVERFLOW}, {
3748c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_STACK_CHECK}, {
3758c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOAT_UNDERFLOW}, {
3768c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INTEGER_DIVIDE_BY_ZERO}, {
3778c2ecf20Sopenharmony_ci	ERRDOS, 534, NT_STATUS_INTEGER_OVERFLOW}, {
3788c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PRIVILEGED_INSTRUCTION}, {
3798c2ecf20Sopenharmony_ci	ERRDOS, ERRnomem, NT_STATUS_TOO_MANY_PAGING_FILES}, {
3808c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FILE_INVALID}, {
3818c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ALLOTTED_SPACE_EXCEEDED},
3828c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
3838c2ecf20Sopenharmony_ci	 from NT_STATUS_INSUFFICIENT_RESOURCES to
3848c2ecf20Sopenharmony_ci	 NT_STATUS_INSUFF_SERVER_RESOURCES during the session setup } */
3858c2ecf20Sopenharmony_ci	{
3868c2ecf20Sopenharmony_ci	ERRDOS, ERRnoresource, NT_STATUS_INSUFFICIENT_RESOURCES}, {
3878c2ecf20Sopenharmony_ci	ERRDOS, ERRbadpath, NT_STATUS_DFS_EXIT_PATH_FOUND}, {
3888c2ecf20Sopenharmony_ci	ERRDOS, 23, NT_STATUS_DEVICE_DATA_ERROR}, {
3898c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_CONNECTED}, {
3908c2ecf20Sopenharmony_ci	ERRDOS, 21, NT_STATUS_DEVICE_POWER_FAILURE}, {
3918c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_FREE_VM_NOT_AT_BASE}, {
3928c2ecf20Sopenharmony_ci	ERRDOS, 487, NT_STATUS_MEMORY_NOT_ALLOCATED}, {
3938c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_WORKING_SET_QUOTA}, {
3948c2ecf20Sopenharmony_ci	ERRDOS, 19, NT_STATUS_MEDIA_WRITE_PROTECTED}, {
3958c2ecf20Sopenharmony_ci	ERRDOS, 21, NT_STATUS_DEVICE_NOT_READY}, {
3968c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_GROUP_ATTRIBUTES}, {
3978c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_IMPERSONATION_LEVEL}, {
3988c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANT_OPEN_ANONYMOUS}, {
3998c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_VALIDATION_CLASS}, {
4008c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_TOKEN_TYPE}, {
4018c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_BAD_MASTER_BOOT_RECORD}, {
4028c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INSTRUCTION_MISALIGNMENT}, {
4038c2ecf20Sopenharmony_ci	ERRDOS, ERRpipebusy, NT_STATUS_INSTANCE_NOT_AVAILABLE}, {
4048c2ecf20Sopenharmony_ci	ERRDOS, ERRpipebusy, NT_STATUS_PIPE_NOT_AVAILABLE}, {
4058c2ecf20Sopenharmony_ci	ERRDOS, ERRbadpipe, NT_STATUS_INVALID_PIPE_STATE}, {
4068c2ecf20Sopenharmony_ci	ERRDOS, ERRpipebusy, NT_STATUS_PIPE_BUSY}, {
4078c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfunc, NT_STATUS_ILLEGAL_FUNCTION}, {
4088c2ecf20Sopenharmony_ci	ERRDOS, ERRnotconnected, NT_STATUS_PIPE_DISCONNECTED}, {
4098c2ecf20Sopenharmony_ci	ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_CLOSING}, {
4108c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PIPE_CONNECTED}, {
4118c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PIPE_LISTENING}, {
4128c2ecf20Sopenharmony_ci	ERRDOS, ERRbadpipe, NT_STATUS_INVALID_READ_MODE}, {
4138c2ecf20Sopenharmony_ci	ERRDOS, 121, NT_STATUS_IO_TIMEOUT}, {
4148c2ecf20Sopenharmony_ci	ERRDOS, 38, NT_STATUS_FILE_FORCED_CLOSED}, {
4158c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STARTED}, {
4168c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PROFILING_NOT_STOPPED}, {
4178c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_COULD_NOT_INTERPRET}, {
4188c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_FILE_IS_A_DIRECTORY}, {
4198c2ecf20Sopenharmony_ci	ERRDOS, ERRunsup, NT_STATUS_NOT_SUPPORTED}, {
4208c2ecf20Sopenharmony_ci	ERRDOS, 51, NT_STATUS_REMOTE_NOT_LISTENING}, {
4218c2ecf20Sopenharmony_ci	ERRDOS, 52, NT_STATUS_DUPLICATE_NAME}, {
4228c2ecf20Sopenharmony_ci	ERRDOS, 53, NT_STATUS_BAD_NETWORK_PATH}, {
4238c2ecf20Sopenharmony_ci	ERRDOS, 54, NT_STATUS_NETWORK_BUSY}, {
4248c2ecf20Sopenharmony_ci	ERRDOS, 55, NT_STATUS_DEVICE_DOES_NOT_EXIST}, {
4258c2ecf20Sopenharmony_ci	ERRDOS, 56, NT_STATUS_TOO_MANY_COMMANDS}, {
4268c2ecf20Sopenharmony_ci	ERRDOS, 57, NT_STATUS_ADAPTER_HARDWARE_ERROR}, {
4278c2ecf20Sopenharmony_ci	ERRDOS, 58, NT_STATUS_INVALID_NETWORK_RESPONSE}, {
4288c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_UNEXPECTED_NETWORK_ERROR}, {
4298c2ecf20Sopenharmony_ci	ERRDOS, 60, NT_STATUS_BAD_REMOTE_ADAPTER}, {
4308c2ecf20Sopenharmony_ci	ERRDOS, 61, NT_STATUS_PRINT_QUEUE_FULL}, {
4318c2ecf20Sopenharmony_ci	ERRDOS, 62, NT_STATUS_NO_SPOOL_SPACE}, {
4328c2ecf20Sopenharmony_ci	ERRDOS, 63, NT_STATUS_PRINT_CANCELLED}, {
4338c2ecf20Sopenharmony_ci	ERRDOS, 64, NT_STATUS_NETWORK_NAME_DELETED}, {
4348c2ecf20Sopenharmony_ci	ERRDOS, 65, NT_STATUS_NETWORK_ACCESS_DENIED}, {
4358c2ecf20Sopenharmony_ci	ERRDOS, 66, NT_STATUS_BAD_DEVICE_TYPE}, {
4368c2ecf20Sopenharmony_ci	ERRDOS, ERRnosuchshare, NT_STATUS_BAD_NETWORK_NAME}, {
4378c2ecf20Sopenharmony_ci	ERRDOS, 68, NT_STATUS_TOO_MANY_NAMES}, {
4388c2ecf20Sopenharmony_ci	ERRDOS, 69, NT_STATUS_TOO_MANY_SESSIONS}, {
4398c2ecf20Sopenharmony_ci	ERRDOS, 70, NT_STATUS_SHARING_PAUSED}, {
4408c2ecf20Sopenharmony_ci	ERRDOS, 71, NT_STATUS_REQUEST_NOT_ACCEPTED}, {
4418c2ecf20Sopenharmony_ci	ERRDOS, 72, NT_STATUS_REDIRECTOR_PAUSED}, {
4428c2ecf20Sopenharmony_ci	ERRDOS, 88, NT_STATUS_NET_WRITE_FAULT}, {
4438c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PROFILING_AT_LIMIT}, {
4448c2ecf20Sopenharmony_ci	ERRDOS, ERRdiffdevice, NT_STATUS_NOT_SAME_DEVICE}, {
4458c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_FILE_RENAMED}, {
4468c2ecf20Sopenharmony_ci	ERRDOS, 240, NT_STATUS_VIRTUAL_CIRCUIT_CLOSED}, {
4478c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SECURITY_ON_OBJECT}, {
4488c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANT_WAIT}, {
4498c2ecf20Sopenharmony_ci	ERRDOS, ERRpipeclosing, NT_STATUS_PIPE_EMPTY}, {
4508c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANT_ACCESS_DOMAIN_INFO}, {
4518c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANT_TERMINATE_SELF}, {
4528c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_SERVER_STATE}, {
4538c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_STATE}, {
4548c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_DOMAIN_ROLE}, {
4558c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_DOMAIN}, {
4568c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_EXISTS}, {
4578c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_LIMIT_EXCEEDED}, {
4588c2ecf20Sopenharmony_ci	ERRDOS, 300, NT_STATUS_OPLOCK_NOT_GRANTED}, {
4598c2ecf20Sopenharmony_ci	ERRDOS, 301, NT_STATUS_INVALID_OPLOCK_PROTOCOL}, {
4608c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_CORRUPTION}, {
4618c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_ERROR}, {
4628c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_GENERIC_NOT_MAPPED}, {
4638c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_DESCRIPTOR_FORMAT}, {
4648c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_USER_BUFFER}, {
4658c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_IO_ERROR}, {
4668c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_CREATE_ERR}, {
4678c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_MAP_ERROR}, {
4688c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNEXPECTED_MM_EXTEND_ERR}, {
4698c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NOT_LOGON_PROCESS}, {
4708c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_EXISTS}, {
4718c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_1}, {
4728c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_2}, {
4738c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_3}, {
4748c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_4}, {
4758c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_5}, {
4768c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_6}, {
4778c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_7}, {
4788c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_8}, {
4798c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_9}, {
4808c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_10}, {
4818c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_11}, {
4828c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_INVALID_PARAMETER_12}, {
4838c2ecf20Sopenharmony_ci	ERRDOS, ERRbadpath, NT_STATUS_REDIRECTOR_NOT_STARTED}, {
4848c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REDIRECTOR_STARTED}, {
4858c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW}, {
4868c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_PACKAGE}, {
4878c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_FUNCTION_TABLE}, {
4888c2ecf20Sopenharmony_ci	ERRDOS, 203, 0xc0000100}, {
4898c2ecf20Sopenharmony_ci	ERRDOS, 145, NT_STATUS_DIRECTORY_NOT_EMPTY}, {
4908c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FILE_CORRUPT_ERROR}, {
4918c2ecf20Sopenharmony_ci	ERRDOS, 267, NT_STATUS_NOT_A_DIRECTORY}, {
4928c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_LOGON_SESSION_STATE}, {
4938c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOGON_SESSION_COLLISION}, {
4948c2ecf20Sopenharmony_ci	ERRDOS, 206, NT_STATUS_NAME_TOO_LONG}, {
4958c2ecf20Sopenharmony_ci	ERRDOS, 2401, NT_STATUS_FILES_OPEN}, {
4968c2ecf20Sopenharmony_ci	ERRDOS, 2404, NT_STATUS_CONNECTION_IN_USE}, {
4978c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MESSAGE_NOT_FOUND}, {
4988c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_PROCESS_IS_TERMINATING}, {
4998c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_LOGON_TYPE}, {
5008c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_GUID_TRANSLATION}, {
5018c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANNOT_IMPERSONATE}, {
5028c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_IMAGE_ALREADY_LOADED}, {
5038c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_PRESENT}, {
5048c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_NOT_EXIST}, {
5058c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_LID_ALREADY_OWNED}, {
5068c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_NOT_LID_OWNER}, {
5078c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_COMMAND}, {
5088c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_LID}, {
5098c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_SELECTOR_NOT_AVAILABLE}, {
5108c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ABIOS_INVALID_SELECTOR}, {
5118c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_LDT}, {
5128c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_SIZE}, {
5138c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_OFFSET}, {
5148c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_LDT_DESCRIPTOR}, {
5158c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NE_FORMAT}, {
5168c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RXACT_INVALID_STATE}, {
5178c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RXACT_COMMIT_FAILURE}, {
5188c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MAPPED_FILE_SIZE_ZERO}, {
5198c2ecf20Sopenharmony_ci	ERRDOS, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES}, {
5208c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANCELLED}, {
5218c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_CANNOT_DELETE}, {
5228c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_COMPUTER_NAME}, {
5238c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_FILE_DELETED}, {
5248c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_ACCOUNT}, {
5258c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_GROUP}, {
5268c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SPECIAL_USER}, {
5278c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MEMBERS_PRIMARY_GROUP}, {
5288c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfid, NT_STATUS_FILE_CLOSED}, {
5298c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_THREADS}, {
5308c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_THREAD_NOT_IN_PROCESS}, {
5318c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TOKEN_ALREADY_IN_USE}, {
5328c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_QUOTA_EXCEEDED}, {
5338c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_COMMITMENT_LIMIT}, {
5348c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_IMAGE_LE_FORMAT}, {
5358c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_IMAGE_NOT_MZ}, {
5368c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_IMAGE_PROTECT}, {
5378c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_INVALID_IMAGE_WIN_16}, {
5388c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOGON_SERVER_CONFLICT}, {
5398c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TIME_DIFFERENCE_AT_DC}, {
5408c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SYNCHRONIZATION_REQUIRED}, {
5418c2ecf20Sopenharmony_ci	ERRDOS, 126, NT_STATUS_DLL_NOT_FOUND}, {
5428c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_OPEN_FAILED}, {
5438c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_IO_PRIVILEGE_FAILED}, {
5448c2ecf20Sopenharmony_ci	ERRDOS, 182, NT_STATUS_ORDINAL_NOT_FOUND}, {
5458c2ecf20Sopenharmony_ci	ERRDOS, 127, NT_STATUS_ENTRYPOINT_NOT_FOUND}, {
5468c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONTROL_C_EXIT}, {
5478c2ecf20Sopenharmony_ci	ERRDOS, 64, NT_STATUS_LOCAL_DISCONNECT}, {
5488c2ecf20Sopenharmony_ci	ERRDOS, 64, NT_STATUS_REMOTE_DISCONNECT}, {
5498c2ecf20Sopenharmony_ci	ERRDOS, 51, NT_STATUS_REMOTE_RESOURCES}, {
5508c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_LINK_FAILED}, {
5518c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_LINK_TIMEOUT}, {
5528c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_INVALID_CONNECTION}, {
5538c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_INVALID_ADDRESS}, {
5548c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DLL_INIT_FAILED}, {
5558c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MISSING_SYSTEMFILE}, {
5568c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNHANDLED_EXCEPTION}, {
5578c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_APP_INIT_FAILURE}, {
5588c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PAGEFILE_CREATE_FAILED}, {
5598c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_PAGEFILE}, {
5608c2ecf20Sopenharmony_ci	ERRDOS, 124, NT_STATUS_INVALID_LEVEL}, {
5618c2ecf20Sopenharmony_ci	ERRDOS, 86, NT_STATUS_WRONG_PASSWORD_CORE}, {
5628c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_FLOAT_CONTEXT}, {
5638c2ecf20Sopenharmony_ci	ERRDOS, 109, NT_STATUS_PIPE_BROKEN}, {
5648c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_CORRUPT}, {
5658c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_IO_FAILED}, {
5668c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_EVENT_PAIR}, {
5678c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNRECOGNIZED_VOLUME}, {
5688c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SERIAL_NO_DEVICE_INITED}, {
5698c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_ALIAS}, {
5708c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MEMBER_NOT_IN_ALIAS}, {
5718c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MEMBER_IN_ALIAS}, {
5728c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ALIAS_EXISTS}, {
5738c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOGON_NOT_GRANTED}, {
5748c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SECRETS}, {
5758c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SECRET_TOO_LONG}, {
5768c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INTERNAL_DB_ERROR}, {
5778c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FULLSCREEN_MODE}, {
5788c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_CONTEXT_IDS}, {
5798c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_LOGON_TYPE_NOT_GRANTED}, {
5808c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NOT_REGISTRY_FILE}, {
5818c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NT_CROSS_ENCRYPTION_REQUIRED}, {
5828c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CTRLR_CONFIG_ERROR}, {
5838c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FT_MISSING_MEMBER}, {
5848c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ILL_FORMED_SERVICE_ENTRY}, {
5858c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ILLEGAL_CHARACTER}, {
5868c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNMAPPABLE_CHARACTER}, {
5878c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNDEFINED_CHARACTER}, {
5888c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_VOLUME}, {
5898c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_ID_MARK_NOT_FOUND}, {
5908c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_WRONG_CYLINDER}, {
5918c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_UNKNOWN_ERROR}, {
5928c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FLOPPY_BAD_REGISTERS}, {
5938c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DISK_RECALIBRATE_FAILED}, {
5948c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DISK_OPERATION_FAILED}, {
5958c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DISK_RESET_FAILED}, {
5968c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SHARED_IRQ_BUSY}, {
5978c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FT_ORPHANING}, {
5988c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000016e}, {
5998c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000016f}, {
6008c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc0000170}, {
6018c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc0000171}, {
6028c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PARTITION_FAILURE}, {
6038c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_BLOCK_LENGTH}, {
6048c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DEVICE_NOT_PARTITIONED}, {
6058c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_LOCK_MEDIA}, {
6068c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNABLE_TO_UNLOAD_MEDIA}, {
6078c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_EOM_OVERFLOW}, {
6088c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_MEDIA}, {
6098c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc0000179}, {
6108c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_SUCH_MEMBER}, {
6118c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_MEMBER}, {
6128c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_KEY_DELETED}, {
6138c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_LOG_SPACE}, {
6148c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TOO_MANY_SIDS}, {
6158c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LM_CROSS_ENCRYPTION_REQUIRED}, {
6168c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_KEY_HAS_CHILDREN}, {
6178c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CHILD_MUST_BE_VOLATILE}, {
6188c2ecf20Sopenharmony_ci	ERRDOS, 87, NT_STATUS_DEVICE_CONFIGURATION_ERROR}, {
6198c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DRIVER_INTERNAL_ERROR}, {
6208c2ecf20Sopenharmony_ci	ERRDOS, 22, NT_STATUS_INVALID_DEVICE_STATE}, {
6218c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_IO_DEVICE_ERROR}, {
6228c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DEVICE_PROTOCOL_ERROR}, {
6238c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BACKUP_CONTROLLER}, {
6248c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOG_FILE_FULL}, {
6258c2ecf20Sopenharmony_ci	ERRDOS, 19, NT_STATUS_TOO_LATE}, {
6268c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_LSA_SECRET},
6278c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
6288c2ecf20Sopenharmony_ci	 from NT_STATUS_NO_TRUST_SAM_ACCOUNT to
6298c2ecf20Sopenharmony_ci	 NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE during the session setup } */
6308c2ecf20Sopenharmony_ci	{
6318c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_NO_TRUST_SAM_ACCOUNT}, {
6328c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_DOMAIN_FAILURE}, {
6338c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_TRUSTED_RELATIONSHIP_FAILURE}, {
6348c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CORRUPT}, {
6358c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_CANT_START}, {
6368c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_TRUST_FAILURE}, {
6378c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MUTANT_LIMIT_EXCEEDED}, {
6388c2ecf20Sopenharmony_ci	ERRDOS, ERRnetlogonNotStarted, NT_STATUS_NETLOGON_NOT_STARTED}, {
6398c2ecf20Sopenharmony_ci	ERRSRV, ERRaccountexpired, NT_STATUS_ACCOUNT_EXPIRED}, {
6408c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_POSSIBLE_DEADLOCK}, {
6418c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NETWORK_CREDENTIAL_CONFLICT}, {
6428c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REMOTE_SESSION_LIMIT}, {
6438c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_EVENTLOG_FILE_CHANGED}, {
6448c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_INTERDOMAIN_TRUST_ACCOUNT}, {
6458c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_WORKSTATION_TRUST_ACCOUNT}, {
6468c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_NOLOGON_SERVER_TRUST_ACCOUNT},
6478c2ecf20Sopenharmony_ci/*	{ This NT error code was 'sqashed'
6488c2ecf20Sopenharmony_ci	 from NT_STATUS_DOMAIN_TRUST_INCONSISTENT to NT_STATUS_LOGON_FAILURE
6498c2ecf20Sopenharmony_ci	 during the session setup }  */
6508c2ecf20Sopenharmony_ci	{
6518c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_DOMAIN_TRUST_INCONSISTENT}, {
6528c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FS_DRIVER_REQUIRED}, {
6538c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_USER_SESSION_KEY}, {
6548c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_USER_SESSION_DELETED}, {
6558c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RESOURCE_LANG_NOT_FOUND}, {
6568c2ecf20Sopenharmony_ci	ERRDOS, ERRnoresource, NT_STATUS_INSUFF_SERVER_RESOURCES}, {
6578c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_BUFFER_SIZE}, {
6588c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_COMPONENT}, {
6598c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_ADDRESS_WILDCARD}, {
6608c2ecf20Sopenharmony_ci	ERRDOS, 68, NT_STATUS_TOO_MANY_ADDRESSES}, {
6618c2ecf20Sopenharmony_ci	ERRDOS, 52, NT_STATUS_ADDRESS_ALREADY_EXISTS}, {
6628c2ecf20Sopenharmony_ci	ERRDOS, 64, NT_STATUS_ADDRESS_CLOSED}, {
6638c2ecf20Sopenharmony_ci	ERRDOS, 64, NT_STATUS_CONNECTION_DISCONNECTED}, {
6648c2ecf20Sopenharmony_ci	ERRDOS, 64, NT_STATUS_CONNECTION_RESET}, {
6658c2ecf20Sopenharmony_ci	ERRDOS, 68, NT_STATUS_TOO_MANY_NODES}, {
6668c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_ABORTED}, {
6678c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_TIMED_OUT}, {
6688c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_NO_RELEASE}, {
6698c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_NO_MATCH}, {
6708c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_RESPONDED}, {
6718c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_ID}, {
6728c2ecf20Sopenharmony_ci	ERRDOS, 59, NT_STATUS_TRANSACTION_INVALID_TYPE}, {
6738c2ecf20Sopenharmony_ci	ERRDOS, ERRunsup, NT_STATUS_NOT_SERVER_SESSION}, {
6748c2ecf20Sopenharmony_ci	ERRDOS, ERRunsup, NT_STATUS_NOT_CLIENT_SESSION}, {
6758c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CANNOT_LOAD_REGISTRY_FILE}, {
6768c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DEBUG_ATTACH_FAILED}, {
6778c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_SYSTEM_PROCESS_TERMINATED}, {
6788c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DATA_NOT_ACCEPTED}, {
6798c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_BROWSER_SERVERS_FOUND}, {
6808c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_VDM_HARD_ERROR}, {
6818c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DRIVER_CANCEL_TIMEOUT}, {
6828c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REPLY_MESSAGE_MISMATCH}, {
6838c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MAPPED_ALIGNMENT}, {
6848c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_IMAGE_CHECKSUM_MISMATCH}, {
6858c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOST_WRITEBEHIND_DATA}, {
6868c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CLIENT_SERVER_PARAMETERS_INVALID}, {
6878c2ecf20Sopenharmony_ci	ERRSRV, ERRpasswordExpired, NT_STATUS_PASSWORD_MUST_CHANGE}, {
6888c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NOT_FOUND}, {
6898c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NOT_TINY_STREAM}, {
6908c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RECOVERY_FAILURE}, {
6918c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_STACK_OVERFLOW_READ}, {
6928c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FAIL_CHECK}, {
6938c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DUPLICATE_OBJECTID}, {
6948c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_OBJECTID_EXISTS}, {
6958c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONVERT_TO_LARGE}, {
6968c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_RETRY}, {
6978c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FOUND_OUT_OF_SCOPE}, {
6988c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ALLOCATE_BUCKET}, {
6998c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PROPSET_NOT_FOUND}, {
7008c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_MARSHALL_OVERFLOW}, {
7018c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_VARIANT}, {
7028c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND}, {
7038c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, NT_STATUS_ACCOUNT_LOCKED_OUT}, {
7048c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfid, NT_STATUS_HANDLE_NOT_CLOSABLE}, {
7058c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_REFUSED}, {
7068c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_GRACEFUL_DISCONNECT}, {
7078c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_ALREADY_ASSOCIATED}, {
7088c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_ADDRESS_NOT_ASSOCIATED}, {
7098c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_INVALID}, {
7108c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ACTIVE}, {
7118c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NETWORK_UNREACHABLE}, {
7128c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_HOST_UNREACHABLE}, {
7138c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PROTOCOL_UNREACHABLE}, {
7148c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PORT_UNREACHABLE}, {
7158c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REQUEST_ABORTED}, {
7168c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_ABORTED}, {
7178c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_COMPRESSION_BUFFER}, {
7188c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_USER_MAPPED_FILE}, {
7198c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_AUDIT_FAILED}, {
7208c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_TIMER_RESOLUTION_NOT_SET}, {
7218c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_CONNECTION_COUNT_LIMIT}, {
7228c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOGIN_TIME_RESTRICTION}, {
7238c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LOGIN_WKSTA_RESTRICTION}, {
7248c2ecf20Sopenharmony_ci	ERRDOS, 193, NT_STATUS_IMAGE_MP_UP_MISMATCH}, {
7258c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000024a}, {
7268c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000024b}, {
7278c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000024c}, {
7288c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000024d}, {
7298c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000024e}, {
7308c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000024f}, {
7318c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INSUFFICIENT_LOGON_INFO}, {
7328c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_DLL_ENTRYPOINT}, {
7338c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_BAD_SERVICE_ENTRYPOINT}, {
7348c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LPC_REPLY_LOST}, {
7358c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT1}, {
7368c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_IP_ADDRESS_CONFLICT2}, {
7378c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_REGISTRY_QUOTA_LIMIT}, {
7388c2ecf20Sopenharmony_ci	ERRSRV, 3, NT_STATUS_PATH_NOT_COVERED}, {
7398c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_NO_CALLBACK_ACTIVE}, {
7408c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_LICENSE_QUOTA_EXCEEDED}, {
7418c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_SHORT}, {
7428c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PWD_TOO_RECENT}, {
7438c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PWD_HISTORY_CONFLICT}, {
7448c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000025d}, {
7458c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_PLUGPLAY_NO_DEVICE}, {
7468c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_UNSUPPORTED_COMPRESSION}, {
7478c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_HW_PROFILE}, {
7488c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_INVALID_PLUGPLAY_DEVICE_PATH}, {
7498c2ecf20Sopenharmony_ci	ERRDOS, 182, NT_STATUS_DRIVER_ORDINAL_NOT_FOUND}, {
7508c2ecf20Sopenharmony_ci	ERRDOS, 127, NT_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND}, {
7518c2ecf20Sopenharmony_ci	ERRDOS, 288, NT_STATUS_RESOURCE_NOT_OWNED}, {
7528c2ecf20Sopenharmony_ci	ERRDOS, ErrTooManyLinks, NT_STATUS_TOO_MANY_LINKS}, {
7538c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_QUOTA_LIST_INCONSISTENT}, {
7548c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, NT_STATUS_FILE_IS_OFFLINE}, {
7558c2ecf20Sopenharmony_ci	ERRDOS, 21, 0xc000026e}, {
7568c2ecf20Sopenharmony_ci	ERRDOS, 161, 0xc0000281}, {
7578c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, 0xc000028a}, {
7588c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, 0xc000028b}, {
7598c2ecf20Sopenharmony_ci	ERRHRD, ERRgeneral, 0xc000028c}, {
7608c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, 0xc000028d}, {
7618c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, 0xc000028e}, {
7628c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, 0xc000028f}, {
7638c2ecf20Sopenharmony_ci	ERRDOS, ERRnoaccess, 0xc0000290}, {
7648c2ecf20Sopenharmony_ci	ERRDOS, ERRbadfunc, 0xc000029c}, {
7658c2ecf20Sopenharmony_ci	ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, {
7668c2ecf20Sopenharmony_ci	ERRDOS, ERRinvlevel, 0x007c0001}, {
7678c2ecf20Sopenharmony_ci	0, 0, 0 }
7688c2ecf20Sopenharmony_ci};
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_ci/*****************************************************************************
7718c2ecf20Sopenharmony_ci Print an error message from the status code
7728c2ecf20Sopenharmony_ci *****************************************************************************/
7738c2ecf20Sopenharmony_cistatic void
7748c2ecf20Sopenharmony_cicifs_print_status(__u32 status_code)
7758c2ecf20Sopenharmony_ci{
7768c2ecf20Sopenharmony_ci	int idx = 0;
7778c2ecf20Sopenharmony_ci
7788c2ecf20Sopenharmony_ci	while (nt_errs[idx].nt_errstr != NULL) {
7798c2ecf20Sopenharmony_ci		if (((nt_errs[idx].nt_errcode) & 0xFFFFFF) ==
7808c2ecf20Sopenharmony_ci		    (status_code & 0xFFFFFF)) {
7818c2ecf20Sopenharmony_ci			pr_notice("Status code returned 0x%08x %s\n",
7828c2ecf20Sopenharmony_ci				  status_code, nt_errs[idx].nt_errstr);
7838c2ecf20Sopenharmony_ci		}
7848c2ecf20Sopenharmony_ci		idx++;
7858c2ecf20Sopenharmony_ci	}
7868c2ecf20Sopenharmony_ci	return;
7878c2ecf20Sopenharmony_ci}
7888c2ecf20Sopenharmony_ci
7898c2ecf20Sopenharmony_ci
7908c2ecf20Sopenharmony_cistatic void
7918c2ecf20Sopenharmony_cintstatus_to_dos(__u32 ntstatus, __u8 *eclass, __u16 *ecode)
7928c2ecf20Sopenharmony_ci{
7938c2ecf20Sopenharmony_ci	int i;
7948c2ecf20Sopenharmony_ci	if (ntstatus == 0) {
7958c2ecf20Sopenharmony_ci		*eclass = 0;
7968c2ecf20Sopenharmony_ci		*ecode = 0;
7978c2ecf20Sopenharmony_ci		return;
7988c2ecf20Sopenharmony_ci	}
7998c2ecf20Sopenharmony_ci	for (i = 0; ntstatus_to_dos_map[i].ntstatus; i++) {
8008c2ecf20Sopenharmony_ci		if (ntstatus == ntstatus_to_dos_map[i].ntstatus) {
8018c2ecf20Sopenharmony_ci			*eclass = ntstatus_to_dos_map[i].dos_class;
8028c2ecf20Sopenharmony_ci			*ecode = ntstatus_to_dos_map[i].dos_code;
8038c2ecf20Sopenharmony_ci			return;
8048c2ecf20Sopenharmony_ci		}
8058c2ecf20Sopenharmony_ci	}
8068c2ecf20Sopenharmony_ci	*eclass = ERRHRD;
8078c2ecf20Sopenharmony_ci	*ecode = ERRgeneral;
8088c2ecf20Sopenharmony_ci}
8098c2ecf20Sopenharmony_ci
8108c2ecf20Sopenharmony_ciint
8118c2ecf20Sopenharmony_cimap_smb_to_linux_error(char *buf, bool logErr)
8128c2ecf20Sopenharmony_ci{
8138c2ecf20Sopenharmony_ci	struct smb_hdr *smb = (struct smb_hdr *)buf;
8148c2ecf20Sopenharmony_ci	unsigned int i;
8158c2ecf20Sopenharmony_ci	int rc = -EIO;	/* if transport error smb error may not be set */
8168c2ecf20Sopenharmony_ci	__u8 smberrclass;
8178c2ecf20Sopenharmony_ci	__u16 smberrcode;
8188c2ecf20Sopenharmony_ci
8198c2ecf20Sopenharmony_ci	/* BB if NT Status codes - map NT BB */
8208c2ecf20Sopenharmony_ci
8218c2ecf20Sopenharmony_ci	/* old style smb error codes */
8228c2ecf20Sopenharmony_ci	if (smb->Status.CifsError == 0)
8238c2ecf20Sopenharmony_ci		return 0;
8248c2ecf20Sopenharmony_ci
8258c2ecf20Sopenharmony_ci	if (smb->Flags2 & SMBFLG2_ERR_STATUS) {
8268c2ecf20Sopenharmony_ci		/* translate the newer STATUS codes to old style SMB errors
8278c2ecf20Sopenharmony_ci		 * and then to POSIX errors */
8288c2ecf20Sopenharmony_ci		__u32 err = le32_to_cpu(smb->Status.CifsError);
8298c2ecf20Sopenharmony_ci		if (logErr && (err != (NT_STATUS_MORE_PROCESSING_REQUIRED)))
8308c2ecf20Sopenharmony_ci			cifs_print_status(err);
8318c2ecf20Sopenharmony_ci		else if (cifsFYI & CIFS_RC)
8328c2ecf20Sopenharmony_ci			cifs_print_status(err);
8338c2ecf20Sopenharmony_ci		ntstatus_to_dos(err, &smberrclass, &smberrcode);
8348c2ecf20Sopenharmony_ci	} else {
8358c2ecf20Sopenharmony_ci		smberrclass = smb->Status.DosError.ErrorClass;
8368c2ecf20Sopenharmony_ci		smberrcode = le16_to_cpu(smb->Status.DosError.Error);
8378c2ecf20Sopenharmony_ci	}
8388c2ecf20Sopenharmony_ci
8398c2ecf20Sopenharmony_ci	/* old style errors */
8408c2ecf20Sopenharmony_ci
8418c2ecf20Sopenharmony_ci	/* DOS class smb error codes - map DOS */
8428c2ecf20Sopenharmony_ci	if (smberrclass == ERRDOS) {
8438c2ecf20Sopenharmony_ci		/* 1 byte field no need to byte reverse */
8448c2ecf20Sopenharmony_ci		for (i = 0;
8458c2ecf20Sopenharmony_ci		     i <
8468c2ecf20Sopenharmony_ci		     sizeof(mapping_table_ERRDOS) /
8478c2ecf20Sopenharmony_ci		     sizeof(struct smb_to_posix_error); i++) {
8488c2ecf20Sopenharmony_ci			if (mapping_table_ERRDOS[i].smb_err == 0)
8498c2ecf20Sopenharmony_ci				break;
8508c2ecf20Sopenharmony_ci			else if (mapping_table_ERRDOS[i].smb_err ==
8518c2ecf20Sopenharmony_ci								smberrcode) {
8528c2ecf20Sopenharmony_ci				rc = mapping_table_ERRDOS[i].posix_code;
8538c2ecf20Sopenharmony_ci				break;
8548c2ecf20Sopenharmony_ci			}
8558c2ecf20Sopenharmony_ci			/* else try next error mapping one to see if match */
8568c2ecf20Sopenharmony_ci		}
8578c2ecf20Sopenharmony_ci	} else if (smberrclass == ERRSRV) {
8588c2ecf20Sopenharmony_ci		/* server class of error codes */
8598c2ecf20Sopenharmony_ci		for (i = 0;
8608c2ecf20Sopenharmony_ci		     i <
8618c2ecf20Sopenharmony_ci		     sizeof(mapping_table_ERRSRV) /
8628c2ecf20Sopenharmony_ci		     sizeof(struct smb_to_posix_error); i++) {
8638c2ecf20Sopenharmony_ci			if (mapping_table_ERRSRV[i].smb_err == 0)
8648c2ecf20Sopenharmony_ci				break;
8658c2ecf20Sopenharmony_ci			else if (mapping_table_ERRSRV[i].smb_err ==
8668c2ecf20Sopenharmony_ci								smberrcode) {
8678c2ecf20Sopenharmony_ci				rc = mapping_table_ERRSRV[i].posix_code;
8688c2ecf20Sopenharmony_ci				break;
8698c2ecf20Sopenharmony_ci			}
8708c2ecf20Sopenharmony_ci			/* else try next error mapping to see if match */
8718c2ecf20Sopenharmony_ci		}
8728c2ecf20Sopenharmony_ci	}
8738c2ecf20Sopenharmony_ci	/* else ERRHRD class errors or junk  - return EIO */
8748c2ecf20Sopenharmony_ci
8758c2ecf20Sopenharmony_ci	cifs_dbg(FYI, "Mapping smb error code 0x%x to POSIX err %d\n",
8768c2ecf20Sopenharmony_ci		 le32_to_cpu(smb->Status.CifsError), rc);
8778c2ecf20Sopenharmony_ci
8788c2ecf20Sopenharmony_ci	/* generic corrective action e.g. reconnect SMB session on
8798c2ecf20Sopenharmony_ci	 * ERRbaduid could be added */
8808c2ecf20Sopenharmony_ci
8818c2ecf20Sopenharmony_ci	return rc;
8828c2ecf20Sopenharmony_ci}
8838c2ecf20Sopenharmony_ci
8848c2ecf20Sopenharmony_ciint
8858c2ecf20Sopenharmony_cimap_and_check_smb_error(struct mid_q_entry *mid, bool logErr)
8868c2ecf20Sopenharmony_ci{
8878c2ecf20Sopenharmony_ci	int rc;
8888c2ecf20Sopenharmony_ci	struct smb_hdr *smb = (struct smb_hdr *)mid->resp_buf;
8898c2ecf20Sopenharmony_ci
8908c2ecf20Sopenharmony_ci	rc = map_smb_to_linux_error((char *)smb, logErr);
8918c2ecf20Sopenharmony_ci	if (rc == -EACCES && !(smb->Flags2 & SMBFLG2_ERR_STATUS)) {
8928c2ecf20Sopenharmony_ci		/* possible ERRBaduid */
8938c2ecf20Sopenharmony_ci		__u8 class = smb->Status.DosError.ErrorClass;
8948c2ecf20Sopenharmony_ci		__u16 code = le16_to_cpu(smb->Status.DosError.Error);
8958c2ecf20Sopenharmony_ci
8968c2ecf20Sopenharmony_ci		/* switch can be used to handle different errors */
8978c2ecf20Sopenharmony_ci		if (class == ERRSRV && code == ERRbaduid) {
8988c2ecf20Sopenharmony_ci			cifs_dbg(FYI, "Server returned 0x%x, reconnecting session...\n",
8998c2ecf20Sopenharmony_ci				code);
9008c2ecf20Sopenharmony_ci			spin_lock(&GlobalMid_Lock);
9018c2ecf20Sopenharmony_ci			if (mid->server->tcpStatus != CifsExiting)
9028c2ecf20Sopenharmony_ci				mid->server->tcpStatus = CifsNeedReconnect;
9038c2ecf20Sopenharmony_ci			spin_unlock(&GlobalMid_Lock);
9048c2ecf20Sopenharmony_ci		}
9058c2ecf20Sopenharmony_ci	}
9068c2ecf20Sopenharmony_ci
9078c2ecf20Sopenharmony_ci	return rc;
9088c2ecf20Sopenharmony_ci}
9098c2ecf20Sopenharmony_ci
9108c2ecf20Sopenharmony_ci
9118c2ecf20Sopenharmony_ci/*
9128c2ecf20Sopenharmony_ci * calculate the size of the SMB message based on the fixed header
9138c2ecf20Sopenharmony_ci * portion, the number of word parameters and the data portion of the message
9148c2ecf20Sopenharmony_ci */
9158c2ecf20Sopenharmony_ciunsigned int
9168c2ecf20Sopenharmony_cismbCalcSize(void *buf, struct TCP_Server_Info *server)
9178c2ecf20Sopenharmony_ci{
9188c2ecf20Sopenharmony_ci	struct smb_hdr *ptr = (struct smb_hdr *)buf;
9198c2ecf20Sopenharmony_ci	return (sizeof(struct smb_hdr) + (2 * ptr->WordCount) +
9208c2ecf20Sopenharmony_ci		2 /* size of the bcc field */ + get_bcc(ptr));
9218c2ecf20Sopenharmony_ci}
9228c2ecf20Sopenharmony_ci
9238c2ecf20Sopenharmony_ci/* The following are taken from fs/ntfs/util.c */
9248c2ecf20Sopenharmony_ci
9258c2ecf20Sopenharmony_ci#define NTFS_TIME_OFFSET ((u64)(369*365 + 89) * 24 * 3600 * 10000000)
9268c2ecf20Sopenharmony_ci
9278c2ecf20Sopenharmony_ci/*
9288c2ecf20Sopenharmony_ci * Convert the NT UTC (based 1601-01-01, in hundred nanosecond units)
9298c2ecf20Sopenharmony_ci * into Unix UTC (based 1970-01-01, in seconds).
9308c2ecf20Sopenharmony_ci */
9318c2ecf20Sopenharmony_cistruct timespec64
9328c2ecf20Sopenharmony_cicifs_NTtimeToUnix(__le64 ntutc)
9338c2ecf20Sopenharmony_ci{
9348c2ecf20Sopenharmony_ci	struct timespec64 ts;
9358c2ecf20Sopenharmony_ci	/* BB what about the timezone? BB */
9368c2ecf20Sopenharmony_ci
9378c2ecf20Sopenharmony_ci	/* Subtract the NTFS time offset, then convert to 1s intervals. */
9388c2ecf20Sopenharmony_ci	s64 t = le64_to_cpu(ntutc) - NTFS_TIME_OFFSET;
9398c2ecf20Sopenharmony_ci	u64 abs_t;
9408c2ecf20Sopenharmony_ci
9418c2ecf20Sopenharmony_ci	/*
9428c2ecf20Sopenharmony_ci	 * Unfortunately can not use normal 64 bit division on 32 bit arch, but
9438c2ecf20Sopenharmony_ci	 * the alternative, do_div, does not work with negative numbers so have
9448c2ecf20Sopenharmony_ci	 * to special case them
9458c2ecf20Sopenharmony_ci	 */
9468c2ecf20Sopenharmony_ci	if (t < 0) {
9478c2ecf20Sopenharmony_ci		abs_t = -t;
9488c2ecf20Sopenharmony_ci		ts.tv_nsec = (time64_t)(do_div(abs_t, 10000000) * 100);
9498c2ecf20Sopenharmony_ci		ts.tv_nsec = -ts.tv_nsec;
9508c2ecf20Sopenharmony_ci		ts.tv_sec = -abs_t;
9518c2ecf20Sopenharmony_ci	} else {
9528c2ecf20Sopenharmony_ci		abs_t = t;
9538c2ecf20Sopenharmony_ci		ts.tv_nsec = (time64_t)do_div(abs_t, 10000000) * 100;
9548c2ecf20Sopenharmony_ci		ts.tv_sec = abs_t;
9558c2ecf20Sopenharmony_ci	}
9568c2ecf20Sopenharmony_ci
9578c2ecf20Sopenharmony_ci	return ts;
9588c2ecf20Sopenharmony_ci}
9598c2ecf20Sopenharmony_ci
9608c2ecf20Sopenharmony_ci/* Convert the Unix UTC into NT UTC. */
9618c2ecf20Sopenharmony_ciu64
9628c2ecf20Sopenharmony_cicifs_UnixTimeToNT(struct timespec64 t)
9638c2ecf20Sopenharmony_ci{
9648c2ecf20Sopenharmony_ci	/* Convert to 100ns intervals and then add the NTFS time offset. */
9658c2ecf20Sopenharmony_ci	return (u64) t.tv_sec * 10000000 + t.tv_nsec/100 + NTFS_TIME_OFFSET;
9668c2ecf20Sopenharmony_ci}
9678c2ecf20Sopenharmony_ci
9688c2ecf20Sopenharmony_cistatic const int total_days_of_prev_months[] = {
9698c2ecf20Sopenharmony_ci	0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334
9708c2ecf20Sopenharmony_ci};
9718c2ecf20Sopenharmony_ci
9728c2ecf20Sopenharmony_cistruct timespec64 cnvrtDosUnixTm(__le16 le_date, __le16 le_time, int offset)
9738c2ecf20Sopenharmony_ci{
9748c2ecf20Sopenharmony_ci	struct timespec64 ts;
9758c2ecf20Sopenharmony_ci	time64_t sec, days;
9768c2ecf20Sopenharmony_ci	int min, day, month, year;
9778c2ecf20Sopenharmony_ci	u16 date = le16_to_cpu(le_date);
9788c2ecf20Sopenharmony_ci	u16 time = le16_to_cpu(le_time);
9798c2ecf20Sopenharmony_ci	SMB_TIME *st = (SMB_TIME *)&time;
9808c2ecf20Sopenharmony_ci	SMB_DATE *sd = (SMB_DATE *)&date;
9818c2ecf20Sopenharmony_ci
9828c2ecf20Sopenharmony_ci	cifs_dbg(FYI, "date %d time %d\n", date, time);
9838c2ecf20Sopenharmony_ci
9848c2ecf20Sopenharmony_ci	sec = 2 * st->TwoSeconds;
9858c2ecf20Sopenharmony_ci	min = st->Minutes;
9868c2ecf20Sopenharmony_ci	if ((sec > 59) || (min > 59))
9878c2ecf20Sopenharmony_ci		cifs_dbg(VFS, "Invalid time min %d sec %lld\n", min, sec);
9888c2ecf20Sopenharmony_ci	sec += (min * 60);
9898c2ecf20Sopenharmony_ci	sec += 60 * 60 * st->Hours;
9908c2ecf20Sopenharmony_ci	if (st->Hours > 24)
9918c2ecf20Sopenharmony_ci		cifs_dbg(VFS, "Invalid hours %d\n", st->Hours);
9928c2ecf20Sopenharmony_ci	day = sd->Day;
9938c2ecf20Sopenharmony_ci	month = sd->Month;
9948c2ecf20Sopenharmony_ci	if (day < 1 || day > 31 || month < 1 || month > 12) {
9958c2ecf20Sopenharmony_ci		cifs_dbg(VFS, "Invalid date, month %d day: %d\n", month, day);
9968c2ecf20Sopenharmony_ci		day = clamp(day, 1, 31);
9978c2ecf20Sopenharmony_ci		month = clamp(month, 1, 12);
9988c2ecf20Sopenharmony_ci	}
9998c2ecf20Sopenharmony_ci	month -= 1;
10008c2ecf20Sopenharmony_ci	days = day + total_days_of_prev_months[month];
10018c2ecf20Sopenharmony_ci	days += 3652; /* account for difference in days between 1980 and 1970 */
10028c2ecf20Sopenharmony_ci	year = sd->Year;
10038c2ecf20Sopenharmony_ci	days += year * 365;
10048c2ecf20Sopenharmony_ci	days += (year/4); /* leap year */
10058c2ecf20Sopenharmony_ci	/* generalized leap year calculation is more complex, ie no leap year
10068c2ecf20Sopenharmony_ci	for years/100 except for years/400, but since the maximum number for DOS
10078c2ecf20Sopenharmony_ci	 year is 2**7, the last year is 1980+127, which means we need only
10088c2ecf20Sopenharmony_ci	 consider 2 special case years, ie the years 2000 and 2100, and only
10098c2ecf20Sopenharmony_ci	 adjust for the lack of leap year for the year 2100, as 2000 was a
10108c2ecf20Sopenharmony_ci	 leap year (divisable by 400) */
10118c2ecf20Sopenharmony_ci	if (year >= 120)  /* the year 2100 */
10128c2ecf20Sopenharmony_ci		days = days - 1;  /* do not count leap year for the year 2100 */
10138c2ecf20Sopenharmony_ci
10148c2ecf20Sopenharmony_ci	/* adjust for leap year where we are still before leap day */
10158c2ecf20Sopenharmony_ci	if (year != 120)
10168c2ecf20Sopenharmony_ci		days -= ((year & 0x03) == 0) && (month < 2 ? 1 : 0);
10178c2ecf20Sopenharmony_ci	sec += 24 * 60 * 60 * days;
10188c2ecf20Sopenharmony_ci
10198c2ecf20Sopenharmony_ci	ts.tv_sec = sec + offset;
10208c2ecf20Sopenharmony_ci
10218c2ecf20Sopenharmony_ci	/* cifs_dbg(FYI, "sec after cnvrt dos to unix time %d\n",sec); */
10228c2ecf20Sopenharmony_ci
10238c2ecf20Sopenharmony_ci	ts.tv_nsec = 0;
10248c2ecf20Sopenharmony_ci	return ts;
10258c2ecf20Sopenharmony_ci}
1026