Windows: tailor smb_MapNTError output for redirector
authorJeffrey Altman <jaltman@your-file-system.com>
Sun, 4 Sep 2011 00:09:20 +0000 (20:09 -0400)
committerJeffrey Altman <jaltman@openafs.org>
Mon, 5 Sep 2011 14:02:44 +0000 (07:02 -0700)
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 <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>

src/WINNT/afsd/smb.c
src/WINNT/afsd/smb.h
src/WINNT/afsd/smb3.c

index bf2c509..24cd62a 100644 (file)
@@ -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,27 +3094,35 @@ 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 */
-
-        /* 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 */
+            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 */
 #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;
index f44e0da..23db04a 100644 (file)
@@ -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);
 
index 2832f28..af59a38 100644 (file)
@@ -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);