DOS error codes

Jeremy Allison jra at samba.org
Sun Jul 3 15:45:55 GMT 2005


On Sun, Jul 03, 2005 at 09:58:29PM +1000, Andrew Tridgell wrote:
> 
> I found a good way of handling places that need DOS error codes for
> functions that return NTSTATUS. What we do is this:
> 
> #define NT_STATUS_DOS(class, code) NT_STATUS(0xF1000000 | ((class)<<16) | code)
> #define NT_STATUS_IS_DOS(status) ((NT_STATUS_V(status) & 0xFF000000) == 0xF1000000)
> #define NT_STATUS_DOS_CLASS(status) ((NT_STATUS_V(status) >> 16) & 0xFF)
> #define NT_STATUS_DOS_CODE(status) (NT_STATUS_V(status) & 0xFFFF)
> 
> then you do this:
> 
>   NTSTATUS status;
> 
>   status = NT_STATUS_DOS(ERRSRV, ERRbaduid);
> 
> and you can pass around a NTSTATUS all you like. When you finally put
> the error onto the wire, you call NT_STATUS_IS_DOS() and separate it
> out.
> 
> It relies on using some of the reserved bits at the top of NT status
> codes for DOS codes. I've started using a similar technique for LDAP
> codes recently.
> 
> The main advantage of this technique is it gets rid of those
> override_ERR_xxx globals, and allows you to just make functions that
> return NTSTATUS.

Yes, I've been slowly cleaning up the use of those globals (at least
access to them is now abstracted into accessor functions).

Are you sure using the reserved bits is safe ? What is the purpose
of them - any possibility Microsoft may change something and start
using them ? (Although with a 32-bit space there's probably always
going to be places we can hide stuff :-).

I'm trying not to be too radical in my changing of Samba3 though.
Much of the error code stuff is quite brittle, and I want to make
sure we keep returning the correct error codes for Win9x.

Is there a way to run the Samba4 torture tester in DOS error
code mode ? That way we could be sure of returning the correct
mapping for NTSTATUS error codes.

Jeremy.


More information about the samba-technical mailing list