Index: openafs/src/WINNT/afsapplib/NTMakefile
diff -c openafs/src/WINNT/afsapplib/NTMakefile:1.5 openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.1
*** openafs/src/WINNT/afsapplib/NTMakefile:1.5	Fri Nov 21 02:59:39 2003
--- openafs/src/WINNT/afsapplib/NTMakefile	Fri Nov  5 14:21:40 2004
***************
*** 126,131 ****
--- 126,134 ----
  	$(DEL) $*.lib $*.exp
  
  clean::
+ 	$(CD) lang
+ 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
+ 	$(CD) ..
  
  
  ############################################################################
Index: openafs/src/WINNT/afsd/NTMakefile
diff -c openafs/src/WINNT/afsd/NTMakefile:1.27.2.1 openafs/src/WINNT/afsd/NTMakefile:1.27.2.2
*** openafs/src/WINNT/afsd/NTMakefile:1.27.2.1	Thu Aug 19 15:50:58 2004
--- openafs/src/WINNT/afsd/NTMakefile	Fri Nov  5 14:21:42 2004
***************
*** 339,364 ****
  AFSD_SDKLIBS =\
  	largeint.lib \
  	netapi32.lib \
!     dnsapi.lib mpr.lib \
  	rpcrt4.lib \
  	user32.lib \
!     Dbghelp.lib \
!     strsafe.lib \
!     mpr.lib \
!     secur32.lib \
!     ole32.lib \
!     oleaut32.lib
  
  AFSD_EXELIBS =\
  	$(DESTDIR)\lib\libosi.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
!     $(DESTDIR)\lib\afsrx.lib \
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\afs\mtafsvldb.lib \
  	$(DESTDIR)\lib\afs\mtafsint.lib \
  	$(DESTDIR)\lib\libafsconf.lib \
  	$(DESTDIR)\lib\afs\afsreg.lib \
!     $(LANAHELPERLIB)
  
  $(AFSD_EXEFILE): $(OUT)\afsd.obj $(AFSDOBJS) $(OUT)\afsd.res  $(RXOBJS) $(AFSD_EXELIBS)
  	$(EXEGUILINK) $(AFSD_SDKLIBS)
--- 339,364 ----
  AFSD_SDKLIBS =\
  	largeint.lib \
  	netapi32.lib \
!         dnsapi.lib mpr.lib \
  	rpcrt4.lib \
  	user32.lib \
!         Dbghelp.lib \
!         strsafe.lib \
!         mpr.lib \
!         secur32.lib \
!         ole32.lib \
!         oleaut32.lib
  
  AFSD_EXELIBS =\
  	$(DESTDIR)\lib\libosi.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
!         $(DESTDIR)\lib\afsrx.lib \
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\afs\mtafsvldb.lib \
  	$(DESTDIR)\lib\afs\mtafsint.lib \
  	$(DESTDIR)\lib\libafsconf.lib \
  	$(DESTDIR)\lib\afs\afsreg.lib \
!         $(LANAHELPERLIB)
  
  $(AFSD_EXEFILE): $(OUT)\afsd.obj $(AFSDOBJS) $(OUT)\afsd.res  $(RXOBJS) $(AFSD_EXELIBS)
  	$(EXEGUILINK) $(AFSD_SDKLIBS)
Index: openafs/src/WINNT/afsd/afsd.c
diff -c openafs/src/WINNT/afsd/afsd.c:1.8 openafs/src/WINNT/afsd/afsd.c:1.8.2.1
*** openafs/src/WINNT/afsd/afsd.c:1.8	Wed Dec  3 14:44:59 2003
--- openafs/src/WINNT/afsd/afsd.c	Fri Nov  5 14:21:42 2004
***************
*** 53,58 ****
--- 53,59 ----
  	MessageBox(NULL, tbuffer, msgp, MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);
  
  	afsd_ForceTrace(TRUE);
+         buf_ForceTrace(TRUE);
  
  	if (traceOnPanic) {
  		_asm int 3h;
Index: openafs/src/WINNT/afsd/afsd95.c
diff -c openafs/src/WINNT/afsd/afsd95.c:1.2 openafs/src/WINNT/afsd/afsd95.c:1.2.8.1
*** openafs/src/WINNT/afsd/afsd95.c:1.2	Fri Oct  5 17:40:47 2001
--- openafs/src/WINNT/afsd/afsd95.c	Fri Nov  5 14:21:42 2004
***************
*** 52,57 ****
--- 52,58 ----
  	/*MessageBox(NULL, tbuffer, msgp, MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);*/
  
  	afsd_ForceTrace(TRUE);
+         buf_ForceTrace(TRUE);
  
  	if (traceOnPanic) {
  		/*asm("int 3");*/
Index: openafs/src/WINNT/afsd/afsd_init.c
diff -c openafs/src/WINNT/afsd/afsd_init.c:1.40.2.5 openafs/src/WINNT/afsd/afsd_init.c:1.40.2.6
*** openafs/src/WINNT/afsd/afsd_init.c:1.40.2.5	Mon Oct 18 00:09:25 2004
--- openafs/src/WINNT/afsd/afsd_init.c	Fri Nov  5 14:21:42 2004
***************
*** 22,28 ****
  #include "afsd.h"
  #include <rx\rx.h>
  #include <rx\rx_null.h>
- 
  #include <WINNT/syscfg.h>
  
  #include "smb.h"
--- 22,27 ----
***************
*** 651,657 ****
          char * p, *q; 
          afsi_log("Sys name %s", buf);
  
!         for (p = q = buf; p < cm_sysName + dummyLen; p++)
          {
              if (*p == '\0' || isspace(*p)) {
                  memcpy(cm_sysNameList[cm_sysNameCount],q,p-q);
--- 650,656 ----
          char * p, *q; 
          afsi_log("Sys name %s", buf);
  
!         for (p = q = buf; p < buf + dummyLen; p++)
          {
              if (*p == '\0' || isspace(*p)) {
                  memcpy(cm_sysNameList[cm_sysNameCount],q,p-q);
Index: openafs/src/WINNT/afsd/afsd_service.c
diff -c openafs/src/WINNT/afsd/afsd_service.c:1.28.2.2 openafs/src/WINNT/afsd/afsd_service.c:1.28.2.3
*** openafs/src/WINNT/afsd/afsd_service.c:1.28.2.2	Mon Oct 18 00:09:25 2004
--- openafs/src/WINNT/afsd/afsd_service.c	Fri Nov  5 14:21:42 2004
***************
*** 82,87 ****
--- 82,88 ----
      osi_LogEnable(afsd_logp);
  
      afsd_ForceTrace(TRUE);
+     buf_ForceTrace(TRUE);
  
      afsi_log("--- begin dump ---");
      cm_DumpSCache(afsi_file, "a");
***************
*** 176,183 ****
          RegCloseKey (parmKey);
          if (code != ERROR_SUCCESS)
              doTrace = 0;
!         if (doTrace)
              afsd_ForceTrace(FALSE);
  
        doneTrace:
          ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
--- 177,186 ----
          RegCloseKey (parmKey);
          if (code != ERROR_SUCCESS)
              doTrace = 0;
!         if (doTrace) {
              afsd_ForceTrace(FALSE);
+             buf_ForceTrace(FALSE);
+         }
  
        doneTrace:
          ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
***************
*** 239,246 ****
          RegCloseKey (parmKey);
          if (code != ERROR_SUCCESS)
              doTrace = 0;
!         if (doTrace)
              afsd_ForceTrace(FALSE);
  
        doneTrace:
          ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
--- 242,251 ----
          RegCloseKey (parmKey);
          if (code != ERROR_SUCCESS)
              doTrace = 0;
!         if (doTrace) {
              afsd_ForceTrace(FALSE);
+             buf_ForceTrace(FALSE);
+         }
  
        doneTrace:
          ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
Index: openafs/src/WINNT/afsd/afskfw.c
diff -c openafs/src/WINNT/afsd/afskfw.c:1.8.2.4 openafs/src/WINNT/afsd/afskfw.c:1.8.2.5
*** openafs/src/WINNT/afsd/afskfw.c:1.8.2.4	Mon Oct 18 00:09:25 2004
--- openafs/src/WINNT/afsd/afskfw.c	Fri Nov  5 14:21:42 2004
***************
*** 56,62 ****
  
  
  #define USE_MS2MIT
! #define USE_KRB4
  #include "afskfw-int.h"
  #include "afskfw.h"
  
--- 56,62 ----
  
  
  #define USE_MS2MIT
! #undef  USE_KRB4
  #include "afskfw-int.h"
  #include "afskfw.h"
  
***************
*** 288,293 ****
--- 288,294 ----
      END_FUNC_INFO
  };
  
+ #ifdef USE_KRB4
  FUNC_INFO k4_fi[] = {
      MAKE_FUNC_INFO(krb_get_cred),
      MAKE_FUNC_INFO(krb_get_tf_realm),
***************
*** 295,300 ****
--- 296,302 ----
      MAKE_FUNC_INFO(tkt_string),
      END_FUNC_INFO
  };
+ #endif
  
  FUNC_INFO k524_fi[] = {
      MAKE_FUNC_INFO(krb524_init_ets),
***************
*** 388,394 ****
--- 390,398 ----
          if ( !inited ) {
              inited = 1;
              LoadFuncs(KRB5_DLL, k5_fi, &hKrb5, 0, 1, 0, 0);
+ #ifdef USE_KRB4
              LoadFuncs(KRB4_DLL, k4_fi, &hKrb4, 0, 1, 0, 0);
+ #endif /* USE_KRB4 */
              LoadFuncs(COMERR_DLL, ce_fi, &hComErr, 0, 0, 1, 0);
              LoadFuncs(SERVICE_DLL, service_fi, &hService, 0, 1, 0, 0);
  #ifdef USE_MS2MIT
***************
*** 457,476 ****
          len = sizeof(use524);
          code = RegQueryValueEx(parmKey, "Use524", NULL, NULL,
                                  (BYTE *) &use524, &len);
!         if (code != ERROR_SUCCESS) {
!             RegCloseKey(parmKey);
! 
!             code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, OpenAFSConfigKeyName,
!                                  0, KEY_QUERY_VALUE, &parmKey);
!             if (code == ERROR_SUCCESS) {
!                 len = sizeof(use524);
!                 code = RegQueryValueEx(parmKey, "Use524", NULL, NULL,
!                                         (BYTE *) &use524, &len);
!                 if (code != ERROR_SUCCESS)
!                     use524 = 0;
!             }
          }
-         RegCloseKey (parmKey);
      }
      return use524;
  }
--- 461,477 ----
          len = sizeof(use524);
          code = RegQueryValueEx(parmKey, "Use524", NULL, NULL,
                                  (BYTE *) &use524, &len);
!         RegCloseKey(parmKey);
!     }
!     if (code != ERROR_SUCCESS) {
!         code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, OpenAFSConfigKeyName,
!                              0, KEY_QUERY_VALUE, &parmKey);
!         if (code == ERROR_SUCCESS) {
!             len = sizeof(use524);
!             code = RegQueryValueEx(parmKey, "Use524", NULL, NULL,
!                                     (BYTE *) &use524, &len);
!             RegCloseKey (parmKey);
          }
      }
      return use524;
  }
***************
*** 488,508 ****
          len = sizeof(enableKFW);
          code = RegQueryValueEx(parmKey, "EnableKFW", NULL, NULL,
                                  (BYTE *) &enableKFW, &len);
-         if (code != ERROR_SUCCESS) {
-             RegCloseKey(parmKey);
- 
-             code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, OpenAFSConfigKeyName,
-                                  0, KEY_QUERY_VALUE, &parmKey);
-             if (code == ERROR_SUCCESS) {
-                 len = sizeof(enableKFW);
-                 code = RegQueryValueEx(parmKey, "EnableKFW", NULL, NULL,
-                                         (BYTE *) &enableKFW, &len);
-                 if (code != ERROR_SUCCESS)
-                     enableKFW = 1;
-             }
-         }
          RegCloseKey (parmKey);
      }
      if ( !enableKFW )
          return FALSE;
  
--- 489,508 ----
          len = sizeof(enableKFW);
          code = RegQueryValueEx(parmKey, "EnableKFW", NULL, NULL,
                                  (BYTE *) &enableKFW, &len);
          RegCloseKey (parmKey);
      }
+     
+     if (code != ERROR_SUCCESS) {
+         code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, OpenAFSConfigKeyName,
+                              0, KEY_QUERY_VALUE, &parmKey);
+         if (code == ERROR_SUCCESS) {
+             len = sizeof(enableKFW);
+             code = RegQueryValueEx(parmKey, "EnableKFW", NULL, NULL,
+                                     (BYTE *) &enableKFW, &len);
+             RegCloseKey (parmKey);
+         }
+     } 
+ 
      if ( !enableKFW )
          return FALSE;
  
***************
*** 2643,2649 ****
          }       
      }
  #else
!     goto cleanup;
  #endif
      strcpy(realm_of_cell, afs_realm_of_cell(ctx, &ak_cellconfig));
  
--- 2643,2650 ----
          }       
      }
  #else
!     if (!try_krb5)
!         goto cleanup;
  #endif
      strcpy(realm_of_cell, afs_realm_of_cell(ctx, &ak_cellconfig));
  
***************
*** 2700,2706 ****
          code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds);
          if (code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ||
               code == KRB5KRB_ERR_GENERIC /* heimdal */ ||
! 			 code == KRB5KRB_AP_ERR_MSG_TYPE) {
              /* Or service@REALM */
              pkrb5_free_principal(ctx,increds.server);
              increds.server = 0;
--- 2701,2707 ----
          code = pkrb5_get_credentials(ctx, 0, cc, &increds, &k5creds);
          if (code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ||
               code == KRB5KRB_ERR_GENERIC /* heimdal */ ||
!              code == KRB5KRB_AP_ERR_MSG_TYPE) {
              /* Or service@REALM */
              pkrb5_free_principal(ctx,increds.server);
              increds.server = 0;
***************
*** 2730,2736 ****
  
          if ((code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ||
                code == KRB5KRB_ERR_GENERIC /* heimdal */ ||
! 			  code == KRB5KRB_AP_ERR_MSG_TYPE) &&
               strcmp(RealmName, realm_of_cell)) {
              /* Or service/cell@REALM_OF_CELL */
              strcpy(RealmName, realm_of_cell);
--- 2731,2737 ----
  
          if ((code == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN ||
                code == KRB5KRB_ERR_GENERIC /* heimdal */ ||
!               code == KRB5KRB_AP_ERR_MSG_TYPE) &&
               strcmp(RealmName, realm_of_cell)) {
              /* Or service/cell@REALM_OF_CELL */
              strcpy(RealmName, realm_of_cell);
***************
*** 3021,3027 ****
      if (ctx && (ctx != alt_ctx))
          pkrb5_free_context(ctx);
  
! 	return(rc? rc : code);
  }
  
  /**************************************/
--- 3022,3028 ----
      if (ctx && (ctx != alt_ctx))
          pkrb5_free_context(ctx);
  
!     return(rc? rc : code);
  }
  
  /**************************************/
Index: openafs/src/WINNT/afsd/cm.h
diff -c openafs/src/WINNT/afsd/cm.h:1.9 openafs/src/WINNT/afsd/cm.h:1.9.2.1
*** openafs/src/WINNT/afsd/cm.h:1.9	Mon Jul 26 19:22:20 2004
--- openafs/src/WINNT/afsd/cm.h	Fri Nov  5 14:21:42 2004
***************
*** 245,252 ****
  #define CM_ERROR_BUFFERTOOSMALL		(CM_ERROR_BASE+38)
  #define CM_ERROR_RENAME_IDENTICAL	(CM_ERROR_BASE+39)
  #define CM_ERROR_ALLOFFLINE             (CM_ERROR_BASE+40)
! #define CM_ERROR_AMBIGUOUS_FILENAME (CM_ERROR_BASE+41)
! #define CM_ERROR_BADLOGONTYPE	(CM_ERROR_BASE+42)
! #define CM_ERROR_GSSCONTINUE    (CM_ERROR_BASE+43)
! #define CM_ERROR_TIDIPC         (CM_ERROR_BASE+44)
  #endif /*  __CM_H_ENV__ */
--- 245,253 ----
  #define CM_ERROR_BUFFERTOOSMALL		(CM_ERROR_BASE+38)
  #define CM_ERROR_RENAME_IDENTICAL	(CM_ERROR_BASE+39)
  #define CM_ERROR_ALLOFFLINE             (CM_ERROR_BASE+40)
! #define CM_ERROR_AMBIGUOUS_FILENAME     (CM_ERROR_BASE+41)
! #define CM_ERROR_BADLOGONTYPE	        (CM_ERROR_BASE+42)
! #define CM_ERROR_GSSCONTINUE            (CM_ERROR_BASE+43)
! #define CM_ERROR_TIDIPC                 (CM_ERROR_BASE+44)
! #define CM_ERROR_TOO_MANY_SYMLINKS      (CM_ERROR_BASE+45)
  #endif /*  __CM_H_ENV__ */
Index: openafs/src/WINNT/afsd/cm_buf.c
diff -c openafs/src/WINNT/afsd/cm_buf.c:1.13.2.2 openafs/src/WINNT/afsd/cm_buf.c:1.13.2.3
*** openafs/src/WINNT/afsd/cm_buf.c:1.13.2.2	Sun Oct 10 19:52:04 2004
--- openafs/src/WINNT/afsd/cm_buf.c	Fri Nov  5 14:21:43 2004
***************
*** 19,27 ****
--- 19,32 ----
  #include <malloc.h>
  #include <stdio.h>
  #include <assert.h>
+ #include <strsafe.h>
  
  #include "afsd.h"
  
+ #ifdef DEBUG
+ #define TRACE_BUFFER 1
+ #endif
+ 
  extern void afsi_log(char *pattern, ...);
  
  /* This module implements the buffer package used by the local transaction
***************
*** 306,317 ****
                               OPEN_ALWAYS,
                               FILE_ATTRIBUTE_NORMAL,
                               NULL);
              if (hf == INVALID_HANDLE_VALUE) {
                  afsi_log("Error creating cache file \"%s\" error %d", 
                            cm_CachePath, GetLastError());
                  return CM_ERROR_INVAL;
              }
-             FreeCacheFileSA(psa);
          } else { /* buf_cacheType == CM_BUF_CACHETYPE_VIRTUAL */
              hf = INVALID_HANDLE_VALUE;
          }
--- 311,322 ----
                               OPEN_ALWAYS,
                               FILE_ATTRIBUTE_NORMAL,
                               NULL);
+             FreeCacheFileSA(psa);
              if (hf == INVALID_HANDLE_VALUE) {
                  afsi_log("Error creating cache file \"%s\" error %d", 
                            cm_CachePath, GetLastError());
                  return CM_ERROR_INVAL;
              }
          } else { /* buf_cacheType == CM_BUF_CACHETYPE_VIRTUAL */
              hf = INVALID_HANDLE_VALUE;
          }
***************
*** 378,385 ****
          /* just for safety's sake */
          buf_maxReservedBufs = buf_nbuffers - 3;
  
          /* init the buffer trace log */
!         buf_logp = osi_LogCreate("buffer", 10);
  
          osi_EndOnce(&once);
  
--- 383,393 ----
          /* just for safety's sake */
          buf_maxReservedBufs = buf_nbuffers - 3;
  
+ #ifdef TRACE_BUFFER
          /* init the buffer trace log */
!         buf_logp = osi_LogCreate("buffer", 1000);
!         osi_LogEnable(buf_logp);
! #endif
  
          osi_EndOnce(&once);
  
***************
*** 532,538 ****
          bp->flags |= CM_BUF_WAITING;
          osi_SleepM((long) bp, &bp->mx);
          lock_ObtainMutex(&bp->mx);
! 		osi_Log1(buf_logp, "buf_WaitIO conflict wait done for 0x%x", bp);
      }
          
      /* if we get here, the IO is done, but we may have to wakeup people waiting for
--- 540,546 ----
          bp->flags |= CM_BUF_WAITING;
          osi_SleepM((long) bp, &bp->mx);
          lock_ObtainMutex(&bp->mx);
!         osi_Log1(buf_logp, "buf_WaitIO conflict wait done for 0x%x", bp);
      }
          
      /* if we get here, the IO is done, but we may have to wakeup people waiting for
***************
*** 1481,1483 ****
--- 1489,1512 ----
      return 0;
  }
  
+ void buf_ForceTrace(BOOL flush)
+ {
+     HANDLE handle;
+     int len;
+     char buf[256];
+ 
+     if (!buf_logp) 
+         return;
+ 
+     len = GetTempPath(sizeof(buf)-10, buf);
+     StringCbCopyA(&buf[len], sizeof(buf)-len, "/afs-buffer.log");
+     handle = CreateFile(buf, GENERIC_WRITE, FILE_SHARE_READ,
+ 			    NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+     if (handle == INVALID_HANDLE_VALUE) {
+         osi_panic("Cannot create log file", __FILE__, __LINE__);
+     }
+     osi_LogPrint(buf_logp, handle);
+     if (flush)
+         FlushFileBuffers(handle);
+     CloseHandle(handle);
+ }
Index: openafs/src/WINNT/afsd/cm_buf.h
diff -c openafs/src/WINNT/afsd/cm_buf.h:1.4.2.2 openafs/src/WINNT/afsd/cm_buf.h:1.4.2.3
*** openafs/src/WINNT/afsd/cm_buf.h:1.4.2.2	Mon Oct 18 00:09:25 2004
--- openafs/src/WINNT/afsd/cm_buf.h	Fri Nov  5 14:21:43 2004
***************
*** 195,200 ****
--- 195,202 ----
  
  extern long buf_SetNBuffers(long nbuffers);
  
+ extern void buf_ForceTrace(BOOL flush);
+ 
  /* error codes */
  #define CM_BUF_EXISTS	1	/* buffer exists, and shouldn't */
  #define CM_ERROR_BASEBUF	0x33333333
Index: openafs/src/WINNT/afsd/cm_conn.c
diff -c openafs/src/WINNT/afsd/cm_conn.c:1.25.2.3 openafs/src/WINNT/afsd/cm_conn.c:1.25.2.4
*** openafs/src/WINNT/afsd/cm_conn.c:1.25.2.3	Mon Oct 18 00:09:25 2004
--- openafs/src/WINNT/afsd/cm_conn.c	Fri Nov  5 14:21:43 2004
***************
*** 384,395 ****
  long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
  	cm_req_t *reqp, cm_conn_t **connpp)
  {
! 	long code;
! 	cm_serverRef_t *tsrp;
      cm_server_t *tsp;
      long firstError = 0;
! 	int someBusy = 0, someOffline = 0, allBusy = 1, allDown = 1;
! 	long timeUsed, timeLeft, hardTimeLeft;
  #ifdef DJGPP
      struct timeval now;
  #endif /* DJGPP */        
--- 384,395 ----
  long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
  	cm_req_t *reqp, cm_conn_t **connpp)
  {
!     long code;
!     cm_serverRef_t *tsrp;
      cm_server_t *tsp;
      long firstError = 0;
!     int someBusy = 0, someOffline = 0, allBusy = 1, allDown = 1;
!     long timeUsed, timeLeft, hardTimeLeft;
  #ifdef DJGPP
      struct timeval now;
  #endif /* DJGPP */        
***************
*** 397,413 ****
      *connpp = NULL;
  
  #ifndef DJGPP
! 	timeUsed = (GetCurrentTime() - reqp->startTime) / 1000;
  #else
      gettimeofday(&now, NULL);
      timeUsed = sub_time(now, reqp->startTime) / 1000;
  #endif
          
! 	/* leave 5 seconds margin of safety */
! 	timeLeft =  ConnDeadtimeout - timeUsed - 5;
! 	hardTimeLeft = HardDeadtimeout - timeUsed - 5;
  
! 	lock_ObtainWrite(&cm_serverLock);
      for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
          tsp = tsrp->server;
          cm_GetServerNoLock(tsp);
--- 397,413 ----
      *connpp = NULL;
  
  #ifndef DJGPP
!     timeUsed = (GetCurrentTime() - reqp->startTime) / 1000;
  #else
      gettimeofday(&now, NULL);
      timeUsed = sub_time(now, reqp->startTime) / 1000;
  #endif
          
!     /* leave 5 seconds margin of safety */
!     timeLeft =  ConnDeadtimeout - timeUsed - 5;
!     hardTimeLeft = HardDeadtimeout - timeUsed - 5;
  
!     lock_ObtainWrite(&cm_serverLock);
      for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
          tsp = tsrp->server;
          cm_GetServerNoLock(tsp);
***************
*** 419,425 ****
              else if (tsrp->status == offline)
                  someOffline = 1;
              else {
! 				allBusy = 0;
                  code = cm_ConnByServer(tsp, usersp, connpp);
                  if (code == 0) {
                      cm_PutServer(tsp);
--- 419,425 ----
              else if (tsrp->status == offline)
                  someOffline = 1;
              else {
!                 allBusy = 0;
                  code = cm_ConnByServer(tsp, usersp, connpp);
                  if (code == 0) {
                      cm_PutServer(tsp);
***************
*** 439,462 ****
                  if (firstError == 0) 
                      firstError = code;
              }
! 		} 
          lock_ObtainWrite(&cm_serverLock);
          cm_PutServerNoLock(tsp);
      }   
  
! 	lock_ReleaseWrite(&cm_serverLock);
! 	if (firstError == 0) {
          if (serversp == NULL)
! 			firstError = CM_ERROR_NOSUCHVOLUME;
          else if (allDown) 
! 			firstError = CM_ERROR_ALLOFFLINE;
! 		else if (allBusy) 
! 			firstError = CM_ERROR_ALLBUSY;
! 		else
! 			firstError = CM_ERROR_TIMEDOUT;
! 	}
  
! 	osi_Log1(afsd_logp, "cm_ConnByMServers returning %x", firstError);
      return firstError;
  }
  
--- 439,462 ----
                  if (firstError == 0) 
                      firstError = code;
              }
!         } 
          lock_ObtainWrite(&cm_serverLock);
          cm_PutServerNoLock(tsp);
      }   
  
!     lock_ReleaseWrite(&cm_serverLock);
!     if (firstError == 0) {
          if (serversp == NULL)
!             firstError = CM_ERROR_NOSUCHVOLUME;
          else if (allDown) 
!             firstError = CM_ERROR_ALLOFFLINE;
!         else if (allBusy) 
!             firstError = CM_ERROR_ALLBUSY;
!         else
!             firstError = CM_ERROR_TIMEDOUT;
!     }
  
!     osi_Log1(afsd_logp, "cm_ConnByMServers returning %x", firstError);
      return firstError;
  }
  
Index: openafs/src/WINNT/afsd/cm_freelance.c
diff -c openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.2 openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.3
*** openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.2	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_freelance.c	Fri Nov  5 14:21:44 2004
***************
*** 73,78 ****
--- 73,117 ----
          }
      }
  }
+ 
+ void cm_FreelanceSymlinkChangeNotifier(void * parmp) {
+     HANDLE hFreelanceSymlinkChangeEvent = 0;
+     HKEY   hkFreelance = 0;
+ 
+     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                       "SOFTWARE\\OpenAFS\\Client\\Freelance\\Symlinks",
+                       0,
+                       KEY_NOTIFY,
+                       &hkFreelance) == ERROR_SUCCESS) {
+ 
+         hFreelanceSymlinkChangeEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+         if (hFreelanceSymlinkChangeEvent == NULL) {
+             RegCloseKey(hkFreelance);
+             return;
+         }
+     }
+ 
+     while ( TRUE ) {
+     /* check hFreelanceSymlinkChangeEvent to see if it is set. 
+      * if so, call cm_noteLocalMountPointSymlinkChange()
+      */
+         if (RegNotifyChangeKeyValue( hkFreelance,   /* hKey */
+                                      FALSE,         /* bWatchSubtree */
+                                      REG_NOTIFY_CHANGE_LAST_SET, /* dwNotifyFilter */
+                                      hFreelanceSymlinkChangeEvent, /* hEvent */
+                                      TRUE          /* fAsynchronous */
+                                      ) != ERROR_SUCCESS) {
+             RegCloseKey(hkFreelance);
+             CloseHandle(hFreelanceSymlinkChangeEvent);
+             return;
+         }
+ 
+         if (WaitForSingleObject(hFreelanceSymlinkChangeEvent, INFINITE) == WAIT_OBJECT_0)
+         {
+             cm_noteLocalMountPointChange();
+         }
+     }
+ }
  #endif
  
  void cm_InitFreelance() {
***************
*** 98,110 ****
                            NULL, 0, &lpid, "cm_FreelanceChangeNotifier");
      osi_assert(phandle != NULL);
      thrd_CloseHandle(phandle);
  #endif
  }
  
  /* yj: Initialization of the fake root directory */
  /* to be called while holding freelance lock unless during init. */
  void cm_InitFakeRootDir() {
- 	
      int i, t1, t2;
      char* currentPos;
      int noChunks;
--- 137,153 ----
                            NULL, 0, &lpid, "cm_FreelanceChangeNotifier");
      osi_assert(phandle != NULL);
      thrd_CloseHandle(phandle);
+ 
+     phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceSymlinkChangeNotifier,
+                           NULL, 0, &lpid, "cm_FreelanceSymlinkChangeNotifier");
+     osi_assert(phandle != NULL);
+     thrd_CloseHandle(phandle);
  #endif
  }
  
  /* yj: Initialization of the fake root directory */
  /* to be called while holding freelance lock unless during init. */
  void cm_InitFakeRootDir() {
      int i, t1, t2;
      char* currentPos;
      int noChunks;
***************
*** 398,409 ****
      long code;
      char rootCellName[256];
  #if !defined(DJGPP)
!     HKEY hkFreelance = 0;
      DWORD dwType, dwSize;
!     DWORD dwMountPoints;
      DWORD dwIndex;
      FILETIME ftLastWriteTime;
-     afs_uint32 unixTime;
  #endif
  
  #if !defined(DJGPP)
--- 441,452 ----
      long code;
      char rootCellName[256];
  #if !defined(DJGPP)
!     HKEY hkFreelance = 0, hkFreelanceSymlinks = 0;
      DWORD dwType, dwSize;
!     DWORD dwMountPoints = 0;
      DWORD dwIndex;
+     DWORD dwSymlinks = 0;
      FILETIME ftLastWriteTime;
  #endif
  
  #if !defined(DJGPP)
***************
*** 440,448 ****
              dwMountPoints = 2;
          }
  
          // get the number of entries there are from the first line
          // that we read
!         cm_noLocalMountPoints = dwMountPoints;
  
          // create space to store the local mount points
          cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
--- 483,516 ----
              dwMountPoints = 2;
          }
  
+         if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                           "SOFTWARE\\OpenAFS\\Client\\Freelance\\Symlinks",
+                           0,
+                           NULL,
+                           REG_OPTION_NON_VOLATILE,
+                           KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                           NULL,
+                           &hkFreelanceSymlinks,
+                           NULL) == ERROR_SUCCESS) {
+ 
+             RegQueryInfoKey( hkFreelanceSymlinks,
+                              NULL,  /* lpClass */
+                              NULL,  /* lpcClass */
+                              NULL,  /* lpReserved */
+                              NULL,  /* lpcSubKeys */
+                              NULL,  /* lpcMaxSubKeyLen */
+                              NULL,  /* lpcMaxClassLen */
+                              &dwSymlinks, /* lpcValues */
+                              NULL,  /* lpcMaxValueNameLen */
+                              NULL,  /* lpcMaxValueLen */
+                              NULL,  /* lpcbSecurityDescriptor */
+                              NULL   /* lpftLastWriteTime */
+                              );
+         }
+ 
          // get the number of entries there are from the first line
          // that we read
!         cm_noLocalMountPoints = dwMountPoints + dwSymlinks;
  
          // create space to store the local mount points
          cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
***************
*** 478,491 ****
                  cm_noLocalMountPoints--;
                  continue;
              }
              aLocalMountPoint->namep=malloc(t-line+1);
              strncpy(aLocalMountPoint->namep, line, t-line);
              aLocalMountPoint->namep[t-line] = '\0';
  		
!             /* copy the mount point string without the trailing dot */
              aLocalMountPoint->mountPointStringp=malloc(strlen(t));
! 			strncpy(aLocalMountPoint->mountPointStringp, t, strlen(t)-1);
! 			aLocalMountPoint->mountPointStringp[strlen(t)-1] = '\0';
      
              osi_Log2(afsd_logp,"found mount point: name %s, string %s",
                        osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
--- 546,561 ----
                  cm_noLocalMountPoints--;
                  continue;
              }
+ 
+             aLocalMountPoint->fileType = CM_SCACHETYPE_MOUNTPOINT;
              aLocalMountPoint->namep=malloc(t-line+1);
              strncpy(aLocalMountPoint->namep, line, t-line);
              aLocalMountPoint->namep[t-line] = '\0';
  		
!             /* copy the mount point string */
              aLocalMountPoint->mountPointStringp=malloc(strlen(t));
!             strncpy(aLocalMountPoint->mountPointStringp, t, strlen(t)-1);
!             aLocalMountPoint->mountPointStringp[strlen(t)-1] = '\0';
      
              osi_Log2(afsd_logp,"found mount point: name %s, string %s",
                        osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
***************
*** 494,499 ****
--- 564,611 ----
              aLocalMountPoint++;
          }
  
+         for ( dwIndex = 0 ; dwIndex < dwSymlinks; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelanceSymlinks, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             /* find the trailing dot; null terminate after it */
+             t2 = strrchr(line, '.');
+             if (t2)
+                 *(t2+1) = '\0';
+ 
+             // line is not empty, so let's parse it
+             t = strchr(line, ':');
+ 
+             // make sure that there is a ':' separator in the line
+             if (!t) {
+                 afsi_log("error occurred while parsing symlink entry: no ':' separator in line %d", dwIndex);
+                 fprintf(stderr, "error occurred while parsing symlink entry: no ':' separator in line %d", dwIndex);
+                 cm_noLocalMountPoints--;
+                 continue;
+             }
+ 
+             aLocalMountPoint->fileType = CM_SCACHETYPE_SYMLINK;
+             aLocalMountPoint->namep=malloc(t-line+1);
+             strncpy(aLocalMountPoint->namep, line, t-line);
+             aLocalMountPoint->namep[t-line] = '\0';
+ 		
+             /* copy the symlink string */
+             aLocalMountPoint->mountPointStringp=malloc(strlen(t)-1);
+             strncpy(aLocalMountPoint->mountPointStringp, t+1, strlen(t)-2);
+             aLocalMountPoint->mountPointStringp[strlen(t)-2] = '\0';
+     
+             osi_Log2(afsd_logp,"found symlink: name %s, string %s",
+                       osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
+                       osi_LogSaveString(afsd_logp,aLocalMountPoint->mountPointStringp));
+ 
+             aLocalMountPoint++;
+         }
+ 
+         if ( hkFreelanceSymlinks )
+             RegCloseKey( hkFreelanceSymlinks );
          RegCloseKey(hkFreelance);
          return 0;
      }
***************
*** 625,634 ****
      return cm_noLocalMountPoints;
  }
  
- cm_localMountPoint_t* cm_getLocalMountPoint(int vnode) {
-     return 0;
- }
- 
  long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp)
  {
      FILE *fp;
--- 737,742 ----
***************
*** 688,709 ****
                           );
  
          if (rw)
!             sprintf(line, "%s%%%s:%s\n", filename, fullname, volume);
          else
!             sprintf(line, "%s#%s:%s\n", filename, fullname, volume);
  
          /* If we are adding a new value, there must be an unused name
           * within the range 0 to dwMountPoints 
           */
          for ( dwIndex = 0; dwIndex <= dwMountPoints; dwIndex++ ) {
              char szIndex[16];
              sprintf(szIndex, "%d", dwIndex);
!             if (RegQueryValueEx( hkFreelance, szIndex, 0, &dwType, NULL, &dwSize) != ERROR_SUCCESS) {
                  /* found an unused value */
                  dwType = REG_SZ;
                  dwSize = strlen(line) + 1;
                  RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
                  break;
              }
          }
          RegCloseKey(hkFreelance);
--- 796,830 ----
                           );
  
          if (rw)
!             sprintf(line, "%s%%%s:%s", filename, fullname, volume);
          else
!             sprintf(line, "%s#%s:%s", filename, fullname, volume);
  
          /* If we are adding a new value, there must be an unused name
           * within the range 0 to dwMountPoints 
           */
          for ( dwIndex = 0; dwIndex <= dwMountPoints; dwIndex++ ) {
              char szIndex[16];
+             char szMount[1024];
+ 
+             dwSize = sizeof(szMount);
              sprintf(szIndex, "%d", dwIndex);
!             if (RegQueryValueEx( hkFreelance, szIndex, 0, &dwType, szMount, &dwSize) != ERROR_SUCCESS) {
                  /* found an unused value */
                  dwType = REG_SZ;
                  dwSize = strlen(line) + 1;
                  RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
                  break;
+             } else {
+ 				int len = strlen(filename);
+ 				if ( dwType == REG_SZ && !strncmp(filename, szMount, len) && 
+ 					(szMount[len] == '%' || szMount[len] == '#')) {
+                     /* Replace the existing value */
+                     dwType = REG_SZ;
+                     dwSize = strlen(line) + 1;
+                     RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
+                     break;
+                 }
              }
          }
          RegCloseKey(hkFreelance);
***************
*** 847,850 ****
--- 968,1127 ----
      return 0;
  }
  
+ long cm_FreelanceAddSymlink(char *filename, char *destination, cm_fid_t *fidp)
+ {
+     FILE *fp;
+     char hfile[120];
+     char line[512];
+     char fullname[200];
+     int n;
+     int alias = 0;
+ #if !defined(DJGPP)
+     HKEY hkFreelanceSymlinks = 0;
+     DWORD dwType, dwSize;
+     DWORD dwSymlinks;
+     DWORD dwIndex;
+ #endif
+ 
+     /* before adding, verify the cell name; if it is not a valid cell,
+        don't add the mount point.
+        allow partial matches as a means of poor man's alias. */
+     /* major performance issue? */
+     osi_Log2(afsd_logp,"Freelance Add Symlink request: filename=%s destination=%s",
+               osi_LogSaveString(afsd_logp,filename), 
+               osi_LogSaveString(afsd_logp,destination));
+     
+     lock_ObtainMutex(&cm_Freelance_Lock);
+ 
+ #if !defined(DJGPP)
+     if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
+                         "SOFTWARE\\OpenAFS\\Client\\Freelance\\Symlinks",
+                         0,
+                         NULL,
+                         REG_OPTION_NON_VOLATILE,
+                         KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                         NULL,
+                         &hkFreelanceSymlinks,
+                         NULL) == ERROR_SUCCESS) {
+ 
+         RegQueryInfoKey( hkFreelanceSymlinks,
+                          NULL,  /* lpClass */
+                          NULL,  /* lpcClass */
+                          NULL,  /* lpReserved */
+                          NULL,  /* lpcSubKeys */
+                          NULL,  /* lpcMaxSubKeyLen */
+                          NULL,  /* lpcMaxClassLen */
+                          &dwSymlinks, /* lpcValues */
+                          NULL,  /* lpcMaxValueNameLen */
+                          NULL,  /* lpcMaxValueLen */
+                          NULL,  /* lpcbSecurityDescriptor */
+                          NULL   /* lpftLastWriteTime */
+                          );
+ 
+         sprintf(line, "%s:%s.", filename, destination);
+ 
+         /* If we are adding a new value, there must be an unused name
+          * within the range 0 to dwSymlinks 
+          */
+         for ( dwIndex = 0; dwIndex <= dwSymlinks; dwIndex++ ) {
+             char szIndex[16];
+             char szLink[1024];
+ 
+             dwSize = sizeof(szLink);
+             sprintf(szIndex, "%d", dwIndex);
+             if (RegQueryValueEx( hkFreelanceSymlinks, szIndex, 0, &dwType, szLink, &dwSize) != ERROR_SUCCESS) {
+                 /* found an unused value */
+                 dwType = REG_SZ;
+                 dwSize = strlen(line) + 1;
+                 RegSetValueEx( hkFreelanceSymlinks, szIndex, 0, dwType, line, dwSize);
+                 break;
+             } else {
+ 				int len = strlen(filename);
+ 				if ( dwType == REG_SZ && !strncmp(filename, szLink, len) && szLink[len] == ':') {
+                     /* Replace the existing value */
+                     dwType = REG_SZ;
+                     dwSize = strlen(line) + 1;
+                     RegSetValueEx( hkFreelanceSymlinks, szIndex, 0, dwType, line, dwSize);
+                     break;
+                 }
+             }
+         }
+         RegCloseKey(hkFreelanceSymlinks);
+     } 
+ #endif
+     lock_ReleaseMutex(&cm_Freelance_Lock);
+ 
+     /* cm_reInitLocalMountPoints(); */
+     if (fidp) {
+         fidp->unique = 1;
+         fidp->vnode = cm_noLocalMountPoints + 1;   /* vnode value of last mt pt */
+     }
+     cm_noteLocalMountPointChange();
+     return 0;
+ }
+ 
+ long cm_FreelanceRemoveSymlink(char *toremove)
+ {
+     int i, n;
+     char* cp;
+     char line[512];
+     char shortname[200];
+     char hfile[120], hfile2[120];
+     FILE *fp1, *fp2;
+     int found=0;
+ #if !defined(DJGPP)
+     HKEY hkFreelanceSymlinks = 0;
+     DWORD dwType, dwSize;
+     DWORD dwSymlinks;
+     DWORD dwIndex;
+ #endif
+ 
+     lock_ObtainMutex(&cm_Freelance_Lock);
+ 
+ 
+ #if !defined(DJGPP)
+     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                       "SOFTWARE\\OpenAFS\\Client\\Freelance\\Symlinks",
+                       0,
+                       KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
+                       &hkFreelanceSymlinks) == ERROR_SUCCESS) {
+ 
+         RegQueryInfoKey( hkFreelanceSymlinks,
+                          NULL,  /* lpClass */
+                          NULL,  /* lpcClass */
+                          NULL,  /* lpReserved */
+                          NULL,  /* lpcSubKeys */
+                          NULL,  /* lpcMaxSubKeyLen */
+                          NULL,  /* lpcMaxClassLen */
+                          &dwSymlinks, /* lpcValues */
+                          NULL,  /* lpcMaxValueNameLen */
+                          NULL,  /* lpcMaxValueLen */
+                          NULL,  /* lpcbSecurityDescriptor */
+                          NULL   /* lpftLastWriteTime */
+                          );
+ 
+         for ( dwIndex = 0; dwIndex < dwSymlinks; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelanceSymlinks, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             cp=strchr(line, ':');
+             memcpy(shortname, line, cp-line);
+             shortname[cp-line]=0;
+ 
+             if (!strcmp(shortname, toremove)) {
+                 RegDeleteValue( hkFreelanceSymlinks, szValueName );
+                 break;
+             }
+         }
+         RegCloseKey(hkFreelanceSymlinks);
+     }
+ #endif
+     
+     lock_ReleaseMutex(&cm_Freelance_Lock);
+     cm_noteLocalMountPointChange();
+     return 0;
+ }
  #endif /* AFS_FREELANCE_CLIENT */
Index: openafs/src/WINNT/afsd/cm_freelance.h
diff -c openafs/src/WINNT/afsd/cm_freelance.h:1.6.2.1 openafs/src/WINNT/afsd/cm_freelance.h:1.6.2.2
*** openafs/src/WINNT/afsd/cm_freelance.h:1.6.2.1	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_freelance.h	Fri Nov  5 14:21:44 2004
***************
*** 3,21 ****
  
  
  typedef struct cm_localMountPoint {
! 	char* namep;
! 	char* mountPointStringp;
! 	struct cm_localMountPoint* next;
  } cm_localMountPoint_t;
  
  extern int cm_getNoLocalMountPoints();
  extern long cm_InitLocalMountPoints();
  extern int cm_getLocalMountPointChange();
  extern int cm_reInitLocalMountPoints();
- extern cm_localMountPoint_t* cm_getLocalMountPoint(int vnode);
  extern void cm_InitFreelance();
  extern long cm_FreelanceRemoveMount(char *toremove);
  extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp);
  extern int cm_clearLocalMountPointChange();
  extern int cm_FakeRootFid(cm_fid_t *fidp);
  
--- 3,23 ----
  
  
  typedef struct cm_localMountPoint {
!     char*                       namep;
!     char*                       mountPointStringp;
!     unsigned int                fileType;
!     struct cm_localMountPoint*  next;
  } cm_localMountPoint_t;
  
  extern int cm_getNoLocalMountPoints();
  extern long cm_InitLocalMountPoints();
  extern int cm_getLocalMountPointChange();
  extern int cm_reInitLocalMountPoints();
  extern void cm_InitFreelance();
  extern long cm_FreelanceRemoveMount(char *toremove);
  extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp);
+ extern long cm_FreelanceRemoveSymlink(char *toremove);
+ extern long cm_FreelanceAddSymlink(char *filename, char *destination, cm_fid_t *fidp);
  extern int cm_clearLocalMountPointChange();
  extern int cm_FakeRootFid(cm_fid_t *fidp);
  
Index: openafs/src/WINNT/afsd/cm_ioctl.c
diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.4 openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.5
*** openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.4	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_ioctl.c	Fri Nov  5 14:21:44 2004
***************
*** 458,470 ****
      code = cm_ParseIoctlPath(ioctlp, userp, &req, &scp);
      if (code) return code;
  
!     cellp = cm_FindCellByID(scp->fid.cell);
!     if (cellp) {
!         strcpy(ioctlp->outDatap, cellp->namep);
          ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
          code = 0;
      }
-     else code = CM_ERROR_NOSUCHCELL;
  
      cm_ReleaseSCache(scp);
      return code;
--- 458,483 ----
      code = cm_ParseIoctlPath(ioctlp, userp, &req, &scp);
      if (code) return code;
  
! #ifdef AFS_FREELANCE_CLIENT
!     if ( cm_freelanceEnabled && 
!          scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
!          scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
!          scp->fid.vnode==0x1 && scp->fid.unique==0x1 ) {
!         strcpy(ioctlp->outDatap, "Freelance.Local.Root");
          ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
          code = 0;
+     } else 
+ #endif /* AFS_FREELANCE_CLIENT */
+     {
+         cellp = cm_FindCellByID(scp->fid.cell);
+         if (cellp) {
+             strcpy(ioctlp->outDatap, cellp->namep);
+             ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
+             code = 0;
+         }
+         else 
+             code = CM_ERROR_NOSUCHCELL;
      }
  
      cm_ReleaseSCache(scp);
      return code;
***************
*** 983,988 ****
--- 996,1002 ----
      /* print trace */
      if (inValue & 8) {
          afsd_ForceTrace(FALSE);
+         buf_ForceTrace(FALSE);
      }
          
      if (inValue & 2) {
***************
*** 1213,1218 ****
--- 1227,1233 ----
           * do lookups of @sys entries and thinks it can trust them */
          /* privs ok, store the entry, ... */
          strcpy(cm_sysName, inname);
+ 		strcpy(cm_sysNameList[0], inname);
          if (setSysName > 1) {       /* ... or list */
              cp = ioctlp->inDatap;
              for (count = 1; count < setSysName; ++count) {
***************
*** 1220,1226 ****
                      osi_panic("cm_IoctlSysName: no cm_sysNameList entry to write\n",
                                 __FILE__, __LINE__);
                  t = strlen(cp);
!                 memcpy(cm_sysNameList[count], cp, t + 1);  /* include null */
                  cp += t + 1;
              }
          }
--- 1235,1241 ----
                      osi_panic("cm_IoctlSysName: no cm_sysNameList entry to write\n",
                                 __FILE__, __LINE__);
                  t = strlen(cp);
!                 strcpy(cm_sysNameList[count], cp);
                  cp += t + 1;
              }
          }
***************
*** 1509,1514 ****
--- 1524,1549 ----
  
      cp = ioctlp->inDatap;		/* contents of link */
  
+ #ifdef AFS_FREELANCE_CLIENT
+     if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
+         /* we are adding the symlink to the root dir., so call
+          * the freelance code to do the add. */
+         if (cp[0] == cp[1] && cp[1] == '\\' && 
+             !_strnicmp(cm_NetbiosName,cp+2,strlen(cm_NetbiosName))) 
+         {
+             /* skip \\AFS\ or \\AFS\all\ */
+             char * p;
+             p = cp + 2 + strlen(cm_NetbiosName) + 1;
+             if ( !_strnicmp("all", p, 3) )
+                 p += 4;
+             cp = p;
+         }
+         osi_Log0(afsd_logp,"IoctlCreateSymlink within Freelance root dir");
+         code = cm_FreelanceAddSymlink(leaf, cp, NULL);
+         return code;
+     }
+ #endif
+ 
      /* Create symlink with mode 0755. */
      tattr.mask = CM_ATTRMASK_UNIXMODEBITS;
      tattr.unixModeBits = 0755;
***************
*** 1618,1623 ****
--- 1653,1668 ----
  
      cp = ioctlp->inDatap;
  
+ #ifdef AFS_FREELANCE_CLIENT
+     if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
+         /* we are adding the mount point to the root dir., so call
+          * the freelance code to do the add. */
+         osi_Log0(afsd_logp,"IoctlDeletelink from Freelance root dir");
+         code = cm_FreelanceRemoveSymlink(cp);
+         return code;
+     }
+ #endif
+ 
      code = cm_Lookup(dscp, cp, CM_FLAG_NOMOUNTCHASE, userp, &req, &scp);
          
      /* if something went wrong, bail out now */
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.14.2.1 openafs/src/WINNT/afsd/cm_scache.c:1.14.2.2
*** openafs/src/WINNT/afsd/cm_scache.c:1.14.2.1	Tue Aug 17 00:28:39 2004
--- openafs/src/WINNT/afsd/cm_scache.c	Fri Nov  5 14:21:44 2004
***************
*** 52,61 ****
  /* must be called with cm_scacheLock write-locked! */
  void cm_AdjustLRU(cm_scache_t *scp)
  {
! 	if (scp == cm_scacheLRULastp)
! 		cm_scacheLRULastp = (cm_scache_t *) osi_QPrev(&scp->q);
! 	osi_QRemove((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
! 	osi_QAdd((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
      if (!cm_scacheLRULastp) 
          cm_scacheLRULastp = scp;
  }
--- 52,61 ----
  /* must be called with cm_scacheLock write-locked! */
  void cm_AdjustLRU(cm_scache_t *scp)
  {
!     if (scp == cm_scacheLRULastp)
!         cm_scacheLRULastp = (cm_scache_t *) osi_QPrev(&scp->q);
!     osi_QRemove((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
!     osi_QAdd((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
      if (!cm_scacheLRULastp) 
          cm_scacheLRULastp = scp;
  }
***************
*** 65,182 ****
   */
  cm_scache_t *cm_GetNewSCache(void)
  {
! 	cm_scache_t *scp;
!         int i;
!         cm_scache_t **lscpp;
!         cm_scache_t *tscp;
! 
! 	if (cm_currentSCaches >= cm_maxSCaches) {
!      	        for (scp = cm_scacheLRULastp;
!      		     scp;
!      		     scp = (cm_scache_t *) osi_QPrev(&scp->q)) {
              if (scp->refCount == 0) 
                  break;
! 	        }
                  
!                 if (scp) {
! 			/* we found an entry, so return it */
!                         if (scp->flags & CM_SCACHEFLAG_INHASH) {
! 				/* hash it out first */
!                                 i = CM_SCACHE_HASH(&scp->fid);
! 				lscpp = &cm_hashTablep[i];
! 				for (tscp = *lscpp;
!      				     tscp;
!      				     lscpp = &tscp->nextp, tscp = *lscpp) {
                      if (tscp == scp) 
                          break;
!                                 }
!                                 osi_assertx(tscp, "afsd: scache hash screwup");
!                                 *lscpp = scp->nextp;
!                                 scp->flags &= ~CM_SCACHEFLAG_INHASH;
!                         }
! 
! 			/* look for things that shouldn't still be set */
!                         osi_assert(scp->bufWritesp == NULL);
!                         osi_assert(scp->bufReadsp == NULL);
! 
! 			/* invalidate so next merge works fine;
! 			 * also initialize some flags */
!                         scp->flags &= ~(CM_SCACHEFLAG_STATD
! 					| CM_SCACHEFLAG_RO
! 					| CM_SCACHEFLAG_PURERO
! 					| CM_SCACHEFLAG_OVERQUOTA
! 					| CM_SCACHEFLAG_OUTOFSPACE);
!                         scp->serverModTime = 0;
!                         scp->dataVersion = 0;
! 			scp->bulkStatProgress = hzero;
  
!                         /* discard callback */
              if (scp->cbServerp) {
                  cm_PutServer(scp->cbServerp);
!                         scp->cbServerp = NULL;
              }
!                         scp->cbExpires = 0;
  
! 			/* remove from dnlc */
! 			cm_dnlcPurgedp(scp);
! 			cm_dnlcPurgevp(scp);
! 
! 			/* discard cached status; if non-zero, Close
! 			 * tried to store this to server but failed */
! 			scp->mask = 0;
! 
! 			/* drop held volume ref */
! 			if (scp->volp) {
! 				cm_PutVolume(scp->volp);
! 				scp->volp = NULL;
! 			}
! 
!                         /* discard symlink info */
!                         if (scp->mountPointStringp) {
!                         	free(scp->mountPointStringp);
!                                 scp->mountPointStringp = NULL;
! 			}
! 			if (scp->mountRootFidp) {
! 				free(scp->mountRootFidp);
! 				scp->mountRootFidp = NULL;
! 			}
! 			if (scp->dotdotFidp) {
! 				free(scp->dotdotFidp);
! 				scp->dotdotFidp = NULL;
! 			}
!                         
! 			/* not locked, but there can be no references to this guy
!                          * while we hold the global refcount lock.
!                          */
!                         cm_FreeAllACLEnts(scp);
!                         
!                         /* now remove from the LRU queue and put it back at the
!                          * head of the LRU queue.
!                          */
! 			cm_AdjustLRU(scp);
! 			
!                         /* and we're done */
!                         return scp;
!                 }
! 	}
          
!         /* if we get here, we should allocate a new scache entry.  We either are below
!          * quota or we have a leak and need to allocate a new one to avoid panicing.
!          */
!         scp = malloc(sizeof(*scp));
!         memset(scp, 0, sizeof(*scp));
! 	lock_InitializeMutex(&scp->mx, "cm_scache_t mutex");
!         lock_InitializeRWLock(&scp->bufCreateLock, "cm_scache_t bufCreateLock");
! 	
!         /* and put it in the LRU queue */
!         osi_QAdd((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
      if (!cm_scacheLRULastp) 
          cm_scacheLRULastp = scp;
!         cm_currentSCaches++;
! 	cm_dnlcPurgedp(scp); /* make doubly sure that this is not in dnlc */
! 	cm_dnlcPurgevp(scp); 
!         return scp;
! }
  
  /* like strcmp, only for fids */
  int cm_FidCmp(cm_fid_t *ap, cm_fid_t *bp)
--- 65,182 ----
   */
  cm_scache_t *cm_GetNewSCache(void)
  {
!     cm_scache_t *scp;
!     int i;
!     cm_scache_t **lscpp;
!     cm_scache_t *tscp;
! 
!     if (cm_currentSCaches >= cm_maxSCaches) {
!         for (scp = cm_scacheLRULastp;
!               scp;
!               scp = (cm_scache_t *) osi_QPrev(&scp->q)) {
              if (scp->refCount == 0) 
                  break;
!         }
                  
!         if (scp) {
!             /* we found an entry, so return it */
!             if (scp->flags & CM_SCACHEFLAG_INHASH) {
!                 /* hash it out first */
!                 i = CM_SCACHE_HASH(&scp->fid);
!                 lscpp = &cm_hashTablep[i];
!                 for (tscp = *lscpp;
!                       tscp;
!                       lscpp = &tscp->nextp, tscp = *lscpp) {
                      if (tscp == scp) 
                          break;
!                 }
!                 osi_assertx(tscp, "afsd: scache hash screwup");
!                 *lscpp = scp->nextp;
!                 scp->flags &= ~CM_SCACHEFLAG_INHASH;
!             }
! 
!             /* look for things that shouldn't still be set */
!             osi_assert(scp->bufWritesp == NULL);
!             osi_assert(scp->bufReadsp == NULL);
! 
!             /* invalidate so next merge works fine;
!             * also initialize some flags */
!             scp->flags &= ~(CM_SCACHEFLAG_STATD
!                              | CM_SCACHEFLAG_RO
!                              | CM_SCACHEFLAG_PURERO
!                              | CM_SCACHEFLAG_OVERQUOTA
!                              | CM_SCACHEFLAG_OUTOFSPACE);
!             scp->serverModTime = 0;
!             scp->dataVersion = 0;
!             scp->bulkStatProgress = hzero;
  
!             /* discard callback */
              if (scp->cbServerp) {
                  cm_PutServer(scp->cbServerp);
!                 scp->cbServerp = NULL;
              }
!             scp->cbExpires = 0;
  
!             /* remove from dnlc */
!             cm_dnlcPurgedp(scp);
!             cm_dnlcPurgevp(scp);
! 
!             /* discard cached status; if non-zero, Close
!              * tried to store this to server but failed */
!             scp->mask = 0;
! 
!             /* drop held volume ref */
!             if (scp->volp) {
!                 cm_PutVolume(scp->volp);
!                 scp->volp = NULL;
!             }
! 
!             /* discard symlink info */
!             if (scp->mountPointStringp) {
!                 free(scp->mountPointStringp);
!                 scp->mountPointStringp = NULL;
!             }
!             if (scp->mountRootFidp) {
!                 free(scp->mountRootFidp);
!                 scp->mountRootFidp = NULL;
!             }
!             if (scp->dotdotFidp) {
!                 free(scp->dotdotFidp);
!                 scp->dotdotFidp = NULL;
!             }
! 
!             /* not locked, but there can be no references to this guy
!              * while we hold the global refcount lock.
!              */
!             cm_FreeAllACLEnts(scp);
! 
!             /* now remove from the LRU queue and put it back at the
!              * head of the LRU queue.
!              */
!             cm_AdjustLRU(scp);
! 
!             /* and we're done */
!             return scp;
!         }
!     }
          
!     /* if we get here, we should allocate a new scache entry.  We either are below
!      * quota or we have a leak and need to allocate a new one to avoid panicing.
!      */
!     scp = malloc(sizeof(*scp));
!     memset(scp, 0, sizeof(*scp));
!     lock_InitializeMutex(&scp->mx, "cm_scache_t mutex");
!     lock_InitializeRWLock(&scp->bufCreateLock, "cm_scache_t bufCreateLock");
! 
!     /* and put it in the LRU queue */
!     osi_QAdd((osi_queue_t **) &cm_scacheLRUFirstp, &scp->q);
      if (!cm_scacheLRULastp) 
          cm_scacheLRULastp = scp;
!     cm_currentSCaches++;
!     cm_dnlcPurgedp(scp); /* make doubly sure that this is not in dnlc */
!     cm_dnlcPurgevp(scp); 
!     return scp;
! }       
  
  /* like strcmp, only for fids */
  int cm_FidCmp(cm_fid_t *ap, cm_fid_t *bp)
***************
*** 189,266 ****
          return 1;
      if (ap->cell != bp->cell) 
          return 1;
!         return 0;
  }
  
  void cm_fakeSCacheInit()
  {
! 	memset(&cm_fakeSCache, 0, sizeof(cm_fakeSCache));
! 	lock_InitializeMutex(&cm_fakeSCache.mx, "cm_scache_t mutex");
! 	cm_fakeSCache.cbServerp = (struct cm_server *)(-1);
! 	/* can leave clientModTime at 0 */
! 	cm_fakeSCache.fileType = CM_SCACHETYPE_FILE;
! 	cm_fakeSCache.unixModeBits = 0777;
! 	cm_fakeSCache.length.LowPart = 1000;
! 	cm_fakeSCache.linkCount = 1;
! }
  
  void cm_InitSCache(long maxSCaches)
  {
! 	static osi_once_t once;
          
!         if (osi_Once(&once)) {
! 		lock_InitializeRWLock(&cm_scacheLock, "cm_scacheLock");
!                 cm_hashTableSize = maxSCaches / 2;
!                 cm_hashTablep = malloc(sizeof(cm_scache_t *) * cm_hashTableSize);
!                 memset(cm_hashTablep, 0, sizeof(cm_scache_t *) * cm_hashTableSize);
! 		cm_allFileLocks = NULL;
!                 cm_currentSCaches = 0;
!                 cm_maxSCaches = maxSCaches;
! 		cm_fakeSCacheInit();
! 		cm_dnlcInit();
! 		osi_EndOnce(&once);
!         }
  }
  
  /* version that doesn't bother creating the entry if we don't find it */
  cm_scache_t *cm_FindSCache(cm_fid_t *fidp)
  {
! 	long hash;
!         cm_scache_t *scp;
!         
!         hash = CM_SCACHE_HASH(fidp);
          
! 	osi_assert(fidp->cell != 0);
  
!         lock_ObtainWrite(&cm_scacheLock);
! 	for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
! 		if (cm_FidCmp(fidp, &scp->fid) == 0) {
! 			scp->refCount++;
!                         cm_AdjustLRU(scp);
!                         lock_ReleaseWrite(&cm_scacheLock);
! 			return scp;
!                 }
          }
!         lock_ReleaseWrite(&cm_scacheLock);
!         return NULL;
  }
  
  long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
! 	cm_req_t *reqp)
  {
! 	long hash;
      cm_scache_t *scp;
      long code;
      cm_volume_t *volp = 0;
      cm_cell_t *cellp;
      char* mp = 0;
! 	int special; // yj: boolean variable to test if file is on root.afs
! 	int isRoot;
      extern cm_fid_t cm_rootFid;
          
      hash = CM_SCACHE_HASH(fidp);
          
! 	osi_assert(fidp->cell != 0);
  
      if (fidp->cell== cm_rootFid.cell && 
           fidp->volume==cm_rootFid.volume &&
--- 189,266 ----
          return 1;
      if (ap->cell != bp->cell) 
          return 1;
!     return 0;
  }
  
  void cm_fakeSCacheInit()
  {
!     memset(&cm_fakeSCache, 0, sizeof(cm_fakeSCache));
!     lock_InitializeMutex(&cm_fakeSCache.mx, "cm_scache_t mutex");
!     cm_fakeSCache.cbServerp = (struct cm_server *)(-1);
!     /* can leave clientModTime at 0 */
!     cm_fakeSCache.fileType = CM_SCACHETYPE_FILE;
!     cm_fakeSCache.unixModeBits = 0777;
!     cm_fakeSCache.length.LowPart = 1000;
!     cm_fakeSCache.linkCount = 1;
! }       
  
  void cm_InitSCache(long maxSCaches)
  {
!     static osi_once_t once;
          
!     if (osi_Once(&once)) {
!         lock_InitializeRWLock(&cm_scacheLock, "cm_scacheLock");
!         cm_hashTableSize = maxSCaches / 2;
!         cm_hashTablep = malloc(sizeof(cm_scache_t *) * cm_hashTableSize);
!         memset(cm_hashTablep, 0, sizeof(cm_scache_t *) * cm_hashTableSize);
!         cm_allFileLocks = NULL;
!         cm_currentSCaches = 0;
!         cm_maxSCaches = maxSCaches;
!         cm_fakeSCacheInit();
!         cm_dnlcInit();
!         osi_EndOnce(&once);
!     }
  }
  
  /* version that doesn't bother creating the entry if we don't find it */
  cm_scache_t *cm_FindSCache(cm_fid_t *fidp)
  {
!     long hash;
!     cm_scache_t *scp;
! 
!     hash = CM_SCACHE_HASH(fidp);
          
!     osi_assert(fidp->cell != 0);
  
!     lock_ObtainWrite(&cm_scacheLock);
!     for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!         if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             scp->refCount++;
!             cm_AdjustLRU(scp);
!             lock_ReleaseWrite(&cm_scacheLock);
!             return scp;
          }
!     }
!     lock_ReleaseWrite(&cm_scacheLock);
!     return NULL;
  }
  
  long cm_GetSCache(cm_fid_t *fidp, cm_scache_t **outScpp, cm_user_t *userp,
!                   cm_req_t *reqp)
  {
!     long hash;
      cm_scache_t *scp;
      long code;
      cm_volume_t *volp = 0;
      cm_cell_t *cellp;
      char* mp = 0;
!     int special; // yj: boolean variable to test if file is on root.afs
!     int isRoot;
      extern cm_fid_t cm_rootFid;
          
      hash = CM_SCACHE_HASH(fidp);
          
!     osi_assert(fidp->cell != 0);
  
      if (fidp->cell== cm_rootFid.cell && 
           fidp->volume==cm_rootFid.volume &&
***************
*** 269,360 ****
          osi_Log0(afsd_logp,"cm_getSCache called with root cell/volume and vnode=0 and unique=0");
      }
  
! 	// yj: check if we have the scp, if so, we don't need
! 	// to do anything else
      lock_ObtainWrite(&cm_scacheLock);
! 	for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
! 		if (cm_FidCmp(fidp, &scp->fid) == 0) {
! 			scp->refCount++;
              *outScpp = scp;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
! 			return 0;
          }
      }
          
! 	// yj: when we get here, it means we don't have an scp
! 	// so we need to either load it or fake it, depending
! 	// on whether the file is "special", see below.
! 
! 	// yj: if we're trying to get an scp for a file that's
! 	// on root.afs of homecell, we want to handle it specially
! 	// because we have to fill in the status stuff 'coz we
! 	// don't want trybulkstat to fill it in for us
  #ifdef AFS_FREELANCE_CLIENT
! 	special = (fidp->cell==AFS_FAKE_ROOT_CELL_ID && 
                 fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
! 			   !(fidp->vnode==0x1 && fidp->unique==0x1));
! 	isRoot = (fidp->cell==AFS_FAKE_ROOT_CELL_ID && 
                fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
! 			  fidp->vnode==0x1 && fidp->unique==0x1);
! 	if (cm_freelanceEnabled && isRoot) {
! 		osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
!           /* freelance: if we are trying to get the root scp for the first
           * time, we will just put in a place holder entry. 
           */
! 		volp = NULL;
! 	}
  	  
! 	if (cm_freelanceEnabled && special) {
! 		osi_Log0(afsd_logp,"cm_getSCache Freelance and special");
          if (fidp->vnode > 1) {
  	    lock_ObtainMutex(&cm_Freelance_Lock);
! 		mp =(cm_localMountPoints+fidp->vnode-2)->mountPointStringp;
! 		lock_ReleaseMutex(&cm_Freelance_Lock);
          } else {
              mp = "";
          }
! 		scp = cm_GetNewSCache();
  		
! 		scp->fid = *fidp;
! 		scp->volp = cm_rootSCachep->volp;
! 		if (scp->dotdotFidp == (cm_fid_t *) NULL)
! 			scp->dotdotFidp = (cm_fid_t *) malloc (sizeof(cm_fid_t));
! 		scp->dotdotFidp->cell=AFS_FAKE_ROOT_CELL_ID;
! 		scp->dotdotFidp->volume=AFS_FAKE_ROOT_VOL_ID;
! 		scp->dotdotFidp->unique=1;
! 		scp->dotdotFidp->vnode=1;
! 		scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
! 		scp->nextp=cm_hashTablep[hash];
! 		cm_hashTablep[hash]=scp;
! 		scp->flags |= CM_SCACHEFLAG_INHASH;
! 		scp->refCount = 1;
! 		scp->fileType = CM_SCACHETYPE_MOUNTPOINT;
! 
! 		lock_ObtainMutex(&cm_Freelance_Lock);
! 		scp->length.LowPart = strlen(mp)+4;
! 		scp->mountPointStringp=malloc(strlen(mp)+1);
! 		strcpy(scp->mountPointStringp,mp);
! 		lock_ReleaseMutex(&cm_Freelance_Lock);
! 
! 		scp->owner=0x0;
! 		scp->unixModeBits=0x1ff;
! 		scp->clientModTime=FakeFreelanceModTime;
! 		scp->serverModTime=FakeFreelanceModTime;
! 		scp->parentUnique = 0x1;
! 		scp->parentVnode=0x1;
! 		scp->group=0;
! 		scp->dataVersion=0x8;
! 		*outScpp = scp;
! 		lock_ReleaseWrite(&cm_scacheLock);
! 		/*afsi_log("   getscache done");*/
! 		return 0;
! 	}
! 	// end of yj code
  #endif /* AFS_FREELANCE_CLIENT */
  
      /* otherwise, we need to find the volume */
! 	if (!cm_freelanceEnabled || !isRoot) {
          lock_ReleaseWrite(&cm_scacheLock);	/* for perf. reasons */
          cellp = cm_FindCellByID(fidp->cell);
          if (!cellp) 
--- 269,360 ----
          osi_Log0(afsd_logp,"cm_getSCache called with root cell/volume and vnode=0 and unique=0");
      }
  
!     // yj: check if we have the scp, if so, we don't need
!     // to do anything else
      lock_ObtainWrite(&cm_scacheLock);
!     for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!         if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             scp->refCount++;
              *outScpp = scp;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
!             return 0;
          }
      }
          
!     // yj: when we get here, it means we don't have an scp
!     // so we need to either load it or fake it, depending
!     // on whether the file is "special", see below.
! 
!     // yj: if we're trying to get an scp for a file that's
!     // on root.afs of homecell, we want to handle it specially
!     // because we have to fill in the status stuff 'coz we
!     // don't want trybulkstat to fill it in for us
  #ifdef AFS_FREELANCE_CLIENT
!     special = (fidp->cell==AFS_FAKE_ROOT_CELL_ID && 
                 fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
!                !(fidp->vnode==0x1 && fidp->unique==0x1));
!     isRoot = (fidp->cell==AFS_FAKE_ROOT_CELL_ID && 
                fidp->volume==AFS_FAKE_ROOT_VOL_ID &&
!               fidp->vnode==0x1 && fidp->unique==0x1);
!     if (cm_freelanceEnabled && isRoot) {
!         osi_Log0(afsd_logp,"cm_getSCache Freelance and isRoot");
!         /* freelance: if we are trying to get the root scp for the first
           * time, we will just put in a place holder entry. 
           */
!         volp = NULL;
!     }
  	  
!     if (cm_freelanceEnabled && special) {
!         osi_Log0(afsd_logp,"cm_getSCache Freelance and special");
          if (fidp->vnode > 1) {
  	    lock_ObtainMutex(&cm_Freelance_Lock);
!             mp =(cm_localMountPoints+fidp->vnode-2)->mountPointStringp;
!             lock_ReleaseMutex(&cm_Freelance_Lock);
          } else {
              mp = "";
          }
!         scp = cm_GetNewSCache();
  		
!         scp->fid = *fidp;
!         scp->volp = cm_rootSCachep->volp;
!         if (scp->dotdotFidp == (cm_fid_t *) NULL)
!             scp->dotdotFidp = (cm_fid_t *) malloc (sizeof(cm_fid_t));
!         scp->dotdotFidp->cell=AFS_FAKE_ROOT_CELL_ID;
!         scp->dotdotFidp->volume=AFS_FAKE_ROOT_VOL_ID;
!         scp->dotdotFidp->unique=1;
!         scp->dotdotFidp->vnode=1;
!         scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
!         scp->nextp=cm_hashTablep[hash];
!         cm_hashTablep[hash]=scp;
!         scp->flags |= CM_SCACHEFLAG_INHASH;
!         scp->refCount = 1;
!         scp->fileType = (cm_localMountPoints+fidp->vnode-2)->fileType;
! 
!         lock_ObtainMutex(&cm_Freelance_Lock);
!         scp->length.LowPart = strlen(mp)+4;
!         scp->mountPointStringp=malloc(strlen(mp)+1);
!         strcpy(scp->mountPointStringp,mp);
!         lock_ReleaseMutex(&cm_Freelance_Lock);
! 
!         scp->owner=0x0;
!         scp->unixModeBits=0x1ff;
!         scp->clientModTime=FakeFreelanceModTime;
!         scp->serverModTime=FakeFreelanceModTime;
!         scp->parentUnique = 0x1;
!         scp->parentVnode=0x1;
!         scp->group=0;
!         scp->dataVersion=0x8;
!         *outScpp = scp;
!         lock_ReleaseWrite(&cm_scacheLock);
!         /*afsi_log("   getscache done");*/
!         return 0;
!     }
!     // end of yj code
  #endif /* AFS_FREELANCE_CLIENT */
  
      /* otherwise, we need to find the volume */
!     if (!cm_freelanceEnabled || !isRoot) {
          lock_ReleaseWrite(&cm_scacheLock);	/* for perf. reasons */
          cellp = cm_FindCellByID(fidp->cell);
          if (!cellp) 
***************
*** 364,419 ****
          if (code) 
              return code;
          lock_ObtainWrite(&cm_scacheLock);
! 	}
          
!         /* otherwise, we have the volume, now reverify that the scp doesn't
!          * exist, and proceed.
!          */
! 	for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
! 		if (cm_FidCmp(fidp, &scp->fid) == 0) {
! 			scp->refCount++;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              if (volp)
!             cm_PutVolume(volp);
              *outScpp = scp;
! 			return 0;
          }
      }
          
      /* now, if we don't have the fid, recycle something */
! 	scp = cm_GetNewSCache();
! 	osi_assert(!(scp->flags & CM_SCACHEFLAG_INHASH));
! 	scp->fid = *fidp;
! 	scp->volp = volp;	/* a held reference */
! 
! 	if (!cm_freelanceEnabled || !isRoot) {
! 	  /* if this scache entry represents a volume root then we need 
! 	   * to copy the dotdotFipd from the volume structure where the 
! 	   * "master" copy is stored (defect 11489)
! 	   */
! 	  if(scp->fid.vnode == 1 && scp->fid.unique == 1 && volp->dotdotFidp) {
  	    if (scp->dotdotFidp == (cm_fid_t *) NULL)
! 	      scp->dotdotFidp = (cm_fid_t *) malloc(sizeof(cm_fid_t));
  	    *(scp->dotdotFidp) = *volp->dotdotFidp;
! 	  }
  	  
! 	  if (volp->roID == fidp->volume)
  	    scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
! 	  else if (volp->bkID == fidp->volume)
  	    scp->flags |= CM_SCACHEFLAG_RO;
! 	}
! 	scp->nextp = cm_hashTablep[hash];
! 	cm_hashTablep[hash] = scp;
      scp->flags |= CM_SCACHEFLAG_INHASH;
! 	scp->refCount = 1;
  
! 	/* XXX - The following fields in the cm_scache are 
! 	 * uninitialized:
! 	 *   fileType
! 	 *   parentVnode
! 	 *   parentUnique
! 	 */
      lock_ReleaseWrite(&cm_scacheLock);
          
      /* now we have a held scache entry; just return it */
--- 364,419 ----
          if (code) 
              return code;
          lock_ObtainWrite(&cm_scacheLock);
!     }
          
!     /* otherwise, we have the volume, now reverify that the scp doesn't
!      * exist, and proceed.
!      */
!     for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!         if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             scp->refCount++;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              if (volp)
!                 cm_PutVolume(volp);
              *outScpp = scp;
!             return 0;
          }
      }
          
      /* now, if we don't have the fid, recycle something */
!     scp = cm_GetNewSCache();
!     osi_assert(!(scp->flags & CM_SCACHEFLAG_INHASH));
!     scp->fid = *fidp;
!     scp->volp = volp;	/* a held reference */
! 
!     if (!cm_freelanceEnabled || !isRoot) {
!         /* if this scache entry represents a volume root then we need 
!          * to copy the dotdotFipd from the volume structure where the 
!          * "master" copy is stored (defect 11489)
!          */
!         if (scp->fid.vnode == 1 && scp->fid.unique == 1 && volp->dotdotFidp) {
  	    if (scp->dotdotFidp == (cm_fid_t *) NULL)
!                 scp->dotdotFidp = (cm_fid_t *) malloc(sizeof(cm_fid_t));
  	    *(scp->dotdotFidp) = *volp->dotdotFidp;
!         }
  	  
!         if (volp->roID == fidp->volume)
  	    scp->flags |= (CM_SCACHEFLAG_PURERO | CM_SCACHEFLAG_RO);
!         else if (volp->bkID == fidp->volume)
  	    scp->flags |= CM_SCACHEFLAG_RO;
!     }
!     scp->nextp = cm_hashTablep[hash];
!     cm_hashTablep[hash] = scp;
      scp->flags |= CM_SCACHEFLAG_INHASH;
!     scp->refCount = 1;
  
!     /* XXX - The following fields in the cm_scache are 
!      * uninitialized:
!      *   fileType
!      *   parentVnode
!      *   parentUnique
!      */
      lock_ReleaseWrite(&cm_scacheLock);
          
      /* now we have a held scache entry; just return it */
***************
*** 477,754 ****
   * CM_SCACHESYNC_STOREDATA_EXCL and CM_SCACHEFLAG_DATASTORING.
   */
  long cm_SyncOp(cm_scache_t *scp, cm_buf_t *bufp, cm_user_t *up, cm_req_t *reqp,
! 	long rights, long flags)
  {
! 	osi_queueData_t *qdp;
!         long code;
!         cm_buf_t *tbufp;
!         long outRights;
!         int bufLocked;
! 
! 	/* lookup this first */
! 	bufLocked = flags & CM_SCACHESYNC_BUFLOCKED;
! 
! 	/* some minor assertions */
! 	if (flags & (CM_SCACHESYNC_STOREDATA | CM_SCACHESYNC_FETCHDATA
! 			| CM_SCACHESYNC_READ | CM_SCACHESYNC_WRITE
! 			| CM_SCACHESYNC_SETSIZE)) {
! 		if (bufp) {
! 			osi_assert(bufp->refCount > 0);
! 			/*
! 			osi_assert(cm_FidCmp(&bufp->fid, &scp->fid) == 0);
! 			 */
! 		}
! 	}
! 	else osi_assert(bufp == NULL);
! 
! 	/* Do the access check.  Now we don't really do the access check
! 	 * atomically, since the caller doesn't expect the parent dir to be
! 	 * returned locked, and that is what we'd have to do to prevent a
! 	 * callback breaking message on the parent due to a setacl call from
! 	 * being processed while we're running.  So, instead, we check things
!          * here, and if things look fine with the access, we proceed to finish
! 	 * the rest of this check.  Sort of a hack, but probably good enough.
!          */
! 
! 	while (1) {
! 		if (flags & CM_SCACHESYNC_FETCHSTATUS) {
! 			/* if we're bringing in a new status block, ensure that
! 			 * we aren't already doing so, and that no one is
! 			 * changing the status concurrently, either.  We need
! 			 * to do this, even if the status is of a different
!                          * type, since we don't have the ability to figure out,
! 			 * in the AFS 3 protocols, which status-changing
! 			 * operation ran first, or even which order a read and
! 			 * a write occurred in.
!                          */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                         		  | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
! 				goto sleep;
!                 }
!                 if (flags & (CM_SCACHESYNC_STORESIZE | CM_SCACHESYNC_STORESTATUS
!                 		| CM_SCACHESYNC_SETSIZE | CM_SCACHESYNC_GETCALLBACK)) {
! 			/* if we're going to make an RPC to change the status, make sure
!                          * that no one is bringing in or sending out the status.
!                          */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                         		  | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
! 				goto sleep;
! 			if (scp->bufReadsp || scp->bufWritesp) goto sleep;
!                 }
!                 if (flags & CM_SCACHESYNC_FETCHDATA) {
!                 	/* if we're bringing in a new chunk of data, make sure that
!                          * nothing is happening to that chunk, and that we aren't
!                          * changing the basic file status info, either.
!                          */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                         		  | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
! 				goto sleep;
!                         if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)))
!                         	goto sleep;
!                 }
!                 if (flags & CM_SCACHESYNC_STOREDATA) {
! 			/* same as fetch data */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                         		  | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
! 				goto sleep;
!                         if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)))
!                         	goto sleep;
!                 }
  
! 		if (flags & CM_SCACHESYNC_STOREDATA_EXCL) {
! 			/* Don't allow concurrent StoreData RPC's */
! 			if (scp->flags & CM_SCACHEFLAG_DATASTORING)
! 				goto sleep;
! 		}
! 
! 		if (flags & CM_SCACHESYNC_ASYNCSTORE) {
! 			/* Don't allow more than one BKG store request */
! 			if (scp->flags & CM_SCACHEFLAG_ASYNCSTORING)
! 				goto sleep;
! 		}
! 
! 		if (flags & CM_SCACHESYNC_LOCK) {
! 			/* Don't allow concurrent fiddling with lock lists */
! 			if (scp->flags & CM_SCACHEFLAG_LOCKING)
! 				goto sleep;
! 		}
! 
!                 /* now the operations that don't correspond to making RPCs */
!                 if (flags & CM_SCACHESYNC_GETSTATUS) {
! 			/* we can use the status that's here, if we're not
! 			 * bringing in new status.
!                          */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING))
! 				goto sleep;
!                 }
! 		if (flags & CM_SCACHESYNC_SETSTATUS) {
!                 	/* we can make a change to the local status, as long as
! 			 * the status isn't changing now.
! 			 *
!                          * If we're fetching or storing a chunk of data, we can
! 			 * change the status locally, since the fetch/store
! 			 * operations don't change any of the data that we're
! 			 * changing here.
!                          */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                         		  | CM_SCACHEFLAG_SIZESTORING))
! 				goto sleep;
!                 }
!                 if (flags & CM_SCACHESYNC_READ) {
! 			/* we're going to read the data, make sure that the
! 			 * status is available, and that the data is here.  It
! 			 * is OK to read while storing the data back.
!                          */
! 			if (scp->flags & CM_SCACHEFLAG_FETCHING)
! 				goto sleep;
!                         if (bufp && ((bufp->cmFlags
! 					 & (CM_BUF_CMFETCHING
! 					     | CM_BUF_CMFULLYFETCHED))
! 					== CM_BUF_CMFETCHING))
!                         	goto sleep;
!                 }
! 		if (flags & CM_SCACHESYNC_WRITE) {
! 			/* don't write unless the status is stable and the chunk
!                          * is stable.
!                          */
! 			if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                         		  | CM_SCACHEFLAG_SIZESTORING))
! 				goto sleep;
!                         if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)))
!                         	goto sleep;
!                 }
  
! 		// yj: modified this so that callback only checked if we're
! 		// not checking something on /afs
          /* fix the conditional to match the one in cm_HaveCallback */
! 		if (  (flags & CM_SCACHESYNC_NEEDCALLBACK)
  #ifdef AFS_FREELANCE_CLIENT
               && (!cm_freelanceEnabled || 
                    !(scp->fid.vnode==0x1 && scp->fid.unique==0x1) ||
                    scp->fid.cell!=AFS_FAKE_ROOT_CELL_ID ||
                    scp->fid.volume!=AFS_FAKE_ROOT_VOL_ID ||
! 				  cm_fakeDirCallback < 2)
  #endif /* AFS_FREELANCE_CLIENT */
! 		    ) {
! 			if (!cm_HaveCallback(scp)) {
! 				osi_Log1(afsd_logp, "CM SyncOp getting callback on scp %x",
!                                 	(long) scp);
! 				if (bufLocked) lock_ReleaseMutex(&bufp->mx);
! 				code = cm_GetCallback(scp, up, reqp, 0);
!                                 if (bufLocked) {
! 					lock_ReleaseMutex(&scp->mx);
!                                         lock_ObtainMutex(&bufp->mx);
!                                         lock_ObtainMutex(&scp->mx);
!                                 }
!                                 if (code) return code;
! 				continue;
!                         }
                  }
!                 
! 		if (rights) {
! 			/* can't check access rights without a callback */
! 			osi_assert(flags & CM_SCACHESYNC_NEEDCALLBACK);
! 
! 			if ((rights & PRSFS_WRITE) && (scp->flags & CM_SCACHEFLAG_RO))
! 				return CM_ERROR_READONLY;
! 
! 			if (cm_HaveAccessRights(scp, up, rights, &outRights)) {
! 				if (~outRights & rights) return CM_ERROR_NOACCESS;
!                         }
!                         else {
! 				/* we don't know the required access rights */
! 				if (bufLocked) lock_ReleaseMutex(&bufp->mx);
!                                 code = cm_GetAccessRights(scp, up, reqp);
!                                 if (code) return code;
!                                 if (bufLocked) {
! 					lock_ReleaseMutex(&scp->mx);
!                                         lock_ObtainMutex(&bufp->mx);
!                                         lock_ObtainMutex(&scp->mx);
!                                 }
!                                 continue;
!                         }
                  }
  
!                 /* if we get here, we're happy */
!                 break;
  
! sleep:
! 		/* first check if we're not supposed to wait: fail 
!                  * in this case, returning with everything still locked.
!                  */
! 		if (flags & CM_SCACHESYNC_NOWAIT) return CM_ERROR_WOULDBLOCK;
  
! 		/* wait here, then try again */
! 		osi_Log1(afsd_logp, "CM SyncOp sleeping scp %x", (long) scp);
          if ( scp->flags & CM_SCACHEFLAG_WAITING ) 
              osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING already set for 0x%x", scp);
          else 
              osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING set for 0x%x", scp);
! 		scp->flags |= CM_SCACHEFLAG_WAITING;
! 		if (bufLocked) lock_ReleaseMutex(&bufp->mx);
          osi_SleepM((long) &scp->flags, &scp->mx);
          osi_Log0(afsd_logp, "CM SyncOp woke!");
          if (bufLocked) 
              lock_ObtainMutex(&bufp->mx);
          lock_ObtainMutex(&scp->mx);
!         } /* big while loop */
          
!         /* now, update the recorded state for RPC-type calls */
!         if (flags & CM_SCACHESYNC_FETCHSTATUS)
!         	scp->flags |= CM_SCACHEFLAG_FETCHING;
! 	if (flags & CM_SCACHESYNC_STORESTATUS)
!         	scp->flags |= CM_SCACHEFLAG_STORING;
! 	if (flags & CM_SCACHESYNC_STORESIZE)
!         	scp->flags |= CM_SCACHEFLAG_SIZESTORING;
! 	if (flags & CM_SCACHESYNC_GETCALLBACK)
!         	scp->flags |= CM_SCACHEFLAG_GETCALLBACK;
! 	if (flags & CM_SCACHESYNC_STOREDATA_EXCL)
! 		scp->flags |= CM_SCACHEFLAG_DATASTORING;
! 	if (flags & CM_SCACHESYNC_ASYNCSTORE)
! 		scp->flags |= CM_SCACHEFLAG_ASYNCSTORING;
! 	if (flags & CM_SCACHESYNC_LOCK)
! 		scp->flags |= CM_SCACHEFLAG_LOCKING;
  
! 	/* now update the buffer pointer */
!         if (flags & CM_SCACHESYNC_FETCHDATA) {
! 		/* ensure that the buffer isn't already in the I/O list */
! 		if (bufp) {
! 			for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
! 				tbufp = osi_GetQData(qdp);
! 	                        osi_assert(tbufp != bufp);
! 	                }
! 		}
!                 
! 		/* queue a held reference to the buffer in the "reading" I/O list */
!                 qdp = osi_QDAlloc();
!                 osi_SetQData(qdp, bufp);
! 		if (bufp) {
! 	                buf_Hold(bufp);
! 	                bufp->cmFlags |= CM_BUF_CMFETCHING;
! 		}
!                 osi_QAdd((osi_queue_t **) &scp->bufReadsp, &qdp->q);
          }
  
!         if (flags & CM_SCACHESYNC_STOREDATA) {
! 		/* ensure that the buffer isn't already in the I/O list */
! 		if (bufp) {
! 			for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
! 				tbufp = osi_GetQData(qdp);
! 	                        osi_assert(tbufp != bufp);
! 	                }
! 		}
!                 
! 		/* queue a held reference to the buffer in the "writing" I/O list */
!                 qdp = osi_QDAlloc();
!                 osi_SetQData(qdp, bufp);
! 		if (bufp) {
! 	                buf_Hold(bufp);
! 	                bufp->cmFlags |= CM_BUF_CMSTORING;
! 		}
!                 osi_QAdd((osi_queue_t **) &scp->bufWritesp, &qdp->q);
          }
!         
!         return 0;
  }
  
  /* for those syncops that setup for RPCs.
--- 477,754 ----
   * CM_SCACHESYNC_STOREDATA_EXCL and CM_SCACHEFLAG_DATASTORING.
   */
  long cm_SyncOp(cm_scache_t *scp, cm_buf_t *bufp, cm_user_t *up, cm_req_t *reqp,
!                long rights, long flags)
  {
!     osi_queueData_t *qdp;
!     long code;
!     cm_buf_t *tbufp;
!     long outRights;
!     int bufLocked;
! 
!     /* lookup this first */
!     bufLocked = flags & CM_SCACHESYNC_BUFLOCKED;
! 
!     /* some minor assertions */
!     if (flags & (CM_SCACHESYNC_STOREDATA | CM_SCACHESYNC_FETCHDATA
!                   | CM_SCACHESYNC_READ | CM_SCACHESYNC_WRITE
!                   | CM_SCACHESYNC_SETSIZE)) {
!         if (bufp) {
!             osi_assert(bufp->refCount > 0);
!             /*
!                osi_assert(cm_FidCmp(&bufp->fid, &scp->fid) == 0);
!              */
!         }
!     }
!     else osi_assert(bufp == NULL);
  
!     /* Do the access check.  Now we don't really do the access check
!      * atomically, since the caller doesn't expect the parent dir to be
!      * returned locked, and that is what we'd have to do to prevent a
!      * callback breaking message on the parent due to a setacl call from
!      * being processed while we're running.  So, instead, we check things
!      * here, and if things look fine with the access, we proceed to finish
!      * the rest of this check.  Sort of a hack, but probably good enough.
!      */
! 
!     while (1) {
!         if (flags & CM_SCACHESYNC_FETCHSTATUS) {
!             /* if we're bringing in a new status block, ensure that
!              * we aren't already doing so, and that no one is
!              * changing the status concurrently, either.  We need
!              * to do this, even if the status is of a different
!              * type, since we don't have the ability to figure out,
!              * in the AFS 3 protocols, which status-changing
!              * operation ran first, or even which order a read and
!              * a write occurred in.
!              */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                                | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
!                 goto sleep;
!         }
!         if (flags & (CM_SCACHESYNC_STORESIZE | CM_SCACHESYNC_STORESTATUS
!                       | CM_SCACHESYNC_SETSIZE | CM_SCACHESYNC_GETCALLBACK)) {
!             /* if we're going to make an RPC to change the status, make sure
!              * that no one is bringing in or sending out the status.
!              */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                                | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
!                 goto sleep;
!             if (scp->bufReadsp || scp->bufWritesp) goto sleep;
!         }
!         if (flags & CM_SCACHESYNC_FETCHDATA) {
!             /* if we're bringing in a new chunk of data, make sure that
!              * nothing is happening to that chunk, and that we aren't
!              * changing the basic file status info, either.
!              */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                                | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
!                 goto sleep;
!             if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)))
!                 goto sleep;
!         }
!         if (flags & CM_SCACHESYNC_STOREDATA) {
!             /* same as fetch data */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                                | CM_SCACHEFLAG_SIZESTORING | CM_SCACHEFLAG_GETCALLBACK))
!                 goto sleep;
!             if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)))
!                 goto sleep;
!         }
! 
!         if (flags & CM_SCACHESYNC_STOREDATA_EXCL) {
!             /* Don't allow concurrent StoreData RPC's */
!             if (scp->flags & CM_SCACHEFLAG_DATASTORING)
!                 goto sleep;
!         }
! 
!         if (flags & CM_SCACHESYNC_ASYNCSTORE) {
!             /* Don't allow more than one BKG store request */
!             if (scp->flags & CM_SCACHEFLAG_ASYNCSTORING)
!                 goto sleep;
!         }
! 
!         if (flags & CM_SCACHESYNC_LOCK) {
!             /* Don't allow concurrent fiddling with lock lists */
!             if (scp->flags & CM_SCACHEFLAG_LOCKING)
!                 goto sleep;
!         }
! 
!         /* now the operations that don't correspond to making RPCs */
!         if (flags & CM_SCACHESYNC_GETSTATUS) {
!             /* we can use the status that's here, if we're not
!              * bringing in new status.
!              */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING))
!                 goto sleep;
!         }
!         if (flags & CM_SCACHESYNC_SETSTATUS) {
!             /* we can make a change to the local status, as long as
!              * the status isn't changing now.
!              *
!              * If we're fetching or storing a chunk of data, we can
!              * change the status locally, since the fetch/store
!              * operations don't change any of the data that we're
!              * changing here.
!              */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                                | CM_SCACHEFLAG_SIZESTORING))
!                 goto sleep;
!         }
!         if (flags & CM_SCACHESYNC_READ) {
!             /* we're going to read the data, make sure that the
!              * status is available, and that the data is here.  It
!              * is OK to read while storing the data back.
!              */
!             if (scp->flags & CM_SCACHEFLAG_FETCHING)
!                 goto sleep;
!             if (bufp && ((bufp->cmFlags
!                            & (CM_BUF_CMFETCHING
!                                | CM_BUF_CMFULLYFETCHED))
!                           == CM_BUF_CMFETCHING))
!                 goto sleep;
!         }
!         if (flags & CM_SCACHESYNC_WRITE) {
!             /* don't write unless the status is stable and the chunk
!              * is stable.
!              */
!             if (scp->flags & (CM_SCACHEFLAG_FETCHING | CM_SCACHEFLAG_STORING
!                                | CM_SCACHEFLAG_SIZESTORING))
!                 goto sleep;
!             if (bufp && (bufp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING)))
!                 goto sleep;
!         }
  
!         // yj: modified this so that callback only checked if we're
!         // not checking something on /afs
          /* fix the conditional to match the one in cm_HaveCallback */
!         if (  (flags & CM_SCACHESYNC_NEEDCALLBACK)
  #ifdef AFS_FREELANCE_CLIENT
               && (!cm_freelanceEnabled || 
                    !(scp->fid.vnode==0x1 && scp->fid.unique==0x1) ||
                    scp->fid.cell!=AFS_FAKE_ROOT_CELL_ID ||
                    scp->fid.volume!=AFS_FAKE_ROOT_VOL_ID ||
!                   cm_fakeDirCallback < 2)
  #endif /* AFS_FREELANCE_CLIENT */
!              ) {
!             if (!cm_HaveCallback(scp)) {
!                 osi_Log1(afsd_logp, "CM SyncOp getting callback on scp %x",
!                           (long) scp);
!                 if (bufLocked) lock_ReleaseMutex(&bufp->mx);
!                 code = cm_GetCallback(scp, up, reqp, 0);
!                 if (bufLocked) {
!                     lock_ReleaseMutex(&scp->mx);
!                     lock_ObtainMutex(&bufp->mx);
!                     lock_ObtainMutex(&scp->mx);
                  }
!                 if (code) return code;
!                 continue;
!             }
!         }
! 
!         if (rights) {
!             /* can't check access rights without a callback */
!             osi_assert(flags & CM_SCACHESYNC_NEEDCALLBACK);
! 
!             if ((rights & PRSFS_WRITE) && (scp->flags & CM_SCACHEFLAG_RO))
!                 return CM_ERROR_READONLY;
! 
!             if (cm_HaveAccessRights(scp, up, rights, &outRights)) {
!                 if (~outRights & rights) return CM_ERROR_NOACCESS;
!             }
!             else {
!                 /* we don't know the required access rights */
!                 if (bufLocked) lock_ReleaseMutex(&bufp->mx);
!                 code = cm_GetAccessRights(scp, up, reqp);
!                 if (code) return code;
!                 if (bufLocked) {
!                     lock_ReleaseMutex(&scp->mx);
!                     lock_ObtainMutex(&bufp->mx);
!                     lock_ObtainMutex(&scp->mx);
                  }
+                 continue;
+             }
+         }
  
!         /* if we get here, we're happy */
!         break;
  
!       sleep:
!         /* first check if we're not supposed to wait: fail 
!          * in this case, returning with everything still locked.
!          */
!         if (flags & CM_SCACHESYNC_NOWAIT) return CM_ERROR_WOULDBLOCK;
  
!         /* wait here, then try again */
!         osi_Log1(afsd_logp, "CM SyncOp sleeping scp %x", (long) scp);
          if ( scp->flags & CM_SCACHEFLAG_WAITING ) 
              osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING already set for 0x%x", scp);
          else 
              osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING set for 0x%x", scp);
!         scp->flags |= CM_SCACHEFLAG_WAITING;
!         if (bufLocked) lock_ReleaseMutex(&bufp->mx);
          osi_SleepM((long) &scp->flags, &scp->mx);
          osi_Log0(afsd_logp, "CM SyncOp woke!");
          if (bufLocked) 
              lock_ObtainMutex(&bufp->mx);
          lock_ObtainMutex(&scp->mx);
!     } /* big while loop */
          
!     /* now, update the recorded state for RPC-type calls */
!     if (flags & CM_SCACHESYNC_FETCHSTATUS)
!         scp->flags |= CM_SCACHEFLAG_FETCHING;
!     if (flags & CM_SCACHESYNC_STORESTATUS)
!         scp->flags |= CM_SCACHEFLAG_STORING;
!     if (flags & CM_SCACHESYNC_STORESIZE)
!         scp->flags |= CM_SCACHEFLAG_SIZESTORING;
!     if (flags & CM_SCACHESYNC_GETCALLBACK)
!         scp->flags |= CM_SCACHEFLAG_GETCALLBACK;
!     if (flags & CM_SCACHESYNC_STOREDATA_EXCL)
!         scp->flags |= CM_SCACHEFLAG_DATASTORING;
!     if (flags & CM_SCACHESYNC_ASYNCSTORE)
!         scp->flags |= CM_SCACHEFLAG_ASYNCSTORING;
!     if (flags & CM_SCACHESYNC_LOCK)
!         scp->flags |= CM_SCACHEFLAG_LOCKING;
! 
!     /* now update the buffer pointer */
!     if (flags & CM_SCACHESYNC_FETCHDATA) {
!         /* ensure that the buffer isn't already in the I/O list */
!         if (bufp) {
!             for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
!                 tbufp = osi_GetQData(qdp);
!                 osi_assert(tbufp != bufp);
!             }
!         }
  
!         /* queue a held reference to the buffer in the "reading" I/O list */
!         qdp = osi_QDAlloc();
!         osi_SetQData(qdp, bufp);
!         if (bufp) {
!             buf_Hold(bufp);
!             bufp->cmFlags |= CM_BUF_CMFETCHING;
          }
+         osi_QAdd((osi_queue_t **) &scp->bufReadsp, &qdp->q);
+     }
  
!     if (flags & CM_SCACHESYNC_STOREDATA) {
!         /* ensure that the buffer isn't already in the I/O list */
!         if (bufp) {
!             for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
!                 tbufp = osi_GetQData(qdp);
!                 osi_assert(tbufp != bufp);
!             }
          }
! 
!         /* queue a held reference to the buffer in the "writing" I/O list */
!         qdp = osi_QDAlloc();
!         osi_SetQData(qdp, bufp);
!         if (bufp) {
!             buf_Hold(bufp);
!             bufp->cmFlags |= CM_BUF_CMSTORING;
!         }
!         osi_QAdd((osi_queue_t **) &scp->bufWritesp, &qdp->q);
!     }
! 
!     return 0;
  }
  
  /* for those syncops that setup for RPCs.
***************
*** 756,822 ****
   */
  void cm_SyncOpDone(cm_scache_t *scp, cm_buf_t *bufp, long flags)
  {
! 	osi_queueData_t *qdp;
! 	cm_buf_t *tbufp;
! 
!         /* now, update the recorded state for RPC-type calls */
!         if (flags & CM_SCACHESYNC_FETCHSTATUS)
!         	scp->flags &= ~CM_SCACHEFLAG_FETCHING;
! 	if (flags & CM_SCACHESYNC_STORESTATUS)
!         	scp->flags &= ~CM_SCACHEFLAG_STORING;
! 	if (flags & CM_SCACHESYNC_STORESIZE)
!         	scp->flags &= ~CM_SCACHEFLAG_SIZESTORING;
! 	if (flags & CM_SCACHESYNC_GETCALLBACK)
!         	scp->flags &= ~CM_SCACHEFLAG_GETCALLBACK;
! 	if (flags & CM_SCACHESYNC_STOREDATA_EXCL)
! 		scp->flags &= ~CM_SCACHEFLAG_DATASTORING;
! 	if (flags & CM_SCACHESYNC_ASYNCSTORE)
! 		scp->flags &= ~CM_SCACHEFLAG_ASYNCSTORING;
! 	if (flags & CM_SCACHESYNC_LOCK)
! 		scp->flags &= ~CM_SCACHEFLAG_LOCKING;
  
! 	/* now update the buffer pointer */
!         if (flags & CM_SCACHESYNC_FETCHDATA) {
! 		/* ensure that the buffer isn't already in the I/O list */
! 		for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
! 			tbufp = osi_GetQData(qdp);
! 			if (tbufp == bufp) break;
!                 }
!                 osi_assert(qdp != NULL);
! 		osi_assert(osi_GetQData(qdp) == bufp);
! 		osi_QRemove((osi_queue_t **) &scp->bufReadsp, &qdp->q);
!                 osi_QDFree(qdp);
! 		if (bufp) {
! 			bufp->cmFlags &=
! 			  ~(CM_BUF_CMFETCHING | CM_BUF_CMFULLYFETCHED);
! 	                buf_Release(bufp);
! 		}
          }
  
! 	/* now update the buffer pointer */
!         if (flags & CM_SCACHESYNC_STOREDATA) {
! 		/* ensure that the buffer isn't already in the I/O list */
! 		for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
! 			tbufp = osi_GetQData(qdp);
! 			if (tbufp == bufp) break;
!                 }
!                 osi_assert(qdp != NULL);
! 		osi_assert(osi_GetQData(qdp) == bufp);
! 		osi_QRemove((osi_queue_t **) &scp->bufWritesp, &qdp->q);
!                 osi_QDFree(qdp);
! 		if (bufp) {
! 			bufp->cmFlags &= ~CM_BUF_CMSTORING;
! 	                buf_Release(bufp);
! 		}
!         }
!         
!         /* and wakeup anyone who is waiting */
!         if (scp->flags & CM_SCACHEFLAG_WAITING) {
!             osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING reset for 0x%x", scp);
!             scp->flags &= ~CM_SCACHEFLAG_WAITING;
!             osi_Wakeup((long) &scp->flags);
          }
! }
  
  /* merge in a response from an RPC.  The scp must be locked, and the callback
   * is optional.
--- 756,822 ----
   */
  void cm_SyncOpDone(cm_scache_t *scp, cm_buf_t *bufp, long flags)
  {
!     osi_queueData_t *qdp;
!     cm_buf_t *tbufp;
  
!     /* now, update the recorded state for RPC-type calls */
!     if (flags & CM_SCACHESYNC_FETCHSTATUS)
!         scp->flags &= ~CM_SCACHEFLAG_FETCHING;
!     if (flags & CM_SCACHESYNC_STORESTATUS)
!         scp->flags &= ~CM_SCACHEFLAG_STORING;
!     if (flags & CM_SCACHESYNC_STORESIZE)
!         scp->flags &= ~CM_SCACHEFLAG_SIZESTORING;
!     if (flags & CM_SCACHESYNC_GETCALLBACK)
!         scp->flags &= ~CM_SCACHEFLAG_GETCALLBACK;
!     if (flags & CM_SCACHESYNC_STOREDATA_EXCL)
!         scp->flags &= ~CM_SCACHEFLAG_DATASTORING;
!     if (flags & CM_SCACHESYNC_ASYNCSTORE)
!         scp->flags &= ~CM_SCACHEFLAG_ASYNCSTORING;
!     if (flags & CM_SCACHESYNC_LOCK)
!         scp->flags &= ~CM_SCACHEFLAG_LOCKING;
! 
!     /* now update the buffer pointer */
!     if (flags & CM_SCACHESYNC_FETCHDATA) {
!         /* ensure that the buffer isn't already in the I/O list */
!         for(qdp = scp->bufReadsp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
!             tbufp = osi_GetQData(qdp);
!             if (tbufp == bufp) break;
!         }
!         osi_assert(qdp != NULL);
!         osi_assert(osi_GetQData(qdp) == bufp);
!         osi_QRemove((osi_queue_t **) &scp->bufReadsp, &qdp->q);
!         osi_QDFree(qdp);
!         if (bufp) {
!             bufp->cmFlags &=
!                 ~(CM_BUF_CMFETCHING | CM_BUF_CMFULLYFETCHED);
!             buf_Release(bufp);
          }
+     }
  
!     /* now update the buffer pointer */
!     if (flags & CM_SCACHESYNC_STOREDATA) {
!         /* ensure that the buffer isn't already in the I/O list */
!         for(qdp = scp->bufWritesp; qdp; qdp = (osi_queueData_t *) osi_QNext(&qdp->q)) {
!             tbufp = osi_GetQData(qdp);
!             if (tbufp == bufp) break;
!         }
!         osi_assert(qdp != NULL);
!         osi_assert(osi_GetQData(qdp) == bufp);
!         osi_QRemove((osi_queue_t **) &scp->bufWritesp, &qdp->q);
!         osi_QDFree(qdp);
!         if (bufp) {
!             bufp->cmFlags &= ~CM_BUF_CMSTORING;
!             buf_Release(bufp);
          }
!     }
! 
!     /* and wakeup anyone who is waiting */
!     if (scp->flags & CM_SCACHEFLAG_WAITING) {
!         osi_Log1(afsd_logp, "CM SyncOp CM_SCACHEFLAG_WAITING reset for 0x%x", scp);
!         scp->flags &= ~CM_SCACHEFLAG_WAITING;
!         osi_Wakeup((long) &scp->flags);
!     }
! }       
  
  /* merge in a response from an RPC.  The scp must be locked, and the callback
   * is optional.
***************
*** 832,954 ****
   * started before that, can cause old info to be merged from the first call.
   */
  void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
! 	cm_user_t *userp, int flags)
  {
! 	// yj: i want to create some fake status for the /afs directory and the
! 	// entries under that directory
  #ifdef AFS_FREELANCE_CLIENT
! 	if (cm_freelanceEnabled && scp == cm_rootSCachep) {
! 		osi_Log0(afsd_logp,"cm_MergeStatus Freelance cm_rootSCachep");
! 		statusp->InterfaceVersion = 0x1;
          statusp->FileType = CM_SCACHETYPE_DIRECTORY;
! 		statusp->LinkCount = scp->linkCount;
! 		statusp->Length = cm_fakeDirSize;
! 		statusp->DataVersion = cm_fakeDirVersion;
! 		statusp->Author = 0x1;
! 		statusp->Owner = 0x0;
! 		statusp->CallerAccess = 0x9;
! 		statusp->AnonymousAccess = 0x9;
! 		statusp->UnixModeBits = 0x1ff;
! 		statusp->ParentVnode = 0x1;
! 		statusp->ParentUnique = 0x1;
! 		statusp->ResidencyMask = 0;
! 		statusp->ClientModTime = FakeFreelanceModTime;
! 		statusp->ServerModTime = FakeFreelanceModTime;
! 		statusp->Group = 0;
! 		statusp->SyncCounter = 0;
! 		statusp->dataVersionHigh = 0;
! 	}
  #endif /* AFS_FREELANCE_CLIENT */
  
! 	if (!(flags & CM_MERGEFLAG_FORCE)
!                	&& statusp->DataVersion < (unsigned long) scp->dataVersion) {
! 		struct cm_cell *cellp;
! 		struct cm_volume *volp;
! 
! 		cellp = cm_FindCellByID(scp->fid.cell);
! 		cm_GetVolumeByID(cellp, scp->fid.volume, userp,
! 				 (cm_req_t *) NULL, &volp);
! 		if (scp->cbServerp)
! 			osi_Log2(afsd_logp, "old data from server %x volume %s",
! 				 scp->cbServerp->addr.sin_addr.s_addr,
! 				 volp->namep);
! 		osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d",
! 			 scp, scp->dataVersion, statusp->DataVersion);
! 		/* we have a number of data fetch/store operations running
! 		 * concurrently, and we can tell which one executed last at the
! 		 * server by its mtime.
! 		 * Choose the one with the largest mtime, and ignore the rest.
! 		 *
! 		 * These concurrent calls are incompatible with setting the
! 		 * mtime, so we won't have a locally changed mtime here.
!                  *
!                  * We could also have ACL info for a different user than usual,
! 		 * in which case we have to do that part of the merge, anyway.
! 		 * We won't have to worry about the info being old, since we
! 		 * won't have concurrent calls
!                  * that change file status running from this machine.
! 		 *
! 		 * Added 3/17/98:  if we see data version regression on an RO
! 		 * file, it's probably due to a server holding an out-of-date
! 		 * replica, rather than to concurrent RPC's.  Failures to
! 		 * release replicas are now flagged by the volserver, but only
! 		 * since AFS 3.4 5.22, so there are plenty of clients getting
! 		 * out-of-date replicas out there.
! 		 *
! 		 * If we discover an out-of-date replica, by this time it's too
! 		 * late to go to another server and retry.  Also, we can't
! 		 * reject the merge, because then there is no way for
! 		 * GetAccess to do its work, and the caller gets into an
! 		 * infinite loop.  So we just grin and bear it.
! 		 */
! 		if (!(scp->flags & CM_SCACHEFLAG_RO))
! 			return;
! 	}
!         scp->serverModTime = statusp->ServerModTime;
! 
! 	if (!(scp->mask & CM_SCACHEMASK_CLIENTMODTIME)) {
!         	scp->clientModTime = statusp->ClientModTime;
! 	}
!         if (!(scp->mask & CM_SCACHEMASK_LENGTH)) {
!         	scp->length.LowPart = statusp->Length;
!                 scp->length.HighPart = 0;
! 	}
! 
! 	scp->serverLength.LowPart = statusp->Length;
! 	scp->serverLength.HighPart = 0;
! 
! 	scp->linkCount = statusp->LinkCount;
!         scp->dataVersion = statusp->DataVersion;
!         scp->owner = statusp->Owner;
!         scp->group = statusp->Group;
!         scp->unixModeBits = statusp->UnixModeBits & 07777;
!         
!         if (statusp->FileType == File)
!         	scp->fileType = CM_SCACHETYPE_FILE;
! 	else if (statusp->FileType == Directory)
! 		scp->fileType = CM_SCACHETYPE_DIRECTORY;
! 	else if (statusp->FileType == SymbolicLink) {
! 		if ((scp->unixModeBits & 0111) == 0)
!                 	scp->fileType = CM_SCACHETYPE_MOUNTPOINT;
! 		else
!                 	scp->fileType = CM_SCACHETYPE_SYMLINK;
!         }
      else {
          osi_Log1(afsd_logp, "Merge, Invalid File Type, scp %x", scp);
          scp->fileType = 0;	/* invalid */
      }
!         /* and other stuff */
!         scp->parentVnode = statusp->ParentVnode;
!         scp->parentUnique = statusp->ParentUnique;
!         
!         /* and merge in the private acl cache info, if this is more than the public
!          * info; merge in the public stuff in any case.
!          */
! 	scp->anyAccess = statusp->AnonymousAccess;
  
!         if (userp != NULL) {
! 		cm_AddACLCache(scp, userp, statusp->CallerAccess);
!         }
  }
  
  /* note that our stat cache info is incorrect, so force us eventually
--- 832,954 ----
   * started before that, can cause old info to be merged from the first call.
   */
  void cm_MergeStatus(cm_scache_t *scp, AFSFetchStatus *statusp, AFSVolSync *volp,
!                     cm_user_t *userp, int flags)
  {
!     // yj: i want to create some fake status for the /afs directory and the
!     // entries under that directory
  #ifdef AFS_FREELANCE_CLIENT
!     if (cm_freelanceEnabled && scp == cm_rootSCachep) {
!         osi_Log0(afsd_logp,"cm_MergeStatus Freelance cm_rootSCachep");
!         statusp->InterfaceVersion = 0x1;
          statusp->FileType = CM_SCACHETYPE_DIRECTORY;
!         statusp->LinkCount = scp->linkCount;
!         statusp->Length = cm_fakeDirSize;
!         statusp->DataVersion = cm_fakeDirVersion;
!         statusp->Author = 0x1;
!         statusp->Owner = 0x0;
!         statusp->CallerAccess = 0x9;
!         statusp->AnonymousAccess = 0x9;
!         statusp->UnixModeBits = 0x1ff;
!         statusp->ParentVnode = 0x1;
!         statusp->ParentUnique = 0x1;
!         statusp->ResidencyMask = 0;
!         statusp->ClientModTime = FakeFreelanceModTime;
!         statusp->ServerModTime = FakeFreelanceModTime;
!         statusp->Group = 0;
!         statusp->SyncCounter = 0;
!         statusp->dataVersionHigh = 0;
!     }
  #endif /* AFS_FREELANCE_CLIENT */
  
!     if (!(flags & CM_MERGEFLAG_FORCE)
!          && statusp->DataVersion < (unsigned long) scp->dataVersion) {
!         struct cm_cell *cellp;
!         struct cm_volume *volp;
! 
!         cellp = cm_FindCellByID(scp->fid.cell);
!         cm_GetVolumeByID(cellp, scp->fid.volume, userp,
!                           (cm_req_t *) NULL, &volp);
!         if (scp->cbServerp)
!             osi_Log2(afsd_logp, "old data from server %x volume %s",
!                       scp->cbServerp->addr.sin_addr.s_addr,
!                       volp->namep);
!         osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d",
!                   scp, scp->dataVersion, statusp->DataVersion);
!         /* we have a number of data fetch/store operations running
!          * concurrently, and we can tell which one executed last at the
!          * server by its mtime.
!          * Choose the one with the largest mtime, and ignore the rest.
!          *
!          * These concurrent calls are incompatible with setting the
!          * mtime, so we won't have a locally changed mtime here.
!          *
!          * We could also have ACL info for a different user than usual,
!          * in which case we have to do that part of the merge, anyway.
!          * We won't have to worry about the info being old, since we
!          * won't have concurrent calls
!          * that change file status running from this machine.
!          *
!          * Added 3/17/98:  if we see data version regression on an RO
!          * file, it's probably due to a server holding an out-of-date
!          * replica, rather than to concurrent RPC's.  Failures to
!          * release replicas are now flagged by the volserver, but only
!          * since AFS 3.4 5.22, so there are plenty of clients getting
!          * out-of-date replicas out there.
!          *
!          * If we discover an out-of-date replica, by this time it's too
!          * late to go to another server and retry.  Also, we can't
!          * reject the merge, because then there is no way for
!          * GetAccess to do its work, and the caller gets into an
!          * infinite loop.  So we just grin and bear it.
!          */
!         if (!(scp->flags & CM_SCACHEFLAG_RO))
!             return;
!     }       
!     scp->serverModTime = statusp->ServerModTime;
! 
!     if (!(scp->mask & CM_SCACHEMASK_CLIENTMODTIME)) {
!         scp->clientModTime = statusp->ClientModTime;
!     }
!     if (!(scp->mask & CM_SCACHEMASK_LENGTH)) {
!         scp->length.LowPart = statusp->Length;
!         scp->length.HighPart = 0;
!     }
! 
!     scp->serverLength.LowPart = statusp->Length;
!     scp->serverLength.HighPart = 0;
! 
!     scp->linkCount = statusp->LinkCount;
!     scp->dataVersion = statusp->DataVersion;
!     scp->owner = statusp->Owner;
!     scp->group = statusp->Group;
!     scp->unixModeBits = statusp->UnixModeBits & 07777;
! 
!     if (statusp->FileType == File)
!         scp->fileType = CM_SCACHETYPE_FILE;
!     else if (statusp->FileType == Directory)
!         scp->fileType = CM_SCACHETYPE_DIRECTORY;
!     else if (statusp->FileType == SymbolicLink) {
!         if ((scp->unixModeBits & 0111) == 0)
!             scp->fileType = CM_SCACHETYPE_MOUNTPOINT;
!         else
!             scp->fileType = CM_SCACHETYPE_SYMLINK;
!     }       
      else {
          osi_Log1(afsd_logp, "Merge, Invalid File Type, scp %x", scp);
          scp->fileType = 0;	/* invalid */
      }
!     /* and other stuff */
!     scp->parentVnode = statusp->ParentVnode;
!     scp->parentUnique = statusp->ParentUnique;
!         
!     /* and merge in the private acl cache info, if this is more than the public
!      * info; merge in the public stuff in any case.
!      */
!     scp->anyAccess = statusp->AnonymousAccess;
  
!     if (userp != NULL) {
!         cm_AddACLCache(scp, userp, statusp->CallerAccess);
!     }
  }
  
  /* note that our stat cache info is incorrect, so force us eventually
***************
*** 961,1020 ****
   */
  void cm_DiscardSCache(cm_scache_t *scp)
  {
! 	lock_AssertMutex(&scp->mx);
      if (scp->cbServerp) {
          cm_PutServer(scp->cbServerp);
  	scp->cbServerp = NULL;
      }
!         scp->cbExpires = 0;
! 	cm_dnlcPurgedp(scp);
!         cm_FreeAllACLEnts(scp);
  }
  
  void cm_AFSFidFromFid(AFSFid *afsFidp, cm_fid_t *fidp)
  {
! 	afsFidp->Volume = fidp->volume;
!         afsFidp->Vnode = fidp->vnode;
!         afsFidp->Unique = fidp->unique;
! }
  
  void cm_HoldSCache(cm_scache_t *scp)
  {
! 	lock_ObtainWrite(&cm_scacheLock);
! 	osi_assert(scp->refCount > 0);
! 	scp->refCount++;
! 	lock_ReleaseWrite(&cm_scacheLock);
  }
  
  void cm_ReleaseSCache(cm_scache_t *scp)
  {
! 	lock_ObtainWrite(&cm_scacheLock);
! 	osi_assert(scp->refCount-- > 0);
! 	lock_ReleaseWrite(&cm_scacheLock);
  }
  
  /* just look for the scp entry to get filetype */
  /* doesn't need to be perfectly accurate, so locking doesn't matter too much */
  int cm_FindFileType(cm_fid_t *fidp)
  {
!         long hash;
!         cm_scache_t *scp;
          
!         hash = CM_SCACHE_HASH(fidp);
          
!         osi_assert(fidp->cell != 0);
  
!         lock_ObtainWrite(&cm_scacheLock);
!         for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!                 if (cm_FidCmp(fidp, &scp->fid) == 0) {
!                   /*scp->refCount++;*/
!                   /*cm_AdjustLRU(scp);*/
!                   lock_ReleaseWrite(&cm_scacheLock);
!                   return scp->fileType;
!                 }
          }
!         lock_ReleaseWrite(&cm_scacheLock);
!         return 0;
  }
  
  /* dump all scp's that have reference count > 0 to a file. 
--- 961,1018 ----
   */
  void cm_DiscardSCache(cm_scache_t *scp)
  {
!     lock_AssertMutex(&scp->mx);
      if (scp->cbServerp) {
          cm_PutServer(scp->cbServerp);
  	scp->cbServerp = NULL;
      }
!     scp->cbExpires = 0;
!     cm_dnlcPurgedp(scp);
!     cm_FreeAllACLEnts(scp);
  }
  
  void cm_AFSFidFromFid(AFSFid *afsFidp, cm_fid_t *fidp)
  {
!     afsFidp->Volume = fidp->volume;
!     afsFidp->Vnode = fidp->vnode;
!     afsFidp->Unique = fidp->unique;
! }       
  
  void cm_HoldSCache(cm_scache_t *scp)
  {
!     lock_ObtainWrite(&cm_scacheLock);
!     osi_assert(scp->refCount > 0);
!     scp->refCount++;
!     lock_ReleaseWrite(&cm_scacheLock);
  }
  
  void cm_ReleaseSCache(cm_scache_t *scp)
  {
!     lock_ObtainWrite(&cm_scacheLock);
!     osi_assert(scp->refCount-- > 0);
!     lock_ReleaseWrite(&cm_scacheLock);
  }
  
  /* just look for the scp entry to get filetype */
  /* doesn't need to be perfectly accurate, so locking doesn't matter too much */
  int cm_FindFileType(cm_fid_t *fidp)
  {
!     long hash;
!     cm_scache_t *scp;
          
!     hash = CM_SCACHE_HASH(fidp);
          
!     osi_assert(fidp->cell != 0);
  
!     lock_ObtainWrite(&cm_scacheLock);
!     for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!         if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             lock_ReleaseWrite(&cm_scacheLock);
!             return scp->fileType;
          }
!     }
!     lock_ReleaseWrite(&cm_scacheLock);
!     return 0;
  }
  
  /* dump all scp's that have reference count > 0 to a file. 
Index: openafs/src/WINNT/afsd/cm_scache.h
diff -c openafs/src/WINNT/afsd/cm_scache.h:1.4.2.2 openafs/src/WINNT/afsd/cm_scache.h:1.4.2.3
*** openafs/src/WINNT/afsd/cm_scache.h:1.4.2.2	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_scache.h	Fri Nov  5 14:21:44 2004
***************
*** 24,30 ****
  typedef struct cm_accessCache {
  	osi_queue_t q;			/* queue header */
          struct cm_user *userp;		/* user having access rights */
!         long rights;			/* rights */
  } cm_accessCache_t;
  
  typedef struct cm_file_lock {
--- 24,30 ----
  typedef struct cm_accessCache {
  	osi_queue_t q;			/* queue header */
          struct cm_user *userp;		/* user having access rights */
!         unsigned long rights;		/* rights */
  } cm_accessCache_t;
  
  typedef struct cm_file_lock {
***************
*** 50,56 ****
  	osi_queue_t q;			/* lru queue; cm_scacheLock */
  	struct cm_scache *nextp;	/* next in hash; cm_scacheLock */
  	cm_fid_t fid;
!         long flags;			/* flags; locked by mx */
  
  	/* synchronization stuff */
          osi_mutex_t mx;			/* mutex for this structure */
--- 50,56 ----
  	osi_queue_t q;			/* lru queue; cm_scacheLock */
  	struct cm_scache *nextp;	/* next in hash; cm_scacheLock */
  	cm_fid_t fid;
!         unsigned long flags;		/* flags; locked by mx */
  
  	/* synchronization stuff */
          osi_mutex_t mx;			/* mutex for this structure */
***************
*** 67,83 ****
          long parentUnique;		/* for ACL callbacks */
  
  	/* local modification stat */
!         long mask;			/* for clientModTime, length and
  					 * truncPos */
  
  	/* file status */
! 	int fileType;			/* file type */
  	time_t clientModTime;	/* mtime */
          time_t serverModTime;	/* at server, for concurrent call
  					 * comparisons */
          osi_hyper_t length;		/* file length */
  	cm_prefetch_t prefetch;		/* prefetch info structure */
!         int unixModeBits;		/* unix protection mode bits */
          int linkCount;			/* link count */
          long dataVersion;		/* data version */
          long owner;			/* file owner */
--- 67,83 ----
          long parentUnique;		/* for ACL callbacks */
  
  	/* local modification stat */
!         unsigned long mask;		/* for clientModTime, length and
  					 * truncPos */
  
  	/* file status */
! 	unsigned int fileType;			/* file type */
  	time_t clientModTime;	/* mtime */
          time_t serverModTime;	/* at server, for concurrent call
  					 * comparisons */
          osi_hyper_t length;		/* file length */
  	cm_prefetch_t prefetch;		/* prefetch info structure */
!         unsigned int unixModeBits;	/* unix protection mode bits */
          int linkCount;			/* link count */
          long dataVersion;		/* data version */
          long owner;			/* file owner */
***************
*** 118,124 ****
          osi_hyper_t bulkStatProgress;	/* track bulk stats of large dirs */
  
          /* open state */
!         short openReads;		/* opens for reading */
          short openWrites;		/* open for writing */
          short openShares;		/* open for read excl */
          short openExcls;		/* open for exclusives */
--- 118,124 ----
          osi_hyper_t bulkStatProgress;	/* track bulk stats of large dirs */
  
          /* open state */
!         short openReads;		/* open for reading */
          short openWrites;		/* open for writing */
          short openShares;		/* open for read excl */
          short openExcls;		/* open for exclusives */
Index: openafs/src/WINNT/afsd/cm_vnodeops.c
diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.4 openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.5
*** openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.4	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_vnodeops.c	Fri Nov  5 14:21:44 2004
***************
*** 427,432 ****
--- 427,435 ----
   * Iterate through all entries in a directory.
   * When the function funcp is called, the buffer is locked but the
   * directory vnode is not.
+  *
+  * If the retscp parameter is not NULL, the parmp must be a 
+  * cm_lookupSearch_t object.  
   */
  long cm_ApplyDir(cm_scache_t *scp, cm_DirFuncp_t funcp, void *parmp,
                    osi_hyper_t *startOffsetp, cm_user_t *userp, cm_req_t *reqp,
***************
*** 465,481 ****
      if (retscp) 			/* if this is a lookup call */
      {
          cm_lookupSearch_t*	sp = parmp;
-         int casefold = sp->caseFold;
- 
-         sp->caseFold = 0; /* we have a strong preference for exact matches */
-         if ( *retscp = cm_dnlcLookup(scp, sp))	/* dnlc hit */
-         {
-             sp->caseFold = casefold;
-             lock_ReleaseMutex(&scp->mx);
-             return 0;
-         }
  
!         sp->caseFold = casefold;
      }	
  
      /*
--- 468,493 ----
      if (retscp) 			/* if this is a lookup call */
      {
          cm_lookupSearch_t*	sp = parmp;
  
! #ifdef AFS_FREELANCE_CLIENT
! 	/* Freelance entries never end up in the DNLC because they
! 	 * do not have an associated cm_server_t
! 	 */
!     if ( !(cm_freelanceEnabled &&
! 			sp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
! 			sp->fid.volume==AFS_FAKE_ROOT_VOL_ID ) )
! #endif /* AFS_FREELANCE_CLIENT */
! 		{
! 	        int casefold = sp->caseFold;
! 			sp->caseFold = 0; /* we have a strong preference for exact matches */
! 			if ( *retscp = cm_dnlcLookup(scp, sp))	/* dnlc hit */
! 			{
! 				sp->caseFold = casefold;
! 				lock_ReleaseMutex(&scp->mx);
! 				return 0;
! 			}
! 	        sp->caseFold = casefold;
! 		}
      }	
  
      /*
***************
*** 787,793 ****
          }
      }
      /* locked, has callback, has valid data in buffer */
!     if ((tlen = scp->length.LowPart) > 1000) return CM_ERROR_TOOBIG;
      if (tlen <= 0) {
          code = CM_ERROR_INVAL;
          goto done;
--- 799,806 ----
          }
      }
      /* locked, has callback, has valid data in buffer */
!     if ((tlen = scp->length.LowPart) > 1000) 
!         return CM_ERROR_TOOBIG;
      if (tlen <= 0) {
          code = CM_ERROR_INVAL;
          goto done;
***************
*** 1096,1101 ****
--- 1109,1121 ----
      int sysNameIndex = 0;
      cm_scache_t *scp = 0;
  
+     if ( stricmp(namep,SMB_IOCTL_FILENAME_NOSLASH) == 0 ) {
+         if (flags & CM_FLAG_CHECKPATH)
+             return CM_ERROR_NOSUCHPATH;
+         else
+             return CM_ERROR_NOSUCHFILE;
+     }
+ 
      for ( sysNameIndex = 0; sysNameIndex < MAXNUMSYSNAMES; sysNameIndex++) {
          code = cm_ExpandSysName(namep, tname, sizeof(tname), sysNameIndex);
          if (code > 0) {
***************
*** 1104,1113 ****
                  *outpScpp = scp;
                  return 0;
              }
! 			if (scp) {
! 				cm_ReleaseSCache(scp);
! 				scp = 0;
! 			}
          } else {
              return cm_LookupInternal(dscp, namep, flags, userp, reqp, outpScpp);
          }
--- 1124,1133 ----
                  *outpScpp = scp;
                  return 0;
              }
!             if (scp) {
!                 cm_ReleaseSCache(scp);
!                 scp = 0;
!             }
          } else {
              return cm_LookupInternal(dscp, namep, flags, userp, reqp, outpScpp);
          }
***************
*** 1405,1416 ****
                  if (tscp->fileType == CM_SCACHETYPE_SYMLINK) {
                      /* this is a symlink; assemble a new buffer */
                      lock_ReleaseMutex(&tscp->mx);
!                     if (symlinkCount++ >= 16) {
                          cm_ReleaseSCache(tscp);
                          cm_ReleaseSCache(dirScp);
                          if (psp) 
                              cm_FreeSpace(psp);
!                         return CM_ERROR_TOOBIG;
                      }
                      if (tc == 0) 
                          restp = "";
--- 1425,1436 ----
                  if (tscp->fileType == CM_SCACHETYPE_SYMLINK) {
                      /* this is a symlink; assemble a new buffer */
                      lock_ReleaseMutex(&tscp->mx);
!                     if (symlinkCount++ >= MAX_SYMLINK_COUNT) {
                          cm_ReleaseSCache(tscp);
                          cm_ReleaseSCache(dirScp);
                          if (psp) 
                              cm_FreeSpace(psp);
!                         return CM_ERROR_TOO_MANY_SYMLINKS;
                      }
                      if (tc == 0) 
                          restp = "";
***************
*** 1659,1667 ****
      bb.counter = 0;
      bb.bufOffset = *offsetp;
  
      /* first, assemble the file IDs we need to stat */
!     code = cm_ApplyDir(dscp, cm_TryBulkProc, (void *) &bb, offsetp, userp,
!                         reqp, NULL);
  
      /* if we failed, bail out early */
      if (code && code != CM_ERROR_STOPNOW) return;
--- 1679,1688 ----
      bb.counter = 0;
      bb.bufOffset = *offsetp;
  
+     lock_ReleaseMutex(&dscp->mx);
      /* first, assemble the file IDs we need to stat */
!     code = cm_ApplyDir(dscp, cm_TryBulkProc, (void *) &bb, offsetp, userp, reqp, NULL);
!     lock_ObtainMutex(&dscp->mx);
  
      /* if we failed, bail out early */
      if (code && code != CM_ERROR_STOPNOW) return;
***************
*** 1671,1677 ****
       * time.
       */
      filex = 0;
!     while(filex < bb.counter) {
          filesThisCall = bb.counter - filex;
          if (filesThisCall > AFSCBMAX) filesThisCall = AFSCBMAX;
  
--- 1692,1698 ----
       * time.
       */
      filex = 0;
!     while (filex < bb.counter) {
          filesThisCall = bb.counter - filex;
          if (filesThisCall > AFSCBMAX) filesThisCall = AFSCBMAX;
  
Index: openafs/src/WINNT/afsd/cm_vnodeops.h
diff -c openafs/src/WINNT/afsd/cm_vnodeops.h:1.5.2.3 openafs/src/WINNT/afsd/cm_vnodeops.h:1.5.2.4
*** openafs/src/WINNT/afsd/cm_vnodeops.h:1.5.2.3	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_vnodeops.h	Fri Nov  5 14:21:45 2004
***************
*** 154,157 ****
--- 154,158 ----
  
  extern long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead);
  
+ #define MAX_SYMLINK_COUNT 16
  #endif /*  __CM_VNODEOPS_H_ENV__ */
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.55.2.3 openafs/src/WINNT/afsd/smb.c:1.55.2.4
*** openafs/src/WINNT/afsd/smb.c:1.55.2.3	Mon Oct 18 00:09:27 2004
--- openafs/src/WINNT/afsd/smb.c	Fri Nov  5 14:21:45 2004
***************
*** 387,396 ****
  {
      unsigned int attrs;
  
!     if (scp->fileType == CM_SCACHETYPE_DIRECTORY
!          || scp->fileType == CM_SCACHETYPE_MOUNTPOINT)
          attrs = SMB_ATTR_DIRECTORY;
!     else
          attrs = 0;
  
      /*
--- 387,407 ----
  {
      unsigned int attrs;
  
!     if ( scp->fileType == CM_SCACHETYPE_DIRECTORY ||
!          scp->fileType == CM_SCACHETYPE_MOUNTPOINT) 
!     {
          attrs = SMB_ATTR_DIRECTORY;
! #ifdef SPECIAL_FOLDERS
! #ifdef AFS_FREELANCE_CLIENT
!         if ( cm_freelanceEnabled &&
!              scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && 
!              scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
!              scp->fid.vnode==0x1 && scp->fid.unique==0x1) {
!             attrs |= SMB_ATTR_SYSTEM;		/* FILE_ATTRIBUTE_SYSTEM */
!         }
! #endif /* AFS_FREELANCE_CLIENT */
! #endif /* SPECIAL_FOLDERS */
!     } else
          attrs = 0;
  
      /*
***************
*** 1300,1306 ****
  {
      int matchType = 0;
      smb_findShare_rock_t * vrock = (smb_findShare_rock_t *) rockp;
!     if(!strnicmp(dep->name, vrock->shareName, 12)) {
          if(!stricmp(dep->name, vrock->shareName))
              matchType = SMB_FINDSHARE_EXACT_MATCH;
          else
--- 1311,1317 ----
  {
      int matchType = 0;
      smb_findShare_rock_t * vrock = (smb_findShare_rock_t *) rockp;
!     if (!strnicmp(dep->name, vrock->shareName, 12)) {
          if(!stricmp(dep->name, vrock->shareName))
              matchType = SMB_FINDSHARE_EXACT_MATCH;
          else
***************
*** 1464,1470 ****
              (uidp? (uidp->unp ? uidp->unp->userp : NULL) : NULL), &req, NULL);
          cm_ReleaseSCache(cm_rootSCachep);
  
!         if(vrock.matchType) {
              sprintf(pathName,"/%s/",vrock.match);
              *pathNamep = strdup(strlwr(pathName));
              free(vrock.match);
--- 1475,1481 ----
              (uidp? (uidp->unp ? uidp->unp->userp : NULL) : NULL), &req, NULL);
          cm_ReleaseSCache(cm_rootSCachep);
  
!         if (vrock.matchType) {
              sprintf(pathName,"/%s/",vrock.match);
              *pathNamep = strdup(strlwr(pathName));
              free(vrock.match);
***************
*** 1546,1556 ****
  /* find a dir search structure by cookie value, and return it held.
   * Must be called with smb_globalLock held.
   */
! smb_dirSearch_t *smb_FindDirSearchNL(long cookie)
  {
      smb_dirSearch_t *dsp;
          
!     for(dsp = smb_firstDirSearchp; dsp; dsp = (smb_dirSearch_t *) osi_QNext(&dsp->q)) {
          if (dsp->cookie == cookie) {
              if (dsp != smb_firstDirSearchp) {
                  /* move to head of LRU queue, too, if we're not already there */
--- 1557,1567 ----
  /* find a dir search structure by cookie value, and return it held.
   * Must be called with smb_globalLock held.
   */
! smb_dirSearch_t *smb_FindDirSearchNoLock(long cookie)
  {
      smb_dirSearch_t *dsp;
          
!     for (dsp = smb_firstDirSearchp; dsp; dsp = (smb_dirSearch_t *) osi_QNext(&dsp->q)) {
          if (dsp->cookie == cookie) {
              if (dsp != smb_firstDirSearchp) {
                  /* move to head of LRU queue, too, if we're not already there */
***************
*** 1562,1568 ****
--- 1573,1581 ----
                  if (!smb_lastDirSearchp)
                      smb_lastDirSearchp = (smb_dirSearch_t *) &dsp->q;
              }
+             lock_ObtainMutex(&dsp->mx);
              dsp->refCount++;
+             lock_ReleaseMutex(&dsp->mx);
              break;
          }
      }
***************
*** 1572,1581 ****
  void smb_DeleteDirSearch(smb_dirSearch_t *dsp)
  {
      lock_ObtainWrite(&smb_globalLock);
-     dsp->flags |= SMB_DIRSEARCH_DELETE;
-     lock_ReleaseWrite(&smb_globalLock);
      lock_ObtainMutex(&dsp->mx);
!     if(dsp->scp != NULL) {
          lock_ObtainMutex(&dsp->scp->mx);
          if (dsp->flags & SMB_DIRSEARCH_BULKST) {
              dsp->flags &= ~SMB_DIRSEARCH_BULKST;
--- 1585,1593 ----
  void smb_DeleteDirSearch(smb_dirSearch_t *dsp)
  {
      lock_ObtainWrite(&smb_globalLock);
      lock_ObtainMutex(&dsp->mx);
!     dsp->flags |= SMB_DIRSEARCH_DELETE;
!     if (dsp->scp != NULL) {
          lock_ObtainMutex(&dsp->scp->mx);
          if (dsp->flags & SMB_DIRSEARCH_BULKST) {
              dsp->flags &= ~SMB_DIRSEARCH_BULKST;
***************
*** 1585,1621 ****
          lock_ReleaseMutex(&dsp->scp->mx);
      }	
      lock_ReleaseMutex(&dsp->mx);
  }               
  
! void smb_ReleaseDirSearch(smb_dirSearch_t *dsp)
  {
      cm_scache_t *scp;
          
      scp = NULL;
  
!     lock_ObtainWrite(&smb_globalLock);
      osi_assert(dsp->refCount-- > 0);
      if (dsp->refCount == 0 && (dsp->flags & SMB_DIRSEARCH_DELETE)) {
          if (&dsp->q == (osi_queue_t *) smb_lastDirSearchp)
              smb_lastDirSearchp = (smb_dirSearch_t *) osi_QPrev(&smb_lastDirSearchp->q);
          osi_QRemove((osi_queue_t **) &smb_firstDirSearchp, &dsp->q);
          lock_FinalizeMutex(&dsp->mx);
          scp = dsp->scp;
          free(dsp);
      }
-     lock_ReleaseWrite(&smb_globalLock);
- 
      /* do this now to avoid spurious locking hierarchy creation */
      if (scp) cm_ReleaseSCache(scp);
  }       
  
  /* find a dir search structure by cookie value, and return it held */
  smb_dirSearch_t *smb_FindDirSearch(long cookie)
  {
      smb_dirSearch_t *dsp;
  
      lock_ObtainWrite(&smb_globalLock);
!     dsp = smb_FindDirSearchNL(cookie);
      lock_ReleaseWrite(&smb_globalLock);
      return dsp;
  }
--- 1597,1643 ----
          lock_ReleaseMutex(&dsp->scp->mx);
      }	
      lock_ReleaseMutex(&dsp->mx);
+     lock_ReleaseWrite(&smb_globalLock);
  }               
  
! /* Must be called with the smb_globalLock held */
! void smb_ReleaseDirSearchNoLock(smb_dirSearch_t *dsp)
  {
      cm_scache_t *scp;
          
      scp = NULL;
  
!     lock_ObtainMutex(&dsp->mx);
      osi_assert(dsp->refCount-- > 0);
      if (dsp->refCount == 0 && (dsp->flags & SMB_DIRSEARCH_DELETE)) {
          if (&dsp->q == (osi_queue_t *) smb_lastDirSearchp)
              smb_lastDirSearchp = (smb_dirSearch_t *) osi_QPrev(&smb_lastDirSearchp->q);
          osi_QRemove((osi_queue_t **) &smb_firstDirSearchp, &dsp->q);
+         lock_ReleaseMutex(&dsp->mx);
          lock_FinalizeMutex(&dsp->mx);
          scp = dsp->scp;
          free(dsp);
+     } else {
+         lock_ReleaseMutex(&dsp->mx);
      }
      /* do this now to avoid spurious locking hierarchy creation */
      if (scp) cm_ReleaseSCache(scp);
  }       
  
+ void smb_ReleaseDirSearch(smb_dirSearch_t *dsp)
+ {
+     lock_ObtainWrite(&smb_globalLock);
+     smb_ReleaseDirSearchNoLock(dsp);
+     lock_ReleaseWrite(&smb_globalLock);
+ }       
+ 
  /* find a dir search structure by cookie value, and return it held */
  smb_dirSearch_t *smb_FindDirSearch(long cookie)
  {
      smb_dirSearch_t *dsp;
  
      lock_ObtainWrite(&smb_globalLock);
!     dsp = smb_FindDirSearchNoLock(cookie);
      lock_ReleaseWrite(&smb_globalLock);
      return dsp;
  }
***************
*** 1650,1664 ****
          }
  
          /* don't do more than this */
!         if (victimCount >= SMB_DIRSEARCH_GCMAX) break;
      }
  	
      /* now release them */
!     lock_ReleaseWrite(&smb_globalLock);
!     for(i = 0; i < victimCount; i++) {
!         smb_ReleaseDirSearch(victimsp[i]);
      }
-     lock_ObtainWrite(&smb_globalLock);
  }
  
  /* function for allocating a dir search entry.  We need these to remember enough context
--- 1672,1685 ----
          }
  
          /* don't do more than this */
!         if (victimCount >= SMB_DIRSEARCH_GCMAX) 
!             break;
      }
  	
      /* now release them */
!     for (i = 0; i < victimCount; i++) {
!         smb_ReleaseDirSearchNoLock(victimsp[i]);
      }
  }
  
  /* function for allocating a dir search entry.  We need these to remember enough context
***************
*** 1677,1701 ****
      counter = 0;
  
      /* what's the biggest ID allowed in this version of the protocol */
!     if (isV3) maxAllowed = 65535;
!     else maxAllowed = 255;
  
!     while(1) {
          /* twice so we have enough tries to find guys we GC after one pass;
           * 10 extra is just in case I mis-counted.
           */
!         if (++counter > 2*maxAllowed+10) osi_panic("afsd: dir search cookie leak",
!                                                     __FILE__, __LINE__);
          if (smb_dirSearchCounter > maxAllowed) {	
              smb_dirSearchCounter = 1;
!             smb_GCDirSearches(isV3);	/* GC some (drops global lock) */
          }	
!         dsp = smb_FindDirSearchNL(smb_dirSearchCounter);
          if (dsp) {
              /* don't need to watch for refcount zero and deleted, since
              * we haven't dropped the global lock.
              */
              dsp->refCount--;
              ++smb_dirSearchCounter;
              continue;
          }	
--- 1698,1724 ----
      counter = 0;
  
      /* what's the biggest ID allowed in this version of the protocol */
!     maxAllowed = isV3 ? 65535 : 255;
  
!     while (1) {
          /* twice so we have enough tries to find guys we GC after one pass;
           * 10 extra is just in case I mis-counted.
           */
!         if (++counter > 2*maxAllowed+10) 
!             osi_panic("afsd: dir search cookie leak", __FILE__, __LINE__);
! 
          if (smb_dirSearchCounter > maxAllowed) {	
              smb_dirSearchCounter = 1;
!             smb_GCDirSearches(isV3);	/* GC some */
          }	
!         dsp = smb_FindDirSearchNoLock(smb_dirSearchCounter);
          if (dsp) {
              /* don't need to watch for refcount zero and deleted, since
              * we haven't dropped the global lock.
              */
+             lock_ObtainMutex(&dsp->mx);
              dsp->refCount--;
+             lock_ReleaseMutex(&dsp->mx);
              ++smb_dirSearchCounter;
              continue;
          }	
***************
*** 1703,1709 ****
          dsp = malloc(sizeof(*dsp));
          memset(dsp, 0, sizeof(*dsp));
          osi_QAdd((osi_queue_t **) &smb_firstDirSearchp, &dsp->q);
!         if (!smb_lastDirSearchp) smb_lastDirSearchp = (smb_dirSearch_t *) &dsp->q;
          dsp->cookie = smb_dirSearchCounter;
          ++smb_dirSearchCounter;
          dsp->refCount = 1;
--- 1726,1733 ----
          dsp = malloc(sizeof(*dsp));
          memset(dsp, 0, sizeof(*dsp));
          osi_QAdd((osi_queue_t **) &smb_firstDirSearchp, &dsp->q);
!         if (!smb_lastDirSearchp) 
!             smb_lastDirSearchp = (smb_dirSearch_t *) &dsp->q;
          dsp->cookie = smb_dirSearchCounter;
          ++smb_dirSearchCounter;
          dsp->refCount = 1;
***************
*** 2275,2280 ****
--- 2299,2311 ----
      else if (code == CM_ERROR_GSSCONTINUE) {
          NTStatus = 0xC0000016L; /* more processing required */
      }
+     else if (code == CM_ERROR_TOO_MANY_SYMLINKS) {
+ #ifdef COMMENT
+         NTStatus = 0xC0000280L; /* reparse point not resolved */
+ #else
+         NTStatus = 0xC0000022L; /* Access Denied */
+ #endif
+     }
      else {
          NTStatus = 0xC0982001L;	/* SMB non-specific error */
      }
***************
*** 3402,3408 ****
      else {
          spacep = inp->spacep;
          smb_StripLastComponent(spacep->data, NULL, pathp);
-         lock_ReleaseMutex(&dsp->mx);
          code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
          if (code) {
              lock_ReleaseMutex(&dsp->mx);
--- 3433,3438 ----
***************
*** 3413,3421 ****
          }
          code = cm_NameI(cm_rootSCachep, spacep->data,
                          caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
-         lock_ObtainMutex(&dsp->mx);
          if (code == 0) {
!             if (dsp->scp != 0) cm_ReleaseSCache(dsp->scp);
              dsp->scp = scp;
              /* we need one hold for the entry we just stored into,
               * and one for our own processing.  When we're done with this
--- 3443,3451 ----
          }
          code = cm_NameI(cm_rootSCachep, spacep->data,
                          caseFold | CM_FLAG_FOLLOW, userp, tidPathp, &req, &scp);
          if (code == 0) {
!             if (dsp->scp != 0) 
!                 cm_ReleaseSCache(dsp->scp);
              dsp->scp = scp;
              /* we need one hold for the entry we just stored into,
               * and one for our own processing.  When we're done with this
***************
*** 3520,3532 ****
              lock_ObtainRead(&scp->bufCreateLock);
              code = buf_Get(scp, &thyper, &bufferp);
              lock_ReleaseRead(&scp->bufCreateLock);
  
              /* now, if we're doing a star match, do bulk fetching of all of 
               * the status info for files in the dir.
               */
              if (starPattern) {
!                 smb_ApplyDirListPatches(&dirListPatchesp, userp,
!                                          &req);
                  if ((dsp->flags & SMB_DIRSEARCH_BULKST) &&
                       LargeIntegerGreaterThanOrEqualTo(thyper, 
                                                        scp->bulkStatProgress)) {
--- 3550,3563 ----
              lock_ObtainRead(&scp->bufCreateLock);
              code = buf_Get(scp, &thyper, &bufferp);
              lock_ReleaseRead(&scp->bufCreateLock);
+             lock_ObtainMutex(&dsp->mx);
  
              /* now, if we're doing a star match, do bulk fetching of all of 
               * 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, 
                                                        scp->bulkStatProgress)) {
***************
*** 3539,3549 ****
                      } else
                          cm_TryBulkStat(scp, &thyper, userp, &req);
                  }
              }
! 
!             lock_ObtainMutex(&scp->mx);
              if (code) 
                  break;
              bufferOffset = thyper;
  
              /* now get the data in the cache */
--- 3570,3582 ----
                      } else
                          cm_TryBulkStat(scp, &thyper, userp, &req);
                  }
+             } else {
+                 lock_ObtainMutex(&scp->mx);
              }
!             lock_ReleaseMutex(&dsp->mx);
              if (code) 
                  break;
+ 
              bufferOffset = thyper;
  
              /* now get the data in the cache */
***************
*** 4917,4924 ****
      rock.name = pathp;
      rock.vnode = scp;
  
!     code = cm_ApplyDir(dscp, smb_FullNameProc, &rock, NULL, 
!                        userp, reqp, NULL); 
      if (code == CM_ERROR_STOPNOW)
          *newPathp = rock.fullName;
      else
--- 4950,4956 ----
      rock.name = pathp;
      rock.vnode = scp;
  
!     code = cm_ApplyDir(dscp, smb_FullNameProc, &rock, NULL, userp, reqp, NULL); 
      if (code == CM_ERROR_STOPNOW)
          *newPathp = rock.fullName;
      else
***************
*** 6932,6937 ****
--- 6964,6970 ----
      }
  
      afsd_ForceTrace(TRUE);
+     buf_ForceTrace(TRUE);
      return EXCEPTION_CONTINUE_SEARCH;
  }       
  #endif
Index: openafs/src/WINNT/afsd/smb3.c
diff -c openafs/src/WINNT/afsd/smb3.c:1.42.2.9 openafs/src/WINNT/afsd/smb3.c:1.42.2.10
*** openafs/src/WINNT/afsd/smb3.c:1.42.2.9	Mon Oct 18 00:09:28 2004
--- openafs/src/WINNT/afsd/smb3.c	Fri Nov  5 14:21:46 2004
***************
*** 72,80 ****
      unsigned long attrs;
  
      if (scp->fileType == CM_SCACHETYPE_DIRECTORY ||
!         scp->fileType == CM_SCACHETYPE_MOUNTPOINT)
          attrs = SMB_ATTR_DIRECTORY;
!     else
          attrs = 0;
      /*
       * We used to mark a file RO if it was in an RO volume, but that
--- 72,91 ----
      unsigned long attrs;
  
      if (scp->fileType == CM_SCACHETYPE_DIRECTORY ||
!         scp->fileType == CM_SCACHETYPE_MOUNTPOINT) 
!     {
          attrs = SMB_ATTR_DIRECTORY;
! #ifdef SPECIAL_FOLDERS
! #ifdef AFS_FREELANCE_CLIENT
!         if ( cm_freelanceEnabled &&
!              scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && 
!              scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
!              scp->fid.vnode==0x1 && scp->fid.unique==0x1) {
!             attrs |= SMB_ATTR_SYSTEM;		/* FILE_ATTRIBUTE_SYSTEM */
!         }
! #endif /* AFS_FREELANCE_CLIENT */
! #endif /* SPECIAL_FOLDERS */
!     } else
          attrs = 0;
      /*
       * We used to mark a file RO if it was in an RO volume, but that
***************
*** 2477,2484 ****
      rock.shortName = shortName;
      rock.vnode = vnode;
      rock.maskp = lastNamep;
!     code = cm_ApplyDir(dscp, cm_GetShortNameProc, &rock, &thyper, userp,
!                         reqp, NULL);
  
      cm_ReleaseSCache(dscp);
  
--- 2488,2494 ----
      rock.shortName = shortName;
      rock.vnode = vnode;
      rock.maskp = lastNamep;
!     code = cm_ApplyDir(dscp, cm_GetShortNameProc, &rock, &thyper, userp, reqp, NULL);
  
      cm_ReleaseSCache(dscp);
  
***************
*** 3575,3582 ****
          pathp = ((char *) p->parmsp) + 12;	/* points to path */
          nextCookie = 0;
          maskp = strrchr(pathp, '\\');
!         if (maskp == NULL) maskp = pathp;
!         else maskp++;	/* skip over backslash */
          strcpy(dsp->mask, maskp);	/* and save mask */
          /* track if this is likely to match a lot of entries */
          starPattern = smb_V3IsStarMask(maskp);
--- 3585,3594 ----
          pathp = ((char *) p->parmsp) + 12;	/* points to path */
          nextCookie = 0;
          maskp = strrchr(pathp, '\\');
!         if (maskp == NULL) 
!             maskp = pathp;
!         else 
!             maskp++;	/* skip over backslash */
          strcpy(dsp->mask, maskp);	/* and save mask */
          /* track if this is likely to match a lot of entries */
          starPattern = smb_V3IsStarMask(maskp);
***************
*** 3585,3591 ****
          osi_assert(p->opcode == 2);
          /* find next; obtain basic parameters from request or open dir file */
          dsp = smb_FindDirSearch(p->parmsp[0]);
!         if (!dsp) return CM_ERROR_BADFD;
          attribute = dsp->attribute;
          maxCount = p->parmsp[1];
          infoLevel = p->parmsp[2];
--- 3597,3604 ----
          osi_assert(p->opcode == 2);
          /* find next; obtain basic parameters from request or open dir file */
          dsp = smb_FindDirSearch(p->parmsp[0]);
!         if (!dsp) 
!             return CM_ERROR_BADFD;
          attribute = dsp->attribute;
          maxCount = p->parmsp[1];
          infoLevel = p->parmsp[2];
***************
*** 3653,3662 ****
      else {
          spacep = cm_GetSpace();
          smb_StripLastComponent(spacep->data, NULL, pathp);
-         lock_ReleaseMutex(&dsp->mx);
- 
          code = smb_LookupTIDPath(vcp, p->tid, &tidPathp);
          if (code) {
              cm_ReleaseUser(userp);
              smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOFILES);
              smb_FreeTran2Packet(outp);
--- 3666,3674 ----
      else {
          spacep = cm_GetSpace();
          smb_StripLastComponent(spacep->data, NULL, pathp);
          code = smb_LookupTIDPath(vcp, p->tid, &tidPathp);
          if (code) {
+             lock_ReleaseMutex(&dsp->mx);
              cm_ReleaseUser(userp);
              smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOFILES);
              smb_FreeTran2Packet(outp);
***************
*** 3669,3677 ****
                          userp, tidPathp, &req, &scp);
          cm_FreeSpace(spacep);
  
-         lock_ObtainMutex(&dsp->mx);
          if (code == 0) {
!             if (dsp->scp != 0) cm_ReleaseSCache(dsp->scp);
              dsp->scp = scp;
              /* we need one hold for the entry we just stored into,
               * and one for our own processing.  When we're done
--- 3681,3689 ----
                          userp, tidPathp, &req, &scp);
          cm_FreeSpace(spacep);
  
          if (code == 0) {
!             if (dsp->scp != 0) 
!                 cm_ReleaseSCache(dsp->scp);
              dsp->scp = scp;
              /* we need one hold for the entry we just stored into,
               * and one for our own processing.  When we're done
***************
*** 3784,3789 ****
--- 3796,3802 ----
              lock_ObtainRead(&scp->bufCreateLock);
              code = buf_Get(scp, &thyper, &bufferp);
              lock_ReleaseRead(&scp->bufCreateLock);
+             lock_ObtainMutex(&dsp->mx);
  
              /* now, if we're doing a star match, do bulk fetching
               * of all of the status info for files in the dir.
***************
*** 3792,3797 ****
--- 3805,3811 ----
                  smb_ApplyV3DirListPatches(scp, &dirListPatchesp,
                                             infoLevel, userp,
                                             &req);
+                 lock_ObtainMutex(&scp->mx);
                  if ((dsp->flags & SMB_DIRSEARCH_BULKST) &&
                      LargeIntegerGreaterThanOrEqualTo(thyper, scp->bulkStatProgress)) {
                      /* Don't bulk stat if risking timeout */
***************
*** 3803,3812 ****
                      } else
                          cm_TryBulkStat(scp, &thyper, userp, &req);
                  }
              }
  
-             lock_ObtainMutex(&scp->mx);
-             if (code) break;
              bufferOffset = thyper;
  
              /* now get the data in the cache */
--- 3817,3829 ----
                      } else
                          cm_TryBulkStat(scp, &thyper, userp, &req);
                  }
+             } else {
+                 lock_ObtainMutex(&scp->mx);
              }
+             lock_ReleaseMutex(&dsp->mx);
+             if (code) 
+                 break;
  
              bufferOffset = thyper;
  
              /* now get the data in the cache */
Index: openafs/src/WINNT/afsd/symlink.c
diff -c openafs/src/WINNT/afsd/symlink.c:1.2 openafs/src/WINNT/afsd/symlink.c:1.2.20.1
*** openafs/src/WINNT/afsd/symlink.c:1.2	Sat Nov  4 05:01:45 2000
--- openafs/src/WINNT/afsd/symlink.c	Fri Nov  5 14:21:47 2004
***************
*** 22,29 ****
  #include <osi.h>
  #include <afsint.h>
  
- typedef long afs_int32;
- 
  #include "fs_utils.h"
  #include "cmd.h"
  
--- 22,27 ----
***************
*** 243,248 ****
--- 241,251 ----
      /* create symlink with a special pioctl for Windows NT, since it doesn't
       * have a symlink system call.
       */
+ 
+     /* TODO: Code needs to go here to prevent the creation of symlinks
+      * in \\AFS\all when not in the "AFS Client Admins" group.
+      */
+ 
      blob.out_size = 0;
      blob.in_size = 1 + strlen(space);
      blob.in = space;
Index: openafs/src/WINNT/afssvrcfg/NTMakefile
diff -c openafs/src/WINNT/afssvrcfg/NTMakefile:1.6 openafs/src/WINNT/afssvrcfg/NTMakefile:1.6.2.1
*** openafs/src/WINNT/afssvrcfg/NTMakefile:1.6	Fri Apr  2 01:56:24 2004
--- openafs/src/WINNT/afssvrcfg/NTMakefile	Fri Nov  5 14:21:49 2004
***************
*** 90,95 ****
--- 90,98 ----
  # Local clean target; augments predefined clean target
  
  clean::
+ 	$(CD) lang
+ 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
+ 	$(CD) ..
  
  mkdir:
  	-mkdir $(OUT)\lang
Index: openafs/src/WINNT/afssvrcpa/NTMakefile
diff -c openafs/src/WINNT/afssvrcpa/NTMakefile:1.5 openafs/src/WINNT/afssvrcpa/NTMakefile:1.5.2.1
*** openafs/src/WINNT/afssvrcpa/NTMakefile:1.5	Thu Feb 26 14:22:45 2004
--- openafs/src/WINNT/afssvrcpa/NTMakefile	Fri Nov  5 14:21:50 2004
***************
*** 55,61 ****
  # Local clean target; augments predefined clean target
  
  clean::
! 
  
  mkdir:
  	-mkdir $(OUT)\lang
--- 55,63 ----
  # Local clean target; augments predefined clean target
  
  clean::
! 	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
! 	$(CD) ..
  
  mkdir:
  	-mkdir $(OUT)\lang
Index: openafs/src/WINNT/afssvrmgr/NTMakefile
diff -c openafs/src/WINNT/afssvrmgr/NTMakefile:1.4 openafs/src/WINNT/afssvrmgr/NTMakefile:1.4.2.1
*** openafs/src/WINNT/afssvrmgr/NTMakefile:1.4	Fri Nov 21 02:59:51 2003
--- openafs/src/WINNT/afssvrmgr/NTMakefile	Fri Nov  5 14:21:51 2004
***************
*** 116,124 ****
  
  $(OUT)\svrmgr_stub.res : AFS_component_version_number.h
  
  mkdir:
  	-mkdir $(OUT)\lang
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
! 	
--- 116,129 ----
  
  $(OUT)\svrmgr_stub.res : AFS_component_version_number.h
  
+ clean::
+ 	$(CD) lang
+ 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
+ 	$(CD) ..
+ 
  mkdir:
  	-mkdir $(OUT)\lang
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
! 
Index: openafs/src/WINNT/afsusrmgr/NTMakefile
diff -c openafs/src/WINNT/afsusrmgr/NTMakefile:1.4 openafs/src/WINNT/afsusrmgr/NTMakefile:1.4.2.1
*** openafs/src/WINNT/afsusrmgr/NTMakefile:1.4	Fri Nov 21 02:59:52 2003
--- openafs/src/WINNT/afsusrmgr/NTMakefile	Fri Nov  5 14:21:52 2004
***************
*** 93,98 ****
--- 93,103 ----
  
  $(OUT)\AfsUsrMgr_stub.res : AFS_component_version_number.h
  
+ clean::
+ 	$(CD) lang
+ 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
+ 	$(CD) ..
+ 
  mkdir:
  	-mkdir $(OUT)\lang
  	cd lang
Index: openafs/src/WINNT/client_config/config.cpp
diff -c openafs/src/WINNT/client_config/config.cpp:1.5 openafs/src/WINNT/client_config/config.cpp:1.5.2.1
*** openafs/src/WINNT/client_config/config.cpp:1.5	Sat Mar 20 13:00:01 2004
--- openafs/src/WINNT/client_config/config.cpp	Fri Nov  5 14:21:52 2004
***************
*** 671,721 ****
  
  void Config_GetSysName (LPTSTR pszName)
  {
!    if (!Config_ReadGlobalString (TEXT("SysName"), pszName, MAX_PATH))
!       lstrcpy (pszName, TEXT("i386_nt40"));
  }
  
  
  BOOL Config_SetSysName (LPCTSTR pszName, ULONG *pStatus)
  {
!    BOOL rc = TRUE;
!    ULONG status = 0;
! 
!    if (Config_GetServiceState() == SERVICE_RUNNING)
!       {
!       struct {
!          ULONG cbData;
!          TCHAR szData[ PIOCTL_MAXSIZE ];
!       } InData;
!       memset (&InData, 0x00, sizeof(InData));
!       InData.cbData = lstrlen(pszName);
!       lstrcpy (InData.szData, pszName);
! 
!       BYTE OutData[ PIOCTL_MAXSIZE ];
!       memset (OutData, 0x00, sizeof(OutData));
! 
!       struct ViceIoctl IOInfo;
!       IOInfo.in_size = sizeof(ULONG) +lstrlen(pszName) +1;
!       IOInfo.in = (char *)&InData;
!       IOInfo.out = (char *)OutData;
!       IOInfo.out_size = PIOCTL_MAXSIZE;
  
!       if ((status = pioctl (0, VIOC_AFS_SYSNAME, &IOInfo, 1)) != 0)
!          {
!          rc = FALSE;
!          }
!       }
! 
!    if (rc)
!       {
!       Config_WriteGlobalString (TEXT("SysName"), pszName);
!       }
! 
!    if (pStatus && !rc)
!       *pStatus = status;
!    if (!rc)
!       Message (MB_ICONHAND, GetErrorTitle(), IDS_FAILCONFIG_SYSNAME, TEXT("%ld"), status);
!    return rc;
  }
  
  
--- 671,737 ----
  
  void Config_GetSysName (LPTSTR pszName)
  {
!     if (!Config_ReadGlobalString (TEXT("SysName"), pszName, MAX_PATH))
!         lstrcpy (pszName, TEXT("i386_nt40"));
  }
  
  
  BOOL Config_SetSysName (LPCTSTR pszName, ULONG *pStatus)
  {
!     BOOL rc = TRUE;
!     ULONG status = 0;
  
!     if (Config_GetServiceState() == SERVICE_RUNNING)
!     {
!         struct {
!             ULONG cbData;
!             TCHAR szData[ PIOCTL_MAXSIZE ];
!         } InData;
!         memset (&InData, 0x00, sizeof(InData));
!         USHORT i=0, j=0, len=lstrlen(pszName);
!         
!         if ( len == 0 ) {
!             Message (MB_ICONHAND, GetErrorTitle(), IDS_FAILCONFIG_SYSNAME, TEXT("A sysname must be specified"));
!             return(-1);
!         }
! 
!         while ( pszName[i] ) {
!             if ( !isspace(pszName[i]) ) {
!                 InData.szData[j++] = pszName[i];
!             } else if (InData.szData[j-1] != '\0') {
!                 InData.szData[j++] = '\0';
!                 InData.cbData++;
!             }
!             i++;
!         }
!         InData.szData[j++] = '\0';
!         InData.cbData++;      /* one word */
! 
!         BYTE OutData[ PIOCTL_MAXSIZE ];
!         memset (OutData, 0x00, sizeof(OutData));
! 
!         struct ViceIoctl IOInfo;
!         IOInfo.in_size = sizeof(ULONG) + j;
!         IOInfo.in = (char *)&InData;
!         IOInfo.out = (char *)OutData;
!         IOInfo.out_size = PIOCTL_MAXSIZE;
! 
!         if ((status = pioctl (0, VIOC_AFS_SYSNAME, &IOInfo, 1)) != 0)
!         {
!             rc = FALSE;
!         }
!     }
! 
!     if (rc)
!     {
!         Config_WriteGlobalString (TEXT("SysName"), pszName);
!     }
! 
!     if (pStatus && !rc)
!         *pStatus = status;
!     if (!rc)
!         Message (MB_ICONHAND, GetErrorTitle(), IDS_FAILCONFIG_SYSNAME, TEXT("%ld"), status);
!     return rc;
  }
  
  
Index: openafs/src/WINNT/client_creds/NTMakefile
diff -c openafs/src/WINNT/client_creds/NTMakefile:1.11 openafs/src/WINNT/client_creds/NTMakefile:1.11.2.1
*** openafs/src/WINNT/client_creds/NTMakefile:1.11	Fri May  7 10:56:00 2004
--- openafs/src/WINNT/client_creds/NTMakefile	Fri Nov  5 14:21:53 2004
***************
*** 127,132 ****
--- 127,137 ----
  
  $(OUT)\afscreds_stub.res : afscreds_stub.rc AFS_component_version_number.h
  
+ clean::
+ 	$(CD) lang
+ 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
+ 	$(CD) ..
+ 
  mkdir:
  	-mkdir $(OUT)\lang
  	cd lang
Index: openafs/src/WINNT/client_exp/make_symbolic_link_dlg.cpp
diff -c openafs/src/WINNT/client_exp/make_symbolic_link_dlg.cpp:1.1 openafs/src/WINNT/client_exp/make_symbolic_link_dlg.cpp:1.1.2.1
*** openafs/src/WINNT/client_exp/make_symbolic_link_dlg.cpp:1.1	Fri Nov 21 02:59:58 2003
--- openafs/src/WINNT/client_exp/make_symbolic_link_dlg.cpp	Fri Nov  5 14:21:55 2004
***************
*** 51,57 ****
  	DDX_Text(pDX, IDC_NAME, m_strName);
  	DDV_MaxChars(pDX, m_strName, 63);
  	DDX_Text(pDX, IDC_DIR, m_strDir);
! 	DDV_MaxChars(pDX, m_strDir, 63);
  	//}}AFX_DATA_MAP
  }
  
--- 51,57 ----
  	DDX_Text(pDX, IDC_NAME, m_strName);
  	DDV_MaxChars(pDX, m_strName, 63);
  	DDX_Text(pDX, IDC_DIR, m_strDir);
! 	DDV_MaxChars(pDX, m_strDir, 255);
  	//}}AFX_DATA_MAP
  }
  
Index: openafs/src/WINNT/client_exp/lang/en_US/afs_shl_ext.rc
diff -c openafs/src/WINNT/client_exp/lang/en_US/afs_shl_ext.rc:1.6 openafs/src/WINNT/client_exp/lang/en_US/afs_shl_ext.rc:1.6.2.1
*** openafs/src/WINNT/client_exp/lang/en_US/afs_shl_ext.rc:1.6	Sat Apr  3 21:41:11 2004
--- openafs/src/WINNT/client_exp/lang/en_US/afs_shl_ext.rc	Fri Nov  5 14:21:55 2004
***************
*** 429,435 ****
      PUSHBUTTON      "OK",IDOK,22,53,45,14
      PUSHBUTTON      "Cancel",IDCANCEL,92,53,45,14
      PUSHBUTTON      "Help",9,167,53,45,14
!     LTEXT           "Share Name:",IDC_STATIC,18,10,29,8
      LTEXT           "Path Name:",IDC_STATIC,19,25,28,8
  END
  
--- 429,449 ----
      PUSHBUTTON      "OK",IDOK,22,53,45,14
      PUSHBUTTON      "Cancel",IDCANCEL,92,53,45,14
      PUSHBUTTON      "Help",9,167,53,45,14
!     LTEXT           "Submount Name:",IDC_STATIC,18,10,29,8
!     LTEXT           "Path Name:",IDC_STATIC,19,25,28,8
! END
! 
! IDD_SYMBOLICLINK_ADD DIALOG DISCARDABLE  0, 0, 235, 79
! STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
! CAPTION "Add Symbolic Link"
! FONT 8, "MS Sans Serif"
! BEGIN
!     EDITTEXT        IDC_NAME,62,8,163,12,ES_AUTOHSCROLL
!     EDITTEXT        IDC_DIR,62,23,163,12,ES_AUTOHSCROLL
!     PUSHBUTTON      "OK",IDOK,22,53,45,14
!     PUSHBUTTON      "Cancel",IDCANCEL,92,53,45,14
!     PUSHBUTTON      "Help",9,167,53,45,14
!     LTEXT           "Link Name:",IDC_STATIC,18,10,29,8
      LTEXT           "Path Name:",IDC_STATIC,19,25,28,8
  END
  
Index: openafs/src/WINNT/install/wix/NTMakefile
diff -c openafs/src/WINNT/install/wix/NTMakefile:1.2.2.2 openafs/src/WINNT/install/wix/NTMakefile:1.2.2.3
*** openafs/src/WINNT/install/wix/NTMakefile:1.2.2.2	Tue Sep 21 10:07:24 2004
--- openafs/src/WINNT/install/wix/NTMakefile	Fri Nov  5 14:21:56 2004
***************
*** 62,70 ****
  
  # Cleanup
  clean::
! 	for %l in ( $(LANGUAGES) ) do (
  		$(MAKE) /f NTMakefile /nologo LANG=%l lang_clean
- 	)
  	$(CD) custom
  	$(MAKE) /f NTMakefile /nologo clean
  	$(CD) ..
--- 62,69 ----
  
  # Cleanup
  clean::
! 	for %l in ( $(LANGUAGES) ) do \
  		$(MAKE) /f NTMakefile /nologo LANG=%l lang_clean
  	$(CD) custom
  	$(MAKE) /f NTMakefile /nologo clean
  	$(CD) ..
Index: openafs/src/WINNT/install/wix/config.wxi
diff -c openafs/src/WINNT/install/wix/config.wxi:1.6 openafs/src/WINNT/install/wix/config.wxi:1.6.2.1
*** openafs/src/WINNT/install/wix/config.wxi:1.6	Sat Jul 24 03:35:04 2004
--- openafs/src/WINNT/install/wix/config.wxi	Fri Nov  5 14:21:57 2004
***************
*** 103,108 ****
--- 103,121 ----
  
      <!-- We are including debug symbols anyway.  Undefine this for a leaner installer witout debug syms. -->
      <?define DebugSyms?>
+ 
+     <!-- Parameters for the features containing debug symbols -->
+     <?ifdef DebugSyms?>
+          <?ifdef Debug?>
+              <?define DebugSymInstallDefault="followParent"?>
+              <?define DebugSymLowLevel="30"?>
+              <?define DebugSymHighLevel="130"?>
+          <?else?>
+              <?define DebugSymInstallDefault="followParent"?>
+              <?define DebugSymLowLevel="130"?>
+              <?define DebugSymHighLevel="130"?>
+          <?endif?>
+     <?endif?>
      
      <!-- Use the afsloopback.dll instead of instloop.exe -->
      <?define UseDllLoopbackInstaller?>
***************
*** 150,153 ****
--- 163,168 ----
  		<?error AFSVER_CL needs to be set to the compiler version?>
      <?endif?>
      <?define SystemDir="$(env.SystemRoot)\System32\"?>
+ 
+ 
  </Include>
Index: openafs/src/WINNT/install/wix/feature.wxi
diff -c openafs/src/WINNT/install/wix/feature.wxi:1.5.2.1 openafs/src/WINNT/install/wix/feature.wxi:1.5.2.2
*** openafs/src/WINNT/install/wix/feature.wxi:1.5.2.1	Fri Aug 20 16:15:19 2004
--- openafs/src/WINNT/install/wix/feature.wxi	Fri Nov  5 14:21:57 2004
***************
*** 1,42 ****
  ﻿<?xml version="1.0" ?>
  <Include>
- 
- 		<?ifdef DebugSyms?>
- 			<?ifdef Debug?>
- 				<?define DebugSymFollowParent="yes"?>
- 				<?define DebugSymLowLevel="30"?>
- 				<?define DebugSymHighLevel="130"?>
- 			<?else?>
- 				<?define DebugSymFollowParent="no"?>
- 				<?define DebugSymLowLevel="130"?>
- 				<?define DebugSymHighLevel="130"?>
- 			<?endif?>
- 		<?endif?>
- 
          <Feature Id="feaOpenAFS" AllowAdvertise="no" Absent="disallow" ConfigurableDirectory="AFSDIR"
              Description="$(loc.StrAFSProdDesc)" Display="expand" InstallDefault="local" Level="30"
              Title="OpenAFS">
              <Feature Id="feaClient" AllowAdvertise="no" Description="$(loc.StrAFSClientLongDesc)" Display="expand"
!                 FollowParent="yes" InstallDefault="local" Level="30" Title="$(loc.StrAFSClientDesc)">
                  
!                 <Feature Id="feaLoopback" FollowParent="yes" AllowAdvertise="no" Description="$(loc.StrLoopbackLongDesc)"
!                     Display="expand" InstallDefault="local" Level="30" Title="$(loc.StrLoopbackDesc)">
                      <ComponentRef Id="rcm_Loopback"/>
                  </Feature>
  
! 				<Feature Id="feaKB301673" AllowAdvertise="no" Absent="disallow" Display="hidden" InstallDefault="local" Level="0" FollowParent="yes">
  					<ComponentRef Id="rcm_KB301673" />
  					<Condition Level="30">VersionNT = 500 And ServicePackLevel &lt; 3</Condition>
  				</Feature>
  				
! 				<Feature Id="feaCredsStartup" AllowAdvertise="no" FollowParent="yes" Display="hidden" InstallDefault="local" Level="30">
  					<ComponentRef Id="cmp_credsStartup" />
  					<Condition Level="130">CREDSSTARTUP = 0</Condition>
  				</Feature>
  				
  			<?ifdef DebugSyms?>
  				<Feature Id="feaClientDebug" AllowAdvertise="no" Description="$(loc.StrAFSClientDebugLongDesc)" Display="expand"
! 					FollowParent="$(var.DebugSymFollowParent)" InstallDefault="local" Level="$(var.DebugSymLowLevel)" Title="$(loc.StrAFSClientDebugDesc)">
                      <ComponentRef Id="cmp_ClientProgramDebug" />
                      <ComponentRef Id="cmp_CommonCommonDebug" />
                      <ComponentRef Id="cmp_ClientCommonDebug" />
--- 1,29 ----
  ﻿<?xml version="1.0" ?>
  <Include>
          <Feature Id="feaOpenAFS" AllowAdvertise="no" Absent="disallow" ConfigurableDirectory="AFSDIR"
              Description="$(loc.StrAFSProdDesc)" Display="expand" InstallDefault="local" Level="30"
              Title="OpenAFS">
              <Feature Id="feaClient" AllowAdvertise="no" Description="$(loc.StrAFSClientLongDesc)" Display="expand"
!                 InstallDefault="followParent" Level="30" Title="$(loc.StrAFSClientDesc)">
                  
!                 <Feature Id="feaLoopback" AllowAdvertise="no" Description="$(loc.StrLoopbackLongDesc)"
!                     Display="expand" InstallDefault="followParent" Level="30" Title="$(loc.StrLoopbackDesc)">
                      <ComponentRef Id="rcm_Loopback"/>
                  </Feature>
  
! 				<Feature Id="feaKB301673" AllowAdvertise="no" Absent="disallow" Display="hidden" InstallDefault="followParent" Level="0">
  					<ComponentRef Id="rcm_KB301673" />
  					<Condition Level="30">VersionNT = 500 And ServicePackLevel &lt; 3</Condition>
  				</Feature>
  				
! 				<Feature Id="feaCredsStartup" AllowAdvertise="no" Display="hidden" InstallDefault="followParent" Level="30">
  					<ComponentRef Id="cmp_credsStartup" />
  					<Condition Level="130">CREDSSTARTUP = 0</Condition>
  				</Feature>
  				
  			<?ifdef DebugSyms?>
  				<Feature Id="feaClientDebug" AllowAdvertise="no" Description="$(loc.StrAFSClientDebugLongDesc)" Display="expand"
! 					InstallDefault="$(var.DebugSymInstallDefault)" Level="$(var.DebugSymLowLevel)" Title="$(loc.StrAFSClientDebugDesc)">
                      <ComponentRef Id="cmp_ClientProgramDebug" />
                      <ComponentRef Id="cmp_CommonCommonDebug" />
                      <ComponentRef Id="cmp_ClientCommonDebug" />
***************
*** 98,104 ****
              </Feature>
              
              <Feature Id="feaServer" AllowAdvertise="no" Description="$(loc.StrAFSServerLongDesc)" Display="expand"
!                 FollowParent="yes" InstallDefault="local" Level="130" Title="$(loc.StrAFSServerDesc)">
  
  				<ComponentRef Id="rcm_Server" />
  				<ComponentRef Id="cmp_CommonDir" />
--- 85,91 ----
              </Feature>
              
              <Feature Id="feaServer" AllowAdvertise="no" Description="$(loc.StrAFSServerLongDesc)" Display="expand"
!                 InstallDefault="followParent" Level="130" Title="$(loc.StrAFSServerDesc)">
  
  				<ComponentRef Id="rcm_Server" />
  				<ComponentRef Id="cmp_CommonDir" />
***************
*** 147,153 ****
  
              <?ifdef DebugSyms?>
  				<Feature Id="feaServerDebug" AllowAdvertise="no" Description="$(loc.StrAFSServerDebugLongDesc)" Display="expand"
! 					FollowParent="$(var.DebugSymFollowParent)" InstallDefault="local" Level="$(var.DebugSymHighLevel)" Title="$(loc.StrAFSServerDebugDesc)">
  					<ComponentRef Id="cmp_Server_Program_Debug" />
  					<ComponentRef Id="cmp_ServerCommonDebug" />
  					<ComponentRef Id="cmp_CommonCommonDebug" />
--- 134,140 ----
  
              <?ifdef DebugSyms?>
  				<Feature Id="feaServerDebug" AllowAdvertise="no" Description="$(loc.StrAFSServerDebugLongDesc)" Display="expand"
! 					InstallDefault="$(var.DebugSymInstallDefault)" Level="$(var.DebugSymHighLevel)" Title="$(loc.StrAFSServerDebugDesc)">
  					<ComponentRef Id="cmp_Server_Program_Debug" />
  					<ComponentRef Id="cmp_ServerCommonDebug" />
  					<ComponentRef Id="cmp_CommonCommonDebug" />
***************
*** 159,165 ****
                  <?include runtime.wxi?>
              </Feature>
              <Feature Id="feaControlCenter" AllowAdvertise="no" Description="$(loc.StrAFSCCLongDesc)"
!                 Display="expand" FollowParent="yes" InstallDefault="local" Level="130" Title="$(loc.StrAFSCCDesc)">
                  
                  <ComponentRef Id="rcm_Control_Center" />
                  <ComponentRef Id="cmp_CommonDir" />
--- 146,152 ----
                  <?include runtime.wxi?>
              </Feature>
              <Feature Id="feaControlCenter" AllowAdvertise="no" Description="$(loc.StrAFSCCLongDesc)"
!                 Display="expand" InstallDefault="followParent" Level="130" Title="$(loc.StrAFSCCDesc)">
                  
                  <ComponentRef Id="rcm_Control_Center" />
                  <ComponentRef Id="cmp_CommonDir" />
***************
*** 197,203 ****
  
              <?ifdef DebugSyms?>
  				<Feature Id="feaControlCenterDebug" AllowAdvertise="no" Description="$(loc.StrAFSCCDebugLongDesc)"
! 					Display="expand" FollowParent="$(var.DebugSymFollowParent)" InstallDefault="local" Level="$(var.DebugSymHighLevel)" Title="$(loc.StrAFSCCDebugDesc)">
  					<ComponentRef Id="cmp_Control_CenterDebug" />
  					<ComponentRef Id="cmp_ServerCommonDebug" />
  					<ComponentRef Id="cmp_CommonCommonDebug" />
--- 184,190 ----
  
              <?ifdef DebugSyms?>
  				<Feature Id="feaControlCenterDebug" AllowAdvertise="no" Description="$(loc.StrAFSCCDebugLongDesc)"
! 					Display="expand" InstallDefault="$(var.DebugSymInstallDefault)" Level="$(var.DebugSymHighLevel)" Title="$(loc.StrAFSCCDebugDesc)">
  					<ComponentRef Id="cmp_Control_CenterDebug" />
  					<ComponentRef Id="cmp_ServerCommonDebug" />
  					<ComponentRef Id="cmp_CommonCommonDebug" />
***************
*** 212,218 ****
                  <?include runtime.wxi?>
              </Feature>
              <Feature Id="feaSDK" AllowAdvertise="no" Description="$(loc.StrAFSSDKLongDesc)" Display="expand"
!                 FollowParent="yes" InstallDefault="local" Level="130" Title="$(loc.StrAFSSDKDesc)">
  
  				<ComponentRef Id="rcm_SDK" />
  
--- 199,205 ----
                  <?include runtime.wxi?>
              </Feature>
              <Feature Id="feaSDK" AllowAdvertise="no" Description="$(loc.StrAFSSDKLongDesc)" Display="expand"
!                 InstallDefault="followParent" Level="130" Title="$(loc.StrAFSSDKDesc)">
  
  				<ComponentRef Id="rcm_SDK" />
  
***************
*** 227,233 ****
  
  			<?ifdef DebugSyms?>
  				<Feature Id="feaSDKDebug" AllowAdvertise="no" Description="$(loc.StrAFSSDKDebugLongDesc)" Display="expand"
! 					FollowParent="$(var.DebugSymFollowParent)" InstallDefault="local" Level="$(var.DebugSymHighLevel)" Title="$(loc.StrAFSSDKDebugDesc)">
  					<?include runtime_debug.wxi?>
  				</Feature>
  			<?endif?>
--- 214,220 ----
  
  			<?ifdef DebugSyms?>
  				<Feature Id="feaSDKDebug" AllowAdvertise="no" Description="$(loc.StrAFSSDKDebugLongDesc)" Display="expand"
! 					InstallDefault="$(var.DebugSymInstallDefault)" Level="$(var.DebugSymHighLevel)" Title="$(loc.StrAFSSDKDebugDesc)">
  					<?include runtime_debug.wxi?>
  				</Feature>
  			<?endif?>
***************
*** 236,242 ****
              </Feature>
              
              <Feature Id="feaDocumentation" AllowAdvertise="no" Description="$(loc.StrAFSDocLongDesc)"
!                 Display="expand" FollowParent="yes" InstallDefault="local" Level="130" Title="$(loc.StrAFSDocDesc)">
  
  				<ComponentRef Id="rcm_Documentation" />
                  
--- 223,229 ----
              </Feature>
              
              <Feature Id="feaDocumentation" AllowAdvertise="no" Description="$(loc.StrAFSDocLongDesc)"
!                 Display="expand" InstallDefault="followParent" Level="130" Title="$(loc.StrAFSDocDesc)">
  
  				<ComponentRef Id="rcm_Documentation" />
                  
Index: openafs/src/WINNT/install/wix/files.wxi
diff -c openafs/src/WINNT/install/wix/files.wxi:1.9.2.2 openafs/src/WINNT/install/wix/files.wxi:1.9.2.3
*** openafs/src/WINNT/install/wix/files.wxi:1.9.2.2	Fri Aug 20 16:15:19 2004
--- openafs/src/WINNT/install/wix/files.wxi	Fri Nov  5 14:21:57 2004
***************
*** 1,6 ****
  <?xml version="1.0"?>
  <Include>
!     <Directory Id="SystemFolder" SourceName="System" LongSource="System">
          <Component Id="cmf_afslogon_DLL" Guid="123197FE-4F53-4035-8D51-FCFB6B50A777">
              <File Id="fileafslogon_DLL" Name="afslogon.dll" LongName="afslogon.dll" KeyPath="yes" DiskId="1" src="$(var.ClientDir)afslogon.dll" />
              <Registry Id="reg_afslogon01" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Action="createKeyAndRemoveKeyOnUninstall" />
--- 1,6 ----
  <?xml version="1.0"?>
  <Include>
!     <Directory Id="SystemFolder" SourceName="System">
          <Component Id="cmf_afslogon_DLL" Guid="123197FE-4F53-4035-8D51-FCFB6B50A777">
              <File Id="fileafslogon_DLL" Name="afslogon.dll" LongName="afslogon.dll" KeyPath="yes" DiskId="1" src="$(var.ClientDir)afslogon.dll" />
              <Registry Id="reg_afslogon01" Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\AfsLogon" Action="createKeyAndRemoveKeyOnUninstall" />
***************
*** 19,25 ****
      </Directory>
      <Directory Id="ProgramFilesFolder">
          <Directory Id="AFSDIR" Name="OpenAFS" SourceName=".">
!             <Directory Id="dirCommon" Name="Common" LongName="Common" SourceName="Common">
                  <Component Id="cmp_CommonDir" Guid="C86B03A1-AE97-48B1-A77B-1B2395F1E117" KeyPath="yes">
                      <Environment Id="envCommon" Name="PATH" Action="create" System="yes" Permanent="no" Part="last" Separator=";" Value="[AFSDIR]Common" />
                      <CreateFolder />
--- 19,25 ----
      </Directory>
      <Directory Id="ProgramFilesFolder">
          <Directory Id="AFSDIR" Name="OpenAFS" SourceName=".">
!             <Directory Id="dirCommon" Name="Common">
                  <Component Id="cmp_CommonDir" Guid="C86B03A1-AE97-48B1-A77B-1B2395F1E117" KeyPath="yes">
                      <Environment Id="envCommon" Name="PATH" Action="create" System="yes" Permanent="no" Part="last" Separator=";" Value="[AFSDIR]Common" />
                      <CreateFolder />
***************
*** 119,125 ****
                      <File Id="fileafs_shl_ext_1033_DLL" Name="ashl1033.dll" LongName="afs_shl_ext_1033.dll" KeyPath="yes" DiskId="1" src="$(var.ClientDir)\afs_shl_ext_1033.dll"/>
                  </Component>
  
!                 <Directory Id="dirCommon_en_US" Name="en_US" LongName="en_US" SourceName="en_US" src="$(var.SrcDir)\WINNT\doc\help\en_US\">
                      <Component Id="cmf_afs_nt_HLP_en_US" Guid="A59FF1E3-984F-47E0-8A65-590A01B6E1C4">
                          <File Id="fileafs_nt_HLP_en_US" Name="afs-nt.hlp" LongName="afs-nt.hlp" KeyPath="yes" DiskId="1">
  							<Shortcut Id="scClientHelp_en_US" Directory="dirShortCut" Name="CliHelp.lnk" LongName="Client Help.lnk" Description="$(loc.StrHlpFileDesc)" Icon="ico_Help" IconIndex="0" Show="normal" WorkingDirectory="dirCommon" />
--- 119,125 ----
                      <File Id="fileafs_shl_ext_1033_DLL" Name="ashl1033.dll" LongName="afs_shl_ext_1033.dll" KeyPath="yes" DiskId="1" src="$(var.ClientDir)\afs_shl_ext_1033.dll"/>
                  </Component>
  
!                 <Directory Id="dirCommon_en_US" Name="en_US" src="$(var.SrcDir)\WINNT\doc\help\en_US\">
                      <Component Id="cmf_afs_nt_HLP_en_US" Guid="A59FF1E3-984F-47E0-8A65-590A01B6E1C4">
                          <File Id="fileafs_nt_HLP_en_US" Name="afs-nt.hlp" LongName="afs-nt.hlp" KeyPath="yes" DiskId="1">
  							<Shortcut Id="scClientHelp_en_US" Directory="dirShortCut" Name="CliHelp.lnk" LongName="Client Help.lnk" Description="$(loc.StrHlpFileDesc)" Icon="ico_Help" IconIndex="0" Show="normal" WorkingDirectory="dirCommon" />
***************
*** 362,369 ****
  
              <Directory Id="dirDocumentation" Name="Docum" LongName="Documentation" SourceName="Docs">
  				<!-- The following directory and everything below it is language dependent. -->
!                 <Directory Id="dirDoc_$(var.Language)" Name="$(var.Language)" LongName="$(var.Language)" SourceName="$(var.Language)">
!                     <Directory Id="dirHtml_$(var.Language)" Name="Html" LongName="Html" SourceName="html" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\">
                          <Component Id="cmf_index2_HTM_$(var.Language)" Guid="$(var.DocHtmlIndexGuid)">
                              <File Id="fileindex2_HTM_$(var.Language)" Name="index.htm" LongName="index.htm" KeyPath="yes" DiskId="1">
  								<Shortcut Id="scDoc_$(var.Language)" Directory="dirShortCut" Name="Doc$(var.Language).lnk" LongName="Documentation ($(var.Language)).lnk" Description="$(loc.StrDocLnkDesc)" Icon="ico_Help" IconIndex="0" Show="normal" WorkingDirectory="dirCommon" />
--- 362,369 ----
  
              <Directory Id="dirDocumentation" Name="Docum" LongName="Documentation" SourceName="Docs">
  				<!-- The following directory and everything below it is language dependent. -->
!                 <Directory Id="dirDoc_$(var.Language)" Name="$(var.Language)">
!                     <Directory Id="dirHtml_$(var.Language)" Name="Html" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\">
                          <Component Id="cmf_index2_HTM_$(var.Language)" Guid="$(var.DocHtmlIndexGuid)">
                              <File Id="fileindex2_HTM_$(var.Language)" Name="index.htm" LongName="index.htm" KeyPath="yes" DiskId="1">
  								<Shortcut Id="scDoc_$(var.Language)" Directory="dirShortCut" Name="Doc$(var.Language).lnk" LongName="Documentation ($(var.Language)).lnk" Description="$(loc.StrDocLnkDesc)" Icon="ico_Help" IconIndex="0" Show="normal" WorkingDirectory="dirCommon" />
***************
*** 380,386 ****
                              <File Id="filetop_GIF_$(var.Language)" Name="top.gif" LongName="top.gif" DiskId="1" />
                              <File Id="file$(var.Language)_RTF" Name="$(var.Language).rtf" LongName="$(var.Language).rtf" KeyPath="yes" DiskId="1" src="$(var.SrcDir)\WINNT\license\lang\$(var.Language).rtf"/>
                          </Component>
!                         <Directory Id="dirCmdRef_$(var.Language)" Name="CmdRef" LongName="CmdRef" SourceName="CmdRef" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\CmdRef\">
                              <Component Id="cmp_Cmd_Ref_$(var.Language)" Guid="$(var.DocHtmlCmdRefGuid)">
                                  <File Id="fileauarf000_HTM_$(var.Language)" Name="auarf000.htm" LongName="auarf000.htm" KeyPath="yes" DiskId="1" />
                                  <File Id="fileauarf002_HTM_$(var.Language)" Name="auarf002.htm" LongName="auarf002.htm" DiskId="1" />
--- 380,386 ----
                              <File Id="filetop_GIF_$(var.Language)" Name="top.gif" LongName="top.gif" DiskId="1" />
                              <File Id="file$(var.Language)_RTF" Name="$(var.Language).rtf" LongName="$(var.Language).rtf" KeyPath="yes" DiskId="1" src="$(var.SrcDir)\WINNT\license\lang\$(var.Language).rtf"/>
                          </Component>
!                         <Directory Id="dirCmdRef_$(var.Language)" Name="CmdRef" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\CmdRef\">
                              <Component Id="cmp_Cmd_Ref_$(var.Language)" Guid="$(var.DocHtmlCmdRefGuid)">
                                  <File Id="fileauarf000_HTM_$(var.Language)" Name="auarf000.htm" LongName="auarf000.htm" KeyPath="yes" DiskId="1" />
                                  <File Id="fileauarf002_HTM_$(var.Language)" Name="auarf002.htm" LongName="auarf002.htm" DiskId="1" />
***************
*** 668,674 ****
                                  <File Id="fileauarf284_HTM_$(var.Language)" Name="auarf284.htm" LongName="auarf284.htm" DiskId="1" />
                              </Component>
                          </Directory> <!-- CmdRef -->
!                         <Directory Id="dirInstallGd_$(var.Language)" Name="InstalGd" LongName="InstallGd" SourceName="InstGd" LongSource="InstallGuide" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\InstallGd\">
                              <Component Id="cmp_Install_Guide_$(var.Language)" Guid="$(var.DocHtmlInstallGuid)">
                                  <File Id="fileawqbg000_HTM_$(var.Language)" Name="awqbg000.htm" LongName="awqbg000.htm" KeyPath="yes" DiskId="1" />
                                  <File Id="fileawqbg002_HTM_$(var.Language)" Name="awqbg002.htm" LongName="awqbg002.htm" DiskId="1" />
--- 668,674 ----
                                  <File Id="fileauarf284_HTM_$(var.Language)" Name="auarf284.htm" LongName="auarf284.htm" DiskId="1" />
                              </Component>
                          </Directory> <!-- CmdRef -->
!                         <Directory Id="dirInstallGd_$(var.Language)" Name="InstalGd" SourceName="InstGd" LongSource="InstallGuide" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\InstallGd\">
                              <Component Id="cmp_Install_Guide_$(var.Language)" Guid="$(var.DocHtmlInstallGuid)">
                                  <File Id="fileawqbg000_HTM_$(var.Language)" Name="awqbg000.htm" LongName="awqbg000.htm" KeyPath="yes" DiskId="1" />
                                  <File Id="fileawqbg002_HTM_$(var.Language)" Name="awqbg002.htm" LongName="awqbg002.htm" DiskId="1" />
***************
*** 715,721 ****
                                  <File Id="filecachmgr_GIF_$(var.Language)" Name="cachm.gif" LongName="cachmgr.gif" DiskId="1" />
                              </Component>
                          </Directory> <!-- Sys Admin guide -->
!                         <Directory Id="dirReleaseNotes_$(var.Language)" Name="Relea" LongName="ReleaseNotes" SourceName="Relea" LongSource="ReleaseNotes" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\ReleaseNotes\">
                              <Component Id="cmp_Release_Notes_$(var.Language)" Guid="$(var.DocHtmlRelNotesGuid)">
                                  <File Id="fileawrns000_HTM_$(var.Language)" Name="awrns.htm" LongName="awrns000.htm" KeyPath="yes" DiskId="1" />
                                  <File Id="fileawrns002_HTM_$(var.Language)" Name="awrns~2.htm" LongName="awrns002.htm" DiskId="1" />
--- 715,721 ----
                                  <File Id="filecachmgr_GIF_$(var.Language)" Name="cachm.gif" LongName="cachmgr.gif" DiskId="1" />
                              </Component>
                          </Directory> <!-- Sys Admin guide -->
!                         <Directory Id="dirReleaseNotes_$(var.Language)" Name="Relea" LongName="ReleaseNotes" src="$(var.SrcDir)\WINNT\doc\install\Documentation\$(var.Language)\html\ReleaseNotes\">
                              <Component Id="cmp_Release_Notes_$(var.Language)" Guid="$(var.DocHtmlRelNotesGuid)">
                                  <File Id="fileawrns000_HTM_$(var.Language)" Name="awrns.htm" LongName="awrns000.htm" KeyPath="yes" DiskId="1" />
                                  <File Id="fileawrns002_HTM_$(var.Language)" Name="awrns~2.htm" LongName="awrns002.htm" DiskId="1" />
***************
*** 730,736 ****
                  </Directory> <!-- $(var.Language) -->
              </Directory> <!-- Documentation -->
  
!             <Directory Id="dirClient" Name="Client" LongName="Client" SourceName="Client">
                  <Component Id="efl_CellServDB" Guid="8E69FDAB-08C5-4927-B1AA-57FCEEB065F2" NeverOverwrite="yes" Permanent="yes">
                      <File Id="file_CellServDB" Name="CelSrvDB" LongName="CellServDB" KeyPath="yes" DiskId="1" src="$(var.CellDbFile)"/>
                      <Condition>OLDCELLSERVDB = ""</Condition>
--- 730,736 ----
                  </Directory> <!-- $(var.Language) -->
              </Directory> <!-- Documentation -->
  
!             <Directory Id="dirClient" Name="Client">
                  <Component Id="efl_CellServDB" Guid="8E69FDAB-08C5-4927-B1AA-57FCEEB065F2" NeverOverwrite="yes" Permanent="yes">
                      <File Id="file_CellServDB" Name="CelSrvDB" LongName="CellServDB" KeyPath="yes" DiskId="1" src="$(var.CellDbFile)"/>
                      <Condition>OLDCELLSERVDB = ""</Condition>
***************
*** 740,746 ****
                      <CopyFile Id="copy_CellServDB" Delete="yes" DestinationDirectory="dirClient" DestinationName="CellServ|CellServDB" SourceDirectory="WindowsFolder" SourceName="afsdcell.ini" />
                      <Condition>OLDCELLSERVDB &lt;&gt; ""</Condition>
                  </Component>
!                 <Directory Id="dirProgram" Name="Program" LongName="Program" SourceName="Program" src="$(var.ClientDir)">
                      <Component Id="cmf_afsshare_EXE" Guid="E972DA35-E950-4736-AE48-E6DDCE8C97D0">
                          <File Id="fileafsshare_EXE" Name="afsshare.exe" LongName="afsshare.exe" KeyPath="yes" DiskId="1" />
                      </Component>
--- 740,746 ----
                      <CopyFile Id="copy_CellServDB" Delete="yes" DestinationDirectory="dirClient" DestinationName="CellServ|CellServDB" SourceDirectory="WindowsFolder" SourceName="afsdcell.ini" />
                      <Condition>OLDCELLSERVDB &lt;&gt; ""</Condition>
                  </Component>
!                 <Directory Id="dirProgram" Name="Program" src="$(var.ClientDir)">
                      <Component Id="cmf_afsshare_EXE" Guid="E972DA35-E950-4736-AE48-E6DDCE8C97D0">
                          <File Id="fileafsshare_EXE" Name="afsshare.exe" LongName="afsshare.exe" KeyPath="yes" DiskId="1" />
                      </Component>
***************
*** 860,871 ****
                      </Component>
                  <?endif?>
                      
!                     <Directory Id="dirSample" Name="Sampl" LongName="Sample" SourceName="Sample">
                          <Component Id="cmp_SDK_Sample" Guid="F9373E95-F410-4AA5-AA79-07C11EE00334">
                              <File Id="filetoken_C" Name="token.c" LongName="token.c" KeyPath="yes" DiskId="1" src="$(var.SrcDir)WINNT\afsd\sample\token.c"/>
                          </Component>
                      </Directory>
!                     <Directory Id="dirInclude" Name="Include" LongName="Include" SourceName="Include">
                          <Component Id="cmp_SDK_Include" Guid="9B12B216-B104-4E49-BE31-4042F2CBD318">
                              <File Id="filebasic_H" Name="basic.h" LongName="basic.h" DiskId="1" src="$(var.IncDir)basic.h" /> 
                              <File Id="filecrypt_H" Name="crypt.h" LongName="crypt.h" DiskId="1" src="$(var.IncDir)crypt.h" /> 
--- 860,871 ----
                      </Component>
                  <?endif?>
                      
!                     <Directory Id="dirSample" Name="Sample">
                          <Component Id="cmp_SDK_Sample" Guid="F9373E95-F410-4AA5-AA79-07C11EE00334">
                              <File Id="filetoken_C" Name="token.c" LongName="token.c" KeyPath="yes" DiskId="1" src="$(var.SrcDir)WINNT\afsd\sample\token.c"/>
                          </Component>
                      </Directory>
!                     <Directory Id="dirInclude" Name="Include">
                          <Component Id="cmp_SDK_Include" Guid="9B12B216-B104-4E49-BE31-4042F2CBD318">
                              <File Id="filebasic_H" Name="basic.h" LongName="basic.h" DiskId="1" src="$(var.IncDir)basic.h" /> 
                              <File Id="filecrypt_H" Name="crypt.h" LongName="crypt.h" DiskId="1" src="$(var.IncDir)crypt.h" /> 
***************
*** 898,904 ****
                              <File Id="fileubik_H" Name="ubik.h" LongName="ubik.h" DiskId="1" src="$(var.IncDir)ubik.h" /> 
                              <File Id="fileubik_int_H" Name="ubik_int.h" LongName="ubik_int.h" DiskId="1" src="$(var.IncDir)ubik_int.h" /> 
                          </Component>
!                         <Directory Id="dirIncludeAfs" Name="afs" LongName="afs" SourceName="afs">
                              <Component Id="cmp_SDK_Include_afs" Guid="692D18AD-4901-4124-8B1F-5D414E65A7D0">
                                  <File Id="fileacl_H" Name="acl.h" LongName="acl.h" DiskId="1" src="$(var.IncDir)afs\acl.h" /> 
                                  <File Id="fileafscbint_H" Name="afscbint.h" LongName="afscbint.h" DiskId="1" src="$(var.IncDir)afs\afscbint.h" /> 
--- 898,904 ----
                              <File Id="fileubik_H" Name="ubik.h" LongName="ubik.h" DiskId="1" src="$(var.IncDir)ubik.h" /> 
                              <File Id="fileubik_int_H" Name="ubik_int.h" LongName="ubik_int.h" DiskId="1" src="$(var.IncDir)ubik_int.h" /> 
                          </Component>
!                         <Directory Id="dirIncludeAfs" Name="afs">
                              <Component Id="cmp_SDK_Include_afs" Guid="692D18AD-4901-4124-8B1F-5D414E65A7D0">
                                  <File Id="fileacl_H" Name="acl.h" LongName="acl.h" DiskId="1" src="$(var.IncDir)afs\acl.h" /> 
                                  <File Id="fileafscbint_H" Name="afscbint.h" LongName="afscbint.h" DiskId="1" src="$(var.IncDir)afs\afscbint.h" /> 
***************
*** 1034,1040 ****
                                  <File Id="filevolume_H" Name="volume.h" LongName="volume.h" DiskId="1" src="$(var.IncDir)afs\volume.h" />
                              </Component>
                          </Directory>
!                         <Directory Id="dirIncludeRx" Name="rx" LongName="rx" SourceName="rx">
                              <Component Id="cmp_SDK_Include_rx" Guid="2E215D10-C080-42A3-B692-AFF94C7A1A2B">
                                  <File Id="fileasn1_err_H" Name="asn1_err.h" LongName="asn1_err.h" DiskId="1" src="$(var.IncDir)rx\asn1_err.h" /> 
                                  <File Id="filefcrypt_H" Name="fcrypt.h" LongName="fcrypt.h" DiskId="1" src="$(var.IncDir)rx\fcrypt.h" /> 
--- 1034,1040 ----
                                  <File Id="filevolume_H" Name="volume.h" LongName="volume.h" DiskId="1" src="$(var.IncDir)afs\volume.h" />
                              </Component>
                          </Directory>
!                         <Directory Id="dirIncludeRx" Name="rx">
                              <Component Id="cmp_SDK_Include_rx" Guid="2E215D10-C080-42A3-B692-AFF94C7A1A2B">
                                  <File Id="fileasn1_err_H" Name="asn1_err.h" LongName="asn1_err.h" DiskId="1" src="$(var.IncDir)rx\asn1_err.h" /> 
                                  <File Id="filefcrypt_H" Name="fcrypt.h" LongName="fcrypt.h" DiskId="1" src="$(var.IncDir)rx\fcrypt.h" /> 
***************
*** 1063,1069 ****
                                  <File Id="filexdr_prototypes_H" Name="XDR_PR~1.h" LongName="xdr_prototypes.h" DiskId="1" src="$(var.IncDir)rx\xdr_prototypes.h" /> 
                              </Component>
                          </Directory>
!                         <Directory Id="dirIncludeWinnt" Name="WINNT" LongName="WINNT" SourceName="WINNT">
                              <Component Id="cmp_SDK_Include_Winnt" Guid="BAAF0193-5C33-4EC1-9D40-DD4595F176E6">
                                  <File Id="fileafsapplib_H" Name="AFSAPP~1.h" LongName="afsapplib.h" DiskId="1" src="$(var.IncDir)WINNT\afsapplib.h" /> 
                                  <File Id="fileafsclass_H" Name="afsclass.h" LongName="afsclass.h" DiskId="1" src="$(var.IncDir)WINNT\afsclass.h" /> 
--- 1063,1069 ----
                                  <File Id="filexdr_prototypes_H" Name="XDR_PR~1.h" LongName="xdr_prototypes.h" DiskId="1" src="$(var.IncDir)rx\xdr_prototypes.h" /> 
                              </Component>
                          </Directory>
!                         <Directory Id="dirIncludeWinnt" Name="WINNT">
                              <Component Id="cmp_SDK_Include_Winnt" Guid="BAAF0193-5C33-4EC1-9D40-DD4595F176E6">
                                  <File Id="fileafsapplib_H" Name="AFSAPP~1.h" LongName="afsapplib.h" DiskId="1" src="$(var.IncDir)WINNT\afsapplib.h" /> 
                                  <File Id="fileafsclass_H" Name="afsclass.h" LongName="afsclass.h" DiskId="1" src="$(var.IncDir)WINNT\afsclass.h" /> 
***************
*** 1115,1121 ****
                              </Component>
                          </Directory>
                      </Directory>
!                     <Directory Id="dirLib" Name="lib" LongName="lib" SourceName="lib">
                          <Component Id="cmp_SDK_Lib" Guid="71BC1B4E-4C4C-4FF8-8DDA-C6AB2BE22142">
                              <File Id="fileafsauthent_LIB" Name="AFSAUT~1.lib" LongName="afsauthent.lib" DiskId="1" src="$(var.LibDir)afsauthent.lib" /> 
                              <File Id="fileafsdes_LIB" Name="afsdes.lib" LongName="afsdes.lib" DiskId="1" src="$(var.LibDir)afsdes.lib" /> 
--- 1115,1121 ----
                              </Component>
                          </Directory>
                      </Directory>
!                     <Directory Id="dirLib" Name="lib">
                          <Component Id="cmp_SDK_Lib" Guid="71BC1B4E-4C4C-4FF8-8DDA-C6AB2BE22142">
                              <File Id="fileafsauthent_LIB" Name="AFSAUT~1.lib" LongName="afsauthent.lib" DiskId="1" src="$(var.LibDir)afsauthent.lib" /> 
                              <File Id="fileafsdes_LIB" Name="afsdes.lib" LongName="afsdes.lib" DiskId="1" src="$(var.LibDir)afsdes.lib" /> 
***************
*** 1134,1140 ****
                              <File Id="filecm_config_OBJ" Name="CM_CON~1.obj" LongName="cm_config.obj" DiskId="1" src="$(var.LibDir)cm_config.obj" /> 
                              <File Id="filecm_dns_OBJ" Name="cm_dns.obj" LongName="cm_dns.obj" DiskId="1" src="$(var.LibDir)cm_dns.obj" /> 
                          </Component>
!                         <Directory Id="dirLibAfs" Name="afs" LongName="afs" SourceName="afs">
                              <Component Id="cmp_SDK_Lib_Afs" Guid="CD671A64-D491-4363-A7AD-645482B481BE">
                                  <File Id="fileafsacl_LIB" Name="afsacl.lib" LongName="afsacl.lib" DiskId="1" src="$(var.LibDir)afs\afsacl.lib" /> 
                                  <File Id="fileafsadminutil_LIB" Name="AFSADM~1.lib" LongName="afsadminutil.lib" DiskId="1" src="$(var.LibDir)afs\afsadminutil.lib" /> 
--- 1134,1140 ----
                              <File Id="filecm_config_OBJ" Name="CM_CON~1.obj" LongName="cm_config.obj" DiskId="1" src="$(var.LibDir)cm_config.obj" /> 
                              <File Id="filecm_dns_OBJ" Name="cm_dns.obj" LongName="cm_dns.obj" DiskId="1" src="$(var.LibDir)cm_dns.obj" /> 
                          </Component>
!                         <Directory Id="dirLibAfs" Name="afs">
                              <Component Id="cmp_SDK_Lib_Afs" Guid="CD671A64-D491-4363-A7AD-645482B481BE">
                                  <File Id="fileafsacl_LIB" Name="afsacl.lib" LongName="afsacl.lib" DiskId="1" src="$(var.LibDir)afs\afsacl.lib" /> 
                                  <File Id="fileafsadminutil_LIB" Name="AFSADM~1.lib" LongName="afsadminutil.lib" DiskId="1" src="$(var.LibDir)afs\afsadminutil.lib" /> 
***************
*** 1178,1187 ****
                      </Directory>
                  </Directory> <!-- /Program -->
              </Directory> <!-- /Client -->
!             <Directory Id="dirServer" Name="Server" LongName="Server" SourceName="Server">
!                 <Directory Id="dirusr" Name="usr" LongName="usr" SourceName="usr">
!                     <Directory Id="dirafs" Name="afs" LongName="afs" SourceName="afs">
!                         <Directory Id="dirbin" Name="bin" LongName="bin" SourceName="bin" src="$(var.ServerDir)">
                              <Component Id="cmf_vlserver_EXE" Guid="F6A43B78-EE17-4483-AA81-4B6C6957977D">
                                  <File Id="filevlserver_EXE" Name="vlser.exe" LongName="vlserver.exe" KeyPath="yes" DiskId="1" />
                              </Component>
--- 1178,1187 ----
                      </Directory>
                  </Directory> <!-- /Program -->
              </Directory> <!-- /Client -->
!             <Directory Id="dirServer" Name="Server">
!                 <Directory Id="dirusr" Name="usr">
!                     <Directory Id="dirafs" Name="afs">
!                         <Directory Id="dirbin" Name="bin" src="$(var.ServerDir)">
                              <Component Id="cmf_vlserver_EXE" Guid="F6A43B78-EE17-4483-AA81-4B6C6957977D">
                                  <File Id="filevlserver_EXE" Name="vlser.exe" LongName="vlserver.exe" KeyPath="yes" DiskId="1" />
                              </Component>
***************
*** 1284,1290 ****
      </Directory> <!-- program files -->
      <!-- References -->
      <Directory Id="ProgramMenuFolder" Name=".">
!         <Directory Id="dirShortCut" Name="OpenAFS" LongName="OpenAFS"/>
      </Directory>
      <Directory Id="StartupFolder" Name="." />
      <Directory Id="WindowsVolume" Name="." />
--- 1284,1290 ----
      </Directory> <!-- program files -->
      <!-- References -->
      <Directory Id="ProgramMenuFolder" Name=".">
!         <Directory Id="dirShortCut" Name="OpenAFS"/>
      </Directory>
      <Directory Id="StartupFolder" Name="." />
      <Directory Id="WindowsVolume" Name="." />
Index: openafs/src/WINNT/install/wix/openafs.wxs
diff -c openafs/src/WINNT/install/wix/openafs.wxs:1.6.2.2 openafs/src/WINNT/install/wix/openafs.wxs:1.6.2.3
*** openafs/src/WINNT/install/wix/openafs.wxs:1.6.2.2	Mon Aug 23 11:55:09 2004
--- openafs/src/WINNT/install/wix/openafs.wxs	Fri Nov  5 14:21:57 2004
***************
*** 153,159 ****
  		 BinaryKey="BIN_afsCustom"
  		 DllEntry="UninstallNsisInstallation"
  		 Execute="immediate" />
!  		<CustomAction
  		 Id="CreateAFSAdminGroup"
  		 BinaryKey="BIN_afsCustom"
  		 DllEntry="CreateAFSClientAdminGroup"
--- 153,159 ----
  		 BinaryKey="BIN_afsCustom"
  		 DllEntry="UninstallNsisInstallation"
  		 Execute="immediate" />
! 		<CustomAction
  		 Id="CreateAFSAdminGroup"
  		 BinaryKey="BIN_afsCustom"
  		 DllEntry="CreateAFSClientAdminGroup"
Index: openafs/src/WINNT/pthread/pthread.c
diff -c openafs/src/WINNT/pthread/pthread.c:1.6.2.2 openafs/src/WINNT/pthread/pthread.c:1.6.2.3
*** openafs/src/WINNT/pthread/pthread.c:1.6.2.2	Mon Oct 18 13:43:49 2004
--- openafs/src/WINNT/pthread/pthread.c	Fri Nov  5 14:21:57 2004
***************
*** 590,603 ****
      (pthread_cache_done || pthread_once(&pthread_cache_once, create_once));
  
      if (terminate_thread_handle == INVALID_HANDLE_VALUE) {
!         CHAR eventName[MAX_PATH];
!         static eventCount = 0;
!         sprintf(eventName, "terminate_thread_wakeup_event %d::%d", _getpid(), eventCount++);
!         terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0,
!                                                      TRUE, FALSE, (LPCTSTR) eventName);
!         terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0, 
!                                                 terminate_thread_routine, (LPVOID) 0, 0, 
!                                                 &terminate_thread_id);
      } else {
      	SetEvent (terminate_thread_wakeup_event);
      }
--- 590,600 ----
      (pthread_cache_done || pthread_once(&pthread_cache_once, create_once));
  
      if (terminate_thread_handle == INVALID_HANDLE_VALUE) {
! 	terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0,
! 				TRUE, FALSE, (LPCTSTR) 0);
! 	terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0, 
! 		                terminate_thread_routine, (LPVOID) 0, 0, 
! 			        &terminate_thread_id);
      } else {
      	SetEvent (terminate_thread_wakeup_event);
      }
***************
*** 714,724 ****
      if (queue_IsEmpty(&waiter_cache)) {
          new = (cond_waiters_t *) malloc(sizeof(cond_waiters_t));
  	if (new != NULL) {
!         CHAR eventName[MAX_PATH];
!         static eventCount = 0;
!         sprintf(eventName, "cond_waiters_t %d::%d", _getpid(), eventCount++);
!         new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE,
!                                   FALSE, (LPCTSTR) eventName);
  	    if (new->event == NULL) {
  		free(new);
  		new = NULL;
--- 711,718 ----
      if (queue_IsEmpty(&waiter_cache)) {
          new = (cond_waiters_t *) malloc(sizeof(cond_waiters_t));
  	if (new != NULL) {
! 	    new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE,
! 				     FALSE, (LPCTSTR) 0);
  	    if (new->event == NULL) {
  		free(new);
  		new = NULL;
Index: openafs/src/afs/afs.h
diff -c openafs/src/afs/afs.h:1.48.2.2 openafs/src/afs/afs.h:1.48.2.3
*** openafs/src/afs/afs.h:1.48.2.2	Mon Oct 18 13:43:49 2004
--- openafs/src/afs/afs.h	Tue Nov  9 12:14:57 2004
***************
*** 1195,1201 ****
  extern int afs_fakestat_enable;
  
  struct buffer {
!     struct fcache *fid;
      afs_int32 page;
      afs_int32 accesstime;
      struct buffer *hashNext;
--- 1195,1201 ----
  extern int afs_fakestat_enable;
  
  struct buffer {
!     struct dcache *fid;
      afs_int32 page;
      afs_int32 accesstime;
      struct buffer *hashNext;
Index: openafs/src/afs/afs_buffer.c
diff -c openafs/src/afs/afs_buffer.c:1.16.2.1 openafs/src/afs/afs_buffer.c:1.16.2.2
*** openafs/src/afs/afs_buffer.c:1.16.2.1	Mon Oct 18 03:11:45 2004
--- openafs/src/afs/afs_buffer.c	Tue Nov  9 12:14:57 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_buffer.c,v 1.16.2.1 2004/10/18 07:11:45 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.16.2.2 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 63,69 ****
  /* page hash table size - this is pretty intertwined with pHash */
  #define PHSIZE (PHPAGEMASK + PHFIDMASK + 1)
  /* the pHash macro */
! #define pHash(fid,page) ((((afs_int32)((fid)->inode)) & PHFIDMASK) \
  			 | (page & PHPAGEMASK))
  
  #ifdef	dirty
--- 63,69 ----
  /* page hash table size - this is pretty intertwined with pHash */
  #define PHSIZE (PHPAGEMASK + PHFIDMASK + 1)
  /* the pHash macro */
! #define pHash(fid,page) ((((afs_int32)((fid)->f.inode)) & PHFIDMASK) \
  			 | (page & PHPAGEMASK))
  
  #ifdef	dirty
***************
*** 88,94 ****
  static afs_int32 timecounter;
  
  /* Prototypes for static routines */
! static struct buffer *afs_newslot(struct fcache * afid, afs_int32 apage,
  				  register struct buffer *lp);
  
  static int dinit_flag = 0;
--- 88,94 ----
  static afs_int32 timecounter;
  
  /* Prototypes for static routines */
! static struct buffer *afs_newslot(struct dcache * afid, afs_int32 apage,
  				  register struct buffer *lp);
  
  static int dinit_flag = 0;
***************
*** 150,156 ****
  }
  
  void *
! DRead(register struct fcache * fid, register int page)
  {
      /* Read a page from the disk. */
      register struct buffer *tb, *tb2;
--- 150,156 ----
  }
  
  void *
! DRead(register struct dcache * fid, register int page)
  {
      /* Read a page from the disk. */
      register struct buffer *tb, *tb2;
***************
*** 224,236 ****
      MObtainWriteLock(&tb->lock, 260);
      MReleaseWriteLock(&afs_bufferLock);
      tb->lockers++;
!     if (page * AFS_BUFFER_PAGESIZE >= fid->chunkBytes) {
  	dirp_Zap(tb->fid);
  	tb->lockers--;
  	MReleaseWriteLock(&tb->lock);
  	return NULL;
      }
!     tfile = afs_CFileOpen(fid->inode);
      code =
  	afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
  		      AFS_BUFFER_PAGESIZE);
--- 224,236 ----
      MObtainWriteLock(&tb->lock, 260);
      MReleaseWriteLock(&afs_bufferLock);
      tb->lockers++;
!     if (page * AFS_BUFFER_PAGESIZE >= fid->f.chunkBytes) {
  	dirp_Zap(tb->fid);
  	tb->lockers--;
  	MReleaseWriteLock(&tb->lock);
  	return NULL;
      }
!     tfile = afs_CFileOpen(fid->f.inode);
      code =
  	afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
  		      AFS_BUFFER_PAGESIZE);
***************
*** 273,279 ****
  
  /* lp is pointer to a fairly-old buffer */
  static struct buffer *
! afs_newslot(struct fcache * afid, afs_int32 apage, register struct buffer *lp)
  {
      /* Find a usable buffer slot */
      register afs_int32 i;
--- 273,279 ----
  
  /* lp is pointer to a fairly-old buffer */
  static struct buffer *
! afs_newslot(struct dcache * afid, afs_int32 apage, register struct buffer *lp)
  {
      /* Find a usable buffer slot */
      register afs_int32 i;
***************
*** 340,346 ****
      }
  
      if (lp->dirty) {
! 	tfile = afs_CFileOpen(lp->fid->inode);
  	afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
  		       AFS_BUFFER_PAGESIZE);
  	lp->dirty = 0;
--- 340,346 ----
      }
  
      if (lp->dirty) {
! 	tfile = afs_CFileOpen(lp->fid->f.inode);
  	afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
  		       AFS_BUFFER_PAGESIZE);
  	lp->dirty = 0;
***************
*** 432,438 ****
   * method of DRead...
   */
  void
! DZap(struct fcache * fid)
  {
      register int i;
      /* Destroy all buffers pertaining to a particular fid. */
--- 432,438 ----
   * method of DRead...
   */
  void
! DZap(struct dcache * fid)
  {
      register int i;
      /* Destroy all buffers pertaining to a particular fid. */
***************
*** 469,475 ****
  	    tb->lockers++;
  	    MReleaseReadLock(&afs_bufferLock);
  	    if (tb->dirty) {
! 		tfile = afs_CFileOpen(tb->fid->inode);
  		afs_CFileWrite(tfile, tb->page * AFS_BUFFER_PAGESIZE,
  			       tb->data, AFS_BUFFER_PAGESIZE);
  		tb->dirty = 0;	/* Clear the dirty flag */
--- 469,475 ----
  	    tb->lockers++;
  	    MReleaseReadLock(&afs_bufferLock);
  	    if (tb->dirty) {
! 		tfile = afs_CFileOpen(tb->fid->f.inode);
  		afs_CFileWrite(tfile, tb->page * AFS_BUFFER_PAGESIZE,
  			       tb->data, AFS_BUFFER_PAGESIZE);
  		tb->dirty = 0;	/* Clear the dirty flag */
***************
*** 484,490 ****
  }
  
  void *
! DNew(register struct fcache * fid, register int page)
  {
      /* Same as read, only do *not* even try to read the page, since it probably doesn't exist. */
      register struct buffer *tb;
--- 484,490 ----
  }
  
  void *
! DNew(register struct dcache * fid, register int page)
  {
      /* Same as read, only do *not* even try to read the page, since it probably doesn't exist. */
      register struct buffer *tb;
***************
*** 494,499 ****
--- 494,504 ----
  	MReleaseWriteLock(&afs_bufferLock);
  	return 0;
      }
+     /* extend the chunk, if needed */
+     if ((page + 1) * AFS_BUFFER_PAGESIZE > fid->f.chunkBytes) {
+         afs_AdjustSize(fid, (page + 1) * AFS_BUFFER_PAGESIZE);
+         afs_WriteDCache(fid, 1);
+     }
      MObtainWriteLock(&tb->lock, 265);
      MReleaseWriteLock(&afs_bufferLock);
      tb->lockers++;
Index: openafs/src/afs/afs_dcache.c
diff -c openafs/src/afs/afs_dcache.c:1.42.2.2 openafs/src/afs/afs_dcache.c:1.42.2.3
*** openafs/src/afs/afs_dcache.c:1.42.2.2	Mon Oct 18 13:43:49 2004
--- openafs/src/afs/afs_dcache.c	Tue Nov  9 12:14:57 2004
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.2 2004/10/18 17:43:49 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/afs_dcache.c,v 1.42.2.3 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 686,692 ****
      AFS_STATCNT(afs_glink);
  #endif
      /* we know this guy's in the LRUQ.  We'll move dude into DCQ below */
!     DZap(&adc->f);
      /* if this guy is in the hash table, pull him out */
      if (adc->f.fid.Fid.Volume != 0) {
  	/* remove entry from first hash chains */
--- 686,692 ----
      AFS_STATCNT(afs_glink);
  #endif
      /* we know this guy's in the LRUQ.  We'll move dude into DCQ below */
!     DZap(adc);
      /* if this guy is in the hash table, pull him out */
      if (adc->f.fid.Fid.Volume != 0) {
  	/* remove entry from first hash chains */
***************
*** 2038,2044 ****
  	 * Right now, we only have one tool, and it's a hammer.  So, we
  	 * fetch the whole file.
  	 */
! 	DZap(&tdc->f);	/* pages in cache may be old */
  #ifdef  IHINT
  	if (file = tdc->ihint) {
  	    if (tdc->f.inode == file->inum)
--- 2038,2044 ----
  	 * Right now, we only have one tool, and it's a hammer.  So, we
  	 * fetch the whole file.
  	 */
! 	DZap(tdc);	/* pages in cache may be old */
  #ifdef  IHINT
  	if (file = tdc->ihint) {
  	    if (tdc->f.inode == file->inum)
***************
*** 2415,2421 ****
  	    afs_CFileClose(file);
  	    ZapDCE(tdc);	/* sets DFEntryMod */
  	    if (vType(avc) == VDIR) {
! 		DZap(&tdc->f);
  	    }
  	    ReleaseWriteLock(&tdc->lock);
  	    afs_PutDCache(tdc);
--- 2415,2421 ----
  	    afs_CFileClose(file);
  	    ZapDCE(tdc);	/* sets DFEntryMod */
  	    if (vType(avc) == VDIR) {
! 		DZap(tdc);
  	    }
  	    ReleaseWriteLock(&tdc->lock);
  	    afs_PutDCache(tdc);
Index: openafs/src/afs/afs_nfsdisp.c
diff -c openafs/src/afs/afs_nfsdisp.c:1.18 openafs/src/afs/afs_nfsdisp.c:1.18.2.1
*** openafs/src/afs/afs_nfsdisp.c:1.18	Tue Jul 15 19:14:12 2003
--- openafs/src/afs/afs_nfsdisp.c	Tue Nov  9 12:18:18 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18 2003/07/15 23:14:12 shadow Exp $");
  
  /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
  #define __XDR_INCLUDE__
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18.2.1 2004/11/09 17:18:18 shadow Exp $");
  
  /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
  #define __XDR_INCLUDE__
***************
*** 747,752 ****
--- 747,759 ----
      resp->flags = FALSE;
  }
  
+ void
+ afs_nfs3_notsupp(struct afs_nfs3_resp *resp)
+ {
+     resp->status = NFS3ERR_NOTSUPP;
+     resp->flags = FALSE;
+ }
+ 
  afs_int32
  nfs3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
  {
***************
*** 1370,1375 ****
--- 1377,1384 ----
  			    crp);
      if (call > 1)
  	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+     else if (call == 1)
+ 	afs_nfs3_notsupp((struct afs_nfs3_resp *)xp);
      else
  	(*afs_rfs3_disp_tbl[NFSPROC3_READDIRPLUS].orig_proc) (args, xp, exp,
  							      rp, crp);
Index: openafs/src/afs/afs_osi_pag.c
diff -c openafs/src/afs/afs_osi_pag.c:1.21.2.1 openafs/src/afs/afs_osi_pag.c:1.21.2.2
*** openafs/src/afs/afs_osi_pag.c:1.21.2.1	Mon Oct 18 03:11:45 2004
--- openafs/src/afs/afs_osi_pag.c	Tue Nov  9 12:09:39 2004
***************
*** 23,29 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_pag.c,v 1.21.2.1 2004/10/18 07:11:45 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_pag.c,v 1.21.2.2 2004/11/09 17:09:39 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 160,166 ****
    if(afs_pag_sleep(acred)) {
      if(!afs_pag_sleepcnt) {
        printf("%s() PAG throttling triggered, pid %d... sleeping.  sleepcnt %d\n",
! 	     __func__, getpid(), afs_pag_sleepcnt);
      }
      
      afs_pag_sleepcnt++;
--- 160,166 ----
    if(afs_pag_sleep(acred)) {
      if(!afs_pag_sleepcnt) {
        printf("%s() PAG throttling triggered, pid %d... sleeping.  sleepcnt %d\n",
! 	     "afs_pag_wait", getpid(), afs_pag_sleepcnt);
      }
      
      afs_pag_sleepcnt++;
Index: openafs/src/afs/afs_pioctl.c
diff -c openafs/src/afs/afs_pioctl.c:1.81.2.2 openafs/src/afs/afs_pioctl.c:1.81.2.3
*** openafs/src/afs/afs_pioctl.c:1.81.2.2	Mon Oct 18 13:43:49 2004
--- openafs/src/afs/afs_pioctl.c	Tue Nov  9 12:14:57 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.2 2004/10/18 17:43:49 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifdef AFS_OBSD_ENV
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.3 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifdef AFS_OBSD_ENV
***************
*** 1717,1723 ****
      Check_AtSys(avc, ain, &sysState, areq);
      ObtainReadLock(&tdc->lock);
      do {
! 	code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid);
      } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
      ReleaseReadLock(&tdc->lock);
      afs_PutDCache(tdc);		/* we're done with the data */
--- 1717,1723 ----
      Check_AtSys(avc, ain, &sysState, areq);
      ObtainReadLock(&tdc->lock);
      do {
! 	code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
      } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
      ReleaseReadLock(&tdc->lock);
      afs_PutDCache(tdc);		/* we're done with the data */
***************
*** 2397,2403 ****
      Check_AtSys(avc, ain, &sysState, areq);
      ObtainReadLock(&tdc->lock);
      do {
! 	code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid);
      } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
      ReleaseReadLock(&tdc->lock);
      bufp = sysState.name;
--- 2397,2403 ----
      Check_AtSys(avc, ain, &sysState, areq);
      ObtainReadLock(&tdc->lock);
      do {
! 	code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
      } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
      ReleaseReadLock(&tdc->lock);
      bufp = sysState.name;
***************
*** 2468,2477 ****
  	ObtainWriteLock(&tdc->lock, 661);
  	if (afs_LocalHero(avc, tdc, &OutDirStatus, 1)) {
  	    /* we can do it locally */
! 	    code = afs_dir_Delete(&tdc->f, bufp);
  	    if (code) {
  		ZapDCE(tdc);	/* surprise error -- invalid value */
! 		DZap(&tdc->f);
  	    }
  	}
  	ReleaseWriteLock(&tdc->lock);
--- 2468,2477 ----
  	ObtainWriteLock(&tdc->lock, 661);
  	if (afs_LocalHero(avc, tdc, &OutDirStatus, 1)) {
  	    /* we can do it locally */
! 	    code = afs_dir_Delete(tdc, bufp);
  	    if (code) {
  		ZapDCE(tdc);	/* surprise error -- invalid value */
! 		DZap(tdc);
  	    }
  	}
  	ReleaseWriteLock(&tdc->lock);
***************
*** 3503,3509 ****
      Check_AtSys(avc, ain, &sysState, areq);
      ObtainReadLock(&tdc->lock);
      do {
! 	code = afs_dir_Lookup(&tdc->f, sysState.name, &tfid.Fid);
      } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
      ReleaseReadLock(&tdc->lock);
      afs_PutDCache(tdc);		/* we're done with the data */
--- 3503,3509 ----
      Check_AtSys(avc, ain, &sysState, areq);
      ObtainReadLock(&tdc->lock);
      do {
! 	code = afs_dir_Lookup(tdc, sysState.name, &tfid.Fid);
      } while (code == ENOENT && Next_AtSys(avc, areq, &sysState));
      ReleaseReadLock(&tdc->lock);
      afs_PutDCache(tdc);		/* we're done with the data */
Index: openafs/src/afs/afs_prototypes.h
diff -c openafs/src/afs/afs_prototypes.h:1.53.2.1 openafs/src/afs/afs_prototypes.h:1.53.2.2
*** openafs/src/afs/afs_prototypes.h:1.53.2.1	Mon Oct 18 03:11:45 2004
--- openafs/src/afs/afs_prototypes.h	Tue Nov  9 12:14:57 2004
***************
*** 31,42 ****
  
  /* afs_buffer.c */
  extern void DInit(int abuffers);
! extern void *DRead(register struct fcache * fid, register int page);
  extern void DRelease(register struct buffer *bp, int flag);
  extern int DVOffset(register void *ap);
! extern void DZap(struct fcache * fid);
  extern void DFlush(void);
! extern void *DNew(register struct fcache * fid, register int page);
  extern void shutdown_bufferpackage(void);
  
  /* afs_call.c */
--- 31,42 ----
  
  /* afs_buffer.c */
  extern void DInit(int abuffers);
! extern void *DRead(register struct dcache * fid, register int page);
  extern void DRelease(register struct buffer *bp, int flag);
  extern int DVOffset(register void *ap);
! extern void DZap(struct dcache * fid);
  extern void DFlush(void);
! extern void *DNew(register struct dcache * fid, register int page);
  extern void shutdown_bufferpackage(void);
  
  /* afs_call.c */
Index: openafs/src/afs/afs_segments.c
diff -c openafs/src/afs/afs_segments.c:1.16.2.2 openafs/src/afs/afs_segments.c:1.16.2.3
*** openafs/src/afs/afs_segments.c:1.16.2.2	Mon Oct 18 13:43:50 2004
--- openafs/src/afs/afs_segments.c	Tue Nov  9 12:14:57 2004
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_segments.c,v 1.16.2.2 2004/10/18 17:43:50 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/afs_segments.c,v 1.16.2.3 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 898,904 ****
  	ObtainWriteLock(&tdc->lock, 679);
  	ZapDCE(tdc);
  	if (vType(avc) == VDIR)
! 	    DZap(&tdc->f);
  	ReleaseWriteLock(&tdc->lock);
  	afs_PutDCache(tdc);
      }
--- 898,904 ----
  	ObtainWriteLock(&tdc->lock, 679);
  	ZapDCE(tdc);
  	if (vType(avc) == VDIR)
! 	    DZap(tdc);
  	ReleaseWriteLock(&tdc->lock);
  	afs_PutDCache(tdc);
      }
Index: openafs/src/afs/FBSD/osi_module.c
diff -c openafs/src/afs/FBSD/osi_module.c:1.5 openafs/src/afs/FBSD/osi_module.c:1.5.2.1
*** openafs/src/afs/FBSD/osi_module.c:1.5	Wed Mar 10 18:01:51 2004
--- openafs/src/afs/FBSD/osi_module.c	Tue Nov  9 12:11:34 2004
***************
*** 12,18 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_module.c,v 1.5 2004/03/10 23:01:51 rees Exp $");
  
  #include <afs/sysincludes.h>
  #include <afsincludes.h>
--- 12,18 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_module.c,v 1.5.2.1 2004/11/09 17:11:34 shadow Exp $");
  
  #include <afs/sysincludes.h>
  #include <afsincludes.h>
***************
*** 43,63 ****
      case MOD_LOAD:
  	if (inited) {
  	    printf("afs cannot be MOD_LOAD'd more than once\n");
! 	    error = -1;
  	    break;
  	}
  	if (sysent[AFS_SYSCALL].sy_call != nosys
  	    && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
  	    printf("AFS_SYSCALL in use. aborting\n");
! 	    error = -1;
  	    break;
  	}
  	memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
  	strcpy(afs_vfsconf.vfc_name, "AFS");
  	afs_vfsconf.vfc_vfsops = &afs_vfsops;
  	afs_vfsconf.vfc_typenum = -1;	/* set by vfs_register */
  	afs_vfsconf.vfc_flags = VFCF_NETWORK;
! 	vfs_register(&afs_vfsconf);	/* doesn't fail */
  	vfs_add_vnodeops(&afs_vnodeop_opv_desc);
  	osi_Init();
  #if 0
--- 43,67 ----
      case MOD_LOAD:
  	if (inited) {
  	    printf("afs cannot be MOD_LOAD'd more than once\n");
! 	    error = EBUSY;
  	    break;
  	}
  	if (sysent[AFS_SYSCALL].sy_call != nosys
  	    && sysent[AFS_SYSCALL].sy_call != lkmnosys) {
  	    printf("AFS_SYSCALL in use. aborting\n");
! 	    error = EBUSY;
  	    break;
  	}
  	memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
+ #ifdef AFS_FBSD53_ENV
+ 	afs_vfsconf.vfc_version = VFS_VERSION;
+ #endif
  	strcpy(afs_vfsconf.vfc_name, "AFS");
  	afs_vfsconf.vfc_vfsops = &afs_vfsops;
  	afs_vfsconf.vfc_typenum = -1;	/* set by vfs_register */
  	afs_vfsconf.vfc_flags = VFCF_NETWORK;
! 	if ((error = vfs_register(&afs_vfsconf)) != 0)
! 	    break;
  	vfs_add_vnodeops(&afs_vnodeop_opv_desc);
  	osi_Init();
  #if 0
***************
*** 80,90 ****
  	    break;
  	}
  	if (afs_globalVFS) {
! 	    error = -1;
  	    break;
  	}
! 	if (vfs_unregister(&afs_vfsconf)) {
! 	    error = -1;
  	    break;
  	}
  	vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
--- 84,93 ----
  	    break;
  	}
  	if (afs_globalVFS) {
! 	    error = EBUSY;
  	    break;
  	}
! 	if ((error = vfs_unregister(&afs_vfsconf)) != 0) {
  	    break;
  	}
  	vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
Index: openafs/src/afs/FBSD/osi_vfsops.c
diff -c openafs/src/afs/FBSD/osi_vfsops.c:1.16 openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.1
*** openafs/src/afs/FBSD/osi_vfsops.c:1.16	Tue Jul 27 12:24:40 2004
--- openafs/src/afs/FBSD/osi_vfsops.c	Tue Nov  9 12:11:34 2004
***************
*** 2,8 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vfsops.c,v 1.16 2004/07/27 16:24:40 rees Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 2,8 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vfsops.c,v 1.16.2.1 2004/11/09 17:11:34 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 12,19 ****
  #include <sys/conf.h>
  #include <sys/syscall.h>
  
! struct vcache *afs_globalVp = 0;
! struct mount *afs_globalVFS = 0;
  int afs_pbuf_freecnt = -1;
  
  #ifdef AFS_FBSD50_ENV
--- 12,19 ----
  #include <sys/conf.h>
  #include <sys/syscall.h>
  
! struct vcache *afs_globalVp = NULL;
! struct mount *afs_globalVFS = NULL;
  int afs_pbuf_freecnt = -1;
  
  #ifdef AFS_FBSD50_ENV
***************
*** 29,37 ****
      return (0);			/* nothing to do. ? */
  }
  
  int
! afs_mount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
  	THREAD_OR_PROC)
  {
      /* ndp contains the mounted-from device.  Just ignore it.
       * we also don't care about our proc struct. */
--- 29,51 ----
      return (0);			/* nothing to do. ? */
  }
  
+ #ifdef AFS_FBSD53_ENV
+ int
+ afs_mount(struct mount *mp, struct thread *td)
+ {
+     int afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p);
+ 
+     return afs_omount(mp, NULL, NULL, td);
+ }
+ #endif
+ 
  int
! #ifdef AFS_FBSD53_ENV
! afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p)
! #else
! afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
  	THREAD_OR_PROC)
+ #endif
  {
      /* ndp contains the mounted-from device.  Just ignore it.
       * we also don't care about our proc struct. */
***************
*** 45,51 ****
  
      if (afs_globalVFS) {	/* Don't allow remounts. */
  	AFS_GUNLOCK();
! 	return (EBUSY);
      }
  
      afs_globalVFS = mp;
--- 59,65 ----
  
      if (afs_globalVFS) {	/* Don't allow remounts. */
  	AFS_GUNLOCK();
! 	return EBUSY;
      }
  
      afs_globalVFS = mp;
***************
*** 53,59 ****
      vfs_getnewfsid(mp);
      mp->mnt_stat.f_iosize = 8192;
  
!     (void)copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
      memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
      memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
      strcpy(mp->mnt_stat.f_mntfromname, "AFS");
--- 67,74 ----
      vfs_getnewfsid(mp);
      mp->mnt_stat.f_iosize = 8192;
  
!     if (path)
! 	(void) copyinstr(path, mp->mnt_stat.f_mntonname, MNAMELEN - 1, &size);
      memset(mp->mnt_stat.f_mntonname + size, 0, MNAMELEN - size);
      memset(mp->mnt_stat.f_mntfromname, 0, MNAMELEN);
      strcpy(mp->mnt_stat.f_mntfromname, "AFS");
***************
*** 89,101 ****
--- 104,122 ----
  }
  
  int
+ #ifdef AFS_FBSD53_ENV
+ afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
+ #else
  afs_root(struct mount *mp, struct vnode **vpp)
+ #endif
  {
      int error;
      struct vrequest treq;
      register struct vcache *tvp = 0;
  #ifdef AFS_FBSD50_ENV
+ #ifndef AFS_FBSD53_ENV
      struct thread *td = curthread;
+ #endif
      struct ucred *cr = td->td_ucred;
  #else
      struct proc *p = curproc;
***************
*** 202,208 ****
--- 223,232 ----
  }
  
  struct vfsops afs_vfsops = {
+ #ifdef AFS_FBSD53_ENV
      afs_mount,
+ #endif
+     afs_omount,
      afs_start,
      afs_unmount,
      afs_root,
***************
*** 217,222 ****
      vfs_stduninit,
      vfs_stdextattrctl,
  #ifdef AFS_FBSD50_ENV
!     NULL,
  #endif
  };
--- 241,246 ----
      vfs_stduninit,
      vfs_stdextattrctl,
  #ifdef AFS_FBSD50_ENV
!     vfs_stdsysctl,
  #endif
  };
Index: openafs/src/afs/IRIX/osi_vnodeops.c
diff -c openafs/src/afs/IRIX/osi_vnodeops.c:1.14.2.1 openafs/src/afs/IRIX/osi_vnodeops.c:1.14.2.2
*** openafs/src/afs/IRIX/osi_vnodeops.c:1.14.2.1	Wed Aug 25 03:09:34 2004
--- openafs/src/afs/IRIX/osi_vnodeops.c	Tue Nov  9 12:13:17 2004
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/IRIX/osi_vnodeops.c,v 1.14.2.1 2004/08/25 07:09:34 shadow Exp $");
  
  #ifdef	AFS_SGI62_ENV
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/IRIX/osi_vnodeops.c,v 1.14.2.2 2004/11/09 17:13:17 shadow Exp $");
  
  #ifdef	AFS_SGI62_ENV
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 354,362 ****
      register struct vnode *vp = AFSTOV(avc);
      struct buf *bp;
      daddr_t bn;
!     size_t acnt, cnt;
!     int off, newoff;
!     ssize_t bsize, rem, len;
      int error;
      struct bmapval bmv[2];
      int nmaps, didFakeOpen = 0;
--- 354,362 ----
      register struct vnode *vp = AFSTOV(avc);
      struct buf *bp;
      daddr_t bn;
!     off_t acnt, cnt;
!     off_t off, newoff;
!     off_t bsize, rem, len;
      int error;
      struct bmapval bmv[2];
      int nmaps, didFakeOpen = 0;
***************
*** 372,378 ****
      if (uio->uio_resid <= 0) {
  	return (0);
      }
!     if (uio->uio_offset < 0 || (signed long)newoff < 0) {
  	return (EINVAL);
      }
      if (ioflag & IO_DIRECT)
--- 372,378 ----
      if (uio->uio_resid <= 0) {
  	return (0);
      }
!     if (uio->uio_offset < 0 || newoff < 0)  {
  	return (EINVAL);
      }
      if (ioflag & IO_DIRECT)
***************
*** 473,479 ****
  	    /*
  	     * read/paging in a normal file
  	     */
! 	    rem = avc->m.Length - (afs_int32) uio->uio_offset;
  	    if (rem <= 0)
  		/* EOF */
  		break;
--- 473,479 ----
  	    /*
  	     * read/paging in a normal file
  	     */
! 	    rem = avc->m.Length - uio->uio_offset;
  	    if (rem <= 0)
  		/* EOF */
  		break;
***************
*** 604,610 ****
  	if (bp->b_flags & B_ERROR) {
  	    /*
  	     * Since we compile -signed, b_error is a signed
! 	     * char when it should ba an unsigned char.
  	     * This can cause some errors codes to be interpreted
  	     * as negative #s
  	     */
--- 604,610 ----
  	if (bp->b_flags & B_ERROR) {
  	    /*
  	     * Since we compile -signed, b_error is a signed
! 	     * char when it should be an unsigned char.
  	     * This can cause some errors codes to be interpreted
  	     * as negative #s
  	     */
***************
*** 638,644 ****
  	     * Make sure it is at least as high as the last byte we just wrote
  	     * into the buffer.
  	     */
! 	    if (avc->m.Length < (afs_int32) uio->uio_offset) {
  		AFS_GLOCK();
  		ObtainWriteLock(&avc->lock, 235);
  		avc->m.Length = uio->uio_offset;
--- 638,644 ----
  	     * Make sure it is at least as high as the last byte we just wrote
  	     * into the buffer.
  	     */
! 	    if (avc->m.Length < uio->uio_offset)  {
  		AFS_GLOCK();
  		ObtainWriteLock(&avc->lock, 235);
  		avc->m.Length = uio->uio_offset;
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.3 openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.4
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.3	Mon Oct 18 13:43:51 2004
--- openafs/src/afs/LINUX/osi_vnodeops.c	Tue Nov  9 12:15:02 2004
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.3 2004/10/18 17:43:51 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.4 2004/11/09 17:15:02 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 333,343 ****
      code = 0;
      offset = (int) fp->f_pos;
      while (1) {
! 	dirpos = BlobScan(&tdc->f, offset);
  	if (!dirpos)
  	    break;
  
! 	de = afs_dir_GetBlob(&tdc->f, dirpos);
  	if (!de)
  	    break;
  
--- 333,343 ----
      code = 0;
      offset = (int) fp->f_pos;
      while (1) {
! 	dirpos = BlobScan(tdc, offset);
  	if (!dirpos)
  	    break;
  
! 	de = afs_dir_GetBlob(tdc, dirpos);
  	if (!de)
  	    break;
  
Index: openafs/src/afs/VNOPS/afs_vnop_attrs.c
diff -c openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.1 openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.2
*** openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.1	Wed Aug 25 03:09:35 2004
--- openafs/src/afs/VNOPS/afs_vnop_attrs.c	Tue Nov  9 12:17:25 2004
***************
*** 24,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.1 2004/08/25 07:09:35 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 24,30 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.2 2004/11/09 17:17:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 317,322 ****
--- 317,330 ----
  				     CMB_ALLOW_EXEC_AS_READ)) {
  		    return EACCES;
  		}
+ #if 0
+ /* The effect of the following is to force the NFS client to refetch the
+  * volume root every time, since the mtime changes.  For Solaris 9 NFSv3
+  * clients, this means looping forever, since for some reason (related
+  * to caching?) it wants the mtime to be consistent two reads in a row.
+  * Why are volume roots special???
+  * --jhutz 2-May-2004
+  */
  		if (avc->mvstat == 2) {
  #if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  		    attrs->va_mtime.tv_nsec += ((++avc->xlatordv) * 1000);
***************
*** 324,329 ****
--- 332,338 ----
  		    attrs->va_mtime.tv_usec += ++avc->xlatordv;
  #endif
  		}
+ #endif
  	    }
  	    if ((au = afs_FindUser(treq.uid, -1, READ_LOCK))) {
  		register struct afs_exporter *exporter = au->exporter;
Index: openafs/src/afs/VNOPS/afs_vnop_create.c
diff -c openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.2 openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.3
*** openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.2	Mon Oct 18 13:43:51 2004
--- openafs/src/afs/VNOPS/afs_vnop_create.c	Tue Nov  9 12:15:04 2004
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.2 2004/10/18 17:43:51 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 154,160 ****
      if (tdc) {
  	/* see if file already exists.  If it does, we only set 
  	 * the size attributes (to handle O_TRUNC) */
! 	code = afs_dir_Lookup(&tdc->f, aname, &newFid.Fid);	/* use dnlc first xxx */
  	if (code == 0) {
  	    ReleaseSharedLock(&tdc->lock);
  	    afs_PutDCache(tdc);
--- 154,160 ----
      if (tdc) {
  	/* see if file already exists.  If it does, we only set 
  	 * the size attributes (to handle O_TRUNC) */
! 	code = afs_dir_Lookup(tdc, aname, &newFid.Fid);	/* use dnlc first xxx */
  	if (code == 0) {
  	    ReleaseSharedLock(&tdc->lock);
  	    afs_PutDCache(tdc);
***************
*** 368,377 ****
  	UpgradeSToWLock(&tdc->lock, 631);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(&tdc->f, aname, &newFid.Fid);
  	if (code) {
  	    ZapDCE(tdc);
! 	    DZap(&tdc->f);
  	}
      }
      if (tdc) {
--- 368,377 ----
  	UpgradeSToWLock(&tdc->lock, 631);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(tdc, aname, &newFid.Fid);
  	if (code) {
  	    ZapDCE(tdc);
! 	    DZap(tdc);
  	}
      }
      if (tdc) {
***************
*** 531,537 ****
      } else {
  	if (adc) {
  	    ZapDCE(adc);
! 	    DZap(&adc->f);
  	}
  	if (avc->states & CStatd) {
  	    osi_dnlc_purgedp(avc);
--- 531,537 ----
      } else {
  	if (adc) {
  	    ZapDCE(adc);
! 	    DZap(adc);
  	}
  	if (avc->states & CStatd) {
  	    osi_dnlc_purgedp(avc);
Index: openafs/src/afs/VNOPS/afs_vnop_dirops.c
diff -c openafs/src/afs/VNOPS/afs_vnop_dirops.c:1.14.2.2 openafs/src/afs/VNOPS/afs_vnop_dirops.c:1.14.2.3
*** openafs/src/afs/VNOPS/afs_vnop_dirops.c:1.14.2.2	Mon Oct 18 13:43:51 2004
--- openafs/src/afs/VNOPS/afs_vnop_dirops.c	Tue Nov  9 12:15:04 2004
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_dirops.c,v 1.14.2.2 2004/10/18 17:43:51 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_dirops.c,v 1.14.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 147,156 ****
  	ObtainWriteLock(&tdc->lock, 632);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(&tdc->f, aname, &newFid.Fid);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- use invalid value */
! 	    DZap(&tdc->f);
  	}
      }
      if (tdc) {
--- 147,156 ----
  	ObtainWriteLock(&tdc->lock, 632);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(tdc, aname, &newFid.Fid);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- use invalid value */
! 	    DZap(tdc);
  	}
      }
      if (tdc) {
***************
*** 250,256 ****
  	struct VenusFid unlinkFid;
  
  	unlinkFid.Fid.Vnode = 0;
! 	code = afs_dir_Lookup(&tdc->f, aname, &unlinkFid.Fid);
  	if (code == 0) {
  	    afs_int32 cached = 0;
  
--- 250,256 ----
  	struct VenusFid unlinkFid;
  
  	unlinkFid.Fid.Vnode = 0;
! 	code = afs_dir_Lookup(tdc, aname, &unlinkFid.Fid);
  	if (code == 0) {
  	    afs_int32 cached = 0;
  
***************
*** 304,313 ****
  	UpgradeSToWLock(&tdc->lock, 634);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Delete(&tdc->f, aname);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- invalid value */
! 	    DZap(&tdc->f);
  	}
      }
      if (tdc) {
--- 304,313 ----
  	UpgradeSToWLock(&tdc->lock, 634);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Delete(tdc, aname);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- invalid value */
! 	    DZap(tdc);
  	}
      }
      if (tdc) {
Index: openafs/src/afs/VNOPS/afs_vnop_link.c
diff -c openafs/src/afs/VNOPS/afs_vnop_link.c:1.15.2.2 openafs/src/afs/VNOPS/afs_vnop_link.c:1.15.2.3
*** openafs/src/afs/VNOPS/afs_vnop_link.c:1.15.2.2	Mon Oct 18 13:43:51 2004
--- openafs/src/afs/VNOPS/afs_vnop_link.c	Tue Nov  9 12:15:04 2004
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_link.c,v 1.15.2.2 2004/10/18 17:43:51 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_link.c,v 1.15.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 137,146 ****
  	ObtainWriteLock(&tdc->lock, 635);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(&tdc->f, aname, &avc->fid.Fid);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- invalid value */
! 	    DZap(&tdc->f);
  	}
      }
      if (tdc) {
--- 137,146 ----
  	ObtainWriteLock(&tdc->lock, 635);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(tdc, aname, &avc->fid.Fid);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- invalid value */
! 	    DZap(tdc);
  	}
      }
      if (tdc) {
Index: openafs/src/afs/VNOPS/afs_vnop_lookup.c
diff -c openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.3 openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.4
*** openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.3	Mon Oct 18 13:43:51 2004
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	Tue Nov  9 12:15:04 2004
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.3 2004/10/18 17:43:51 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.4 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 507,527 ****
      return 1;
  }
  
! #if (defined(AFS_SGI62_ENV) || defined(AFS_SUN57_64BIT_ENV))
! extern int BlobScan(ino64_t * afile, afs_int32 ablob);
! #else
! #if defined(AFS_HPUX1123_ENV)
! /* DEE should use the new afs_inode_t  for all */
! extern int BlobScan(ino_t * afile, afs_int32 ablob);
! #else
! #if defined AFS_LINUX_64BIT_KERNEL
! extern int BlobScan(long *afile, afs_int32 ablob);
! #else
! extern int BlobScan(afs_int32 * afile, afs_int32 ablob);
! #endif
! #endif
! #endif
! 
  
  /* called with an unlocked directory and directory cookie.  Areqp
   * describes who is making the call.
--- 507,513 ----
      return 1;
  }
  
! extern int BlobScan(struct dcache * afile, afs_int32 ablob);
  
  /* called with an unlocked directory and directory cookie.  Areqp
   * describes who is making the call.
***************
*** 674,680 ****
  	/* look for first safe entry to examine in the directory.  BlobScan
  	 * looks for a the 1st allocated dir after the dirCookie slot.
  	 */
! 	newIndex = BlobScan(&dcp->f, (dirCookie >> 5));
  	if (newIndex == 0)
  	    break;
  
--- 660,666 ----
  	/* look for first safe entry to examine in the directory.  BlobScan
  	 * looks for a the 1st allocated dir after the dirCookie slot.
  	 */
! 	newIndex = BlobScan(dcp, (dirCookie >> 5));
  	if (newIndex == 0)
  	    break;
  
***************
*** 683,689 ****
  
  	/* get a ptr to the dir entry */
  	dirEntryp =
! 	    (struct DirEntry *)afs_dir_GetBlob(&dcp->f, newIndex);
  	if (!dirEntryp)
  	    break;
  
--- 669,675 ----
  
  	/* get a ptr to the dir entry */
  	dirEntryp =
! 	    (struct DirEntry *)afs_dir_GetBlob(dcp, newIndex);
  	if (!dirEntryp)
  	    break;
  
***************
*** 1293,1299 ****
      {				/* sub-block just to reduce stack usage */
  	register struct dcache *tdc;
  	afs_size_t dirOffset, dirLen;
- 	struct fcache *theDir;
  	struct VenusFid tfid;
  
  	/* now we have to lookup the next fid */
--- 1279,1284 ----
***************
*** 1351,1365 ****
  
  	/* lookup the name in the appropriate dir, and return a cache entry
  	 * on the resulting fid */
- 	theDir = &tdc->f;
  	code =
! 	    afs_dir_LookupOffset(theDir, sysState.name, &tfid.Fid,
  				 &dirCookie);
  
  	/* If the first lookup doesn't succeed, maybe it's got @sys in the name */
  	while (code == ENOENT && Next_AtSys(adp, &treq, &sysState))
  	    code =
! 		afs_dir_LookupOffset(theDir, sysState.name, &tfid.Fid,
  				     &dirCookie);
  	tname = sysState.name;
  
--- 1336,1349 ----
  
  	/* lookup the name in the appropriate dir, and return a cache entry
  	 * on the resulting fid */
  	code =
! 	    afs_dir_LookupOffset(tdc, sysState.name, &tfid.Fid,
  				 &dirCookie);
  
  	/* If the first lookup doesn't succeed, maybe it's got @sys in the name */
  	while (code == ENOENT && Next_AtSys(adp, &treq, &sysState))
  	    code =
! 		afs_dir_LookupOffset(tdc, sysState.name, &tfid.Fid,
  				     &dirCookie);
  	tname = sysState.name;
  
Index: openafs/src/afs/VNOPS/afs_vnop_readdir.c
diff -c openafs/src/afs/VNOPS/afs_vnop_readdir.c:1.24.2.2 openafs/src/afs/VNOPS/afs_vnop_readdir.c:1.24.2.4
*** openafs/src/afs/VNOPS/afs_vnop_readdir.c:1.24.2.2	Mon Oct 18 13:43:53 2004
--- openafs/src/afs/VNOPS/afs_vnop_readdir.c	Tue Nov  9 12:19:16 2004
***************
*** 23,29 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_readdir.c,v 1.24.2.2 2004/10/18 17:43:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_readdir.c,v 1.24.2.4 2004/11/09 17:19:16 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 67,73 ****
      become static.
  */
  int
! BlobScan(struct fcache * afile, afs_int32 ablob)
  {
      register afs_int32 relativeBlob;
      afs_int32 pageBlob;
--- 67,73 ----
      become static.
  */
  int
! BlobScan(struct dcache * afile, afs_int32 ablob)
  {
      register afs_int32 relativeBlob;
      afs_int32 pageBlob;
***************
*** 292,297 ****
--- 292,300 ----
       afs_size_t off;
  {
      int code = 0;
+     struct volume *tvp;
+     afs_uint32 Volume = vc->fid.Fid.Volume;
+     afs_uint32 Vnode  = de->fid.vnode;
  #if	defined(AFS_SUN56_ENV)
      struct dirent64 *direntp;
  #else
***************
*** 304,309 ****
--- 307,385 ----
  #endif /* AFS_SGI53_ENV */
  
      AFS_STATCNT(afs_readdir_move);
+ 
+ #define READDIR_CORRECT_INUMS
+ #ifdef READDIR_CORRECT_INUMS
+     if (de->name[0] == '.' && !de->name[1]) {
+ 	/* This is the '.' entry; if we are a volume root, we need to
+ 	 * ignore the directory and use the inum for the mount point.
+ 	 */
+ 	if (!FidCmp(&afs_rootFid, &vc->fid)) {
+ 	    Volume = 0;
+ 	    Vnode  = 2;
+ 	} else if (vc->mvstat == 2) {
+ 	    tvp = afs_GetVolume(&vc->fid, 0, READ_LOCK);
+ 	    if (tvp) {
+ 		Volume = tvp->mtpoint.Fid.Volume;
+ 		Vnode  = tvp->mtpoint.Fid.Vnode;
+ 		afs_PutVolume(tvp, READ_LOCK);
+ 	    }
+ 	}
+     }
+     else if (de->name[0] == '.' && de->name[1] == '.' && !de->name[2]) {
+ 	/* This is the '..' entry.  Getting this right is very tricky,
+ 	 * because we might be a volume root (so our parent is in a
+ 	 * different volume), or our parent might be a volume root
+ 	 * (so we actually want the mount point) or BOTH! */
+ 	if (!FidCmp(&afs_rootFid, &vc->fid)) {
+ 	    /* We are the root of the AFS root, and thus our own parent */
+ 	    Volume = 0;
+ 	    Vnode  = 2;
+ 	} else if (vc->mvstat == 2) {
+ 	    /* We are a volume root, which means our parent is in another
+ 	     * volume.  Luckily, we should have his fid cached... */
+ 	    if (vc->mvid) {
+ 		if (!FidCmp(&afs_rootFid, vc->mvid)) {
+ 		    /* Parent directory is the root of the AFS root */
+ 		    Volume = 0;
+ 		    Vnode  = 2;
+ 		} else if (vc->mvid->Fid.Vnode == 1
+ 			   && vc->mvid->Fid.Unique == 1) {
+ 		    /* XXX The above test is evil and probably breaks DFS */
+ 		    /* Parent directory is the target of a mount point */
+ 		    tvp = afs_GetVolume(vc->mvid, 0, READ_LOCK);
+ 		    if (tvp) {
+ 			Volume = tvp->mtpoint.Fid.Volume;
+ 			Vnode  = tvp->mtpoint.Fid.Vnode;
+ 			afs_PutVolume(tvp, READ_LOCK);
+ 		    }
+ 		} else {
+ 		    /* Parent directory is not a volume root */
+ 		    Volume = vc->mvid->Fid.Volume;
+ 		    Vnode  = vc->mvid->Fid.Vnode;
+ 		}
+ 	    }
+ 	} else if (de->fid.vnode == 1 && de->fid.vunique == 1) {
+ 	    /* XXX The above test is evil and probably breaks DFS */
+ 	    /* Parent directory is a volume root; use the right inum */
+ 	    tvp = afs_GetVolume(&vc->fid, 0, READ_LOCK);
+ 	    if (tvp) {
+ 		if (tvp->cell == afs_rootFid.Cell
+ 		    && tvp->volume == afs_rootFid.Fid.Volume) {
+ 		    /* Parent directory is the root of the AFS root */
+ 		    Volume = 0;
+ 		    Vnode  = 2;
+ 		} else {
+ 		    /* Parent directory is the target of a mount point */
+ 		    Volume = tvp->mtpoint.Fid.Volume;
+ 		    Vnode  = tvp->mtpoint.Fid.Vnode;
+ 		}
+ 		afs_PutVolume(tvp, READ_LOCK);
+ 	    }
+ 	}
+     }
+ #endif
+ 
  #ifdef	AFS_SGI53_ENV
      {
  	afs_int32 use64BitDirent;
***************
*** 328,335 ****
  
  	if (use64BitDirent) {
  	    struct min_dirent sdirEntry;
! 	    sdirEntry.d_fileno =
! 		(vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode);
  	    FIXUPSTUPIDINODE(sdirEntry.d_fileno);
  	    sdirEntry.d_reclen = rlen;
  	    sdirEntry.d_off = (off_t) off;
--- 404,410 ----
  
  	if (use64BitDirent) {
  	    struct min_dirent sdirEntry;
! 	    sdirEntry.d_fileno = (Volume << 16) + ntohl(Vnode);
  	    FIXUPSTUPIDINODE(sdirEntry.d_fileno);
  	    sdirEntry.d_reclen = rlen;
  	    sdirEntry.d_off = (off_t) off;
***************
*** 352,359 ****
  	    }
  	} else {
  	    struct irix5_min_dirent sdirEntry;
! 	    sdirEntry.d_fileno =
! 		(vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode);
  	    FIXUPSTUPIDINODE(sdirEntry.d_fileno);
  	    sdirEntry.d_reclen = rlen;
  	    sdirEntry.d_off = (afs_int32) off;
--- 427,433 ----
  	    }
  	} else {
  	    struct irix5_min_dirent sdirEntry;
! 	    sdirEntry.d_fileno = (Volume << 16) + ntohl(Vnode);
  	    FIXUPSTUPIDINODE(sdirEntry.d_fileno);
  	    sdirEntry.d_reclen = rlen;
  	    sdirEntry.d_off = (afs_int32) off;
***************
*** 384,390 ****
  #else
      direntp = (struct dirent *)osi_AllocLargeSpace(AFS_LRALLOCSIZ);
  #endif
!     direntp->d_ino = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode);
      FIXUPSTUPIDINODE(direntp->d_ino);
  #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
      direntp->d_offset = off;
--- 458,464 ----
  #else
      direntp = (struct dirent *)osi_AllocLargeSpace(AFS_LRALLOCSIZ);
  #endif
!     direntp->d_ino =  (Volume << 16) + ntohl(Vnode);
      FIXUPSTUPIDINODE(direntp->d_ino);
  #if defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)
      direntp->d_offset = off;
***************
*** 398,404 ****
      osi_FreeLargeSpace((char *)direntp);
  #else /* AFS_SUN5_ENV */
      /* Note the odd mechanism for building the inode number */
!     sdirEntry.d_fileno = (vc->fid.Fid.Volume << 16) + ntohl(de->fid.vnode);
      FIXUPSTUPIDINODE(sdirEntry.d_fileno);
      sdirEntry.d_reclen = rlen;
  #if !defined(AFS_SGI_ENV)
--- 472,478 ----
      osi_FreeLargeSpace((char *)direntp);
  #else /* AFS_SUN5_ENV */
      /* Note the odd mechanism for building the inode number */
!     sdirEntry.d_fileno = (Volume << 16) + ntohl(Vnode);
      FIXUPSTUPIDINODE(sdirEntry.d_fileno);
      sdirEntry.d_reclen = rlen;
  #if !defined(AFS_SGI_ENV)
***************
*** 641,648 ****
  	origOffset = auio->afsio_offset;
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
! 	if (!(us = BlobScan(&tdc->f, (origOffset >> 5)))
! 	    || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f, us))) {
  	    /* failed to setup nde, return what we've got, and release ode */
  	    if (len) {
  		/* something to hand over. */
--- 715,722 ----
  	origOffset = auio->afsio_offset;
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
! 	if (!(us = BlobScan(tdc, (origOffset >> 5)))
! 	    || !(nde = (struct DirEntry *)afs_dir_GetBlob(tdc, us))) {
  	    /* failed to setup nde, return what we've got, and release ode */
  	    if (len) {
  		/* something to hand over. */
***************
*** 932,939 ****
  
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
! 	if (!(us = BlobScan(&tdc->f, (origOffset >> 5)))
! 	    || !(nde = (struct DirEntry *)afs_dir_GetBlob(&tdc->f, us))) {
  	    /* failed to setup nde, return what we've got, and release ode */
  	    if (len) {
  		/* something to hand over. */
--- 1006,1013 ----
  
  	/* scan for the next interesting entry scan for in-use blob otherwise up point at
  	 * this blob note that ode, if non-zero, also represents a held dir page */
! 	if (!(us = BlobScan(tdc, (origOffset >> 5)))
! 	    || !(nde = (struct DirEntry *)afs_dir_GetBlob(tdc, us))) {
  	    /* failed to setup nde, return what we've got, and release ode */
  	    if (len) {
  		/* something to hand over. */
Index: openafs/src/afs/VNOPS/afs_vnop_remove.c
diff -c openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.2 openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.3
*** openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.2	Mon Oct 18 13:43:53 2004
--- openafs/src/afs/VNOPS/afs_vnop_remove.c	Tue Nov  9 12:15:04 2004
***************
*** 23,29 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.2 2004/10/18 17:43:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 154,163 ****
  	UpgradeSToWLock(&tdc->lock, 637);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Delete(&tdc->f, aname);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- invalid value */
! 	    DZap(&tdc->f);
  	}
      }
      if (tdc) {
--- 154,163 ----
  	UpgradeSToWLock(&tdc->lock, 637);
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Delete(tdc, aname);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- invalid value */
! 	    DZap(tdc);
  	}
      }
      if (tdc) {
***************
*** 357,363 ****
       * done the work */
      if (!tvc)
  	if (tdc) {
! 	    code = afs_dir_Lookup(&tdc->f, aname, &unlinkFid.Fid);
  	    if (code == 0) {
  		afs_int32 cached = 0;
  
--- 357,363 ----
       * done the work */
      if (!tvc)
  	if (tdc) {
! 	    code = afs_dir_Lookup(tdc, aname, &unlinkFid.Fid);
  	    if (code == 0) {
  		afs_int32 cached = 0;
  
Index: openafs/src/afs/VNOPS/afs_vnop_rename.c
diff -c openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.2 openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.3
*** openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.2	Mon Oct 18 13:43:53 2004
--- openafs/src/afs/VNOPS/afs_vnop_rename.c	Tue Nov  9 12:15:04 2004
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_rename.c,v 1.16.2.2 2004/10/18 17:43:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_rename.c,v 1.16.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 146,152 ****
      }
  
      if (code == 0)
! 	code = afs_dir_Lookup(&tdc1->f, aname1, &fileFid.Fid);
      if (code) {
  	if (tdc1) {
  	    ReleaseWriteLock(&tdc1->lock);
--- 146,152 ----
      }
  
      if (code == 0)
! 	code = afs_dir_Lookup(tdc1, aname1, &fileFid.Fid);
      if (code) {
  	if (tdc1) {
  	    ReleaseWriteLock(&tdc1->lock);
***************
*** 205,242 ****
  	    if (!doLocally) {
  		if (tdc1) {
  		    ZapDCE(tdc1);
! 		    DZap(&tdc1->f);
  		}
  		if (tdc2) {
  		    ZapDCE(tdc2);
! 		    DZap(&tdc2->f);
  		}
  	    }
  	}
  	/* now really do the work */
  	if (doLocally) {
  	    /* first lookup the fid of the dude we're moving */
! 	    code = afs_dir_Lookup(&tdc1->f, aname1, &fileFid.Fid);
  	    if (code == 0) {
  		/* delete the source */
! 		code = afs_dir_Delete(&tdc1->f, aname1);
  	    }
  	    /* first see if target is there */
  	    if (code == 0
! 		&& afs_dir_Lookup(&tdc2->f, aname2,
  				  &unlinkFid.Fid) == 0) {
  		/* target already exists, and will be unlinked by server */
! 		code = afs_dir_Delete(&tdc2->f, aname2);
  	    }
  	    if (code == 0) {
! 		code = afs_dir_Create(&tdc2->f, aname2, &fileFid.Fid);
  	    }
  	    if (code != 0) {
  		ZapDCE(tdc1);
! 		DZap(&tdc1->f);
  		if (!oneDir) {
  		    ZapDCE(tdc2);
! 		    DZap(&tdc2->f);
  		}
  	    }
  	}
--- 205,242 ----
  	    if (!doLocally) {
  		if (tdc1) {
  		    ZapDCE(tdc1);
! 		    DZap(tdc1);
  		}
  		if (tdc2) {
  		    ZapDCE(tdc2);
! 		    DZap(tdc2);
  		}
  	    }
  	}
  	/* now really do the work */
  	if (doLocally) {
  	    /* first lookup the fid of the dude we're moving */
! 	    code = afs_dir_Lookup(tdc1, aname1, &fileFid.Fid);
  	    if (code == 0) {
  		/* delete the source */
! 		code = afs_dir_Delete(tdc1, aname1);
  	    }
  	    /* first see if target is there */
  	    if (code == 0
! 		&& afs_dir_Lookup(tdc2, aname2,
  				  &unlinkFid.Fid) == 0) {
  		/* target already exists, and will be unlinked by server */
! 		code = afs_dir_Delete(tdc2, aname2);
  	    }
  	    if (code == 0) {
! 		code = afs_dir_Create(tdc2, aname2, &fileFid.Fid);
  	    }
  	    if (code != 0) {
  		ZapDCE(tdc1);
! 		DZap(tdc1);
  		if (!oneDir) {
  		    ZapDCE(tdc2);
! 		    DZap(tdc2);
  		}
  	    }
  	}
***************
*** 339,345 ****
  	    if (tdc1) {
  		ObtainWriteLock(&tdc1->lock, 648);
  		ZapDCE(tdc1);	/* mark as unknown */
! 		DZap(&tdc1->f);
  		ReleaseWriteLock(&tdc1->lock);
  		afs_PutDCache(tdc1);	/* put it back */
  	    }
--- 339,345 ----
  	    if (tdc1) {
  		ObtainWriteLock(&tdc1->lock, 648);
  		ZapDCE(tdc1);	/* mark as unknown */
! 		DZap(tdc1);
  		ReleaseWriteLock(&tdc1->lock);
  		afs_PutDCache(tdc1);	/* put it back */
  	    }
Index: openafs/src/afs/VNOPS/afs_vnop_symlink.c
diff -c openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.2 openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.3
*** openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.2	Mon Oct 18 13:43:53 2004
--- openafs/src/afs/VNOPS/afs_vnop_symlink.c	Tue Nov  9 12:15:04 2004
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.2 2004/10/18 17:43:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 184,193 ****
      /* otherwise, we should see if we can make the change to the dir locally */
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(&tdc->f, aname, &newFid.Fid);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- use invalid value */
! 	    DZap(&tdc->f);
  	}
      }
      if (tdc) {
--- 184,193 ----
      /* otherwise, we should see if we can make the change to the dir locally */
      if (afs_LocalHero(adp, tdc, &OutDirStatus, 1)) {
  	/* we can do it locally */
! 	code = afs_dir_Create(tdc, aname, &newFid.Fid);
  	if (code) {
  	    ZapDCE(tdc);	/* surprise error -- use invalid value */
! 	    DZap(tdc);
  	}
      }
      if (tdc) {
Index: openafs/src/cf/osconf.m4
diff -c openafs/src/cf/osconf.m4:1.51.2.4 openafs/src/cf/osconf.m4:1.51.2.5
*** openafs/src/cf/osconf.m4:1.51.2.4	Mon Oct 18 13:43:54 2004
--- openafs/src/cf/osconf.m4	Tue Nov  9 12:19:55 2004
***************
*** 255,260 ****
--- 255,273 ----
  		SHLIB_LINKER="${MT_CC} -shared"
  		;;
  
+ 	ppc64_linux26)
+ 		KERN_OPTMZ=-O2
+ 		LEX="flex -l"
+ 		MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}'
+ 		MT_LIBS="-lpthread"
+ 		PAM_CFLAGS="-g -O2 -Dlinux -DLINUX_PAM -fPIC"
+ 		SHLIB_LDFLAGS="-shared -Xlinker -x"
+ 		TXLIBS="-lncurses"
+ 		XCFLAGS="-g -O2 -D_LARGEFILE64_SOURCE"
+ 		YACC="bison -y"
+ 		SHLIB_LINKER="${MT_CC} -shared"
+ 		;;
+ 
  	i386_umlinux22)
  		CC="gcc -pipe"
  		CCOBJ="gcc -pipe"
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.46.2.7 openafs/src/config/NTMakefile.i386_nt40:1.46.2.9
*** openafs/src/config/NTMakefile.i386_nt40:1.46.2.7	Mon Oct 18 00:21:25 2004
--- openafs/src/config/NTMakefile.i386_nt40	Tue Nov  9 12:09:08 2004
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=7200
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=7400
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
Index: openafs/src/config/afs_sysnames.h
diff -c openafs/src/config/afs_sysnames.h:1.50.2.2 openafs/src/config/afs_sysnames.h:1.50.2.3
*** openafs/src/config/afs_sysnames.h:1.50.2.2	Mon Oct 18 13:43:55 2004
--- openafs/src/config/afs_sysnames.h	Tue Nov  9 12:19:58 2004
***************
*** 138,143 ****
--- 138,144 ----
  #define SYS_NAME_ID_ppc_linux2          1600
  #define SYS_NAME_ID_ppc_linux22         1601
  #define SYS_NAME_ID_ppc_linux24         1602
+ #define SYS_NAME_ID_ppc_linux26         1603
  
  #define SYS_NAME_ID_sparc_linux2	1700
  #define SYS_NAME_ID_sparc_linux22	1701
Index: openafs/src/config/param.ppc_linux26.h
diff -c /dev/null openafs/src/config/param.ppc_linux26.h:1.1.2.1
*** /dev/null	Tue Nov  9 14:50:18 2004
--- openafs/src/config/param.ppc_linux26.h	Tue Nov  9 12:19:58 2004
***************
*** 0 ****
--- 1,140 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ /* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel,
+  * it's a judgment call. If something is obviously ppc specific, use that
+  * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2"
+  * in the sysname is the current version of the client. This takes into
+  * account the perferred OS user space configuration as well as the kernel.
+  */
+ 
+ #define AFS_LINUX20_ENV        1
+ #define AFS_LINUX22_ENV        1
+ #define AFS_LINUX24_ENV        1
+ #define AFS_LINUX26_ENV        1
+ #define AFS_PPC_LINUX20_ENV    1
+ #define AFS_PPC_LINUX22_ENV    1
+ #define AFS_PPC_LINUX24_ENV    1
+ #define AFS_PPC_LINUX26_ENV 1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 137
+ #define AFS_64BIT_ENV	1
+ #define AFS_64BIT_CLIENT	1
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ 
+ #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
+ #include <linux/threads.h>
+ 
+ #include <linux/config.h>
+ #ifdef CONFIG_SMP
+ #ifndef AFS_SMP
+ #define AFS_SMP 1
+ #endif
+ #endif
+ /* Using "AFS_SMP" to map to however many #define's are required to get
+  * MP to compile for Linux
+  */
+ #ifdef AFS_SMP
+ #ifndef CONFIG_SMP
+ #define CONFIG_SMP 1
+ #endif
+ #ifndef __SMP__
+ #define __SMP__
+ #endif
+ #define AFS_GLOBAL_SUNLOCK
+ #endif
+ 
+ #endif /* __KERNEL__  && !DUMP_KERNEL */
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS       2	/* Set to Userdisabled, allow sysctl to override */
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME       "ppc_linux26"
+ #define SYS_NAME_ID    SYS_NAME_ID_ppc_linux26
+ #define AFSBIG_ENDIAN    1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV            1	/* read/write implemented via VM */
+ 
+ #ifdef KERNEL
+ #ifndef MIN
+ #define MIN(A,B) ((A) < (B) ? (A) : (B))
+ #endif
+ #ifndef MAX
+ #define MAX(A,B) ((A) > (B) ? (A) : (B))
+ #endif
+ #endif /* KERNEL */
+ 
+ #endif /* AFS_PARAM_H */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ /* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel,
+  * it's a judgment call. If something is obviously ppc specific, use that
+  * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2"
+  * in the sysname is the current version of the client. This takes into
+  * account the perferred OS user space configuration as well as the kernel.
+  */
+ 
+ #define UKERNEL                        1	/* user space kernel */
+ #define AFS_ENV                        1
+ #define AFS_USR_LINUX20_ENV    1
+ #define AFS_USR_LINUX22_ENV    1
+ #define AFS_USR_LINUX24_ENV    1
+ #define AFS_USR_LINUX26_ENV 1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 137
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS             0	/* if nonzero, garbage collect PAGs */
+ 
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME       "ppc_linux26"
+ #define SYS_NAME_ID    SYS_NAME_ID_ppc_linux26
+ #define AFSBIG_ENDIAN       1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV            1	/* read/write implemented via VM */
+ 
+ #define        afsio_iov       uio_iov
+ #define        afsio_iovcnt    uio_iovcnt
+ #define        afsio_offset    uio_offset
+ #define        afsio_seg       uio_segflg
+ #define        afsio_fmode     uio_fmode
+ #define        afsio_resid     uio_resid
+ #define        AFS_UIOSYS      1
+ #define        AFS_UIOUSER     UIO_USERSPACE
+ #define        AFS_CLBYTES     MCLBYTES
+ #define        AFS_MINCHANGE   2
+ #define        VATTR_NULL      usr_vattr_null
+ 
+ #define AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #endif /* AFS_PARAM_H */
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/packaging/MacOS/OpenAFS.Info.plist
diff -c openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2 openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.1
*** openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2	Fri Oct 24 02:26:13 2003
--- openafs/src/packaging/MacOS/OpenAFS.Info.plist	Tue Nov  9 14:31:02 2004
***************
*** 3,19 ****
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.2.10</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.2.10</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
! 	<integer>2</integer>
  	<key>IFPkgFlagAllowBackRev</key>
  	<false/>
  	<key>IFPkgFlagAuthorizationAction</key>
--- 3,19 ----
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.74</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.74</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
! 	<integer>3</integer>
  	<key>IFPkgFlagAllowBackRev</key>
  	<false/>
  	<key>IFPkgFlagAuthorizationAction</key>
Index: openafs/src/packaging/MacOS/OpenAFS.info
diff -c openafs/src/packaging/MacOS/OpenAFS.info:1.1 openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.1
*** openafs/src/packaging/MacOS/OpenAFS.info:1.1	Mon Aug 26 16:24:11 2002
--- openafs/src/packaging/MacOS/OpenAFS.info	Tue Nov  9 14:31:02 2004
***************
*** 1,5 ****
  Title OpenAFS
! Version 1.2.6
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
--- 1,5 ----
  Title OpenAFS
! Version 1.3.74
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
Index: openafs/src/rx/rx_getaddr.c
diff -c openafs/src/rx/rx_getaddr.c:1.15.2.1 openafs/src/rx/rx_getaddr.c:1.15.2.2
*** openafs/src/rx/rx_getaddr.c:1.15.2.1	Mon Oct 18 03:12:06 2004
--- openafs/src/rx/rx_getaddr.c	Tue Nov  9 12:16:12 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_getaddr.c,v 1.15.2.1 2004/10/18 07:12:06 shadow Exp $");
  
  #ifndef AFS_DJGPP_ENV
  #ifndef KERNEL
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_getaddr.c,v 1.15.2.2 2004/11/09 17:16:12 shadow Exp $");
  
  #ifndef AFS_DJGPP_ENV
  #ifndef KERNEL
***************
*** 342,359 ****
      for (cp = (char *)ifc.ifc_buf, cplim = ifc.ifc_buf + ifc.ifc_len;
  	 cp < cplim;
  #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
! 	 cp += _SIZEOF_ADDR_IFREQ(*ifr))
  #else
  #ifdef AFS_AIX51_ENV
! 	 cp = cpnext)
  #else
! 	 cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a)))
  #endif
  #endif
      {
  	ifr = (struct ifreq *)cp;
  #else
-     for (i = 0; i < len; ++i) {
  	ifr = &ifs[i];
  #endif
  	a = (struct sockaddr_in *)&ifr->ifr_addr;
--- 342,363 ----
      for (cp = (char *)ifc.ifc_buf, cplim = ifc.ifc_buf + ifc.ifc_len;
  	 cp < cplim;
  #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
! 	 cp += _SIZEOF_ADDR_IFREQ(*ifr)
  #else
  #ifdef AFS_AIX51_ENV
! 	 cp = cpnext
  #else
! 	 cp += sizeof(ifr->ifr_name) + MAX(a->sin_len, sizeof(*a))
  #endif
  #endif
+ 	) 
+ #else
+     for (i = 0; i < len; ++i) 
+ #endif
      {
+ #if    defined(AFS_AIX41_ENV) || defined (AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  	ifr = (struct ifreq *)cp;
  #else
  	ifr = &ifs[i];
  #endif
  	a = (struct sockaddr_in *)&ifr->ifr_addr;
***************
*** 367,374 ****
  	    continue;		/* ignore this address */
  	}
  	if (a->sin_addr.s_addr != 0) {
! 	    if (!loopbacks && (ifr->ifr_flags & IFF_LOOPBACK)) {
! 		continue;	/* skip aliased loopbacks as well. */
  	    }
  	    if (count >= maxSize)	/* no more space */
  		printf("Too many interfaces..ignoring 0x%x\n",
--- 371,382 ----
  	    continue;		/* ignore this address */
  	}
  	if (a->sin_addr.s_addr != 0) {
!             if (!loopbacks) {
!                 if (a->sin_addr.s_addr == htonl(0x7f000001)) 
! 		    continue;	/* skip loopback address as well. */
!             } else {
!                 if (ifr->ifr_flags & IFF_LOOPBACK) 
! 		    continue;	/* skip aliased loopbacks as well. */
  	    }
  	    if (count >= maxSize)	/* no more space */
  		printf("Too many interfaces..ignoring 0x%x\n",
Index: openafs/src/sys/pioctl_nt.c
diff -c openafs/src/sys/pioctl_nt.c:1.18.2.2 openafs/src/sys/pioctl_nt.c:1.18.2.3
*** openafs/src/sys/pioctl_nt.c:1.18.2.2	Mon Oct 18 13:44:02 2004
--- openafs/src/sys/pioctl_nt.c	Fri Nov  5 14:21:58 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.18.2.2 2004/10/18 17:44:02 shadow Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.18.2.3 2004/11/05 19:21:58 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
***************
*** 530,536 ****
  	CloseHandle(reqHandle);
  	errno = CMtoUNIXerror(temp);
          if ( IoctlDebug() )
!             fprintf(stderr, "pioctl temp != 0: %d\r\n",temp);
  	return -1;
      }
  
--- 530,536 ----
  	CloseHandle(reqHandle);
  	errno = CMtoUNIXerror(temp);
          if ( IoctlDebug() )
!             fprintf(stderr, "pioctl temp != 0: 0x%X\r\n",temp);
  	return -1;
      }
  
Index: openafs/src/ubik/ubik.p.h
diff -c openafs/src/ubik/ubik.p.h:1.11.2.2 openafs/src/ubik/ubik.p.h:1.11.2.3
*** openafs/src/ubik/ubik.p.h:1.11.2.2	Mon Oct 18 13:44:03 2004
--- openafs/src/ubik/ubik.p.h	Tue Nov  9 12:09:41 2004
***************
*** 366,372 ****
  				 struct ubik_client **uclientp,
  				 int (*secproc) (), char *funcName, 
  				 afs_int32 gen_rxkad_level, 
! 				 afs_int32 maxservers, afs_int32 serviceid, 
  				 afs_int32 deadtime, afs_uint32 server, 
  				 afs_uint32 port, afs_int32 usrvid);
  
--- 366,372 ----
  				 struct ubik_client **uclientp,
  				 int (*secproc) (), char *funcName, 
  				 afs_int32 gen_rxkad_level, 
! 				 afs_int32 maxservers, char *serviceid, 
  				 afs_int32 deadtime, afs_uint32 server, 
  				 afs_uint32 port, afs_int32 usrvid);
  
Index: openafs/src/ubik/uinit.c
diff -c openafs/src/ubik/uinit.c:1.6.2.1 openafs/src/ubik/uinit.c:1.6.2.2
*** openafs/src/ubik/uinit.c:1.6.2.1	Mon Oct 18 03:12:16 2004
--- openafs/src/ubik/uinit.c	Tue Nov  9 12:09:41 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/uinit.c,v 1.6.2.1 2004/10/18 07:12:16 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/uinit.c,v 1.6.2.2 2004/11/09 17:09:41 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef AFS_NT40_ENV
***************
*** 57,63 ****
  ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth,
  	       struct ubik_client **uclientp, int (*secproc) (),
  	       char *funcName, afs_int32 gen_rxkad_level, 
! 	       afs_int32 maxservers, afs_int32 serviceid, afs_int32 deadtime,
  	       afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
  {
      afs_int32 code, scIndex, i;
--- 57,63 ----
  ugen_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth,
  	       struct ubik_client **uclientp, int (*secproc) (),
  	       char *funcName, afs_int32 gen_rxkad_level, 
! 	       afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
  	       afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
  {
      afs_int32 code, scIndex, i;
Index: openafs/src/util/Makefile.in
diff -c openafs/src/util/Makefile.in:1.24.2.1 openafs/src/util/Makefile.in:1.24.2.2
*** openafs/src/util/Makefile.in:1.24.2.1	Mon Oct 18 03:12:17 2004
--- openafs/src/util/Makefile.in	Tue Nov  9 14:35:50 2004
***************
*** 68,113 ****
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/casestrcpy.c
  
  hputil.o: ${srcdir}/hputil.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/hputil.c
  
  flipbase64.o: ${srcdir}/flipbase64.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/flipbase64.c
  
  volparse.o: ${srcdir}/volparse.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/volparse.c
  
  snprintf.o: ${srcdir}/snprintf.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/snprintf.c
  
  base64.o: ${srcdir}/base64.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/base64.c
  
  hostparse.o: ${srcdir}/hostparse.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/hostparse.c
  
  ktime.o: ${srcdir}/ktime.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/ktime.c
  
  kreltime.o: ${srcdir}/kreltime.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/kreltime.c
  
  get_krbrlm.o: ${srcdir}/get_krbrlm.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/get_krbrlm.c
  
  uuid.o: ${srcdir}/uuid.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/uuid.c
  
  sys.o: ${srcdir}/sys.c AFS_component_version_number.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/sys.c
  
  sys: sys.o 
  	${CC} ${LDFLAGS} -o sys sys.o
  
  isathing.o: ${srcdir}/isathing.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/isathing.c
  
  serverLog.o: ${srcdir}/serverLog.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/serverLog.c
  
  dirpath.o: ${srcdir}/dirpath.c ${includes}
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/dirpath.c
--- 68,113 ----
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/casestrcpy.c
  
  hputil.o: ${srcdir}/hputil.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/hputil.c
  
  flipbase64.o: ${srcdir}/flipbase64.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/flipbase64.c
  
  volparse.o: ${srcdir}/volparse.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/volparse.c
  
  snprintf.o: ${srcdir}/snprintf.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/snprintf.c
  
  base64.o: ${srcdir}/base64.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/base64.c
  
  hostparse.o: ${srcdir}/hostparse.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/hostparse.c
  
  ktime.o: ${srcdir}/ktime.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/ktime.c
  
  kreltime.o: ${srcdir}/kreltime.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/kreltime.c
  
  get_krbrlm.o: ${srcdir}/get_krbrlm.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/get_krbrlm.c
  
  uuid.o: ${srcdir}/uuid.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/uuid.c
  
  sys.o: ${srcdir}/sys.c AFS_component_version_number.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/sys.c
  
  sys: sys.o 
  	${CC} ${LDFLAGS} -o sys sys.o
  
  isathing.o: ${srcdir}/isathing.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/isathing.c
  
  serverLog.o: ${srcdir}/serverLog.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/serverLog.c
  
  dirpath.o: ${srcdir}/dirpath.c ${includes}
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/dirpath.c
***************
*** 116,134 ****
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/fileutil.c
  
  netutils.o: ${srcdir}/netutils.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/netutils.c
  
  afs_atomlist.o: ${srcdir}/afs_atomlist.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/afs_atomlist.c
  
  afs_lhash.o: ${srcdir}/afs_lhash.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/afs_lhash.c
  
  strlcat.o: ${srcdir}/strlcat.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/strlcat.c
  
  strlcpy.o: ${srcdir}/strlcpy.c ${includes}
! 	${CC} ${CFLAGS} -c ${srcdir}/strlcpy.c
  
  #
  # Install targets
--- 116,134 ----
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/fileutil.c
  
  netutils.o: ${srcdir}/netutils.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/netutils.c
  
  afs_atomlist.o: ${srcdir}/afs_atomlist.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/afs_atomlist.c
  
  afs_lhash.o: ${srcdir}/afs_lhash.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/afs_lhash.c
  
  strlcat.o: ${srcdir}/strlcat.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/strlcat.c
  
  strlcpy.o: ${srcdir}/strlcpy.c ${includes}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/strlcpy.c
  
  #
  # Install targets
Index: openafs/src/vfsck/fsck.h
diff -c openafs/src/vfsck/fsck.h:1.2 openafs/src/vfsck/fsck.h:1.2.2.1
*** openafs/src/vfsck/fsck.h:1.2	Tue Jul 15 19:17:27 2003
--- openafs/src/vfsck/fsck.h	Tue Nov  9 12:18:48 2004
***************
*** 325,327 ****
--- 325,333 ----
  #define fs_link         fs_unused[0]
  #define fs_rlink        fs_unused[1]
  #endif /* AFS_HPUX110_ENV */
+ 
+ #ifdef AFS_SUN59_ENV
+ /* diskaddr_t is longlong */
+ int bread(int fd, char *buf, diskaddr_t blk, long size);
+ int bwrite(int fd, char *buf,  diskaddr_t blk, long size);
+ #endif
Index: openafs/src/vfsck/utilities.c
diff -c openafs/src/vfsck/utilities.c:1.5 openafs/src/vfsck/utilities.c:1.5.2.1
*** openafs/src/vfsck/utilities.c:1.5	Tue Jul 15 19:17:27 2003
--- openafs/src/vfsck/utilities.c	Tue Nov  9 12:18:48 2004
***************
*** 19,25 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vfsck/utilities.c,v 1.5 2003/07/15 23:17:27 shadow Exp $");
  
  #include <sys/param.h>
  #define VICE			/* allow us to put our changes in at will */
--- 19,25 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vfsck/utilities.c,v 1.5.2.1 2004/11/09 17:18:48 shadow Exp $");
  
  #include <sys/param.h>
  #define VICE			/* allow us to put our changes in at will */
***************
*** 388,394 ****
--- 388,398 ----
  bread(fd, buf, blk, size)
       int fd;
       char *buf;
+ #ifdef AFS_SUN59_ENV
+      diskaddr_t blk;
+ #else
       daddr_t blk;
+ #endif
       long size;
  {
      char *cp;
***************
*** 451,457 ****
--- 455,465 ----
  bwrite(fd, buf, blk, size)
       int fd;
       char *buf;
+ #ifdef AFS_SUN59_ENV
+      diskaddr_t blk;
+ #else
       daddr_t blk;
+ #endif
       long size;
  {
      int i, n;
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.81 openafs/src/viced/afsfileprocs.c:1.81.2.1
*** openafs/src/viced/afsfileprocs.c:1.81	Wed Jun  2 04:23:39 2004
--- openafs/src/viced/afsfileprocs.c	Thu Oct 28 16:47:23 2004
***************
*** 29,35 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81 2004/06/02 08:23:39 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 29,35 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.1 2004/10/28 20:47:23 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 2732,2737 ****
--- 2732,2738 ----
  			      &rights, &anyrights))) {
  	    tstatus = &OutStats->AFSBulkStats_val[i];
  	    tstatus->errorCode = errorCode;
+ 	    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
  	    parentwhentargetnotdir = (Vnode *) 0;
  	    targetptr = (Vnode *) 0;
  	    volptr = (Volume *) 0;
Index: openafs/src/viced/callback.c
diff -c openafs/src/viced/callback.c:1.55.2.1 openafs/src/viced/callback.c:1.55.2.4
*** openafs/src/viced/callback.c:1.55.2.1	Mon Oct 18 03:12:22 2004
--- openafs/src/viced/callback.c	Tue Nov  9 12:17:49 2004
***************
*** 83,89 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/callback.c,v 1.55.2.1 2004/10/18 07:12:22 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>		/* for malloc() */
--- 83,89 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/callback.c,v 1.55.2.4 2004/11/09 17:17:49 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>		/* for malloc() */
***************
*** 572,577 ****
--- 572,578 ----
      struct AFSCBs tc;
      int code;
      int j;
+     struct rx_connection *cb_conn = NULL;
  
  #ifdef	ADAPT_MTU
      rx_SetConnDeadTime(ahost->callback_rxcon, 4);
***************
*** 594,601 ****
  	tc.AFSCBs_len = i;
  	tc.AFSCBs_val = tcbs;
  
  	H_UNLOCK;
! 	code |= RXAFSCB_CallBack(ahost->callback_rxcon, &tf, &tc);
  	H_LOCK;
      }
  
--- 595,606 ----
  	tc.AFSCBs_len = i;
  	tc.AFSCBs_val = tcbs;
  
+ 	cb_conn = ahost->callback_rxcon;
+ 	rx_GetConnection(cb_conn);
  	H_UNLOCK;
! 	code |= RXAFSCB_CallBack(cb_conn, &tf, &tc);
! 	rx_PutConnection(cb_conn);
! 	cb_conn = NULL;
  	H_LOCK;
      }
  
***************
*** 855,865 ****
  	struct host *hp;
  	hp = cba[i].hp;
  	if (hp && xhost != hp) {
- 	    rx_PutConnection(hp->callback_rxcon);
  	    h_Release_r(hp);
  	}
      }
  
      return;
  }
  
--- 860,879 ----
  	struct host *hp;
  	hp = cba[i].hp;
  	if (hp && xhost != hp) {
  	    h_Release_r(hp);
  	}
      }
  
+     /* H_UNLOCK around this so h_FreeConnection does not deadlock.
+        h_FreeConnection should *never* be called on a callback connection,
+        but on 10/27/04 a deadlock occurred where it was, when we know why,
+        this should be reverted. -- shadow */
+     H_UNLOCK;
+     for (i = 0; i < j; i++) {
+ 	rx_PutConnection(conns[i]);
+     }
+     H_LOCK;
+ 
      return;
  }
  
***************
*** 1076,1096 ****
      struct CallBack *cb;
      int code;
      char hoststr[16];
  
      cbstuff.nbreakers++;
      if (!(host->hostFlags & RESETDONE) && !(host->hostFlags & HOSTDELETED)) {
  	host->hostFlags &= ~ALTADDR;	/* alterrnate addresses are invalid */
  	if (host->interface) {
  	    H_UNLOCK;
  	    code =
! 		RXAFSCB_InitCallBackState3(host->callback_rxcon,
! 					   &FS_HostUUID);
! 	    H_LOCK;
  	} else {
  	    H_UNLOCK;
! 	    code = RXAFSCB_InitCallBackState(host->callback_rxcon);
! 	    H_LOCK;
  	}
  	host->hostFlags |= ALTADDR;	/* alternate addresses are valid */
  	if (code) {
  	    if (ShowProblems) {
--- 1090,1113 ----
      struct CallBack *cb;
      int code;
      char hoststr[16];
+     struct rx_connection *cb_conn;
  
      cbstuff.nbreakers++;
      if (!(host->hostFlags & RESETDONE) && !(host->hostFlags & HOSTDELETED)) {
  	host->hostFlags &= ~ALTADDR;	/* alterrnate addresses are invalid */
+ 	cb_conn = host->callback_rxcon;
+ 	rx_GetConnection(cb_conn);
  	if (host->interface) {
  	    H_UNLOCK;
  	    code =
! 		RXAFSCB_InitCallBackState3(cb_conn, &FS_HostUUID);
  	} else {
  	    H_UNLOCK;
! 	    code = RXAFSCB_InitCallBackState(cb_conn);
  	}
+ 	rx_PutConnection(cb_conn);
+ 	cb_conn = NULL;
+ 	H_LOCK;
  	host->hostFlags |= ALTADDR;	/* alternate addresses are valid */
  	if (code) {
  	    if (ShowProblems) {
***************
*** 1626,1631 ****
--- 1643,1649 ----
      int code;
      int held = 0;
      char hoststr[16];
+     struct rx_connection *cb_conn = NULL;
  
      ViceLog(5,
  	    ("GSS: Delete longest inactive host %s\n",
***************
*** 1661,1676 ****
      } else {
  	/* host is up, try a call */
  	hp->hostFlags &= ~ALTADDR;	/* alternate addresses are invalid */
  	if (hp->interface) {
  	    H_UNLOCK;
  	    code =
! 		RXAFSCB_InitCallBackState3(hp->callback_rxcon, &FS_HostUUID);
! 	    H_LOCK;
  	} else {
  	    H_UNLOCK;
! 	    code = RXAFSCB_InitCallBackState(hp->callback_rxcon);
! 	    H_LOCK;
  	}
  	hp->hostFlags |= ALTADDR;	/* alternate addresses are valid */
  	if (code) {
  	    /* failed, mark host down and need reset */
--- 1679,1697 ----
      } else {
  	/* host is up, try a call */
  	hp->hostFlags &= ~ALTADDR;	/* alternate addresses are invalid */
+ 	cb_conn = hp->callback_rxcon;
+ 	rx_GetConnection(hp->callback_rxcon);
  	if (hp->interface) {
  	    H_UNLOCK;
  	    code =
! 		RXAFSCB_InitCallBackState3(cb_conn, &FS_HostUUID);
  	} else {
  	    H_UNLOCK;
! 	    code = RXAFSCB_InitCallBackState(cb_conn);
  	}
+ 	rx_PutConnection(cb_conn);
+ 	cb_conn = NULL;
+ 	H_LOCK;
  	hp->hostFlags |= ALTADDR;	/* alternate addresses are valid */
  	if (code) {
  	    /* failed, mark host down and need reset */
Index: openafs/src/viced/host.c
diff -c openafs/src/viced/host.c:1.57.2.1 openafs/src/viced/host.c:1.57.2.2
*** openafs/src/viced/host.c:1.57.2.1	Mon Oct 18 03:12:22 2004
--- openafs/src/viced/host.c	Tue Nov  9 12:17:49 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.1 2004/10/18 07:12:22 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.2 2004/11/09 17:17:49 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 947,952 ****
--- 947,953 ----
      afs_int32 hport;
      char hoststr[16], hoststr2[16];
      Capabilities caps;
+     struct rx_connection *cb_conn = NULL;
  
      caps.Capabilities_val = NULL;
  
***************
*** 979,989 ****
  	    goto retry;
  	}
  	host->hostFlags &= ~ALTADDR;
  	H_UNLOCK;
  	code =
! 	    RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf, &caps);
  	if (code == RXGEN_OPCODE)
! 	    code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf);
  	H_LOCK;
  	if (code == RXGEN_OPCODE) {
  	    identP = (struct Identity *)malloc(sizeof(struct Identity));
--- 980,994 ----
  	    goto retry;
  	}
  	host->hostFlags &= ~ALTADDR;
+ 	cb_conn = host->callback_rxcon;
+ 	rx_GetConnection(cb_conn);
  	H_UNLOCK;
  	code =
! 	    RXAFSCB_TellMeAboutYourself(cb_conn, &interf, &caps);
  	if (code == RXGEN_OPCODE)
! 	    code = RXAFSCB_WhoAreYou(cb_conn, &interf);
! 	rx_PutConnection(cb_conn);
! 	cb_conn=NULL;
  	H_LOCK;
  	if (code == RXGEN_OPCODE) {
  	    identP = (struct Identity *)malloc(sizeof(struct Identity));
***************
*** 1098,1109 ****
  	h_gethostcps_r(host, FT_ApproxTime());
  	if (!(host->Console & 1)) {
  	    int pident = 0;
  	    H_UNLOCK;
  	    code =
! 		RXAFSCB_TellMeAboutYourself(host->callback_rxcon, &interf,
! 					    &caps);
  	    if (code == RXGEN_OPCODE)
! 		code = RXAFSCB_WhoAreYou(host->callback_rxcon, &interf);
  	    H_LOCK;
  	    if (code == RXGEN_OPCODE) {
  		if (!identP)
--- 1103,1117 ----
  	h_gethostcps_r(host, FT_ApproxTime());
  	if (!(host->Console & 1)) {
  	    int pident = 0;
+ 	    cb_conn = host->callback_rxcon;
+ 	    rx_GetConnection(cb_conn);
  	    H_UNLOCK;
  	    code =
! 		RXAFSCB_TellMeAboutYourself(cb_conn, &interf, &caps);
  	    if (code == RXGEN_OPCODE)
! 		code = RXAFSCB_WhoAreYou(cb_conn, &interf);
! 	    rx_PutConnection(cb_conn);
! 	    cb_conn=NULL;
  	    H_LOCK;
  	    if (code == RXGEN_OPCODE) {
  		if (!identP)
***************
*** 1146,1153 ****
  			 ntohs(host->port)));
  	    }
  	    if (code == 0 && !identP->valid) {
  		H_UNLOCK;
! 		code = RXAFSCB_InitCallBackState(host->callback_rxcon);
  		H_LOCK;
  	    } else if (code == 0) {
  		oldHost = h_LookupUuid_r(&identP->uuid);
--- 1154,1165 ----
  			 ntohs(host->port)));
  	    }
  	    if (code == 0 && !identP->valid) {
+ 	        cb_conn = host->callback_rxcon;
+ 	        rx_GetConnection(cb_conn);
  		H_UNLOCK;
! 		code = RXAFSCB_InitCallBackState(cb_conn);
! 	        rx_PutConnection(cb_conn);
! 	        cb_conn=NULL;
  		H_LOCK;
  	    } else if (code == 0) {
  		oldHost = h_LookupUuid_r(&identP->uuid);
***************
*** 1172,1181 ****
  		} else {
  		    /* This really is a new host */
  		    hashInsertUuid_r(&identP->uuid, host);
  		    H_UNLOCK;
  		    code =
! 			RXAFSCB_InitCallBackState3(host->callback_rxcon,
  						   &FS_HostUUID);
  		    H_LOCK;
  		    if (code == 0) {
  			ViceLog(25,
--- 1184,1197 ----
  		} else {
  		    /* This really is a new host */
  		    hashInsertUuid_r(&identP->uuid, host);
+ 		    cb_conn = host->callback_rxcon;
+ 		    rx_GetConnection(cb_conn);		
  		    H_UNLOCK;
  		    code =
! 			RXAFSCB_InitCallBackState3(cb_conn,
  						   &FS_HostUUID);
+ 		    rx_PutConnection(cb_conn);
+ 		    cb_conn=NULL;
  		    H_LOCK;
  		    if (code == 0) {
  			ViceLog(25,
***************
*** 2043,2048 ****
--- 2059,2065 ----
  CheckHost(register struct host *host, int held)
  {
      register struct client *client;
+     struct rx_connection *cb_conn = NULL;
      int code;
  
      /* Host is held by h_Enumerate */
***************
*** 2055,2060 ****
--- 2072,2079 ----
      }
      if (host->LastCall < checktime) {
  	h_Lock_r(host);
+ 	cb_conn = host->callback_rxcon;
+ 	rx_GetConnection(cb_conn);
  	if (!(host->hostFlags & HOSTDELETED)) {
  	    if (host->LastCall < clientdeletetime) {
  		host->hostFlags |= HOSTDELETED;
***************
*** 2063,2075 ****
  		    if (host->interface) {
  			H_UNLOCK;
  			code =
! 			    RXAFSCB_InitCallBackState3(host->callback_rxcon,
  						       &FS_HostUUID);
  			H_LOCK;
  		    } else {
  			H_UNLOCK;
  			code =
! 			    RXAFSCB_InitCallBackState(host->callback_rxcon);
  			H_LOCK;
  		    }
  		    host->hostFlags |= ALTADDR;	/* alternate addresses valid */
--- 2082,2094 ----
  		    if (host->interface) {
  			H_UNLOCK;
  			code =
! 			    RXAFSCB_InitCallBackState3(cb_conn,
  						       &FS_HostUUID);
  			H_LOCK;
  		    } else {
  			H_UNLOCK;
  			code =
! 			    RXAFSCB_InitCallBackState(cb_conn);
  			H_LOCK;
  		    }
  		    host->hostFlags |= ALTADDR;	/* alternate addresses valid */
***************
*** 2093,2099 ****
  		    if (host->interface) {
  			afsUUID uuid = host->interface->uuid;
  			H_UNLOCK;
! 			code = RXAFSCB_ProbeUuid(host->callback_rxcon, &uuid);
  			H_LOCK;
  			if (code) {
  			    if (MultiProbeAlternateAddress_r(host)) {
--- 2112,2118 ----
  		    if (host->interface) {
  			afsUUID uuid = host->interface->uuid;
  			H_UNLOCK;
! 			code = RXAFSCB_ProbeUuid(cb_conn, &uuid);
  			H_LOCK;
  			if (code) {
  			    if (MultiProbeAlternateAddress_r(host)) {
***************
*** 2107,2113 ****
  			}
  		    } else {
  			H_UNLOCK;
! 			code = RXAFSCB_Probe(host->callback_rxcon);
  			H_LOCK;
  			if (code) {
  			    char hoststr[16];
--- 2126,2132 ----
  			}
  		    } else {
  			H_UNLOCK;
! 			code = RXAFSCB_Probe(cb_conn);
  			H_LOCK;
  			if (code) {
  			    char hoststr[16];
***************
*** 2121,2126 ****
--- 2140,2149 ----
  		}
  	    }
  	}
+ 	H_UNLOCK;
+ 	rx_PutConnection(cb_conn);
+ 	cb_conn=NULL;
+ 	H_LOCK;
  	h_Unlock_r(host);
      }
      H_UNLOCK;
Index: openafs/src/vol/namei_ops.c
diff -c openafs/src/vol/namei_ops.c:1.21.2.2 openafs/src/vol/namei_ops.c:1.21.2.3
*** openafs/src/vol/namei_ops.c:1.21.2.2	Mon Oct 18 13:44:06 2004
--- openafs/src/vol/namei_ops.c	Tue Nov  9 12:16:40 2004
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.2 2004/10/18 17:44:06 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.3 2004/11/09 17:16:40 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
***************
*** 229,235 ****
   * name space.
   */
  #define VICE_README "These files and directories are a part of the AFS \
! namespace. Modifying them\nin any way will result in loss of AFS data.\n"
  int
  namei_ViceREADME(char *partition)
  {
--- 229,236 ----
   * name space.
   */
  #define VICE_README "These files and directories are a part of the AFS \
! namespace. Modifying them\nin any way will result in loss of AFS data,\n\
! ownership and permissions included.\n"
  int
  namei_ViceREADME(char *partition)
  {
Index: openafs/src/vol/vol-salvage.c
diff -c openafs/src/vol/vol-salvage.c:1.41.2.2 openafs/src/vol/vol-salvage.c:1.41.2.3
*** openafs/src/vol/vol-salvage.c:1.41.2.2	Mon Oct 18 13:44:06 2004
--- openafs/src/vol/vol-salvage.c	Tue Nov  9 12:20:26 2004
***************
*** 92,98 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.2 2004/10/18 17:44:06 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 92,98 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.3 2004/11/09 17:20:26 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
***************
*** 1589,1595 ****
      }
      if (!canfork || debug || Fork() == 0) {
  	int nInodes;
! 	nInodes = status.st_size / sizeof(struct ViceInodeInfo);
  	if (nInodes == 0) {
  	    fclose(summaryFile);
  	    close(inodeFd);
--- 1589,1596 ----
      }
      if (!canfork || debug || Fork() == 0) {
  	int nInodes;
! 	unsigned long st_size=(unsigned long) status.st_size;
! 	nInodes = st_size / sizeof(struct ViceInodeInfo);
  	if (nInodes == 0) {
  	    fclose(summaryFile);
  	    close(inodeFd);
***************
*** 1598,1604 ****
  		RemoveTheForce(fileSysPath);
  	    else {
  		struct VolumeSummary *vsp;
! 		int i, j;
  
  		GetVolumeSummary(singleVolumeNumber);
  
--- 1599,1605 ----
  		RemoveTheForce(fileSysPath);
  	    else {
  		struct VolumeSummary *vsp;
! 		int i;
  
  		GetVolumeSummary(singleVolumeNumber);
  
***************
*** 1611,1617 ****
  		singleVolumeNumber ? "No applicable" : "No", dev);
  	    return -1;
  	}
! 	ip = (struct ViceInodeInfo *)malloc(status.st_size);
  	if (ip == NULL) {
  	    fclose(summaryFile);
  	    close(inodeFd);
--- 1612,1618 ----
  		singleVolumeNumber ? "No applicable" : "No", dev);
  	    return -1;
  	}
! 	ip = (struct ViceInodeInfo *)malloc(nInodes*sizeof(struct ViceInodeInfo));
  	if (ip == NULL) {
  	    fclose(summaryFile);
  	    close(inodeFd);
***************
*** 1621,1627 ****
  		("Unable to allocate enough space to read inode table; %s not salvaged\n",
  		 dev);
  	}
! 	if (read(inodeFd, ip, status.st_size) != status.st_size) {
  	    fclose(summaryFile);
  	    close(inodeFd);
  	    unlink(path);
--- 1622,1628 ----
  		("Unable to allocate enough space to read inode table; %s not salvaged\n",
  		 dev);
  	}
! 	if (read(inodeFd, ip, st_size) != st_size) {
  	    fclose(summaryFile);
  	    close(inodeFd);
  	    unlink(path);
***************
*** 1630,1636 ****
  	}
  	qsort(ip, nInodes, sizeof(struct ViceInodeInfo), CompareInodes);
  	if (afs_lseek(inodeFd, 0, SEEK_SET) == -1
! 	    || write(inodeFd, ip, status.st_size) != status.st_size) {
  	    fclose(summaryFile);
  	    close(inodeFd);
  	    unlink(path);
--- 1631,1637 ----
  	}
  	qsort(ip, nInodes, sizeof(struct ViceInodeInfo), CompareInodes);
  	if (afs_lseek(inodeFd, 0, SEEK_SET) == -1
! 	    || write(inodeFd, ip, st_size) != st_size) {
  	    fclose(summaryFile);
  	    close(inodeFd);
  	    unlink(path);
***************
*** 1673,1686 ****
      assert(afs_fstat(fileno(summaryFile), &status) != -1);
      if (status.st_size != 0) {
  	int ret;
! 	inodeSummary = (struct InodeSummary *)malloc(status.st_size);
  	assert(inodeSummary != NULL);
  	/* For GNU we need to do lseek to get the file pointer moved. */
  	assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
! 	ret = read(fileno(summaryFile), inodeSummary, status.st_size);
! 	assert(ret == status.st_size);
      }
!     nVolumesInInodeFile = status.st_size / sizeof(struct InodeSummary);
      fclose(summaryFile);
      close(inodeFd);
      unlink(summaryFileName);
--- 1674,1689 ----
      assert(afs_fstat(fileno(summaryFile), &status) != -1);
      if (status.st_size != 0) {
  	int ret;
! 	unsigned long st_status=(unsigned long)status.st_size;
! 	inodeSummary = (struct InodeSummary *)malloc(st_status);
  	assert(inodeSummary != NULL);
  	/* For GNU we need to do lseek to get the file pointer moved. */
  	assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0);
! 	ret = read(fileno(summaryFile), inodeSummary, st_status);
! 	assert(ret == st_status);
      }
!     nVolumesInInodeFile =(unsigned long)(status.st_size) / sizeof(struct InodeSummary);
!     Log("%d nVolumesInInodeFile %d \n",nVolumesInInodeFile,(unsigned long)(status.st_size));
      fclose(summaryFile);
      close(inodeFd);
      unlink(summaryFileName);
***************
*** 2026,2031 ****
--- 2029,2035 ----
  
      /* Fix actual inode counts */
      if (!Showmode) {
+ 	Log("totalInodes %d\n",totalInodes);
  	for (ip = inodes; totalInodes; ip++, totalInodes--) {
  	    static int TraceBadLinkCounts = 0;
  #ifdef AFS_NAMEI_ENV
***************
*** 2061,2066 ****
--- 2065,2072 ----
  		}
  		ip->linkCount++;
  	    }
+ 
+ 	   Log("%d inodes to process\n",totalInodes); 
  	}
  #ifdef AFS_NAMEI_ENV
  	while (dec_VGLinkH > 0) {
Index: openafs/src/volser/volprocs.c
diff -c openafs/src/volser/volprocs.c:1.34.2.1 openafs/src/volser/volprocs.c:1.34.2.2
*** openafs/src/volser/volprocs.c:1.34.2.1	Mon Oct 18 03:12:29 2004
--- openafs/src/volser/volprocs.c	Tue Nov  9 12:13:45 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volprocs.c,v 1.34.2.1 2004/10/18 07:12:29 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volprocs.c,v 1.34.2.2 2004/11/09 17:13:45 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 1540,1545 ****
--- 1540,1549 ----
  	td->maxquota = astatus->maxquota;
      if (astatus->dayUse != -1)
  	td->dayUse = astatus->dayUse;
+     if (astatus->creationDate != -1)
+ 	td->creationDate = astatus->creationDate;
+     if (astatus->updateDate != -1)
+ 	td->updateDate = astatus->updateDate;
      VUpdateVolume(&error, tv);
      tt->rxCallPtr = (struct rx_call *)0;
      if (TRELE(tt))
Index: openafs/src/volser/volser_prototypes.h
diff -c openafs/src/volser/volser_prototypes.h:1.4 openafs/src/volser/volser_prototypes.h:1.4.2.1
*** openafs/src/volser/volser_prototypes.h:1.4	Tue Jul 15 19:17:48 2003
--- openafs/src/volser/volser_prototypes.h	Tue Nov  9 12:13:45 2004
***************
*** 17,22 ****
--- 17,23 ----
  extern void MapPartIdIntoName(afs_int32 partId, char *partName);
  extern int yesprompt(char *str);
  extern int PrintError(char *msg, afs_int32 errcode);
+ extern void init_volintInfo(struct volintInfo *vinfo);
  extern int UV_SetSecurity(register struct rx_securityClass *as,
  			  afs_int32 aindex);
  extern struct rx_connection *UV_Bind(afs_int32 aserver, afs_int32 port);
Index: openafs/src/volser/vos.c
diff -c openafs/src/volser/vos.c:1.40.2.1 openafs/src/volser/vos.c:1.40.2.2
*** openafs/src/volser/vos.c:1.40.2.1	Tue Aug 17 00:28:45 2004
--- openafs/src/volser/vos.c	Tue Nov  9 12:13:45 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.1 2004/08/17 04:28:45 jaltman Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.2 2004/11/09 17:13:45 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 499,509 ****
  		fprintf(STDOUT, "    Last Access %s",
  			ctime((time_t *) & pntr->accessDate));
  #endif
! 	    fprintf(STDOUT, "    Last Update %s",
! 		    ctime((time_t *) & pntr->updateDate));
! 	    fprintf(STDOUT,
! 		    "    %d accesses in the past day (i.e., vnode references)\n",
! 		    pntr->dayUse);
  	} else if (pntr->status == VBUSY) {
  	    *totalBusy += 1;
  	    qPut(&busyHead, pntr->volid);
--- 499,513 ----
  		fprintf(STDOUT, "    Last Access %s",
  			ctime((time_t *) & pntr->accessDate));
  #endif
! 	    if (!pntr->updateDate)
! 		fprintf(STDOUT, "    Last Update Never\n");
! 	    else {
! 		fprintf(STDOUT, "    Last Update %s",
! 			ctime((time_t *) & pntr->updateDate));
! 		fprintf(STDOUT,
! 			"    %d accesses in the past day (i.e., vnode references)\n",
! 			pntr->dayUse);
! 	    }
  	} else if (pntr->status == VBUSY) {
  	    *totalBusy += 1;
  	    qPut(&busyHead, pntr->volid);
***************
*** 652,662 ****
  		fprintf(STDOUT, "    Last Access %s",
  			ctime((time_t *) & a_xInfoP->accessDate));
  #endif
! 	    fprintf(STDOUT, "    Last Update %s",
! 		    ctime((time_t *) & a_xInfoP->updateDate));
! 	    fprintf(STDOUT,
! 		    "    %d accesses in the past day (i.e., vnode references)\n",
! 		    a_xInfoP->dayUse);
  
  	    /*
  	     * Print all the read/write and authorship stats.
--- 656,670 ----
  		fprintf(STDOUT, "    Last Access %s",
  			ctime((time_t *) & a_xInfoP->accessDate));
  #endif
! 	    if (!a_xInfoP->updateDate)
! 		fprintf(STDOUT, "    Last Update Never\n");
! 	    else {
! 		fprintf(STDOUT, "    Last Update %s",
! 			ctime((time_t *) & a_xInfoP->updateDate));
! 		fprintf(STDOUT,
! 			"    %d accesses in the past day (i.e., vnode references)\n",
! 			a_xInfoP->dayUse);
! 	    }
  
  	    /*
  	     * Print all the read/write and authorship stats.
***************
*** 1388,1403 ****
  	return (ENOENT);
      }
  
!     memset(&info, 0, sizeof(info));
      info.volid = volid;
      info.type = RWVOL;
-     info.dayUse = -1;
-     info.maxquota = -1;
-     info.flags = -1;
-     info.spare0 = -1;
-     info.spare1 = -1;
-     info.spare2 = -1;
-     info.spare3 = -1;
  
      if (as->parms[1].items) {
  	/* -max <quota> */
--- 1396,1404 ----
  	return (ENOENT);
      }
  
!     init_volintInfo(&info);
      info.volid = volid;
      info.type = RWVOL;
  
      if (as->parms[1].items) {
  	/* -max <quota> */
Index: openafs/src/volser/vsprocs.c
diff -c openafs/src/volser/vsprocs.c:1.33 openafs/src/volser/vsprocs.c:1.33.2.1
*** openafs/src/volser/vsprocs.c:1.33	Wed Jul 28 23:44:08 2004
--- openafs/src/volser/vsprocs.c	Tue Nov  9 12:13:45 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.33 2004/07/29 03:44:08 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.33.2.1 2004/11/09 17:13:45 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 406,411 ****
--- 406,424 ----
      return 0;
  }
  
+ void init_volintInfo(struct volintInfo *vinfo) {
+     memset(vinfo, 0, sizeof(struct volintInfo));
+ 
+     vinfo->maxquota = -1;
+     vinfo->dayUse = -1;
+     vinfo->creationDate = -1;
+     vinfo->updateDate = -1;
+     vinfo->flags = -1;
+     vinfo->spare0 = -1;
+     vinfo->spare1 = -1;
+     vinfo->spare2 = -1;
+     vinfo->spare3 = -1;
+ }
  
  static struct rx_securityClass *uvclass = 0;
  static int uvindex = -1;
***************
*** 624,631 ****
      tid = 0;
      aconn = (struct rx_connection *)0;
      error = 0;
!     memset(&tstatus, 0, sizeof(struct volintInfo));
!     tstatus.dayUse = -1;
      tstatus.maxquota = aquota;
  
      aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
--- 637,644 ----
      tid = 0;
      aconn = (struct rx_connection *)0;
      error = 0;
! 
!     init_volintInfo(&tstatus);
      tstatus.maxquota = aquota;
  
      aconn = UV_Bind(aserver, AFSCONF_VOLUMEPORT);
***************
*** 1338,1343 ****
--- 1351,1358 ----
  
      infop = (volintInfo *) volumeInfo.volEntries_val;
      infop->maxquota = -1;	/* Else it will replace the default quota */
+     infop->creationDate = -1;	/* Else it will use the source creation date */
+     infop->updateDate = -1;	/* Else it will use the source update date */
  #endif
  
      /* create a volume on the target machine */
***************
*** 4237,4245 ****
  	goto refail;
      }
  
!     memset(&vinfo, 0, sizeof(struct volintInfo));
!     vinfo.dayUse = -1;
!     vinfo.maxquota = -1;
      vinfo.creationDate = newCreateDate;
      vinfo.updateDate = newUpdateDate;
      code = AFSVolSetInfo(toconn, totid, &vinfo);
--- 4252,4258 ----
  	goto refail;
      }
  
!     init_volintInfo(&vinfo);
      vinfo.creationDate = newCreateDate;
      vinfo.updateDate = newUpdateDate;
      code = AFSVolSetInfo(toconn, totid, &vinfo);
