Index: openafs/src/JAVA/classes/org/openafs/jafs/Token.java
diff -c openafs/src/JAVA/classes/org/openafs/jafs/Token.java:1.3 openafs/src/JAVA/classes/org/openafs/jafs/Token.java:1.3.4.1
*** openafs/src/JAVA/classes/org/openafs/jafs/Token.java:1.3	Fri Oct 14 22:12:23 2005
--- openafs/src/JAVA/classes/org/openafs/jafs/Token.java	Fri Dec 14 16:35:55 2007
***************
*** 144,149 ****
--- 144,163 ----
    }
  
    /**
+    * Constructs a new <CODE>Token</CODE> object instance given the
+    * name of the AFS cell it represents; the token for administrative
+    * access will be extracted from the kernel cache manager if possible.
+    *
+    * @param cellName    the name of the cell to Token into
+    * @exception AFSException  If an error occurs in the native code
+    */
+   public Token(String cellName) 
+       throws AFSException
+   {
+       this(null, null, cellName);
+   }
+ 
+   /**
     * Constructs a new <CODE>Token</CODE> object instance given 
     * the name of the AFS cell it represents and the username and password 
     * of the user to be Tokend for 
Index: openafs/src/JAVA/libjafs/AdminToken.c
diff -c openafs/src/JAVA/libjafs/AdminToken.c:1.4 openafs/src/JAVA/libjafs/AdminToken.c:1.4.4.1
*** openafs/src/JAVA/libjafs/AdminToken.c:1.4	Fri Oct 14 22:12:24 2005
--- openafs/src/JAVA/libjafs/AdminToken.c	Fri Dec 14 16:35:56 2007
***************
*** 30,35 ****
--- 30,36 ----
  #include <kautils.h>
  #include <cellconfig.h>
  #include <afs_AdminClientErrors.h>
+ #include <rx/rxkad.h>
  
  /**
   * Static function used to initialize the client library and the 
***************
*** 71,76 ****
--- 72,78 ----
    const char *password;
    void *tokenHandle;
    int rc;
+   int err;
  
    // convert java strings
    if( jcellName != NULL ) { 
***************
*** 101,108 ****
        password = NULL;
    }
  
!   if ( !(afsclient_TokenGetNew( cellName, userName, password, &tokenHandle, 
! 				&ast) ) ) {
      // release converted strings
        if( cellName != NULL ) {
  	  (*env)->ReleaseStringUTFChars(env, jcellName, cellName);
--- 103,113 ----
        password = NULL;
    }
  
!   err = (password==NULL || userName==NULL)
!     ? afsclient_TokenGetExisting( cellName, &tokenHandle, &ast)
!     : afsclient_TokenGetNew( cellName, userName, password, &tokenHandle, &ast);
! 
!   if ( !err ) {
      // release converted strings
        if( cellName != NULL ) {
  	  (*env)->ReleaseStringUTFChars(env, jcellName, cellName);
Index: openafs/src/JAVA/libjafs/Makefile.in
diff -c openafs/src/JAVA/libjafs/Makefile.in:1.4 openafs/src/JAVA/libjafs/Makefile.in:1.4.4.1
*** openafs/src/JAVA/libjafs/Makefile.in:1.4	Fri Oct 14 22:12:25 2005
--- openafs/src/JAVA/libjafs/Makefile.in	Fri Dec 14 16:35:56 2007
***************
*** 13,19 ****
  TOP_INCDIR=@TOP_INCDIR@
  TOP_LIBDIR=@TOP_LIBDIR@
  TOP_JLIBDIR=@TOP_SRCDIR@/JAVA/libjafs
! JNI_INC=${JAVA_HOME}/include
  prefix=@prefix@
  exec_prefix=@exec_prefix@
  bindir=@bindir@
--- 13,19 ----
  TOP_INCDIR=@TOP_INCDIR@
  TOP_LIBDIR=@TOP_LIBDIR@
  TOP_JLIBDIR=@TOP_SRCDIR@/JAVA/libjafs
! JNI_INC=-I ${JAVA_HOME}/include -I `dirname ${JAVA_HOME}/include/*/jni_md.h`
  prefix=@prefix@
  exec_prefix=@exec_prefix@
  bindir=@bindir@
***************
*** 35,44 ****
  OBJECT_FLAGS = -fPIC -c
  
  ifeq "$(BUILD_TYPE)" "admin"
! 	INC := -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ -I${JAVA_HOME}/include -I ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} -I${TOP_SRCDIR}/config ${MT_CFLAGS}
  else
! 	INC := -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} -I${JAVA_HOME}/include -I ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} ${FSINCLUDES} -D_REENTRANT -DLIBJUAFS ${MT_CFLAGS}
  endif
  
--- 35,44 ----
  OBJECT_FLAGS = -fPIC -c
  
  ifeq "$(BUILD_TYPE)" "admin"
! 	INC := -I${TOP_INCDIR} -I${TOP_INCDIR}/afs/ ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} -I${TOP_SRCDIR}/config ${MT_CFLAGS}
  else
! 	INC := -I${TOP_SRCDIR}/libuafs -I${TOP_INCDIR} ${JNI_INC}
  	CFLAGS := ${INC} ${DBG} ${OPTMZ} ${FSINCLUDES} -D_REENTRANT -DLIBJUAFS ${MT_CFLAGS}
  endif
  
***************
*** 50,56 ****
  JAVADOCSDIR = javadocs/
  
  JAVAH = ${JAVA_HOME}/bin/javah -classpath ${ROOTPACKAGEDIR} -jni -d ${LIBJAFSADMDIR}
! JAVAC = ${JAVA_HOME}/bin/javac -classpath ${ROOTPACKAGEDIR}
  
  J_NATIVE_PREFIX = org.openafs.jafs.
  C_NATIVE_PREFIX = org_openafs_jafs_
--- 50,56 ----
  JAVADOCSDIR = javadocs/
  
  JAVAH = ${JAVA_HOME}/bin/javah -classpath ${ROOTPACKAGEDIR} -jni -d ${LIBJAFSADMDIR}
! JAVAC = ${JAVA_HOME}/bin/javac -source 1.4 -classpath ${ROOTPACKAGEDIR}
  
  J_NATIVE_PREFIX = org.openafs.jafs.
  C_NATIVE_PREFIX = org_openafs_jafs_
***************
*** 153,158 ****
--- 153,159 ----
  
  LIBJAFS_LIBS =\
  	${TOP_LIBDIR}/libjuafs.a \
+ 	${TOP_LIBDIR}/libafsutil.a \
  	${TOP_LIBDIR}/libdes.a \
  	-lresolv \
  	-lpthread
Index: openafs/src/WINNT/afsd/afsd.h
diff -c openafs/src/WINNT/afsd/afsd.h:1.18.2.5 openafs/src/WINNT/afsd/afsd.h:1.18.2.6
*** openafs/src/WINNT/afsd/afsd.h:1.18.2.5	Thu Nov 29 11:11:43 2007
--- openafs/src/WINNT/afsd/afsd.h	Sat Dec 22 23:52:58 2007
***************
*** 127,133 ****
  
  extern HANDLE WaitToTerminate;
  
! #undef  DFS_SUPPORT
  #define LOG_PACKET 1
  #undef  NOTSERVICE
  #define LOCK_TESTING 1
--- 127,133 ----
  
  extern HANDLE WaitToTerminate;
  
! #define DFS_SUPPORT 1
  #define LOG_PACKET 1
  #undef  NOTSERVICE
  #define LOCK_TESTING 1
Index: openafs/src/WINNT/afsd/afsd_init.c
diff -c openafs/src/WINNT/afsd/afsd_init.c:1.79.2.22 openafs/src/WINNT/afsd/afsd_init.c:1.79.2.23
*** openafs/src/WINNT/afsd/afsd_init.c:1.79.2.22	Fri Dec  7 11:05:22 2007
--- openafs/src/WINNT/afsd/afsd_init.c	Mon Dec 24 00:24:14 2007
***************
*** 752,760 ****
      dummyLen = sizeof(numBkgD);
      code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL,
                              (BYTE *) &numBkgD, &dummyLen);
!     if (code == ERROR_SUCCESS)
          afsi_log("%d background daemons", numBkgD);
!     else {
          numBkgD = CM_CONFIGDEFAULT_DAEMONS;
          afsi_log("Defaulting to %d background daemons", numBkgD);
      }
--- 752,762 ----
      dummyLen = sizeof(numBkgD);
      code = RegQueryValueEx(parmKey, "Daemons", NULL, NULL,
                              (BYTE *) &numBkgD, &dummyLen);
!     if (code == ERROR_SUCCESS) {
!         if (numBkgD > CM_MAX_DAEMONS)
!             numBkgD = CM_MAX_DAEMONS;
          afsi_log("%d background daemons", numBkgD);
!     } else {
          numBkgD = CM_CONFIGDEFAULT_DAEMONS;
          afsi_log("Defaulting to %d background daemons", numBkgD);
      }
Index: openafs/src/WINNT/afsd/afsd_service.c
diff -c openafs/src/WINNT/afsd/afsd_service.c:1.52.4.18 openafs/src/WINNT/afsd/afsd_service.c:1.52.4.19
*** openafs/src/WINNT/afsd/afsd_service.c:1.52.4.18	Sun Nov  4 19:24:45 2007
--- openafs/src/WINNT/afsd/afsd_service.c	Sat Dec 22 23:52:58 2007
***************
*** 1305,1310 ****
--- 1305,1313 ----
          SetServiceStatus(StatusHandle, &ServiceStatus);
  #endif
  
+         /* Notify any volume status handlers that the cache manager has started */
+         cm_VolStatus_Service_Started();
+ 
  /* the following ifdef chooses the mode of operation for the service.  to enable
   * a runtime flag (instead of compile-time), pioctl() would need to dynamically
   * determine the mode, in order to use the correct ioctl special-file path. */
***************
*** 1367,1375 ****
  	LogEvent(EVENTLOG_INFORMATION_TYPE, MSG_SERVICE_RUNNING);
      }
  
-     /* Notify any volume status handlers that we have started */
-     cm_VolStatus_Service_Started();
- 
      /* allow an exit to be called when started */
      hHookDll = LoadLibrary(AFSD_HOOK_DLL);
      if (hHookDll)
--- 1370,1375 ----
Index: openafs/src/WINNT/afsd/afslogon.c
diff -c openafs/src/WINNT/afsd/afslogon.c:1.45.2.11 openafs/src/WINNT/afsd/afslogon.c:1.45.2.12
*** openafs/src/WINNT/afsd/afslogon.c:1.45.2.11	Tue Apr 17 00:04:36 2007
--- openafs/src/WINNT/afsd/afslogon.c	Tue Dec 11 23:25:38 2007
***************
*** 1230,1236 ****
  	    /* We can't use pInfo->Domain for the domain since in the cross realm case 
  	     * this is source domain and not the destination domain.
  	     */
! 	    if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
  		WCHAR Domain[64]=L"";
  		GetLocalShortDomain(Domain, sizeof(Domain));
  		if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
--- 1230,1236 ----
  	    /* We can't use pInfo->Domain for the domain since in the cross realm case 
  	     * this is source domain and not the destination domain.
  	     */
! 	    if (tokenUser && QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
  		WCHAR Domain[64]=L"";
  		GetLocalShortDomain(Domain, sizeof(Domain));
  		if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
***************
*** 1342,1348 ****
      /* We can't use pInfo->Domain for the domain since in the cross realm case 
       * this is source domain and not the destination domain.
       */
!     if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
          WCHAR Domain[64]=L"";
          GetLocalShortDomain(Domain, sizeof(Domain));
          if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
--- 1342,1348 ----
      /* We can't use pInfo->Domain for the domain since in the cross realm case 
       * this is source domain and not the destination domain.
       */
!     if (tokenUser && QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
          WCHAR Domain[64]=L"";
          GetLocalShortDomain(Domain, sizeof(Domain));
          if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
Index: openafs/src/WINNT/afsd/cm.h
diff -c openafs/src/WINNT/afsd/cm.h:1.17.2.6 openafs/src/WINNT/afsd/cm.h:1.17.2.7
*** openafs/src/WINNT/afsd/cm.h:1.17.2.6	Thu Aug 30 22:56:59 2007
--- openafs/src/WINNT/afsd/cm.h	Sat Dec 22 23:52:58 2007
***************
*** 303,308 ****
--- 303,309 ----
  #define CM_ERROR_NOT_A_DFSLINK          (CM_ERROR_BASE+53)
  #define CM_ERROR_INEXACT_MATCH          (CM_ERROR_BASE+54)
  #define CM_ERROR_BPLUS_NOMATCH          (CM_ERROR_BASE+55)
+ #define CM_ERROR_EAS_NOT_SUPPORTED      (CM_ERROR_BASE+56)
  
  /* Used by cm_FollowMountPoint and cm_GetVolumeByName */
  #define RWVOL	0
Index: openafs/src/WINNT/afsd/cm_buf.c
diff -c openafs/src/WINNT/afsd/cm_buf.c:1.31.2.24 openafs/src/WINNT/afsd/cm_buf.c:1.31.2.25
*** openafs/src/WINNT/afsd/cm_buf.c:1.31.2.24	Wed Nov 14 12:19:41 2007
--- openafs/src/WINNT/afsd/cm_buf.c	Mon Dec 10 15:35:06 2007
***************
*** 700,718 ****
          i = BUF_HASH(&bp->fid, &bp->offset);
          lbpp = &(cm_data.buf_scacheHashTablepp[i]);
          for(tbp = *lbpp; tbp; lbpp = &tbp->hashp, tbp = *lbpp) {
!             if (tbp == bp) break;
          }
  
          /* we better find it */
          osi_assertx(tbp != NULL, "buf_Recycle: hash table screwup");
  
          *lbpp = bp->hashp;	/* hash out */
  
          /* Remove from file hash */
  
          i = BUF_FILEHASH(&bp->fid);
          prevBp = bp->fileHashBackp;
          nextBp = bp->fileHashp;
          if (prevBp)
              prevBp->fileHashp = nextBp;
          else
--- 700,722 ----
          i = BUF_HASH(&bp->fid, &bp->offset);
          lbpp = &(cm_data.buf_scacheHashTablepp[i]);
          for(tbp = *lbpp; tbp; lbpp = &tbp->hashp, tbp = *lbpp) {
!             if (tbp == bp) 
!                 break;
          }
  
          /* we better find it */
          osi_assertx(tbp != NULL, "buf_Recycle: hash table screwup");
  
          *lbpp = bp->hashp;	/* hash out */
+         bp->hashp = NULL;
  
          /* Remove from file hash */
  
          i = BUF_FILEHASH(&bp->fid);
          prevBp = bp->fileHashBackp;
+         bp->fileHashBackp = NULL;
          nextBp = bp->fileHashp;
+         bp->fileHashp = NULL;
          if (prevBp)
              prevBp->fileHashp = nextBp;
          else
***************
*** 1560,1566 ****
  
      i = BUF_FILEHASH(&scp->fid);
  
!     lock_ObtainWrite(&buf_globalLock);
  
      for (bp = cm_data.buf_fileHashTablepp[i]; bp; bp = bp->fileHashp) {
          if (cm_FidCmp(&bp->fid, &scp->fid) == 0) {
--- 1564,1570 ----
  
      i = BUF_FILEHASH(&scp->fid);
  
!     lock_ObtainRead(&buf_globalLock);
  
      for (bp = cm_data.buf_fileHashTablepp[i]; bp; bp = bp->fileHashp) {
          if (cm_FidCmp(&bp->fid, &scp->fid) == 0) {
***************
*** 1570,1576 ****
              }
          }
      }
!     lock_ReleaseWrite(&buf_globalLock);
  
      if (found)
          return 0;
--- 1574,1580 ----
              }
          }
      }
!     lock_ReleaseRead(&buf_globalLock);
  
      if (found)
          return 0;
Index: openafs/src/WINNT/afsd/cm_callback.c
diff -c openafs/src/WINNT/afsd/cm_callback.c:1.41.4.24 openafs/src/WINNT/afsd/cm_callback.c:1.41.4.28
*** openafs/src/WINNT/afsd/cm_callback.c:1.41.4.24	Tue Dec  4 10:48:48 2007
--- openafs/src/WINNT/afsd/cm_callback.c	Wed Dec 26 11:22:19 2007
***************
*** 359,365 ****
      unsigned long host = 0;
      unsigned short port = 0;
      cm_server_t *tsp = NULL;
!     cm_cell_t * cellp = NULL;
  
      MUTEX_ENTER(&callp->lock);
  
--- 359,365 ----
      unsigned long host = 0;
      unsigned short port = 0;
      cm_server_t *tsp = NULL;
!     cm_cell_t* cellp = NULL;
  
      MUTEX_ENTER(&callp->lock);
  
***************
*** 370,380 ****
          tsp = cm_FindServerByIP(host, CM_SERVER_FILE);
          if (tsp)
              cellp = tsp->cellp;
      }
  
-     osi_Log2(afsd_logp, "SRXAFSCB_CallBack from host 0x%x port %d",
-               ntohl(host),
-               ntohs(port));
  
      for (i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) {
          tfidp = &fidsArrayp->AFSCBFids_val[i];
--- 370,389 ----
          tsp = cm_FindServerByIP(host, CM_SERVER_FILE);
          if (tsp)
              cellp = tsp->cellp;
+ 
+         if (cellp)
+             osi_Log2(afsd_logp, "SRXAFSCB_CallBack from host 0x%x port %d",
+                      ntohl(host),
+                      ntohs(port));
+         else 
+             osi_Log3(afsd_logp, "SRXAFSCB_CallBack from host 0x%x port %d for cell %s",
+                      ntohl(host),
+                      ntohs(port),
+                      cellp->name /* does not need to be saved, doesn't change */);
+     } else {
+         osi_Log0(afsd_logp, "SRXAFSCB_CallBack from unknown host");
      }
  
  
      for (i=0; i < (long) fidsArrayp->AFSCBFids_len; i++) {
          tfidp = &fidsArrayp->AFSCBFids_val[i];
***************
*** 1842,1848 ****
          
      osi_Log0(afsd_logp, "CheckCBExpiration");
  
!     now = osi_Time();
      lock_ObtainWrite(&cm_scacheLock);
      for (i=0; i<cm_data.scacheHashTableSize; i++) {
          for (scp = cm_data.scacheHashTablep[i]; scp; scp=scp->nextp) {
--- 1851,1857 ----
          
      osi_Log0(afsd_logp, "CheckCBExpiration");
  
!     now = time(NULL);
      lock_ObtainWrite(&cm_scacheLock);
      for (i=0; i<cm_data.scacheHashTableSize; i++) {
          for (scp = cm_data.scacheHashTablep[i]; scp; scp=scp->nextp) {
***************
*** 1905,1912 ****
                  tsp->downTime = osi_Time();
              }
              cm_ForceNewConnections(tsp);
-             lock_ReleaseMutex(&tsp->mx);
- 
              /* Now update the volume status */
              for (tsrvp = tsp->vols; tsrvp; tsrvp = tsrvp->nextp) {
                  for (i=0; i<NUM_SERVER_VOLS; i++) {
--- 1914,1919 ----
***************
*** 1924,1929 ****
--- 1931,1937 ----
                      }
                  }
              }
+             lock_ReleaseMutex(&tsp->mx);
          }
      }
  }
Index: openafs/src/WINNT/afsd/cm_cell.c
diff -c openafs/src/WINNT/afsd/cm_cell.c:1.23.2.7 openafs/src/WINNT/afsd/cm_cell.c:1.23.2.9
*** openafs/src/WINNT/afsd/cm_cell.c:1.23.2.7	Wed Oct 10 11:22:14 2007
--- openafs/src/WINNT/afsd/cm_cell.c	Fri Dec 28 02:13:15 2007
***************
*** 26,34 ****
  osi_rwlock_t cm_cellLock;
  
  /* function called as callback proc from cm_SearchCellFile.  Return 0 to
!  * continue processing.
   */
! long cm_AddCellProc(void *rockp, struct sockaddr_in *addrp, char *namep)
  {
      cm_server_t *tsp;
      cm_serverRef_t *tsrp;
--- 26,36 ----
  osi_rwlock_t cm_cellLock;
  
  /* function called as callback proc from cm_SearchCellFile.  Return 0 to
!  * continue processing.  
!  *
!  * At the present time the return value is ignored by the caller.
   */
! long cm_AddCellProc(void *rockp, struct sockaddr_in *addrp, char *hostnamep)
  {
      cm_server_t *tsp;
      cm_serverRef_t *tsrp;
***************
*** 41,46 ****
--- 43,54 ----
      {
          if ( !tsp->cellp )
              tsp->cellp = cellp;
+         else if (tsp->cellp != cellp) {
+             osi_Log3(afsd_logp, "found a vlserver %s associated with two cells named %s and %s",
+                      osi_LogSaveString(afsd_logp,hostnamep),
+                      osi_LogSaveString(afsd_logp,tsp->cellp->name), 
+                      osi_LogSaveString(afsd_logp,cellp->name));
+         }
      }       
      else
          tsp = cm_NewServer(addrp, CM_SERVER_VLDB, cellp);
***************
*** 52,57 ****
--- 60,66 ----
      lock_ObtainWrite(&cm_serverLock);
      tsrp->refCount--;
      lock_ReleaseWrite(&cm_serverLock);
+ 
      return 0;
  }
  
***************
*** 139,146 ****
              strcpy(fullname, cp->name);
              break;
          }
!     }   
!     lock_ReleaseRead(&cm_cellLock);	
  
      if (cp) {
          cm_UpdateCell(cp);
--- 148,165 ----
              strcpy(fullname, cp->name);
              break;
          }
!     }
! 
!     if (!cp) {
!         for (cp = cm_data.allCellsp; cp; cp=cp->allNextp) {
!             if (strnicmp(namep, cp->name, strlen(namep)) == 0) {
!                 strcpy(fullname, cp->name);
!                 break;
!             }
!         }   
!     }
! 
!     lock_ReleaseRead(&cm_cellLock);
  
      if (cp) {
          cm_UpdateCell(cp);
***************
*** 161,166 ****
--- 180,195 ----
          if (cp)
              goto done;
  
+         for (cp = cm_data.allCellsp; cp; cp=cp->allNextp) {
+             if (strnicmp(namep, cp->name, strlen(namep)) == 0) {
+                 strcpy(fullname, cp->name);
+                 break;
+             }
+         }   
+ 
+         if (cp)
+             goto done;
+ 
          if ( cm_data.currentCells >= cm_data.maxCells )
              osi_panic("Exceeded Max Cells", __FILE__, __LINE__);
  
Index: openafs/src/WINNT/afsd/cm_config.h
diff -c openafs/src/WINNT/afsd/cm_config.h:1.8.6.1 openafs/src/WINNT/afsd/cm_config.h:1.8.6.3
*** openafs/src/WINNT/afsd/cm_config.h:1.8.6.1	Thu Aug  9 01:33:56 2007
--- openafs/src/WINNT/afsd/cm_config.h	Fri Dec 28 02:09:11 2007
***************
*** 13,20 ****
  #define CM_CONFIGDEFAULT_CACHESIZE	98304
  #define CM_CONFIGDEFAULT_BLOCKSIZE	4096
  #define CM_CONFIGDEFAULT_STATS		10000
! #define CM_CONFIGDEFAULT_CHUNKSIZE	20
! #define CM_CONFIGDEFAULT_DAEMONS	2
  #define CM_CONFIGDEFAULT_SVTHREADS	25
  #define CM_CONFIGDEFAULT_TRACEBUFSIZE	5000
  
--- 13,20 ----
  #define CM_CONFIGDEFAULT_CACHESIZE	98304
  #define CM_CONFIGDEFAULT_BLOCKSIZE	4096
  #define CM_CONFIGDEFAULT_STATS		10000
! #define CM_CONFIGDEFAULT_CHUNKSIZE	18      /* 256KB */
! #define CM_CONFIGDEFAULT_DAEMONS	1
  #define CM_CONFIGDEFAULT_SVTHREADS	25
  #define CM_CONFIGDEFAULT_TRACEBUFSIZE	5000
  
Index: openafs/src/WINNT/afsd/cm_conn.h
diff -c openafs/src/WINNT/afsd/cm_conn.h:1.13.4.8 openafs/src/WINNT/afsd/cm_conn.h:1.13.4.9
*** openafs/src/WINNT/afsd/cm_conn.h:1.13.4.8	Sun Jun 10 13:00:07 2007
--- openafs/src/WINNT/afsd/cm_conn.h	Sat Dec 22 23:52:58 2007
***************
*** 32,44 ****
  
  #define CM_CONN_FLAG_FORCE_NEW	1
  
! /* structure used for tracking RPC progress */
  typedef struct cm_req {
  	DWORD startTime;		/* Quit before RDR times us out */
  	int rpcError;			/* RPC error code */
  	int volumeError;		/* volume error code */
  	int accessError;		/* access error code */
  	int flags;
  } cm_req_t;
  
  /* flags in cm_req structure */
--- 32,50 ----
  
  #define CM_CONN_FLAG_FORCE_NEW	1
  
! /* 
!  * structure used for tracking RPC progress
!  * and for passing path info from the smb layer 
!  * to the cache manager functions.
!  */
  typedef struct cm_req {
  	DWORD startTime;		/* Quit before RDR times us out */
  	int rpcError;			/* RPC error code */
  	int volumeError;		/* volume error code */
  	int accessError;		/* access error code */
  	int flags;
+         char * tidPathp;
+         char * relPathp;
  } cm_req_t;
  
  /* flags in cm_req structure */
Index: openafs/src/WINNT/afsd/cm_daemon.c
diff -c openafs/src/WINNT/afsd/cm_daemon.c:1.16.4.20 openafs/src/WINNT/afsd/cm_daemon.c:1.16.4.21
*** openafs/src/WINNT/afsd/cm_daemon.c:1.16.4.20	Thu Nov 29 11:02:14 2007
--- openafs/src/WINNT/afsd/cm_daemon.c	Mon Dec 24 00:24:14 2007
***************
*** 49,81 ****
  cm_bkgRequest_t *cm_bkgListEndp;	/* last elt in the list of requests */
  
  static int daemon_ShutdownFlag = 0;
  
  #ifndef DJGPP
  void cm_IpAddrDaemon(long parm)
  {
      extern void smb_CheckVCs(void);
  
      rx_StartClientThread();
  
      while (daemon_ShutdownFlag == 0) {
! 	DWORD Result = NotifyAddrChange(NULL,NULL);
! 	if (Result == NO_ERROR && daemon_ShutdownFlag == 0) {
  	    Sleep(2500);
! 	    osi_Log0(afsd_logp, "cm_IpAddrDaemon CheckDownServers");
!             cm_CheckServers(CM_FLAG_CHECKVLDBSERVERS | CM_FLAG_CHECKUPSERVERS | CM_FLAG_CHECKDOWNSERVERS, NULL);
! 	    cm_ForceNewConnectionsAllServers();
!             cm_CheckServers(CM_FLAG_CHECKFILESERVERS | CM_FLAG_CHECKUPSERVERS | CM_FLAG_CHECKDOWNSERVERS, NULL);
! 	    smb_CheckVCs();
!             cm_VolStatus_Network_Addr_Change();
  	}	
      }
  }
  #endif
  
! void cm_BkgDaemon(long parm)
  {
      cm_bkgRequest_t *rp;
      afs_int32 code;
  
      rx_StartClientThread();
  
--- 49,108 ----
  cm_bkgRequest_t *cm_bkgListEndp;	/* last elt in the list of requests */
  
  static int daemon_ShutdownFlag = 0;
+ static int cm_nDaemons = 0;
+ 
+ static EVENT_HANDLE cm_Daemon_ShutdownEvent = NULL;
+ static EVENT_HANDLE cm_IPAddrDaemon_ShutdownEvent = NULL;
+ static EVENT_HANDLE cm_BkgDaemon_ShutdownEvent[CM_MAX_DAEMONS] = 
+        {NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL};
  
  #ifndef DJGPP
  void cm_IpAddrDaemon(long parm)
  {
      extern void smb_CheckVCs(void);
+     char * name = "cm_IPAddrDaemon_ShutdownEvent";
+ 
+     cm_IPAddrDaemon_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name);
+     if ( GetLastError() == ERROR_ALREADY_EXISTS )
+         afsi_log("Event Object Already Exists: %s", name);
  
      rx_StartClientThread();
  
      while (daemon_ShutdownFlag == 0) {
! 	DWORD Result;
!         
!         thrd_SetEvent(cm_IPAddrDaemon_ShutdownEvent);
!         Result = NotifyAddrChange(NULL,NULL);
!         if (Result == NO_ERROR && daemon_ShutdownFlag == 0) {
!             thrd_ResetEvent(cm_IPAddrDaemon_ShutdownEvent);
  	    Sleep(2500);
!             if (daemon_ShutdownFlag == 0) {
!                 osi_Log0(afsd_logp, "cm_IpAddrDaemon CheckDownServers");
!                 cm_CheckServers(CM_FLAG_CHECKVLDBSERVERS | CM_FLAG_CHECKUPSERVERS | CM_FLAG_CHECKDOWNSERVERS, NULL);
!                 cm_ForceNewConnectionsAllServers();
!                 cm_CheckServers(CM_FLAG_CHECKFILESERVERS | CM_FLAG_CHECKUPSERVERS | CM_FLAG_CHECKDOWNSERVERS, NULL);
!                 smb_CheckVCs();
!                 cm_VolStatus_Network_Addr_Change();
!             }
  	}	
      }
+ 
+     thrd_SetEvent(cm_IPAddrDaemon_ShutdownEvent);
  }
  #endif
  
! void cm_BkgDaemon(void * parm)
  {
      cm_bkgRequest_t *rp;
      afs_int32 code;
+     char name[32] = "";
+     long daemonID = (long)parm;
+ 
+     snprintf(name, sizeof(name), "cm_BkgDaemon_ShutdownEvent%d", daemonID);
+ 
+     cm_BkgDaemon_ShutdownEvent[daemonID] = thrd_CreateEvent(NULL, FALSE, FALSE, name);
+     if ( GetLastError() == ERROR_ALREADY_EXISTS )
+         afsi_log("Event Object Already Exists: %s", name);
  
      rx_StartClientThread();
  
***************
*** 144,149 ****
--- 171,179 ----
  	}
      }
      lock_ReleaseWrite(&cm_daemonLock);
+ 
+     thrd_SetEvent(cm_BkgDaemon_ShutdownEvent[daemonID]);
+ 
  }
  
  void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4,
***************
*** 322,329 ****
--- 352,364 ----
      unsigned long code;
      struct hostent *thp;
      HMODULE hHookDll;
+     char * name = "cm_Daemon_ShutdownEvent";
      int configureFirewall = IsWindowsFirewallPresent();
  
+     cm_Daemon_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name);
+     if ( GetLastError() == ERROR_ALREADY_EXISTS )
+         afsi_log("Event Object Already Exists: %s", name);
+ 
      if (!configureFirewall) {
  	afsi_log("No Windows Firewall detected");
      }
***************
*** 368,374 ****
  	smb_RestartListeners();
  
          if (daemon_ShutdownFlag == 1)
!             return;
  
          if (configureFirewall) {
  	    /* Open Microsoft Firewall to allow in port 7001 */
--- 403,409 ----
  	smb_RestartListeners();
  
          if (daemon_ShutdownFlag == 1)
!             break;
  
          if (configureFirewall) {
  	    /* Open Microsoft Firewall to allow in port 7001 */
***************
*** 401,407 ****
  	    osi_Log0(afsd_logp, "cm_Daemon CheckDownServers");
              cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL);
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 436,442 ----
  	    osi_Log0(afsd_logp, "cm_Daemon CheckDownServers");
              cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL);
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 412,418 ****
  	    osi_Log0(afsd_logp, "cm_Daemon CheckUpServers");
              cm_CheckServers(CM_FLAG_CHECKUPSERVERS, NULL);
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 447,453 ----
  	    osi_Log0(afsd_logp, "cm_Daemon CheckUpServers");
              cm_CheckServers(CM_FLAG_CHECKUPSERVERS, NULL);
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 421,427 ****
              lastVolCheck = now;
              cm_RefreshVolumes();
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 456,462 ----
              lastVolCheck = now;
              cm_RefreshVolumes();
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 431,437 ****
              lastVolCBRenewalCheck = now;
              cm_VolumeRenewROCallbacks();
              if (daemon_ShutdownFlag == 1)
!                 return;
              now = osi_Time();
          }
  
--- 466,472 ----
              lastVolCBRenewalCheck = now;
              cm_VolumeRenewROCallbacks();
              if (daemon_ShutdownFlag == 1)
!                 break;
              now = osi_Time();
          }
  
***************
*** 440,446 ****
              lastVolCheck = now;
              cm_CheckOfflineVolumes();
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 475,481 ----
              lastVolCheck = now;
              cm_CheckOfflineVolumes();
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 449,455 ****
              lastCBExpirationCheck = now;
              cm_CheckCBExpiration();
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 484,490 ----
              lastCBExpirationCheck = now;
              cm_CheckCBExpiration();
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 458,464 ****
              lastLockCheck = now;
              cm_CheckLocks();
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 493,499 ----
              lastLockCheck = now;
              cm_CheckLocks();
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 467,473 ****
              lastTokenCacheCheck = now;
              cm_CheckTokenCache(now);
              if (daemon_ShutdownFlag == 1)
!                 return;
  	    now = osi_Time();
          }
  
--- 502,508 ----
              lastTokenCacheCheck = now;
              cm_CheckTokenCache(now);
              if (daemon_ShutdownFlag == 1)
!                 break;
  	    now = osi_Time();
          }
  
***************
*** 490,504 ****
              }
          }
  
!         if (daemon_ShutdownFlag == 1)
!             return;
  	thrd_Sleep(30 * 1000);		/* sleep 30 seconds */
      }
  }       
  
  void cm_DaemonShutdown(void)
  {
      daemon_ShutdownFlag = 1;
  }
  
  void cm_InitDaemon(int nDaemons)
--- 525,557 ----
              }
          }
  
!         if (daemon_ShutdownFlag == 1) {
!             break;
!         }
  	thrd_Sleep(30 * 1000);		/* sleep 30 seconds */
      }
+     thrd_SetEvent(cm_Daemon_ShutdownEvent);
  }       
  
  void cm_DaemonShutdown(void)
  {
+     int i;
+     DWORD code;
+ 
      daemon_ShutdownFlag = 1;
+     osi_Wakeup((LONG_PTR) &cm_bkgListp);
+ 
+     /* wait for shutdown */
+     if (cm_Daemon_ShutdownEvent)
+         code = thrd_WaitForSingleObject_Event(cm_Daemon_ShutdownEvent, INFINITE); 
+ 
+     for ( i=0; i<cm_nDaemons; i++) {
+         if (cm_BkgDaemon_ShutdownEvent[i])
+             code = thrd_WaitForSingleObject_Event(cm_BkgDaemon_ShutdownEvent[i], INFINITE);
+     }
+ 
+     if (cm_IPAddrDaemon_ShutdownEvent)
+         code = thrd_WaitForSingleObject_Event(cm_IPAddrDaemon_ShutdownEvent, INFINITE);
  }
  
  void cm_InitDaemon(int nDaemons)
***************
*** 507,513 ****
      long pid;
      thread_t phandle;
      int i;
!         
      if (osi_Once(&once)) {
          lock_InitializeRWLock(&cm_daemonLock, "cm_daemonLock");
          osi_EndOnce(&once);
--- 560,568 ----
      long pid;
      thread_t phandle;
      int i;
! 
!     cm_nDaemons = (nDaemons > CM_MAX_DAEMONS) ? CM_MAX_DAEMONS : nDaemons;
!     
      if (osi_Once(&once)) {
          lock_InitializeRWLock(&cm_daemonLock, "cm_daemonLock");
          osi_EndOnce(&once);
***************
*** 526,534 ****
          osi_assertx(phandle != NULL, "cm_Daemon thread creation failure");
          thrd_CloseHandle(phandle);
  
! 	for(i=0; i < nDaemons; i++) {
              phandle = thrd_Create((SecurityAttrib) 0, 0,
!                                    (ThreadFunc) cm_BkgDaemon, 0, 0, &pid,
                                     "cm_BkgDaemon");
              osi_assertx(phandle != NULL, "cm_BkgDaemon thread creation failure");
              thrd_CloseHandle(phandle);
--- 581,589 ----
          osi_assertx(phandle != NULL, "cm_Daemon thread creation failure");
          thrd_CloseHandle(phandle);
  
! 	for(i=0; i < cm_nDaemons; i++) {
              phandle = thrd_Create((SecurityAttrib) 0, 0,
!                                    (ThreadFunc) cm_BkgDaemon, (LPVOID)i, 0, &pid,
                                     "cm_BkgDaemon");
              osi_assertx(phandle != NULL, "cm_BkgDaemon thread creation failure");
              thrd_CloseHandle(phandle);
Index: openafs/src/WINNT/afsd/cm_daemon.h
diff -c openafs/src/WINNT/afsd/cm_daemon.h:1.4.4.2 openafs/src/WINNT/afsd/cm_daemon.h:1.4.4.3
*** openafs/src/WINNT/afsd/cm_daemon.h:1.4.4.2	Sat Feb  3 21:46:25 2007
--- openafs/src/WINNT/afsd/cm_daemon.h	Mon Dec 24 00:24:14 2007
***************
*** 41,44 ****
--- 41,46 ----
  extern void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1,
  	afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp);
  
+ #define CM_MAX_DAEMONS 8
+ 
  #endif /*  __CM_DAEMON_H_ENV_ */
Index: openafs/src/WINNT/afsd/cm_dcache.c
diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.22 openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.23
*** openafs/src/WINNT/afsd/cm_dcache.c:1.30.2.22	Wed Nov 14 12:19:41 2007
--- openafs/src/WINNT/afsd/cm_dcache.c	Fri Dec 28 02:26:00 2007
***************
*** 696,702 ****
              lock_ReleaseMutex(&scp->mx);
              mxheld = 0;
          }
!         code = buf_Get(scp, &base, &bp);
          if (!mxheld) {
              lock_ObtainMutex(&scp->mx);
              mxheld = 1;
--- 696,702 ----
              lock_ReleaseMutex(&scp->mx);
              mxheld = 0;
          }
!         code = buf_Get(scp, &offset, &bp);
          if (!mxheld) {
              lock_ObtainMutex(&scp->mx);
              mxheld = 1;
***************
*** 1356,1361 ****
--- 1356,1366 ----
          osi_Log1(afsd_logp,"GetBuffer returns cm_data.rootSCachep=%x",cm_data.rootSCachep);
  #endif
  
+     if (cm_HaveCallback(scp) && bufp->dataVersion == scp->dataVersion) {
+         /* We already have this buffer don't do extra work */
+         return 0;
+     }
+ 
      cm_AFSFidFromFid(&tfid, &scp->fid);
  
      code = cm_SetupFetchBIOD(scp, &bufp->offset, &biod, userp, reqp);
Index: openafs/src/WINNT/afsd/cm_freelance.h
diff -c openafs/src/WINNT/afsd/cm_freelance.h:1.12 openafs/src/WINNT/afsd/cm_freelance.h:1.12.6.1
*** openafs/src/WINNT/afsd/cm_freelance.h:1.12	Fri Mar 11 00:33:22 2005
--- openafs/src/WINNT/afsd/cm_freelance.h	Sat Dec 22 22:39:59 2007
***************
*** 6,12 ****
      char*                       namep;
      char*                       mountPointStringp;
      unsigned int                fileType;
-     struct cm_localMountPoint*  next;
  } cm_localMountPoint_t;
  
  extern int cm_getNoLocalMountPoints();
--- 6,11 ----
Index: openafs/src/WINNT/afsd/cm_ioctl.c
diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.27 openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.28
*** openafs/src/WINNT/afsd/cm_ioctl.c:1.73.2.27	Sun Nov  4 19:24:46 2007
--- openafs/src/WINNT/afsd/cm_ioctl.c	Sat Dec 22 22:44:58 2007
***************
*** 1922,1934 ****
                  scp->fileType == CM_SCACHETYPE_DFSLINK ||
                 code == CM_ERROR_NOSUCHPATH &&
                  scp->fileType == CM_SCACHETYPE_INVALID) {
          cp = ioctlp->outDatap;
!         StringCbCopyA(cp, SMB_IOCTL_MAXDATA - (cp - ioctlp->outAllocp), spacep->data);
          cp += strlen(cp) + 1;
          ioctlp->outDatap = cp;
-         cm_FreeSpace(spacep);
-         if (newRootScp != NULL)
-             cm_ReleaseSCache(newRootScp);
          code = 0;
      }
  
--- 1922,1932 ----
                  scp->fileType == CM_SCACHETYPE_DFSLINK ||
                 code == CM_ERROR_NOSUCHPATH &&
                  scp->fileType == CM_SCACHETYPE_INVALID) {
+ 
          cp = ioctlp->outDatap;
!         StringCbCopyA(cp, SMB_IOCTL_MAXDATA - (cp - ioctlp->outAllocp), scp->mountPointStringp);
          cp += strlen(cp) + 1;
          ioctlp->outDatap = cp;
          code = 0;
      }
  
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.35.2.50 openafs/src/WINNT/afsd/cm_scache.c:1.35.2.54
*** openafs/src/WINNT/afsd/cm_scache.c:1.35.2.50	Wed Nov 14 12:19:41 2007
--- openafs/src/WINNT/afsd/cm_scache.c	Fri Dec 28 10:47:43 2007
***************
*** 494,500 ****
       * without network, the stat cache item will still be
       * considered valid.
       */
!     now = osi_Time();
  
      lock_ObtainWrite(&cm_scacheLock);
      for ( scp = cm_data.allSCachesp; scp; scp = scp->allNextp ) {
--- 494,500 ----
       * without network, the stat cache item will still be
       * considered valid.
       */
!     now = time(NULL);
  
      lock_ObtainWrite(&cm_scacheLock);
      for ( scp = cm_data.allSCachesp; scp; scp = scp->allNextp ) {
***************
*** 640,646 ****
      long code;
      cm_volume_t *volp = NULL;
      cm_cell_t *cellp;
-     char* mp = NULL;
      int special; // yj: boolean variable to test if file is on root.afs
      int isRoot;
      extern cm_fid_t cm_rootFid;
--- 640,645 ----
***************
*** 697,710 ****
      }
  	  
      if (cm_freelanceEnabled && special) {
          osi_Log0(afsd_logp,"cm_GetSCache Freelance and special");
!         if (fidp->vnode > 1 && fidp->vnode <= cm_noLocalMountPoints + 2) {
! 	    lock_ObtainMutex(&cm_Freelance_Lock);
!             mp =(cm_localMountPoints+fidp->vnode-2)->mountPointStringp;
!             lock_ReleaseMutex(&cm_Freelance_Lock);
          } else {
!             mp = "";
          }
          scp = cm_GetNewSCache();
  	if (scp == NULL) {
  	    osi_Log0(afsd_logp,"cm_GetSCache unable to obtain *new* scache entry");
--- 696,719 ----
      }
  	  
      if (cm_freelanceEnabled && special) {
+         char mp[MOUNTPOINTLEN] = "";
+         afs_uint32 fileType;
+ 
          osi_Log0(afsd_logp,"cm_GetSCache Freelance and special");
!         lock_ObtainMutex(&cm_Freelance_Lock);
!         if (fidp->vnode >= 2 && fidp->vnode - 2 < cm_noLocalMountPoints) {
!             strncpy(mp,(cm_localMountPoints+fidp->vnode-2)->mountPointStringp, MOUNTPOINTLEN);
!             mp[MOUNTPOINTLEN-1] = '\0';
!             if ( !strnicmp(mp, "msdfs:", strlen("msdfs:")) )
!                 fileType = CM_SCACHETYPE_DFSLINK;
!             else
!                 fileType = (cm_localMountPoints+fidp->vnode-2)->fileType;
          } else {
!             fileType = CM_SCACHETYPE_INVALID;
! 
          }
+         lock_ReleaseMutex(&cm_Freelance_Lock);
+ 
          scp = cm_GetNewSCache();
  	if (scp == NULL) {
  	    osi_Log0(afsd_logp,"cm_GetSCache unable to obtain *new* scache entry");
***************
*** 735,752 ****
          scp->flags |= CM_SCACHEFLAG_INHASH;
          scp->refCount = 1;
  	osi_Log1(afsd_logp,"cm_GetSCache (freelance) sets refCount to 1 scp 0x%x", scp);
!         if (fidp->vnode > 1 && fidp->vnode <= cm_noLocalMountPoints + 2)
!             scp->fileType = (cm_localMountPoints+fidp->vnode-2)->fileType;
!         else 
!             scp->fileType = CM_SCACHETYPE_INVALID;
! 
!         lock_ObtainMutex(&cm_Freelance_Lock);
          scp->length.LowPart = (DWORD)strlen(mp)+4;
          scp->length.HighPart = 0;
          strncpy(scp->mountPointStringp,mp,MOUNTPOINTLEN);
-         scp->mountPointStringp[MOUNTPOINTLEN-1] = '\0';
-         lock_ReleaseMutex(&cm_Freelance_Lock);
- 
          scp->owner=0x0;
          scp->unixModeBits=0777;
          scp->clientModTime=FakeFreelanceModTime;
--- 744,753 ----
          scp->flags |= CM_SCACHEFLAG_INHASH;
          scp->refCount = 1;
  	osi_Log1(afsd_logp,"cm_GetSCache (freelance) sets refCount to 1 scp 0x%x", scp);
!         scp->fileType = fileType;
          scp->length.LowPart = (DWORD)strlen(mp)+4;
          scp->length.HighPart = 0;
          strncpy(scp->mountPointStringp,mp,MOUNTPOINTLEN);
          scp->owner=0x0;
          scp->unixModeBits=0777;
          scp->clientModTime=FakeFreelanceModTime;
***************
*** 1277,1298 ****
              scp->waitCount = scp->waitRequests = 1;
          }
  
-         if (bufLocked) 
-             lock_ReleaseMutex(&bufp->mx);
- 
          cm_SyncOpAddToWaitQueue(scp, flags, bufp);
          wakeupCycle = 0;
          do {
!             if (wakeupCycle++ != 0)
!                 lock_ObtainMutex(&scp->mx);
              osi_SleepM((LONG_PTR) &scp->flags, &scp->mx);
          } while (!cm_SyncOpCheckContinue(scp, flags, bufp));
  
  	smb_UpdateServerPriority();
  
-         if (bufLocked) 
-             lock_ObtainMutex(&bufp->mx);
-         lock_ObtainMutex(&scp->mx);
          scp->waitCount--;
          osi_Log3(afsd_logp, "CM SyncOp woke! scp 0x%p; still waiting %d threads of %d requests", 
                   scp, scp->waitCount, scp->waitRequests);
--- 1278,1296 ----
              scp->waitCount = scp->waitRequests = 1;
          }
  
          cm_SyncOpAddToWaitQueue(scp, flags, bufp);
          wakeupCycle = 0;
          do {
!             if (bufLocked) 
!                 lock_ReleaseMutex(&bufp->mx);
              osi_SleepM((LONG_PTR) &scp->flags, &scp->mx);
+             if (bufLocked) 
+                 lock_ObtainMutex(&bufp->mx);
+             lock_ObtainMutex(&scp->mx);
          } while (!cm_SyncOpCheckContinue(scp, flags, bufp));
  
  	smb_UpdateServerPriority();
  
          scp->waitCount--;
          osi_Log3(afsd_logp, "CM SyncOp woke! scp 0x%p; still waiting %d threads of %d requests", 
                   scp, scp->waitCount, scp->waitRequests);
***************
*** 1504,1510 ****
          statusp->Group = 0;
          statusp->SyncCounter = 0;
          statusp->dataVersionHigh = (afs_uint32)(cm_data.fakeDirVersion >> 32);
! 	statusp->errorCode = 0;
      }
  #endif /* AFS_FREELANCE_CLIENT */
  
--- 1502,1510 ----
          statusp->Group = 0;
          statusp->SyncCounter = 0;
          statusp->dataVersionHigh = (afs_uint32)(cm_data.fakeDirVersion >> 32);
!         statusp->errorCode = 0;
! 
!         buf_ForceDataVersion(scp, scp->dataVersion, cm_data.fakeDirVersion);
      }
  #endif /* AFS_FREELANCE_CLIENT */
  
***************
*** 1637,1651 ****
      }
  
      if ((flags & CM_MERGEFLAG_STOREDATA) && dataVersion - scp->dataVersion == 1) {
! 	cm_buf_t *bp;
! 
! 	for (bp = cm_data.buf_fileHashTablepp[BUF_FILEHASH(&scp->fid)]; bp; bp=bp->fileHashp)
  	{
! 	    if (cm_FidCmp(&scp->fid, &bp->fid) == 0 && 
! 		bp->dataVersion == scp->dataVersion)
! 		bp->dataVersion = dataVersion;
  	}
  
      }
      scp->dataVersion = dataVersion;
  }
--- 1637,1690 ----
      }
  
      if ((flags & CM_MERGEFLAG_STOREDATA) && dataVersion - scp->dataVersion == 1) {
!         buf_ForceDataVersion(scp, scp->dataVersion, dataVersion);
!     } else if (scp->dataVersion != 0 && 
!         (!(flags & CM_MERGEFLAG_DIROP) && dataVersion != scp->dataVersion ||
!          (flags & CM_MERGEFLAG_DIROP) && dataVersion - scp->dataVersion > 1)) {
!         /* 
!          * We now know that all of the data buffers that we have associated
!          * with this scp are invalid.  Subsequent operations will go faster
!          * if the buffers are removed from the hash tables.
!          *
!          * We do not remove directory buffers if the dataVersion delta is 1 because
!          * those version numbers will be updated as part of the directory operation.
!          */
!         int i, j;
!         cm_buf_t **lbpp;
!         cm_buf_t *tbp;
!         cm_buf_t *bp, *prevBp, *nextBp;
! 
!         lock_ObtainWrite(&buf_globalLock);
!         i = BUF_FILEHASH(&scp->fid);
!        	for (bp = cm_data.buf_fileHashTablepp[i]; bp; bp=nextBp)
  	{
!             nextBp = bp->fileHashp;
! 
!             if (cm_FidCmp(&scp->fid, &bp->fid) == 0) {
!                 prevBp = bp->fileHashBackp;
!                 bp->fileHashBackp = bp->fileHashp = NULL;
!                 if (prevBp)
!                     prevBp->fileHashp = nextBp;
!                 else
!                     cm_data.buf_fileHashTablepp[i] = nextBp;
!                 if (nextBp)
!                     nextBp->fileHashBackp = prevBp;
! 
!                 j = BUF_HASH(&bp->fid, &bp->offset);
!                 lbpp = &(cm_data.buf_scacheHashTablepp[j]);
!                 for(tbp = *lbpp; tbp; lbpp = &tbp->hashp, tbp = *lbpp) {
!                     if (tbp == bp) 
!                         break;
!                 }
! 
!                 *lbpp = bp->hashp;	/* hash out */
!                 bp->hashp = NULL;
! 
!                 bp->flags &= ~CM_BUF_INHASH;
!             }
  	}
  
+         lock_ReleaseWrite(&buf_globalLock);
      }
      scp->dataVersion = dataVersion;
  }
***************
*** 1671,1676 ****
--- 1710,1718 ----
      cm_dnlcPurgevp(scp);
      cm_FreeAllACLEnts(scp);
  
+     if (scp->fileType == CM_SCACHETYPE_DFSLINK)
+         cm_VolStatus_Invalidate_DFS_Mapping(scp);
+ 
      /* Force mount points and symlinks to be re-evaluated */
      scp->mountPointStringp[0] = '\0';
  }
Index: openafs/src/WINNT/afsd/cm_scache.h
diff -c openafs/src/WINNT/afsd/cm_scache.h:1.21.2.17 openafs/src/WINNT/afsd/cm_scache.h:1.21.2.19
*** openafs/src/WINNT/afsd/cm_scache.h:1.21.2.17	Wed Nov 14 01:23:33 2007
--- openafs/src/WINNT/afsd/cm_scache.h	Fri Dec 28 10:47:43 2007
***************
*** 307,312 ****
--- 307,313 ----
  						 * in old info.
                                                   */
  #define CM_MERGEFLAG_STOREDATA		2	/* Merge due to storedata op */
+ #define CM_MERGEFLAG_DIROP              4       /* Merge due to directory op */ 
  
  /* hash define.  Must not include the cell, since the callback revocation code
   * doesn't necessarily know the cell in the case of a multihomed server
***************
*** 318,335 ****
  				    (fidp)->unique))	\
  					% cm_data.scacheHashTableSize)
  
  typedef struct cm_scache_waiter {
      osi_queue_t q;
      afs_int32   threadId;
  
      cm_scache_t *scp;
      afs_int32   flags;
!     void        *bufp;
  } cm_scache_waiter_t;
  
- #include "cm_conn.h"
- #include "cm_buf.h"
- 
  extern void cm_InitSCache(int, long);
  
  #ifdef DEBUG_REFCOUNT
--- 319,336 ----
  				    (fidp)->unique))	\
  					% cm_data.scacheHashTableSize)
  
+ #include "cm_conn.h"
+ #include "cm_buf.h"
+ 
  typedef struct cm_scache_waiter {
      osi_queue_t q;
      afs_int32   threadId;
  
      cm_scache_t *scp;
      afs_int32   flags;
!     cm_buf_t    *bufp;
  } cm_scache_waiter_t;
  
  extern void cm_InitSCache(int, long);
  
  #ifdef DEBUG_REFCOUNT
Index: openafs/src/WINNT/afsd/cm_server.c
diff -c openafs/src/WINNT/afsd/cm_server.c:1.25.2.14 openafs/src/WINNT/afsd/cm_server.c:1.25.2.16
*** openafs/src/WINNT/afsd/cm_server.c:1.25.2.14	Sun Nov  4 19:24:46 2007
--- openafs/src/WINNT/afsd/cm_server.c	Mon Dec 24 00:30:37 2007
***************
*** 35,47 ****
  {
      cm_server_t *tsp;
  
!     lock_ObtainRead(&cm_serverLock);
      for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
          cm_GetServerNoLock(tsp);
  	cm_ForceNewConnections(tsp);
          cm_PutServerNoLock(tsp);
      }
!     lock_ReleaseRead(&cm_serverLock);
  }
  
  void 
--- 35,47 ----
  {
      cm_server_t *tsp;
  
!     lock_ObtainWrite(&cm_serverLock);
      for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
          cm_GetServerNoLock(tsp);
  	cm_ForceNewConnections(tsp);
          cm_PutServerNoLock(tsp);
      }
!     lock_ReleaseWrite(&cm_serverLock);
  }
  
  void 
***************
*** 133,139 ****
              cm_volume_t * volp;
              int i;
  
-             lock_ReleaseMutex(&tsp->mx);
              for (tsrvp = tsp->vols; tsrvp; tsrvp = tsrvp->nextp) {
                  for (i=0; i<NUM_SERVER_VOLS; i++) {
                      if (tsrvp->ids[i] != 0) {
--- 133,138 ----
***************
*** 148,154 ****
                      }
                  }
              }
-             lock_ObtainMutex(&tsp->mx);
          }
      } else {
  	/* mark server as down */
--- 147,152 ----
***************
*** 170,176 ****
              cm_volume_t * volp;
              int i;
  
-             lock_ReleaseMutex(&tsp->mx);
              for (tsrvp = tsp->vols; tsrvp; tsrvp = tsrvp->nextp) {
                  for (i=0; i<NUM_SERVER_VOLS; i++) {
                      if (tsrvp->ids[i] != 0) {
--- 168,173 ----
***************
*** 185,191 ****
                      }
                  }
              }
-             lock_ObtainMutex(&tsp->mx);
          }
      }
  
--- 182,187 ----
Index: openafs/src/WINNT/afsd/cm_vnodeops.c
diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.47 openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.49
*** openafs/src/WINNT/afsd/cm_vnodeops.c:1.69.2.47	Fri Dec  7 11:05:23 2007
--- openafs/src/WINNT/afsd/cm_vnodeops.c	Sat Dec 22 23:52:58 2007
***************
*** 476,482 ****
      long code;
      osi_hyper_t thyper;
      cm_buf_t *bufferp;
!     cm_dirEntry_t *dep;
      unsigned short *hashTable;
      unsigned int i, idx;
      int BeyondPage = 0, HaveDot = 0, HaveDotDot = 0;
--- 476,482 ----
      long code;
      osi_hyper_t thyper;
      cm_buf_t *bufferp;
!     cm_dirEntry_t *dep = 0;
      unsigned short *hashTable;
      unsigned int i, idx;
      int BeyondPage = 0, HaveDot = 0, HaveDotDot = 0;
***************
*** 575,581 ****
  {
      char *tp;
      long code;
!     cm_dirEntry_t *dep;
      cm_buf_t *bufferp;
      long temp;
      osi_hyper_t dirLength;
--- 575,581 ----
  {
      char *tp;
      long code;
!     cm_dirEntry_t *dep = 0;
      cm_buf_t *bufferp;
      long temp;
      osi_hyper_t dirLength;
***************
*** 1646,1652 ****
      cm_dnlcRemove(dscp, namep);
      cm_SyncOpDone(dscp, NULL, sflags);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &newDirStatus, &volSync, userp, 0);
      } else if (code == CM_ERROR_NOSUCHFILE) {
  	/* windows would not have allowed the request to delete the file 
  	 * if it did not believe the file existed.  therefore, we must 
--- 1646,1652 ----
      cm_dnlcRemove(dscp, namep);
      cm_SyncOpDone(dscp, NULL, sflags);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &newDirStatus, &volSync, userp, CM_MERGEFLAG_DIROP);
      } else if (code == CM_ERROR_NOSUCHFILE) {
  	/* windows would not have allowed the request to delete the file 
  	 * if it did not believe the file existed.  therefore, we must 
***************
*** 1719,1724 ****
--- 1719,1727 ----
          if (!linkScp->mountPointStringp[0]) {
              strncpy(linkScp->mountPointStringp, bufp->datap, temp);
              linkScp->mountPointStringp[temp] = 0;	/* null terminate */
+ 
+             if ( !strnicmp(linkScp->mountPointStringp, "msdfs:", strlen("msdfs:")) )
+                  linkScp->fileType = CM_SCACHETYPE_DFSLINK;
          }
          buf_Release(bufp);
      }	/* don't have sym link contents cached */
***************
*** 1741,1749 ****
      char *linkp;
      cm_space_t *tsp;
  
      lock_ObtainMutex(&linkScp->mx);
      code = cm_HandleLink(linkScp, userp, reqp);
!     if (code) 
          goto done;
  
      /* if we may overflow the buffer, bail out; buffer is signficantly
--- 1744,1755 ----
      char *linkp;
      cm_space_t *tsp;
  
+     *newRootScpp = NULL;
+     *newSpaceBufferp = NULL;
+ 
      lock_ObtainMutex(&linkScp->mx);
      code = cm_HandleLink(linkScp, userp, reqp);
!     if (code)
          goto done;
  
      /* if we may overflow the buffer, bail out; buffer is signficantly
***************
*** 1780,1792 ****
          } else {
              linkScp->fileType = CM_SCACHETYPE_DFSLINK;
              strcpy(tsp->data, linkp);
-             *newRootScpp = NULL;
              code = CM_ERROR_PATH_NOT_COVERED;
          }
!     } else if ( !strnicmp(linkp, "msdfs:", (len = (long)strlen("msdfs:"))) ) {
          linkScp->fileType = CM_SCACHETYPE_DFSLINK;
          strcpy(tsp->data, linkp);
-         *newRootScpp = NULL;
          code = CM_ERROR_PATH_NOT_COVERED;
      } else if (*linkp == '\\' || *linkp == '/') {
  #if 0   
--- 1786,1797 ----
          } else {
              linkScp->fileType = CM_SCACHETYPE_DFSLINK;
              strcpy(tsp->data, linkp);
              code = CM_ERROR_PATH_NOT_COVERED;
          }
!     } else if ( linkScp->fileType == CM_SCACHETYPE_DFSLINK ||
!                 !strnicmp(linkp, "msdfs:", (len = (long)strlen("msdfs:"))) ) {
          linkScp->fileType = CM_SCACHETYPE_DFSLINK;
          strcpy(tsp->data, linkp);
          code = CM_ERROR_PATH_NOT_COVERED;
      } else if (*linkp == '\\' || *linkp == '/') {
  #if 0   
***************
*** 1802,1820 ****
           */
          linkScp->fileType = CM_SCACHETYPE_INVALID;
          strcpy(tsp->data, linkp);
-         *newRootScpp = NULL;
          code = CM_ERROR_NOSUCHPATH;
  #endif  
      } else {
          /* a relative link */
          strcpy(tsp->data, linkp);
-         *newRootScpp = NULL;
      }
      if (pathSuffixp[0] != 0) {	/* if suffix string is non-null */
          strcat(tsp->data, "\\");
          strcat(tsp->data, pathSuffixp);
      }
!     *newSpaceBufferp = tsp;
  
    done:
      lock_ReleaseMutex(&linkScp->mx);
--- 1807,1830 ----
           */
          linkScp->fileType = CM_SCACHETYPE_INVALID;
          strcpy(tsp->data, linkp);
          code = CM_ERROR_NOSUCHPATH;
  #endif  
      } else {
          /* a relative link */
          strcpy(tsp->data, linkp);
      }
      if (pathSuffixp[0] != 0) {	/* if suffix string is non-null */
          strcat(tsp->data, "\\");
          strcat(tsp->data, pathSuffixp);
      }
!     if (code == 0)
!         *newSpaceBufferp = tsp;
!     else {
!         cm_FreeSpace(tsp);
! 
!         if (code == CM_ERROR_PATH_NOT_COVERED && reqp->tidPathp && reqp->relPathp)
!             cm_VolStatus_Notify_DFS_Mapping(linkScp, reqp->tidPathp, reqp->relPathp);
!     }
  
    done:
      lock_ReleaseMutex(&linkScp->mx);
***************
*** 2716,2722 ****
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0);
      }
      lock_ReleaseMutex(&dscp->mx);
  
--- 2726,2732 ----
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, CM_MERGEFLAG_DIROP);
      }
      lock_ReleaseMutex(&dscp->mx);
  
***************
*** 2866,2872 ****
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0);
      }
      lock_ReleaseMutex(&dscp->mx);
  
--- 2876,2882 ----
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, CM_MERGEFLAG_DIROP);
      }
      lock_ReleaseMutex(&dscp->mx);
  
***************
*** 2976,2982 ****
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0);
      }
      lock_ReleaseMutex(&dscp->mx);
  
--- 2986,2992 ----
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, CM_MERGEFLAG_DIROP);
      }
      lock_ReleaseMutex(&dscp->mx);
  
***************
*** 3058,3064 ****
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0);
      }
      lock_ReleaseMutex(&dscp->mx);
  
--- 3068,3074 ----
      lock_ObtainMutex(&dscp->mx);
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, CM_MERGEFLAG_DIROP);
      }
      lock_ReleaseMutex(&dscp->mx);
  
***************
*** 3162,3168 ****
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
          cm_dnlcRemove(dscp, namep); 
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, 0);
      }
      lock_ReleaseMutex(&dscp->mx);
  
--- 3172,3178 ----
      cm_SyncOpDone(dscp, NULL, CM_SCACHESYNC_STOREDATA);
      if (code == 0) {
          cm_dnlcRemove(dscp, namep); 
!         cm_MergeStatus(NULL, dscp, &updatedDirStatus, &volSync, userp, CM_MERGEFLAG_DIROP);
      }
      lock_ReleaseMutex(&dscp->mx);
  
***************
*** 3357,3363 ****
  
      if (code == 0)
          cm_MergeStatus(NULL, oldDscp, &updatedOldDirStatus, &volSync,
!                         userp, 0);
      lock_ReleaseMutex(&oldDscp->mx);
  
      if (code == 0) {
--- 3367,3373 ----
  
      if (code == 0)
          cm_MergeStatus(NULL, oldDscp, &updatedOldDirStatus, &volSync,
!                         userp, CM_MERGEFLAG_DIROP);
      lock_ReleaseMutex(&oldDscp->mx);
  
      if (code == 0) {
***************
*** 3400,3406 ****
          cm_SyncOpDone(newDscp, NULL, CM_SCACHESYNC_STOREDATA);
          if (code == 0)
              cm_MergeStatus(NULL, newDscp, &updatedNewDirStatus, &volSync,
!                             userp, 0);
          lock_ReleaseMutex(&newDscp->mx);
  
          if (code == 0) {
--- 3410,3416 ----
          cm_SyncOpDone(newDscp, NULL, CM_SCACHESYNC_STOREDATA);
          if (code == 0)
              cm_MergeStatus(NULL, newDscp, &updatedNewDirStatus, &volSync,
!                             userp, CM_MERGEFLAG_DIROP);
          lock_ReleaseMutex(&newDscp->mx);
  
          if (code == 0) {
Index: openafs/src/WINNT/afsd/cm_vnodeops.h
diff -c openafs/src/WINNT/afsd/cm_vnodeops.h:1.14.4.6 openafs/src/WINNT/afsd/cm_vnodeops.h:1.14.4.7
*** openafs/src/WINNT/afsd/cm_vnodeops.h:1.14.4.6	Fri Dec  7 11:05:24 2007
--- openafs/src/WINNT/afsd/cm_vnodeops.h	Sat Dec 22 23:52:58 2007
***************
*** 189,194 ****
--- 189,198 ----
  extern long cm_EvaluateSymLink(cm_scache_t *dscp, cm_scache_t *linkScp,
  	cm_scache_t **outScpp, cm_user_t *userp, cm_req_t *reqp);
  
+ extern long cm_FollowMountPoint(cm_scache_t *scp, cm_scache_t *dscp, cm_user_t *userp,
+                                 cm_req_t *reqp, cm_scache_t **outScpp);
+ 
+ 
  extern long cm_Lock(cm_scache_t *scp, unsigned char sLockType,
          LARGE_INTEGER LOffset, LARGE_INTEGER LLength, cm_key_t key,
  	int allowWait, cm_user_t *userp, cm_req_t *reqp,
Index: openafs/src/WINNT/afsd/cm_volstat.c
diff -c openafs/src/WINNT/afsd/cm_volstat.c:1.1.2.3 openafs/src/WINNT/afsd/cm_volstat.c:1.1.2.4
*** openafs/src/WINNT/afsd/cm_volstat.c:1.1.2.3	Thu Nov 29 11:11:44 2007
--- openafs/src/WINNT/afsd/cm_volstat.c	Sat Dec 22 23:52:58 2007
***************
*** 46,51 ****
--- 46,59 ----
  dll_VolStatus_Funcs_t dll_funcs;
  cm_VolStatus_Funcs_t cm_funcs;
  
+ static char volstat_NetbiosName[64] = "";
+ 
+ afs_uint32
+ cm_VolStatus_Active(void)
+ {
+     return (hVolStatus != NULL);
+ }
+ 
  /* This function is used to load any Volume Status Handlers 
   * and their associated function pointers.  
   */
***************
*** 64,69 ****
--- 72,83 ----
          dummyLen = sizeof(wd);
          code = RegQueryValueEx(parmKey, "VolStatusHandler", NULL, NULL,
                                  (BYTE *) &wd, &dummyLen);
+ 
+         if (code == 0) {
+             dummyLen = sizeof(volstat_NetbiosName);
+             code = RegQueryValueEx(parmKey, "NetbiosName", NULL, NULL, 
+                                    (BYTE *)volstat_NetbiosName, &dummyLen);
+         }
          RegCloseKey (parmKey);
      }
  
***************
*** 76,81 ****
--- 90,96 ----
              cm_funcs.cm_VolStatus_Path_To_ID = cm_VolStatus_Path_To_ID;
              cm_funcs.cm_VolStatus_Path_To_DFSlink = cm_VolStatus_Path_To_DFSlink;
  
+             dll_funcs.version = DLL_VOLSTATUS_FUNCS_VERSION;
              code = dll_VolStatus_Initialization(&dll_funcs, &cm_funcs);
          } 
  
***************
*** 87,92 ****
--- 102,109 ----
          }
      }
  
+     osi_Log1(afsd_logp,"cm_VolStatus_Initialization 0x%x", code);
+ 
      return code;
  }
  
***************
*** 96,101 ****
--- 113,120 ----
  long 
  cm_VolStatus_Finalize(void)
  {
+     osi_Log1(afsd_logp,"cm_VolStatus_Finalize handle 0x%x", hVolStatus);
+ 
      if (hVolStatus == NULL)
          return 0;
  
***************
*** 113,118 ****
--- 132,139 ----
  {
      long code = 0;
  
+     osi_Log1(afsd_logp,"cm_VolStatus_Service_Started handle 0x%x", hVolStatus);
+ 
      if (hVolStatus == NULL)
          return 0;
     
***************
*** 131,136 ****
--- 152,159 ----
  {
      long code = 0;
  
+     osi_Log1(afsd_logp,"cm_VolStatus_Service_Stopped handle 0x%x", hVolStatus);
+ 
      if (hVolStatus == NULL)
          return 0;
     
***************
*** 225,246 ****
  }
  
  
  long __fastcall
! cm_VolStatus_Path_To_ID(const char * share, const char * path, afs_uint32 * cellID, afs_uint32 * volID)
  {
!     afs_uint32  code;
      cm_req_t    req;
      cm_scache_t *scp;
  
      if (cellID == NULL || volID == NULL)
          return CM_ERROR_INVAL;
  
!     cm_InitReq(&req);
  
  
!     code = cm_NameI(cm_data.rootSCachep, (char *)path, CM_FLAG_FOLLOW, cm_rootUserp, (char *)share, &req, &scp);
      if (code)
!         return code;
  
      lock_ObtainMutex(&scp->mx);
      code = cm_SyncOp(scp, NULL,cm_rootUserp, &req, 0,
--- 248,315 ----
  }
  
  
+ 
+ long
+ cm_VolStatus_Notify_DFS_Mapping(cm_scache_t *scp, char *tidPathp, char *pathp)
+ {
+     long code = 0;
+     char src[1024], *p;
+     size_t len;
+ 
+     if (hVolStatus == NULL || dll_funcs.version < 2)
+         return 0;
+ 
+     snprintf(src,sizeof(src), "\\\\%s%s", volstat_NetbiosName, tidPathp);
+     len = strlen(src);
+     if ((src[len-1] == '\\' || src[len-1] == '/') &&
+         (pathp[0] == '\\' || pathp[0] == '/'))
+         strncat(src, &pathp[1], sizeof(src));
+     else
+         strncat(src, pathp, sizeof(src));
+ 
+     for ( p=src; *p; p++ ) {
+         if (*p == '/')
+             *p = '\\';
+     }
+ 
+     code = dll_funcs.dll_VolStatus_Notify_DFS_Mapping(scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique,
+                                                       src, scp->mountPointStringp);
+ 
+     return code;
+ }
+ 
+ long
+ cm_VolStatus_Invalidate_DFS_Mapping(cm_scache_t *scp)
+ {
+     long code = 0;
+ 
+     if (hVolStatus == NULL || dll_funcs.version < 2)
+         return 0;
+ 
+     code = dll_funcs.dll_VolStatus_Invalidate_DFS_Mapping(scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique);
+ 
+     return code;
+ }
+ 
+ 
  long __fastcall
! cm_VolStatus_Path_To_ID(const char * share, const char * path, afs_uint32 * cellID, afs_uint32 * volID, enum volstatus *pstatus)
  {
!     afs_uint32  code = 0;
      cm_req_t    req;
      cm_scache_t *scp;
  
      if (cellID == NULL || volID == NULL)
          return CM_ERROR_INVAL;
  
!     osi_Log2(afsd_logp,"cm_VolStatus_Path_To_ID share %s path %s", 
!               osi_LogSaveString(afsd_logp, (char *)share), osi_LogSaveString(afsd_logp, (char *)path));
  
+     cm_InitReq(&req);
  
!     code = cm_NameI(cm_data.rootSCachep, (char *)path, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW, cm_rootUserp, (char *)share, &req, &scp);
      if (code)
!         goto done;
  
      lock_ObtainMutex(&scp->mx);
      code = cm_SyncOp(scp, NULL,cm_rootUserp, &req, 0,
***************
*** 248,271 ****
      if (code) {
          lock_ReleaseMutex(&scp->mx);
          cm_ReleaseSCache(scp);
!         return code;
      }
          
      cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
  
      *cellID = scp->fid.cell;
      *volID  = scp->fid.volume;
  
      lock_ReleaseMutex(&scp->mx);
      cm_ReleaseSCache(scp);
  
!     return 0;
  }
  
  long __fastcall
  cm_VolStatus_Path_To_DFSlink(const char * share, const char * path, afs_uint32 *pBufSize, char *pBuffer)
  {
!     afs_uint32  code;
      cm_req_t    req;
      cm_scache_t *scp;
      size_t      len;
--- 317,343 ----
      if (code) {
          lock_ReleaseMutex(&scp->mx);
          cm_ReleaseSCache(scp);
!         goto done;
      }
          
      cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
  
      *cellID = scp->fid.cell;
      *volID  = scp->fid.volume;
+     *pstatus = cm_GetVolumeStatus(scp->volp, scp->fid.volume);
  
      lock_ReleaseMutex(&scp->mx);
      cm_ReleaseSCache(scp);
  
!   done:
!     osi_Log1(afsd_logp,"cm_VolStatus_Path_To_ID code 0x%x",code); 
!     return code;
  }
  
  long __fastcall
  cm_VolStatus_Path_To_DFSlink(const char * share, const char * path, afs_uint32 *pBufSize, char *pBuffer)
  {
!     afs_uint32  code = 0;
      cm_req_t    req;
      cm_scache_t *scp;
      size_t      len;
***************
*** 273,283 ****
      if (pBufSize == NULL || (pBuffer == NULL && *pBufSize != 0))
          return CM_ERROR_INVAL;
  
      cm_InitReq(&req);
  
!     code = cm_NameI(cm_data.rootSCachep, (char *)path, CM_FLAG_FOLLOW, cm_rootUserp, (char *)share, &req, &scp);
      if (code)
!         return code;
  
      lock_ObtainMutex(&scp->mx);
      code = cm_SyncOp(scp, NULL, cm_rootUserp, &req, 0,
--- 345,359 ----
      if (pBufSize == NULL || (pBuffer == NULL && *pBufSize != 0))
          return CM_ERROR_INVAL;
  
+     osi_Log2(afsd_logp,"cm_VolStatus_Path_To_DFSlink share %s path %s", 
+               osi_LogSaveString(afsd_logp, (char *)share), osi_LogSaveString(afsd_logp, (char *)path));
+ 
      cm_InitReq(&req);
  
!     code = cm_NameI(cm_data.rootSCachep, (char *)path, CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW, 
!                     cm_rootUserp, (char *)share, &req, &scp);
      if (code)
!         goto done;
  
      lock_ObtainMutex(&scp->mx);
      code = cm_SyncOp(scp, NULL, cm_rootUserp, &req, 0,
***************
*** 285,297 ****
      if (code) {
          lock_ReleaseMutex(&scp->mx);
          cm_ReleaseSCache(scp);
!         return code;
      }
          
      cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
  
!     if (scp->fileType != CM_SCACHETYPE_DFSLINK)
!         return CM_ERROR_NOT_A_DFSLINK;
  
      len = strlen(scp->mountPointStringp) + 1;
      if (pBuffer == NULL)
--- 361,375 ----
      if (code) {
          lock_ReleaseMutex(&scp->mx);
          cm_ReleaseSCache(scp);
!         goto done;
      }
          
      cm_SyncOpDone(scp, NULL, CM_SCACHESYNC_NEEDCALLBACK | CM_SCACHESYNC_GETSTATUS);
  
!     if (scp->fileType != CM_SCACHETYPE_DFSLINK) {
!         code = CM_ERROR_NOT_A_DFSLINK;
!         goto done;
!     }
  
      len = strlen(scp->mountPointStringp) + 1;
      if (pBuffer == NULL)
***************
*** 299,309 ****
      else if (*pBufSize >= len) {
          strcpy(pBuffer, scp->mountPointStringp);
          *pBufSize = len;
!     } else 
          code = CM_ERROR_TOOBIG;
  
      lock_ReleaseMutex(&scp->mx);
      cm_ReleaseSCache(scp);
  
!     return 0;
  }
--- 377,391 ----
      else if (*pBufSize >= len) {
          strcpy(pBuffer, scp->mountPointStringp);
          *pBufSize = len;
!     } else {
          code = CM_ERROR_TOOBIG;
+         goto done;
+     }
  
      lock_ReleaseMutex(&scp->mx);
      cm_ReleaseSCache(scp);
  
!   done:
!     osi_Log1(afsd_logp,"cm_VolStatus_Path_To_DFSlink code 0x%x",code); 
!     return code;
  }
Index: openafs/src/WINNT/afsd/cm_volstat.h
diff -c openafs/src/WINNT/afsd/cm_volstat.h:1.1.2.4 openafs/src/WINNT/afsd/cm_volstat.h:1.1.2.5
*** openafs/src/WINNT/afsd/cm_volstat.h:1.1.2.4	Thu Nov 29 11:11:44 2007
--- openafs/src/WINNT/afsd/cm_volstat.h	Sat Dec 22 23:52:58 2007
***************
*** 55,79 ****
  
  extern long cm_VolStatus_Change_Notification(afs_uint32 cellID, afs_uint32 volID, enum volstatus status);
  
! extern long __fastcall cm_VolStatus_Path_To_ID(const char * share, const char * path, afs_uint32 * cellID, afs_uint32 * volID);
  
  extern long __fastcall cm_VolStatus_Path_To_DFSlink(const char * share, const char * path, afs_uint32 *pBufSize, char *pBuffer);
  
! #define DLL_VOLSTATUS_FUNCS_VERSION 1
  typedef struct dll_VolStatus_Funcs {
      afs_uint32          version;
      long (__fastcall * dll_VolStatus_Service_Started)(void);
      long (__fastcall * dll_VolStatus_Service_Stopped)(void);
      long (__fastcall * dll_VolStatus_Network_Started)(const char *netbios32, const char *netbios64);
      long (__fastcall * dll_VolStatus_Network_Stopped)(const char *netbios32, const char *netbios64);
      long (__fastcall * dll_VolStatus_Network_Addr_Change)(void);
      long (__fastcall * dll_VolStatus_Change_Notification)(afs_uint32 cellID, afs_uint32 volID, enum volstatus status);
  } dll_VolStatus_Funcs_t;
  
  #define CM_VOLSTATUS_FUNCS_VERSION 1
  typedef struct cm_VolStatus_Funcs {
      afs_uint32          version;
!     long (__fastcall * cm_VolStatus_Path_To_ID)(const char * share, const char * path, afs_uint32 * cellID, afs_uint32 * volID);
      long (__fastcall * cm_VolStatus_Path_To_DFSlink)(const char * share, const char * path, afs_uint32 *pBufSize, char *pBuffer);
  } cm_VolStatus_Funcs_t;
  
--- 55,90 ----
  
  extern long cm_VolStatus_Change_Notification(afs_uint32 cellID, afs_uint32 volID, enum volstatus status);
  
! extern long __fastcall cm_VolStatus_Path_To_ID(const char * share, const char * path, afs_uint32 * cellID, afs_uint32 * volID, enum volstatus *pstatus);
  
  extern long __fastcall cm_VolStatus_Path_To_DFSlink(const char * share, const char * path, afs_uint32 *pBufSize, char *pBuffer);
  
! extern long cm_VolStatus_Notify_DFS_Mapping(cm_scache_t *scp, char *tidPathp, char *pathp);
! 
! extern long cm_VolStatus_Invalidate_DFS_Mapping(cm_scache_t *scp);
! 
! #define DLL_VOLSTATUS_FUNCS_VERSION 2
  typedef struct dll_VolStatus_Funcs {
      afs_uint32          version;
+     /* version 1 */
      long (__fastcall * dll_VolStatus_Service_Started)(void);
      long (__fastcall * dll_VolStatus_Service_Stopped)(void);
      long (__fastcall * dll_VolStatus_Network_Started)(const char *netbios32, const char *netbios64);
      long (__fastcall * dll_VolStatus_Network_Stopped)(const char *netbios32, const char *netbios64);
      long (__fastcall * dll_VolStatus_Network_Addr_Change)(void);
      long (__fastcall * dll_VolStatus_Change_Notification)(afs_uint32 cellID, afs_uint32 volID, enum volstatus status);
+     /* version 2 */
+     long (__fastcall * dll_VolStatus_Notify_DFS_Mapping)(afs_uint32 cellID, afs_uint32 volID, 
+                                                          afs_uint32 vnodeID, afs_uint32 uniqID,
+                                                          char *src, char *target);
+     long (__fastcall * dll_VolStatus_Invalidate_DFS_Mapping)(afs_uint32 cellID, afs_uint32 volID, 
+                                                              afs_uint32 vnodeID, afs_uint32 uniqID);
  } dll_VolStatus_Funcs_t;
  
  #define CM_VOLSTATUS_FUNCS_VERSION 1
  typedef struct cm_VolStatus_Funcs {
      afs_uint32          version;
!     long (__fastcall * cm_VolStatus_Path_To_ID)(const char * share, const char * path, afs_uint32 * cellID, afs_uint32 * volID, enum volstatus *pstatus);
      long (__fastcall * cm_VolStatus_Path_To_DFSlink)(const char * share, const char * path, afs_uint32 *pBufSize, char *pBuffer);
  } cm_VolStatus_Funcs_t;
  
Index: openafs/src/WINNT/afsd/cm_volume.c
diff -c openafs/src/WINNT/afsd/cm_volume.c:1.14.4.21 openafs/src/WINNT/afsd/cm_volume.c:1.14.4.22
*** openafs/src/WINNT/afsd/cm_volume.c:1.14.4.21	Sun Nov 11 22:25:55 2007
--- openafs/src/WINNT/afsd/cm_volume.c	Mon Dec 24 00:19:09 2007
***************
*** 1119,1142 ****
      lock_ReleaseWrite(&cm_volumeLock);
  }
  
! void
! cm_UpdateVolumeStatus(cm_volume_t *volp, afs_uint32 volID)
  {
-     struct cm_vol_state * statep = NULL;
      enum volstatus newStatus;
      cm_serverRef_t *tsrp;
      cm_server_t *tsp;
      int someBusy = 0, someOffline = 0, allOffline = 1, allBusy = 1, allDown = 1;
  
!     if (volp->rw.ID == volID) {
!         statep = &volp->rw;
!     } else if (volp->ro.ID == volID) {
!         statep = &volp->ro;
!     } else if (volp->bk.ID == volID) {
!         statep = &volp->bk;
!     }
! 
!     if (!statep) {
  #ifdef DEBUG
          DebugBreak();
  #endif
--- 1119,1134 ----
      lock_ReleaseWrite(&cm_volumeLock);
  }
  
! 
! static void
! cm_UpdateVolumeStatusInt(cm_volume_t *volp, struct cm_vol_state *statep)
  {
      enum volstatus newStatus;
      cm_serverRef_t *tsrp;
      cm_server_t *tsp;
      int someBusy = 0, someOffline = 0, allOffline = 1, allBusy = 1, allDown = 1;
  
!     if (!volp || !statep) {
  #ifdef DEBUG
          DebugBreak();
  #endif
***************
*** 1173,1185 ****
      else
  	newStatus = vl_online;
  
- 
      if (statep->ID && statep->state != newStatus)
          cm_VolumeStatusNotification(volp, statep->ID, statep->state, newStatus);
  
      statep->state = newStatus;
  }
  
  /*
  ** Finds all volumes that reside on this server and reorders their
  ** RO list according to the changed rank of server.
--- 1165,1203 ----
      else
  	newStatus = vl_online;
  
      if (statep->ID && statep->state != newStatus)
          cm_VolumeStatusNotification(volp, statep->ID, statep->state, newStatus);
  
      statep->state = newStatus;
  }
  
+ void
+ cm_UpdateVolumeStatus(cm_volume_t *volp, afs_uint32 volID)
+ {
+ 
+     if (volp->rw.ID == volID) {
+         cm_UpdateVolumeStatusInt(volp, &volp->rw);
+     } else if (volp->ro.ID == volID) {
+         cm_UpdateVolumeStatusInt(volp, &volp->ro);
+     } else if (volp->bk.ID == volID) {
+         cm_UpdateVolumeStatusInt(volp, &volp->bk);
+     } else {
+         /*
+          * If we are called with volID == 0 then something has gone wrong.
+          * Most likely a race occurred in the server volume list maintenance.
+          * Since we don't know which volume's status should be updated, 
+          * just update all of them that are known to exist.  Better to be 
+          * correct than fast.
+          */
+         if (volp->rw.ID != 0)
+             cm_UpdateVolumeStatusInt(volp, &volp->rw);
+         if (volp->ro.ID != 0)
+             cm_UpdateVolumeStatusInt(volp, &volp->ro);
+         if (volp->bk.ID != 0)
+             cm_UpdateVolumeStatusInt(volp, &volp->bk);
+     }
+ }
+ 
  /*
  ** Finds all volumes that reside on this server and reorders their
  ** RO list according to the changed rank of server.
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.118.2.47 openafs/src/WINNT/afsd/smb.c:1.118.2.48
*** openafs/src/WINNT/afsd/smb.c:1.118.2.47	Thu Nov 29 11:08:57 2007
--- openafs/src/WINNT/afsd/smb.c	Sat Dec 22 23:52:58 2007
***************
*** 2876,2898 ****
      else if (code == CM_ERROR_PATH_NOT_COVERED) {
          NTStatus = 0xC0000257L; /* Path Not Covered */
      } 
- #ifdef COMMENT
      else if (code == CM_ERROR_ALLBUSY) {
!         NTStatus = 0xC00000BFL; /* Network Busy */
      } 
      else if (code == CM_ERROR_ALLOFFLINE || code == CM_ERROR_ALLDOWN) {
-         NTStatus = 0xC0000350L; /* Remote Host Down */
-     } 
- #else
-     /* we do not want to be telling the SMB/CIFS client that
-      * the AFS Client Service is busy or down.  
-      */
-     else if (code == CM_ERROR_ALLBUSY || 
-              code == CM_ERROR_ALLOFFLINE ||
- 	     code == CM_ERROR_ALLDOWN) {
          NTStatus = 0xC00000BEL; /* Bad Network Path */
!     }
! #endif
      else if (code == RXKADUNKNOWNKEY) {
  	NTStatus = 0xC0000322L; /* Bad Kerberos key */
      } 
--- 2876,2887 ----
      else if (code == CM_ERROR_PATH_NOT_COVERED) {
          NTStatus = 0xC0000257L; /* Path Not Covered */
      } 
      else if (code == CM_ERROR_ALLBUSY) {
!         NTStatus = 0xC000022DL; /* Retry */
      } 
      else if (code == CM_ERROR_ALLOFFLINE || code == CM_ERROR_ALLDOWN) {
          NTStatus = 0xC00000BEL; /* Bad Network Path */
!     } 
      else if (code == RXKADUNKNOWNKEY) {
  	NTStatus = 0xC0000322L; /* Bad Kerberos key */
      } 
***************
*** 3891,3913 ****
  
      /* mask starts out all blanks */
      memset(maskp, ' ', 11);
  
      /* find last backslash, or use whole thing if there is none */
      tp = strrchr(pathp, '\\');
!     if (!tp) tp = pathp;
!     else tp++;	/* skip slash */
          
      up = maskp;
  
      /* names starting with a dot are illegal */
!     if (*tp == '.') valid8Dot3 = 0;
  
      for(i=0;; i++) {
          tc = *tp++;
!         if (tc == 0) return valid8Dot3;
!         if (tc == '.' || tc == '"') break;
!         if (i < 8) *up++ = tc;
!         else valid8Dot3 = 0;
      }
          
      /* if we get here, tp point after the dot */
--- 3880,3910 ----
  
      /* mask starts out all blanks */
      memset(maskp, ' ', 11);
+     maskp[11] = '\0';
  
      /* find last backslash, or use whole thing if there is none */
      tp = strrchr(pathp, '\\');
!     if (!tp) 
!         tp = pathp;
!     else 
!         tp++;	/* skip slash */
          
      up = maskp;
  
      /* names starting with a dot are illegal */
!     if (*tp == '.') 
!         valid8Dot3 = 0;
  
      for(i=0;; i++) {
          tc = *tp++;
!         if (tc == 0) 
!             return valid8Dot3;
!         if (tc == '.' || tc == '"') 
!             break;
!         if (i < 8) 
!             *up++ = tc;
!         else
!             valid8Dot3 = 0;
      }
          
      /* if we get here, tp point after the dot */
***************
*** 3986,3992 ****
  {
      unsigned char *pathp;
      unsigned char *tp;
!     unsigned char mask[11];
      unsigned char *statBlockp;
      unsigned char initStatBlock[21];
      int statLen;
--- 3983,3989 ----
  {
      unsigned char *pathp;
      unsigned char *tp;
!     unsigned char mask[12];
      unsigned char *statBlockp;
      unsigned char initStatBlock[21];
      int statLen;
***************
*** 4052,4059 ****
      return 0;
  }       
  
! long smb_ApplyDirListPatches(smb_dirListPatch_t **dirPatchespp,
!                              cm_user_t *userp, cm_req_t *reqp)
  {
      long code = 0;
      cm_scache_t *scp;
--- 4049,4058 ----
      return 0;
  }       
  
! static long 
! smb_ApplyDirListPatches(smb_dirListPatch_t **dirPatchespp,
!                         char * tidPathp, char * relPathp,
!                         cm_user_t *userp, cm_req_t *reqp)
  {
      long code = 0;
      cm_scache_t *scp;
***************
*** 4063,4075 ****
--- 4062,4081 ----
      char attr;
      smb_dirListPatch_t *patchp;
      smb_dirListPatch_t *npatchp;
+     char path[AFSPATHMAX];
  
      for (patchp = *dirPatchespp; patchp; patchp =
           (smb_dirListPatch_t *) osi_QNext(&patchp->q)) {
  
          dptr = patchp->dptr;
  
+         snprintf(path, AFSPATHMAX, "%s\\%s", relPathp ? relPathp : "", patchp->dep->name);
+         reqp->relPathp = path;
+         reqp->tidPathp = tidPathp;
+ 
          code = cm_GetSCache(&patchp->fid, &scp, userp, reqp);
+         reqp->relPathp = reqp->tidPathp = NULL;
+ 
          if (code) {
              if( patchp->flags & SMB_DIRLISTPATCH_DOTFILE )
                  *dptr++ = SMB_ATTR_HIDDEN;
***************
*** 4133,4139 ****
      char *tp;
      long code = 0;
      char *pathp;
!     cm_dirEntry_t *dep;
      int maxCount;
      smb_dirListPatch_t *dirListPatchesp;
      smb_dirListPatch_t *curPatchp;
--- 4139,4145 ----
      char *tp;
      long code = 0;
      char *pathp;
!     cm_dirEntry_t *dep = 0;
      int maxCount;
      smb_dirListPatch_t *dirListPatchesp;
      smb_dirListPatch_t *curPatchp;
***************
*** 4156,4162 ****
      char shortName[13];
      char *actualName;
      char *shortNameEnd;
!     char mask[11];
      int returnedNames;
      long nextEntryCookie;
      int numDirChunks;		/* # of 32 byte dir chunks in this entry */
--- 4162,4168 ----
      char shortName[13];
      char *actualName;
      char *shortNameEnd;
!     char mask[12];
      int returnedNames;
      long nextEntryCookie;
      int numDirChunks;		/* # of 32 byte dir chunks in this entry */
***************
*** 4167,4173 ****
      int starPattern;
      int rootPath = 0;
      int caseFold;
!     char *tidPathp;
      cm_req_t req;
      cm_fid_t fid;
      int fileType;
--- 4173,4179 ----
      int starPattern;
      int rootPath = 0;
      int caseFold;
!     char *tidPathp = 0;
      cm_req_t req;
      cm_fid_t fid;
      int fileType;
***************
*** 4218,4224 ****
          dsp = smb_NewDirSearch(0);
          dsp->attribute = attribute;
          smb_Get8Dot3MaskFromPath(mask, pathp);
!         memcpy(dsp->mask, mask, 11);
  
          /* track if this is likely to match a lot of entries */
          if (smb_IsStarMask(mask)) 
--- 4224,4230 ----
          dsp = smb_NewDirSearch(0);
          dsp->attribute = attribute;
          smb_Get8Dot3MaskFromPath(mask, pathp);
!         memcpy(dsp->mask, mask, 12);
  
          /* track if this is likely to match a lot of entries */
          if (smb_IsStarMask(mask)) 
***************
*** 4244,4250 ****
           */
          memcpy(&clientCookie, &inCookiep[17], 4);
  
!         memcpy(mask, dsp->mask, 11);
  
          /* assume we're doing a star match if it has continued for more
           * than one call.
--- 4250,4256 ----
           */
          memcpy(&clientCookie, &inCookiep[17], 4);
  
!         memcpy(mask, dsp->mask, 12);
  
          /* assume we're doing a star match if it has continued for more
           * than one call.
***************
*** 4275,4291 ****
              smb_ReleaseDirSearch(dsp);
              return CM_ERROR_NOFILES;
          }
          code = cm_NameI(cm_data.rootSCachep, spacep->data,
                          caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
                  cm_ReleaseSCache(scp);
                  lock_ReleaseMutex(&dsp->mx);
                  cm_ReleaseUser(userp);
                  smb_DeleteDirSearch(dsp);
                  smb_ReleaseDirSearch(dsp);
!                 if ( WANTS_DFS_PATHNAMES(inp) )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
--- 4281,4301 ----
              smb_ReleaseDirSearch(dsp);
              return CM_ERROR_NOFILES;
          }
+         strcpy(dsp->tidPath, tidPathp ? tidPathp : "/");
+         strcpy(dsp->relPath, spacep->data);
+ 
          code = cm_NameI(cm_data.rootSCachep, spacep->data,
                          caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
+                 int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, spacep->data);
                  cm_ReleaseSCache(scp);
                  lock_ReleaseMutex(&dsp->mx);
                  cm_ReleaseUser(userp);
                  smb_DeleteDirSearch(dsp);
                  smb_ReleaseDirSearch(dsp);
!                 if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
***************
*** 4409,4415 ****
               * the status info for files in the dir.
               */
              if (starPattern) {
!                 smb_ApplyDirListPatches(&dirListPatchesp, userp, &req);
                  lock_ObtainMutex(&scp->mx);
                  if ((dsp->flags & SMB_DIRSEARCH_BULKST) &&
                       LargeIntegerGreaterThanOrEqualTo(thyper, 
--- 4419,4425 ----
               * the status info for files in the dir.
               */
              if (starPattern) {
!                 smb_ApplyDirListPatches(&dirListPatchesp, dsp->tidPath, dsp->relPath, userp, &req);
                  lock_ObtainMutex(&scp->mx);
                  if ((dsp->flags & SMB_DIRSEARCH_BULKST) &&
                       LargeIntegerGreaterThanOrEqualTo(thyper, 
***************
*** 4632,4638 ****
      /* apply and free last set of patches; if not doing a star match, this
       * will be empty, but better safe (and freeing everything) than sorry.
       */
!     smb_ApplyDirListPatches(&dirListPatchesp, userp, &req);
  
      /* special return code for unsuccessful search */
      if (code == 0 && dataLength < 21 && returnedNames == 0)
--- 4642,4648 ----
      /* apply and free last set of patches; if not doing a star match, this
       * will be empty, but better safe (and freeing everything) than sorry.
       */
!     smb_ApplyDirListPatches(&dirListPatchesp, dsp->tidPath, dsp->relPath, userp, &req);
  
      /* special return code for unsuccessful search */
      if (code == 0 && dataLength < 21 && returnedNames == 0)
***************
*** 4719,4727 ****
          
  #ifdef DFS_SUPPORT
      if (newScp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(newScp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 4729,4738 ----
          
  #ifdef DFS_SUPPORT
      if (newScp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(newScp, tidPathp, pathp);
          cm_ReleaseSCache(newScp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 4806,4814 ****
  
  #ifdef DFS_SUPPORT
      if (newScp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(newScp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 4817,4826 ----
  
  #ifdef DFS_SUPPORT
      if (newScp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(newScp, tidPathp, pathp);
          cm_ReleaseSCache(newScp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 4940,4946 ****
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
!                 if ( WANTS_DFS_PATHNAMES(inp) )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
--- 4952,4959 ----
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
!                 int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
!                 if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
***************
*** 4974,4982 ****
          
  #ifdef DFS_SUPPORT
      if (newScp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(newScp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 4987,4996 ----
          
  #ifdef DFS_SUPPORT
      if (newScp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(newScp, tidPathp, pathp);
          cm_ReleaseSCache(newScp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5129,5137 ****
  
  #ifdef DFS_SUPPORT
      if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(scp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5143,5152 ----
  
  #ifdef DFS_SUPPORT
      if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, pathp);
          cm_ReleaseSCache(scp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5243,5253 ****
  
          cm_DirEntryListAdd(dep->name, &rockp->matches);
  
!             rockp->any = 1;
  
!             /* If we made a case sensitive exact match, we might as well quit now. */
!             if (!(rockp->flags & SMB_MASKFLAG_CASEFOLD) && !strcmp(matchName, rockp->maskp))
!                 code = CM_ERROR_STOPNOW;
          else
              code = 0;
      }
--- 5258,5268 ----
  
          cm_DirEntryListAdd(dep->name, &rockp->matches);
  
!         rockp->any = 1;
  
!         /* If we made a case sensitive exact match, we might as well quit now. */
!         if (!(rockp->flags & SMB_MASKFLAG_CASEFOLD) && !strcmp(matchName, rockp->maskp))
!             code = CM_ERROR_STOPNOW;
          else
              code = 0;
      }
***************
*** 5305,5313 ****
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5320,5329 ----
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp,spacep->data);
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5466,5474 ****
          
  #ifdef DFS_SUPPORT
      if (oldDscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5482,5491 ----
          
  #ifdef DFS_SUPPORT
      if (oldDscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(oldDscp, tidPathp, spacep->data);
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5487,5496 ****
  
  #ifdef DFS_SUPPORT
      if (newDscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseSCache(newDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5504,5514 ----
  
  #ifdef DFS_SUPPORT
      if (newDscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(newDscp, tidPathp, spacep->data);
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseSCache(newDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5666,5674 ****
          
  #ifdef DFS_SUPPORT
      if (oldDscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5684,5693 ----
          
  #ifdef DFS_SUPPORT
      if (oldDscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(oldDscp, tidPathp, spacep->data);
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5686,5695 ****
  
  #ifdef DFS_SUPPORT
      if (newDscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(newDscp);
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5705,5715 ----
  
  #ifdef DFS_SUPPORT
      if (newDscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(newDscp, tidPathp, spacep->data);
          cm_ReleaseSCache(newDscp);
          cm_ReleaseSCache(oldDscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5891,5899 ****
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5911,5920 ----
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 7281,7289 ****
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 7302,7311 ----
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 7405,7413 ****
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 7427,7436 ----
          
  #ifdef DFS_SUPPORT
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
Index: openafs/src/WINNT/afsd/smb.h
diff -c openafs/src/WINNT/afsd/smb.h:1.41.2.18 openafs/src/WINNT/afsd/smb.h:1.41.2.19
*** openafs/src/WINNT/afsd/smb.h:1.41.2.18	Mon Sep 10 15:08:17 2007
--- openafs/src/WINNT/afsd/smb.h	Sat Dec 22 23:52:58 2007
***************
*** 460,465 ****
--- 460,467 ----
  					 * locked by smb_globalLock */
      unsigned short attribute;	        /* search attribute
  					 * (used for extended protocol) */
+     char tidPath[256];                  /* tid path */
+     char relPath[1024];                 /* relative path */        
      char mask[256];			/* search mask for V3 */
  } smb_dirSearch_t;
  
Index: openafs/src/WINNT/afsd/smb3.c
diff -c openafs/src/WINNT/afsd/smb3.c:1.95.2.48 openafs/src/WINNT/afsd/smb3.c:1.95.2.49
*** openafs/src/WINNT/afsd/smb3.c:1.95.2.48	Sun Nov  4 19:24:46 2007
--- openafs/src/WINNT/afsd/smb3.c	Sat Dec 22 23:52:58 2007
***************
*** 1070,1079 ****
  	if (vcp->flags & SMB_VCFLAG_USENT)
          {
              int policy = smb_FindShareCSCPolicy(shareName);
              smb_SetSMBParm(outp, 2, SMB_SUPPORT_SEARCH_BITS | 
! #ifdef DFS_SUPPORT
!                             SMB_SHARE_IS_IN_DFS |
! #endif
                              (policy << 2));
          }
      } else {
--- 1070,1090 ----
  	if (vcp->flags & SMB_VCFLAG_USENT)
          {
              int policy = smb_FindShareCSCPolicy(shareName);
+             HKEY parmKey;
+             DWORD code;
+             DWORD dwAdvertiseDFS = 0, dwSize = sizeof(DWORD);
+ 
+             code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
+                                  0, KEY_QUERY_VALUE, &parmKey);
+             if (code == ERROR_SUCCESS) {
+                 code = RegQueryValueEx(parmKey, "AdvertiseDFS", NULL, NULL,
+                                        (BYTE *)&dwAdvertiseDFS, &dwSize);
+                 if (code != ERROR_SUCCESS)
+                     dwAdvertiseDFS = 0;
+                 RegCloseKey (parmKey);
+             }
              smb_SetSMBParm(outp, 2, SMB_SUPPORT_SEARCH_BITS | 
!                            (dwAdvertiseDFS ? SMB_SHARE_IS_IN_DFS : 0) |
                              (policy << 2));
          }
      } else {
***************
*** 2222,2231 ****
          
  #ifdef DFS_SUPPORT
          if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
              cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
              smb_FreeTran2Packet(outp);
!             if ( WANTS_DFS_PATHNAMES(p) )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
--- 2233,2243 ----
          
  #ifdef DFS_SUPPORT
          if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+             int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
              cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
              smb_FreeTran2Packet(outp);
!             if ( WANTS_DFS_PATHNAMES(p) || pnc )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
***************
*** 2251,2260 ****
      } else {
  #ifdef DFS_SUPPORT
          if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              smb_FreeTran2Packet(outp);
!             if ( WANTS_DFS_PATHNAMES(p) )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
--- 2263,2273 ----
      } else {
  #ifdef DFS_SUPPORT
          if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
+             int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, lastNamep);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              smb_FreeTran2Packet(outp);
!             if ( WANTS_DFS_PATHNAMES(p) || pnc )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
***************
*** 2627,2632 ****
--- 2640,2646 ----
      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
+         DebugBreak();
          return CM_ERROR_PATH_NOT_COVERED;
      }
  #endif /* DFS_SUPPORT */
***************
*** 2770,2776 ****
                  if (code == 0) {
  #ifdef DFS_SUPPORT
                      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
!                         if ( WANTS_DFS_PATHNAMES(p) )
                              code = CM_ERROR_PATH_NOT_COVERED;
                          else
                              code = CM_ERROR_BADSHARENAME;
--- 2784,2791 ----
                  if (code == 0) {
  #ifdef DFS_SUPPORT
                      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
!                         int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
!                         if ( WANTS_DFS_PATHNAMES(p) || pnc )
                              code = CM_ERROR_PATH_NOT_COVERED;
                          else
                              code = CM_ERROR_BADSHARENAME;
***************
*** 2816,2824 ****
  
  #ifdef DFS_SUPPORT
      if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(scp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(p) )
              code = CM_ERROR_PATH_NOT_COVERED;
          else
              code = CM_ERROR_BADSHARENAME;
--- 2831,2840 ----
  
  #ifdef DFS_SUPPORT
      if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, pathp);
          cm_ReleaseSCache(scp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(p) || pnc )
              code = CM_ERROR_PATH_NOT_COVERED;
          else
              code = CM_ERROR_BADSHARENAME;
***************
*** 2982,2988 ****
  	infoLevel != SMB_INFO_QUERY_ALL_EAS) {
          osi_Log2(smb_logp, "Bad Tran2 op 0x%x infolevel 0x%x",
                    p->opcode, infoLevel);
!         smb_SendTran2Error(vcp, p, opx, CM_ERROR_BAD_LEVEL);
          return 0;
      }
  
--- 2998,3005 ----
  	infoLevel != SMB_INFO_QUERY_ALL_EAS) {
          osi_Log2(smb_logp, "Bad Tran2 op 0x%x infolevel 0x%x",
                    p->opcode, infoLevel);
!         smb_SendTran2Error(vcp, p, opx, 
!                            infoLevel == SMB_INFO_QUERY_ALL_EAS ? CM_ERROR_EAS_NOT_SUPPORTED : CM_ERROR_BAD_LEVEL);
          return 0;
      }
  
***************
*** 3040,3046 ****
                  if (code == 0) {
  #ifdef DFS_SUPPORT
                      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
!                         if ( WANTS_DFS_PATHNAMES(p) )
                              code = CM_ERROR_PATH_NOT_COVERED;
                          else
                              code = CM_ERROR_BADSHARENAME;
--- 3057,3064 ----
                  if (code == 0) {
  #ifdef DFS_SUPPORT
                      if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
!                         int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
!                         if ( WANTS_DFS_PATHNAMES(p) || pnc )
                              code = CM_ERROR_PATH_NOT_COVERED;
                          else
                              code = CM_ERROR_BADSHARENAME;
***************
*** 3162,3168 ****
      }               
      else if (infoLevel == SMB_INFO_QUERY_ALL_EAS) {
  	/* we don't support EAs */
! 	code = CM_ERROR_INVAL;
      }       
  
    done:
--- 3180,3186 ----
      }               
      else if (infoLevel == SMB_INFO_QUERY_ALL_EAS) {
  	/* we don't support EAs */
! 	code = CM_ERROR_EAS_NOT_SUPPORTED;
      }       
  
    done:
***************
*** 3575,3585 ****
      long code = 0;
      int maxReferralLevel = 0;
      char requestFileName[1024] = "";
      smb_tran2Packet_t *outp = 0;
      cm_user_t *userp = 0;
      cm_req_t req;
      CPINFO CodePageInfo;
!     int i, nbnLen, reqLen;
      int idx;
  
      cm_InitReq(&req);
--- 3593,3606 ----
      long code = 0;
      int maxReferralLevel = 0;
      char requestFileName[1024] = "";
+     char referralPath[1024] = "";
      smb_tran2Packet_t *outp = 0;
      cm_user_t *userp = 0;
+     cm_scache_t *scp = 0;
+     cm_scache_t *dscp = 0;
      cm_req_t req;
      CPINFO CodePageInfo;
!     int i, nbnLen, reqLen, refLen;
      int idx;
  
      cm_InitReq(&req);
***************
*** 3596,3652 ****
      nbnLen = strlen(cm_NetbiosName);
      reqLen = strlen(requestFileName);
  
!     if (reqLen == nbnLen + 5 &&
!         requestFileName[0] == '\\' &&
          !_strnicmp(cm_NetbiosName,&requestFileName[1],nbnLen) &&
!         requestFileName[nbnLen+1] == '\\' &&
!         (!_strnicmp("all",&requestFileName[nbnLen+2],3) || 
! 	  !_strnicmp("*.",&requestFileName[nbnLen+2],2)))
      {
!         USHORT * sp;
!         struct smb_v2_referral * v2ref;
!         outp = smb_GetTran2ResponsePacket(vcp, p, op, 0, 2 * (reqLen + 8));
! 
!         sp = (USHORT *)outp->datap;
!         idx = 0;
!         sp[idx++] = reqLen;   /* path consumed */
!         sp[idx++] = 1;        /* number of referrals */
!         sp[idx++] = 0x03;     /* flags */
  #ifdef DFS_VERSION_1
!         sp[idx++] = 1;        /* Version Number */
!         sp[idx++] = reqLen + 4;  /* Referral Size */ 
!         sp[idx++] = 1;        /* Type = SMB Server */
!         sp[idx++] = 0;        /* Do not strip path consumed */
!         for ( i=0;i<=reqLen; i++ )
!             sp[i+idx] = requestFileName[i];
  #else /* DFS_VERSION_2 */
!         sp[idx++] = 2;      /* Version Number */
!         sp[idx++] = sizeof(struct smb_v2_referral);     /* Referral Size */
!         idx += (sizeof(struct smb_v2_referral) / 2);
!         v2ref = (struct smb_v2_referral *) &sp[5];
!         v2ref->ServerType = 1;  /* SMB Server */
!         v2ref->ReferralFlags = 0x03;
!         v2ref->Proximity = 0;   /* closest */
!         v2ref->TimeToLive = 3600; /* seconds */
!         v2ref->DfsPathOffset = idx * 2;
!         v2ref->DfsAlternativePathOffset = idx * 2;
!         v2ref->NetworkAddressOffset = 0;
!         for ( i=0;i<=reqLen; i++ )
!             sp[i+idx] = requestFileName[i];
  #endif
      } else {
-         userp = smb_GetTran2User(vcp, p);
-         if (!userp) {
-             osi_Log1(smb_logp,"ReceiveTran2GetDfsReferral unable to resolve user [%d]", p->uid);
-             code = CM_ERROR_BADSMB;
-             goto done;
-         }   
- 
- 		/* not done yet */
          code = CM_ERROR_NOSUCHPATH;
      }
! 
    done:
      if (userp)
          cm_ReleaseUser(userp);
      if (code == 0) 
--- 3617,3768 ----
      nbnLen = strlen(cm_NetbiosName);
      reqLen = strlen(requestFileName);
  
!     if (reqLen > nbnLen + 2 && requestFileName[0] == '\\' &&
          !_strnicmp(cm_NetbiosName,&requestFileName[1],nbnLen) &&
!         requestFileName[nbnLen+1] == '\\') 
      {
!         int found = 0;
! 
!         if (!_strnicmp("all",&requestFileName[nbnLen+2],3) ||
!              !_strnicmp("*.",&requestFileName[nbnLen+2],2)) 
!         {
!             found = 1;
!             strcpy(referralPath, requestFileName);
!             refLen = reqLen;
!         } else {
!             userp = smb_GetTran2User(vcp, p);
!             if (!userp) {
!                 osi_Log1(smb_logp,"ReceiveTran2GetDfsReferral unable to resolve user [%d]", p->uid);
!                 code = CM_ERROR_BADSMB;
!                 goto done;
!             }   
! 
!             /* 
!              * We have a requested path.  Check to see if it is something 
!              * we know about.
!              */
!             code = cm_NameI(cm_data.rootSCachep, &requestFileName[nbnLen+2],
!                             CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
!                             userp, NULL, &req, &scp);
!             if (code == 0) {
!                 /* Yes it is. */
!                 found = 1;
!                 strcpy(referralPath, requestFileName);
!                 refLen = reqLen;
!             } else if (code == CM_ERROR_PATH_NOT_COVERED ) {
!                 char temp[1024];
!                 char pathName[1024];
!                 char *lastComponent;
!                 /* 
!                  * we have a msdfs link somewhere in the path
!                  * we should figure out where in the path the link is.
!                  * and return it.
!                  */
!                 osi_Log1(smb_logp,"ReceiveTran2GetDfsReferral PATH_NOT_COVERED [%s]", requestFileName);
! 
!                 strcpy(temp, &requestFileName[nbnLen+2]);
! 
!                 do {
!                     if (dscp) {
!                         cm_ReleaseSCache(dscp);
!                         dscp = 0;
!                     }
!                     if (scp) {
!                         cm_ReleaseSCache(scp);
!                         scp = 0;
!                     }
!                     smb_StripLastComponent(pathName, &lastComponent, temp);
! 
!                     code = cm_NameI(cm_data.rootSCachep, pathName,
!                                     CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
!                                     userp, NULL, &req, &dscp);
!                     if (code == 0) {
!                         code = cm_NameI(dscp, ++lastComponent,
!                                         CM_FLAG_CASEFOLD,
!                                         userp, NULL, &req, &scp);
!                         if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK)
!                             break;
!                     }
!                 } while (code == CM_ERROR_PATH_NOT_COVERED);
! 
!                 /* scp should now be the DfsLink we are looking for */
!                 if (scp) {
!                     /* figure out how much of the input path was used */
!                     reqLen = nbnLen+2 + strlen(pathName) + 1 + strlen(lastComponent);
! 
!                     strcpy(referralPath, &scp->mountPointStringp[strlen("msdfs:")]);
!                     refLen = strlen(referralPath);
!                     found = 1;
!                 }
!             } else {
!                 char shareName[MAX_PATH + 1];
!                 char *p, *q;
!                 /* we may have a sharename that is a volume reference */
! 
!                 for (p = &requestFileName[nbnLen+2], q = shareName; *p && *p != '\\'; p++, q++)
!                 {
!                     *q = *p;
!                 }
!                 *q = '\0';
!                 
!                 if (smb_FindShare(vcp, vcp->usersp, shareName, &p)) {
!                     code = cm_NameI(cm_data.rootSCachep, "", 
!                                     CM_FLAG_CASEFOLD | CM_FLAG_FOLLOW,
!                                     userp, p, &req, &scp);
!                     free(p);
! 
!                     if (code == 0) {
!                         found = 1;
!                         strcpy(referralPath, requestFileName);
!                         refLen = reqLen;
!                     }
!                 }
!             }
!         }
!         
!         if (found)
!         {
!             USHORT * sp;
!             struct smb_v2_referral * v2ref;
!             outp = smb_GetTran2ResponsePacket(vcp, p, op, 0, 2 * (refLen + 8));
! 
!             sp = (USHORT *)outp->datap;
!             idx = 0;
!             sp[idx++] = reqLen;   /* path consumed */
!             sp[idx++] = 1;        /* number of referrals */
!             sp[idx++] = 0x03;     /* flags */
  #ifdef DFS_VERSION_1
!             sp[idx++] = 1;        /* Version Number */
!             sp[idx++] = refLen + 4;  /* Referral Size */ 
!             sp[idx++] = 1;        /* Type = SMB Server */
!             sp[idx++] = 0;        /* Do not strip path consumed */
!             for ( i=0;i<=refLen; i++ )
!                 sp[i+idx] = referralPath[i];
  #else /* DFS_VERSION_2 */
!             sp[idx++] = 2;      /* Version Number */
!             sp[idx++] = sizeof(struct smb_v2_referral);     /* Referral Size */
!             idx += (sizeof(struct smb_v2_referral) / 2);
!             v2ref = (struct smb_v2_referral *) &sp[5];
!             v2ref->ServerType = 1;  /* SMB Server */
!             v2ref->ReferralFlags = 0x03;
!             v2ref->Proximity = 0;   /* closest */
!             v2ref->TimeToLive = 3600; /* seconds */
!             v2ref->DfsPathOffset = idx * 2;
!             v2ref->DfsAlternativePathOffset = idx * 2;
!             v2ref->NetworkAddressOffset = 0;
!             for ( i=0;i<=refLen; i++ )
!                 sp[i+idx] = referralPath[i];
  #endif
+         } 
      } else {
          code = CM_ERROR_NOSUCHPATH;
      }
!          
    done:
+     if (dscp)
+         cm_ReleaseSCache(dscp);
+     if (scp)
+         cm_ReleaseSCache(scp);
      if (userp)
          cm_ReleaseUser(userp);
      if (code == 0) 
***************
*** 3679,3688 ****
      return CM_ERROR_BADOP;
  }
  
! long 
! smb_ApplyV3DirListPatches(cm_scache_t *dscp,
! 	smb_dirListPatch_t **dirPatchespp, int infoLevel, cm_user_t *userp,
! 	cm_req_t *reqp)
  {
      long code = 0;
      cm_scache_t *scp;
--- 3795,3805 ----
      return CM_ERROR_BADOP;
  }
  
! static long 
! smb_ApplyV3DirListPatches(cm_scache_t *dscp,smb_dirListPatch_t **dirPatchespp, 
!                           char * tidPathp, char * relPathp, 
!                           int infoLevel, cm_user_t *userp,
!                           cm_req_t *reqp)
  {
      long code = 0;
      cm_scache_t *scp;
***************
*** 3697,3702 ****
--- 3814,3820 ----
      smb_dirListPatch_t *npatchp;
      afs_uint32 rights;
      afs_int32 mustFake = 0;
+     char path[AFSPATHMAX];
  
      code = cm_FindACLCache(dscp, userp, &rights);
      if (code == 0 && !(rights & PRSFS_READ))
***************
*** 3716,3722 ****
--- 3834,3845 ----
  
      for(patchp = *dirPatchespp; patchp; patchp =
           (smb_dirListPatch_t *) osi_QNext(&patchp->q)) {
+         snprintf(path, AFSPATHMAX, "%s\\%s", relPathp ? relPathp : "", patchp->dep->name);
+         reqp->relPathp = path;
+         reqp->tidPathp = tidPathp;
+ 
          code = cm_GetSCache(&patchp->fid, &scp, userp, reqp);
+         reqp->relPathp = reqp->tidPathp = NULL;
          if (code) 
              continue;
  
***************
*** 3840,3846 ****
--- 3963,3973 ----
          code = 0;
          while (code == 0 && scp->fileType == CM_SCACHETYPE_SYMLINK) {
              lock_ReleaseMutex(&scp->mx);
+             snprintf(path, AFSPATHMAX, "%s\\%s", relPathp ? relPathp : "", patchp->dep->name);
+             reqp->relPathp = path;
+             reqp->tidPathp = tidPathp;
              code = cm_EvaluateSymLink(dscp, scp, &targetScp, userp, reqp);
+             reqp->relPathp = reqp->tidPathp = NULL;
              if (code == 0) {
                  /* we have a more accurate file to use (the
                   * target of the symbolic link).  Otherwise,
***************
*** 3884,3890 ****
  
              /* Copy attributes */
              lattr = smb_ExtAttributes(scp);
!             if (code == CM_ERROR_NOSUCHPATH && scp->fileType == CM_SCACHETYPE_SYMLINK) {
                  if (lattr == SMB_ATTR_NORMAL)
                      lattr = SMB_ATTR_DIRECTORY;
                  else
--- 4011,4018 ----
  
              /* Copy attributes */
              lattr = smb_ExtAttributes(scp);
!             if (code == CM_ERROR_NOSUCHPATH && scp->fileType == CM_SCACHETYPE_SYMLINK ||
!                 code == CM_ERROR_PATH_NOT_COVERED && scp->fileType == CM_SCACHETYPE_DFSLINK) {
                  if (lattr == SMB_ATTR_NORMAL)
                      lattr = SMB_ATTR_DIRECTORY;
                  else
***************
*** 4117,4123 ****
      int attribute;
      long nextCookie;
      long code = 0, code2 = 0;
!     char *pathp;
      int maxCount;
      smb_dirListPatch_t *dirListPatchesp;
      smb_dirListPatch_t *curPatchp;
--- 4245,4251 ----
      int attribute;
      long nextCookie;
      long code = 0, code2 = 0;
!     char *pathp = 0;
      int maxCount;
      smb_dirListPatch_t *dirListPatchesp;
      smb_dirListPatch_t *curPatchp;
***************
*** 4138,4148 ****
      int searchFlags;
      int eos;
      smb_tran2Packet_t *outp;		/* response packet */
!     char *tidPathp;
      int align;
      char shortName[13];			/* 8.3 name if needed */
      int NeedShortName;
      char *shortNameEnd;
      cm_req_t req;
      char * s;
  
--- 4266,4277 ----
      int searchFlags;
      int eos;
      smb_tran2Packet_t *outp;		/* response packet */
!     char *tidPathp = 0;
      int align;
      char shortName[13];			/* 8.3 name if needed */
      int NeedShortName;
      char *shortNameEnd;
+     cm_dirEntry_t * dep = NULL;
      cm_req_t req;
      char * s;
  
***************
*** 4268,4276 ****
  
  #ifdef DFS_SUPPORT_BUT_NOT_FIND_FIRST
      if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
  	cm_ReleaseSCache(scp);
  	cm_ReleaseUser(userp);
! 	if ( WANTS_DFS_PATHNAMES(p) )
  	    code = CM_ERROR_PATH_NOT_COVERED;
  	else
  	    code = CM_ERROR_BADSHARENAME;
--- 4397,4406 ----
  
  #ifdef DFS_SUPPORT_BUT_NOT_FIND_FIRST
      if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, spacep->data);
  	cm_ReleaseSCache(scp);
  	cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(p) || pnc )
  	    code = CM_ERROR_PATH_NOT_COVERED;
  	else
  	    code = CM_ERROR_BADSHARENAME;
***************
*** 4461,4467 ****
          curPatchp->fid.unique = targetscp->fid.unique;
  
          /* temp */
!         curPatchp->dep = NULL;
      }   
  
      if (searchFlags & TRAN2_FIND_FLAG_RETURN_RESUME_KEYS) {
--- 4591,4601 ----
          curPatchp->fid.unique = targetscp->fid.unique;
  
          /* temp */
!         dep = (cm_dirEntry_t *)malloc(sizeof(cm_dirEntry_t)+strlen(maskp));
!         strcpy(dep->name, maskp);
!         dep->fid.vnode = targetscp->fid.vnode;
!         dep->fid.unique = targetscp->fid.unique;
!         curPatchp->dep = dep;
      }   
  
      if (searchFlags & TRAN2_FIND_FLAG_RETURN_RESUME_KEYS) {
***************
*** 4480,4486 ****
      }
  
      /* apply the patches */
!     code2 = smb_ApplyV3DirListPatches(scp, &dirListPatchesp, infoLevel, userp, &req);
  
      outp->parmsp[0] = 0;
      outp->parmsp[1] = 1;        /* number of names returned */
--- 4614,4620 ----
      }
  
      /* apply the patches */
!     code2 = smb_ApplyV3DirListPatches(scp, &dirListPatchesp, tidPathp, spacep->data, infoLevel, userp, &req);
  
      outp->parmsp[0] = 0;
      outp->parmsp[1] = 1;        /* number of names returned */
***************
*** 4504,4509 ****
--- 4638,4645 ----
  
   skip_file:
      smb_FreeTran2Packet(outp);
+     if (dep)
+         free(dep);
      cm_ReleaseSCache(scp);
      cm_ReleaseSCache(targetscp);
      cm_ReleaseUser(userp);
***************
*** 4519,4528 ****
      char *tp;
      long code = 0, code2 = 0;
      char *pathp;
!     cm_dirEntry_t *dep;
      int maxCount;
!     smb_dirListPatch_t *dirListPatchesp;
!     smb_dirListPatch_t *curPatchp;
      cm_buf_t *bufferp;
      long temp;
      long orbytes;			/* # of bytes in this output record */
--- 4655,4664 ----
      char *tp;
      long code = 0, code2 = 0;
      char *pathp;
!     cm_dirEntry_t *dep = 0;
      int maxCount;
!     smb_dirListPatch_t *dirListPatchesp = 0;
!     smb_dirListPatch_t *curPatchp = 0;
      cm_buf_t *bufferp;
      long temp;
      long orbytes;			/* # of bytes in this output record */
***************
*** 4731,4736 ****
--- 4867,4876 ----
              smb_ReleaseDirSearch(dsp);
              return 0;
          }
+ 
+         strcpy(dsp->tidPath, tidPathp ? tidPathp : "/");
+         strcpy(dsp->relPath, spacep->data);
+ 
          code = cm_NameI(cm_data.rootSCachep, spacep->data,
                          CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                          userp, tidPathp, &req, &scp);
***************
*** 4739,4747 ****
          if (code == 0) {
  #ifdef DFS_SUPPORT_BUT_NOT_FIND_FIRST
              if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
                  cm_ReleaseSCache(scp);
                  cm_ReleaseUser(userp);
!                 if ( WANTS_DFS_PATHNAMES(p) )
                      code = CM_ERROR_PATH_NOT_COVERED;
                  else
                      code = CM_ERROR_BADSHARENAME;
--- 4879,4888 ----
          if (code == 0) {
  #ifdef DFS_SUPPORT_BUT_NOT_FIND_FIRST
              if (scp->fileType == CM_SCACHETYPE_DFSLINK) {
+                 int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, spacep->data);
                  cm_ReleaseSCache(scp);
                  cm_ReleaseUser(userp);
!                 if ( WANTS_DFS_PATHNAMES(p) || pnc )
                      code = CM_ERROR_PATH_NOT_COVERED;
                  else
                      code = CM_ERROR_BADSHARENAME;
***************
*** 4877,4885 ****
               * of all of the status info for files in the dir.
               */
              if (starPattern) {
!                 smb_ApplyV3DirListPatches(scp, &dirListPatchesp,
!                                            infoLevel, userp,
!                                            &req);
                  lock_ObtainMutex(&scp->mx);
                  if ((dsp->flags & SMB_DIRSEARCH_BULKST) &&
                      LargeIntegerGreaterThanOrEqualTo(thyper, scp->bulkStatProgress)) {
--- 5018,5025 ----
               * of all of the status info for files in the dir.
               */
              if (starPattern) {
!                 code2 = smb_ApplyV3DirListPatches(scp, &dirListPatchesp, dsp->tidPath, dsp->relPath, infoLevel, userp, &req);
!                 
                  lock_ObtainMutex(&scp->mx);
                  if ((dsp->flags & SMB_DIRSEARCH_BULKST) &&
                      LargeIntegerGreaterThanOrEqualTo(thyper, scp->bulkStatProgress)) {
***************
*** 5189,5196 ****
      /* apply and free last set of patches; if not doing a star match, this
       * will be empty, but better safe (and freeing everything) than sorry.
       */
!     code2 = smb_ApplyV3DirListPatches(scp, &dirListPatchesp, infoLevel, userp, &req);
!         
      /* now put out the final parameters */
      if (returnedNames == 0) 
          eos = 1;
--- 5329,5337 ----
      /* apply and free last set of patches; if not doing a star match, this
       * will be empty, but better safe (and freeing everything) than sorry.
       */
!     code2 = smb_ApplyV3DirListPatches(scp, &dirListPatchesp, dsp->tidPath, 
!                                       dsp->relPath, infoLevel, userp, &req);
! 
      /* now put out the final parameters */
      if (returnedNames == 0) 
          eos = 1;
***************
*** 5393,5401 ****
  
  #ifdef DFS_SUPPORT
      if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK) {
          cm_ReleaseSCache(scp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
--- 5534,5543 ----
  
  #ifdef DFS_SUPPORT
      if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK) {
+         int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, pathp);
          cm_ReleaseSCache(scp);
          cm_ReleaseUser(userp);
!         if ( WANTS_DFS_PATHNAMES(inp) || pnc )
              return CM_ERROR_PATH_NOT_COVERED;
          else
              return CM_ERROR_BADSHARENAME;
***************
*** 5413,5421 ****
  
  #ifdef DFS_SUPPORT
          if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
              cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
!             if ( WANTS_DFS_PATHNAMES(inp) )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
--- 5555,5564 ----
  
  #ifdef DFS_SUPPORT
          if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+             int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
              cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
!             if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
***************
*** 6579,6590 ****
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
                  cm_ReleaseSCache(dscp);
                  cm_ReleaseUser(userp);
                  free(realPathp);
  		if (baseFidp) 
  		    smb_ReleaseFID(baseFidp);
!                 if ( WANTS_DFS_PATHNAMES(inp) )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
--- 6722,6734 ----
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+                 int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
                  cm_ReleaseSCache(dscp);
                  cm_ReleaseUser(userp);
                  free(realPathp);
  		if (baseFidp) 
  		    smb_ReleaseFID(baseFidp);
!                 if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
***************
*** 6612,6623 ****
                          userp, tidPathp, &req, &scp);
  #ifdef DFS_SUPPORT
          if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK) {
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
  	    if (baseFidp) 
  		smb_ReleaseFID(baseFidp);
!             if ( WANTS_DFS_PATHNAMES(inp) )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
--- 6756,6768 ----
                          userp, tidPathp, &req, &scp);
  #ifdef DFS_SUPPORT
          if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK) {
+             int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, realPathp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
  	    if (baseFidp) 
  		smb_ReleaseFID(baseFidp);
!             if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
***************
*** 6648,6653 ****
--- 6793,6799 ----
  
  #ifdef DFS_SUPPORT
                  if (code == 0 && dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+                     int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
                      if (scp)
                          cm_ReleaseSCache(scp);
                      cm_ReleaseSCache(dscp);
***************
*** 6655,6661 ****
                      free(realPathp);
  		    if (baseFidp) 
  			smb_ReleaseFID(baseFidp);
!                     if ( WANTS_DFS_PATHNAMES(inp) )
                          return CM_ERROR_PATH_NOT_COVERED;
                      else
                          return CM_ERROR_BADSHARENAME;
--- 6801,6807 ----
                      free(realPathp);
  		    if (baseFidp) 
  			smb_ReleaseFID(baseFidp);
!                     if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                          return CM_ERROR_PATH_NOT_COVERED;
                      else
                          return CM_ERROR_BADSHARENAME;
***************
*** 7378,7389 ****
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
                  cm_ReleaseSCache(dscp);
                  cm_ReleaseUser(userp);
                  free(realPathp);
  		if (baseFidp)
  		    smb_ReleaseFID(baseFidp);
!                 if ( WANTS_DFS_PATHNAMES(inp) )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
--- 7524,7536 ----
          if (code == 0) {
  #ifdef DFS_SUPPORT
              if (dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+                 int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
                  cm_ReleaseSCache(dscp);
                  cm_ReleaseUser(userp);
                  free(realPathp);
  		if (baseFidp)
  		    smb_ReleaseFID(baseFidp);
!                 if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
***************
*** 7411,7422 ****
                          userp, tidPathp, &req, &scp);
  #ifdef DFS_SUPPORT
          if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK) {
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
  	    if (baseFidp)
  		smb_ReleaseFID(baseFidp);
!             if ( WANTS_DFS_PATHNAMES(inp) )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
--- 7558,7570 ----
                          userp, tidPathp, &req, &scp);
  #ifdef DFS_SUPPORT
          if (code == 0 && scp->fileType == CM_SCACHETYPE_DFSLINK) {
+             int pnc = cm_VolStatus_Notify_DFS_Mapping(scp, tidPathp, realPathp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
  	    if (baseFidp)
  		smb_ReleaseFID(baseFidp);
!             if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                  return CM_ERROR_PATH_NOT_COVERED;
              else
                  return CM_ERROR_BADSHARENAME;
***************
*** 7435,7446 ****
                               userp, tidPathp, &req, &dscp);
  #ifdef DFS_SUPPORT
              if (code == 0 && dscp->fileType == CM_SCACHETYPE_DFSLINK) {
                  cm_ReleaseSCache(dscp);
                  cm_ReleaseUser(userp);
                  free(realPathp);
  		if (baseFidp)
  		    smb_ReleaseFID(baseFidp);
!                 if ( WANTS_DFS_PATHNAMES(inp) )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
--- 7583,7595 ----
                               userp, tidPathp, &req, &dscp);
  #ifdef DFS_SUPPORT
              if (code == 0 && dscp->fileType == CM_SCACHETYPE_DFSLINK) {
+                 int pnc = cm_VolStatus_Notify_DFS_Mapping(dscp, tidPathp, spacep->data);
                  cm_ReleaseSCache(dscp);
                  cm_ReleaseUser(userp);
                  free(realPathp);
  		if (baseFidp)
  		    smb_ReleaseFID(baseFidp);
!                 if ( WANTS_DFS_PATHNAMES(inp) || pnc )
                      return CM_ERROR_PATH_NOT_COVERED;
                  else
                      return CM_ERROR_BADSHARENAME;
Index: openafs/src/WINNT/doc/install/Documentation/en_US/html/index.htm
diff -c openafs/src/WINNT/doc/install/Documentation/en_US/html/index.htm:1.5.4.23 openafs/src/WINNT/doc/install/Documentation/en_US/html/index.htm:1.5.4.24
*** openafs/src/WINNT/doc/install/Documentation/en_US/html/index.htm:1.5.4.23	Tue Dec  4 14:54:24 2007
--- openafs/src/WINNT/doc/install/Documentation/en_US/html/index.htm	Fri Dec 28 14:47:11 2007
***************
*** 57,63 ****
  
  <h1>OpenAFS for Windows</h1>
  
! <h2>Version 1.5.28</h2>
  
  <p class=MsoNormal>&nbsp; </p>
  
--- 57,63 ----
  
  <h1>OpenAFS for Windows</h1>
  
! <h2>Version 1.5.29</h2>
  
  <p class=MsoNormal>&nbsp; </p>
  
***************
*** 80,86 ****
  <span
  style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></span><a
! href="ReleaseNotes/relnotes-frames.htm">OpenAFS for Windows 1.5.28
  Release Notes</a></p>
  
  <p style='margin-left:36.0pt;text-indent:-18.0pt;'>
--- 80,86 ----
  <span
  style='font-family:Symbol'>·<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span></span><a
! href="ReleaseNotes/relnotes-frames.htm">OpenAFS for Windows 1.5.29
  Release Notes</a></p>
  
  <p style='margin-left:36.0pt;text-indent:-18.0pt;'>
Index: openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/logo.htm
diff -c openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/logo.htm:1.1.6.23 openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/logo.htm:1.1.6.24
*** openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/logo.htm:1.1.6.23	Tue Dec  4 14:54:29 2007
--- openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/logo.htm	Fri Dec 28 14:47:19 2007
***************
*** 18,24 ****
  .shape {behavior:url(#default#VML);}
  </style>
  <![endif]-->
! <title>OpenAFS for Windows 1.5.28 Release Notes</title>
  <!--[if gte mso 9]><xml>
   <o:DocumentProperties>
    <o:Revision>1</o:Revision>
--- 18,24 ----
  .shape {behavior:url(#default#VML);}
  </style>
  <![endif]-->
! <title>OpenAFS for Windows 1.5.29 Release Notes</title>
  <!--[if gte mso 9]><xml>
   <o:DocumentProperties>
    <o:Revision>1</o:Revision>
Index: openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes-frames.htm
diff -c openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes-frames.htm:1.1.4.25 openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes-frames.htm:1.1.4.26
*** openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes-frames.htm:1.1.4.25	Tue Dec  4 14:54:29 2007
--- openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes-frames.htm	Fri Dec 28 14:47:19 2007
***************
*** 8,14 ****
  <meta name=Generator content="Microsoft Word 11">
  <meta name=Originator content="Microsoft Word 11">
  <link rel=File-List href="relnotes-frames_files/filelist.xml">
! <title>OpenAFS for Windows 1.5.28 Release Notes</title>
  <!--[if gte mso 9]><xml>
   <w:WordDocument>
    <w:Zoom>0</w:Zoom>
--- 8,14 ----
  <meta name=Generator content="Microsoft Word 11">
  <meta name=Originator content="Microsoft Word 11">
  <link rel=File-List href="relnotes-frames_files/filelist.xml">
! <title>OpenAFS for Windows 1.5.29 Release Notes</title>
  <!--[if gte mso 9]><xml>
   <w:WordDocument>
    <w:Zoom>0</w:Zoom>
Index: openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes.htm
diff -c openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes.htm:1.6.4.29 openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes.htm:1.6.4.30
*** openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes.htm:1.6.4.29	Fri Dec  7 11:06:24 2007
--- openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/relnotes.htm	Fri Dec 28 14:47:19 2007
***************
*** 19,25 ****
  .shape {behavior:url(#default#VML);}
  </style>
  <![endif]-->
! <title>OpenAFS for Windows 1.5.28 Release Notes</title>
  <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
   name="PostalCode"/>
  <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
--- 19,25 ----
  .shape {behavior:url(#default#VML);}
  </style>
  <![endif]-->
! <title>OpenAFS for Windows 1.5.29 Release Notes</title>
  <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
   name="PostalCode"/>
  <o:SmartTagType namespaceuri="urn:schemas-microsoft-com:office:smarttags"
***************
*** 583,589 ****
  
  <div class=Section1>
  
! <p class=MsoTitle>OpenAFS for Windows 1.5.28<br>
  Release Notes</p>
  
  <p class=MsoBodyText>The Andrew File System (AFS) is a location-independent
--- 583,589 ----
  
  <div class=Section1>
  
! <p class=MsoTitle>OpenAFS for Windows 1.5.29<br>
  Release Notes</p>
  
  <p class=MsoBodyText>The Andrew File System (AFS) is a location-independent
Index: openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/toc.htm
diff -c openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/toc.htm:1.2.6.24 openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/toc.htm:1.2.6.25
*** openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/toc.htm:1.2.6.24	Fri Dec  7 11:06:25 2007
--- openafs/src/WINNT/doc/install/Documentation/en_US/html/ReleaseNotes/toc.htm	Fri Dec 28 14:47:20 2007
***************
*** 10,16 ****
  <meta name=Originator content="Microsoft Word 11">
  <base target=body>
  <link rel=File-List href="toc_files/filelist.xml">
! <title>OpenAFS for Windows 1.5.28 Table of Contents</title>
  <!--[if gte mso 9]><xml>
   <o:DocumentProperties>
    <o:Author>Jeffrey Altman</o:Author>
--- 10,16 ----
  <meta name=Originator content="Microsoft Word 11">
  <base target=body>
  <link rel=File-List href="toc_files/filelist.xml">
! <title>OpenAFS for Windows 1.5.29 Table of Contents</title>
  <!--[if gte mso 9]><xml>
   <o:DocumentProperties>
    <o:Author>Jeffrey Altman</o:Author>
Index: openafs/src/WINNT/pthread/pthread.c
diff -c openafs/src/WINNT/pthread/pthread.c:1.11 openafs/src/WINNT/pthread/pthread.c:1.11.2.1
*** openafs/src/WINNT/pthread/pthread.c:1.11	Mon Apr 24 10:25:12 2006
--- openafs/src/WINNT/pthread/pthread.c	Tue Dec 25 18:06:14 2007
***************
*** 126,132 ****
  	    if (mp->isLocked) {
  		/* same thread tried to recursively lock, fail */
  		LeaveCriticalSection(&mp->cs);
! 		rc = EBUSY;
  	    } else {
  		mp->isLocked = 1;
  		mp->tid = GetCurrentThreadId();
--- 126,132 ----
  	    if (mp->isLocked) {
  		/* same thread tried to recursively lock, fail */
  		LeaveCriticalSection(&mp->cs);
! 		rc = EDEADLK;
  	    } else {
  		mp->isLocked = 1;
  		mp->tid = GetCurrentThreadId();
***************
*** 161,168 ****
--- 161,174 ----
  	     */
  	    LeaveCriticalSection(&mp->cs);
  	    rc = EDEADLK;
+ #ifdef PTHREAD_DEBUG
+             DebugBreak();
+ #endif
  	}
      } else {
+ #ifdef PTHREAD_DEBUG
+         DebugBreak();
+ #endif
  	rc = EINVAL;
      }
  	
***************
*** 178,186 ****
  	    mp->tid = 0;
  	    LeaveCriticalSection(&mp->cs);
  	} else {
! 	    rc = 0;
  	}
      } else {
  	rc = EINVAL;
      }
      return rc;
--- 184,198 ----
  	    mp->tid = 0;
  	    LeaveCriticalSection(&mp->cs);
  	} else {
! #ifdef PTHREAD_DEBUG
!             DebugBreak();
! #endif
! 	    rc = EPERM;
  	}
      } else {
+ #ifdef PTHREAD_DEBUG
+         DebugBreak();
+ #endif
  	rc = EINVAL;
      }
      return rc;
***************
*** 192,197 ****
--- 204,212 ----
      if (mp != NULL) {
  	DeleteCriticalSection(&mp->cs);
      } else {
+ #ifdef PTHREAD_DEBUG
+         DebugBreak();
+ #endif
  	rc = EINVAL;
      }
  
***************
*** 806,871 ****
  	queue_Append(&cond->waiting_threads, my_entry);
  	LeaveCriticalSection(&cond->cs);
  
! 	if (!pthread_mutex_unlock(mutex)) {
  	    switch(WaitForSingleObject(my_entry->event, time)) {
! 		case WAIT_FAILED:
! 		    rc = -1;
! 		    break;
! 		case WAIT_TIMEOUT:
! 		    rc = ETIME;
! 		    /*
! 		     * This is a royal pain.  We've timed out waiting
! 		     * for the signal, but between the time out and here
! 		     * it is possible that we were actually signalled by 
! 		     * another thread.  So we grab the condition lock
! 		     * and scan the waiting thread queue to see if we are
! 		     * still there.  If we are, we just remove ourselves.
! 		     *
! 		     * If we are no longer listed in the waiter queue,
! 		     * it means that we were signalled after the time
! 		     * out occurred and so we have to do another wait
! 		     * WHICH HAS TO SUCCEED!  In this case, we reset
! 		     * rc to indicate that we were signalled.
! 		     *
! 		     * We have to wait or otherwise, the event
! 		     * would be cached in the signalled state, which
! 		     * is wrong.  It might be more efficient to just
! 		     * close and reopen the event.
! 		     */
! 		    EnterCriticalSection(&cond->cs);
! 		    for(queue_Scan(&cond->waiting_threads, cur,
! 				   next, cond_waiter)) {
! 			if (cur == my_entry) {
! 			    hasnt_been_signalled = 1;
! 			    break;
! 			}
! 		    }
! 		    if (hasnt_been_signalled) {
! 			queue_Remove(cur);
! 		    } else {
! 			rc = 0;
! 			if (ResetEvent(my_entry->event)) {
! 			    if (pthread_mutex_lock(mutex)) {
! 				rc = -5;
! 			    }
! 			} else {
! 			    rc = -6;
! 			}
! 		    }
! 		    LeaveCriticalSection(&cond->cs);
! 		    break;
! 		case WAIT_ABANDONED:
! 		    rc = -2;
! 		    break;
! 		case WAIT_OBJECT_0:
! 		    if (pthread_mutex_lock(mutex)) {
! 			rc = -3;
! 		    }
! 		    break;
! 		default:
! 		    rc = -4;
! 		    break;
! 	    }
  	} else {
  	    rc = EINVAL;
  	}
--- 821,883 ----
  	queue_Append(&cond->waiting_threads, my_entry);
  	LeaveCriticalSection(&cond->cs);
  
! 	if (pthread_mutex_unlock(mutex) == 0) {
  	    switch(WaitForSingleObject(my_entry->event, time)) {
!             case WAIT_FAILED:
!                 rc = -1;
!                 break;
!             case WAIT_TIMEOUT:
!                 rc = ETIMEDOUT;
!                 /*
!                  * This is a royal pain.  We've timed out waiting
!                  * for the signal, but between the time out and here
!                  * it is possible that we were actually signalled by 
!                  * another thread.  So we grab the condition lock
!                  * and scan the waiting thread queue to see if we are
!                  * still there.  If we are, we just remove ourselves.
!                  *
!                  * If we are no longer listed in the waiter queue,
!                  * it means that we were signalled after the time
!                  * out occurred and so we have to do another wait
!                  * WHICH HAS TO SUCCEED!  In this case, we reset
!                  * rc to indicate that we were signalled.
!                  *
!                  * We have to wait or otherwise, the event
!                  * would be cached in the signalled state, which
!                  * is wrong.  It might be more efficient to just
!                  * close and reopen the event.
!                  */
!                 EnterCriticalSection(&cond->cs);
!                 for(queue_Scan(&cond->waiting_threads, cur,
!                                 next, cond_waiter)) {
!                     if (cur == my_entry) {
!                         hasnt_been_signalled = 1;
!                         break;
!                     }
!                 }
!                 if (hasnt_been_signalled) {
!                     queue_Remove(cur);
!                 } else {
!                     rc = 0;
!                     if (!ResetEvent(my_entry->event)) {
!                         rc = -6;
!                     }
!                 }
!                 LeaveCriticalSection(&cond->cs);
!                 break;
!             case WAIT_ABANDONED:
!                 rc = -2;
!                 break;
!             case WAIT_OBJECT_0:
!                 rc = 0;
!                 break;
!             default:
!                 rc = -4;
!                 break;
!             }
!             if (pthread_mutex_lock(mutex) != 0) {
!                 rc = -3;
!             }   
  	} else {
  	    rc = EINVAL;
  	}
Index: openafs/src/afs/afs_buffer.c
diff -c openafs/src/afs/afs_buffer.c:1.22 openafs/src/afs/afs_buffer.c:1.22.4.1
*** openafs/src/afs/afs_buffer.c:1.22	Tue Jan 24 12:40:11 2006
--- openafs/src/afs/afs_buffer.c	Thu Dec 13 14:18:29 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_buffer.c,v 1.22 2006/01/24 17:40:11 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_buffer.c,v 1.22.4.1 2007/12/13 19:18:29 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 534,540 ****
      register struct buffer *tp;
  #endif
      int i;
-     extern int afs_cold_shutdown;
  
      AFS_STATCNT(shutdown_bufferpackage);
      /* Free all allocated Buffers and associated buffer pages */
--- 534,539 ----
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.86.4.18 openafs/src/afs/afs_call.c:1.86.4.19
*** openafs/src/afs/afs_call.c:1.86.4.18	Tue Nov  6 23:33:59 2007
--- openafs/src/afs/afs_call.c	Mon Dec 10 17:42:30 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.86.4.18 2007/11/07 04:33:59 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.86.4.19 2007/12/10 22:42:30 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 1259,1269 ****
      shutdown_daemons();
  #endif
  
-     /* Close file only after daemons which can write to it are stopped. */
-     if (afs_cacheInodep) {	/* memcache won't set this */
- 	osi_UFSClose(afs_cacheInodep);	/* Since we always leave it open */
- 	afs_cacheInodep = 0;
-     }
  #ifdef notdef
      shutdown_CB();
      shutdown_AFS();
--- 1259,1264 ----
***************
*** 1272,1278 ****
      shutdown_rx();
      afs_shutdown_BKG();
  #endif
-     return;
      shutdown_bufferpackage();
      shutdown_cache();
      shutdown_osi();
--- 1267,1272 ----
***************
*** 1292,1297 ****
--- 1286,1298 ----
      memset(&afs_stats_cmfullperf, 0, sizeof(struct afs_stats_CMFullPerf));
  */
      afs_warn(" ALL allocated tables\n");
+ 
+     /* Close file only after daemons which can write to it are stopped. */
+     if (afs_cacheInodep) {	/* memcache won't set this */
+ 	osi_UFSClose(afs_cacheInodep);	/* Since we always leave it open */
+ 	afs_cacheInodep = 0;
+     }
+ 
      afs_shuttingdown = 0;
  
      return;			/* Just kill daemons for now */
Index: openafs/src/afs/afs_osi_alloc.c
diff -c openafs/src/afs/afs_osi_alloc.c:1.11.6.4 openafs/src/afs/afs_osi_alloc.c:1.11.6.5
*** openafs/src/afs/afs_osi_alloc.c:1.11.6.4	Fri Nov 30 14:17:01 2007
--- openafs/src/afs/afs_osi_alloc.c	Thu Dec 13 14:18:29 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_alloc.c,v 1.11.6.4 2007/11/30 19:17:01 shadow Exp $");
  
  
  
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_alloc.c,v 1.11.6.5 2007/12/13 19:18:29 shadow Exp $");
  
  
  
***************
*** 227,255 ****
  void
  shutdown_osinet(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osinet);
      if (afs_cold_shutdown) {
  	struct osi_packet *tp;
  
  	while ((tp = freePacketList)) {
  	    freePacketList = tp->next;
- 	    afs_osi_Free(tp, AFS_LRALLOCSIZ);
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_LRALLOCSIZ);
  #endif
  	}
  
  	while ((tp = freeSmallList)) {
  	    freeSmallList = tp->next;
- 	    afs_osi_Free(tp, AFS_SMALLOCSIZ);
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_SMALLOCSIZ);
  #endif
  	}
  	LOCK_INIT(&osi_fsplock, "osi_fsplock");
  	LOCK_INIT(&osi_flplock, "osi_flplock");
      }
  }
  #endif
--- 227,260 ----
  void
  shutdown_osinet(void)
  {
      AFS_STATCNT(shutdown_osinet);
      if (afs_cold_shutdown) {
  	struct osi_packet *tp;
  
  	while ((tp = freePacketList)) {
  	    freePacketList = tp->next;
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_LRALLOCSIZ);
  #endif
+ 	    afs_osi_Free(tp, AFS_LRALLOCSIZ);
  	}
  
  	while ((tp = freeSmallList)) {
  	    freeSmallList = tp->next;
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_SMALLOCSIZ);
  #endif
+ 	    afs_osi_Free(tp, AFS_SMALLOCSIZ);
  	}
  	LOCK_INIT(&osi_fsplock, "osi_fsplock");
  	LOCK_INIT(&osi_flplock, "osi_flplock");
      }
+     if (afs_stats_cmperf.LargeBlocksActive || 
+ 	afs_stats_cmperf.SmallBlocksActive) 
+     {
+ 	afs_warn("WARNING: not all blocks freed: large %d small %d\n", 
+ 		 afs_stats_cmperf.LargeBlocksActive, 
+ 		 afs_stats_cmperf.SmallBlocksActive);
+     }
  }
  #endif
Index: openafs/src/afs/afs_server.c
diff -c openafs/src/afs/afs_server.c:1.43.4.4 openafs/src/afs/afs_server.c:1.43.4.5
*** openafs/src/afs/afs_server.c:1.43.4.4	Mon Nov 26 16:08:38 2007
--- openafs/src/afs/afs_server.c	Tue Dec 11 16:30:04 2007
***************
*** 33,39 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.43.4.4 2007/11/26 21:08:38 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 33,39 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.43.4.5 2007/12/11 21:30:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 1129,1135 ****
  	    sa->sa_iprank = afs_min(sa->sa_iprank, MED);
  	}
      }
!     return 0;
  }
  #else /* AFS_USERSPACE_IP_ADDR */
  #if (! defined(AFS_SUN5_ENV)) && !defined(AFS_DARWIN60_ENV) && defined(USEIFADDR)
--- 1129,1135 ----
  	    sa->sa_iprank = afs_min(sa->sa_iprank, MED);
  	}
      }
!     return;
  }
  #else /* AFS_USERSPACE_IP_ADDR */
  #if (! defined(AFS_SUN5_ENV)) && !defined(AFS_DARWIN60_ENV) && defined(USEIFADDR)
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.114.2.5 openafs/src/afs/afs_vcache.c:1.114.2.7
*** openafs/src/afs/afs_vcache.c:1.114.2.5	Thu Nov  9 23:36:34 2006
--- openafs/src/afs/afs_vcache.c	Thu Dec 13 14:47:46 2007
***************
*** 39,45 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.114.2.5 2006/11/10 04:36:34 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 39,45 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.114.2.7 2007/12/13 19:47:46 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
Index: openafs/src/afs/AIX/osi_file.c
diff -c openafs/src/afs/AIX/osi_file.c:1.9.14.2 openafs/src/afs/AIX/osi_file.c:1.9.14.3
*** openafs/src/afs/AIX/osi_file.c:1.9.14.2	Wed Aug 15 23:52:33 2007
--- openafs/src/afs/AIX/osi_file.c	Thu Dec 13 14:18:31 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_file.c,v 1.9.14.2 2007/08/16 03:52:33 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_file.c,v 1.9.14.3 2007/12/13 19:18:31 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 272,279 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 272,277 ----
Index: openafs/src/afs/AIX/osi_vfsops.c
diff -c openafs/src/afs/AIX/osi_vfsops.c:1.12 openafs/src/afs/AIX/osi_vfsops.c:1.12.8.1
*** openafs/src/afs/AIX/osi_vfsops.c:1.12	Thu Aug 19 01:42:24 2004
--- openafs/src/afs/AIX/osi_vfsops.c	Thu Dec 13 14:18:31 2007
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_vfsops.c,v 1.12 2004/08/19 05:42:24 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/AIX/osi_vfsops.c,v 1.12.8.1 2007/12/13 19:18:31 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 34,41 ****
  struct vfs *afs_globalVFS = 0;
  struct vcache *afs_globalVp = 0;
  
- extern int afs_cold_shutdown;
- 
  static int afs_root_nolock(struct vfs *afsp, struct vnode **avpp);
  
  static int
--- 34,39 ----
Index: openafs/src/afs/DARWIN/osi_file.c
diff -c openafs/src/afs/DARWIN/osi_file.c:1.12.2.3 openafs/src/afs/DARWIN/osi_file.c:1.12.2.4
*** openafs/src/afs/DARWIN/osi_file.c:1.12.2.3	Wed Oct 10 13:01:43 2007
--- openafs/src/afs/DARWIN/osi_file.c	Thu Dec 13 14:18:32 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_file.c,v 1.12.2.3 2007/10/10 17:01:43 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_file.c,v 1.12.2.4 2007/12/13 19:18:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 418,425 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 418,423 ----
Index: openafs/src/afs/DUX/osi_file.c
diff -c openafs/src/afs/DUX/osi_file.c:1.9 openafs/src/afs/DUX/osi_file.c:1.9.14.1
*** openafs/src/afs/DUX/osi_file.c:1.9	Tue Jul 15 19:14:18 2003
--- openafs/src/afs/DUX/osi_file.c	Thu Dec 13 14:18:32 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DUX/Attic/osi_file.c,v 1.9 2003/07/15 23:14:18 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DUX/Attic/osi_file.c,v 1.9.14.1 2007/12/13 19:18:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 279,286 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 279,284 ----
Index: openafs/src/afs/FBSD/osi_file.c
diff -c openafs/src/afs/FBSD/osi_file.c:1.13.14.1 openafs/src/afs/FBSD/osi_file.c:1.13.14.2
*** openafs/src/afs/FBSD/osi_file.c:1.13.14.1	Thu Nov  9 18:30:53 2006
--- openafs/src/afs/FBSD/osi_file.c	Thu Dec 13 14:18:32 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_file.c,v 1.13.14.1 2006/11/09 23:30:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_file.c,v 1.13.14.2 2007/12/13 19:18:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 244,251 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 244,249 ----
Index: openafs/src/afs/HPUX/osi_file.c
diff -c openafs/src/afs/HPUX/osi_file.c:1.8.14.1 openafs/src/afs/HPUX/osi_file.c:1.8.14.2
*** openafs/src/afs/HPUX/osi_file.c:1.8.14.1	Thu Nov  9 18:30:53 2006
--- openafs/src/afs/HPUX/osi_file.c	Thu Dec 13 14:18:32 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/HPUX/osi_file.c,v 1.8.14.1 2006/11/09 23:30:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/HPUX/osi_file.c,v 1.8.14.2 2007/12/13 19:18:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 223,230 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 223,228 ----
Index: openafs/src/afs/IRIX/osi_file.c
diff -c openafs/src/afs/IRIX/osi_file.c:1.11.14.1 openafs/src/afs/IRIX/osi_file.c:1.11.14.2
*** openafs/src/afs/IRIX/osi_file.c:1.11.14.1	Thu Nov  9 18:30:53 2006
--- openafs/src/afs/IRIX/osi_file.c	Thu Dec 13 14:18:32 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/IRIX/osi_file.c,v 1.11.14.1 2006/11/09 23:30:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/IRIX/osi_file.c,v 1.11.14.2 2007/12/13 19:18:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 262,269 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 262,267 ----
Index: openafs/src/afs/IRIX/osi_vfsops.c
diff -c openafs/src/afs/IRIX/osi_vfsops.c:1.14 openafs/src/afs/IRIX/osi_vfsops.c:1.14.8.1
*** openafs/src/afs/IRIX/osi_vfsops.c:1.14	Wed Aug 18 22:19:16 2004
--- openafs/src/afs/IRIX/osi_vfsops.c	Thu Dec 13 14:18:32 2007
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/IRIX/osi_vfsops.c,v 1.14 2004/08/19 02:19:16 kolya Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/IRIX/osi_vfsops.c,v 1.14.8.1 2007/12/13 19:18:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 207,213 ****
       int flags;
       cred_t *cr;
  {
-     extern int afs_afs_cold_shutdown;
      struct vcache *tvc;
      vnode_t *vp, *rootvp = NULL;
      register struct afs_q *tq;
--- 207,212 ----
Index: openafs/src/afs/LINUX/osi_file.c
diff -c openafs/src/afs/LINUX/osi_file.c:1.28.2.5 openafs/src/afs/LINUX/osi_file.c:1.28.2.6
*** openafs/src/afs/LINUX/osi_file.c:1.28.2.5	Thu Nov  9 18:30:53 2006
--- openafs/src/afs/LINUX/osi_file.c	Thu Dec 13 14:18:33 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.28.2.5 2006/11/09 23:30:53 shadow Exp $");
  
  #ifdef AFS_LINUX24_ENV
  #include "h/module.h" /* early to avoid printf->printk mapping */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.28.2.6 2007/12/13 19:18:33 shadow Exp $");
  
  #ifdef AFS_LINUX24_ENV
  #include "h/module.h" /* early to avoid printf->printk mapping */
***************
*** 349,356 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 349,354 ----
Index: openafs/src/afs/NBSD/osi_file.c
diff -c openafs/src/afs/NBSD/osi_file.c:1.5.14.1 openafs/src/afs/NBSD/osi_file.c:1.5.14.2
*** openafs/src/afs/NBSD/osi_file.c:1.5.14.1	Thu Nov  9 18:30:54 2006
--- openafs/src/afs/NBSD/osi_file.c	Thu Dec 13 14:18:33 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/NBSD/osi_file.c,v 1.5.14.1 2006/11/09 23:30:54 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/NBSD/osi_file.c,v 1.5.14.2 2007/12/13 19:18:33 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 224,231 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 224,229 ----
Index: openafs/src/afs/SOLARIS/osi_file.c
diff -c openafs/src/afs/SOLARIS/osi_file.c:1.13.14.1 openafs/src/afs/SOLARIS/osi_file.c:1.13.14.2
*** openafs/src/afs/SOLARIS/osi_file.c:1.13.14.1	Thu Nov  9 18:30:54 2006
--- openafs/src/afs/SOLARIS/osi_file.c	Thu Dec 13 14:18:33 2007
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_file.c,v 1.13.14.1 2006/11/09 23:30:54 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_file.c,v 1.13.14.2 2007/12/13 19:18:33 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 398,405 ****
  void
  shutdown_osifile(void)
  {
-     extern int afs_cold_shutdown;
- 
      AFS_STATCNT(shutdown_osifile);
      if (afs_cold_shutdown) {
  	afs_osicred_initialized = 0;
--- 398,403 ----
Index: openafs/src/afs/VNOPS/afs_vnop_remove.c
diff -c openafs/src/afs/VNOPS/afs_vnop_remove.c:1.52.2.3 openafs/src/afs/VNOPS/afs_vnop_remove.c:1.52.2.4
*** openafs/src/afs/VNOPS/afs_vnop_remove.c:1.52.2.3	Mon Jul 31 17:27:40 2006
--- openafs/src/afs/VNOPS/afs_vnop_remove.c	Wed Dec 19 15:57:55 2007
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.52.2.3 2006/07/31 21:27:40 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 21,27 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.52.2.4 2007/12/19 20:57:55 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 418,424 ****
--- 418,428 ----
  	code = afsremove(adp, tdc, tvc, aname, acred, &treq);
      }
      afs_PutFakeStat(&fakestate);
+ #ifndef AFS_DARWIN80_ENV
+     /* we can't track by thread, it's not exported in the KPI; only do
+        this on !macos */
      osi_Assert(!WriteLocked(&adp->lock) || (adp->lock.pid_writer != MyPidxx));
+ #endif
      return code;
  }
  
Index: openafs/src/auth/ktc.c
diff -c openafs/src/auth/ktc.c:1.16.8.8 openafs/src/auth/ktc.c:1.16.8.9
*** openafs/src/auth/ktc.c:1.16.8.8	Thu Nov  8 09:23:29 2007
--- openafs/src/auth/ktc.c	Thu Dec 13 13:53:52 2007
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/ktc.c,v 1.16.8.8 2007/11/08 14:23:29 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/auth/ktc.c,v 1.16.8.9 2007/12/13 18:53:52 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
***************
*** 54,59 ****
--- 54,63 ----
  #include <afs/vice.h>
  #ifdef	AFS_AIX_ENV
  #include <sys/lockf.h>
+ #ifdef AFS_AIX51_ENV
+ #include <sys/cred.h>
+ #include <sys/pag.h>
+ #endif
  #endif
  #ifdef HAVE_UNISTD_H
  #include <unistd.h>
***************
*** 1610,1615 ****
--- 1614,1625 ----
  static afs_uint32
  curpag(void)
  {
+ #if defined(AFS_AIX51_ENV)
+     int code = getpagvalue("afs");
+     if (code < 0 && errno == EINVAL)
+ 	code = 0;
+     return code;
+ #else
      gid_t groups[NGROUPS_MAX];
      afs_uint32 g0, g1;
      afs_uint32 h, l, ret;
***************
*** 1633,1638 ****
--- 1643,1649 ----
  	    return -1;
      }
      return -1;
+ #endif
  }
  
  int
Index: openafs/src/butc/dbentries.c
diff -c openafs/src/butc/dbentries.c:1.8.14.3 openafs/src/butc/dbentries.c:1.8.14.4
*** openafs/src/butc/dbentries.c:1.8.14.3	Mon Nov 26 16:08:41 2007
--- openafs/src/butc/dbentries.c	Tue Dec 11 11:27:06 2007
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/dbentries.c,v 1.8.14.3 2007/11/26 21:08:41 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/dbentries.c,v 1.8.14.4 2007/12/11 16:27:06 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 310,316 ****
      if (message) {
  	printf("Updating database - done\n");
      }
!     return 0;
  }
  
  #define MAXVOLUMESTOADD 100
--- 310,316 ----
      if (message) {
  	printf("Updating database - done\n");
      }
!     return;
  }
  
  #define MAXVOLUMESTOADD 100
Index: openafs/src/config/NTMakefile.amd64_w2k
diff -c openafs/src/config/NTMakefile.amd64_w2k:1.24.2.33 openafs/src/config/NTMakefile.amd64_w2k:1.24.2.34
*** openafs/src/config/NTMakefile.amd64_w2k:1.24.2.33	Fri Dec  7 10:57:04 2007
--- openafs/src/config/NTMakefile.amd64_w2k	Fri Dec 28 15:19:10 2007
***************
*** 84,90 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=5
! AFSPRODUCT_VER_PATCH=2800
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 84,90 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=5
! AFSPRODUCT_VER_PATCH=2900
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.84.2.32 openafs/src/config/NTMakefile.i386_nt40:1.84.2.33
*** openafs/src/config/NTMakefile.i386_nt40:1.84.2.32	Fri Dec  7 10:57:04 2007
--- openafs/src/config/NTMakefile.i386_nt40	Fri Dec 28 15:19:10 2007
***************
*** 84,90 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=5
! AFSPRODUCT_VER_PATCH=2800
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 84,90 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=5
! AFSPRODUCT_VER_PATCH=2900
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/config/NTMakefile.i386_w2k
diff -c openafs/src/config/NTMakefile.i386_w2k:1.23.2.33 openafs/src/config/NTMakefile.i386_w2k:1.23.2.34
*** openafs/src/config/NTMakefile.i386_w2k:1.23.2.33	Fri Dec  7 10:57:04 2007
--- openafs/src/config/NTMakefile.i386_w2k	Fri Dec 28 15:19:10 2007
***************
*** 84,90 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=5
! AFSPRODUCT_VER_PATCH=2800
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
--- 84,90 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=5
! AFSPRODUCT_VER_PATCH=2900
  AFSPRODUCT_VER_BUILD=0
  
  AFSPRODUCT_VERSION=$(AFSPRODUCT_VER_MAJOR).$(AFSPRODUCT_VER_MINOR).$(AFSPRODUCT_VER_PATCH)
Index: openafs/src/packaging/RedHat/openafs.spec.in
diff -c openafs/src/packaging/RedHat/openafs.spec.in:1.2.2.12 openafs/src/packaging/RedHat/openafs.spec.in:1.2.2.14
*** openafs/src/packaging/RedHat/openafs.spec.in:1.2.2.12	Mon Nov 26 17:20:27 2007
--- openafs/src/packaging/RedHat/openafs.spec.in	Thu Dec 13 15:06:26 2007
***************
*** 1,4 ****
! # Openafs Spec $Revision: 1.2.2.12 $
  
  %define afsvers @VERSION@
  %define pkgvers @VERSION@
--- 1,4 ----
! # Openafs Spec $Revision: 1.2.2.14 $
  
  %define afsvers @VERSION@
  %define pkgvers @VERSION@
***************
*** 233,241 ****
  %if %{krb5support}
  BuildRequires: krb5-devel
  %endif
- %if %{build_userspace}
- BuildRequires: autoconf
- %endif
  ExclusiveArch: %{ix86} x86_64 ia64
  
  #    http://dl.openafs.org/dl/openafs/candidate/%{afsvers}/...
--- 233,238 ----
***************
*** 462,468 ****
  Summary: OpenAFS programs to use with krb5
  Requires: openafs = %{PACKAGE_VERSION}
  Group: Networking/Filesystems
! BuildRequires: autoconf, automake
  
  %description krb5
  The AFS distributed filesystem.  AFS is a distributed filesystem
--- 459,465 ----
  Summary: OpenAFS programs to use with krb5
  Requires: openafs = %{PACKAGE_VERSION}
  Group: Networking/Filesystems
! BuildRequires: krb5-devel
  
  %description krb5
  The AFS distributed filesystem.  AFS is a distributed filesystem
***************
*** 810,819 ****
         --sbindir=%{_sbindir} \
         --disable-strip-binaries \
  %if %{build_modules}
!        --with-linux-kernel-headers=%{ksrc} \
  %endif
  %if %{krb5support}
! 	--with-krb5-conf \
  %endif
         $config_opts \
         || exit 1
--- 807,816 ----
         --sbindir=%{_sbindir} \
         --disable-strip-binaries \
  %if %{build_modules}
!        --with-linux-kernel-headers=${ksrc} \
  %endif
  %if %{krb5support}
! 	--with-krb5-conf=/usr/kerberos/bin/krb5-config \
  %endif
         $config_opts \
         || exit 1
***************
*** 835,841 ****
  	--sbindir=%{_sbindir} \
  	--with-linux-kernel-headers=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} \
  %if %{krb5support}
! 	--with-krb5-conf \
  %endif
  	$config_opts \
  	|| exit 1
--- 832,838 ----
  	--sbindir=%{_sbindir} \
  	--with-linux-kernel-headers=%{_usrsrc}/kernels/%{kverrel}${kvariant:+-$kvariant}-%{_target_cpu} \
  %if %{krb5support}
! 	--with-krb5-conf=/usr/kerberos/bin/krb5-config \
  %endif
  	$config_opts \
  	|| exit 1
***************
*** 1131,1141 ****
    rm -f $RPM_BUILD_ROOT%{_libdir}/$f
  done
  
- # Remove empty files from the krb5 migration
- for f in afs2k5db fakeka ; do
-   rm -f $RPM_BUILD_ROOT%{_sbindir}/$f
- done
- 
  %if !%{build_authlibs}
  rm -f $RPM_BUILD_ROOT%{_libdir}/libafsauthent.so
  rm -f $RPM_BUILD_ROOT%{_libdir}/libafsrpc.so
--- 1128,1133 ----
***************
*** 1157,1163 ****
  
    dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
    mkdir -p ${dstdir}
!   install -m 744 ${srcdir}/libafs-%{kverrel}${kvariant}.ko $dstdir/openafs.ko
  done
  %else
  # Install the kernel modules
--- 1149,1155 ----
  
    dstdir=$RPM_BUILD_ROOT/lib/modules/%{kverrel}${kvariant}/extra/openafs
    mkdir -p ${dstdir}
!   install -m 644 ${srcdir}/libafs-%{kverrel}${kvariant}.ko $dstdir/openafs.ko
  done
  %else
  # Install the kernel modules
***************
*** 1177,1184 ****
  
      mkdir -p ${dstdir}
  
-     # Mark kernel modules as executable; otherwise they won't get stripped 
-     # by /usr/lib/rpm/brp-strip
      install -m 644 ${srcdir}/${modname} ${dstdir}/openafs${kmodend}
  done
  %endif
--- 1169,1174 ----
***************
*** 1532,1537 ****
--- 1522,1530 ----
  ###
  ##############################################################################
  %changelog
+ * Wed Dec 12 2007  Simon Wilkinson <simon@sxw.org.uk> 1.4.5
+ - Make the RPM mockable
+ 
  * Tue Oct 29 2007  Simon Wilkinson <simon@sxw.org.uk> 1.4.5
  - Update to match the shipped 1.4.5 RPMS
  - Fix the kvariant stuff to only configure the 'standard' case once
Index: openafs/src/pam/afs_setcred.c
diff -c openafs/src/pam/afs_setcred.c:1.14 openafs/src/pam/afs_setcred.c:1.14.4.1
*** openafs/src/pam/afs_setcred.c:1.14	Sun May 29 23:35:52 2005
--- openafs/src/pam/afs_setcred.c	Mon Dec 10 13:28:07 2007
***************
*** 20,26 ****
  #include <security/pam_modules.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pam/afs_setcred.c,v 1.14 2005/05/30 03:35:52 shadow Exp $");
  
  #include <sys/param.h>
  #include <afs/kautils.h>
--- 20,26 ----
  #include <security/pam_modules.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pam/afs_setcred.c,v 1.14.4.1 2007/12/10 18:28:07 shadow Exp $");
  
  #include <sys/param.h>
  #include <afs/kautils.h>
***************
*** 62,68 ****
      int auth_ok = 0;
      char *lh;
      char *user = NULL;
!     long password_expires = -1;
      char *reason = NULL;
      struct passwd unix_pwd, *upwd = NULL;
      char upwd_buf[2048];	/* size is a guess. */
--- 62,68 ----
      int auth_ok = 0;
      char *lh;
      char *user = NULL;
!     int password_expires = -1;
      char *reason = NULL;
      struct passwd unix_pwd, *upwd = NULL;
      char upwd_buf[2048];	/* size is a guess. */
Index: openafs/src/pam/afs_util.c
diff -c openafs/src/pam/afs_util.c:1.12.14.3 openafs/src/pam/afs_util.c:1.12.14.4
*** openafs/src/pam/afs_util.c:1.12.14.3	Thu Nov  8 09:14:49 2007
--- openafs/src/pam/afs_util.c	Thu Dec 13 13:53:52 2007
***************
*** 19,27 ****
  #include <limits.h>
  #include <string.h>
  #include <stdlib.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pam/afs_util.c,v 1.12.14.3 2007/11/08 14:14:49 shadow Exp $");
  
  #include "afs_util.h"
  
--- 19,31 ----
  #include <limits.h>
  #include <string.h>
  #include <stdlib.h>
+ #ifdef AFS_AIX51_ENV
+ #include <sys/cred.h>
+ #include <sys/pag.h>
+ #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/pam/afs_util.c,v 1.12.14.4 2007/12/13 18:53:52 shadow Exp $");
  
  #include "afs_util.h"
  
***************
*** 174,179 ****
--- 178,189 ----
  static afs_int32
  curpag(void)
  {
+ #if defined(AFS_AIX51_ENV)
+     int code = getpagvalue("afs");
+     if (code < 0 && errno == EINVAL)
+         code = 0;
+     return code;
+ #else
      gid_t groups[NGROUPS_MAX];
      afs_uint32 g0, g1;
      afs_uint32 h, l, ret;
***************
*** 197,202 ****
--- 207,213 ----
  	    return -1;
      }
      return -1;
+ #endif
  }
  
  /* Returns the AFS pag number, if any, otherwise return -1 */
Index: openafs/src/rx/rx_pthread.c
diff -c openafs/src/rx/rx_pthread.c:1.24.4.2 openafs/src/rx/rx_pthread.c:1.24.4.3
*** openafs/src/rx/rx_pthread.c:1.24.4.2	Tue Oct 30 11:16:45 2007
--- openafs/src/rx/rx_pthread.c	Tue Dec 25 17:59:46 2007
***************
*** 19,25 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_pthread.c,v 1.24.4.2 2007/10/30 15:16:45 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
--- 19,25 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_pthread.c,v 1.24.4.3 2007/12/25 22:59:46 jaltman Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
***************
*** 146,152 ****
--- 146,154 ----
      unsigned long rx_pthread_n_event_expired = 0;
      unsigned long rx_pthread_n_event_waits = 0;
      long rx_pthread_n_event_woken = 0;
+     unsigned long rx_pthread_n_event_error = 0;
      struct timespec rx_pthread_next_event_time = { 0, 0 };
+     int error;
  
      assert(pthread_mutex_lock(&event_handler_mutex) == 0);
  
***************
*** 171,186 ****
  	rx_pthread_next_event_time.tv_sec = cv.sec;
  	rx_pthread_next_event_time.tv_nsec = cv.usec * 1000;
  	rx_pthread_n_event_waits++;
! 	if (pthread_cond_timedwait
  	    (&rx_event_handler_cond, &event_handler_mutex,
! 	     &rx_pthread_next_event_time) == -1) {
! #ifdef notdef
! 	    assert(errno == EAGAIN);
! #endif
  	    rx_pthread_n_event_expired++;
  	} else {
! 	    rx_pthread_n_event_woken++;
! 	}
  	rx_pthread_event_rescheduled = 0;
      }
  }
--- 173,197 ----
  	rx_pthread_next_event_time.tv_sec = cv.sec;
  	rx_pthread_next_event_time.tv_nsec = cv.usec * 1000;
  	rx_pthread_n_event_waits++;
! 	error = pthread_cond_timedwait
  	    (&rx_event_handler_cond, &event_handler_mutex,
! 	     &rx_pthread_next_event_time);
!         if (error == 0) {
! 	    rx_pthread_n_event_woken++;
!         } 
! #ifdef AFS_NT40_ENV        
!         else if (error == ETIMEDOUT) {
  	    rx_pthread_n_event_expired++;
  	} else {
!             rx_pthread_n_event_error++;
!         }
! #else
!         else if (errno == ETIMEDOUT) {
!             rx_pthread_n_event_expired++;
!         } else {
!             rx_pthread_n_event_error++;
!         }
! #endif
  	rx_pthread_event_rescheduled = 0;
      }
  }
Index: openafs/src/shlibafsrpc/mapfile
diff -c openafs/src/shlibafsrpc/mapfile:1.5.4.2 openafs/src/shlibafsrpc/mapfile:1.5.4.4
*** openafs/src/shlibafsrpc/mapfile:1.5.4.2	Tue Apr 10 14:39:55 2007
--- openafs/src/shlibafsrpc/mapfile	Mon Dec 17 16:12:57 2007
***************
*** 79,85 ****
  	multi_Select;
  	multi_Init;
  	multi_Finalize_Ignore;
! 	add_to_error_table;
  	xdr_afsUUID;
  	xdr_afs_int32;
  	xdr_afs_uint32;
--- 79,85 ----
  	multi_Select;
  	multi_Init;
  	multi_Finalize_Ignore;
! 	afs_add_to_error_table;
  	xdr_afsUUID;
  	xdr_afs_int32;
  	xdr_afs_uint32;
***************
*** 115,120 ****
--- 115,125 ----
  	RXSTATS_ClearProcessRPCStats;
  	RXSTATS_ClearPeerRPCStats;
  	TM_GetTimeOfDay;
+ 	strcompose;
+ 	stolower;
+ 	ucstring;
+ 	lcstring;
+ 	AssertionFailed;
  
      local:
  	*;
Index: openafs/src/sys/pagsh.c
diff -c openafs/src/sys/pagsh.c:1.9.14.4 openafs/src/sys/pagsh.c:1.9.14.6
*** openafs/src/sys/pagsh.c:1.9.14.4	Mon Nov 26 16:08:44 2007
--- openafs/src/sys/pagsh.c	Thu Dec 13 16:22:39 2007
***************
*** 11,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pagsh.c,v 1.9.14.4 2007/11/26 21:08:44 shadow Exp $");
  
  #ifdef	AFS_AIX32_ENV
  #include <signal.h>
  #endif
  #include <stdio.h>
  #include <stdlib.h>
--- 11,25 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pagsh.c,v 1.9.14.6 2007/12/13 21:22:39 shadow Exp $");
  
  #ifdef	AFS_AIX32_ENV
  #include <signal.h>
+ #ifdef AFS_AIX51_ENV
+ #include <sys/cred.h>
+ #include <sys/pag.h>
+ #include <errno.h>
+ #endif
  #endif
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 85,95 ****
  curpag(void)
  {
  #if defined(AFS_AIX51_ENV)
!     afs_int32 pag;
! 
!     if (kcred_getpag(cred, PAG_AFS, &pag) < 0 || pag == 0)
!         pag = NOPAG;
!     return pag;
  #else
      afs_uint32 groups[NGROUPS_MAX];
      afs_uint32 g0, g1;
--- 90,99 ----
  curpag(void)
  {
  #if defined(AFS_AIX51_ENV)
!     int code = getpagvalue("afs");
!     if (code < 0 && errno == EINVAL)
! 	code = 0;
!     return code;
  #else
      afs_uint32 groups[NGROUPS_MAX];
      afs_uint32 g0, g1;
Index: openafs/src/tsm41/aix_aklog.c
diff -c openafs/src/tsm41/aix_aklog.c:1.1.2.3 openafs/src/tsm41/aix_aklog.c:1.1.2.5
*** openafs/src/tsm41/aix_aklog.c:1.1.2.3	Sun Dec  9 01:07:32 2007
--- openafs/src/tsm41/aix_aklog.c	Thu Dec 13 18:06:08 2007
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/tsm41/aix_aklog.c,v 1.1.2.3 2007/12/09 06:07:32 shadow Exp $");
  
  #if defined(AFS_AIX51_ENV)
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/tsm41/aix_aklog.c,v 1.1.2.5 2007/12/13 23:06:08 shadow Exp $");
  
  #if defined(AFS_AIX51_ENV)
  #include <sys/types.h>
***************
*** 32,37 ****
--- 32,38 ----
  #include <afs/dirpath.h>
  #include <rx/rxkad.h>
  #include <afs/auth.h>
+ #include <afs/ptserver.h>
  #include "aix_auth_prototypes.h"
  
  struct afsconf_cell ak_cellconfig; /* General information about the cell */
***************
*** 525,530 ****
--- 526,535 ----
       * not work if you change %d to something else.
       */
      
+     /* Don't do first-time registration. Handle only the simple case */
+     if ((status == 0) && (viceId != ANONYMOUSID))
+ 	sprintf (username, "AFS ID %d", (int) viceId);
+ 
      /* Reset the "aclient" structure before we call ktc_SetToken.
       * This structure was first set by the ktc_GetToken call when
       * we were comparing whether identical tokens already existed.
Index: openafs/src/ubik/phys.c
diff -c openafs/src/ubik/phys.c:1.9.2.1 openafs/src/ubik/phys.c:1.9.2.2
*** openafs/src/ubik/phys.c:1.9.2.1	Tue Oct 30 11:16:47 2007
--- openafs/src/ubik/phys.c	Mon Dec 10 17:45:55 2007
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/phys.c,v 1.9.2.1 2007/10/30 15:16:47 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/phys.c,v 1.9.2.2 2007/12/10 22:45:55 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 78,92 ****
      }
  
      /* not found, open it and try to enter in cache */
!     strcpy(pbuffer, adbase->pathName);
!     strcat(pbuffer, ".DB");
!     if (afid < 0) {
! 	i = -afid;
! 	strcat(pbuffer, "SYS");
!     } else
! 	i = afid;
!     sprintf(temp, "%d", i);
!     strcat(pbuffer, temp);
      fd = open(pbuffer, O_CREAT | O_RDWR, 0600);
      if (fd < 0) {
  	/* try opening read-only */
--- 78,85 ----
      }
  
      /* not found, open it and try to enter in cache */
!     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d", adbase->pathName, 
! 		 (afid<0)?"SYS":"", (afid<0)?-afid:afid);
      fd = open(pbuffer, O_CREAT | O_RDWR, 0600);
      if (fd < 0) {
  	/* try opening read-only */
Index: openafs/src/ubik/recovery.c
diff -c openafs/src/ubik/recovery.c:1.14.4.1 openafs/src/ubik/recovery.c:1.14.4.2
*** openafs/src/ubik/recovery.c:1.14.4.1	Tue Oct 30 11:16:47 2007
--- openafs/src/ubik/recovery.c	Mon Dec 10 17:45:55 2007
***************
*** 11,22 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/recovery.c,v 1.14.4.1 2007/10/30 15:16:47 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
  #include <time.h>
  #else
  #include <sys/file.h>
  #include <netinet/in.h>
--- 11,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/recovery.c,v 1.14.4.2 2007/12/10 22:45:55 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
  #include <time.h>
+ #include <fcntl.h>
  #else
  #include <sys/file.h>
  #include <netinet/in.h>
***************
*** 425,433 ****
      struct timeval tv;
      int length, tlen, offset, file, nbytes;
      struct rx_call *rxcall;
!     char tbuffer[256];
      struct ubik_stat ubikstat;
      struct in_addr inAddr;
  
      /* otherwise, begin interaction */
      urecovery_state = 0;
--- 426,438 ----
      struct timeval tv;
      int length, tlen, offset, file, nbytes;
      struct rx_call *rxcall;
!     char tbuffer[1024];
      struct ubik_stat ubikstat;
      struct in_addr inAddr;
+ #ifndef OLD_URECOVERY
+     char pbuffer[1028];
+     int flen, fd = -1;
+ #endif
  
      /* otherwise, begin interaction */
      urecovery_state = 0;
***************
*** 530,540 ****
  	    urecovery_state |= UBIK_RECHAVEDB;
  	} else {
  	    /* we don't have the best version; we should fetch it. */
- #if defined(UBIK_PAUSE)
  	    DBHOLD(ubik_dbase);
- #else
- 	    ObtainWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  	    urecovery_AbortAll(ubik_dbase);
  
  	    /* Rx code to do the Bulk fetch */
--- 535,541 ----
***************
*** 558,564 ****
  		goto FetchEndCall;
  	    }
  
! 	    /* Truncate the file firest */
  	    code = (*ubik_dbase->truncate) (ubik_dbase, file, 0);
  	    if (code) {
  		ubik_dprint("truncate io error=%d\n", code);
--- 559,566 ----
  		goto FetchEndCall;
  	    }
  
! #ifdef OLD_URECOVERY
! 	    /* Truncate the file first */
  	    code = (*ubik_dbase->truncate) (ubik_dbase, file, 0);
  	    if (code) {
  		ubik_dprint("truncate io error=%d\n", code);
***************
*** 573,578 ****
--- 575,594 ----
  		ubik_dprint("setlabel io error=%d\n", code);
  		goto FetchEndCall;
  	    }
+ #else
+ 	    flen = length;
+ 	    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+ 	    fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
+ 	    if (fd < 0) {
+ 		code = errno;
+ 		goto FetchEndCall;
+ 	    }
+ 	    code = lseek(fd, HDRSIZE, 0);
+ 	    if (code != HDRSIZE) {
+ 		close(fd);
+ 		goto FetchEndCall;
+ 	    }
+ #endif
  
  	    while (length > 0) {
  		tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
***************
*** 580,597 ****
--- 596,624 ----
  		if (nbytes != tlen) {
  		    ubik_dprint("Rx-read bulk error=%d\n", code = BULK_ERROR);
  		    code = EIO;
+ 		    close(fd);
  		    goto FetchEndCall;
  		}
+ #ifdef OLD_URECOVERY
  		nbytes =
  		    (*ubik_dbase->write) (ubik_dbase, file, tbuffer, offset,
  					  tlen);
+ #else
+ 		nbytes = write(fd, tbuffer, tlen);
+ #endif
  		if (nbytes != tlen) {
  		    code = UIOERROR;
+ 		    close(fd);
  		    goto FetchEndCall;
  		}
  		offset += tlen;
  		length -= tlen;
  	    }
+ #ifndef OLD_URECOVERY
+ 	    code = close(fd);
+ 	    if (code)
+ 		goto FetchEndCall;
+ #endif	    
  	    code = EndDISK_GetFile(rxcall, &tversion);
  	  FetchEndCall:
  	    tcode = rx_EndCall(rxcall, code);
***************
*** 602,614 ****
--- 629,664 ----
  		urecovery_state |= UBIK_RECHAVEDB;
  		memcpy(&ubik_dbase->version, &tversion,
  		       sizeof(struct ubik_version));
+ #ifdef OLD_URECOVERY
  		(*ubik_dbase->sync) (ubik_dbase, 0);	/* get data out first */
+ #else
+ 		afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB0", ubik_dbase->pathName);
+ #ifdef AFS_NT40_ENV
+ 		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+ 		code = unlink(pbuffer);
+ 		if (!code)
+ 		    code = rename(tbuffer, pbuffer);
+ 		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+ #endif
+ 		if (!code) 
+ 		    code = rename(pbuffer, tbuffer);
+ 		if (!code)
+ #endif
  		/* after data is good, sync disk with correct label */
  		code =
  		    (*ubik_dbase->setlabel) (ubik_dbase, 0,
  					     &ubik_dbase->version);
+ #ifndef OLD_URECOVERY
+ #ifdef AFS_NT40_ENV
+ 		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+ 		unlink(pbuffer);
+ #endif
+ #endif
  	    }
  	    if (code) {
+ #ifndef OLD_URECOVERY
+ 		unlink(pbuffer);
+ #endif
  		ubik_dbase->version.epoch = 0;
  		ubik_dbase->version.counter = 0;
  		ubik_print("Ubik: Synchronize database failed (error = %d)\n",
***************
*** 618,628 ****
  	    }
  	    udisk_Invalidate(ubik_dbase, 0);	/* data has changed */
  	    LWP_NoYieldSignal(&ubik_dbase->version);
- #if defined(UBIK_PAUSE)
  	    DBRELE(ubik_dbase);
- #else
- 	    ReleaseWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  	}
  #if defined(UBIK_PAUSE)
  	if (!(urecovery_state & UBIK_RECSYNCSITE))
--- 668,674 ----
***************
*** 637,647 ****
  	 * database and overwrite this one.
  	 */
  	if (ubik_dbase->version.epoch == 1) {
- #if defined(UBIK_PAUSE)
  	    DBHOLD(ubik_dbase);
- #else
- 	    ObtainWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  	    urecovery_AbortAll(ubik_dbase);
  	    ubik_epochTime = 2;
  	    ubik_dbase->version.epoch = ubik_epochTime;
--- 683,689 ----
***************
*** 650,660 ****
  		(*ubik_dbase->setlabel) (ubik_dbase, 0, &ubik_dbase->version);
  	    udisk_Invalidate(ubik_dbase, 0);	/* data may have changed */
  	    LWP_NoYieldSignal(&ubik_dbase->version);
- #if defined(UBIK_PAUSE)
  	    DBRELE(ubik_dbase);
- #else
- 	    ReleaseWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  	}
  
  	/* Check the other sites and send the database to them if they
--- 692,698 ----
***************
*** 664,674 ****
  	    /* now propagate out new version to everyone else */
  	    dbok = 1;		/* start off assuming they all worked */
  
- #if defined(UBIK_PAUSE)
  	    DBHOLD(ubik_dbase);
- #else
- 	    ObtainWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  	    /*
  	     * Check if a write transaction is in progress. We can't send the
  	     * db when a write is in progress here because the db would be
--- 702,708 ----
***************
*** 684,703 ****
  		tv.tv_sec = 0;
  		tv.tv_usec = 50000;
  		while ((ubik_dbase->flags & DBWRITING) && (safety < 500)) {
- #if defined(UBIK_PAUSE)
  		    DBRELE(ubik_dbase);
- #else
- 		    ReleaseWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  		    /* sleep for a little while */
  		    IOMGR_Select(0, 0, 0, 0, &tv);
  		    tv.tv_usec += 10000;
  		    safety++;
- #if defined(UBIK_PAUSE)
  		    DBHOLD(ubik_dbase);
- #else
- 		    ObtainWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  		}
  	    }
  
--- 718,729 ----
***************
*** 764,774 ****
  		    ts->currentDB = 1;
  		}
  	    }
- #if defined(UBIK_PAUSE)
  	    DBRELE(ubik_dbase);
- #else
- 	    ReleaseWriteLock(&ubik_dbase->versionLock);
- #endif /* UBIK_PAUSE */
  	    if (dbok)
  		urecovery_state |= UBIK_RECSENTDB;
  	}
--- 790,796 ----
Index: openafs/src/ubik/remote.c
diff -c openafs/src/ubik/remote.c:1.15.4.2 openafs/src/ubik/remote.c:1.15.4.3
*** openafs/src/ubik/remote.c:1.15.4.2	Tue Oct 30 11:16:47 2007
--- openafs/src/ubik/remote.c	Mon Dec 10 17:45:55 2007
***************
*** 11,21 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/remote.c,v 1.15.4.2 2007/10/30 15:16:47 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
  #else
  #include <sys/file.h>
  #include <netinet/in.h>
--- 11,22 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/remote.c,v 1.15.4.3 2007/12/10 22:45:55 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
+ #include <fcntl.h>
  #else
  #include <sys/file.h>
  #include <netinet/in.h>
***************
*** 24,29 ****
--- 25,31 ----
  #include <lock.h>
  #include <rx/xdr.h>
  #include <rx/rx.h>
+ #include <errno.h>
  #include <afs/afsutil.h>
  
  #define UBIK_INTERNALS
***************
*** 488,500 ****
  {
      register afs_int32 code;
      register struct ubik_dbase *dbase;
!     char tbuffer[256];
      afs_int32 offset;
      struct ubik_version tversion;
      register int tlen;
      struct rx_peer *tpeer;
      struct rx_connection *tconn;
      afs_uint32 otherHost;
  
      /* send the file back to the requester */
  
--- 490,506 ----
  {
      register afs_int32 code;
      register struct ubik_dbase *dbase;
!     char tbuffer[1024];
      afs_int32 offset;
      struct ubik_version tversion;
      register int tlen;
      struct rx_peer *tpeer;
      struct rx_connection *tconn;
      afs_uint32 otherHost;
+ #ifndef OLD_URECOVERY
+     char pbuffer[1028];
+     int flen, fd = -1;
+ #endif
  
      /* send the file back to the requester */
  
***************
*** 532,541 ****
--- 538,562 ----
  	       afs_inet_ntoa(otherHost));
  
      offset = 0;
+ #ifdef OLD_URECOVERY
      (*dbase->truncate) (dbase, file, 0);	/* truncate first */
      tversion.epoch = 0;		/* start off by labelling in-transit db as invalid */
      tversion.counter = 0;
      (*dbase->setlabel) (dbase, file, &tversion);	/* setlabel does sync */
+ #else
+     flen = length;
+     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+     fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
+     if (fd < 0) {
+ 	code = errno;
+ 	goto failed;
+     }
+     code = lseek(fd, HDRSIZE, 0);
+     if (code != HDRSIZE) {
+ 	close(fd);
+ 	goto failed;
+     }
+ #endif
      memcpy(&ubik_dbase->version, &tversion, sizeof(struct ubik_version));
      while (length > 0) {
  	tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
***************
*** 544,572 ****
--- 565,627 ----
  	    DBRELE(dbase);
  	    ubik_dprint("Rx-read length error=%d\n", code);
  	    code = BULK_ERROR;
+ 	    close(fd);
  	    goto failed;
  	}
+ #ifdef OLD_URECOVERY
  	code = (*dbase->write) (dbase, file, tbuffer, offset, tlen);
+ #else
+ 	code = write(fd, tbuffer, tlen);
+ #endif
  	if (code != tlen) {
  	    DBRELE(dbase);
  	    ubik_dprint("write failed error=%d\n", code);
  	    code = UIOERROR;
+ 	    close(fd);
  	    goto failed;
  	}
  	offset += tlen;
  	length -= tlen;
      }
+ #ifndef OLD_URECOVERY
+     code = close(fd);
+     if (code)
+ 	goto failed;
+ #endif     
  
      /* sync data first, then write label and resync (resync done by setlabel call).
       * This way, good label is only on good database. */
+ #ifdef OLD_URECOVERY
      (*ubik_dbase->sync) (dbase, file);
+ #else
+     afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB0", ubik_dbase->pathName);
+ #ifdef AFS_NT40_ENV
+     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+     code = unlink(pbuffer);
+     if (!code)
+ 	code = rename(tbuffer, pbuffer);
+     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+ #endif
+     if (!code) 
+ 	code = rename(pbuffer, tbuffer);
+     if (!code)
+ #endif
      code = (*ubik_dbase->setlabel) (dbase, file, avers);
+ #ifndef OLD_URECOVERY
+ #ifdef AFS_NT40_ENV
+     afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+     unlink(pbuffer);
+ #endif
+ #endif
      memcpy(&ubik_dbase->version, avers, sizeof(struct ubik_version));
      udisk_Invalidate(dbase, file);	/* new dbase, flush disk buffers */
      LWP_NoYieldSignal(&dbase->version);
      DBRELE(dbase);
    failed:
      if (code) {
+ #ifndef OLD_URECOVERY
+ 	unlink(pbuffer);
+ #endif
  	ubik_print
  	    ("Ubik: Synchronize database with server %s failed (error = %d)\n",
  	     afs_inet_ntoa(otherHost), code);
Index: openafs/src/uss/lex.l
diff -c openafs/src/uss/lex.l:1.1.14.2 openafs/src/uss/lex.l:1.1.14.3
*** openafs/src/uss/lex.l:1.1.14.2	Mon Nov 26 16:08:45 2007
--- openafs/src/uss/lex.l	Mon Dec 10 13:22:34 2007
***************
*** 11,17 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/uss/lex.l,v 1.1.14.2 2007/11/26 21:08:45 shadow Exp $");
  
  
  #include <string.h>
--- 11,17 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/uss/lex.l,v 1.1.14.3 2007/12/10 18:22:34 shadow Exp $");
  
  
  #include <string.h>
***************
*** 24,29 ****
--- 24,30 ----
  #else
  #define dprint(x)
  #endif
+ void Replace(char *in, char *out);
  %}
  
  /* definitions */
Index: openafs/src/util/snprintf.c
diff -c openafs/src/util/snprintf.c:1.24.4.1 openafs/src/util/snprintf.c:1.24.4.3
*** openafs/src/util/snprintf.c:1.24.4.1	Tue Oct 30 11:16:48 2007
--- openafs/src/util/snprintf.c	Fri Dec 14 08:19:43 2007
***************
*** 4,10 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/util/snprintf.c,v 1.24.4.1 2007/10/30 15:16:48 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdarg.h>
--- 4,10 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/util/snprintf.c,v 1.24.4.3 2007/12/14 13:19:43 jaltman Exp $");
  
  #include <sys/types.h>
  #include <stdarg.h>
***************
*** 14,19 ****
--- 14,22 ----
  #ifndef AFS_NT40_ENV
  #include <netinet/in.h>
  #include <netdb.h>
+ #ifndef HAVE_VSYSLOG
+ #include <syslog.h>
+ #endif
  #else
  #include <winsock2.h>
  #endif
***************
*** 522,527 ****
--- 525,540 ----
  #endif /* AFS_OSF20_ENV || AFS_AIX32_ENV */
  
  #ifndef AFS_NT40_ENV
+ #ifndef HAVE_VSYSLOG
+ void
+ vsyslog(int priority, const char *format, va_list args)
+ {
+   char buf[1024];
+   vsnprintf(buf, sizeof(buf), format, args);
+   syslog(priority, "%s", buf);
+ }
+ #endif
+ 
  #if defined(AFS_OSF20_ENV) && !defined(AFS_DUX50_ENV) || defined(AFS_AIX32_ENV) || (defined(AFS_SUN55_ENV) && !defined(AFS_SUN56_ENV)) || !defined(HAVE_SNPRINTF)
  
  #ifdef AFS_AIX51_ENV
Index: openafs/src/viced/NTMakefile
diff -c openafs/src/viced/NTMakefile:1.6.2.4 openafs/src/viced/NTMakefile:1.6.2.5
*** openafs/src/viced/NTMakefile:1.6.2.4	Wed Sep 19 13:58:48 2007
--- openafs/src/viced/NTMakefile	Fri Dec 14 08:35:39 2007
***************
*** 80,90 ****
  
  ############################################################################
  # generate versioninfo resources
! $(EXERES): AFS_component_version_number.h
  
! $(CBDRES): AFS_component_version_number.h
  
! install:  $(INCFILES) $(EXERES) $(CBD) $(CBDRES)
  
  mkdir:
  	
--- 80,94 ----
  
  ############################################################################
  # generate versioninfo resources
! $(EXERES): fileserver.rc AFS_component_version_number.h
  
! $(CBDRES): cbd.rc AFS_component_version_number.h
  
! install:  $(INCFILES) $(CBD)
  
  mkdir:
  	
+ clean::
+ 	$(DEL) $(EXERES)
+ 	$(DEL) $(CBDRES)
+ 
Index: openafs/src/vlserver/vldb_check.c
diff -c openafs/src/vlserver/vldb_check.c:1.11.14.3 openafs/src/vlserver/vldb_check.c:1.11.14.4
*** openafs/src/vlserver/vldb_check.c:1.11.14.3	Mon Nov 26 16:08:46 2007
--- openafs/src/vlserver/vldb_check.c	Tue Dec 11 15:43:50 2007
***************
*** 25,31 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vldb_check.c,v 1.11.14.3 2007/11/26 21:08:46 shadow Exp $");
  
  #include <sys/types.h>
  #include <sys/stat.h>
--- 25,31 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vldb_check.c,v 1.11.14.4 2007/12/11 20:43:50 shadow Exp $");
  
  #include <sys/types.h>
  #include <sys/stat.h>
***************
*** 242,248 ****
      if (headerp->vital_header.headersize != sizeof(*headerp))
  	printf("Header reports its size as %d (should be %d)\n",
  	       headerp->vital_header.headersize, sizeof(*headerp));
!     return 0;
  }
  
  readMH(addr, mhblockP)
--- 242,248 ----
      if (headerp->vital_header.headersize != sizeof(*headerp))
  	printf("Header reports its size as %d (should be %d)\n",
  	       headerp->vital_header.headersize, sizeof(*headerp));
!     return;
  }
  
  readMH(addr, mhblockP)
***************
*** 267,273 ****
  	for (j = 0; j < VL_MAXIPADDRS_PERMH; j++)
  	    e->ex_addrs[j] = ntohl(e->ex_addrs[j]);
      }
!     return 0;
  }
  
  readentry(addr, vlentryp, type)
--- 267,273 ----
  	for (j = 0; j < VL_MAXIPADDRS_PERMH; j++)
  	    e->ex_addrs[j] = ntohl(e->ex_addrs[j]);
      }
!     return;
  }
  
  readentry(addr, vlentryp, type)
***************
*** 348,354 ****
  	    }
  	}
      }
!     return 0;
  }
  
  void
--- 348,354 ----
  	    }
  	}
      }
!     return;
  }
  
  void
***************
*** 565,571 ****
  	    ("%d entries in name hash, longest is %d, shortest is %d, average length is %f\n",
  	     count, longest, shortest, ((float)count / (float)HASHSIZE));
      }
!     return 0;
  }
  
  /*
--- 565,571 ----
  	    ("%d entries in name hash, longest is %d, shortest is %d, average length is %f\n",
  	     count, longest, shortest, ((float)count / (float)HASHSIZE));
      }
!     return;
  }
  
  /*
***************
*** 639,645 ****
  		 ((float)count / (float)HASHSIZE));
  	}
      }
!     return 0;
  }
  
  /*
--- 639,645 ----
  		 ((float)count / (float)HASHSIZE));
  	}
      }
!     return;
  }
  
  /*
***************
*** 684,690 ****
      }
      if (verbose)
  	printf("%d entries on free chain\n", count);
!     return 0;
  }
  
  /*
--- 684,690 ----
      }
      if (verbose)
  	printf("%d entries on free chain\n", count);
!     return;
  }
  
  /*
***************
*** 895,901 ****
  	printf("%d simple entries, %d multihomed entries, Total = %d\n",
  	       regentries, mhentries, mhentries + regentries);
      }
!     return 0;
  }
  
  int
--- 895,901 ----
  	printf("%d simple entries, %d multihomed entries, Total = %d\n",
  	       regentries, mhentries, mhentries + regentries);
      }
!     return;
  }
  
  int
Index: openafs/src/volser/vsprocs.c
diff -c openafs/src/volser/vsprocs.c:1.38.2.8 openafs/src/volser/vsprocs.c:1.38.2.10
*** openafs/src/volser/vsprocs.c:1.38.2.8	Mon Nov 26 16:08:46 2007
--- openafs/src/volser/vsprocs.c	Tue Dec 18 10:16:31 2007
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.38.2.8 2007/11/26 21:08:46 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.38.2.10 2007/12/18 15:16:31 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 141,146 ****
--- 141,156 ----
  	{ if (verbose) { fprintf(STDOUT, (es), (p1), (p2), (p3)); fflush(STDOUT); } }
  #define VDONE \
  	{ if (verbose) { fprintf(STDOUT, " done\n"); fflush(STDOUT); } }
+ #define VEPRINT(es) \
+ 	{ if (verbose) { fprintf(STDERR, (es)); fflush(STDERR); } }
+ #define VEPRINT1(es, p) \
+ 	{ if (verbose) { fprintf(STDERR, (es), (p)); fflush(STDERR); } }
+ #define VEPRINT2(es, p1, p2) \
+ 	{ if (verbose) { fprintf(STDERR, (es), (p1), (p2)); fflush(STDERR); } }
+ #define VEPRINT3(es, p1, p2, p3) \
+ 	{ if (verbose) { fprintf(STDERR, (es), (p1), (p2), (p3)); fflush(STDERR); } }
+ #define VEDONE \
+ 	{ if (verbose) { fprintf(STDERR, " done\n"); fflush(STDERR); } }
  
  
  
***************
*** 3845,3883 ****
      (void)signal(SIGINT, dump_sig_handler);
  
      if (!fromdate) {
! 	VPRINT("Full Dump ...\n");
      } else {
! 	VPRINT1("Incremental Dump (as of %.24s)...\n",
  		ctime(&tmv));
      }
  
      /* get connections to the servers */
      fromconn = UV_Bind(afromserver, AFSCONF_VOLUMEPORT);
  
!     VPRINT1("Starting transaction on volume %u...", afromvol);
      code = AFSVolTransCreate(fromconn, afromvol, afrompart, ITBusy, &fromtid);
      EGOTO1(error_exit, code,
  	   "Could not start transaction on the volume %u to be dumped\n",
  	   afromvol);
!     VDONE;
  
      fromcall = rx_NewCall(fromconn);
  
!     VPRINT1("Starting volume dump on volume %u...", afromvol);
      if (flags & VOLDUMPV2_OMITDIRS) 
  	code = StartAFSVolDumpV2(fromcall, fromtid, fromdate, flags);
      else
        retryold:
  	code = StartAFSVolDump(fromcall, fromtid, fromdate);
      EGOTO(error_exit, code, "Could not start the dump process \n");
!     VDONE;
  
!     VPRINT1("Dumping volume %u...", afromvol);
      code = DumpFunction(fromcall, rock);
      if (code == RXGEN_OPCODE) 
  	goto error_exit;
      EGOTO(error_exit, code, "Error while dumping volume \n");
!     VDONE;
  
    error_exit:
      if (fromcall) {
--- 3855,3893 ----
      (void)signal(SIGINT, dump_sig_handler);
  
      if (!fromdate) {
! 	VEPRINT("Full Dump ...\n");
      } else {
! 	VEPRINT1("Incremental Dump (as of %.24s)...\n",
  		ctime(&tmv));
      }
  
      /* get connections to the servers */
      fromconn = UV_Bind(afromserver, AFSCONF_VOLUMEPORT);
  
!     VEPRINT1("Starting transaction on volume %u...", afromvol);
      code = AFSVolTransCreate(fromconn, afromvol, afrompart, ITBusy, &fromtid);
      EGOTO1(error_exit, code,
  	   "Could not start transaction on the volume %u to be dumped\n",
  	   afromvol);
!     VEDONE;
  
      fromcall = rx_NewCall(fromconn);
  
!     VEPRINT1("Starting volume dump on volume %u...", afromvol);
      if (flags & VOLDUMPV2_OMITDIRS) 
  	code = StartAFSVolDumpV2(fromcall, fromtid, fromdate, flags);
      else
        retryold:
  	code = StartAFSVolDump(fromcall, fromtid, fromdate);
      EGOTO(error_exit, code, "Could not start the dump process \n");
!     VEDONE;
  
!     VEPRINT1("Dumping volume %u...", afromvol);
      code = DumpFunction(fromcall, rock);
      if (code == RXGEN_OPCODE) 
  	goto error_exit;
      EGOTO(error_exit, code, "Error while dumping volume \n");
!     VEDONE;
  
    error_exit:
      if (fromcall) {
***************
*** 3888,3894 ****
  	    error = code;
      }
      if (fromtid) {
! 	VPRINT1("Ending transaction on volume %u...", afromvol);
  	code = AFSVolEndTrans(fromconn, fromtid, &rcode);
  	if (code || rcode) {
  	    fprintf(STDERR, "Could not end transaction on the volume %lu\n",
--- 3898,3904 ----
  	    error = code;
      }
      if (fromtid) {
! 	VEPRINT1("Ending transaction on volume %u...", afromvol);
  	code = AFSVolEndTrans(fromconn, fromtid, &rcode);
  	if (code || rcode) {
  	    fprintf(STDERR, "Could not end transaction on the volume %lu\n",
***************
*** 3896,3902 ****
  	    if (!error)
  		error = (code ? code : rcode);
  	}
! 	VDONE;
      }
      if (fromconn)
  	rx_DestroyConnection(fromconn);
--- 3906,3912 ----
  	    if (!error)
  		error = (code ? code : rcode);
  	}
! 	VEDONE;
      }
      if (fromconn)
  	rx_DestroyConnection(fromconn);
***************
*** 3936,3976 ****
      (void)signal(SIGINT, dump_sig_handler);
  
      if (!fromdate) {
! 	VPRINT("Full Dump ...\n");
      } else {
! 	VPRINT1("Incremental Dump (as of %.24s)...\n",
  		ctime(&tmv));
      }
  
      /* get connections to the servers */
      fromconn = UV_Bind(afromserver, AFSCONF_VOLUMEPORT);
  
!     VPRINT1("Starting transaction on volume %u...", afromvol);
      code = AFSVolTransCreate(fromconn, afromvol, afrompart, ITBusy, &fromtid);
      EGOTO1(error_exit, code,
  	   "Could not start transaction on the volume %u to be dumped\n",
  	   afromvol);
!     VDONE;
  
      /* Get a clone id */
!     VPRINT1("Allocating new volume id for clone of volume %u ...", afromvol);
      code = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &clonevol);
      EGOTO1(error_exit, code,
  	   "Could not get an ID for the clone of volume %u from the VLDB\n",
  	   afromvol);
!     VDONE;
  
      /* Do the clone. Default flags on clone are set to delete on salvage and out of service */
!     VPRINT2("Cloning source volume %u to clone volume %u...", afromvol,
  	    clonevol);
      strcpy(vname, "dump-clone-temp");
      code =
  	AFSVolClone(fromconn, fromtid, 0, readonlyVolume, vname, &clonevol);
      EGOTO1(error_exit, code, "Failed to clone the source volume %u\n",
  	   afromvol);
!     VDONE;
  
!     VPRINT1("Ending the transaction on the volume %u ...", afromvol);
      rcode = 0;
      code = AFSVolEndTrans(fromconn, fromtid, &rcode);
      fromtid = 0;
--- 3946,3986 ----
      (void)signal(SIGINT, dump_sig_handler);
  
      if (!fromdate) {
! 	VEPRINT("Full Dump ...\n");
      } else {
! 	VEPRINT1("Incremental Dump (as of %.24s)...\n",
  		ctime(&tmv));
      }
  
      /* get connections to the servers */
      fromconn = UV_Bind(afromserver, AFSCONF_VOLUMEPORT);
  
!     VEPRINT1("Starting transaction on volume %u...", afromvol);
      code = AFSVolTransCreate(fromconn, afromvol, afrompart, ITBusy, &fromtid);
      EGOTO1(error_exit, code,
  	   "Could not start transaction on the volume %u to be dumped\n",
  	   afromvol);
!     VEDONE;
  
      /* Get a clone id */
!     VEPRINT1("Allocating new volume id for clone of volume %u ...", afromvol);
      code = ubik_VL_GetNewVolumeId(cstruct, 0, 1, &clonevol);
      EGOTO1(error_exit, code,
  	   "Could not get an ID for the clone of volume %u from the VLDB\n",
  	   afromvol);
!     VEDONE;
  
      /* Do the clone. Default flags on clone are set to delete on salvage and out of service */
!     VEPRINT2("Cloning source volume %u to clone volume %u...", afromvol,
  	    clonevol);
      strcpy(vname, "dump-clone-temp");
      code =
  	AFSVolClone(fromconn, fromtid, 0, readonlyVolume, vname, &clonevol);
      EGOTO1(error_exit, code, "Failed to clone the source volume %u\n",
  	   afromvol);
!     VEDONE;
  
!     VEPRINT1("Ending the transaction on the volume %u ...", afromvol);
      rcode = 0;
      code = AFSVolEndTrans(fromconn, fromtid, &rcode);
      fromtid = 0;
***************
*** 3978,4026 ****
  	code = rcode;
      EGOTO1(error_exit, code,
  	   "Failed to end the transaction on the volume %u\n", afromvol);
!     VDONE;
  
  
!     VPRINT1("Starting transaction on the cloned volume %u ...", clonevol);
      code =
  	AFSVolTransCreate(fromconn, clonevol, afrompart, ITOffline,
  			  &clonetid);
      EGOTO1(error_exit, code,
  	   "Failed to start a transaction on the cloned volume%u\n",
  	   clonevol);
!     VDONE;
  
!     VPRINT1("Setting flags on cloned volume %u ...", clonevol);
      code = AFSVolSetFlags(fromconn, clonetid, VTDeleteOnSalvage | VTOutOfService);	/*redundant */
      EGOTO1(error_exit, code, "Could not set falgs on the cloned volume %u\n",
  	   clonevol);
!     VDONE;
  
  
      fromcall = rx_NewCall(fromconn);
  
!     VPRINT1("Starting volume dump from cloned volume %u...", clonevol);
      if (flags & VOLDUMPV2_OMITDIRS) 
  	code = StartAFSVolDumpV2(fromcall, clonetid, fromdate, flags);
      else
  	code = StartAFSVolDump(fromcall, clonetid, fromdate);
      EGOTO(error_exit, code, "Could not start the dump process \n");
!     VDONE;
  
!     VPRINT1("Dumping volume %u...", afromvol);
      code = DumpFunction(fromcall, rock);
      EGOTO(error_exit, code, "Error while dumping volume \n");
!     VDONE;
  
    error_exit:
      /* now delete the clone */
!     VPRINT1("Deleting the cloned volume %u ...", clonevol);
      code = AFSVolDeleteVolume(fromconn, clonetid);
      if (code) {
  	fprintf(STDERR, "Failed to delete the cloned volume %lu\n",
  		(unsigned long)clonevol);
      } else {
! 	VDONE;
      }
  
      if (fromcall) {
--- 3988,4036 ----
  	code = rcode;
      EGOTO1(error_exit, code,
  	   "Failed to end the transaction on the volume %u\n", afromvol);
!     VEDONE;
  
  
!     VEPRINT1("Starting transaction on the cloned volume %u ...", clonevol);
      code =
  	AFSVolTransCreate(fromconn, clonevol, afrompart, ITOffline,
  			  &clonetid);
      EGOTO1(error_exit, code,
  	   "Failed to start a transaction on the cloned volume%u\n",
  	   clonevol);
!     VEDONE;
  
!     VEPRINT1("Setting flags on cloned volume %u ...", clonevol);
      code = AFSVolSetFlags(fromconn, clonetid, VTDeleteOnSalvage | VTOutOfService);	/*redundant */
      EGOTO1(error_exit, code, "Could not set falgs on the cloned volume %u\n",
  	   clonevol);
!     VEDONE;
  
  
      fromcall = rx_NewCall(fromconn);
  
!     VEPRINT1("Starting volume dump from cloned volume %u...", clonevol);
      if (flags & VOLDUMPV2_OMITDIRS) 
  	code = StartAFSVolDumpV2(fromcall, clonetid, fromdate, flags);
      else
  	code = StartAFSVolDump(fromcall, clonetid, fromdate);
      EGOTO(error_exit, code, "Could not start the dump process \n");
!     VEDONE;
  
!     VEPRINT1("Dumping volume %u...", afromvol);
      code = DumpFunction(fromcall, rock);
      EGOTO(error_exit, code, "Error while dumping volume \n");
!     VEDONE;
  
    error_exit:
      /* now delete the clone */
!     VEPRINT1("Deleting the cloned volume %u ...", clonevol);
      code = AFSVolDeleteVolume(fromconn, clonetid);
      if (code) {
  	fprintf(STDERR, "Failed to delete the cloned volume %lu\n",
  		(unsigned long)clonevol);
      } else {
! 	VEDONE;
      }
  
      if (fromcall) {
***************
*** 4032,4038 ****
  	}
      }
      if (clonetid) {
! 	VPRINT1("Ending transaction on cloned volume %u...", clonevol);
  	code = AFSVolEndTrans(fromconn, clonetid, &rcode);
  	if (code || rcode) {
  	    fprintf(STDERR,
--- 4042,4048 ----
  	}
      }
      if (clonetid) {
! 	VEPRINT1("Ending transaction on cloned volume %u...", clonevol);
  	code = AFSVolEndTrans(fromconn, clonetid, &rcode);
  	if (code || rcode) {
  	    fprintf(STDERR,
***************
*** 4041,4047 ****
  	    if (!error)
  		error = (code ? code : rcode);
  	}
! 	VDONE;
      }
      if (fromconn)
  	rx_DestroyConnection(fromconn);
--- 4051,4057 ----
  	    if (!error)
  		error = (code ? code : rcode);
  	}
! 	VEDONE;
      }
      if (fromconn)
  	rx_DestroyConnection(fromconn);
