DOS error codes
Andrew Tridgell
tridge at osdl.org
Sun Jul 3 11:58:29 GMT 2005
Jeremy,
Just a quick note about the method of handling DOS error codes in
Samba3, as it affects this share mode code that you have been playing
with recently.
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.
Cheers, Tridge
More information about the samba-technical
mailing list