Index: openafs/src/WINNT/afsd/afsd_init.c
diff -c openafs/src/WINNT/afsd/afsd_init.c:1.40.2.11 openafs/src/WINNT/afsd/afsd_init.c:1.40.2.15
*** openafs/src/WINNT/afsd/afsd_init.c:1.40.2.11	Tue Dec  7 07:49:22 2004
--- openafs/src/WINNT/afsd/afsd_init.c	Sun Jan 30 23:23:57 2005
***************
*** 388,400 ****
      long maxcpus;
      long ltt, ltto;
      long rx_mtu, rx_nojumbo;
!     long virtualCache;
      char rootCellName[256];
      struct rx_service *serverp;
      static struct rx_securityClass *nullServerSecurityClassp;
      struct hostent *thp;
      char *msgBuf;
!     char buf[1024];
      HKEY parmKey;
      DWORD dummyLen;
      DWORD regType;
--- 388,400 ----
      long maxcpus;
      long ltt, ltto;
      long rx_mtu, rx_nojumbo;
!     long virtualCache = 0;
      char rootCellName[256];
      struct rx_service *serverp;
      static struct rx_securityClass *nullServerSecurityClassp;
      struct hostent *thp;
      char *msgBuf;
!     char buf[1024], *p, *q;
      HKEY parmKey;
      DWORD dummyLen;
      DWORD regType;
***************
*** 622,630 ****
          }
          afsi_log("Cache path %s", cm_CachePath);
      } else {
!         GetWindowsDirectory(cm_CachePath, sizeof(cm_CachePath));
!         cm_CachePath[2] = 0;	/* get drive letter only */
!         StringCbCatA(cm_CachePath, sizeof(cm_CachePath), "\\AFSCache");
          afsi_log("Default cache path %s", cm_CachePath);
      }
  
--- 622,633 ----
          }
          afsi_log("Cache path %s", cm_CachePath);
      } else {
!         dummyLen = ExpandEnvironmentStrings("%TEMP%\\AFSCache", cm_CachePath, sizeof(cm_CachePath));
!         if (dummyLen > sizeof(cm_CachePath)) {
!             afsi_log("Cache path [%%TEMP%%\\AFSCache] longer than %d after expanding env strings", 
!                      sizeof(cm_CachePath));
!             osi_panic("CachePath too long", __FILE__, __LINE__);
!         }
          afsi_log("Default cache path %s", cm_CachePath);
      }
  
***************
*** 668,702 ****
  
      dummyLen = sizeof(buf);
      code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, buf, &dummyLen);
!     if (code == ERROR_SUCCESS && buf[0]) {
!         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);
!                 cm_sysNameList[cm_sysNameCount][p-q] = '\0';
!                 cm_sysNameCount++;
! 
!                 do {
!                     if (*p == '\0')
!                         goto done_sysname;
!                         
!                     p++;
!                 } while (*p == '\0' || isspace(*p));
!                 q = p;
!                 p--;
!             }
          }
-       done_sysname:
-         StringCbCopyA(cm_sysName, MAXSYSNAME, cm_sysNameList[0]);
-     } else {
-         cm_sysNameCount = 1;
-         StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40");
-         StringCbCopyA(cm_sysNameList[0], MAXSYSNAME, "i386_nt40");
-         afsi_log("Default sys name %s", cm_sysName);
      }
  
      dummyLen = sizeof(cryptall);
      code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
--- 671,706 ----
  
      dummyLen = sizeof(buf);
      code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, buf, &dummyLen);
!     if (code != ERROR_SUCCESS || !buf[0]) {
! #if defined(_IA64_)
!         StringCbCopyA(buf, sizeof(buf), "ia64_win64");
! #elif defined(_AMD64)
!         StringCbCopyA(buf, sizeof(buf), "amd64_win64");
! #else /* assume x86 32-bit */
!         StringCbCopyA(buf, sizeof(buf), "x86_win32 i386_w2k i386_nt40");
! #endif
!     }
!     afsi_log("Sys name %s", buf); 
  
!     /* breakup buf into individual search string entries */
!     for (p = q = buf; p < buf + dummyLen; p++)
!     {
!         if (*p == '\0' || isspace(*p)) {
!             memcpy(cm_sysNameList[cm_sysNameCount],q,p-q);
!             cm_sysNameList[cm_sysNameCount][p-q] = '\0';
!             cm_sysNameCount++;
! 
!             do {
!                 if (*p == '\0')
!                     goto done_sysname;
!                 p++;
!             } while (*p == '\0' || isspace(*p));
!             q = p;
!             p--;
          }
      }
+   done_sysname:
+     StringCbCopyA(cm_sysName, MAXSYSNAME, cm_sysNameList[0]);
  
      dummyLen = sizeof(cryptall);
      code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,
***************
*** 890,931 ****
      /* Ensure the AFS Netbios Name is registered to allow loopback access */
      configureBackConnectionHostNames();
  
-     /* initialize RX, and tell it to listen to port 7001, which is used for
-      * callback RPC messages.
-      */
-     code = rx_Init(htons(7001));
-     afsi_log("rx_Init code %x", code);
-     if (code != 0) {
-         *reasonP = "afsd: failed to init rx client on port 7001";
-         return -1;
-     }
- 
-     /* Initialize the RPC server for session keys */
-     RpcInit();
- 
-     /* create an unauthenticated service #1 for callbacks */
-     nullServerSecurityClassp = rxnull_NewServerSecurityObject();
-     serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1,
-                              RXAFSCB_ExecuteRequest);
-     afsi_log("rx_NewService addr %x", (int)serverp);
-     if (serverp == NULL) {
-         *reasonP = "unknown error";
-         return -1;
-     }
- 
-     nullServerSecurityClassp = rxnull_NewServerSecurityObject();
-     serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats",
-                              &nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest);
-     afsi_log("rx_NewService addr %x", (int)serverp);
-     if (serverp == NULL) {
-         *reasonP = "unknown error";
-         return -1;
-     }
-         
-     /* start server threads, *not* donating this one to the pool */
-     rx_StartServer(0);
-     afsi_log("rx_StartServer");
- 
      /* init user daemon, and other packages */
      cm_InitUser();
  
--- 894,899 ----
***************
*** 962,967 ****
--- 930,968 ----
  #endif
  #endif
  
+     /* initialize RX, and tell it to listen to port 7001, which is used for
+      * callback RPC messages.
+      */
+     code = rx_Init(htons(7001));
+     afsi_log("rx_Init code %x", code);
+     if (code != 0) {
+         *reasonP = "afsd: failed to init rx client on port 7001";
+         return -1;
+     }
+ 
+     /* create an unauthenticated service #1 for callbacks */
+     nullServerSecurityClassp = rxnull_NewServerSecurityObject();
+     serverp = rx_NewService(0, 1, "AFS", &nullServerSecurityClassp, 1,
+                              RXAFSCB_ExecuteRequest);
+     afsi_log("rx_NewService addr %x", (int)serverp);
+     if (serverp == NULL) {
+         *reasonP = "unknown error";
+         return -1;
+     }
+ 
+     nullServerSecurityClassp = rxnull_NewServerSecurityObject();
+     serverp = rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats",
+                              &nullServerSecurityClassp, 1, RXSTATS_ExecuteRequest);
+     afsi_log("rx_NewService addr %x", (int)serverp);
+     if (serverp == NULL) {
+         *reasonP = "unknown error";
+         return -1;
+     }
+         
+     /* start server threads, *not* donating this one to the pool */
+     rx_StartServer(0);
+     afsi_log("rx_StartServer");
+ 
      code = cm_GetRootCellName(rootCellName);
      afsi_log("cm_GetRootCellName code %d, cm_freelanceEnabled= %d, rcn= %s", 
                code, cm_freelanceEnabled, (code ? "<none>" : rootCellName));
***************
*** 988,993 ****
--- 989,998 ----
      if (cm_freelanceEnabled)
          cm_InitFreelance();
  #endif
+ 
+     /* Initialize the RPC server for session keys */
+     RpcInit();
+ 
      return 0;
  }
  
Index: openafs/src/WINNT/afsd/afsd_service.c
diff -c openafs/src/WINNT/afsd/afsd_service.c:1.28.2.8 openafs/src/WINNT/afsd/afsd_service.c:1.28.2.12
*** openafs/src/WINNT/afsd/afsd_service.c:1.28.2.8	Tue Dec  7 01:02:46 2004
--- openafs/src/WINNT/afsd/afsd_service.c	Sun Jan 30 23:09:28 2005
***************
*** 171,180 ****
      long code;
  
      switch (ctrlCode) {
      case SERVICE_CONTROL_STOP:
!         /* Shutdown RPC */
!         RpcMgmtStopServerListening(NULL);
  
          /* Force trace if requested */
          code = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                               AFSConfigKeyName,
--- 171,188 ----
      long code;
  
      switch (ctrlCode) {
+     case SERVICE_CONTROL_SHUTDOWN:
      case SERVICE_CONTROL_STOP:
!         ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
!         ServiceStatus.dwWin32ExitCode = NO_ERROR;
!         ServiceStatus.dwCheckPoint = 1;
!         ServiceStatus.dwWaitHint = 30000;
!         ServiceStatus.dwControlsAccepted = 0;
!         SetServiceStatus(StatusHandle, &ServiceStatus);
  
+ #ifdef	FLUSH_VOLUME
+         afsd_ServiceFlushVolume((DWORD) lpEventData);                         
+ #endif                                                                                      
          /* Force trace if requested */
          code = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
                               AFSConfigKeyName,
***************
*** 195,214 ****
          }
  
        doneTrace:
-         ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
-         ServiceStatus.dwWin32ExitCode = NO_ERROR;
-         ServiceStatus.dwCheckPoint = 1;
-         ServiceStatus.dwWaitHint = 10000;
-         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
-         SetServiceStatus(StatusHandle, &ServiceStatus);
          SetEvent(WaitToTerminate);
          break;
      case SERVICE_CONTROL_INTERROGATE:
          ServiceStatus.dwCurrentState = SERVICE_RUNNING;
          ServiceStatus.dwWin32ExitCode = NO_ERROR;
          ServiceStatus.dwCheckPoint = 0;
          ServiceStatus.dwWaitHint = 0;
!         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP;
          SetServiceStatus(StatusHandle, &ServiceStatus);
          break;
          /* XXX handle system shutdown */
--- 203,217 ----
          }
  
        doneTrace:
          SetEvent(WaitToTerminate);
          break;
+ 
      case SERVICE_CONTROL_INTERROGATE:
          ServiceStatus.dwCurrentState = SERVICE_RUNNING;
          ServiceStatus.dwWin32ExitCode = NO_ERROR;
          ServiceStatus.dwCheckPoint = 0;
          ServiceStatus.dwWaitHint = 0;
!         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
          SetServiceStatus(StatusHandle, &ServiceStatus);
          break;
          /* XXX handle system shutdown */
***************
*** 236,244 ****
  
      switch (ctrlCode) 
      {
      case SERVICE_CONTROL_STOP:
!         /* Shutdown RPC */
!         RpcMgmtStopServerListening(NULL);
  
          /* Force trace if requested */
          code = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
--- 239,256 ----
  
      switch (ctrlCode) 
      {
+     case SERVICE_CONTROL_SHUTDOWN:
      case SERVICE_CONTROL_STOP:
!         ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
!         ServiceStatus.dwWin32ExitCode = NO_ERROR;
!         ServiceStatus.dwCheckPoint = 1;
!         ServiceStatus.dwWaitHint = 30000;
!         ServiceStatus.dwControlsAccepted = 0;
!         SetServiceStatus(StatusHandle, &ServiceStatus);
! 
! #ifdef	FLUSH_VOLUME
!         afsd_ServiceFlushVolume((DWORD) lpEventData);                         
! #endif                                                                                      
  
          /* Force trace if requested */
          code = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
***************
*** 260,271 ****
          }
  
        doneTrace:
-         ServiceStatus.dwCurrentState = SERVICE_STOP_PENDING;
-         ServiceStatus.dwWin32ExitCode = NO_ERROR;
-         ServiceStatus.dwCheckPoint = 1;
-         ServiceStatus.dwWaitHint = 10000;
-         ServiceStatus.dwControlsAccepted = 0;
-         SetServiceStatus(StatusHandle, &ServiceStatus);
          SetEvent(WaitToTerminate);
          dwRet = NO_ERROR;
          break;
--- 272,277 ----
***************
*** 275,281 ****
          ServiceStatus.dwWin32ExitCode = NO_ERROR;
          ServiceStatus.dwCheckPoint = 0;
          ServiceStatus.dwWaitHint = 0;
!         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_POWEREVENT;
          SetServiceStatus(StatusHandle, &ServiceStatus);
          dwRet = NO_ERROR;
          break;
--- 281,287 ----
          ServiceStatus.dwWin32ExitCode = NO_ERROR;
          ServiceStatus.dwCheckPoint = 0;
          ServiceStatus.dwWaitHint = 0;
!         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_POWEREVENT;
          SetServiceStatus(StatusHandle, &ServiceStatus);
          dwRet = NO_ERROR;
          break;
***************
*** 966,972 ****
  RegisterServiceCtrlHandlerExFunc pRegisterServiceCtrlHandlerEx = NULL;
  RegisterServiceCtrlHandlerFunc   pRegisterServiceCtrlHandler   = NULL; 
  
! void afsd_Main(DWORD argc, LPTSTR *argv)
  {
      long code;
      char *reason;
--- 972,978 ----
  RegisterServiceCtrlHandlerExFunc pRegisterServiceCtrlHandlerEx = NULL;
  RegisterServiceCtrlHandlerFunc   pRegisterServiceCtrlHandler   = NULL; 
  
! VOID WINAPI afsd_Main(DWORD argc, LPTSTR *argv)
  {
      long code;
      char *reason;
***************
*** 1155,1161 ****
          ServiceStatus.dwWaitHint = 0;
  
          /* accept Power events */
!         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_POWEREVENT;
          SetServiceStatus(StatusHandle, &ServiceStatus);
  #endif  
          {
--- 1161,1167 ----
          ServiceStatus.dwWaitHint = 0;
  
          /* accept Power events */
!         ServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN | SERVICE_ACCEPT_POWEREVENT;
          SetServiceStatus(StatusHandle, &ServiceStatus);
  #endif  
          {
***************
*** 1181,1186 ****
--- 1187,1194 ----
      DismountGlobalDrives();
      smb_Shutdown();
      rx_Finalize();
+     RpcShutdown();
+     buf_Shutdown();
  
  #ifdef	REGISTER_POWER_NOTIFICATIONS
      /* terminate thread used to flush cache */
Index: openafs/src/WINNT/afsd/afsd_service.rc
diff -c openafs/src/WINNT/afsd/afsd_service.rc:1.3 openafs/src/WINNT/afsd/afsd_service.rc:1.3.2.1
*** openafs/src/WINNT/afsd/afsd_service.rc:1.3	Thu Jun 19 15:00:46 2003
--- openafs/src/WINNT/afsd/afsd_service.rc	Sun Jan 30 23:09:28 2005
***************
*** 13,17 ****
--- 13,20 ----
  #define AFS_VERINFO_NAME "afsd_service"
  #define AFS_VERINFO_FILENAME "afsd_service.exe"
  
+ 1	ICON	afsd.ico
+ 
  #include "AFS_component_version_number.h"
  #include "..\..\config\NTVersioninfo.rc"
+ 
Index: openafs/src/WINNT/afsd/afskfw.c
diff -c openafs/src/WINNT/afsd/afskfw.c:1.8.2.5 openafs/src/WINNT/afsd/afskfw.c:1.8.2.7
*** openafs/src/WINNT/afsd/afskfw.c:1.8.2.5	Fri Nov  5 14:21:42 2004
--- openafs/src/WINNT/afsd/afskfw.c	Sun Jan 30 23:08:57 2005
***************
*** 63,68 ****
--- 63,69 ----
  #include <osilog.h>
  #include <rxkad_prototypes.h>   /* for life_to_time */
  #include <afs/ptserver.h>
+ #include <afs/ptuser.h>
  
  /*
   * TIMING _____________________________________________________________________
***************
*** 2509,2515 ****
               * level
               */
  
!             if (status = pr_Initialize(1L, confname, aserver->cell, 0))
                  return status;
              if (status = pr_CreateUser(username, &id))
                  return status;
--- 2510,2516 ----
               * level
               */
  
!             if (status = pr_Initialize(1L, confname, aserver->cell))
                  return status;
              if (status = pr_CreateUser(username, &id))
                  return status;
Index: openafs/src/WINNT/afsd/afslogon.c
diff -c openafs/src/WINNT/afsd/afslogon.c:1.24.2.4 openafs/src/WINNT/afsd/afslogon.c:1.24.2.5
*** openafs/src/WINNT/afsd/afslogon.c:1.24.2.4	Tue Dec  7 07:49:23 2004
--- openafs/src/WINNT/afsd/afslogon.c	Sun Jan 30 23:05:00 2005
***************
*** 254,259 ****
--- 254,281 ----
      return (Status.dwCurrentState == SERVICE_RUNNING);
  }   
  
+ BOOL IsServiceStartPending (void)
+ {
+     SERVICE_STATUS Status;
+     SC_HANDLE hManager;
+     memset (&Status, 0x00, sizeof(Status));
+     Status.dwCurrentState = SERVICE_STOPPED;
+ 
+     if ((hManager = OpenSCManager (NULL, NULL, GENERIC_READ)) != NULL)
+     {
+         SC_HANDLE hService;
+         if ((hService = OpenService (hManager, TEXT("TransarcAFSDaemon"), GENERIC_READ)) != NULL)
+         {
+             QueryServiceStatus (hService, &Status);
+             CloseServiceHandle (hService);
+         }
+ 
+         CloseServiceHandle (hManager);
+     }
+     DebugEvent("AFS AfsLogon - Test Service Start Pending","Return Code[%x] ?Start Pending[%d]",Status.dwCurrentState,(Status.dwCurrentState == SERVICE_START_PENDING));
+     return (Status.dwCurrentState == SERVICE_RUNNING);
+ }   
+ 
  /* LOOKUPKEYCHAIN: macro to look up the value in the list of keys in order until it's found
     v:variable to receive value (reference type)
     t:type
***************
*** 550,555 ****
--- 572,581 ----
  
      GetCPInfo(CP_ACP, &CodePageInfo);
  
+     if (CodePageInfo.MaxCharSize > 1)
+         // Only supporting non-Unicode strings
+         return FALSE;
+     
      if (uInputString.Buffer && ((LPBYTE) uInputString.Buffer)[1] == '\0')
      {
          // Looks like unicode, better translate it
***************
*** 561,567 ****
      }
      else
          lpszOutputString[0] = '\0';
- 
      return FALSE;
  }  // UnicodeStringToANSI
  
--- 587,592 ----
***************
*** 654,659 ****
--- 679,687 ----
      sleepInterval = opt.sleepInterval;
      *lpLogonScript = opt.logonScript;
  
+     if (retryInterval < sleepInterval)
+         sleepInterval = retryInterval;
+ 
      DebugEvent("Got logon script: %S",opt.logonScript);
  
      afsWillAutoStart = AFSWillAutoStart();
***************
*** 687,693 ****
          /* We get the user's home directory path, if applicable, though we can't lookup the
             cell right away because the client service may not have started yet. This call
             also sets the AD_REALM flag in opt.flags if applicable. */
!         if(ISREMOTE(opt.flags)) {
              DebugEvent("Is Remote");
              GetAdHomePath(homePath,MAX_PATH,lpLogonId,&opt);
          }       
--- 715,721 ----
          /* We get the user's home directory path, if applicable, though we can't lookup the
             cell right away because the client service may not have started yet. This call
             also sets the AD_REALM flag in opt.flags if applicable. */
!         if (ISREMOTE(opt.flags)) {
              DebugEvent("Is Remote");
              GetAdHomePath(homePath,MAX_PATH,lpLogonId,&opt);
          }       
***************
*** 698,706 ****
          DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]",
                      opt.LogonOption,afsWillAutoStart);
  
!         if(ISADREALM(opt.flags)) {
              code = GetFileCellName(homePath,cell,256);
!             if(!code) {
                  DebugEvent("profile path [%s] is in cell [%s]",homePath,cell);
              }
              /* Don't bail out if GetFileCellName failed.
--- 726,734 ----
          DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]",
                      opt.LogonOption,afsWillAutoStart);
  
!         if (ISADREALM(opt.flags)) {
              code = GetFileCellName(homePath,cell,256);
!             if (!code) {
                  DebugEvent("profile path [%s] is in cell [%s]",homePath,cell);
              }
              /* Don't bail out if GetFileCellName failed.
***************
*** 728,756 ****
                      *ctemp = tolower(*ctemp);
                  }
                  uppercased_name = FALSE;
!                 continue;
              }
          }
          else {  
              /*JUST check to see if its running*/
              if (IsServiceRunning())
                  break;
!             code = KTC_NOCM;
!             if (!afsWillAutoStart)
                  break;
          }
  
-         /* is service started yet?*/
-         DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]",
-                     code,uname,cell);
- 
-         /* If we've failed because the client isn't running yet and the
-          * client is set to autostart (and therefore it makes sense for
-          * us to wait for it to start) then sleep a while and try again. 
-          * If the error was something else, then give up. */
-         if (code != KTC_NOCM && code != KTC_NOCMRPC || !afsWillAutoStart)
-             break;
- 
          /* If the retry interval has expired and we still aren't
           * logged in, then just give up if we are not in interactive
           * mode or the failSilently flag is set, otherwise let the
--- 756,786 ----
                      *ctemp = tolower(*ctemp);
                  }
                  uppercased_name = FALSE;
!                 goto sleeping;
              }
+ 
+             /* is service started yet?*/
+             DebugEvent("AFS AfsLogon - ka_UserAuthenticateGeneral2","Code[%x] uname[%s] Cell[%s]",
+                         code,uname,cell);
+ 
+             /* If we've failed because the client isn't running yet and the
+             * client is set to autostart (and therefore it makes sense for
+             * us to wait for it to start) then sleep a while and try again. 
+             * If the error was something else, then give up. */
+             if (code != KTC_NOCM && code != KTC_NOCMRPC || !afsWillAutoStart)
+                 break;
          }
          else {  
              /*JUST check to see if its running*/
              if (IsServiceRunning())
                  break;
!             if (afsWillAutoStart && !IsServiceStartPending()) {
!                 code = KTC_NOCMRPC;
!                 reason = "AFS Service start failed";
                  break;
+             }
          }
  
          /* If the retry interval has expired and we still aren't
           * logged in, then just give up if we are not in interactive
           * mode or the failSilently flag is set, otherwise let the
***************
*** 767,780 ****
                  break;
  
              /* Wait just a little while and try again */
!             retryInterval = sleepInterval = DEFAULT_SLEEP_INTERVAL;
          }
  
!         if (retryInterval < sleepInterval)
!             sleepInterval = retryInterval;
! 
          Sleep(sleepInterval * 1000);
- 
          retryInterval -= sleepInterval;
      }
  
--- 797,807 ----
                  break;
  
              /* Wait just a little while and try again */
!             retryInterval = opt.retryInterval;
          }
  
!       sleeping:
          Sleep(sleepInterval * 1000);
          retryInterval -= sleepInterval;
      }
  
***************
*** 809,815 ****
              *lpLogonScript = NULL;
              if (!afsWillAutoStart)	// its not running, so if not autostart or integrated logon then just skip
                  code = 0;
- 
          }
      }
  
--- 836,841 ----
Index: openafs/src/WINNT/afsd/afslogon.h
diff -c openafs/src/WINNT/afsd/afslogon.h:1.5 openafs/src/WINNT/afsd/afslogon.h:1.5.2.1
*** openafs/src/WINNT/afsd/afslogon.h:1.5	Wed Aug  4 15:30:03 2004
--- openafs/src/WINNT/afsd/afslogon.h	Sun Jan 30 23:05:01 2005
***************
*** 41,47 ****
  #define REG_CLIENT_TRACE_OPTION_PARM	"TraceOption"
  #define REG_CLIENT_LOGON_OPTION_PARM	"LogonOptions"
  #define REG_CLIENT_LOGON_SCRIPT_PARMW	L"LogonScript"
! #define DEFAULT_RETRY_INTERVAL          30                        /* seconds*/
  #define DEFAULT_FAIL_SILENTLY           FALSE
  #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
  #define DEFAULT_LOGON_OPTION			1
--- 41,47 ----
  #define REG_CLIENT_TRACE_OPTION_PARM	"TraceOption"
  #define REG_CLIENT_LOGON_OPTION_PARM	"LogonOptions"
  #define REG_CLIENT_LOGON_SCRIPT_PARMW	L"LogonScript"
! #define DEFAULT_RETRY_INTERVAL          60                        /* seconds*/
  #define DEFAULT_FAIL_SILENTLY           FALSE
  #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
  #define DEFAULT_LOGON_OPTION			1
Index: openafs/src/WINNT/afsd/cm_aclent.c
diff -c openafs/src/WINNT/afsd/cm_aclent.c:1.4 openafs/src/WINNT/afsd/cm_aclent.c:1.4.2.3
*** openafs/src/WINNT/afsd/cm_aclent.c:1.4	Sun Apr  4 22:16:11 2004
--- openafs/src/WINNT/afsd/cm_aclent.c	Sun Jan 30 23:24:44 2005
***************
*** 28,75 ****
   * An aclent structure is free if it has no back vnode pointer.
   */
  osi_rwlock_t cm_aclLock;		/* lock for system's aclents */
! cm_aclent_t *cm_aclLRUp;		/* LRUQ for dudes in vnodes' lists */
! cm_aclent_t *cm_aclLRUEndp;		/* ditto */
! 
  /* 
   * Get an acl cache entry for a particular user and file, or return that it doesn't exist.
   * Called with the scp locked.
   */
  long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, long *rightsp)
  {
! 	cm_aclent_t *aclp;
  
! 	lock_ObtainWrite(&cm_aclLock);
! 	for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) {
! 		if (aclp->userp == userp) {
! 			if (aclp->tgtLifetime && aclp->tgtLifetime <= (long) osi_Time()) {
! 				/* ticket expired */
! 				aclp->tgtLifetime = 0;
! 				*rightsp = 0;
! 				break; /* get a new acl from server */
! 			}
! 			else {
! 				*rightsp = aclp->randomAccess;
! 				if (cm_aclLRUEndp == aclp)
!                                 	cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q);
! 
! 				/* move to the head of the LRU queue */
! 				osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q);
!                                 osi_QAddH((osi_queue_t **) &cm_aclLRUp,
!                                 	(osi_queue_t **) &cm_aclLRUEndp,
!                                         &aclp->q);
! 			}
! 			lock_ReleaseWrite(&cm_aclLock);
! 			return 0;
! 		}
! 	}
! 
! 	/* 
! 	 * If we make it here, this entry isn't present, so we're going to fail. 
! 	 */
! 	lock_ReleaseWrite(&cm_aclLock);
! 	return -1;
! }
  
  
  /* 
--- 28,74 ----
   * An aclent structure is free if it has no back vnode pointer.
   */
  osi_rwlock_t cm_aclLock;		/* lock for system's aclents */
! cm_aclent_t *cm_aclLRUp;                /* LRUQ for dudes in vnode's lists */
! cm_aclent_t *cm_aclLRUEndp;             /* ditto */
  /* 
   * Get an acl cache entry for a particular user and file, or return that it doesn't exist.
   * Called with the scp locked.
   */
  long cm_FindACLCache(cm_scache_t *scp, cm_user_t *userp, long *rightsp)
  {
!     cm_aclent_t *aclp;
!     long retval = -1;
  
!     lock_ObtainWrite(&cm_aclLock);
!     for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) {
!         if (aclp->userp == userp) {
!             if (aclp->tgtLifetime && aclp->tgtLifetime <= (long) osi_Time()) {
!                 /* ticket expired */
!                 aclp->tgtLifetime = 0;
!                 *rightsp = 0;   /* get a new acl from server */
! 
!                 /* Shouldn't we remove this entry from the scp?
!                  * 2005-01-25 - jaltman@secure-endpoints.com
!                  */
!             } else {
!                 *rightsp = aclp->randomAccess;
!                 if (cm_aclLRUEndp == aclp)
!                     cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q);
! 
!                 /* move to the head of the LRU queue */
!                 osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q);
!                 osi_QAddH((osi_queue_t **) &cm_aclLRUp,
!                            (osi_queue_t **) &cm_aclLRUEndp,
!                            &aclp->q);
!                 retval = 0;     /* success */
!             }               
!             break;
!         }
!     }
! 
!     lock_ReleaseWrite(&cm_aclLock);
!     return retval;
! }       
  
  
  /* 
***************
*** 78,115 ****
   */
  static cm_aclent_t *GetFreeACLEnt(void)
  {
! 	cm_aclent_t *aclp;
!         cm_aclent_t *taclp;
!         cm_aclent_t **laclpp;
! 
! 	if (cm_aclLRUp == NULL)
! 		osi_panic("empty aclent LRU", __FILE__, __LINE__);
! 
! 	aclp = cm_aclLRUEndp;
! 	if (aclp == cm_aclLRUEndp)
!         	cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q);
! 	osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q);
! 	if (aclp->backp) {
! 		/* 
! 		 * Remove the entry from the vnode's list 
! 		 */
! 		laclpp = &aclp->backp->randomACLp;
! 		for (taclp = *laclpp; taclp; laclpp = &taclp->nextp, taclp = *laclpp) {
! 			if (taclp == aclp) 
! 				break;
! 		}
! 		if (!taclp) 
! 			osi_panic("GetFreeACLEnt race", __FILE__, __LINE__);
! 		*laclpp = aclp->nextp;			/* remove from vnode list */
! 		aclp->backp = NULL;
! 	}
! 	
      /* release the old user */
      if (aclp->userp) {
! 		cm_ReleaseUser(aclp->userp);
          aclp->userp = NULL;
! 	}
! 	return aclp;
  }
  
  
--- 77,114 ----
   */
  static cm_aclent_t *GetFreeACLEnt(void)
  {
!     cm_aclent_t *aclp;
!     cm_aclent_t *taclp;
!     cm_aclent_t **laclpp;
! 
!     if (cm_aclLRUp == NULL)
!         osi_panic("empty aclent LRU", __FILE__, __LINE__);
! 
!     aclp = cm_aclLRUEndp;
!     if (aclp == cm_aclLRUEndp)
!         cm_aclLRUEndp = (cm_aclent_t *) osi_QPrev(&aclp->q);
!     osi_QRemove((osi_queue_t **) &cm_aclLRUp, &aclp->q);
!     if (aclp->backp) {
!         /* 
!          * Remove the entry from the vnode's list 
!          */
!         laclpp = &aclp->backp->randomACLp;
!         for (taclp = *laclpp; taclp; laclpp = &taclp->nextp, taclp = *laclpp) {
!             if (taclp == aclp) 
!                 break;
!         }
!         if (!taclp) 
!             osi_panic("GetFreeACLEnt race", __FILE__, __LINE__);
!         *laclpp = aclp->nextp;			/* remove from vnode list */
!         aclp->backp = NULL;
!     }
! 
      /* release the old user */
      if (aclp->userp) {
!         cm_ReleaseUser(aclp->userp);
          aclp->userp = NULL;
!     }
!     return aclp;
  }
  
  
***************
*** 121,156 ****
   */
  long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights)
  {
! 	register struct cm_aclent *aclp;
  
! 	lock_ObtainWrite(&cm_aclLock);
! 	for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) {
! 		if (aclp->userp == userp) {
! 			aclp->randomAccess = rights;
! 			if (aclp->tgtLifetime == 0) 
! 				aclp->tgtLifetime = cm_TGTLifeTime(pag);
! 			lock_ReleaseWrite(&cm_aclLock);
! 			return 0;
! 		}
! 	}
! 
! 	/* 
! 	 * Didn't find the dude we're looking for, so take someone from the LRUQ 
! 	 * and  reuse. But first try the free list and see if there's already 
! 	 * someone there.
! 	 */
! 	aclp = GetFreeACLEnt();		 /* can't fail, panics instead */
! 	osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q);
! 	aclp->backp = scp;
! 	aclp->nextp = scp->randomACLp;
! 	scp->randomACLp = aclp;
      cm_HoldUser(userp);
! 	aclp->userp = userp;
! 	aclp->randomAccess = rights;
! 	aclp->tgtLifetime = cm_TGTLifeTime(userp);
! 	lock_ReleaseWrite(&cm_aclLock);
  
! 	return 0;
  }
  
  /* 
--- 120,155 ----
   */
  long cm_AddACLCache(cm_scache_t *scp, cm_user_t *userp, long rights)
  {
!     register struct cm_aclent *aclp;
  
!     lock_ObtainWrite(&cm_aclLock);
!     for (aclp = scp->randomACLp; aclp; aclp = aclp->nextp) {
!         if (aclp->userp == userp) {
!             aclp->randomAccess = rights;
!             if (aclp->tgtLifetime == 0) 
!                 aclp->tgtLifetime = cm_TGTLifeTime(pag);
!             lock_ReleaseWrite(&cm_aclLock);
!             return 0;
!         }
!     }
! 
!     /* 
!      * Didn't find the dude we're looking for, so take someone from the LRUQ 
!      * and  reuse. But first try the free list and see if there's already 
!      * someone there.
!      */
!     aclp = GetFreeACLEnt();		 /* can't fail, panics instead */
!     osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q);
!     aclp->backp = scp;
!     aclp->nextp = scp->randomACLp;
!     scp->randomACLp = aclp;
      cm_HoldUser(userp);
!     aclp->userp = userp;
!     aclp->randomAccess = rights;
!     aclp->tgtLifetime = cm_TGTLifeTime(userp);
!     lock_ReleaseWrite(&cm_aclLock);
  
!     return 0;
  }
  
  /* 
***************
*** 158,189 ****
   */
  long cm_InitACLCache(long size)
  {
! 	cm_aclent_t *aclp;
! 	long i;
! 	static osi_once_t once;
! 
! 	
! 	if (osi_Once(&once)) {
! 		lock_InitializeRWLock(&cm_aclLock, "cm_aclLock");
! 		osi_EndOnce(&once);
! 	}
! 
! 	lock_ObtainWrite(&cm_aclLock);
! 	cm_aclLRUp = cm_aclLRUEndp = NULL;
! 	aclp = (cm_aclent_t *) malloc(size * sizeof(cm_aclent_t));
! 	memset(aclp, 0, size * sizeof(cm_aclent_t));
! 
! 	/* 
! 	 * Put all of these guys on the LRU queue 
! 	 */
! 	for (i = 0; i < size; i++) {
! 		osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp,
!                 	&aclp->q);
! 		aclp++;
! 	}
! 
! 	lock_ReleaseWrite(&cm_aclLock);
! 	return 0;
  }
  
  
--- 157,185 ----
   */
  long cm_InitACLCache(long size)
  {
!     cm_aclent_t *aclp;
!     long i;
!     static osi_once_t once;
! 
!     if (osi_Once(&once)) {
!         lock_InitializeRWLock(&cm_aclLock, "cm_aclLock");
!         osi_EndOnce(&once);
!     }
! 
!     lock_ObtainWrite(&cm_aclLock);
!     cm_aclLRUp = cm_aclLRUEndp = NULL;
!     aclp = (cm_aclent_t *) malloc(size * sizeof(cm_aclent_t));
!     memset(aclp, 0, size * sizeof(cm_aclent_t));
! 
!     /* 
!      * Put all of these guys on the LRU queue 
!      */
!     for (i = 0; i < size; i++) {
!         osi_QAddH((osi_queue_t **) &cm_aclLRUp, (osi_queue_t **) &cm_aclLRUEndp, &aclp->q);
!         aclp++;
!     }
!     lock_ReleaseWrite(&cm_aclLock);
!     return 0;
  }
  
  
***************
*** 194,215 ****
   */
  void cm_FreeAllACLEnts(cm_scache_t *scp)
  {
! 	cm_aclent_t *aclp;
! 	cm_aclent_t *taclp;
  
! 	lock_ObtainWrite(&cm_aclLock);
! 	for (aclp = scp->randomACLp; aclp; aclp = taclp) {
! 		taclp = aclp->nextp;
! 		if (aclp->userp) {
! 			cm_ReleaseUser(aclp->userp);
! 			aclp->userp = NULL;
! 		}
! 		aclp->backp = (struct cm_scache *) 0;
! 	}
! 
! 	scp->randomACLp = (struct cm_aclent *) 0;
! 	scp->anyAccess = 0;		/* reset this, too */
! 	lock_ReleaseWrite(&cm_aclLock);
  }
  
  
--- 190,211 ----
   */
  void cm_FreeAllACLEnts(cm_scache_t *scp)
  {
!     cm_aclent_t *aclp;
!     cm_aclent_t *taclp;
  
!     lock_ObtainWrite(&cm_aclLock);
!     for (aclp = scp->randomACLp; aclp; aclp = taclp) {
!         taclp = aclp->nextp;
!         if (aclp->userp) {
!             cm_ReleaseUser(aclp->userp);
!             aclp->userp = NULL;
!         }
!         aclp->backp = (struct cm_scache *) 0;
!     }
! 
!     scp->randomACLp = (struct cm_aclent *) 0;
!     scp->anyAccess = 0;		/* reset this, too */
!     lock_ReleaseWrite(&cm_aclLock);
  }
  
  
***************
*** 220,238 ****
   */
  void cm_InvalidateACLUser(cm_scache_t *scp, cm_user_t *userp)
  {
! 	cm_aclent_t *aclp;
!         cm_aclent_t **laclpp;
  
! 	lock_ObtainWrite(&cm_aclLock);
! 	laclpp = &scp->randomACLp;
! 	for (aclp = *laclpp; aclp; laclpp = &aclp->nextp, aclp = *laclpp) {
! 		if (userp == aclp->userp) {	/* One for a given user/scache */
! 			*laclpp = aclp->nextp;
              cm_ReleaseUser(aclp->userp);
              aclp->userp = NULL;
! 			aclp->backp = (struct cm_scache *) 0;
! 			break;
! 		}
! 	}
! 	lock_ReleaseWrite(&cm_aclLock);
  }
--- 216,234 ----
   */
  void cm_InvalidateACLUser(cm_scache_t *scp, cm_user_t *userp)
  {
!     cm_aclent_t *aclp;
!     cm_aclent_t **laclpp;
  
!     lock_ObtainWrite(&cm_aclLock);
!     laclpp = &scp->randomACLp;
!     for (aclp = *laclpp; aclp; laclpp = &aclp->nextp, aclp = *laclpp) {
!         if (userp == aclp->userp) {	/* One for a given user/scache */
!             *laclpp = aclp->nextp;
              cm_ReleaseUser(aclp->userp);
              aclp->userp = NULL;
!             aclp->backp = (struct cm_scache *) 0;
!             break;
!         }
!     }
!     lock_ReleaseWrite(&cm_aclLock);
  }
Index: openafs/src/WINNT/afsd/cm_buf.c
diff -c openafs/src/WINNT/afsd/cm_buf.c:1.13.2.5 openafs/src/WINNT/afsd/cm_buf.c:1.13.2.7
*** openafs/src/WINNT/afsd/cm_buf.c:1.13.2.5	Tue Dec  7 01:01:41 2004
--- openafs/src/WINNT/afsd/cm_buf.c	Sun Jan 30 23:08:57 2005
***************
*** 86,91 ****
--- 86,94 ----
  static
  HANDLE CacheHandle;
  
+ static 
+ VOID * ViewOfFile;
+ 
  static
  SYSTEM_INFO sysInfo;
  #endif /* !DJGPP */
***************
*** 316,325 ****
--- 319,338 ----
                  afsi_log("Error creating cache file \"%s\" error %d", 
                            cm_CachePath, GetLastError());
                  return CM_ERROR_INVAL;
+             } else if (GetLastError() == ERROR_ALREADY_EXISTS) {
+                 BY_HANDLE_FILE_INFORMATION fileInfo;
+ 
+                 afsi_log("Cache File \"%s\" already exists", cm_CachePath);
+                 if ( GetFileInformationByHandle(hf, &fileInfo) )
+                     afsi_log("Existing File Size: %08X:%08X",
+                               fileInfo.nFileSizeHigh,
+                               fileInfo.nFileSizeLow);
              }
          } else { /* buf_cacheType == CM_BUF_CACHETYPE_VIRTUAL */
              hf = INVALID_HANDLE_VALUE;
          }
+         afsi_log("File Mapping Size: %08X", buf_nbuffers * buf_bufferSize);
+ 
          CacheHandle = hf;
          hm = CreateFileMapping(hf,
                                  NULL,
***************
*** 328,344 ****
                                  NULL);
          if (hm == NULL) {
              if (GetLastError() == ERROR_DISK_FULL) {
!                 afsi_log("Error creating cache file \"%s\" mapping: disk full",
!                           cm_CachePath);
                  return CM_ERROR_TOOMANYBUFS;
              }
              return CM_ERROR_INVAL;
          }
!         data = MapViewOfFile(hm,
!                               FILE_MAP_ALL_ACCESS,
!                               0, 0,   
!                               buf_nbuffers * buf_bufferSize);
!         if (data == NULL) {
              afsi_log("Error mapping view of file: 0x%X", GetLastError());
              if (hf != INVALID_HANDLE_VALUE)
                  CloseHandle(hf);
--- 341,356 ----
                                  NULL);
          if (hm == NULL) {
              if (GetLastError() == ERROR_DISK_FULL) {
!                 afsi_log("Error creating cache file mapping: disk full");
                  return CM_ERROR_TOOMANYBUFS;
              }
              return CM_ERROR_INVAL;
          }
!         ViewOfFile = MapViewOfFile(hm,
!                                    FILE_MAP_ALL_ACCESS,
!                                    0, 0,   
!                                    buf_nbuffers * buf_bufferSize);
!         if (ViewOfFile == NULL) {
              afsi_log("Error mapping view of file: 0x%X", GetLastError());
              if (hf != INVALID_HANDLE_VALUE)
                  CloseHandle(hf);
***************
*** 346,351 ****
--- 358,365 ----
              return CM_ERROR_INVAL;
          }
          CloseHandle(hm);
+ 
+         data = ViewOfFile;
  #else   
          /* djgpp doesn't support memory mapped files */
          data = malloc(buf_nbuffers * buf_bufferSize);
***************
*** 406,411 ****
--- 420,432 ----
      return 0;
  }
  
+ void
+ buf_Shutdown(void)
+ {
+     UnmapViewOfFile(ViewOfFile);
+     CloseHandle(CacheHandle);
+ }
+ 
  /* add nbuffers to the buffer pool, if possible.
   * Called with no locks held.
   */
Index: openafs/src/WINNT/afsd/cm_buf.h
diff -c openafs/src/WINNT/afsd/cm_buf.h:1.4.2.3 openafs/src/WINNT/afsd/cm_buf.h:1.4.2.4
*** openafs/src/WINNT/afsd/cm_buf.h:1.4.2.3	Fri Nov  5 14:21:43 2004
--- openafs/src/WINNT/afsd/cm_buf.h	Sun Jan 30 22:53:23 2005
***************
*** 142,147 ****
--- 142,149 ----
  
  extern long buf_Init(cm_buf_ops_t *);
  
+ extern void buf_Shutdown(void);
+ 
  extern long buf_CountFreeList(void);
  
  extern void buf_Release(cm_buf_t *);
Index: openafs/src/WINNT/afsd/cm_callback.c
diff -c openafs/src/WINNT/afsd/cm_callback.c:1.20.2.6 openafs/src/WINNT/afsd/cm_callback.c:1.20.2.7
*** openafs/src/WINNT/afsd/cm_callback.c:1.20.2.6	Tue Dec  7 00:58:20 2004
--- openafs/src/WINNT/afsd/cm_callback.c	Sun Jan 30 23:08:57 2005
***************
*** 775,787 ****
               */
              lock_ReleaseMutex(&scp->mx);
              cm_CallbackNotifyChange(scp);
              lock_ObtainMutex(&scp->mx);
          }
!         if (freeFlag) free(revp);
      }
  
      /* if we freed the list, zap the pointer to it */
!     if (freeFlag) cm_racingRevokesp = NULL;
  
      lock_ReleaseWrite(&cm_callbackLock);
  
--- 775,791 ----
               */
              lock_ReleaseMutex(&scp->mx);
              cm_CallbackNotifyChange(scp);
+             lock_ReleaseWrite(&cm_callbackLock);
              lock_ObtainMutex(&scp->mx);
+             lock_ObtainWrite(&cm_callbackLock);
          }
!         if (freeFlag) 
!             free(revp);
      }
  
      /* if we freed the list, zap the pointer to it */
!     if (freeFlag) 
!         cm_racingRevokesp = NULL;
  
      lock_ReleaseWrite(&cm_callbackLock);
  
Index: openafs/src/WINNT/afsd/cm_cell.c
diff -c openafs/src/WINNT/afsd/cm_cell.c:1.14.2.1 openafs/src/WINNT/afsd/cm_cell.c:1.14.2.3
*** openafs/src/WINNT/afsd/cm_cell.c:1.14.2.1	Tue Aug 17 13:16:02 2004
--- openafs/src/WINNT/afsd/cm_cell.c	Sun Jan 30 23:08:49 2005
***************
*** 95,106 ****
              memset(cp, 0, sizeof(cm_cell_t));
          } 
          else {
              dns_expired = 1;
!             /* must empty cp->vlServersp */
!             lock_ObtainWrite(&cp->mx);
!             cm_FreeServerList(&cp->vlServersp);
!             cp->vlServersp = NULL;
!             lock_ReleaseWrite(&cp->mx);
          }
  
          code = cm_SearchCellFile(namep, fullname, cm_AddCellProc, cp);
--- 95,119 ----
              memset(cp, 0, sizeof(cm_cell_t));
          } 
          else {
+             cm_cell_t **cpp;
+ 
              dns_expired = 1;
!             if (cp->vlServersp) {
!                 /* must empty cp->vlServersp */
!                 lock_ObtainMutex(&cp->mx);
!                 cm_FreeServerList(&cp->vlServersp);
!                 cp->vlServersp = NULL;
!                 lock_ReleaseMutex(&cp->mx);
!             }
!             /* remove the entry from the allCells list 
!              * we will re-insert it later 
!              */
!             for (cpp = &cm_allCellsp; *cpp; cpp=&(*cpp)->nextp) {
!                 if (*cpp == cp) {
!                     (*cpp) = cp->nextp;
!                     break;
!                 }
!             }
          }
  
          code = cm_SearchCellFile(namep, fullname, cm_AddCellProc, cp);
Index: openafs/src/WINNT/afsd/cm_conn.c
diff -c openafs/src/WINNT/afsd/cm_conn.c:1.25.2.4 openafs/src/WINNT/afsd/cm_conn.c:1.25.2.5
*** openafs/src/WINNT/afsd/cm_conn.c:1.25.2.4	Fri Nov  5 14:21:43 2004
--- openafs/src/WINNT/afsd/cm_conn.c	Sun Jan 30 23:08:57 2005
***************
*** 138,167 ****
   */
  int
  cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
! 	struct cm_fid *fidp, 
! 	AFSVolSync *volSyncp, 
! 	cm_serverRef_t * serversp,
! 	cm_callbackRequest_t *cbrp, long errorCode)
  {
      cm_server_t *serverp = 0;
      cm_serverRef_t **serverspp = 0;
! 	cm_serverRef_t *tsrp;
! 	cm_ucell_t *ucellp;
      int retry = 0;
      int free_svr_list = 0;
! 	int dead_session;
      long timeUsed, timeLeft;
          
! 	osi_Log2(afsd_logp, "cm_Analyze connp 0x%x, code %d",
! 		 (long) connp, errorCode);
  
! 	/* no locking required, since connp->serverp never changes after
! 	 * creation */
! 	dead_session = (userp->cellInfop == NULL);
! 	if (connp)
! 		serverp = connp->serverp;
  
! 	/* Update callback pointer */
      if (cbrp && serverp && errorCode == 0) {
          if (cbrp->serverp) {
              if ( cbrp->serverp != serverp ) {
--- 138,167 ----
   */
  int
  cm_Analyze(cm_conn_t *connp, cm_user_t *userp, cm_req_t *reqp,
!            struct cm_fid *fidp, 
!            AFSVolSync *volSyncp, 
!            cm_serverRef_t * serversp,
!            cm_callbackRequest_t *cbrp, long errorCode)
  {
      cm_server_t *serverp = 0;
      cm_serverRef_t **serverspp = 0;
!     cm_serverRef_t *tsrp;
!     cm_ucell_t *ucellp;
      int retry = 0;
      int free_svr_list = 0;
!     int dead_session;
      long timeUsed, timeLeft;
          
!     osi_Log2(afsd_logp, "cm_Analyze connp 0x%x, code %d",
!              (long) connp, errorCode);
  
!     /* no locking required, since connp->serverp never changes after
!      * creation */
!     dead_session = (userp->cellInfop == NULL);
!     if (connp)
!         serverp = connp->serverp;
  
!     /* Update callback pointer */
      if (cbrp && serverp && errorCode == 0) {
          if (cbrp->serverp) {
              if ( cbrp->serverp != serverp ) {
***************
*** 178,216 ****
          lock_ReleaseWrite(&cm_callbackLock);
      }
  
! 	/* If not allowed to retry, don't */
! 	if (reqp->flags & CM_REQ_NORETRY)
! 		goto out;
  
! 	/* if timeout - check that it did not exceed the SMB timeout
       * and retry */
      
! 	    /* timeleft - get if from reqp the same way as cmXonnByMServers does */
  #ifndef DJGPP
! 	    timeUsed = (GetCurrentTime() - reqp->startTime) / 1000;
  #else
! 	    gettimeofday(&now, NULL);
! 	    timeUsed = sub_time(now, reqp->startTime) / 1000;
  #endif
  	    
! 	    /* leave 5 seconds margin for sleep */
! 	    timeLeft = RDRtimeout - timeUsed;
  
      if (errorCode == CM_ERROR_TIMEDOUT && timeLeft > 5 ) {
!             thrd_Sleep(3000);
!             cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL);
!             retry = 1;
!         } 
  
      /* if all servers are offline, mark them non-busy and start over */
      if (errorCode == CM_ERROR_ALLOFFLINE && timeLeft > 7) {
! 	    osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE.");
! 	    thrd_Sleep(5000);
! 	    /* cm_ForceUpdateVolume marks all servers as non_busy */
! 		/* No it doesn't and it won't do anything if all of the 
! 		 * the servers are marked as DOWN.  So clear the DOWN
! 		 * flag and reset the busy state as well.
! 		 */
          if (!serversp) {
              cm_GetServerList(fidp, userp, reqp, &serverspp);
              serversp = *serverspp;
--- 178,216 ----
          lock_ReleaseWrite(&cm_callbackLock);
      }
  
!     /* If not allowed to retry, don't */
!     if (reqp->flags & CM_REQ_NORETRY)
!         goto out;
  
!     /* if timeout - check that it did not exceed the SMB timeout
       * and retry */
      
!     /* timeleft - get if from reqp the same way as cmXonnByMServers does */
  #ifndef DJGPP
!     timeUsed = (GetCurrentTime() - reqp->startTime) / 1000;
  #else
!     gettimeofday(&now, NULL);
!     timeUsed = sub_time(now, reqp->startTime) / 1000;
  #endif
  	    
!     /* leave 5 seconds margin for sleep */
!     timeLeft = RDRtimeout - timeUsed;
  
      if (errorCode == CM_ERROR_TIMEDOUT && timeLeft > 5 ) {
!         thrd_Sleep(3000);
!         cm_CheckServers(CM_FLAG_CHECKDOWNSERVERS, NULL);
!         retry = 1;
!     } 
  
      /* if all servers are offline, mark them non-busy and start over */
      if (errorCode == CM_ERROR_ALLOFFLINE && timeLeft > 7) {
!         osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE.");
!         thrd_Sleep(5000);
!         /* cm_ForceUpdateVolume marks all servers as non_busy */
!         /* No it doesn't and it won't do anything if all of the 
!          * the servers are marked as DOWN.  So clear the DOWN
!          * flag and reset the busy state as well.
!          */
          if (!serversp) {
              cm_GetServerList(fidp, userp, reqp, &serverspp);
              serversp = *serverspp;
***************
*** 233,239 ****
  
          if (fidp != NULL)   /* Not a VLDB call */
              cm_ForceUpdateVolume(fidp, userp, reqp);
! 	}
  
  	/* if all servers are busy, mark them non-busy and start over */
      if (errorCode == CM_ERROR_ALLBUSY && timeLeft > 7) {
--- 233,239 ----
  
          if (fidp != NULL)   /* Not a VLDB call */
              cm_ForceUpdateVolume(fidp, userp, reqp);
!     }
  
  	/* if all servers are busy, mark them non-busy and start over */
      if (errorCode == CM_ERROR_ALLBUSY && timeLeft > 7) {
***************
*** 258,384 ****
  
  	/* special codes:  VBUSY and VRESTARTING */
  	if (errorCode == VBUSY || errorCode == VRESTARTING) {
!         if (!serversp) {
!             cm_GetServerList(fidp, userp, reqp, &serverspp);
!             serversp = *serverspp;
!             free_svr_list = 1;
!         }
! 		lock_ObtainWrite(&cm_serverLock);
! 		for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
! 			if (tsrp->server == serverp
! 			    && tsrp->status == not_busy) {
! 				tsrp->status = busy;
! 				break;
! 			}
! 		}
!         lock_ReleaseWrite(&cm_serverLock);
!         if (free_svr_list) {
!             cm_FreeServerList(&serversp);
!             *serverspp = serversp;
!         }
! 		retry = 1;
  	}
  
  	/* special codes:  missing volumes */
  	if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE
! 	    || errorCode == VSALVAGE || errorCode == VNOSERVICE) {
! 		/* Log server being offline for this volume */
! 		osi_Log4(afsd_logp, "cm_Analyze found server %d.%d.%d.%d marked offline for a volume",
! 			 ((serverp->addr.sin_addr.s_addr & 0xff)),
! 			 ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
! 			 ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
! 			 ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
! 		/* Create Event Log message */ 
! 		{
! 		    HANDLE h;
! 		    char *ptbuf[1];
! 		    char s[100];
! 		    h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
! 		    sprintf(s, "cm_Analyze: Server %d.%d.%d.%d reported volume %d as missing.",
! 			    ((serverp->addr.sin_addr.s_addr & 0xff)),
! 			    ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
! 			    ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
! 			    ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24),
! 			    fidp->volume);
! 		    ptbuf[0] = s;
! 		    ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL,
! 				1, 0, ptbuf, NULL);
! 		    DeregisterEventSource(h);
! 		}
  
! 		/* Mark server offline for this volume */
!         if (!serversp) {
!             cm_GetServerList(fidp, userp, reqp, &serverspp);
!             serversp = *serverspp;
!             free_svr_list = 1;
!         }
! 		for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
! 			if (tsrp->server == serverp)
! 				tsrp->status = offline;
! 		}
!         if (free_svr_list) {
!             cm_FreeServerList(&serversp);
!             *serverspp = serversp;
!         }
!         if ( timeLeft > 2 )
  		retry = 1;
  	}
  
  	/* RX codes */
  	if (errorCode == RX_CALL_TIMEOUT) {
! 		/* server took longer than hardDeadTime 
! 		 * don't mark server as down but don't retry
! 		 * this is to prevent the SMB session from timing out
! 		 * In addition, we log an event to the event log 
! 		 */
  #ifndef DJGPP
! 		HANDLE h;
!                 char *ptbuf[1];
!                 char s[100];
!                 h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
!                 sprintf(s, "cm_Analyze: HardDeadTime exceeded.");
!                 ptbuf[0] = s;
!                 ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL,
!                         1, 0, ptbuf, NULL);
!                 DeregisterEventSource(h);
  #endif /* !DJGPP */
  	  
! 		retry = 0;
! 	  	osi_Log0(afsd_logp, "cm_Analyze: hardDeadTime exceeded");
  	}
  	else if (errorCode >= -64 && errorCode < 0) {
! 		/* mark server as down */
! 		lock_ObtainMutex(&serverp->mx);
!         serverp->flags |= CM_SERVERFLAG_DOWN;
! 		lock_ReleaseMutex(&serverp->mx);
              if ( timeLeft > 2 )
!         retry = 1;
!     }
  
! 	if (errorCode == RXKADEXPIRED && !dead_session) {
! 		lock_ObtainMutex(&userp->mx);
! 		ucellp = cm_GetUCell(userp, serverp->cellp);
! 		if (ucellp->ticketp) {
! 			free(ucellp->ticketp);
! 			ucellp->ticketp = NULL;
! 		}
! 		ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
! 		ucellp->gen++;
! 		lock_ReleaseMutex(&userp->mx);
!             if ( timeLeft > 2 )
! 		retry = 1;
! 	}
  
! 	if (retry && dead_session)
! 		retry = 0;
!  
! out:
! 	/* drop this on the way out */
! 	if (connp)
! 		cm_PutConn(connp);
  
! 	/* retry until we fail to find a connection */
!         return retry;
  }
  
  long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
--- 258,385 ----
  
  	/* special codes:  VBUSY and VRESTARTING */
  	if (errorCode == VBUSY || errorCode == VRESTARTING) {
!             if (!serversp) {
!                 cm_GetServerList(fidp, userp, reqp, &serverspp);
!                 serversp = *serverspp;
!                 free_svr_list = 1;
!             }
!             lock_ObtainWrite(&cm_serverLock);
!             for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
!                 if (tsrp->server == serverp
!                      && tsrp->status == not_busy) {
!                     tsrp->status = busy;
!                     break;
!                 }
!             }
!             lock_ReleaseWrite(&cm_serverLock);
!             if (free_svr_list) {
!                 cm_FreeServerList(&serversp);
!                 *serverspp = serversp;
!             }
!             retry = 1;
  	}
  
  	/* special codes:  missing volumes */
  	if (errorCode == VNOVOL || errorCode == VMOVED || errorCode == VOFFLINE
! 	    || errorCode == VSALVAGE || errorCode == VNOSERVICE) 
!         {
!             /* Log server being offline for this volume */
!             osi_Log4(afsd_logp, "cm_Analyze found server %d.%d.%d.%d marked offline for a volume",
!                       ((serverp->addr.sin_addr.s_addr & 0xff)),
!                       ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
!                       ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
!                       ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24));
!             /* Create Event Log message */ 
!             {
!                 HANDLE h;
!                 char *ptbuf[1];
!                 char s[100];
!                 h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
!                 sprintf(s, "cm_Analyze: Server %d.%d.%d.%d reported volume %d as missing.",
!                          ((serverp->addr.sin_addr.s_addr & 0xff)),
!                          ((serverp->addr.sin_addr.s_addr & 0xff00)>> 8),
!                          ((serverp->addr.sin_addr.s_addr & 0xff0000)>> 16),
!                          ((serverp->addr.sin_addr.s_addr & 0xff000000)>> 24),
!                          fidp->volume);
!                 ptbuf[0] = s;
!                 ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL,
!                              1, 0, ptbuf, NULL);
!                 DeregisterEventSource(h);
!             }
  
!             /* Mark server offline for this volume */
!             if (!serversp) {
!                 cm_GetServerList(fidp, userp, reqp, &serverspp);
!                 serversp = *serverspp;
!                 free_svr_list = 1;
!             }
!             for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
!                 if (tsrp->server == serverp)
!                     tsrp->status = offline;
!             }
!             if (free_svr_list) {
!                 cm_FreeServerList(&serversp);
!                 *serverspp = serversp;
!             }
!             if ( timeLeft > 2 )
  		retry = 1;
  	}
  
  	/* RX codes */
  	if (errorCode == RX_CALL_TIMEOUT) {
!             /* server took longer than hardDeadTime 
!              * don't mark server as down but don't retry
!              * this is to prevent the SMB session from timing out
!              * In addition, we log an event to the event log 
!              */
  #ifndef DJGPP
!             HANDLE h;
!             char *ptbuf[1];
!             char s[100];
!             h = RegisterEventSource(NULL, AFS_DAEMON_EVENT_NAME);
!             sprintf(s, "cm_Analyze: HardDeadTime exceeded.");
!             ptbuf[0] = s;
!             ReportEvent(h, EVENTLOG_WARNING_TYPE, 0, 1009, NULL,
!                          1, 0, ptbuf, NULL);
!             DeregisterEventSource(h);
  #endif /* !DJGPP */
  	  
!             retry = 0;
!             osi_Log0(afsd_logp, "cm_Analyze: hardDeadTime exceeded");
  	}
  	else if (errorCode >= -64 && errorCode < 0) {
!             /* mark server as down */
!             lock_ObtainMutex(&serverp->mx);
!             serverp->flags |= CM_SERVERFLAG_DOWN;
!             lock_ReleaseMutex(&serverp->mx);
              if ( timeLeft > 2 )
!                 retry = 1;
!         }
  
!     if (errorCode == RXKADEXPIRED && !dead_session) {
!         lock_ObtainMutex(&userp->mx);
!         ucellp = cm_GetUCell(userp, serverp->cellp);
!         if (ucellp->ticketp) {
!             free(ucellp->ticketp);
!             ucellp->ticketp = NULL;
!         }
!         ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
!         ucellp->gen++;
!         lock_ReleaseMutex(&userp->mx);
!         if ( timeLeft > 2 )
!             retry = 1;
!     }       
! 
!     if (retry && dead_session)
!         retry = 0;
  
!   out:
!     /* drop this on the way out */
!     if (connp)
!         cm_PutConn(connp);
  
!     /* retry until we fail to find a connection */
!     return retry;
  }
  
  long cm_ConnByMServers(cm_serverRef_t *serversp, cm_user_t *usersp,
Index: openafs/src/WINNT/afsd/cm_dcache.c
diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.3 openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.5
*** openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.3	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_dcache.c	Sun Jan 30 23:09:28 2005
***************
*** 1191,1198 ****
          afsStatus.ParentVnode = 0x1;
          afsStatus.ParentUnique = 0x1;
          afsStatus.ResidencyMask = 0;
!         afsStatus.ClientModTime = FakeFreelanceModTime;
!         afsStatus.ServerModTime = FakeFreelanceModTime;
          afsStatus.Group = 0;
          afsStatus.SyncCounter = 0;
          afsStatus.dataVersionHigh = 0;
--- 1191,1198 ----
          afsStatus.ParentVnode = 0x1;
          afsStatus.ParentUnique = 0x1;
          afsStatus.ResidencyMask = 0;
!         afsStatus.ClientModTime = (afs_uint32)FakeFreelanceModTime;
!         afsStatus.ServerModTime = (afs_uint32)FakeFreelanceModTime;
          afsStatus.Group = 0;
          afsStatus.SyncCounter = 0;
          afsStatus.dataVersionHigh = 0;
Index: openafs/src/WINNT/afsd/cm_freelance.c
diff -c openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.10 openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.11
*** openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.10	Tue Dec  7 01:14:52 2004
--- openafs/src/WINNT/afsd/cm_freelance.c	Thu Dec 16 14:02:48 2004
***************
*** 477,484 ****
              rootCellName[0] = '.';
              code = cm_GetRootCellName(&rootCellName[1]);
              if (code == 0) {
!                 cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell", 0, NULL);
!                 cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell", 1, NULL);
                  dwMountPoints = 2;
              }
          }
--- 477,484 ----
              rootCellName[0] = '.';
              code = cm_GetRootCellName(&rootCellName[1]);
              if (code == 0) {
!                 cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL);
!                 cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL);
                  dwMountPoints = 2;
              }
          }
***************
*** 660,667 ****
          rootCellName[0] = '.';
        	code = cm_GetRootCellName(&rootCellName[1]);
          if (code == 0) {
!             cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell", 0, NULL);
!             cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell", 1, NULL);
          }
          return 0;
      }
--- 660,667 ----
          rootCellName[0] = '.';
        	code = cm_GetRootCellName(&rootCellName[1]);
          if (code == 0) {
!             cm_FreelanceAddMount(&rootCellName[1], &rootCellName[1], "root.cell.", 0, NULL);
!             cm_FreelanceAddMount(rootCellName, &rootCellName[1], "root.cell.", 1, NULL);
          }
          return 0;
      }
Index: openafs/src/WINNT/afsd/cm_ioctl.c
diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.7 openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.9
*** openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.7	Tue Dec  7 00:58:20 2004
--- openafs/src/WINNT/afsd/cm_ioctl.c	Sun Jan 30 23:17:43 2005
***************
*** 1164,1180 ****
  
  long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
  {
!     /* if we don't know our default cell, return failure */
!     if (cm_rootCellp == NULL) {
!         return CM_ERROR_NOSUCHCELL;
!     }
  
!     /* return the default cellname to the caller */
!     StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep);
!     ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  
!     /* done: success */
!     return 0;
  }
  
  long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp)
--- 1164,1184 ----
  
  long cm_IoctlGetWsCell(smb_ioctl_t *ioctlp, cm_user_t *userp)
  {
! 	long code = 0;
  
! 	if (cm_freelanceEnabled) {
! 	    StringCbCopyA(ioctlp->outDatap, 999999, "Freelance.Local.Root");
! 		ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
! 	} else if (cm_rootCellp) {
! 	    /* return the default cellname to the caller */
! 	    StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep);
! 	    ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
! 	} else {
! 	    /* if we don't know our default cell, return failure */
! 		code = CM_ERROR_NOSUCHCELL;
!     }
  
!     return code;
  }
  
  long cm_IoctlSysName(struct smb_ioctl *ioctlp, struct cm_user *userp)
***************
*** 1561,1569 ****
      return code;
  }
  
- extern long cm_AssembleLink(cm_scache_t *linkScp, char *pathSuffixp,
-                             cm_scache_t **newRootScpp, cm_space_t **newSpaceBufferp,
-                             cm_user_t *userp, cm_req_t *reqp);
  
  long cm_IoctlListlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
  {
--- 1565,1570 ----
***************
*** 1607,1612 ****
--- 1608,1614 ----
          cm_FreeSpace(spacep);
          if (newRootScp != NULL)
              cm_ReleaseSCache(newRootScp);
+         code = 0;
      }       
  
      return code;
***************
*** 1936,1942 ****
  
      /* cell name is right here */
      cellp = cm_GetCell(tp, 0);
!     if (!cellp) return CM_ERROR_NOSUCHCELL;
      tp += strlen(tp) + 1;
  
  #ifndef DJGPP
--- 1938,1945 ----
  
      /* cell name is right here */
      cellp = cm_GetCell(tp, 0);
!     if (!cellp) 
!         return CM_ERROR_NOSUCHCELL;
      tp += strlen(tp) + 1;
  
  #ifndef DJGPP
Index: openafs/src/WINNT/afsd/cm_rpc.c
diff -c openafs/src/WINNT/afsd/cm_rpc.c:1.6 openafs/src/WINNT/afsd/cm_rpc.c:1.6.2.1
*** openafs/src/WINNT/afsd/cm_rpc.c:1.6	Sun Dec  7 17:49:13 2003
--- openafs/src/WINNT/afsd/cm_rpc.c	Sun Jan 30 23:05:01 2005
***************
*** 40,54 ****
  extern void afsi_log(char *pattern, ...);
  
  typedef struct tokenEvent {
! 	afs_uuid_t uuid;
! 	char sessionKey[8];
! 	struct tokenEvent *next;
  } tokenEvent_t;
  
  tokenEvent_t *tokenEvents = NULL;
  
  osi_mutex_t tokenEventLock;
  
  /*
   * Add a new uuid and session key to the list.
   */
--- 40,56 ----
  extern void afsi_log(char *pattern, ...);
  
  typedef struct tokenEvent {
!     afs_uuid_t uuid;
!     char sessionKey[8];
!     struct tokenEvent *next;
  } tokenEvent_t;
  
  tokenEvent_t *tokenEvents = NULL;
  
  osi_mutex_t tokenEventLock;
  
+ EVENT_HANDLE rpc_ShutdownEvent = NULL;
+ 
  /*
   * Add a new uuid and session key to the list.
   */
***************
*** 56,68 ****
  	afs_uuid_t uuid,
  	char sessionKey[8])
  {
! 	tokenEvent_t *te = malloc(sizeof(tokenEvent_t));
! 	te->uuid = uuid;
! 	memcpy(te->sessionKey, sessionKey, sizeof(te->sessionKey));
! 	lock_ObtainMutex(&tokenEventLock);
! 	te->next = tokenEvents;
! 	tokenEvents = te;
! 	lock_ReleaseMutex(&tokenEventLock);
  }
  
  /*
--- 58,70 ----
  	afs_uuid_t uuid,
  	char sessionKey[8])
  {
!     tokenEvent_t *te = malloc(sizeof(tokenEvent_t));
!     te->uuid = uuid;
!     memcpy(te->sessionKey, sessionKey, sizeof(te->sessionKey));
!     lock_ObtainMutex(&tokenEventLock);
!     te->next = tokenEvents;
!     tokenEvents = te;
!     lock_ReleaseMutex(&tokenEventLock);
  }
  
  /*
***************
*** 73,99 ****
   */
  BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8])
  {
! 	RPC_STATUS status;
! 	tokenEvent_t *te;
! 	tokenEvent_t **ltep;
! 
! 	lock_ObtainMutex(&tokenEventLock);
! 	te = tokenEvents;
! 	ltep = &tokenEvents;
! 	while (te) {
! 	    if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) {
! 			*ltep = te->next;
! 			lock_ReleaseMutex(&tokenEventLock);
! 			memcpy(sessionKey, te->sessionKey,
! 				sizeof(te->sessionKey));
! 			free(te);
! 			return TRUE;
! 	    }
! 	    ltep = &te->next;
! 	    te = te->next;
! 	}
! 	lock_ReleaseMutex(&tokenEventLock);
! 	return FALSE;
  }
  
  /*
--- 75,101 ----
   */
  BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8])
  {
!     RPC_STATUS status;
!     tokenEvent_t *te;
!     tokenEvent_t **ltep;
! 
!     lock_ObtainMutex(&tokenEventLock);
!     te = tokenEvents;
!     ltep = &tokenEvents;
!     while (te) {
!         if (UuidEqual((UUID *)&uuid, (UUID *)&te->uuid, &status)) {
!             *ltep = te->next;
!             lock_ReleaseMutex(&tokenEventLock);
!             memcpy(sessionKey, te->sessionKey,
!                     sizeof(te->sessionKey));
!             free(te);
!             return TRUE;
!         }
!         ltep = &te->next;
!         te = te->next;
!     }
!     lock_ReleaseMutex(&tokenEventLock);
!     return FALSE;
  }
  
  /*
***************
*** 104,220 ****
  	afs_uuid_t uuid,
  	unsigned char __RPC_FAR sessionKey[8])
  {
! 	cm_RegisterNewTokenEvent(uuid, sessionKey);
! 	return 0;
  }
  
  long AFSRPC_GetToken(
  	afs_uuid_t uuid,
  	unsigned char __RPC_FAR sessionKey[8])
  {
! 	BOOL found;
  
! 	found = cm_FindTokenEvent(uuid, sessionKey);
! 	if (!found)
! 		return 1;
  
! 	return 0;
  }
  
  void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes)
  {
! 	return ((void __RPC_FAR *) malloc(cBytes));
  }
  
  void __RPC_USER midl_user_free(void __RPC_FAR * p)
  {
! 	free(p);
  } 
  
  void RpcListen()
  {
! 	RPC_STATUS		status;
! 	char			*task;
! 	RPC_BINDING_VECTOR	*ptrBindingVector = NULL;
! 	BOOLEAN			ifaceRegistered = FALSE;
! 	BOOLEAN			epRegistered = FALSE;
  
  #ifdef	NOOSIDEBUGSERVER	/* Use All Protseqs already done in OSI */
  
! 	status = RpcServerUseAllProtseqs(1, NULL);
! 	if (status != RPC_S_OK) {
! 		task = "Use All Protocol Sequences";
! 		goto cleanup;
! 	}
  
  #endif	/* NOOSIDEBUGSERVER */
  
! 	status = RpcServerRegisterIf(afsrpc_v1_0_s_ifspec, NULL, NULL);
! 	if (status != RPC_S_OK) {
! 		task = "Register Interface";
! 		goto cleanup;
! 	}
! 	ifaceRegistered = TRUE;
! 
! 	status = RpcServerInqBindings(&ptrBindingVector);
! 	if (status != RPC_S_OK) {
! 		task = "Inquire Bindings";
! 		goto cleanup;
! 	}
! 
! 	status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
! 	if (status != RPC_S_OK) {
! 		task = "Register Authentication Info";
! 		goto cleanup;
! 	}
! 
! 	status = RpcEpRegister(afsrpc_v1_0_s_ifspec, ptrBindingVector,
! 				NULL, "AFS session key interface");
! 	if (status != RPC_S_OK) {
! 		task = "Register Endpoints";
! 		goto cleanup;
! 	}
! 	epRegistered = TRUE;
! 
! 	afsi_log("RPC server listening");
! 
! 	status = RpcServerListen(OSI_MAXRPCCALLS, OSI_MAXRPCCALLS, 0);
! 	if (status != RPC_S_OK) {
! 		task = "Server Listen";
! 	}
  
  cleanup:
! 	if (epRegistered)
! 		(void) RpcEpUnregister(afsrpc_v1_0_s_ifspec, ptrBindingVector,
! 					NULL);
! 
! 	if (ptrBindingVector)
! 		(void) RpcBindingVectorFree(&ptrBindingVector);
! 
! 	if (ifaceRegistered)
! 		(void) RpcServerUnregisterIf(afsrpc_v1_0_s_ifspec, NULL, FALSE);
! 
! 	if (status != RPC_S_OK)
! 		afsi_log("RPC problem, code %d for %s", status, task);
! 
! 	return;
  }
  
  long RpcInit()
  {
! 	LONG status = ERROR_SUCCESS;
! 	HANDLE listenThread;
! 	ULONG listenThreadID = 0;
  
! 	lock_InitializeMutex(&tokenEventLock, "token event lock");
  
! 	listenThread = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)RpcListen,
! 				    0, 0, &listenThreadID);
  
! 	if (listenThread == NULL) {
! 		status = GetLastError();
! 	}
! 	CloseHandle(listenThread);
  
! 	return status;
  }
--- 106,242 ----
  	afs_uuid_t uuid,
  	unsigned char __RPC_FAR sessionKey[8])
  {
!     cm_RegisterNewTokenEvent(uuid, sessionKey);
!     return 0;
  }
  
  long AFSRPC_GetToken(
  	afs_uuid_t uuid,
  	unsigned char __RPC_FAR sessionKey[8])
  {
!     BOOL found;
  
!     found = cm_FindTokenEvent(uuid, sessionKey);
!     if (!found)
!         return 1;
  
!     return 0;
  }
  
  void __RPC_FAR * __RPC_USER midl_user_allocate (size_t cBytes)
  {
!     return ((void __RPC_FAR *) malloc(cBytes));
  }
  
  void __RPC_USER midl_user_free(void __RPC_FAR * p)
  {
!     free(p);
  } 
  
  void RpcListen()
  {
!     RPC_STATUS		status;
!     char			*task;
!     RPC_BINDING_VECTOR	*ptrBindingVector = NULL;
!     BOOLEAN			ifaceRegistered = FALSE;
!     BOOLEAN			epRegistered = FALSE;
  
  #ifdef	NOOSIDEBUGSERVER	/* Use All Protseqs already done in OSI */
  
!     status = RpcServerUseAllProtseqs(1, NULL);
!     if (status != RPC_S_OK) {
!         task = "Use All Protocol Sequences";
!         goto cleanup;
!     }
  
  #endif	/* NOOSIDEBUGSERVER */
  
!     status = RpcServerRegisterIf(afsrpc_v1_0_s_ifspec, NULL, NULL);
!     if (status != RPC_S_OK) {
!         task = "Register Interface";
!         goto cleanup;
!     }
!     ifaceRegistered = TRUE;
! 
!     status = RpcServerInqBindings(&ptrBindingVector);
!     if (status != RPC_S_OK) {
!         task = "Inquire Bindings";
!         goto cleanup;
!     }
! 
!     status = RpcServerRegisterAuthInfo(NULL, RPC_C_AUTHN_WINNT, NULL, NULL);
!     if (status != RPC_S_OK) {
!         task = "Register Authentication Info";
!         goto cleanup;
!     }
! 
!     status = RpcEpRegister(afsrpc_v1_0_s_ifspec, ptrBindingVector,
!                             NULL, "AFS session key interface");
!     if (status != RPC_S_OK) {
!         task = "Register Endpoints";
!         goto cleanup;
!     }
!     epRegistered = TRUE;
! 
!     afsi_log("RPC server listening");
! 
!     status = RpcServerListen(OSI_MAXRPCCALLS, OSI_MAXRPCCALLS, 0);
!     if (status != RPC_S_OK) {
!         task = "Server Listen";
!     }
  
  cleanup:
!     if (epRegistered)
!         (void) RpcEpUnregister(afsrpc_v1_0_s_ifspec, ptrBindingVector,
!                                 NULL);
! 
!     if (ptrBindingVector)
!         (void) RpcBindingVectorFree(&ptrBindingVector);
! 
!     if (ifaceRegistered)
!         (void) RpcServerUnregisterIf(afsrpc_v1_0_s_ifspec, NULL, FALSE);
! 
!     if (status != RPC_S_OK)
!         afsi_log("RPC problem, code %d for %s", status, task);
!     else
!         afsi_log("RPC shutdown");
! 
!     if (rpc_ShutdownEvent != NULL)
!         thrd_SetEvent(rpc_ShutdownEvent);
!     return;
  }
  
  long RpcInit()
  {
!     LONG status = ERROR_SUCCESS;
!     HANDLE listenThread;
!     ULONG listenThreadID = 0;
!     char * name = "afsd_rpc_ShutdownEvent";
! 
!     lock_InitializeMutex(&tokenEventLock, "token event lock");
  
!     rpc_ShutdownEvent = thrd_CreateEvent(NULL, FALSE, FALSE, name);
!     if ( GetLastError() == ERROR_ALREADY_EXISTS )
!         afsi_log("Event Object Already Exists: %s", name);
  
!     listenThread = CreateThread(NULL, 0, (PTHREAD_START_ROUTINE)RpcListen,
!                                 0, 0, &listenThreadID);
  
!     if (listenThread == NULL) {
!         status = GetLastError();
!     }
!     CloseHandle(listenThread);
  
!     return status;
  }
+ 
+ void RpcShutdown(void)
+ {
+     RpcMgmtStopServerListening(NULL);
+ 
+     if (rpc_ShutdownEvent != NULL) {
+         thrd_WaitForSingleObject_Event(rpc_ShutdownEvent, INFINITE);
+         CloseHandle(rpc_ShutdownEvent);
+     }
+ }
+ 
Index: openafs/src/WINNT/afsd/cm_rpc.h
diff -c openafs/src/WINNT/afsd/cm_rpc.h:1.3 openafs/src/WINNT/afsd/cm_rpc.h:1.3.16.1
*** openafs/src/WINNT/afsd/cm_rpc.h:1.3	Mon Apr 30 02:48:05 2001
--- openafs/src/WINNT/afsd/cm_rpc.h	Sun Jan 30 23:05:01 2005
***************
*** 19,24 ****
  void cm_RegisterNewTokenEvent(afs_uuid_t uuid, char sessionKey[8]);
  BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]);
  
! extern long RpcInit();
! 
  #endif /* __CM_RPC_H__ */
--- 19,24 ----
  void cm_RegisterNewTokenEvent(afs_uuid_t uuid, char sessionKey[8]);
  BOOL cm_FindTokenEvent(afs_uuid_t uuid, char sessionKey[8]);
  
! extern long RpcInit(void);
! extern void RpcShutdown(void);
  #endif /* __CM_RPC_H__ */
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.14.2.3 openafs/src/WINNT/afsd/cm_scache.c:1.14.2.6
*** openafs/src/WINNT/afsd/cm_scache.c:1.14.2.3	Tue Dec  7 00:58:20 2004
--- openafs/src/WINNT/afsd/cm_scache.c	Sun Jan 30 23:09:28 2005
***************
*** 344,350 ****
          scp->parentUnique = 0x1;
          scp->parentVnode=0x1;
          scp->group=0;
!         scp->dataVersion=0x8;
          *outScpp = scp;
          lock_ReleaseWrite(&cm_scacheLock);
          /*afsi_log("   getscache done");*/
--- 344,350 ----
          scp->parentUnique = 0x1;
          scp->parentVnode=0x1;
          scp->group=0;
!         scp->dataVersion=cm_fakeDirVersion;
          *outScpp = scp;
          lock_ReleaseWrite(&cm_scacheLock);
          /*afsi_log("   getscache done");*/
***************
*** 853,860 ****
          statusp->ParentVnode = 0x1;
          statusp->ParentUnique = 0x1;
          statusp->ResidencyMask = 0;
!         statusp->ClientModTime = FakeFreelanceModTime;
!         statusp->ServerModTime = FakeFreelanceModTime;
          statusp->Group = 0;
          statusp->SyncCounter = 0;
          statusp->dataVersionHigh = 0;
--- 853,860 ----
          statusp->ParentVnode = 0x1;
          statusp->ParentUnique = 0x1;
          statusp->ResidencyMask = 0;
!         statusp->ClientModTime = (afs_uint32)FakeFreelanceModTime;
!         statusp->ServerModTime = (afs_uint32)FakeFreelanceModTime;
          statusp->Group = 0;
          statusp->SyncCounter = 0;
          statusp->dataVersionHigh = 0;
***************
*** 982,988 ****
  void cm_HoldSCacheNoLock(cm_scache_t *scp)
  {
  #ifdef NOLOCK_ASSERT
!     osi_assert(scp->refCount > 0);
  #endif
      scp->refCount++;
  }
--- 982,988 ----
  void cm_HoldSCacheNoLock(cm_scache_t *scp)
  {
  #ifdef NOLOCK_ASSERT
!     osi_assert(scp->refCount >= 0);
  #endif
      scp->refCount++;
  }
***************
*** 990,996 ****
  void cm_HoldSCache(cm_scache_t *scp)
  {
      lock_ObtainWrite(&cm_scacheLock);
!     osi_assert(scp->refCount > 0);
      scp->refCount++;
      lock_ReleaseWrite(&cm_scacheLock);
  }
--- 990,996 ----
  void cm_HoldSCache(cm_scache_t *scp)
  {
      lock_ObtainWrite(&cm_scacheLock);
!     osi_assert(scp->refCount >= 0);
      scp->refCount++;
      lock_ReleaseWrite(&cm_scacheLock);
  }
Index: openafs/src/WINNT/afsd/cm_vnodeops.c
diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.8 openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.9
*** openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.8	Mon Dec 13 09:13:08 2004
--- openafs/src/WINNT/afsd/cm_vnodeops.c	Sun Jan 30 23:23:45 2005
***************
*** 995,1002 ****
       * that we stopped early, probably because we found the entry we're
       * looking for.  Any other non-zero code is an error.
       */
!     if (code && code != CM_ERROR_STOPNOW) 
          return code;
  
      getroot = (dscp==cm_rootSCachep) ;
      if (!rock.found) {
--- 995,1013 ----
       * that we stopped early, probably because we found the entry we're
       * looking for.  Any other non-zero code is an error.
       */
!     if (code && code != CM_ERROR_STOPNOW) { 
!         /* if the cm_scache_t we are searching in is not a directory 
!          * we must return path not found because the error 
!          * is to describe the final component not an intermediary
!          */
!         if (code == CM_ERROR_NOTDIR) {
!             if (flags & CM_FLAG_CHECKPATH)
!                 return CM_ERROR_NOSUCHPATH;
!             else
!                 return CM_ERROR_NOSUCHFILE;
!         }
          return code;
+     }
  
      getroot = (dscp==cm_rootSCachep) ;
      if (!rock.found) {
Index: openafs/src/WINNT/afsd/fs.c
diff -c openafs/src/WINNT/afsd/fs.c:1.16.2.3 openafs/src/WINNT/afsd/fs.c:1.16.2.5
*** openafs/src/WINNT/afsd/fs.c:1.16.2.3	Mon Oct 18 00:09:27 2004
--- openafs/src/WINNT/afsd/fs.c	Sun Jan 30 23:09:42 2005
***************
*** 18,27 ****
--- 18,30 ----
  #include <time.h>
  #include <winsock2.h>
  #include <errno.h>
+ #include <assert.h>
  #include <rx/rx_globals.h>
  
  #include <osi.h>
  #include <afsint.h>
+ #include <afs/ptserver.h>
+ #include <afs/ptuser.h>
  
  #include "fs.h"
  #include "fs_utils.h"
***************
*** 31,40 ****
--- 34,46 ----
  
  #define	MAXHOSTS 13
  #define	OMAXHOSTS 8
+ #define MAXCELLHOSTS 8
  #define MAXNAME 100
  #define	MAXSIZE	2048
  #define MAXINSIZE 1300    /* pioctl complains if data is larger than this */
  #define VMSGSIZE 128      /* size of msg buf in volume hdr */
+ #define MAXCELLCHARS		64
+ #define MAXHOSTCHARS		64
  
  static char space[MAXSIZE];
  static char tspace[1024];
***************
*** 43,70 ****
  static struct ubik_client *uclient;
  #endif /* not WIN32 */
  
! static MemDumpCmd(struct cmd_syndesc *asp);
! static CSCPolicyCmd(struct cmd_syndesc *asp);
  
  extern afs_int32 VL_GetEntryByNameO();
  
  static char pn[] = "fs";
  static int rxInitDone = 0;
  
- static GetCellName();
- 
- #define MAXCELLCHARS		64
- #define MAXHOSTCHARS		64
- #define MAXHOSTSPERCELL		8
- 
  struct afsconf_cell {
! 	char name[MAXCELLCHARS];
!         short numServers;
!         short flags;
!         struct sockaddr_in hostAddr[MAXHOSTSPERCELL];
!         char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];
!         char *linkedCell;
! };
  
  
  /*
--- 49,78 ----
  static struct ubik_client *uclient;
  #endif /* not WIN32 */
  
! static int GetClientAddrsCmd(struct cmd_syndesc *asp, char *arock);
! static int SetClientAddrsCmd(struct cmd_syndesc *asp, char *arock);
! static int FlushMountCmd(struct cmd_syndesc *asp, char *arock);
! static int RxStatProcCmd(struct cmd_syndesc *asp, char *arock);
! static int RxStatPeerCmd(struct cmd_syndesc *asp, char *arock);
! 
! extern struct cmd_syndesc *cmd_CreateSyntax();
! 
! static int MemDumpCmd(struct cmd_syndesc *asp, char *arock);
! static int CSCPolicyCmd(struct cmd_syndesc *asp, char *arock);
  
  extern afs_int32 VL_GetEntryByNameO();
  
  static char pn[] = "fs";
  static int rxInitDone = 0;
  
  struct afsconf_cell {
!     char name[MAXCELLCHARS];
!     short numServers;
!     short flags;
!     struct sockaddr_in hostAddr[MAXCELLHOSTS];
!     char hostName[MAXCELLHOSTS][MAXHOSTCHARS];
!     char *linkedCell;
! };      
  
  
  /*
***************
*** 76,84 ****
  typedef char sec_rgy_name_t[1025];	/* A DCE definition */
  
  struct Acl {
!     int dfs;	/* Originally true if a dfs acl; now also the type
! 		   of the acl (1, 2, or 3, corresponding to object,
! 		   initial dir, or initial object). */
      sec_rgy_name_t cell; /* DFS cell name */
      int nplus;
      int nminus;
--- 84,92 ----
  typedef char sec_rgy_name_t[1025];	/* A DCE definition */
  
  struct Acl {
!     int dfs;	        /* Originally true if a dfs acl; now also the type
!                          * of the acl (1, 2, or 3, corresponding to object,
!                          * initial dir, or initial object). */
      sec_rgy_name_t cell; /* DFS cell name */
      int nplus;
      int nminus;
***************
*** 92,118 ****
      afs_int32 rights;
  };
  
! void ZapAcl (acl)
!     struct Acl *acl; {
      ZapList(acl->pluslist);
      ZapList(acl->minuslist);
      free(acl);
  }
  
- foldcmp (a, b)
-     register char *a;
-     register char *b; {
-     register char t, u;
-     while (1) {
-         t = *a++;
-         u = *b++;
-         if (t >= 'A' && t <= 'Z') t += 0x20;
-         if (u >= 'A' && u <= 'Z') u += 0x20;
-         if (t != u) return 1;
-         if (t == 0) return 0;
-     }
- }
- 
  /*
   * Mods for the AFS/DFS protocol translator.
   *
--- 100,116 ----
      afs_int32 rights;
  };
  
! static void 
! ZapAcl (struct Acl *acl)
! {
!     if (!acl)
!         return;
! 
      ZapList(acl->pluslist);
      ZapList(acl->minuslist);
      free(acl);
  }
  
  /*
   * Mods for the AFS/DFS protocol translator.
   *
***************
*** 144,158 ****
   * Offset of -id switch in command structure for various commands.
   * The -if switch is the next switch always.
   */
! int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
  
  /*
   * Determine whether either the -id or -if switches are present, and
   * return 0, 1 or 2, as appropriate. Abort if both switches are present.
   */
! int getidf(as, id)
!     struct cmd_syndesc *as;
!     int id;	/* Offset of -id switch; -if is next switch */
  {
      int idf = 0;
  
--- 142,156 ----
   * Offset of -id switch in command structure for various commands.
   * The -if switch is the next switch always.
   */
! static int parm_setacl_id, parm_copyacl_id, parm_listacl_id;
  
  /*
   * Determine whether either the -id or -if switches are present, and
   * return 0, 1 or 2, as appropriate. Abort if both switches are present.
   */
! /* int id; Offset of -id switch; -if is next switch */
! static int 
! getidf(struct cmd_syndesc *as, int id)
  {
      int idf = 0;
  
***************
*** 163,170 ****
  	idf |= 2;
      }
      if (idf == 3) {
! 	fprintf
! 	    (stderr,
  	     "%s: you may specify either -id or -if, but not both switches\n",
  	     pn);
  	exit(1);
--- 161,167 ----
  	idf |= 2;
      }
      if (idf == 3) {
! 	fprintf(stderr,
  	     "%s: you may specify either -id or -if, but not both switches\n",
  	     pn);
  	exit(1);
***************
*** 172,221 ****
      return idf;
  }
  
! void PRights (arights, dfs)
!     register afs_int32 arights;
!     int dfs;
  {
      if (!dfs) {
! 	if (arights & PRSFS_READ) printf("r");
! 	if (arights & PRSFS_LOOKUP) printf("l");
! 	if (arights & PRSFS_INSERT) printf("i");
! 	if (arights & PRSFS_DELETE) printf("d");
! 	if (arights & PRSFS_WRITE) printf("w");
! 	if (arights & PRSFS_LOCK) printf("k");
! 	if (arights & PRSFS_ADMINISTER) printf("a");
! 	if (arights & PRSFS_USR0) printf("A");
! 	if (arights & PRSFS_USR1) printf("B");
! 	if (arights & PRSFS_USR2) printf("C");
! 	if (arights & PRSFS_USR3) printf("D");
! 	if (arights & PRSFS_USR4) printf("E");
! 	if (arights & PRSFS_USR5) printf("F");
! 	if (arights & PRSFS_USR6) printf("G");
! 	if (arights & PRSFS_USR7) printf("H");
      } else {
! 	if (arights & DFS_READ) printf("r"); else printf("-");
! 	if (arights & DFS_WRITE) printf("w"); else printf("-");
! 	if (arights & DFS_EXECUTE) printf("x"); else printf("-");
! 	if (arights & DFS_CONTROL) printf("c"); else printf("-");
! 	if (arights & DFS_INSERT) printf("i"); else printf("-");
! 	if (arights & DFS_DELETE) printf("d"); else printf("-");
! 	if (arights & (DFS_USRALL)) printf("+");
! 	if (arights & DFS_USR0) printf("A");
! 	if (arights & DFS_USR1) printf("B");
! 	if (arights & DFS_USR2) printf("C");
! 	if (arights & DFS_USR3) printf("D");
! 	if (arights & DFS_USR4) printf("E");
! 	if (arights & DFS_USR5) printf("F");
! 	if (arights & DFS_USR6) printf("G");
! 	if (arights & DFS_USR7) printf("H");
      }	
  }
  
  /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
! static int InAFS(apath)
! register char *apath; {
      struct ViceIoctl blob;
!     register afs_int32 code;
  
      blob.in_size = 0;
      blob.out_size = MAXSIZE;
--- 169,261 ----
      return idf;
  }
  
! static int
! PRights(afs_int32 arights, int dfs)
  {
      if (!dfs) {
! 	if (arights & PRSFS_READ) 
!             printf("r");
! 	if (arights & PRSFS_LOOKUP) 
!             printf("l");
! 	if (arights & PRSFS_INSERT) 
!             printf("i");
! 	if (arights & PRSFS_DELETE) 
!             printf("d");
! 	if (arights & PRSFS_WRITE) 
!             printf("w");
! 	if (arights & PRSFS_LOCK) 
!             printf("k");
! 	if (arights & PRSFS_ADMINISTER) 
!             printf("a");
! 	if (arights & PRSFS_USR0) 
!             printf("A");
! 	if (arights & PRSFS_USR1) 
!             printf("B");
! 	if (arights & PRSFS_USR2) 
!             printf("C");
! 	if (arights & PRSFS_USR3) 
!             printf("D");
! 	if (arights & PRSFS_USR4) 
!             printf("E");
! 	if (arights & PRSFS_USR5) 
!             printf("F");
! 	if (arights & PRSFS_USR6) 
!             printf("G");
! 	if (arights & PRSFS_USR7) 
!             printf("H");
      } else {
! 	if (arights & DFS_READ) 
!             printf("r");
!         else 
!             printf("-");
! 	if (arights & DFS_WRITE) 
!             printf("w"); 
!         else 
!             printf("-");
! 	if (arights & DFS_EXECUTE) 
!             printf("x"); 
!         else 
!             printf("-");
! 	if (arights & DFS_CONTROL) 
!             printf("c"); 
!         else 
!             printf("-");
! 	if (arights & DFS_INSERT) 
!             printf("i"); 
!         else 
!             printf("-");
! 	if (arights & DFS_DELETE) 
!             printf("d"); 
!         else 
!             printf("-");
! 	if (arights & (DFS_USRALL)) 
!             printf("+");
! 	if (arights & DFS_USR0) 
!             printf("A");
! 	if (arights & DFS_USR1) 
!             printf("B");
! 	if (arights & DFS_USR2) 
!             printf("C");
! 	if (arights & DFS_USR3) 
!             printf("D");
! 	if (arights & DFS_USR4) 
!             printf("E");
! 	if (arights & DFS_USR5) 
!             printf("F");
! 	if (arights & DFS_USR6) 
!             printf("G");
! 	if (arights & DFS_USR7) 
!             printf("H");
      }	
+     return 0;
  }
  
  /* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
! static int 
! InAFS(char *apath)
! {
      struct ViceIoctl blob;
!     afs_int32 code;
  
      blob.in_size = 0;
      blob.out_size = MAXSIZE;
***************
*** 223,237 ****
  
      code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
      if (code) {
! 	if ((errno == EINVAL) || (errno == ENOENT)) return 0;
      }
      return 1;
  }
  
  /* return a static pointer to a buffer */
! static char *Parent(apath)
! char *apath; {
!     register char *tp;
      strcpy(tspace, apath);
      tp = strrchr(tspace, '\\');
      if (tp) {
--- 263,279 ----
  
      code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
      if (code) {
! 	if ((errno == EINVAL) || (errno == ENOENT)) 
!             return 0;
      }
      return 1;
  }
  
  /* return a static pointer to a buffer */
! static char *
! Parent(char *apath)
! {
!     char *tp;
      strcpy(tspace, apath);
      tp = strrchr(tspace, '\\');
      if (tp) {
***************
*** 246,259 ****
  
  enum rtype {add, destroy, deny};
  
! afs_int32 Convert(arights, dfs, rtypep)
!     register char *arights;
!     int dfs;
!     enum rtype *rtypep;
  {
!     register int i, len;
      afs_int32 mode;
!     register char tc;
  
      *rtypep = add;	/* add rights, by default */
  
--- 288,299 ----
  
  enum rtype {add, destroy, deny};
  
! static afs_int32 
! Convert(char *arights, int dfs, enum rtype *rtypep)
  {
!     int i, len;
      afs_int32 mode;
!     char tc;
  
      *rtypep = add;	/* add rights, by default */
  
***************
*** 262,275 ****
  	    *rtypep = deny;
  	    return 0;
  	}
! 	if (!strcmp(arights,"read")) return DFS_READ | DFS_EXECUTE;
! 	if (!strcmp(arights, "write")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE;
! 	if (!strcmp(arights, "all")) return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | DFS_WRITE | DFS_CONTROL;
      } else {
! 	if (!strcmp(arights,"read")) return PRSFS_READ | PRSFS_LOOKUP;
! 	if (!strcmp(arights, "write")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK;
! 	if (!strcmp(arights, "mail")) return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
! 	if (!strcmp(arights, "all")) return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
      }
      if (!strcmp(arights, "none")) {
  	*rtypep = destroy; /* Remove entire entry */
--- 302,326 ----
  	    *rtypep = deny;
  	    return 0;
  	}
! 	if (!strcmp(arights,"read")) 
!             return DFS_READ | DFS_EXECUTE;
! 	if (!strcmp(arights, "write")) 
!             return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | 
!                 DFS_WRITE;
! 	if (!strcmp(arights, "all")) 
!             return DFS_READ | DFS_EXECUTE | DFS_INSERT | DFS_DELETE | 
!                 DFS_WRITE | DFS_CONTROL;
      } else {
! 	if (!strcmp(arights,"read")) 
!             return PRSFS_READ | PRSFS_LOOKUP;
! 	if (!strcmp(arights, "write")) 
!             return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | 
!                 PRSFS_WRITE | PRSFS_LOCK;
! 	if (!strcmp(arights, "mail")) 
!             return PRSFS_INSERT | PRSFS_LOCK | PRSFS_LOOKUP;
! 	if (!strcmp(arights, "all")) 
!             return PRSFS_READ | PRSFS_LOOKUP | PRSFS_INSERT | PRSFS_DELETE | 
!                 PRSFS_WRITE | PRSFS_LOCK | PRSFS_ADMINISTER;
      }
      if (!strcmp(arights, "none")) {
  	*rtypep = destroy; /* Remove entire entry */
***************
*** 280,322 ****
      for(i=0;i<len;i++) {
          tc = *arights++;
  	if (dfs) {
! 	    if (tc == '-') continue;
! 	    else if (tc == 'r') mode |= DFS_READ;
! 	    else if (tc == 'w') mode |= DFS_WRITE;
! 	    else if (tc == 'x') mode |= DFS_EXECUTE;
! 	    else if (tc == 'c') mode |= DFS_CONTROL;
! 	    else if (tc == 'i') mode |= DFS_INSERT;
! 	    else if (tc == 'd') mode |= DFS_DELETE;
! 	    else if (tc == 'A') mode |= DFS_USR0;
! 	    else if (tc == 'B') mode |= DFS_USR1;
! 	    else if (tc == 'C') mode |= DFS_USR2;
! 	    else if (tc == 'D') mode |= DFS_USR3;
! 	    else if (tc == 'E') mode |= DFS_USR4;
! 	    else if (tc == 'F') mode |= DFS_USR5;
! 	    else if (tc == 'G') mode |= DFS_USR6;
! 	    else if (tc == 'H') mode |= DFS_USR7;
  	    else {
! 		fprintf(stderr, "%s: illegal DFS rights character '%c'.\n", pn, tc);
  		exit(1);
  	    }
  	} else {
! 	    if (tc == 'r') mode |= PRSFS_READ;
! 	    else if (tc == 'l') mode |= PRSFS_LOOKUP;
! 	    else if (tc == 'i') mode |= PRSFS_INSERT;
! 	    else if (tc == 'd') mode |= PRSFS_DELETE;
! 	    else if (tc == 'w') mode |= PRSFS_WRITE;
! 	    else if (tc == 'k') mode |= PRSFS_LOCK;
! 	    else if (tc == 'a') mode |= PRSFS_ADMINISTER;
! 	    else if (tc == 'A') mode |= PRSFS_USR0;
! 	    else if (tc == 'B') mode |= PRSFS_USR1;
! 	    else if (tc == 'C') mode |= PRSFS_USR2;
! 	    else if (tc == 'D') mode |= PRSFS_USR3;
! 	    else if (tc == 'E') mode |= PRSFS_USR4;
! 	    else if (tc == 'F') mode |= PRSFS_USR5;
! 	    else if (tc == 'G') mode |= PRSFS_USR6;
! 	    else if (tc == 'H') mode |= PRSFS_USR7;
  	    else {
! 		fprintf(stderr, "%s: illegal rights character '%c'.\n", pn, tc);
  		exit(1);
  	    }
  	}
--- 331,405 ----
      for(i=0;i<len;i++) {
          tc = *arights++;
  	if (dfs) {
! 	    if (tc == '-') 
!                 continue;
! 	    else if (tc == 'r') 
!                 mode |= DFS_READ;
! 	    else if (tc == 'w') 
!                 mode |= DFS_WRITE;
! 	    else if (tc == 'x') 
!                 mode |= DFS_EXECUTE;
! 	    else if (tc == 'c') 
!                 mode |= DFS_CONTROL;
! 	    else if (tc == 'i') 
!                 mode |= DFS_INSERT;
! 	    else if (tc == 'd') 
!                 mode |= DFS_DELETE;
! 	    else if (tc == 'A') 
!                 mode |= DFS_USR0;
! 	    else if (tc == 'B') 
!                 mode |= DFS_USR1;
! 	    else if (tc == 'C') 
!                 mode |= DFS_USR2;
! 	    else if (tc == 'D') 
!                 mode |= DFS_USR3;
! 	    else if (tc == 'E') 
!                 mode |= DFS_USR4;
! 	    else if (tc == 'F') 
!                 mode |= DFS_USR5;
! 	    else if (tc == 'G') 
!                 mode |= DFS_USR6;
! 	    else if (tc == 'H') 
!                 mode |= DFS_USR7;
  	    else {
! 		fprintf(stderr, "%s: illegal DFS rights character '%c'.\n", 
!                          pn, tc);
  		exit(1);
  	    }
  	} else {
! 	    if (tc == 'r') 
!                 mode |= PRSFS_READ;
! 	    else if (tc == 'l') 
!                 mode |= PRSFS_LOOKUP;
! 	    else if (tc == 'i') 
!                 mode |= PRSFS_INSERT;
! 	    else if (tc == 'd') 
!                 mode |= PRSFS_DELETE;
! 	    else if (tc == 'w') 
!                 mode |= PRSFS_WRITE;
! 	    else if (tc == 'k') 
!                 mode |= PRSFS_LOCK;
! 	    else if (tc == 'a') 
!                 mode |= PRSFS_ADMINISTER;
! 	    else if (tc == 'A') 
!                 mode |= PRSFS_USR0;
! 	    else if (tc == 'B') 
!                 mode |= PRSFS_USR1;
! 	    else if (tc == 'C') 
!                 mode |= PRSFS_USR2;
! 	    else if (tc == 'D') 
!                 mode |= PRSFS_USR3;
! 	    else if (tc == 'E') 
!                 mode |= PRSFS_USR4;
! 	    else if (tc == 'F') 
!                 mode |= PRSFS_USR5;
! 	    else if (tc == 'G') 
!                 mode |= PRSFS_USR6;
! 	    else if (tc == 'H') 
!                 mode |= PRSFS_USR7;
  	    else {
! 		fprintf(stderr, "%s: illegal rights character '%c'.\n", pn, 
!                          tc);
  		exit(1);
  	    }
  	}
***************
*** 324,356 ****
      return mode;
  }
  
! struct AclEntry *FindList (alist, aname)
!     char *aname;
!     register struct AclEntry *alist; {
      while (alist) {
!         if (!foldcmp(alist->name, aname)) return alist;
          alist = alist->next;
      }
      return 0;
  }
  
  /* if no parm specified in a particular slot, set parm to be "." instead */
! static void SetDotDefault(aitemp)
! struct cmd_item **aitemp; {
!     register struct cmd_item *ti;
!     if (*aitemp) return;	/* already has value */
      /* otherwise, allocate an item representing "." */
      ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
      ti->next = (struct cmd_item *) 0;
      ti->data = (char *) malloc(2);
      strcpy(ti->data, ".");
      *aitemp = ti;
  }
  
! void ChangeList (al, plus, aname, arights)
!     struct Acl *al;
!     char *aname;
!     afs_int32 arights, plus; {
      struct AclEntry *tlist;
      tlist = (plus ? al->pluslist : al->minuslist);
      tlist = FindList (tlist, aname);
--- 407,443 ----
      return mode;
  }
  
! static struct AclEntry *
! FindList (struct AclEntry *alist, char *aname)
! {
      while (alist) {
!         if (!strcasecmp(alist->name, aname)) 
!             return alist;
          alist = alist->next;
      }
      return 0;
  }
  
  /* if no parm specified in a particular slot, set parm to be "." instead */
! static void 
! SetDotDefault(struct cmd_item **aitemp)
! {
!     struct cmd_item *ti;
!     if (*aitemp) 
!         return;	                /* already has value */
      /* otherwise, allocate an item representing "." */
      ti = (struct cmd_item *) malloc(sizeof(struct cmd_item));
+     assert(ti);
      ti->next = (struct cmd_item *) 0;
      ti->data = (char *) malloc(2);
+     assert(ti->data);
      strcpy(ti->data, ".");
      *aitemp = ti;
  }
  
! static void 
! ChangeList (struct Acl *al, afs_int32 plus, char *aname, afs_int32 arights)
! {
      struct AclEntry *tlist;
      tlist = (plus ? al->pluslist : al->minuslist);
      tlist = FindList (tlist, aname);
***************
*** 365,370 ****
--- 452,458 ----
      }
      /* Otherwise we make a new item and plug in the new data. */
      tlist = (struct AclEntry *) malloc(sizeof (struct AclEntry));
+     assert(tlist);
      strcpy(tlist->name, aname);
      tlist->rights = arights;
      if (plus) {
***************
*** 373,399 ****
          al->nplus++;
          if (arights == 0 || arights == -1)
  	    al->nplus -= PruneList(&al->pluslist, al->dfs);
!     }
!     else {
          tlist->next = al->minuslist;
          al->minuslist = tlist;
          al->nminus++;
!         if (arights == 0) al->nminus -= PruneList(&al->minuslist, al->dfs);
      }
  }
  
! void ZapList (alist)
!     struct AclEntry *alist; {
!     register struct AclEntry *tp, *np;
      for (tp = alist; tp; tp = np) {
          np = tp->next;
          free(tp);
      }
  }
  
! int PruneList (ae, dfs)
!     struct AclEntry **ae;
!     int dfs;
  {
      struct AclEntry **lp;
      struct AclEntry *te, *ne;
--- 461,487 ----
          al->nplus++;
          if (arights == 0 || arights == -1)
  	    al->nplus -= PruneList(&al->pluslist, al->dfs);
!     } else {
          tlist->next = al->minuslist;
          al->minuslist = tlist;
          al->nminus++;
!         if (arights == 0) 
!             al->nminus -= PruneList(&al->minuslist, al->dfs);
      }
  }
  
! static void 
! ZapList (struct AclEntry *alist)
! {
!     struct AclEntry *tp, *np;
      for (tp = alist; tp; tp = np) {
          np = tp->next;
          free(tp);
      }
  }
  
! static int 
! PruneList (struct AclEntry **ae, int dfs)
  {
      struct AclEntry **lp;
      struct AclEntry *te, *ne;
***************
*** 406,413 ****
              ne = te->next;
              free(te);
              ctr++;
! 	}
!         else {
              ne = te->next;
              lp = &te->next;
  	}
--- 494,500 ----
              ne = te->next;
              free(te);
              ctr++;
! 	} else {
              ne = te->next;
              lp = &te->next;
  	}
***************
*** 415,423 ****
      return ctr;
  }
  
! char *SkipLine (astr)
!     register char *astr; {
!     while (*astr !='\n') astr++;
      astr++;
      return astr;
  }
--- 502,512 ----
      return ctr;
  }
  
! static char *
! SkipLine (char *astr)
! {
!     while (*astr !='\n') 
!         astr++;
      astr++;
      return astr;
  }
***************
*** 429,441 ****
   * assume that the acl is AFS: for DFS, the user can always resort to
   * acl_edit, but for AFS there may be no other way out).
   */
! struct Acl  *EmptyAcl(astr)
!     char *astr;
  {
!     register struct Acl *tp;
      int junk;
  
      tp = (struct Acl *)malloc(sizeof (struct Acl));
      tp->nplus = tp->nminus = 0;
      tp->pluslist = tp->minuslist = 0;
      tp->dfs = 0;
--- 518,531 ----
   * assume that the acl is AFS: for DFS, the user can always resort to
   * acl_edit, but for AFS there may be no other way out).
   */
! static struct Acl *
! EmptyAcl(char *astr)
  {
!     struct Acl *tp;
      int junk;
  
      tp = (struct Acl *)malloc(sizeof (struct Acl));
+     assert(tp);
      tp->nplus = tp->nminus = 0;
      tp->pluslist = tp->minuslist = 0;
      tp->dfs = 0;
***************
*** 443,456 ****
      return tp;
  }
  
! struct Acl *ParseAcl (astr)
!     char *astr; {
      int nplus, nminus, i, trights;
      char tname[MAXNAME];
      struct AclEntry *first, *last, *tl;
      struct Acl *ta;
  
      ta = (struct Acl *) malloc (sizeof (struct Acl));
      ta->dfs = 0;
      sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
      astr = SkipLine(astr);
--- 533,548 ----
      return tp;
  }
  
! static struct Acl *
! ParseAcl (char *astr)
! {
      int nplus, nminus, i, trights;
      char tname[MAXNAME];
      struct AclEntry *first, *last, *tl;
      struct Acl *ta;
  
      ta = (struct Acl *) malloc (sizeof (struct Acl));
+     assert(ta);
      ta->dfs = 0;
      sscanf(astr, "%d dfs:%d %s", &ta->nplus, &ta->dfs, ta->cell);
      astr = SkipLine(astr);
***************
*** 466,476 ****
          sscanf(astr, "%100s %d", tname, &trights);
          astr = SkipLine(astr);
          tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
!         if (!first) first = tl;
          strcpy(tl->name, tname);
          tl->rights = trights;
          tl->next = 0;
!         if (last) last->next = tl;
          last = tl;
      }
      ta->pluslist = first;
--- 558,571 ----
          sscanf(astr, "%100s %d", tname, &trights);
          astr = SkipLine(astr);
          tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
!         assert(tl);
!         if (!first) 
!             first = tl;
          strcpy(tl->name, tname);
          tl->rights = trights;
          tl->next = 0;
!         if (last) 
!             last->next = tl;
          last = tl;
      }
      ta->pluslist = first;
***************
*** 481,491 ****
          sscanf(astr, "%100s %d", tname, &trights);
          astr = SkipLine(astr);
          tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
!         if (!first) first = tl;
          strcpy(tl->name, tname);
          tl->rights = trights;
          tl->next = 0;
!         if (last) last->next = tl;
          last = tl;
      }
      ta->minuslist = first;
--- 576,589 ----
          sscanf(astr, "%100s %d", tname, &trights);
          astr = SkipLine(astr);
          tl = (struct AclEntry *) malloc(sizeof (struct AclEntry));
!         assert(tl);
!         if (!first) 
!             first = tl;
          strcpy(tl->name, tname);
          tl->rights = trights;
          tl->next = 0;
!         if (last) 
!             last->next = tl;
          last = tl;
      }
      ta->minuslist = first;
***************
*** 493,518 ****
      return ta;
  }
  
! void PrintStatus(status, name, motd, offmsg)
!     VolumeStatus *status;
!     char *name;
!     char *motd;
!     char *offmsg; {
      printf("Volume status for vid = %u named %s\n",status->Vid, name);
      if (*offmsg != 0)
  	printf("Current offline message is %s\n",offmsg);
      if (*motd != 0)
  	printf("Current message of the day is %s\n",motd);
      printf("Current disk quota is ");
!     if (status->MaxQuota != 0) printf("%d\n", status->MaxQuota);
!     else printf("unlimited\n");
      printf("Current blocks used are %d\n",status->BlocksInUse);
!     printf("The partition has %d blocks available out of %d\n\n",status->PartBlocksAvail, status->PartMaxBlocks);
  }
  
! void QuickPrintStatus(status, name)
! VolumeStatus *status;
! char *name; {
      double QuotaUsed =0.0;
      double PartUsed =0.0;
      int WARN = 0;
--- 591,618 ----
      return ta;
  }
  
! static int
! PrintStatus(VolumeStatus *status, char *name, char *motd, char *offmsg)
! {
      printf("Volume status for vid = %u named %s\n",status->Vid, name);
      if (*offmsg != 0)
  	printf("Current offline message is %s\n",offmsg);
      if (*motd != 0)
  	printf("Current message of the day is %s\n",motd);
      printf("Current disk quota is ");
!     if (status->MaxQuota != 0) 
!         printf("%d\n", status->MaxQuota);
!     else 
!         printf("unlimited\n");
      printf("Current blocks used are %d\n",status->BlocksInUse);
!     printf("The partition has %d blocks available out of %d\n\n",
!             status->PartBlocksAvail, status->PartMaxBlocks);
!     return 0;
  }
  
! static int
! QuickPrintStatus(VolumeStatus *status, char *name)
! {
      double QuotaUsed =0.0;
      double PartUsed =0.0;
      int WARN = 0;
***************
*** 527,549 ****
      if (QuotaUsed > 90.0){
  	printf(" %5.0f%%<<", QuotaUsed);
  	WARN = 1;
!     }
!     else printf(" %5.0f%%  ", QuotaUsed);
      PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
      if (PartUsed > 97.0){
  	printf(" %9.0f%%<<", PartUsed);
  	WARN = 1;
!     }
!     else printf(" %9.0f%%  ", PartUsed);
      if (WARN){
! 	printf("\t<<WARNING\n");
!     }
!     else printf("\n");
  }
  
! void QuickPrintSpace(status, name)
! VolumeStatus *status;
! char *name; {
      double PartUsed =0.0;
      int WARN = 0;
      printf("%-25.25s",name);
--- 627,650 ----
      if (QuotaUsed > 90.0){
  	printf(" %5.0f%%<<", QuotaUsed);
  	WARN = 1;
!     } else 
!         printf(" %5.0f%%  ", QuotaUsed);
      PartUsed = (100.0 - ((((double)status->PartBlocksAvail)/status->PartMaxBlocks) * 100.0));
      if (PartUsed > 97.0){
  	printf(" %9.0f%%<<", PartUsed);
  	WARN = 1;
!     } else 
!         printf(" %9.0f%%  ", PartUsed);
      if (WARN){
! 	printf("  <<WARNING\n");
!     } else 
!         printf("\n");
!     return 0;
  }
  
! static int
! QuickPrintSpace(VolumeStatus *status, char *name)
! {
      double PartUsed =0.0;
      int WARN = 0;
      printf("%-25.25s",name);
***************
*** 554,582 ****
      if (PartUsed > 90.0){
  	printf(" %4.0f%%<<", PartUsed);
  	WARN = 1;
!     }
!     else printf(" %4.0f%%  ", PartUsed);
      if (WARN){
! 	printf("\t<<WARNING\n");
!     }
!     else printf("\n");
  }
  
! char *AclToString(acl)
!     struct Acl *acl; {
      static char mydata[MAXSIZE];
      char tstring[MAXSIZE];
      char dfsstring[30];
      struct AclEntry *tp;
      
!     if (acl->dfs) sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
!     else dfsstring[0] = '\0';
      sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
!     for(tp = acl->pluslist;tp;tp=tp->next) {
          sprintf(tstring, "%s %d\n", tp->name, tp->rights);
          strcat(mydata, tstring);
      }
!     for(tp = acl->minuslist;tp;tp=tp->next) {
          sprintf(tstring, "%s %d\n", tp->name, tp->rights);
          strcat(mydata, tstring);
      }
--- 655,687 ----
      if (PartUsed > 90.0){
  	printf(" %4.0f%%<<", PartUsed);
  	WARN = 1;
!     } else 
!         printf(" %4.0f%%  ", PartUsed);
      if (WARN){
! 	printf("  <<WARNING\n");
!     } else 
!         printf("\n");
!     return 0;
  }
  
! static char *
! AclToString(struct Acl *acl)
! {
      static char mydata[MAXSIZE];
      char tstring[MAXSIZE];
      char dfsstring[30];
      struct AclEntry *tp;
      
!     if (acl->dfs) 
!         sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
!     else 
!         dfsstring[0] = '\0';
      sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
!     for (tp = acl->pluslist;tp;tp=tp->next) {
          sprintf(tstring, "%s %d\n", tp->name, tp->rights);
          strcat(mydata, tstring);
      }
!     for (tp = acl->minuslist;tp;tp=tp->next) {
          sprintf(tstring, "%s %d\n", tp->name, tp->rights);
          strcat(mydata, tstring);
      }
***************
*** 631,637 ****
--- 736,744 ----
          }
  
          psidAdmin = (PSID)malloc(dwSize); memset(psidAdmin,0,dwSize);
+         assert(psidAdmin);
          pszRefDomain = (char *)malloc(dwSize2);
+         assert(pszRefDomain);
  
          if (!LookupAccountName(NULL, pszAdminGroup, psidAdmin, &dwSize, pszRefDomain, &dwSize2, &snu)) {
              /* We can't lookup the group now even though we looked it up earlier.  
***************
*** 655,660 ****
--- 762,768 ----
                      GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize);
  
                      pGroups = (PTOKEN_GROUPS)malloc(dwSize);
+                     assert(pGroups);
  
                      /* Allocate that buffer, and read in the list of groups. */
                      if (GetTokenInformation (hToken, TokenGroups, pGroups, dwSize, &dwSize))
***************
*** 687,692 ****
--- 795,801 ----
                      GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize);
  
                      pTokenUser = (PTOKEN_USER)malloc(dwSize);
+                     assert(pTokenUser);
  
                      if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize))
                          gle = GetLastError();
***************
*** 718,736 ****
      return fAdmin;
  }
  
! static SetACLCmd(as)
! struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     struct Acl *ta;
!     register struct cmd_item *ti, *ui;
      int plusp;
      afs_int32 rights;
      int clear;
      int idf = getidf(as, parm_setacl_id);
  
!     if (as->parms[2].items) clear=1;
!     else clear=0;
      plusp = !(as->parms[3].items);
      for(ti=as->parms[0].items; ti;ti=ti->next) {
  	blob.out_size = MAXSIZE;
--- 827,850 ----
      return fAdmin;
  }
  
! static int
! SetACLCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct Acl *ta = 0;
!     struct cmd_item *ti, *ui;
      int plusp;
      afs_int32 rights;
      int clear;
      int idf = getidf(as, parm_setacl_id);
  
!     int error = 0;
! 
!     if (as->parms[2].items)
!         clear = 1;
!     else
!         clear = 0;
      plusp = !(as->parms[3].items);
      for(ti=as->parms[0].items; ti;ti=ti->next) {
  	blob.out_size = MAXSIZE;
***************
*** 739,772 ****
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
! 	    return 1;
  	}
  	ta = ParseAcl(space);
  	if (!plusp && ta->dfs) {
  	    fprintf(stderr,
  		    "fs: %s: you may not use the -negative switch with DFS acl's.\n%s",
  		    ti->data,
  		    "(you may specify \"null\" to revoke all rights, however)\n");
! 	    return 1;
  	}
! 	if (clear) ta = EmptyAcl(space);
! 	else ta = ParseAcl(space);
! 	CleanAcl(ta);
  	for(ui=as->parms[1].items; ui; ui=ui->next->next) {
  	    enum rtype rtype;
  	    if (!ui->next) {
! 		fprintf(stderr,"%s: Missing second half of user/access pair.\n", pn);
  		return 1;
  	    }
  	    rights = Convert(ui->next->data, ta->dfs, &rtype);
  	    if (rtype == destroy && !ta->dfs) {
! 		if (!FindList(ta->pluslist, ui->data)) {
! 		    fprintf(stderr,"%s: Invalid arg (%s doesn't exist in the current acl)\n", pn, ui->data);
! 		    return 1;
! 		}
  	    }
! 	    if (rtype == deny && !ta->dfs) plusp = 0;
! 	    if (rtype == destroy && ta->dfs) rights = -1;
  	    ChangeList(ta, plusp, ui->data, rights);
  	}
  	blob.in = AclToString(ta);
--- 853,899 ----
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
! 	    error = 1;
!             continue;
  	}
+         if (ta)
+             ZapAcl(ta);
  	ta = ParseAcl(space);
  	if (!plusp && ta->dfs) {
  	    fprintf(stderr,
  		    "fs: %s: you may not use the -negative switch with DFS acl's.\n%s",
  		    ti->data,
  		    "(you may specify \"null\" to revoke all rights, however)\n");
! 	    error = 1;
!             continue;
  	}
!         if (ta)
!             ZapAcl(ta);
! 	if (clear) 
!             ta = EmptyAcl(space);
! 	else 
!             ta = ParseAcl(space);
! 	CleanAcl(ta, ti->data);
  	for(ui=as->parms[1].items; ui; ui=ui->next->next) {
  	    enum rtype rtype;
  	    if (!ui->next) {
! 		fprintf(stderr,
!                         "%s: Missing second half of user/access pair.\n", pn);
!                 ZapAcl(ta);
  		return 1;
  	    }
  	    rights = Convert(ui->next->data, ta->dfs, &rtype);
  	    if (rtype == destroy && !ta->dfs) {
!                 struct AclEntry *tlist;
! 
!                 tlist = (plusp ? ta->pluslist : ta->minuslist);
! 		if (!FindList(tlist, ui->data))
!                     continue;
  	    }
! 	    if (rtype == deny && !ta->dfs) 
!                 plusp = 0;
! 	    if (rtype == destroy && ta->dfs) 
!                 rights = -1;
  	    ChangeList(ta, plusp, ui->data, rights);
  	}
  	blob.in = AclToString(ta);
***************
*** 810,844 ****
      " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
  		    }
  		} else {
! 		    fprintf(stderr,"%s: Invalid argument, possible reasons include:\n", pn);
  		    fprintf(stderr,"\t-File not in AFS\n");
! 		    fprintf(stderr,"\t-Too many users on access control list\n");
! 		    fprintf(stderr,"\t-Tried to add non-existent user to access control list\n");
  		}
! 		return 1;
! 	    }
! 	    else {
  		Die(errno, ti->data);
! 		continue;
! 	    }
! 	}
      }
!     return 0;
  }
  
! 
! static CopyACLCmd(as)
! struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     struct Acl *fa, *ta;
      struct AclEntry *tp;
!     register struct cmd_item *ti;
      int clear;
      int idf = getidf(as, parm_copyacl_id);
  
!     if (as->parms[2].items) clear=1;
!     else clear=0;
      blob.out_size = MAXSIZE;
      blob.in_size = idf;
      blob.in = blob.out = space;
--- 937,978 ----
      " (You may inhibit this message by setting \"FS_EXPERT\" in your environment)\n");
  		    }
  		} else {
! 		    fprintf(stderr,
!                             "%s: Invalid argument, possible reasons include:\n", 
!                              pn);
  		    fprintf(stderr,"\t-File not in AFS\n");
! 		    fprintf(stderr,
!                             "\t-Too many users on access control list\n");
! 		    fprintf(stderr,
!                             "\t-Tried to add non-existent user to access control list\n");
  		}
!             } else {
  		Die(errno, ti->data);
!             }
!             error = 1;
!         }
      }
!     if (ta)
!         ZapAcl(ta);
!     return error;
  }
  
! static int 
! CopyACLCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct Acl *fa, *ta = 0;
      struct AclEntry *tp;
!     struct cmd_item *ti;
      int clear;
      int idf = getidf(as, parm_copyacl_id);
+     int error = 0;
  
!     if (as->parms[2].items) 
!         clear=1;
!     else 
!         clear=0;
      blob.out_size = MAXSIZE;
      blob.in_size = idf;
      blob.in = blob.out = space;
***************
*** 848,854 ****
  	return 1;
      }
      fa = ParseAcl(space);
!     CleanAcl(fa);
      for (ti=as->parms[1].items; ti;ti=ti->next) {
  	blob.out_size = MAXSIZE;
  	blob.in_size = idf;
--- 982,988 ----
  	return 1;
      }
      fa = ParseAcl(space);
!     CleanAcl(fa, as->parms[0].items->data);
      for (ti=as->parms[1].items; ti;ti=ti->next) {
  	blob.out_size = MAXSIZE;
  	blob.in_size = idf;
***************
*** 856,874 ****
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
! 	    return 1;
  	}
! 	if (clear) ta = EmptyAcl(space);
! 	else ta = ParseAcl(space);
! 	CleanAcl(ta);
  	if (ta->dfs != fa->dfs) {
! 	    fprintf(stderr, "fs: incompatible file system types: acl not copied to %s; aborted\n", ti->data);
! 	    goto next;
  	}
  	if (ta->dfs) {
  	    if (! clear && strcmp(ta->cell, fa->cell) != 0) {
! 		fprintf(stderr, "fs: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", ti->data);
! 		goto next;
  	    }
  	    strcpy(ta->cell, fa->cell);
  	}
--- 990,1019 ----
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
! 	    error = 1;
!             continue;
  	}
!         if (ta)
!             ZapAcl(ta);
! 	if (clear) 
!             ta = EmptyAcl(space);
! 	else 
!             ta = ParseAcl(space);
! 	CleanAcl(ta, ti->data);
  	if (ta->dfs != fa->dfs) {
! 	    fprintf(stderr, 
!                     "%s: incompatible file system types: acl not copied to %s; aborted\n", 
!                     pn, ti->data);
! 	    error = 1;
!             continue;
  	}
  	if (ta->dfs) {
  	    if (! clear && strcmp(ta->cell, fa->cell) != 0) {
! 		fprintf(stderr, 
!                         "%s: default DCE cell differs for file %s: use \"-clear\" switch; acl not merged\n", 
!                         pn, ti->data);
!                 error = 1;
! 		continue;
  	    }
  	    strcpy(ta->cell, fa->cell);
  	}
***************
*** 882,921 ****
  	code = pioctl(ti->data, VIOCSETAL, &blob, 1);
  	if (code) {
  	    if (errno == EINVAL) {
! 		fprintf(stderr,"%s: Invalid argument, possible reasons include:\n", pn);
  		fprintf(stderr,"\t-File not in AFS\n");
! 		return 1;
! 	    }
! 	    else {
  		Die(errno, ti->data);
- 		goto next;
  	    }
  	}
!       next:
  	ZapAcl(ta);
!     }
!     return 0;
  }
  
  
  
! /* tell if a name is 23 or -45 (digits or minus digits), which are bad names we must prune */
! static BadName(aname)
! register char *aname; {
!     register int tc;
!     while(tc = *aname++) {
  	/* all must be '-' or digit to be bad */
! 	if (tc != '-' && (tc < '0' || tc > '9')) return 0;
      }
!     return 1;
  }
  
  
  /* clean up an access control list of its bad entries; return 1 if we made
     any changes to the list, and 0 otherwise */
! int CleanAcl(aa)
! struct Acl *aa; {
!     register struct AclEntry *te, **le, *ne;
      int changes;
  
      /* Don't correct DFS ACL's for now */
--- 1027,1099 ----
  	code = pioctl(ti->data, VIOCSETAL, &blob, 1);
  	if (code) {
  	    if (errno == EINVAL) {
! 		fprintf(stderr,
!                         "%s: Invalid argument, possible reasons include:\n", pn);
  		fprintf(stderr,"\t-File not in AFS\n");
! 	    } else {
  		Die(errno, ti->data);
  	    }
+             error = 1;
  	}
!     } 
!     if (ta)
  	ZapAcl(ta);
!     ZapAcl(fa);
!     return error;
  }
  
+ /* pioctl() call to get the cellname of a pathname */
+ static afs_int32
+ GetCell(char *fname, char *cellname)
+ {
+     afs_int32 code;
+     struct ViceIoctl blob;
+ 
+     blob.in_size = 0;
+     blob.out_size = MAXCELLCHARS;
+     blob.out = cellname;
+ 
+     code = pioctl(fname, VIOC_FILE_CELL_NAME, &blob, 1);
+     return code ? errno : 0;
+ }
  
+ /* Check if a username is valid: If it contains only digits (or a
+  * negative sign), then it might be bad.  We then query the ptserver
+  * to see.
+  */
+ static int
+ BadName(char *aname, char *fname)
+ {
+     afs_int32 tc, code, id;
+     char *nm;
+     char cell[MAXCELLCHARS];
  
!     for ( nm = aname; tc = *nm; nm++) {
  	/* all must be '-' or digit to be bad */
! 	if (tc != '-' && (tc < '0' || tc > '9'))
!             return 0;
      }
! 
!     /* Go to the PRDB and see if this all number username is valid */
!     code = GetCell(fname, cell);
!     if (code)
!         return 0;
! 
!     pr_Initialize(1, AFSDIR_CLIENT_ETC_DIRPATH, cell);
!     code = pr_SNameToId(aname, &id);
!     pr_End();
! 
!     /* 1=>Not-valid; 0=>Valid */
!     return ((!code && (id == ANONYMOUSID)) ? 1 : 0);
  }
  
  
  /* clean up an access control list of its bad entries; return 1 if we made
     any changes to the list, and 0 otherwise */
! static int 
! CleanAcl(struct Acl *aa, char *fname)
! {
!     struct AclEntry *te, **le, *ne;
      int changes;
  
      /* Don't correct DFS ACL's for now */
***************
*** 927,954 ****
      le = &aa->pluslist;
      for(te = aa->pluslist; te; te=ne) {
  	ne = te->next;
! 	if (BadName(te->name)) {
  	    /* zap this dude */
  	    *le = te->next;
  	    aa->nplus--;
  	    free(te);
  	    changes++;
! 	}
! 	else {
  	    le = &te->next;
  	}
      }
      le = &aa->minuslist;
      for(te = aa->minuslist; te; te=ne) {
  	ne = te->next;
! 	if (BadName(te->name)) {
  	    /* zap this dude */
  	    *le = te->next;
  	    aa->nminus--;
  	    free(te);
  	    changes++;
! 	}
! 	else {
  	    le = &te->next;
  	}
      }
--- 1105,1130 ----
      le = &aa->pluslist;
      for(te = aa->pluslist; te; te=ne) {
  	ne = te->next;
! 	if (BadName(te->name, fname)) {
  	    /* zap this dude */
  	    *le = te->next;
  	    aa->nplus--;
  	    free(te);
  	    changes++;
! 	} else {
  	    le = &te->next;
  	}
      }
      le = &aa->minuslist;
      for(te = aa->minuslist; te; te=ne) {
  	ne = te->next;
! 	if (BadName(te->name, fname)) {
  	    /* zap this dude */
  	    *le = te->next;
  	    aa->nminus--;
  	    free(te);
  	    changes++;
! 	} else {
  	    le = &te->next;
  	}
      }
***************
*** 957,970 ****
  
  
  /* clean up an acl to not have bogus entries */
! static CleanACLCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
!     register struct Acl *ta;
      struct ViceIoctl blob;
      int changes;
!     register struct cmd_item *ti;
!     register struct AclEntry *te;
  
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
--- 1133,1148 ----
  
  
  /* clean up an acl to not have bogus entries */
! static int 
! CleanACLCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     struct Acl *ta = 0;
      struct ViceIoctl blob;
      int changes;
!     struct cmd_item *ti;
!     struct AclEntry *te;
!     int error = 0;
  
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
***************
*** 974,991 ****
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
  	    continue;
  	}
  	ta = ParseAcl(space);
  
  	if (ta->dfs) {
  	    fprintf(stderr,
  		    "%s: cleanacl is not supported for DFS access lists.\n",
  		    pn);
! 	    return 1;
  	}
  
! 	changes = CleanAcl(ta);
  
  	if (changes) {
  	    /* now set the acl */
--- 1152,1173 ----
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	    continue;
  	}
+         if (ta)
+             ZapAcl(ta);
  	ta = ParseAcl(space);
  
  	if (ta->dfs) {
  	    fprintf(stderr,
  		    "%s: cleanacl is not supported for DFS access lists.\n",
  		    pn);
! 	    error = 1;
!             continue;
  	}
  
! 	changes = CleanAcl(ta, ti->data);
  
  	if (changes) {
  	    /* now set the acl */
***************
*** 995,1015 ****
  	    code = pioctl(ti->data, VIOCSETAL, &blob, 1);
  	    if (code) {
  		if (errno == EINVAL) {
! 		    fprintf(stderr,"%s: Invalid argument, possible reasons include\n", pn);
  		    fprintf(stderr,"%s: File not in vice or\n", pn);
! 		    fprintf(stderr,"%s: Too many users on access control list or\n", pn);
! 		    return 1;
! 		}
! 		else {
  		    Die(errno, ti->data);
- 		    continue;
  		}
  	    }
  
  	    /* now list the updated acl */
  	    printf("Access list for %s is now\n", ti->data);
  	    if (ta->nplus > 0) {
! 		if (!ta->dfs) printf("Normal rights:\n");
  		for(te = ta->pluslist;te;te=te->next) {
  		    printf("  %s ", te->name);
  		    PRights(te->rights, ta->dfs);
--- 1177,1201 ----
  	    code = pioctl(ti->data, VIOCSETAL, &blob, 1);
  	    if (code) {
  		if (errno == EINVAL) {
! 		    fprintf(stderr,
!                             "%s: Invalid argument, possible reasons include\n", 
!                              pn);
  		    fprintf(stderr,"%s: File not in vice or\n", pn);
! 		    fprintf(stderr,
!                             "%s: Too many users on access control list or\n", 
!                             pn);
! 		} else {
  		    Die(errno, ti->data);
  		}
+                 error = 1;
+                 continue;
  	    }
  
  	    /* now list the updated acl */
  	    printf("Access list for %s is now\n", ti->data);
  	    if (ta->nplus > 0) {
! 		if (!ta->dfs) 
!                     printf("Normal rights:\n");
  		for(te = ta->pluslist;te;te=te->next) {
  		    printf("  %s ", te->name);
  		    PRights(te->rights, ta->dfs);
***************
*** 1024,1045 ****
  		    printf("\n");
  		}
  	    }
! 	    if (ti->next) printf("\n");
! 	}
! 	else
  	    printf("Access list for %s is fine.\n", ti->data);
      }
!     return 0;
  }
  
! static ListACLCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
!     register struct Acl *ta;
      struct ViceIoctl blob;
      struct AclEntry *te;
!     register struct cmd_item *ti;
      int idf = getidf(as, parm_listacl_id);
  
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
--- 1210,1235 ----
  		    printf("\n");
  		}
  	    }
! 	    if (ti->next) 
!                 printf("\n");
! 	} else
  	    printf("Access list for %s is fine.\n", ti->data);
      }
!     if (ta)
!         ZapAcl(ta);
!     return error;
  }
  
! static int 
! ListACLCmd(struct cmd_syndesc *as, char *arock) 
! {
!     afs_int32 code;
!     struct Acl *ta = 0;
      struct ViceIoctl blob;
      struct AclEntry *te;
!     struct cmd_item *ti;
      int idf = getidf(as, parm_listacl_id);
+     int error = 0;
  
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
***************
*** 1050,1055 ****
--- 1240,1246 ----
  	code = pioctl(ti->data, VIOCGETAL, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	    continue;
  	}
  	ta = ParseAcl(space);
***************
*** 1072,1078 ****
  	}
  	separator = ta->dfs? DFS_SEPARATOR : ' ';
  	if (ta->nplus > 0) {
! 	    if (!ta->dfs) printf("Normal rights:\n");
  	    for(te = ta->pluslist;te;te=te->next) {
  		printf("  %s%c", te->name, separator);
  		PRights(te->rights, ta->dfs);
--- 1263,1270 ----
  	}
  	separator = ta->dfs? DFS_SEPARATOR : ' ';
  	if (ta->nplus > 0) {
! 	    if (!ta->dfs) 
!                 printf("Normal rights:\n");
  	    for(te = ta->pluslist;te;te=te->next) {
  		printf("  %s%c", te->name, separator);
  		PRights(te->rights, ta->dfs);
***************
*** 1087,1159 ****
  		printf("\n");
  	    }
  	}
! 	if (ti->next) printf("\n");
      }
!     return 0;
  }
  
! static FlushVolumeCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
  
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	blob.in_size = blob.out_size = 0;
  	code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
  	if (code) {
! 	    fprintf(stderr, "Error flushing volume\n");
! 	    Die(errno,ti->data);
  	    continue;
  	}
      }
!     return 0;
  }
  
! static FlushCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     int error;
!     register struct cmd_item *ti;
  
-     error = 0;
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	blob.in_size = blob.out_size = 0;
  	code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
  	if (code) {
- 	    error = 1;
  	    if (errno == EMFILE) {
! 		fprintf(stderr,"%s: Can't flush active file %s\n", pn, ti->data);
! 		continue;
! 	    }
! 	    else {
! 		fprintf(stderr, "Error flushing file\n");
! 		Die(errno,ti->data);
! 		continue;
  	    }
  	}
      }
      return error;
  }
  
  /* all this command does is repackage its args and call SetVolCmd */
! static SetQuotaCmd(as)
! register struct cmd_syndesc *as; {
      struct cmd_syndesc ts;
  
      /* copy useful stuff from our command slot; we may later have to reorder */
      memcpy(&ts, as, sizeof(ts));	/* copy whole thing */
!     return SetVolCmd(&ts);
  }
  
! static SetVolCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      struct VolumeStatus *status;
      char *motd, *offmsg, *input;
  
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
--- 1279,1358 ----
  		printf("\n");
  	    }
  	}
! 	if (ti->next) 
!             printf("\n");
!         ZapAcl(ta);
      }
!     return error;
  }
  
! static int
! FlushVolumeCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
!     int error = 0;
  
+     SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	blob.in_size = blob.out_size = 0;
  	code = pioctl(ti->data, VIOC_FLUSHVOLUME, &blob, 0);
  	if (code) {
! 	    fprintf(stderr, "Error flushing volume ");
!             perror(ti->data);
!             error = 1;
  	    continue;
  	}
      }
!     return error;
  }
  
! static int 
! FlushCmd(struct cmd_syndesc *as, char *arock) 
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
! 
!     int error = 0;
  
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	blob.in_size = blob.out_size = 0;
  	code = pioctl(ti->data, VIOCFLUSH, &blob, 0);
  	if (code) {
  	    if (errno == EMFILE) {
! 		fprintf(stderr, "%s: Can't flush active file %s\n", pn, 
!                         ti->data);
! 	    } else {
! 		fprintf(stderr, "%s: Error flushing file ", pn);
! 		perror(ti->data);
  	    }
+             error = 1;
+             continue;
  	}
      }
      return error;
  }
  
  /* all this command does is repackage its args and call SetVolCmd */
! static int
! SetQuotaCmd(struct cmd_syndesc *as, char *arock) {
      struct cmd_syndesc ts;
  
      /* copy useful stuff from our command slot; we may later have to reorder */
      memcpy(&ts, as, sizeof(ts));	/* copy whole thing */
!     return SetVolCmd(&ts, arock);
  }
  
! static int
! SetVolCmd(struct cmd_syndesc *as, char *arock) {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      struct VolumeStatus *status;
      char *motd, *offmsg, *input;
+     int error = 0;
  
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
***************
*** 1164,1224 ****
  	blob.in = space;
  	status = (VolumeStatus *)space;
  	status->MinQuota = status->MaxQuota = -1;
! 	motd = offmsg = (char *) 0;
  	if (as->parms[1].items) {
  	    code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
  	    if (code) {
! 		fprintf(stderr,"fs: bad integer specified for quota.\n");
! 		return code;
  	    }
  	}
! 	if (as->parms[2].items) motd = as->parms[2].items->data;
! 	if (as->parms[3].items) offmsg = as->parms[3].items->data;
  	input = (char *)status + sizeof(*status);
  	*(input++) = '\0';	/* never set name: this call doesn't change vldb */
  	if(offmsg) {
! 	  if (strlen(offmsg) >= VMSGSIZE) {
! 	    fprintf(stderr,"fs: message must be shorter than %d characters\n",
! 		    VMSGSIZE);
! 	    return code;
! 	  }
  	    strcpy(input,offmsg);
  	    blob.in_size += strlen(offmsg);
  	    input += strlen(offmsg) + 1;
! 	}
! 	else *(input++) = '\0';
  	if(motd) {
! 	  if (strlen(motd) >= VMSGSIZE) {
! 	    fprintf(stderr,"fs: message must be shorter than %d characters\n",
! 		    VMSGSIZE);
! 	    return code;
! 	  }
  	    strcpy(input,motd);
  	    blob.in_size += strlen(motd);
  	    input += strlen(motd) + 1;
! 	}
! 	else *(input++) = '\0';
  	code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
  	if (code) {
! 	    Die(errno, ti->data);
! 	    return 1;
  	}
      }
!     return 0;
  }
  
! static ExamineCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      struct VolumeStatus *status;
      char *name, *offmsg, *motd;
!     int error;
      
-     error = 0;
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per file */
  	blob.out_size = MAXSIZE;
  	blob.in_size = 0;
--- 1363,1440 ----
  	blob.in = space;
  	status = (VolumeStatus *)space;
  	status->MinQuota = status->MaxQuota = -1;
! 	motd = offmsg = NULL;
  	if (as->parms[1].items) {
  	    code = util_GetInt32(as->parms[1].items->data, &status->MaxQuota);
  	    if (code) {
! 		fprintf(stderr,"%s: bad integer specified for quota.\n", pn);
! 		error = 1;
!                 continue;
  	    }
  	}
! 	if (as->parms[2].items) 
!             motd = as->parms[2].items->data;
! 	if (as->parms[3].items) 
!             offmsg = as->parms[3].items->data;
  	input = (char *)status + sizeof(*status);
  	*(input++) = '\0';	/* never set name: this call doesn't change vldb */
  	if(offmsg) {
!             if (strlen(offmsg) >= VMSGSIZE) {
!                 fprintf(stderr,"%s: message must be shorter than %d characters\n",
!                          pn, VMSGSIZE);
!                 error = 1;
!                 continue;
!             }
  	    strcpy(input,offmsg);
  	    blob.in_size += strlen(offmsg);
  	    input += strlen(offmsg) + 1;
! 	} else 
!             *(input++) = '\0';
  	if(motd) {
!             if (strlen(motd) >= VMSGSIZE) {
!                 fprintf(stderr,"%s: message must be shorter than %d characters\n",
!                          pn, VMSGSIZE);
!                 return code;
!             }
  	    strcpy(input,motd);
  	    blob.in_size += strlen(motd);
  	    input += strlen(motd) + 1;
! 	} else 
!             *(input++) = '\0';
  	code = pioctl(ti->data,VIOCSETVOLSTAT, &blob, 1);
  	if (code) {
! 	    error = 1;
  	}
      }
!     return error;
  }
  
! #ifndef WIN32
! /* 
!  * Why is VenusFid declared in the kernel-only section of afs.h, 
!  * if it's the exported interface of the (UNIX) cache manager?
!  */
! struct VenusFid {
!     afs_int32 Cell;
!     AFSFid Fid;
! };
! #endif /* WIN32 */
! 
! static int 
! ExamineCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      struct VolumeStatus *status;
      char *name, *offmsg, *motd;
!     int error = 0;
      
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
+ #ifndef WIN32
+         struct VenusFid vfid;
+ #endif /* WIN32 */
  	/* once per file */
  	blob.out_size = MAXSIZE;
  	blob.in_size = 0;
***************
*** 1233,1250 ****
  	name = (char *)status + sizeof(*status);
  	offmsg = name + strlen(name) + 1;
  	motd = offmsg + strlen(offmsg) + 1;
  	PrintStatus(status, name, motd, offmsg);
      }
      return error;
  }
  
! static ListQuotaCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      struct VolumeStatus *status;
      char *name;
      
      printf("%-25s%-10s%-10s%-7s%-13s\n", 
             "Volume Name", "     Quota", "      Used", "  %Used", "    Partition");
--- 1449,1479 ----
  	name = (char *)status + sizeof(*status);
  	offmsg = name + strlen(name) + 1;
  	motd = offmsg + strlen(offmsg) + 1;
+ 
+ #ifndef WIN32
+         blob.out_size = sizeof(struct VenusFid);
+         blob.out = (char *) &vfid;
+         if (0 == pioctl(ti->data, VIOCGETFID, &blob, 1)) {
+             printf("File %s (%u.%u.%u) contained in volume %u\n",
+                     ti->data, vfid.Fid.Volume, vfid.Fid.Vnode, vfid.Fid.Unique,
+                     vfid.Fid.Volume);
+         }
+ #endif /* WIN32 */
  	PrintStatus(status, name, motd, offmsg);
      }
      return error;
  }
  
! static int
! ListQuotaCmd(struct cmd_syndesc *as, char *arock) 
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      struct VolumeStatus *status;
      char *name;
+ 
+     int error = 0;
      
      printf("%-25s%-10s%-10s%-7s%-13s\n", 
             "Volume Name", "     Quota", "      Used", "  %Used", "    Partition");
***************
*** 1257,1279 ****
  	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
  	    continue;
  	}
  	status = (VolumeStatus *)space;
  	name = (char *)status + sizeof(*status);
  	QuickPrintStatus(status, name);
      }
!     return 0;
  }
  
! static WhereIsCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
!     register int j;
      afs_int32 *hosts;
      char *tp;
      
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
--- 1486,1511 ----
  	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	    continue;
  	}
  	status = (VolumeStatus *)space;
  	name = (char *)status + sizeof(*status);
  	QuickPrintStatus(status, name);
      }
!     return error;
  }
  
! static int
! WhereIsCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
!     int j;
      afs_int32 *hosts;
      char *tp;
+     int error = 0;
      
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
***************
*** 1285,1312 ****
  	code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
  	    continue;
  	}
  	hosts = (afs_int32 *) space;
! 	printf("File %s is on host%s ", ti->data, (hosts[0] && !hosts[1]) ? "": "s");
  	for(j=0; j<MAXHOSTS; j++) {
! 	    if (hosts[j] == 0) break;
  	    tp = hostutil_GetNameByINet(hosts[j]);
  	    printf("%s ", tp);
  	}
  	printf("\n");
      }
!     return 0;
  }
  
  
! static DiskFreeCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      char *name;
      struct VolumeStatus *status;
      
      printf("%-25s%-10s%-10s%-10s%-6s\n", "Volume Name", "    kbytes",
  	   "      used", "     avail", " %used");
--- 1517,1549 ----
  	code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	    continue;
  	}
  	hosts = (afs_int32 *) space;
! 	printf("File %s is on host%s ", ti->data, 
!                 (hosts[0] && !hosts[1]) ? "": "s");
  	for(j=0; j<MAXHOSTS; j++) {
! 	    if (hosts[j] == 0) 
!                 break;
  	    tp = hostutil_GetNameByINet(hosts[j]);
  	    printf("%s ", tp);
  	}
  	printf("\n");
      }
!     return error;
  }
  
  
! static int
! DiskFreeCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      char *name;
      struct VolumeStatus *status;
+     int error = 0;
      
      printf("%-25s%-10s%-10s%-10s%-6s\n", "Volume Name", "    kbytes",
  	   "      used", "     avail", " %used");
***************
*** 1319,1340 ****
  	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
  	    continue;
  	}
  	status = (VolumeStatus *)space;
  	name = (char *)status + sizeof(*status);
  	QuickPrintSpace(status, name);
      }
!     return 0;
  }
  
! static QuotaCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      double quotaPct;
      struct VolumeStatus *status;
      
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
--- 1556,1580 ----
  	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	    continue;
  	}
  	status = (VolumeStatus *)space;
  	name = (char *)status + sizeof(*status);
  	QuickPrintSpace(status, name);
      }
!     return error;
  }
  
! static int
! QuotaCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      double quotaPct;
      struct VolumeStatus *status;
+     int error = 0;
      
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
***************
*** 1345,1370 ****
  	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
  	    continue;
  	}
  	status = (VolumeStatus *)space;
! 	if (status->MaxQuota) quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
! 	else quotaPct = 0.0;
  	printf("%2.0f%% of quota used.\n", quotaPct);
      }
!     return 0;
  }
  
! static ListMountCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     int error;
!     register struct cmd_item *ti;
      char orig_name[1024];		/*Original name, may be modified*/
      char true_name[1024];		/*``True'' dirname (e.g., symlink target)*/
      char parent_dir[1024];		/*Parent directory of true name*/
!     register char *last_component;	/*Last component of true name*/
  #ifndef WIN32
      struct stat statbuff;		/*Buffer for status info*/
  #endif /* not WIN32 */
--- 1585,1613 ----
  	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	    continue;
  	}
  	status = (VolumeStatus *)space;
! 	if (status->MaxQuota) 
!             quotaPct = ((((double)status->BlocksInUse)/status->MaxQuota) * 100.0);
! 	else 
!             quotaPct = 0.0;
  	printf("%2.0f%% of quota used.\n", quotaPct);
      }
!     return error;
  }
  
! static int
! ListMountCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      char orig_name[1024];		/*Original name, may be modified*/
      char true_name[1024];		/*``True'' dirname (e.g., symlink target)*/
      char parent_dir[1024];		/*Parent directory of true name*/
!     char *last_component;	/*Last component of true name*/
  #ifndef WIN32
      struct stat statbuff;		/*Buffer for status info*/
  #endif /* not WIN32 */
***************
*** 1373,1379 ****
  #endif /* not WIN32 */
      int	thru_symlink;			/*Did we get to a mount point via a symlink?*/
      
!     error = 0;
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per file */
  	thru_symlink = 0;
--- 1616,1622 ----
  #endif /* not WIN32 */
      int	thru_symlink;			/*Did we get to a mount point via a symlink?*/
      
!     int error = 0;
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per file */
  	thru_symlink = 0;
***************
*** 1388,1395 ****
  #ifndef WIN32
  	if (lstat(orig_name, &statbuff) < 0) {
  	    /* if lstat fails, we should still try the pioctl, since it
! 		may work (for example, lstat will fail, but pioctl will
! 		    work if the volume of offline (returning ENODEV). */
  	    statbuff.st_mode = S_IFDIR; /* lie like pros */
  	}
  
--- 1631,1638 ----
  #ifndef WIN32
  	if (lstat(orig_name, &statbuff) < 0) {
  	    /* if lstat fails, we should still try the pioctl, since it
!              * may work (for example, lstat will fail, but pioctl will
!              * work if the volume of offline (returning ENODEV). */
  	    statbuff.st_mode = S_IFDIR; /* lie like pros */
  	}
  
***************
*** 1404,1412 ****
  	     */
  	    link_chars_read = readlink(orig_name, true_name, 1024);
  	    if (link_chars_read <= 0) {
! 		fprintf(stderr,"%s: Can't read target name for '%s' symbolic link!\n",
  		       pn, orig_name);
! 		exit(1);
  	    }
  
  	    /*
--- 1647,1657 ----
  	     */
  	    link_chars_read = readlink(orig_name, true_name, 1024);
  	    if (link_chars_read <= 0) {
! 		fprintf(stderr,
!                         "%s: Can't read target name for '%s' symbolic link!\n",
  		       pn, orig_name);
! 		error = 1;
!                 continue;
  	    }
  
  	    /*
***************
*** 1425,1432 ****
  		strcpy(++last_component, true_name);
  		strcpy(true_name, orig_name);
  	    }
! 	}
! 	else
  	    strcpy(true_name, orig_name);
  #else	/* WIN32 */
  	strcpy(true_name, orig_name);
--- 1670,1676 ----
  		strcpy(++last_component, true_name);
  		strcpy(true_name, orig_name);
  	    }
! 	} else
  	    strcpy(true_name, orig_name);
  #else	/* WIN32 */
  	strcpy(true_name, orig_name);
***************
*** 1435,1442 ****
--- 1679,1688 ----
  	/*
  	 * Find rightmost slash, if any.
  	 */
+ #ifdef WIN32
  	last_component = (char *) strrchr(true_name, '\\');
  	if (!last_component)
+ #endif /* WIN32 */
  	    last_component = (char *) strrchr(true_name, '/');
  	if (last_component) {
  	    /*
***************
*** 1446,1453 ****
  	    strncpy(parent_dir, true_name, last_component - true_name + 1);
  	    parent_dir[last_component - true_name + 1] = 0;
  	    last_component++;   /*Skip the slash*/
! 	}
! 	else {
  	    /*
  	     * No slash appears in the given file name.  Set parent_dir to the current
  	     * directory, and the last component as the given name.
--- 1692,1698 ----
  	    strncpy(parent_dir, true_name, last_component - true_name + 1);
  	    parent_dir[last_component - true_name + 1] = 0;
  	    last_component++;   /*Skip the slash*/
! 	} else {
  	    /*
  	     * No slash appears in the given file name.  Set parent_dir to the current
  	     * directory, and the last component as the given name.
***************
*** 1459,1466 ****
  	}
  
  	if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
! 	    fprintf(stderr,"fs: you may not use '.' or '..' as the last component\n");
! 	    fprintf(stderr,"fs: of a name in the 'fs lsmount' command.\n");
  	    error = 1;
  	    continue;
  	}
--- 1704,1711 ----
  	}
  
  	if (strcmp(last_component, ".") == 0 || strcmp(last_component, "..") == 0) {
! 	    fprintf(stderr,"%s: you may not use '.' or '..' as the last component\n",pn);
! 	    fprintf(stderr,"%s: of a name in the 'fs lsmount' command.\n",pn);
  	    error = 1;
  	    continue;
  	}
***************
*** 1473,1501 ****
  
  	code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
  
! 	if (code == 0)
  	    printf("'%s' is a %smount point for volume '%s'\n",
  		   ti->data,
  		   (thru_symlink ? "symbolic link, leading to a " : ""),
  		   space);
  
! 	else {
! 	    error = 1;
! 	    if (errno == EINVAL)
! 		fprintf(stderr,"'%s' is not a mount point.\n",
! 		       ti->data);
! 	    else {
  		Die(errno, (ti->data ? ti->data : parent_dir));
  	    }
  	}
      }
      return error;
  }
  
! static MakeMountCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
!     register char *cellName, *volName, *tmpName;
  #ifdef WIN32
      char localCellName[1000];
  #else /* not WIN32 */
--- 1718,1746 ----
  
  	code = pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &blob, 1);
  
! 	if (code == 0) {
  	    printf("'%s' is a %smount point for volume '%s'\n",
  		   ti->data,
  		   (thru_symlink ? "symbolic link, leading to a " : ""),
  		   space);
  
! 	} else {
! 	    if (errno == EINVAL) {
! 		fprintf(stderr,"'%s' is not a mount point.\n", ti->data);
! 	    } else {
  		Die(errno, (ti->data ? ti->data : parent_dir));
  	    }
+ 	    error = 1;
  	}
      }
      return error;
  }
  
! static int
! MakeMountCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     char *cellName, *volName, *tmpName;
  #ifdef WIN32
      char localCellName[1000];
  #else /* not WIN32 */
***************
*** 1504,1546 ****
  #endif /* not WIN32 */
      struct ViceIoctl blob;
  
! /*
  
! defect #3069
  
      if (as->parms[5].items && !as->parms[2].items) {
! 	fprintf(stderr,"fs: must provide cell when creating cellular mount point.\n");
  	return 1;
      }
! */
  
      if (as->parms[2].items)	/* cell name specified */
  	cellName = as->parms[2].items->data;
      else
! 	cellName = (char *) 0;
      volName = as->parms[1].items->data;
  
      if (strlen(volName) >= 64) {
! 	fprintf(stderr,"fs: volume name too long (length must be < 64 characters)\n");
  	return 1;
      }
  
      /* Check for a cellname in the volume specification, and complain
       * if it doesn't match what was specified with -cell */
      if (tmpName = strchr(volName, ':')) {
!       *tmpName = '\0';
!       if (cellName) {
! 	if (foldcmp(cellName,volName)) {
! 	  fprintf(stderr,"fs: cellnames do not match.\n");
! 	  return 1;
! 	}
!       }
!       cellName = volName;
!       volName = ++tmpName;
      }
  
      if (!InAFS(Parent(as->parms[0].items->data))) {
! 	fprintf(stderr,"fs: mount points must be created within the AFS file system\n");
  	return 1;
      }
  
--- 1749,1791 ----
  #endif /* not WIN32 */
      struct ViceIoctl blob;
  
!     /*
  
!     defect #3069
  
      if (as->parms[5].items && !as->parms[2].items) {
! 	fprintf(stderr,"%s: must provide cell when creating cellular mount point.\n", pn);
  	return 1;
      }
!     */
  
      if (as->parms[2].items)	/* cell name specified */
  	cellName = as->parms[2].items->data;
      else
! 	cellName = NULL;
      volName = as->parms[1].items->data;
  
      if (strlen(volName) >= 64) {
! 	fprintf(stderr,"%s: volume name too long (length must be < 64 characters)\n", pn);
  	return 1;
      }
  
      /* Check for a cellname in the volume specification, and complain
       * if it doesn't match what was specified with -cell */
      if (tmpName = strchr(volName, ':')) {
!         *tmpName = '\0';
!         if (cellName) {
!             if (strcasecmp(cellName,volName)) {
!                 fprintf(stderr,"fs: cellnames do not match.\n");
!                 return 1;
!             }
!         }
!         cellName = volName;
!         volName = ++tmpName;
      }
  
      if (!InAFS(Parent(as->parms[0].items->data))) {
! 	fprintf(stderr,"%s: mount points must be created within the AFS file system\n", pn);
  	return 1;
      }
  
***************
*** 1568,1575 ****
  	  /* make the check.  Don't complain if there are problems with init */
  	  code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
  	  if (code == VL_NOENT) {
! 	      fprintf(stderr,"fs: warning, volume %s does not exist in cell %s.\n",
! 		      volName, cellName ? cellName : space);
  	  }
        }
      }
--- 1813,1820 ----
  	  /* make the check.  Don't complain if there are problems with init */
  	  code = ubik_Call(VL_GetEntryByNameO, uclient, 0, volName, &vldbEntry);
  	  if (code == VL_NOENT) {
! 	      fprintf(stderr,"%s: warning, volume %s does not exist in cell %s.\n",
! 		      pn, volName, cellName ? cellName : space);
  	  }
        }
      }
***************
*** 1615,1628 ****
   *	    (or ``.'' if none is provided)
   *      tp: Set to point to the actual name of the mount point to nuke.
   */
! static RemoveMountCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code=0;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      char tbuffer[1024];
      char lsbuffer[1024];
!     register char *tp;
      
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per file */
--- 1860,1874 ----
   *	    (or ``.'' if none is provided)
   *      tp: Set to point to the actual name of the mount point to nuke.
   */
! static int
! RemoveMountCmd(struct cmd_syndesc *as, char *arock) {
!     afs_int32 code=0;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      char tbuffer[1024];
      char lsbuffer[1024];
!     char *tp;
!     int error = 0;
      
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per file */
***************
*** 1633,1640 ****
  	    strncpy(tbuffer, ti->data, code=tp-ti->data+1);  /* the dir name */
              tbuffer[code] = 0;
  	    tp++;   /* skip the slash */
! 	}
! 	else {
  	    fs_ExtractDriveLetter(ti->data, tbuffer);
  	    strcat(tbuffer, ".");
  	    tp = ti->data;
--- 1879,1885 ----
  	    strncpy(tbuffer, ti->data, code=tp-ti->data+1);  /* the dir name */
              tbuffer[code] = 0;
  	    tp++;   /* skip the slash */
! 	} else {
  	    fs_ExtractDriveLetter(ti->data, tbuffer);
  	    strcat(tbuffer, ".");
  	    tp = ti->data;
***************
*** 1646,1656 ****
  	blob.out_size = sizeof(lsbuffer);
  	code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
  	if (code) {
! 	    if (errno == EINVAL)
! 		fprintf(stderr,"fs: '%s' is not a mount point.\n", ti->data);
! 	    else {
  		Die(errno, ti->data);
  	    }
  	    continue;	/* don't bother trying */
  	}
  	blob.out_size = 0;
--- 1891,1902 ----
  	blob.out_size = sizeof(lsbuffer);
  	code = pioctl(tbuffer, VIOC_AFS_STAT_MT_PT, &blob, 0);
  	if (code) {
! 	    if (errno == EINVAL) {
! 		fprintf(stderr,"%s: '%s' is not a mount point.\n", pn, ti->data);
!             } else {
  		Die(errno, ti->data);
  	    }
+             error = 1;
  	    continue;	/* don't bother trying */
  	}
  	blob.out_size = 0;
***************
*** 1659,1680 ****
  	code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
  	if (code) {
  	    Die(errno, ti->data);
  	}
- 
      }
!     return code;
  }
  
  /*
  */
  
! static CheckServersCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register afs_int32 j;
      afs_int32 temp;
!     register char *tp;
      struct afsconf_cell info;
      struct chservinfo checkserv;
  
--- 1905,1927 ----
  	code = pioctl(tbuffer, VIOC_AFS_DELETE_MT_PT, &blob, 0);
  	if (code) {
  	    Die(errno, ti->data);
+             error = 1;
  	}
      }
!     return error;
  }
  
  /*
  */
  
! static int
! CheckServersCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     afs_int32 j;
      afs_int32 temp;
!     char *tp;
      struct afsconf_cell info;
      struct chservinfo checkserv;
  
***************
*** 1688,1695 ****
  
      /* prepare flags for checkservers command */
      temp = 2;	/* default to checking local cell only */
!     if (as->parms[2].items) temp |= 1;	/* set fast flag */
!     if (as->parms[1].items) temp &= ~2;	/* turn off local cell check */
      
      checkserv.magic = 0x12345678;	/* XXX */
      checkserv.tflags=temp;
--- 1935,1944 ----
  
      /* prepare flags for checkservers command */
      temp = 2;	/* default to checking local cell only */
!     if (as->parms[2].items) 
!         temp |= 1;	/* set fast flag */
!     if (as->parms[1].items) 
!         temp &= ~2;	/* turn off local cell check */
      
      checkserv.magic = 0x12345678;	/* XXX */
      checkserv.tflags=temp;
***************
*** 1702,1730 ****
  	}
  	strcpy(checkserv.tbuffer,info.name);
  	checkserv.tsize=strlen(info.name)+1;
      }
- 	else
- 	{
- 		strcpy(checkserv.tbuffer,"\0");
- 		checkserv.tsize=0;
- 	}
  
! 	if(as->parms[3].items)
! 	{
! 		checkserv.tinterval=atol(as->parms[3].items->data);
  
! 		/* sanity check */
! 		if(checkserv.tinterval<0) {
! 		    printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
! 		    checkserv.tinterval=0;
! 		} else if(checkserv.tinterval> 600) {
! 		    printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
! 		    checkserv.tinterval=600;	/* 10 min max interval */
!         }
! 	}
! 	else {
          checkserv.tinterval = -1;	/* don't change current interval */
! 	}
  
      if ( checkserv.tinterval != 0 ) {
  #ifdef WIN32
--- 1951,1975 ----
  	}
  	strcpy(checkserv.tbuffer,info.name);
  	checkserv.tsize=strlen(info.name)+1;
+     } else {
+         strcpy(checkserv.tbuffer,"\0");
+         checkserv.tsize=0;
      }
  
!     if(as->parms[3].items) {
!         checkserv.tinterval=atol(as->parms[3].items->data);
  
!         /* sanity check */
!         if(checkserv.tinterval<0) {
!             printf("Warning: The negative -interval is ignored; treated as an inquiry\n");
!             checkserv.tinterval=0;
!         } else if(checkserv.tinterval> 600) {
!             printf("Warning: The maximum -interval value is 10 mins (600 secs)\n");
!             checkserv.tinterval=600;	/* 10 min max interval */
!         }       
!     } else {
          checkserv.tinterval = -1;	/* don't change current interval */
!     }
  
      if ( checkserv.tinterval != 0 ) {
  #ifdef WIN32
***************
*** 1747,1753 ****
  	    return code;
  	}
  	Die(errno, 0);
!         return code;
      }
      memcpy(&temp, space, sizeof(afs_int32));
      if (checkserv.tinterval >= 0) {
--- 1992,1998 ----
  	    return code;
  	}
  	Die(errno, 0);
!         return 1;
      }
      memcpy(&temp, space, sizeof(afs_int32));
      if (checkserv.tinterval >= 0) {
***************
*** 1760,1771 ****
      }
      if (temp == 0) {
  	printf("All servers are running.\n");
!     }
!     else {
  	printf("These servers unavailable due to network or server problems: ");
  	for(j=0; j < MAXHOSTS; j++) {
  	    memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
! 	    if (temp == 0) break;
  	    tp = hostutil_GetNameByINet(temp);
  	    printf(" %s", tp);
  	}
--- 2005,2016 ----
      }
      if (temp == 0) {
  	printf("All servers are running.\n");
!     } else {
  	printf("These servers unavailable due to network or server problems: ");
  	for(j=0; j < MAXHOSTS; j++) {
  	    memcpy(&temp, space + j*sizeof(afs_int32), sizeof(afs_int32));
! 	    if (temp == 0) 
!                 break;
  	    tp = hostutil_GetNameByINet(temp);
  	    printf(" %s", tp);
  	}
***************
*** 1775,1783 ****
      return code;
  }
  
! static GagCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code=0;
      struct ViceIoctl blob;
      struct gaginfo gagflags;
      struct cmd_item *show;
--- 2020,2029 ----
      return code;
  }
  
! static int
! MessagesCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code=0;
      struct ViceIoctl blob;
      struct gaginfo gagflags;
      struct cmd_item *show;
***************
*** 1789,1824 ****
      blob.out = space;
      memset(space, 0, sizeof(afs_int32));	/* so we assure zero when nothing is copied back */
  
!     if (show = as->parms[0].items)
!        if (!foldcmp (show->data, "user"))
!           gagflags.showflags |= GAGUSER;
!        else if (!foldcmp (show->data, "console"))
!           gagflags.showflags |= GAGCONSOLE;
!        else if (!foldcmp (show->data, "all"))
!           gagflags.showflags |= GAGCONSOLE | GAGUSER;
!        else if (!foldcmp (show->data, "none"))
!           /* do nothing */ ;
!        else {
! 	 fprintf(stderr, 
! 	  "unrecognized flag %s: must be in {user,console,all,none}\n", 
! 	  show->data);
! 	 code = EINVAL;
!        }
   
      if (code)
!       return code;
  
      code = pioctl(0, VIOC_GAG, &blob, 1);
      if (code) {
  	Die(errno, 0);
!         return code;
      }
!     return code;
  }
  
! static CheckVolumesCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      
      blob.in_size = 0;
--- 2035,2072 ----
      blob.out = space;
      memset(space, 0, sizeof(afs_int32));	/* so we assure zero when nothing is copied back */
  
!     if (show = as->parms[0].items) {
!         if (!strcasecmp (show->data, "user"))
!             gagflags.showflags |= GAGUSER;
!         else if (!strcasecmp (show->data, "console"))
!             gagflags.showflags |= GAGCONSOLE;
!         else if (!strcasecmp (show->data, "all"))
!             gagflags.showflags |= GAGCONSOLE | GAGUSER;
!         else if (!strcasecmp (show->data, "none"))
!             /* do nothing */ ;
!         else {
!             fprintf(stderr, 
!                      "unrecognized flag %s: must be in {user,console,all,none}\n", 
!                      show->data);
!             code = EINVAL;
!         }
!     }
   
      if (code)
!         return 1;
  
      code = pioctl(0, VIOC_GAG, &blob, 1);
      if (code) {
  	Die(errno, 0);
!         return 1;
      }
!     return 0;
  }
  
! static int
! CheckVolumesCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      
      blob.in_size = 0;
***************
*** 1828,1841 ****
  	Die(errno, 0);
  	return 1;
      }
!     else printf("All volumeID/name mappings checked.\n");
      
      return 0;
  }
  
! static SetCacheSizeCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      afs_int32 temp;
      
--- 2076,2090 ----
  	Die(errno, 0);
  	return 1;
      }
!     printf("All volumeID/name mappings checked.\n");
      
      return 0;
  }
  
! static int
! SetCacheSizeCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      afs_int32 temp;
      
***************
*** 1858,1910 ****
      if (as->parms[0].items) {
  	code = util_GetInt32(as->parms[0].items->data, &temp);
  	if (code) {
! 	    fprintf(stderr,"fs: bad integer specified for cache size.\n");
! 	    return code;
  	}
!     }
!     else
  	temp = 0;
      blob.in = (char *) &temp;
      blob.in_size = sizeof(afs_int32);
      blob.out_size = 0;
      code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
!     if (code)
  	Die(errno, (char *) 0);
!     else
! 	printf("New cache size set.\n");
      return 0;
  }
  
  #define MAXGCSIZE	16
! static GetCacheParmsCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      afs_int32 parms[MAXGCSIZE];
!     
!     blob.in = (char *) 0;
      blob.in_size = 0;
      blob.out_size = sizeof(parms);
      blob.out = (char *) parms;
      code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
!     if (code)
! 	Die(errno, (char *) 0);
!     else {
! 	printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
! 	       parms[1], parms[0]);
! 	if (parms[1] > parms[0])
! 	    printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
      }
      return 0;
  }
  
! static ListCellsCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      afs_int32 i, j, *lp, magic, size;
!     char *tcp, *tp;
!     afs_int32 clear, maxa = OMAXHOSTS;
      struct ViceIoctl blob;
      
      for(i=0;i<1000;i++) {
  	tp = space;
--- 2107,2167 ----
      if (as->parms[0].items) {
  	code = util_GetInt32(as->parms[0].items->data, &temp);
  	if (code) {
! 	    fprintf(stderr,"%s: bad integer specified for cache size.\n", pn);
! 	    return 1;
  	}
!     } else
  	temp = 0;
      blob.in = (char *) &temp;
      blob.in_size = sizeof(afs_int32);
      blob.out_size = 0;
      code = pioctl(0, VIOCSETCACHESIZE, &blob, 1);
!     if (code) {
  	Die(errno, (char *) 0);
!         return 1;
!     } 
!       
!     printf("New cache size set.\n");
      return 0;
  }
  
  #define MAXGCSIZE	16
! static int
! GetCacheParmsCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      afs_int32 parms[MAXGCSIZE];
! 
!     memset(parms, 0, sizeof(parms));
!     blob.in = NULL;
      blob.in_size = 0;
      blob.out_size = sizeof(parms);
      blob.out = (char *) parms;
      code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1);
!     if (code) {
! 	Die(errno, NULL);
!         return 1;
      }
+      
+     printf("AFS using %d of the cache's available %d 1K byte blocks.\n",
+            parms[1], parms[0]);
+     if (parms[1] > parms[0])
+         printf("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n");
      return 0;
  }
  
! static int
! ListCellsCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      afs_int32 i, j, *lp, magic, size;
!     char *tp;
!     afs_int32 addr, maxa = OMAXHOSTS;
      struct ViceIoctl blob;
+     int resolve;
+ 
+     resolve = !(as->parms[0].items);    /* -numeric */
      
      for(i=0;i<1000;i++) {
  	tp = space;
***************
*** 1919,1930 ****
  	blob.out = space;
  	code = pioctl(0, VIOCGETCELL, &blob, 1);
  	if (code < 0) {
! 	    if (errno == EDOM) break;	/* done with the list */
! 	    else {
! 		Die(errno, 0);
! 		return 1;
! 	    }
! 	}
  	tp = space;
  	memcpy(&magic, tp, sizeof(afs_int32));	
  	if (magic == 0x12345678) {
--- 2176,2186 ----
  	blob.out = space;
  	code = pioctl(0, VIOCGETCELL, &blob, 1);
  	if (code < 0) {
! 	    if (errno == EDOM) 
!                 break;	/* done with the list */
!             Die(errno, 0);
!             return 1;
! 	}       
  	tp = space;
  	memcpy(&magic, tp, sizeof(afs_int32));	
  	if (magic == 0x12345678) {
***************
*** 1933,1970 ****
  	}
  	printf("Cell %s on hosts", tp+maxa*sizeof(afs_int32));
  	for(j=0; j < maxa; j++) {
! 	    memcpy(&clear, tp + j*sizeof(afs_int32), sizeof(afs_int32));
! 	    if (clear == 0) break;
! 	    tcp = hostutil_GetNameByINet(clear);
! 	    printf(" %s", tcp);
  	}
  	printf(".\n");
      }
      return 0;
  }
  
- static NewCellCmd(as)
- register struct cmd_syndesc *as; {
  #ifndef WIN32
!     register afs_int32 code, linkedstate=0, size=0, *lp;
      struct ViceIoctl blob;
-     register struct cmd_item *ti;
-     register char *tp, *cellname=0;
-     register struct hostent *thp;
-     afs_int32 fsport = 0, vlport = 0;
  
! #ifdef WIN32
!     if ( !IsAdmin() ) {
!         fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
!         return EACCES;
      }
! #else /* WIN32 */
!     if (geteuid()) {
!         fprintf (stderr,"Permission denied: requires root access.\n");
!         return EACCES;
      }
  #endif /* WIN32 */
  
      memset(space, 0, MAXHOSTS * sizeof(afs_int32));
      tp = space;
      lp = (afs_int32 *)tp;
--- 2189,2297 ----
  	}
  	printf("Cell %s on hosts", tp+maxa*sizeof(afs_int32));
  	for(j=0; j < maxa; j++) {
!             char *name, tbuffer[20];
! 
! 	    memcpy(&addr, tp + j*sizeof(afs_int32), sizeof(afs_int32));
! 	    if (addr == 0) 
!                 break;
! 
!             if (resolve) {
!                 name = hostutil_GetNameByINet(addr);
!             } else {
!                 addr = ntohl(addr);
!                 sprintf(tbuffer, "%d.%d.%d.%d", (addr >> 24) & 0xff,
!                          (addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
!                 name = tbuffer;
!             }
! 	    printf(" %s", name);
  	}
  	printf(".\n");
      }
      return 0;
  }
  
  #ifndef WIN32
! static int
! ListAliasesCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code, i;
!     char *tp, *aliasName, *realName;
      struct ViceIoctl blob;
  
!     for (i = 0;; i++) {
! 	tp = space;
! 	memcpy(tp, &i, sizeof(afs_int32));
! 	blob.out_size = MAXSIZE;
! 	blob.in_size = sizeof(afs_int32);
! 	blob.in = space;
! 	blob.out = space;
! 	code = pioctl(0, VIOC_GETALIAS, &blob, 1);
! 	if (code < 0) {
! 	    if (errno == EDOM)
! 		break;		/* done with the list */
! 	    Die(errno, 0);
! 	    return 1;
! 	}
! 	tp = space;
! 	aliasName = tp;
! 	tp += strlen(aliasName) + 1;
! 	realName = tp;
! 	printf("Alias %s for cell %s\n", aliasName, realName);
      }
!     return 0;
! }
! 
! static int
! CallBackRxConnCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     struct ViceIoctl blob;
!     struct cmd_item *ti;
!     afs_int32 hostAddr;
!     struct hostent *thp;
!     char *tp;
!     int setp;
!     
!     ti = as->parms[0].items;
!     setp = 1;
!     if (ti) {
!         thp = hostutil_GetHostByName(ti->data);
! 	if (!thp) {
! 	    fprintf(stderr, "host %s not found in host table.\n", ti->data);
! 	    return 1;
! 	}
! 	else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
!     } else {
!         hostAddr = 0;   /* means don't set host */
! 	setp = 0;       /* aren't setting host */
!     }
!     
!     /* now do operation */
!     blob.in_size = sizeof(afs_int32);
!     blob.out_size = sizeof(afs_int32);
!     blob.in = (char *) &hostAddr;
!     blob.out = (char *) &hostAddr;
!     
!     code = pioctl(0, VIOC_CBADDR, &blob, 1);
!     if (code < 0) {
! 	Die(errno, 0);
! 	return 1;
      }
+     return 0;
+ }
  #endif /* WIN32 */
  
+ static int
+ NewCellCmd(struct cmd_syndesc *as, char *arock)
+ {
+ #ifndef WIN32
+     afs_int32 code, linkedstate=0, size=0, *lp;
+     struct ViceIoctl blob;
+     struct cmd_item *ti;
+     char *tp, *cellname=0;
+     struct hostent *thp;
+     afs_int32 fsport = 0, vlport = 0;
+ 
      memset(space, 0, MAXHOSTS * sizeof(afs_int32));
      tp = space;
      lp = (afs_int32 *)tp;
***************
*** 2025,2033 ****
  	Die(errno, 0);
      return 0;
  #else /* WIN32 */
!     register afs_int32 code;
      struct ViceIoctl blob;
      
      blob.in_size = 0;
      blob.in = (char *) 0;
      blob.out_size = MAXSIZE;
--- 2352,2365 ----
  	Die(errno, 0);
      return 0;
  #else /* WIN32 */
!     afs_int32 code;
      struct ViceIoctl blob;
      
+     if ( !IsAdmin() ) {
+         fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
+         return EACCES;
+     }
+ 
      blob.in_size = 0;
      blob.in = (char *) 0;
      blob.out_size = MAXSIZE;
***************
*** 2036,2065 ****
      code = pioctl((char *) 0, VIOCNEWCELL, &blob, 1);
  
      if (code) {
!        Die(errno, (char *) 0);
      }
!     else
!        printf("Cell servers information refreshed\n");
      return 0;
  #endif /* WIN32 */
  }
  
! static WhichCellCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
!     int error;
      
-     error = 0;	/* no error occurred */
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
! 	/* once per file */
! 	blob.in_size = 0;
! 	blob.out_size = MAXSIZE;
! 	blob.out = space;
! 
! 	code = pioctl(ti->data, VIOC_FILE_CELL_NAME, &blob, 1);
  	if (code) {
  	    if (errno == ENOENT)
  		fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
--- 2368,2430 ----
      code = pioctl((char *) 0, VIOCNEWCELL, &blob, 1);
  
      if (code) {
!         Die(errno, (char *) 0);
!         return 1;
      }
!     
!     printf("Cell servers information refreshed\n");
      return 0;
  #endif /* WIN32 */
  }
  
! #ifndef WIN32
! static int
! NewAliasCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     char *tp;
!     char *aliasName, *realName;
! 
!     /* Setup and do the NEWALIAS pioctl call */
!     aliasName = as->parms[0].items->data;
!     realName = as->parms[1].items->data;
!     tp = space;
!     strcpy(tp, aliasName);
!     tp += strlen(aliasName) + 1;
!     strcpy(tp, realName);
!     tp += strlen(realName) + 1;
! 
!     blob.in_size = tp - space;
!     blob.in = space;
!     blob.out_size = 0;
!     blob.out = space;
!     code = pioctl(0, VIOC_NEWALIAS, &blob, 1);
!     if (code < 0) {
! 	if (errno == EEXIST) {
! 	    fprintf(stderr,
! 		    "%s: cell name `%s' in use by an existing cell.\n", pn,
! 		    aliasName);
! 	} else {
! 	    Die(errno, 0);
! 	}
! 	return 1;
!     }
!     return 0;
! }
! #endif /* WIN32 */
! 
! static int
! WhichCellCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     struct cmd_item *ti;
!     int error = 0;
!     char cell[MAXCELLCHARS]="";
      
      SetDotDefault(&as->parms[0].items);
      for(ti=as->parms[0].items; ti; ti=ti->next) {
!         code = GetCell(ti->data, cell);
  	if (code) {
  	    if (errno == ENOENT)
  		fprintf(stderr,"%s: no such cell as '%s'\n", pn, ti->data);
***************
*** 2068,2114 ****
  	    error = 1;
  	    continue;
  	}
! 	else
! 	    printf("File %s lives in cell '%s'\n", ti->data, space);
      }
      return error;
  }
  
! static WSCellCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      
      blob.in_size = 0;
!     blob.in = (char *) 0;
      blob.out_size = MAXSIZE;
      blob.out = space;
  
!     code = pioctl((char *) 0, VIOC_GET_WS_CELL, &blob, 1);
  
      if (code) {
! 	Die(errno, (char *) 0);
      }
!     else
! 	printf("This workstation belongs to cell '%s'\n", space);
      return 0;
  }
  
- static PrimaryCellCmd(as)
- register struct cmd_syndesc *as; {
  /*
      fprintf(stderr,"This command is obsolete, as is the concept of a primary token.\n");
- */
      return 0;
  }
  
! static MonitorCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
      afs_int32 hostAddr;
!     register struct hostent *thp;
      char *tp;
      int setp;
      
--- 2433,2482 ----
  	    error = 1;
  	    continue;
  	}
!         printf("File %s lives in cell '%s'\n", ti->data, cell);
      }
      return error;
  }
  
! static int
! WSCellCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      
      blob.in_size = 0;
!     blob.in = NULL;
      blob.out_size = MAXSIZE;
      blob.out = space;
  
!     code = pioctl(NULL, VIOC_GET_WS_CELL, &blob, 1);
  
      if (code) {
! 	Die(errno, NULL);
!         return 1;
      }
! 
!     printf("This workstation belongs to cell '%s'\n", space);
      return 0;
  }
  
  /*
+ static int
+ PrimaryCellCmd(struct cmd_syndesc *as, char *arock)
+ {
      fprintf(stderr,"This command is obsolete, as is the concept of a primary token.\n");
      return 0;
  }
+ */
  
! static int
! MonitorCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
      afs_int32 hostAddr;
!     struct hostent *thp;
      char *tp;
      int setp;
      
***************
*** 2116,2139 ****
      setp = 1;
      if (ti) {
  	/* set the host */
! 	if (!strcmp(ti->data, "off"))
  	    hostAddr = 0xffffffff;
! 	else {
  	    thp = hostutil_GetHostByName(ti->data);
  	    if (!thp) {
  		if (!strcmp(ti->data, "localhost")) {
  		    fprintf(stderr,"localhost not in host table, assuming 127.0.0.1\n");
  		    hostAddr = htonl(0x7f000001);
! 		}
! 		else {
  		    fprintf(stderr,"host %s not found in host table.\n", ti->data);
  		    return 1;
  		}
! 	    }
! 	    else memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
  	}
!     }
!     else {
  	hostAddr = 0;	/* means don't set host */
  	setp = 0;	/* aren't setting host */
      }
--- 2484,2506 ----
      setp = 1;
      if (ti) {
  	/* set the host */
! 	if (!strcmp(ti->data, "off")) {
  	    hostAddr = 0xffffffff;
! 	} else {
  	    thp = hostutil_GetHostByName(ti->data);
  	    if (!thp) {
  		if (!strcmp(ti->data, "localhost")) {
  		    fprintf(stderr,"localhost not in host table, assuming 127.0.0.1\n");
  		    hostAddr = htonl(0x7f000001);
! 		} else {
  		    fprintf(stderr,"host %s not found in host table.\n", ti->data);
  		    return 1;
  		}
! 	    } else {
!                 memcpy(&hostAddr, thp->h_addr, sizeof(afs_int32));
!             }
  	}
!     } else {
  	hostAddr = 0;	/* means don't set host */
  	setp = 0;	/* aren't setting host */
      }
***************
*** 2146,2162 ****
      code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
      if (code) {
  	Die(errno, 0);
! 	exit(1);
      }
      if (setp) {
  	printf("%s: new monitor host set.\n", pn);
!     }
!     else {
  	/* now decode old address */
  	if (hostAddr == 0xffffffff) {
  	    printf("Cache monitoring is currently disabled.\n");
! 	}
! 	else {
  	    tp = hostutil_GetNameByINet(hostAddr);
  	    printf("Using host %s for monitor services.\n", tp);
  	}
--- 2513,2527 ----
      code = pioctl(0, VIOC_AFS_MARINER_HOST, &blob, 1);
      if (code) {
  	Die(errno, 0);
! 	return 1;
      }
      if (setp) {
  	printf("%s: new monitor host set.\n", pn);
!     } else {
  	/* now decode old address */
  	if (hostAddr == 0xffffffff) {
  	    printf("Cache monitoring is currently disabled.\n");
! 	} else {
  	    tp = hostutil_GetNameByINet(hostAddr);
  	    printf("Using host %s for monitor services.\n", tp);
  	}
***************
*** 2164,2172 ****
      return 0;
  }
  
! static SysNameCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      struct cmd_item *ti;
      char *input = space;
--- 2529,2538 ----
      return 0;
  }
  
! static int
! SysNameCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      struct cmd_item *ti;
      char *input = space;
***************
*** 2212,2218 ****
          return 1;
      }    
      if (setp) {
!         printf("%s: new sysname%s set.\n", pn, setp > 1 ? "s" : "");
          return 0;
      }
  
--- 2578,2584 ----
          return 1;
      }    
      if (setp) {
!         printf("%s: new sysname%s set.\n", pn, setp > 1 ? " list" : "");
          return 0;
      }
  
***************
*** 2224,2230 ****
          return 1;
      } 
      
!     printf("Current sysname%s", setp > 1 ? "s are" : " is");
      for (; setp > 0; --setp ) {
          printf(" \'%s\'", input);
          input += strlen(input) + 1;
--- 2590,2596 ----
          return 1;
      } 
      
!     printf("Current sysname%s is", setp > 1 ? " list" : "");
      for (; setp > 0; --setp ) {
          printf(" \'%s\'", input);
          input += strlen(input) + 1;
***************
*** 2233,2245 ****
      return 0;
  }
  
! char *exported_types[] = {"null", "nfs", ""};
! static ExportAfsCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
!     register struct cmd_item *ti;
!     int export=0, type=0, mode = 0, exp = 0, gstat = 0, exportcall, pwsync=0, smounts=0;
      
  #ifdef WIN32
      if ( !IsAdmin() ) {
--- 2599,2612 ----
      return 0;
  }
  
! static char *exported_types[] = {"null", "nfs", ""};
! static int ExportAfsCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
!     int export = 0, type = 0, mode = 0, exp = 0, gstat = 0;
!     int exportcall, pwsync = 0, smounts = 0;
      
  #ifdef WIN32
      if ( !IsAdmin() ) {
***************
*** 2254,2295 ****
  #endif /* WIN32 */
  
      ti = as->parms[0].items;
!     if (strcmp(ti->data, "nfs")	== 0) type = 0x71; /* NFS */
      else {
! 	fprintf(stderr,"Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
  	return 1;
      }
      ti = as->parms[1].items;
      if (ti) {
! 	if (strcmp(ti->data, "on") == 0) export = 3;
! 	else if (strcmp(ti->data, "off") == 0) export = 2;
  	else {
! 	    printf("Illegal argument %s\n", ti->data);
  	    return 1;
  	}
  	exp = 1;
      }
      if (ti = as->parms[2].items) {	/* -noconvert */
! 	if (strcmp(ti->data, "on") == 0) mode = 2;
! 	else if (strcmp(ti->data, "off") == 0) mode = 3;
  	else {
! 	    printf("Illegal argument %s\n", ti->data);
  	    return 1;
  	}
      }
      if (ti = as->parms[3].items) {	/* -uidcheck */
! 	if (strcmp(ti->data, "on") == 0) pwsync = 3;
! 	else if (strcmp(ti->data, "off") == 0) pwsync = 2;
  	else {
! 	    printf("Illegal argument %s\n", ti->data);
  	    return 1;
  	}
      }
      if (ti = as->parms[4].items) {	/* -submounts */
! 	if (strcmp(ti->data, "on") == 0) smounts = 3;
! 	else if (strcmp(ti->data, "off") == 0) smounts = 2;
  	else {
! 	    printf("Illegal argument %s\n", ti->data);
  	    return 1;
  	}
      }
--- 2621,2672 ----
  #endif /* WIN32 */
  
      ti = as->parms[0].items;
!     if (strcmp(ti->data, "nfs")	== 0) 
!         type = 0x71; /* NFS */
      else {
! 	fprintf(stderr,
!                 "Invalid exporter type, '%s', Only the 'nfs' exporter is currently supported\n", ti->data);
  	return 1;
      }
      ti = as->parms[1].items;
      if (ti) {
! 	if (strcmp(ti->data, "on") == 0) 
!             export = 3;
! 	else if (strcmp(ti->data, "off") == 0) 
!             export = 2;
  	else {
! 	    fprintf(stderr, "Illegal argument %s\n", ti->data);
  	    return 1;
  	}
  	exp = 1;
      }
      if (ti = as->parms[2].items) {	/* -noconvert */
! 	if (strcmp(ti->data, "on") == 0) 
!             mode = 2;
! 	else if (strcmp(ti->data, "off") == 0) 
!             mode = 3;
  	else {
! 	    fprintf(stderr, "Illegal argument %s\n", ti->data);
  	    return 1;
  	}
      }
      if (ti = as->parms[3].items) {	/* -uidcheck */
! 	if (strcmp(ti->data, "on") == 0) 
!             pwsync = 3;
! 	else if (strcmp(ti->data, "off") == 0) 
!             pwsync = 2;
  	else {
! 	    fprintf(stderr, "Illegal argument %s\n", ti->data);
  	    return 1;
  	}
      }
      if (ti = as->parms[4].items) {	/* -submounts */
! 	if (strcmp(ti->data, "on") == 0) 
!             smounts = 3;
! 	else if (strcmp(ti->data, "off") == 0) 
!             smounts = 2;
  	else {
! 	    fprintf(stderr, "Illegal argument %s\n", ti->data);
  	    return 1;
  	}
      }
***************
*** 2303,2313 ****
      code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
      if (code) {
  	if (errno == ENODEV) {
! 	    fprintf(stderr,"Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
  	} else {
  	    Die(errno, 0);
- 	    exit(1);
  	}
      } else {
  	if (!gstat) {
  	    if (exportcall & 1) {
--- 2680,2691 ----
      code = pioctl(0, VIOC_EXPORTAFS, &blob, 1);
      if (code) {
  	if (errno == ENODEV) {
! 	    fprintf(stderr,
!                     "Sorry, the %s-exporter type is currently not supported on this AFS client\n", exported_types[type]);
  	} else {
  	    Die(errno, 0);
  	}
+         return 1;
      } else {
  	if (!gstat) {
  	    if (exportcall & 1) {
***************
*** 2320,2346 ****
  	    }
  	}
      }
!     return(0);
  }
  
  
! static GetCellCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      struct afsconf_cell info;
!     register struct cmd_item *ti;
      struct a {
  	afs_int32 stat;
  	afs_int32 junk;
      } args;
!     
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per cell */
  	blob.out_size = sizeof(args);
  	blob.out = (caddr_t) &args;
  	code = GetCellName(ti->data, &info);
  	if (code) {
  	    continue;
  	}
  	blob.in_size = 1+strlen(info.name);
--- 2698,2728 ----
  	    }
  	}
      }
!     return 0;
  }
  
  
! static int
! GetCellCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      struct afsconf_cell info;
!     struct cmd_item *ti;
      struct a {
  	afs_int32 stat;
  	afs_int32 junk;
      } args;
!     int error = 0;
! 
!     memset(&args, 0, sizeof(args));      /* avoid Purify UMR error */
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per cell */
  	blob.out_size = sizeof(args);
  	blob.out = (caddr_t) &args;
  	code = GetCellName(ti->data, &info);
  	if (code) {
+             error = 1;
  	    continue;
  	}
  	blob.in_size = 1+strlen(info.name);
***************
*** 2348,2381 ****
  	code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
  	if (code) {
  	    if (errno == ENOENT)
! 		fprintf(stderr,"fs: the cell named '%s' does not exist\n", info.name);
  	    else
  		Die(errno, info.name);
! 	    return 1;
  	}
  	printf("Cell %s status: ", info.name);
  #ifdef notdef
! 	if (args.stat & 1) printf("primary ");
  #endif
! 	if (args.stat & 2) printf("no setuid allowed");
! 	else printf("setuid allowed");
! 	if (args.stat & 4) printf(", using old VLDB");
  	printf("\n");
      }
!     return 0;
  }
  
! static SetCellCmd(as)
! register struct cmd_syndesc *as; {
!     register afs_int32 code;
      struct ViceIoctl blob;
      struct afsconf_cell info;
!     register struct cmd_item *ti;
      struct a {
  	afs_int32 stat;
  	afs_int32 junk;
  	char cname[64];
      } args;
  
      /* figure stuff to set */
      args.stat = 0;
--- 2730,2775 ----
  	code = pioctl(0, VIOC_GETCELLSTATUS, &blob, 1);
  	if (code) {
  	    if (errno == ENOENT)
! 		fprintf(stderr,"%s: the cell named '%s' does not exist\n", pn, info.name);
  	    else
  		Die(errno, info.name);
! 	    error = 1;
!             continue;
  	}
  	printf("Cell %s status: ", info.name);
  #ifdef notdef
! 	if (args.stat & 1) 
!             printf("primary ");
  #endif
! 	if (args.stat & 2) 
!             printf("no setuid allowed");
! 	else 
!             printf("setuid allowed");
! 	if (args.stat & 4) 
!             printf(", using old VLDB");
  	printf("\n");
      }
!     return error;
  }
  
! static int SetCellCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
      struct ViceIoctl blob;
      struct afsconf_cell info;
!     struct cmd_item *ti;
      struct a {
  	afs_int32 stat;
  	afs_int32 junk;
  	char cname[64];
      } args;
+     int error = 0;
+ 
+     /* Check arguments. */
+     if (as->parms[1].items && as->parms[2].items) {
+         fprintf(stderr, "Cannot specify both -suid and -nosuid.\n");
+         return 1;
+     }
  
      /* figure stuff to set */
      args.stat = 0;
***************
*** 2393,2405 ****
      }
  #endif /* WIN32 */
  
!     if (! as->parms[1].items) args.stat |= CM_SETCELLFLAG_SUID; /* default to -nosuid */
  
      /* set stat for all listed cells */
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per cell */
  	code = GetCellName(ti->data, &info);
  	if (code) {
  	    continue;
  	}
  	strcpy(args.cname, info.name);
--- 2787,2801 ----
      }
  #endif /* WIN32 */
  
!     if (! as->parms[1].items) 
!         args.stat |= CM_SETCELLFLAG_SUID; /* default to -nosuid */
  
      /* set stat for all listed cells */
      for(ti=as->parms[0].items; ti; ti=ti->next) {
  	/* once per cell */
  	code = GetCellName(ti->data, &info);
  	if (code) {
+             error = 1;
  	    continue;
  	}
  	strcpy(args.cname, info.name);
***************
*** 2409,2451 ****
  	blob.out = (caddr_t) 0;
  	code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
  	if (code) {
! 	    Die(errno, 0);
! 	    exit(1);
  	}
      }
!     return 0;
  }
  
  #ifdef WIN32
! static GetCellName(char *cellNamep, struct afsconf_cell *infop)
  {
! 	strcpy(infop->name, cellNamep);
!         return 0;
  }
  
! static VLDBInit(int noAuthFlag, struct afsconf_cell *infop)
  {
! 	return 0;
  }
- 
  #else /* not WIN32 */
! 
! static GetCellName(cellName, info)
! char *cellName;
! struct afsconf_cell *info;
  {
      struct afsconf_dir *tdir;
!     register int code;
  
!     tdir = afsconf_Open(AFSCONF_CLIENTNAME);
      if (!tdir) {
! 	fprintf(stderr,"Could not process files in configuration directory (%s).\n",AFSCONF_CLIENTNAME);
  	return -1;
      }
  
      code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
      if (code) {
! 	fprintf(stderr,"fs: cell %s not in %s/CellServDB\n", cellName, AFSCONF_CLIENTNAME);
  	return code;
      }
  
--- 2805,2849 ----
  	blob.out = (caddr_t) 0;
  	code = pioctl(0, VIOC_SETCELLSTATUS, &blob, 1);
  	if (code) {
! 	    Die(errno, info.name);      /* XXX added cell name to Die() call */
!             error = 1;
  	}
      }
!     return error;
  }
  
  #ifdef WIN32
! static int
! GetCellName(char *cellNamep, struct afsconf_cell *infop)
  {
!     strcpy(infop->name, cellNamep);
!     return 0;
  }
  
! static int
! VLDBInit(int noAuthFlag, struct afsconf_cell *infop)
  {
!     return 0;
  }
  #else /* not WIN32 */
! static int
! GetCellName(char *cellName, struct afsconf_cell *info)
  {
      struct afsconf_dir *tdir;
!     int code;
  
!     tdir = afsconf_Open(AFSDIR_CLIENT_ETC_CLIENTNAME);
      if (!tdir) {
! 	fprintf(stderr,
!                 "Could not process files in configuration directory (%s).\n",
!                  AFSDIR_CLIENT_ETC_CLIENTNAME);
  	return -1;
      }
  
      code = afsconf_GetCellInfo(tdir, cellName, AFSCONF_VLDBSERVICE, info);
      if (code) {
! 	fprintf(stderr,"fs: cell %s not in %s/CellServDB\n", cellName, 
!                 AFSDIR_CLIENT_ETC_CLIENTNAME);
  	return code;
      }
  
***************
*** 2453,2534 ****
  }
  
  
! static VLDBInit(noAuthFlag,  info)
! int noAuthFlag;
! struct afsconf_cell *info;
! {   afs_int32 code;
!     struct ktc_principal sname;
!     struct ktc_token ttoken;
!     afs_int32 scIndex;
!     struct rx_securityClass *sc;
!     struct rx_connection *serverconns[VLDB_MAXSERVERS];
!     afs_int32 i;
  
!     code = rx_Init(0);
!     if (code) {
! 	fprintf(stderr,"fs: could not initialize rx.\n");
! 	return code;
!     }
      rxInitDone = 1;
!     rx_SetRxDeadTime(50);
!     if (!noAuthFlag) {   /* we don't need tickets for null */
! 	strcpy(sname.cell, info->name);
! 	sname.instance[0] = 0;
! 	strcpy(sname.name, "afs");
! 	code = ktc_GetToken(&sname,&ttoken, sizeof(ttoken), (char *)0);
! 	if (code) {
! 	    fprintf(stderr,"fs: Could not get afs tokens, running unauthenticated.\n");
! 	    scIndex = 0;
! 	}
! 	else {
! 	    /* got a ticket */
! 	    if (ttoken.kvno >= 0 && ttoken.kvno	<= 256)	scIndex	= 2;	/* kerberos */
! 	    else {
! 		fprintf (stderr, "fs: funny kvno (%d) in ticket, proceeding\n",
! 			 ttoken.kvno);
! 		scIndex = 2;
! 	    }
! 	}
!     }
!     else scIndex = 0;	    /* don't authenticate */
!     switch (scIndex) {
! 	case 0 :
! 	    sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
! 	    break;
! 	
! 	case 1 :
! 	    break;
! 	case 2:
! 	    sc = (struct rx_securityClass *)
! 		rxkad_NewClientSecurityObject(rxkad_clear, &ttoken.sessionKey,
! 					      ttoken.kvno, ttoken.ticketLen,
! 					      ttoken.ticket);
! 	    break;
!     }
!     if (info->numServers > VLDB_MAXSERVERS) {
! 	fprintf(stderr, "fs: info.numServers=%d (> VLDB_MAXSERVERS=%d)\n",
! 		info->numServers, VLDB_MAXSERVERS);
! 	exit(1);
!     }
!     memset(serverconns, 0, sizeof(serverconns));
!     for (i = 0;i<info->numServers;i++) 
! 	serverconns[i] = rx_NewConnection(info->hostAddr[i].sin_addr.s_addr,
! 					  info->hostAddr[i].sin_port, USER_SERVICE_ID,
! 					  sc, scIndex);
! 
!     if (sc)
!         rxs_Release(sc);    /* Decrement the initial refCount */
!     code = ubik_ClientInit(serverconns, &uclient);
! 
!     if (code) {
! 	fprintf(stderr,"fs: ubik client init failed.\n");
! 	return code;
!     }
!     return 0;
  }
  #endif /* not WIN32 */
  
! static    struct ViceIoctl gblob;
  static int debug = 0;
  /* 
   * here follow some routines in suport of the setserverprefs and
--- 2851,2872 ----
  }
  
  
! static int
! VLDBInit(int noAuthFlag, struct afsconf_cell *info)
! {
!     afs_int32 code;
  
!     code = ugen_ClientInit(noAuthFlag, AFSDIR_CLIENT_ETC_DIRPATH, 
! 			   info->name, 0, &uclient, 
!                            NULL, pn, rxkad_clear,
!                            VLDB_MAXSERVERS, AFSCONF_VLDBSERVICE, 50,
!                            0, 0, USER_SERVICE_ID);
      rxInitDone = 1;
!     return code;
  }
  #endif /* not WIN32 */
  
! static struct ViceIoctl gblob;
  static int debug = 0;
  /* 
   * here follow some routines in suport of the setserverprefs and
***************
*** 2541,2550 ****
   * GetPrefCmd  reads the Cache Manager's current list of server ranks
   */
  
! static pokeServers()
  {
! int code;
! 
      cm_SSetPref_t *ssp;
      code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
  
--- 2879,2889 ----
   * GetPrefCmd  reads the Cache Manager's current list of server ranks
   */
  
! #ifdef WIN32
! static int 
! pokeServers(void)
  {
!     int code;
      cm_SSetPref_t *ssp;
      code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
  
***************
*** 2553,2567 ****
      gblob.in = space;
      return code;
  }
  
! static addServer(name, rank)
! 	char *name;
! 	unsigned short rank;
  {  
! 	int code;
! 	cm_SSetPref_t *ssp;
! 	cm_SPref_t *sp;
! 	struct hostent *thostent;
  
  #ifndef MAXUSHORT
  #ifdef MAXSHORT
--- 2892,2935 ----
      gblob.in = space;
      return code;
  }
+ #else
+ /*
+  * returns -1 if error message printed,
+  * 0 on success,
+  * errno value if error and no error message printed
+  */
+ static int
+ pokeServers(void)
+ {
+     int code;
+ 
+     code = pioctl(0, VIOC_SETSPREFS, &gblob, 1);
+     if (code && (errno == EINVAL)) {
+ 	struct setspref *ssp;
+ 	ssp = (struct setspref *)gblob.in;
+ 	if (!(ssp->flags & DBservers)) {
+ 	    gblob.in = (void *)&(ssp->servers[0]);
+ 	    gblob.in_size -= ((char *)&(ssp->servers[0])) - (char *)ssp;
+ 	    code = pioctl(0, VIOC_SETSPREFS33, &gblob, 1);
+ 	    return code ? errno : 0;
+ 	}
+ 	fprintf(stderr,
+ 		"This cache manager does not support VL server preferences.\n");
+ 	return -1;
+     }
+ 
+     return code ? errno : 0;
+ }
+ #endif /* WIN32 */
  
! #ifdef WIN32
! static int
! addServer(char *name, unsigned short rank)
  {  
!     int code;
!     cm_SSetPref_t *ssp;
!     cm_SPref_t *sp;
!     struct hostent *thostent;
  
  #ifndef MAXUSHORT
  #ifdef MAXSHORT
***************
*** 2571,2604 ****
  #endif
  #endif
  
! 	code = 0;
! 	thostent = hostutil_GetHostByName(name);
! 	if (!thostent) {
! 		fprintf (stderr, "%s: couldn't resolve name.\n", name);
! 		return EINVAL;
! 	}
  
! 	ssp = (cm_SSetPref_t *)(gblob.in);
  
! 	if (gblob.in_size > MAXINSIZE - sizeof(cm_SPref_t)) {
! 		code = pokeServers();
! 		ssp->num_servers = 0;
! 	}
  
! 	sp = (cm_SPref_t *)((char*)gblob.in + gblob.in_size);
! 	memcpy (&(sp->host.s_addr), thostent->h_addr, sizeof(afs_uint32));
! 	sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
! 	gblob.in_size += sizeof(cm_SPref_t);
! 	ssp->num_servers++;
  
! 	if (debug) fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",name,sp->rank,sp->host.s_addr);
! 	
! 	return code;
! }
  
! static BOOL IsWindowsNT (void)
  {
!     static BOOL fChecked = FALSE;
      static BOOL fIsWinNT = FALSE;
  
      if (!fChecked)
--- 2939,3028 ----
  #endif
  #endif
  
!     code = 0;
!     thostent = hostutil_GetHostByName(name);
!     if (!thostent) {
!         fprintf (stderr, "%s: couldn't resolve name.\n", name);
!         return EINVAL;
!     }
  
!     ssp = (cm_SSetPref_t *)(gblob.in);
  
!     if (gblob.in_size > MAXINSIZE - sizeof(cm_SPref_t)) {
!         code = pokeServers();
!         ssp->num_servers = 0;
!     }
  
!     sp = (cm_SPref_t *)((char*)gblob.in + gblob.in_size);
!     memcpy (&(sp->host.s_addr), thostent->h_addr, sizeof(afs_uint32));
!     sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
!     gblob.in_size += sizeof(cm_SPref_t);
!     ssp->num_servers++;
  
!     if (debug) fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",name,sp->rank,sp->host.s_addr);
  
!     return code;
! }
! #else
! /*
!  * returns -1 if error message printed,
!  * 0 on success,
!  * errno value if error and no error message printed
!  */
! static int
! addServer(char *name, afs_int32 rank)
  {
!     int t, code;
!     struct setspref *ssp;
!     struct spref *sp;
!     struct hostent *thostent;
!     afs_uint32 addr;
!     int error = 0;
! 
! #ifndef MAXUSHORT
! #ifdef MAXSHORT
! #define MAXUSHORT ((unsigned short) 2*MAXSHORT+1)	/* assumes two's complement binary system */
! #else
! #define MAXUSHORT ((unsigned short) ~0)
! #endif
! #endif
! 
!     thostent = hostutil_GetHostByName(name);
!     if (!thostent) {
! 	fprintf(stderr, "%s: couldn't resolve name.\n", name);
! 	return -1;
!     }
! 
!     ssp = (struct setspref *)(gblob.in);
! 
!     for (t = 0; thostent->h_addr_list[t]; t++) {
! 	if (gblob.in_size > MAXINSIZE - sizeof(struct spref)) {
! 	    code = pokeServers();
! 	    if (code)
! 		error = code;
! 	    ssp->num_servers = 0;
! 	}
! 
! 	sp = (struct spref *)(gblob.in + gblob.in_size);
! 	memcpy(&(sp->server.s_addr), thostent->h_addr_list[t],
! 	       sizeof(afs_uint32));
! 	sp->rank = (rank > MAXUSHORT ? MAXUSHORT : rank);
! 	gblob.in_size += sizeof(struct spref);
! 	ssp->num_servers++;
! 
! 	if (debug)
! 	    fprintf(stderr, "adding server %s, rank %d, ip addr 0x%lx\n",
! 		    name, sp->rank, sp->server.s_addr);
!     }
! 
!     return error;
! }
! #endif /* WIN32 */
! 
! #ifdef WIN32
! static BOOL IsWindowsNT (void)
! {
!     static BOOL fChecked = FALSE;
      static BOOL fIsWinNT = FALSE;
  
      if (!fChecked)
***************
*** 2618,2795 ****
      }
      return fIsWinNT;
  }
! 
! 
! static SetPrefCmd(as)
! register struct cmd_syndesc *as; {
!   FILE *infd;
!   afs_int32 code;
!   struct cmd_item *ti;
!   char name[80];
!   afs_int32 rank;
!   cm_SSetPref_t *ssp;
!     
!   ssp = (cm_SSetPref_t *)space;
!   ssp->flags = 0;
!   ssp->num_servers = 0;
!   gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
!   gblob.in = space;
!   gblob.out = space;
!   gblob.out_size = MAXSIZE;
  
  #ifdef WIN32
      if ( !IsAdmin() ) {
          fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
          return EACCES;
      }
! #else /* WIN32 */
!     if (geteuid()) {
!         fprintf (stderr,"Permission denied: requires root access.\n");
!         return EACCES;
      }
- #endif /* WIN32 */
  
!   code = 0;
  
!   ti = as->parms[2].items;  /* -file */
!   if (ti) {
!     if (debug) fprintf(stderr,"opening file %s\n",ti->data);
!     if (!(infd = fopen(ti->data,"r" ))) {
!       code = errno;
!       Die(errno,ti->data);
      }
!     else
!       while ( fscanf(infd, "%79s%ld", name, &rank) != EOF) {
! 	code = addServer (name, (unsigned short) rank);
!       }
!   }
  
!   ti = as->parms[3].items;  /* -stdin */
!   if (ti) {
!     while ( scanf("%79s%ld", name, &rank) != EOF) {
!       code = addServer (name, (unsigned short) rank);
      }
!   }
!   
!   for (ti = as->parms[0].items;ti;ti=ti->next) {/*list of servers, ranks */
      if (ti) {
!       if (!ti->next) {
! 	break;
!       }
!       code = addServer (ti->data, (unsigned short) atol(ti->next->data));
!       if (debug)
! 	printf("set fs prefs %s %s\n", ti->data, ti->next->data);
!       ti=ti->next;
!     }
!   }
!   code = pokeServers();
!   if (debug) 
!     printf("now working on vlservers, code=%d, errno=%d\n",code,errno);
! 
!   ssp = (cm_SSetPref_t *)space;
!   gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
!   gblob.in = space;
!   ssp->flags = CM_SPREF_VLONLY;
!   ssp->num_servers = 0;
  
!   for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
      if (ti) {
!       if (!ti->next) {
! 	break;
!       }
!       code = addServer (ti->data, (unsigned short) atol(ti->next->data));
!       if (debug) 
! 	printf("set vl prefs %s %s\n", ti->data, ti->next->data);
!       ti=ti->next;
      }
-   }
  
!   if (as->parms[1].items) {
!     if (debug) 
!       printf("now poking vlservers\n");
      code = pokeServers();
!   }
  
! if (code) 
!   Die(errno,0);
  
! return code;
  }
  
  
! static GetPrefCmd(as)
! register struct cmd_syndesc *as; {
!   afs_int32 code;
!   struct cmd_item *ti;
!   char *name, tbuffer[20];
!   afs_int32 addr;
!   FILE * outfd;
!   int resolve;
!   int vlservers;
!   struct ViceIoctl blob;
!   struct cm_SPrefRequest *in;
!   struct cm_SPrefInfo *out;
!   int i;
!     
!   code = 0;
!   ti = as->parms[0].items;  /* -file */
!   if (ti) {
!     if (debug) fprintf(stderr,"opening file %s\n",ti->data);
!     if (!(outfd = freopen(ti->data,"w",stdout))) {
!       Die(errno,ti->data);
!       return errno;
!     }
!   }
! 
!   ti = as->parms[1].items;  /* -numeric */
!   resolve = !(ti);
!   ti = as->parms[2].items;  /* -vlservers */
!   vlservers = (ti ? CM_SPREF_VLONLY : 0);
! /*  ti = as->parms[3].items;   -cell */
! 
!   in = (struct cm_SPrefRequest *)space;
!   in->offset = 0;
! 
!   do {
!     blob.in_size=sizeof(struct cm_SPrefRequest);
!     blob.in = (char *)in;
!     blob.out = space;
!     blob.out_size = MAXSIZE;
  
!     in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct cm_SPref);
!     in->flags = vlservers; 
  
!     code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
!     if (code){
!       perror("getserverprefs pioctl");
!       Die (errno,0);
      }
-     else {
-       out = (struct cm_SPrefInfo *) blob.out;
  
!       for (i=0;i<out->num_servers;i++) {
! 	if (resolve) {
! 	  name = hostutil_GetNameByINet(out->servers[i].host.s_addr);
  	}
! 	else {
! 	  addr = ntohl(out->servers[i].host.s_addr);
! 	  sprintf(tbuffer, "%d.%d.%d.%d", (addr>>24) & 0xff, (addr>>16) & 0xff,
! 		  (addr>>8) & 0xff, addr & 0xff);
! 	  name=tbuffer;
  	}
- 	printf ("%-50s %5u\n",name,out->servers[i].rank);      
-       }
-   
-       in->offset = out->next_offset;
-     }
-   } while (!code && out->next_offset > 0);
  
!     return code;
  }
  
! static TraceCmd(struct cmd_syndesc *asp)
  {
! 	long code;
      struct ViceIoctl blob;
      long inValue;
      long outValue;
--- 3042,3392 ----
      }
      return fIsWinNT;
  }
! #endif /* WIN32 */
  
  #ifdef WIN32
+ static int
+ SetPrefCmd(struct cmd_syndesc *as, char * arock)
+ {
+     FILE *infd;
+     afs_int32 code;
+     struct cmd_item *ti;
+     char name[80];
+     afs_int32 rank;
+     cm_SSetPref_t *ssp;
+     
+     ssp = (cm_SSetPref_t *)space;
+     ssp->flags = 0;
+     ssp->num_servers = 0;
+     gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
+     gblob.in = space;
+     gblob.out = space;
+     gblob.out_size = MAXSIZE;
+ 
      if ( !IsAdmin() ) {
          fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
          return EACCES;
      }
! 
!     code = 0;
! 
!     ti = as->parms[2].items;  /* -file */
!     if (ti) {
!         if (debug) fprintf(stderr,"opening file %s\n",ti->data);
!         if (!(infd = fopen(ti->data,"r" ))) {
!             code = errno;
!             Die(errno,ti->data);
!         }
!         else
!             while ( fscanf(infd, "%79s%ld", name, &rank) != EOF) {
!                 code = addServer (name, (unsigned short) rank);
!             }
      }
  
!     ti = as->parms[3].items;  /* -stdin */
!     if (ti) {
!         while ( scanf("%79s%ld", name, &rank) != EOF) {
!             code = addServer (name, (unsigned short) rank);
!         }
!     }
  
!     for (ti = as->parms[0].items;ti;ti=ti->next) {/*list of servers, ranks */
!         if (ti) {
!             if (!ti->next) {
!                 break;
!             }
!             code = addServer (ti->data, (unsigned short) atol(ti->next->data));
!             if (debug)
!                 printf("set fs prefs %s %s\n", ti->data, ti->next->data);
!             ti=ti->next;
!         }
      }
!     code = pokeServers();
!     if (debug) 
!         printf("now working on vlservers, code=%d, errno=%d\n",code,errno);
! 
!     ssp = (cm_SSetPref_t *)space;
!     gblob.in_size = ((char*)&(ssp->servers[0])) - (char *)ssp;
!     gblob.in = space;
!     ssp->flags = CM_SPREF_VLONLY;
!     ssp->num_servers = 0;
  
!     for (ti = as->parms[1].items;ti;ti=ti->next) { /* list of dbservers, ranks */
!         if (ti) {
!             if (!ti->next) {
!                 break;
!             }
!             code = addServer (ti->data, (unsigned short) atol(ti->next->data));
!             if (debug) 
!                 printf("set vl prefs %s %s\n", ti->data, ti->next->data);
!             ti=ti->next;
!         }
      }
! 
!     if (as->parms[1].items) {
!         if (debug) 
!             printf("now poking vlservers\n");
!         code = pokeServers();
!     }
! 
!     if (code) 
!         Die(errno,0);
! 
!     return code;
! }
! #else
! static int
! SetPrefCmd(struct cmd_syndesc *as, char *arock)
! {
!     FILE *infd;
!     afs_int32 code;
!     struct cmd_item *ti;
!     char name[80];
!     afs_int32 rank;
!     struct setspref *ssp;
!     int error = 0;		/* -1 means error message printed,
! 				 * >0 means errno value for unprinted message */
! 
!     ssp = (struct setspref *)space;
!     ssp->flags = 0;
!     ssp->num_servers = 0;
!     gblob.in_size = ((char *)&(ssp->servers[0])) - (char *)ssp;
!     gblob.in = space;
!     gblob.out = space;
!     gblob.out_size = MAXSIZE;
! 
! 
!     if (geteuid()) {
! 	fprintf(stderr, "Permission denied: requires root access.\n");
! 	return 1;
!     }
! 
!     ti = as->parms[2].items;	/* -file */
      if (ti) {
! 	if (debug)
! 	    fprintf(stderr, "opening file %s\n", ti->data);
! 	if (!(infd = fopen(ti->data, "r"))) {
! 	    perror(ti->data);
! 	    error = -1;
! 	} else {
! 	    while (fscanf(infd, "%79s%ld", name, &rank) != EOF) {
! 		code = addServer(name, (unsigned short)rank);
! 		if (code)
! 		    error = code;
! 	    }
! 	}
!     }
  
!     ti = as->parms[3].items;	/* -stdin */
      if (ti) {
! 	while (scanf("%79s%ld", name, &rank) != EOF) {
! 	    code = addServer(name, (unsigned short)rank);
! 	    if (code)
! 		error = code;
! 	}
      }
  
!     for (ti = as->parms[0].items; ti; ti = ti->next) {	/* list of servers, ranks */
! 	if (ti) {
! 	    if (!ti->next) {
! 		break;
! 	    }
! 	    code = addServer(ti->data, (unsigned short)atol(ti->next->data));
! 	    if (code)
! 		error = code;
! 	    if (debug)
! 		printf("set fs prefs %s %s\n", ti->data, ti->next->data);
! 	    ti = ti->next;
! 	}
!     }
      code = pokeServers();
!     if (code)
! 	error = code;
!     if (debug)
! 	printf("now working on vlservers, code=%d\n", code);
! 
!     ssp = (struct setspref *)space;
!     ssp->flags = DBservers;
!     ssp->num_servers = 0;
!     gblob.in_size = ((char *)&(ssp->servers[0])) - (char *)ssp;
!     gblob.in = space;
  
!     for (ti = as->parms[1].items; ti; ti = ti->next) {	/* list of dbservers, ranks */
! 	if (ti) {
! 	    if (!ti->next) {
! 		break;
! 	    }
! 	    code = addServer(ti->data, (unsigned short)atol(ti->next->data));
! 	    if (code)
! 		error = code;
! 	    if (debug)
! 		printf("set vl prefs %s %s\n", ti->data, ti->next->data);
! 	    ti = ti->next;
! 	}
!     }
! 
!     if (as->parms[1].items) {
! 	if (debug)
! 	    printf("now poking vlservers\n");
! 	code = pokeServers();
! 	if (code)
! 	    error = code;
!     }
! 
!     if (error > 0)
! 	Die(error, 0);
  
!     return error ? 1 : 0;
  }
+ #endif /* WIN32 */
+ 
+ #ifdef WIN32
+ static int 
+ GetPrefCmd(struct cmd_syndesc *as, char *arock)
+ {
+     afs_int32 code;
+     struct cmd_item *ti;
+     char *name, tbuffer[20];
+     afs_int32 addr;
+     FILE * outfd;
+     int resolve;
+     int vlservers;
+     struct ViceIoctl blob;
+     struct cm_SPrefRequest *in;
+     struct cm_SPrefInfo *out;
+     int i;
+     
+     code = 0;
+     ti = as->parms[0].items;  /* -file */
+     if (ti) {
+         if (debug) fprintf(stderr,"opening file %s\n",ti->data);
+         if (!(outfd = freopen(ti->data,"w",stdout))) {
+             Die(errno,ti->data);
+             return errno;
+         }
+     }
  
+     ti = as->parms[1].items;  /* -numeric */
+     resolve = !(ti);
+     ti = as->parms[2].items;  /* -vlservers */
+     vlservers = (ti ? CM_SPREF_VLONLY : 0);
+     /*  ti = as->parms[3].items;   -cell */
+ 
+     in = (struct cm_SPrefRequest *)space;
+     in->offset = 0;
+ 
+     do {
+         blob.in_size=sizeof(struct cm_SPrefRequest);
+         blob.in = (char *)in;
+         blob.out = space;
+         blob.out_size = MAXSIZE;
+ 
+         in->num_servers = (MAXSIZE - 2*sizeof(short))/sizeof(struct cm_SPref);
+         in->flags = vlservers; 
+ 
+         code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
+         if (code){
+             perror("getserverprefs pioctl");
+             Die (errno,0);
+         }
+         else {
+             out = (struct cm_SPrefInfo *) blob.out;
  
!             for (i=0;i<out->num_servers;i++) {
!                 if (resolve) {
!                     name = hostutil_GetNameByINet(out->servers[i].host.s_addr);
!                 }
!                 else {
!                     addr = ntohl(out->servers[i].host.s_addr);
!                     sprintf(tbuffer, "%d.%d.%d.%d", (addr>>24) & 0xff, (addr>>16) & 0xff,
!                              (addr>>8) & 0xff, addr & 0xff);
!                     name=tbuffer;
!                 }
!                 printf ("%-50s %5u\n",name,out->servers[i].rank);      
!             }
  
!             in->offset = out->next_offset;
!         }
!     } while (!code && out->next_offset > 0);
! 
!     return code;
! }
! #else
! static int
! GetPrefCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     struct cmd_item *ti;
!     char *name, tbuffer[20];
!     afs_int32 rank, addr;
!     FILE *outfd;
!     int resolve;
!     int vlservers = 0;
!     struct ViceIoctl blob;
!     struct sprefrequest *in;
!     struct sprefinfo *out;
!     int i;
  
!     ti = as->parms[0].items;	/* -file */
!     if (ti) {
! 	if (debug)
! 	    fprintf(stderr, "opening file %s\n", ti->data);
! 	if (!(outfd = freopen(ti->data, "w", stdout))) {
! 	    perror(ti->data);
! 	    return 1;
! 	}
      }
  
!     ti = as->parms[1].items;	/* -numeric */
!     resolve = !(ti);
!     ti = as->parms[2].items;	/* -vlservers */
!     vlservers |= (ti ? DBservers : 0);
!     /*  ti = as->parms[3].items;   -cell */
! 
!     in = (struct sprefrequest *)space;
!     in->offset = 0;
! 
!     do {
! 	blob.in_size = sizeof(struct sprefrequest);
! 	blob.in = (char *)in;
! 	blob.out = space;
! 	blob.out_size = MAXSIZE;
! 
! 	in->num_servers =
! 	    (MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
! 	in->flags = vlservers;
! 
! 	code = pioctl(0, VIOC_GETSPREFS, &blob, 1);
! 	if (code) {
! 	    perror("getserverprefs pioctl");
! 	    return 1;
  	}
! 
! 	out = (struct sprefinfo *)blob.out;
! 
! 	for (i = 0; i < out->num_servers; i++) {
! 	    if (resolve) {
! 		name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
! 	    } else {
! 		addr = ntohl(out->servers[i].server.s_addr);
! 		sprintf(tbuffer, "%d.%d.%d.%d", (addr >> 24) & 0xff,
! 			(addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
! 		name = tbuffer;
! 	    }
! 	    printf("%-50s %5u\n", name, out->servers[i].rank);
  	}
  
! 	in->offset = out->next_offset;
!     } while (out->next_offset > 0);
! 
!     return 0;
  }
+ #endif /* WIN32 */
  
! static int
! TraceCmd(struct cmd_syndesc *asp, char *arock)
  {
!     long code;
      struct ViceIoctl blob;
      long inValue;
      long outValue;
***************
*** 2807,2983 ****
  #endif /* WIN32 */
  
      if ((asp->parms[0].items && asp->parms[1].items)) {
! 		fprintf(stderr, "fs trace: must use at most one of '-off' or '-on'\n");
          return EINVAL;
      }
          
! 	/* determine if we're turning this tracing on or off */
! 	inValue = 0;
      if (asp->parms[0].items)
          inValue = 3;		/* enable */
! 	else if (asp->parms[1].items) inValue = 2;	/* disable */
!     if (asp->parms[2].items) inValue |= 4;		/* do reset */
! 	if (asp->parms[3].items) inValue |= 8;		/* dump */
          
      blob.in_size = sizeof(long);
      blob.in = (char *) &inValue;
      blob.out_size = sizeof(long);
      blob.out = (char *) &outValue;
          
! 	code = pioctl(NULL, VIOC_TRACECTL, &blob, 1);
  	if (code) {
! 		Die(errno, NULL);
! 		return code;
  	}
-         
-     if (outValue) printf("AFS tracing enabled.\n");
-     else printf("AFS tracing disabled.\n");
  
!     return 0;
! }
  
! static void sbusage()
! {
! 	fprintf(stderr, "example usage: fs storebehind -files *.o -kb 99999 -default 0\n");
! 	fprintf(stderr, "               fs sb 50000 *.[ao] -default 10\n");
  }
  
! static StoreBehindCmd(as)  /* fs sb -kbytes 9999 -files *.o -default 64 */
! struct cmd_syndesc *as; {
      afs_int32 code;
      struct ViceIoctl blob;
      struct cmd_item *ti;
!     struct sbstruct tsb;
!     int kb;
!     
! #ifdef WIN32
!     if ( !IsAdmin() ) {
!         fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");  
!         return EACCES;
      }
! #else /* WIN32 */
!     if (geteuid()) {
!         fprintf (stderr,"Permission denied: requires root access.\n");
!         return EACCES;
      }
! #endif /* WIN32 */
! 
!     if ((as->parms[0].items && as->parms[1].items) ||   
!         (!as->parms[0].items && !as->parms[1].items)) /* same as logical xor */
!       ;
!     else {
!       sbusage();
!       return EINVAL;
      }
  
!     ti=as->parms[2].items;
!     if (ti && ti->data) {
!       kb = atoi (ti->data);
!     }
!     else kb = -1;
!     tsb.sb_default = kb;
! 
!     ti=as->parms[1].items;
!     if (ti && ti->data) {
!       kb = atoi (ti->data);
!     }
!     else kb = -1;
!     tsb.sb_thisfile = kb;
!     
!     ti=as->parms[0].items;
!     do { 
!       /* once per file */
!       blob.in = &tsb;
!       blob.out = &tsb;
!       blob.in_size = sizeof(tsb);
!       blob.out_size = sizeof(tsb);
!       fprintf (stderr, "storbehind %s %d %d\n", (ti?ti->data:0), 
! 	       tsb.sb_thisfile, tsb.sb_default);
!       code = pioctl((ti ? ti->data : 0) , VIOC_STOREBEHIND, &blob, 1);
!       if (code) {
! 	Die(errno, (ti ? ti->data : 0));
! 	continue;
!       }
!       if (blob.out_size == sizeof(tsb)) {
! 	fprintf (stderr, "storbehind %s is now %d (default %d)\n", (ti?ti->data:0), 
! 		 tsb.sb_thisfile, tsb.sb_default);
!       }
!       ti = (ti ? ti->next : ti);
!     } while (ti);
  
      return 0;
  }
  
! static afs_int32 SetCryptCmd(as)
!     struct cmd_syndesc *as;
  {
!     afs_int32 code = 0, flag;
      struct ViceIoctl blob;
!     char *tp;
!  
! #ifdef WIN32
!     if ( !IsAdmin() ) {
!         fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
!         return EACCES;
      }
! #else /* WIN32 */
!     if (geteuid()) {
!         fprintf (stderr,"Permission denied: requires root access.\n");
!         return EACCES;
      }
! #endif /* WIN32 */
! 
!     tp = as->parms[0].items->data;
!     if (strcmp(tp, "on") == 0)
!       flag = 1;
!     else if (strcmp(tp, "off") == 0)
!       flag = 0;
!     else {
!       fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
!       return EINVAL;
      }
  
!     blob.in = (char *) &flag;
!     blob.in_size = sizeof(flag);
      blob.out_size = 0;
-     code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
-     if (code)
-       Die(code, (char *) 0);
-     return 0;
- }
- 
- static afs_int32 GetCryptCmd(as)
-     struct cmd_syndesc *as;
- {
-     afs_int32 code = 0, flag;
-     struct ViceIoctl blob;
-     char *tp;
-  
-     blob.in = (char *) 0;
-     blob.in_size = 0;
-     blob.out_size = sizeof(flag);
-     blob.out = space;
- 
-     code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
  
!     if (code) Die(code, (char *) 0);
!     else {
!       tp = space;
!       memcpy(&flag, tp, sizeof(afs_int32));
!       printf("Security level is currently ");
!       if (flag == 1)
!         printf("crypt (data security).\n");
!       else
!         printf("clear.\n");
      }
      return 0;
  }
  
! main(argc, argv)
! int argc;
! char **argv; {
!     register afs_int32 code;
!     register struct cmd_syndesc *ts;
  
  #ifdef	AFS_AIX32_ENV
      /*
--- 3404,4079 ----
  #endif /* WIN32 */
  
      if ((asp->parms[0].items && asp->parms[1].items)) {
!         fprintf(stderr, "fs trace: must use at most one of '-off' or '-on'\n");
          return EINVAL;
      }
          
!     /* determine if we're turning this tracing on or off */
!     inValue = 0;
      if (asp->parms[0].items)
          inValue = 3;		/* enable */
!     else if (asp->parms[1].items) 
!         inValue = 2;	/* disable */
!     if (asp->parms[2].items) 
!         inValue |= 4;		/* do reset */
!     if (asp->parms[3].items) 
!         inValue |= 8;		/* dump */
          
      blob.in_size = sizeof(long);
      blob.in = (char *) &inValue;
      blob.out_size = sizeof(long);
      blob.out = (char *) &outValue;
          
!     code = pioctl(NULL, VIOC_TRACECTL, &blob, 1);
!     if (code) {
!         Die(errno, NULL);
!         return code;
!     }
! 
!     if (outValue) 
!         printf("AFS tracing enabled.\n");
!     else 
!         printf("AFS tracing disabled.\n");
! 
!     return 0;
! }
! 
! static void sbusage(void)
! {
!     fprintf(stderr, "example usage: %s storebehind -files *.o -kb 99999 -default 0\n", pn);
!     fprintf(stderr, "               %s sb 50000 *.[ao] -default 10\n", pn);
! }       
! 
! /* fs sb -kbytes 9999 -files *.o -default 64 */
! static int
! StoreBehindCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code = 0;
!     struct ViceIoctl blob;
!     struct cmd_item *ti;
!     struct sbstruct tsb, tsb2;
!     int verbose = 0;
!     afs_int32 allfiles;
!     char *t;
!     int error = 0;
! 
! #ifdef WIN32
!     if ( !IsAdmin() ) {
!         fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");  
!         return EACCES;
!     }
! #endif /* WIN32 */
! 
!     tsb.sb_thisfile = -1;
!     ti = as->parms[0].items;	/* -kbytes */
!     if (ti) {
! 	if (!as->parms[1].items) {
! 	    fprintf(stderr, "%s: you must specify -files with -kbytes.\n",
! 		    pn);
! 	    return 1;
! 	}
! 	tsb.sb_thisfile = strtol(ti->data, &t, 10) * 1024;
! 	if ((tsb.sb_thisfile < 0) || (t != ti->data + strlen(ti->data))) {
! 	    fprintf(stderr, "%s: %s must be 0 or a positive number.\n", pn,
! 		    ti->data);
! 	    return 1;
! 	}
!     }
! 
!     allfiles = tsb.sb_default = -1;	/* Don't set allfiles yet */
!     ti = as->parms[2].items;	/* -allfiles */
!     if (ti) {
! 	allfiles = strtol(ti->data, &t, 10) * 1024;
! 	if ((allfiles < 0) || (t != ti->data + strlen(ti->data))) {
! 	    fprintf(stderr, "%s: %s must be 0 or a positive number.\n", pn,
! 		    ti->data);
! 	    return 1;
! 	}
!     }
! 
!     /* -verbose or -file only or no options */
!     if (as->parms[3].items || (as->parms[1].items && !as->parms[0].items)
! 	|| (!as->parms[0].items && !as->parms[1].items
! 	    && !as->parms[2].items))
! 	verbose = 1;
! 
!     blob.in = (char *)&tsb;
!     blob.out = (char *)&tsb2;
!     blob.in_size = blob.out_size = sizeof(struct sbstruct);
!     memset(&tsb2, 0, sizeof(tsb2));
! 
!     /* once per -file */
!     for (ti = as->parms[1].items; ti; ti = ti->next) {
! 	/* Do this solely to see if the file is there */
! 	code = pioctl(ti->data, VIOCWHEREIS, &blob, 1);
! 	if (code) {
! 	    Die(errno, ti->data);
! 	    error = 1;
! 	    continue;
! 	}
! 
! 	code = pioctl(ti->data, VIOC_STOREBEHIND, &blob, 1);
  	if (code) {
! 	    Die(errno, ti->data);
! 	    error = 1;
! 	    continue;
  	}
  
! 	if (verbose && (blob.out_size == sizeof(tsb2))) {
! 	    if (tsb2.sb_thisfile == -1) {
! 		fprintf(stdout, "Will store %s according to default.\n",
! 			ti->data);
! 	    } else {
! 		fprintf(stdout,
! 			"Will store up to %d kbytes of %s asynchronously.\n",
! 			(tsb2.sb_thisfile / 1024), ti->data);
! 	    }
! 	}
!     }
! 
!     /* If no files - make at least one pioctl call, or
!      * set the allfiles default if we need to.
!      */
!     if (!as->parms[1].items || (allfiles != -1)) {
! 	tsb.sb_default = allfiles;
! 	code = pioctl(0, VIOC_STOREBEHIND, &blob, 1);
! 	if (code) {
! 	    Die(errno, ((allfiles == -1) ? 0 : "-allfiles"));
! 	    error = 1;
! 	}
!     }
! 
!     /* Having no arguments also reports the default store asynchrony */
!     if (verbose && (blob.out_size == sizeof(tsb2))) {
! 	fprintf(stdout, "Default store asynchrony is %d kbytes.\n",
! 		(tsb2.sb_default / 1024));
!     }
! 
!     return error;
! }
! 
! static afs_int32 
! SetCryptCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code = 0, flag;
!     struct ViceIoctl blob;
!     char *tp;
!  
! #ifdef WIN32
!     if ( !IsAdmin() ) {
!         fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
!         return EACCES;
!     }
! #endif /* WIN32 */
! 
!     tp = as->parms[0].items->data;
!     if (strcmp(tp, "on") == 0)
!       flag = 1;
!     else if (strcmp(tp, "off") == 0)
!       flag = 0;
!     else {
!       fprintf (stderr, "%s: %s must be \"on\" or \"off\".\n", pn, tp);
!       return EINVAL;
!     }
! 
!     blob.in = (char *) &flag;
!     blob.in_size = sizeof(flag);
!     blob.out_size = 0;
!     code = pioctl(0, VIOC_SETRXKCRYPT, &blob, 1);
!     if (code)
!         Die(code, NULL);
!     return 0;
! }
! 
! static afs_int32 
! GetCryptCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code = 0, flag;
!     struct ViceIoctl blob;
!     char *tp;
!  
!     blob.in = NULL;
!     blob.in_size = 0;
!     blob.out_size = sizeof(flag);
!     blob.out = space;
! 
!     code = pioctl(0, VIOC_GETRXKCRYPT, &blob, 1);
! 
!     if (code) 
!         Die(code, NULL);
!     else {
!       tp = space;
!       memcpy(&flag, tp, sizeof(afs_int32));
!       printf("Security level is currently ");
!       if (flag == 1)
!         printf("crypt (data security).\n");
!       else
!         printf("clear.\n");
!     }
!     return 0;
! }
! 
! static int
! MemDumpCmd(struct cmd_syndesc *asp, char *arock)
! {
!     long code;
!     struct ViceIoctl blob;
!     long inValue;
!     long outValue;
!   
!     if ((asp->parms[0].items && asp->parms[1].items)) {
!         fprintf(stderr, "%s trace: must use at most one of '-begin' or '-end'\n", pn);
!         return EINVAL;
!     }
!   
!     /* determine if we're turning this tracing on or off */
!     inValue = 0;
!     if (asp->parms[0].items)
!         inValue = 1;            /* begin */
!     else if (asp->parms[1].items) 
!         inValue = 0;            /* end */
!   
!     blob.in_size = sizeof(long);
!     blob.in = (char *) &inValue;
!     blob.out_size = sizeof(long);
!     blob.out = (char *) &outValue;
! 
!     code = pioctl(NULL, VIOC_TRACEMEMDUMP, &blob, 1);
!     if (code) {
!         Die(errno, NULL);
!         return code;
!     }
! 
!     if (outValue) printf("AFS memdump begin.\n");
!     else printf("AFS memdump end.\n");
! 
!     return 0;
! }
! 
! static int
! CSCPolicyCmd(struct cmd_syndesc *asp, char *arock)
! {
!     struct cmd_item *ti;
!     char *share = NULL;
!     HKEY hkCSCPolicy;
! 
!     for(ti=asp->parms[0].items; ti;ti=ti->next) {
!         share = ti->data;
!         if (share)
!         {
!             break;
!         }
!     }
! 
!     if (share)
!     {
!         char *policy;
! 
!         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                         "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
!                         0, 
!                         "AFS", 
!                         REG_OPTION_NON_VOLATILE,
!                         KEY_WRITE,
!                         NULL, 
!                         &hkCSCPolicy,
!                         NULL );
! 
!         if ( hkCSCPolicy == NULL ) {
!             fprintf (stderr,"Permission denied: requires Administrator access.\n");
!             return EACCES;
!         }
! 
!         if ( !IsAdmin() ) {
!             fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
!             RegCloseKey(hkCSCPolicy);
!             return EACCES;
!         }
! 
!         policy = "manual";
! 		
!         if (asp->parms[1].items)
!             policy = "manual";
!         if (asp->parms[2].items)
!             policy = "programs";
!         if (asp->parms[3].items)
!             policy = "documents";
!         if (asp->parms[4].items)
!             policy = "disable";
! 		
!         RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, strlen(policy)+1);
! 		
!         printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
!         printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n"); 
!     }
!     else
!     {
!         DWORD dwIndex, dwPolicies;
!         char policyName[256];
!         DWORD policyNameLen;
!         char policy[256];
!         DWORD policyLen;
!         DWORD dwType;
! 
!         /* list current csc policies */
! 
!         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
!                         "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
!                         0, 
!                         "AFS", 
!                         REG_OPTION_NON_VOLATILE,
!                         KEY_READ|KEY_QUERY_VALUE,
!                         NULL, 
!                         &hkCSCPolicy,
!                         NULL );
! 
!         RegQueryInfoKey( hkCSCPolicy,
!                          NULL,  /* lpClass */
!                          NULL,  /* lpcClass */
!                          NULL,  /* lpReserved */
!                          NULL,  /* lpcSubKeys */
!                          NULL,  /* lpcMaxSubKeyLen */
!                          NULL,  /* lpcMaxClassLen */
!                          &dwPolicies, /* lpcValues */
!                          NULL,  /* lpcMaxValueNameLen */
!                          NULL,  /* lpcMaxValueLen */
!                          NULL,  /* lpcbSecurityDescriptor */
!                          NULL   /* lpftLastWriteTime */
!                          );
! 		
!         printf("Current CSC policies:\n");
!         for ( dwIndex = 0; dwIndex < dwPolicies; dwIndex ++ ) {
! 
!             policyNameLen = sizeof(policyName);
!             policyLen = sizeof(policy);
!             RegEnumValue( hkCSCPolicy, dwIndex, policyName, &policyNameLen, NULL,
!                           &dwType, policy, &policyLen);
! 
!             printf("  %s = %s\n", policyName, policy);
!         }
!     }
! 
!     RegCloseKey(hkCSCPolicy);
!     return (0);
! }
! 
! #ifndef WIN32
! /* get clients interface addresses */
! static int
! GetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     struct cmd_item *ti;
!     char *name;
!     struct ViceIoctl blob;
!     struct sprefrequest *in;
!     struct sprefinfo *out;
! 
!     in = (struct sprefrequest *)space;
!     in->offset = 0;
! 
!     do {
! 	blob.in_size = sizeof(struct sprefrequest);
! 	blob.in = (char *)in;
! 	blob.out = space;
! 	blob.out_size = MAXSIZE;
! 
! 	in->num_servers =
! 	    (MAXSIZE - 2 * sizeof(short)) / sizeof(struct spref);
! 	/* returns addr in network byte order */
! 	code = pioctl(0, VIOC_GETCPREFS, &blob, 1);
! 	if (code) {
! 	    perror("getClientInterfaceAddr pioctl");
! 	    return 1;
! 	}
! 
! 	{
! 	    int i;
! 	    out = (struct sprefinfo *)blob.out;
! 	    for (i = 0; i < out->num_servers; i++) {
! 		afs_int32 addr;
! 		char tbuffer[32];
! 		addr = ntohl(out->servers[i].server.s_addr);
! 		sprintf(tbuffer, "%d.%d.%d.%d", (addr >> 24) & 0xff,
! 			(addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
! 		printf("%-50s\n", tbuffer);
! 	    }
! 	    in->offset = out->next_offset;
! 	}
!     } while (out->next_offset > 0);
! 
!     return 0;
! }
! 
! static int
! SetClientAddrsCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code, addr;
!     struct cmd_item *ti;
!     char name[80];
!     struct ViceIoctl blob;
!     struct setspref *ssp;
!     int sizeUsed = 0, i, flag;
!     afs_int32 existingAddr[1024];	/* existing addresses on this host */
!     int existNu;
!     int error = 0;
! 
!     ssp = (struct setspref *)space;
!     ssp->num_servers = 0;
!     blob.in = space;
!     blob.out = space;
!     blob.out_size = MAXSIZE;
! 
!     if (geteuid()) {
! 	fprintf(stderr, "Permission denied: requires root access.\n");
! 	return 1;
!     }
! 
!     /* extract all existing interface addresses */
!     existNu = rx_getAllAddr(existingAddr, 1024);
!     if (existNu < 0)
! 	return 1;
! 
!     sizeUsed = sizeof(struct setspref);	/* space used in ioctl buffer */
!     for (ti = as->parms[0].items; ti; ti = ti->next) {
! 	if (sizeUsed >= sizeof(space)) {
! 	    fprintf(stderr, "No more space\n");
! 	    return 1;
! 	}
! 	addr = extractAddr(ti->data, 20);	/* network order */
! 	if ((addr == AFS_IPINVALID) || (addr == AFS_IPINVALIDIGNORE)) {
! 	    fprintf(stderr, "Error in specifying address: %s..ignoring\n",
! 		    ti->data);
! 	    error = 1;
! 	    continue;
! 	}
! 	/* see if it is an address that really exists */
! 	for (flag = 0, i = 0; i < existNu; i++)
! 	    if (existingAddr[i] == addr) {
! 		flag = 1;
! 		break;
! 	    }
! 	if (!flag) {		/* this is an nonexistent address */
! 	    fprintf(stderr, "Nonexistent address: 0x%08x..ignoring\n", addr);
! 	    error = 1;
! 	    continue;
! 	}
! 	/* copy all specified addr into ioctl buffer */
! 	(ssp->servers[ssp->num_servers]).server.s_addr = addr;
! 	printf("Adding 0x%08x\n", addr);
! 	ssp->num_servers++;
! 	sizeUsed += sizeof(struct spref);
!     }
!     if (ssp->num_servers < 1) {
! 	fprintf(stderr, "No addresses specified\n");
! 	return 1;
!     }
!     blob.in_size = sizeUsed - sizeof(struct spref);
! 
!     code = pioctl(0, VIOC_SETCPREFS, &blob, 1);	/* network order */
!     if (code) {
! 	Die(errno, 0);
! 	error = 1;
!     }
! 
!     return error;
! }
! 
! static int
! FlushMountCmd(struct cmd_syndesc *as, char *arock)
! {
!     afs_int32 code;
!     struct ViceIoctl blob;
!     struct cmd_item *ti;
!     char orig_name[1024];	/*Original name, may be modified */
!     char true_name[1024];	/*``True'' dirname (e.g., symlink target) */
!     char parent_dir[1024];	/*Parent directory of true name */
!     char *last_component;	/*Last component of true name */
!     struct stat statbuff;	/*Buffer for status info */
!     int link_chars_read;	/*Num chars read in readlink() */
!     int thru_symlink;		/*Did we get to a mount point via a symlink? */
!     int error = 0;
! 
!     for (ti = as->parms[0].items; ti; ti = ti->next) {
! 	/* once per file */
! 	thru_symlink = 0;
! 	sprintf(orig_name, "%s%s", (ti->data[0] == '/') ? "" : "./",
! 		ti->data);
! 
! 	if (lstat(orig_name, &statbuff) < 0) {
! 	    /* if lstat fails, we should still try the pioctl, since it
! 	     * may work (for example, lstat will fail, but pioctl will
! 	     * work if the volume of offline (returning ENODEV). */
! 	    statbuff.st_mode = S_IFDIR;	/* lie like pros */
! 	}
! 
! 	/*
! 	 * The lstat succeeded.  If the given file is a symlink, substitute
! 	 * the file name with the link name.
! 	 */
! 	if ((statbuff.st_mode & S_IFMT) == S_IFLNK) {
! 	    thru_symlink = 1;
! 	    /*
! 	     * Read name of resolved file.
! 	     */
! 	    link_chars_read = readlink(orig_name, true_name, 1024);
! 	    if (link_chars_read <= 0) {
! 		fprintf(stderr,
! 			"%s: Can't read target name for '%s' symbolic link!\n",
! 			pn, orig_name);
! 		error = 1;
! 		continue;
! 	    }
! 
! 	    /*
! 	     * Add a trailing null to what was read, bump the length.
! 	     */
! 	    true_name[link_chars_read++] = 0;
! 
! 	    /*
! 	     * If the symlink is an absolute pathname, we're fine.  Otherwise, we
! 	     * have to create a full pathname using the original name and the
! 	     * relative symlink name.  Find the rightmost slash in the original
! 	     * name (we know there is one) and splice in the symlink value.
! 	     */
! 	    if (true_name[0] != '/') {
! 		last_component = (char *)strrchr(orig_name, '/');
! 		strcpy(++last_component, true_name);
! 		strcpy(true_name, orig_name);
! 	    }
! 	} else
! 	    strcpy(true_name, orig_name);
! 
! 	/*
! 	 * Find rightmost slash, if any.
! 	 */
! 	last_component = (char *)strrchr(true_name, '/');
! 	if (last_component) {
! 	    /*
! 	     * Found it.  Designate everything before it as the parent directory,
! 	     * everything after it as the final component.
! 	     */
! 	    strncpy(parent_dir, true_name, last_component - true_name);
! 	    parent_dir[last_component - true_name] = 0;
! 	    last_component++;	/*Skip the slash */
! 	} else {
! 	    /*
! 	     * No slash appears in the given file name.  Set parent_dir to the current
! 	     * directory, and the last component as the given name.
! 	     */
! 	    strcpy(parent_dir, ".");
! 	    last_component = true_name;
! 	}
! 
! 	if (strcmp(last_component, ".") == 0
! 	    || strcmp(last_component, "..") == 0) {
! 	    fprintf(stderr,
! 		    "%s: you may not use '.' or '..' as the last component\n",
! 		    pn);
! 	    fprintf(stderr, "%s: of a name in the 'fs flushmount' command.\n",
! 		    pn);
! 	    error = 1;
! 	    continue;
! 	}
! 
! 	blob.in = last_component;
! 	blob.in_size = strlen(last_component) + 1;
! 	blob.out_size = 0;
! 	memset(space, 0, MAXSIZE);
! 
! 	code = pioctl(parent_dir, VIOC_AFS_FLUSHMOUNT, &blob, 1);
  
! 	if (code != 0) {
! 	    if (errno == EINVAL) {
! 		fprintf(stderr, "'%s' is not a mount point.\n", ti->data);
! 	    } else {
! 		Die(errno, (ti->data ? ti->data : parent_dir));
! 	    }
! 	    error = 1;
! 	}
!     }
!     return error;
  }
  
! static int
! RxStatProcCmd(struct cmd_syndesc *as, char *arock)
! {
      afs_int32 code;
+     afs_int32 flags = 0;
      struct ViceIoctl blob;
      struct cmd_item *ti;
! 
!     if (as->parms[0].items) {	/* -enable */
! 	flags |= AFSCALL_RXSTATS_ENABLE;
      }
!     if (as->parms[1].items) {	/* -disable */
! 	flags |= AFSCALL_RXSTATS_DISABLE;
      }
!     if (as->parms[2].items) {	/* -clear */
! 	flags |= AFSCALL_RXSTATS_CLEAR;
!     }
!     if (flags == 0) {
! 	fprintf(stderr, "You must specify at least one argument\n");
! 	return 1;
      }
  
!     blob.in = (char *)&flags;
!     blob.in_size = sizeof(afs_int32);
!     blob.out_size = 0;
! 
!     code = pioctl(NULL, VIOC_RXSTAT_PROC, &blob, 1);
!     if (code != 0) {
! 	Die(errno, NULL);
! 	return 1;
!     }
  
      return 0;
  }
  
! static int
! RxStatPeerCmd(struct cmd_syndesc *as, char *arock)
  {
!     afs_int32 code;
!     afs_int32 flags = 0;
      struct ViceIoctl blob;
!     struct cmd_item *ti;
! 
!     if (as->parms[0].items) {	/* -enable */
! 	flags |= AFSCALL_RXSTATS_ENABLE;
      }
!     if (as->parms[1].items) {	/* -disable */
! 	flags |= AFSCALL_RXSTATS_DISABLE;
      }
!     if (as->parms[2].items) {	/* -clear */
! 	flags |= AFSCALL_RXSTATS_CLEAR;
!     }
!     if (flags == 0) {
! 	fprintf(stderr, "You must specify at least one argument\n");
! 	return 1;
      }
  
!     blob.in = (char *)&flags;
!     blob.in_size = sizeof(afs_int32);
      blob.out_size = 0;
  
!     code = pioctl(NULL, VIOC_RXSTAT_PEER, &blob, 1);
!     if (code != 0) {
! 	Die(errno, NULL);
! 	return 1;
      }
+ 
      return 0;
  }
+ #endif /* WIN32 */
  
! #ifndef WIN32
! #include "AFS_component_version_number.c"
! #endif
! 
! main(int argc, char **argv)
! {
!     afs_int32 code;
!     struct cmd_syndesc *ts;
  
  #ifdef	AFS_AIX32_ENV
      /*
***************
*** 3000,3009 ****
  #endif /* WIN32 */
  
      /* try to find volume location information */
-     
- 
      osi_Init();
  
      ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
      cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
      cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
--- 4096,4115 ----
  #endif /* WIN32 */
  
      /* try to find volume location information */
      osi_Init();
  
+ #ifndef WIN32
+     ts = cmd_CreateSyntax("getclientaddrs", GetClientAddrsCmd, 0,
+ 			  "get client network interface addresses");
+     cmd_CreateAlias(ts, "gc");
+ 
+     ts = cmd_CreateSyntax("setclientaddrs", SetClientAddrsCmd, 0,
+ 			  "set client network interface addresses");
+     cmd_AddParm(ts, "-address", CMD_LIST, CMD_OPTIONAL | CMD_EXPANDS,
+                 "client network interfaces");
+     cmd_CreateAlias(ts, "sc");
+ #endif /* WIN32 */
+ 
      ts = cmd_CreateSyntax("setserverprefs", SetPrefCmd, 0, "set server ranks");
      cmd_AddParm(ts, "-servers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "fileserver names and ranks");
      cmd_AddParm(ts, "-vlservers", CMD_LIST, CMD_OPTIONAL|CMD_EXPANDS, "VL server names and ranks");
***************
*** 3051,3056 ****
--- 4157,4168 ----
      ts = cmd_CreateSyntax("flush", FlushCmd, 0, "flush file from cache");
      cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
      
+ #ifndef WIN32
+     ts = cmd_CreateSyntax("flushmount", FlushMountCmd, 0,
+                            "flush mount symlink from cache");
+     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
+ #endif
+ 
      ts = cmd_CreateSyntax("setvol", SetVolCmd, 0, "set volume status");
      cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
      cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
***************
*** 3061,3070 ****
      cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
      cmd_CreateAlias(ts, "sv");
      
!     ts = cmd_CreateSyntax("messages", GagCmd, 0, "control Cache Manager messages");
      cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
  
!     ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display volume status");
      cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
      cmd_CreateAlias(ts, "lv");
      cmd_CreateAlias(ts, "listvol");
--- 4173,4182 ----
      cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
      cmd_CreateAlias(ts, "sv");
      
!     ts = cmd_CreateSyntax("messages", MessagesCmd, 0, "control Cache Manager messages");
      cmd_AddParm(ts, "-show", CMD_SINGLE, CMD_OPTIONAL, "[user|console|all|none]");
  
!     ts = cmd_CreateSyntax("examine", ExamineCmd, 0, "display file/volume status");
      cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
      cmd_CreateAlias(ts, "lv");
      cmd_CreateAlias(ts, "listvol");
***************
*** 3120,3125 ****
--- 4232,4238 ----
      ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info");
  
      ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");
+     cmd_AddParm(ts, "-numeric", CMD_FLAG, CMD_OPTIONAL, "addresses only");
      
      ts = cmd_CreateSyntax("setquota", SetQuotaCmd, 0, "set volume quota");
      cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
***************
*** 3134,3140 ****
      cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "cell name");
      cmd_AddParm(ts, "-servers", CMD_LIST, CMD_REQUIRED, "primary servers");
      cmd_AddParm(ts, "-linkedcell", CMD_SINGLE, CMD_OPTIONAL, "linked cell name");
- #endif
  
  #ifdef FS_ENABLE_SERVER_DEBUG_PORTS
      /*
--- 4247,4252 ----
***************
*** 3147,3152 ****
--- 4259,4270 ----
      cmd_AddParm(ts, "-vlport", CMD_SINGLE, CMD_OPTIONAL, "cell's vldb server port");
  #endif
  
+     ts = cmd_CreateSyntax("newalias", NewAliasCmd, 0,
+ 			  "configure new cell alias");
+     cmd_AddParm(ts, "-alias", CMD_SINGLE, 0, "alias name");
+     cmd_AddParm(ts, "-name", CMD_SINGLE, 0, "real name of cell");
+ #endif
+ 
      ts = cmd_CreateSyntax("whichcell", WhichCellCmd, 0, "list file's cell");
      cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
  
***************
*** 3198,3203 ****
--- 4316,4338 ----
  
      ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0, "get cache manager encryption flag");
  
+ #ifndef WIN32
+     ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
+ 			  "Manage per process RX statistics");
+     cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL, "Enable RX stats");
+     cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "Disable RX stats");
+     cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "Clear RX stats");
+ 
+     ts = cmd_CreateSyntax("rxstatpeer", RxStatPeerCmd, 0,
+ 			  "Manage per peer RX statistics");
+     cmd_AddParm(ts, "-enable", CMD_FLAG, CMD_OPTIONAL, "Enable RX stats");
+     cmd_AddParm(ts, "-disable", CMD_FLAG, CMD_OPTIONAL, "Disable RX stats");
+     cmd_AddParm(ts, "-clear", CMD_FLAG, CMD_OPTIONAL, "Clear RX stats");
+ 
+     ts = cmd_CreateSyntax("setcbaddr", CallBackRxConnCmd, 0, "configure callback connection address");
+     cmd_AddParm(ts, "-addr", CMD_SINGLE, CMD_OPTIONAL, "host name or address");
+ #endif
+ 
      ts = cmd_CreateSyntax("trace", TraceCmd, 0, "enable or disable CM tracing");
      cmd_AddParm(ts, "-on", CMD_FLAG, CMD_OPTIONAL, "enable tracing");
      cmd_AddParm(ts, "-off", CMD_FLAG, CMD_OPTIONAL, "disable tracing");
***************
*** 3219,3248 ****
      code = cmd_Dispatch(argc, argv);
  
  #ifndef WIN32
!     if (rxInitDone) rx_Finalize();
  #endif /* not WIN32 */
      
      return code;
  }
  
! void Die(code, filename)
!     int   code;
!     char *filename;
  { /*Die*/
  
      if (code == EINVAL) {
  	if (filename)
  	    fprintf(stderr,"%s: Invalid argument; it is possible that %s is not in AFS.\n", pn, filename);
! 	else fprintf(stderr,"%s: Invalid argument.\n", pn);
      }
      else if (code == ENOENT) {
! 	if (filename) fprintf(stderr,"%s: File '%s' doesn't exist\n", pn, filename);
! 	else fprintf(stderr,"%s: no such file returned\n", pn);
      }
!     else if (code == EROFS)  fprintf(stderr,"%s: You can not change a backup or readonly volume\n", pn);
      else if (code == EACCES || code == EPERM) {
! 	if (filename) fprintf(stderr,"%s: You don't have the required access rights on '%s'\n", pn, filename);
! 	else fprintf(stderr,"%s: You do not have the required rights to do this operation\n", pn);
      }
      else if (code == ENODEV) {
  	fprintf(stderr,"%s: AFS service may not have started.\n", pn);
--- 4354,4389 ----
      code = cmd_Dispatch(argc, argv);
  
  #ifndef WIN32
!     if (rxInitDone) 
!         rx_Finalize();
  #endif /* not WIN32 */
      
      return code;
  }
  
! static void 
! Die(int code, char *filename)
  { /*Die*/
  
      if (code == EINVAL) {
  	if (filename)
  	    fprintf(stderr,"%s: Invalid argument; it is possible that %s is not in AFS.\n", pn, filename);
! 	else 
!             fprintf(stderr,"%s: Invalid argument.\n", pn);
      }
      else if (code == ENOENT) {
! 	if (filename) 
!             fprintf(stderr,"%s: File '%s' doesn't exist\n", pn, filename);
! 	else 
!             fprintf(stderr,"%s: no such file returned\n", pn);
      }
!     else if (code == EROFS)  
!         fprintf(stderr,"%s: You can not change a backup or readonly volume\n", pn);
      else if (code == EACCES || code == EPERM) {
! 	if (filename) 
!             fprintf(stderr,"%s: You don't have the required access rights on '%s'\n", pn, filename);
! 	else 
!             fprintf(stderr,"%s: You do not have the required rights to do this operation\n", pn);
      }
      else if (code == ENODEV) {
  	fprintf(stderr,"%s: AFS service may not have started.\n", pn);
***************
*** 3263,3270 ****
  	    fprintf(stderr,"%s: Connection timed out", pn);
      }
      else {
! 	if (filename) fprintf(stderr,"%s:'%s'", pn, filename);
! 	else fprintf(stderr,"%s", pn);
  #ifdef WIN32
  	fprintf(stderr, ": code 0x%x\n", code);
  #else /* not WIN32 */
--- 4404,4413 ----
  	    fprintf(stderr,"%s: Connection timed out", pn);
      }
      else {
! 	if (filename) 
!             fprintf(stderr,"%s:'%s'", pn, filename);
! 	else 
!             fprintf(stderr,"%s", pn);
  #ifdef WIN32
  	fprintf(stderr, ": code 0x%x\n", code);
  #else /* not WIN32 */
***************
*** 3273,3416 ****
      }
  } /*Die*/
  
- static MemDumpCmd(struct cmd_syndesc *asp)
- {
-     long code;
-     struct ViceIoctl blob;
-     long inValue;
-     long outValue;
-   
-     if ((asp->parms[0].items && asp->parms[1].items)) {
-         fprintf(stderr, "fs trace: must use at most one of '-begin' or '-end'\n");
-         return EINVAL;
-     }
-   
-     /* determine if we're turning this tracing on or off */
-     inValue = 0;
-     if (asp->parms[0].items)
-         inValue = 1;            /* begin */
-     else if (asp->parms[1].items) 
-         inValue = 0;            /* end */
-   
-     blob.in_size = sizeof(long);
-     blob.in = (char *) &inValue;
-     blob.out_size = sizeof(long);
-     blob.out = (char *) &outValue;
- 
-     code = pioctl(NULL, VIOC_TRACEMEMDUMP, &blob, 1);
-     if (code) {
-         Die(errno, NULL);
-         return code;
-     }
- 
-     if (outValue) printf("AFS memdump begin.\n");
-     else printf("AFS memdump end.\n");
- 
-     return 0;
- }
- 
- static CSCPolicyCmd(struct cmd_syndesc *asp)
- {
-     struct cmd_item *ti;
-     char *share = NULL;
-     HKEY hkCSCPolicy;
- 
-     for(ti=asp->parms[0].items; ti;ti=ti->next) {
-         share = ti->data;
-         if (share)
-         {
-             break;
-         }
-     }
- 
-     if (share)
-     {
-         char *policy;
- 
-         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
-                         "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
-                         0, 
-                         "AFS", 
-                         REG_OPTION_NON_VOLATILE,
-                         KEY_WRITE,
-                         NULL, 
-                         &hkCSCPolicy,
-                         NULL );
- 
-         if ( hkCSCPolicy == NULL ) {
-             fprintf (stderr,"Permission denied: requires Administrator access.\n");
-             return EACCES;
-         }
- 
-         if ( !IsAdmin() ) {
-             fprintf (stderr,"Permission denied: requires AFS Client Administrator access.\n");
-             RegCloseKey(hkCSCPolicy);
-             return EACCES;
-         }
- 
-         policy = "manual";
- 		
-         if (asp->parms[1].items)
-             policy = "manual";
-         if (asp->parms[2].items)
-             policy = "programs";
-         if (asp->parms[3].items)
-             policy = "documents";
-         if (asp->parms[4].items)
-             policy = "disable";
- 		
-         RegSetValueEx( hkCSCPolicy, share, 0, REG_SZ, policy, strlen(policy)+1);
- 		
-         printf("CSC policy on share \"%s\" changed to \"%s\".\n\n", share, policy);
-         printf("Close all applications that accessed files on this share or restart AFS Client for the change to take effect.\n"); 
-     }
-     else
-     {
-         DWORD dwIndex, dwPolicies;
-         char policyName[256];
-         DWORD policyNameLen;
-         char policy[256];
-         DWORD policyLen;
-         DWORD dwType;
- 
-         /* list current csc policies */
- 
-         RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
-                         "SOFTWARE\\OpenAFS\\Client\\CSCPolicy",
-                         0, 
-                         "AFS", 
-                         REG_OPTION_NON_VOLATILE,
-                         KEY_READ|KEY_QUERY_VALUE,
-                         NULL, 
-                         &hkCSCPolicy,
-                         NULL );
- 
-         RegQueryInfoKey( hkCSCPolicy,
-                          NULL,  /* lpClass */
-                          NULL,  /* lpcClass */
-                          NULL,  /* lpReserved */
-                          NULL,  /* lpcSubKeys */
-                          NULL,  /* lpcMaxSubKeyLen */
-                          NULL,  /* lpcMaxClassLen */
-                          &dwPolicies, /* lpcValues */
-                          NULL,  /* lpcMaxValueNameLen */
-                          NULL,  /* lpcMaxValueLen */
-                          NULL,  /* lpcbSecurityDescriptor */
-                          NULL   /* lpftLastWriteTime */
-                          );
- 		
-         printf("Current CSC policies:\n");
-         for ( dwIndex = 0; dwIndex < dwPolicies; dwIndex ++ ) {
- 
-             policyNameLen = sizeof(policyName);
-             policyLen = sizeof(policy);
-             RegEnumValue( hkCSCPolicy, dwIndex, policyName, &policyNameLen, NULL,
-                           &dwType, policy, &policyLen);
- 
-             printf("  %s = %s\n", policyName, policy);
-         }
-     }
- 
-     RegCloseKey(hkCSCPolicy);
-     return (0);
- }
--- 4416,4418 ----
Index: openafs/src/WINNT/afsd/fs.h
diff -c openafs/src/WINNT/afsd/fs.h:1.3 openafs/src/WINNT/afsd/fs.h:1.3.2.1
*** openafs/src/WINNT/afsd/fs.h:1.3	Mon Dec  8 01:08:45 2003
--- openafs/src/WINNT/afsd/fs.h	Sun Jan 30 23:05:02 2005
***************
*** 11,28 ****
  #define __FS_H_ENV__ 1
  
  /* some forward references */
! extern void ZapList(struct AclEntry *);
  
! extern void ZapAcl(struct Acl *);
  
! extern int PruneList (struct AclEntry **, int);
  
! extern void ChangeList(struct Acl *, afs_int32, char *, afs_int32);
  
! extern int CleanAcl(struct Acl *);
  
! extern void Die(int, char *);
! 
! static SetVolCmd(struct cmd_syndesc *);
  
  #endif /* FS_H_ENV */
--- 11,27 ----
  #define __FS_H_ENV__ 1
  
  /* some forward references */
! static void ZapList (struct AclEntry *alist);
  
! static int PruneList (struct AclEntry **ae, int dfs);
  
! static int CleanAcl(struct Acl *aa, char *fname);
  
! static int SetVolCmd(struct cmd_syndesc *as, char *arock);
  
! static int GetCellName(char *cellNamep, struct afsconf_cell *infop);
  
! static int VLDBInit(int noAuthFlag, struct afsconf_cell *infop);
  
+ static void Die(int code, char *filename);
  #endif /* FS_H_ENV */
Index: openafs/src/WINNT/afsd/fs_utils.c
diff -c openafs/src/WINNT/afsd/fs_utils.c:1.7 openafs/src/WINNT/afsd/fs_utils.c:1.7.2.1
*** openafs/src/WINNT/afsd/fs_utils.c:1.7	Thu Jun  3 23:10:45 2004
--- openafs/src/WINNT/afsd/fs_utils.c	Sun Jan 30 23:05:02 2005
***************
*** 121,126 ****
--- 121,127 ----
      return 0;
  }
  
+ #ifdef COMMENT
  struct hostent *hostutil_GetHostByName(char *namep)
  {
  	struct hostent *thp;
***************
*** 149,154 ****
--- 150,156 ----
  	/* return static buffer */
          return hostNameBuffer;
  }
+ #endif
  
  /* is this a digit or a digit-like thing? */
  static int ismeta(ac, abase)
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.55.2.10 openafs/src/WINNT/afsd/smb.c:1.55.2.11
*** openafs/src/WINNT/afsd/smb.c:1.55.2.10	Mon Dec 13 09:13:09 2004
--- openafs/src/WINNT/afsd/smb.c	Sun Jan 30 23:17:43 2005
***************
*** 779,787 ****
      smb_vc_t *vcp;
  
      lock_ObtainWrite(&smb_rctLock);
!     for(vcp = smb_allVCsp; vcp; vcp=vcp->nextp) {
          if (lsn == vcp->lsn && lana == vcp->lana) {
!             vcp->refCount++;
              break;
          }
      }
--- 779,787 ----
      smb_vc_t *vcp;
  
      lock_ObtainWrite(&smb_rctLock);
!     for (vcp = smb_allVCsp; vcp; vcp=vcp->nextp) {
          if (lsn == vcp->lsn && lana == vcp->lana) {
!             smb_HoldVCNoLock(vcp);
              break;
          }
      }
***************
*** 842,847 ****
--- 842,852 ----
      return 0;
  }
  
+ void smb_ReleaseVCNoLock(smb_vc_t *vcp)
+ {
+     osi_assert(vcp->refCount-- > 0);
+ }       
+ 
  void smb_ReleaseVC(smb_vc_t *vcp)
  {
      lock_ObtainWrite(&smb_rctLock);
***************
*** 849,854 ****
--- 854,864 ----
      lock_ReleaseWrite(&smb_rctLock);
  }       
  
+ void smb_HoldVCNoLock(smb_vc_t *vcp)
+ {
+     vcp->refCount++;
+ }       
+ 
  void smb_HoldVC(smb_vc_t *vcp)
  {
      lock_ObtainWrite(&smb_rctLock);
***************
*** 873,879 ****
          tidp->nextp = vcp->tidsp;
          tidp->refCount = 1;
          tidp->vcp = vcp;
!         vcp->refCount++;
          vcp->tidsp = tidp;
          lock_InitializeMutex(&tidp->mx, "tid_t mutex");
          tidp->tid = tid;
--- 883,889 ----
          tidp->nextp = vcp->tidsp;
          tidp->refCount = 1;
          tidp->vcp = vcp;
!         smb_HoldVCNoLock(vcp);
          vcp->tidsp = tidp;
          lock_InitializeMutex(&tidp->mx, "tid_t mutex");
          tidp->tid = tid;
***************
*** 887,916 ****
      smb_tid_t *tp;
      smb_tid_t **ltpp;
      cm_user_t *userp;
-     smb_vc_t  *vcp;
  
      userp = NULL;
-     vcp = NULL;
      lock_ObtainWrite(&smb_rctLock);
      osi_assert(tidp->refCount-- > 0);
      if (tidp->refCount == 0 && (tidp->flags & SMB_TIDFLAG_DELETE)) {
          ltpp = &tidp->vcp->tidsp;
!         for(tp = *ltpp; tp; ltpp = &tp->nextp, tp = *ltpp) {
!             if (tp == tidp) break;
          }
          osi_assert(tp != NULL);
          *ltpp = tp->nextp;
          lock_FinalizeMutex(&tidp->mx);
          userp = tidp->userp;	/* remember to drop ref later */
!         vcp = tidp->vcp;
      }
      lock_ReleaseWrite(&smb_rctLock);
!     if (userp) {
          cm_ReleaseUser(userp);
-     }	
-     if (vcp) {
-         smb_ReleaseVC(vcp);
-     }   
  }	        
  
  smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags)
--- 897,923 ----
      smb_tid_t *tp;
      smb_tid_t **ltpp;
      cm_user_t *userp;
  
      userp = NULL;
      lock_ObtainWrite(&smb_rctLock);
      osi_assert(tidp->refCount-- > 0);
      if (tidp->refCount == 0 && (tidp->flags & SMB_TIDFLAG_DELETE)) {
          ltpp = &tidp->vcp->tidsp;
!         for (tp = *ltpp; tp; ltpp = &tp->nextp, tp = *ltpp) {
!             if (tp == tidp) 
!                 break;
          }
          osi_assert(tp != NULL);
          *ltpp = tp->nextp;
          lock_FinalizeMutex(&tidp->mx);
          userp = tidp->userp;	/* remember to drop ref later */
!         tidp->userp = NULL;
!         smb_ReleaseVCNoLock(tidp->vcp);
!         tidp->vcp = NULL;
      }
      lock_ReleaseWrite(&smb_rctLock);
!     if (userp)
          cm_ReleaseUser(userp);
  }	        
  
  smb_user_t *smb_FindUID(smb_vc_t *vcp, unsigned short uid, int flags)
***************
*** 933,939 ****
          uidp->nextp = vcp->usersp;
          uidp->refCount = 1;
          uidp->vcp = vcp;
!         vcp->refCount++;
          vcp->usersp = uidp;
          lock_InitializeMutex(&uidp->mx, "user_t mutex");
          uidp->userID = uid;
--- 940,946 ----
          uidp->nextp = vcp->usersp;
          uidp->refCount = 1;
          uidp->vcp = vcp;
!         smb_HoldVCNoLock(vcp);
          vcp->usersp = uidp;
          lock_InitializeMutex(&uidp->mx, "user_t mutex");
          uidp->userID = uid;
***************
*** 992,1001 ****
      smb_user_t *up;
      smb_user_t **lupp;
      cm_user_t *userp;
-     smb_vc_t  *vcp;
  
      userp = NULL;
-     vcp = NULL;
      lock_ObtainWrite(&smb_rctLock);
      osi_assert(uidp->refCount-- > 0);
      if (uidp->refCount == 0 && (uidp->flags & SMB_USERFLAG_DELETE)) {
--- 999,1006 ----
***************
*** 1007,1016 ****
          *lupp = up->nextp;
          lock_FinalizeMutex(&uidp->mx);
          if (uidp->unp) {
!             userp = uidp->unp->userp;	/* remember to drop ref later */
!             uidp->unp->userp = NULL;
          }       
!         vcp = uidp->vcp;
          uidp->vcp = NULL;
      }		
      lock_ReleaseWrite(&smb_rctLock);
--- 1012,1021 ----
          *lupp = up->nextp;
          lock_FinalizeMutex(&uidp->mx);
          if (uidp->unp) {
!             userp = uidp->unp->userp;	/* avoid deadlock by releasing */
!             uidp->unp->userp = NULL;    /* after releasing the lock */
          }       
!         smb_ReleaseVCNoLock(uidp->vcp);
          uidp->vcp = NULL;
      }		
      lock_ReleaseWrite(&smb_rctLock);
***************
*** 1018,1026 ****
          cm_ReleaseUserVCRef(userp);
          cm_ReleaseUser(userp);
      }	
-     if (vcp) {
-         smb_ReleaseVC(vcp);
-     }
  }	
  
  /* retrieve a held reference to a user structure corresponding to an incoming
--- 1023,1028 ----
***************
*** 1110,1116 ****
      }
  
    retry:
!     for(fidp = vcp->fidsp; fidp; fidp = (smb_fid_t *) osi_QNext(&fidp->q)) {
          if (fid == fidp->fid) {
              if (newFid) {
                  fid++;
--- 1112,1118 ----
      }
  
    retry:
!     for (fidp = vcp->fidsp; fidp; fidp = (smb_fid_t *) osi_QNext(&fidp->q)) {
          if (fid == fidp->fid) {
              if (newFid) {
                  fid++;
***************
*** 1141,1147 ****
          osi_QAdd((osi_queue_t **)&vcp->fidsp, &fidp->q);
          fidp->refCount = 1;
          fidp->vcp = vcp;
!         vcp->refCount++;
          lock_InitializeMutex(&fidp->mx, "fid_t mutex");
          fidp->fid = fid;
          fidp->curr_chunk = fidp->prev_chunk = -2;
--- 1143,1149 ----
          osi_QAdd((osi_queue_t **)&vcp->fidsp, &fidp->q);
          fidp->refCount = 1;
          fidp->vcp = vcp;
!         smb_HoldVCNoLock(vcp);
          lock_InitializeMutex(&fidp->mx, "fid_t mutex");
          fidp->fid = fid;
          fidp->curr_chunk = fidp->prev_chunk = -2;
***************
*** 1170,1193 ****
      osi_assert(fidp->refCount-- > 0);
      if (fidp->refCount == 0 && (fidp->flags & SMB_FID_DELETE)) {
          vcp = fidp->vcp;
!         if (!(fidp->flags & SMB_FID_IOCTL))
              scp = fidp->scp;
          osi_QRemove((osi_queue_t **) &vcp->fidsp, &fidp->q);
          thrd_CloseHandle(fidp->raw_write_event);
  
          /* and see if there is ioctl stuff to free */
          ioctlp = fidp->ioctlp;
          if (ioctlp) {
!             if (ioctlp->prefix) cm_FreeSpace(ioctlp->prefix);
!             if (ioctlp->inAllocp) free(ioctlp->inAllocp);
!             if (ioctlp->outAllocp) free(ioctlp->outAllocp);
              free(ioctlp);
          }       
  
          free(fidp);
  
!         /* do not call smb_ReleaseVC() because we already have the lock */
!         vcp->refCount--;
      }
      lock_ReleaseWrite(&smb_rctLock);
  
--- 1172,1201 ----
      osi_assert(fidp->refCount-- > 0);
      if (fidp->refCount == 0 && (fidp->flags & SMB_FID_DELETE)) {
          vcp = fidp->vcp;
!         fidp->vcp = NULL;
!         if (!(fidp->flags & SMB_FID_IOCTL)) {
              scp = fidp->scp;
+             fidp->scp = NULL;
+         }
+ 
          osi_QRemove((osi_queue_t **) &vcp->fidsp, &fidp->q);
          thrd_CloseHandle(fidp->raw_write_event);
  
          /* and see if there is ioctl stuff to free */
          ioctlp = fidp->ioctlp;
          if (ioctlp) {
!             if (ioctlp->prefix) 
!                 cm_FreeSpace(ioctlp->prefix);
!             if (ioctlp->inAllocp) 
!                 free(ioctlp->inAllocp);
!             if (ioctlp->outAllocp) 
!                 free(ioctlp->outAllocp);
              free(ioctlp);
          }       
  
          free(fidp);
  
!         smb_ReleaseVCNoLock(vcp);
      }
      lock_ReleaseWrite(&smb_rctLock);
  
***************
*** 1854,1859 ****
--- 1862,1869 ----
  
  void smb_FreePacket(smb_packet_t *tbp)
  {
+     smb_vc_t * vcp = NULL;
+ 
      osi_assert(tbp->magic == SMB_PACKETMAGIC);
          
      lock_ObtainWrite(&smb_globalLock);
***************
*** 1861,1866 ****
--- 1871,1877 ----
      smb_packetFreeListp = tbp;
      tbp->magic = SMB_PACKETMAGIC;
      tbp->ncbp = NULL;
+     vcp = tbp->vcp;
      tbp->vcp = NULL;
      tbp->resumeCode = 0;
      tbp->inCount = 0;
***************
*** 1871,1876 ****
--- 1882,1890 ----
      tbp->ncb_length = 0;
      tbp->flags = 0;
      lock_ReleaseWrite(&smb_globalLock);
+ 
+     if (vcp)
+         smb_ReleaseVC(vcp);
  }
  
  static void FreeNCB(NCB *bufferp)
***************
*** 2966,2971 ****
--- 2980,2987 ----
              cm_FreeSpace(inp->spacep);
              smb_FreePacket(inp);
              smb_FreePacket(outp);
+             if (vcp)
+                 smb_ReleaseVC(vcp);
              FreeNCB(ncbp);
              free(wL);
          } while (nwL);
***************
*** 3404,3413 ****
          memcpy(dsp->mask, mask, 11);
  
          /* track if this is likely to match a lot of entries */
!         if (smb_IsStarMask(mask)) starPattern = 1;
!         else starPattern = 0;
!     }	
!     else {
          /* pull the next cookie value out of the search status block */
          nextCookie = inCookiep[13] + (inCookiep[14]<<8) + (inCookiep[15]<<16)
              + (inCookiep[16]<<24);
--- 3420,3430 ----
          memcpy(dsp->mask, mask, 11);
  
          /* track if this is likely to match a lot of entries */
!         if (smb_IsStarMask(mask)) 
!             starPattern = 1;
!         else 
!             starPattern = 0;
!     } else {
          /* pull the next cookie value out of the search status block */
          nextCookie = inCookiep[13] + (inCookiep[14]<<8) + (inCookiep[15]<<16)
              + (inCookiep[16]<<24);
***************
*** 3837,3843 ****
      caseFold = CM_FLAG_CASEFOLD;
  
      code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if(code) {
          cm_ReleaseUser(userp);
          return CM_ERROR_NOSUCHPATH;
      }
--- 3854,3860 ----
      caseFold = CM_FLAG_CASEFOLD;
  
      code = smb_LookupTIDPath(vcp, ((smb_t *)inp)->tid, &tidPathp);
!     if (code) {
          cm_ReleaseUser(userp);
          return CM_ERROR_NOSUCHPATH;
      }
Index: openafs/src/WINNT/afsd/smb.h
diff -c openafs/src/WINNT/afsd/smb.h:1.14.2.7 openafs/src/WINNT/afsd/smb.h:1.14.2.8
*** openafs/src/WINNT/afsd/smb.h:1.14.2.7	Mon Dec 13 09:13:10 2004
--- openafs/src/WINNT/afsd/smb.h	Sun Jan 30 23:17:45 2005
***************
*** 436,441 ****
--- 436,443 ----
  
  extern void smb_ReleaseVC(smb_vc_t *vcp);
  
+ extern void smb_ReleaseVCNoLock(smb_vc_t *vcp);
+ 
  extern smb_tid_t *smb_FindTID(smb_vc_t *vcp, unsigned short tid, int flags);
  
  extern void smb_ReleaseTID(smb_tid_t *tidp);
***************
*** 513,518 ****
--- 515,522 ----
  
  extern void smb_HoldVC(smb_vc_t *vcp);
  
+ extern void smb_HoldVCNoLock(smb_vc_t *vcp);
+ 
  /* some globals, too */
  extern char *smb_localNamep;
  extern int loggedOut;
Index: openafs/src/WINNT/afsd/smb3.c
diff -c openafs/src/WINNT/afsd/smb3.c:1.42.2.14 openafs/src/WINNT/afsd/smb3.c:1.42.2.17
*** openafs/src/WINNT/afsd/smb3.c:1.42.2.14	Mon Dec 13 09:13:10 2004
--- openafs/src/WINNT/afsd/smb3.c	Sun Jan 30 23:24:58 2005
***************
*** 667,672 ****
--- 667,674 ----
              /* extended authentication */
              char *secBlobIn;
              int secBlobInLength;
+ 
+             OutputDebugF("NT Session Setup: Extended");
          
              if (!(vcp->flags & SMB_VCFLAG_SESSX_RCVD)) {
                  caps = smb_GetSMBParm(inp,10) | (((unsigned long) smb_GetSMBParm(inp,11)) << 16);
***************
*** 703,708 ****
--- 705,715 ----
              char *primaryDomain;
              int  datalen;
  
+             if (smb_authType == SMB_AUTH_NTLM)
+                 OutputDebugF("NT Session Setup: NTLM");
+             else
+                 OutputDebugF("NT Session Setup: None");
+ 
              /* TODO: parse for extended auth as well */
              ciPwdLength = smb_GetSMBParm(inp, 7); /* case insensitive password length */
              csPwdLength = smb_GetSMBParm(inp, 8); /* case sensitive password length */
***************
*** 719,724 ****
--- 726,736 ----
              accountName = smb_ParseString(tp, &tp);
              primaryDomain = smb_ParseString(tp, NULL);
  
+             OutputDebugF("Account Name: %s",accountName);
+             OutputDebugF("Primary Domain: %s", primaryDomain);
+             OutputDebugF("Case Sensitive Password: %s", csPwd && csPwd[0] ? "yes" : "no");
+             OutputDebugF("Case Insensitive Password: %s", ciPwd && ciPwd[0] ? "yes" : "no");
+ 
              if (smb_GetNormalizedUsername(usern, accountName, primaryDomain)) {
                  /* shouldn't happen */
                  code = CM_ERROR_BADSMB;
***************
*** 732,737 ****
--- 744,753 ----
  
              if (smb_authType == SMB_AUTH_NTLM) {
                  code = smb_AuthenticateUserLM(vcp, accountName, primaryDomain, ciPwd, ciPwdLength, csPwd, csPwdLength);
+                 if ( code )
+                     OutputDebugF("LM authentication failed [%d]", code);
+                 else
+                     OutputDebugF("LM authentication succeeded");
              }
          }
      }  else { /* V3 */
***************
*** 740,745 ****
--- 756,771 ----
          char *accountName;
          char *primaryDomain;
  
+         switch ( smb_authType ) {
+         case SMB_AUTH_EXTENDED:
+             OutputDebugF("V3 Session Setup: Extended");
+             break;
+         case SMB_AUTH_NTLM:
+             OutputDebugF("V3 Session Setup: NTLM");
+             break;
+         default:
+             OutputDebugF("V3 Session Setup: None");
+         }
          ciPwdLength = smb_GetSMBParm(inp, 7);
          tp = smb_GetSMBData(inp, NULL);
          ciPwd = tp;
***************
*** 748,753 ****
--- 774,783 ----
          accountName = smb_ParseString(tp, &tp);
          primaryDomain = smb_ParseString(tp, NULL);
  
+         OutputDebugF("Account Name: %s",accountName);
+         OutputDebugF("Primary Domain: %s", primaryDomain);
+         OutputDebugF("Case Insensitive Password: %s", ciPwd && ciPwd[0] ? "yes" : "no");
+ 
          if ( smb_GetNormalizedUsername(usern, accountName, primaryDomain)) {
              /* shouldn't happen */
              code = CM_ERROR_BADSMB;
***************
*** 759,764 ****
--- 789,798 ----
           */
          if (smb_authType == SMB_AUTH_NTLM || smb_authType == SMB_AUTH_EXTENDED) {
              code = smb_AuthenticateUserLM(vcp,accountName,primaryDomain,ciPwd,ciPwdLength,"",0);
+             if ( code )
+                 OutputDebugF("LM authentication failed [%d]", code);
+             else
+                 OutputDebugF("LM authentication succeeded");
          }
      }
  
***************
*** 1111,1117 ****
  /* free a tran2 packet; must be called with smb_globalLock held */
  void smb_FreeTran2Packet(smb_tran2Packet_t *t2p)
  {
!     if (t2p->vcp) smb_ReleaseVC(t2p->vcp);
      if (t2p->flags & SMB_TRAN2PFLAG_ALLOC) {
          if (t2p->parmsp)
              free(t2p->parmsp);
--- 1145,1152 ----
  /* free a tran2 packet; must be called with smb_globalLock held */
  void smb_FreeTran2Packet(smb_tran2Packet_t *t2p)
  {
!     if (t2p->vcp) 
!         smb_ReleaseVC(t2p->vcp);
      if (t2p->flags & SMB_TRAN2PFLAG_ALLOC) {
          if (t2p->parmsp)
              free(t2p->parmsp);
***************
*** 3708,3717 ****
          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);
              smb_DeleteDirSearch(dsp);
              smb_ReleaseDirSearch(dsp);
              return 0;
--- 3743,3752 ----
          smb_StripLastComponent(spacep->data, NULL, pathp);
          code = smb_LookupTIDPath(vcp, p->tid, &tidPathp);
          if (code) {
              cm_ReleaseUser(userp);
              smb_SendTran2Error(vcp, p, opx, CM_ERROR_NOFILES);
              smb_FreeTran2Packet(outp);
+             lock_ReleaseMutex(&dsp->mx);
              smb_DeleteDirSearch(dsp);
              smb_ReleaseDirSearch(dsp);
              return 0;
***************
*** 4337,4344 ****
           * and truncate the file if we find it, otherwise we create the
           * file.
           */
!         if (!lastNamep) lastNamep = pathp;
!         else lastNamep++;
          code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD, userp,
                            &req, &scp);
          if (code && code != CM_ERROR_NOSUCHFILE) {
--- 4372,4381 ----
           * and truncate the file if we find it, otherwise we create the
           * file.
           */
!         if (!lastNamep) 
!             lastNamep = pathp;
!         else 
!             lastNamep++;
          code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD, userp,
                            &req, &scp);
          if (code && code != CM_ERROR_NOSUCHFILE) {
***************
*** 4356,4362 ****
      if (code == 0) {
          code = cm_CheckOpen(scp, openMode, trunc, userp, &req);
          if (code) {
!             if (dscp) cm_ReleaseSCache(dscp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              return code;
--- 4393,4400 ----
      if (code == 0) {
          code = cm_CheckOpen(scp, openMode, trunc, userp, &req);
          if (code) {
!             if (dscp) 
!                 cm_ReleaseSCache(dscp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              return code;
***************
*** 4364,4370 ****
  
          if (excl) {
              /* oops, file shouldn't be there */
!             if (dscp) cm_ReleaseSCache(dscp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              return CM_ERROR_EXISTS;
--- 4402,4409 ----
  
          if (excl) {
              /* oops, file shouldn't be there */
!             if (dscp) 
!                 cm_ReleaseSCache(dscp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              return CM_ERROR_EXISTS;
***************
*** 4523,4529 ****
                        CM_SCACHESYNC_NEEDCALLBACK
  			 | CM_SCACHESYNC_GETSTATUS
  			 | CM_SCACHESYNC_LOCK);
! 	if (code) goto doneSync;
  
  	LockType = smb_GetSMBParm(inp, 3) & 0xff;
  	Timeout = (smb_GetSMBParm(inp, 5) << 16) + smb_GetSMBParm(inp, 4);
--- 4562,4569 ----
                        CM_SCACHESYNC_NEEDCALLBACK
  			 | CM_SCACHESYNC_GETSTATUS
  			 | CM_SCACHESYNC_LOCK);
! 	if (code) 
!             goto doneSync;
  
  	LockType = smb_GetSMBParm(inp, 3) & 0xff;
  	Timeout = (smb_GetSMBParm(inp, 5) << 16) + smb_GetSMBParm(inp, 4);
***************
*** 4585,4590 ****
--- 4625,4631 ----
                  /* Put on waiting list */
                  waitingLock = malloc(sizeof(smb_waitingLock_t));
                  waitingLock->vcp = vcp;
+                 smb_HoldVC(vcp);
                  waitingLock->inp = smb_CopyPacket(inp);
                  waitingLock->outp = smb_CopyPacket(outp);
                  waitingLock->timeRemaining = Timeout;
***************
*** 4597,4603 ****
                  /* don't send reply immediately */
                  outp->flags |= SMB_PACKETFLAG_NOSEND;
              }
!             if (code) break;
  	}       
  
      if (code) {
--- 4638,4645 ----
                  /* don't send reply immediately */
                  outp->flags |= SMB_PACKETFLAG_NOSEND;
              }
!             if (code) 
!                 break;
  	}       
  
      if (code) {
***************
*** 4852,4860 ****
  
      cm_InitReq(&req);
  
      treeCreate = FALSE;
      foundscp = FALSE;
-     scp = NULL;
  
      nameLength = smb_GetSMBOffsetParm(inp, 2, 1);
      flags = smb_GetSMBOffsetParm(inp, 3, 1)
--- 4894,4907 ----
  
      cm_InitReq(&req);
  
+     /* This code is very long and has a lot of if-then-else clauses
+      * scp and dscp get reused frequently and we need to ensure that 
+      * we don't lose a reference.  Start by ensuring that they are NULL.
+      */
+     scp = NULL;
+     dscp = NULL;
      treeCreate = FALSE;
      foundscp = FALSE;
  
      nameLength = smb_GetSMBOffsetParm(inp, 2, 1);
      flags = smb_GetSMBOffsetParm(inp, 3, 1)
***************
*** 5001,5008 ****
      if (desiredAccess & AFS_ACCESS_WRITE)
          fidflags |= SMB_FID_OPENWRITE;
  
-     dscp = NULL;
      code = 0;
      /* For an exclusive create, we want to do a case sensitive match for the last component. */
      if ( createDisp == FILE_CREATE || 
           createDisp == FILE_OVERWRITE ||
--- 5048,5055 ----
      if (desiredAccess & AFS_ACCESS_WRITE)
          fidflags |= SMB_FID_OPENWRITE;
  
      code = 0;
+ 
      /* For an exclusive create, we want to do a case sensitive match for the last component. */
      if ( createDisp == FILE_CREATE || 
           createDisp == FILE_OVERWRITE ||
***************
*** 5023,5037 ****
                      return CM_ERROR_EXISTS;
                  }
              }
!         } else
!             dscp = NULL;
      } else {
          code = cm_NameI(baseDirp, realPathp, CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                          userp, tidPathp, &req, &scp);
      }
-     if (code == 0) 
-         foundscp = TRUE;
  
      if (!foundscp || (fidflags & (SMB_FID_OPENDELETE | SMB_FID_OPENWRITE))) {
          /* look up parent directory */
          /* If we are trying to create a path (i.e. multiple nested directories), then we don't *need*
--- 5070,5086 ----
                      return CM_ERROR_EXISTS;
                  }
              }
!         }
!         /* we have both scp and dscp */
      } else {
          code = cm_NameI(baseDirp, realPathp, CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD,
                          userp, tidPathp, &req, &scp);
+         /* we might have scp but not dscp */
      }
  
+     if (scp)
+         foundscp = TRUE;
+     
      if (!foundscp || (fidflags & (SMB_FID_OPENDELETE | SMB_FID_OPENWRITE))) {
          /* look up parent directory */
          /* If we are trying to create a path (i.e. multiple nested directories), then we don't *need*
***************
*** 5039,5046 ****
           * recognize.
           */
  
!         if ( !dscp ) {
!             while (1) {
                  char *tp;
  
                  code = cm_NameI(baseDirp, spacep->data,
--- 5088,5097 ----
           * recognize.
           */
  
!         /* we might or might not have scp */
! 
!         if (dscp == NULL) {
!             do {
                  char *tp;
  
                  code = cm_NameI(baseDirp, spacep->data,
***************
*** 5060,5079 ****
                              smb_ReleaseFID(baseFidp);
                          cm_ReleaseUser(userp);
                          free(realPathp);
                          return CM_ERROR_BADNTFILENAME;
                      }
                  }
!                 else
!                     break;
!             }
          } else
!             code = 0;
  
          if (baseFid != 0) 
              smb_ReleaseFID(baseFidp);
  
          if (code) {
              osi_Log0(smb_logp,"NTCreateX parent not found");
              cm_ReleaseUser(userp);
              free(realPathp);
              return code;
--- 5111,5137 ----
                              smb_ReleaseFID(baseFidp);
                          cm_ReleaseUser(userp);
                          free(realPathp);
+                         if (scp)
+                             cm_ReleaseSCache(scp);
                          return CM_ERROR_BADNTFILENAME;
                      }
+                     code = 0;
                  }
!             } while (dscp == NULL && code == 0);
          } else
! 			code = 0;
! 
!         /* we might have scp and we might have dscp */
  
          if (baseFid != 0) 
              smb_ReleaseFID(baseFidp);
  
          if (code) {
              osi_Log0(smb_logp,"NTCreateX parent not found");
+             if (scp)
+                 cm_ReleaseSCache(scp);
+             if (dscp)
+                 cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
              free(realPathp);
              return code;
***************
*** 5081,5086 ****
--- 5139,5146 ----
  
          if (treeCreate && dscp->fileType == CM_SCACHETYPE_FILE) {
              /* A file exists where we want a directory. */
+             if (scp)
+                 cm_ReleaseSCache(scp);
              cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
              free(realPathp);
***************
*** 5093,5098 ****
--- 5153,5161 ----
              lastNamep++;
  
          if (!smb_IsLegalFilename(lastNamep)) {
+             if (scp)
+                 cm_ReleaseSCache(scp);
+ 			if (dscp)
              cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
              free(realPathp);
***************
*** 5118,5313 ****
                  return code;
              }
          }
!     }
!     else {
          if (baseFid != 0) 
              smb_ReleaseFID(baseFidp);
! 	}       
  
! 	/* if we get here, if code is 0, the file exists and is represented by
! 	 * scp.  Otherwise, we have to create it.  The dir may be represented
! 	 * by dscp, or we may have found the file directly.  If code is non-zero,
! 	 * scp is NULL.
! 	 */
! 	if (code == 0 && !treeCreate) {
!             if (createDisp == FILE_CREATE) {
!                 /* oops, file shouldn't be there */
!                 if (dscp) cm_ReleaseSCache(dscp);
!                 cm_ReleaseSCache(scp);
!                 cm_ReleaseUser(userp);
!                 free(realPathp);
!                 return CM_ERROR_EXISTS;
!             }
  
!             if ( createDisp == FILE_OVERWRITE || 
!                  createDisp == FILE_OVERWRITE_IF) {
!                 setAttr.mask = CM_ATTRMASK_LENGTH;
!                 setAttr.length.LowPart = 0;
!                 setAttr.length.HighPart = 0;
!                 /* now watch for a symlink */
!                 code = 0;
!                 while (code == 0 && scp->fileType == CM_SCACHETYPE_SYMLINK) {
!                     targetScp = 0;
!                     code = cm_EvaluateSymLink(dscp, scp, &targetScp, userp, &req);
!                     if (code == 0) {
!                         /* we have a more accurate file to use (the
!                         * target of the symbolic link).  Otherwise,
!                         * we'll just use the symlink anyway.
!                         */
!                         osi_Log2(smb_logp, "symlink vp %x to vp %x",
!                                   scp, targetScp);
!                         cm_ReleaseSCache(scp);
!                         scp = targetScp;
!                     }
                  }
-                 code = cm_SetAttr(scp, &setAttr, userp, &req);
-                 openAction = 3;	/* truncated existing file */
              }
!             else 
!                 openAction = 1;	/* found existing file */
  
!             code = cm_CheckNTOpen(scp, desiredAccess, createDisp, userp,
!                                   &req);
!             if (code) {
!                 if (dscp) cm_ReleaseSCache(dscp);
!                 cm_ReleaseSCache(scp);
!                 cm_ReleaseUser(userp);
!                 free(realPathp);
!                 return code;
!             }
! 	}       
! 	else if (createDisp == FILE_OPEN || createDisp == FILE_OVERWRITE) {
!             /* don't create if not found */
!             if (dscp) cm_ReleaseSCache(dscp);
              cm_ReleaseUser(userp);
              free(realPathp);
!             return CM_ERROR_NOSUCHFILE;
! 	}       
! 	else if (realDirFlag == 0 || realDirFlag == -1) {
!             osi_assert(dscp != NULL);
!             osi_Log1(smb_logp, "smb_ReceiveNTCreateX creating file %s",
!                       osi_LogSaveString(smb_logp, lastNamep));
!             openAction = 2;		/* created file */
!             setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
!             setAttr.clientModTime = time(NULL);
!             code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp,
!                               &req);
!             if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
                  smb_NotifyChange(FILE_ACTION_ADDED,
!                                   FILE_NOTIFY_CHANGE_FILE_NAME,
!                                   dscp, lastNamep, NULL, TRUE);
!             if (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE) {
                  /* Not an exclusive create, and someone else tried
                   * creating it already, then we open it anyway.  We
                   * don't bother retrying after this, since if this next
                   * fails, that means that the file was deleted after we
                   * started this call.
                   */
!                 code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD,
!                                   userp, &req, &scp);
!                 if (code == 0) {
!                     if (createDisp == FILE_OVERWRITE_IF) {
!                         setAttr.mask = CM_ATTRMASK_LENGTH;
!                         setAttr.length.LowPart = 0;
!                         setAttr.length.HighPart = 0;
! 
!                         /* now watch for a symlink */
!                         code = 0;
!                         while (code == 0 && scp->fileType == CM_SCACHETYPE_SYMLINK) {
!                             targetScp = 0;
!                             code = cm_EvaluateSymLink(dscp, scp, &targetScp, userp, &req);
!                             if (code == 0) {
!                                 /* we have a more accurate file to use (the
!                                 * target of the symbolic link).  Otherwise,
!                                 * we'll just use the symlink anyway.
!                                 */
!                                 osi_Log2(smb_logp, "symlink vp %x to vp %x",
!                                           scp, targetScp);
!                                 cm_ReleaseSCache(scp);
!                                 scp = targetScp;
!                             }
!                         }
!                         code = cm_SetAttr(scp, &setAttr, userp, &req);
!                     }
!                 }	/* lookup succeeded */
!             }
! 	}       
! 	else {
!             char *tp, *pp;
!             char *cp; /* This component */
!             int clen = 0; /* length of component */
!             cm_scache_t *tscp;
!             int isLast = 0;
! 		
!             /* create directory */
!             if ( !treeCreate ) 
!                 treeStartp = lastNamep;
!             osi_assert(dscp != NULL);
!             osi_Log1(smb_logp, "smb_ReceiveNTCreateX creating directory [%s]",
!                       osi_LogSaveString(smb_logp, treeStartp));
!             openAction = 2;		/* created directory */
! 
!             setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
!             setAttr.clientModTime = time(NULL);
! 		
!             pp = treeStartp;
!             cp = spacep->data;
!             tscp = dscp;
! 
!             while (pp && *pp) {
!                 tp = strchr(pp, '\\');
!                 if (!tp) {
!                     strcpy(cp,pp);
!                     clen = strlen(cp);
!                     isLast = 1; /* indicate last component.  the supplied path never ends in a slash */
!                 }
!                 else {
!                     clen = tp - pp;
!                     strncpy(cp,pp,clen);
!                     *(cp + clen) = 0;
!                     tp++;
!                 }
!                 pp = tp;
! 
!                 if (clen == 0) 
!                     continue; /* the supplied path can't have consecutive slashes either , but */
! 
!                 /* cp is the next component to be created. */
!                 code = cm_MakeDir(tscp, cp, 0, &setAttr, userp, &req);
!                 if (code == 0 && (tscp->flags & CM_SCACHEFLAG_ANYWATCH))
!                     smb_NotifyChange(FILE_ACTION_ADDED,
!                                       FILE_NOTIFY_CHANGE_DIR_NAME,
!                                       tscp, cp, NULL, TRUE);
!                 if (code == 0 || 
!                      (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE)) {
!                     /* Not an exclusive create, and someone else tried
!                      * creating it already, then we open it anyway.  We
!                      * don't bother retrying after this, since if this next
!                      * fails, that means that the file was deleted after we
!                      * started this call.
!                      */
!                     code = cm_Lookup(tscp, cp, CM_FLAG_CASEFOLD,
!                                       userp, &req, &scp);
!                 }
!                 if (code) break;
  
!                 if (!isLast) { /* for anything other than dscp, release it unless it's the last one */
!                     cm_ReleaseSCache(tscp);
!                     tscp = scp; /* Newly created directory will be next parent */
!                 }
              }
  
!             /* 
!              * if we get here and code == 0, then scp is the last directory created, and tscp is the
!              * parent of scp.  dscp got released if dscp != tscp. both tscp and scp are held.
!              */
!             dscp = tscp;
! 	}
  
      if (code) {
          /* something went wrong creating or truncating the file */
!         if (scp) cm_ReleaseSCache(scp);
!         if (dscp) cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
          free(realPathp);
          return code;
--- 5181,5388 ----
                  return code;
              }
          }
!         /* we have scp and dscp */
!     } else {
!         /* we have scp but not dscp */
          if (baseFid != 0) 
              smb_ReleaseFID(baseFidp);
!     }       
  
!     /* if we get here, if code is 0, the file exists and is represented by
!      * scp.  Otherwise, we have to create it.  The dir may be represented
!      * by dscp, or we may have found the file directly.  If code is non-zero,
!      * scp is NULL.
!      */
!     if (code == 0 && !treeCreate) {
!         if (createDisp == FILE_CREATE) {
!             /* oops, file shouldn't be there */
!             if (dscp)
!                 cm_ReleaseSCache(dscp);
!             cm_ReleaseSCache(scp);
!             cm_ReleaseUser(userp);
!             free(realPathp);
!             return CM_ERROR_EXISTS;
!         }
  
!         if ( createDisp == FILE_OVERWRITE || 
!              createDisp == FILE_OVERWRITE_IF) {
!             setAttr.mask = CM_ATTRMASK_LENGTH;
!             setAttr.length.LowPart = 0;
!             setAttr.length.HighPart = 0;
!             /* now watch for a symlink */
!             code = 0;
!             while (code == 0 && scp->fileType == CM_SCACHETYPE_SYMLINK) {
!                 targetScp = 0;
!                 osi_assert(dscp != NULL);
!                 code = cm_EvaluateSymLink(dscp, scp, &targetScp, userp, &req);
!                 if (code == 0) {
!                     /* we have a more accurate file to use (the
!                      * target of the symbolic link).  Otherwise,
!                      * we'll just use the symlink anyway.
!                      */
!                     osi_Log2(smb_logp, "symlink vp %x to vp %x",
!                               scp, targetScp);
!                     cm_ReleaseSCache(scp);
!                     scp = targetScp;
                  }
              }
!             code = cm_SetAttr(scp, &setAttr, userp, &req);
!             openAction = 3;	/* truncated existing file */
!         }
!         else 
!             openAction = 1;	/* found existing file */
  
!         code = cm_CheckNTOpen(scp, desiredAccess, createDisp, userp, &req);
!         if (code) {
!             if (dscp)
!                 cm_ReleaseSCache(dscp);
!             cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
!             return code;
!         }
!     } else if (createDisp == FILE_OPEN || createDisp == FILE_OVERWRITE) {
!         /* don't create if not found */
!         if (dscp)
!             cm_ReleaseSCache(dscp);
!         if (scp)
!             cm_ReleaseSCache(scp);
!         cm_ReleaseUser(userp);
!         free(realPathp);
!         return CM_ERROR_NOSUCHFILE;
!     } else if (realDirFlag == 0 || realDirFlag == -1) {
!         osi_assert(dscp != NULL);
!         osi_Log1(smb_logp, "smb_ReceiveNTCreateX creating file %s",
!                   osi_LogSaveString(smb_logp, lastNamep));
!         openAction = 2;		/* created file */
!         setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
!         setAttr.clientModTime = time(NULL);
!         code = cm_Create(dscp, lastNamep, 0, &setAttr, &scp, userp, &req);
!         if (code == 0 && (dscp->flags & CM_SCACHEFLAG_ANYWATCH))
!             smb_NotifyChange(FILE_ACTION_ADDED,
!                               FILE_NOTIFY_CHANGE_FILE_NAME,
!                               dscp, lastNamep, NULL, TRUE);
!         if (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE) {
!             /* Not an exclusive create, and someone else tried
!              * creating it already, then we open it anyway.  We
!              * don't bother retrying after this, since if this next
!              * fails, that means that the file was deleted after we
!              * started this call.
!              */
!             code = cm_Lookup(dscp, lastNamep, CM_FLAG_CASEFOLD,
!                               userp, &req, &scp);
!             if (code == 0) {
!                 if (createDisp == FILE_OVERWRITE_IF) {
!                     setAttr.mask = CM_ATTRMASK_LENGTH;
!                     setAttr.length.LowPart = 0;
!                     setAttr.length.HighPart = 0;
! 
!                     /* now watch for a symlink */
!                     code = 0;
!                     while (code == 0 && scp->fileType == CM_SCACHETYPE_SYMLINK) {
!                         targetScp = 0;
!                         code = cm_EvaluateSymLink(dscp, scp, &targetScp, userp, &req);
!                         if (code == 0) {
!                             /* we have a more accurate file to use (the
!                              * target of the symbolic link).  Otherwise,
!                              * we'll just use the symlink anyway.
!                              */
!                             osi_Log2(smb_logp, "symlink vp %x to vp %x",
!                                       scp, targetScp);
!                             cm_ReleaseSCache(scp);
!                             scp = targetScp;
!                         }
!                     }
!                     code = cm_SetAttr(scp, &setAttr, userp, &req);
!                 }
!             }	/* lookup succeeded */
!         }
!     } else {
!         char *tp, *pp;
!         char *cp; /* This component */
!         int clen = 0; /* length of component */
!         cm_scache_t *tscp1, *tscp2;
!         int isLast = 0;
! 
!         /* create directory */
!         if ( !treeCreate ) 
!             treeStartp = lastNamep;
!         osi_assert(dscp != NULL);
!         osi_Log1(smb_logp, "smb_ReceiveNTCreateX creating directory [%s]",
!                   osi_LogSaveString(smb_logp, treeStartp));
!         openAction = 2;		/* created directory */
! 
!         setAttr.mask = CM_ATTRMASK_CLIENTMODTIME;
!         setAttr.clientModTime = time(NULL);
! 
!         pp = treeStartp;
!         cp = spacep->data;
!         tscp1 = dscp;
!         cm_HoldSCache(tscp1);
!         tscp2 = NULL;
! 
!         while (pp && *pp) {
!             tp = strchr(pp, '\\');
!             if (!tp) {
!                 strcpy(cp,pp);
!                 clen = strlen(cp);
!                 isLast = 1; /* indicate last component.  the supplied path never ends in a slash */
!             } else {
!                 clen = tp - pp;
!                 strncpy(cp,pp,clen);
!                 *(cp + clen) = 0;
!                 tp++;
!             }
!             pp = tp;
! 
!             if (clen == 0) 
!                 continue; /* the supplied path can't have consecutive slashes either , but */
! 
!             /* cp is the next component to be created. */
!             code = cm_MakeDir(tscp1, cp, 0, &setAttr, userp, &req);
!             if (code == 0 && (tscp1->flags & CM_SCACHEFLAG_ANYWATCH))
                  smb_NotifyChange(FILE_ACTION_ADDED,
!                                   FILE_NOTIFY_CHANGE_DIR_NAME,
!                                   tscp1, cp, NULL, TRUE);
!             if (code == 0 || 
!                  (code == CM_ERROR_EXISTS && createDisp != FILE_CREATE)) {
                  /* Not an exclusive create, and someone else tried
                   * creating it already, then we open it anyway.  We
                   * don't bother retrying after this, since if this next
                   * fails, that means that the file was deleted after we
                   * started this call.
                   */
!                 code = cm_Lookup(tscp1, cp, CM_FLAG_CASEFOLD,
!                                   userp, &req, &tscp2);
!             }       
!             if (code) 
!                 break;
  
!             if (!isLast) { /* for anything other than dscp, release it unless it's the last one */
!                 cm_ReleaseSCache(tscp1);
!                 tscp1 = tscp2; /* Newly created directory will be next parent */
!                 /* the hold is transfered to tscp1 from tscp2 */
              }
+         }
  
!         if (dscp)
!             cm_ReleaseSCache(dscp);
!         dscp = tscp1;
!         if (scp)
!             cm_ReleaseSCache(scp);
!         scp = tscp2;
!         /* 
!          * if we get here and code == 0, then scp is the last directory created, and dscp is the
!          * parent of scp.
!          */
!     }
  
      if (code) {
          /* something went wrong creating or truncating the file */
!         if (scp) 
!             cm_ReleaseSCache(scp);
!         if (dscp) 
!             cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
          free(realPathp);
          return code;
***************
*** 5325,5338 ****
                  * target of the symbolic link).  Otherwise,
                  * we'll just use the symlink anyway.
                  */
!                 osi_Log2(smb_logp, "symlink vp %x to vp %x",
!                           scp, targetScp);
                  cm_ReleaseSCache(scp);
                  scp = targetScp;
              }
          }
  
          if (scp->fileType != CM_SCACHETYPE_FILE) {
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
--- 5400,5414 ----
                  * target of the symbolic link).  Otherwise,
                  * we'll just use the symlink anyway.
                  */
!                 osi_Log2(smb_logp, "symlink vp %x to vp %x", scp, targetScp);
                  cm_ReleaseSCache(scp);
                  scp = targetScp;
              }
          }
  
          if (scp->fileType != CM_SCACHETYPE_FILE) {
+ 			if (dscp)
+             cm_ReleaseSCache(dscp);
              cm_ReleaseSCache(scp);
              cm_ReleaseUser(userp);
              free(realPathp);
***************
*** 5343,5349 ****
      /* (only applies to single component case) */
      if (realDirFlag == 1 && scp->fileType == CM_SCACHETYPE_FILE) {
          cm_ReleaseSCache(scp);
!         if (dscp) cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
          free(realPathp);
          return CM_ERROR_NOTDIR;
--- 5419,5425 ----
      /* (only applies to single component case) */
      if (realDirFlag == 1 && scp->fileType == CM_SCACHETYPE_FILE) {
          cm_ReleaseSCache(scp);
!         cm_ReleaseSCache(dscp);
          cm_ReleaseUser(userp);
          free(realPathp);
          return CM_ERROR_NOTDIR;
***************
*** 5353,5359 ****
      fidp = smb_FindFID(vcp, 0, SMB_FLAG_CREATE);
      osi_assert(fidp);
      /* save a pointer to the vnode */
!     fidp->scp = scp;
  
      fidp->flags = fidflags;
  
--- 5429,5435 ----
      fidp = smb_FindFID(vcp, 0, SMB_FLAG_CREATE);
      osi_assert(fidp);
      /* save a pointer to the vnode */
!     fidp->scp = scp;    /* Hold transfered to fidp->scp and no longer needed */
  
      fidp->flags = fidflags;
  
***************
*** 5367,5373 ****
      fidp->NTopen_wholepathp = realPathp;
  
      /* we don't need this any longer */
!     if (dscp) cm_ReleaseSCache(dscp);
      cm_Open(scp, 0, userp);
  
      /* set inp->fid so that later read calls in same msg can find fid */
--- 5443,5452 ----
      fidp->NTopen_wholepathp = realPathp;
  
      /* we don't need this any longer */
!     if (dscp) {
!         cm_ReleaseSCache(dscp);
!         dscp = NULL;
!     }
      cm_Open(scp, 0, userp);
  
      /* set inp->fid so that later read calls in same msg can find fid */
***************
*** 5408,5413 ****
--- 5487,5493 ----
      return 0;
  }       
  
+ 
  /*
   * A lot of stuff copied verbatim from NT Create&X to NT Tran Create.
   * Instead, ultimately, would like to use a subroutine for common code.
***************
*** 6318,6324 ****
          }
  
          smb_SendPacket(vcp, watch);
-         smb_ReleaseVC(vcp);
          smb_FreePacket(watch);
          watch = nextWatch;
      }
--- 6398,6403 ----
***************
*** 6385,6392 ****
              ((smb_t *)watch)->errHigh = 0xC0;
              ((smb_t *)watch)->flg2 |= SMB_FLAGS2_ERR_STATUS;
              smb_SendPacket(vcp, watch);
-             if (watch->vcp)
-                 smb_ReleaseVC(watch->vcp);
              smb_FreePacket(watch);
              return 0;
          }
--- 6464,6469 ----
***************
*** 6411,6417 ****
  {
      char *oldPathp, *newPathp;
      long code = 0;
-     cm_user_t *userp;
      char * tp;
      int attrs;
      int rename_type;
--- 6488,6493 ----
Index: openafs/src/WINNT/aklog/aklog.c
diff -c openafs/src/WINNT/aklog/aklog.c:1.5.2.3 openafs/src/WINNT/aklog/aklog.c:1.5.2.5
*** openafs/src/WINNT/aklog/aklog.c:1.5.2.3	Mon Oct 18 00:09:34 2004
--- openafs/src/WINNT/aklog/aklog.c	Sun Jan 30 23:09:10 2005
***************
*** 24,29 ****
--- 24,30 ----
  #include <krb.h>
  #include <krb5.h>
  #include <afs/ptserver.h>
+ #include <afs/ptuser.h>
  
  #ifdef WIN32
  #include <windows.h>
***************
*** 280,286 ****
               * level
               */
  
!             if ((*status = pr_Initialize(1L, confname, aserver->cell, 0))) {
                  printf("Error %d\n", status);
                  return;
              }
--- 281,287 ----
               * level
               */
  
!             if ((*status = pr_Initialize(1L, confname, aserver->cell))) {
                  printf("Error %d\n", status);
                  return;
              }
Index: openafs/src/WINNT/client_exp/NTMakefile
diff -c openafs/src/WINNT/client_exp/NTMakefile:1.7 openafs/src/WINNT/client_exp/NTMakefile:1.7.2.1
*** openafs/src/WINNT/client_exp/NTMakefile:1.7	Sat Mar  6 10:25:53 2004
--- openafs/src/WINNT/client_exp/NTMakefile	Sun Jan 30 23:05:03 2005
***************
*** 59,65 ****
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\libafsconf.lib \
  	$(DESTDIR)\lib\libosi.lib \
! 	$(DESTDIR)\lib\afs\TaLocale.lib
  
  $(DLLFILE): $(DLLOBJS) $(DLLLIBS)
  	$(DLLCONLINK) /DEF:afs_shl_ext.def $(DLLSDKLIBS)
--- 59,66 ----
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\libafsconf.lib \
  	$(DESTDIR)\lib\libosi.lib \
! 	$(DESTDIR)\lib\afs\TaLocale.lib \
! 	$(DESTDIR)\lib\afs\afsutil.lib
  
  $(DLLFILE): $(DLLOBJS) $(DLLLIBS)
  	$(DLLCONLINK) /DEF:afs_shl_ext.def $(DLLSDKLIBS)
Index: openafs/src/WINNT/install/wix/config.wxi
diff -c openafs/src/WINNT/install/wix/config.wxi:1.6.2.1 openafs/src/WINNT/install/wix/config.wxi:1.6.2.2
*** openafs/src/WINNT/install/wix/config.wxi:1.6.2.1	Fri Nov  5 14:21:57 2004
--- openafs/src/WINNT/install/wix/config.wxi	Sun Jan 30 22:53:24 2005
***************
*** 101,107 ****
          <?error AFSDEV_BUILDTYPE is not set in the environment.?>
      <?endif?>
  
!     <!-- We are including debug symbols anyway.  Undefine this for a leaner installer witout debug syms. -->
      <?define DebugSyms?>
  
      <!-- Parameters for the features containing debug symbols -->
--- 101,107 ----
          <?error AFSDEV_BUILDTYPE is not set in the environment.?>
      <?endif?>
  
!     <!-- We are including debug symbols anyway.  Undefine this for a leaner installer without debug syms. -->
      <?define DebugSyms?>
  
      <!-- Parameters for the features containing debug symbols -->
Index: openafs/src/afs/afs.h
diff -c openafs/src/afs/afs.h:1.48.2.4 openafs/src/afs/afs.h:1.48.2.8
*** openafs/src/afs/afs.h:1.48.2.4	Fri Dec 17 10:29:28 2004
--- openafs/src/afs/afs.h	Sun Jan 30 23:24:34 2005
***************
*** 562,580 ****
  #define VREFCOUNT_SET(v, c)	atomic_set(&((vnode_t *) v)->v_count, c)
  #define VREFCOUNT_DEC(v)	atomic_dec(&((vnode_t *) v)->v_count)
  #define VREFCOUNT_INC(v)	atomic_inc(&((vnode_t *) v)->v_count)
- #define DLOCK()      spin_lock(&dcache_lock)
- #define DUNLOCK()    spin_unlock(&dcache_lock)
- #define DGET(d)      dget_locked(d)
- #define DCOUNT(d)    atomic_read(&(d)->d_count)
  #else
  #define VREFCOUNT(v)		((v)->vrefCount)
  #define VREFCOUNT_SET(v, c)	(v)->vrefCount = c;
  #define VREFCOUNT_DEC(v)	(v)->vrefCount--;
  #define VREFCOUNT_INC(v)	(v)->vrefCount++;
! #define DLOCK()
! #define DUNLOCK()
! #define DGET(d)      dget(d)
! #define DCOUNT(d)    ((d)->d_count)
  #endif
  
  #define	AFS_MAXDV   0x7fffffff	/* largest dataversion number */
--- 562,574 ----
  #define VREFCOUNT_SET(v, c)	atomic_set(&((vnode_t *) v)->v_count, c)
  #define VREFCOUNT_DEC(v)	atomic_dec(&((vnode_t *) v)->v_count)
  #define VREFCOUNT_INC(v)	atomic_inc(&((vnode_t *) v)->v_count)
  #else
  #define VREFCOUNT(v)		((v)->vrefCount)
  #define VREFCOUNT_SET(v, c)	(v)->vrefCount = c;
  #define VREFCOUNT_DEC(v)	(v)->vrefCount--;
  #define VREFCOUNT_INC(v)	(v)->vrefCount++;
! #define d_unhash(d) list_empty(&(d)->d_hash)
! #define dget_locked(d) dget(d)
  #endif
  
  #define	AFS_MAXDV   0x7fffffff	/* largest dataversion number */
***************
*** 1195,1201 ****
  extern int afs_fakestat_enable;
  
  struct buffer {
!     struct dcache *fid;
      afs_int32 page;
      afs_int32 accesstime;
      struct buffer *hashNext;
--- 1189,1196 ----
  extern int afs_fakestat_enable;
  
  struct buffer {
!     afs_int32 fid;		/* is adc->index, the cache file number */
!     afs_inode_t inode;		/* is adc->f.inode, the inode number of the cache file */
      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.2 openafs/src/afs/afs_buffer.c:1.16.2.3
*** openafs/src/afs/afs_buffer.c:1.16.2.2	Tue Nov  9 12:14:57 2004
--- openafs/src/afs/afs_buffer.c	Sun Jan 30 23:18:41 2005
***************
*** 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"
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_buffer.c,v 1.16.2.3 2005/01/31 04:18:41 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)->f.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)) & PHFIDMASK) \
  			 | (page & PHPAGEMASK))
  
  #ifdef	dirty
***************
*** 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;
--- 88,94 ----
  static afs_int32 timecounter;
  
  /* Prototypes for static routines */
! static struct buffer *afs_newslot(struct dcache *adc, afs_int32 apage,
  				  register struct buffer *lp);
  
  static int dinit_flag = 0;
***************
*** 130,136 ****
  #endif
  	/* Fill in each buffer with an empty indication. */
  	tb = &Buffers[i];
! 	dirp_Zap(tb->fid);
  	tb->accesstime = 0;
  	tb->lockers = 0;
  #if AFS_USEBUFFERS
--- 130,137 ----
  #endif
  	/* Fill in each buffer with an empty indication. */
  	tb = &Buffers[i];
! 	tb->fid = 0;
! 	tb->inode = 0;
  	tb->accesstime = 0;
  	tb->lockers = 0;
  #if AFS_USEBUFFERS
***************
*** 150,156 ****
  }
  
  void *
! DRead(register struct dcache * fid, register int page)
  {
      /* Read a page from the disk. */
      register struct buffer *tb, *tb2;
--- 151,157 ----
  }
  
  void *
! DRead(register struct dcache *adc, register int page)
  {
      /* Read a page from the disk. */
      register struct buffer *tb, *tb2;
***************
*** 160,166 ****
      AFS_STATCNT(DRead);
      MObtainWriteLock(&afs_bufferLock, 256);
  
! #define bufmatch(tb) (tb->page == page && dirp_Eq(tb->fid, fid))
  #define buf_Front(head,parent,p) {(parent)->hashNext = (p)->hashNext; (p)->hashNext= *(head);*(head)=(p);}
  
      /* this apparently-complicated-looking code is simply an example of
--- 161,167 ----
      AFS_STATCNT(DRead);
      MObtainWriteLock(&afs_bufferLock, 256);
  
! #define bufmatch(tb) (tb->page == page && tb->fid == adc->index)
  #define buf_Front(head,parent,p) {(parent)->hashNext = (p)->hashNext; (p)->hashNext= *(head);*(head)=(p);}
  
      /* this apparently-complicated-looking code is simply an example of
***************
*** 169,175 ****
       * of larger code size.  This could be simplified by better use of
       * macros. 
       */
!     if ((tb = phTable[pHash(fid, page)])) {
  	if (bufmatch(tb)) {
  	    MObtainWriteLock(&tb->lock, 257);
  	    ReleaseWriteLock(&afs_bufferLock);
--- 170,176 ----
       * of larger code size.  This could be simplified by better use of
       * macros. 
       */
!     if ((tb = phTable[pHash(adc->index, page)])) {
  	if (bufmatch(tb)) {
  	    MObtainWriteLock(&tb->lock, 257);
  	    ReleaseWriteLock(&afs_bufferLock);
***************
*** 180,186 ****
  	    return tb->data;
  	} else {
  	    register struct buffer **bufhead;
! 	    bufhead = &(phTable[pHash(fid, page)]);
  	    while ((tb2 = tb->hashNext)) {
  		if (bufmatch(tb2)) {
  		    buf_Front(bufhead, tb, tb2);
--- 181,187 ----
  	    return tb->data;
  	} else {
  	    register struct buffer **bufhead;
! 	    bufhead = &(phTable[pHash(adc->index, page)]);
  	    while ((tb2 = tb->hashNext)) {
  		if (bufmatch(tb2)) {
  		    buf_Front(bufhead, tb, tb2);
***************
*** 216,222 ****
       * is at least the oldest buffer on one particular hash chain, so it's 
       * a pretty good place to start looking for the truly oldest buffer.
       */
!     tb = afs_newslot(fid, page, (tb ? tb : tb2));
      if (!tb) {
  	MReleaseWriteLock(&afs_bufferLock);
  	return NULL;
--- 217,223 ----
       * is at least the oldest buffer on one particular hash chain, so it's 
       * a pretty good place to start looking for the truly oldest buffer.
       */
!     tb = afs_newslot(adc, page, (tb ? tb : tb2));
      if (!tb) {
  	MReleaseWriteLock(&afs_bufferLock);
  	return NULL;
***************
*** 224,242 ****
      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);
      afs_CFileClose(tfile);
      if (code < AFS_BUFFER_PAGESIZE) {
! 	dirp_Zap(tb->fid);
  	tb->lockers--;
  	MReleaseWriteLock(&tb->lock);
  	return NULL;
--- 225,245 ----
      MObtainWriteLock(&tb->lock, 260);
      MReleaseWriteLock(&afs_bufferLock);
      tb->lockers++;
!     if (page * AFS_BUFFER_PAGESIZE >= adc->f.chunkBytes) {
! 	tb->fid = 0;
! 	tb->inode = 0;
  	tb->lockers--;
  	MReleaseWriteLock(&tb->lock);
  	return NULL;
      }
!     tfile = afs_CFileOpen(adc->f.inode);
      code =
  	afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
  		      AFS_BUFFER_PAGESIZE);
      afs_CFileClose(tfile);
      if (code < AFS_BUFFER_PAGESIZE) {
! 	tb->fid = 0;
! 	tb->inode = 0;
  	tb->lockers--;
  	MReleaseWriteLock(&tb->lock);
  	return NULL;
***************
*** 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;
--- 276,282 ----
  
  /* lp is pointer to a fairly-old buffer */
  static struct buffer *
! afs_newslot(struct dcache *adc, 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->f.inode);
  	afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
  		       AFS_BUFFER_PAGESIZE);
  	lp->dirty = 0;
--- 343,350 ----
      }
  
      if (lp->dirty) {
! 	/* see DFlush for rationale for not getting and locking the dcache */
! 	tfile = afs_CFileOpen(lp->inode);
  	afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
  		       AFS_BUFFER_PAGESIZE);
  	lp->dirty = 0;
***************
*** 349,355 ****
      }
  
      /* Now fill in the header. */
!     dirp_Cpy(lp->fid, afid);	/* set this */
      lp->page = apage;
      lp->accesstime = timecounter++;
      FixupBucket(lp);		/* move to the right hash bucket */
--- 353,360 ----
      }
  
      /* Now fill in the header. */
!     lp->fid = adc->index;
!     lp->inode = adc->f.inode;
      lp->page = apage;
      lp->accesstime = timecounter++;
      FixupBucket(lp);		/* move to the right hash bucket */
***************
*** 432,438 ****
   * method of DRead...
   */
  void
! DZap(struct dcache * fid)
  {
      register int i;
      /* Destroy all buffers pertaining to a particular fid. */
--- 437,443 ----
   * method of DRead...
   */
  void
! DZap(struct dcache *adc)
  {
      register int i;
      /* Destroy all buffers pertaining to a particular fid. */
***************
*** 442,451 ****
      MObtainReadLock(&afs_bufferLock);
  
      for (i = 0; i <= PHPAGEMASK; i++)
! 	for (tb = phTable[pHash(fid, i)]; tb; tb = tb->hashNext)
! 	    if (dirp_Eq(tb->fid, fid)) {
  		MObtainWriteLock(&tb->lock, 262);
! 		dirp_Zap(tb->fid);
  		tb->dirty = 0;
  		MReleaseWriteLock(&tb->lock);
  	    }
--- 447,457 ----
      MObtainReadLock(&afs_bufferLock);
  
      for (i = 0; i <= PHPAGEMASK; i++)
! 	for (tb = phTable[pHash(adc->index, i)]; tb; tb = tb->hashNext)
! 	    if (tb->fid == adc->index) {
  		MObtainWriteLock(&tb->lock, 262);
! 		tb->fid = 0;
! 		tb->inode = 0;
  		tb->dirty = 0;
  		MReleaseWriteLock(&tb->lock);
  	    }
***************
*** 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 */
--- 475,492 ----
  	    tb->lockers++;
  	    MReleaseReadLock(&afs_bufferLock);
  	    if (tb->dirty) {
! 		/* it seems safe to do this I/O without having the dcache
! 		 * locked, since the only things that will update the data in
! 		 * a directory are the buffer package, which holds the relevant
! 		 * tb->lock while doing the write, or afs_GetDCache, which 
! 		 * DZap's the directory while holding the dcache lock.
! 		 * It is not possible to lock the dcache or even call
! 		 * afs_GetDSlot to map the index to the dcache since the dir
! 		 * package's caller has some dcache object locked already (so
! 		 * we cannot lock afs_xdcache). In addition, we cannot obtain
! 		 * a dcache lock while holding the tb->lock of the same file
! 		 * since that can deadlock with DRead/DNew */
! 		tfile = afs_CFileOpen(tb->inode);
  		afs_CFileWrite(tfile, tb->page * AFS_BUFFER_PAGESIZE,
  			       tb->data, AFS_BUFFER_PAGESIZE);
  		tb->dirty = 0;	/* Clear the dirty flag */
***************
*** 484,503 ****
  }
  
  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;
      AFS_STATCNT(DNew);
      MObtainWriteLock(&afs_bufferLock, 264);
!     if ((tb = afs_newslot(fid, page, NULL)) == 0) {
  	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);
--- 501,524 ----
  }
  
  void *
! DNew(register struct dcache *adc, 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;
      AFS_STATCNT(DNew);
      MObtainWriteLock(&afs_bufferLock, 264);
!     if ((tb = afs_newslot(adc, page, NULL)) == 0) {
  	MReleaseWriteLock(&afs_bufferLock);
  	return 0;
      }
      /* extend the chunk, if needed */
!     /* Do it now, not in DFlush or afs_newslot when the data is written out,
!      * since now our caller has adc->lock writelocked, and we can't acquire
!      * that lock (or even map from a fid to a dcache) in afs_newslot or
!      * DFlush due to lock hierarchy issues */
!     if ((page + 1) * AFS_BUFFER_PAGESIZE > adc->f.chunkBytes) {
! 	afs_AdjustSize(adc, (page + 1) * AFS_BUFFER_PAGESIZE);
! 	afs_WriteDCache(adc, 1);
      }
      MObtainWriteLock(&tb->lock, 265);
      MReleaseWriteLock(&afs_bufferLock);
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.74.2.3 openafs/src/afs/afs_call.c:1.74.2.4
*** openafs/src/afs/afs_call.c:1.74.2.3	Tue Dec  7 01:12:11 2004
--- openafs/src/afs/afs_call.c	Sun Jan 30 23:23:22 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.3 2004/12/07 06:12:11 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.4 2005/01/31 04:23:22 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 2617,2626 ****
      ObtainWriteLock(&logp->lock, 189);
      if (--logp->setCount == 0) {
  	/* no more users -- free it (but keep log structure around) */
- 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
  	logp->firstUsed = logp->firstFree = 0;
  	logp->logElements = 0;
  	logp->datap = NULL;
--- 2617,2626 ----
      ObtainWriteLock(&logp->lock, 189);
      if (--logp->setCount == 0) {
  	/* no more users -- free it (but keep log structure around) */
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
+ 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  	logp->firstUsed = logp->firstFree = 0;
  	logp->logElements = 0;
  	logp->datap = NULL;
***************
*** 2643,2652 ****
  	logp->logElements = 0;
  
  	/* free and allocate a new one */
- 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
  	logp->datap =
  	    (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
  #ifdef	KERNEL_HAVE_PIN
--- 2643,2652 ----
  	logp->logElements = 0;
  
  	/* free and allocate a new one */
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
+ 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  	logp->datap =
  	    (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
  #ifdef	KERNEL_HAVE_PIN
***************
*** 2670,2676 ****
  	    /* found the dude we want to remove */
  	    *lpp = logp->nextp;
  	    osi_FreeSmallSpace(logp->name);
! 	    osi_FreeSmallSpace(logp->datap);
  	    osi_FreeSmallSpace(logp);
  	    break;		/* won't find it twice */
  	}
--- 2670,2679 ----
  	    /* found the dude we want to remove */
  	    *lpp = logp->nextp;
  	    osi_FreeSmallSpace(logp->name);
! #ifdef KERNEL_HAVE_PIN
! 	    unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
! #endif
! 	    afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  	    osi_FreeSmallSpace(logp);
  	    break;		/* won't find it twice */
  	}
***************
*** 2928,2937 ****
  	    /* found the dude we want to remove */
  	    *lpp = setp->nextp;
  	    osi_FreeSmallSpace(setp->name);
- 	    afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
  #ifdef	KERNEL_HAVE_PIN
  	    unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
  #endif
  	    for (i = 0; i < ICL_LOGSPERSET; i++) {
  		if ((tlp = setp->logs[i]))
  		    afs_icl_LogReleNL(tlp);
--- 2931,2940 ----
  	    /* found the dude we want to remove */
  	    *lpp = setp->nextp;
  	    osi_FreeSmallSpace(setp->name);
  #ifdef	KERNEL_HAVE_PIN
  	    unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
  #endif
+ 	    afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
  	    for (i = 0; i < ICL_LOGSPERSET; i++) {
  		if ((tlp = setp->logs[i]))
  		    afs_icl_LogReleNL(tlp);
Index: openafs/src/afs/afs_dcache.c
diff -c openafs/src/afs/afs_dcache.c:1.42.2.4 openafs/src/afs/afs_dcache.c:1.42.2.6
*** openafs/src/afs/afs_dcache.c:1.42.2.4	Tue Dec  7 01:12:11 2004
--- openafs/src/afs/afs_dcache.c	Sun Jan 30 23:24:34 2005
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.4 2004/12/07 06:12:11 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.6 2005/01/31 04:24:34 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
Index: openafs/src/afs/afs_osi.c
diff -c openafs/src/afs/afs_osi.c:1.48.2.1 openafs/src/afs/afs_osi.c:1.48.2.3
*** openafs/src/afs/afs_osi.c:1.48.2.1	Tue Dec  7 01:12:11 2004
--- openafs/src/afs/afs_osi.c	Sun Jan 30 23:25:32 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.1 2004/12/07 06:12:11 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.3 2005/01/31 04:25:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 850,879 ****
  #endif
  
  #if defined(AFS_LINUX22_ENV)
  void
  afs_osi_TraverseProcTable()
  {
      struct task_struct *p;
! 
! #ifdef EXPORTED_TASKLIST_LOCK
!     read_lock(&tasklist_lock);
! #endif
  #ifdef DEFINED_FOR_EACH_PROCESS
      for_each_process(p) if (p->pid) {
  	if (p->state & TASK_ZOMBIE)
  	    continue;
  	afs_GCPAGs_perproc_func(p);
      }
  #else
      for_each_task(p) if (p->pid) {
  	if (p->state & TASK_ZOMBIE)
  	    continue;
  	afs_GCPAGs_perproc_func(p);
      }
  #endif
! #ifdef EXPORTED_TASKLIST_LOCK
!     read_unlock(&tasklist_lock);
! #endif
  }
  #endif
  
--- 850,887 ----
  #endif
  
  #if defined(AFS_LINUX22_ENV)
+ extern rwlock_t tasklist_lock __attribute__((weak));
  void
  afs_osi_TraverseProcTable()
  {
      struct task_struct *p;
!     if (&tasklist_lock)
!        read_lock(&tasklist_lock);
  #ifdef DEFINED_FOR_EACH_PROCESS
      for_each_process(p) if (p->pid) {
+ #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
+ 	if (p->exit_state)
+ 	    continue;
+ #else
  	if (p->state & TASK_ZOMBIE)
  	    continue;
+ #endif
  	afs_GCPAGs_perproc_func(p);
      }
  #else
      for_each_task(p) if (p->pid) {
+ #ifdef STRUCT_TASK_STRUCT_HAS_EXIT_STATE
+ 	if (p->exit_state)
+ 	    continue;
+ #else
  	if (p->state & TASK_ZOMBIE)
  	    continue;
+ #endif
  	afs_GCPAGs_perproc_func(p);
      }
  #endif
!     if (&tasklist_lock)
!        read_unlock(&tasklist_lock);
  }
  #endif
  
Index: openafs/src/afs/afs_osi.h
diff -c openafs/src/afs/afs_osi.h:1.22.2.1 openafs/src/afs/afs_osi.h:1.22.2.2
*** openafs/src/afs/afs_osi.h:1.22.2.1	Mon Oct 18 03:11:45 2004
--- openafs/src/afs/afs_osi.h	Sun Jan 30 23:18:41 2005
***************
*** 184,198 ****
  #endif /* AFS_SGI61_ENV */
  
  /*
-  * The following three routines provide the fid routines used by the buffer
-  * and directory packages.
-  */
- #define dirp_Zap(afid)    ((afid) = 0)
- #define dirp_Eq(afid, bfid) ((afid) == (bfid))
- #define dirp_Cpy(dfid,sfid) ((dfid) = (sfid))
- 
- 
- /*
   * osi_ThreadUnique() should yield a value that can be found in ps
   * output in order to draw correspondences between ICL traces and what
   * is going on in the system.  So if ps cannot show thread IDs it is
--- 184,189 ----
Index: openafs/src/afs/afs_osi_pag.c
diff -c openafs/src/afs/afs_osi_pag.c:1.21.2.2 openafs/src/afs/afs_osi_pag.c:1.21.2.3
*** openafs/src/afs/afs_osi_pag.c:1.21.2.2	Tue Nov  9 12:09:39 2004
--- openafs/src/afs/afs_osi_pag.c	Sun Jan 30 23:19:20 2005
***************
*** 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 */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_pag.c,v 1.21.2.3 2005/01/31 04:19:20 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 189,195 ****
  #if     defined(AFS_SUN5_ENV)
      struct AFS_UCRED **acred = *credpp;
  #elif  defined(AFS_OBSD_ENV)
!     struct AFS_UCRED **acred = p->p_ucred;
  #else
      struct AFS_UCRED **acred = NULL;
  #endif
--- 189,195 ----
  #if     defined(AFS_SUN5_ENV)
      struct AFS_UCRED **acred = *credpp;
  #elif  defined(AFS_OBSD_ENV)
!     struct AFS_UCRED **acred = &p->p_ucred;
  #else
      struct AFS_UCRED **acred = NULL;
  #endif
***************
*** 285,291 ****
  #if     defined(AFS_SUN5_ENV)
      struct AFS_UCRED **acred = *credp;
  #elif  defined(AFS_OBSD_ENV)
!     struct AFS_UCRED **acred = p->p_ucred;
  #else
      struct AFS_UCRED **acred = NULL;
  #endif
--- 285,291 ----
  #if     defined(AFS_SUN5_ENV)
      struct AFS_UCRED **acred = *credp;
  #elif  defined(AFS_OBSD_ENV)
!     struct AFS_UCRED **acred = &p->p_ucred;
  #else
      struct AFS_UCRED **acred = NULL;
  #endif
Index: openafs/src/afs/afs_pioctl.c
diff -c openafs/src/afs/afs_pioctl.c:1.81.2.4 openafs/src/afs/afs_pioctl.c:1.81.2.6
*** openafs/src/afs/afs_pioctl.c:1.81.2.4	Tue Dec  7 01:12:11 2004
--- openafs/src/afs/afs_pioctl.c	Sun Jan 30 23:19:41 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.4 2004/12/07 06:12:11 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.6 2005/01/31 04:19:41 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifdef AFS_OBSD_ENV
***************
*** 271,279 ****
      if (current->thread.flags & THREAD_IA32)
  #elif defined(AFS_PPC64_LINUX20_ENV)
  #ifdef AFS_PPC64_LINUX26_ENV
!       if (current->thread_info->flags & _TIF_32BIT)
! #else /*Linux 2.6*/
!     if (current->thread.flags & PPC_FLAG_32BIT) 
  #endif
  #elif defined(AFS_S390X_LINUX20_ENV)
      if (current->thread.flags & S390_FLAG_31BIT)
--- 271,279 ----
      if (current->thread.flags & THREAD_IA32)
  #elif defined(AFS_PPC64_LINUX20_ENV)
  #ifdef AFS_PPC64_LINUX26_ENV
!     if (current->thread_info->flags & _TIF_32BIT)
! #else /*Linux 2.6 */
!     if (current->thread.flags & PPC_FLAG_32BIT)
  #endif
  #elif defined(AFS_S390X_LINUX20_ENV)
      if (current->thread.flags & S390_FLAG_31BIT)
***************
*** 1119,1180 ****
      if (inSize > MAXPIOCTLTOKENLEN || inSize < 0 || ablob->out_size < 0)
  	return E2BIG;
  
      if (inSize > AFS_LRALLOCSIZ) {
!         inData = osi_AllocLargeSpace(inSize+1);
      } else {
!         inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
      }
      if (!inData)
!         return ENOMEM;
      if (inSize > 0) {
  	AFS_COPYIN(ablob->in, inData, inSize, code);
  	inData[inSize] = '\0';
      } else
  	code = 0;
      if (code) {
!     if (inSize > AFS_LRALLOCSIZ) {
!         osi_Free(inData, inSize+1);
!     } else {
!         osi_FreeLargeSpace(inData);
!     }
!     afs_PutFakeStat(&fakestate);
!     return code;
      }
!     if (function == 8 && device == 'V') { /* PGetTokens */
!         outSizeMax = MAXPIOCTLTOKENLEN;
!         outData = osi_Alloc(outSizeMax);
      } else {
!         outSizeMax = AFS_LRALLOCSIZ;
!         outData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
      }
      if (!outData) {
!         if (inSize > AFS_LRALLOCSIZ) {
!             osi_Free(inData, inSize+1);
!         } else {
!             osi_FreeLargeSpace(inData);
!         }
!         return ENOMEM;
      }
      outSize = 0;
      code =
  	(*pioctlSw[function]) (avc, function, &treq, inData, outData, inSize,
  			       &outSize, acred);
      if (inSize > AFS_LRALLOCSIZ) {
!         osi_Free(inData, inSize+1);
      } else {
!         osi_FreeLargeSpace(inData);
      }
      if (code == 0 && ablob->out_size > 0) {
!         if (outSize > ablob->out_size) {
!             code = E2BIG; /* data wont fit in user buffer */
!         } else if (outSize) {
!             AFS_COPYOUT(outData, ablob->out, outSize, code);
!         }
      }
      if (outSizeMax > AFS_LRALLOCSIZ) {
!         osi_Free(outData, outSizeMax);
      } else {
!         osi_FreeLargeSpace(outData);
      }
      afs_PutFakeStat(&fakestate);
      return afs_CheckCode(code, &treq, 41);
--- 1119,1181 ----
      if (inSize > MAXPIOCTLTOKENLEN || inSize < 0 || ablob->out_size < 0)
  	return E2BIG;
  
+     /* Note that we use osi_Alloc for large allocs and osi_AllocLargeSpace for small ones */
      if (inSize > AFS_LRALLOCSIZ) {
! 	inData = osi_Alloc(inSize + 1);
      } else {
! 	inData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
      }
      if (!inData)
! 	return ENOMEM;
      if (inSize > 0) {
  	AFS_COPYIN(ablob->in, inData, inSize, code);
  	inData[inSize] = '\0';
      } else
  	code = 0;
      if (code) {
! 	if (inSize > AFS_LRALLOCSIZ) {
! 	    osi_Free(inData, inSize + 1);
! 	} else {
! 	    osi_FreeLargeSpace(inData);
! 	}
! 	afs_PutFakeStat(&fakestate);
! 	return code;
      }
!     if (function == 8 && device == 'V') {	/* PGetTokens */
! 	outSizeMax = MAXPIOCTLTOKENLEN;
! 	outData = osi_Alloc(outSizeMax);
      } else {
! 	outSizeMax = AFS_LRALLOCSIZ;
! 	outData = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
      }
      if (!outData) {
! 	if (inSize > AFS_LRALLOCSIZ) {
! 	    osi_Free(inData, inSize + 1);
! 	} else {
! 	    osi_FreeLargeSpace(inData);
! 	}
! 	return ENOMEM;
      }
      outSize = 0;
      code =
  	(*pioctlSw[function]) (avc, function, &treq, inData, outData, inSize,
  			       &outSize, acred);
      if (inSize > AFS_LRALLOCSIZ) {
! 	osi_Free(inData, inSize + 1);
      } else {
! 	osi_FreeLargeSpace(inData);
      }
      if (code == 0 && ablob->out_size > 0) {
! 	if (outSize > ablob->out_size) {
! 	    code = E2BIG;	/* data wont fit in user buffer */
! 	} else if (outSize) {
! 	    AFS_COPYOUT(outData, ablob->out, outSize, code);
! 	}
      }
      if (outSizeMax > AFS_LRALLOCSIZ) {
! 	osi_Free(outData, outSizeMax);
      } else {
! 	osi_FreeLargeSpace(outData);
      }
      afs_PutFakeStat(&fakestate);
      return afs_CheckCode(code, &treq, 41);
***************
*** 2762,2769 ****
  		return error;
  	    }
  	} else {
!             foundname = num;
!             strcpy(outname, (*sysnamelist)[0]);
  	}
  	afs_PutUser(au, READ_LOCK);
      } else {
--- 2763,2770 ----
  		return error;
  	    }
  	} else {
! 	    foundname = num;
! 	    strcpy(outname, (*sysnamelist)[0]);
  	}
  	afs_PutUser(au, READ_LOCK);
      } else {
***************
*** 3770,3790 ****
      struct unixuser *tu;
      struct srvAddr **addrs;
  
!     /*AFS_STATCNT(PCallBackAddr);*/
!     if ( !afs_resourceinit_flag )      /* afs deamons havn't started yet */
! 	return EIO;          /* Inappropriate ioctl for device */
  
      if (!afs_osi_suser(acred))
  	return EACCES;
  
!     if ( ainSize < sizeof(afs_int32) )
  	return EINVAL;
  
      memcpy(&addr, ain, sizeof(afs_int32));
  
      ObtainReadLock(&afs_xinterface);
!     for ( i=0; (unsigned short)i < afs_cb_interface.numberOfInterfaces; i++) {
! 	if (afs_cb_interface.addr_in[i] == addr) break;
      }
  
      ReleaseWriteLock(&afs_xinterface);
--- 3771,3792 ----
      struct unixuser *tu;
      struct srvAddr **addrs;
  
!     /*AFS_STATCNT(PCallBackAddr); */
!     if (!afs_resourceinit_flag)	/* afs deamons havn't started yet */
! 	return EIO;		/* Inappropriate ioctl for device */
  
      if (!afs_osi_suser(acred))
  	return EACCES;
  
!     if (ainSize < sizeof(afs_int32))
  	return EINVAL;
  
      memcpy(&addr, ain, sizeof(afs_int32));
  
      ObtainReadLock(&afs_xinterface);
!     for (i = 0; (unsigned short)i < afs_cb_interface.numberOfInterfaces; i++) {
! 	if (afs_cb_interface.addr_in[i] == addr)
! 	    break;
      }
  
      ReleaseWriteLock(&afs_xinterface);
***************
*** 3792,3856 ****
      if (afs_cb_interface.addr_in[i] != addr)
  	return EINVAL;
  
!     ObtainReadLock(&afs_xserver);  /* Necessary? */
      ObtainReadLock(&afs_xsrvAddr);
  
      srvAddrCount = 0;
!     for (i=0;i<NSERVERS;i++) {
!         for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
!             srvAddrCount++;
!         }
      }
  
      addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs));
      j = 0;
!     for (i=0;i<NSERVERS;i++) {
!         for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
!             if (j >= srvAddrCount) break;
!             addrs[j++] = sa;
!         }
      }
  
      ReleaseReadLock(&afs_xsrvAddr);
      ReleaseReadLock(&afs_xserver);
  
!     for (i=0; i<j; i++) {
!         sa = addrs[i];
!         ts = sa->server;
!         if (!ts)
!             continue;
! 
!         /* vlserver has no callback conn */
!         if (sa->sa_portal == AFS_VLPORT) {
!             continue;
!         }
! 
!         if (!ts->cell) /* not really an active server, anyway, it must */
! 	    continue;  /* have just been added by setsprefs */
! 
!         /* get a connection, even if host is down; bumps conn ref count */
!         tu = afs_GetUser(areq->uid, ts->cell->cellNum, SHARED_LOCK);
!         tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu,
! 			  1/*force*/, 1/*create*/, SHARED_LOCK);
!         afs_PutUser(tu, SHARED_LOCK);
!         if (!tc)
  	    continue;
  
!         if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(ts)) {
!             if (sa->sa_flags & SRVADDR_ISDOWN) {
!                 rx_SetConnDeadTime(tc->id, 3);
!             }
  
  #ifdef RX_ENABLE_LOCKS
!             AFS_GUNLOCK();
  #endif /* RX_ENABLE_LOCKS */
  	    code = RXAFS_CallBackRxConnAddr(tc->id, &addr);
  #ifdef RX_ENABLE_LOCKS
!             AFS_GLOCK();
  #endif /* RX_ENABLE_LOCKS */
  	}
! 	afs_PutConn(tc, SHARED_LOCK);   /* done with it now */
!     } /* Outer loop over addrs */
  #endif /* UKERNEL */
      return 0;
  }
--- 3794,3858 ----
      if (afs_cb_interface.addr_in[i] != addr)
  	return EINVAL;
  
!     ObtainReadLock(&afs_xserver);	/* Necessary? */
      ObtainReadLock(&afs_xsrvAddr);
  
      srvAddrCount = 0;
!     for (i = 0; i < NSERVERS; i++) {
! 	for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
! 	    srvAddrCount++;
! 	}
      }
  
      addrs = afs_osi_Alloc(srvAddrCount * sizeof(*addrs));
      j = 0;
!     for (i = 0; i < NSERVERS; i++) {
! 	for (sa = afs_srvAddrs[i]; sa; sa = sa->next_bkt) {
! 	    if (j >= srvAddrCount)
! 		break;
! 	    addrs[j++] = sa;
! 	}
      }
  
      ReleaseReadLock(&afs_xsrvAddr);
      ReleaseReadLock(&afs_xserver);
  
!     for (i = 0; i < j; i++) {
! 	sa = addrs[i];
! 	ts = sa->server;
! 	if (!ts)
  	    continue;
  
! 	/* vlserver has no callback conn */
! 	if (sa->sa_portal == AFS_VLPORT) {
! 	    continue;
! 	}
! 
! 	if (!ts->cell)		/* not really an active server, anyway, it must */
! 	    continue;		/* have just been added by setsprefs */
! 
! 	/* get a connection, even if host is down; bumps conn ref count */
! 	tu = afs_GetUser(areq->uid, ts->cell->cellNum, SHARED_LOCK);
! 	tc = afs_ConnBySA(sa, ts->cell->fsport, ts->cell->cellNum, tu,
! 			  1 /*force */ , 1 /*create */ , SHARED_LOCK);
! 	afs_PutUser(tu, SHARED_LOCK);
! 	if (!tc)
! 	    continue;
  
+ 	if ((sa->sa_flags & SRVADDR_ISDOWN) || afs_HaveCallBacksFrom(ts)) {
+ 	    if (sa->sa_flags & SRVADDR_ISDOWN) {
+ 		rx_SetConnDeadTime(tc->id, 3);
+ 	    }
  #ifdef RX_ENABLE_LOCKS
! 	    AFS_GUNLOCK();
  #endif /* RX_ENABLE_LOCKS */
  	    code = RXAFS_CallBackRxConnAddr(tc->id, &addr);
  #ifdef RX_ENABLE_LOCKS
! 	    AFS_GLOCK();
  #endif /* RX_ENABLE_LOCKS */
  	}
! 	afs_PutConn(tc, SHARED_LOCK);	/* done with it now */
!     }				/* Outer loop over addrs */
  #endif /* UKERNEL */
      return 0;
  }
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.65.2.4 openafs/src/afs/afs_vcache.c:1.65.2.9
*** openafs/src/afs/afs_vcache.c:1.65.2.4	Mon Oct 18 13:43:50 2004
--- openafs/src/afs/afs_vcache.c	Sun Jan 30 23:20:35 2005
***************
*** 39,45 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.4 2004/10/18 17:43:50 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 39,45 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.9 2005/01/31 04:20:35 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 557,709 ****
      MReleaseWriteLock(&afs_xvcb);
  }
  
- #if defined(AFS_LINUX22_ENV) && !defined(AFS_LINUX26_ENV)
- 
- static void
- __shrink_dcache_parent(struct dentry *parent)
- {
-     struct dentry *this_parent = parent;
-     struct list_head *next;
-     int found = 0;
-     LIST_HEAD(afs_dentry_unused);
- 
-   repeat:
-     next = this_parent->d_subdirs.next;
-   resume:
-     while (next != &this_parent->d_subdirs) {
- 	struct list_head *tmp = next;
- 	struct dentry *dentry = list_entry(tmp, struct dentry, d_child);
- 	next = tmp->next;
- 	if (!DCOUNT(dentry)) {
- 	    list_del(&dentry->d_lru);
- 	    list_add(&dentry->d_lru, afs_dentry_unused.prev);
- 	    found++;
- 	}
- 	/*
- 	 * Descend a level if the d_subdirs list is non-empty.
- 	 */
- 	if (!list_empty(&dentry->d_subdirs)) {
- 	    this_parent = dentry;
- 	    goto repeat;
- 	}
-     }
-     /*
-      * All done at this level ... ascend and resume the search.
-      */
-     if (this_parent != parent) {
- 	next = this_parent->d_child.next;
- 	this_parent = this_parent->d_parent;
- 	goto resume;
-     }
- 
-     for (;;) {
- 	struct dentry *dentry;
- 	struct list_head *tmp;
- 
- 	tmp = afs_dentry_unused.prev;
- 
- 	if (tmp == &afs_dentry_unused)
- 	    break;
- #ifdef AFS_LINUX24_ENV
- 	list_del_init(tmp);
- #else
- 	list_del(tmp);
- 	INIT_LIST_HEAD(tmp);
- #endif /* AFS_LINUX24_ENV */
- 	dentry = list_entry(tmp, struct dentry, d_lru);
- 
- #ifdef AFS_LINUX24_ENV
- 	/* Unused dentry with a count? */
- 	if (DCOUNT(dentry))
- 	    BUG();
- #endif
- 	DGET(dentry);
- #ifdef AFS_LINUX24_ENV
- 	list_del_init(&dentry->d_hash);	/* d_drop */
- #else
- 	list_del(&dentry->d_hash);
- 	INIT_LIST_HEAD(&dentry->d_hash);
- #endif /* AFS_LINUX24_ENV */
- 	DUNLOCK();
- 	dput(dentry);
- 	DLOCK();
- 	if (!--found)
- 	    break;
-     }
- }
- 
- /* afs_TryFlushDcacheChildren -- Shakes loose vcache references held by
-  *                               children of the dentry
-  *
-  * LOCKS -- Called with afs_xvcache write locked. Drops and reaquires
-  *          AFS_GLOCK, so it can call dput, which may call iput, but
-  *          keeps afs_xvcache exclusively.
-  *
-  * Tree traversal algorithm from fs/dcache.c: select_parent()
-  */
- static void
- afs_TryFlushDcacheChildren(struct vcache *tvc)
- {
-     struct inode *ip = AFSTOI(tvc);
-     struct dentry *this_parent;
-     struct list_head *next;
-     struct list_head *cur;
-     struct list_head *head = &ip->i_dentry;
-     struct dentry *dentry;
- 
-     AFS_GUNLOCK();
-   restart:
- #ifndef old_vcache_scheme
-     DLOCK();
-     cur = head;
-     while ((cur = cur->next) != head) {
- 	dentry = list_entry(cur, struct dentry, d_alias);
- 
- 	if (!list_empty(&dentry->d_hash) && !list_empty(&dentry->d_subdirs))
- 	    __shrink_dcache_parent(dentry);
- 
- 	if (!DCOUNT(dentry)) {
- 	    DGET(dentry);
- #ifdef AFS_LINUX24_ENV
- 	    list_del_init(&dentry->d_hash);	/* d_drop */
- #else
- 	    list_del(&dentry->d_hash);
- 	    INIT_LIST_HEAD(&dentry->d_hash);
- #endif /* AFS_LINUX24_ENV */
- 	    DUNLOCK();
- 	    dput(dentry);
- 	    goto restart;
- 	}
-     }
-     DUNLOCK();
-     AFS_GLOCK();
- #else
-   restart:
-     DLOCK();
-     cur = head;
-     while ((cur = cur->next) != head) {
- 	dentry = list_entry(cur, struct dentry, d_alias);
- 
- 	afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN,
- 		   ICL_TYPE_POINTER, ip, ICL_TYPE_STRING,
- 		   dentry->d_parent->d_name.name, ICL_TYPE_STRING,
- 		   dentry->d_name.name);
- 
- 	if (!DCOUNT(dentry)) {
- 	    AFS_GUNLOCK();
- 	    DGET(dentry);
- 	    DUNLOCK();
- 	    d_drop(dentry);
- 	    dput(dentry);
- 	    AFS_GLOCK();
- 	    goto restart;
- 	}
-     }
-     DUNLOCK();
- #endif
- }
- #endif /* AFS_LINUX22_ENV && !AFS_LINUX26_ENV */
- 
  /*
   * afs_NewVCache
   *
--- 557,562 ----
***************
*** 839,860 ****
  	    }
  #elif defined(AFS_LINUX22_ENV)
  	    if (tvc != afs_globalVp && VREFCOUNT(tvc) && tvc->opens == 0) {
- #if defined(AFS_LINUX26_ENV)
                  struct dentry *dentry;
                  struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry;
                  AFS_GUNLOCK();
!                 cur=head;
                  while ((cur = cur->next) != head) {
                      dentry = list_entry(cur, struct dentry, d_alias);
!                     if (!d_unhashed(dentry) &&
!                         !list_empty(&dentry->d_subdirs))
! 			shrink_dcache_parent(dentry);
!                 }
!                 d_prune_aliases(AFSTOI(tvc));
!                 AFS_GLOCK();
! #else
! 		afs_TryFlushDcacheChildren(tvc);
  #endif
  	    }
  #endif
  
--- 692,732 ----
  	    }
  #elif defined(AFS_LINUX22_ENV)
  	    if (tvc != afs_globalVp && VREFCOUNT(tvc) && tvc->opens == 0) {
                  struct dentry *dentry;
                  struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry;
+                 AFS_FAST_HOLD(tvc);
                  AFS_GUNLOCK();
! 
! restart:
! #if defined(AFS_LINUX24_ENV)
!                 spin_lock(&dcache_lock);
! #endif
!                 cur = head;
                  while ((cur = cur->next) != head) {
                      dentry = list_entry(cur, struct dentry, d_alias);
! 
! 		    if (d_unhashed(dentry))
! 			continue;
! 
! 		    dget_locked(dentry);
! 
! #if defined(AFS_LINUX24_ENV)
! 		    spin_unlock(&dcache_lock);
! #endif
! 		    if (d_invalidate(dentry) == -EBUSY) {
! 			dput(dentry);
! 			/* perhaps lock and try to continue? (use cur as head?) */
! 			goto inuse;
! 		    }
! 		    dput(dentry);
! 		    goto restart;
! 		}		    
! #if defined(AFS_LINUX24_ENV)
! 		spin_unlock(&dcache_lock);
  #endif
+ 	    inuse:
+ 		AFS_GLOCK();
+ 		AFS_FAST_RELE(tvc);
  	    }
  #endif
  
***************
*** 2895,2900 ****
--- 2767,2783 ----
      LOCK_INIT(&afs_xvcb, "afs_xvcb");
  
  #if	!defined(AFS_OSF_ENV)
+ #ifdef AFS_LINUX26_ENV
+     printf("old style would have needed %d contiguous bytes\n", astatSize *
+ 	   sizeof(struct vcache));
+     Initial_freeVCList = freeVCList = tvp = (struct vcache *)
+ 	afs_osi_Alloc(sizeof(struct vcache));
+     for (i = 0; i < astatSize; i++) {
+ 	tvp->nextfree = (struct vcache *) afs_osi_Alloc(sizeof(struct vcache));
+ 	tvp = tvp->nextfree;
+     }
+     tvp->nextfree = NULL;
+ #else
      /* Allocate and thread the struct vcache entries */
      tvp = (struct vcache *)afs_osi_Alloc(astatSize * sizeof(struct vcache));
      memset((char *)tvp, 0, sizeof(struct vcache) * astatSize);
***************
*** 2909,2915 ****
      pin((char *)tvp, astatSize * sizeof(struct vcache));	/* XXX */
  #endif
  #endif
! 
  
  #if defined(AFS_SGI_ENV)
      for (i = 0; i < astatSize; i++) {
--- 2792,2798 ----
      pin((char *)tvp, astatSize * sizeof(struct vcache));	/* XXX */
  #endif
  #endif
! #endif
  
  #if defined(AFS_SGI_ENV)
      for (i = 0; i < astatSize; i++) {
***************
*** 3019,3030 ****
--- 2902,2926 ----
      }
      afs_cbrSpace = 0;
  
+ #ifdef AFS_LINUX26_ENV
+     {
+ 	struct vcache *tvp = Initial_freeVCList;
+ 	while (tvp) {
+ 	    struct vcache *next = tvp->nextfree;
+ 	    
+ 	    afs_osi_Free(tvp, sizeof(struct vcache));
+ 	    tvp = next;
+ 	}
+     }
+ #else
  #ifdef  KERNEL_HAVE_PIN
      unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
  #if	!defined(AFS_OSF_ENV)
      afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
+ #endif
+ 
  #if	!defined(AFS_OSF_ENV)
      freeVCList = Initial_freeVCList = 0;
  #endif
Index: openafs/src/afs/DUX/osi_vnodeops.c
diff -c openafs/src/afs/DUX/osi_vnodeops.c:1.11 openafs/src/afs/DUX/osi_vnodeops.c:1.11.2.1
*** openafs/src/afs/DUX/osi_vnodeops.c:1.11	Tue Jul 15 19:14:19 2003
--- openafs/src/afs/DUX/osi_vnodeops.c	Sun Jan 30 22:49:11 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DUX/osi_vnodeops.c,v 1.11 2003/07/15 23:14:19 shadow Exp $");
  
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DUX/osi_vnodeops.c,v 1.11.2.1 2005/01/31 03:49:11 shadow Exp $");
  
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 114,121 ****
       struct nameidata *ndp;
  {
      int code;
!     AFS_GLOCK();
!     code = afs_lookup(adp, ndp);
      AFS_GUNLOCK();
      return code;
  }
--- 114,128 ----
       struct nameidata *ndp;
  {
      int code;
!     char aname[MAXNAMLEN + 1];  /* XXX */
!     struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
!     struct ucred *acred = ndp->ni_cred;
!     int wantparent = ndp->ni_nameiop & WANTPARENT;
!     int opflag = ndp->ni_nameiop & OPFLAG;
!     AFS_GLOCK();
!     memcpy(aname, ndp->ni_ptr, ndp->ni_namelen);
!     aname[ndp->ni_namelen] = '\0';
!     code = afs_lookup(adp, aname, avcp, acred, opflag, wantparent);
      AFS_GUNLOCK();
      return code;
  }
***************
*** 125,133 ****
       struct vattr *attrs;
  {
      int code;
      AFS_GLOCK();
!     code = afs_create(ndp, attrs);
      AFS_GUNLOCK();
      return code;
  }
  
--- 132,149 ----
       struct vattr *attrs;
  {
      int code;
+     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
+     char *aname = ndp->ni_dent.d_name;
+     enum vcexcl aexcl = NONEXCL;        /* XXX - create called properly */
+     int amode = 0;              /* XXX - checked in higher level */
+     struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
+     struct ucred *acred = ndp->ni_cred;
      AFS_GLOCK();
!     code = afs_create(adp, aname, attrs, aexcl, 
! 		      amode, avcp, acred);
! 
      AFS_GUNLOCK();
+     afs_PutVCache(adp);
      return code;
  }
  
***************
*** 208,215 ****
       struct nameidata *ndp;
  {
      int code;
      AFS_GLOCK();
!     code = afs_remove(ndp);
      AFS_GUNLOCK();
      return code;
  }
--- 224,235 ----
       struct nameidata *ndp;
  {
      int code;
+     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
+     char *aname = ndp->ni_dent.d_name;
+     struct ucred *acred = ndp->ni_cred;
      AFS_GLOCK();
!     code = afs_remove(adp, aname, acred);
!     afs_PutVCache(adp);
      AFS_GUNLOCK();
      return code;
  }
***************
*** 219,227 ****
       struct nameidata *ndp;
  {
      int code;
      AFS_GLOCK();
!     code = afs_link(avc, ndp);
      AFS_GUNLOCK();
      return code;
  }
  
--- 239,251 ----
       struct nameidata *ndp;
  {
      int code;
+     struct vcache *adp = VTOAFS(ndp->ni_dvp);
+     char *aname = ndp->ni_dent.d_name;
+     struct ucred *acred = ndp->ni_cred;
      AFS_GLOCK();
!     code = afs_link(avc, adp, aname, acred);
      AFS_GUNLOCK();
+     afs_PutVCache(adp);
      return code;
  }
  
***************
*** 229,236 ****
       struct nameidata *fndp, *tndp;
  {
      int code;
!     AFS_GLOCK();
!     code = afs_rename(fndp, tndp);
      AFS_GUNLOCK();
      return code;
  }
--- 253,271 ----
       struct nameidata *fndp, *tndp;
  {
      int code;
!     struct vcache *aodp = VTOAFS(fndp->ni_dvp);
!     char *aname1 = fndp->ni_dent.d_name;
!     struct vcache *andp = VTOAFS(tndp->ni_dvp);
!     char *aname2 = tndp->ni_dent.d_name;
!     struct ucred *acred = tndp->ni_cred;
!     AFS_GLOCK();
!     code = afs_rename(aodp, aname1, andp, aname2, acred);
!     AFS_RELE(tndp->ni_dvp);
!     if (tndp->ni_vp != NULL) {
!         AFS_RELE(tndp->ni_vp);
!     }
!     AFS_RELE(fndp->ni_dvp);
!     AFS_RELE(fndp->ni_vp);
      AFS_GUNLOCK();
      return code;
  }
***************
*** 240,247 ****
       struct vattr *attrs;
  {
      int code;
      AFS_GLOCK();
!     code = afs_mkdir(ndp, attrs);
      AFS_GUNLOCK();
      return code;
  }
--- 275,287 ----
       struct vattr *attrs;
  {
      int code;
+     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
+     char *aname = ndp->ni_dent.d_name;
+     register struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
+     struct ucred *acred = ndp->ni_cred;
      AFS_GLOCK();
!     code = afs_mkdir(adp, aname, attrs, avcp, acred);
!     AFS_RELE(adp);
      AFS_GUNLOCK();
      return code;
  }
***************
*** 250,257 ****
       struct nameidata *ndp;
  {
      int code;
!     AFS_GLOCK();
!     code = afs_rmdir(ndp);
      AFS_GUNLOCK();
      return code;
  }
--- 290,302 ----
       struct nameidata *ndp;
  {
      int code;
!     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
!     char *aname = ndp->ni_dent.d_name;
!     struct ucred *acred = ndp->ni_cred;
!     AFS_GLOCK();
!     code = afs_rmdir(adp, aname, acred);
!     afs_PutVCache(adp);
!     afs_PutVCache(ndp->ni_vp);
      AFS_GUNLOCK();
      return code;
  }
***************
*** 262,269 ****
       register char *atargetName;
  {
      int code;
      AFS_GLOCK();
!     code = afs_symlink(ndp, attrs, atargetName);
      AFS_GUNLOCK();
      return code;
  }
--- 307,318 ----
       register char *atargetName;
  {
      int code;
+     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
+     char *aname = ndp->ni_dent.d_name;
+     struct ucred *acred = ndp->ni_cred;
      AFS_GLOCK();
!     code = afs_symlink(adp, aname, attrs, atargetName, acred);
!     AFS_RELE(ndp->ni_dvp);
      AFS_GUNLOCK();
      return code;
  }
Index: openafs/src/afs/LINUX/osi_groups.c
diff -c openafs/src/afs/LINUX/osi_groups.c:1.25.2.1 openafs/src/afs/LINUX/osi_groups.c:1.25.2.2
*** openafs/src/afs/LINUX/osi_groups.c:1.25.2.1	Mon Oct 18 03:11:46 2004
--- openafs/src/afs/LINUX/osi_groups.c	Sun Jan 30 23:14:36 2005
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.1 2004/10/18 07:11:46 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.2 2005/01/31 04:14:36 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 155,177 ****
  #if defined(AFS_LINUX26_ENV)
      struct group_info *group_info;
      gid_t g0, g1;
  
      AFS_STATCNT(setpag);
  
      group_info = afs_getgroups(*cr);
      if (group_info->ngroups < 2
  	||  afs_get_pag_from_groups(GROUP_AT(group_info, 0),
! 				    GROUP_AT(group_info, 1)) == NOPAG) {
  	/* We will have to make sure group_info is big enough for pag */
! 	struct group_info *tmp;
! 	int i;
! 	
! 	tmp = groups_alloc(group_info->ngroups + 2);
! 	for (i = 0; i < group_info->ngroups; ++i)
! 		GROUP_AT(tmp, i + 2) = GROUP_AT(group_info, i);
! 	put_group_info(group_info);
! 	group_info = tmp;
!     }
  
      *newpag = (pagvalue == -1 ? genpag() : pagvalue);
      afs_get_groups_from_pag(*newpag, &g0, &g1);
--- 155,178 ----
  #if defined(AFS_LINUX26_ENV)
      struct group_info *group_info;
      gid_t g0, g1;
+     struct group_info *tmp;
+     int i;
+     int need_space = 0;
  
      AFS_STATCNT(setpag);
  
      group_info = afs_getgroups(*cr);
      if (group_info->ngroups < 2
  	||  afs_get_pag_from_groups(GROUP_AT(group_info, 0),
! 				    GROUP_AT(group_info, 1)) == NOPAG) 
  	/* We will have to make sure group_info is big enough for pag */
!       need_space = 2;
! 
!     tmp = groups_alloc(group_info->ngroups + need_space);
!     
!     for (i = 0; i < group_info->ngroups; ++i)
!       GROUP_AT(tmp, i + need_space) = GROUP_AT(group_info, i);
!     group_info = tmp;
  
      *newpag = (pagvalue == -1 ? genpag() : pagvalue);
      afs_get_groups_from_pag(*newpag, &g0, &g1);
Index: openafs/src/afs/LINUX/osi_machdep.h
diff -c openafs/src/afs/LINUX/osi_machdep.h:1.22.2.1 openafs/src/afs/LINUX/osi_machdep.h:1.22.2.2
*** openafs/src/afs/LINUX/osi_machdep.h:1.22.2.1	Tue Dec  7 01:09:23 2004
--- openafs/src/afs/LINUX/osi_machdep.h	Sun Jan 30 23:16:29 2005
***************
*** 47,52 ****
--- 47,60 ----
  #define SIG_UNLOCK(X) spin_unlock_irq(&X->sig->siglock)
  #endif
  
+ #if defined (STRUCT_TASK_STRUCT_HAS_RLIM)
+ #define TASK_STRUCT_RLIM rlim
+ #elif defined (STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM)
+ #define TASK_STRUCT_RLIM signal->rlim
+ #else
+ #error Not sure what to do about rlim (should be in the Linux task struct somewhere....)
+ #endif
+ 
  
  #define afs_hz HZ
  #include "h/sched.h"
Index: openafs/src/afs/LINUX/osi_misc.c
diff -c openafs/src/afs/LINUX/osi_misc.c:1.34.2.1 openafs/src/afs/LINUX/osi_misc.c:1.34.2.2
*** openafs/src/afs/LINUX/osi_misc.c:1.34.2.1	Tue Dec  7 01:12:12 2004
--- openafs/src/afs/LINUX/osi_misc.c	Sun Jan 30 23:16:29 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_misc.c,v 1.34.2.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_misc.c,v 1.34.2.2 2005/01/31 04:16:29 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 138,145 ****
      } else
  	filp->f_pos = offset;
  
!     savelim = current->rlim[RLIMIT_FSIZE].rlim_cur;
!     current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
  
      /* Read/Write the data. */
      TO_USER_SPACE();
--- 138,145 ----
      } else
  	filp->f_pos = offset;
  
!     savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
!     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
  
      /* Read/Write the data. */
      TO_USER_SPACE();
***************
*** 151,157 ****
  	code = asize;
      TO_KERNEL_SPACE();
  
!     current->rlim[RLIMIT_FSIZE].rlim_cur = savelim;
  
      if (code >= 0) {
  	*resid = asize - code;
--- 151,157 ----
  	code = asize;
      TO_KERNEL_SPACE();
  
!     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = savelim;
  
      if (code >= 0) {
  	*resid = asize - code;
***************
*** 173,180 ****
      int count;
      unsigned long savelim;
  
!     savelim = current->rlim[RLIMIT_FSIZE].rlim_cur;
!     current->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
  
      if (uiop->uio_seg == AFS_UIOSYS)
  	TO_USER_SPACE();
--- 173,180 ----
      int count;
      unsigned long savelim;
  
!     savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
!     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
  
      if (uiop->uio_seg == AFS_UIOSYS)
  	TO_USER_SPACE();
***************
*** 217,223 ****
      if (uiop->uio_seg == AFS_UIOSYS)
  	TO_KERNEL_SPACE();
  
!     current->rlim[RLIMIT_FSIZE].rlim_cur = savelim;
  
      return code;
  }
--- 217,223 ----
      if (uiop->uio_seg == AFS_UIOSYS)
  	TO_KERNEL_SPACE();
  
!     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = savelim;
  
      return code;
  }
Index: openafs/src/afs/LINUX/osi_module.c
diff -c openafs/src/afs/LINUX/osi_module.c:1.52.2.5 openafs/src/afs/LINUX/osi_module.c:1.52.2.6
*** openafs/src/afs/LINUX/osi_module.c:1.52.2.5	Fri Dec 17 10:29:30 2004
--- openafs/src/afs/LINUX/osi_module.c	Sun Jan 30 23:25:13 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.5 2004/12/17 15:29:30 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.6 2005/01/31 04:25:13 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
***************
*** 33,70 ****
  #include <linux/init.h>
  #include <linux/sched.h>
  #endif
- #if !defined(EXPORTED_SYS_CALL_TABLE) && defined(HAVE_KERNEL_LINUX_SYSCALL_H)
- #include <linux/syscall.h>
- #endif
- 
- #ifdef AFS_SPARC64_LINUX24_ENV
- #define __NR_setgroups32      82	/* This number is not exported for some bizarre reason. */
- #endif
- 
- #if !defined(AFS_LINUX24_ENV)
- asmlinkage int (*sys_settimeofdayp) (struct timeval * tv,
- 				     struct timezone * tz);
- #endif
- asmlinkage long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist);
- #ifdef EXPORTED_SYS_CALL_TABLE
- #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
- extern unsigned int sys_call_table[];	/* changed to uint because SPARC64 and S390X have syscalltable of 32bit items */
- #else
- extern void *sys_call_table[];	/* safer for other linuces */
- #endif
- #else /* EXPORTED_SYS_CALL_TABLE */
- #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
- static unsigned int *sys_call_table;	/* changed to uint because SPARC64 and S390X have syscalltable of 32bit items */
- #else
- static void **sys_call_table;	/* safer for other linuces */
- #endif
- #endif
- 
- #if defined(AFS_S390X_LINUX24_ENV)
- #define _S(x) ((x)<<1)
- #else
- #define _S(x) x
- #endif
  
  extern struct file_system_type afs_fs_type;
  
--- 33,38 ----
***************
*** 82,137 ****
  unsigned long afs_linux_page_offset = 0;	/* contains the PAGE_OFFSET value */
  #endif
  
- /* Since sys_ni_syscall is not exported, I need to cache it in order to restore
-  * it.
-  */
- #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
- static unsigned int afs_ni_syscall = 0;
- #else
- static void *afs_ni_syscall = 0;
- #endif
- 
- #ifdef AFS_AMD64_LINUX20_ENV
- #ifdef EXPORTED_IA32_SYS_CALL_TABLE
- extern void *ia32_sys_call_table[];
- #else
- static void **ia32_sys_call_table;
- #endif
- 
- static void *ia32_ni_syscall = 0;
- asmlinkage long (*sys32_setgroupsp) (int gidsetsize, u16 * grouplist);
- #if defined(__NR_ia32_setgroups32)
- asmlinkage long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist);
- #endif /* __NR_ia32_setgroups32 */
- #endif /* AFS_AMD64_LINUX20_ENV */
- 
- #ifdef AFS_PPC64_LINUX20_ENV
- asmlinkage long (*sys32_setgroupsp)(int gidsetsize, gid_t *grouplist);
- #endif /* AFS_AMD64_LINUX20_ENV */
- 
- #ifdef AFS_SPARC64_LINUX20_ENV
- static unsigned int afs_ni_syscall32 = 0;
- asmlinkage int (*sys32_setgroupsp) (int gidsetsize,
- 				    __kernel_gid_t32 * grouplist);
- #if defined(__NR_setgroups32)
- asmlinkage int (*sys32_setgroups32p) (int gidsetsize,
- 				      __kernel_gid_t32 * grouplist);
- #endif /* __NR_setgroups32 */
- #ifdef EXPORTED_SYS_CALL_TABLE
- extern unsigned int sys_call_table32[];
- #else /* EXPORTED_SYS_CALL_TABLE */
- static unsigned int *sys_call_table32;
- #endif /* EXPORTED_SYS_CALL_TABLE */
- 
- asmlinkage int
- afs_syscall32(long syscall, long parm1, long parm2, long parm3, long parm4,
- 	      long parm5)
- {
-     __asm__ __volatile__("srl %o4, 0, %o4\n\t" "mov %o7, %i7\n\t"
- 			 "call afs_syscall\n\t" "srl %o5, 0, %o5\n\t"
- 			 "ret\n\t" "nop");
- }
- #endif /* AFS_SPARC64_LINUX20_ENV */
  
  static int afs_ioctl(struct inode *, struct file *, unsigned int,
  		     unsigned long);
--- 50,55 ----
***************
*** 226,273 ****
  		       sysargs.param2, sysargs.param3, sysargs.param4);
  }
  
- #ifdef AFS_IA64_LINUX20_ENV
- 
- asmlinkage long
- afs_syscall_stub(int r0, int r1, long r2, long r3, long r4, long gp)
- {
-     __asm__ __volatile__("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" "mov r41 = b0\n\t"	/* save rp */
- 			 "mov out0 = in0\n\t" "mov out1 = in1\n\t" "mov out2 = in2\n\t" "mov out3 = in3\n\t" "mov out4 = in4\n\t" "mov out5 = gp\n\t"	/* save gp */
- 			 ";;\n" ".L1:\n\t" "mov r3 = ip\n\t" ";;\n\t" "addl r15=.fptr_afs_syscall-.L1,r3\n\t" ";;\n\t" "ld8 r15=[r15]\n\t" ";;\n\t" "ld8 r16=[r15],8\n\t" ";;\n\t" "ld8 gp=[r15]\n\t" "mov b6=r16\n\t" "br.call.sptk.many b0 = b6\n\t" ";;\n\t" "mov ar.pfs = r42\n\t" "mov b0 = r41\n\t" "mov gp = r48\n\t"	/* restore gp */
- 			 "br.ret.sptk.many b0\n" ".fptr_afs_syscall:\n\t"
- 			 "data8 @fptr(afs_syscall)\n\t" ".skip 8");
- }
- 
- asmlinkage long
- afs_xsetgroups_stub(int r0, int r1, long r2, long r3, long r4, long gp)
- {
-     __asm__ __volatile__("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" "mov r41 = b0\n\t"	/* save rp */
- 			 "mov out0 = in0\n\t" "mov out1 = in1\n\t" "mov out2 = in2\n\t" "mov out3 = in3\n\t" "mov out4 = in4\n\t" "mov out5 = gp\n\t"	/* save gp */
- 			 ";;\n" ".L2:\n\t" "mov r3 = ip\n\t" ";;\n\t" "addl r15=.fptr_afs_xsetgroups - .L2,r3\n\t" ";;\n\t" "ld8 r15=[r15]\n\t" ";;\n\t" "ld8 r16=[r15],8\n\t" ";;\n\t" "ld8 gp=[r15]\n\t" "mov b6=r16\n\t" "br.call.sptk.many b0 = b6\n\t" ";;\n\t" "mov ar.pfs = r42\n\t" "mov b0 = r41\n\t" "mov gp = r48\n\t"	/* restore gp */
- 			 "br.ret.sptk.many b0\n" ".fptr_afs_xsetgroups:\n\t"
- 			 "data8 @fptr(afs_xsetgroups)\n\t" ".skip 8");
- }
- 
- struct fptr {
-     void *ip;
-     unsigned long gp;
- };
- 
- #endif /* AFS_IA64_LINUX20_ENV */
- 
- #ifdef AFS_LINUX24_ENV
- asmlinkage int (*sys_setgroups32p) (int gidsetsize,
- 				    __kernel_gid32_t * grouplist);
- #endif /* AFS_LINUX24_ENV */
- 
- #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
- #define POINTER2SYSCALL (unsigned int)(unsigned long)
- #define SYSCALL2POINTER (void *)(long)
- #else
- #define POINTER2SYSCALL (void *)
- #define SYSCALL2POINTER (void *)
- #endif
- 
  
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
  int __init
--- 144,149 ----
***************
*** 277,321 ****
  init_module(void)
  #endif
  {
! #if defined(AFS_IA64_LINUX20_ENV)
!     unsigned long kernel_gp = 0;
!     static struct fptr sys_setgroups;
! #endif /* defined(AFS_IA64_LINUX20_ENV) */
!     extern long afs_xsetgroups();
! #if defined(__NR_setgroups32)
!     extern int afs_xsetgroups32();
! #endif /* __NR_setgroups32 */
! #if defined(AFS_SPARC64_LINUX20_ENV) || defined (AFS_AMD64_LINUX20_ENV) || defined(AFS_PPC64_LINUX20_ENV)
!     extern int afs32_xsetgroups();
! #if (defined(__NR_setgroups32) && defined(AFS_SPARC64_LINUX20_ENV))
!     extern int afs32_xsetgroups32();
! #endif /* defined(__NR_setgroups32) && defined(AFS_SPARC64_LINUX20_ENV) */
! #if (defined(__NR_ia32_setgroups32) && defined(AFS_AMD64_LINUX20_ENV))
!     extern int afs32_xsetgroups32();
! #endif /* (defined(__NR_ia32_setgroups32) && defined(AFS_AMD64_LINUX20_ENV) */
! #endif /* AFS_SPARC64_LINUX20_ENV || AFS_AMD64_LINUX20_ENV || AFS_PPC64_LINUX20_ENV */
! 
! #if !defined(EXPORTED_SYS_CALL_TABLE) || (defined(AFS_AMD64_LINUX20_ENV) && !defined(EXPORTED_IA32_SYS_CALL_TABLE))
!     unsigned long *ptr;
!     unsigned long offset=0;
!     unsigned long datalen=0;
! #if defined(EXPORTED_KALLSYMS_SYMBOL)
!     unsigned long token=0;
! #endif
! #if defined(EXPORTED_KALLSYMS_SYMBOL) || defined(EXPORTED_KALLSYMS_ADDRESS)
!     int ret;
!     char *mod_name;
!     unsigned long mod_start=0;
!     unsigned long mod_end=0;
!     char *sec_name;
!     unsigned long sec_start=0;
!     unsigned long sec_end=0;
!     char *sym_name;
!     unsigned long sym_start=0;
!     unsigned long sym_end=0;
! #endif
! #endif /* EXPORTED_SYS_CALL_TABLE */
! 
      RWLOCK_INIT(&afs_xosi, "afs_xosi");
  
  #if !defined(AFS_LINUX24_ENV)
--- 153,159 ----
  init_module(void)
  #endif
  {
!     int e;
      RWLOCK_INIT(&afs_xosi, "afs_xosi");
  
  #if !defined(AFS_LINUX24_ENV)
***************
*** 331,576 ****
  #endif /* AFS_S390_LINUX22_ENV */
  #endif /* !defined(AFS_LINUX24_ENV) */
  
- #ifndef EXPORTED_SYS_CALL_TABLE
-     sys_call_table = 0;
- 
- #ifdef EXPORTED_KALLSYMS_SYMBOL
-     ret = 1;
-     token = 0;
-     while (ret) {
- 	sym_start = 0;
- 	ret =
- 	    kallsyms_symbol_to_address("sys_call_table", &token, &mod_name,
- 				       &mod_start, &mod_end, &sec_name,
- 				       &sec_start, &sec_end, &sym_name,
- 				       &sym_start, &sym_end);
- 	if (ret && !strcmp(mod_name, "kernel"))
- 	    break;
-     }
-     if (ret && sym_start) {
- 	sys_call_table = sym_start;
-     }
- #elif defined(EXPORTED_KALLSYMS_ADDRESS)
-     ret =
- 	kallsyms_address_to_symbol((unsigned long)&init_mm, &mod_name,
- 				   &mod_start, &mod_end, &sec_name,
- 				   &sec_start, &sec_end, &sym_name,
- 				   &sym_start, &sym_end);
-     ptr = (unsigned long *)sec_start;
-     datalen = (sec_end - sec_start) / sizeof(unsigned long);
- #elif defined(AFS_IA64_LINUX20_ENV)
-     ptr = (unsigned long *)(&sys_close - 0x180000);
-     datalen = 0x180000 / sizeof(ptr);
- #elif defined(AFS_AMD64_LINUX20_ENV)
-     ptr = (unsigned long *)&init_mm;
-     datalen = 0x360000 / sizeof(ptr);
- #else
-     ptr = (unsigned long *)&init_mm;
-     datalen = 16384;
- #endif
-     for (offset = 0; offset < datalen; ptr++, offset++) {
- #if defined(AFS_IA64_LINUX20_ENV)
- 	unsigned long close_ip =
- 	    (unsigned long)((struct fptr *)&sys_close)->ip;
- 	unsigned long chdir_ip =
- 	    (unsigned long)((struct fptr *)&sys_chdir)->ip;
- 	unsigned long write_ip =
- 	    (unsigned long)((struct fptr *)&sys_write)->ip;
- 	if (ptr[0] == close_ip && ptr[__NR_chdir - __NR_close] == chdir_ip
- 	    && ptr[__NR_write - __NR_close] == write_ip) {
- 	    sys_call_table = (void *)&(ptr[-1 * (__NR_close - 1024)]);
- 	    break;
- 	}
- #elif defined(EXPORTED_SYS_WAIT4) && defined(EXPORTED_SYS_CLOSE)
- 	if (ptr[0] == (unsigned long)&sys_close
- 	    && ptr[__NR_wait4 - __NR_close] == (unsigned long)&sys_wait4) {
- 	    sys_call_table = ptr - __NR_close;
- 	    break;
- 	}
- #elif defined(EXPORTED_SYS_CHDIR) && defined(EXPORTED_SYS_CLOSE)
- 	if (ptr[0] == (unsigned long)&sys_close
- 	    && ptr[__NR_chdir - __NR_close] == (unsigned long)&sys_chdir) {
- 	    sys_call_table = ptr - __NR_close;
- 	    break;
- 	}
- #elif defined(EXPORTED_SYS_OPEN)
- 	if (ptr[0] == (unsigned long)&sys_exit
- 	    && ptr[__NR_open - __NR_exit] == (unsigned long)&sys_open) {
- 	    sys_call_table = ptr - __NR_exit;
- 	    break;
- 	}
- #else /* EXPORTED_SYS_OPEN */
- 	break;
- #endif /* EXPORTED_KALLSYMS_ADDRESS */
-     }
- #ifdef EXPORTED_KALLSYMS_ADDRESS
-     ret =
- 	kallsyms_address_to_symbol((unsigned long)sys_call_table, &mod_name,
- 				   &mod_start, &mod_end, &sec_name,
- 				   &sec_start, &sec_end, &sym_name,
- 				   &sym_start, &sym_end);
-     if (ret && strcmp(sym_name, "sys_call_table"))
- 	sys_call_table = 0;
- #endif /* EXPORTED_KALLSYMS_ADDRESS */
-     if (!sys_call_table) {
- 	printf("Failed to find address of sys_call_table\n");
-     } else {
- 	printf("Found sys_call_table at %lx\n", (unsigned long)sys_call_table);
- #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
- 	error cant support this yet.;
- #endif /* AFS_SPARC64_LINUX20_ENV */
- #endif /* EXPORTED_SYS_CALL_TABLE */
- 
- #ifdef AFS_AMD64_LINUX20_ENV
- #ifndef EXPORTED_IA32_SYS_CALL_TABLE
- 	ia32_sys_call_table = 0;
- #ifdef EXPORTED_KALLSYMS_SYMBOL
- 	ret = 1;
- 	token = 0;
- 	while (ret) {
- 	    sym_start = 0;
- 	    ret = kallsyms_symbol_to_address("ia32_sys_call_table", &token,
- 					     &mod_name, &mod_start, &mod_end,
- 					     &sec_name, &sec_start, &sec_end,
- 					     &sym_name, &sym_start, &sym_end);
- 	    if (ret && !strcmp(mod_name, "kernel"))
- 		break;
- 	}
- 	if (ret && sym_start) {
- 	    ia32_sys_call_table = sym_start;
- 	}
- #else /* EXPORTED_KALLSYMS_SYMBOL */
- #ifdef EXPORTED_KALLSYMS_ADDRESS
- 	ret = kallsyms_address_to_symbol((unsigned long)
- 					 &interruptible_sleep_on,
- 					 &mod_name, &mod_start, &mod_end,
- 					 &sec_name, &sec_start, &sec_end,
- 					 &sym_name, &sym_start, &sym_end);
- 	ptr = (unsigned long *)sec_start;
- 	datalen = (sec_end - sec_start) / sizeof(unsigned long);
- #else /* EXPORTED_KALLSYMS_ADDRESS */
- #if defined(AFS_AMD64_LINUX20_ENV)
- 	ptr = (unsigned long *)&interruptible_sleep_on;
- 	datalen = 0x180000 / sizeof(ptr);
- #else /* AFS_AMD64_LINUX20_ENV */
- 	ptr = (unsigned long *)&interruptible_sleep_on;
- 	datalen = 16384;
- #endif /* AFS_AMD64_LINUX20_ENV */
- #endif /* EXPORTED_KALLSYMS_ADDRESS */
- 	for (offset = 0; offset < datalen; ptr++, offset++) {
- 	    if (ptr[0] == (unsigned long)&sys_exit
- 		&& ptr[__NR_ia32_open - __NR_ia32_exit] ==
- 		(unsigned long)&sys_open) {
- 		    ia32_sys_call_table = ptr - __NR_ia32_exit;
- 		    break;
- 	    }
- 	}
- #ifdef EXPORTED_KALLSYMS_ADDRESS
- 	ret = kallsyms_address_to_symbol((unsigned long)ia32_sys_call_table,
- 					 &mod_name, &mod_start, &mod_end,
- 					 &sec_name, &sec_start, &sec_end,
- 					 &sym_name, &sym_start, &sym_end);
- 	if (ret && strcmp(sym_name, "ia32_sys_call_table"))
- 	    ia32_sys_call_table = 0;
- #endif /* EXPORTED_KALLSYMS_ADDRESS */
- #endif /* EXPORTED_KALLSYMS_SYMBOL */
- 	if (!ia32_sys_call_table) {
- 	    printf("Warning: Failed to find address of ia32_sys_call_table\n");
- 	} else {
- 	    printf("Found ia32_sys_call_table at %lx\n", (unsigned long)ia32_sys_call_table);
- 	}
- #else
- 	printf("Found ia32_sys_call_table at %lx\n", (unsigned long)ia32_sys_call_table);
- #endif /* IA32_SYS_CALL_TABLE */
- #endif
- 
- 	/* Initialize pointers to kernel syscalls. */
- #if !defined(AFS_LINUX24_ENV)
- 	sys_settimeofdayp = SYSCALL2POINTER sys_call_table[_S(__NR_settimeofday)];
- #endif /* AFS_IA64_LINUX20_ENV */
- 
- 	/* setup AFS entry point. */
- 	if (
- #if defined(AFS_IA64_LINUX20_ENV)
- 		SYSCALL2POINTER sys_call_table[__NR_afs_syscall - 1024]
- #else
- 		SYSCALL2POINTER sys_call_table[_S(__NR_afs_syscall)]
- #endif
- 		== afs_syscall) {
- 	    printf("AFS syscall entry point already in use!\n");
- 	    return -EBUSY;
- 	}
- #if defined(AFS_IA64_LINUX20_ENV)
- 	afs_ni_syscall = sys_call_table[__NR_afs_syscall - 1024];
- 	sys_call_table[__NR_afs_syscall - 1024] =
- 		POINTER2SYSCALL((struct fptr *)afs_syscall_stub)->ip;
- #else /* AFS_IA64_LINUX20_ENV */
- 	afs_ni_syscall = sys_call_table[_S(__NR_afs_syscall)];
- 	sys_call_table[_S(__NR_afs_syscall)] = POINTER2SYSCALL afs_syscall;
- #ifdef AFS_SPARC64_LINUX20_ENV
- 	afs_ni_syscall32 = sys_call_table32[__NR_afs_syscall];
- 	sys_call_table32[__NR_afs_syscall] = POINTER2SYSCALL afs_syscall32;
- #endif
- #endif /* AFS_IA64_LINUX20_ENV */
- #ifdef AFS_AMD64_LINUX20_ENV
- 	if (ia32_sys_call_table) {
- 	    ia32_ni_syscall = ia32_sys_call_table[__NR_ia32_afs_syscall];
- 	    ia32_sys_call_table[__NR_ia32_afs_syscall] =
- 		    POINTER2SYSCALL afs_syscall;
- 	}
- #endif /* AFS_S390_LINUX22_ENV */
- #ifndef EXPORTED_SYS_CALL_TABLE
-     }
- #endif /* EXPORTED_SYS_CALL_TABLE */
      osi_Init();
-     register_filesystem(&afs_fs_type);
- 
-     /* Intercept setgroups calls */
-     if (sys_call_table) {
- #if defined(AFS_IA64_LINUX20_ENV)
-     sys_setgroupsp = (void *)&sys_setgroups;
- 
-     ((struct fptr *)sys_setgroupsp)->ip =
- 	SYSCALL2POINTER sys_call_table[__NR_setgroups - 1024];
-     ((struct fptr *)sys_setgroupsp)->gp = kernel_gp;
- 
-     sys_call_table[__NR_setgroups - 1024] =
- 	POINTER2SYSCALL((struct fptr *)afs_xsetgroups_stub)->ip;
- #else /* AFS_IA64_LINUX20_ENV */
-     sys_setgroupsp = SYSCALL2POINTER sys_call_table[_S(__NR_setgroups)];
-     sys_call_table[_S(__NR_setgroups)] = POINTER2SYSCALL afs_xsetgroups;
- #ifdef AFS_SPARC64_LINUX20_ENV
-     sys32_setgroupsp = SYSCALL2POINTER sys_call_table32[__NR_setgroups];
-     sys_call_table32[__NR_setgroups] = POINTER2SYSCALL afs32_xsetgroups;
- #endif /* AFS_SPARC64_LINUX20_ENV */
- #if defined(__NR_setgroups32)
-     sys_setgroups32p = SYSCALL2POINTER sys_call_table[__NR_setgroups32];
-     sys_call_table[__NR_setgroups32] = POINTER2SYSCALL afs_xsetgroups32;
- #ifdef AFS_SPARC64_LINUX20_ENV
- 	sys32_setgroups32p =
- 	    SYSCALL2POINTER sys_call_table32[__NR_setgroups32];
- 	sys_call_table32[__NR_setgroups32] =
- 	    POINTER2SYSCALL afs32_xsetgroups32;
- #endif /* AFS_SPARC64_LINUX20_ENV */
- #endif /* __NR_setgroups32 */
- #ifdef AFS_AMD64_LINUX20_ENV
-     if (ia32_sys_call_table) {
- 	sys32_setgroupsp =
- 	    SYSCALL2POINTER ia32_sys_call_table[__NR_ia32_setgroups];
- 	ia32_sys_call_table[__NR_ia32_setgroups] =
- 	    POINTER2SYSCALL afs32_xsetgroups;
- #if defined(__NR_ia32_setgroups32)
- 	sys32_setgroups32p =
- 	    SYSCALL2POINTER ia32_sys_call_table[__NR_ia32_setgroups32];
- 	ia32_sys_call_table[__NR_ia32_setgroups32] =
- 	    POINTER2SYSCALL afs32_xsetgroups32;
- #endif /* __NR_ia32_setgroups32 */
-     }
- #endif /* AFS_AMD64_LINUX20_ENV */
- #endif /* AFS_IA64_LINUX20_ENV */
- 
-     }
  
      osi_sysctl_init();
      afsproc_init();
  
--- 169,179 ----
  #endif /* AFS_S390_LINUX22_ENV */
  #endif /* !defined(AFS_LINUX24_ENV) */
  
      osi_Init();
  
+     e = osi_syscall_init();
+     if (e) return e;
+     register_filesystem(&afs_fs_type);
      osi_sysctl_init();
      afsproc_init();
  
***************
*** 586,624 ****
  #endif
  {
      osi_sysctl_clean();
!     if (sys_call_table) {
! #if defined(AFS_IA64_LINUX20_ENV)
!     sys_call_table[__NR_setgroups - 1024] =
! 	POINTER2SYSCALL((struct fptr *)sys_setgroupsp)->ip;
!     sys_call_table[__NR_afs_syscall - 1024] = afs_ni_syscall;
! #else /* AFS_IA64_LINUX20_ENV */
!     sys_call_table[_S(__NR_setgroups)] = POINTER2SYSCALL sys_setgroupsp;
!     sys_call_table[_S(__NR_afs_syscall)] = afs_ni_syscall;
! # ifdef AFS_SPARC64_LINUX20_ENV
!     sys_call_table32[__NR_setgroups] = POINTER2SYSCALL sys32_setgroupsp;
!     sys_call_table32[__NR_afs_syscall] = afs_ni_syscall32;
! # endif
! # if defined(__NR_setgroups32)
!     sys_call_table[__NR_setgroups32] = POINTER2SYSCALL sys_setgroups32p;
! # ifdef AFS_SPARC64_LINUX20_ENV
! 	sys_call_table32[__NR_setgroups32] =
! 	    POINTER2SYSCALL sys32_setgroups32p;
! # endif
! # endif
! #endif /* AFS_IA64_LINUX20_ENV */
! #ifdef AFS_AMD64_LINUX20_ENV
!     if (ia32_sys_call_table) {
! 	ia32_sys_call_table[__NR_ia32_setgroups] =
! 	    POINTER2SYSCALL sys32_setgroupsp;
! 	ia32_sys_call_table[__NR_ia32_afs_syscall] =
! 	    POINTER2SYSCALL ia32_ni_syscall;
! # if defined(__NR_setgroups32)
! 	ia32_sys_call_table[__NR_ia32_setgroups32] =
! 	    POINTER2SYSCALL sys32_setgroups32p;
! #endif
!     }
! #endif
!     }
      unregister_filesystem(&afs_fs_type);
  
      osi_linux_free_inode_pages();	/* Invalidate all pages using AFS inodes. */
--- 189,195 ----
  #endif
  {
      osi_sysctl_clean();
!     osi_syscall_clean();
      unregister_filesystem(&afs_fs_type);
  
      osi_linux_free_inode_pages();	/* Invalidate all pages using AFS inodes. */
Index: openafs/src/afs/LINUX/osi_probe.c
diff -c /dev/null openafs/src/afs/LINUX/osi_probe.c:1.1.2.1
*** /dev/null	Sun Jan 30 23:45:40 2005
--- openafs/src/afs/LINUX/osi_probe.c	Sun Jan 30 23:25:13 2005
***************
*** 0 ****
--- 1,1125 ----
+ /*
+  * vi:set cin noet sw=4 tw=70:
+  * Copyright 2004, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  *
+  * Portions of this code borrowed from arla under the following terms:
+  * Copyright (c) 2003-2004 Kungliga Tekniska Högskolan
+  * (Royal Institute of Technology, Stockholm, Sweden).
+  * All rights reserved.
+  * 
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+  * are met:
+  * 
+  * 1. Redistributions of source code must retain the above copyright
+  *    notice, this list of conditions and the following disclaimer.
+  * 
+  * 2. Redistributions in binary form must reproduce the above copyright
+  *    notice, this list of conditions and the following disclaimer in the
+  *    documentation and/or other materials provided with the distribution.
+  * 
+  * 3. Neither the name of the Institute nor the names of its contributors
+  *    may be used to endorse or promote products derived from this software
+  *    without specific prior written permission.
+  * 
+  * Alternatively, this software may be distributed under the terms of the
+  * GNU General Public License ("GPL").
+  * 
+  * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+  * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+  * SUCH DAMAGE.
+  */
+ 
+ /* Code to find the Linux syscall table */
+ 
+ #ifdef OSI_PROBE_STANDALONE
+ #define OSI_PROBE_DEBUG
+ #endif
+ #ifndef OSI_PROBE_STANDALONE
+ #include <afsconfig.h>
+ #include "afs/param.h"
+ #endif
+ #include <linux/module.h> /* early to avoid printf->printk mapping */
+ #ifndef OSI_PROBE_STANDALONE
+ #include "afs/sysincludes.h"
+ #include "afsincludes.h"
+ #endif
+ #include <linux/version.h>
+ #include <linux/config.h>
+ #include <linux/linkage.h>
+ #include <linux/init.h>
+ #include <linux/unistd.h>
+ #include <linux/mm.h>
+ 
+ #ifdef AFS_AMD64_LINUX20_ENV
+ #include <asm/ia32_unistd.h>
+ #endif
+ 
+ #ifdef HAVE_KERNEL_LINUX_SYSCALL_H
+ #include <linux/syscall.h>
+ #endif
+ 
+ /* number of syscalls */
+ /* NB: on MIPS we care about the 4xxx range */
+ #ifndef NR_syscalls
+ #define NR_syscalls 222
+ #endif
+ 
+ /* lower bound of valid kernel text pointers */
+ //#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,5,0)
+ #define ktxt_lower_bound (((unsigned long)&kernel_thread )  & ~0xfffffL)
+ //#else
+ //#define ktxt_lower_bound (((unsigned long)&empty_zero_page) & ~0xfffffL)
+ //#endif
+ 
+ /* On SPARC64 and S390X, sys_call_table contains 32-bit entries
+  * even though pointers are 64 bit quantities.
+  */
+ #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
+ #define SYSCALLTYPE unsigned int
+ #define PROBETYPE int
+ #else
+ #define SYSCALLTYPE void *
+ #define PROBETYPE long
+ #endif
+ 
+ 
+ /* Allow the user to specify sys_call_table addresses */
+ static unsigned long sys_call_table_addr[4] = { 0,0,0,0 };
+ MODULE_PARM(sys_call_table_addr, "1-4l");
+ MODULE_PARM_DESC(sys_call_table_addr, "Location of system call tables");
+ 
+ /* If this is set, we are more careful about avoiding duplicate matches */
+ static int probe_carefully = 1;
+ MODULE_PARM(probe_carefully, "i");
+ MODULE_PARM_DESC(probe_carefully, "Probe for system call tables carefully");
+ 
+ static int probe_ignore_syscalls[8] = { -1, -1, -1, -1, -1, -1, -1, -1 };
+ MODULE_PARM(probe_ignore_syscalls, "1-8i");
+ MODULE_PARM_DESC(probe_ignore_syscalls, "Syscalls to ignore in table checks");
+ 
+ #ifdef OSI_PROBE_DEBUG
+ /* 
+  * Debugging flags:
+  * 0x0001 - General debugging
+  * 0x0002 - detail - try
+  * 0x0004 - detail - try_harder
+  * 0x0008 - detail - check_table
+  * 0x0010 - detail - check_harder
+  * 0x0020 - detail - check_harder/zapped
+  * 0x0040 - automatically ignore setgroups and afs_syscall
+  */
+ static int probe_debug = 0x41;
+ MODULE_PARM(probe_debug, "i");
+ MODULE_PARM_DESC(probe_debug, "Debugging level");
+ 
+ static unsigned long probe_debug_addr[4] = { 0,0,0,0 };
+ MODULE_PARM(probe_debug_addr, "1-4l");
+ MODULE_PARM_DESC(probe_debug_addr, "Debug range starting locations");
+ 
+ static unsigned long probe_debug_range = 0;
+ MODULE_PARM(probe_debug_range, "l");
+ MODULE_PARM_DESC(probe_debug_range, "Debug range length");
+ 
+ static unsigned long probe_debug_tag = 0;
+ MODULE_PARM(probe_debug_tag, "l");
+ MODULE_PARM_DESC(probe_debug_tag, "Debugging output start tag");
+ #endif
+ 
+ 
+ /* Weak references are our friends.  They are supported by the in-kernel
+  * linker in Linux 2.6 and by all versions of modutils back to 2.2pre1.
+  * A weak reference not satisified by the kernel will have value zero.
+  */
+ extern int kallsyms_symbol_to_address(char *name, unsigned long *token,
+ 				      char **mod_name,
+ 				      unsigned long *mod_start,
+ 				      unsigned long *mod_end,
+ 				      char **sec_name,
+ 				      unsigned long *sec_start,
+ 				      unsigned long *sec_end,
+ 				      char **sym_name,
+ 				      unsigned long *sym_start,
+ 				      unsigned long *sym_end
+ 				     ) __attribute__((weak));
+ 
+ extern int kallsyms_address_to_symbol(unsigned long address,
+ 				      char **mod_name,
+ 				      unsigned long *mod_start,
+ 				      unsigned long *mod_end,
+ 				      char **sec_name,
+ 				      unsigned long *sec_start,
+ 				      unsigned long *sec_end,
+ 				      char **sym_name,
+ 				      unsigned long *sym_start,
+ 				      unsigned long *sym_end
+ 				     ) __attribute__((weak));
+ 
+ extern SYSCALLTYPE sys_call_table[] __attribute__((weak));
+ extern SYSCALLTYPE ia32_sys_call_table[] __attribute__((weak));
+ extern SYSCALLTYPE sys_call_table32[] __attribute__((weak));
+ 
+ extern asmlinkage long sys_close(unsigned int) __attribute__((weak));
+ extern asmlinkage long sys_chdir(const char *) __attribute__((weak));
+ extern asmlinkage int  sys_write(unsigned int, const char *, size_t) __attribute__((weak));
+ #ifdef AFS_LINUX26_ENV
+ extern asmlinkage long sys_wait4(pid_t, int *, int, struct rusage *) __attribute__((weak));
+ #else
+ extern asmlinkage long sys_wait4(pid_t, unsigned int *, int, struct rusage *) __attribute__((weak));
+ #endif
+ extern asmlinkage int  sys_exit (int) __attribute__((weak));
+ extern asmlinkage long sys_open (const char *, int, int) __attribute__((weak));
+ extern asmlinkage long sys_ioctl(unsigned int, unsigned int, unsigned long) __attribute__((weak));
+ 
+ 
+ /* Structures used to control probing.  We put all the details of which
+  * symbols we're interested in, what syscall functions to look for, etc
+  * into tables, so we can then have a single copy of the functions that
+  * actually do the work.
+  */
+ typedef struct {
+     char *name;
+     int NR1;
+     void *fn1;
+     int NR2;
+     void *fn2;
+     int NR3;
+     void *fn3;
+ } tryctl;
+ 
+ typedef struct {
+     char *symbol;                   /* symbol name */
+     char *desc;                     /* description for messages */
+     int offset;                     /* first syscall number in table */
+ 
+     void *weak_answer;              /* weak symbol ref */
+     void *parm_answer;              /* module parameter answer */
+     void *debug_answer;             /* module parameter answer */
+     unsigned long given_answer;     /* compiled-in answer, if any */
+ 
+     tryctl *trylist;                /* array of combinations to try */
+ 
+     unsigned long try_sect_sym;     /* symbol in section to try scanning */
+     unsigned long try_base;         /* default base address for scan */
+     unsigned long try_base_mask;    /* base address bits to force to zero */
+     unsigned long try_length;       /* default length for scan */
+ 
+     int n_zapped_syscalls;          /* number of unimplemented system calls */
+     int *zapped_syscalls;           /* list of unimplemented system calls */
+ 
+     int n_unique_syscalls;          /* number of unique system calls */
+     int *unique_syscalls;           /* list of unimplemented system calls */
+ 
+     int verifyNR;                   /* syscall number to verify match */
+     void *verify_fn;                /* syscall pointer to verify match */
+ 
+     int debug_ignore_NR[4];         /* syscalls to ignore for debugging */
+ } probectl;
+ 
+ 
+ 
+ /********** Probing Configuration: sys_call_table **********/
+ 
+ /* syscall pairs/triplets to probe */
+ /* On PPC64 and SPARC64, we need to omit the ones that might match both tables */
+ static tryctl main_try[] = {
+ #if !defined(AFS_PPC64_LINUX20_ENV) && !defined(AFS_SPARC64_LINUX20_ENV)
+     { "scan: close+chdir+write", __NR_close, &sys_close, __NR_chdir, &sys_chdir, __NR_write, &sys_write },
+ #endif
+     { "scan: close+wait4",       __NR_close, &sys_close, __NR_wait4, &sys_wait4, -1,         0          },
+ #if !defined(AFS_PPC64_LINUX20_ENV) && !defined(AFS_SPARC64_LINUX20_ENV)
+     { "scan: close+chdir",       __NR_close, &sys_close, __NR_chdir, &sys_chdir, -1,         0          },
+ #endif
+     { "scan: close+ioctl",       __NR_close, &sys_close, __NR_ioctl, &sys_ioctl, -1,         0          },
+     { "scan: exit+open",         __NR_exit,  &sys_exit,  __NR_open,  &sys_open,  -1,         0          },
+     { 0 }
+ };
+ 
+ /* zapped syscalls for try_harder */
+ /* this list is based on the table in 'zapped_syscalls' */
+ 
+ static int main_zapped_syscalls[] = {
+ /* 
+  * SPARC-Linux uses syscall number mappings chosen to be compatible
+  * with SunOS.  So, it doesn't have any of the traditional calls or
+  * the new STREAMS ones.  However, there are a number of syscalls
+  * which are SunOS-specific (not implemented on Linux), i386-specific
+  * (not implemented on SPARC-Linux), or implemented only on one of
+  * sparc32 or sparc64.  Of course, there are no __NR macros for most
+  * of these.
+  * 
+  * Note that the calls we list here are implemented by sys_nis_syscall,
+  * not by sys_ni_syscall.  That means we have to exclude all of the
+  * other entries, or we might get a sys_ni_syscall into the list and
+  * the test would no longer work.
+  */
+ #if defined(AFS_SPARC64_LINUX20_ENV)
+     /* mmap2, fstat64, getmsg, putmsg, modify_ldt */
+     56, 63, 151, 152, 218,
+ #elif defined(AFS_SPARC_LINUX20_ENV)
+     /* memory_ordering, getmsg, putmsg, unimplemented, modify_ldt */
+     52, 151, 152, 164, 218,
+ #else /* !AFS_SPARC_LINUX20_ENV */
+ 
+ /* 
+  * These 7 syscalls are present in the syscall table on most "older"
+  * platforms that use the traditional syscall number mappings.  They
+  * are not implemented on any platform.
+  */
+ #ifdef __NR_break
+     __NR_break,
+ #endif
+ #ifdef __NR_stty
+     __NR_stty,
+ #endif
+ #ifdef __NR_gtty
+     __NR_gtty,
+ #endif
+ #ifdef __NR_ftime
+     __NR_ftime,
+ #endif
+ #ifdef __NR_prof
+     __NR_prof,
+ #endif
+ #ifdef __NR_lock
+     __NR_lock,
+ #endif
+ #ifdef __NR_mpx
+     __NR_mpx,
+ #endif
+ /* 
+  * On s390 and arm (but not arm26), the seven traditional unimplemented
+  * system calls are indeed present and unimplemented.  However, the
+  * corresponding __NR macros are not defined, so the tests above fail.
+  * Instead, we just have to know the numbers for these.
+  */
+ #ifdef AFS_S390_LINUX20_ENV
+     /* break, stty, gtty, ftime, prof, lock, mpx */
+     17, 31, 32, 35, 44, 53, 56,
+ #endif
+ 
+ /* 
+  * Sadly, some newer platforms like IA64, amd64, and PA-RISC don't have
+  * the traditional numbers, so the list above are not helpful.  They
+  * do have entries for getpmsg/putpmsg, which are always unimplemented.
+  */
+ #ifdef __NR_getpmsg
+     __NR_getpmsg,
+ #endif
+ #ifdef __NR_putpmsg
+     __NR_putpmsg,
+ #endif
+ 
+ /* 
+  * The module-loading mechanism changed in Linux 2.6, and insmod's
+  * loss is our gain: three new unimplemented system calls! 
+  */
+ #if defined(AFS_LINUX26_ENV)
+ #ifdef __NR_
+     __NR_create_module,
+ #endif
+ #ifdef __NR_query_module
+     __NR_query_module,
+ #endif
+ #ifdef __NR_get_kernel_syms
+     __NR_get_kernel_syms,
+ #endif
+ #endif /* AFS_LINUX26_ENV */
+ 
+ /* 
+  * On IA64, the old module-loading calls are indeed present and
+  * unimplemented, but the __NR macros are not defined.  Again,
+  * we simply have to know their numbers.
+  */
+ #ifdef AFS_IA64_LINUX26_ENV
+     /* create_module, query_module, get_kernel_sysms */
+     1132, 1136, 1135,
+ #endif
+ 
+ /* And the same deal for arm (not arm26), if we ever support that. */
+ #if 0
+     /* create_module, query_module, get_kernel_sysms */
+     127, 167, 130,
+ #endif
+ 
+ /*
+  * Alpha-Linux uses syscall number mappings chosen to be compatible
+  * with OSF/1.  So, it doesn't have any of the traditional calls or
+  * the new STREAMS ones, but it does have several OSF/1-specific
+  * syscalls which are not implemented on Linux.  These don't exist on
+  * any other platform.
+  */
+ #ifdef __NR_osf_syscall
+     __NR_osf_syscall,
+ #endif
+ #ifdef __NR_osf_profil
+     __NR_osf_profil,
+ #endif
+ #ifdef __NR_osf_reboot
+     __NR_osf_reboot,
+ #endif
+ #ifdef __NR_osf_kmodcall
+     __NR_osf_kmodcall,
+ #endif
+ #ifdef __NR_osf_old_vtrace
+     __NR_osf_old_vtrace,
+ #endif
+ 
+ /*
+  * On PPC64, we need a couple more entries to distinguish the two
+  * tables, since the system call numbers are the same and the sets of
+  * unimplemented calls are very similar.
+  * mmap2 and fstat64 are implemented only for 32-bit calls
+  */
+ #ifdef AFS_PPC64_LINUX20_ENV
+     __NR_mmap2,
+     __NR_fstat64,
+ #endif /* AFS_PPC64_LINUX20_ENV */
+ 
+ /* Similarly for S390X, with lcown16 and fstat64 */
+ #ifdef AFS_S390X_LINUX20_ENV
+     /* lchown16, fstat64 */
+     16, 197,
+ #endif
+ #endif /* !AFS_SPARC_LINUX20_ENV */
+     0
+ };
+ 
+ /* unique syscalls for try_harder */
+ static int main_unique_syscalls[] = {
+     __NR_exit, __NR_mount, __NR_read, __NR_write,
+     __NR_open, __NR_close, __NR_unlink
+ };
+ 
+ /* probe control structure */
+ static probectl main_probe = {
+     /* symbol name and description */
+     "sys_call_table",
+     "system call table",
+ 
+     /* syscall number of first entry in table */
+ #ifdef AFS_IA64_LINUX20_ENV
+     1024,
+ #else
+     0,
+ #endif
+ 
+     sys_call_table,               /* weak symbol ref */
+     0, 0,                         /* module parameter answers */
+ #ifdef AFS_LINUX_sys_call_table
+     AFS_LINUX_sys_call_table,     /* compiled-in answer, if any */
+ #else
+     0,
+ #endif
+ 
+     main_try,                     /* array of combinations to try */
+ 
+     /* symbol in section to try scanning */
+ #if defined(AFS_SPARC64_LINUX20_ENV)
+     (unsigned long)&sys_close,
+ #elif defined(AFS_AMD64_LINUX20_ENV)
+     /* On this platform, it's in a different section! */
+     (unsigned long)&tasklist_lock,
+ #else
+     (unsigned long)&init_mm,
+ #endif
+ 
+     /* default base address for scan */
+     /* base address bits to force to zero */
+     /* default length for scan */
+ #if   defined(AFS_SPARC64_LINUX20_ENV)
+     (unsigned long)(&sys_close),
+     0xfffff,
+     0x10000,
+ #elif   defined(AFS_IA64_LINUX20_ENV)
+     (unsigned long)(&sys_close - 0x180000),
+     0,
+     (0x180000 / sizeof(unsigned long *)),
+ #elif defined(AFS_AMD64_LINUX20_ENV)
+     (unsigned long)(&tasklist_lock - 0x1000),
+     0,
+     16384,
+ #else
+     (unsigned long)&init_mm,
+     0,
+     16384,
+ #endif
+ 
+     /* number and list of unimplemented system calls */
+     ((sizeof(main_zapped_syscalls)/sizeof(main_zapped_syscalls[0])) - 1),
+     main_zapped_syscalls,
+ 
+     /* number and list of unique system calls */
+     (sizeof(main_unique_syscalls)/sizeof(main_unique_syscalls[0])),
+     main_unique_syscalls,
+ 
+     /* syscall number and pointer to verify match */
+     __NR_close, &sys_close,
+ 
+     /* syscalls to ignore for debugging */
+     {
+ #if   defined(AFS_ALPHA_LINUX20_ENV)
+ 	338,
+ #elif defined(AFS_AMD64_LINUX20_ENV)
+ 	183,
+ #elif defined(AFS_IA64_LINUX20_ENV)
+ 	1141,
+ #elif defined(AFS_SPARC_LINUX20_ENV) || defined(AFS_SPARC64_LINUX20_ENV)
+ 	227,
+ #else
+ 	137,
+ #endif
+ 	__NR_setgroups,
+ #ifdef __NR_setgroups32
+ 	__NR_setgroups32,
+ #else
+ 	-1,
+ #endif
+ 	-1,
+     }
+ };
+ 
+ 
+ /********** Probing Configuration: amd64 ia32_sys_call_table **********/
+ #if defined(AFS_AMD64_LINUX20_ENV)
+ 
+ /* syscall pairs/triplets to probe */
+ static tryctl ia32_try[] = {
+     { "scan: close+chdir+write", __NR_ia32_close, &sys_close, __NR_ia32_chdir, &sys_chdir,        __NR_ia32_write, &sys_write },
+     { "scan: close+chdir",       __NR_ia32_close, &sys_close, __NR_ia32_chdir, &sys_chdir,        -1,              0          },
+     { 0 }
+ };
+ 
+ /* zapped syscalls for try_harder */
+ static int ia32_zapped_syscalls[] = {
+     __NR_ia32_break, __NR_ia32_stty, __NR_ia32_gtty, __NR_ia32_ftime,
+     __NR_ia32_prof,  __NR_ia32_lock, __NR_ia32_mpx,
+     0
+ };
+ 
+ /* unique syscalls for try_harder */
+ static int ia32_unique_syscalls[] = {
+     __NR_ia32_exit, __NR_ia32_mount, __NR_ia32_read, __NR_ia32_write,
+     __NR_ia32_open, __NR_ia32_close, __NR_ia32_unlink
+ };
+ 
+ /* probe control structure */
+ static probectl ia32_probe = {
+     /* symbol name and description */
+     "ia32_sys_call_table",
+     "32-bit system call table",
+ 
+     /* syscall number of first entry in table */
+     0,
+ 
+     ia32_sys_call_table,          /* weak symbol ref */
+     0, 0,                         /* module parameter answers */
+ #ifdef AFS_LINUX_ia32_sys_call_table
+     AFS_LINUX_ia32_sys_call_table,/* compiled-in answer, if any */
+ #else
+     0,
+ #endif
+ 
+     ia32_try,                     /* array of combinations to try */
+ 
+     /* symbol in section to try scanning */
+     (unsigned long)&init_mm,
+ 
+     /* default base address for scan */
+     /* base address bits to force to zero */
+     /* default length for scan */
+     (unsigned long)&init_mm,
+     0,
+     (0x180000 / sizeof(unsigned long *)),
+ 
+     /* number and list of unimplemented system calls */
+     ((sizeof(ia32_zapped_syscalls)/sizeof(ia32_zapped_syscalls[0])) - 1),
+     ia32_zapped_syscalls,
+ 
+     /* number and list of unique system calls */
+     (sizeof(ia32_unique_syscalls)/sizeof(ia32_unique_syscalls[0])),
+     ia32_unique_syscalls,
+ 
+     /* syscall number and pointer to verify match */
+     __NR_ia32_close, &sys_close,
+ 
+     /* syscalls to ignore for debugging */
+     {
+ 	137,
+ 	__NR_ia32_setgroups,
+ 	__NR_ia32_setgroups32,
+ 	-1,
+     }
+ };
+ 
+ static probectl *probe_list[] = {
+     &main_probe, &ia32_probe
+ };
+ 
+ 
+ /********** Probing Configuration: ppc64, sparc64 sys_call_table32 **********/
+ #elif defined(AFS_PPC64_LINUX20_ENV) || defined(AFS_SPARC64_LINUX20_ENV)
+ 
+ /* 
+  * syscall pairs/triplets to probe
+  * This has to be empty, because anything that would work will
+  * also match the main table, and that's no good.
+  */
+ static tryctl sct32_try[] = {
+     { 0 }
+ };
+ 
+ /* zapped syscalls for try_harder */
+ static int sct32_zapped_syscalls[] = {
+ #ifdef AFS_PPC64_LINUX20_ENV
+     /* These should be sufficient */
+     __NR_break, __NR_stty, __NR_gtty, __NR_ftime,
+     __NR_prof, __NR_lock, __NR_mpx,
+ #endif
+ #ifdef AFS_SPARC64_LINUX20_ENV
+     /* memory_ordering, getmsg, putmsg, unimplemented, modify_ldt */
+     52, 151, 152, 164, 218,
+ #endif
+     0
+ };
+ 
+ /* unique syscalls for try_harder */
+ /* mmap2 and fstat64 are implemented only for 32-bit calls */
+ static int sct32_unique_syscalls[] = {
+ #ifdef AFS_PPC64_LINUX20_ENV
+     __NR_mmap2, __NR_fstat64,
+ #endif
+     __NR_exit, __NR_mount, __NR_read, __NR_write,
+     __NR_open, __NR_close, __NR_unlink
+ };
+ 
+ /* probe control structure */
+ static probectl sct32_probe = {
+     /* symbol name and description */
+     "sys_call_table32",
+     "32-bit system call table",
+ 
+     /* syscall number of first entry in table */
+     0,
+ 
+     sys_call_table32,             /* weak symbol ref */
+     0, 0,                         /* module parameter answers */
+ #ifdef AFS_LINUX_sys_call_table32
+     AFS_LINUX_sys_call_table32,   /* compiled-in answer, if any */
+ #else
+     0,
+ #endif
+ 
+     sct32_try,                   /* array of combinations to try */
+ 
+     /* symbol in section to try scanning */
+ #if defined(AFS_SPARC64_LINUX20_ENV)
+     (unsigned long)&sys_close,
+ #else
+     (unsigned long)&init_mm,
+ #endif
+ 
+     /* default base address for scan */
+     /* base address bits to force to zero */
+     /* default length for scan */
+ #if   defined(AFS_SPARC64_LINUX20_ENV)
+     (unsigned long)(&sys_close),
+     0xfffff,
+     0x10000,
+ #else
+     (unsigned long)&init_mm,
+     0,
+     16384,
+ #endif
+ 
+     /* number and list of unimplemented system calls */
+     ((sizeof(sct32_zapped_syscalls)/sizeof(sct32_zapped_syscalls[0])) - 1),
+     sct32_zapped_syscalls,
+ 
+     /* number and list of unique system calls */
+     (sizeof(sct32_unique_syscalls)/sizeof(sct32_unique_syscalls[0])),
+     sct32_unique_syscalls,
+ 
+     /* syscall number and pointer to verify match */
+     __NR_close, &sys_close,
+ 
+     /* syscalls to ignore for debugging */
+     {
+ #if defined(AFS_SPARC64_LINUX20_ENV)
+ 	227,
+ #else
+ 	137,
+ #endif
+ 	__NR_setgroups,
+ 	-1,
+ 	-1,
+     }
+ };
+ 
+ static probectl *probe_list[] = {
+     &main_probe, &sct32_probe
+ };
+ 
+ 
+ /********** Probing Configuration: s390x sys_call_table_emu **********/
+ #elif defined(AFS_S390X_LINUX20_ENV)
+ 
+ /* syscall pairs/triplets to probe */
+ /* nothing worthwhile is exported, so this is empty */
+ static tryctl emu_try[] = {
+     { 0 }
+ };
+ 
+ /* zapped syscalls for try_harder */
+ static int emu_zapped_syscalls[] = {
+     /* break, stty, gtty, ftime, prof, lock, mpx */
+     17, 31, 32, 35, 44, 53, 56,
+     0
+ };
+ 
+ /* unique syscalls for try_harder */
+ static int emu_unique_syscalls[] = {
+     /* lchown16, fstat64 */
+     16, 197,
+     __NR_exit, __NR_mount, __NR_read, __NR_write,
+     __NR_open, __NR_close, __NR_unlink
+ };
+ 
+ /* probe control structure */
+ static probectl emu_probe = {
+     /* symbol name and description */
+     "sys_call_table_emu",
+     "32-bit system call table",
+ 
+     /* syscall number of first entry in table */
+     0,
+ 
+     sys_call_table_emu,           /* weak symbol ref */
+     0, 0,                         /* module parameter answers */
+ #ifdef AFS_LINUX_sys_call_table_emu
+     AFS_LINUX_sys_call_table_emu, /* compiled-in answer, if any */
+ #else
+     0,
+ #endif
+ 
+     emu_try,                      /* array of combinations to try */
+ 
+     /* symbol in section to try scanning */
+     (unsigned long)&init_mm,
+ 
+     /* default base address for scan */
+     /* base address bits to force to zero */
+     /* default length for scan */
+     (unsigned long)&init_mm,
+     0,
+     16384,
+ 
+     /* number and list of unimplemented system calls */
+     ((sizeof(emu_zapped_syscalls)/sizeof(emu_zapped_syscalls[0])) - 1),
+     emu_zapped_syscalls,
+ 
+     /* number and list of unique system calls */
+     (sizeof(emu_unique_syscalls)/sizeof(emu_unique_syscalls[0])),
+     emu_unique_syscalls,
+ 
+     /* syscall number and pointer to verify match */
+     __NR_close, &sys_close,
+ 
+     /* syscalls to ignore for debugging */
+     {
+ 	137,
+ 	__NR_setgroups,
+ 	-1,
+ 	-1,
+     }
+ };
+ 
+ static probectl *probe_list[] = {
+     &main_probe, &emu_probe
+ };
+ 
+ 
+ /********** End of Probing Configuration **********/
+ 
+ #else /* no per-platform probe control, so use the default list */
+ static probectl *probe_list[] = {
+     &main_probe
+ };
+ #endif
+ 
+ #define N_PROBE_LIST (sizeof(probe_list) / sizeof(*probe_list))
+ #define DEBUG_IN_RANGE(P,x) (!probe_debug_range ||                             \
+   (P->debug_answer &&                                                          \
+    (unsigned long)(x) >= (unsigned long)P->debug_answer &&                     \
+    (unsigned long)(x) <  (unsigned long)P->debug_answer + probe_debug_range))
+ 
+ 
+ 
+ static int check_table(probectl *P, PROBETYPE *ptr)
+ {
+     PROBETYPE *x;
+     int i, j;
+ 
+     for (x = ptr, i = 0; i < NR_syscalls; i++, x++) {
+ #ifdef OSI_PROBE_DEBUG
+ 	if (probe_debug & 0x0040) {
+ 	    for (j = 0; j < 4; j++) {
+ 		if (P->debug_ignore_NR[j] == i) break;
+ 	    }
+ 	    if (j < 4) continue;
+ 	}
+ #endif
+ 	for (j = 0; j < 8; j++) {
+ 	    if (probe_ignore_syscalls[j] == i) break;
+ 	}
+ 	if (j < 8) continue;
+ 	if (*x <= ktxt_lower_bound) {
+ #ifdef OSI_PROBE_DEBUG
+ 	    if ((probe_debug & 0x0008) && DEBUG_IN_RANGE(P,ptr))
+ 		printk("<7>check 0x%lx -> %d [0x%lx]\n",
+ 		       (unsigned long)ptr, i, (unsigned long)*x);
+ #endif
+ 	    return i;
+ 	}
+     }
+ #ifdef OSI_PROBE_DEBUG
+     if ((probe_debug & 0x0008) && DEBUG_IN_RANGE(P,ptr))
+ 	printk("<7>check 0x%lx -> ok\n", (unsigned long)ptr);
+ #endif
+     return -1;
+ }
+ 
+ static void *try(probectl *P, tryctl *T, PROBETYPE *ptr,
+ 		 unsigned long datalen)
+ {
+     char *mod_name, *sec_name, *sym_name;
+     unsigned long mod_start, mod_end;
+     unsigned long sec_start, sec_end;
+     unsigned long sym_start, sym_end;
+     unsigned long offset, ip1, ip2, ip3;
+     int ret;
+ 
+ #ifdef AFS_IA64_LINUX20_ENV
+     ip1 = T->fn1 ? (unsigned long)((struct fptr *)T->fn1)->ip : 0;
+     ip2 = T->fn2 ? (unsigned long)((struct fptr *)T->fn2)->ip : 0;
+     ip3 = T->fn3 ? (unsigned long)((struct fptr *)T->fn3)->ip : 0;
+ #else
+     ip1 = (unsigned long)T->fn1;
+     ip2 = (unsigned long)T->fn2;
+     ip3 = (unsigned long)T->fn3;
+ #endif
+ 
+ #ifdef OSI_PROBE_DEBUG
+     if (probe_debug & 0x0001)
+ 	printk("<7>osi_probe: %s                      %s (%d->0x%lx, %d->0x%lx, %d->0x%lx)\n",
+ 	       P->symbol, T->name, T->NR1, ip1, T->NR2, ip2, T->NR3, ip3);
+ #endif
+ 
+     if (!ip1 || !ip2 || (T->NR3 >= 0 && !ip3))
+ 	return 0;
+ 
+     for (offset = 0; offset < datalen; offset++, ptr++) {
+ 	ret = check_table(P, ptr);
+ 	if (ret >= 0) {
+ 	    /* return value is number of entries to skip */
+ 	    ptr    += ret;
+ 	    offset += ret;
+ 	    continue;
+ 	}
+ 
+ #ifdef OSI_PROBE_DEBUG
+ 	if ((probe_debug & 0x0002) && DEBUG_IN_RANGE(P,ptr))
+ 	    printk("<7>try 0x%lx\n", (unsigned long)ptr);
+ #endif
+ 	if (ptr[T->NR1 - P->offset] != ip1)                    continue;
+ 	if (ptr[T->NR2 - P->offset] != ip2)        continue;
+ 	if (ip3 && ptr[T->NR3 - P->offset] != ip3) continue;
+ 
+ #ifdef OSI_PROBE_DEBUG
+ 	if (probe_debug & 0x0002)
+ 	    printk("<7>try found 0x%lx\n", (unsigned long)ptr);
+ #endif
+ 	if (kallsyms_address_to_symbol) {
+ 	    ret = kallsyms_address_to_symbol((unsigned long)ptr,
+ 					     &mod_name, &mod_start, &mod_end,
+ 					     &sec_name, &sec_start, &sec_end,
+ 					     &sym_name, &sym_start, &sym_end);
+ 	    if (!ret || strcmp(sym_name, P->symbol)) continue;
+ 	}
+ 	/* XXX should we make sure there is only one match? */
+ 	return (void *)ptr;
+     }
+     return 0;
+ }
+ 
+ 
+ static int check_harder(probectl *P, PROBETYPE *p)
+ {
+     unsigned long ip1;
+     int i, s;
+ 
+     /* Check zapped syscalls */
+     for (i = 1; i < P->n_zapped_syscalls; i++) {
+ 	if (p[P->zapped_syscalls[i]] != p[P->zapped_syscalls[0]]) {
+ #ifdef OSI_PROBE_DEBUG
+ 	    if ((probe_debug & 0x0020) && DEBUG_IN_RANGE(P,p))
+ 		printk("<7>check_harder 0x%lx zapped failed i=%d\n", (unsigned long)p, i);
+ #endif
+ 	    return 0;
+ 	}
+     }
+ 
+     /* Check unique syscalls */
+     for (i = 0; i < P->n_unique_syscalls; i++) {
+ 	for (s = 0; s < NR_syscalls; s++) {
+ 	    if (p[s] == p[P->unique_syscalls[i]] && s != P->unique_syscalls[i]) {
+ #ifdef OSI_PROBE_DEBUG
+ 		if ((probe_debug & 0x0010) && DEBUG_IN_RANGE(P,p))
+ 		    printk("<7>check_harder 0x%lx unique failed i=%d s=%d\n", (unsigned long)p, i, s);
+ #endif
+ 		return 0;
+ 	    }
+ 	}
+     }
+ 
+ #ifdef AFS_IA64_LINUX20_ENV
+     ip1 = P->verify_fn ? (unsigned long)((struct fptr *)(P->verify_fn))->ip : 0;
+ #else
+     ip1 = (unsigned long)(P->verify_fn);
+ #endif
+ 
+     if (ip1 && p[P->verifyNR - P->offset] != ip1) {
+ #ifdef OSI_PROBE_DEBUG
+ 	if ((probe_debug & 0x0010) && DEBUG_IN_RANGE(P,p))
+ 	    printk("<7>check_harder 0x%lx verify failed\n", (unsigned long)p);
+ #endif
+ 	return 0;
+     }
+ 
+ #ifdef OSI_PROBE_DEBUG
+     if ((probe_debug & 0x0010) && DEBUG_IN_RANGE(P,p))
+ 	printk("<7>check_harder 0x%lx success!\n", (unsigned long)p);
+ #endif
+     return 1;
+ }
+ 
+ static void *try_harder(probectl *P, PROBETYPE *ptr, unsigned long datalen)
+ {
+     char *mod_name, *sec_name, *sym_name;
+     unsigned long mod_start, mod_end;
+     unsigned long sec_start, sec_end;
+     unsigned long sym_start, sym_end;
+     unsigned long offset;
+     void *match = 0;
+     int ret;
+ 
+ #ifdef OSI_PROBE_DEBUG
+     if (probe_debug & 0x0001)
+ 	printk("<7>osi_probe: %s                      try_harder\n", P->symbol);
+ #endif
+     for (offset = 0; offset < datalen; offset++, ptr++) {
+ 	ret = check_table(P, ptr);
+         if (ret >= 0) {
+             /* return value is number of entries to skip */
+ 	    ptr    += ret;
+ 	    offset += ret;
+ 	    continue;
+ 	}
+ 
+ #ifdef OSI_PROBE_DEBUG
+ 	if ((probe_debug & 0x0004) && DEBUG_IN_RANGE(P,ptr))
+ 	    printk("<7>try_harder 0x%lx\n", (unsigned long)ptr);
+ #endif
+ 	if (!check_harder(P, ptr))
+ 	    continue;
+ 
+ #ifdef OSI_PROBE_DEBUG
+ 	if (probe_debug & 0x0004)
+ 	    printk("<7>try_harder found 0x%lx\n", (unsigned long)ptr);
+ #endif
+ 
+ 	if (kallsyms_address_to_symbol) {
+ 	    ret = kallsyms_address_to_symbol((unsigned long)ptr,
+ 					     &mod_name, &mod_start, &mod_end,
+ 					     &sec_name, &sec_start, &sec_end,
+ 					     &sym_name, &sym_start, &sym_end);
+ 	    if (!ret || strcmp(sym_name, P->symbol)) continue;
+ 	}
+ 
+ 	if (match) {
+ #ifdef OSI_PROBE_DEBUG
+ 	    if (probe_debug & 0x0005)
+ 		printk("<7>%s: try_harder found multiple matches!\n", P->symbol);
+ #endif
+ 	    return 0;
+ 	}
+ 
+ 	match = (void *)ptr;
+ 	if (!probe_carefully)
+ 	    break;
+     }
+     return match;
+ }
+ 
+ 
+ #ifdef OSI_PROBE_DEBUG
+ #define check_result(x,m) do {                                                             \
+     if (probe_debug & 0x0001) {                                                              \
+ 	printk("<7>osi_probe: %s = 0x%016lx %s\n", P->symbol, (unsigned long)(x), (m)); \
+     }                                                                                      \
+     if ((x)) {                                                                             \
+ 	*method = (m);                                                                     \
+         final_answer = (void *)(x);                                                        \
+     }                                                                                      \
+ } while (0)
+ #else
+ #define check_result(x,m) do {  \
+     if ((x)) {                  \
+         *method = (m);          \
+         return (void *)(x);     \
+     }                           \
+ } while (0)
+ #endif
+ static void *do_find_syscall_table(probectl *P, char **method)
+ {
+     char *mod_name, *sec_name, *sym_name;
+     unsigned long mod_start, mod_end;
+     unsigned long sec_start, sec_end;
+     unsigned long sym_start, sym_end;
+     PROBETYPE *B;
+     unsigned long token, L;
+     tryctl *T;
+     void *answer;
+ #ifdef OSI_PROBE_DEBUG
+     void *final_answer = 0;
+ #endif
+     int ret;
+ 
+     *method = "not found";
+ 
+     /* if it's exported, there's nothing to do */
+     check_result(P->weak_answer, "exported");
+ 
+     /* ask the kernel to do the name lookup, if it's willing */
+     if (kallsyms_symbol_to_address) {
+ 	token = 0;
+         sym_start = 0;
+ 	do {
+ 	    ret = kallsyms_symbol_to_address(P->symbol, &token,
+ 					     &mod_name, &mod_start, &mod_end,
+ 					     &sec_name, &sec_start, &sec_end,
+ 					     &sym_name, &sym_start, &sym_end);
+ 	    if (ret && !strcmp(mod_name, "kernel") && sym_start)
+ 		break;
+ 	    sym_start = 0;
+ 	} while (ret);
+         check_result(sym_start, "kallsyms_symbol_to_address");
+     }
+ 
+     /* Maybe a little birdie told us */
+     check_result(P->parm_answer,  "module parameter");
+     check_result(P->given_answer, "compiled-in");
+ 
+     /* OK, so we have to scan. */
+     B = (PROBETYPE *)((P->try_base) & ~(P->try_base_mask));
+     L = P->try_length;
+     /* Now, see if the kernel will tell us something better than the default */
+     if (kallsyms_address_to_symbol) {
+ 	ret = kallsyms_address_to_symbol(P->try_sect_sym,
+ 					 &mod_name, &mod_start, &mod_end,
+ 					 &sec_name, &sec_start, &sec_end,
+ 					 &sym_name, &sym_start, &sym_end);
+ 	if (ret) {
+ 	    B = (PROBETYPE *)sec_start;
+ 	    L = (sec_end - sec_start) / sizeof(unsigned long);
+ 	}
+     }
+ 
+ #ifdef OSI_PROBE_DEBUG
+     if (probe_debug & 0x0007)
+ 	printk("<7>osi_probe: %s                      base=0x%lx, len=0x%lx\n",
+ 	       P->symbol, (unsigned long)B, L);
+     if (probe_debug & 0x0009) {
+ 	printk("<7>osi_probe: %s                      ktxt_lower_bound=0x%lx\n",
+ 	       P->symbol, ktxt_lower_bound);
+ 	printk("<7>osi_probe: %s                      NR_syscalls=%d\n",
+ 	       P->symbol, NR_syscalls);
+     }
+ #endif
+ 
+     for (T = P->trylist; T->name; T++) {
+ 	answer = try(P, T, B, L);
+         check_result(answer, T->name);
+     }
+ 
+     /* XXX more checks here */
+ 
+     answer = try_harder(P, B, L);
+     check_result(answer, "pattern scan");
+ 
+ #ifdef OSI_PROBE_DEBUG
+     return final_answer;
+ #else
+     return 0;
+ #endif
+ }
+ 
+ void *osi_find_syscall_table(int which)
+ {
+     probectl *P;
+     void *answer;
+     char *method;
+ 
+     if (which < 0 || which >= N_PROBE_LIST) {
+ 	printk("error - afs_find_syscall_table called with invalid index!\n");
+ 	return 0;
+     }
+     P = probe_list[which];
+     if (which < 4) {
+ 	P->parm_answer = (void *)sys_call_table_addr[which];
+ #ifdef OSI_PROBE_DEBUG
+ 	P->debug_answer = (void *)probe_debug_addr[which];
+ #endif
+     }
+     answer = do_find_syscall_table(P, &method);
+     if (!answer) {
+ 	printk("Warning: failed to find address of %s\n", P->desc);
+ 	printk("System call hooks will not be installed; proceeding anyway\n");
+ 	return 0;
+     }
+     printk("Found %s at 0x%lx (%s)\n", P->desc, (unsigned long)answer, method);
+     return answer;
+ }
+ 
+ 
+ #ifdef OSI_PROBE_STANDALONE
+ int __init osi_probe_init(void)
+ {
+     int i;
+ 
+     if (!probe_debug_tag) probe_debug_tag = jiffies;
+     printk("*** osi_probe %ld debug = 0x%04x ***\n",
+ 	   probe_debug_tag, probe_debug);
+     for (i = 0; i < N_PROBE_LIST; i++)
+ 	(void)osi_find_syscall_table(i);
+     return 0;
+ }
+ 
+ void osi_probe_exit(void) { }
+ 
+ module_init(osi_probe_init);
+ module_exit(osi_probe_exit);
+ #endif
Index: openafs/src/afs/LINUX/osi_prototypes.h
diff -c openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.3 openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.4
*** openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.3	Fri Dec 17 10:29:30 2004
--- openafs/src/afs/LINUX/osi_prototypes.h	Sun Jan 30 23:25:13 2005
***************
*** 41,46 ****
--- 41,53 ----
  extern void osi_linux_free_inode_pages(void);
  extern void check_bad_parent(struct dentry *dp);
  
+ /* osi_probe.c */
+ extern void *osi_find_syscall_table(int which);
+ 
+ /* osi_syscall.c */
+ extern int osi_syscall_init(void);
+ extern void osi_syscall_clean(void);
+ 
  /* osi_sysctl.c */
  extern int osi_sysctl_init(void);
  extern void osi_sysctl_clean(void);
Index: openafs/src/afs/LINUX/osi_syscall.c
diff -c /dev/null openafs/src/afs/LINUX/osi_syscall.c:1.1.2.1
*** /dev/null	Sun Jan 30 23:45:40 2005
--- openafs/src/afs/LINUX/osi_syscall.c	Sun Jan 30 23:25:13 2005
***************
*** 0 ****
--- 1,382 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ /*
+  * Linux module support routines.
+  *
+  */
+ #include <afsconfig.h>
+ #include "afs/param.h"
+ 
+ RCSID
+     ("$Header: /cvs/openafs/src/afs/LINUX/osi_syscall.c,v 1.1.2.1 2005/01/31 04:25:13 shadow Exp $");
+ 
+ #include <linux/module.h> /* early to avoid printf->printk mapping */
+ #include "afs/sysincludes.h"
+ #include "afsincludes.h"
+ #include "h/unistd.h"		/* For syscall numbers. */
+ #include "h/mm.h"
+ 
+ #ifdef AFS_AMD64_LINUX20_ENV
+ #include "../asm/ia32_unistd.h"
+ #endif
+ 
+ #include <linux/proc_fs.h>
+ #include <linux/slab.h>
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+ #include <linux/init.h>
+ #include <linux/sched.h>
+ #endif
+ 
+ 
+ /* On SPARC64 and S390X, sys_call_table contains 32-bit entries
+  * even though pointers are 64 bit quantities.
+  * XXX unify this with osi_probe.c
+  */
+ #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
+ #define SYSCALLTYPE unsigned int
+ #define POINTER2SYSCALL (unsigned int)(unsigned long)
+ #define SYSCALL2POINTER (void *)(long)
+ #else
+ #define SYSCALLTYPE void *
+ #define POINTER2SYSCALL (void *)
+ #define SYSCALL2POINTER (void *)
+ #endif
+ 
+ #if defined(AFS_S390X_LINUX24_ENV)
+ #define _S(x) ((x)<<1)
+ #elif defined(AFS_IA64_LINUX20_ENV)
+ #define _S(x) ((x)-1024)
+ #else
+ #define _S(x) x
+ #endif
+ 
+ 
+ /***** ALL PLATFORMS *****/
+ extern asmlinkage long
+ afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4);
+ 
+ static SYSCALLTYPE *afs_sys_call_table;
+ static SYSCALLTYPE afs_ni_syscall = 0;
+ 
+ extern long afs_xsetgroups();
+ asmlinkage long (*sys_setgroupsp) (int gidsetsize, gid_t * grouplist);
+ 
+ #ifdef AFS_LINUX24_ENV
+ extern int afs_xsetgroups32();
+ asmlinkage int (*sys_setgroups32p) (int gidsetsize,
+ 				    __kernel_gid32_t * grouplist);
+ #endif
+ 
+ #if !defined(AFS_LINUX24_ENV)
+ asmlinkage int (*sys_settimeofdayp) (struct timeval * tv, struct timezone * tz);
+ #endif
+ 
+ 
+ /***** AMD64 *****/
+ #ifdef AFS_AMD64_LINUX20_ENV
+ static SYSCALLTYPE *afs_ia32_sys_call_table;
+ static SYSCALLTYPE ia32_ni_syscall = 0;
+ 
+ extern int afs32_xsetgroups();
+ asmlinkage long (*sys32_setgroupsp) (int gidsetsize, u16 * grouplist);
+ #ifdef AFS_LINUX24_ENV
+ extern int afs32_xsetgroups32();
+ asmlinkage long (*sys32_setgroups32p) (int gidsetsize, gid_t * grouplist);
+ #endif /* __NR_ia32_setgroups32 */
+ #endif /* AFS_AMD64_LINUX20_ENV */
+ 
+ 
+ /***** PPC64 *****/
+ #ifdef AFS_PPC64_LINUX20_ENV
+ extern SYSCALLTYPE *afs_sys_call_table32;
+ static SYSCALLTYPE afs_ni_syscall32 = 0;
+ 
+ extern int afs32_xsetgroups();
+ asmlinkage long (*sys32_setgroupsp)(int gidsetsize, gid_t *grouplist);
+ #endif /* AFS_AMD64_LINUX20_ENV */
+ 
+ 
+ /***** SPARC64 *****/
+ #ifdef AFS_SPARC64_LINUX20_ENV
+ extern SYSCALLTYPE *afs_sys_call_table32;
+ static SYSCALLTYPE afs_ni_syscall32 = 0;
+ 
+ extern int afs32_xsetgroups();
+ asmlinkage int (*sys32_setgroupsp) (int gidsetsize,
+ 				    __kernel_gid_t32 * grouplist);
+ #ifdef AFS_LINUX24_ENV
+ /* This number is not exported for some bizarre reason. */
+ #define __NR_setgroups32      82
+ extern int afs32_xsetgroups32();
+ asmlinkage int (*sys32_setgroups32p) (int gidsetsize,
+ 				      __kernel_gid_t32 * grouplist);
+ #endif
+ 
+ asmlinkage int
+ afs_syscall32(long syscall, long parm1, long parm2, long parm3, long parm4,
+ 	      long parm5)
+ {
+     __asm__ __volatile__("srl %o4, 0, %o4\n\t" "mov %o7, %i7\n\t"
+ 			 "call afs_syscall\n\t" "srl %o5, 0, %o5\n\t"
+ 			 "ret\n\t" "nop");
+ }
+ #endif /* AFS_SPARC64_LINUX20_ENV */
+ 
+ 
+ /***** IA64 *****/
+ #ifdef AFS_IA64_LINUX20_ENV
+ 
+ asmlinkage long
+ afs_syscall_stub(int r0, int r1, long r2, long r3, long r4, long gp)
+ {
+     __asm__ __volatile__("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" "mov r41 = b0\n\t"	/* save rp */
+ 			 "mov out0 = in0\n\t" "mov out1 = in1\n\t" "mov out2 = in2\n\t" "mov out3 = in3\n\t" "mov out4 = in4\n\t" "mov out5 = gp\n\t"	/* save gp */
+ 			 ";;\n" ".L1:\n\t" "mov r3 = ip\n\t" ";;\n\t" "addl r15=.fptr_afs_syscall-.L1,r3\n\t" ";;\n\t" "ld8 r15=[r15]\n\t" ";;\n\t" "ld8 r16=[r15],8\n\t" ";;\n\t" "ld8 gp=[r15]\n\t" "mov b6=r16\n\t" "br.call.sptk.many b0 = b6\n\t" ";;\n\t" "mov ar.pfs = r42\n\t" "mov b0 = r41\n\t" "mov gp = r48\n\t"	/* restore gp */
+ 			 "br.ret.sptk.many b0\n" ".fptr_afs_syscall:\n\t"
+ 			 "data8 @fptr(afs_syscall)\n\t" ".skip 8");
+ }
+ 
+ asmlinkage long
+ afs_xsetgroups_stub(int r0, int r1, long r2, long r3, long r4, long gp)
+ {
+     __asm__ __volatile__("alloc r42 = ar.pfs, 8, 3, 6, 0\n\t" "mov r41 = b0\n\t"	/* save rp */
+ 			 "mov out0 = in0\n\t" "mov out1 = in1\n\t" "mov out2 = in2\n\t" "mov out3 = in3\n\t" "mov out4 = in4\n\t" "mov out5 = gp\n\t"	/* save gp */
+ 			 ";;\n" ".L2:\n\t" "mov r3 = ip\n\t" ";;\n\t" "addl r15=.fptr_afs_xsetgroups - .L2,r3\n\t" ";;\n\t" "ld8 r15=[r15]\n\t" ";;\n\t" "ld8 r16=[r15],8\n\t" ";;\n\t" "ld8 gp=[r15]\n\t" "mov b6=r16\n\t" "br.call.sptk.many b0 = b6\n\t" ";;\n\t" "mov ar.pfs = r42\n\t" "mov b0 = r41\n\t" "mov gp = r48\n\t"	/* restore gp */
+ 			 "br.ret.sptk.many b0\n" ".fptr_afs_xsetgroups:\n\t"
+ 			 "data8 @fptr(afs_xsetgroups)\n\t" ".skip 8");
+ }
+ 
+ struct fptr {
+     void *ip;
+     unsigned long gp;
+ };
+ 
+ #endif /* AFS_IA64_LINUX20_ENV */
+ 
+ 
+ 
+ /**********************************************************************/
+ /********************* System Call Initialization *********************/
+ /**********************************************************************/
+ 
+ int osi_syscall_init(void)
+ {
+ /***** IA64 *****/
+ #ifdef AFS_IA64_LINUX20_ENV
+     /* This needs to be first because we are declaring variables, and
+      * also because the handling of syscall pointers is bizarre enough
+      * that we want to special-case even the "common" part.
+      */
+     unsigned long kernel_gp = 0;
+     static struct fptr sys_setgroups;
+ 
+     afs_sys_call_table = osi_find_syscall_table(0);
+     if (afs_sys_call_table) {
+ 
+ #if !defined(AFS_LINUX24_ENV)
+ 	/* XXX no sys_settimeofday on IA64? */
+ #endif
+ 
+ 	/* check we aren't already loaded */
+ 	/* XXX this can't be right */
+ 	if (SYSCALL2POINTER afs_sys_call_table[_S(__NR_afs_syscall)]
+ 	    == afs_syscall) {
+ 	    printf("AFS syscall entry point already in use!\n");
+ 	    return -EBUSY;
+ 	}
+ 
+ 	/* setup AFS entry point */
+ 	afs_ni_syscall = afs_sys_call_table[_S(__NR_afs_syscall)];
+ 	afs_sys_call_table[_S(__NR_afs_syscall)] =
+ 		POINTER2SYSCALL((struct fptr *)afs_syscall_stub)->ip;
+ 
+ 	/* setup setgroups */
+ 	sys_setgroupsp = (void *)&sys_setgroups;
+ 
+ 	((struct fptr *)sys_setgroupsp)->ip =
+ 	    SYSCALL2POINTER afs_sys_call_table[_S(__NR_setgroups)];
+ 	((struct fptr *)sys_setgroupsp)->gp = kernel_gp;
+ 
+ 	afs_sys_call_table[__S(_NR_setgroups)] =
+ 	    POINTER2SYSCALL((struct fptr *)afs_xsetgroups_stub)->ip;
+     }
+ 
+     /* XXX no 32-bit syscalls on IA64? */
+ 
+ 
+ /***** COMMON (except IA64) *****/
+ #else /* !AFS_IA64_LINUX20_ENV */
+ 
+     afs_sys_call_table = osi_find_syscall_table(0);
+     if (afs_sys_call_table) {
+ #if !defined(AFS_LINUX24_ENV)
+ 	sys_settimeofdayp =
+ 	    SYSCALL2POINTER afs_sys_call_table[_S(__NR_settimeofday)];
+ #endif /* AFS_LINUX24_ENV */
+ 
+ 	/* check we aren't already loaded */
+ 	if (SYSCALL2POINTER afs_sys_call_table[_S(__NR_afs_syscall)]
+ 	    == afs_syscall) {
+ 	    printf("AFS syscall entry point already in use!\n");
+ 	    return -EBUSY;
+ 	}
+ 
+ 	/* setup AFS entry point */
+ 	afs_ni_syscall = afs_sys_call_table[_S(__NR_afs_syscall)];
+ 	afs_sys_call_table[_S(__NR_afs_syscall)] = POINTER2SYSCALL afs_syscall;
+ 
+ 	/* setup setgroups */
+ 	sys_setgroupsp = SYSCALL2POINTER afs_sys_call_table[_S(__NR_setgroups)];
+ 	afs_sys_call_table[_S(__NR_setgroups)] = POINTER2SYSCALL afs_xsetgroups;
+ 
+ #if defined(__NR_setgroups32)
+ 	/* setup setgroups32 */
+ 	sys_setgroups32p = SYSCALL2POINTER afs_sys_call_table[__NR_setgroups32];
+ 	afs_sys_call_table[__NR_setgroups32] = POINTER2SYSCALL afs_xsetgroups32;
+ #endif
+     }
+ #endif /* !AFS_IA64_LINUX20_ENV */
+ 
+ 
+ /***** AMD64 *****/
+ #ifdef AFS_AMD64_LINUX20_ENV
+     afs_ia32_sys_call_table = osi_find_syscall_table(1);
+     if (afs_ia32_sys_call_table) {
+ 	/* setup AFS entry point for IA32 */
+ 	ia32_ni_syscall = afs_ia32_sys_call_table[__NR_ia32_afs_syscall];
+ 	afs_ia32_sys_call_table[__NR_ia32_afs_syscall] =
+ 	    POINTER2SYSCALL afs_syscall;
+ 
+ 	/* setup setgroups for IA32 */
+ 	sys32_setgroupsp =
+ 	    SYSCALL2POINTER afs_ia32_sys_call_table[__NR_ia32_setgroups];
+ 	afs_ia32_sys_call_table[__NR_ia32_setgroups] =
+ 	    POINTER2SYSCALL afs32_xsetgroups;
+ 
+ #if AFS_LINUX24_ENV
+ 	/* setup setgroups32 for IA32 */
+ 	sys32_setgroups32p =
+ 	    SYSCALL2POINTER afs_ia32_sys_call_table[__NR_ia32_setgroups32];
+ 	afs_ia32_sys_call_table[__NR_ia32_setgroups32] =
+ 	    POINTER2SYSCALL afs32_xsetgroups32;
+ #endif /* __NR_ia32_setgroups32 */
+     }
+ #endif /* AFS_AMD64_LINUX20_ENV */
+ 
+ 
+ /***** PPC64 *****/
+ #ifdef AFS_PPC64_LINUX20_ENV
+     /* XXX no 32-bit syscalls on PPC64? */
+ #endif
+ 
+ 
+ /***** SPARC64 *****/
+ #ifdef AFS_SPARC64_LINUX20_ENV
+     afs_sys_call_table32 = osi_find_syscall_table(1);
+     if (afs_sys_call_table32) {
+ 	/* setup AFS entry point for 32-bit SPARC */
+ 	afs_ni_syscall32 = afs_sys_call_table32[__NR_afs_syscall];
+ 	afs_sys_call_table32[__NR_afs_syscall] = POINTER2SYSCALL afs_syscall32;
+ 
+ 	/* setup setgroups for 32-bit SPARC */
+ 	sys32_setgroupsp = SYSCALL2POINTER afs_sys_call_table32[__NR_setgroups];
+ 	afs_sys_call_table32[__NR_setgroups] = POINTER2SYSCALL afs32_xsetgroups;
+ 
+ #ifdef AFS_LINUX24_ENV
+ 	/* setup setgroups32 for 32-bit SPARC */
+ 	sys32_setgroups32p =
+ 	    SYSCALL2POINTER afs_sys_call_table32[__NR_setgroups32];
+ 	afs_sys_call_table32[__NR_setgroups32] =
+ 	    POINTER2SYSCALL afs32_xsetgroups32;
+ #endif
+     }
+ #endif /* AFS_SPARC64_LINUX20_ENV */
+     return 0;
+ }
+ 
+ 
+ 
+ /**********************************************************************/
+ /************************ System Call Cleanup *************************/
+ /**********************************************************************/
+ 
+ void osi_syscall_clean(void)
+ {
+ /***** COMMON *****/
+     if (afs_sys_call_table) {
+ 	/* put back the AFS entry point */
+ 	afs_sys_call_table[_S(__NR_afs_syscall)] = afs_ni_syscall;
+ 
+ 	/* put back setgroups */
+ #if defined(AFS_IA64_LINUX20_ENV)
+ 	afs_sys_call_table[_S(__NR_setgroups)] =
+ 	    POINTER2SYSCALL((struct fptr *)sys_setgroupsp)->ip;
+ #else /* AFS_IA64_LINUX20_ENV */
+ 	afs_sys_call_table[_S(__NR_setgroups)] =
+ 	    POINTER2SYSCALL sys_setgroupsp;
+ #endif
+ 
+ #if defined(__NR_setgroups32) && !defined(AFS_IA64_LINUX20_ENV)
+ 	/* put back setgroups32 */
+ 	afs_sys_call_table[__NR_setgroups32] = POINTER2SYSCALL sys_setgroups32p;
+ #endif
+     }
+ 
+ 
+ /***** IA64 *****/
+ #ifdef AFS_IA64_LINUX20_ENV
+     /* XXX no 32-bit syscalls on IA64? */
+ #endif
+ 
+ 
+ /***** AMD64 *****/
+ #ifdef AFS_AMD64_LINUX20_ENV
+     if (afs_ia32_sys_call_table) {
+ 	/* put back AFS entry point for IA32 */
+ 	afs_ia32_sys_call_table[__NR_ia32_afs_syscall] =
+ 	    POINTER2SYSCALL ia32_ni_syscall;
+ 
+ 	/* put back setgroups for IA32 */
+ 	afs_ia32_sys_call_table[__NR_ia32_setgroups] =
+ 	    POINTER2SYSCALL sys32_setgroupsp;
+ 
+ #ifdef AFS_LINUX24_ENV
+ 	/* put back setgroups32 for IA32 */
+ 	afs_ia32_sys_call_table[__NR_ia32_setgroups32] =
+ 	    POINTER2SYSCALL sys32_setgroups32p;
+ #endif
+     }
+ #endif
+ 
+ 
+ /***** PPC64 *****/
+ #ifdef AFS_PPC64_LINUX20_ENV
+     /* XXX no 32-bit syscalls on PPC64? */
+ #endif
+ 
+ 
+ /***** SPARC64 *****/
+ #ifdef AFS_SPARC64_LINUX20_ENV
+     if (afs_sys_call_table32) {
+ 	/* put back AFS entry point for 32-bit SPARC */
+ 	afs_sys_call_table32[__NR_afs_syscall] = afs_ni_syscall32;
+ 
+ 	/* put back setgroups for IA32 */
+ 	afs_sys_call_table32[__NR_setgroups] =
+ 	    POINTER2SYSCALL sys32_setgroupsp;
+ 
+ #ifdef AFS_LINUX24_ENV
+ 	/* put back setgroups32 for IA32 */
+ 	afs_sys_call_table32[__NR_setgroups32] =
+ 	    POINTER2SYSCALL sys32_setgroups32p;
+ #endif
+     }
+ #endif
+ }
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.8 openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.11
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.8	Fri Dec 17 09:43:23 2004
--- openafs/src/afs/LINUX/osi_vnodeops.c	Sun Jan 30 23:23:11 2005
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.8 2004/12/17 14:43:23 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.11 2005/01/31 04:23:11 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 518,523 ****
--- 518,526 ----
      if (!code)
  	code = afs_VerifyVCache(vcp, &treq);
  
+     if (!code && (vcp->states & CRO) && 
+ 	(vmap->vm_file->f_flags & (FWRITE | FTRUNC)))
+ 	code = EACCES;
  
      if (code)
  	code = -code;
***************
*** 1047,1053 ****
  #endif
  
  	dp->d_op = &afs_dentry_operations;
- 	dp->d_time = jiffies;
  	d_instantiate(dp, ip);
      }
  
--- 1050,1055 ----
***************
*** 1118,1124 ****
  	    ip->i_op = &afs_symlink_iops;
  #endif
      }
-     dp->d_time = jiffies;
      dp->d_op = &afs_dentry_operations;
      d_add(dp, AFSTOI(vcp));
  
--- 1120,1125 ----
***************
*** 1277,1283 ****
  	tvcp->v.v_fop = &afs_dir_fops;
  #endif
  	dp->d_op = &afs_dentry_operations;
- 	dp->d_time = jiffies;
  	d_instantiate(dp, AFSTOI(tvcp));
      }
  
--- 1278,1283 ----
***************
*** 1331,1338 ****
--- 1331,1340 ----
      cred_t *credp = crref();
      const char *oldname = olddp->d_name.name;
      const char *newname = newdp->d_name.name;
+     struct dentry *rehash = NULL;
  
  #if defined(AFS_LINUX26_ENV)
+     /* Prevent any new references during rename operation. */
      lock_kernel();
  #endif
      /* Remove old and new entries from name hash. New one will change below.
***************
*** 1341,1365 ****
       * cases. Let another lookup put things right, if need be.
       */
  #if defined(AFS_LINUX26_ENV)
!     if (!d_unhashed(olddp))
! 	d_drop(olddp);
!     if (!d_unhashed(newdp))
  	d_drop(newdp);
  #else
!     if (!list_empty(&olddp->d_hash))
! 	d_drop(olddp);
!     if (!list_empty(&newdp->d_hash))
  	d_drop(newdp);
  #endif
      AFS_GLOCK();
      code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), newname, credp);
      AFS_GUNLOCK();
  
!     if (!code) {
! 	/* update time so it doesn't expire immediately */
! 	newdp->d_time = jiffies;
! 	d_move(olddp, newdp);
!     }
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
--- 1343,1370 ----
       * cases. Let another lookup put things right, if need be.
       */
  #if defined(AFS_LINUX26_ENV)
!     if (!d_unhashed(newdp)) {
  	d_drop(newdp);
+ 	rehash = newdp;
+     }
  #else
!     if (!list_empty(&newdp->d_hash)) {
  	d_drop(newdp);
+ 	rehash = newdp;
+     }
+ #endif
+ 
+ #if defined(AFS_LINUX24_ENV)
+     if (atomic_read(&olddp->d_count) > 1)
+ 	shrink_dcache_parent(olddp);
  #endif
+ 
      AFS_GLOCK();
      code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), newname, credp);
      AFS_GUNLOCK();
  
!     if (rehash)
! 	d_rehash(rehash);
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
Index: openafs/src/afs/OBSD/osi_sleep.c
diff -c openafs/src/afs/OBSD/osi_sleep.c:1.7 openafs/src/afs/OBSD/osi_sleep.c:1.7.2.1
*** openafs/src/afs/OBSD/osi_sleep.c:1.7	Tue Jul 15 19:14:25 2003
--- openafs/src/afs/OBSD/osi_sleep.c	Sun Jan 30 23:18:25 2005
***************
*** 1,5 ****
  /*
!  * $Id: osi_sleep.c,v 1.7 2003/07/15 23:14:25 shadow Exp $
   */
  
  /*
--- 1,5 ----
  /*
!  * $Id: osi_sleep.c,v 1.7.2.1 2005/01/31 04:18:25 shadow Exp $
   */
  
  /*
***************
*** 45,51 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/OBSD/osi_sleep.c,v 1.7 2003/07/15 23:14:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afs/afsincludes.h"	/* Afs-based standard headers */
--- 45,51 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/OBSD/osi_sleep.c,v 1.7.2.1 2005/01/31 04:18:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afs/afsincludes.h"	/* Afs-based standard headers */
***************
*** 54,66 ****
  static char waitV;
  
  
- void
- afs_osi_InitWaitHandle(struct afs_osi_WaitHandle *achandle)
- {
-     AFS_STATCNT(osi_InitWaitHandle);
-     achandle->proc = NULL;
- }
- 
  /* cancel osi_Wait */
  void
  afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
--- 54,59 ----
Index: openafs/src/afs/OBSD/osi_vnodeops.c
diff -c openafs/src/afs/OBSD/osi_vnodeops.c:1.18 openafs/src/afs/OBSD/osi_vnodeops.c:1.18.2.1
*** openafs/src/afs/OBSD/osi_vnodeops.c:1.18	Tue Jul 27 10:39:31 2004
--- openafs/src/afs/OBSD/osi_vnodeops.c	Sun Jan 30 23:18:25 2005
***************
*** 3,9 ****
   * Original NetBSD version for Transarc afs by John Kohl <jtk@MIT.EDU>
   * OpenBSD version by Jim Rees <rees@umich.edu>
   *
!  * $Id: osi_vnodeops.c,v 1.18 2004/07/27 14:39:31 rees Exp $
   */
  
  /*
--- 3,9 ----
   * Original NetBSD version for Transarc afs by John Kohl <jtk@MIT.EDU>
   * OpenBSD version by Jim Rees <rees@umich.edu>
   *
!  * $Id: osi_vnodeops.c,v 1.18.2.1 2005/01/31 04:18:25 shadow Exp $
   */
  
  /*
***************
*** 99,105 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/OBSD/osi_vnodeops.c,v 1.18 2004/07/27 14:39:31 rees Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afs/afsincludes.h"	/* Afs-based standard headers */
--- 99,105 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/OBSD/osi_vnodeops.c,v 1.18.2.1 2005/01/31 04:18:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afs/afsincludes.h"	/* Afs-based standard headers */
***************
*** 894,899 ****
--- 894,907 ----
      int haveGlock = ISAFS_GLOCK();
      int haveVlock = CheckLock(&afs_xvcache);
  
+ #if 0
+     printf("reclaim usecount %d\n", vp->v_usecount);
+     /* OK, there are no internal vrefCounts, so there shouldn't
+      * be any more refs here. */
+     vp->v_data = NULL;		/* remove from vnode */
+     avc->v = NULL;		/* also drop the ptr to vnode */
+     return 0;
+ #else
      if (!haveGlock)
  	AFS_GLOCK();
      if (!haveVlock)
***************
*** 909,914 ****
--- 917,923 ----
      if (!haveGlock)
  	AFS_GUNLOCK();
      return code;
+ #endif
  }
  
  int
Index: openafs/src/afs/VNOPS/afs_vnop_attrs.c
diff -c openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.3 openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.4
*** openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.3	Tue Dec  7 01:12:13 2004
--- openafs/src/afs/VNOPS/afs_vnop_attrs.c	Sun Jan 30 23:23:36 2005
***************
*** 24,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.3 2004/12/07 06:12:13 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.4 2005/01/31 04:23:36 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 398,414 ****
  #if	defined(AFS_AIX_ENV)
  /* Boy, was this machine dependent bogosity hard to swallow????.... */
      if (av->va_mode != -1) {
! #else
! #if	defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_MODE) {
! #else
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_MODE) {
  #else
      if (av->va_mode != ((unsigned short)-1)) {
  #endif
- #endif
- #endif
  	mask |= AFS_SETMODE;
  	as->UnixModeBits = av->va_mode & 0xffff;
  	if (avc->states & CForeign) {
--- 398,412 ----
  #if	defined(AFS_AIX_ENV)
  /* Boy, was this machine dependent bogosity hard to swallow????.... */
      if (av->va_mode != -1) {
! #elif	defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_MODE) {
! #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_MODE) {
+ #elif	defined(AFS_XBSD_ENV)
+     if (av->va_mode != (mode_t)VNOVAL) {
  #else
      if (av->va_mode != ((unsigned short)-1)) {
  #endif
  	mask |= AFS_SETMODE;
  	as->UnixModeBits = av->va_mode & 0xffff;
  	if (avc->states & CForeign) {
***************
*** 419,458 ****
      }
  #if defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_GID) {
! #else
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_GID) {
! #else
! #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
  #if	defined(AFS_HPUX102_ENV)
      if (av->va_gid != GID_NO_CHANGE) {
  #else
      if (av->va_gid != ((unsigned short)-1)) {
  #endif
  #else
      if (av->va_gid != -1) {
- #endif
- #endif /* AFS_SUN5_ENV */
  #endif /* AFS_LINUX22_ENV */
  	mask |= AFS_SETGROUP;
  	as->Group = av->va_gid;
      }
  #if defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_UID) {
! #else
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_UID) {
! #else
! #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
  #if	defined(AFS_HPUX102_ENV)
      if (av->va_uid != UID_NO_CHANGE) {
  #else
      if (av->va_uid != ((unsigned short)-1)) {
  #endif
  #else
      if (av->va_uid != -1) {
- #endif
- #endif /* AFS_SUN5_ENV */
  #endif /* AFS_LINUX22_ENV */
  	mask |= AFS_SETOWNER;
  	as->Owner = av->va_uid;
--- 417,452 ----
      }
  #if defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_GID) {
! #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_GID) {
! #elif (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
  #if	defined(AFS_HPUX102_ENV)
      if (av->va_gid != GID_NO_CHANGE) {
  #else
      if (av->va_gid != ((unsigned short)-1)) {
  #endif
+ #elif	defined(AFS_XBSD_ENV)
+     if (av->va_gid != (gid_t)VNOVAL) {
  #else
      if (av->va_gid != -1) {
  #endif /* AFS_LINUX22_ENV */
  	mask |= AFS_SETGROUP;
  	as->Group = av->va_gid;
      }
  #if defined(AFS_LINUX22_ENV)
      if (av->va_mask & ATTR_UID) {
! #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_UID) {
! #elif (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
  #if	defined(AFS_HPUX102_ENV)
      if (av->va_uid != UID_NO_CHANGE) {
+ #elif	defined(AFS_XBSD_ENV)
+     if (av->va_uid != (uid_t)VNOVAL) {
  #else
      if (av->va_uid != ((unsigned short)-1)) {
  #endif
  #else
      if (av->va_uid != -1) {
  #endif /* AFS_LINUX22_ENV */
  	mask |= AFS_SETOWNER;
  	as->Owner = av->va_uid;
***************
*** 544,564 ****
       */
  #if	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
! #else
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
! #else
! #ifdef	AFS_OSF_ENV
      if (attrs->va_size != VNOVAL) {
! #else
! #ifdef	AFS_AIX41_ENV
      if (attrs->va_size != -1) {
  #else
      if (attrs->va_size != ~0) {
  #endif
- #endif
- #endif
- #endif
  	if (!afs_AccessOK(avc, PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS)) {
  	    code = EACCES;
  	    goto done;
--- 538,552 ----
       */
  #if	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
! #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
! #elif	defined(AFS_OSF_ENV) || defined(AFS_XBSD_ENV)
      if (attrs->va_size != VNOVAL) {
! #elif	defined(AFS_AIX41_ENV)
      if (attrs->va_size != -1) {
  #else
      if (attrs->va_size != ~0) {
  #endif
  	if (!afs_AccessOK(avc, PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS)) {
  	    code = EACCES;
  	    goto done;
***************
*** 582,598 ****
  #endif
  #if	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
! #else
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
! #else
! #if	defined(AFS_OSF_ENV)
      if (attrs->va_size != VNOVAL) {
! #else /* AFS_OSF_ENV */
      if (attrs->va_size != -1) {
  #endif
- #endif
- #endif
  	afs_size_t tsize = attrs->va_size;
  	ObtainWriteLock(&avc->lock, 128);
  	avc->states |= CDirty;
--- 570,582 ----
  #endif
  #if	defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & ATTR_SIZE) {
! #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (attrs->va_mask & AT_SIZE) {
! #elif	defined(AFS_OSF_ENV) || defined(AFS_XBSD_ENV)
      if (attrs->va_size != VNOVAL) {
! #else
      if (attrs->va_size != -1) {
  #endif
  	afs_size_t tsize = attrs->va_size;
  	ObtainWriteLock(&avc->lock, 128);
  	avc->states |= CDirty;
Index: openafs/src/afs/VNOPS/afs_vnop_create.c
diff -c openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.3 openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.4
*** openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.3	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_create.c	Sun Jan 30 22:49:15 2005
***************
*** 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 */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.4 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 30,39 ****
   * I think we can get away without it, but I'm not sure.  Note that
   * afs_setattr is called in here for truncation.
   */
- #ifdef	AFS_OSF_ENV
- int
- afs_create(struct nameidata *ndp, struct vattr *attrs)
- #else /* AFS_OSF_ENV */
  #ifdef AFS_SGI64_ENV
  int
  afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, int flags,
--- 30,35 ----
***************
*** 44,60 ****
  	   enum vcexcl aexcl, int amode, struct vcache **avcp,
  	   struct AFS_UCRED *acred)
  #endif				/* AFS_SGI64_ENV */
- #endif				/* AFS_OSF_ENV */
  {
- #ifdef AFS_OSF_ENV
-     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
-     char *aname = ndp->ni_dent.d_name;
-     enum vcexcl aexcl = NONEXCL;	/* XXX - create called properly */
-     int amode = 0;		/* XXX - checked in higher level */
-     struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
-     struct ucred *acred = ndp->ni_cred;
- #endif
- 
      afs_int32 origCBs, origZaps, finalZaps;
      struct vrequest treq;
      register afs_int32 code;
--- 40,46 ----
***************
*** 311,353 ****
  	     (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE,
  	      SHARED_LOCK, NULL));
  
! #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV)
!     if (code == EEXIST && aexcl == NONEXCL) {
! 	/* This lookup was handled in the common vn_open code in the
! 	 * vnode layer */
! 	if (tdc) {
! 	    ReleaseSharedLock(&tdc->lock);
! 	    afs_PutDCache(tdc);
! 	}
! 	ReleaseWriteLock(&adp->lock);
! 	goto done;
!     }
! #else /* AFS_OSF_ENV */
  #ifdef AFS_SGI64_ENV
!     if (code == EEXIST && !(flags & VEXCL)) {
  #else /* AFS_SGI64_ENV */
!     if (code == EEXIST && aexcl == NONEXCL) {
! #endif /* AFS_SGI64_ENV */
  	/* if we get an EEXIST in nonexcl mode, just do a lookup */
  	if (tdc) {
  	    ReleaseSharedLock(&tdc->lock);
  	    afs_PutDCache(tdc);
  	}
  	ReleaseWriteLock(&adp->lock);
  #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  #if defined(AFS_SGI64_ENV)
! 	code =
! 	    afs_lookup(VNODE_TO_FIRST_BHV((vnode_t *) adp), aname, avcp, NULL,
! 		       0, NULL, acred);
  #else
  	code = afs_lookup(adp, aname, avcp, NULL, 0, NULL, acred);
  #endif /* AFS_SGI64_ENV */
  #else /* SUN5 || SGI */
  	code = afs_lookup(adp, aname, avcp, acred);
  #endif /* SUN5 || SGI */
  	goto done;
      }
- #endif /* AFS_OSF_ENV */
      if (code) {
  	if (code < 0) {
  	    ObtainWriteLock(&afs_xcbhash, 488);
--- 297,329 ----
  	     (tc, code, &adp->fid, &treq, AFS_STATS_FS_RPCIDX_CREATEFILE,
  	      SHARED_LOCK, NULL));
  
!     if (code == EEXIST &&
  #ifdef AFS_SGI64_ENV
!     !(flags & VEXCL)
  #else /* AFS_SGI64_ENV */
!     aexcl == NONEXCL
! #endif
!     ) {
  	/* if we get an EEXIST in nonexcl mode, just do a lookup */
  	if (tdc) {
  	    ReleaseSharedLock(&tdc->lock);
  	    afs_PutDCache(tdc);
  	}
  	ReleaseWriteLock(&adp->lock);
+ #if !(defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV))
  #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  #if defined(AFS_SGI64_ENV)
! 	code = afs_lookup(VNODE_TO_FIRST_BHV((vnode_t *) adp), aname, avcp, 
! 			  NULL, 0, NULL, acred);
  #else
  	code = afs_lookup(adp, aname, avcp, NULL, 0, NULL, acred);
  #endif /* AFS_SGI64_ENV */
  #else /* SUN5 || SGI */
  	code = afs_lookup(adp, aname, avcp, acred);
  #endif /* SUN5 || SGI */
+ #endif /* !(AFS_OSF_ENV || AFS_DARWIN_ENV) */
  	goto done;
      }
      if (code) {
  	if (code < 0) {
  	    ObtainWriteLock(&afs_xcbhash, 488);
***************
*** 475,484 ****
      code = afs_CheckCode(code, &treq, 20);
  
    done2:
- #ifdef	AFS_OSF_ENV
-     afs_PutVCache(adp);
- #endif /* AFS_OSF_ENV */
- 
      return code;
  }
  
--- 451,456 ----
Index: openafs/src/afs/VNOPS/afs_vnop_dirops.c
diff -c openafs/src/afs/VNOPS/afs_vnop_dirops.c:1.14.2.3 openafs/src/afs/VNOPS/afs_vnop_dirops.c:1.14.2.4
*** openafs/src/afs/VNOPS/afs_vnop_dirops.c:1.14.2.3	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_dirops.c	Sun Jan 30 22:49:15 2005
***************
*** 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 */
--- 21,27 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_dirops.c,v 1.14.2.4 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 36,59 ****
  /* don't set CDirty in here because RPC is called synchronously */
  
  int
! #ifdef	AFS_OSF_ENV
! afs_mkdir(ndp, attrs)
!      struct nameidata *ndp;
!      struct vattr *attrs;
  {
-     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
-     char *aname = ndp->ni_dent.d_name;
-     register struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
-     struct ucred *acred = ndp->ni_cred;
- #else /* AFS_OSF_ENV */
- afs_mkdir(OSI_VC_ARG(adp), aname, attrs, avcp, acred)
-      OSI_VC_DECL(adp);
-      register struct vcache **avcp;
-      char *aname;
-      struct vattr *attrs;
-      struct AFS_UCRED *acred;
- {
- #endif
      struct vrequest treq;
      register afs_int32 code;
      register struct conn *tc;
--- 36,44 ----
  /* don't set CDirty in here because RPC is called synchronously */
  
  int
! afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs, 
!      register struct vcache **avcp, struct AFS_UCRED *acred)
  {
      struct vrequest treq;
      register afs_int32 code;
      register struct conn *tc;
***************
*** 172,205 ****
      afs_PutFakeStat(&fakestate);
      code = afs_CheckCode(code, &treq, 26);
    done2:
- #ifdef	AFS_OSF_ENV
-     AFS_RELE(ndp->ni_dvp);
- #endif /* AFS_OSF_ENV */
      return code;
  }
  
  
  int
- #ifdef	AFS_OSF_ENV
- afs_rmdir(ndp)
-      struct nameidata *ndp;
- {
-     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
-     char *aname = ndp->ni_dent.d_name;
-     struct ucred *acred = ndp->ni_cred;
- #else /* AFS_OSF_ENV */
  /* don't set CDirty in here because RPC is called synchronously */
  #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
! afs_rmdir(OSI_VC_ARG(adp), aname, cdirp, acred)
!      struct vnode *cdirp;
  #else
! afs_rmdir(adp, aname, acred)
  #endif
-      OSI_VC_DECL(adp);
-      char *aname;
-      struct AFS_UCRED *acred;
  {
- #endif
      struct vrequest treq;
      register struct dcache *tdc;
      register struct vcache *tvc = NULL;
--- 157,175 ----
      afs_PutFakeStat(&fakestate);
      code = afs_CheckCode(code, &treq, 26);
    done2:
      return code;
  }
  
  
  int
  /* don't set CDirty in here because RPC is called synchronously */
  #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
! afs_rmdir(OSI_VC_DECL(adp), char *aname, struct vnode *cdirp, 
! 	  struct AFS_UCRED *acred)
  #else
! afs_rmdir(OSI_VC_DECL(adp), char *aname, struct AFS_UCRED *acred)
  #endif
  {
      struct vrequest treq;
      register struct dcache *tdc;
      register struct vcache *tvc = NULL;
***************
*** 336,344 ****
      afs_PutFakeStat(&fakestate);
      code = afs_CheckCode(code, &treq, 27);
    done2:
- #ifdef	AFS_OSF_ENV
-     afs_PutVCache(adp);
-     afs_PutVCache(ndp->ni_vp);
- #endif /* AFS_OSF_ENV */
      return code;
  }
--- 306,310 ----
Index: openafs/src/afs/VNOPS/afs_vnop_fid.c
diff -c openafs/src/afs/VNOPS/afs_vnop_fid.c:1.11.2.1 openafs/src/afs/VNOPS/afs_vnop_fid.c:1.11.2.2
*** openafs/src/afs/VNOPS/afs_vnop_fid.c:1.11.2.1	Wed Aug 25 03:09:35 2004
--- openafs/src/afs/VNOPS/afs_vnop_fid.c	Sun Jan 30 22:49:15 2005
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_fid.c,v 1.11.2.1 2004/08/25 07:09:35 shadow Exp $");
  
  #if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_OBSD_ENV)
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_fid.c,v 1.11.2.2 2005/01/31 03:49:15 shadow Exp $");
  
  #if !defined(AFS_DUX40_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_OBSD_ENV)
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 67,86 ****
  
  extern int afs_NFSRootOnly;	/* 1 => only allow NFS mounts of /afs. */
  
- int
  #if !defined(AFS_DEC_ENV) && !defined(AFS_ATHENA_ENV)
  #ifdef AFS_AIX41_ENV
! afs_fid(OSI_VC_ARG(avc), fidpp, credp)
!      struct ucred *credp;
  #else
! afs_fid(OSI_VC_ARG(avc), fidpp)
  #endif				/* AFS_AIX41_ENV */
-      OSI_VC_DECL(avc);
- #if	defined(AFS_AIX_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV)
-      struct fid *fidpp;
- #else
-      struct fid **fidpp;
- #endif
  {
      struct SmallFid Sfid;
      long addr[2];
--- 67,81 ----
  
  extern int afs_NFSRootOnly;	/* 1 => only allow NFS mounts of /afs. */
  
  #if !defined(AFS_DEC_ENV) && !defined(AFS_ATHENA_ENV)
+ int
  #ifdef AFS_AIX41_ENV
! afs_fid(OSI_VC_DECL(avc), struct fid *fidpp, struct ucred *credp)
! #elif defined(AFS_OSF_ENV) || defined(AFS_SUN54_ENV)
! afs_fid(OSI_VC_DECL(avc), struct fid *fidpp)
  #else
! afs_fid(OSI_VC_DECL(avc), struct fid **fidpp)
  #endif				/* AFS_AIX41_ENV */
  {
      struct SmallFid Sfid;
      long addr[2];
Index: openafs/src/afs/VNOPS/afs_vnop_link.c
diff -c openafs/src/afs/VNOPS/afs_vnop_link.c:1.15.2.3 openafs/src/afs/VNOPS/afs_vnop_link.c:1.15.2.4
*** openafs/src/afs/VNOPS/afs_vnop_link.c:1.15.2.3	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_link.c	Sun Jan 30 22:49:15 2005
***************
*** 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 */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_link.c,v 1.15.2.4 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 32,46 ****
   * RPC is called synchronously. */
  
  int
- #ifdef	AFS_OSF_ENV
- afs_link(avc, ndp)
-      struct vcache *avc;
-      struct nameidata *ndp;
- {
-     struct vcache *adp = VTOAFS(ndp->ni_dvp);
-     char *aname = ndp->ni_dent.d_name;
-     struct ucred *acred = ndp->ni_cred;
- #else /* AFS_OSF_ENV */
  #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
  afs_link(OSI_VC_ARG(adp), avc, aname, acred)
  #else
--- 32,37 ----
***************
*** 51,57 ****
       char *aname;
       struct AFS_UCRED *acred;
  {
- #endif
      struct vrequest treq;
      register struct dcache *tdc;
      register afs_int32 code;
--- 42,47 ----
***************
*** 170,177 ****
      afs_PutFakeStat(&vfakestate);
      afs_PutFakeStat(&dfakestate);
    done2:
- #ifdef	AFS_OSF_ENV
-     afs_PutVCache(adp);
- #endif /* AFS_OSF_ENV */
      return code;
  }
--- 160,164 ----
Index: openafs/src/afs/VNOPS/afs_vnop_lookup.c
diff -c openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.5 openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.6
*** openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.5	Tue Dec  7 01:12:13 2004
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	Sun Jan 30 22:49:15 2005
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.5 2004/12/07 06:12:13 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.6 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 1077,1112 ****
  static int AFSDOBULK = 1;
  
  int
! #ifdef	AFS_OSF_ENV
! afs_lookup(adp, ndp)
!      struct vcache *adp;
!      struct nameidata *ndp;
! {
!     char aname[MAXNAMLEN + 1];	/* XXX */
!     struct vcache **avcp = (struct vcache **)&(ndp->ni_vp);
!     struct ucred *acred = ndp->ni_cred;
!     int wantparent = ndp->ni_nameiop & WANTPARENT;
!     int opflag = ndp->ni_nameiop & OPFLAG;
! #else				/* AFS_OSF_ENV */
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
! afs_lookup(OSI_VC_ARG(adp), aname, avcp, pnp, flags, rdir, acred)
!      struct pathname *pnp;
!      int flags;
!      struct vnode *rdir;
! #else
! #if defined(UKERNEL)
! afs_lookup(adp, aname, avcp, acred, flags)
!      int flags;
  #else
! afs_lookup(adp, aname, avcp, acred)
! #endif				/* UKERNEL */
! #endif				/* SUN5 || SGI */
!      OSI_VC_DECL(adp);
!      struct vcache **avcp;
!      char *aname;
!      struct AFS_UCRED *acred;
! {
  #endif
      struct vrequest treq;
      char *tname = NULL;
      register struct vcache *tvc = 0;
--- 1077,1092 ----
  static int AFSDOBULK = 1;
  
  int
! #ifdef AFS_OSF_ENV
! afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, struct AFS_UCRED *acred, int opflag, int wantparent)
! #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
! afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, struct pathname *pnp, int flags, struct vnode *rdir, struct AFS_UCRED *acred)
! #elif defined(UKERNEL)
! afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, struct AFS_UCRED *acred, int flags)
  #else
! afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, struct AFS_UCRED *acred)
  #endif
+ {
      struct vrequest treq;
      char *tname = NULL;
      register struct vcache *tvc = 0;
***************
*** 1131,1138 ****
  
  #ifdef	AFS_OSF_ENV
      ndp->ni_dvp = AFSTOV(adp);
-     memcpy(aname, ndp->ni_ptr, ndp->ni_namelen);
-     aname[ndp->ni_namelen] = '\0';
  #endif /* AFS_OSF_ENV */
  
  #if defined(AFS_DARWIN_ENV)
--- 1111,1116 ----
Index: openafs/src/afs/VNOPS/afs_vnop_remove.c
diff -c openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.5 openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.6
*** openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.5	Mon Dec 13 14:35:05 2004
--- openafs/src/afs/VNOPS/afs_vnop_remove.c	Sun Jan 30 22:49:15 2005
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.5 2004/12/13 19:35:05 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 21,27 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.6 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 217,236 ****
  /* Note that we don't set CDirty here, this is OK because the unlink
   * RPC is called synchronously */
  int
- #ifdef	AFS_OSF_ENV
- afs_remove(ndp)
-      struct nameidata *ndp;
- {
-     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
-     char *aname = ndp->ni_dent.d_name;
-     struct ucred *acred = ndp->ni_cred;
- #else				/* AFS_OSF_ENV */
  afs_remove(OSI_VC_ARG(adp), aname, acred)
       OSI_VC_DECL(adp);
       char *aname;
       struct AFS_UCRED *acred;
  {
- #endif
      struct vrequest treq;
      register struct dcache *tdc;
      struct VenusFid unlinkFid;
--- 217,227 ----
***************
*** 250,256 ****
  
      if ((code = afs_InitReq(&treq, acred))) {
  #ifdef  AFS_OSF_ENV
- 	afs_PutVCache(adp);
  	afs_PutVCache(tvc);
  #endif
  	return code;
--- 241,246 ----
***************
*** 261,267 ****
      if (code) {
  	afs_PutFakeStat(&fakestate);
  #ifdef  AFS_OSF_ENV
- 	afs_PutVCache(adp);
  	afs_PutVCache(tvc);
  #endif
  	return code;
--- 251,256 ----
***************
*** 272,297 ****
  	code = afs_DynrootVOPRemove(adp, acred, aname);
  	afs_PutFakeStat(&fakestate);
  #ifdef  AFS_OSF_ENV
- 	afs_PutVCache(adp);
  	afs_PutVCache(tvc);
  #endif
  	return code;
      }
- #if 0
-     if (adp->mvstat == 2) {
- 	afs_PutFakeStat(&fakestate);
- #ifdef  AFS_OSF_ENV
- 	afs_PutVCache(adp);
- 	afs_PutVCache(tvc);
- #endif
- 	return EISDIR;
-     }
- #endif
  
      if (strlen(aname) > AFSNAMEMAX) {
  	afs_PutFakeStat(&fakestate);
  #ifdef  AFS_OSF_ENV
- 	afs_PutVCache(adp);
  	afs_PutVCache(tvc);
  #endif
  	return ENAMETOOLONG;
--- 261,274 ----
***************
*** 301,307 ****
  #ifdef	AFS_OSF_ENV
      tvc = VTOAFS(ndp->ni_vp);	/* should never be null */
      if (code) {
- 	afs_PutVCache(adp);
  	afs_PutVCache(tvc);
  	afs_PutFakeStat(&fakestate);
  	return afs_CheckCode(code, &treq, 22);
--- 278,283 ----
***************
*** 320,326 ****
        */
      if (adp->states & CRO) {
  #ifdef  AFS_OSF_ENV
- 	afs_PutVCache(adp);
  	afs_PutVCache(tvc);
  #endif
  	code = EROFS;
--- 296,301 ----
***************
*** 434,442 ****
      } else {
  	code = afsremove(adp, tdc, tvc, aname, acred, &treq);
      }
- #ifdef	AFS_OSF_ENV
-     afs_PutVCache(adp);
- #endif /* AFS_OSF_ENV */
      afs_PutFakeStat(&fakestate);
      return code;
  }
--- 409,414 ----
Index: openafs/src/afs/VNOPS/afs_vnop_rename.c
diff -c openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.3 openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.4
*** openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.3	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_rename.c	Sun Jan 30 22:49:15 2005
***************
*** 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 */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_rename.c,v 1.16.2.4 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 359,386 ****
  }
  
  int
- #ifdef	AFS_OSF_ENV
- afs_rename(fndp, tndp)
-      struct nameidata *fndp, *tndp;
- {
-     struct vcache *aodp = VTOAFS(fndp->ni_dvp);
-     char *aname1 = fndp->ni_dent.d_name;
-     struct vcache *andp = VTOAFS(tndp->ni_dvp);
-     char *aname2 = tndp->ni_dent.d_name;
-     struct ucred *acred = tndp->ni_cred;
- #else /* AFS_OSF_ENV */
  #if defined(AFS_SGI_ENV)
! afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, npnp, acred)
!     struct pathname *npnp;
  #else
! afs_rename(OSI_VC_ARG(aodp), aname1, andp, aname2, acred)
  #endif
-      OSI_VC_DECL(aodp);
-      struct vcache *andp;
-      char *aname1, *aname2;
-      struct AFS_UCRED *acred;
  {
- #endif
      register afs_int32 code;
      struct afs_fakestat_state ofakestate;
      struct afs_fakestat_state nfakestate;
--- 359,370 ----
  }
  
  int
  #if defined(AFS_SGI_ENV)
! afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, achar *name2, struct pathname *npnp, struct AFS_UCRED *acred)
  #else
! afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, char *aname2, struct AFS_UCRED *acred)
  #endif
  {
      register afs_int32 code;
      struct afs_fakestat_state ofakestate;
      struct afs_fakestat_state nfakestate;
***************
*** 402,415 ****
    done:
      afs_PutFakeStat(&ofakestate);
      afs_PutFakeStat(&nfakestate);
- #ifdef	AFS_OSF_ENV
-     AFS_RELE(tndp->ni_dvp);
-     if (tndp->ni_vp != NULL) {
- 	AFS_RELE(tndp->ni_vp);
-     }
-     AFS_RELE(fndp->ni_dvp);
-     AFS_RELE(fndp->ni_vp);
- #endif /* AFS_OSF_ENV */
      code = afs_CheckCode(code, &treq, 25);
      return code;
  }
--- 386,391 ----
Index: openafs/src/afs/VNOPS/afs_vnop_symlink.c
diff -c openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.3 openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.4
*** openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.3	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_symlink.c	Sun Jan 30 22:49:15 2005
***************
*** 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 */
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.4 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 42,57 ****
  
  /* don't set CDirty in here because RPC is called synchronously */
  int afs_symlink
- #ifdef	AFS_OSF_ENV
-   (ndp, attrs, atargetName)
-      struct nameidata *ndp;
-      struct vattr *attrs;
-      register char *atargetName;
- {
-     register struct vcache *adp = VTOAFS(ndp->ni_dvp);
-     char *aname = ndp->ni_dent.d_name;
-     struct ucred *acred = ndp->ni_cred;
- #else				/* AFS_OSF_ENV */
    (OSI_VC_ARG(adp), aname, attrs, atargetName, acred)
       OSI_VC_DECL(adp);
       char *atargetName;
--- 42,47 ----
***************
*** 59,65 ****
       struct vattr *attrs;
       struct AFS_UCRED *acred;
  {
- #endif
      afs_uint32 now = 0;
      struct vrequest treq;
      afs_int32 code;
--- 49,54 ----
***************
*** 236,244 ****
  	afs_PutVolume(volp, READ_LOCK);
      code = afs_CheckCode(code, &treq, 31);
    done2:
- #ifdef  AFS_OSF_ENV
-     AFS_RELE(ndp->ni_dvp);
- #endif /* AFS_OSF_ENV */
      return code;
  }
  
--- 225,230 ----
Index: openafs/src/afs/VNOPS/afs_vnop_write.c
diff -c openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.2 openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.3
*** openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.2	Tue Dec  7 01:12:14 2004
--- openafs/src/afs/VNOPS/afs_vnop_write.c	Sun Jan 30 22:49:15 2005
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v 1.36.2.2 2004/12/07 06:12:14 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_write.c,v 1.36.2.3 2005/01/31 03:49:15 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 714,722 ****
      return code;
  }
  
! 
! 
! #if !defined (AFS_AIX_ENV) && !defined (AFS_HPUX_ENV) && !defined (AFS_SUN5_ENV) && !defined(AFS_SGI_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
  #ifdef AFS_DUX50_ENV
  #define vno_close(X) vn_close((X), 0, NOCRED)
  #elif defined(AFS_DUX40_ENV)
--- 714,720 ----
      return code;
  }
  
! #ifdef AFS_OSF_ENV
  #ifdef AFS_DUX50_ENV
  #define vno_close(X) vn_close((X), 0, NOCRED)
  #elif defined(AFS_DUX40_ENV)
***************
*** 770,781 ****
  	    afd->f_flag &= ~(FSHLOCK | FEXLOCK);
  	    code = vno_close(afd);
  	    if (flags)
- #if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV) || defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)
  		HandleFlock(tvc, LOCK_UN, &treq, u.u_procp->p_pid,
  			    1 /*onlymine */ );
- #else
- 		HandleFlock(tvc, LOCK_UN, &treq, 0, 1 /*onlymine */ );
- #endif
  #ifdef	AFS_DEC_ENV
  	    grele((struct gnode *)tvc);
  #else
--- 768,775 ----
***************
*** 993,1019 ****
  
  int
  #ifdef	AFS_OSF_ENV
! afs_fsync(avc, fflags, acred, waitfor)
!      int fflags;
!      int waitfor;
  #else				/* AFS_OSF_ENV */
  #if defined(AFS_SGI_ENV) || defined(AFS_SUN53_ENV)
! afs_fsync(OSI_VC_ARG(avc), flag, acred
  #ifdef AFS_SGI65_ENV
! 	  , start, stop
! #endif
      )
! #else
! afs_fsync(avc, acred)
! #endif
! #endif
! OSI_VC_DECL(avc);
!      struct AFS_UCRED *acred;
! #if defined(AFS_SGI_ENV) || defined(AFS_SUN53_ENV)
!      int flag;
! #ifdef AFS_SGI65_ENV
!      off_t start, stop;
! #endif
  #endif
  {
      register afs_int32 code;
--- 987,1003 ----
  
  int
  #ifdef	AFS_OSF_ENV
! afs_fsync(OSI_VC_DECL(avc), int fflags, struct AFS_UCRED *acred, int waitfor)
  #else				/* AFS_OSF_ENV */
  #if defined(AFS_SGI_ENV) || defined(AFS_SUN53_ENV)
! afs_fsync(OSI_VC_DECL(avc), int flag, struct AFS_UCRED *acred
  #ifdef AFS_SGI65_ENV
! 	  , off_t start, off_t stop
! #endif /* AFS_SGI65_ENV */
      )
! #else /* !OSF && !SUN53 && !SGI */
! afs_fsync(OSI_VC_DECL(avc), struct AFS_UCRED *acred)
! #endif 
  #endif
  {
      register afs_int32 code;
Index: openafs/src/afsd/Makefile.in
diff -c openafs/src/afsd/Makefile.in:1.16 openafs/src/afsd/Makefile.in:1.16.2.1
*** openafs/src/afsd/Makefile.in:1.16	Fri Oct 24 02:26:05 2003
--- openafs/src/afsd/Makefile.in	Sun Jan 30 23:13:57 2005
***************
*** 72,78 ****
  			${INSTALL} -f ${srcdir}/afs.rc.solaris.2.7 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
  		sun*_58 ) \
  			${INSTALL} -f ${srcdir}/afs.rc.solaris.2.8 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
! 		sun*_59 ) \
  			${INSTALL} -f ${srcdir}/afs.rc.solaris.2.9 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
                  sun4x_5? ) \
                          ${INSTALL} -f ${srcdir}/afs.rc.solaris.2_5 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
--- 72,78 ----
  			${INSTALL} -f ${srcdir}/afs.rc.solaris.2.7 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
  		sun*_58 ) \
  			${INSTALL} -f ${srcdir}/afs.rc.solaris.2.8 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
! 		sun*_59 | sun*_510 ) \
  			${INSTALL} -f ${srcdir}/afs.rc.solaris.2.9 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
                  sun4x_5? ) \
                          ${INSTALL} -f ${srcdir}/afs.rc.solaris.2_5 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
Index: openafs/src/afsd/afsd.c
diff -c openafs/src/afsd/afsd.c:1.43.2.1 openafs/src/afsd/afsd.c:1.43.2.2
*** openafs/src/afsd/afsd.c:1.43.2.1	Tue Dec  7 13:25:08 2004
--- openafs/src/afsd/afsd.c	Sun Jan 30 23:09:51 2005
***************
*** 56,62 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.1 2004/12/07 18:25:08 shadow Exp $");
  
  #define VFS 1
  
--- 56,62 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.2 2005/01/31 04:09:51 shadow Exp $");
  
  #define VFS 1
  
***************
*** 1932,1938 ****
      if (afsd_debug)
  	printf("%s: Calling AFSOP_VOLUMEINFO: volume info file is '%s'\n", rn,
  	       fullpn_VolInfoFile);
!     call_syscall(AFSOP_VOLUMEINFO, fullpn_VolInfoFile);
  
      /*
       * Pass the kernel the name of the afs logging file holding the volume
--- 1932,1940 ----
      if (afsd_debug)
  	printf("%s: Calling AFSOP_VOLUMEINFO: volume info file is '%s'\n", rn,
  	       fullpn_VolInfoFile);
!     /* once again, meaningless for a memory-based cache. */
!     if (!(cacheFlags & AFSCALL_INIT_MEMCACHE)) 
! 	call_syscall(AFSOP_VOLUMEINFO, fullpn_VolInfoFile);
  
      /*
       * Pass the kernel the name of the afs logging file holding the volume
Index: openafs/src/cf/linux-test3.m4
diff -c openafs/src/cf/linux-test3.m4:1.8.2.4 openafs/src/cf/linux-test3.m4:1.8.2.5
*** openafs/src/cf/linux-test3.m4:1.8.2.4	Mon Dec 13 14:35:34 2004
--- openafs/src/cf/linux-test3.m4	Sun Jan 30 23:12:51 2005
***************
*** 116,122 ****
  AC_DEFUN([LINUX_KERNEL_PAGE_FOLLOW_LINK],[
  AC_MSG_CHECKING(for page_follow_link_light vs page_follow_link)
  save_CPPFLAGS="$CPPFLAGS"
! CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $CPPFLAGS"
  AC_CACHE_VAL(ac_cv_linux_kernel_page_follow_link,
  [
  AC_TRY_COMPILE(
--- 116,122 ----
  AC_DEFUN([LINUX_KERNEL_PAGE_FOLLOW_LINK],[
  AC_MSG_CHECKING(for page_follow_link_light vs page_follow_link)
  save_CPPFLAGS="$CPPFLAGS"
! CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -Werror-implicit-function-declaration -D__KERNEL__ $CPPFLAGS"
  AC_CACHE_VAL(ac_cv_linux_kernel_page_follow_link,
  [
  AC_TRY_COMPILE(
***************
*** 126,130 ****
    ],
    ac_cv_linux_kernel_page_follow_link=yes,
    ac_cv_linux_kernel_page_follow_link=no)])
! AC_MSG_RESULT($ac_cv_linux_kernel_page_follow_page)
  CPPFLAGS="$save_CPPFLAGS"])
--- 126,130 ----
    ],
    ac_cv_linux_kernel_page_follow_link=yes,
    ac_cv_linux_kernel_page_follow_link=no)])
! AC_MSG_RESULT($ac_cv_linux_kernel_page_follow_link)
  CPPFLAGS="$save_CPPFLAGS"])
Index: openafs/src/cf/linux-test4.m4
diff -c openafs/src/cf/linux-test4.m4:1.20 openafs/src/cf/linux-test4.m4:1.20.2.3
*** openafs/src/cf/linux-test4.m4:1.20	Mon Jun 21 17:54:20 2004
--- openafs/src/cf/linux-test4.m4	Sun Jan 30 23:25:33 2005
***************
*** 188,210 ****
  CPPFLAGS="$save_CPPFLAGS"])
  
  
- AC_DEFUN([LINUX_EXPORTS_TASKLIST_LOCK], [
- AC_MSG_CHECKING(for exported tasklist_lock)
- save_CPPFLAGS="$CPPFLAGS"
- CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -I${LINUX_KERNEL_PATH}/include/asm/mach-${SUBARCH} -D__KERNEL__ $CPPFLAGS"
- AC_CACHE_VAL(ac_cv_linux_exports_tasklist_lock,
- [
- AC_TRY_COMPILE(
- [#include <linux/modversions.h>],
- [#ifndef __ver_tasklist_lock
- #error tasklist_lock not exported
- #endif],
- ac_cv_linux_exports_tasklist_lock=yes,
- ac_cv_linux_exports_tasklist_lock=no)])
- AC_MSG_RESULT($ac_cv_linux_exports_tasklist_lock)
- CPPFLAGS="$save_CPPFLAGS"])
- 
- 
  AC_DEFUN([LINUX_FS_STRUCT_INODE_HAS_I_CDEV], [
  AC_MSG_CHECKING(for i_cdev in struct inode)
  save_CPPFLAGS="$CPPFLAGS"
--- 188,193 ----
***************
*** 392,394 ****
--- 375,422 ----
  ac_cv_linux_sched_struct_task_struct_has_sighand=no)])
  AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_sighand)
  CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_RLIM], [
+ AC_MSG_CHECKING(for rlim in struct task_struct)
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -I${LINUX_KERNEL_PATH}/include/asm/mach-${SUBARCH} -D__KERNEL__ $CPPFLAGS"
+ AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_rlim,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/sched.h>],
+ [struct task_struct _tsk;
+ printf("%d\n", _tsk.rlim);],
+ ac_cv_linux_sched_struct_task_struct_has_rlim=yes,
+ ac_cv_linux_sched_struct_task_struct_has_rlim=no)])
+ AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_rlim)
+ CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_SIGNAL_RLIM], [
+ AC_MSG_CHECKING(for signal->rlim in struct task_struct)
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -I${LINUX_KERNEL_PATH}/include/asm/mach-${SUBARCH} -D__KERNEL__ $CPPFLAGS"
+ AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_signal_rlim,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/sched.h>],
+ [struct task_struct _tsk;
+ printf("%d\n", _tsk.signal->rlim);],
+ ac_cv_linux_sched_struct_task_struct_has_signal_rlim=yes,
+ ac_cv_linux_sched_struct_task_struct_has_signal_rlim=no)])
+ AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_signal_rlim)
+ CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_SCHED_STRUCT_TASK_STRUCT_HAS_EXIT_STATE], [
+ AC_MSG_CHECKING(for exit_state in struct task_struct)
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -I${LINUX_KERNEL_PATH}/include/asm/mach-${SUBARCH} -D__KERNEL__ $CPPFLAGS"
+ AC_CACHE_VAL(ac_cv_linux_sched_struct_task_struct_has_exit_state,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/sched.h>],
+ [struct task_struct _tsk;
+ printf("%d\n", _tsk.exit_state);],
+ ac_cv_linux_sched_struct_task_struct_has_exit_state=yes,
+ ac_cv_linux_sched_struct_task_struct_has_exit_state=no)])
+ AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_exit_state)
+ CPPFLAGS="$save_CPPFLAGS"])
Index: openafs/src/cf/osconf.m4
diff -c openafs/src/cf/osconf.m4:1.51.2.8 openafs/src/cf/osconf.m4:1.51.2.9
*** openafs/src/cf/osconf.m4:1.51.2.8	Fri Dec 17 10:29:25 2004
--- openafs/src/cf/osconf.m4	Sun Jan 30 23:13:49 2005
***************
*** 195,201 ****
  		YACC="byacc"
  		;;
  
! 	*nbsd2*)
  		LEX="flex -l"
  		MT_CFLAGS='${XCFLAGS} -DAFS_PTHREAD_ENV -D_REENTRANT '
  		MT_LIBS="-lpthread" # XXX -pthread soon
--- 195,201 ----
  		YACC="byacc"
  		;;
  
! 	*nbsd2*|*nbsd3*)
  		LEX="flex -l"
  		MT_CFLAGS='${XCFLAGS} -DAFS_PTHREAD_ENV -D_REENTRANT '
  		MT_LIBS="-lpthread" # XXX -pthread soon
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.46.2.14 openafs/src/config/NTMakefile.i386_nt40:1.46.2.15
*** openafs/src/config/NTMakefile.i386_nt40:1.46.2.14	Thu Dec 16 15:07:20 2004
--- openafs/src/config/NTMakefile.i386_nt40	Sun Jan 30 22:53:24 2005
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=7700
  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=7701
  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.6 openafs/src/config/afs_sysnames.h:1.50.2.7
*** openafs/src/config/afs_sysnames.h:1.50.2.6	Fri Dec 17 10:29:27 2004
--- openafs/src/config/afs_sysnames.h	Sun Jan 30 23:13:49 2005
***************
*** 198,203 ****
--- 198,204 ----
  #define SYS_NAME_ID_sparc64_nbsd20	2523
  #define SYS_NAME_ID_macppc_nbsd20	2524
  #define SYS_NAME_ID_i386_nbsd21		2525
+ #define SYS_NAME_ID_i386_nbsd30		2526
  
  #define SYS_NAME_ID_i386_obsd31		2600
  #define SYS_NAME_ID_i386_obsd32		2601
Index: openafs/src/config/make_libafs_tree.pl
diff -c openafs/src/config/make_libafs_tree.pl:1.1.2.1 openafs/src/config/make_libafs_tree.pl:1.1.2.2
*** openafs/src/config/make_libafs_tree.pl:1.1.2.1	Wed Aug 25 03:03:38 2004
--- openafs/src/config/make_libafs_tree.pl	Sun Jan 30 23:23:02 2005
***************
*** 63,69 ****
  #
  # Manual actions
  #
! &copyit("$projdir/configure-libafs", "$treedir/configure-libafs");
  &copyit("$projdir/Makefile-libafs.in", "$treedir/Makefile.in");
  
  system("$objdir/src/config/config", 
--- 63,69 ----
  #
  # Manual actions
  #
! &copyit("$projdir/configure-libafs", "$treedir/configure");
  &copyit("$projdir/Makefile-libafs.in", "$treedir/Makefile.in");
  
  system("$objdir/src/config/config", 
Index: openafs/src/config/param.i386_nbsd30.h
diff -c /dev/null openafs/src/config/param.i386_nbsd30.h:1.1.2.1
*** /dev/null	Sun Jan 30 23:45:41 2005
--- openafs/src/config/param.i386_nbsd30.h	Sun Jan 30 23:13:49 2005
***************
*** 0 ****
--- 1,21 ----
+ #ifndef	AFS_I386_PARAM_H
+ #define	AFS_I386_PARAM_H
+ 
+ #define AFS_X86_XBSD_ENV 1
+ #define AFS_X86_ENV 1
+ #define AFSLITTLE_ENDIAN 1
+ 
+ #define SYS_NAME       "i386_nbsd30"
+ #define SYS_NAME_ID    SYS_NAME_ID_i386_nbsd30
+ 
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #endif /* !defined(UKERNEL) */
+ 
+ #endif /* AFS_I386_PARAM_H */
+ 
Index: openafs/src/config/param.nbsd30.h
diff -c /dev/null openafs/src/config/param.nbsd30.h:1.1.2.1
*** /dev/null	Sun Jan 30 23:45:41 2005
--- openafs/src/config/param.nbsd30.h	Sun Jan 30 23:13:49 2005
***************
*** 0 ****
--- 1,158 ----
+ /* NetBSD shared section */
+ 
+ #ifndef	AFS_PARAM_COMMON_H
+ #define	AFS_PARAM_COMMON_H 1
+ 
+ #define AFS_64BIT_ENV  1
+ #define AFS_NAMEI_ENV  1	/* User space interface to file system */
+ #define AFS_64BIT_IOPS_ENV 1	/* Needed for NAMEI */
+ #define AFS_64BIT_CLIENT 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 210
+ 
+ #ifndef	MOUNT_AFS
+ #define	MOUNT_AFS AFS_MOUNT_AFS
+ #endif
+ 
+ #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
+ 
+ #define AFS_NBSD_ENV 1
+ #define AFS_NBSD15_ENV 1
+ #define AFS_NBSD16_ENV 1
+ #define AFS_NBSD20_ENV 1
+ #define AFS_NONFSTRANS 1
+ #define AFS_KERBEROS_ENV 1
+ 
+ #define AFS_VFSINCL_ENV 1
+ 
+ #define AFS_HAVE_FFS            1	/* Use system's ffs. */
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
+ #define AFS_HAVE_STATVFS    1	/* System supports statvfs */
+ #endif
+ 
+ #ifndef UKERNEL
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
+ #include <sys/param.h>
+ #endif
+ 
+ #define FTRUNC O_TRUNC
+ 
+ #define IUPD 0x0010
+ #define IACC 0x0020
+ #define ICHG 0x0040
+ #define IMOD 0x0080
+ 
+ #define IN_LOCK(ip)     lockmgr(&ip->i_lock, LK_EXCLUSIVE, \
+                                 NULL, curproc)
+ #define IN_UNLOCK(ip)   lockmgr(&ip->i_lock, LK_RELEASE, \
+                                 NULL, curproc)
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_VM_RDWR_ENV	1
+ #define AFS_VFS_ENV	1
+ #define AFS_GREEDY43_ENV	1
+ 
+ #define AFS_GCPAGS	        0	/* if nonzero, garbage collect PAGs */
+ #define AFS_USE_GETTIMEOFDAY    1	/* use gettimeofday to implement rx clock */
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef _KERNEL
+ #define AFS_GLOBAL_SUNLOCK        1
+ #define	AFS_VFS34	1	/* What is VFS34??? */
+ #define	AFS_SHORTGID	1	/* are group id's short? */
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	UIO_SYSSPACE
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	CLBYTES
+ #define	osi_GetTime(x)	microtime(x)
+ #define	AFS_KALLOC(x)	kalloc(x)
+ #define	AFS_KFREE(x,y)	kfree(x,y)
+ #define	v_count		v_usecount
+ #define v_vfsp		v_mount
+ #define vfs_bsize	mnt_stat.f_bsize
+ #define vfs_fsid	mnt_stat.f_fsid
+ #define va_nodeid	va_fileid
+ #define vfs_vnodecovered mnt_vnodecovered
+ #define direct		dirent
+ #define vnode_t		struct vnode
+ 
+ #ifndef MUTEX_DEFAULT
+ #define MUTEX_DEFAULT   0
+ #endif /* MUTEX_DEFAULT */
+ 
+ #ifndef SSYS
+ #define SSYS            0x00002
+ #endif /* SSYS */
+ 
+ #define p_rcred         p_ucred
+ 
+ #define	VN_RELE(vp)	vrele(((struct vnode *)(vp)))
+ #define	VN_HOLD(vp)	VREF(((struct vnode *)(vp)))
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
+ enum vcexcl { NONEXCL, EXCL };
+ 
+ #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 /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ && !defined(IGNORE_STDS_H) */ 
+ #endif /* _KERNEL */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ 
+ /* This section for user space compiles only */
+ 
+ #define UKERNEL			1	/* user space kernel */
+ 
+ #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 */
+ 
+ #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	UIO_SYSSPACE
+ #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
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__) && !defined(IGNORE_STDS_H)
+ #include <limits.h>
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/mount.h>
+ #include <sys/fcntl.h>
+ #include <netinet/in.h>
+ #include <sys/uio.h>
+ #include <sys/socket.h>
+ #endif
+ 
+ #endif /* !defined(UKERNEL) */
+ 
+ #endif /* AFS_PARAM_COMMON_H */
Index: openafs/src/config/param.sunx86_510.h
diff -c openafs/src/config/param.sunx86_510.h:1.2 openafs/src/config/param.sunx86_510.h:1.2.2.1
*** openafs/src/config/param.sunx86_510.h:1.2	Sun Aug  8 14:14:08 2004
--- openafs/src/config/param.sunx86_510.h	Sun Jan 30 23:14:21 2005
***************
*** 133,147 ****
  
  /* This section for user space compiles only */
  
- /*
-  * Copyright 2000, International Business Machines Corporation and others.
-  * All Rights Reserved.
-  * 
-  * This software has been released under the terms of the IBM Public
-  * License.  For details, see the LICENSE file in the top-level source
-  * directory or online at http://www.openafs.org/dl/license10.html
-  */
- 
  #ifndef	AFS_PARAM_H
  #define	AFS_PARAM_H
  
--- 133,138 ----
***************
*** 156,161 ****
--- 147,158 ----
  #define AFS_ENV			1
  #define AFS_USR_SUN5_ENV	1
  #define AFS_USR_SUN6_ENV	1
+ #define AFS_USR_SUN7_ENV        1
+ #define AFS_USR_SUN8_ENV        1
+ #define AFS_USR_SUN9_ENV        1
+ 
+ #define AFS_64BIT_ENV           1
+ 
  
  #include <afs/afs_sysnames.h>
  
***************
*** 170,178 ****
  #define AFS_MOUNT_AFS		1
  
  /* Machine / Operating system information */
! #define sys_sun4x_55		1
! #define SYS_NAME		"sun4x_55"
! #define SYS_NAME_ID		SYS_NAME_ID_sun4x_55
  #define AFSLITTLE_ENDIAN	1
  #define AFS_HAVE_FFS            1	/* Use system's ffs. */
  #define AFS_HAVE_STATVFS	0	/* System doesn't support statvfs */
--- 167,175 ----
  #define AFS_MOUNT_AFS		1
  
  /* Machine / Operating system information */
! #define sys_sunx86_510          1
! #define SYS_NAME                "sunx86_510"
! #define SYS_NAME_ID             SYS_NAME_ID_sunx86_510
  #define AFSLITTLE_ENDIAN	1
  #define AFS_HAVE_FFS            1	/* Use system's ffs. */
  #define AFS_HAVE_STATVFS	0	/* System doesn't support statvfs */
Index: openafs/src/libafs/Makefile.common.in
diff -c openafs/src/libafs/Makefile.common.in:1.21 openafs/src/libafs/Makefile.common.in:1.21.2.1
*** openafs/src/libafs/Makefile.common.in:1.21	Thu Mar 11 02:24:23 2004
--- openafs/src/libafs/Makefile.common.in	Sun Jan 30 23:25:16 2005
***************
*** 387,392 ****
--- 387,396 ----
  	$(CRULE_OPT)
  osi_module.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_module.c
  	$(CRULE_NOOPT)
+ osi_probe.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_probe.c
+ 	$(CRULE_NOOPT)
+ osi_syscall.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_syscall.c
+ 	$(CRULE_NOOPT)
  osi_sysctl.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_sysctl.c
  	$(CRULE_NOOPT)
  osi_alloc.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_alloc.c
Index: openafs/src/libafs/MakefileProto.LINUX.in
diff -c openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.4 openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.5
*** openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.4	Tue Dec  7 10:59:32 2004
--- openafs/src/libafs/MakefileProto.LINUX.in	Sun Jan 30 23:25:16 2005
***************
*** 18,24 ****
--- 18,26 ----
  	osi_file.o \
  	osi_misc.o \
  	osi_module.o \
+ 	osi_probe.o \
  	osi_sleep.o \
+ 	osi_syscall.o \
  	osi_sysctl.o \
  	osi_vfsops.o \
  	osi_vm.o \
Index: openafs/src/lwp/lwp.c
diff -c openafs/src/lwp/lwp.c:1.27.2.2 openafs/src/lwp/lwp.c:1.27.2.3
*** openafs/src/lwp/lwp.c:1.27.2.2	Mon Dec 13 14:40:19 2004
--- openafs/src/lwp/lwp.c	Sun Jan 30 23:20:00 2005
***************
*** 17,23 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/lwp.c,v 1.27.2.2 2004/12/13 19:40:19 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 17,23 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/lwp.c,v 1.27.2.3 2005/01/31 04:20:00 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
***************
*** 121,127 ****
  struct QUEUE {
      PROCESS head;
      int count;
! } runnable[MAX_PRIORITIES], blocked;
  /* Invariant for runnable queues: The head of each queue points to the currently running process if it is in that queue, or it points to the next process in that queue that should run. */
  
  /* Offset of stack field within pcb -- used by stack checking stuff */
--- 121,127 ----
  struct QUEUE {
      PROCESS head;
      int count;
! } runnable[MAX_PRIORITIES], blocked, qwaiting;
  /* Invariant for runnable queues: The head of each queue points to the currently running process if it is in that queue, or it points to the next process in that queue that should run. */
  
  /* Offset of stack field within pcb -- used by stack checking stuff */
***************
*** 242,248 ****
  {
      register PROCESS tp;
      (tp = lwp_cpptr)->status = QWAITING;
!     lwp_remove(tp, &runnable[tp->priority]);
      Set_LWP_RC();
      return LWP_SUCCESS;
  }
--- 242,248 ----
  {
      register PROCESS tp;
      (tp = lwp_cpptr)->status = QWAITING;
!     move(tp, &runnable[tp->priority], &qwaiting);
      Set_LWP_RC();
      return LWP_SUCCESS;
  }
***************
*** 253,259 ****
  {
      if (pid->status == QWAITING) {
  	pid->status = READY;
! 	insert(pid, &runnable[pid->priority]);
  	return LWP_SUCCESS;
      } else
  	return LWP_ENOWAIT;
--- 253,259 ----
  {
      if (pid->status == QWAITING) {
  	pid->status = READY;
! 	move(pid, &qwaiting, &runnable[pid->priority]);
  	return LWP_SUCCESS;
      } else
  	return LWP_ENOWAIT;
***************
*** 561,566 ****
--- 561,569 ----
  	    for_all_elts(x, blocked, {
  			 Dump_One_Process(x);}
  	)
+ 	    for_all_elts(x, qwaiting, {
+ 			 Dump_One_Process(x);}
+ 	)
      } else
  	printf("***LWP: LWP support not initialized\n");
      return 0;
***************
*** 601,606 ****
--- 604,611 ----
      }
      blocked.head = NULL;
      blocked.count = 0;
+     qwaiting.head = NULL;
+     qwaiting.count = 0;
      lwp_init = (struct lwp_ctl *)malloc(sizeof(struct lwp_ctl));
      temp = (PROCESS) malloc(sizeof(struct lwp_pcb));
      if (lwp_init == NULL || temp == NULL)
***************
*** 660,665 ****
--- 665,673 ----
  	for_all_elts(cur, blocked, {
  		     Free_PCB(cur);}
      )
+ 	for_all_elts(cur, qwaiting, {
+ 		     Free_PCB(cur);}
+     )
  	free(lwp_init);
      lwp_init = NULL;
      return LWP_SUCCESS;
***************
*** 784,790 ****
      lwp_remove(pid,
  	       (pid->blockflag || pid->status == WAITING
  		|| pid->status ==
! 		DESTROYED ? &blocked : &runnable[pid->priority]));
      LWPANCHOR.processcnt--;
      return 0;
  }
--- 792,800 ----
      lwp_remove(pid,
  	       (pid->blockflag || pid->status == WAITING
  		|| pid->status ==
! 		DESTROYED ? &blocked : 
! 		(pid->status == QWAITING) ? &qwaiting :
! 		&runnable[pid->priority]));
      LWPANCHOR.processcnt--;
      return 0;
  }
***************
*** 811,816 ****
--- 821,829 ----
      case DESTROYED:
  	printf("DESTROYED");
  	break;
+     case QWAITING:
+ 	printf("QWAITING");
+ 	break;
      default:
  	printf("unknown");
      }
***************
*** 870,876 ****
  		     printf(" \"%s\"", p->name);
  		     }
  	)
! 	    puts("]");
      }
  #endif
  
--- 883,895 ----
  		     printf(" \"%s\"", p->name);
  		     }
  	)
! 	puts("]");
! 	printf("[Qwaiting (%d):", qwaiting.count);
! 	for_all_elts(p, qwaiting, {
! 		     printf(" \"%s\"", p->name);
! 		     }
! 	)
! 	puts("]");
      }
  #endif
  
Index: openafs/src/packaging/Debian/kern-sysname
diff -c openafs/src/packaging/Debian/kern-sysname:1.1 openafs/src/packaging/Debian/kern-sysname:1.1.2.1
*** openafs/src/packaging/Debian/kern-sysname:1.1	Mon Aug 26 16:52:02 2002
--- openafs/src/packaging/Debian/kern-sysname	Sun Jan 30 23:14:37 2005
***************
*** 11,18 ****
  	    esac
  ;;
      ia64)
!     echo ia64_linux24
! ;;
      alpha)
  	case $KVERS in
  	    2.2*)
--- 11,25 ----
  	    esac
  ;;
      ia64)
! 	case $KVERS in
! 	    2.4*)
! 		echo ia64_linux24
! 		;;
! 	    2.6*)
! 		echo ia64_linux26
! 		;;
! 	    esac
! 	;;
      alpha)
  	case $KVERS in
  	    2.2*)
Index: openafs/src/packaging/MacOS/OpenAFS.Info.plist
diff -c openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.4 openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.5
*** openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.4	Fri Dec 17 10:36:45 2004
--- openafs/src/packaging/MacOS/OpenAFS.Info.plist	Sun Jan 30 23:37:23 2005
***************
*** 3,15 ****
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.77</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.77</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
--- 3,15 ----
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.78</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.78</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
Index: openafs/src/packaging/MacOS/OpenAFS.info
diff -c openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.4 openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.5
*** openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.4	Fri Dec 17 10:36:45 2004
--- openafs/src/packaging/MacOS/OpenAFS.info	Sun Jan 30 23:37:23 2005
***************
*** 1,5 ****
  Title OpenAFS
! Version 1.3.77
  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.78
  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/ptserver/Makefile.in
diff -c openafs/src/ptserver/Makefile.in:1.14 openafs/src/ptserver/Makefile.in:1.14.2.1
*** openafs/src/ptserver/Makefile.in:1.14	Fri Oct 24 02:26:13 2003
--- openafs/src/ptserver/Makefile.in	Sun Jan 30 22:58:39 2005
***************
*** 14,20 ****
  	${TOP_INCDIR}/rx/xdr.h \
  	${TOP_INCDIR}/afs/keys.h \
  	${TOP_INCDIR}/afs/cellconfig.h \
! 	ptserver.h ptclient.h ptint.h pterror.h map.h
  
  LINCLS=${TOP_INCDIR}/ubik.h \
  	${TOP_INCDIR}/lock.h \
--- 14,20 ----
  	${TOP_INCDIR}/rx/xdr.h \
  	${TOP_INCDIR}/afs/keys.h \
  	${TOP_INCDIR}/afs/cellconfig.h \
! 	ptserver.h ptclient.h ptuser.h ptint.h pterror.h map.h
  
  LINCLS=${TOP_INCDIR}/ubik.h \
  	${TOP_INCDIR}/lock.h \
***************
*** 23,29 ****
  	${TOP_INCDIR}/rx/rxkad.h \
  	${TOP_INCDIR}/afs/auth.h \
  	${TOP_INCDIR}/afs/cellconfig.h \
! 	ptclient.h ptint.h pterror.h
  
  LIBS=${TOP_LIBDIR}/libubik.a \
  	${TOP_LIBDIR}/libauth.a \
--- 23,29 ----
  	${TOP_INCDIR}/rx/rxkad.h \
  	${TOP_INCDIR}/afs/auth.h \
  	${TOP_INCDIR}/afs/cellconfig.h \
! 	ptclient.h ptuser.h ptint.h pterror.h
  
  LIBS=${TOP_LIBDIR}/libubik.a \
  	${TOP_LIBDIR}/libauth.a \
***************
*** 49,54 ****
--- 49,55 ----
  	${TOP_INCDIR}/afs/print.h \
  	${TOP_INCDIR}/afs/prserver.h \
  	${TOP_INCDIR}/afs/ptclient.h \
+ 	${TOP_INCDIR}/afs/ptuser.h \
  	${TOP_INCDIR}/afs/pterror.h \
  	${TOP_INCDIR}/afs/ptint.h \
  	${TOP_INCDIR}/afs/ptserver.h
***************
*** 170,175 ****
--- 171,177 ----
  	${DESTDIR}${includedir}/afs/print.h \
  	${DESTDIR}${includedir}/afs/prserver.h \
  	${DESTDIR}${includedir}/afs/ptclient.h \
+ 	${DESTDIR}${includedir}/afs/ptuser.h \
  	${DESTDIR}${includedir}/afs/pterror.h \
  	${DESTDIR}${includedir}/afs/ptint.h \
  	${DESTDIR}${includedir}/afs/ptserver.h
***************
*** 213,218 ****
--- 215,223 ----
  ${DEST}/include/afs/ptclient.h: ptclient.h
  	${INSTALL} $? $@
  
+ ${DEST}/include/afs/ptuser.h: ptuser.h
+ 	${INSTALL} $? $@
+ 
  #
  # Misc. targets
  #
***************
*** 270,278 ****
--- 275,289 ----
  ${DESTDIR}${includedir}/afs/ptclient.h: ptclient.h
  	${INSTALL} $? $@
  
+ ${DESTDIR}${includedir}/afs/ptuser.h: ptuser.h
+ 	${INSTALL} $? $@
+ 
  ${TOP_INCDIR}/afs/ptclient.h: ptclient.h
  	${INSTALL} $? $@
  
+ ${TOP_INCDIR}/afs/ptuser.h: ptuser.h
+ 	${INSTALL} $? $@
+ 
  ${DESTDIR}${includedir}/afs/pterror.h: pterror.h
  	${INSTALL} $? $@
  
***************
*** 303,308 ****
--- 314,320 ----
  	${DEST}/include/afs/print.h \
  	${DEST}/include/afs/prserver.h \
  	${DEST}/include/afs/ptclient.h \
+ 	${DEST}/include/afs/ptuser.h \
  	${DEST}/include/afs/pterror.h \
  	${DEST}/include/afs/ptint.h \
  	${DEST}/include/afs/ptserver.h
Index: openafs/src/ptserver/NTMakefile
diff -c openafs/src/ptserver/NTMakefile:1.9 openafs/src/ptserver/NTMakefile:1.9.2.1
*** openafs/src/ptserver/NTMakefile:1.9	Thu Aug  5 12:31:40 2004
--- openafs/src/ptserver/NTMakefile	Sun Jan 30 22:58:39 2005
***************
*** 21,27 ****
  	$(INCFILEDIR)\afs\ptint.h \
  	$(INCFILEDIR)\afs\pterror.h \
  	ptopcodes.h \
! 	$(INCFILEDIR)\afs\ptclient.h 
  
  ############################################################################
  # build afsprot.lib
--- 21,28 ----
  	$(INCFILEDIR)\afs\ptint.h \
  	$(INCFILEDIR)\afs\pterror.h \
  	ptopcodes.h \
! 	$(INCFILEDIR)\afs\ptclient.h \
! 	$(INCFILEDIR)\afs\ptuser.h
  
  ############################################################################
  # build afsprot.lib
Index: openafs/src/ptserver/ptuser.c
diff -c openafs/src/ptserver/ptuser.c:1.16.2.1 openafs/src/ptserver/ptuser.c:1.16.2.2
*** openafs/src/ptserver/ptuser.c:1.16.2.1	Mon Oct 18 03:12:04 2004
--- openafs/src/ptserver/ptuser.c	Sun Jan 30 22:58:39 2005
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.1 2004/10/18 07:12:04 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.2 2005/01/31 03:58:39 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
***************
*** 29,34 ****
--- 29,35 ----
  #include "afs/cellconfig.h"
  #include "afs/afsutil.h"
  #include "afs/ptclient.h"
+ #include "afs/ptuser.h"
  #include "afs/pterror.h"
  #else /* defined(UKERNEL) */
  #include <afs/stds.h>
***************
*** 54,59 ****
--- 55,61 ----
  #include <afs/cellconfig.h>
  #include <afs/afsutil.h>
  #include "ptclient.h"
+ #include "ptuser.h"
  #include "pterror.h"
  #endif /* defined(UKERNEL) */
  
Index: openafs/src/ptserver/ptuser.h
diff -c /dev/null openafs/src/ptserver/ptuser.h:1.1.2.1
*** /dev/null	Sun Jan 30 23:45:42 2005
--- openafs/src/ptserver/ptuser.h	Sun Jan 30 22:58:39 2005
***************
*** 0 ****
--- 1,44 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef PTUSER_H
+ #define PTUSER_H
+ 
+ #include "afs/ptint.h"
+ 
+ afs_int32 pr_Initialize(afs_int32 secLevel, char *confDir, char *cell);
+ int pr_End(void);
+ int pr_CreateUser(char name[PR_MAXNAMELEN], afs_int32 *id);
+ int pr_CreateGroup(char name[PR_MAXNAMELEN], char owner[PR_MAXNAMELEN], afs_int32 *id);
+ int pr_Delete(char *name);
+ int pr_DeleteByID(afs_int32 id);
+ int pr_AddToGroup(char *user, char *group);
+ int pr_RemoveUserFromGroup(char *user, char *group);
+ int pr_NameToId(namelist *names, idlist *ids);
+ int pr_SNameToId(char name[PR_MAXNAMELEN], afs_int32 *id);
+ int pr_IdToName(idlist *ids, namelist *names);
+ int pr_SIdToName(afs_int32 id, char name[PR_MAXNAMELEN]);
+ int pr_GetCPS(afs_int32 id, prlist *CPS);
+ int pr_GetCPS2(afs_int32 id, afs_int32 host, prlist *CPS);
+ int pr_GetHostCPS(afs_int32 host, prlist *CPS);
+ int pr_ListMembers(char *group, namelist *lnames);
+ int pr_ListOwned(afs_int32 oid, namelist *lnames, afs_int32 *moreP);
+ int pr_IDListMembers(afs_int32 gid, namelist *lnames);
+ int pr_ListEntry(afs_int32 id, struct prcheckentry *aentry);
+ afs_int32 pr_ListEntries(int flag, afs_int32 startindex, afs_int32 *nentries, struct prlistentries **entries, afs_int32 *nextstartindex);
+ int pr_CheckEntryByName(char *name, afs_int32 *id, char *owner, char *creator);
+ int pr_CheckEntryById(char *name, afs_int32 id, char *owner, char *creator);
+ int pr_ChangeEntry(char *oldname, char *newname, afs_int32 *newid, char *newowner);
+ int pr_IsAMemberOf(char *uname, char *gname, afs_int32 *flag);
+ int pr_ListMaxUserId(afs_int32 *mid);
+ int pr_SetMaxUserId(afs_int32 mid);
+ int pr_ListMaxGroupId(afs_int32 *mid);
+ int pr_SetMaxGroupId(afs_int32 mid);
+ afs_int32 pr_SetFieldsEntry(afs_int32 id, afs_int32 mask, afs_int32 flags, afs_int32 ngroups, afs_int32 nusers);
+ #endif /* PTUSER_H */
\ No newline at end of file
Index: openafs/src/rx/rx.c
diff -c openafs/src/rx/rx.c:1.58.2.4 openafs/src/rx/rx.c:1.58.2.6
*** openafs/src/rx/rx.c:1.58.2.4	Tue Dec  7 01:10:05 2004
--- openafs/src/rx/rx.c	Sun Jan 30 23:14:45 2005
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.4 2004/12/07 06:10:05 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.6 2005/01/31 04:14:45 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
***************
*** 2673,2678 ****
--- 2673,2681 ----
  		MUTEX_ENTER(&conn->conn_data_lock);
  		conn->refCount--;
  		MUTEX_EXIT(&conn->conn_data_lock);
+ 		MUTEX_ENTER(&rx_stats_mutex);
+ 		rx_stats.nBusies++;
+ 		MUTEX_EXIT(&rx_stats_mutex);
  		return tp;
  	    }
  	    rxi_KeepAliveOn(call);
***************
*** 5032,5037 ****
--- 5035,5043 ----
  	if (!(call->flags & RX_CALL_TQ_BUSY)) {
  	    call->flags |= RX_CALL_TQ_BUSY;
  	    do {
+ #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
+ 	    restart:
+ #ifdef	AFS_GLOBAL_RXLOCK_KERNEL
  		call->flags &= ~RX_CALL_NEED_START;
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
  		nXmitPackets = 0;
***************
*** 5085,5091 ****
  		    /* Transmit the packet if it needs to be sent. */
  		    if (!clock_Lt(&now, &p->retryTime)) {
  			if (nXmitPackets == maxXmitPackets) {
! 			    osi_Panic("rxi_Start: xmit list overflowed");
  			}
  			xmitList[nXmitPackets++] = p;
  		    }
--- 5091,5102 ----
  		    /* Transmit the packet if it needs to be sent. */
  		    if (!clock_Lt(&now, &p->retryTime)) {
  			if (nXmitPackets == maxXmitPackets) {
! 			    rxi_SendXmitList(call, xmitList, nXmitPackets, 
! 					     istack, &now, &retryTime, 
! 					     resending);
! 			    osi_Free(xmitList, maxXmitPackets * 
! 				     sizeof(struct rx_packet *));
! 			    goto restart;
  			}
  			xmitList[nXmitPackets++] = p;
  		    }
Index: openafs/src/rx/rx.h
diff -c openafs/src/rx/rx.h:1.22.2.2 openafs/src/rx/rx.h:1.22.2.3
*** openafs/src/rx/rx.h:1.22.2.2	Tue Dec  7 01:10:05 2004
--- openafs/src/rx/rx.h	Sun Jan 30 23:14:46 2005
***************
*** 804,810 ****
      int ignorePacketDally;	/* packets dropped because call is in dally state */
      int receiveCbufPktAllocFailures;
      int sendCbufPktAllocFailures;
!     int spares[5];
  };
  
  /* structures for debug input and output packets */
--- 804,811 ----
      int ignorePacketDally;	/* packets dropped because call is in dally state */
      int receiveCbufPktAllocFailures;
      int sendCbufPktAllocFailures;
!     int nBusies;
!     int spares[4];
  };
  
  /* structures for debug input and output packets */
Index: openafs/src/rx/rx_globals.h
diff -c openafs/src/rx/rx_globals.h:1.9.2.1 openafs/src/rx/rx_globals.h:1.9.2.2
*** openafs/src/rx/rx_globals.h:1.9.2.1	Mon Oct 18 03:12:06 2004
--- openafs/src/rx/rx_globals.h	Sun Jan 30 23:20:25 2005
***************
*** 249,264 ****
  EXT struct rx_peer **rx_peerHashTable;
  EXT struct rx_connection **rx_connHashTable;
  EXT struct rx_connection *rx_connCleanup_list INIT(0);
! EXT afs_uint32 rx_hashTableSize INIT(256);	/* Power of 2 */
! EXT afs_uint32 rx_hashTableMask INIT(255);	/* One less than rx_hashTableSize */
  #ifdef RX_ENABLE_LOCKS
  EXT afs_kmutex_t rx_peerHashTable_lock;
  EXT afs_kmutex_t rx_connHashTable_lock;
  #endif /* RX_ENABLE_LOCKS */
  
! #define CONN_HASH(host, port, cid, epoch, type) ((((cid)>>RX_CIDSHIFT)&rx_hashTableMask))
  
! #define PEER_HASH(host, port)  ((host ^ port) & rx_hashTableMask)
  
  /* Forward definitions of internal procedures */
  #define	rxi_ChallengeOff(conn)	rxevent_Cancel((conn)->challengeEvent, (struct rx_call*)0, 0);
--- 249,263 ----
  EXT struct rx_peer **rx_peerHashTable;
  EXT struct rx_connection **rx_connHashTable;
  EXT struct rx_connection *rx_connCleanup_list INIT(0);
! EXT afs_uint32 rx_hashTableSize INIT(257);	/* Prime number */
  #ifdef RX_ENABLE_LOCKS
  EXT afs_kmutex_t rx_peerHashTable_lock;
  EXT afs_kmutex_t rx_connHashTable_lock;
  #endif /* RX_ENABLE_LOCKS */
  
! #define CONN_HASH(host, port, cid, epoch, type) ((((cid)>>RX_CIDSHIFT)%rx_hashTableSize))
  
! #define PEER_HASH(host, port)  ((host ^ port) % rx_hashTableSize)
  
  /* Forward definitions of internal procedures */
  #define	rxi_ChallengeOff(conn)	rxevent_Cancel((conn)->challengeEvent, (struct rx_call*)0, 0);
Index: openafs/src/rx/rx_packet.c
diff -c openafs/src/rx/rx_packet.c:1.35.2.3 openafs/src/rx/rx_packet.c:1.35.2.7
*** openafs/src/rx/rx_packet.c:1.35.2.3	Tue Dec  7 01:10:06 2004
--- openafs/src/rx/rx_packet.c	Sun Jan 30 23:34:46 2005
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.35.2.3 2004/12/07 06:10:06 shadow Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.35.2.7 2005/01/31 04:34:46 shadow Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
***************
*** 191,197 ****
  	j = MIN(resid, packet->wirevec[i].iov_len - (offset - l));
  	memcpy(out, (char *)(packet->wirevec[i].iov_base) + (offset - l), j);
  	resid -= j;
! 	l += packet->wirevec[i].iov_len;
  	i++;
      }
  
--- 191,199 ----
  	j = MIN(resid, packet->wirevec[i].iov_len - (offset - l));
  	memcpy(out, (char *)(packet->wirevec[i].iov_base) + (offset - l), j);
  	resid -= j;
!         out += j;
!   	l += packet->wirevec[i].iov_len;
! 	offset = l;
  	i++;
      }
  
***************
*** 231,237 ****
--- 233,241 ----
  	j = MIN(resid, packet->wirevec[i].iov_len - (offset - l));
  	memcpy(b, in, j);
  	resid -= j;
+         in += j;
  	l += packet->wirevec[i].iov_len;
+ 	offset = l;
  	i++;
      }
  
Index: openafs/src/rx/rx_prototypes.h
diff -c openafs/src/rx/rx_prototypes.h:1.14.2.2 openafs/src/rx/rx_prototypes.h:1.14.2.3
*** openafs/src/rx/rx_prototypes.h:1.14.2.2	Tue Dec  7 01:10:06 2004
--- openafs/src/rx/rx_prototypes.h	Sun Jan 30 23:34:46 2005
***************
*** 274,279 ****
--- 274,281 ----
  
  
  /* rx_event.c */
+ extern int rxevent_nFree;
+ extern int rxevent_nPosted;
  #if 0
  extern struct rxevent *rxevent_Post(struct clock *when,
  				    void (*func) (struct rxevent * event,
Index: openafs/src/rx/rxdebug.c
diff -c openafs/src/rx/rxdebug.c:1.15.2.3 openafs/src/rx/rxdebug.c:1.15.2.4
*** openafs/src/rx/rxdebug.c:1.15.2.3	Tue Dec  7 01:06:50 2004
--- openafs/src/rx/rxdebug.c	Sun Jan 30 23:23:17 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rxdebug.c,v 1.15.2.3 2004/12/07 06:06:50 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rxdebug.c,v 1.15.2.4 2005/01/31 04:23:17 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
***************
*** 256,262 ****
      withRxStats = (supportedDebugValues & RX_SERVER_DEBUG_RX_STATS);
      withWaiters = (supportedDebugValues & RX_SERVER_DEBUG_WAITER_CNT);
      withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS);
!     withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_WAITED_CNT);
      withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER);
  
      printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n",
--- 256,262 ----
      withRxStats = (supportedDebugValues & RX_SERVER_DEBUG_RX_STATS);
      withWaiters = (supportedDebugValues & RX_SERVER_DEBUG_WAITER_CNT);
      withIdleThreads = (supportedDebugValues & RX_SERVER_DEBUG_IDLE_THREADS);
!     withWaited = (supportedDebugValues & RX_SERVER_DEBUG_WAITED_CNT);
      withPeers = (supportedDebugValues & RX_SERVER_DEBUG_ALL_PEER);
  
      printf("Free packets: %d, packet reclaims: %d, calls: %d, used FDs: %d\n",
Index: openafs/src/rx/LINUX/rx_knet.c
diff -c openafs/src/rx/LINUX/rx_knet.c:1.23.2.4 openafs/src/rx/LINUX/rx_knet.c:1.23.2.5
*** openafs/src/rx/LINUX/rx_knet.c:1.23.2.4	Tue Dec  7 01:10:11 2004
--- openafs/src/rx/LINUX/rx_knet.c	Sun Jan 30 23:25:34 2005
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/LINUX/rx_knet.c,v 1.23.2.4 2004/12/07 06:10:11 shadow Exp $");
  
  #include <linux/version.h>
  #ifdef AFS_LINUX22_ENV
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/LINUX/rx_knet.c,v 1.23.2.5 2005/01/31 04:25:34 shadow Exp $");
  
  #include <linux/version.h>
  #ifdef AFS_LINUX22_ENV
***************
*** 194,213 ****
  
      return code;
  }
! 
  void
  osi_StopListener(void)
  {
      struct task_struct *listener;
      extern int rxk_ListenerPid;
  
! #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
!     read_lock(&tasklist_lock);
! #endif
      listener = find_task_by_pid(rxk_ListenerPid);
! #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
!     read_unlock(&tasklist_lock);
! #endif
      while (rxk_ListenerPid) {
  	flush_signals(listener);
  	force_sig(SIGKILL, listener);
--- 194,211 ----
  
      return code;
  }
! extern rwlock_t tasklist_lock __attribute__((weak));
  void
  osi_StopListener(void)
  {
      struct task_struct *listener;
      extern int rxk_ListenerPid;
  
!     if (&tasklist_lock)
!       read_lock(&tasklist_lock);
      listener = find_task_by_pid(rxk_ListenerPid);
!     if (&tasklist_lock)
!        read_unlock(&tasklist_lock);
      while (rxk_ListenerPid) {
  	flush_signals(listener);
  	force_sig(SIGKILL, listener);
Index: openafs/src/sys/pioctl_nt.c
diff -c openafs/src/sys/pioctl_nt.c:1.18.2.5 openafs/src/sys/pioctl_nt.c:1.18.2.7
*** openafs/src/sys/pioctl_nt.c:1.18.2.5	Tue Dec  7 01:15:58 2004
--- openafs/src/sys/pioctl_nt.c	Sun Jan 30 23:09:37 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.18.2.5 2004/12/07 06:15:58 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.7 2005/01/31 04:09:37 shadow Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
***************
*** 199,204 ****
--- 199,206 ----
  		    FILE_FLAG_WRITE_THROUGH, NULL);
      fflush(stdout);
      if (fh == INVALID_HANDLE_VALUE) {
+         int  gonext = 0;
+ 
          gle = GetLastError();
          if (gle && ioctlDebug ) {
              char buf[4096];
***************
*** 246,263 ****
                      fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
                               szPath,szUser,res);
                  }
  
!                 sprintf(szPath, "\\\\%s\\all", szClient);
!                 res = WNetAddConnection2(&nr,NULL,szUser,0);
!                 if (res) {
!                     if ( ioctlDebug ) {
!                         fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
!                                  szPath,szUser,res);
!                     }
!                     goto next_attempt;
                  }
              }
  
              fh = CreateFile(tbuffer, GENERIC_READ | GENERIC_WRITE,
                               FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
                               FILE_FLAG_WRITE_THROUGH, NULL);
--- 248,269 ----
                      fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
                               szPath,szUser,res);
                  }
+                 gonext = 1;
+             }
  
!             sprintf(szPath, "\\\\%s\\all", szClient);
!             res = WNetAddConnection2(&nr,NULL,szUser,0);
!             if (res) {
!                 if ( ioctlDebug ) {
!                     fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
!                              szPath,szUser,res);
                  }
+                 gonext = 1;
              }
  
+             if (gonext)
+                 goto next_attempt;
+ 
              fh = CreateFile(tbuffer, GENERIC_READ | GENERIC_WRITE,
                               FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
                               FILE_FLAG_WRITE_THROUGH, NULL);
***************
*** 301,316 ****
                      fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
                               szPath,szUser,res);
                  }
  
!                 sprintf(szPath, "\\\\%s\\all", szClient);
!                 res = WNetAddConnection2(&nr,NULL,szUser,0);
!                 if (res) {
!                     if ( ioctlDebug ) {
!                         fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
!                                  szPath,szUser,res);
!                     }
!                     return -1;
                  }
              }
  
              fh = CreateFile(tbuffer, GENERIC_READ | GENERIC_WRITE,
--- 307,322 ----
                      fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
                               szPath,szUser,res);
                  }
+             }
  
!             sprintf(szPath, "\\\\%s\\all", szClient);
!             res = WNetAddConnection2(&nr,NULL,szUser,0);
!             if (res) {
!                 if ( ioctlDebug ) {
!                     fprintf(stderr, "pioctl WNetAddConnection2(%s,%s) failed: 0x%X\r\n",
!                              szPath,szUser,res);
                  }
+                 return -1;
              }
  
              fh = CreateFile(tbuffer, GENERIC_READ | GENERIC_WRITE,
***************
*** 337,342 ****
--- 343,350 ----
                  }
                  return -1;
              }
+         } else {
+             return -1;
          }
      }
  
Index: openafs/src/venus/fstrace.c
diff -c openafs/src/venus/fstrace.c:1.16 openafs/src/venus/fstrace.c:1.16.2.1
*** openafs/src/venus/fstrace.c:1.16	Wed Sep 24 15:26:54 2003
--- openafs/src/venus/fstrace.c	Sun Jan 30 23:14:08 2005
***************
*** 14,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.16 2003/09/24 19:26:54 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 14,20 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.16.2.1 2005/01/31 04:14:08 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 2115,2121 ****
  afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
       long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
  {
!     int code;
  #ifdef AFS_LINUX20_ENV
  #if defined AFS_LINUX_64BIT_KERNEL
      long long eparm[4];
--- 2115,2121 ----
  afs_syscall(call, parm0, parm1, parm2, parm3, parm4, parm5, parm6)
       long call, parm0, parm1, parm2, parm3, parm4, parm5, parm6;
  {
!     int code, rval;
  #ifdef AFS_LINUX20_ENV
  #if defined AFS_LINUX_64BIT_KERNEL
      long long eparm[4];
***************
*** 2133,2141 ****
  #endif
      /* Linux can only handle 5 arguments in the actual syscall. */
      if (call == AFSCALL_ICL) {
! 	code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
      } else {
! 	code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
      }
  #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
      /* on sparc this function returns none value, so do it myself */
--- 2133,2145 ----
  #endif
      /* Linux can only handle 5 arguments in the actual syscall. */
      if (call == AFSCALL_ICL) {
! 	rval = proc_afs_syscall(call, parm0, parm1, parm2, eparm, &code);
! 	if (rval)
! 	    code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
      } else {
! 	rval = proc_afs_syscall(call, parm0, parm1, parm2, parm3, &code);
! 	if (rval)
! 	    code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
      }
  #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
      /* on sparc this function returns none value, so do it myself */
Index: openafs/src/vfsck/setup.c
diff -c openafs/src/vfsck/setup.c:1.10.2.1 openafs/src/vfsck/setup.c:1.10.2.2
*** openafs/src/vfsck/setup.c:1.10.2.1	Wed Aug 25 03:22:22 2004
--- openafs/src/vfsck/setup.c	Sun Jan 30 23:12:57 2005
***************
*** 19,25 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vfsck/setup.c,v 1.10.2.1 2004/08/25 07:22:22 shadow Exp $");
  
  #include <stdio.h>
  #define VICE
--- 19,25 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vfsck/setup.c,v 1.10.2.2 2005/01/31 04:12:57 shadow Exp $");
  
  #include <stdio.h>
  #define VICE
***************
*** 743,749 ****
       */
      altsblock.fs_fsbtodb = sblock.fs_fsbtodb;
  #ifdef AFS_NEWCG_ENV
! # ifndef AFS_SUN59_ENV
      altsblock.fs_interleave = sblock.fs_interleave;
  # endif
      altsblock.fs_npsect = sblock.fs_npsect;
--- 743,753 ----
       */
      altsblock.fs_fsbtodb = sblock.fs_fsbtodb;
  #ifdef AFS_NEWCG_ENV
! # if defined(AFS_SUN59_ENV) && defined(FS_SI_OK)
!     /* fs_interleave replaced with fs_si and FS_SI_OK defined in */
!     /* ufs_fs.h version 2.63 don't need to compare either */
!     altsblock.fs_si = sblock.fs_si;
! # else
      altsblock.fs_interleave = sblock.fs_interleave;
  # endif
      altsblock.fs_npsect = sblock.fs_npsect;
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.81.2.1 openafs/src/viced/afsfileprocs.c:1.81.2.3
*** openafs/src/viced/afsfileprocs.c:1.81.2.1	Thu Oct 28 16:47:23 2004
--- openafs/src/viced/afsfileprocs.c	Sun Jan 30 23:14:50 2005
***************
*** 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>
--- 29,35 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.3 2005/01/31 04:14:50 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 483,493 ****
--- 483,503 ----
  		    /* I'm not really worried about when we restarted, I'm   */
  		    /* just worried about when the first VBUSY was returned. */
  		    TM_GetTimeOfDay(&restartedat, 0);
+ 		    if (busyonrst) {
+ 			FS_LOCK;
+ 			afs_perfstats.fs_nBusies++;
+ 			FS_UNLOCK;
+ 		    }
  		    return (busyonrst ? VBUSY : VRESTARTING);
  		} else {
  		    struct timeval now;
  		    TM_GetTimeOfDay(&now, 0);
  		    if ((now.tv_sec - restartedat.tv_sec) < (11 * 60)) {
+ 			if (busyonrst) {
+ 			    FS_LOCK;
+ 			    afs_perfstats.fs_nBusies++;
+ 			    FS_UNLOCK;
+ 			}
  			return (busyonrst ? VBUSY : VRESTARTING);
  		    } else {
  			return (VRESTARTING);
***************
*** 2308,2320 ****
  #ifdef AFS_64BIT_ENV
  #ifndef AFS_LARGEFILE_ENV
      if (Pos + Len > 0x7fffffff)
! 	return E2BIG;
  #endif /* !AFS_LARGEFILE_ENV */
      tPos = (afs_sfsize_t) Pos;
      tLen = (afs_sfsize_t) Len;
  #else /* AFS_64BIT_ENV */
      if (Pos.high || Len.high)
! 	return E2BIG;
      tPos = Pos.low;
      tLen = Len.low;
  #endif /* AFS_64BIT_ENV */
--- 2318,2330 ----
  #ifdef AFS_64BIT_ENV
  #ifndef AFS_LARGEFILE_ENV
      if (Pos + Len > 0x7fffffff)
! 	return EFBIG;
  #endif /* !AFS_LARGEFILE_ENV */
      tPos = (afs_sfsize_t) Pos;
      tLen = (afs_sfsize_t) Len;
  #else /* AFS_64BIT_ENV */
      if (Pos.high || Len.high)
! 	return EFBIG;
      tPos = Pos.low;
      tLen = Len.low;
  #endif /* AFS_64BIT_ENV */
***************
*** 3121,3134 ****
  #ifdef AFS_64BIT_ENV
  #ifndef AFS_LARGEFILE_ENV
      if (FileLength > 0x7fffffff)
! 	return E2BIG;
  #endif /* !AFS_LARGEFILE_ENV */
      tPos = (afs_fsize_t) Pos;
      tLength = (afs_fsize_t) Length;
      tFileLength = (afs_fsize_t) FileLength;
  #else /* AFS_64BIT_ENV */
      if (FileLength.high)
! 	return E2BIG;
      tPos = Pos.low;
      tLength = Length.low;
      tFileLength = FileLength.low;
--- 3131,3144 ----
  #ifdef AFS_64BIT_ENV
  #ifndef AFS_LARGEFILE_ENV
      if (FileLength > 0x7fffffff)
! 	return EFBIG;
  #endif /* !AFS_LARGEFILE_ENV */
      tPos = (afs_fsize_t) Pos;
      tLength = (afs_fsize_t) Length;
      tFileLength = (afs_fsize_t) FileLength;
  #else /* AFS_64BIT_ENV */
      if (FileLength.high)
! 	return EFBIG;
      tPos = Pos.low;
      tLength = Length.low;
      tFileLength = FileLength.low;
***************
*** 5640,5646 ****
      a_perfP->host_ClientBlocks = CEBlocks;
  
      a_perfP->sysname_ID = afs_perfstats.sysname_ID;
! 
  }				/*FillPerfValues */
  
  
--- 5650,5657 ----
      a_perfP->host_ClientBlocks = CEBlocks;
  
      a_perfP->sysname_ID = afs_perfstats.sysname_ID;
!     a_perfP->rx_nBusies = (afs_int32) rx_stats.nBusies;
!     a_perfP->fs_nBusies = afs_perfstats.fs_nBusies;
  }				/*FillPerfValues */
  
  
Index: openafs/src/viced/callback.c
diff -c openafs/src/viced/callback.c:1.55.2.4 openafs/src/viced/callback.c:1.55.2.5
*** openafs/src/viced/callback.c:1.55.2.4	Tue Nov  9 12:17:49 2004
--- openafs/src/viced/callback.c	Sun Jan 30 23:10:43 2005
***************
*** 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() */
--- 83,89 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/callback.c,v 1.55.2.5 2005/01/31 04:10:43 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>		/* for malloc() */
***************
*** 1552,1572 ****
  }
  
  static struct host *lih_host;
! static int lih_host_held = 0;
  
  static int
  lih_r(register struct host *host, register int held,
        register struct host *hostp)
  {
-     lih_host_held = 0;
      if (host->cblist
  	&& ((hostp && host != hostp) || (!held && !h_OtherHolds_r(host)))
  	&& (!lih_host || host->ActiveCall < lih_host->ActiveCall)) {
  	lih_host = host;
!     }
!     if (!held) {
  	held = 1;
- 	lih_host_held = 1;
      }
      return held;
  }
--- 1552,1572 ----
  }
  
  static struct host *lih_host;
! static int lih_host_held;
  
  static int
  lih_r(register struct host *host, register int held,
        register struct host *hostp)
  {
      if (host->cblist
  	&& ((hostp && host != hostp) || (!held && !h_OtherHolds_r(host)))
  	&& (!lih_host || host->ActiveCall < lih_host->ActiveCall)) {
+ 	if (lih_host != NULL && lih_host_held) {
+ 	    h_Release_r(lih_host);
+ 	}
  	lih_host = host;
! 	lih_host_held = !held;
  	held = 1;
      }
      return held;
  }
***************
*** 1594,1606 ****
  	h_Enumerate_r(lih_r, hp2, (char *)hp1);
  	hp = lih_host;
  	if (hp) {
  	    cbstuff.GSS4++;
  	    if (!ClearHostCallbacks_r(hp, 0 /* not locked or held */ )) {
! 		if (lih_host_held) 
  		    h_Release_r(hp);
  		return 0;
  	    }
! 	    if (lih_host_held) 
  		h_Release_r(hp);
  	    hp2 = hp->next;
  	} else {
--- 1594,1608 ----
  	h_Enumerate_r(lih_r, hp2, (char *)hp1);
  	hp = lih_host;
  	if (hp) {
+ 	    /* set in lih_r! private copy before giving up H_LOCK */
+ 	    int lih_host_held2=lih_host_held;   
  	    cbstuff.GSS4++;
  	    if (!ClearHostCallbacks_r(hp, 0 /* not locked or held */ )) {
! 		if (lih_host_held2)
  		    h_Release_r(hp);
  		return 0;
  	    }
! 	    if (lih_host_held2)
  		h_Release_r(hp);
  	    hp2 = hp->next;
  	} else {
Index: openafs/src/viced/fs_stats.h
diff -c openafs/src/viced/fs_stats.h:1.3 openafs/src/viced/fs_stats.h:1.3.2.1
*** openafs/src/viced/fs_stats.h:1.3	Tue Jul 15 19:17:30 2003
--- openafs/src/viced/fs_stats.h	Sun Jan 30 23:14:50 2005
***************
*** 123,132 ****
       */
      afs_int32 sysname_ID;	/*Unique hardware/OS identifier */
  
      /*
       * Spares
       */
!     afs_int32 spare[31];
  };
  
  #if FS_STATS_DETAILED
--- 123,135 ----
       */
      afs_int32 sysname_ID;	/*Unique hardware/OS identifier */
  
+     afs_int32 rx_nBusies;	/*Ttl VBUSYs sent to shed load */
+     afs_int32 fs_nBusies;	/*Ttl VBUSYs sent during restart/vol clone */
+ 
      /*
       * Spares
       */
!     afs_int32 spare[29];
  };
  
  #if FS_STATS_DETAILED
Index: openafs/src/volser/vsprocs.c
diff -c openafs/src/volser/vsprocs.c:1.33.2.1 openafs/src/volser/vsprocs.c:1.33.2.3
*** openafs/src/volser/vsprocs.c:1.33.2.1	Tue Nov  9 12:13:45 2004
--- openafs/src/volser/vsprocs.c	Sun Jan 30 23:34:47 2005
***************
*** 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>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.33.2.3 2005/01/31 04:34:47 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
Index: openafs/src/xstat/xstat_fs_test.c
diff -c openafs/src/xstat/xstat_fs_test.c:1.8 openafs/src/xstat/xstat_fs_test.c:1.8.2.1
*** openafs/src/xstat/xstat_fs_test.c:1.8	Tue Jul 15 19:17:52 2003
--- openafs/src/xstat/xstat_fs_test.c	Sun Jan 30 23:14:51 2005
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/xstat/xstat_fs_test.c,v 1.8 2003/07/15 23:17:52 shadow Exp $");
  
  #include "xstat_fs.h"		/*Interface for xstat_fs module */
  #include <cmd.h>		/*Command line interpreter */
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/xstat/xstat_fs_test.c,v 1.8.2.1 2005/01/31 04:14:51 shadow Exp $");
  
  #include "xstat_fs.h"		/*Interface for xstat_fs module */
  #include <cmd.h>		/*Command line interpreter */
***************
*** 246,253 ****
      printf("\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
      printf("\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
      printf("\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
!     printf("\t%10d rx_nFreeCallStructs\n\n", a_ovP->rx_nFreeCallStructs);
  
      /*
       * Host module fields.
       */
--- 246,255 ----
      printf("\t%10d rx_nClientConns\n", a_ovP->rx_nClientConns);
      printf("\t%10d rx_nPeerStructs\n", a_ovP->rx_nPeerStructs);
      printf("\t%10d rx_nCallStructs\n", a_ovP->rx_nCallStructs);
!     printf("\t%10d rx_nFreeCallStructs\n", a_ovP->rx_nFreeCallStructs);
!     printf("\t%10d rx_nBusies\n\n", a_ovP->rx_nBusies);
  
+     printf("\t%10d fs_nBusies\n\n", a_ovP->fs_nBusies);
      /*
       * Host module fields.
       */
