From 3e3400e422129a8a19d180c4e37689294d927ecb Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Sat, 3 Sep 2011 20:09:20 -0400 Subject: [PATCH] Windows: tailor smb_MapNTError output for redirector Separate mappings apply for the afs redirector. Add a boolean parameter to the function signature that is set true when the call requires the redirector mapping. Change-Id: Ib2892b6c78047f3f1d289e31c4236ea90d8026ab Reviewed-on: http://gerrit.openafs.org/5351 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- src/WINNT/afsd/smb.c | 32 ++++++++++++++++++++------------ src/WINNT/afsd/smb.h | 2 +- src/WINNT/afsd/smb3.c | 4 ++-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c index bf2c50968c..24cd62a040 100644 --- a/src/WINNT/afsd/smb.c +++ b/src/WINNT/afsd/smb.c @@ -3078,7 +3078,7 @@ void smb_SendPacket(smb_vc_t *vcp, smb_packet_t *inp) smb_FreeNCB(ncbp); } -void smb_MapNTError(long code, unsigned long *NTStatusp) +void smb_MapNTError(long code, unsigned long *NTStatusp, afs_uint32 redir) { unsigned long NTStatus; @@ -3094,26 +3094,34 @@ void smb_MapNTError(long code, unsigned long *NTStatusp) NTStatus = 0xC0000034L; /* Name not found */ } else if (code == CM_ERROR_TIMEDOUT) { + if (redir) + NTStatus = 0xC0020052L; /* RPC_NT_COMM_FAILURE */ + else { #ifdef COMMENT - NTStatus = 0xC00000CFL; /* Sharing Paused */ + NTStatus = 0xC00000CFL; /* Sharing Paused */ - /* Do not send Timeout to the SMB redirector. - * It causes the redirector to drop the connection */ - NTStatus = 0x00000102L; /* Timeout */ - /* do not send Retry to the SMB redirector. - * It believes the error comes from the transport - * layer not from the SMB server. */ - NTStatus = 0xC000022DL; /* Retry */ + /* Do not send Timeout to the SMB redirector. + * It causes the redirector to drop the connection */ + NTStatus = 0x00000102L; /* Timeout */ + /* do not send Retry to the SMB redirector. + * It believes the error comes from the transport + * layer not from the SMB server. */ + NTStatus = 0xC000022DL; /* Retry */ #else - NTStatus = 0xC00000B5L; /* I/O Timeout */ + NTStatus = 0xC00000B5L; /* I/O Timeout */ #endif + } } else if (code == CM_ERROR_RETRY) { + if (redir) + NTStatus = 0xC000022DL; /* Retry */ + else { #ifdef COMMENT NTStatus = 0xC000022DL; /* Retry */ #else NTStatus = 0xC00000B5L; /* I/O Timeout */ #endif + } } else if (code == CM_ERROR_NOACCESS) { NTStatus = 0xC0000022L; /* Access denied */ @@ -8691,7 +8699,7 @@ void smb_DispatchPacket(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp, */ if (code) { if (vcp->flags & SMB_VCFLAG_STATUS32) { - smb_MapNTError(code, &NTStatus); + smb_MapNTError(code, &NTStatus, FALSE); outWctp = outp->wctp; smbp = (smb_t *) &outp->data; if (code != CM_ERROR_PARTIALWRITE @@ -9892,7 +9900,7 @@ void smb_Listener(void *parmp) if (vcp->flags & SMB_VCFLAG_STATUS32) { unsigned long NTStatus; - smb_MapNTError(code, &NTStatus); + smb_MapNTError(code, &NTStatus, FALSE); outWctp = outp->wctp; smbp = (smb_t *) &outp->data; *outWctp++ = 0; diff --git a/src/WINNT/afsd/smb.h b/src/WINNT/afsd/smb.h index f44e0da2b7..23db04abda 100644 --- a/src/WINNT/afsd/smb.h +++ b/src/WINNT/afsd/smb.h @@ -733,7 +733,7 @@ extern void smb_SendPacket(smb_vc_t *vcp, smb_packet_t *inp); extern void smb_MapCoreError(long code, smb_vc_t *vcp, unsigned short *scodep, unsigned char *classp); -extern void smb_MapNTError(long code, unsigned long *NTStatusp); +extern void smb_MapNTError(long code, unsigned long *NTStatusp, afs_uint32 redir); extern void smb_MapWin32Error(long code, unsigned long *Win32Ep); diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c index 2832f28c76..af59a38525 100644 --- a/src/WINNT/afsd/smb3.c +++ b/src/WINNT/afsd/smb3.c @@ -1499,7 +1499,7 @@ void smb_SendTran2Error(smb_vc_t *vcp, smb_tran2Packet_t *t2p, unsigned long NTStatus; if (vcp->flags & SMB_VCFLAG_STATUS32) - smb_MapNTError(code, &NTStatus); + smb_MapNTError(code, &NTStatus, FALSE); else smb_MapCoreError(code, vcp, &errCode, &errClass); @@ -1562,7 +1562,7 @@ void smb_SendTran2Packet(smb_vc_t *vcp, smb_tran2Packet_t *t2p, smb_packet_t *tp if (vcp->flags & SMB_VCFLAG_STATUS32) { unsigned long NTStatus; - smb_MapNTError(t2p->error_code, &NTStatus); + smb_MapNTError(t2p->error_code, &NTStatus, FALSE); smbp->rcls = (unsigned char) (NTStatus & 0xff); smbp->reh = (unsigned char) ((NTStatus >> 8) & 0xff);