From 2b0de5b5ca1196a39379dcd86a25b6e73c52cf3c Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Wed, 4 May 2011 16:51:23 +1000 Subject: errors: Merge source3/ werror_to_ntstatus() code to source4/ --- source4/libcli/util/errormap.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'source4/libcli/util') diff --git a/source4/libcli/util/errormap.c b/source4/libcli/util/errormap.c index ef0d482388..68a8e5e0ea 100644 --- a/source4/libcli/util/errormap.c +++ b/source4/libcli/util/errormap.c @@ -621,11 +621,6 @@ static const struct { NTSTATUS ntstatus; WERROR werror; } ntstatus_to_werror_map[] = { - /* - * we add this manualy here, so that W_ERROR(0x5) - * gets mapped to NTSTATUS_ACCESS_DENIED - */ - {NT_STATUS_ACCESS_DENIED, WERR_ACCESS_DENIED}, {NT_STATUS(0x103), W_ERROR(0x3e5)}, {NT_STATUS(0x105), W_ERROR(0xea)}, {NT_STATUS(0x106), W_ERROR(0x514)}, @@ -1160,7 +1155,14 @@ static const struct { {NT_STATUS(0x80000025), W_ERROR(0x962)}, {NT_STATUS(0x80000288), W_ERROR(0x48d)}, {NT_STATUS(0x80000289), W_ERROR(0x48e)}, - {NT_STATUS_OK, WERR_OK} + {NT_STATUS_OK, WERR_OK}}; + +static const struct { + WERROR werror; + NTSTATUS ntstatus; +} werror_to_ntstatus_map[] = { + { W_ERROR(0x5), NT_STATUS_ACCESS_DENIED }, + { WERR_OK, NT_STATUS_OK } }; bool ntstatus_check_dos_mapping = true; @@ -1234,6 +1236,14 @@ NTSTATUS werror_to_ntstatus(WERROR error) { int i; if (W_ERROR_IS_OK(error)) return NT_STATUS_OK; + + for (i=0; !W_ERROR_IS_OK(werror_to_ntstatus_map[i].werror); i++) { + if (W_ERROR_V(error) == + W_ERROR_V(werror_to_ntstatus_map[i].werror)) { + return werror_to_ntstatus_map[i].ntstatus; + } + } + 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)) { -- cgit