errormap.c

来自「samba最新软件」· C语言 代码 · 共 1,404 行 · 第 1/4 页

C
1,404
字号
	{NT_STATUS(0xc0000284), W_ERROR(0x489)},	{NT_STATUS(0xc0000285), W_ERROR(0x48a)},	{NT_STATUS(0xc0000286), W_ERROR(0x48b)},	{NT_STATUS(0xc0000287), W_ERROR(0x48c)},	{NT_STATUS(0xc000028a), W_ERROR(0x5)},	{NT_STATUS(0xc000028b), W_ERROR(0x5)},	{NT_STATUS(0xc000028d), W_ERROR(0x5)},	{NT_STATUS(0xc000028e), W_ERROR(0x5)},	{NT_STATUS(0xc000028f), W_ERROR(0x5)},	{NT_STATUS(0xc0000290), W_ERROR(0x5)},	{NT_STATUS(0xc0000291), W_ERROR(0x1777)},	{NT_STATUS(0xc0000292), W_ERROR(0x1778)},	{NT_STATUS(0xc0000293), W_ERROR(0x1772)},	{NT_STATUS(0xc0000295), W_ERROR(0x1068)},	{NT_STATUS(0xc0000296), W_ERROR(0x1069)},	{NT_STATUS(0xc0000297), W_ERROR(0x106a)},	{NT_STATUS(0xc0000298), W_ERROR(0x106b)},	{NT_STATUS(0xc0000299), W_ERROR(0x201a)},	{NT_STATUS(0xc000029a), W_ERROR(0x201b)},	{NT_STATUS(0xc000029b), W_ERROR(0x201c)},	{NT_STATUS(0xc000029c), W_ERROR(0x1)},	{NT_STATUS(0xc000029d), W_ERROR(0x10ff)},	{NT_STATUS(0xc000029e), W_ERROR(0x1100)},	{NT_STATUS(0xc000029f), W_ERROR(0x494)},	{NT_STATUS(0xc00002a1), W_ERROR(0x200a)},	{NT_STATUS(0xc00002a2), W_ERROR(0x200b)},	{NT_STATUS(0xc00002a3), W_ERROR(0x200c)},	{NT_STATUS(0xc00002a4), W_ERROR(0x200d)},	{NT_STATUS(0xc00002a5), W_ERROR(0x200e)},	{NT_STATUS(0xc00002a6), W_ERROR(0x200f)},	{NT_STATUS(0xc00002a7), W_ERROR(0x2010)},	{NT_STATUS(0xc00002a8), W_ERROR(0x2011)},	{NT_STATUS(0xc00002a9), W_ERROR(0x2012)},	{NT_STATUS(0xc00002aa), W_ERROR(0x2013)},	{NT_STATUS(0xc00002ab), W_ERROR(0x2014)},	{NT_STATUS(0xc00002ac), W_ERROR(0x2015)},	{NT_STATUS(0xc00002ad), W_ERROR(0x2016)},	{NT_STATUS(0xc00002ae), W_ERROR(0x2017)},	{NT_STATUS(0xc00002af), W_ERROR(0x2018)},	{NT_STATUS(0xc00002b0), W_ERROR(0x2019)},	{NT_STATUS(0xc00002b1), W_ERROR(0x211e)},	{NT_STATUS(0xc00002b2), W_ERROR(0x1127)},	{NT_STATUS(0xc00002b6), W_ERROR(0x651)},	{NT_STATUS(0xc00002b7), W_ERROR(0x49a)},	{NT_STATUS(0xc00002b8), W_ERROR(0x49b)},	{NT_STATUS(0xc00002c1), W_ERROR(0x2024)},	{NT_STATUS(0xc00002c3), W_ERROR(0x575)},	{NT_STATUS(0xc00002c5), W_ERROR(0x3e6)},	{NT_STATUS(0xc00002c6), W_ERROR(0x1075)},	{NT_STATUS(0xc00002c7), W_ERROR(0x1076)},	{NT_STATUS(0xc00002ca), W_ERROR(0x10e8)},	{NT_STATUS(0xc00002cb), W_ERROR(0x2138)},	{NT_STATUS(0xc00002cc), W_ERROR(0x4e3)},	{NT_STATUS(0xc00002cd), W_ERROR(0x2139)},	{NT_STATUS(0xc00002cf), W_ERROR(0x49d)},	{NT_STATUS(0xc00002d0), W_ERROR(0x213a)},	{NT_STATUS(0xc00002d4), W_ERROR(0x2141)},	{NT_STATUS(0xc00002d5), W_ERROR(0x2142)},	{NT_STATUS(0xc00002d6), W_ERROR(0x2143)},	{NT_STATUS(0xc00002d7), W_ERROR(0x2144)},	{NT_STATUS(0xc00002d8), W_ERROR(0x2145)},	{NT_STATUS(0xc00002d9), W_ERROR(0x2146)},	{NT_STATUS(0xc00002da), W_ERROR(0x2147)},	{NT_STATUS(0xc00002db), W_ERROR(0x2148)},	{NT_STATUS(0xc00002dc), W_ERROR(0x2149)},	{NT_STATUS(0xc00002dd), W_ERROR(0x32)},	{NT_STATUS(0xc00002df), W_ERROR(0x2151)},	{NT_STATUS(0xc00002e0), W_ERROR(0x2152)},	{NT_STATUS(0xc00002e1), W_ERROR(0x2153)},	{NT_STATUS(0xc00002e2), W_ERROR(0x2154)},	{NT_STATUS(0xc00002e3), W_ERROR(0x215d)},	{NT_STATUS(0xc00002e4), W_ERROR(0x2163)},	{NT_STATUS(0xc00002e5), W_ERROR(0x2164)},	{NT_STATUS(0xc00002e6), W_ERROR(0x2165)},	{NT_STATUS(0xc00002e7), W_ERROR(0x216d)},	{NT_STATUS(0xc00002fe), W_ERROR(0x45b)},	{NT_STATUS(0xc00002ff), W_ERROR(0x4e7)},	{NT_STATUS(0xc0000300), W_ERROR(0x4e6)},	{NT_STATUS(0x80000001), W_ERROR(0x80000001)},	{NT_STATUS(0x80000002), W_ERROR(0x3e6)},	{NT_STATUS(0x80000003), W_ERROR(0x80000003)},	{NT_STATUS(0x80000004), W_ERROR(0x80000004)},	{NT_STATUS(0x80000005), W_ERROR(0xea)},	{NT_STATUS(0x80000006), W_ERROR(0x12)},	{NT_STATUS(0x8000000b), W_ERROR(0x56f)},	{NT_STATUS(0x8000000d), W_ERROR(0x12b)},	{NT_STATUS(0x8000000e), W_ERROR(0x1c)},	{NT_STATUS(0x8000000f), W_ERROR(0x15)},	{NT_STATUS(0x80000010), W_ERROR(0x15)},	{NT_STATUS(0x80000011), W_ERROR(0xaa)},	{NT_STATUS(0x80000012), W_ERROR(0x103)},	{NT_STATUS(0x80000013), W_ERROR(0xfe)},	{NT_STATUS(0x80000014), W_ERROR(0xff)},	{NT_STATUS(0x80000015), W_ERROR(0xff)},	{NT_STATUS(0x80000016), W_ERROR(0x456)},	{NT_STATUS(0x8000001a), W_ERROR(0x103)},	{NT_STATUS(0x8000001b), W_ERROR(0x44d)},	{NT_STATUS(0x8000001c), W_ERROR(0x456)},	{NT_STATUS(0x8000001d), W_ERROR(0x457)},	{NT_STATUS(0x8000001e), W_ERROR(0x44c)},	{NT_STATUS(0x8000001f), W_ERROR(0x44e)},	{NT_STATUS(0x80000021), W_ERROR(0x44f)},	{NT_STATUS(0x80000022), W_ERROR(0x450)},	{NT_STATUS(0x80000025), W_ERROR(0x962)},	{NT_STATUS(0x80000288), W_ERROR(0x48d)},	{NT_STATUS(0x80000289), W_ERROR(0x48e)},	{NT_STATUS_OK, WERR_OK}};/*  check if a DOS encoded NTSTATUS code maps to the given NTSTATUS code*/bool ntstatus_dos_equal(NTSTATUS status1, NTSTATUS status2){	/* when we negotiate nt status support, we don't want to consider	   the mapping of dos codes, as we want to catch the cases where	   a forced dos code is needed	*/	if (lp_nt_status_support(global_loadparm)) {		return NT_STATUS_V(status1) == NT_STATUS_V(status2);	}	/* otherwise check if the mapping comes out right. Note that it is important	   that we do the mapping only from ntstatus -> dos and not from dos -> ntstatus,	   as that is the mapping that servers must do */	if (!NT_STATUS_IS_DOS(status1) && NT_STATUS_IS_DOS(status2)) {		uint8_t eclass;		uint32_t ecode;		ntstatus_to_dos(status1, &eclass, &ecode);		return eclass == NT_STATUS_DOS_CLASS(status2) &&			ecode == NT_STATUS_DOS_CODE(status2);	}	if (NT_STATUS_IS_DOS(status1) && !NT_STATUS_IS_DOS(status2)) {		uint8_t eclass;		uint32_t ecode;		ntstatus_to_dos(status2, &eclass, &ecode);		return eclass == NT_STATUS_DOS_CLASS(status1) &&			ecode == NT_STATUS_DOS_CODE(status1);	}	return NT_STATUS_V(status1) == NT_STATUS_V(status2);}/*****************************************************************************convert a NT status code to a dos class/code *****************************************************************************/void ntstatus_to_dos(NTSTATUS ntstatus, uint8_t *eclass, uint32_t *ecode){	int i;	if (NT_STATUS_IS_OK(ntstatus)) {		*eclass = 0;		*ecode = 0;		return;	}	if (NT_STATUS_IS_DOS(ntstatus)) {		*eclass = NT_STATUS_DOS_CLASS(ntstatus);		*ecode  = NT_STATUS_DOS_CODE(ntstatus);		return;	}	for (i=0; NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus); i++) {		if (NT_STATUS_V(ntstatus) == 		    NT_STATUS_V(ntstatus_to_dos_map[i].ntstatus)) {			*eclass = ntstatus_to_dos_map[i].dos_class;			*ecode = ntstatus_to_dos_map[i].dos_code;			return;		}	}	*eclass = ERRHRD;	*ecode = ERRgeneral;}/*****************************************************************************convert a WERROR to a NT status32 code *****************************************************************************/NTSTATUS werror_to_ntstatus(WERROR error){	int i;	if (W_ERROR_IS_OK(error)) return NT_STATUS_OK;	for (i=0; NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus); i++) {		if (W_ERROR_V(error) == 		    W_ERROR_V(ntstatus_to_werror_map[i].werror)) {			return ntstatus_to_werror_map[i].ntstatus;		}	}	/* just guess ... */	return NT_STATUS(W_ERROR_V(error) | 0xc0000000);}/*****************************************************************************convert a NTSTATUS to a WERROR *****************************************************************************/WERROR ntstatus_to_werror(NTSTATUS error){	int i;	if (NT_STATUS_IS_OK(error)) return WERR_OK;	for (i=0; NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus); i++) {		if (NT_STATUS_V(error) == 		    NT_STATUS_V(ntstatus_to_werror_map[i].ntstatus)) {			return ntstatus_to_werror_map[i].werror;		}	}	/* a lame guess */	return W_ERROR(NT_STATUS_V(error) & 0xffff);}/* Mapping between Unix, DOS and NT error numbers */struct unix_error_map {	int unix_error;	NTSTATUS nt_error;};const struct unix_error_map unix_nt_errmap[] = {	{ EAGAIN,       STATUS_MORE_ENTRIES },	{ EINTR,        STATUS_MORE_ENTRIES },	{ ENOBUFS,      STATUS_MORE_ENTRIES },#ifdef EWOULDBLOCK	{ EWOULDBLOCK,  STATUS_MORE_ENTRIES },#endif	{ EINPROGRESS,  NT_STATUS_MORE_PROCESSING_REQUIRED },	{ EPERM,        NT_STATUS_ACCESS_DENIED },	{ EACCES,       NT_STATUS_ACCESS_DENIED },	{ ENOENT,       NT_STATUS_OBJECT_NAME_NOT_FOUND },	{ ENOTDIR,      NT_STATUS_NOT_A_DIRECTORY },	{ EIO,          NT_STATUS_IO_DEVICE_ERROR },	{ EBADF,        NT_STATUS_INVALID_HANDLE },	{ EINVAL,       NT_STATUS_INVALID_PARAMETER },	{ EEXIST,       NT_STATUS_OBJECT_NAME_COLLISION},	{ ENFILE,       NT_STATUS_TOO_MANY_OPENED_FILES },	{ EMFILE,       NT_STATUS_TOO_MANY_OPENED_FILES },	{ ENOSPC,       NT_STATUS_DISK_FULL },	{ EISDIR,       NT_STATUS_FILE_IS_A_DIRECTORY },	{ ENOTSOCK,     NT_STATUS_INVALID_HANDLE },	{ EFAULT,       NT_STATUS_INVALID_PARAMETER },	{ EMSGSIZE,     NT_STATUS_INVALID_BUFFER_SIZE },	{ ENOMEM,       NT_STATUS_NO_MEMORY },	{ EPIPE,        NT_STATUS_CONNECTION_DISCONNECTED },	{ ECONNREFUSED, NT_STATUS_CONNECTION_REFUSED },#ifdef ECONNRESET	{ ECONNRESET,   NT_STATUS_CONNECTION_RESET },#endif	{ EBUSY,        NT_STATUS_SHARING_VIOLATION },#ifdef ENOTSUP	{ ENOTSUP,      NT_STATUS_NOT_SUPPORTED},#endif#ifdef EOPNOTSUPP	{ EOPNOTSUPP,   NT_STATUS_NOT_SUPPORTED},#endif#ifdef EHOSTUNREACH	{ EHOSTUNREACH, NT_STATUS_HOST_UNREACHABLE },#endif#ifdef ENETUNREACH	{ ENETUNREACH,  NT_STATUS_NETWORK_UNREACHABLE },#endif#ifdef ETIMEDOUT	{ ETIMEDOUT,    NT_STATUS_IO_TIMEOUT },#endif#ifdef EADDRINUSE	{ EADDRINUSE,   NT_STATUS_ADDRESS_ALREADY_ASSOCIATED },#endif#ifdef ENOATTR	{ ENOATTR,      NT_STATUS_NOT_FOUND },#endif#ifdef ENODATA	{ ENODATA,      NT_STATUS_NOT_FOUND },#endif#ifdef EDQUOT	{ EDQUOT,       NT_STATUS_QUOTA_EXCEEDED },#endif#ifdef ENOTEMPTY	{ ENOTEMPTY,    NT_STATUS_DIRECTORY_NOT_EMPTY },#endif#ifdef EXDEV	{ EXDEV,        NT_STATUS_NOT_SAME_DEVICE },#endif#ifdef EROFS	{ EROFS,        NT_STATUS_MEDIA_WRITE_PROTECTED },#endif#ifdef ENAMETOOLONG	{ ENAMETOOLONG, NT_STATUS_NAME_TOO_LONG },#endif#ifdef EFBIG	{ EFBIG,        NT_STATUS_DISK_FULL },#endif#ifdef EADDRNOTAVAIL	{ EADDRNOTAVAIL,NT_STATUS_ADDRESS_NOT_ASSOCIATED },#endif#ifdef ESOCKTNOSUPPORT	{ ESOCKTNOSUPPORT,NT_STATUS_INVALID_PARAMETER_MIX },#endif#ifdef EAFNOSUPPORT	{ EAFNOSUPPORT,	NT_STATUS_INVALID_PARAMETER_MIX },#endif#ifdef ENOPROTOOPT	{ ENOPROTOOPT,	NT_STATUS_INVALID_PARAMETER_MIX },#endif#ifdef ENODEV	{ ENODEV,	NT_STATUS_NO_SUCH_DEVICE },#endif#ifdef ENOSYS	{ ENOSYS,	NT_STATUS_INVALID_SYSTEM_SERVICE },#endif	{ 0, NT_STATUS_UNSUCCESSFUL }};/********************************************************************* Map an NT error code from a Unix error code.*********************************************************************/NTSTATUS map_nt_error_from_unix(int unix_error){	int i;	/* Look through list */	for (i=0;i<ARRAY_SIZE(unix_nt_errmap);i++) {		if (unix_nt_errmap[i].unix_error == unix_error) {			return unix_nt_errmap[i].nt_error;		}	}	/* Default return */	return NT_STATUS_UNSUCCESSFUL;}NTSTATUS ndr_map_error2ntstatus(enum ndr_err_code ndr_err){	switch (ndr_err) {	case NDR_ERR_SUCCESS:		return NT_STATUS_OK;	case NDR_ERR_BUFSIZE:		return NT_STATUS_BUFFER_TOO_SMALL;	case NDR_ERR_TOKEN:		return NT_STATUS_INTERNAL_ERROR;	case NDR_ERR_ALLOC:		return NT_STATUS_NO_MEMORY;	case NDR_ERR_ARRAY_SIZE:		return NT_STATUS_ARRAY_BOUNDS_EXCEEDED;	case NDR_ERR_INVALID_POINTER:		return NT_STATUS_INVALID_PARAMETER_MIX;	case NDR_ERR_UNREAD_BYTES:		return NT_STATUS_PORT_MESSAGE_TOO_LONG;	default:		break;	}	/* we should map all error codes to different status codes */	return NT_STATUS_INVALID_PARAMETER;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?