Index: openafs/src/WINNT/afsapplib/NTMakefile
diff -c openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.1 openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.3
*** openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.1	Fri Nov  5 14:21:40 2004
--- openafs/src/WINNT/afsapplib/NTMakefile	Tue Dec  7 01:00:54 2004
***************
*** 127,133 ****
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
  	$(CD) ..
  
  
--- 127,133 ----
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do ( if exist @$(NTLANG) do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean )
  	$(CD) ..
  
  
Index: openafs/src/WINNT/afsd/NTMakefile
diff -c openafs/src/WINNT/afsd/NTMakefile:1.27.2.2 openafs/src/WINNT/afsd/NTMakefile:1.27.2.6
*** openafs/src/WINNT/afsd/NTMakefile:1.27.2.2	Fri Nov  5 14:21:42 2004
--- openafs/src/WINNT/afsd/NTMakefile	Tue Dec  7 01:02:22 2004
***************
*** 337,345 ****
  AFSD_EXEFILE = $(EXEDIR)\afsd.exe
  
  AFSD_SDKLIBS =\
- 	largeint.lib \
  	netapi32.lib \
!         dnsapi.lib mpr.lib \
  	rpcrt4.lib \
  	user32.lib \
          Dbghelp.lib \
--- 337,345 ----
  AFSD_EXEFILE = $(EXEDIR)\afsd.exe
  
  AFSD_SDKLIBS =\
  	netapi32.lib \
!         dnsapi.lib \
!         mpr.lib \
  	rpcrt4.lib \
  	user32.lib \
          Dbghelp.lib \
***************
*** 366,372 ****
  
  # afsd_service.exe
  $(EXEDIR)\afsd_service.exe: $(OUT)\afsd_service.obj $(AFSDOBJS) $(OUT)\afsd_service.res  $(RXOBJS) $(AFSD_EXELIBS)
! 	$(EXECONLINK) $(AFSD_SDKLIBS) /MAP 
  	$(EXEPREP)
  
  # fs.exe
--- 366,372 ----
  
  # afsd_service.exe
  $(EXEDIR)\afsd_service.exe: $(OUT)\afsd_service.obj $(AFSDOBJS) $(OUT)\afsd_service.res  $(RXOBJS) $(AFSD_EXELIBS)
! 	$(EXECONLINK) $(AFSD_SDKLIBS) /MAP /LARGEADDRESSAWARE
  	$(EXEPREP)
  
  # fs.exe
Index: openafs/src/WINNT/afsd/afsd.h
diff -c openafs/src/WINNT/afsd/afsd.h:1.5 openafs/src/WINNT/afsd/afsd.h:1.5.2.1
*** openafs/src/WINNT/afsd/afsd.h:1.5	Tue Jul 20 10:36:41 2004
--- openafs/src/WINNT/afsd/afsd.h	Tue Dec  7 01:01:41 2004
***************
*** 62,67 ****
--- 62,68 ----
  #include "cm_buf.h"
  #include "cm_freelance.h"
  #include "smb_ioctl.h"
+ #include "afsd_init.h"
  #ifdef DJGPP
  #include "afs/afsmsg95.h"
  #endif
Index: openafs/src/WINNT/afsd/afsd_init.c
diff -c openafs/src/WINNT/afsd/afsd_init.c:1.40.2.6 openafs/src/WINNT/afsd/afsd_init.c:1.40.2.11
*** openafs/src/WINNT/afsd/afsd_init.c:1.40.2.6	Fri Nov  5 14:21:42 2004
--- openafs/src/WINNT/afsd/afsd_init.c	Tue Dec  7 07:49:22 2004
***************
*** 16,21 ****
--- 16,23 ----
  #include <nb30.h>
  #include <stdio.h>
  #include <stdlib.h>
+ #include <locale.h>
+ #include <mbctype.h>
  #include <winsock2.h>
  
  #include <osi.h>
***************
*** 37,42 ****
--- 39,46 ----
  
  char AFSConfigKeyName[] =
  	"SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters";
+ char OpenAFSConfigKeyName[] =
+ 	"SOFTWARE\\OpenAFS\\Client";
  
  osi_log_t *afsd_logp;
  
***************
*** 99,123 ****
  int cm_dnsEnabled = 1;
  #endif
  
  extern initUpperCaseTable();
  void afsd_initUpperCaseTable() 
  {
! 	initUpperCaseTable();
  }
  
  void
  afsi_start()
  {
! 	char wd[100];
! 	char t[100], u[100], *p, *path;
! 	int zilch;
! 	int code;
      DWORD dwLow, dwHigh;
! 	HKEY parmKey;
! 	DWORD dummyLen;
      DWORD maxLogSize = 100 * 1024;
  
! 	afsi_file = INVALID_HANDLE_VALUE;
      if (getenv("TEMP"))
      {
          StringCbCopyA(wd, sizeof(wd), getenv("TEMP"));
--- 103,154 ----
  int cm_dnsEnabled = 1;
  #endif
  
+ 
+ static int afsi_log_useTimestamp = 1;
+ 
+ void
+ afsi_log(char *pattern, ...)
+ {
+     char s[256], t[100], d[100], u[512];
+     DWORD zilch;
+     va_list ap;
+     va_start(ap, pattern);
+ 
+     StringCbVPrintfA(s, sizeof(s), pattern, ap);
+     if ( afsi_log_useTimestamp ) {
+         GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
+         GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, d, sizeof(d));
+         StringCbPrintfA(u, sizeof(u), "%s %s: %s\n", d, t, s);
+         if (afsi_file != INVALID_HANDLE_VALUE)
+             WriteFile(afsi_file, u, strlen(u), &zilch, NULL);
+ #ifdef NOTSERVICE
+         printf("%s", u);
+ #endif 
+     } else {
+         if (afsi_file != INVALID_HANDLE_VALUE)
+             WriteFile(afsi_file, s, strlen(s), &zilch, NULL);
+     }
+ }
+ 
  extern initUpperCaseTable();
  void afsd_initUpperCaseTable() 
  {
!     initUpperCaseTable();
  }
  
  void
  afsi_start()
  {
!     char wd[100];
!     char t[100], u[100], *p, *path;
!     int zilch;
!     int code;
      DWORD dwLow, dwHigh;
!     HKEY parmKey;
!     DWORD dummyLen;
      DWORD maxLogSize = 100 * 1024;
  
!     afsi_file = INVALID_HANDLE_VALUE;
      if (getenv("TEMP"))
      {
          StringCbCopyA(wd, sizeof(wd), getenv("TEMP"));
***************
*** 125,145 ****
      else
      {
          code = GetWindowsDirectory(wd, sizeof(wd));
!         if (code == 0) return;
      }
! 	StringCbCatA(wd, sizeof(wd), "\\afsd_init.log");
! 	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
! 	afsi_file = CreateFile(wd, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                             OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
  
      code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
                           0, KEY_QUERY_VALUE, &parmKey);
! 	if (code == ERROR_SUCCESS) {
          dummyLen = sizeof(maxLogSize);
          code = RegQueryValueEx(parmKey, "MaxLogSize", NULL, NULL,
                                  (BYTE *) &maxLogSize, &dummyLen);
          RegCloseKey (parmKey);
! 	}
  
      if (maxLogSize) {
          dwLow = GetFileSize( afsi_file, &dwHigh );
--- 156,177 ----
      else
      {
          code = GetWindowsDirectory(wd, sizeof(wd));
!         if (code == 0) 
!             return;
      }
!     StringCbCatA(wd, sizeof(wd), "\\afsd_init.log");
!     GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
!     afsi_file = CreateFile(wd, GENERIC_WRITE, FILE_SHARE_READ, NULL,
                             OPEN_ALWAYS, FILE_FLAG_WRITE_THROUGH, NULL);
  
      code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName,
                           0, KEY_QUERY_VALUE, &parmKey);
!     if (code == ERROR_SUCCESS) {
          dummyLen = sizeof(maxLogSize);
          code = RegQueryValueEx(parmKey, "MaxLogSize", NULL, NULL,
                                  (BYTE *) &maxLogSize, &dummyLen);
          RegCloseKey (parmKey);
!     }
  
      if (maxLogSize) {
          dwLow = GetFileSize( afsi_file, &dwHigh );
***************
*** 151,192 ****
      }
  
      SetFilePointer(afsi_file, 0, NULL, FILE_END);
! 	GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, u, sizeof(u));
! 	StringCbCatA(t, sizeof(t), ": Create log file\n");
! 	StringCbCatA(u, sizeof(u), ": Created log file\n");
! 	WriteFile(afsi_file, t, strlen(t), &zilch, NULL);
! 	WriteFile(afsi_file, u, strlen(u), &zilch, NULL);
      p = "PATH=";
      path = getenv("PATH");
! 	WriteFile(afsi_file, p, strlen(p), &zilch, NULL);
! 	WriteFile(afsi_file, path, strlen(path), &zilch, NULL);
! 	WriteFile(afsi_file, "\n", 1, &zilch, NULL);
! }
! 
! static int afsi_log_useTimestamp = 1;
! 
! void
! afsi_log(char *pattern, ...)
! {
! 	char s[256], t[100], d[100], u[512];
! 	int zilch;
! 	va_list ap;
! 	va_start(ap, pattern);
! 
! 	StringCbVPrintfA(s, sizeof(s), pattern, ap);
!     if ( afsi_log_useTimestamp ) {
!         GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, t, sizeof(t));
! 		GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, d, sizeof(d));
! 		StringCbPrintfA(u, sizeof(u), "%s %s: %s\n", d, t, s);
!         if (afsi_file != INVALID_HANDLE_VALUE)
!             WriteFile(afsi_file, u, strlen(u), &zilch, NULL);
! #ifdef NOTSERVICE
!         printf("%s", u);
! #endif 
!     } else {
!         if (afsi_file != INVALID_HANDLE_VALUE)
!             WriteFile(afsi_file, s, strlen(s), &zilch, NULL);
!     }
  }
  
  /*
--- 183,212 ----
      }
  
      SetFilePointer(afsi_file, 0, NULL, FILE_END);
!     GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, u, sizeof(u));
!     StringCbCatA(t, sizeof(t), ": Create log file\n");
!     StringCbCatA(u, sizeof(u), ": Created log file\n");
!     WriteFile(afsi_file, t, strlen(t), &zilch, NULL);
!     WriteFile(afsi_file, u, strlen(u), &zilch, NULL);
      p = "PATH=";
      path = getenv("PATH");
!     WriteFile(afsi_file, p, strlen(p), &zilch, NULL);
!     WriteFile(afsi_file, path, strlen(path), &zilch, NULL);
!     WriteFile(afsi_file, "\n", 1, &zilch, NULL);
! 
!     /* Initialize C RTL Code Page conversion functions */
!     /* All of the path info obtained from the SMB client is in the OEM code page */
!     afsi_log("OEM Code Page = %d", GetOEMCP());
!     afsi_log("locale =  %s", setlocale(LC_ALL,NULL));
! #ifdef COMMENT
!     /* Two things to look into.  First, should mbstowcs() be performing 
!      * character set translations from OEM to Unicode in smb3.c; 
!      * Second, do we need to set this translation in each function 
!      * due to multi-threading. 
!      */
!     afsi_log("locale -> %s", setlocale(LC_ALL, ".OCP"));
!     afsi_log("_setmbcp = %d -> %d", _setmbcp(_MB_CP_OEM), _getmbcp());
! #endif /* COMMENT */
  }
  
  /*
***************
*** 195,219 ****
  
  void afsd_ForceTrace(BOOL flush)
  {
! 	HANDLE handle;
! 	int len;
! 	char buf[256];
  
! 	if (!logReady) 
          return;
  
! 	len = GetTempPath(sizeof(buf)-10, buf);
! 	StringCbCopyA(&buf[len], sizeof(buf)-len, "/afsd.log");
! 	handle = CreateFile(buf, GENERIC_WRITE, FILE_SHARE_READ,
! 			    NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
! 	if (handle == INVALID_HANDLE_VALUE) {
! 		logReady = 0;
! 		osi_panic("Cannot create log file", __FILE__, __LINE__);
! 	}
! 	osi_LogPrint(afsd_logp, handle);
! 	if (flush)
! 		FlushFileBuffers(handle);
! 	CloseHandle(handle);
  }
  
  static void
--- 215,239 ----
  
  void afsd_ForceTrace(BOOL flush)
  {
!     HANDLE handle;
!     int len;
!     char buf[256];
  
!     if (!logReady) 
          return;
  
!     len = GetTempPath(sizeof(buf)-10, buf);
!     StringCbCopyA(&buf[len], sizeof(buf)-len, "/afsd.log");
!     handle = CreateFile(buf, GENERIC_WRITE, FILE_SHARE_READ,
!                          NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
!     if (handle == INVALID_HANDLE_VALUE) {
!         logReady = 0;
!         osi_panic("Cannot create log file", __FILE__, __LINE__);
!     }
!     osi_LogPrint(afsd_logp, handle);
!     if (flush)
!         FlushFileBuffers(handle);
!     CloseHandle(handle);
  }
  
  static void
***************
*** 250,256 ****
      DWORD dwType;
      DWORD dwSize;
      DWORD dwValue;
!     PBYTE pHostNames = NULL, pName;
      BOOL  bNameFound = FALSE;   
  
      if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
--- 270,276 ----
      DWORD dwType;
      DWORD dwSize;
      DWORD dwValue;
!     PBYTE pHostNames = NULL, pName = NULL;
      BOOL  bNameFound = FALSE;   
  
      if ( RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
***************
*** 273,284 ****
          }
               
          if ( !bNameFound ) {
              if ( !pHostNames ) {
!                 pName = pHostNames = malloc(strlen(cm_NetbiosName) + 2);
                  dwSize = 1;
              }
!             strcpy(pName, cm_NetbiosName);
!             pName += strlen(cm_NetbiosName) + 1;
              *pName = '\0';  /* add a second nul terminator */
  
              dwType = REG_MULTI_SZ;
--- 293,306 ----
          }
               
          if ( !bNameFound ) {
+             int size = strlen(cm_NetbiosName) + 2;
              if ( !pHostNames ) {
!                 pHostNames = malloc(size);
                  dwSize = 1;
              }
!             pName = pHostNames;
!             StringCbCopyA(pName, size, cm_NetbiosName);
!             pName += size - 1;
              *pName = '\0';  /* add a second nul terminator */
  
              dwType = REG_MULTI_SZ;
***************
*** 971,982 ****
  
  int afsd_InitDaemons(char **reasonP)
  {
! 	long code;
! 	cm_req_t req;
  
! 	cm_InitReq(&req);
  
! 	/* this should really be in an init daemon from here on down */
  
      if (!cm_freelanceEnabled) {
  		osi_Log0(afsd_logp, "Loading Root Volume from cell");
--- 993,1004 ----
  
  int afsd_InitDaemons(char **reasonP)
  {
!     long code;
!     cm_req_t req;
  
!     cm_InitReq(&req);
  
!     /* this should really be in an init daemon from here on down */
  
      if (!cm_freelanceEnabled) {
  		osi_Log0(afsd_logp, "Loading Root Volume from cell");
***************
*** 990,1028 ****
          }
      }
  
! 	/* compute the root fid */
! 	if (!cm_freelanceEnabled) {
          cm_rootFid.cell = cm_rootCellp->cellID;
          cm_rootFid.volume = cm_GetROVolumeID(cm_rootVolumep);
          cm_rootFid.vnode = 1;
          cm_rootFid.unique = 1;
! 	}
! 	else
          cm_FakeRootFid(&cm_rootFid);
          
      code = cm_GetSCache(&cm_rootFid, &cm_rootSCachep, cm_rootUserp, &req);
! 	afsi_log("cm_GetSCache code %x scache %x", code,
               (code ? (cm_scache_t *)-1 : cm_rootSCachep));
! 	if (code != 0) {
! 		*reasonP = "unknown error";
! 		return -1;
! 	}
  
! 	cm_InitDaemon(numBkgD);
! 	afsi_log("cm_InitDaemon");
  
! 	return 0;
  }
  
  int afsd_InitSMB(char **reasonP, void *aMBfunc)
  {
! 	/* Do this last so that we don't handle requests before init is done.
       * Here we initialize the SMB listener.
       */
      smb_Init(afsd_logp, cm_NetbiosName, smb_UseV3, LANadapter, numSvThreads, aMBfunc);
!     afsi_log("smb_Init");
  
! 	return 0;
  }
  
  #ifdef ReadOnly
--- 1012,1066 ----
          }
      }
  
!     /* compute the root fid */
!     if (!cm_freelanceEnabled) {
          cm_rootFid.cell = cm_rootCellp->cellID;
          cm_rootFid.volume = cm_GetROVolumeID(cm_rootVolumep);
          cm_rootFid.vnode = 1;
          cm_rootFid.unique = 1;
!     }
!     else
          cm_FakeRootFid(&cm_rootFid);
          
      code = cm_GetSCache(&cm_rootFid, &cm_rootSCachep, cm_rootUserp, &req);
!     afsi_log("cm_GetSCache code %x scache %x", code,
               (code ? (cm_scache_t *)-1 : cm_rootSCachep));
!     if (code != 0) {
!         *reasonP = "unknown error";
!         return -1;
!     }
  
!     cm_InitDaemon(numBkgD);
!     afsi_log("cm_InitDaemon");
  
!     return 0;
  }
  
  int afsd_InitSMB(char **reasonP, void *aMBfunc)
  {
!     HKEY parmKey;
!     DWORD dummyLen;
!     DWORD dwValue;
!     DWORD code;
! 
!     code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, OpenAFSConfigKeyName,
!                          0, KEY_QUERY_VALUE, &parmKey);
!     if (code == ERROR_SUCCESS) {
!         dummyLen = sizeof(DWORD);
!         code = RegQueryValueEx(parmKey, "StoreAnsiFilenames", NULL, NULL,
!                                 (BYTE *) &dwValue, &dummyLen);
!         if (code == ERROR_SUCCESS)
!             smb_StoreAnsiFilenames = dwValue ? 1 : 0;
!         RegCloseKey (parmKey);
!     }
! 
!     /* Do this last so that we don't handle requests before init is done.
       * Here we initialize the SMB listener.
       */
      smb_Init(afsd_logp, cm_NetbiosName, smb_UseV3, LANadapter, numSvThreads, aMBfunc);
!     afsi_log("smb_Init complete");
  
!     return 0;
  }
  
  #ifdef ReadOnly
Index: openafs/src/WINNT/afsd/afsd_service.c
diff -c openafs/src/WINNT/afsd/afsd_service.c:1.28.2.3 openafs/src/WINNT/afsd/afsd_service.c:1.28.2.8
*** openafs/src/WINNT/afsd/afsd_service.c:1.28.2.3	Fri Nov  5 14:21:42 2004
--- openafs/src/WINNT/afsd/afsd_service.c	Tue Dec  7 01:02:46 2004
***************
*** 11,16 ****
--- 11,19 ----
  #include <afs/stds.h>
  
  #include <windows.h>
+ #include <softpub.h>
+ #include <psapi.h>
+ #include <winerror.h>
  #include <string.h>
  #include <setjmp.h>
  #include "afsd.h"
***************
*** 41,46 ****
--- 44,52 ----
  
  extern void afsi_log(char *pattern, ...);
  
+ static SERVICE_STATUS		ServiceStatus;
+ static SERVICE_STATUS_HANDLE	StatusHandle;
+ 
  HANDLE hAFSDMainThread = NULL;
  
  HANDLE WaitToTerminate;
***************
*** 93,108 ****
      smb_DumpVCP(afsi_file, "a");			
      afsi_log("--- end   dump ---");
      
      DebugBreak();	
  
      SetEvent(WaitToTerminate);
  
  #ifdef JUMP
      if (GetCurrentThreadId() == MainThreadId)
          longjmp(notifier_jmp, 1);
-     else
  #endif /* JUMP */
!         ExitThread(1);
  }
  
  /*
--- 99,123 ----
      smb_DumpVCP(afsi_file, "a");			
      afsi_log("--- end   dump ---");
      
+ #ifdef DEBUG
      DebugBreak();	
+ #endif
  
      SetEvent(WaitToTerminate);
  
  #ifdef JUMP
      if (GetCurrentThreadId() == MainThreadId)
          longjmp(notifier_jmp, 1);
  #endif /* JUMP */
! 
!     ServiceStatus.dwCurrentState = SERVICE_STOPPED;
!     ServiceStatus.dwWin32ExitCode = NO_ERROR;
!     ServiceStatus.dwCheckPoint = 0;
!     ServiceStatus.dwWaitHint = 0;
!     ServiceStatus.dwControlsAccepted = 0;
!     SetServiceStatus(StatusHandle, &ServiceStatus);
! 
!     exit(1);
  }
  
  /*
***************
*** 113,121 ****
      return 0;
  }
  
- static SERVICE_STATUS		ServiceStatus;
- static SERVICE_STATUS_HANDLE	StatusHandle;
- 
  DWORD
  afsd_ServiceFlushVolume(DWORD dwlpEventData)
  {
--- 128,133 ----
***************
*** 421,426 ****
--- 433,957 ----
      RegCloseKey(hKey);
  }
  
+ DWORD
+ GetVersionInfo( CHAR * filename, CHAR * szOutput, DWORD dwOutput )
+ {
+     DWORD dwVersionHandle;
+     LPVOID pVersionInfo = 0;
+     DWORD retval = 0;
+     LPDWORD pLangInfo = 0;
+     LPTSTR szVersion = 0;
+     UINT len = 0;
+     TCHAR szVerQ[] = TEXT("\\StringFileInfo\\12345678\\FileVersion");
+     DWORD size = GetFileVersionInfoSize(filename, &dwVersionHandle);
+ 
+     if (!size) {
+         afsi_log("GetFileVersionInfoSize failed");
+         return GetLastError();
+     }
+ 
+     pVersionInfo = malloc(size);
+     if (!pVersionInfo) {
+         afsi_log("out of memory 1");
+         return ERROR_NOT_ENOUGH_MEMORY;
+     }
+ 
+     GetFileVersionInfo(filename, dwVersionHandle, size, pVersionInfo);
+     if (retval = GetLastError())
+     {
+         afsi_log("GetFileVersionInfo failed: %d", retval);
+         goto cleanup;
+     }
+ 
+     VerQueryValue(pVersionInfo, TEXT("\\VarFileInfo\\Translation"),
+                        (LPVOID*)&pLangInfo, &len);
+     if (retval = GetLastError())
+     {
+         afsi_log("VerQueryValue 1 failed: %d", retval);
+         goto cleanup;
+     }
+ 
+     wsprintf(szVerQ,
+              TEXT("\\StringFileInfo\\%04x%04x\\FileVersion"),
+              LOWORD(*pLangInfo), HIWORD(*pLangInfo));
+ 
+     VerQueryValue(pVersionInfo, szVerQ, (LPVOID*)&szVersion, &len);
+     if (retval = GetLastError())
+     {
+         /* try again with language 409 since the old binaries were tagged wrong */
+         wsprintf(szVerQ,
+                   TEXT("\\StringFileInfo\\0409%04x\\FileVersion"),
+                   HIWORD(*pLangInfo));
+ 
+         VerQueryValue(pVersionInfo, szVerQ, (LPVOID*)&szVersion, &len);
+         if (retval = GetLastError()) {
+             afsi_log("VerQueryValue 2 failed: [%s] %d", szVerQ, retval);
+             goto cleanup;
+         }
+     }
+     snprintf(szOutput, dwOutput, TEXT("%s"), szVersion);
+     szOutput[dwOutput - 1] = 0;
+ 
+  cleanup:
+     if (pVersionInfo)
+         free(pVersionInfo);
+ 
+     return retval;
+ }
+ 
+ static HINSTANCE hCrypt32;
+ static DWORD (WINAPI *pCertGetNameString)(PCCERT_CONTEXT pCertContext,  DWORD dwType,  DWORD dwFlags,
+                                           void* pvTypePara, LPTSTR pszNameString, DWORD cchNameString);
+ static BOOL (WINAPI *pCryptQueryObject)(DWORD dwObjectType, const void* pvObject, DWORD dwExpectedContentTypeFlags,
+                                         DWORD dwExpectedFormatTypeFlags, DWORD dwFlags,
+                                         DWORD* pdwMsgAndCertEncodingType, DWORD* pdwContentType,
+                                         DWORD* pdwFormatType, HCERTSTORE* phCertStore,
+                                         HCRYPTMSG* phMsg, const void** ppvContext);
+ static BOOL (WINAPI *pCryptMsgGetParam)(HCRYPTMSG hCryptMsg, DWORD dwParamType, DWORD dwIndex,
+                                         void* pvData, DWORD* pcbData);
+ static PCCERT_CONTEXT (WINAPI *pCertFindCertificateInStore)(HCERTSTORE hCertStore, DWORD dwCertEncodingType,
+                                                             DWORD dwFindFlags, DWORD dwFindType,
+                                                             const void* pvFindPara,
+                                                             PCCERT_CONTEXT pPrevCertContext);
+ static BOOL (WINAPI *pCertCloseStore)(HCERTSTORE hCertStore, DWORD dwFlags);
+ static BOOL (WINAPI *pCryptMsgClose)(HCRYPTMSG hCryptMsg);
+ static BOOL (WINAPI *pCertCompareCertificate)(DWORD dwCertEncodingType, PCERT_INFO pCertId1,
+                                               PCERT_INFO pCertId2);
+ static BOOL (WINAPI *pCertFreeCertificateContext)(PCCERT_CONTEXT pCertContext);
+ 
+ void LoadCrypt32(void)
+ {
+     hCrypt32 = LoadLibrary("crypt32");
+     if ( !hCrypt32 )
+         return;
+ 
+     (FARPROC) pCertGetNameString = GetProcAddress( hCrypt32, "CertGetNameString" );
+     (FARPROC) pCryptQueryObject = GetProcAddress( hCrypt32, "CryptQueryObject" );
+     (FARPROC) pCryptMsgGetParam = GetProcAddress( hCrypt32, "CryptMsgGetParam" );
+     (FARPROC) pCertFindCertificateInStore = GetProcAddress( hCrypt32, "CertFindCertificateInStore" );
+     (FARPROC) pCertCloseStore = GetProcAddress( hCrypt32, "CertCloseStore" );
+     (FARPROC) pCryptMsgClose = GetProcAddress( hCrypt32, "CryptMsgClose" );
+     (FARPROC) pCertCompareCertificate = GetProcAddress( hCrypt32, "CertCompareCertificate" );
+     (FARPROC) pCertFreeCertificateContext = GetProcAddress( hCrypt32, "CertFreeCertificateContext" );
+     
+     if ( !pCertGetNameString ||
+          !pCryptQueryObject ||
+          !pCryptMsgGetParam ||
+          !pCertFindCertificateInStore ||
+          !pCertCloseStore ||
+          !pCryptMsgClose ||
+          !pCertCompareCertificate ||
+          !pCertFreeCertificateContext)
+     {
+         FreeLibrary(hCrypt32);
+         hCrypt32 = NULL;
+     }
+ }
+ 
+ void UnloadCrypt32(void)
+ {
+     FreeLibrary(hCrypt32);
+ }
+ 
+ #define ENCODING (X509_ASN_ENCODING | PKCS_7_ASN_ENCODING)
+ 
+ PCCERT_CONTEXT GetCertCtx(CHAR * filename)
+ {
+     wchar_t wfilename[260];
+     BOOL fResult;
+     DWORD dwEncoding;
+     DWORD dwContentType;
+     DWORD dwFormatType;
+     DWORD dwSignerInfo;
+     HCERTSTORE hStore = NULL;
+     HCRYPTMSG hMsg = NULL;
+     PCMSG_SIGNER_INFO pSignerInfo = NULL;
+     PCCERT_CONTEXT pCertContext = NULL;
+     CERT_INFO CertInfo;
+ 
+     if ( hCrypt32 == NULL )
+         return NULL;
+ 
+     ZeroMemory(&CertInfo, sizeof(CertInfo));
+     mbstowcs(wfilename, filename, 260);
+ 
+     fResult = pCryptQueryObject(CERT_QUERY_OBJECT_FILE,
+ 			        wfilename,
+ 			        CERT_QUERY_CONTENT_FLAG_PKCS7_SIGNED_EMBED,
+ 			        CERT_QUERY_FORMAT_FLAG_BINARY,
+ 			        0,
+ 			        &dwEncoding,
+ 			        &dwContentType,
+ 			        &dwFormatType,
+ 			        &hStore,
+ 			        &hMsg,
+ 			        NULL);
+ 
+     if (!fResult) {
+         afsi_log("CryptQueryObject failed for [%s] with error 0x%x",
+ 		 filename,
+ 		 GetLastError());
+ 	goto __exit;
+     }
+ 
+     fResult = pCryptMsgGetParam(hMsg,
+ 			        CMSG_SIGNER_INFO_PARAM,
+ 			        0,
+ 			        NULL,
+ 			        &dwSignerInfo);
+ 
+     if (!fResult) {
+         afsi_log("CryptMsgGetParam failed for [%s] with error 0x%x",
+ 		 filename,
+ 		 GetLastError());
+ 	goto __exit;
+     }
+ 
+     pSignerInfo = (PCMSG_SIGNER_INFO)LocalAlloc(LPTR, dwSignerInfo);
+ 
+     fResult = pCryptMsgGetParam(hMsg,
+ 			        CMSG_SIGNER_INFO_PARAM,
+ 			        0,
+ 			        (PVOID)pSignerInfo,
+ 			        &dwSignerInfo);
+     
+     if (!fResult) {
+         afsi_log("CryptMsgGetParam failed for [%s] with error 0x%x",
+ 		 filename,
+ 		 GetLastError());
+ 	goto __exit;
+     }
+ 
+     CertInfo.Issuer = pSignerInfo->Issuer;
+     CertInfo.SerialNumber = pSignerInfo->SerialNumber;
+ 
+     pCertContext = pCertFindCertificateInStore(hStore,
+ 					      ENCODING,
+ 					      0,
+ 					      CERT_FIND_SUBJECT_CERT,
+ 					      (PVOID) &CertInfo,
+ 					      NULL);
+ 
+     if (!pCertContext) {
+       afsi_log("CertFindCertificateInStore for file [%s] failed with 0x%x",
+ 	       filename,
+ 	       GetLastError());
+       goto __exit;
+     }
+ 
+   __exit:
+     if (pSignerInfo)
+       LocalFree(pSignerInfo);
+ 
+     /*    if (pCertContext)
+ 	  CertFreeCertificateContext(pCertContext);*/
+ 
+     if (hStore)
+       pCertCloseStore(hStore,0);
+ 
+     if (hMsg)
+       pCryptMsgClose(hMsg);
+ 
+     return pCertContext;
+ }
+ 
+ BOOL VerifyTrust(CHAR * filename)
+ {
+     WIN_TRUST_ACTDATA_CONTEXT_WITH_SUBJECT fContextWSubject;
+     WIN_TRUST_SUBJECT_FILE fSubjectFile;
+     GUID trustAction = WIN_SPUB_ACTION_PUBLISHED_SOFTWARE;
+     GUID subject = WIN_TRUST_SUBJTYPE_PE_IMAGE;
+     wchar_t wfilename[260];
+     LONG ret;
+     BOOL success = FALSE;
+ 
+     LONG (WINAPI *pWinVerifyTrust)(HWND hWnd, GUID* pgActionID, WINTRUST_DATA* pWinTrustData) = NULL;
+     HINSTANCE hWinTrust;
+ 
+     if (filename == NULL ) 
+         return FALSE;
+ 
+     hWinTrust = LoadLibrary("wintrust");
+     if ( !hWinTrust )
+         return FALSE;
+ 
+     if (((FARPROC) pWinVerifyTrust =
+           GetProcAddress( hWinTrust, "WinVerifyTrust" )) == NULL )
+     {
+         FreeLibrary(hWinTrust);
+         return FALSE;
+     }
+ 
+     mbstowcs(wfilename, filename, 260);
+ 
+     fSubjectFile.hFile = CreateFile(filename, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING,
+                                     0, NULL);
+     fSubjectFile.lpPath = wfilename;
+     fContextWSubject.hClientToken = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+                                                 FALSE, GetCurrentProcessId());
+     fContextWSubject.SubjectType = &subject;
+     fContextWSubject.Subject = &fSubjectFile;
+ 
+     ret = pWinVerifyTrust(INVALID_HANDLE_VALUE, &trustAction, (WINTRUST_DATA *)&fContextWSubject);
+ 
+     if ( fSubjectFile.hFile != INVALID_HANDLE_VALUE )
+         CloseHandle( fSubjectFile.hFile );
+     if ( fContextWSubject.hClientToken != INVALID_HANDLE_VALUE )
+         CloseHandle( fContextWSubject.hClientToken );
+ 
+     if (ret == ERROR_SUCCESS) {
+         success = TRUE;
+     } else {
+         DWORD gle = GetLastError();
+         switch (gle) {
+         case TRUST_E_PROVIDER_UNKNOWN:
+             afsi_log("VerifyTrust failed: \"Generic Verify V2\" Provider Unknown");
+             break;  
+         case TRUST_E_NOSIGNATURE:
+             afsi_log("VerifyTrust failed: Unsigned executable");
+             break;
+         case TRUST_E_EXPLICIT_DISTRUST:
+             afsi_log("VerifyTrust failed: Certificate Marked as Untrusted by the user");
+             break;
+         case TRUST_E_SUBJECT_NOT_TRUSTED:
+             afsi_log("VerifyTrust failed: File is not trusted");
+             break;
+         case TRUST_E_BAD_DIGEST:
+             afsi_log("VerifyTrust failed: Executable has been modified");
+             break;
+         case CRYPT_E_SECURITY_SETTINGS:
+             afsi_log("VerifyTrust failed: local security options prevent verification");
+             break;
+         default:
+             afsi_log("VerifyTrust failed: 0x%X", GetLastError());
+         }
+         success = FALSE;
+     }
+     FreeLibrary(hWinTrust);
+     return success;
+ }
+ 
+ void LogCertCtx(PCCERT_CONTEXT pCtx) {
+     DWORD dwData;
+     LPTSTR szName = NULL;
+ 
+     if ( hCrypt32 == NULL )
+         return;
+ 
+     // Get Issuer name size.
+     if (!(dwData = pCertGetNameString(pCtx,
+ 		     		      CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 				      CERT_NAME_ISSUER_FLAG,
+ 				      NULL,
+ 				      NULL,
+ 				      0))) {
+         afsi_log("CertGetNameString failed: 0x%x", GetLastError());
+ 	goto __exit;
+     }
+ 
+     // Allocate memory for Issuer name.
+     szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(TCHAR));
+ 
+     // Get Issuer name.
+     if (!(pCertGetNameString(pCtx,
+ 			     CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 			     CERT_NAME_ISSUER_FLAG,
+ 			     NULL,
+ 			     szName,
+ 			     dwData))) {
+         afsi_log("CertGetNameString failed: 0x%x", GetLastError());
+ 	goto __exit;
+     }
+ 
+     // print Issuer name.
+     afsi_log("Issuer Name: %s", szName);
+     LocalFree(szName);
+     szName = NULL;
+ 
+     // Get Subject name size.
+     if (!(dwData = pCertGetNameString(pCtx,
+ 				      CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 				      0,
+ 				      NULL,
+ 				      NULL,
+ 				      0))) {
+         afsi_log("CertGetNameString failed: 0x%x", GetLastError());
+ 	goto __exit;
+     }
+ 
+     // Allocate memory for subject name.
+     szName = (LPTSTR)LocalAlloc(LPTR, dwData * sizeof(TCHAR));
+ 
+     // Get subject name.
+     if (!(pCertGetNameString(pCtx,
+ 			     CERT_NAME_SIMPLE_DISPLAY_TYPE,
+ 			     0,
+ 			     NULL,
+ 			     szName,
+ 			     dwData))) {
+         afsi_log("CertGetNameString failed: 0x%x", GetLastError());
+ 	goto __exit;
+     }
+ 
+     // Print Subject Name.
+     afsi_log("Subject Name: %s", szName);
+ 
+   __exit:
+ 
+     if (szName)
+         LocalFree(szName);
+ }
+ 
+ BOOL AFSModulesVerify(void)
+ {
+     CHAR filename[1024];
+     CHAR afsdVersion[128];
+     CHAR modVersion[128];
+     CHAR checkName[1024];
+     BOOL trustVerified = FALSE;
+     HMODULE hMods[1024];
+     HANDLE hProcess;
+     DWORD cbNeeded;
+     unsigned int i;
+     BOOL success = TRUE;
+     PCCERT_CONTEXT pCtxService = NULL;
+     HINSTANCE hPSAPI;
+     DWORD (WINAPI *pGetModuleFileNameExA)(HANDLE hProcess, HMODULE hModule, LPTSTR lpFilename, DWORD nSize);
+     BOOL (WINAPI *pEnumProcessModules)(HANDLE hProcess, HMODULE* lphModule, DWORD cb, LPDWORD lpcbNeeded);
+     DWORD dummyLen, code;
+     DWORD cacheSize = CM_CONFIGDEFAULT_CACHESIZE;
+     DWORD verifyServiceSig = TRUE;
+     HKEY parmKey;
+ 
+     hPSAPI = LoadLibrary("psapi");
+ 
+     if ( hPSAPI == NULL )
+         return FALSE;
+ 
+     if (!GetModuleFileName(NULL, filename, sizeof(filename)))
+         return FALSE;
+ 
+     if (GetVersionInfo(filename, afsdVersion, sizeof(afsdVersion)))
+         return FALSE;
+ 
+     afsi_log("%s version %s", filename, afsdVersion);
+ 
+     if (((FARPROC) pGetModuleFileNameExA =
+           GetProcAddress( hPSAPI, "GetModuleFileNameExA" )) == NULL ||
+          ((FARPROC) pEnumProcessModules =
+            GetProcAddress( hPSAPI, "EnumProcessModules" )) == NULL)
+     {
+         FreeLibrary(hPSAPI);
+         return FALSE;
+     }
+ 
+ 
+     code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, 
+                         "SYSTEM\\CurrentControlSet\\Services\\TransarcAFSDaemon\\Parameters",
+                         0, KEY_QUERY_VALUE, &parmKey);
+     if (code == ERROR_SUCCESS) {
+         dummyLen = sizeof(cacheSize);
+         code = RegQueryValueEx(parmKey, "CacheSize", NULL, NULL,
+                                (BYTE *) &cacheSize, &dummyLen);
+         RegCloseKey (parmKey);
+     }
+ 
+     code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\OpenAFS\\Client",
+                          0, KEY_QUERY_VALUE, &parmKey);
+     if (code == ERROR_SUCCESS) {
+         dummyLen = sizeof(verifyServiceSig);
+         code = RegQueryValueEx(parmKey, "VerifyServiceSignature", NULL, NULL,
+                                 (BYTE *) &verifyServiceSig, &dummyLen);
+         RegCloseKey (parmKey);
+     }
+ 
+     if (verifyServiceSig && cacheSize < 716800) {
+         trustVerified = VerifyTrust(filename);
+     } else {
+         afsi_log("Signature Verification disabled");
+     }
+ 
+     if (trustVerified) {
+         LoadCrypt32();
+ 
+         // get a certificate context for the signer of afsd_service.
+         pCtxService = GetCertCtx(filename);
+         if (pCtxService)
+             LogCertCtx(pCtxService);
+     }
+ 
+     // Get a list of all the modules in this process.
+     hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ,
+                            FALSE, GetCurrentProcessId());
+ 
+     if (pEnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded))
+     {
+         afsi_log("Num of Process Modules: %d", (cbNeeded / sizeof(HMODULE)));
+ 
+         for (i = 0; i < (cbNeeded / sizeof(HMODULE)); i++)
+         {
+             char szModName[2048];
+ 
+             // Get the full path to the module's file.
+             if (pGetModuleFileNameExA(hProcess, hMods[i], szModName, sizeof(szModName)))
+             {
+                 lstrcpy(checkName, szModName);
+                 strlwr(checkName);
+ 
+                 if ( strstr(checkName, "afspthread.dll") ||
+                      strstr(checkName, "afsauthent.dll") ||
+                      strstr(checkName, "afsrpc.dll") ||
+                      strstr(checkName, "libafsconf.dll") ||
+                      strstr(checkName, "libosi.dll") )
+                 {
+                     if (GetVersionInfo(szModName, modVersion, sizeof(modVersion))) {
+                         success = FALSE;
+                         continue;
+                     }
+ 
+                     afsi_log("%s version %s", szModName, modVersion);
+                     if (strcmp(afsdVersion,modVersion)) {
+                         afsi_log("Version mismatch: %s", szModName);
+                         success = FALSE;
+                     }
+                     if ( trustVerified ) {
+                         if ( !VerifyTrust(szModName) ) {
+                             afsi_log("Signature Verification failed: %s", szModName);
+                             success = FALSE;
+                         } 
+                         else if (pCtxService) {
+                             PCCERT_CONTEXT pCtx = GetCertCtx(szModName);
+ 
+                             if (!pCtx || !pCertCompareCertificate(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
+                                                                   pCtxService->pCertInfo,
+                                                                   pCtx->pCertInfo)) {
+                                 afsi_log("Certificate mismatch: %s", szModName);
+                                 if (pCtx)
+                                     LogCertCtx(pCtx);
+                                 
+                                 success = FALSE;
+                             }
+                             
+                             if (pCtx)
+                                 pCertFreeCertificateContext(pCtx);
+                         }
+                     }
+                 }
+             }
+         }
+     }
+ 
+     if (pCtxService) {
+         pCertFreeCertificateContext(pCtxService);
+         UnloadCrypt32();
+     }
+ 
+     FreeLibrary(hPSAPI);
+ 
+     CloseHandle(hProcess);
+     return success;
+ }
+ 
  typedef BOOL ( APIENTRY * AfsdInitHook )(void);
  #define AFSD_INIT_HOOK "AfsdInitHook"
  #define AFSD_HOOK_DLL  "afsdhook.dll"
***************
*** 527,532 ****
--- 1058,1076 ----
      }
  #endif
  
+     /* Verify the versions of the DLLs which were loaded */
+     if (!AFSModulesVerify()) {
+         ServiceStatus.dwCurrentState = SERVICE_STOPPED;
+         ServiceStatus.dwWin32ExitCode = NO_ERROR;
+         ServiceStatus.dwCheckPoint = 0;
+         ServiceStatus.dwWaitHint = 0;
+         ServiceStatus.dwControlsAccepted = 0;
+         SetServiceStatus(StatusHandle, &ServiceStatus);
+                        
+         /* exit if initialization failed */
+         return;
+     }
+ 
      /* allow an exit to be called prior to any initialization */
      hInitHookDll = LoadLibrary(AFSD_HOOK_DLL);
      if (hInitHookDll)
Index: openafs/src/WINNT/afsd/afsicf.cpp
diff -c openafs/src/WINNT/afsd/afsicf.cpp:1.1 openafs/src/WINNT/afsd/afsicf.cpp:1.1.2.1
*** openafs/src/WINNT/afsd/afsicf.cpp:1.1	Wed Jul 14 02:00:18 2004
--- openafs/src/WINNT/afsd/afsicf.cpp	Tue Dec  7 00:53:57 2004
***************
*** 135,140 ****
--- 135,141 ----
  	INetFwOpenPort * fwPort = NULL;
  	HRESULT hr;
  	HRESULT rhr = S_OK; /* return value */
+         int i = 0;
  
  	hr = fwProfile->get_GloballyOpenPorts(&fwPorts);
  	if (FAILED(hr)) {
***************
*** 145,151 ****
  	}
  
  	// go through the supplied ports
! 	for (int i=0; i<nPorts; i++) {
  		VARIANT_BOOL vbEnabled;
  		BSTR bstName = NULL;
  		BOOL bCreate = FALSE;
--- 146,152 ----
  	}
  
  	// go through the supplied ports
! 	for (i=0; i<nPorts; i++) {
  		VARIANT_BOOL vbEnabled;
  		BSTR bstName = NULL;
  		BOOL bCreate = FALSE;
Index: openafs/src/WINNT/afsd/afslogon.c
diff -c openafs/src/WINNT/afsd/afslogon.c:1.24.2.3 openafs/src/WINNT/afsd/afslogon.c:1.24.2.4
*** openafs/src/WINNT/afsd/afslogon.c:1.24.2.3	Fri Aug 20 16:17:00 2004
--- openafs/src/WINNT/afsd/afslogon.c	Tue Dec  7 07:49:23 2004
***************
*** 550,559 ****
  
      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
--- 550,555 ----
***************
*** 565,570 ****
--- 561,567 ----
      }
      else
          lpszOutputString[0] = '\0';
+ 
      return FALSE;
  }  // UnicodeStringToANSI
  
Index: openafs/src/WINNT/afsd/cm_buf.c
diff -c openafs/src/WINNT/afsd/cm_buf.c:1.13.2.3 openafs/src/WINNT/afsd/cm_buf.c:1.13.2.5
*** openafs/src/WINNT/afsd/cm_buf.c:1.13.2.3	Fri Nov  5 14:21:43 2004
--- openafs/src/WINNT/afsd/cm_buf.c	Tue Dec  7 01:01:41 2004
***************
*** 339,344 ****
--- 339,345 ----
                                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);
              CloseHandle(hm);
***************
*** 1464,1480 ****
  
      lock_ObtainRead(&buf_globalLock);
    
!     sprintf(output, "%s - dumping buf_HashTable - buf_hashSize=%d\n", cookie, buf_hashSize);
      WriteFile(outputFile, output, strlen(output), &zilch, NULL);
    
      for (i = 0; i < buf_hashSize; i++)
      {
!         for(bp = buf_hashTablepp[i]; bp; bp=bp->hashp) 
          {
              if (bp->refCount)
              {
!                 sprintf(output, "%s bp=0x%08X, hash=%d, fid (cell=%d, volume=%d,"
!                         "vnode=%d, unique=%d), size=%d refCount=%d\n", 
                          cookie, (void *)bp, i, bp->fid.cell, bp->fid.volume, 
                          bp->fid.vnode, bp->fid.unique, bp->size, bp->refCount);
                  WriteFile(outputFile, output, strlen(output), &zilch, NULL);
--- 1465,1480 ----
  
      lock_ObtainRead(&buf_globalLock);
    
!     StringCbPrintfA(output, sizeof(output), "%s - dumping buf_HashTable - buf_hashSize=%d\n", cookie, buf_hashSize);
      WriteFile(outputFile, output, strlen(output), &zilch, NULL);
    
      for (i = 0; i < buf_hashSize; i++)
      {
!         for (bp = buf_hashTablepp[i]; bp; bp=bp->hashp) 
          {
              if (bp->refCount)
              {
!                 StringCbPrintfA(output, sizeof(output), "vnode=%d, unique=%d), size=%d refCount=%d\n", 
                          cookie, (void *)bp, i, bp->fid.cell, bp->fid.volume, 
                          bp->fid.vnode, bp->fid.unique, bp->size, bp->refCount);
                  WriteFile(outputFile, output, strlen(output), &zilch, NULL);
***************
*** 1482,1488 ****
          }
      }
    
!     sprintf(output, "%s - Done dumping buf_HashTable.\n", cookie);
      WriteFile(outputFile, output, strlen(output), &zilch, NULL);
  
      lock_ReleaseRead(&buf_globalLock);
--- 1482,1488 ----
          }
      }
    
!     StringCbPrintfA(output, sizeof(output), "%s - Done dumping buf_HashTable.\n", cookie);
      WriteFile(outputFile, output, strlen(output), &zilch, NULL);
  
      lock_ReleaseRead(&buf_globalLock);
Index: openafs/src/WINNT/afsd/cm_callback.c
diff -c openafs/src/WINNT/afsd/cm_callback.c:1.20.2.5 openafs/src/WINNT/afsd/cm_callback.c:1.20.2.6
*** openafs/src/WINNT/afsd/cm_callback.c:1.20.2.5	Mon Oct 18 00:09:25 2004
--- openafs/src/WINNT/afsd/cm_callback.c	Tue Dec  7 00:58:20 2004
***************
*** 160,166 ****
          if (scp->fid.volume == tfid.volume &&
               scp->fid.vnode == tfid.vnode &&
               scp->fid.unique == tfid.unique) {
!             scp->refCount++;
              lock_ReleaseWrite(&cm_scacheLock);
              osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
              lock_ObtainMutex(&scp->mx);
--- 160,166 ----
          if (scp->fid.volume == tfid.volume &&
               scp->fid.vnode == tfid.vnode &&
               scp->fid.unique == tfid.unique) {
!             cm_HoldSCacheNoLock(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
              lock_ObtainMutex(&scp->mx);
***************
*** 168,174 ****
              lock_ReleaseMutex(&scp->mx);
              cm_CallbackNotifyChange(scp);
              lock_ObtainWrite(&cm_scacheLock);
!             scp->refCount--;
          }
      }
      lock_ReleaseWrite(&cm_scacheLock);
--- 168,174 ----
              lock_ReleaseMutex(&scp->mx);
              cm_CallbackNotifyChange(scp);
              lock_ObtainWrite(&cm_scacheLock);
!             cm_ReleaseSCacheNoLock(scp);
          }
      }
      lock_ReleaseWrite(&cm_scacheLock);
***************
*** 201,207 ****
      for (hash = 0; hash < cm_hashTableSize; hash++) {
          for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
              if (scp->fid.volume == fidp->Volume) {
!                 scp->refCount++;
                  lock_ReleaseWrite(&cm_scacheLock);
                  lock_ObtainMutex(&scp->mx);
                  osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
--- 201,207 ----
      for (hash = 0; hash < cm_hashTableSize; hash++) {
          for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
              if (scp->fid.volume == fidp->Volume) {
!                 cm_HoldSCacheNoLock(scp);
                  lock_ReleaseWrite(&cm_scacheLock);
                  lock_ObtainMutex(&scp->mx);
                  osi_Log1(afsd_logp, "Discarding SCache scp %x", scp);
***************
*** 209,215 ****
                  lock_ReleaseMutex(&scp->mx);
                  cm_CallbackNotifyChange(scp);
                  lock_ObtainWrite(&cm_scacheLock);
!                 scp->refCount--;
              }
          }	/* search one hash bucket */
      }	/* search all hash buckets */
--- 209,215 ----
                  lock_ReleaseMutex(&scp->mx);
                  cm_CallbackNotifyChange(scp);
                  lock_ObtainWrite(&cm_scacheLock);
!                 cm_ReleaseSCacheNoLock(scp);
              }
          }	/* search one hash bucket */
      }	/* search all hash buckets */
***************
*** 290,296 ****
  	lock_ObtainWrite(&cm_scacheLock);
  	for (hash = 0; hash < cm_hashTableSize; hash++) {
              for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!                 scp->refCount++;
                  lock_ReleaseWrite(&cm_scacheLock);
                  lock_ObtainMutex(&scp->mx);
                  discarded = 0;
--- 290,296 ----
  	lock_ObtainWrite(&cm_scacheLock);
  	for (hash = 0; hash < cm_hashTableSize; hash++) {
              for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!                 cm_HoldSCacheNoLock(scp);
                  lock_ReleaseWrite(&cm_scacheLock);
                  lock_ObtainMutex(&scp->mx);
                  discarded = 0;
***************
*** 306,312 ****
                  if (discarded)
                      cm_CallbackNotifyChange(scp);
                  lock_ObtainWrite(&cm_scacheLock);
!                 scp->refCount--;
              }	/* search one hash bucket */
  	}      	/* search all hash buckets */
  	
--- 306,312 ----
                  if (discarded)
                      cm_CallbackNotifyChange(scp);
                  lock_ObtainWrite(&cm_scacheLock);
!                 cm_ReleaseSCacheNoLock(scp);
              }	/* search one hash bucket */
  	}      	/* search all hash buckets */
  	
***************
*** 909,925 ****
      lock_ObtainWrite(&cm_scacheLock);
      for (i=0; i<cm_hashTableSize; i++) {
          for (scp = cm_hashTablep[i]; scp; scp=scp->nextp) {
!             scp->refCount++;
              lock_ReleaseWrite(&cm_scacheLock);
              if (scp->cbExpires > 0 && (scp->cbServerp == NULL || now > scp->cbExpires)) {
                  osi_Log1(afsd_logp, "Callback Expiration Discarding SCache scp %x", scp);
-                 cm_CallbackNotifyChange(scp);
                  lock_ObtainMutex(&scp->mx);
                  cm_DiscardSCache(scp);
                  lock_ReleaseMutex(&scp->mx);
              }
              lock_ObtainWrite(&cm_scacheLock);
!             osi_assert(scp->refCount-- > 0);
          }
      }
      lock_ReleaseWrite(&cm_scacheLock);
--- 909,925 ----
      lock_ObtainWrite(&cm_scacheLock);
      for (i=0; i<cm_hashTableSize; i++) {
          for (scp = cm_hashTablep[i]; scp; scp=scp->nextp) {
!             cm_HoldSCacheNoLock(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              if (scp->cbExpires > 0 && (scp->cbServerp == NULL || now > scp->cbExpires)) {
                  osi_Log1(afsd_logp, "Callback Expiration Discarding SCache scp %x", scp);
                  lock_ObtainMutex(&scp->mx);
                  cm_DiscardSCache(scp);
                  lock_ReleaseMutex(&scp->mx);
+                 cm_CallbackNotifyChange(scp);
              }
              lock_ObtainWrite(&cm_scacheLock);
!             cm_ReleaseSCacheNoLock(scp);
          }
      }
      lock_ReleaseWrite(&cm_scacheLock);
Index: openafs/src/WINNT/afsd/cm_callback.h
diff -c openafs/src/WINNT/afsd/cm_callback.h:1.3.16.1 openafs/src/WINNT/afsd/cm_callback.h:1.3.16.2
*** openafs/src/WINNT/afsd/cm_callback.h:1.3.16.1	Tue Aug 17 00:28:38 2004
--- openafs/src/WINNT/afsd/cm_callback.h	Tue Dec  7 01:01:41 2004
***************
*** 66,69 ****
--- 66,71 ----
  
  extern osi_rwlock_t cm_callbackLock;
  
+ extern void cm_CallbackNotifyChange(cm_scache_t *scp);
+ 
  #endif /*  _CM_CALLBACK_H_ENV__ */
Index: openafs/src/WINNT/afsd/cm_config.c
diff -c openafs/src/WINNT/afsd/cm_config.c:1.20 openafs/src/WINNT/afsd/cm_config.c:1.20.2.1
*** openafs/src/WINNT/afsd/cm_config.c:1.20	Thu Jul 22 05:23:52 2004
--- openafs/src/WINNT/afsd/cm_config.c	Tue Dec  7 01:01:41 2004
***************
*** 738,744 ****
  
  void cm_GetConfigDir(char *dir)
  {
! 	char wdir[256];
      int tlen;
  #ifdef AFS_WIN95_ENV
      char *afsconf_path;
--- 738,744 ----
  
  void cm_GetConfigDir(char *dir)
  {
!     char wdir[256];
      int tlen;
  #ifdef AFS_WIN95_ENV
      char *afsconf_path;
Index: openafs/src/WINNT/afsd/cm_config.h
diff -c openafs/src/WINNT/afsd/cm_config.h:1.6 openafs/src/WINNT/afsd/cm_config.h:1.6.2.1
*** openafs/src/WINNT/afsd/cm_config.h:1.6	Tue Aug  3 13:27:52 2004
--- openafs/src/WINNT/afsd/cm_config.h	Tue Dec  7 01:01:41 2004
***************
*** 55,60 ****
--- 55,62 ----
  
  extern long cm_GetCellServDB(char *cellNamep);
  
+ extern void cm_GetConfigDir(char *dir);
+ 
  #endif /* __CM_CONFIG_INTERFACES_ONLY__ */
  
  #endif /* __CONFIG_H_ENV_ */
Index: openafs/src/WINNT/afsd/cm_freelance.c
diff -c openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.3 openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.10
*** openafs/src/WINNT/afsd/cm_freelance.c:1.15.2.3	Fri Nov  5 14:21:44 2004
--- openafs/src/WINNT/afsd/cm_freelance.c	Tue Dec  7 01:14:52 2004
***************
*** 332,338 ****
    
  /* called directly from ioctl */
  /* called while not holding freelance lock */
! int cm_noteLocalMountPointChange() {
      lock_ObtainMutex(&cm_Freelance_Lock);
      cm_fakeDirVersion++;
      cm_localMountPointChangeFlag = 1;
--- 332,338 ----
    
  /* called directly from ioctl */
  /* called while not holding freelance lock */
! int cm_noteLocalMountPointChange(void) {
      lock_ObtainMutex(&cm_Freelance_Lock);
      cm_fakeDirVersion++;
      cm_localMountPointChangeFlag = 1;
***************
*** 377,389 ****
                   ) {
  
                  // mark the scp to be reused
                  lock_ReleaseWrite(&cm_scacheLock);
                  lock_ObtainMutex(&scp->mx);
                  cm_DiscardSCache(scp);
                  lock_ReleaseMutex(&scp->mx);
                  cm_CallbackNotifyChange(scp);
                  lock_ObtainWrite(&cm_scacheLock);
!                 scp->refCount--;
  
                  // take the scp out of the hash
                  lscpp = &cm_hashTablep[hash];
--- 377,390 ----
                   ) {
  
                  // mark the scp to be reused
+                 cm_HoldSCacheNoLock(scp);
                  lock_ReleaseWrite(&cm_scacheLock);
                  lock_ObtainMutex(&scp->mx);
                  cm_DiscardSCache(scp);
                  lock_ReleaseMutex(&scp->mx);
                  cm_CallbackNotifyChange(scp);
                  lock_ObtainWrite(&cm_scacheLock);
!                 cm_ReleaseSCacheNoLock(scp);
  
                  // take the scp out of the hash
                  lscpp = &cm_hashTablep[hash];
***************
*** 451,460 ****
  
  #if !defined(DJGPP)
      if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
!                         "SOFTWARE\\OpenAFS\\Client\\Freelance",
! 						0,
!                         KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
!                         &hkFreelance) == ERROR_SUCCESS) {
  
          RegQueryInfoKey( hkFreelance,
                           NULL,  /* lpClass */
--- 452,461 ----
  
  #if !defined(DJGPP)
      if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
!                       "SOFTWARE\\OpenAFS\\Client\\Freelance",
!                       0,
!                       KEY_READ|KEY_WRITE|KEY_QUERY_VALUE,
!                       &hkFreelance) == ERROR_SUCCESS) {
  
          RegQueryInfoKey( hkFreelance,
                           NULL,  /* lpClass */
***************
*** 473,486 ****
          smb_UnixTimeFromLargeSearchTime(&FakeFreelanceModTime, &ftLastWriteTime);
  
          if ( dwMountPoints == 0 ) {
!             sprintf(line,"%s#%s:root.cell.\n",rootCellName,rootCellName);
!             dwType = REG_SZ;
!             dwSize = strlen(line) + 1;
!             RegSetValueEx( hkFreelance, "0", 0, dwType, line, dwSize);
!             sprintf(line,".%s%%%s:root.cell.\n",rootCellName,rootCellName);
!             dwSize = strlen(line) + 1;
!             RegSetValueEx( hkFreelance, "1", 0, dwType, line, dwSize);
!             dwMountPoints = 2;
          }
  
          if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
--- 474,486 ----
          smb_UnixTimeFromLargeSearchTime(&FakeFreelanceModTime, &ftLastWriteTime);
  
          if ( dwMountPoints == 0 ) {
!             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;
!             }
          }
  
          if (RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
***************
*** 527,534 ****
              TCHAR szValueName[16];
              DWORD dwValueSize = 16;
              dwSize = sizeof(line);
!             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
!                           &dwType, line, &dwSize);
  
              /* find the trailing dot; null terminate after it */
              t2 = strrchr(line, '.');
--- 527,541 ----
              TCHAR szValueName[16];
              DWORD dwValueSize = 16;
              dwSize = sizeof(line);
!             if (RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
!                           &dwType, line, &dwSize))
!             {
!                 afsi_log("RegEnumValue(hkFreelance) failed");
!                 cm_noLocalMountPoints--;
!                 continue;
!             }
! 
!             afsi_log("Mountpoint[%d] = %s",dwIndex, line);
  
              /* find the trailing dot; null terminate after it */
              t2 = strrchr(line, '.');
***************
*** 568,575 ****
              TCHAR szValueName[16];
              DWORD dwValueSize = 16;
              dwSize = sizeof(line);
!             RegEnumValue( hkFreelanceSymlinks, dwIndex, szValueName, &dwValueSize, NULL,
!                           &dwType, line, &dwSize);
  
              /* find the trailing dot; null terminate after it */
              t2 = strrchr(line, '.');
--- 575,589 ----
              TCHAR szValueName[16];
              DWORD dwValueSize = 16;
              dwSize = sizeof(line);
!             if (RegEnumValue( hkFreelanceSymlinks, dwIndex, szValueName, &dwValueSize, NULL,
!                               &dwType, line, &dwSize))
!             {
!                 afsi_log("RegEnumValue(hkFreelanceSymlinks) failed");
!                 cm_noLocalMountPoints--;
!                 continue;
!             }
! 
!             afsi_log("Symlink[%d] = %s",dwIndex, line);
  
              /* find the trailing dot; null terminate after it */
              t2 = strrchr(line, '.');
***************
*** 618,644 ****
      strcat(hdir, AFS_FREELANCE_INI);
      // open the ini file for reading
      fp = fopen(hdir, "r");
- 
-     // if we fail to open the file, create an empty one
      if (!fp) {
!         fp = fopen(hdir, "w");
!       	code = cm_GetRootCellName(rootCellName);
!         if (code == 0) {
!             fputs("1\n", fp);
!             fprintf(fp,"%s#%s:root.cell.\n",rootCellName,rootCellName);
!             fprintf(fp,".%s%%%s:root.cell.\n",rootCellName,rootCellName);
!             fclose(fp);
!             fp = fopen(hdir, "r");
!         } else {
!             fputs("0\n", fp);
!             fclose(fp);
!             return 0;  /* success */
!         }
      }
  
-     // we successfully opened the file
-     osi_Log0(afsd_logp,"opened afs_freelance.ini");
- 	
  #if !defined(DJGPP)
      RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
                      "SOFTWARE\\OpenAFS\\Client\\Freelance",
--- 632,645 ----
      strcat(hdir, AFS_FREELANCE_INI);
      // open the ini file for reading
      fp = fopen(hdir, "r");
      if (!fp) {
!         /* look in the Windows directory where we used to store the file */
!         GetWindowsDirectory(hdir, sizeof(hdir));
!         strcat(hdir,"\\");
!         strcat(hdir, AFS_FREELANCE_INI);
!         fp = fopen(hdir, "r");
      }
  
  #if !defined(DJGPP)
      RegCreateKeyEx( HKEY_LOCAL_MACHINE, 
                      "SOFTWARE\\OpenAFS\\Client\\Freelance",
***************
*** 652,657 ****
--- 653,674 ----
      dwIndex = 0;
  #endif
  
+     if (!fp) {
+ #if !defined(DJGPP)
+         RegCloseKey(hkFreelance);
+ #endif
+         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;
+     }
+ 
+     // we successfully opened the file
+     osi_Log0(afsd_logp,"opened afs_freelance.ini");
+ 	
      // now we read the first line to see how many entries
      // there are
      fgets(line, sizeof(line), fp);
***************
*** 668,676 ****
      // that we read
      cm_noLocalMountPoints = atoi(line);
  
!     // create space to store the local mount points
!     cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
!     aLocalMountPoint = cm_localMountPoints;
  
      // now we read n lines and parse them into local mount points
      // where n is the number of local mount points there are, as
--- 685,695 ----
      // that we read
      cm_noLocalMountPoints = atoi(line);
  
!     if (cm_noLocalMountPoints > 0) {
!         // create space to store the local mount points
!         cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
!         aLocalMountPoint = cm_localMountPoints;
!     }
  
      // now we read n lines and parse them into local mount points
      // where n is the number of local mount points there are, as
***************
*** 688,693 ****
--- 707,717 ----
              return -1;
          }
  
+         /* find the trailing dot; null terminate after it */
+         t2 = strrchr(line, '.');
+         if (t2)
+             *(t2+1) = '\0';
+ 
  #if !defined(DJGPP)
          if ( hkFreelance ) {
              char szIndex[16];
***************
*** 714,721 ****
          *(aLocalMountPoint->namep + (t-line)) = 0;
  
          aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
!         memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
!         *(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
  
          osi_Log2(afsd_logp,"found mount point: name %s, string %s",
                    aLocalMountPoint->namep,
--- 738,745 ----
          *(aLocalMountPoint->namep + (t-line)) = 0;
  
          aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
!         memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-1);
!         *(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-1)) = 0;
  
          osi_Log2(afsd_logp,"found mount point: name %s, string %s",
                    aLocalMountPoint->namep,
***************
*** 737,742 ****
--- 761,918 ----
      return cm_noLocalMountPoints;
  }
  
+ #if !defined(DJGPP)
+ long cm_FreelanceMountPointExists(char * filename)
+ {
+     char* cp;
+     char line[512];
+     char shortname[200];
+     int found = 0;
+     HKEY hkFreelance = 0;
+     DWORD dwType, dwSize;
+     DWORD dwMountPoints;
+     DWORD dwIndex;
+         
+     lock_ObtainMutex(&cm_Freelance_Lock);
+ 
+     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                       "SOFTWARE\\OpenAFS\\Client\\Freelance",
+                       0,
+                       KEY_READ|KEY_QUERY_VALUE,
+                       &hkFreelance) == ERROR_SUCCESS) 
+     {
+         RegQueryInfoKey( hkFreelance,
+                          NULL,  /* lpClass */
+                          NULL,  /* lpcClass */
+                          NULL,  /* lpReserved */
+                          NULL,  /* lpcSubKeys */
+                          NULL,  /* lpcMaxSubKeyLen */
+                          NULL,  /* lpcMaxClassLen */
+                          &dwMountPoints, /* lpcValues */
+                          NULL,  /* lpcMaxValueNameLen */
+                          NULL,  /* lpcMaxValueLen */
+                          NULL,  /* lpcbSecurityDescriptor */
+                          NULL   /* lpftLastWriteTime */
+                          );
+ 
+         for ( dwIndex = 0; dwIndex < dwMountPoints; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             cp=strchr(line, '#');
+             if (!cp)
+                 cp=strchr(line, '%');
+             memcpy(shortname, line, cp-line);
+             shortname[cp-line]=0;
+ 
+             if (!strcmp(shortname, filename)) {
+                 found = 1;
+                 break;
+             }
+         }
+         for ( dwIndex = 0; dwIndex < dwMountPoints; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             cp=strchr(line, '#');
+             if (!cp)
+                 cp=strchr(line, '%');
+             memcpy(shortname, line, cp-line);
+             shortname[cp-line]=0;
+ 
+             if (!stricmp(shortname, filename)) {
+                 found = 1;
+                 break;
+             }
+         }
+         RegCloseKey(hkFreelance);
+     }
+ 
+     lock_ReleaseMutex(&cm_Freelance_Lock);
+ 
+     return found;
+ }
+ 
+ long cm_FreelanceSymlinkExists(char * filename)
+ {
+     char* cp;
+     char line[512];
+     char shortname[200];
+     int found = 0;
+     HKEY hkFreelance = 0;
+     DWORD dwType, dwSize;
+     DWORD dwSymlinks;
+     DWORD dwIndex;
+         
+     lock_ObtainMutex(&cm_Freelance_Lock);
+ 
+     if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
+                       "SOFTWARE\\OpenAFS\\Client\\Freelance\\Symlinks",
+                       0,
+                       KEY_READ|KEY_QUERY_VALUE,
+                       &hkFreelance) == ERROR_SUCCESS) 
+     {
+         RegQueryInfoKey( hkFreelance,
+                          NULL,  /* lpClass */
+                          NULL,  /* lpcClass */
+                          NULL,  /* lpReserved */
+                          NULL,  /* lpcSubKeys */
+                          NULL,  /* lpcMaxSubKeyLen */
+                          NULL,  /* lpcMaxClassLen */
+                          &dwSymlinks, /* lpcValues */
+                          NULL,  /* lpcMaxValueNameLen */
+                          NULL,  /* lpcMaxValueLen */
+                          NULL,  /* lpcbSecurityDescriptor */
+                          NULL   /* lpftLastWriteTime */
+                          );
+ 
+         for ( dwIndex = 0; dwIndex < dwSymlinks; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             cp=strchr(line, ':');
+             memcpy(shortname, line, cp-line);
+             shortname[cp-line]=0;
+ 
+             if (!strcmp(shortname, filename)) {
+                 found = 1;
+                 break;
+             }
+         }
+         for ( dwIndex = 0; dwIndex < dwSymlinks; dwIndex++ ) {
+             TCHAR szValueName[16];
+             DWORD dwValueSize = 16;
+             dwSize = sizeof(line);
+             RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
+                           &dwType, line, &dwSize);
+ 
+             cp=strchr(line, ':');
+             memcpy(shortname, line, cp-line);
+             shortname[cp-line]=0;
+ 
+             if (!stricmp(shortname, filename)) {
+                 found = 1;
+                 break;
+             }
+         }
+         RegCloseKey(hkFreelance);
+     }
+ 
+     lock_ReleaseMutex(&cm_Freelance_Lock);
+ 
+     return found;
+ }
+ #endif
+ 
  long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp)
  {
      FILE *fp;
***************
*** 761,766 ****
--- 937,946 ----
                osi_LogSaveString(afsd_logp,cellname), 
                osi_LogSaveString(afsd_logp,volume), 
                rw ? "rw" : "ro");
+ 
+     if ( filename[0] == '\0' || cellname[0] == '\0' || volume[0] == '\0' )
+         return -1;
+ 
      if (cellname[0] == '.') {
          if (!cm_GetCell_Gen(&cellname[1], fullname, CM_FLAG_CREATE))
              return -1;
***************
*** 768,773 ****
--- 948,959 ----
          if (!cm_GetCell_Gen(cellname, fullname, CM_FLAG_CREATE))
              return -1;
      }
+ 
+ #if !defined(DJGPP)
+     if ( cm_FreelanceMountPointExists(filename) ||
+          cm_FreelanceSymlinkExists(filename) )
+         return -1;
+ #endif
      
      osi_Log1(afsd_logp,"Freelance Adding Mount for Cell: %s", 
                osi_LogSaveString(afsd_logp,cellname));
***************
*** 816,824 ****
                  RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
                  break;
              } else {
! 				int len = strlen(filename);
! 				if ( dwType == REG_SZ && !strncmp(filename, szMount, len) && 
! 					(szMount[len] == '%' || szMount[len] == '#')) {
                      /* Replace the existing value */
                      dwType = REG_SZ;
                      dwSize = strlen(line) + 1;
--- 1002,1010 ----
                  RegSetValueEx( hkFreelance, szIndex, 0, dwType, line, dwSize);
                  break;
              } else {
!                 int len = strlen(filename);
!                 if ( dwType == REG_SZ && !strncmp(filename, szMount, len) && 
!                      (szMount[len] == '%' || szMount[len] == '#')) {
                      /* Replace the existing value */
                      dwType = REG_SZ;
                      dwSize = strlen(line) + 1;
***************
*** 877,883 ****
  
      lock_ObtainMutex(&cm_Freelance_Lock);
  
- 
  #if !defined(DJGPP)
      if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
                        "SOFTWARE\\OpenAFS\\Client\\Freelance",
--- 1063,1068 ----
***************
*** 970,980 ****
  
  long cm_FreelanceAddSymlink(char *filename, char *destination, cm_fid_t *fidp)
  {
-     FILE *fp;
-     char hfile[120];
      char line[512];
      char fullname[200];
-     int n;
      int alias = 0;
  #if !defined(DJGPP)
      HKEY hkFreelanceSymlinks = 0;
--- 1155,1162 ----
***************
*** 983,996 ****
      DWORD dwIndex;
  #endif
  
!     /* before adding, verify the cell name; if it is not a valid cell,
!        don't add the mount point.
!        allow partial matches as a means of poor man's alias. */
!     /* major performance issue? */
      osi_Log2(afsd_logp,"Freelance Add Symlink request: filename=%s destination=%s",
                osi_LogSaveString(afsd_logp,filename), 
                osi_LogSaveString(afsd_logp,destination));
      
      lock_ObtainMutex(&cm_Freelance_Lock);
  
  #if !defined(DJGPP)
--- 1165,1197 ----
      DWORD dwIndex;
  #endif
  
!     /* before adding, verify the filename.  If it is already in use, either as 
!      * as mount point or a cellname, do not permit the creation of the symlink.
!      */
      osi_Log2(afsd_logp,"Freelance Add Symlink request: filename=%s destination=%s",
                osi_LogSaveString(afsd_logp,filename), 
                osi_LogSaveString(afsd_logp,destination));
      
+     if ( filename[0] == '\0' || destination[0] == '\0' )
+         return -1;
+ 
+     fullname[0] = '\0';
+     if (filename[0] == '.') {
+         cm_GetCell_Gen(&filename[1], fullname, CM_FLAG_CREATE);
+         if (stricmp(&filename[1],fullname) == 0)
+             return -1;
+     } else {
+         cm_GetCell_Gen(filename, fullname, CM_FLAG_CREATE);
+         if (stricmp(filename,fullname) == 0)
+             return -1;
+     }
+ 
+ #if !defined(DJGPP)
+     if ( cm_FreelanceMountPointExists(filename) ||
+          cm_FreelanceSymlinkExists(filename) )
+         return -1;
+ #endif
+ 
      lock_ObtainMutex(&cm_Freelance_Lock);
  
  #if !defined(DJGPP)
***************
*** 1036,1043 ****
                  RegSetValueEx( hkFreelanceSymlinks, szIndex, 0, dwType, line, dwSize);
                  break;
              } else {
! 				int len = strlen(filename);
! 				if ( dwType == REG_SZ && !strncmp(filename, szLink, len) && szLink[len] == ':') {
                      /* Replace the existing value */
                      dwType = REG_SZ;
                      dwSize = strlen(line) + 1;
--- 1237,1244 ----
                  RegSetValueEx( hkFreelanceSymlinks, szIndex, 0, dwType, line, dwSize);
                  break;
              } else {
!                 int len = strlen(filename);
!                 if ( dwType == REG_SZ && !strncmp(filename, szLink, len) && szLink[len] == ':') {
                      /* Replace the existing value */
                      dwType = REG_SZ;
                      dwSize = strlen(line) + 1;
***************
*** 1062,1073 ****
  
  long cm_FreelanceRemoveSymlink(char *toremove)
  {
-     int i, n;
      char* cp;
      char line[512];
      char shortname[200];
-     char hfile[120], hfile2[120];
-     FILE *fp1, *fp2;
      int found=0;
  #if !defined(DJGPP)
      HKEY hkFreelanceSymlinks = 0;
--- 1263,1271 ----
***************
*** 1078,1084 ****
  
      lock_ObtainMutex(&cm_Freelance_Lock);
  
- 
  #if !defined(DJGPP)
      if (RegOpenKeyEx( HKEY_LOCAL_MACHINE, 
                        "SOFTWARE\\OpenAFS\\Client\\Freelance\\Symlinks",
--- 1276,1281 ----
Index: openafs/src/WINNT/afsd/cm_freelance.h
diff -c openafs/src/WINNT/afsd/cm_freelance.h:1.6.2.2 openafs/src/WINNT/afsd/cm_freelance.h:1.6.2.3
*** openafs/src/WINNT/afsd/cm_freelance.h:1.6.2.2	Fri Nov  5 14:21:44 2004
--- openafs/src/WINNT/afsd/cm_freelance.h	Tue Dec  7 01:01:41 2004
***************
*** 14,19 ****
--- 14,20 ----
  extern int cm_getLocalMountPointChange();
  extern int cm_reInitLocalMountPoints();
  extern void cm_InitFreelance();
+ extern int cm_noteLocalMountPointChange(void);
  extern long cm_FreelanceRemoveMount(char *toremove);
  extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp);
  extern long cm_FreelanceRemoveSymlink(char *toremove);
Index: openafs/src/WINNT/afsd/cm_ioctl.c
diff -c openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.5 openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.7
*** openafs/src/WINNT/afsd/cm_ioctl.c:1.33.2.5	Fri Nov  5 14:21:44 2004
--- openafs/src/WINNT/afsd/cm_ioctl.c	Tue Dec  7 00:58:20 2004
***************
*** 91,103 ****
      lock_ObtainWrite(&cm_scacheLock);
      for (hash=0; hash < cm_hashTableSize; hash++) {
          for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!             scp->refCount++;
              lock_ReleaseWrite(&cm_scacheLock);
              lock_ObtainMutex(&scp->mx);
              cm_InvalidateACLUser(scp, userp);
              lock_ReleaseMutex(&scp->mx);
              lock_ObtainWrite(&cm_scacheLock);
!             scp->refCount--;
          }
      }
      lock_ReleaseWrite(&cm_scacheLock);
--- 91,103 ----
      lock_ObtainWrite(&cm_scacheLock);
      for (hash=0; hash < cm_hashTableSize; hash++) {
          for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
!             cm_HoldSCacheNoLock(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              lock_ObtainMutex(&scp->mx);
              cm_InvalidateACLUser(scp, userp);
              lock_ReleaseMutex(&scp->mx);
              lock_ObtainWrite(&cm_scacheLock);
!             cm_ReleaseSCacheNoLock(scp);
          }
      }
      lock_ReleaseWrite(&cm_scacheLock);
***************
*** 259,265 ****
   * easier (because we can always jump past the initial "/afs" to find
   * the AFS path that should be written into afsdsbmt.ini).
   */
! void cm_NormalizeAfsPath (char *outpathp, char *inpathp)
  {
      char *cp;
      char bslash_mountRoot[256];
--- 259,265 ----
   * easier (because we can always jump past the initial "/afs" to find
   * the AFS path that should be written into afsdsbmt.ini).
   */
! void cm_NormalizeAfsPath(char *outpathp, long outlen, char *inpathp)
  {
      char *cp;
      char bslash_mountRoot[256];
***************
*** 268,280 ****
      bslash_mountRoot[0] = '\\';
         
      if (!strnicmp (inpathp, cm_mountRoot, strlen(cm_mountRoot)))
!         lstrcpy (outpathp, inpathp);
      else if (!strnicmp (inpathp, bslash_mountRoot, strlen(bslash_mountRoot)))
!         lstrcpy (outpathp, inpathp);
      else if ((inpathp[0] == '/') || (inpathp[0] == '\\'))
!         sprintf (outpathp, "%s%s", cm_mountRoot, inpathp);
      else // inpathp looks like "<cell>/usr"
!         sprintf (outpathp, "%s/%s", cm_mountRoot, inpathp);
  
      for (cp = outpathp; *cp != 0; ++cp) {
          if (*cp == '\\')
--- 268,280 ----
      bslash_mountRoot[0] = '\\';
         
      if (!strnicmp (inpathp, cm_mountRoot, strlen(cm_mountRoot)))
!         StringCbCopy(outpathp, outlen, inpathp);
      else if (!strnicmp (inpathp, bslash_mountRoot, strlen(bslash_mountRoot)))
!         StringCbCopy(outpathp, outlen, inpathp);
      else if ((inpathp[0] == '/') || (inpathp[0] == '\\'))
!         StringCbPrintfA(outpathp, outlen, "%s%s", cm_mountRoot, inpathp);
      else // inpathp looks like "<cell>/usr"
!         StringCbPrintfA(outpathp, outlen, "%s/%s", cm_mountRoot, inpathp);
  
      for (cp = outpathp; *cp != 0; ++cp) {
          if (*cp == '\\')
***************
*** 286,295 ****
      }
  
      if (!strcmpi (outpathp, cm_mountRoot)) {
!         strcpy (outpathp, cm_mountRoot);
      }
  }
  
  /* parse the passed-in file name and do a namei on its parent.  If we fail,
   * return an error code, otherwise return the vnode located in *scpp.
   */
--- 286,296 ----
      }
  
      if (!strcmpi (outpathp, cm_mountRoot)) {
!         StringCbCopy(outpathp, outlen, cm_mountRoot);
      }
  }
  
+ #define LEAF_SIZE 256
  /* parse the passed-in file name and do a namei on its parent.  If we fail,
   * return an error code, otherwise return the vnode located in *scpp.
   */
***************
*** 301,307 ****
      char *tp, *jp;
      cm_scache_t *substRootp;
  
!     strcpy(tbuffer, ioctlp->inDatap);
      tp = strrchr(tbuffer, '\\');
      jp = strrchr(tbuffer, '/');
      if (!tp)
--- 302,308 ----
      char *tp, *jp;
      cm_scache_t *substRootp;
  
!     StringCbCopyA(tbuffer, sizeof(tbuffer), ioctlp->inDatap);
      tp = strrchr(tbuffer, '\\');
      jp = strrchr(tbuffer, '/');
      if (!tp)
***************
*** 309,322 ****
      else if (jp && (tp - tbuffer) < (jp - tbuffer))
          tp = jp;
      if (!tp) {
!         strcpy(tbuffer, "\\");
          if (leafp) 
!             strcpy(leafp, ioctlp->inDatap);
      }
      else {
          *tp = 0;
          if (leafp) 
!             strcpy(leafp, tp+1);
      }   
  
      if (tbuffer[0] == tbuffer[1] &&
--- 310,323 ----
      else if (jp && (tp - tbuffer) < (jp - tbuffer))
          tp = jp;
      if (!tp) {
!         StringCbCopyA(tbuffer, sizeof(tbuffer), "\\");
          if (leafp) 
!             StringCbCopyA(leafp, LEAF_SIZE, ioctlp->inDatap);
      }
      else {
          *tp = 0;
          if (leafp) 
!             StringCbCopyA(leafp, LEAF_SIZE, tp+1);
      }   
  
      if (tbuffer[0] == tbuffer[1] &&
***************
*** 463,469 ****
           scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
           scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
           scp->fid.vnode==0x1 && scp->fid.unique==0x1 ) {
!         strcpy(ioctlp->outDatap, "Freelance.Local.Root");
          ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
          code = 0;
      } else 
--- 464,470 ----
           scp->fid.cell==AFS_FAKE_ROOT_CELL_ID &&
           scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
           scp->fid.vnode==0x1 && scp->fid.unique==0x1 ) {
!         StringCbCopyA(ioctlp->outDatap, 999999, "Freelance.Local.Root");
          ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
          code = 0;
      } else 
***************
*** 471,477 ****
      {
          cellp = cm_FindCellByID(scp->fid.cell);
          if (cellp) {
!             strcpy(ioctlp->outDatap, cellp->namep);
              ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
              code = 0;
          }
--- 472,478 ----
      {
          cellp = cm_FindCellByID(scp->fid.cell);
          if (cellp) {
!             StringCbCopyA(ioctlp->outDatap, 999999, cellp->namep);
              ioctlp->outDatap += strlen(ioctlp->outDatap) + 1;
              code = 0;
          }
***************
*** 547,553 ****
      for (i=0; i<cm_hashTableSize; i++) {
          for (scp = cm_hashTablep[i]; scp; scp = scp->nextp) {
              if (scp->fid.volume == volume) {
!                 scp->refCount++;
                  lock_ReleaseWrite(&cm_scacheLock);
  
                  /* now flush the file */
--- 548,554 ----
      for (i=0; i<cm_hashTableSize; i++) {
          for (scp = cm_hashTablep[i]; scp; scp = scp->nextp) {
              if (scp->fid.volume == volume) {
!                 cm_HoldSCacheNoLock(scp);
                  lock_ReleaseWrite(&cm_scacheLock);
  
                  /* now flush the file */
***************
*** 555,561 ****
                  if ( code )
                      afsi_log("cm_FlushFile returns error: [%x]",code);
                  lock_ObtainWrite(&cm_scacheLock);
!                 scp->refCount--;
              }
          }
      }
--- 556,562 ----
                  if ( code )
                      afsi_log("cm_FlushFile returns error: [%x]",code);
                  lock_ObtainWrite(&cm_scacheLock);
!                 cm_ReleaseSCacheNoLock(scp);
              }
          }
      }
***************
*** 620,630 ****
      cp = ioctlp->inDatap;
      memcpy((char *)&volStat, cp, sizeof(AFSFetchVolumeStatus));
      cp += sizeof(AFSFetchVolumeStatus);
!     strcpy(volName, cp);
      cp += strlen(volName)+1;
!     strcpy(offLineMsg, cp);
      cp +=  strlen(offLineMsg)+1;
!     strcpy(motd, cp);
      storeStat.Mask = 0;
      if (volStat.MinQuota != -1) {
          storeStat.MinQuota = volStat.MinQuota;
--- 621,631 ----
      cp = ioctlp->inDatap;
      memcpy((char *)&volStat, cp, sizeof(AFSFetchVolumeStatus));
      cp += sizeof(AFSFetchVolumeStatus);
!     StringCbCopyA(volName, sizeof(volName), cp);
      cp += strlen(volName)+1;
!     StringCbCopyA(offLineMsg, sizeof(offLineMsg), cp);
      cp +=  strlen(offLineMsg)+1;
!     StringCbCopyA(motd, sizeof(motd), cp);
      storeStat.Mask = 0;
      if (volStat.MinQuota != -1) {
          storeStat.MinQuota = volStat.MinQuota;
***************
*** 660,670 ****
      cp = ioctlp->outDatap;
      memcpy(cp, (char *)&volStat, sizeof(VolumeStatus));
      cp += sizeof(VolumeStatus);
!     strcpy(cp, volName);
      cp += strlen(volName)+1;
!     strcpy(cp, offLineMsg);
      cp += strlen(offLineMsg)+1;
!     strcpy(cp, motd);
      cp += strlen(motd)+1;
  
      /* now return updated return data pointer */
--- 661,671 ----
      cp = ioctlp->outDatap;
      memcpy(cp, (char *)&volStat, sizeof(VolumeStatus));
      cp += sizeof(VolumeStatus);
!     StringCbCopyA(cp, 999999, volName);
      cp += strlen(volName)+1;
!     StringCbCopyA(cp, 999999, offLineMsg);
      cp += strlen(offLineMsg)+1;
!     StringCbCopyA(cp, 999999, motd);
      cp += strlen(motd)+1;
  
      /* now return updated return data pointer */
***************
*** 716,726 ****
      cp = ioctlp->outDatap;
      memcpy(cp, (char *)&volStat, sizeof(AFSFetchVolumeStatus));
      cp += sizeof(AFSFetchVolumeStatus);
!     strcpy(cp, volName);
      cp += strlen(volName)+1;
!     strcpy(cp, offLineMsg);
      cp += strlen(offLineMsg)+1;
!     strcpy(cp, motd);
      cp += strlen(motd)+1;
  
      /* return new size */
--- 717,727 ----
      cp = ioctlp->outDatap;
      memcpy(cp, (char *)&volStat, sizeof(AFSFetchVolumeStatus));
      cp += sizeof(AFSFetchVolumeStatus);
!     StringCbCopyA(cp, 999999, volName);
      cp += strlen(volName)+1;
!     StringCbCopyA(cp, 999999, offLineMsg);
      cp += strlen(offLineMsg)+1;
!     StringCbCopyA(cp, 999999, motd);
      cp += strlen(motd)+1;
  
      /* return new size */
***************
*** 811,817 ****
      code = cm_ReadMountPoint(scp, userp, &req);
      if (code == 0) {
          cp = ioctlp->outDatap;
!         strcpy(cp, scp->mountPointStringp);
          cp += strlen(cp) + 1;
          ioctlp->outDatap = cp;
      }
--- 812,818 ----
      code = cm_ReadMountPoint(scp, userp, &req);
      if (code == 0) {
          cp = ioctlp->outDatap;
!         StringCbCopyA(cp, 999999, scp->mountPointStringp);
          cp += strlen(cp) + 1;
          ioctlp->outDatap = cp;
      }
***************
*** 1096,1102 ****
          }
          lock_ReleaseRead(&cm_serverLock);
          cp = basep + max * sizeof(afs_int32);
!         strcpy(cp, tcellp->namep);
          cp += strlen(tcellp->namep)+1;
          ioctlp->outDatap = cp;
      }
--- 1097,1103 ----
          }
          lock_ReleaseRead(&cm_serverLock);
          cp = basep + max * sizeof(afs_int32);
!         StringCbCopyA(cp, 999999, tcellp->namep);
          cp += strlen(tcellp->namep)+1;
          ioctlp->outDatap = cp;
      }
***************
*** 1169,1175 ****
      }
  
      /* return the default cellname to the caller */
!     strcpy(ioctlp->outDatap, cm_rootCellp->namep);
      ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  
      /* done: success */
--- 1170,1176 ----
      }
  
      /* return the default cellname to the caller */
!     StringCbCopyA(ioctlp->outDatap, 999999, cm_rootCellp->namep);
      ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
  
      /* done: success */
***************
*** 1218,1224 ****
          osi_panic("cm_IoctlSysName: !cm_sysName\n", __FILE__, __LINE__);
  
      if (!setSysName) {      /* user just wants the info */
!         strcpy(outname, cm_sysName);
          foundname = cm_sysNameCount;
          *sysnamelist = cm_sysNameList;
      } else {        
--- 1219,1225 ----
          osi_panic("cm_IoctlSysName: !cm_sysName\n", __FILE__, __LINE__);
  
      if (!setSysName) {      /* user just wants the info */
!         StringCbCopyA(outname, sizeof(outname), cm_sysName);
          foundname = cm_sysNameCount;
          *sysnamelist = cm_sysNameList;
      } else {        
***************
*** 1226,1233 ****
          /* clear @sys entries from the dnlc, once afs_lookup can
           * do lookups of @sys entries and thinks it can trust them */
          /* privs ok, store the entry, ... */
!         strcpy(cm_sysName, inname);
! 		strcpy(cm_sysNameList[0], inname);
          if (setSysName > 1) {       /* ... or list */
              cp = ioctlp->inDatap;
              for (count = 1; count < setSysName; ++count) {
--- 1227,1234 ----
          /* clear @sys entries from the dnlc, once afs_lookup can
           * do lookups of @sys entries and thinks it can trust them */
          /* privs ok, store the entry, ... */
!         StringCbCopyA(cm_sysName, sizeof(cm_sysName), inname);
!         StringCbCopyA(cm_sysNameList[0], MAXSYSNAME, inname);
          if (setSysName > 1) {       /* ... or list */
              cp = ioctlp->inDatap;
              for (count = 1; count < setSysName; ++count) {
***************
*** 1235,1241 ****
                      osi_panic("cm_IoctlSysName: no cm_sysNameList entry to write\n",
                                 __FILE__, __LINE__);
                  t = strlen(cp);
!                 strcpy(cm_sysNameList[count], cp);
                  cp += t + 1;
              }
          }
--- 1236,1242 ----
                      osi_panic("cm_IoctlSysName: no cm_sysNameList entry to write\n",
                                 __FILE__, __LINE__);
                  t = strlen(cp);
!                 StringCbCopyA(cm_sysNameList[count], MAXSYSNAME, cp);
                  cp += t + 1;
              }
          }
***************
*** 1248,1254 ****
          memcpy(cp, (char *)&foundname, sizeof(afs_int32));
          cp += sizeof(afs_int32);	/* skip found flag */
          if (foundname) {
!             strcpy(cp, outname);
              cp += strlen(outname) + 1;	/* skip name and terminating null char */
              for ( count=1; count < foundname ; ++count) {   /* ... or list */
                  if ( !(*sysnamelist)[count] )
--- 1249,1255 ----
          memcpy(cp, (char *)&foundname, sizeof(afs_int32));
          cp += sizeof(afs_int32);	/* skip found flag */
          if (foundname) {
!             StringCbCopyA(cp, 999999, outname);
              cp += strlen(outname) + 1;	/* skip name and terminating null char */
              for ( count=1; count < foundname ; ++count) {   /* ... or list */
                  if ( !(*sysnamelist)[count] )
***************
*** 1258,1264 ****
                  if (t >= MAXSYSNAME)
                      osi_panic("cm_IoctlSysName: sysname entry garbled\n", 
                                 __FILE__, __LINE__);
!                 strcpy(cp, (*sysnamelist)[count]);
                  cp += t + 1;
              }
          }
--- 1259,1265 ----
                  if (t >= MAXSYSNAME)
                      osi_panic("cm_IoctlSysName: sysname entry garbled\n", 
                                 __FILE__, __LINE__);
!                 StringCbCopyA(cp, 999999, (*sysnamelist)[count]);
                  cp += t + 1;
              }
          }
***************
*** 1426,1432 ****
  
  long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
  {
!     char leaf[256];
      long code;
      cm_scache_t *dscp;
      cm_attr_t tattr;
--- 1427,1433 ----
  
  long cm_IoctlCreateMountPoint(struct smb_ioctl *ioctlp, struct cm_user *userp)
  {
!     char leaf[LEAF_SIZE];
      long code;
      cm_scache_t *dscp;
      cm_attr_t tattr;
***************
*** 1453,1464 ****
       */
  
      /* Extract the possibly partial cell name */
!     strcpy(cell, ioctlp->inDatap + 1);      /* Skip the mp type character */
          
      if (cp = strchr(cell, ':')) {
          /* Extract the volume name */
          *cp = 0;
!         strcpy(volume,  cp + 1);
  	
          /* Get the full name for this cell */
          code = cm_SearchCellFile(cell, fullCell, 0, 0);
--- 1454,1465 ----
       */
  
      /* Extract the possibly partial cell name */
!     StringCbCopyA(cell, sizeof(cell), ioctlp->inDatap + 1);      /* Skip the mp type character */
          
      if (cp = strchr(cell, ':')) {
          /* Extract the volume name */
          *cp = 0;
!         StringCbCopyA(volume,  sizeof(volume), cp + 1);
  	
          /* Get the full name for this cell */
          code = cm_SearchCellFile(cell, fullCell, 0, 0);
***************
*** 1469,1478 ****
          if (code)
              return CM_ERROR_NOSUCHCELL;
  	
!         sprintf(mpInfo, "%c%s:%s", *ioctlp->inDatap, fullCell, volume);
      } else {
          /* No cell name specified */
!         strcpy(mpInfo, ioctlp->inDatap);
      }
  
  #ifdef AFS_FREELANCE_CLIENT
--- 1470,1479 ----
          if (code)
              return CM_ERROR_NOSUCHCELL;
  	
!         StringCbPrintfA(mpInfo, sizeof(mpInfo), "%c%s:%s", *ioctlp->inDatap, fullCell, volume);
      } else {
          /* No cell name specified */
!         StringCbCopyA(mpInfo, sizeof(mpInfo), ioctlp->inDatap);
      }
  
  #ifdef AFS_FREELANCE_CLIENT
***************
*** 1504,1510 ****
  
  long cm_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
  {
!     char leaf[256];
      long code;
      cm_scache_t *dscp;
      cm_attr_t tattr;
--- 1505,1511 ----
  
  long cm_IoctlSymlink(struct smb_ioctl *ioctlp, struct cm_user *userp)
  {
!     char leaf[LEAF_SIZE];
      long code;
      cm_scache_t *dscp;
      cm_attr_t tattr;
***************
*** 1596,1606 ****
      if (code == 0) {
          cp = ioctlp->outDatap;
          if (newRootScp != NULL) {
!             strcpy(cp, cm_mountRoot);
!             strcat(cp, "/");
              cp += strlen(cp);
          }
!         strcpy(cp, spacep->data);
          cp += strlen(cp) + 1;
          ioctlp->outDatap = cp;
          cm_FreeSpace(spacep);
--- 1597,1607 ----
      if (code == 0) {
          cp = ioctlp->outDatap;
          if (newRootScp != NULL) {
!             StringCbCopyA(cp, 999999, cm_mountRoot);
!             StringCbCatA(cp, 999999, "/");
              cp += strlen(cp);
          }
!         StringCbCopyA(cp, 999999, spacep->data);
          cp += strlen(cp) + 1;
          ioctlp->outDatap = cp;
          cm_FreeSpace(spacep);
***************
*** 1814,1820 ****
      ucellp->kvno = ct.AuthHandle;
      ucellp->expirationTime = ct.EndTimestamp;
      ucellp->gen++;
!     if (uname) strcpy(ucellp->userName, uname);
      ucellp->flags |= CM_UCELLFLAG_RXKAD;
      lock_ReleaseMutex(&userp->mx);
  
--- 1815,1822 ----
      ucellp->kvno = ct.AuthHandle;
      ucellp->expirationTime = ct.EndTimestamp;
      ucellp->gen++;
!     if (uname) 
!         StringCbCopyA(ucellp->userName, MAXKTCNAMELEN, uname);
      ucellp->flags |= CM_UCELLFLAG_RXKAD;
      lock_ReleaseMutex(&userp->mx);
  
***************
*** 1900,1910 ****
      cp += sizeof(temp);
  
      /* cell name */
!     strcpy(cp, ucellp->cellp->namep);
      cp += strlen(cp) + 1;
  
      /* user name */
!     strcpy(cp, ucellp->userName);
      cp += strlen(cp) + 1;
  
      ioctlp->outDatap = cp;
--- 1902,1912 ----
      cp += sizeof(temp);
  
      /* cell name */
!     StringCbCopyA(cp, 999999, ucellp->cellp->namep);
      cp += strlen(cp) + 1;
  
      /* user name */
!     StringCbCopyA(cp, 999999, ucellp->userName);
      cp += strlen(cp) + 1;
  
      ioctlp->outDatap = cp;
***************
*** 1988,1998 ****
      cp += sizeof(temp);
  
      /* cell name */
!     strcpy(cp, ucellp->cellp->namep);
      cp += strlen(cp) + 1;
  
      /* user name */
!     strcpy(cp, ucellp->userName);
      cp += strlen(cp) + 1;
  
      ioctlp->outDatap = cp;
--- 1990,2000 ----
      cp += sizeof(temp);
  
      /* cell name */
!     StringCbCopyA(cp, 999999, ucellp->cellp->namep);
      cp += strlen(cp) + 1;
  
      /* user name */
!     StringCbCopyA(cp, 999999, ucellp->userName);
      cp += strlen(cp) + 1;
  
      ioctlp->outDatap = cp;
***************
*** 2084,2090 ****
      /* Parse the input parameters--first the required afs path,
       * then the requested submount name (which may be "").
       */
!     cm_NormalizeAfsPath (afspath, ioctlp->inDatap);
      submountreqp = ioctlp->inDatap + (strlen(ioctlp->inDatap)+1);
  
      /* If the caller supplied a suggested submount name, see if
--- 2086,2092 ----
      /* Parse the input parameters--first the required afs path,
       * then the requested submount name (which may be "").
       */
!     cm_NormalizeAfsPath (afspath, sizeof(afspath), ioctlp->inDatap);
      submountreqp = ioctlp->inDatap + (strlen(ioctlp->inDatap)+1);
  
      /* If the caller supplied a suggested submount name, see if
***************
*** 2125,2133 ****
                             strlen(&afspath[strlen(cm_mountRoot)])+1:2);
  
              RegCloseKey( hkSubmounts );
! 			strcpy(ioctlp->outDatap, submountreqp);
! 			ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
! 			lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
              return 0;
          }
  
--- 2127,2135 ----
                             strlen(&afspath[strlen(cm_mountRoot)])+1:2);
  
              RegCloseKey( hkSubmounts );
!             StringCbCopyA(ioctlp->outDatap, 999999, submountreqp);
!             ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
!             lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
              return 0;
          }
  
***************
*** 2135,2143 ****
           * supplied path matches the submount's path, we can still
           * use the suggested submount name.
           */
!         cm_NormalizeAfsPath (submountPathNormalized, submountPath);
          if (!strcmp (submountPathNormalized, afspath)) {
!             strcpy(ioctlp->outDatap, submountreqp);
              ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
              RegCloseKey( hkSubmounts );
              lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
--- 2137,2145 ----
           * supplied path matches the submount's path, we can still
           * use the suggested submount name.
           */
!         cm_NormalizeAfsPath (submountPathNormalized, sizeof(submountPathNormalized), submountPath);
          if (!strcmp (submountPathNormalized, afspath)) {
!             StringCbCopyA(ioctlp->outDatap, 999999, submountreqp);
              ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
              RegCloseKey( hkSubmounts );
              lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
***************
*** 2204,2212 ****
           * that our caller specified. If so, we can return
           * this submount.
           */
!         cm_NormalizeAfsPath (submountPathNormalized, submountPath);
          if (!strcmp (submountPathNormalized, afspath)) {
!             strcpy(ioctlp->outDatap, submountName);
              ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
              RegCloseKey(hkSubmounts);
              lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
--- 2206,2214 ----
           * that our caller specified. If so, we can return
           * this submount.
           */
!         cm_NormalizeAfsPath (submountPathNormalized, sizeof(submountPathNormalized), submountPath);
          if (!strcmp (submountPathNormalized, afspath)) {
!             StringCbCopyA(ioctlp->outDatap, 999999, submountName);
              ioctlp->outDatap += strlen(ioctlp->outDatap) +1;
              RegCloseKey(hkSubmounts);
              lock_ReleaseMutex(&cm_Afsdsbmt_Lock);
***************
*** 2221,2227 ****
       * when writing out the submount.
       */
  
!     sprintf(ioctlp->outDatap, "auto%ld", nextAutoSubmount);
  
      RegSetValueEx( hkSubmounts, 
                     ioctlp->outDatap,
--- 2223,2229 ----
       * when writing out the submount.
       */
  
!     StringCbPrintfA(ioctlp->outDatap, 999999, "auto%ld", nextAutoSubmount);
  
      RegSetValueEx( hkSubmounts, 
                     ioctlp->outDatap,
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.14.2.2 openafs/src/WINNT/afsd/cm_scache.c:1.14.2.3
*** openafs/src/WINNT/afsd/cm_scache.c:1.14.2.2	Fri Nov  5 14:21:44 2004
--- openafs/src/WINNT/afsd/cm_scache.c	Tue Dec  7 00:58:20 2004
***************
*** 235,241 ****
      lock_ObtainWrite(&cm_scacheLock);
      for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
          if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             scp->refCount++;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              return scp;
--- 235,241 ----
      lock_ObtainWrite(&cm_scacheLock);
      for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
          if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             cm_HoldSCacheNoLock(scp);
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              return scp;
***************
*** 272,280 ****
      // yj: check if we have the scp, if so, we don't need
      // to do anything else
      lock_ObtainWrite(&cm_scacheLock);
!     for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
          if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             scp->refCount++;
              *outScpp = scp;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
--- 272,280 ----
      // yj: check if we have the scp, if so, we don't need
      // to do anything else
      lock_ObtainWrite(&cm_scacheLock);
!     for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
          if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             cm_HoldSCacheNoLock(scp);
              *outScpp = scp;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
***************
*** 369,377 ****
      /* otherwise, we have the volume, now reverify that the scp doesn't
       * exist, and proceed.
       */
!     for(scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
          if (cm_FidCmp(fidp, &scp->fid) == 0) {
!             scp->refCount++;
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              if (volp)
--- 369,378 ----
      /* otherwise, we have the volume, now reverify that the scp doesn't
       * exist, and proceed.
       */
!     for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
          if (cm_FidCmp(fidp, &scp->fid) == 0) {
! 			osi_assert(scp->volp == volp);
!             cm_HoldSCacheNoLock(scp);
              cm_AdjustLRU(scp);
              lock_ReleaseWrite(&cm_scacheLock);
              if (volp)
***************
*** 978,983 ****
--- 979,992 ----
      afsFidp->Unique = fidp->unique;
  }       
  
+ void cm_HoldSCacheNoLock(cm_scache_t *scp)
+ {
+ #ifdef NOLOCK_ASSERT
+     osi_assert(scp->refCount > 0);
+ #endif
+     scp->refCount++;
+ }
+ 
  void cm_HoldSCache(cm_scache_t *scp)
  {
      lock_ObtainWrite(&cm_scacheLock);
***************
*** 986,991 ****
--- 995,1005 ----
      lock_ReleaseWrite(&cm_scacheLock);
  }
  
+ void cm_ReleaseSCacheNoLock(cm_scache_t *scp)
+ {
+     osi_assert(scp->refCount-- > 0);
+ }
+ 
  void cm_ReleaseSCache(cm_scache_t *scp)
  {
      lock_ObtainWrite(&cm_scacheLock);
***************
*** 1033,1041 ****
    
      for (scp = cm_scacheLRULastp; scp; scp = (cm_scache_t *) osi_QPrev(&scp->q)) 
      {
!         if (scp->refCount != 0)
          {
!             sprintf(output, "%s fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%d\n", 
                      cookie, scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique, 
                      scp->refCount);
              WriteFile(outputFile, output, strlen(output), &zilch, NULL);
--- 1047,1055 ----
    
      for (scp = cm_scacheLRULastp; scp; scp = (cm_scache_t *) osi_QPrev(&scp->q)) 
      {
!         if (scp->refCount > 0)
          {
!             sprintf(output, "%s fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u\n", 
                      cookie, scp->fid.cell, scp->fid.volume, scp->fid.vnode, scp->fid.unique, 
                      scp->refCount);
              WriteFile(outputFile, output, strlen(output), &zilch, NULL);
***************
*** 1051,1059 ****
          {
              if (scp)
              {
!                 if (scp->refCount)
                  {
!                     sprintf(output, "%s scp=0x%08X, hash=%d, fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%d\n", 
                              cookie, (void *)scp, i, scp->fid.cell, scp->fid.volume, scp->fid.vnode, 
                              scp->fid.unique, scp->refCount);
                      WriteFile(outputFile, output, strlen(output), &zilch, NULL);
--- 1065,1073 ----
          {
              if (scp)
              {
!                 if (scp->refCount > 0)
                  {
!                     sprintf(output, "%s scp=0x%08X, hash=%d, fid (cell=%d, volume=%d, vnode=%d, unique=%d) refCount=%u\n", 
                              cookie, (void *)scp, i, scp->fid.cell, scp->fid.volume, scp->fid.vnode, 
                              scp->fid.unique, scp->refCount);
                      WriteFile(outputFile, output, strlen(output), &zilch, NULL);
Index: openafs/src/WINNT/afsd/cm_scache.h
diff -c openafs/src/WINNT/afsd/cm_scache.h:1.4.2.3 openafs/src/WINNT/afsd/cm_scache.h:1.4.2.5
*** openafs/src/WINNT/afsd/cm_scache.h:1.4.2.3	Fri Nov  5 14:21:44 2004
--- openafs/src/WINNT/afsd/cm_scache.h	Tue Dec  7 01:01:41 2004
***************
*** 58,64 ****
          				 * write-locked to prevent buffers from
                                           * being created during a truncate op, etc.
                                           */
!         unsigned long refCount;			/* reference count; cm_scacheLock */
          osi_queueData_t *bufReadsp;	/* queue of buffers being read */
          osi_queueData_t *bufWritesp;	/* queue of buffers being written */
  
--- 58,64 ----
          				 * write-locked to prevent buffers from
                                           * being created during a truncate op, etc.
                                           */
!         long refCount;			/* reference count; cm_scacheLock */
          osi_queueData_t *bufReadsp;	/* queue of buffers being read */
          osi_queueData_t *bufWritesp;	/* queue of buffers being written */
  
***************
*** 240,247 ****
--- 240,251 ----
  
  extern void cm_AFSFidFromFid(struct AFSFid *, cm_fid_t *);
  
+ extern void cm_HoldSCacheNoLock(cm_scache_t *);
+ 
  extern void cm_HoldSCache(cm_scache_t *);
  
+ extern void cm_ReleaseSCacheNoLock(cm_scache_t *);
+ 
  extern void cm_ReleaseSCache(cm_scache_t *);
  
  extern cm_scache_t *cm_FindSCache(cm_fid_t *fidp);
***************
*** 256,259 ****
--- 260,265 ----
  
  extern void cm_DiscardSCache(cm_scache_t *scp);
  
+ extern int cm_FindFileType(cm_fid_t *fidp);
+ 
  #endif /*  __CM_SCACHE_H_ENV__ */
Index: openafs/src/WINNT/afsd/cm_user.c
diff -c openafs/src/WINNT/afsd/cm_user.c:1.5 openafs/src/WINNT/afsd/cm_user.c:1.5.2.1
*** openafs/src/WINNT/afsd/cm_user.c:1.5	Sun Apr  4 22:16:11 2004
--- openafs/src/WINNT/afsd/cm_user.c	Tue Dec  7 00:58:20 2004
***************
*** 27,121 ****
  
  void cm_InitUser(void)
  {
! 	static osi_once_t once;
          
!         if (osi_Once(&once)) {
! 		lock_InitializeRWLock(&cm_userLock, "cm_userLock");
!                 osi_EndOnce(&once);
! 	}
          
!         cm_rootUserp = cm_NewUser();
  }
  
  cm_user_t *cm_NewUser(void)
  {
! 	cm_user_t *up;
          
!         up = malloc(sizeof(*up));
!         memset(up, 0, sizeof(*up));
!         up->refCount = 1;
!         up->vcRefs = 1;		/* from caller */
!         lock_InitializeMutex(&up->mx, "cm_user_t");
!         return up;
  }
  
  /* must be called with locked userp */
  cm_ucell_t *cm_GetUCell(cm_user_t *userp, cm_cell_t *cellp)
  {
! 	cm_ucell_t *ucp;
          
! 	lock_AssertMutex(&userp->mx);
!         for(ucp = userp->cellInfop; ucp; ucp=ucp->nextp) {
! 		if (ucp->cellp == cellp) break;
!         }
          
!         if (!ucp) {
! 		ucp = malloc(sizeof(*ucp));
!                 memset(ucp, 0, sizeof(*ucp));
!                 ucp->nextp = userp->cellInfop;
! 		if (userp->cellInfop)
! 			ucp->iterator = userp->cellInfop->iterator + 1;
! 		else
! 			ucp->iterator = 1;
!                 userp->cellInfop = ucp;
!                 ucp->cellp = cellp;
!         }
          
!         return ucp;
  }
  
  cm_ucell_t *cm_FindUCell(cm_user_t *userp, int iterator)
  {
! 	cm_ucell_t *ucp;
! 	cm_ucell_t *best;
  
! 	best = NULL;
! 	lock_AssertMutex(&userp->mx);
! 	for (ucp = userp->cellInfop; ucp; ucp = ucp->nextp) {
! 		if (ucp->iterator >= iterator)
! 			best = ucp;
! 		else
! 			break;
! 	}
! 	return best;
  }
  
  void cm_HoldUser(cm_user_t *up)
  {
! 	lock_ObtainWrite(&cm_userLock);
! 	up->refCount++;
! 	lock_ReleaseWrite(&cm_userLock);
  }
  
  void cm_ReleaseUser(cm_user_t *up)
  {
! 	cm_ucell_t *ucp;
      cm_ucell_t *ncp;
  
! 	if (up == NULL) return;
  
! 	lock_ObtainWrite(&cm_userLock);
! 	osi_assert(up->refCount-- > 0);
! 	if (up->refCount == 0) {
! 		lock_FinalizeMutex(&up->mx);
!         for(ucp = up->cellInfop; ucp; ucp = ncp) {
! 			ncp = ucp->nextp;
! 			if (ucp->ticketp) free(ucp->ticketp);
              free(ucp);
          }
          free(up);
      }
! 	lock_ReleaseWrite(&cm_userLock);
  }
  
  /* release the count of the # of connections that use this user structure.
--- 27,124 ----
  
  void cm_InitUser(void)
  {
!     static osi_once_t once;
          
!     if (osi_Once(&once)) {
!         lock_InitializeRWLock(&cm_userLock, "cm_userLock");
!         osi_EndOnce(&once);
!     }
          
!     cm_rootUserp = cm_NewUser();
  }
  
  cm_user_t *cm_NewUser(void)
  {
!     cm_user_t *up;
          
!     up = malloc(sizeof(*up));
!     memset(up, 0, sizeof(*up));
!     up->refCount = 1;
!     up->vcRefs = 1;		/* from caller */
!     lock_InitializeMutex(&up->mx, "cm_user_t");
!     return up;
  }
  
  /* must be called with locked userp */
  cm_ucell_t *cm_GetUCell(cm_user_t *userp, cm_cell_t *cellp)
  {
!     cm_ucell_t *ucp;
          
!     lock_AssertMutex(&userp->mx);
!     for (ucp = userp->cellInfop; ucp; ucp=ucp->nextp) {
!         if (ucp->cellp == cellp) 
!             break;
!     }
          
!     if (!ucp) {
!         ucp = malloc(sizeof(*ucp));
!         memset(ucp, 0, sizeof(*ucp));
!         ucp->nextp = userp->cellInfop;
!         if (userp->cellInfop)
!             ucp->iterator = userp->cellInfop->iterator + 1;
!         else
!             ucp->iterator = 1;
!         userp->cellInfop = ucp;
!         ucp->cellp = cellp;
!     }
          
!     return ucp;
  }
  
  cm_ucell_t *cm_FindUCell(cm_user_t *userp, int iterator)
  {
!     cm_ucell_t *ucp;
!     cm_ucell_t *best;
  
!     best = NULL;
!     lock_AssertMutex(&userp->mx);
!     for (ucp = userp->cellInfop; ucp; ucp = ucp->nextp) {
!         if (ucp->iterator >= iterator)
!             best = ucp;
!         else
!             break;
!     }       
!     return best;
  }
  
  void cm_HoldUser(cm_user_t *up)
  {
!     lock_ObtainWrite(&cm_userLock);
!     up->refCount++;
!     lock_ReleaseWrite(&cm_userLock);
  }
  
  void cm_ReleaseUser(cm_user_t *up)
  {
!     cm_ucell_t *ucp;
      cm_ucell_t *ncp;
  
!     if (up == NULL) 
!         return;
  
!     lock_ObtainWrite(&cm_userLock);
!     osi_assert(up->refCount-- > 0);
!     if (up->refCount == 0) {
!         lock_FinalizeMutex(&up->mx);
!         for (ucp = up->cellInfop; ucp; ucp = ncp) {
!             ncp = ucp->nextp;
!             if (ucp->ticketp) 
!                 free(ucp->ticketp);
              free(ucp);
          }
          free(up);
      }
!     lock_ReleaseWrite(&cm_userLock);
  }
  
  /* release the count of the # of connections that use this user structure.
***************
*** 126,135 ****
   */
  void cm_ReleaseUserVCRef(cm_user_t *userp)
  {
! 	lock_ObtainMutex(&userp->mx);
! 	osi_assert(userp->vcRefs-- > 0);
! 	lock_ReleaseMutex(&userp->mx);
! }
  
  
  /*
--- 129,138 ----
   */
  void cm_ReleaseUserVCRef(cm_user_t *userp)
  {
!     lock_ObtainMutex(&userp->mx);
!     osi_assert(userp->vcRefs-- > 0);
!     lock_ReleaseMutex(&userp->mx);
! }       
  
  
  /*
***************
*** 142,187 ****
   */
  void cm_CheckTokenCache(long now)
  {
!         extern smb_vc_t *smb_allVCsp; /* global vcp list */
! 	smb_vc_t   *vcp;
! 	smb_user_t *usersp;
! 	cm_user_t  *userp = NULL;
! 	cm_ucell_t *ucellp;
! 	BOOL bExpired=FALSE;
!   
! 	/* 
! 	 * For every vcp, get the user and check his tokens 
! 	 */
! 	lock_ObtainWrite(&smb_rctLock);
! 	for(vcp=smb_allVCsp; vcp; vcp=vcp->nextp) {
! 	        for(usersp=vcp->usersp; usersp; usersp=usersp->nextp) {
! 				if (usersp->unp) {
! 		           if ((userp=usersp->unp->userp)==0)
! 					   continue;
! 				} else
! 					continue;
! 			lock_ObtainMutex(&userp->mx);
! 			for(ucellp=userp->cellInfop; ucellp; ucellp=ucellp->nextp) {
! 			  if(ucellp->flags & CM_UCELLFLAG_RXKAD) {
! 			    if(ucellp->expirationTime < now) {
! 				  /* this guy's tokens have expired */
! 				  osi_Log3(afsd_logp, "cm_CheckTokens: Tokens for user:%s have expired expiration time:0x%x ucellp:%x", ucellp->userName, ucellp->expirationTime, ucellp);
! 				  if (ucellp->ticketp) {
! 				          free(ucellp->ticketp);
! 					  ucellp->ticketp = NULL;
! 				  }
! 				  ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
! 				  ucellp->gen++;
! 				  bExpired=TRUE;
! 			    }
! 			  } 
! 			}
! 			lock_ReleaseMutex(&userp->mx);
! 			if(bExpired) {
! 			        bExpired=FALSE;
! 				cm_ResetACLCache(userp);
! 			}
! 		}
! 	}
! 	lock_ReleaseWrite(&smb_rctLock);
  }
--- 145,191 ----
   */
  void cm_CheckTokenCache(long now)
  {
!     extern smb_vc_t *smb_allVCsp; /* global vcp list */
!     smb_vc_t   *vcp;
!     smb_user_t *usersp;
!     cm_user_t  *userp = NULL;
!     cm_ucell_t *ucellp;
!     BOOL bExpired=FALSE;
! 
!     /* 
!      * For every vcp, get the user and check his tokens 
!      */
!     lock_ObtainWrite(&smb_rctLock);
!     for (vcp=smb_allVCsp; vcp; vcp=vcp->nextp) {
!         for (usersp=vcp->usersp; usersp; usersp=usersp->nextp) {
!             if (usersp->unp) {
!                 if ((userp=usersp->unp->userp)==0)
!                     continue;
!             } else
!                 continue;
!             lock_ObtainMutex(&userp->mx);
!             for (ucellp=userp->cellInfop; ucellp; ucellp=ucellp->nextp) {
!                 if (ucellp->flags & CM_UCELLFLAG_RXKAD) {
!                     if (ucellp->expirationTime < now) {
!                         /* this guy's tokens have expired */
!                         osi_Log3(afsd_logp, "cm_CheckTokens: Tokens for user:%s have expired expiration time:0x%x ucellp:%x", 
!                                  ucellp->userName, ucellp->expirationTime, ucellp);
!                         if (ucellp->ticketp) {
!                             free(ucellp->ticketp);
!                             ucellp->ticketp = NULL;
!                         }
!                         ucellp->flags &= ~CM_UCELLFLAG_RXKAD;
!                         ucellp->gen++;
!                         bExpired=TRUE;
!                     }
!                 } 
!             }
!             lock_ReleaseMutex(&userp->mx);
!             if (bExpired) {
!                 bExpired=FALSE;
!                 cm_ResetACLCache(userp);
!             }
!         }
!     }
!     lock_ReleaseWrite(&smb_rctLock);
  }
Index: openafs/src/WINNT/afsd/cm_user.h
diff -c openafs/src/WINNT/afsd/cm_user.h:1.2.20.1 openafs/src/WINNT/afsd/cm_user.h:1.2.20.2
*** openafs/src/WINNT/afsd/cm_user.h:1.2.20.1	Mon Oct 18 00:09:26 2004
--- openafs/src/WINNT/afsd/cm_user.h	Tue Dec  7 00:58:20 2004
***************
*** 21,49 ****
   * corresponding userp's userp->mx mutex.
   */
  typedef struct cm_ucell {
! 	struct cm_ucell *nextp;		/* next cell in the list */
!         struct cm_cell *cellp;		/* the cell this applies to */
! 	char *ticketp;			/* locked by mx */
!         int ticketLen;			/* by mx */
!         struct ktc_encryptionKey sessionKey;	/* by mx */
!         long kvno;			/* key version in ticket */
!         long expirationTime;		/* when tix expire */
! 	int gen;			/* generation number */
! 	int iterator;			/* for use as ListTokens cookie */
!         long flags;			/* flags */
! 	char userName[MAXKTCNAMELEN];	/* user name */
  } cm_ucell_t;
  
  #define CM_UCELLFLAG_HASTIX	1	/* has Kerberos tickets */
  #define CM_UCELLFLAG_RXKAD	2	/* an rxkad connection */
  #define CM_UCELLFLAG_BADTIX	4	/* tickets are bad or expired */
  
  typedef struct cm_user {
! 	unsigned long refCount;			/* ref count */
! 	cm_ucell_t *cellInfop;		/* list of cell info */
!         osi_mutex_t mx;			/* mutex */
!         int vcRefs;			/* count of references from virtual circuits */
!         long flags;
  } cm_user_t;
  
  #define CM_USERFLAG_DELETE	1	/* delete on last reference */
--- 21,50 ----
   * corresponding userp's userp->mx mutex.
   */
  typedef struct cm_ucell {
!     struct cm_ucell *nextp;		/* next cell in the list */
!     struct cm_cell *cellp;		/* the cell this applies to */
!     char *ticketp;			/* locked by mx */
!     int ticketLen;			/* by mx */
!     struct ktc_encryptionKey sessionKey;/* by mx */
!     long kvno;			        /* key version in ticket */
!     long expirationTime;		/* when tix expire */
!     int gen;			        /* generation number */
!     int iterator;			/* for use as ListTokens cookie */
!     long flags;			        /* flags */
!     char userName[MAXKTCNAMELEN];	/* user name */
  } cm_ucell_t;
  
  #define CM_UCELLFLAG_HASTIX	1	/* has Kerberos tickets */
  #define CM_UCELLFLAG_RXKAD	2	/* an rxkad connection */
  #define CM_UCELLFLAG_BADTIX	4	/* tickets are bad or expired */
+ #define CM_UCELLFLAG_RXGK       8       /* an rxgk connection */
  
  typedef struct cm_user {
!     unsigned long refCount;             /* ref count - cm_userLock */
!     cm_ucell_t *cellInfop;	        /* list of cell info */
!     osi_mutex_t mx;		        /* mutex */
!     int vcRefs;			        /* count of references from virtual circuits */
!     long flags;
  } cm_user_t;
  
  #define CM_USERFLAG_DELETE	1	/* delete on last reference */
Index: openafs/src/WINNT/afsd/cm_vnodeops.c
diff -c openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.5 openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.7
*** openafs/src/WINNT/afsd/cm_vnodeops.c:1.19.2.5	Fri Nov  5 14:21:44 2004
--- openafs/src/WINNT/afsd/cm_vnodeops.c	Tue Dec  7 01:16:22 2004
***************
*** 552,561 ****
              lock_ObtainRead(&scp->bufCreateLock);
              code = buf_Get(scp, &thyper, &bufferp);
              lock_ReleaseRead(&scp->bufCreateLock);
  
              lock_ObtainMutex(&bufferp->mx);
-             if (code) 
-                 break;
              bufferOffset = thyper;
  
              /* now get the data in the cache */
--- 552,564 ----
              lock_ObtainRead(&scp->bufCreateLock);
              code = buf_Get(scp, &thyper, &bufferp);
              lock_ReleaseRead(&scp->bufCreateLock);
+ 			if (code) {
+ 				/* if buf_Get() fails we do not have a buffer object to lock */
+                 bufferp = NULL;
+                 break;
+ 			}
  
              lock_ObtainMutex(&bufferp->mx);
              bufferOffset = thyper;
  
              /* now get the data in the cache */
***************
*** 1004,1013 ****
                  return CM_ERROR_NOSUCHFILE;
          }
          else {  /* nonexistent dir on freelance root, so add it */
              osi_Log1(afsd_logp,"cm_Lookup adding mount for non-existent directory: %s", 
                        osi_LogSaveString(afsd_logp,namep));
!             code = cm_FreelanceAddMount(namep, namep, "root.cell.", namep[0] == '.', &rock.fid);
!             if (code < 0) {   /* add mount point failed, so give up */
                  if (flags & CM_FLAG_CHECKPATH)
                      return CM_ERROR_NOSUCHPATH;
                  else
--- 1007,1034 ----
                  return CM_ERROR_NOSUCHFILE;
          }
          else {  /* nonexistent dir on freelance root, so add it */
+             char fullname[200] = ".";
+             int  found = 0;
+ 
              osi_Log1(afsd_logp,"cm_Lookup adding mount for non-existent directory: %s", 
                        osi_LogSaveString(afsd_logp,namep));
!             if (namep[0] == '.') {
!                 if (cm_GetCell_Gen(&namep[1], &fullname[1], CM_FLAG_CREATE)) {
!                     found = 1;
!                     if ( stricmp(&namep[1], &fullname[1]) )
!                         code = cm_FreelanceAddSymlink(namep, fullname, &rock.fid);
!                     else
!                         code = cm_FreelanceAddMount(namep, &fullname[1], "root.cell.", 1, &rock.fid);
!                 }
!             } else {
!                 if (cm_GetCell_Gen(namep, fullname, CM_FLAG_CREATE))
!                     found = 1;
!                 if ( stricmp(namep, fullname) )
!                     code = cm_FreelanceAddSymlink(namep, fullname, &rock.fid);
!                 else
!                     code = cm_FreelanceAddMount(namep, fullname, "root.cell.", 0, &rock.fid);
!             }
!             if (!found || code < 0) {   /* add mount point failed, so give up */
                  if (flags & CM_FLAG_CHECKPATH)
                      return CM_ERROR_NOSUCHPATH;
                  else
Index: openafs/src/WINNT/afsd/cm_volume.c
diff -c openafs/src/WINNT/afsd/cm_volume.c:1.8.2.1 openafs/src/WINNT/afsd/cm_volume.c:1.8.2.2
*** openafs/src/WINNT/afsd/cm_volume.c:1.8.2.1	Tue Aug 17 00:28:39 2004
--- openafs/src/WINNT/afsd/cm_volume.c	Tue Dec  7 00:53:57 2004
***************
*** 39,161 ****
  
  /*
   * Update a volume.  Caller holds volume's lock (volp->mx).
   */
  long cm_UpdateVolume(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *reqp,
  	cm_volume_t *volp)
  {
      cm_conn_t *connp;
      int i;
! 	cm_serverRef_t *tsrp;
      cm_server_t *tsp;
      struct sockaddr_in tsockAddr;
      long tflags;
      u_long tempAddr;
!     struct vldbentry vldbEntry;	/* don't use NVLDB yet; they're not common */
! 	int ROcount = 0;
! 	long code;
  
! 	/* clear out old bindings */
      cm_FreeServerList(&volp->rwServersp);
      cm_FreeServerList(&volp->roServersp);
      cm_FreeServerList(&volp->bkServersp);
  
      /* now we have volume structure locked and held; make RPC to fill it */
      do {
! 		code = cm_ConnByMServers(cellp->vlServersp, userp, reqp,
!                                   &connp);
!         if (code) continue;
! 		osi_Log1(afsd_logp, "CALL VL_GetEntryByNameO name %s",
!                   volp->namep);
!         code = VL_GetEntryByNameO(connp->callp, volp->namep, &vldbEntry);
! 	} while (cm_Analyze(connp, userp, reqp, NULL, NULL, cellp->vlServersp, NULL, code));
      code = cm_MapVLRPCError(code, reqp);
  
      if (code == 0) {
! 		/* decode the response */
! 		lock_ObtainWrite(&cm_volumeLock);
!         if (vldbEntry.flags & VLF_RWEXISTS)
!             volp->rwID = vldbEntry.volumeId[0];
! 		else
              volp->rwID = 0;
!         if (vldbEntry.flags & VLF_ROEXISTS)
!             volp->roID = vldbEntry.volumeId[1];
          else
              volp->roID = 0;
!         if (vldbEntry.flags & VLF_BACKEXISTS)
!             volp->bkID = vldbEntry.volumeId[2];
! 		else
              volp->bkID = 0;
! 		lock_ReleaseWrite(&cm_volumeLock);
!         for(i=0; i<vldbEntry.nServers; i++) {
! 			/* create a server entry */
! 			tflags = vldbEntry.serverFlags[i];
! 			if (tflags & VLSF_DONTUSE) continue;
! 			tsockAddr.sin_family = AF_INET;
! 			tempAddr = htonl(vldbEntry.serverNumber[i]);
! 			tsockAddr.sin_addr.s_addr = tempAddr;
! 			tsp = cm_FindServer(&tsockAddr, CM_SERVER_FILE);
! 			if (!tsp)
                  tsp = cm_NewServer(&tsockAddr, CM_SERVER_FILE,
                                      cellp);
  
! 			/* if this server was created by fs setserverprefs */
! 			if ( !tsp->cellp ) 
! 				tsp->cellp = cellp;
  
              osi_assert(tsp != NULL);
                          
              /* and add it to the list(s). */
! 			/*
               * Each call to cm_NewServerRef() increments the
               * ref count of tsp.  These reference will be dropped,
! 			 * if and when the volume is reset; see reset code
! 			 * earlier in this function.
! 			 */
! 			if ((tflags & VLSF_RWVOL)
!                  && (vldbEntry.flags & VLF_RWEXISTS)) {
! 				tsrp = cm_NewServerRef(tsp);
                  cm_InsertServerList(&volp->rwServersp, tsrp);
                  lock_ObtainWrite(&cm_serverLock);
                  tsrp->refCount--;       /* drop allocation reference */
                  lock_ReleaseWrite(&cm_serverLock);
! 			}
!             if ((tflags & VLSF_ROVOL)
!                  && (vldbEntry.flags & VLF_ROEXISTS)) {
! 				tsrp = cm_NewServerRef(tsp);
! 				cm_InsertServerList(&volp->roServersp, tsrp);
                  lock_ObtainWrite(&cm_serverLock);
                  tsrp->refCount--;       /* drop allocation reference */
                  lock_ReleaseWrite(&cm_serverLock);
! 				ROcount++;
              }
! 			/* We don't use VLSF_BACKVOL !?! */
!             if ((tflags & VLSF_RWVOL)
!                  && (vldbEntry.flags & VLF_BACKEXISTS)) {
! 				tsrp = cm_NewServerRef(tsp);
                  cm_InsertServerList(&volp->bkServersp, tsrp);
                  lock_ObtainWrite(&cm_serverLock);
                  tsrp->refCount--;       /* drop allocation reference */
                  lock_ReleaseWrite(&cm_serverLock);
! 			}
! 			/* Drop the reference obtained by cm_FindServer() */
! 			cm_PutServer(tsp);
          }
! 
! 		/*
! 		 * Randomize RO list
! 		 *
! 		 * If the first n servers have the same ipRank, then we 
! 		 * randomly pick one among them and move it to the beginning.
! 		 * We don't bother to re-order the whole list because
! 		 * the rest of the list is used only if the first server is
! 		 * down.  We only do this for the RO list; we assume the other
! 		 * lists are length 1.
! 		 */
! 		if (ROcount > 1) {
! 			cm_RandomizeServer(&volp->roServersp);
! 		}
! 	}
! 	return code;
  }
  
  long cm_GetVolumeByID(cm_cell_t *cellp, long volumeID, cm_user_t *userp,
--- 39,250 ----
  
  /*
   * Update a volume.  Caller holds volume's lock (volp->mx).
+  *
+  *
+  *  shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU}  01:38    (JHutz)
+  *    Yes, we support multihomed fileservers.
+  *    Since before we got the code from IBM.
+  *    But to find out about multiple addresses on a multihomed server, you need
+  *    to use VL_GetEntryByNameU and VL_GetAddrsU.  If you use
+  *    VL_GetEntryByNameO or VL_GetEntryByNameN, the vlserver just gives you one
+  *    address per server.
+  *  shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU}  01:39    (JHutz)
+  *    see src/afs/afs_volume.c, paying particular attention to
+  *    afs_NewVolumeByName, afs_SetupVolume, and InstallUVolumeEntry
+  *  shadow / openafs / jaltman {ANDREW.CMU.EDU}  01:40    (Jeffrey Altman)
+  *    thanks.  The windows client calls the 0 versions.
+  *  shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU}  01:51    (JHutz)
+  *    Oh.  Ew.
+  *    By not using the N versions, you only get up to 8 sites instead of 13.
+  *    By not using the U versions, you don't get to know about multihomed serve
+  *  shadow / openafs / jhutz@CS.CMU.EDU {ANDREW.CMU.EDU}  01:52    (JHutz)
+  *    Of course, you probably want to support the older versions for backward
+  *    compatibility.  If you do that, you need to call the newest interface
+  *    first, and fall back to successively older versions if you get
+  *    RXGEN_OPCODE.
   */
  long cm_UpdateVolume(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *reqp,
  	cm_volume_t *volp)
  {
      cm_conn_t *connp;
      int i;
!     cm_serverRef_t *tsrp;
      cm_server_t *tsp;
      struct sockaddr_in tsockAddr;
      long tflags;
      u_long tempAddr;
!     struct vldbentry vldbEntry;
!     struct nvldbentry nvldbEntry;
! #ifdef MULTIHOMED
!     struct uvldbentry uvldbEntry;
! #endif
!     int type = -1;
!     int ROcount = 0;
!     long code;
  
!     /* clear out old bindings */
      cm_FreeServerList(&volp->rwServersp);
      cm_FreeServerList(&volp->roServersp);
      cm_FreeServerList(&volp->bkServersp);
  
      /* now we have volume structure locked and held; make RPC to fill it */
      do {
!         code = cm_ConnByMServers(cellp->vlServersp, userp, reqp, &connp);
!         if (code) 
!             continue;
!         osi_Log1(afsd_logp, "CALL VL_GetEntryByName{UNO} name %s", volp->namep);
! #ifdef MULTIHOMED
!         code = VL_GetEntryByNameU(connp->callp, volp->namep, &uvldbEntry);
!         if ( code == RXGEN_OPCODE ) 
! #endif
!         {
!             code = VL_GetEntryByNameN(connp->callp, volp->namep, &nvldbEntry);
!             type = 1;
!         }
!         if ( code == RXGEN_OPCODE ) {
!             code = VL_GetEntryByNameO(connp->callp, volp->namep, &vldbEntry);
!             type = 0;
!         }
!     } while (cm_Analyze(connp, userp, reqp, NULL, NULL, cellp->vlServersp, NULL, code));
      code = cm_MapVLRPCError(code, reqp);
  
      if (code == 0) {
!         afs_int32 flags;
!         afs_int32 nServers;
!         afs_int32 rwID;
!         afs_int32 roID;
!         afs_int32 bkID;
!         afs_int32 serverNumber[NMAXNSERVERS];
!         afs_int32 serverFlags[NMAXNSERVERS];
! 
!         switch ( type ) {
!         case 0:
!             flags = vldbEntry.flags;
!             nServers = vldbEntry.nServers;
!             rwID = vldbEntry.volumeId[0];
!             roID = vldbEntry.volumeId[1];
!             bkID = vldbEntry.volumeId[2];
!             for ( i=0; i<nServers; i++ ) {
!                 serverFlags[i] = vldbEntry.serverFlags[i];
!                 serverNumber[i] = vldbEntry.serverNumber[i];
!             }
!             break;
!         case 1:
!             flags = nvldbEntry.flags;
!             nServers = nvldbEntry.nServers;
!             rwID = nvldbEntry.volumeId[0];
!             roID = nvldbEntry.volumeId[1];
!             bkID = nvldbEntry.volumeId[2];
!             for ( i=0; i<nServers; i++ ) {
!                 serverFlags[i] = nvldbEntry.serverFlags[i];
!                 serverNumber[i] = nvldbEntry.serverNumber[i];
!             }
!             break;
! #ifdef MULTIHOMED
!         case 2:
!             flags = uvldbEntry.flags;
!             nServers = uvldbEntry.nServers;
!             rwID = uvldbEntry.volumeId[0];
!             roID = uvldbEntry.volumeId[1];
!             bkID = uvldbEntry.volumeId[2];
!             for ( i=0; i<nServers; i++ ) {
!                 serverFlags[i] = uvldbEntry.serverFlags[i];
!                 if ( !(flags & VLSERVER_FLAG_UUID) )
!                     serverNumber[i] = uvldbEntry.serverNumber[i].time_low;
!                 else {
!                     /* see afs/afs_volume.c InstallUVolumeEntry().  We need to 
!                      * implement an equivalent to afs_FindServer() and afs_GetServer()
!                      * which support multiple addresses.
!                      */
!                 }
!             }
!             break;
! #endif
!         }
! 
!         /* decode the response */
!         lock_ObtainWrite(&cm_volumeLock);
!         if (flags & VLF_RWEXISTS)
!             volp->rwID = rwID;
!         else
              volp->rwID = 0;
!         if (flags & VLF_ROEXISTS)
!             volp->roID = roID;
          else
              volp->roID = 0;
!         if (flags & VLF_BACKEXISTS)
!             volp->bkID = bkID;
!         else
              volp->bkID = 0;
!         lock_ReleaseWrite(&cm_volumeLock);
!         for (i=0; i<nServers; i++) {
!             /* create a server entry */
!             tflags = serverFlags[i];
!             if (tflags & VLSF_DONTUSE) 
!                 continue;
!             tsockAddr.sin_family = AF_INET;
!             tempAddr = htonl(serverNumber[i]);
!             tsockAddr.sin_addr.s_addr = tempAddr;
!             tsp = cm_FindServer(&tsockAddr, CM_SERVER_FILE);
!             if (!tsp)
                  tsp = cm_NewServer(&tsockAddr, CM_SERVER_FILE,
                                      cellp);
  
!             /* if this server was created by fs setserverprefs */
!             if ( !tsp->cellp ) 
!                 tsp->cellp = cellp;
  
              osi_assert(tsp != NULL);
                          
              /* and add it to the list(s). */
!             /*
               * Each call to cm_NewServerRef() increments the
               * ref count of tsp.  These reference will be dropped,
!              * if and when the volume is reset; see reset code
!              * earlier in this function.
!              */
!             if ((tflags & VLSF_RWVOL) && (flags & VLF_RWEXISTS)) {
!                 tsrp = cm_NewServerRef(tsp);
                  cm_InsertServerList(&volp->rwServersp, tsrp);
                  lock_ObtainWrite(&cm_serverLock);
                  tsrp->refCount--;       /* drop allocation reference */
                  lock_ReleaseWrite(&cm_serverLock);
!             }
!             if ((tflags & VLSF_ROVOL) && (flags & VLF_ROEXISTS)) {
!                 tsrp = cm_NewServerRef(tsp);
!                 cm_InsertServerList(&volp->roServersp, tsrp);
                  lock_ObtainWrite(&cm_serverLock);
                  tsrp->refCount--;       /* drop allocation reference */
                  lock_ReleaseWrite(&cm_serverLock);
!                 ROcount++;
              }
!             /* We don't use VLSF_BACKVOL !?! */
!             if ((tflags & VLSF_RWVOL) && (flags & VLF_BACKEXISTS)) {
!                 tsrp = cm_NewServerRef(tsp);
                  cm_InsertServerList(&volp->bkServersp, tsrp);
                  lock_ObtainWrite(&cm_serverLock);
                  tsrp->refCount--;       /* drop allocation reference */
                  lock_ReleaseWrite(&cm_serverLock);
!             }
!             /* Drop the reference obtained by cm_FindServer() */
!             cm_PutServer(tsp);
!         }       
! 
!         /*
!          * Randomize RO list
!          *
!          * If the first n servers have the same ipRank, then we 
!          * randomly pick one among them and move it to the beginning.
!          * We don't bother to re-order the whole list because
!          * the rest of the list is used only if the first server is
!          * down.  We only do this for the RO list; we assume the other
!          * lists are length 1.
!          */
!         if (ROcount > 1) {
!             cm_RandomizeServer(&volp->roServersp);
          }
!     }
!     return code;
  }
  
  long cm_GetVolumeByID(cm_cell_t *cellp, long volumeID, cm_user_t *userp,
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.55.2.4 openafs/src/WINNT/afsd/smb.c:1.55.2.9
*** openafs/src/WINNT/afsd/smb.c:1.55.2.4	Fri Nov  5 14:21:45 2004
--- openafs/src/WINNT/afsd/smb.c	Tue Dec  7 07:49:31 2004
***************
*** 51,56 ****
--- 51,58 ----
  int smb_LogoffTokenTransfer;
  time_t smb_LogoffTransferTimeout;
  
+ int smb_StoreAnsiFilenames = 0;
+ 
  DWORD last_msg_time = 0;
  
  long ongoingOps = 0;
***************
*** 95,100 ****
--- 97,103 ----
  #define NCBmax MAXIMUM_WAIT_OBJECTS
  EVENT_HANDLE NCBavails[NCBmax], NCBevents[NCBmax];
  EVENT_HANDLE **NCBreturns;
+ EVENT_HANDLE *smb_ServerShutdown;
  DWORD NCBsessions[NCBmax];
  NCB *NCBs[NCBmax];
  struct smb_packet *bufs[NCBmax];
***************
*** 157,163 ****
   * Time in Unix format of midnight, 1/1/1970 local time.
   * When added to dosUTime, gives Unix (AFS) time.
   */
! long smb_localZero = 0;
  
  /* Time difference for converting to kludge-GMT */
  int smb_NowTZ;
--- 160,166 ----
   * Time in Unix format of midnight, 1/1/1970 local time.
   * When added to dosUTime, gives Unix (AFS) time.
   */
! time_t smb_localZero = 0;
  
  /* Time difference for converting to kludge-GMT */
  int smb_NowTZ;
***************
*** 362,367 ****
--- 365,374 ----
          return "S(0d)_ReceiveTran2CreateDirectory";
      case 14:
          return "S(0e)_ReceiveTran2SessionSetup";
+     case 16:
+         return "S(10)_ReceiveTran2GetDfsReferral";
+     case 17:
+         return "S(11)_ReceiveTran2ReportDfsInconsistency";
      }
  }       
  
***************
*** 392,405 ****
      {
          attrs = SMB_ATTR_DIRECTORY;
  #ifdef SPECIAL_FOLDERS
! #ifdef AFS_FREELANCE_CLIENT
!         if ( cm_freelanceEnabled &&
!              scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && 
!              scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
!              scp->fid.vnode==0x1 && scp->fid.unique==0x1) {
!             attrs |= SMB_ATTR_SYSTEM;		/* FILE_ATTRIBUTE_SYSTEM */
!         }
! #endif /* AFS_FREELANCE_CLIENT */
  #endif /* SPECIAL_FOLDERS */
      } else
          attrs = 0;
--- 399,405 ----
      {
          attrs = SMB_ATTR_DIRECTORY;
  #ifdef SPECIAL_FOLDERS
!         attrs |= SMB_ATTR_SYSTEM;		/* FILE_ATTRIBUTE_SYSTEM */
  #endif /* SPECIAL_FOLDERS */
      } else
          attrs = 0;
***************
*** 713,719 ****
  }       
  #endif /* !DJGPP */
  
! void smb_SearchTimeFromUnixTime(long *dosTimep, time_t unixTime)
  {
      struct tm *ltp;
      int dosDate;
--- 713,719 ----
  }       
  #endif /* !DJGPP */
  
! void smb_SearchTimeFromUnixTime(time_t *dosTimep, time_t unixTime)
  {
      struct tm *ltp;
      int dosDate;
***************
*** 745,752 ****
      unsigned short dosTime;
      struct tm localTm;
          
!     dosDate = searchTime & 0xffff;
!     dosTime = (searchTime >> 16) & 0xffff;
  
      localTm.tm_year = 80 + ((dosDate>>9) & 0x3f);
      localTm.tm_mon = ((dosDate >> 5) & 0xf) - 1;	/* January is 0 in localTm */
--- 745,752 ----
      unsigned short dosTime;
      struct tm localTm;
          
!     dosDate = (unsigned short) (searchTime & 0xffff);
!     dosTime = (unsigned short) ((searchTime >> 16) & 0xffff);
  
      localTm.tm_year = 80 + ((dosDate>>9) & 0x3f);
      localTm.tm_mon = ((dosDate >> 5) & 0xf) - 1;	/* January is 0 in localTm */
***************
*** 1655,1661 ****
      int i;
          
      victimCount = 0;	/* how many have we got so far */
!     for(tp = smb_lastDirSearchp; tp; tp=prevp) {
          /* we'll move tp from queue, so
           * do this early.
           */
--- 1655,1661 ----
      int i;
          
      victimCount = 0;	/* how many have we got so far */
!     for (tp = smb_lastDirSearchp; tp; tp=prevp) {
          /* we'll move tp from queue, so
           * do this early.
           */
***************
*** 2869,2880 ****
  {
      afs_uint32 count = 0;
  
!     while(1) {
          count++;
          thrd_Sleep(10000);
          if ((count % 72) == 0)	{	/* every five minutes */
              struct tm myTime;
!             long old_localZero = smb_localZero;
  		 
              /* Initialize smb_localZero */
              myTime.tm_isdst = -1;		/* compute whether on DST or not */
--- 2869,2884 ----
  {
      afs_uint32 count = 0;
  
!     while(smbShutdownFlag == 0) {
          count++;
          thrd_Sleep(10000);
+ 
+         if (smbShutdownFlag == 1)
+             break;
+         
          if ((count % 72) == 0)	{	/* every five minutes */
              struct tm myTime;
!             time_t old_localZero = smb_localZero;
  		 
              /* Initialize smb_localZero */
              myTime.tm_isdst = -1;		/* compute whether on DST or not */
***************
*** 2996,3001 ****
--- 3000,3007 ----
      /* parse input parameters */
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
      passwordp = smb_ParseASCIIBlock(tp, &tp);
      tp = strrchr(pathp, '\\');
      if (!tp)
***************
*** 3172,3177 ****
--- 3178,3185 ----
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, (char **) &tp);
      osi_assert(pathp != NULL);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
      statBlockp = smb_ParseVblBlock(tp, (char **) &tp, &statLen);
      osi_assert(statBlockp != NULL);
      if (statLen == 0) {
***************
*** 3269,3280 ****
          smb_SearchTimeFromUnixTime(&dosTime, scp->clientModTime);
                  
          /* copy out time */
!         shortTemp = dosTime & 0xffff;
          *((u_short *)dptr) = shortTemp;
          dptr += 2;
  
          /* and copy out date */
!         shortTemp = (dosTime>>16) & 0xffff;
          *((u_short *)dptr) = shortTemp;
          dptr += 2;
                  
--- 3277,3288 ----
          smb_SearchTimeFromUnixTime(&dosTime, scp->clientModTime);
                  
          /* copy out time */
!         shortTemp = (unsigned short) (dosTime & 0xffff);
          *((u_short *)dptr) = shortTemp;
          dptr += 2;
  
          /* and copy out date */
!         shortTemp = (unsigned short) ((dosTime>>16) & 0xffff);
          *((u_short *)dptr) = shortTemp;
          dptr += 2;
                  
***************
*** 3353,3358 ****
--- 3361,3368 ----
  
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
      inCookiep = smb_ParseVblBlock(tp, &tp, &dataLength);
  
      /* bail out if request looks bad */
***************
*** 3655,3661 ****
               * attributes */
  
              /* no hidden files */
!             if(smb_hideDotFiles && !(dsp->attribute & SMB_ATTR_HIDDEN) && smb_IsDotFile(actualName))
                  goto nextEntry;
  
              if (!(dsp->attribute & SMB_ATTR_DIRECTORY))  /* no directories */
--- 3665,3671 ----
               * attributes */
  
              /* no hidden files */
!             if (smb_hideDotFiles && !(dsp->attribute & SMB_ATTR_HIDDEN) && smb_IsDotFile(actualName))
                  goto nextEntry;
  
              if (!(dsp->attribute & SMB_ATTR_DIRECTORY))  /* no directories */
***************
*** 3724,3729 ****
--- 3734,3741 ----
               * never hurts to be sure.
               */
              strncpy(op, actualName, 13);
+             if (smb_StoreAnsiFilenames)
+                 CharToOem(op, op);
  
              /* Uppercase if requested by client */
              if ((((smb_t *)inp)->flg2 & 1) == 0)
***************
*** 3807,3818 ****
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
      osi_Log1(smb_logp, "SMB receive check path %s",
               osi_LogSaveString(smb_logp, pathp));
- 
-     if (!pathp) {
-         return CM_ERROR_BADFD;
-     }
          
      rootScp = cm_rootSCachep;
          
--- 3819,3830 ----
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
+     if (!pathp)
+         return CM_ERROR_BADFD;
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
      osi_Log1(smb_logp, "SMB receive check path %s",
               osi_LogSaveString(smb_logp, pathp));
          
      rootScp = cm_rootSCachep;
          
***************
*** 3879,3889 ****
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
! 
!     if (!pathp) {
          return CM_ERROR_BADSMB;
!     }
!         
      osi_Log2(smb_logp, "SMB receive setfile attributes time %d, attr 0x%x",
               dosTime, attribute);
  
--- 3891,3901 ----
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
!     if (!pathp)
          return CM_ERROR_BADSMB;
!     if (smb_StoreAnsiFilenames)
!         OemToChar(pathp,pathp);
!                
      osi_Log2(smb_logp, "SMB receive setfile attributes time %d, attr 0x%x",
               dosTime, attribute);
  
***************
*** 3977,3989 ****
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
! 
!     if (!pathp) {
          return CM_ERROR_BADSMB;
-     }
          
      if (*pathp == 0)		/* null path */
          pathp = "\\";
  
      osi_Log1(smb_logp, "SMB receive getfile attributes path %s",
               osi_LogSaveString(smb_logp, pathp));
--- 3989,4002 ----
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
!     if (!pathp)
          return CM_ERROR_BADSMB;
          
      if (*pathp == 0)		/* null path */
          pathp = "\\";
+     else
+         if (smb_StoreAnsiFilenames)
+             OemToChar(pathp,pathp);
  
      osi_Log1(smb_logp, "SMB receive getfile attributes path %s",
               osi_LogSaveString(smb_logp, pathp));
***************
*** 4020,4025 ****
--- 4033,4039 ----
       */
      spacep = inp->spacep;
      smb_StripLastComponent(spacep->data, &lastComp, pathp);
+ #ifndef SPECIAL_FOLDERS
      if (lastComp && stricmp(lastComp, "\\desktop.ini") == 0) {
          code = cm_NameI(rootScp, spacep->data,
                          caseFold | CM_FLAG_DIRSEARCH | CM_FLAG_FOLLOW,
***************
*** 4042,4047 ****
--- 4056,4062 ----
              }
          }
      }
+ #endif /* SPECIAL_FOLDERS */
  
      code = cm_NameI(rootScp, pathp, caseFold | CM_FLAG_FOLLOW, userp,
                      tidPathp, &req, &newScp);
***************
*** 4079,4086 ****
      smb_SetSMBParm(outp, 0, attrs);
          
      smb_DosUTimeFromUnixTime(&dosTime, newScp->clientModTime);
!     smb_SetSMBParm(outp, 1, dosTime & 0xffff);
!     smb_SetSMBParm(outp, 2, (dosTime>>16) & 0xffff);
      smb_SetSMBParm(outp, 3, newScp->length.LowPart & 0xffff);
      smb_SetSMBParm(outp, 4, (newScp->length.LowPart >> 16) & 0xffff);
      smb_SetSMBParm(outp, 5, 0);
--- 4094,4101 ----
      smb_SetSMBParm(outp, 0, attrs);
          
      smb_DosUTimeFromUnixTime(&dosTime, newScp->clientModTime);
!     smb_SetSMBParm(outp, 1, (unsigned int)(dosTime & 0xffff));
!     smb_SetSMBParm(outp, 2, (unsigned int)((dosTime>>16) & 0xffff));
      smb_SetSMBParm(outp, 3, newScp->length.LowPart & 0xffff);
      smb_SetSMBParm(outp, 4, (newScp->length.LowPart >> 16) & 0xffff);
      smb_SetSMBParm(outp, 5, 0);
***************
*** 4135,4140 ****
--- 4150,4157 ----
  
      pathp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(pathp, NULL);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
  	
      osi_Log1(smb_logp, "SMB receive open file [%s]", osi_LogSaveString(smb_logp, pathp));
  
***************
*** 4223,4230 ****
      smb_SetSMBParm(outp, 0, fidp->fid);
      smb_SetSMBParm(outp, 1, smb_Attributes(scp));
      smb_DosUTimeFromUnixTime(&dosTime, scp->clientModTime);
!     smb_SetSMBParm(outp, 2, dosTime & 0xffff);
!     smb_SetSMBParm(outp, 3, (dosTime >> 16) & 0xffff);
      smb_SetSMBParm(outp, 4, scp->length.LowPart & 0xffff);
      smb_SetSMBParm(outp, 5, (scp->length.LowPart >> 16) & 0xffff);
      /* pass the open mode back; XXXX add access checks */
--- 4240,4247 ----
      smb_SetSMBParm(outp, 0, fidp->fid);
      smb_SetSMBParm(outp, 1, smb_Attributes(scp));
      smb_DosUTimeFromUnixTime(&dosTime, scp->clientModTime);
!     smb_SetSMBParm(outp, 2, (unsigned int)(dosTime & 0xffff));
!     smb_SetSMBParm(outp, 3, (unsigned int)((dosTime >> 16) & 0xffff));
      smb_SetSMBParm(outp, 4, scp->length.LowPart & 0xffff);
      smb_SetSMBParm(outp, 5, (scp->length.LowPart >> 16) & 0xffff);
      /* pass the open mode back; XXXX add access checks */
***************
*** 4320,4325 ****
--- 4337,4344 ----
          
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
  
      osi_Log1(smb_logp, "SMB receive unlink %s",
               osi_LogSaveString(smb_logp, pathp));
***************
*** 4741,4747 ****
--- 4760,4770 ----
  
      tp = smb_GetSMBData(inp, NULL);
      oldPathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(oldPathp,oldPathp);
      newPathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(newPathp,newPathp);
  
      osi_Log2(smb_logp, "smb rename [%s] to [%s]",
                osi_LogSaveString(smb_logp, oldPathp),
***************
*** 4818,4823 ****
--- 4841,4848 ----
  
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
  
      spacep = inp->spacep;
      smb_StripLastComponent(spacep->data, &lastNamep, pathp);
***************
*** 5449,5455 ****
                              writeBackOffset.HighPart, cm_chunkSize, 0, userp);
      }
  
!     osi_Log2(smb_logp, "smb_WriteData fid %d returns %d written %d",
                fidp->fid, code, *writtenp);
      return code;
  }
--- 5474,5480 ----
                              writeBackOffset.HighPart, cm_chunkSize, 0, userp);
      }
  
!     osi_Log3(smb_logp, "smb_WriteData fid %d returns %d written %d",
                fidp->fid, code, *writtenp);
      return code;
  }
***************
*** 5839,5844 ****
--- 5864,5871 ----
          
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
  
      if (strcmp(pathp, "\\") == 0)
          return CM_ERROR_EXISTS;
***************
*** 5953,5958 ****
--- 5980,5987 ----
          
      tp = smb_GetSMBData(inp, NULL);
      pathp = smb_ParseASCIIBlock(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
  
      spacep = inp->spacep;
      smb_StripLastComponent(spacep->data, &lastNamep, pathp);
***************
*** 5977,5984 ****
      /* otherwise, scp points to the parent directory.  Do a lookup, and
       * truncate the file if we find it, otherwise we create the file.
       */
!     if (!lastNamep) lastNamep = pathp;
!     else lastNamep++;
  
      if (!smb_IsLegalFilename(lastNamep))
          return CM_ERROR_BADNTFILENAME;
--- 6006,6015 ----
      /* otherwise, scp points to the parent directory.  Do a lookup, and
       * truncate the file if we find it, otherwise we create the file.
       */
!     if (!lastNamep) 
!         lastNamep = pathp;
!     else 
!         lastNamep++;
  
      if (!smb_IsLegalFilename(lastNamep))
          return CM_ERROR_BADNTFILENAME;
***************
*** 6464,6471 ****
      while (1) {
          code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBevents,
                                                   FALSE, INFINITE);
!         if (code == WAIT_OBJECT_0)
!             continue;
  
          /* error checking */
          if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
--- 6495,6506 ----
      while (1) {
          code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBevents,
                                                   FALSE, INFINITE);
!         if (code == WAIT_OBJECT_0) {
!             if (smbShutdownFlag == 1)
!                 break;
!             else
!                 continue;
!         }
  
          /* error checking */
          if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
***************
*** 6523,6530 ****
          /* Get a session */
          code = thrd_WaitForMultipleObjects_Event(numSessions, SessionEvents,
                                                   FALSE, INFINITE);
!         if (code == WAIT_OBJECT_0)
!             continue;
  
          if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numSessions))
          {
--- 6558,6569 ----
          /* Get a session */
          code = thrd_WaitForMultipleObjects_Event(numSessions, SessionEvents,
                                                   FALSE, INFINITE);
!         if (code == WAIT_OBJECT_0) {
!             if ( smbShutdownFlag == 1 )
!                 break;
!             else
!                 continue;
!         }
  
          if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numSessions))
          {
***************
*** 6562,6569 ****
        NCBretry:
          code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBavails,
                                                   FALSE, INFINITE);
!         if (code == WAIT_OBJECT_0)
!             goto NCBretry;
  
          /* error checking */
          if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
--- 6601,6612 ----
        NCBretry:
          code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBavails,
                                                   FALSE, INFINITE);
!         if (code == WAIT_OBJECT_0) {
!             if ( smbShutdownFlag == 1 ) 
!                 break;
!             else
!                 goto NCBretry;
!         }
  
          /* error checking */
          if (code >= WAIT_ABANDONED_0 && code < (WAIT_ABANDONED_0 + numNCBs))
***************
*** 6603,6611 ****
  
          /* Fire it up */
          ncbp = NCBs[idx_NCB];
- #ifdef DJGPP
-         dos_ncb = ((smb_ncb_t *)ncbp)->dos_ncb;
- #endif /* DJGPP */
          ncbp->ncb_lsn = (unsigned char) LSNs[idx_session];
          ncbp->ncb_command = NCBRECV | ASYNCH;
          ncbp->ncb_lana_num = lanas[idx_session];
--- 6646,6651 ----
***************
*** 6619,6624 ****
--- 6659,6665 ----
          ((smb_ncb_t*)ncbp)->orig_pkt = bufs[idx_NCB];
          ncbp->ncb_event = NCBreturns[0][idx_NCB];
          ncbp->ncb_length = SMB_PACKETSIZE;
+         dos_ncb = ((smb_ncb_t *)ncbp)->dos_ncb;
          Netbios(ncbp, dos_ncb);
  #endif /* !DJGPP */
      }
***************
*** 6657,6664 ****
      while (1) {
          code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBreturns[myIdx],
                                                   FALSE, INFINITE);
          if (code == WAIT_OBJECT_0) {
!             continue;
          }
  
          /* error checking */
--- 6698,6711 ----
      while (1) {
          code = thrd_WaitForMultipleObjects_Event(numNCBs, NCBreturns[myIdx],
                                                   FALSE, INFINITE);
+ 
+         /* terminate silently if shutdown flag is set */
          if (code == WAIT_OBJECT_0) {
!             if (smbShutdownFlag == 1) {
!                 thrd_SetEvent(smb_ServerShutdown[myIdx]);
!                 break;
!             } else
!                 continue;
          }
  
          /* error checking */
***************
*** 6824,6830 ****
           * Either way, we can't do anything with this packet.
           * Log, sleep and resume.
           */
!         if(!vcp) {
              HANDLE h;
              char buf[1000];
              char *ptbuf[1];
--- 6871,6877 ----
           * Either way, we can't do anything with this packet.
           * Log, sleep and resume.
           */
!         if (!vcp) {
              HANDLE h;
              char buf[1000];
              char *ptbuf[1];
***************
*** 6843,6849 ****
              ptbuf[0] = buf;
  
              h = RegisterEventSource(NULL,AFS_DAEMON_EVENT_NAME);
!             if(h) {
                  ReportEvent(h, EVENTLOG_ERROR_TYPE, 0, 1001, NULL,1,sizeof(*ncbp),ptbuf,(void*)ncbp);
                  DeregisterEventSource(h);
              }
--- 6890,6896 ----
              ptbuf[0] = buf;
  
              h = RegisterEventSource(NULL,AFS_DAEMON_EVENT_NAME);
!             if (h) {
                  ReportEvent(h, EVENTLOG_ERROR_TYPE, 0, 1001, NULL,1,sizeof(*ncbp),ptbuf,(void*)ncbp);
                  DeregisterEventSource(h);
              }
***************
*** 7525,7530 ****
--- 7572,7586 ----
          NCBreturns[i] = malloc(NCBmax * sizeof(EVENT_HANDLE));
          NCBreturns[i][0] = retHandle;
      }
+ 
+     smb_ServerShutdown = malloc(smb_NumServerThreads * sizeof(EVENT_HANDLE));
+     for (i = 0; i < smb_NumServerThreads; i++) {
+         sprintf(eventName, "smb_ServerShutdown[%d]", i);
+         smb_ServerShutdown[i] = thrd_CreateEvent(NULL, FALSE, FALSE, eventName);
+         if ( GetLastError() == ERROR_ALREADY_EXISTS )
+             afsi_log("Event Object Already Exists: %s", eventName);
+     }
+ 
      for (i = 1; i <= nThreads; i++)
          InitNCBslot(i);
      numNCBs = nThreads + 1;
***************
*** 7625,7632 ****
      smb_tran2DispatchTable[12].procp = smb_ReceiveTran2FindNotifyNext;
      smb_tran2DispatchTable[13].procp = smb_ReceiveTran2CreateDirectory;
      smb_tran2DispatchTable[14].procp = smb_ReceiveTran2SessionSetup;
!     smb_tran2DispatchTable[14].procp = smb_ReceiveTran2GetDFSReferral;
!     smb_tran2DispatchTable[14].procp = smb_ReceiveTran2ReportDFSInconsistency;
  
      /* setup the rap dispatch table */
      memset(smb_rapDispatchTable, 0, sizeof(smb_rapDispatchTable));
--- 7681,7688 ----
      smb_tran2DispatchTable[12].procp = smb_ReceiveTran2FindNotifyNext;
      smb_tran2DispatchTable[13].procp = smb_ReceiveTran2CreateDirectory;
      smb_tran2DispatchTable[14].procp = smb_ReceiveTran2SessionSetup;
!     smb_tran2DispatchTable[16].procp = smb_ReceiveTran2GetDFSReferral;
!     smb_tran2DispatchTable[17].procp = smb_ReceiveTran2ReportDFSInconsistency;
  
      /* setup the rap dispatch table */
      memset(smb_rapDispatchTable, 0, sizeof(smb_rapDispatchTable));
***************
*** 7789,7795 ****
  #ifndef DJGPP
          code = Netbios(ncbp);
  #else
! 		code = Netbios(ncbp, dos_ncb);
  #endif
          /*fprintf(stderr, "returned from NCBHANGUP session %d LSN %d\n", i, LSNs[i]);*/
          if (code == 0) code = ncbp->ncb_retcode;
--- 7845,7851 ----
  #ifndef DJGPP
          code = Netbios(ncbp);
  #else
!         code = Netbios(ncbp, dos_ncb);
  #endif
          /*fprintf(stderr, "returned from NCBHANGUP session %d LSN %d\n", i, LSNs[i]);*/
          if (code == 0) code = ncbp->ncb_retcode;
***************
*** 7819,7824 ****
--- 7875,7897 ----
          }       
          fflush(stderr);
      }
+ 
+     /* Trigger the shutdown of all SMB threads */
+     for (i = 0; i < smb_NumServerThreads; i++)
+         thrd_SetEvent(NCBreturns[i][0]);
+ 
+     thrd_SetEvent(NCBevents[0]);
+     thrd_SetEvent(SessionEvents[0]);
+     thrd_SetEvent(NCBavails[0]);
+ 
+     for (i = 0;i < smb_NumServerThreads; i++) {
+         DWORD code = thrd_WaitForSingleObject_Event(smb_ServerShutdown[i], INFINITE);
+         if (code == WAIT_OBJECT_0) {
+             continue;
+         } else {
+             afsi_log("smb_Shutdown[%d] wait error",i);
+         }
+     }
  }
  
  /* Get the UNC \\<servername>\<sharename> prefix. */
Index: openafs/src/WINNT/afsd/smb.h
diff -c openafs/src/WINNT/afsd/smb.h:1.14.2.4 openafs/src/WINNT/afsd/smb.h:1.14.2.6
*** openafs/src/WINNT/afsd/smb.h:1.14.2.4	Mon Oct 18 00:09:28 2004
--- openafs/src/WINNT/afsd/smb.h	Tue Dec  7 07:49:33 2004
***************
*** 18,38 ****
  
  /* basic core protocol SMB structure */
  typedef struct smb {
! 	unsigned char id[4];
!         unsigned char com;
!         unsigned char rcls;
!         unsigned char reh;
!         unsigned char errLow;
!         unsigned char errHigh;
!         unsigned char reb;
!         unsigned short flg2;
!         unsigned short res[6];
!         unsigned short tid;
!         unsigned short pid;
!         unsigned short uid;
!         unsigned short mid;
!         unsigned char wct;
!         unsigned char vdata[1];
  } smb_t;
  
  /* more defines */
--- 18,38 ----
  
  /* basic core protocol SMB structure */
  typedef struct smb {
!     unsigned char id[4];
!     unsigned char com;
!     unsigned char rcls;
!     unsigned char reh;
!     unsigned char errLow;
!     unsigned char errHigh;
!     unsigned char reb;
!     unsigned short flg2;
!     unsigned short res[6];
!     unsigned short tid;
!     unsigned short pid;
!     unsigned short uid;
!     unsigned short mid;
!     unsigned char wct;
!     unsigned char vdata[1];
  } smb_t;
  
  /* more defines */
***************
*** 94,116 ****
   */
  #define SMB_PACKETMAGIC	0x7436353	/* magic # for packets */
  typedef struct smb_packet {
! 	char data[SMB_PACKETSIZE];
! 	struct smb_packet *nextp;	/* in free list, or whatever */
!         long magic;
! 	cm_space_t *spacep;		/* use this for stripping last component */
! 	NCB *ncbp;			/* use this for sending */
! 	struct smb_vc *vcp;
! 	unsigned long resumeCode;
!         unsigned short inCount;
!         unsigned short fid;		/* for calls bundled with openAndX */
!         unsigned char *wctp;
!         unsigned char inCom;
! 	unsigned char oddByte;
! 	unsigned short ncb_length;
! 	unsigned char flags;
  #ifdef DJGPP
!         dos_ptr dos_pkt;
!         unsigned int dos_pkt_sel;
  #endif /* DJGPP */
  } smb_packet_t;
  
--- 94,116 ----
   */
  #define SMB_PACKETMAGIC	0x7436353	/* magic # for packets */
  typedef struct smb_packet {
!     char data[SMB_PACKETSIZE];
!     struct smb_packet *nextp;	        /* in free list, or whatever */
!     long magic;
!     cm_space_t *spacep;		        /* use this for stripping last component */
!     NCB *ncbp;			        /* use this for sending */
!     struct smb_vc *vcp;
!     unsigned long resumeCode;
!     unsigned short inCount;
!     unsigned short fid;		        /* for calls bundled with openAndX */
!     unsigned char *wctp;
!     unsigned char inCom;
!     unsigned char oddByte;
!     unsigned short ncb_length;
!     unsigned char flags;
  #ifdef DJGPP
!     dos_ptr dos_pkt;
!     unsigned int dos_pkt_sel;
  #endif /* DJGPP */
  } smb_packet_t;
  
***************
*** 122,134 ****
  /* a structure for making Netbios calls; locked by smb_globalLock */
  #define SMB_NCBMAGIC	0x2334344
  typedef struct myncb {
! 	NCB ncb;			/* ncb to use */
!         struct myncb *nextp;		/* when on free list */
!         long magic;
  #ifdef DJGPP
!         dos_ptr dos_ncb;
!         smb_packet_t *orig_pkt;
!         unsigned int dos_ncb_sel;
  #endif /* DJGPP */
  } smb_ncb_t;
  
--- 122,134 ----
  /* a structure for making Netbios calls; locked by smb_globalLock */
  #define SMB_NCBMAGIC	0x2334344
  typedef struct myncb {
!     NCB ncb;			        /* ncb to use */
!     struct myncb *nextp;		/* when on free list */
!     long magic;
  #ifdef DJGPP
!     dos_ptr dos_ncb;
!     smb_packet_t *orig_pkt;
!     unsigned int dos_ncb_sel;
  #endif /* DJGPP */
  } smb_ncb_t;
  
***************
*** 140,167 ****
  
  /* one per virtual circuit */
  typedef struct smb_vc {
! 	struct smb_vc *nextp;		/* not used */
!     unsigned long refCount;			/* the reference count */
!     long flags;			/* the flags, if any; locked by mx */
      osi_mutex_t mx;			/* the mutex */
! 	long vcID;			/* VC id */
!     unsigned short lsn;		/* the NCB LSN associated with this */
! 	unsigned short uidCounter;	/* session ID counter */
!     unsigned short tidCounter;	/* tree ID counter */
!     unsigned short fidCounter;	/* file handle ID counter */
      struct smb_tid *tidsp;		/* the first child in the tid list */
!     struct smb_user *usersp;	/* the first child in the user session list */
      struct smb_fid *fidsp;		/* the first child in the open file list */
! 	struct smb_user *justLoggedOut;	/* ready for profile upload? */
! 	time_t logoffTime;	/* tick count when logged off */
! 	/*struct cm_user *logonDLLUser;	/* integrated logon user */
! 	unsigned char errorCount;
      char rname[17];
! 	int lana;
! 	char encKey[MSV1_0_CHALLENGE_LENGTH]; /* MSV1_0_CHALLENGE_LENGTH is 8 */
!     void * secCtx;              /* security context when negotiating SMB extended auth
!                                  * valid when SMB_VCFLAG_AUTH_IN_PROGRESS is set
!                                  */
  } smb_vc_t;
  
  					/* have we negotiated ... */
--- 140,166 ----
  
  /* one per virtual circuit */
  typedef struct smb_vc {
!     struct smb_vc *nextp;		/* not used */
!     unsigned long refCount;		/* the reference count */
!     long flags;			        /* the flags, if any; locked by mx */
      osi_mutex_t mx;			/* the mutex */
!     long vcID;			        /* VC id */
!     unsigned short lsn;		        /* the NCB LSN associated with this */
!     unsigned short uidCounter;	        /* session ID counter */
!     unsigned short tidCounter;	        /* tree ID counter */
!     unsigned short fidCounter;	        /* file handle ID counter */
      struct smb_tid *tidsp;		/* the first child in the tid list */
!     struct smb_user *usersp;	        /* the first child in the user session list */
      struct smb_fid *fidsp;		/* the first child in the open file list */
!     struct smb_user *justLoggedOut;	/* ready for profile upload? */
!     time_t logoffTime;	                /* tick count when logged off */
!     unsigned char errorCount;
      char rname[17];
!     int lana;
!     char encKey[MSV1_0_CHALLENGE_LENGTH]; /* MSV1_0_CHALLENGE_LENGTH is 8 */
!     void * secCtx;                      /* security context when negotiating SMB extended auth
!                                          * valid when SMB_VCFLAG_AUTH_IN_PROGRESS is set
!                                          */
  } smb_vc_t;
  
  					/* have we negotiated ... */
***************
*** 176,198 ****
  
  /* one per user session */
  typedef struct smb_user {
! 	struct smb_user *nextp;		/* next sibling */
!         unsigned long refCount;			/* ref count */
!         long flags;			/* flags; locked by mx */
!         osi_mutex_t mx;
!         long userID;			/* the session identifier */
!         struct smb_vc *vcp;		/* back ptr to virtual circuit */
!   struct smb_username *unp;        /* user name struct */
  } smb_user_t;
  
  typedef struct smb_username {
! 	struct smb_username *nextp;		/* next sibling */
!         unsigned long refCount;			/* ref count */
!         long flags;			/* flags; locked by mx */
!         osi_mutex_t mx;
! 	struct cm_user *userp;		/* CM user structure */
!         char *name;			/* user name */
!   char *machine;                  /* machine name */
  } smb_username_t;
  
  #define SMB_USERFLAG_DELETE	1	/* delete struct when ref count zero */
--- 175,197 ----
  
  /* one per user session */
  typedef struct smb_user {
!     struct smb_user *nextp;		/* next sibling */
!     unsigned long refCount;		/* ref count */
!     long flags;			        /* flags; locked by mx */
!     osi_mutex_t mx;
!     long userID;			/* the session identifier */
!     struct smb_vc *vcp;		        /* back ptr to virtual circuit */
!     struct smb_username *unp;           /* user name struct */
  } smb_user_t;
  
  typedef struct smb_username {
!     struct smb_username *nextp;		/* next sibling */
!     unsigned long refCount;		/* ref count */
!     long flags;			        /* flags; locked by mx */
!     osi_mutex_t mx;
!     struct cm_user *userp;		/* CM user structure */
!     char *name;			        /* user name */
!     char *machine;                      /* machine name */
  } smb_username_t;
  
  #define SMB_USERFLAG_DELETE	1	/* delete struct when ref count zero */
***************
*** 201,215 ****
  
  /* one per tree-connect */
  typedef struct smb_tid {
! 	struct smb_tid *nextp;		/* next sibling */
!         unsigned long refCount;
!         long flags;
!         osi_mutex_t mx;			/* for non-tree-related stuff */
!         unsigned short tid;		/* the tid */
!         struct smb_vc *vcp;		/* back ptr */
!         struct cm_user *userp;		/* user logged in at the
  					 * tree connect level (base) */
! 	char *pathname;			/* pathname derived from sharename */
  } smb_tid_t;
  
  #define SMB_TIDFLAG_DELETE	1	/* delete struct when ref count zero */
--- 200,214 ----
  
  /* one per tree-connect */
  typedef struct smb_tid {
!     struct smb_tid *nextp;		/* next sibling */
!     unsigned long refCount;
!     long flags;
!     osi_mutex_t mx;			/* for non-tree-related stuff */
!     unsigned short tid;		        /* the tid */
!     struct smb_vc *vcp;		        /* back ptr */
!     struct cm_user *userp;		/* user logged in at the
  					 * tree connect level (base) */
!     char *pathname;			/* pathname derived from sharename */
  } smb_tid_t;
  
  #define SMB_TIDFLAG_DELETE	1	/* delete struct when ref count zero */
***************
*** 217,256 ****
  
  /* one per process ID */
  typedef struct smb_pid {
! 	struct smb_pid *nextp;		/* next sibling */
!         unsigned long refCount;
!         long flags;
!         osi_mutex_t mx;			/* for non-tree-related stuff */
!         unsigned short pid;		/* the pid */
!         struct smb_tid *tidp;		/* back ptr */
  } smb_pid_t;
  
  /* ioctl parameter, while being assembled and/or processed */
  typedef struct smb_ioctl {
! 	/* input side */
! 	char *inDatap;			/* ioctl func's current position
  					 * in input parameter block */
! 	char *inAllocp;			/* allocated input parameter block */
!         long inCopied;			/* # of input bytes copied in so far
  					 * by write calls */
! 	cm_space_t *prefix;		/* prefix for subst drives */
! 	char *tidPathp;			/* Pathname associated with Tree ID */
  
! 	/* output side */
!         char *outDatap;			/* output results assembled so far */
!         char *outAllocp;		/* output results assembled so far */
!         long outCopied;			/* # of output bytes copied back so far
! 					 * by read calls */
  	
!         /* flags */
!         long flags;
  
!         /* fid pointer */
!         struct smb_fid *fidp;
! 
!   /* uid pointer */
!   smb_user_t *uidp;
  
  } smb_ioctl_t;
  
  /* flags for smb_ioctl_t */
--- 216,254 ----
  
  /* one per process ID */
  typedef struct smb_pid {
!     struct smb_pid *nextp;		/* next sibling */
!     unsigned long refCount;
!     long flags;
!     osi_mutex_t mx;			/* for non-tree-related stuff */
!     unsigned short pid;		        /* the pid */
!     struct smb_tid *tidp;		/* back ptr */
  } smb_pid_t;
  
  /* ioctl parameter, while being assembled and/or processed */
  typedef struct smb_ioctl {
!     /* input side */
!     char *inDatap;			/* ioctl func's current position
  					 * in input parameter block */
!     char *inAllocp;			/* allocated input parameter block */
!     long inCopied;			/* # of input bytes copied in so far
  					 * by write calls */
!     cm_space_t *prefix;		        /* prefix for subst drives */
!     char *tidPathp;			/* Pathname associated with Tree ID */
  
!     /* output side */
!     char *outDatap;			/* output results assembled so far */
!     char *outAllocp;		        /* output results assembled so far */
!     long outCopied;			/* # of output bytes copied back so far
!                                          * by read calls */
  	
!     /* flags */
!     long flags;
  
!     /* fid pointer */
!     struct smb_fid *fidp;
  
+     /* uid pointer */
+     smb_user_t *uidp;
  } smb_ioctl_t;
  
  /* flags for smb_ioctl_t */
***************
*** 259,285 ****
  
  /* one per file ID; these are really file descriptors */
  typedef struct smb_fid {
! 	osi_queue_t q;
!         unsigned long refCount;
!         unsigned long flags;
!         osi_mutex_t mx;			/* for non-tree-related stuff */
!         unsigned short fid;		/* the file ID */
!         struct smb_vc *vcp;		/* back ptr */
!         struct cm_scache *scp;		/* scache of open file */
!         long offset;			/* our file pointer */
!         smb_ioctl_t *ioctlp;		/* ptr to ioctl structure */
  					/* Under NT, we may need to know the
  					 * parent directory and pathname used
  					 * to open the file, either to delete
  					 * the file on close, or to do a
  					 * change notification */
! 	struct cm_scache *NTopen_dscp;	/* parent directory (NT) */
! 	char *NTopen_pathp;		/* path used in open (NT) */
! 	char *NTopen_wholepathp;	/* entire path, not just last name */
! 	int curr_chunk;			/* chunk being read */
! 	int prev_chunk;			/* previous chunk read */
! 	int raw_writers;		/* pending async raw writes */
! 	EVENT_HANDLE raw_write_event;	/* signal this when raw_writers zero */
  } smb_fid_t;
  
  #define SMB_FID_OPENREAD		1	/* open for reading */
--- 257,283 ----
  
  /* one per file ID; these are really file descriptors */
  typedef struct smb_fid {
!     osi_queue_t q;
!     unsigned long refCount;
!     unsigned long flags;
!     osi_mutex_t mx;			/* for non-tree-related stuff */
!     unsigned short fid;		        /* the file ID */
!     struct smb_vc *vcp;		        /* back ptr */
!     struct cm_scache *scp;		/* scache of open file */
!     long offset;			/* our file pointer */
!     smb_ioctl_t *ioctlp;		/* ptr to ioctl structure */
  					/* Under NT, we may need to know the
  					 * parent directory and pathname used
  					 * to open the file, either to delete
  					 * the file on close, or to do a
  					 * change notification */
!     struct cm_scache *NTopen_dscp;	/* parent directory (NT) */
!     char *NTopen_pathp;		        /* path used in open (NT) */
!     char *NTopen_wholepathp;	        /* entire path, not just last name */
!     int curr_chunk;			/* chunk being read */
!     int prev_chunk;			/* previous chunk read */
!     int raw_writers;		        /* pending async raw writes */
!     EVENT_HANDLE raw_write_event;	/* signal this when raw_writers zero */
  } smb_fid_t;
  
  #define SMB_FID_OPENREAD		1	/* open for reading */
***************
*** 311,327 ****
  
  /* for tracking in-progress directory searches */
  typedef struct smb_dirSearch {
! 	osi_queue_t q;			/* queue of all outstanding cookies */
!         osi_mutex_t mx;			/* just in case the caller screws up */
!         unsigned long refCount;			/* reference count */
!         long cookie;			/* value returned to the caller */
!         struct cm_scache *scp;		/* vnode of the dir we're searching */
!         time_t lastTime;		/* last time we used this */
!         long flags;			/* flags (see below);
  					 * locked by smb_globalLock */
!         unsigned short attribute;	/* search attribute
  					 * (used for extended protocol) */
!         char mask[256];			/* search mask for V3 */
  } smb_dirSearch_t;
  
  #define SMB_DIRSEARCH_DELETE	1	/* delete struct when ref count zero */
--- 309,325 ----
  
  /* for tracking in-progress directory searches */
  typedef struct smb_dirSearch {
!     osi_queue_t q;			/* queue of all outstanding cookies */
!     osi_mutex_t mx;			/* just in case the caller screws up */
!     unsigned long refCount;		/* reference count */
!     long cookie;			/* value returned to the caller */
!     struct cm_scache *scp;		/* vnode of the dir we're searching */
!     time_t lastTime;		        /* last time we used this */
!     long flags;			        /* flags (see below);
  					 * locked by smb_globalLock */
!     unsigned short attribute;	        /* search attribute
  					 * (used for extended protocol) */
!     char mask[256];			/* search mask for V3 */
  } smb_dirSearch_t;
  
  #define SMB_DIRSEARCH_DELETE	1	/* delete struct when ref count zero */
***************
*** 331,341 ****
  
  /* type for patching directory listings */
  typedef struct smb_dirListPatch {
! 	osi_queue_t q;
!     char *dptr;		/* ptr to attr, time, data, sizel, sizeh */
!     long flags;     /* flags.  See below */
! 	cm_fid_t fid;
!   cm_dirEntry_t *dep;   /* temp */
  } smb_dirListPatch_t;
  
  /* dirListPatch Flags */
--- 329,339 ----
  
  /* type for patching directory listings */
  typedef struct smb_dirListPatch {
!     osi_queue_t q;
!     char *dptr;		                /* ptr to attr, time, data, sizel, sizeh */
!     long flags;                         /* flags.  See below */
!     cm_fid_t fid;
!     cm_dirEntry_t *dep;                 /* temp */
  } smb_dirListPatch_t;
  
  /* dirListPatch Flags */
***************
*** 346,357 ****
  
  /* waiting lock list elements */
  typedef struct smb_waitingLock {
! 	osi_queue_t q;
! 	smb_vc_t *vcp;
! 	smb_packet_t *inp;
! 	smb_packet_t *outp;
! 	time_t timeRemaining;
! 	void *lockp;
  } smb_waitingLock_t;
  
  extern smb_waitingLock_t *smb_allWaitingLocks;
--- 344,355 ----
  
  /* waiting lock list elements */
  typedef struct smb_waitingLock {
!     osi_queue_t q;
!     smb_vc_t *vcp;
!     smb_packet_t *inp;
!     smb_packet_t *outp;
!     time_t timeRemaining;
!     void *lockp;
  } smb_waitingLock_t;
  
  extern smb_waitingLock_t *smb_allWaitingLocks;
***************
*** 359,366 ****
  typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
  typedef struct smb_dispatch {
! 	smb_proc_t *procp;	/* proc to call */
!         int flags;		/* flags describing function */
  } smb_dispatch_t;
  
  #define SMB_DISPATCHFLAG_CHAINED	1	/* this is an _AND_X function */
--- 357,364 ----
  typedef long (smb_proc_t)(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp);
  
  typedef struct smb_dispatch {
!     smb_proc_t *procp;	                /* proc to call */
!     int flags;		                /* flags describing function */
  } smb_dispatch_t;
  
  #define SMB_DISPATCHFLAG_CHAINED	1	/* this is an _AND_X function */
***************
*** 492,497 ****
--- 490,496 ----
  extern int smb_maxVCPerServer; /* max # of VCs per server */
  extern int smb_maxMpxRequests; /* max # of mpx requests */
  
+ extern int smb_StoreAnsiFilenames;
  extern int smb_hideDotFiles;
  extern unsigned int smb_IsDotFile(char *lastComp);
  
***************
*** 515,526 ****
  
  /* used for getting a challenge for SMB auth */
  typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {  
! 	MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
  
  typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {  
! 	MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;  
! 	UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
  } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
  /**/
  
--- 514,525 ----
  
  /* used for getting a challenge for SMB auth */
  typedef struct _MSV1_0_LM20_CHALLENGE_REQUEST {  
!     MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;
  } MSV1_0_LM20_CHALLENGE_REQUEST, *PMSV1_0_LM20_CHALLENGE_REQUEST;
  
  typedef struct _MSV1_0_LM20_CHALLENGE_RESPONSE {  
!     MSV1_0_PROTOCOL_MESSAGE_TYPE MessageType;  
!     UCHAR ChallengeToClient[MSV1_0_CHALLENGE_LENGTH];
  } MSV1_0_LM20_CHALLENGE_RESPONSE, *PMSV1_0_LM20_CHALLENGE_RESPONSE;
  /**/
  
***************
*** 569,574 ****
--- 568,575 ----
  
  extern char *smb_GetSharename(void);
  
+ extern DWORD smb_ServerExceptionFilter(void);
+ 
  /* include other include files */
  #include "smb3.h"
  #include "smb_ioctl.h"
Index: openafs/src/WINNT/afsd/smb3.c
diff -c openafs/src/WINNT/afsd/smb3.c:1.42.2.10 openafs/src/WINNT/afsd/smb3.c:1.42.2.13
*** openafs/src/WINNT/afsd/smb3.c:1.42.2.10	Fri Nov  5 14:21:46 2004
--- openafs/src/WINNT/afsd/smb3.c	Tue Dec  7 07:49:33 2004
***************
*** 21,27 ****
  #include <string.h>
  #include <stdio.h>
  #include <time.h>
- 
  #include <osi.h>
  
  #include "afsd.h"
--- 21,26 ----
***************
*** 76,89 ****
      {
          attrs = SMB_ATTR_DIRECTORY;
  #ifdef SPECIAL_FOLDERS
! #ifdef AFS_FREELANCE_CLIENT
!         if ( cm_freelanceEnabled &&
!              scp->fid.cell==AFS_FAKE_ROOT_CELL_ID && 
!              scp->fid.volume==AFS_FAKE_ROOT_VOL_ID &&
!              scp->fid.vnode==0x1 && scp->fid.unique==0x1) {
!             attrs |= SMB_ATTR_SYSTEM;		/* FILE_ATTRIBUTE_SYSTEM */
!         }
! #endif /* AFS_FREELANCE_CLIENT */
  #endif /* SPECIAL_FOLDERS */
      } else
          attrs = 0;
--- 75,81 ----
      {
          attrs = SMB_ATTR_DIRECTORY;
  #ifdef SPECIAL_FOLDERS
!         attrs |= SMB_ATTR_SYSTEM;		/* FILE_ATTRIBUTE_SYSTEM */
  #endif /* SPECIAL_FOLDERS */
      } else
          attrs = 0;
***************
*** 944,949 ****
--- 936,943 ----
      tp = smb_GetSMBData(inp, NULL);
      passwordp = smb_ParseString(tp, &tp);
      pathp = smb_ParseString(tp, &tp);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
      servicep = smb_ParseString(tp, &tp);
  
      tp = strrchr(pathp, '\\');
***************
*** 1210,1216 ****
      smb_SetSMBParm(tp, 7, dataOffset);	/* offset of data */
      smb_SetSMBParm(tp, 8, 0);		/* data displacement */
      smb_SetSMBParm(tp, 9, 0);		/* low: setup word count *
!     * high: resvd */
  
      datap = smb_GetSMBData(tp, NULL);
      *datap++ = 0;				/* we rounded to even */
--- 1204,1210 ----
      smb_SetSMBParm(tp, 7, dataOffset);	/* offset of data */
      smb_SetSMBParm(tp, 8, 0);		/* data displacement */
      smb_SetSMBParm(tp, 9, 0);		/* low: setup word count *
!                                          * high: resvd */
  
      datap = smb_GetSMBData(tp, NULL);
      *datap++ = 0;				/* we rounded to even */
***************
*** 2044,2050 ****
      if (attributes & 1) initialModeBits &= ~0222;
          
      pathp = (char *) (&p->parmsp[14]);
!         
      outp = smb_GetTran2ResponsePacket(vcp, p, op, 40, 0);
  
      spacep = cm_GetSpace();
--- 2038,2046 ----
      if (attributes & 1) initialModeBits &= ~0222;
          
      pathp = (char *) (&p->parmsp[14]);
!     if (smb_StoreAnsiFilenames)
!         OemToChar(pathp,pathp);
!     
      outp = smb_GetTran2ResponsePacket(vcp, p, op, 40, 0);
  
      spacep = cm_GetSpace();
***************
*** 2591,2599 ****
          spacep = cm_GetSpace();
          smb_StripLastComponent(spacep->data, &lastComp,
                                  (char *)(&p->parmsp[3]));
          /* Make sure that lastComp is not NULL */
          if (lastComp) {
!             if (strcmp(lastComp, "\\desktop.ini") == 0) {
                  code = cm_NameI(cm_rootSCachep, spacep->data,
                                   CM_FLAG_CASEFOLD
                                   | CM_FLAG_DIRSEARCH
--- 2587,2596 ----
          spacep = cm_GetSpace();
          smb_StripLastComponent(spacep->data, &lastComp,
                                  (char *)(&p->parmsp[3]));
+ #ifndef SPECIAL_FOLDERS
          /* Make sure that lastComp is not NULL */
          if (lastComp) {
!             if (stricmp(lastComp, "\\desktop.ini") == 0) {
                  code = cm_NameI(cm_rootSCachep, spacep->data,
                                   CM_FLAG_CASEFOLD
                                   | CM_FLAG_DIRSEARCH
***************
*** 2621,2626 ****
--- 2618,2625 ----
                  }
              }
          }
+ #endif /* SPECIAL_FOLDERS */
+ 
          cm_FreeSpace(spacep);
      }
  
***************
*** 3583,3588 ****
--- 3582,3589 ----
          dsp = smb_NewDirSearch(1);
          dsp->attribute = attribute;
          pathp = ((char *) p->parmsp) + 12;	/* points to path */
+         if (smb_StoreAnsiFilenames)
+             OemToChar(pathp,pathp);
          nextCookie = 0;
          maskp = strrchr(pathp, '\\');
          if (maskp == NULL) 
***************
*** 3979,3989 ****
--- 3980,3994 ----
              else
                  *((u_long *)(op + 60)) = onbytes;
              strcpy(origOp+ohbytes, dep->name);
+             if (smb_StoreAnsiFilenames)
+                 CharToOem(origOp+ohbytes, origOp+ohbytes);
  
              /* Short name if requested and needed */
              if (infoLevel == 0x104) {
                  if (NeedShortName) {
                      strcpy(op + 70, shortName);
+                     if (smb_StoreAnsiFilenames)
+                         CharToOem(op + 70, op + 70);
                      *(op + 68) = shortNameEnd - shortName;
                  }
              }
***************
*** 4001,4007 ****
              /* now we emit the attribute.  This is tricky, since
               * we need to really stat the file to find out what
               * type of entry we've got.  Right now, we're copying
!              * out data from * a buffer, while holding the scp
               * locked, so it isn't really convenient to stat
               * something now.  We'll put in a place holder
               * now, and make a second pass before returning this
--- 4006,4012 ----
              /* now we emit the attribute.  This is tricky, since
               * we need to really stat the file to find out what
               * type of entry we've got.  Right now, we're copying
!              * out data from a buffer, while holding the scp
               * locked, so it isn't really convenient to stat
               * something now.  We'll put in a place holder
               * now, and make a second pass before returning this
***************
*** 4213,4218 ****
--- 4218,4225 ----
      if (attributes & 1) initialModeBits &= ~0222;
          
      pathp = smb_GetSMBData(inp, NULL);
+     if (smb_StoreAnsiFilenames)
+         OemToChar(pathp,pathp);
  
      spacep = inp->spacep;
      smb_StripLastComponent(spacep->data, &lastNamep, pathp);
***************
*** 4856,4861 ****
--- 4863,4870 ----
      realPathp = malloc(nameLength+1);
      memcpy(realPathp, pathp, nameLength);
      realPathp[nameLength] = 0;
+     if (smb_StoreAnsiFilenames)
+         OemToChar(realPathp,realPathp);
  
      spacep = inp->spacep;
      smb_StripLastComponent(spacep->data, &lastNamep, realPathp);
***************
*** 5477,5482 ****
--- 5486,5493 ----
      realPathp = malloc(nameLength+1);
      memcpy(realPathp, pathp, nameLength);
      realPathp[nameLength] = 0;
+     if (smb_StoreAnsiFilenames)
+         OemToChar(realPathp,realPathp);
  
      spacep = cm_GetSpace();
      smb_StripLastComponent(spacep->data, &lastNamep, realPathp);
***************
*** 5983,5998 ****
  unsigned char nullSecurityDesc[36] = {
      0x01,				/* security descriptor revision */
      0x00,				/* reserved, should be zero */
!     0x00, 0x80,			/* security descriptor control;
!     * 0x8000 : self-relative format */
      0x14, 0x00, 0x00, 0x00,		/* offset of owner SID */
      0x1c, 0x00, 0x00, 0x00,		/* offset of group SID */
      0x00, 0x00, 0x00, 0x00,		/* offset of DACL would go here */
      0x00, 0x00, 0x00, 0x00,		/* offset of SACL would go here */
      0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
!     /* "null SID" owner SID */
      0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
!     /* "null SID" group SID */
  };      
  
  long smb_ReceiveNTTranQuerySecurityDesc(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
--- 5994,6009 ----
  unsigned char nullSecurityDesc[36] = {
      0x01,				/* security descriptor revision */
      0x00,				/* reserved, should be zero */
!     0x00, 0x80,			        /* security descriptor control;
!                                          * 0x8000 : self-relative format */
      0x14, 0x00, 0x00, 0x00,		/* offset of owner SID */
      0x1c, 0x00, 0x00, 0x00,		/* offset of group SID */
      0x00, 0x00, 0x00, 0x00,		/* offset of DACL would go here */
      0x00, 0x00, 0x00, 0x00,		/* offset of SACL would go here */
      0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
!                                         /* "null SID" owner SID */
      0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
!                                         /* "null SID" group SID */
  };      
  
  long smb_ReceiveNTTranQuerySecurityDesc(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
***************
*** 6219,6224 ****
--- 6230,6236 ----
          smb_SetSMBDataLength(watch, parmCount + 1);
  
          if (parmCount != 0) {
+             char * p;
              outData = smb_GetSMBData(watch, NULL);
              outData++;	/* round to get to parmOffset */
              oldOutData = outData;
***************
*** 6228,6234 ****
              /* Action */
              *((DWORD *)outData) = nameLen*2; outData += 4;
              /* File Name Length */
!             mbstowcs((WCHAR *)outData, filename, nameLen);
              /* File Name */
              if (twoEntries) {
                  outData = oldOutData + oldParmCount;
--- 6240,6250 ----
              /* Action */
              *((DWORD *)outData) = nameLen*2; outData += 4;
              /* File Name Length */
!             p = strdup(filename);
!             if (smb_StoreAnsiFilenames)
!                 CharToOem(p,p);
!             mbstowcs((WCHAR *)outData, p, nameLen);
!             free(p);
              /* File Name */
              if (twoEntries) {
                  outData = oldOutData + oldParmCount;
***************
*** 6238,6245 ****
                  /* Action */
                  *((DWORD *)outData) = otherNameLen*2;
                  outData += 4;	/* File Name Length */
!                 mbstowcs((WCHAR *)outData, otherFilename,
!                           otherNameLen);	/* File Name */
              }       
          }       
  
--- 6254,6264 ----
                  /* Action */
                  *((DWORD *)outData) = otherNameLen*2;
                  outData += 4;	/* File Name Length */
!                 p = strdup(otherFilename);
!                 if (smb_StoreAnsiFilenames)
!                     CharToOem(p,p);
!                 mbstowcs((WCHAR *)outData, p, otherNameLen);	/* File Name */
!                 free(p);
              }       
          }       
  
***************
*** 6351,6357 ****
  
  long smb_ReceiveNTRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
!     char *oldname, *newname;
      long code = 0;
      cm_user_t *userp;
      char * tp;
--- 6370,6376 ----
  
  long smb_ReceiveNTRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
  {
!     char *oldPathp, *newPathp;
      long code = 0;
      cm_user_t *userp;
      char * tp;
***************
*** 6367,6384 ****
      }
  
      tp = smb_GetSMBData(inp, NULL);
!     oldname = smb_ParseASCIIBlock(tp, &tp);
!     newname = smb_ParseASCIIBlock(tp, &tp);
  
      osi_Log3(smb_logp, "NTRename for [%s]->[%s] type [%s]",
!              osi_LogSaveString(smb_logp, oldname),
!              osi_LogSaveString(smb_logp, newname),
               ((rename_type==RENAME_FLAG_RENAME)?"rename":"hardlink"));
  
      if (rename_type == RENAME_FLAG_RENAME) {
!         code = smb_Rename(vcp,inp,oldname,newname,attrs);
      } else { /* RENAME_FLAG_HARD_LINK */
!         code = smb_Link(vcp,inp,oldname,newname);
      }
      return code;
  }
--- 6386,6407 ----
      }
  
      tp = smb_GetSMBData(inp, NULL);
!     oldPathp = smb_ParseASCIIBlock(tp, &tp);
!     if (smb_StoreAnsiFilenames)
!         OemToChar(oldPathp,oldPathp);
!     newPathp = smb_ParseASCIIBlock(tp, &tp);
!     if (smb_StoreAnsiFilenames)
!         OemToChar(newPathp,newPathp);
  
      osi_Log3(smb_logp, "NTRename for [%s]->[%s] type [%s]",
!              osi_LogSaveString(smb_logp, oldPathp),
!              osi_LogSaveString(smb_logp, newPathp),
               ((rename_type==RENAME_FLAG_RENAME)?"rename":"hardlink"));
  
      if (rename_type == RENAME_FLAG_RENAME) {
!         code = smb_Rename(vcp,inp,oldPathp,newPathp,attrs);
      } else { /* RENAME_FLAG_HARD_LINK */
!         code = smb_Link(vcp,inp,oldPathp,newPathp);
      }
      return code;
  }
Index: openafs/src/WINNT/afssvrcfg/NTMakefile
diff -c openafs/src/WINNT/afssvrcfg/NTMakefile:1.6.2.1 openafs/src/WINNT/afssvrcfg/NTMakefile:1.6.2.3
*** openafs/src/WINNT/afssvrcfg/NTMakefile:1.6.2.1	Fri Nov  5 14:21:49 2004
--- openafs/src/WINNT/afssvrcfg/NTMakefile	Tue Dec  7 01:00:57 2004
***************
*** 91,97 ****
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
  	$(CD) ..
  
  mkdir:
--- 91,97 ----
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do ( if exist @$(NTLANG) do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean )
  	$(CD) ..
  
  mkdir:
***************
*** 99,102 ****
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
! 	
--- 99,102 ----
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
! 
Index: openafs/src/WINNT/afssvrcpa/NTMakefile
diff -c openafs/src/WINNT/afssvrcpa/NTMakefile:1.5.2.1 openafs/src/WINNT/afssvrcpa/NTMakefile:1.5.2.3
*** openafs/src/WINNT/afssvrcpa/NTMakefile:1.5.2.1	Fri Nov  5 14:21:50 2004
--- openafs/src/WINNT/afssvrcpa/NTMakefile	Tue Dec  7 01:00:58 2004
***************
*** 56,62 ****
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
  	$(CD) ..
  
  mkdir:
--- 56,62 ----
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do ( if exist @$(NTLANG) do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean )
  	$(CD) ..
  
  mkdir:
Index: openafs/src/WINNT/afssvrmgr/NTMakefile
diff -c openafs/src/WINNT/afssvrmgr/NTMakefile:1.4.2.1 openafs/src/WINNT/afssvrmgr/NTMakefile:1.4.2.3
*** openafs/src/WINNT/afssvrmgr/NTMakefile:1.4.2.1	Fri Nov  5 14:21:51 2004
--- openafs/src/WINNT/afssvrmgr/NTMakefile	Tue Dec  7 01:00:58 2004
***************
*** 118,124 ****
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
  	$(CD) ..
  
  mkdir:
--- 118,124 ----
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do ( if exist @$(NTLANG) do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean )
  	$(CD) ..
  
  mkdir:
Index: openafs/src/WINNT/afsusrmgr/NTMakefile
diff -c openafs/src/WINNT/afsusrmgr/NTMakefile:1.4.2.1 openafs/src/WINNT/afsusrmgr/NTMakefile:1.4.2.3
*** openafs/src/WINNT/afsusrmgr/NTMakefile:1.4.2.1	Fri Nov  5 14:21:52 2004
--- openafs/src/WINNT/afsusrmgr/NTMakefile	Tue Dec  7 01:00:59 2004
***************
*** 95,101 ****
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
  	$(CD) ..
  
  mkdir:
--- 95,101 ----
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do ( if exist @$(NTLANG) do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean )
  	$(CD) ..
  
  mkdir:
***************
*** 103,106 ****
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
! 	
--- 103,106 ----
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
! 
Index: openafs/src/WINNT/client_config/drivemap.cpp
diff -c openafs/src/WINNT/client_config/drivemap.cpp:1.27.2.3 openafs/src/WINNT/client_config/drivemap.cpp:1.27.2.4
*** openafs/src/WINNT/client_config/drivemap.cpp:1.27.2.3	Mon Oct 18 00:09:34 2004
--- openafs/src/WINNT/client_config/drivemap.cpp	Tue Dec  7 00:55:54 2004
***************
*** 141,147 ****
                      0,
                      NULL,
                      REG_OPTION_NON_VOLATILE,
!                     KEY_READ,
                      NULL,
                      &hkSub,
                      NULL);
--- 141,147 ----
                      0,
                      NULL,
                      REG_OPTION_NON_VOLATILE,
!                     KEY_WRITE,
                      NULL,
                      &hkSub,
                      NULL);
Index: openafs/src/WINNT/client_config/tab_drives.cpp
diff -c openafs/src/WINNT/client_config/tab_drives.cpp:1.8 openafs/src/WINNT/client_config/tab_drives.cpp:1.8.2.1
*** openafs/src/WINNT/client_config/tab_drives.cpp:1.8	Thu May  6 17:06:58 2004
--- openafs/src/WINNT/client_config/tab_drives.cpp	Tue Dec  7 00:55:54 2004
***************
*** 722,758 ****
  // Action - On Add or On Edit a submount item
  void Submounts_EditSubmount (HWND hDlg, PSUBMOUNT pSubmount)
  {
!    HWND hList = GetDlgItem (hDlg, IDC_LIST);
  
!    if (ModalDialogParam (IDD_SUBMOUNT_EDIT, GetParent(hDlg), (DLGPROC)SubEdit_DlgProc, (LPARAM)pSubmount) == IDOK)
!       {
!       TCHAR szMapping[ MAX_PATH ];
!       AdjustAfsPath (szMapping, pSubmount->szMapping, TRUE, FALSE);
  
!       HLISTITEM hItem;
!       for (hItem = FastList_FindFirst (hList); hItem; hItem = FastList_FindNext (hList, hItem))
!          {
!          LPCTSTR pszSubmount;
!          if ((pszSubmount = FastList_GetItemText (hList, hItem, 0)) == NULL)
!             continue;
! 
!          if (!lstrcmpi (pszSubmount, pSubmount->szSubmount))
!             break;
!          }
! 
!       if (!hItem)
!          {
!          FASTLISTADDITEM ai;
!          memset (&ai, 0x00, sizeof(FASTLISTADDITEM));
!          ai.iFirstImage = IMAGE_NOIMAGE;
!          ai.iSecondImage = IMAGE_NOIMAGE;
!          ai.pszText = pSubmount->szSubmount;
!          ai.lParam = 0;
!          hItem = FastList_AddItem (hList, &ai);
!          }
  
!       FastList_SetItemText (hList, hItem, 1, szMapping);
!       }
  }
  
  
--- 722,778 ----
  // Action - On Add or On Edit a submount item
  void Submounts_EditSubmount (HWND hDlg, PSUBMOUNT pSubmount)
  {
!     TCHAR szOrigSubmount[MAX_PATH];
!     _tcscpy(szOrigSubmount, pSubmount->szSubmount);
  
!     HWND hList = GetDlgItem (hDlg, IDC_LIST);
  
!     if (ModalDialogParam (IDD_SUBMOUNT_EDIT, GetParent(hDlg), (DLGPROC)SubEdit_DlgProc, (LPARAM)pSubmount) == IDOK)
!     {
!         TCHAR szMapping[ MAX_PATH ];
!         BOOL bNameChange = (szOrigSubmount[0] && _tcsicmp(szOrigSubmount, pSubmount->szSubmount));
  
!         AdjustAfsPath (szMapping, pSubmount->szMapping, TRUE, FALSE);
! 
!         HLISTITEM hItem;
! 
!         if ( bNameChange ) {
!             for (hItem = FastList_FindFirst (hList); hItem; hItem = FastList_FindNext (hList, hItem))
!             {
!                 LPCTSTR pszSubmount;
!                 if ((pszSubmount = FastList_GetItemText (hList, hItem, 0)) == NULL)
!                     continue;
! 
!                 if (!_tcsicmp(szOrigSubmount, pszSubmount) ) {
!                     FastList_RemoveItem (hList, hItem);
!                     break;
!                 }
!             }
!         }
! 
!         for (hItem = FastList_FindFirst (hList); hItem; hItem = FastList_FindNext (hList, hItem))
!         {
!             LPCTSTR pszSubmount;
!             if ((pszSubmount = FastList_GetItemText (hList, hItem, 0)) == NULL)
!                 continue;
! 
!             if (!_tcsicmp(pszSubmount, pSubmount->szSubmount))
!                 break;
!         }
! 
!         if (!hItem)
!         {
!             FASTLISTADDITEM ai;
!             memset (&ai, 0x00, sizeof(FASTLISTADDITEM));
!             ai.iFirstImage = IMAGE_NOIMAGE;
!             ai.iSecondImage = IMAGE_NOIMAGE;
!             ai.pszText = pSubmount->szSubmount;
!             ai.lParam = 0;
!             hItem = FastList_AddItem (hList, &ai);
!         }
! 
!         FastList_SetItemText (hList, hItem, 1, szMapping);
!     }
  }
  
  
Index: openafs/src/WINNT/client_creds/NTMakefile
diff -c openafs/src/WINNT/client_creds/NTMakefile:1.11.2.1 openafs/src/WINNT/client_creds/NTMakefile:1.11.2.3
*** openafs/src/WINNT/client_creds/NTMakefile:1.11.2.1	Fri Nov  5 14:21:53 2004
--- openafs/src/WINNT/client_creds/NTMakefile	Tue Dec  7 01:01:00 2004
***************
*** 129,135 ****
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean
  	$(CD) ..
  
  mkdir:
--- 129,135 ----
  
  clean::
  	$(CD) lang
! 	for /f %l in ('dir /B ??_??') do ( if exist @$(NTLANG) do @$(NTLANG) %l $(MAKECMD) /nologo /f NTMakefile clean )
  	$(CD) ..
  
  mkdir:
Index: openafs/src/WINNT/client_creds/creds.cpp
diff -c openafs/src/WINNT/client_creds/creds.cpp:1.11 openafs/src/WINNT/client_creds/creds.cpp:1.11.2.1
*** openafs/src/WINNT/client_creds/creds.cpp:1.11	Tue Jul 20 11:51:07 2004
--- openafs/src/WINNT/client_creds/creds.cpp	Tue Dec  7 00:54:00 2004
***************
*** 446,452 ****
      }
      else if (IsServiceRunning())
      {
!         char szCellA[ 256 ] = "";
          int rc;
          HKEY hk;
  
--- 446,452 ----
      }
      else if (IsServiceRunning())
      {
!         char szCellA[ cchRESOURCE ] = "";
          int rc;
          HKEY hk;
  
***************
*** 463,470 ****
          } else {
              rc = 0;
          }
! 		if (rc == 0)
! 			CopyAnsiToString(pszCell, szCellA);
      }
      return rc;
  }
--- 463,470 ----
          } else {
              rc = 0;
          }
!         if (rc == 0)
!             CopyAnsiToString(pszCell, szCellA);
      }
      return rc;
  }
Index: openafs/src/WINNT/client_creds/credstab.cpp
diff -c openafs/src/WINNT/client_creds/credstab.cpp:1.5 openafs/src/WINNT/client_creds/credstab.cpp:1.5.2.1
*** openafs/src/WINNT/client_creds/credstab.cpp:1.5	Mon Jun 28 12:33:20 2004
--- openafs/src/WINNT/client_creds/credstab.cpp	Tue Dec  7 00:54:00 2004
***************
*** 389,394 ****
--- 389,398 ----
         pszCell = (LPTSTR)GetWindowLong (hDlg, DWL_USER);
     if (pszCell)
        {
+       HWND hTab = GetDlgItem (g.hMain, IDC_TABS);
+       LPTSTR pszTab = (LPTSTR)GetTabParam (hTab, TabCtrl_GetCurSel(hTab));
+       HWND hChildDlg = NULL;
+ 
        lock_ObtainMutex(&g.credsLock);
        for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
           {
***************
*** 399,415 ****
  
              // Check the active tab, and fix its checkbox if necessary
              //
-             HWND hTab = GetDlgItem (g.hMain, IDC_TABS);
-             LPTSTR pszTab = (LPTSTR)GetTabParam (hTab, TabCtrl_GetCurSel(hTab));
              if (pszTab && HIWORD(pszTab) && (!lstrcmpi (pszTab, pszCell)))
                 {
!                HWND hDlg = GetTabChild (hTab);
!                if (hDlg)
!                   CheckDlgButton (hDlg, IDC_CREDS_REMIND, FALSE);
                 }
              }
           }
        lock_ReleaseMutex(&g.credsLock);
!       }
  }
  
--- 403,418 ----
  
              // Check the active tab, and fix its checkbox if necessary
              //
              if (pszTab && HIWORD(pszTab) && (!lstrcmpi (pszTab, pszCell)))
                 {
!                hChildDlg = GetTabChild (hTab);
                 }
              }
           }
        lock_ReleaseMutex(&g.credsLock);
! 
!       if (hChildDlg)
!          CheckDlgButton (hChildDlg, IDC_CREDS_REMIND, FALSE);
! 	  }
  }
  
Index: openafs/src/WINNT/client_osi/NTMakefile
diff -c openafs/src/WINNT/client_osi/NTMakefile:1.7 openafs/src/WINNT/client_osi/NTMakefile:1.7.2.1
*** openafs/src/WINNT/client_osi/NTMakefile:1.7	Thu Feb 26 14:22:49 2004
--- openafs/src/WINNT/client_osi/NTMakefile	Tue Dec  7 00:55:55 2004
***************
*** 72,79 ****
  DLLLIBS =\
          rpcndr.lib \
          rpcrt4.lib \
!         rpcns4.lib \
! 	largeint.lib
  
  $(DLLFILE): $(DLLOBJS) 
  	$(DLLGUILINK) $(DLLLIBS) -def:libosi.def
--- 72,79 ----
  DLLLIBS =\
          rpcndr.lib \
          rpcrt4.lib \
!         rpcns4.lib
! #	largeint.lib
  
  $(DLLFILE): $(DLLOBJS) 
  	$(DLLGUILINK) $(DLLLIBS) -def:libosi.def
Index: openafs/src/WINNT/install/NSIS/OpenAFS.nsi
diff -c openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.69.2.4 openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.69.2.6
*** openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.69.2.4	Thu Sep  9 16:13:14 2004
--- openafs/src/WINNT/install/NSIS/OpenAFS.nsi	Wed Dec  8 04:10:37 2004
***************
*** 574,579 ****
--- 574,583 ----
    WriteRegStr HKCR "FOLDER\shellex\ContextMenuHandlers\AFS Client Shell Extension" "" "{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Shell Extensions\Approved" "{DC515C27-6CAC-11D1-BAE7-00C04FD140D2}" "AFS Client Shell Extension"
    WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Control Panel\Cpls" "afs_cpa" "$INSTDIR\Client\Program\afs_cpa.cpl"
+ 
+   ; Support for apps that wrote submount data directly to afsdsbmt.ini
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\afsdsbmt.ini" "AFS Mappings" "USR:Software\OpenAFS\Client\mappings"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\afsdsbmt.ini" "AFS Submounts" "SYS:OpenAFS\Client\Submounts"
    
    ; AFS Reg entries
    DeleteRegKey HKLM "${AFS_REGKEY_ROOT}\AFS Client\CurrentVersion"
***************
*** 1963,1969 ****
    DeleteRegKey /ifempty HKLM "${AFS_REGKEY_ROOT}"
    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS"
    DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Services\NetBT\Parameters" "SmbDeviceEnabled"
!  
    RMDir  "$INSTDIR"
  
  SectionEnd
--- 1967,1976 ----
    DeleteRegKey /ifempty HKLM "${AFS_REGKEY_ROOT}"
    DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS"
    DeleteRegValue HKLM "SYSTEM\CurrentControlSet\Services\NetBT\Parameters" "SmbDeviceEnabled"
! 
!   ; Support for apps that wrote submount data directly to afsdsbmt.ini
!   DeleteRegKey HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\afsdsbmt.ini"
! 
    RMDir  "$INSTDIR"
  
  SectionEnd
***************
*** 2232,2249 ****
--- 2239,2287 ----
    StrCmp $R0 "0" good
    
  startOver:
+    ; We want to read in the existing parameters and make them the defaults
+    
+    ;AFS Crypt security
+    ReadRegDWORD $R1 HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "SecurityLevel"
+    StrCmp $R1 "" +3
+    WriteINIStr $1 "Field 3" "State" $R1
+    goto +2
+    WriteINIStr $1 "Field 3" "State" "1"
+    
+    ;Use DNS
+    ReadRegDWORD $R1 HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "UseDNS"
+    StrCmp $R1 "" +3
+    WriteINIStr $1 "Field 9" "State" $R1
+    goto +2
+    WriteINIStr $1 "Field 9" "State" "1"
+    
+    ; Use integrated logon
+    ReadRegDWORD $R1 HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "LogonOptions"
+    StrCmp $R1 "" +3
+    WriteINIStr $1 "Field 7" "State" $R1
+    goto +2
+    WriteINIStr $1 "Field 7" "State" "0"
+    
     ; If this is a server install, we do NOT want to recommend the Freelance client
     ; And we do not need to ask for the cell name.
     SectionGetFlags ${secServer} $R1
     IntOp $R1 $R1 & ${SF_SELECTED}
     StrCmp $R1 "1" +1 NotServer
     WriteINIStr $1 "Field 6" "Text" "Enable AFS Freelance client (Not Recommended for servers)"
+    ReadRegDWORD $R1 HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "FreelanceClient"
+    StrCmp $R1 "" +3
+    WriteINIStr $1 "Field 5" "State" $R1
+    goto +2
     WriteINIStr $1 "Field 5" "State" "0"
     WriteINIStr $1 "Field 1" "Flags" "DISABLED"
     WriteINIStr $1 "Field 2" "Flags" "DISABLED"
     goto SkipServerTest
  NotServer:
     WriteINIStr $1 "Field 6" "Text" "Enable AFS Freelance client (Recommended)"
+    ReadRegDWORD $R1 HKLM "SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" "FreelanceClient"
+    StrCmp $R1 "" +3
+    WriteINIStr $1 "Field 5" "State" $R1
+    goto +2
     WriteINIStr $1 "Field 5" "State" "1"
     WriteINIStr $1 "Field 1" "Flags" ""
     WriteINIStr $1 "Field 2" "Flags" ""
Index: openafs/src/WINNT/install/wix/feature.wxi
diff -c openafs/src/WINNT/install/wix/feature.wxi:1.5.2.2 openafs/src/WINNT/install/wix/feature.wxi:1.5.2.3
*** openafs/src/WINNT/install/wix/feature.wxi:1.5.2.2	Fri Nov  5 14:21:57 2004
--- openafs/src/WINNT/install/wix/feature.wxi	Wed Dec  8 05:20:50 2004
***************
*** 35,40 ****
--- 35,41 ----
  				<ComponentRef Id="rcm_Client" />
                  <ComponentRef Id="rcm_ClientCacheSize" />
                  <ComponentRef Id="rcm_ClientCachePath" />
+                 <ComponentRef Id="rcm_StoreAnsiFilenames" />
  
  				<ComponentRef Id="cmp_CommonDir" />
  
Index: openafs/src/WINNT/install/wix/property.wxi
diff -c openafs/src/WINNT/install/wix/property.wxi:1.6.2.1 openafs/src/WINNT/install/wix/property.wxi:1.6.2.2
*** openafs/src/WINNT/install/wix/property.wxi:1.6.2.1	Fri Aug 20 16:15:19 2004
--- openafs/src/WINNT/install/wix/property.wxi	Wed Dec  8 04:58:53 2004
***************
*** 26,31 ****
--- 26,34 ----
  	<!-- empty property
  	<Property Id="AFSCACHESIZE"></Property>
  	-->
+ 	<!-- empty property
+ 	<Property Id="STOREANSIFILENAMES"></Property>
+ 	-->
  
      <!-- Add/remove programs -->
      <Property Id="ARPCOMMENTS">$(var.ProductComments)</Property>
Index: openafs/src/WINNT/install/wix/registry.wxi
diff -c openafs/src/WINNT/install/wix/registry.wxi:1.5.2.1 openafs/src/WINNT/install/wix/registry.wxi:1.5.2.3
*** openafs/src/WINNT/install/wix/registry.wxi:1.5.2.1	Fri Aug 20 16:15:19 2004
--- openafs/src/WINNT/install/wix/registry.wxi	Wed Dec  8 04:58:53 2004
***************
*** 123,137 ****
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="UseDNS" Type="integer" Value="[USEDNS]" Id="reg_Full_Client10" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="SecurityLevel" Type="integer" Value="[SECURITYLEVEL]" Id="reg_Full_Client12" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="SMBAuthType" Type="integer" Value="[SMBAUTHTYPE]" Id="reg_Full_Client13" />
      </Component>
      <Component Id="rcm_ClientCachePath" Guid="4080E08D-6649-4A06-B286-F5E737DF4D8A" Transitive="yes">
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="CachePath" Type="expandable" Value="[AFSCACHEPATH]" Id="reg_Full_Client14" KeyPath="yes" />
          <Condition>AFSCACHEPATH &lt;&gt; ""</Condition>
      </Component>
      <Component Id="rcm_ClientCacheSize" Guid="F3A12290-920B-42E9-8E49-4958D7C0B6E2" Transitive="yes">
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="CacheSize" Type="integer" Value="[AFSCACHESIZE]" Id="reg_Full_Client15" KeyPath="yes" />
          <Condition>AFSCACHESIZE &lt;&gt; ""</Condition>
      </Component>
      <Component Id="rcm_Documentation" Guid="97493526-4A5C-4C55-A1D6-EA38841B1B85">
          <Registry Root="HKLM" Key="SOFTWARE\TransarcCorporation\AFS Supplemental Documentation" KeyPath="yes" Id="reg_Docs2" />
          <Registry Root="HKLM" Key="SOFTWARE\TransarcCorporation\AFS Supplemental Documentation" Action="createKeyAndRemoveKeyOnUninstall" Id="reg_Docs" />
--- 123,143 ----
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="UseDNS" Type="integer" Value="[USEDNS]" Id="reg_Full_Client10" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="SecurityLevel" Type="integer" Value="[SECURITYLEVEL]" Id="reg_Full_Client12" />
          <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="SMBAuthType" Type="integer" Value="[SMBAUTHTYPE]" Id="reg_Full_Client13" />
+         <Registry Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\afsdsbmt.ini" Name="AFS Mappings" Type="string" Value="USR:Software\OpenAFS\Client\mappings" Id="reg_Full_Client14" />
+         <Registry Root="HKLM" Key="SOFTWARE\Microsoft\Windows NT\CurrentVersion\IniFileMapping\afsdsbmt.ini" Name="AFS Submounts" Type="string" Value="SYS:OpenAFS\Client\Submounts" Id="reg_Full_Client15" />
      </Component>
      <Component Id="rcm_ClientCachePath" Guid="4080E08D-6649-4A06-B286-F5E737DF4D8A" Transitive="yes">
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="CachePath" Type="expandable" Value="[AFSCACHEPATH]" Id="reg_Full_Client16" KeyPath="yes" />
          <Condition>AFSCACHEPATH &lt;&gt; ""</Condition>
      </Component>
      <Component Id="rcm_ClientCacheSize" Guid="F3A12290-920B-42E9-8E49-4958D7C0B6E2" Transitive="yes">
!         <Registry Root="HKLM" Key="SYSTEM\CurrentControlSet\Services\TransarcAFSDaemon\Parameters" Name="CacheSize" Type="integer" Value="[AFSCACHESIZE]" Id="reg_Full_Client17" KeyPath="yes" />
          <Condition>AFSCACHESIZE &lt;&gt; ""</Condition>
      </Component>
+     <Component Id="rcm_StoreAnsiFilenames" Guid="EAC84AD6-CF90-4b28-AF32-6F96DF55C3C4" Transitive="yes">
+         <Registry Root="HKLM" Key="SOFTWARE\OpenAFS\Client" Name="StoreAnsiFilenames" Type="integer" Value="[STOREANSIFILENAMES]" Id="reg_Full_Client18" KeyPath="yes" />
+         <Condition>STOREANSIFILENAMES &lt;&gt; ""</Condition>
+     </Component>
      <Component Id="rcm_Documentation" Guid="97493526-4A5C-4C55-A1D6-EA38841B1B85">
          <Registry Root="HKLM" Key="SOFTWARE\TransarcCorporation\AFS Supplemental Documentation" KeyPath="yes" Id="reg_Docs2" />
          <Registry Root="HKLM" Key="SOFTWARE\TransarcCorporation\AFS Supplemental Documentation" Action="createKeyAndRemoveKeyOnUninstall" Id="reg_Docs" />
Index: openafs/src/WINNT/pthread/NTMakefile
diff -c openafs/src/WINNT/pthread/NTMakefile:1.8 openafs/src/WINNT/pthread/NTMakefile:1.8.2.1
*** openafs/src/WINNT/pthread/NTMakefile:1.8	Fri Nov 21 03:00:10 2003
--- openafs/src/WINNT/pthread/NTMakefile	Tue Dec  7 00:55:56 2004
***************
*** 20,25 ****
--- 20,28 ----
  
  PTHR_DLLFILE = $(DESTDIR)\lib\afspthread.dll
  
+ $(OUT)\pthread.res: pthread.rc AFS_component_version_number.h
+ 	$(RC) /fo$*.res $(*F).rc 
+ 
  PTHR_DLLOBJS = \
  	$(OUT)\pthread.obj \
  	$(OUT)\pthread.res
Index: openafs/src/WINNT/pthread/pthread.c
diff -c openafs/src/WINNT/pthread/pthread.c:1.6.2.3 openafs/src/WINNT/pthread/pthread.c:1.6.2.4
*** openafs/src/WINNT/pthread/pthread.c:1.6.2.3	Fri Nov  5 14:21:57 2004
--- openafs/src/WINNT/pthread/pthread.c	Tue Dec  7 11:16:09 2004
***************
*** 590,600 ****
      (pthread_cache_done || pthread_once(&pthread_cache_once, create_once));
  
      if (terminate_thread_handle == INVALID_HANDLE_VALUE) {
! 	terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0,
! 				TRUE, FALSE, (LPCTSTR) 0);
! 	terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0, 
! 		                terminate_thread_routine, (LPVOID) 0, 0, 
! 			        &terminate_thread_id);
      } else {
      	SetEvent (terminate_thread_wakeup_event);
      }
--- 590,603 ----
      (pthread_cache_done || pthread_once(&pthread_cache_once, create_once));
  
      if (terminate_thread_handle == INVALID_HANDLE_VALUE) {
!         CHAR eventName[MAX_PATH];
!         static eventCount = 0;
!         sprintf(eventName, "terminate_thread_wakeup_event %d::%d", _getpid(), eventCount++);
!         terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0,
!                                                      TRUE, FALSE, (LPCTSTR) eventName);
!         terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0, 
!                                                 terminate_thread_routine, (LPVOID) 0, 0, 
!                                                 &terminate_thread_id);
      } else {
      	SetEvent (terminate_thread_wakeup_event);
      }
***************
*** 711,718 ****
      if (queue_IsEmpty(&waiter_cache)) {
          new = (cond_waiters_t *) malloc(sizeof(cond_waiters_t));
  	if (new != NULL) {
! 	    new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE,
! 				     FALSE, (LPCTSTR) 0);
  	    if (new->event == NULL) {
  		free(new);
  		new = NULL;
--- 714,724 ----
      if (queue_IsEmpty(&waiter_cache)) {
          new = (cond_waiters_t *) malloc(sizeof(cond_waiters_t));
  	if (new != NULL) {
!         CHAR eventName[MAX_PATH];
!         static eventCount = 0;
!         sprintf(eventName, "cond_waiters_t %d::%d", _getpid(), eventCount++);
!         new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE,
!                                   FALSE, (LPCTSTR) eventName);
  	    if (new->event == NULL) {
  		free(new);
  		new = NULL;
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.74.2.2 openafs/src/afs/afs_call.c:1.74.2.3
*** openafs/src/afs/afs_call.c:1.74.2.2	Wed Aug 25 03:16:11 2004
--- openafs/src/afs/afs_call.c	Tue Dec  7 01:12:11 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.2 2004/08/25 07:16: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.3 2004/12/07 06:12:11 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 271,277 ****
  	complete_and_exit(0, 0);
  	break;
      default:
! 	printf("Unknown op %d in StartDaemon()\n", parm);
  	break;
      }
      return 0;
--- 271,277 ----
  	complete_and_exit(0, 0);
  	break;
      default:
! 	printf("Unknown op %ld in StartDaemon()\n", (long)parm);
  	break;
      }
      return 0;
***************
*** 1096,1101 ****
--- 1096,1102 ----
  };
  
  
+ #if defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV))
  static void
  iparam32_to_iparam(const struct iparam32 *src, struct iparam *dst)
  {
***************
*** 1104,1109 ****
--- 1105,1111 ----
      dst->param3 = src->param3;
      dst->param4 = src->param4;
  }
+ #endif
  
  /*
   * If you need to change copyin_iparam(), you may also need to change
***************
*** 3018,3024 ****
      for (tp = afs_icl_allSets; tp; tp = np) {
  	tp->refCount++;		/* hold this guy */
  	ReleaseWriteLock(&afs_icl_lock);
! 	code = (*aproc) (tp->name, arock, tp);
  	ObtainWriteLock(&afs_icl_lock, 206);
  	np = tp->nextp;		/* tp may disappear next, but not np */
  	if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
--- 3020,3026 ----
      for (tp = afs_icl_allSets; tp; tp = np) {
  	tp->refCount++;		/* hold this guy */
  	ReleaseWriteLock(&afs_icl_lock);
! 	code = (*aproc) (tp->name, arock, (struct afs_icl_log *)tp);
  	ObtainWriteLock(&afs_icl_lock, 206);
  	np = tp->nextp;		/* tp may disappear next, but not np */
  	if (--tp->refCount == 0 && (tp->states & ICL_SETF_DELETED))
Index: openafs/src/afs/afs_conn.c
diff -c openafs/src/afs/afs_conn.c:1.13 openafs/src/afs/afs_conn.c:1.13.2.1
*** openafs/src/afs/afs_conn.c:1.13	Tue Jul 15 19:14:11 2003
--- openafs/src/afs/afs_conn.c	Tue Dec  7 01:12:11 2004
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_conn.c,v 1.13 2003/07/15 23:14:11 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_conn.c,v 1.13.2.1 2004/12/07 06:12:11 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 220,226 ****
  	    }
  	    isec = 2;
  	    /* kerberos tickets on channel 2 */
! 	    csec = rxkad_NewClientSecurityObject(level, tu->ct.HandShakeKey,
  						 /* kvno */
  						 tu->ct.AuthHandle, tu->stLen,
  						 tu->stp);
--- 220,227 ----
  	    }
  	    isec = 2;
  	    /* kerberos tickets on channel 2 */
! 	    csec = rxkad_NewClientSecurityObject(level,
!                                                  (struct ktc_encryptionKey *)tu->ct.HandShakeKey,
  						 /* kvno */
  						 tu->ct.AuthHandle, tu->stLen,
  						 tu->stp);
Index: openafs/src/afs/afs_daemons.c
diff -c openafs/src/afs/afs_daemons.c:1.28.2.1 openafs/src/afs/afs_daemons.c:1.28.2.2
*** openafs/src/afs/afs_daemons.c:1.28.2.1	Wed Aug 25 03:16:11 2004
--- openafs/src/afs/afs_daemons.c	Tue Dec  7 01:12:11 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.28.2.1 2004/08/25 07:16:11 shadow Exp $");
  
  #ifdef AFS_AIX51_ENV
  #define __FULL_PROTO
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.28.2.2 2004/12/07 06:12:11 shadow Exp $");
  
  #ifdef AFS_AIX51_ENV
  #define __FULL_PROTO
***************
*** 292,324 ****
  	strcpy(rootVolName, afs_rootVolumeName);
      }
  
!     if (!usingDynroot) {
  	struct cell *lc = afs_GetPrimaryCell(READ_LOCK);
  
  	if (!lc)
  	    return ENOENT;
  	localcell = lc->cellNum;
  	afs_PutCell(lc, READ_LOCK);
-     }
- 
-     if (usingDynroot) {
- 	afs_GetDynrootFid(&afs_rootFid);
- 	tvp = afs_GetVolume(&afs_rootFid, NULL, READ_LOCK);
-     } else {
  	tvp = afs_GetVolumeByName(rootVolName, localcell, 1, NULL, READ_LOCK);
!     }
!     if (!tvp && !usingDynroot) {
! 	char buf[128];
! 	int len = strlen(rootVolName);
! 
! 	if ((len < 9) || strcmp(&rootVolName[len - 9], ".readonly")) {
! 	    strcpy(buf, rootVolName);
! 	    afs_strcat(buf, ".readonly");
! 	    tvp = afs_GetVolumeByName(buf, localcell, 1, NULL, READ_LOCK);
  	}
!     }
!     if (tvp) {
! 	if (!usingDynroot) {
  	    int volid = (tvp->roVol ? tvp->roVol : tvp->volume);
  	    afs_rootFid.Cell = localcell;
  	    if (afs_rootFid.Fid.Volume && afs_rootFid.Fid.Volume != volid
--- 292,319 ----
  	strcpy(rootVolName, afs_rootVolumeName);
      }
  
!     if (usingDynroot) {
! 	afs_GetDynrootFid(&afs_rootFid);
! 	tvp = afs_GetVolume(&afs_rootFid, NULL, READ_LOCK);
!     } else {
  	struct cell *lc = afs_GetPrimaryCell(READ_LOCK);
  
  	if (!lc)
  	    return ENOENT;
  	localcell = lc->cellNum;
  	afs_PutCell(lc, READ_LOCK);
  	tvp = afs_GetVolumeByName(rootVolName, localcell, 1, NULL, READ_LOCK);
! 	if (!tvp) {
! 	    char buf[128];
! 	    int len = strlen(rootVolName);
! 
! 	    if ((len < 9) || strcmp(&rootVolName[len - 9], ".readonly")) {
! 		strcpy(buf, rootVolName);
! 		afs_strcat(buf, ".readonly");
! 		tvp = afs_GetVolumeByName(buf, localcell, 1, NULL, READ_LOCK);
! 	    }
  	}
! 	if (tvp) {
  	    int volid = (tvp->roVol ? tvp->roVol : tvp->volume);
  	    afs_rootFid.Cell = localcell;
  	    if (afs_rootFid.Fid.Volume && afs_rootFid.Fid.Volume != volid
***************
*** 337,342 ****
--- 332,339 ----
  	    afs_rootFid.Fid.Vnode = 1;
  	    afs_rootFid.Fid.Unique = 1;
  	}
+     }
+     if (tvp) {
  	afs_initState = 300;	/* won */
  	afs_osi_Wakeup(&afs_initState);
  	afs_PutVolume(tvp, READ_LOCK);
Index: openafs/src/afs/afs_dcache.c
diff -c openafs/src/afs/afs_dcache.c:1.42.2.3 openafs/src/afs/afs_dcache.c:1.42.2.4
*** openafs/src/afs/afs_dcache.c:1.42.2.3	Tue Nov  9 12:14:57 2004
--- openafs/src/afs/afs_dcache.c	Tue Dec  7 01:12:11 2004
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.3 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 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 */
***************
*** 1199,1205 ****
  {
      afs_int32 chunk;
      register afs_int32 i, index;
!     register struct dcache *tdc;
  
      AFS_STATCNT(afs_FindDCache);
      chunk = AFS_CHUNK(abyte);
--- 1199,1205 ----
  {
      afs_int32 chunk;
      register afs_int32 i, index;
!     register struct dcache *tdc = NULL;
  
      AFS_STATCNT(afs_FindDCache);
      chunk = AFS_CHUNK(abyte);
***************
*** 1526,1532 ****
      register struct osi_file *file;
      register struct conn *tc;
      int downDCount = 0;
!     struct server *newCallback;
      char setNewCallback;
      char setVcacheStatus;
      char doVcacheUpdate;
--- 1526,1532 ----
      register struct osi_file *file;
      register struct conn *tc;
      int downDCount = 0;
!     struct server *newCallback = NULL;
      char setNewCallback;
      char setVcacheStatus;
      char doVcacheUpdate;
Index: openafs/src/afs/afs_init.c
diff -c openafs/src/afs/afs_init.c:1.28 openafs/src/afs/afs_init.c:1.28.2.1
*** openafs/src/afs/afs_init.c:1.28	Sat May  8 00:23:56 2004
--- openafs/src/afs/afs_init.c	Tue Dec  7 01:12:11 2004
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28 2004/05/08 04:23:56 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28.2.1 2004/12/07 06:12:11 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 351,357 ****
--- 351,359 ----
      struct osi_stat tstat;
      register struct osi_file *tfile;
      struct afs_fheader theader;
+ #ifndef AFS_LINUX22_ENV
      struct vnode *filevp;
+ #endif
      int goodFile;
  
      AFS_STATCNT(afs_InitCacheInfo);
Index: openafs/src/afs/afs_memcache.c
diff -c openafs/src/afs/afs_memcache.c:1.15 openafs/src/afs/afs_memcache.c:1.15.2.1
*** openafs/src/afs/afs_memcache.c:1.15	Tue Jul 15 19:14:12 2003
--- openafs/src/afs/afs_memcache.c	Tue Dec  7 01:12:11 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_memcache.c,v 1.15 2003/07/15 23:14:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifndef AFS_LINUX22_ENV
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_memcache.c,v 1.15.2.1 2004/12/07 06:12:11 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifndef AFS_LINUX22_ENV
***************
*** 84,96 ****
  }
  
  int
! afs_MemCacheClose(char *file)
  {
      return 0;
  }
  
  void *
  afs_MemCacheOpen(ino_t blkno)
  {
      struct memCacheEntry *mep;
  
--- 84,101 ----
  }
  
  int
! afs_MemCacheClose(struct osi_file *file)
  {
      return 0;
  }
  
+ #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV)
  void *
  afs_MemCacheOpen(ino_t blkno)
+ #else
+ void *
+ afs_MemCacheOpen(afs_int32 blkno)
+ #endif
  {
      struct memCacheEntry *mep;
  
***************
*** 108,116 ****
   * this routine simulates a read in the Memory Cache 
   */
  int
! afs_MemReadBlk(register struct memCacheEntry *mceP, int offset, char *dest,
  	       int size)
  {
      int bytesRead;
  
      MObtainReadLock(&mceP->afs_memLock);
--- 113,122 ----
   * this routine simulates a read in the Memory Cache 
   */
  int
! afs_MemReadBlk(register struct osi_file *fP, int offset, void *dest,
  	       int size)
  {
+     register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
      int bytesRead;
  
      MObtainReadLock(&mceP->afs_memLock);
***************
*** 188,196 ****
  
  /*XXX: this extends a block arbitrarily to support big directories */
  int
! afs_MemWriteBlk(register struct memCacheEntry *mceP, int offset, char *src,
  		int size)
  {
      AFS_STATCNT(afs_MemWriteBlk);
      MObtainWriteLock(&mceP->afs_memLock, 560);
      if (size + offset > mceP->dataSize) {
--- 194,203 ----
  
  /*XXX: this extends a block arbitrarily to support big directories */
  int
! afs_MemWriteBlk(register struct osi_file *fP, int offset, void *src,
  		int size)
  {
+     register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
      AFS_STATCNT(afs_MemWriteBlk);
      MObtainWriteLock(&mceP->afs_memLock, 560);
      if (size + offset > mceP->dataSize) {
***************
*** 300,307 ****
  }
  
  int
! afs_MemCacheTruncate(register struct memCacheEntry *mceP, int size)
  {
      AFS_STATCNT(afs_MemCacheTruncate);
  
      MObtainWriteLock(&mceP->afs_memLock, 313);
--- 307,315 ----
  }
  
  int
! afs_MemCacheTruncate(register struct osi_file *fP, int size)
  {
+     register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
      AFS_STATCNT(afs_MemCacheTruncate);
  
      MObtainWriteLock(&mceP->afs_memLock, 313);
***************
*** 321,331 ****
  
  int
  afs_MemCacheStoreProc(register struct rx_call *acall,
! 		      register struct memCacheEntry *mceP,
  		      register afs_int32 alen, struct vcache *avc,
  		      int *shouldWake, afs_size_t * abytesToXferP,
! 		      afs_size_t * abytesXferredP, afs_int32 length)
  {
  
      register afs_int32 code;
      register int tlen;
--- 329,340 ----
  
  int
  afs_MemCacheStoreProc(register struct rx_call *acall,
! 		      register struct osi_file *fP,
  		      register afs_int32 alen, struct vcache *avc,
  		      int *shouldWake, afs_size_t * abytesToXferP,
! 		      afs_size_t * abytesXferredP)
  {
+     register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
  
      register afs_int32 code;
      register int tlen;
***************
*** 407,417 ****
  
  int
  afs_MemCacheFetchProc(register struct rx_call *acall,
! 		      register struct memCacheEntry *mceP, afs_size_t abase,
  		      struct dcache *adc, struct vcache *avc,
  		      afs_size_t * abytesToXferP, afs_size_t * abytesXferredP,
  		      afs_int32 lengthFound)
  {
      register afs_int32 code;
      afs_int32 length;
      int moredata = 0;
--- 416,427 ----
  
  int
  afs_MemCacheFetchProc(register struct rx_call *acall,
! 		      register struct osi_file *fP, afs_size_t abase,
  		      struct dcache *adc, struct vcache *avc,
  		      afs_size_t * abytesToXferP, afs_size_t * abytesXferredP,
  		      afs_int32 lengthFound)
  {
+     register struct memCacheEntry *mceP = (struct memCacheEntry *)fP;
      register afs_int32 code;
      afs_int32 length;
      int moredata = 0;
Index: openafs/src/afs/afs_osi.c
diff -c openafs/src/afs/afs_osi.c:1.48 openafs/src/afs/afs_osi.c:1.48.2.1
*** openafs/src/afs/afs_osi.c:1.48	Sun Aug  8 20:17:33 2004
--- openafs/src/afs/afs_osi.c	Tue Dec  7 01:12:11 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48 2004/08/09 00:17:33 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/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 */
***************
*** 445,452 ****
--- 445,454 ----
  void *
  afs_osi_Alloc(size_t x)
  {
+ #if !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
      register struct osimem *tm = NULL;
      register int size;
+ #endif
  
      AFS_STATCNT(osi_Alloc);
      /* 0-length allocs may return NULL ptr from AFS_KALLOC, so we special-case
Index: openafs/src/afs/afs_pioctl.c
diff -c openafs/src/afs/afs_pioctl.c:1.81.2.3 openafs/src/afs/afs_pioctl.c:1.81.2.4
*** openafs/src/afs/afs_pioctl.c:1.81.2.3	Tue Nov  9 12:14:57 2004
--- openafs/src/afs/afs_pioctl.c	Tue Dec  7 01:12:11 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.3 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #ifdef AFS_OBSD_ENV
--- 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
***************
*** 195,200 ****
--- 195,201 ----
  #define PSetClientContext 99	/*  Special pioctl to setup caller's creds  */
  int afs_nobody = NFS_NOBODY;
  
+ #if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || defined(AFS_HPUX_64BIT_ENV) || defined(AFS_SUN57_64BIT_ENV) || (defined(AFS_SGI_ENV) && (_MIPS_SZLONG==64)) || (defined(AFS_LINUX_64BIT_KERNEL) && !defined(AFS_ALPHA_LINUX20_ENV) && !defined(AFS_IA64_LINUX20_ENV) && !defined(AFS_AMD64_LINUX20_ENV))
  static void
  afs_ioctl32_to_afs_ioctl(const struct afs_ioctl32 *src, struct afs_ioctl *dst)
  {
***************
*** 203,208 ****
--- 204,210 ----
      dst->in_size = src->in_size;
      dst->out_size = src->out_size;
  }
+ #endif
  
  /*
   * If you need to change copyin_afs_ioctl(), you may also need to change
***************
*** 846,854 ****
       int follow;
  {
      struct afs_ioctl data;
!     struct AFS_UCRED *tmpcred, *foreigncreds = NULL;
      register afs_int32 code = 0;
!     struct vnode *vp;
  #ifdef AFS_DEC_ENV
      struct vnode *gp;
  #endif
--- 848,859 ----
       int follow;
  {
      struct afs_ioctl data;
! #ifdef AFS_NEED_CLIENTCONTEXT
!     struct AFS_UCRED *tmpcred;
! #endif
!     struct AFS_UCRED *foreigncreds = NULL;
      register afs_int32 code = 0;
!     struct vnode *vp = NULL;
  #ifdef AFS_DEC_ENV
      struct vnode *gp;
  #endif
***************
*** 1519,1525 ****
      char *motd = afs_osi_Alloc(256);
      register struct conn *tc;
      register afs_int32 code = 0;
!     struct VolumeStatus volstat;
      register char *cp;
      char *Name, *OfflineMsg, *MOTD;
      XSTATS_DECLS;
--- 1524,1530 ----
      char *motd = afs_osi_Alloc(256);
      register struct conn *tc;
      register afs_int32 code = 0;
!     struct AFSFetchVolumeStatus volstat;
      register char *cp;
      char *Name, *OfflineMsg, *MOTD;
      XSTATS_DECLS;
***************
*** 2691,2697 ****
   /* for the reader.  */
  DECL_PIOCTL(PSetSysName)
  {
!     char *cp, *cp2, inname[MAXSYSNAME], outname[MAXSYSNAME];
      int setsysname, foundname = 0;
      register struct afs_exporter *exporter;
      register struct unixuser *au;
--- 2696,2702 ----
   /* for the reader.  */
  DECL_PIOCTL(PSetSysName)
  {
!     char *cp, *cp2 = NULL, inname[MAXSYSNAME], outname[MAXSYSNAME];
      int setsysname, foundname = 0;
      register struct afs_exporter *exporter;
      register struct unixuser *au;
Index: openafs/src/afs/afs_prototypes.h
diff -c openafs/src/afs/afs_prototypes.h:1.53.2.2 openafs/src/afs/afs_prototypes.h:1.53.2.4
*** openafs/src/afs/afs_prototypes.h:1.53.2.2	Tue Nov  9 12:14:57 2004
--- openafs/src/afs/afs_prototypes.h	Tue Dec  7 01:12:12 2004
***************
*** 196,201 ****
--- 196,203 ----
  
  /* afs_cell.c */
  extern afs_rwlock_t afs_xcell;
+ extern struct afs_q CellLRU;           
+ 
  extern void afs_CellInit(void);
  extern void shutdown_cell(void);
  extern int afs_cellname_init(ino_t inode, int lookupcode);
***************
*** 424,451 ****
  
  /* afs_memcache.c */
  extern int afs_InitMemCache(int blkCount, int blkSize, int flags);
! extern int afs_MemCacheClose(char *file);
  extern void *afs_MemCacheOpen(ino_t blkno);
! extern int afs_MemReadBlk(register struct memCacheEntry *mceP, int offset,
! 			  char *dest, int size);
  extern int afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset,
  			   struct iovec *iov, int nio, int size);
  extern int afs_MemReadUIO(ino_t blkno, struct uio *uioP);
! extern int afs_MemWriteBlk(register struct memCacheEntry *mceP, int offset,
! 			   char *src, int size);
  extern int afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset,
  			    struct iovec *iov, int nio, int size);
  extern int afs_MemWriteUIO(ino_t blkno, struct uio *uioP);
! extern int afs_MemCacheTruncate(register struct memCacheEntry *mceP,
  				int size);
  extern int afs_MemCacheStoreProc(register struct rx_call *acall,
! 				 register struct memCacheEntry *mceP,
  				 register afs_int32 alen, struct vcache *avc,
  				 int *shouldWake, afs_size_t * abytesToXferP,
! 				 afs_size_t * abytesXferredP,
! 				 afs_int32 length);
  extern int afs_MemCacheFetchProc(register struct rx_call *acall,
! 				 register struct memCacheEntry *mceP,
  				 afs_size_t abase, struct dcache *adc,
  				 struct vcache *avc,
  				 afs_size_t * abytesToXferP,
--- 426,456 ----
  
  /* afs_memcache.c */
  extern int afs_InitMemCache(int blkCount, int blkSize, int flags);
! extern int afs_MemCacheClose(struct osi_file *file);
! #if defined(AFS_SUN57_64BIT_ENV) || defined(AFS_SGI62_ENV)
  extern void *afs_MemCacheOpen(ino_t blkno);
! #else
! extern void *afs_MemCacheOpen(afs_int32 blkno);
! #endif
! extern int afs_MemReadBlk(register struct osi_file *fP, int offset,
! 			  void *dest, int size);
  extern int afs_MemReadvBlk(register struct memCacheEntry *mceP, int offset,
  			   struct iovec *iov, int nio, int size);
  extern int afs_MemReadUIO(ino_t blkno, struct uio *uioP);
! extern int afs_MemWriteBlk(register struct osi_file *fP, int offset,
! 			   void *src, int size);
  extern int afs_MemWritevBlk(register struct memCacheEntry *mceP, int offset,
  			    struct iovec *iov, int nio, int size);
  extern int afs_MemWriteUIO(ino_t blkno, struct uio *uioP);
! extern int afs_MemCacheTruncate(register struct osi_file *fP,
  				int size);
  extern int afs_MemCacheStoreProc(register struct rx_call *acall,
! 				 register struct osi_file *fP,
  				 register afs_int32 alen, struct vcache *avc,
  				 int *shouldWake, afs_size_t * abytesToXferP,
! 				 afs_size_t * abytesXferredP);
  extern int afs_MemCacheFetchProc(register struct rx_call *acall,
! 				 register struct osi_file *fP,
  				 afs_size_t abase, struct dcache *adc,
  				 struct vcache *avc,
  				 afs_size_t * abytesToXferP,
***************
*** 545,551 ****
  extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp,
  		    size_t asize, size_t * resid);
  extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
! extern void setup_uio(uio_t * uiop, struct iovec *iovecp, char *buf,
  		      afs_offs_t pos, int count, uio_flag_t flag,
  		      uio_seg_t seg);
  extern int uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop);
--- 550,556 ----
  extern int osi_rdwr(int rw, struct osi_file *file, caddr_t addrp,
  		    size_t asize, size_t * resid);
  extern int osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
! extern void setup_uio(uio_t * uiop, struct iovec *iovecp, const char *buf,
  		      afs_offs_t pos, int count, uio_flag_t flag,
  		      uio_seg_t seg);
  extern int uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop);
***************
*** 659,664 ****
--- 664,670 ----
  extern struct vcache *afs_globalVp;
  #ifdef AFS_LINUX20_ENV
  extern void vcache2inode(struct vcache *avc);
+ extern void vcache2fakeinode(struct vcache *rootvp, struct vcache *mpvp);
  #endif
  
  /* afs_pioctl.c */
***************
*** 705,711 ****
  extern void afs_RemoveSrvAddr(struct srvAddr *sap);
  extern void afs_ActivateServer(struct srvAddr *sap);
  #ifdef AFS_USERSPACE_IP_ADDR
! extern int afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr,
  				afs_uint32 subnetmask);
  #else
  #if (!defined(AFS_SUN5_ENV)) && defined(USEIFADDR)
--- 711,717 ----
  extern void afs_RemoveSrvAddr(struct srvAddr *sap);
  extern void afs_ActivateServer(struct srvAddr *sap);
  #ifdef AFS_USERSPACE_IP_ADDR
! extern void afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr,
  				afs_uint32 subnetmask);
  #else
  #if (!defined(AFS_SUN5_ENV)) && defined(USEIFADDR)
***************
*** 713,718 ****
--- 719,725 ----
  #endif
  #endif
  extern int afs_HaveCallBacksFrom(struct server *aserver);
+ extern void shutdown_server(void);
  
  
  
***************
*** 952,958 ****
  			       struct vrequest *areq);
  extern void afs_PutFakeStat(struct afs_fakestat_state *state);
  extern int afs_ENameOK(register char *aname);
! extern void Check_AtSys(register struct vcache *avc, char *aname,
  			struct sysname_info *state, struct vrequest *areq);
  extern int Next_AtSys(register struct vcache *avc, struct vrequest *areq,
  		      struct sysname_info *state);
--- 959,965 ----
  			       struct vrequest *areq);
  extern void afs_PutFakeStat(struct afs_fakestat_state *state);
  extern int afs_ENameOK(register char *aname);
! extern void Check_AtSys(register struct vcache *avc, const char *aname,
  			struct sysname_info *state, struct vrequest *areq);
  extern int Next_AtSys(register struct vcache *avc, struct vrequest *areq,
  		      struct sysname_info *state);
***************
*** 981,986 ****
--- 988,995 ----
  extern int afs_UFSRead(register struct vcache *avc, struct uio *auio,
  		       struct AFS_UCRED *acred, daddr_t albn,
  		       struct buf **abpp, int noLock);
+ extern void afs_PrefetchChunk(struct vcache *avc, struct dcache *adc,
+ 			      struct AFS_UCRED *acred, struct vrequest *areq);
  
  
  /* VNOPS/afs_vnop_readdir.c */
Index: openafs/src/afs/afs_segments.c
diff -c openafs/src/afs/afs_segments.c:1.16.2.3 openafs/src/afs/afs_segments.c:1.16.2.4
*** openafs/src/afs/afs_segments.c:1.16.2.3	Tue Nov  9 12:14:57 2004
--- openafs/src/afs/afs_segments.c	Tue Dec  7 01:12:12 2004
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_segments.c,v 1.16.2.3 2004/11/09 17:14:57 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_segments.c,v 1.16.2.4 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 236,242 ****
       */
      origCBs = afs_allCBs;
  
-   retry:
      maxStoredLength = 0;
      tlen = avc->m.Length;
      minj = 0;
--- 236,241 ----
***************
*** 301,307 ****
  	    afs_size_t base, bytes;
  	    afs_uint32 nchunks;
  	    int nomore;
! 	    unsigned int first;
  	    int *shouldwake;
  	    struct conn *tc;
  	    struct osi_file *tfile;
--- 300,306 ----
  	    afs_size_t base, bytes;
  	    afs_uint32 nchunks;
  	    int nomore;
! 	    unsigned int first = 0;
  	    int *shouldwake;
  	    struct conn *tc;
  	    struct osi_file *tfile;
Index: openafs/src/afs/afs_server.c
diff -c openafs/src/afs/afs_server.c:1.33.2.1 openafs/src/afs/afs_server.c:1.33.2.3
*** openafs/src/afs/afs_server.c:1.33.2.1	Wed Aug 25 03:07:53 2004
--- openafs/src/afs/afs_server.c	Tue Dec  7 01:12:40 2004
***************
*** 33,39 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.33.2.1 2004/08/25 07:07:53 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 33,39 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.33.2.3 2004/12/07 06:12:40 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 498,506 ****
      struct conn *tc;
      afs_int32 i, j;
      afs_int32 code;
!     afs_int32 start, end, delta;
      osi_timeval_t tv;
-     int setTimer;
      struct unixuser *tu;
      char tbuffer[CVBS];
      int srvAddrCount;
--- 498,506 ----
      struct conn *tc;
      afs_int32 i, j;
      afs_int32 code;
!     afs_int32 start, end = 0, delta;
!     afs_int32 m_error;
      osi_timeval_t tv;
      struct unixuser *tu;
      char tbuffer[CVBS];
      int srvAddrCount;
***************
*** 508,516 ****
      struct conn **conns;
      int nconns;
      struct rx_connection **rxconns;      
-     int nrxconns;
      afs_int32 *conntimer, *deltas;
-     XSTATS_DECLS;
  
      AFS_STATCNT(afs_CheckServers);
  
--- 508,514 ----
***************
*** 600,639 ****
      start = osi_Time();         /* time the gettimeofday call */
      AFS_GUNLOCK(); 
      multi_Rx(rxconns,nconns)
! 	{
! 	    tv.tv_sec = tv.tv_usec = 0;
! 	    multi_RXAFS_GetTime(&tv.tv_sec, &tv.tv_usec);
! 	    tc = conns[multi_i];
! 	    sa = tc->srvr;
! 	    if (conntimer[multi_i] == 0)
! 		rx_SetConnDeadTime(tc->id, AFS_RXDEADTIME);
! 	    end = osi_Time();
! 	    if ((start == end) && !multi_error)
! 		deltas[multi_i] = end - tv.tv_sec;
! 	    if (( multi_error >= 0 ) && (sa->sa_flags & SRVADDR_ISDOWN) && (tc->srvr == sa)) {
! 		/* server back up */
! 		print_internet_address("afs: file server ", sa, " is back up", 2);
! 		
!                 ObtainWriteLock(&afs_xserver, 244);
!                 ObtainWriteLock(&afs_xsrvAddr, 245);        
!                 afs_MarkServerUpOrDown(sa, 0);
!                 ReleaseWriteLock(&afs_xsrvAddr);
!                 ReleaseWriteLock(&afs_xserver);
! 		
! 		if (afs_waitForeverCount) {
! 		    afs_osi_Wakeup(&afs_waitForever);
! 		}
! 	    } else {
! 		if (multi_error < 0) {
! 		                /* server crashed */
! 		    afs_ServerDown(sa);
! 		    ForceNewConnections(sa);  /* multi homed clients */
! 		}
! 	    }
! 	    
! 	} multi_End;
      AFS_GLOCK(); 
!  
      /*
       * If we're supposed to set the time, and the call worked
       * quickly (same second response) and this is the host we
--- 598,644 ----
      start = osi_Time();         /* time the gettimeofday call */
      AFS_GUNLOCK(); 
      multi_Rx(rxconns,nconns)
!       {
! 	tv.tv_sec = tv.tv_usec = 0;
! 	multi_RXAFS_GetTime(&tv.tv_sec, &tv.tv_usec);
! 	tc = conns[multi_i];
! 	sa = tc->srvr;
! 	if (conntimer[multi_i] == 0)
! 	  rx_SetConnDeadTime(tc->id, AFS_RXDEADTIME);
! 	end = osi_Time();
! 	m_error=multi_error;
! 	if ((start == end) && !multi_error)
! 	  deltas[multi_i] = end - tv.tv_sec;
! 	
!       } multi_End;
      AFS_GLOCK(); 
!     
!     for(i=0;i<nconns;i++){
!       tc = conns[i];
!       sa = tc->srvr;
!       
!       if (( m_error >= 0 ) && (sa->sa_flags & SRVADDR_ISDOWN) && (tc->srvr == sa)) {
! 	/* server back up */
! 	print_internet_address("afs: file server ", sa, " is back up", 2);
! 	
! 	ObtainWriteLock(&afs_xserver, 244);
! 	ObtainWriteLock(&afs_xsrvAddr, 245);        
! 	afs_MarkServerUpOrDown(sa, 0);
! 	ReleaseWriteLock(&afs_xsrvAddr);
! 	ReleaseWriteLock(&afs_xserver);
! 	
! 	if (afs_waitForeverCount) {
! 	  afs_osi_Wakeup(&afs_waitForever);
! 	}
!       } else {
! 	if (m_error < 0) {
! 	  /* server crashed */
! 	  afs_ServerDown(sa);
! 	  ForceNewConnections(sa);  /* multi homed clients */
! 	}
!       }
!     }
! 
      /*
       * If we're supposed to set the time, and the call worked
       * quickly (same second response) and this is the host we
***************
*** 1053,1059 ****
   * afs_uint32 subnetmask;         subnet mask of local addr in net order
   *
   */
! int
  afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr,
  		     afs_uint32 subnetmask)
  {
--- 1058,1064 ----
   * afs_uint32 subnetmask;         subnet mask of local addr in net order
   *
   */
! void
  afsi_SetServerIPRank(struct srvAddr *sa, afs_int32 addr,
  		     afs_uint32 subnetmask)
  {
Index: openafs/src/afs/afs_stats.h
diff -c openafs/src/afs/afs_stats.h:1.11.2.1 openafs/src/afs/afs_stats.h:1.11.2.2
*** openafs/src/afs/afs_stats.h:1.11.2.1	Sat Aug 28 21:18:56 2004
--- openafs/src/afs/afs_stats.h	Tue Dec  7 01:12:12 2004
***************
*** 45,51 ****
  typedef struct timeval osi_timeval_t;
  #endif /* !KERNEL */
  
! #define XSTATS_DECLS struct afs_stats_opTimingData *opP; \
      osi_timeval_t opStartTime, opStopTime, elapsedTime
  
  #define XSTATS_START_TIME(arg) \
--- 45,51 ----
  typedef struct timeval osi_timeval_t;
  #endif /* !KERNEL */
  
! #define XSTATS_DECLS struct afs_stats_opTimingData *opP = NULL; \
      osi_timeval_t opStartTime, opStopTime, elapsedTime
  
  #define XSTATS_START_TIME(arg) \
Index: openafs/src/afs/afs_util.c
diff -c openafs/src/afs/afs_util.c:1.17 openafs/src/afs/afs_util.c:1.17.2.1
*** openafs/src/afs/afs_util.c:1.17	Tue Jul 15 19:14:13 2003
--- openafs/src/afs/afs_util.c	Tue Dec  7 01:12:12 2004
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_util.c,v 1.17 2003/07/15 23:14:13 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_util.c,v 1.17.2.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 301,307 ****
  	for (i = 0; i < NSERVERS; i++) {
  	    for (ts = afs_servers[i]; ts; ts = ts->next) {
  		if (ts->flags & SRVR_ISDOWN)
! 		    printf("Server entry %x is marked down\n", ts);
  		for (sa = ts->addr; sa; sa = sa->next_sa) {
  		    for (tc = sa->conns; tc; tc = tc->next) {
  			if (tc->refCount)
--- 301,307 ----
  	for (i = 0; i < NSERVERS; i++) {
  	    for (ts = afs_servers[i]; ts; ts = ts->next) {
  		if (ts->flags & SRVR_ISDOWN)
! 		    printf("Server entry %lx is marked down\n", (unsigned long)ts);
  		for (sa = ts->addr; sa; sa = sa->next_sa) {
  		    for (tc = sa->conns; tc; tc = tc->next) {
  			if (tc->refCount)
***************
*** 329,335 ****
  	for (i = 0; i < NUSERS; i++) {
  	    for (tu = afs_users[i]; tu; tu = tu->next) {
  		if (tu->refCount)
! 		    printf("user at %x is held\n", tu);
  	    }
  	}
      }
--- 329,335 ----
  	for (i = 0; i < NUSERS; i++) {
  	    for (tu = afs_users[i]; tu; tu = tu->next) {
  		if (tu->refCount)
! 		    printf("user at %lx is held\n", (unsigned long)tu);
  	    }
  	}
      }
Index: openafs/src/afs/afs_volume.c
diff -c openafs/src/afs/afs_volume.c:1.26 openafs/src/afs/afs_volume.c:1.26.2.1
*** openafs/src/afs/afs_volume.c:1.26	Wed Aug 27 17:43:16 2003
--- openafs/src/afs/afs_volume.c	Tue Dec  7 01:12:12 2004
***************
*** 19,25 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_volume.c,v 1.26 2003/08/27 21:43:16 rees Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 19,25 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_volume.c,v 1.26.2.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 411,417 ****
  
  
  static struct volume *
! afs_SetupVolume(afs_int32 volid, char *aname, char *ve, struct cell *tcell,
  		afs_int32 agood, afs_int32 type, struct vrequest *areq)
  {
      struct volume *tv;
--- 411,417 ----
  
  
  static struct volume *
! afs_SetupVolume(afs_int32 volid, char *aname, void *ve, struct cell *tcell,
  		afs_int32 agood, afs_int32 type, struct vrequest *areq)
  {
      struct volume *tv;
Index: openafs/src/afs/sysincludes.h
diff -c openafs/src/afs/sysincludes.h:1.28 openafs/src/afs/sysincludes.h:1.28.2.2
*** openafs/src/afs/sysincludes.h:1.28	Thu Jun 24 13:38:23 2004
--- openafs/src/afs/sysincludes.h	Wed Dec  8 05:35:28 2004
***************
*** 72,78 ****
--- 72,80 ----
  /* Avoid conflicts with coda overloading AFS type namespace. Must precede
   * inclusion of uaccess.h.
   */
+ #ifndef _LINUX_CODA_FS_I
  #define _LINUX_CODA_FS_I
+ #endif
  #define _CFS_HEADER_
  struct coda_inode_info {
  };
***************
*** 140,145 ****
--- 142,153 ----
  #include "sys/cmn_err.h"
  #ifdef AFS_SGI64_ENV
  #include <ksys/behavior.h>
+ /* in 6.5.20f, ksys/behavior.h doesn't bother to define BHV_IS_BHVL,
+  * but sys/vnode.h uses it in VNODE_TO_FIRST_BHV. It looks like from
+  * older headers like we want the old behavior, so we fake it. */
+ #if defined(BHV_PREPARE) && !defined(CELL_CAPABLE)
+ #define BHV_IS_BHVL(bhp) (0)
+ #endif
  #endif /* AFS_SGI64_ENV */
  #include "fs/efs_inode.h"
  #ifdef AFS_SGI_EFS_IOPS_ENV
Index: openafs/src/afs/LINUX/osi_alloc.c
diff -c openafs/src/afs/LINUX/osi_alloc.c:1.22 openafs/src/afs/LINUX/osi_alloc.c:1.22.2.1
*** openafs/src/afs/LINUX/osi_alloc.c:1.22	Wed Jul 14 00:14:31 2004
--- openafs/src/afs/LINUX/osi_alloc.c	Tue Dec  7 01:12:12 2004
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v 1.22 2004/07/14 04:14:31 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v 1.22.2.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 96,106 ****
  #endif
  		);
  	    if (new)		/* piggy back alloc type */
! 		(unsigned long)new |= KM_TYPE;
  	} else {
  	    new = (void *)vmalloc(asize);
  	    if (new)		/* piggy back alloc type */
! 		(unsigned long)new |= VM_TYPE;
  	}
  
  	if (!new) {
--- 96,106 ----
  #endif
  		);
  	    if (new)		/* piggy back alloc type */
! 		new = (void *)(KM_TYPE | (unsigned long)new);
  	} else {
  	    new = (void *)vmalloc(asize);
  	    if (new)		/* piggy back alloc type */
! 		new = (void *)(VM_TYPE | (unsigned long)new);
  	}
  
  	if (!new) {
***************
*** 143,150 ****
  	vfree(MEMADDR(p));
  	break;
      default:
! 	printf("afs_osi_Free: Asked to free unknown type %d at 0x%x\n",
! 	       MEMTYPE(p), MEMADDR(p));
  	break;
      }
  
--- 143,150 ----
  	vfree(MEMADDR(p));
  	break;
      default:
! 	printf("afs_osi_Free: Asked to free unknown type %d at 0x%lx\n",
! 	       (int)MEMTYPE(p), (unsigned long)MEMADDR(p));
  	break;
      }
  
***************
*** 196,203 ****
      memtype = MEMTYPE(lmp->chunk);
      if (memtype != KM_TYPE && memtype != VM_TYPE) {
  	printf
! 	    ("osi_linux_verify_alloced_memory: unknown type %d at 0x%x, index=%d\n",
! 	     memtype, lmp->chunk, index);
      }
      afs_linux_hash_verify_count++;
  }
--- 196,203 ----
      memtype = MEMTYPE(lmp->chunk);
      if (memtype != KM_TYPE && memtype != VM_TYPE) {
  	printf
! 	    ("osi_linux_verify_alloced_memory: unknown type %d at 0x%lx, index=%lu\n",
! 	     (int)memtype, (unsigned long)lmp->chunk, (unsigned long)index);
      }
      afs_linux_hash_verify_count++;
  }
Index: openafs/src/afs/LINUX/osi_file.c
diff -c openafs/src/afs/LINUX/osi_file.c:1.19 openafs/src/afs/LINUX/osi_file.c:1.19.2.3
*** openafs/src/afs/LINUX/osi_file.c:1.19	Mon Apr 12 12:04:32 2004
--- openafs/src/afs/LINUX/osi_file.c	Wed Dec  8 12:21:46 2004
***************
*** 11,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.19 2004/04/12 16:04:32 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
  #include "afs/afs_stats.h"	/* afs statistics */
  #include "h/smp_lock.h"
- #include "h/module.h"
  
  
  int afs_osicred_initialized = 0;
--- 11,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.19.2.3 2004/12/08 17:21:46 shadow Exp $");
  
+ #include "h/module.h" /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
  #include "afs/afs_stats.h"	/* afs statistics */
  #include "h/smp_lock.h"
  
  
  int afs_osicred_initialized = 0;
***************
*** 29,39 ****
  void *
  osi_UFSOpen(afs_int32 ainode)
  {
-     struct inode *ip;
      register struct osi_file *afile = NULL;
      extern int cacheDiskType;
      afs_int32 code = 0;
-     int dummy;
      struct inode *tip = NULL;
      struct file *filp = NULL;
      AFS_STATCNT(osi_UFSOpen);
--- 29,37 ----
***************
*** 121,127 ****
  int
  osi_UFSTruncate(register struct osi_file *afile, afs_int32 asize)
  {
-     struct AFS_UCRED *oldCred;
      register afs_int32 code;
      struct osi_stat tstat;
      struct iattr newattrs;
--- 119,124 ----
***************
*** 141,147 ****
      down_write(&inode->i_alloc_sem);
  #endif
      down(&inode->i_sem);
!     inode->i_size = newattrs.ia_size = asize;
      newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
  #if defined(AFS_LINUX24_ENV)
      newattrs.ia_ctime = CURRENT_TIME;
--- 138,144 ----
      down_write(&inode->i_alloc_sem);
  #endif
      down(&inode->i_sem);
!     newattrs.ia_size = asize;
      newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
  #if defined(AFS_LINUX24_ENV)
      newattrs.ia_ctime = CURRENT_TIME;
***************
*** 159,164 ****
--- 156,162 ----
      if (!code)
  	truncate_inode_pages(&inode->i_data, asize);
  #else
+     inode->i_size = asize;
      if (inode->i_sb->s_op && inode->i_sb->s_op->notify_change) {
  	code = inode->i_sb->s_op->notify_change(&afile->dentry, &newattrs);
      }
***************
*** 184,193 ****
  afs_osi_Read(register struct osi_file *afile, int offset, void *aptr,
  	     afs_int32 asize)
  {
-     struct AFS_UCRED *oldCred;
      size_t resid;
      register afs_int32 code;
-     register afs_int32 cnt1 = 0;
      AFS_STATCNT(osi_Read);
  
      /**
--- 182,189 ----
***************
*** 222,228 ****
  afs_osi_Write(register struct osi_file *afile, afs_int32 offset, void *aptr,
  	      afs_int32 asize)
  {
-     struct AFS_UCRED *oldCred;
      size_t resid;
      register afs_int32 code;
      AFS_STATCNT(osi_Write);
--- 218,223 ----
Index: openafs/src/afs/LINUX/osi_machdep.h
diff -c openafs/src/afs/LINUX/osi_machdep.h:1.22 openafs/src/afs/LINUX/osi_machdep.h:1.22.2.1
*** openafs/src/afs/LINUX/osi_machdep.h:1.22	Wed Jul 14 00:08:06 2004
--- openafs/src/afs/LINUX/osi_machdep.h	Tue Dec  7 01:09:23 2004
***************
*** 51,57 ****
--- 51,67 ----
  #define afs_hz HZ
  #include "h/sched.h"
  #define osi_Time() (xtime.tv_sec)
+ #ifdef AFS_LINUX_64BIT_KERNEL
+ #define osi_GetTime(V)                                 \
+     do {                                               \
+        struct timeval tv;                              \
+        do_gettimeofday(&tv);                           \
+        (V)->tv_sec = (afs_int32)tv.tv_sec;             \
+        (V)->tv_usec = (afs_int32)tv.tv_usec;           \
+     } while (0)
+ #else
  #define osi_GetTime(V) do_gettimeofday((V))
+ #endif
  
  #undef gop_lookupname
  #define gop_lookupname osi_lookupname
Index: openafs/src/afs/LINUX/osi_misc.c
diff -c openafs/src/afs/LINUX/osi_misc.c:1.34 openafs/src/afs/LINUX/osi_misc.c:1.34.2.1
*** openafs/src/afs/LINUX/osi_misc.c:1.34	Sat May 15 02:43:12 2004
--- openafs/src/afs/LINUX/osi_misc.c	Tue Dec  7 01:12:12 2004
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_misc.c,v 1.34 2004/05/15 06:43: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.1 2004/12/07 06:12:12 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 167,173 ****
  osi_file_uio_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
  {
      struct file *filp = &osifile->file;
-     struct inode *ip = FILE_INODE(&osifile->file);
      KERNEL_SPACE_DECL;
      int code = 0;
      struct iovec *iov;
--- 167,172 ----
***************
*** 227,236 ****
   * Setup a uio struct.
   */
  void
! setup_uio(uio_t * uiop, struct iovec *iovecp, char *buf, afs_offs_t pos,
  	  int count, uio_flag_t flag, uio_seg_t seg)
  {
!     iovecp->iov_base = buf;
      iovecp->iov_len = count;
      uiop->uio_iov = iovecp;
      uiop->uio_iovcnt = 1;
--- 226,235 ----
   * Setup a uio struct.
   */
  void
! setup_uio(uio_t * uiop, struct iovec *iovecp, const char *buf, afs_offs_t pos,
  	  int count, uio_flag_t flag, uio_seg_t seg)
  {
!     iovecp->iov_base = (char *)buf;
      iovecp->iov_len = count;
      uiop->uio_iov = iovecp;
      uiop->uio_iovcnt = 1;
***************
*** 248,254 ****
  int
  uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop)
  {
!     int count, n;
      struct iovec *iov;
      int code;
  
--- 247,253 ----
  int
  uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop)
  {
!     int count;
      struct iovec *iov;
      int code;
  
***************
*** 371,378 ****
  #else
  		if (ip->i_nrpages) {
  #endif
! 		    printf("Failed to invalidate all pages on inode 0x%x\n",
! 			   ip);
  		}
  	    }
  	}
--- 370,377 ----
  #else
  		if (ip->i_nrpages) {
  #endif
! 		    printf("Failed to invalidate all pages on inode 0x%lx\n",
! 			   (unsigned long)ip);
  		}
  	    }
  	}
***************
*** 387,397 ****
  
  #if defined(AFS_LINUX24_ENV)
      if (atomic_read(&ip->i_count) > 1)
  #else
      if (ip->i_count > 1)
  #endif
- 	printf("afs_put_inode: ino %d (0x%x) has count %d\n", ip->i_ino, ip,
- 	       ip->i_count);
  
      afs_InactiveVCache(vcp, credp);
      ObtainWriteLock(&vcp->lock, 504);
--- 386,399 ----
  
  #if defined(AFS_LINUX24_ENV)
      if (atomic_read(&ip->i_count) > 1)
+ 	printf("afs_put_inode: ino %ld (0x%lx) has count %ld\n",
+ 	       (long)ip->i_ino, (unsigned long)ip,
+ 	       (long)atomic_read(&ip->i_count));
  #else
      if (ip->i_count > 1)
+ 	printf("afs_put_inode: ino %ld (0x%lx) has count %ld\n",
+ 	       (long)ip->i_ino, (unsigned long)ip, (long)ip->i_count);
  #endif
  
      afs_InactiveVCache(vcp, credp);
      ObtainWriteLock(&vcp->lock, 504);
Index: openafs/src/afs/LINUX/osi_module.c
diff -c openafs/src/afs/LINUX/osi_module.c:1.52.2.2 openafs/src/afs/LINUX/osi_module.c:1.52.2.4
*** openafs/src/afs/LINUX/osi_module.c:1.52.2.2	Mon Oct 18 13:43:51 2004
--- openafs/src/afs/LINUX/osi_module.c	Tue Dec  7 01:12:13 2004
***************
*** 15,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.2 2004/10/18 17:43:51 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "h/unistd.h"		/* For syscall numbers. */
--- 15,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.4 2004/12/07 06:12: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. */
***************
*** 26,32 ****
  #include "../asm/ia32_unistd.h"
  #endif
  
- #include <linux/module.h>
  #include <linux/proc_fs.h>
  #include <linux/slab.h>
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
--- 27,32 ----
***************
*** 68,74 ****
--- 68,76 ----
  
  extern struct file_system_type afs_fs_type;
  
+ #if !defined(AFS_LINUX24_ENV)
  static long get_page_offset(void);
+ #endif
  
  #if defined(AFS_LINUX24_ENV)
  DECLARE_MUTEX(afs_global_lock);
***************
*** 138,149 ****
--- 140,191 ----
      .ioctl = afs_ioctl,
  };
  
+ int
+ csdbproc_read(char *buffer, char **start, off_t offset, int count,
+ 	      int *eof, void *data)
+ {
+     int len, j;
+     struct afs_q *cq, *tq;
+     struct cell *tc;
+     char tbuffer[16];
+     afs_uint32 addr;
+     
+     len = 0;
+     ObtainReadLock(&afs_xcell);
+     for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
+ 	tc = QTOC(cq); tq = QNext(cq);
+ 	len += sprintf(buffer + len, ">%s #(%d/%d)\n", tc->cellName, 
+ 		       tc->cellNum, tc->cellIndex);
+ 	for (j = 0; j < MAXCELLHOSTS; j++) {
+ 	    if (!tc->cellHosts[j]) break;
+ 	    addr = ntohl(tc->cellHosts[j]->addr->sa_ip);
+ 	    sprintf(tbuffer, "%d.%d.%d.%d", 
+ 		    (int)((addr>>24) & 0xff), (int)((addr>>16) & 0xff),
+ 		    (int)((addr>>8)  & 0xff), (int)( addr      & 0xff));
+             len += sprintf(buffer + len, "%s #%s\n", tbuffer, tbuffer);
+ 	}
+     }
+     ReleaseReadLock(&afs_xcell);
+     
+     if (offset >= len) {
+ 	*start = buffer;
+ 	*eof = 1;
+ 	return 0;
+     }
+     *start = buffer + offset;
+     if ((len -= offset) > count)
+ 	return count;
+     *eof = 1;
+     return len;
+ }
+ 
  static struct proc_dir_entry *openafs_procfs;
  
  static int
  afsproc_init()
  {
      struct proc_dir_entry *entry1;
+     struct proc_dir_entry *entry2;
  
      openafs_procfs = proc_mkdir(PROC_FSDIRNAME, proc_root_fs);
      entry1 = create_proc_entry(PROC_SYSCALL_NAME, 0666, openafs_procfs);
***************
*** 152,163 ****
--- 194,208 ----
  
      entry1->owner = THIS_MODULE;
  
+     entry2 = create_proc_read_entry(PROC_CELLSERVDB_NAME, (S_IFREG|S_IRUGO), openafs_procfs, csdbproc_read, NULL);
+ 
      return 0;
  }
  
  static void
  afsproc_exit()
  {
+     remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs);
      remove_proc_entry(PROC_SYSCALL_NAME, openafs_procfs);
      remove_proc_entry(PROC_FSDIRNAME, proc_root_fs);
  }
***************
*** 254,261 ****
      unsigned long *ptr;
      unsigned long offset=0;
      unsigned long datalen=0;
!     int ret;
      unsigned long token=0;
      char *mod_name;
      unsigned long mod_start=0;
      unsigned long mod_end=0;
--- 299,309 ----
      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;
***************
*** 265,270 ****
--- 313,319 ----
      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");
***************
*** 366,372 ****
      if (!sys_call_table) {
  	printf("Failed to find address of sys_call_table\n");
      } else {
! 	printf("Found sys_call_table at %x\n", sys_call_table);
  #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_S390X_LINUX24_ENV)
  	error cant support this yet.;
  #endif /* AFS_SPARC64_LINUX20_ENV */
--- 415,421 ----
      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 */
***************
*** 428,437 ****
  	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 %x\n", ia32_sys_call_table);
  	}
  #else
! 	printf("Found ia32_sys_call_table at %x\n", ia32_sys_call_table);
  #endif /* IA32_SYS_CALL_TABLE */
  #endif
  
--- 477,486 ----
  	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
  
***************
*** 536,543 ****
  cleanup_module(void)
  #endif
  {
-     struct task_struct *t;
- 
      osi_sysctl_clean();
      if (sys_call_table) {
  #if defined(AFS_IA64_LINUX20_ENV)
--- 585,590 ----
Index: openafs/src/afs/LINUX/osi_prototypes.h
diff -c openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.1 openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.2
*** openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.1	Mon Oct 18 03:11:46 2004
--- openafs/src/afs/LINUX/osi_prototypes.h	Tue Dec  7 01:12:13 2004
***************
*** 41,46 ****
--- 41,50 ----
  extern void osi_linux_free_inode_pages(void);
  extern void check_bad_parent(struct dentry *dp);
  
+ /* osi_sysctl.c */
+ extern int osi_sysctl_init();
+ extern void osi_sysctl_clean();
+ 
  /* osi_vm.c */
  extern int osi_VM_FlushVCache(struct vcache *avc, int *slept);
  extern void osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred,
***************
*** 53,58 ****
--- 57,67 ----
  
  /* osi_vfsops.c */
  extern void set_inode_cache(struct inode *ip, struct vattr *vp);
+ extern void put_inode_on_dummy_list(struct inode *ip);
+ extern void vattr2inode(struct inode *ip, struct vattr *vp);
  
+ /* osi_vnodeops.c */
+ extern int afs_linux_writepage_sync(struct inode *ip, struct page *pp,
+ 				    unsigned long offset, unsigned int count);
  
  #endif /* _OSI_PROTO_H_ */
Index: openafs/src/afs/LINUX/osi_sleep.c
diff -c openafs/src/afs/LINUX/osi_sleep.c:1.22 openafs/src/afs/LINUX/osi_sleep.c:1.22.2.1
*** openafs/src/afs/LINUX/osi_sleep.c:1.22	Mon Jun 21 15:30:21 2004
--- openafs/src/afs/LINUX/osi_sleep.c	Tue Dec  7 01:12:13 2004
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_sleep.c,v 1.22 2004/06/21 19:30:21 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/LINUX/osi_sleep.c,v 1.22.2.1 2004/12/07 06:12:13 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 50,56 ****
  afs_osi_Wait(afs_int32 ams, struct afs_osi_WaitHandle *ahandle, int aintok)
  {
      afs_int32 endTime;
-     struct timer_list *timer = NULL;
      int code;
  
      AFS_STATCNT(osi_Wait);
--- 50,55 ----
Index: openafs/src/afs/LINUX/osi_vfs.hin
diff -c openafs/src/afs/LINUX/osi_vfs.hin:1.6 openafs/src/afs/LINUX/osi_vfs.hin:1.6.2.1
*** openafs/src/afs/LINUX/osi_vfs.hin:1.6	Tue Apr 20 22:20:23 2004
--- openafs/src/afs/LINUX/osi_vfs.hin	Tue Dec  7 01:12:13 2004
***************
*** 98,116 ****
  #define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
  
  
- /* va_masks - these should match their respective ATTR_xxx #defines in fs.h.
-  * afs_notify_change has to use the attr bits in both the Linux and AFS
-  * meanings. The glue layer code uses the ATTR_xxx style names.
-  */
- #define AT_SIZE		ATTR_SIZE
- #define AT_MODE		ATTR_MODE
- #undef AT_UID
- #define AT_UID		ATTR_UID
- #undef AT_GID
- #define AT_GID		ATTR_GID
- #define AT_MTIME	ATTR_MTIME
- 
- 
  #define vnodeops inode_operations
  
  #endif /* OSI_VFS_H_ */
--- 98,103 ----
Index: openafs/src/afs/LINUX/osi_vfsops.c
diff -c openafs/src/afs/LINUX/osi_vfsops.c:1.29 openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.1
*** openafs/src/afs/LINUX/osi_vfsops.c:1.29	Wed Jul 28 23:08:48 2004
--- openafs/src/afs/LINUX/osi_vfsops.c	Tue Dec  7 01:12:13 2004
***************
*** 16,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29 2004/07/29 03:08:48 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "afs/afs_stats.h"
--- 16,25 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.1 2004/12/07 06:12:13 shadow Exp $");
  
+ #define __NO_VERSION__		/* don't define kernel_version in module.h */
+ #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "afs/afs_stats.h"
***************
*** 28,36 ****
  #include "h/smp_lock.h"
  #endif
  
- #define __NO_VERSION__		/* don't define kernel_version in module.h */
- #include <linux/module.h>
- 
  
  struct vcache *afs_globalVp = 0;
  struct vfs *afs_globalVFS = 0;
--- 30,35 ----
***************
*** 52,58 ****
  struct super_block *afs_read_super(struct super_block *sb, void *data, int silent);
  int afs_fill_super(struct super_block *sb, void *data, int silent);
  static struct super_block *afs_get_sb(struct file_system_type *fs_type, int flags, const char *dev_name, void *data);
- void put_inode_on_dummy_list(struct inode *ip);
  
  /* afs_file_system
   * VFS entry for Linux - installed in init_module
--- 51,56 ----
***************
*** 267,273 ****
--- 265,275 ----
   * has synced some pages of a file to disk.
   */
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
+ #ifdef WRITE_INODE_NOT_VOID
+ static int
+ #else
  static void
+ #endif
  afs_write_inode(struct inode *ip, int unused)
  #else
  static void
***************
*** 280,285 ****
--- 282,290 ----
  
      /* for now we don't actually update the metadata during msync. This
       * is just to keep linux happy.  */
+ #ifdef WRITE_INODE_NOT_VOID
+     return 0;
+ #endif
  }
  
  
***************
*** 300,307 ****
  static void
  afs_delete_inode(struct inode *ip)
  {
-     struct vcache *vp = ITOAFS(ip);
- 
  #ifdef AFS_LINUX26_ENV
      put_inode_on_dummy_list(ip);
  #endif
--- 305,310 ----
***************
*** 317,325 ****
  static void
  afs_put_super(struct super_block *sbp)
  {
-     extern int afs_afs_cold_shutdown;
      int code = 0;
-     int fv_slept;
  
      AFS_GLOCK();
      AFS_STATCNT(afs_unmount);
--- 320,326 ----
***************
*** 339,345 ****
  #endif
  
      osi_linux_verify_alloced_memory();
-   done:
      AFS_GUNLOCK();
  
      if (!code) {
--- 340,345 ----
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.4 openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.5
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.4	Tue Nov  9 12:15:02 2004
--- openafs/src/afs/LINUX/osi_vnodeops.c	Tue Dec  7 01:12:13 2004
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.4 2004/11/09 17:15:02 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.5 2004/12/07 06:12:13 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 36,41 ****
--- 36,44 ----
  #if defined(AFS_LINUX24_ENV)
  #include "h/smp_lock.h"
  #endif
+ #if defined(AFS_LINUX26_ENV)
+ #include "h/writeback.h"
+ #endif
  
  #ifdef pgoff2loff
  #define pageoff(pp) pgoff2loff((pp)->index)
***************
*** 84,90 ****
  	if (*offp + count > afs_vmMappingEnd) {
  	    uio_t tuio;
  	    struct iovec iov;
- 	    afs_size_t oldOffset = *offp;
  	    afs_int32 xfered = 0;
  
  	    if (*offp < afs_vmMappingEnd) {
--- 87,92 ----
***************
*** 145,151 ****
  afs_linux_write(struct file *fp, const char *buf, size_t count, loff_t * offp)
  {
      ssize_t code = 0;
!     int code2;
      struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode);
      struct vrequest treq;
      cred_t *credp = crref();
--- 147,153 ----
  afs_linux_write(struct file *fp, const char *buf, size_t count, loff_t * offp)
  {
      ssize_t code = 0;
!     int code2 = 0;
      struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode);
      struct vrequest treq;
      cred_t *credp = crref();
***************
*** 252,257 ****
--- 254,261 ----
      return code;
  }
  
+ extern int BlobScan(struct dcache * afile, afs_int32 ablob);
+ 
  /* This is a complete rewrite of afs_readdir, since we can make use of
   * filldir instead of afs_readdir_move. Note that changes to vcache/dcache
   * handling and use of bulkstats will need to be reflected here as well.
***************
*** 346,353 ****
  	if (de->name)
  	    len = strlen(de->name);
  	else {
! 	    printf("afs_linux_readdir: afs_dir_GetBlob failed, null name (inode %x, dirpos %d)\n", 
! 		   &tdc->f.inode, dirpos);
  	    DRelease((struct buffer *) de, 0);
  	    afs_PutDCache(tdc);
  	    ReleaseReadLock(&avc->lock);
--- 350,357 ----
  	if (de->name)
  	    len = strlen(de->name);
  	else {
! 	    printf("afs_linux_readdir: afs_dir_GetBlob failed, null name (inode %lx, dirpos %d)\n", 
! 		   (unsigned long)&tdc->f.inode, dirpos);
  	    DRelease((struct buffer *) de, 0);
  	    afs_PutDCache(tdc);
  	    ReleaseReadLock(&avc->lock);
***************
*** 486,492 ****
  	    ReleaseWriteLock(&vcp->lock);
      }
  
-   unlock_exit:
      AFS_GUNLOCK();
  }
  
--- 490,495 ----
***************
*** 837,850 ****
   * later on, we shouldn't have to do it until later. Perhaps in the future..
   */
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
  static int
  afs_linux_dentry_revalidate(struct dentry *dp, int flags)
  #else
  static int
  afs_linux_dentry_revalidate(struct dentry *dp)
  #endif
  {
!     char *name;
      cred_t *credp = crref();
      struct vrequest treq;
      struct vcache *lookupvcp = NULL;
--- 840,858 ----
   * later on, we shouldn't have to do it until later. Perhaps in the future..
   */
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
+ #ifdef DOP_REVALIDATE_TAKES_NAMEIDATA
+ static int
+ afs_linux_dentry_revalidate(struct dentry *dp, struct nameidata *nd)
+ #else
  static int
  afs_linux_dentry_revalidate(struct dentry *dp, int flags)
+ #endif
  #else
  static int
  afs_linux_dentry_revalidate(struct dentry *dp)
  #endif
  {
!     char *name = NULL;
      cred_t *credp = crref();
      struct vrequest treq;
      struct vcache *lookupvcp = NULL;
***************
*** 985,997 ****
   *
   * name is in kernel space at this point.
   */
  int
  afs_linux_create(struct inode *dip, struct dentry *dp, int mode)
  {
      int code;
      cred_t *credp = crref();
      struct vattr vattr;
-     enum vcexcl excl;
      const char *name = dp->d_name.name;
      struct inode *ip;
  
--- 993,1010 ----
   *
   * name is in kernel space at this point.
   */
+ #ifdef IOP_CREATE_TAKES_NAMEIDATA
+ int
+ afs_linux_create(struct inode *dip, struct dentry *dp, int mode,
+ 		 struct nameidata *nd)
+ #else
  int
  afs_linux_create(struct inode *dip, struct dentry *dp, int mode)
+ #endif
  {
      int code;
      cred_t *credp = crref();
      struct vattr vattr;
      const char *name = dp->d_name.name;
      struct inode *ip;
  
***************
*** 1003,1009 ****
  #endif
      AFS_GLOCK();
      code =
! 	afs_create(ITOAFS(dip), name, &vattr, NONEXCL, mode,
  		   (struct vcache **)&ip, credp);
  
      if (!code) {
--- 1016,1022 ----
  #endif
      AFS_GLOCK();
      code =
! 	afs_create(ITOAFS(dip), (char *)name, &vattr, NONEXCL, mode,
  		   (struct vcache **)&ip, credp);
  
      if (!code) {
***************
*** 1045,1052 ****
--- 1058,1071 ----
  
  /* afs_linux_lookup */
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
+ #ifdef IOP_LOOKUP_TAKES_NAMEIDATA
+ struct dentry *
+ afs_linux_lookup(struct inode *dip, struct dentry *dp,
+ 		 struct nameidata *nd)
+ #else
  struct dentry *
  afs_linux_lookup(struct inode *dip, struct dentry *dp)
+ #endif
  #else
  int
  afs_linux_lookup(struct inode *dip, struct dentry *dp)
***************
*** 1471,1478 ****
--- 1490,1502 ----
  }
  
  #if defined(AFS_LINUX24_ENV)
+ #ifdef AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL
+ int
+ afs_linux_writepage(struct page *pp, struct writeback_control *wbc)
+ #else
  int
  afs_linux_writepage(struct page *pp)
+ #endif
  {
      struct address_space *mapping = pp->mapping;
      struct inode *inode;
***************
*** 1480,1486 ****
      unsigned offset = PAGE_CACHE_SIZE;
      long status;
  
! #ifdef PageLaunder
      if (PageLaunder(pp)) {
  	return(fail_writepage(pp));
      }
--- 1504,1514 ----
      unsigned offset = PAGE_CACHE_SIZE;
      long status;
  
! #if defined(AFS_LINUX26_ENV)
!     if (PageReclaim(pp)) {
! 	return WRITEPAGE_ACTIVATE;
!     }
! #else
      if (PageLaunder(pp)) {
  	return(fail_writepage(pp));
      }
***************
*** 1513,1520 ****
--- 1541,1553 ----
  /* afs_linux_permission
   * Check access rights - returns error if can't check or permission denied.
   */
+ #ifdef IOP_PERMISSION_TAKES_NAMEIDATA
+ int
+ afs_linux_permission(struct inode *ip, int mode, struct nameidata *nd)
+ #else
  int
  afs_linux_permission(struct inode *ip, int mode)
+ #endif
  {
      int code;
      cred_t *credp = crref();
Index: openafs/src/afs/OBSD/osi_vfsops.c
diff -c openafs/src/afs/OBSD/osi_vfsops.c:1.18 openafs/src/afs/OBSD/osi_vfsops.c:1.18.2.1
*** openafs/src/afs/OBSD/osi_vfsops.c:1.18	Thu Mar 25 12:04:44 2004
--- openafs/src/afs/OBSD/osi_vfsops.c	Tue Dec  7 01:19:16 2004
***************
*** 3,9 ****
   * Original NetBSD version for Transarc afs by John Kohl <jtk@MIT.EDU>
   * OpenBSD version by Jim Rees <rees@umich.edu>
   *
!  * $Id: osi_vfsops.c,v 1.18 2004/03/25 17:04:44 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_vfsops.c,v 1.18.2.1 2004/12/07 06:19:16 shadow Exp $
   */
  
  /*
***************
*** 94,100 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/OBSD/osi_vfsops.c,v 1.18 2004/03/25 17:04:44 rees Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afs/afsincludes.h"	/* Afs-based standard headers */
--- 94,100 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/OBSD/osi_vfsops.c,v 1.18.2.1 2004/12/07 06:19:16 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afs/afsincludes.h"	/* Afs-based standard headers */
***************
*** 116,122 ****
  static int afs_badcall(struct proc *p, void *xx, register_t * yy);
  static struct sysent old_sysent;
  
- char afs_NetBSD_osname[] = "OpenBSD";
  struct osi_vfs *afs_globalVFS;
  struct vcache *afs_globalVp;
  
--- 116,121 ----
***************
*** 463,469 ****
      if (memname[M_AFSBUFFER] == NULL)
  	memname[M_AFSBUFFER] = afsbfrmem;
      lkmid = lkmtp->id;
!     printf("OpenAFS ($Revision: 1.18 $) lkm loaded\n");
      return 0;
  }
  
--- 462,468 ----
      if (memname[M_AFSBUFFER] == NULL)
  	memname[M_AFSBUFFER] = afsbfrmem;
      lkmid = lkmtp->id;
!     printf("OpenAFS ($Revision: 1.18.2.1 $) lkm loaded\n");
      return 0;
  }
  
***************
*** 495,505 ****
  libafs_lkmentry(struct lkm_table *lkmtp, int cmd, int ver)
  {
      if (cmd == LKM_E_LOAD) {
- 	if (strcmp(ostype, afs_NetBSD_osname)) {
- 	    printf("This is %s version %s\n", ostype, osrelease);
- 	    printf("This version of AFS is only for %s\n", afs_NetBSD_osname);
- 	    return EPROGMISMATCH;
- 	}
  	if (sysent[AFS_SYSCALL].sy_call == afs3_syscall
  	    || sysent[AFS_SYSCALL].sy_call == afs_badcall) {
  	    printf("AFS already loaded\n");
--- 494,499 ----
Index: openafs/src/afs/VNOPS/afs_vnop_attrs.c
diff -c openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.2 openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.3
*** openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.2	Tue Nov  9 12:17:25 2004
--- openafs/src/afs/VNOPS/afs_vnop_attrs.c	Tue Dec  7 01:12:13 2004
***************
*** 24,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.2 2004/11/09 17:17:25 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 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 */
***************
*** 399,410 ****
  /* Boy, was this machine dependent bogosity hard to swallow????.... */
      if (av->va_mode != -1) {
  #else
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
      if (av->va_mask & AT_MODE) {
  #else
      if (av->va_mode != ((unsigned short)-1)) {
  #endif
  #endif
  	mask |= AFS_SETMODE;
  	as->UnixModeBits = av->va_mode & 0xffff;
  	if (avc->states & CForeign) {
--- 399,414 ----
  /* 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) {
***************
*** 413,419 ****
  	    ReleaseWriteLock(&avc->lock);
  	}
      }
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
      if (av->va_mask & AT_GID) {
  #else
  #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
--- 417,426 ----
  	    ReleaseWriteLock(&avc->lock);
  	}
      }
! #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))
***************
*** 426,435 ****
      if (av->va_gid != -1) {
  #endif
  #endif /* AFS_SUN5_ENV */
  	mask |= AFS_SETGROUP;
  	as->Group = av->va_gid;
      }
! #if defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
      if (av->va_mask & AT_UID) {
  #else
  #if (defined(AFS_HPUX_ENV) || defined(AFS_SUN_ENV))
--- 433,446 ----
      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))
***************
*** 442,455 ****
      if (av->va_uid != -1) {
  #endif
  #endif /* AFS_SUN5_ENV */
  	mask |= AFS_SETOWNER;
  	as->Owner = av->va_uid;
      }
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
      if (av->va_mask & AT_MTIME) {
  #else
      if (av->va_mtime.tv_sec != -1) {
  #endif
  	mask |= AFS_SETMODTIME;
  #ifndef	AFS_SGI_ENV
  #if	defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
--- 453,471 ----
      if (av->va_uid != -1) {
  #endif
  #endif /* AFS_SUN5_ENV */
+ #endif /* AFS_LINUX22_ENV */
  	mask |= AFS_SETOWNER;
  	as->Owner = av->va_uid;
      }
! #if	defined(AFS_LINUX22_ENV)
!     if (av->va_mask & ATTR_MTIME) {
! #else
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
      if (av->va_mask & AT_MTIME) {
  #else
      if (av->va_mtime.tv_sec != -1) {
  #endif
+ #endif
  	mask |= AFS_SETMODTIME;
  #ifndef	AFS_SGI_ENV
  #if	defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
***************
*** 526,532 ****
       * path (unlike BSD or SUNOS), so we skip this check for Ultrix.
       *
       */
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & AT_SIZE) {
  #else
  #ifdef	AFS_OSF_ENV
--- 542,551 ----
       * path (unlike BSD or SUNOS), so we skip this check for Ultrix.
       *
       */
! #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
***************
*** 539,544 ****
--- 558,564 ----
  #endif
  #endif
  #endif
+ #endif
  	if (!afs_AccessOK(avc, PRSFS_WRITE, &treq, DONT_CHECK_MODE_BITS)) {
  	    code = EACCES;
  	    goto done;
***************
*** 560,566 ****
  #if defined(AFS_SGI_ENV)
      AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE);
  #endif
! #if	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV) || defined(AFS_LINUX22_ENV)
      if (attrs->va_mask & AT_SIZE) {
  #else
  #if	defined(AFS_OSF_ENV)
--- 580,589 ----
  #if defined(AFS_SGI_ENV)
      AFS_RWLOCK((vnode_t *) avc, VRWLOCK_WRITE);
  #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)
***************
*** 569,574 ****
--- 592,598 ----
      if (attrs->va_size != -1) {
  #endif
  #endif
+ #endif
  	afs_size_t tsize = attrs->va_size;
  	ObtainWriteLock(&avc->lock, 128);
  	avc->states |= CDirty;
Index: openafs/src/afs/VNOPS/afs_vnop_flock.c
diff -c openafs/src/afs/VNOPS/afs_vnop_flock.c:1.24.2.1 openafs/src/afs/VNOPS/afs_vnop_flock.c:1.24.2.2
*** openafs/src/afs/VNOPS/afs_vnop_flock.c:1.24.2.1	Wed Aug 25 03:09:35 2004
--- openafs/src/afs/VNOPS/afs_vnop_flock.c	Tue Dec  7 01:12:13 2004
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_flock.c,v 1.24.2.1 2004/08/25 07:09:35 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_flock.c,v 1.24.2.2 2004/12/07 06:12:13 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 469,483 ****
  
  
  #ifdef	AFS_OSF_ENV
! afs_lockctl(struct vcache * avc, struct eflock * af, int flag,
! 	    struct AFS_UCRED * acred, pid_t clid, off_t offset)
  #elif defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
! afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
! 	    struct AFS_UCRED * acred, pid_t clid)
  #else
  u_int clid = 0;
! afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
! 	    struct AFS_UCRED * acred)
  #endif
  {
      struct vrequest treq;
--- 469,483 ----
  
  
  #ifdef	AFS_OSF_ENV
! int afs_lockctl(struct vcache * avc, struct eflock * af, int flag,
! 		struct AFS_UCRED * acred, pid_t clid, off_t offset)
  #elif defined(AFS_SGI_ENV) || (defined(AFS_SUN_ENV) && !defined(AFS_SUN5_ENV)) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
! int afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
! 		struct AFS_UCRED * acred, pid_t clid)
  #else
  u_int clid = 0;
! int afs_lockctl(struct vcache * avc, struct AFS_FLOCK * af, int acmd,
! 		struct AFS_UCRED * acred)
  #endif
  {
      struct vrequest treq;
Index: openafs/src/afs/VNOPS/afs_vnop_lookup.c
diff -c openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.4 openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.5
*** openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.4	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	Tue Dec  7 01:12:13 2004
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.4 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 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 */
***************
*** 67,73 ****
      char *cpos, *volnamep;
      char type, *buf;
      afs_int32 prefetch;		/* 1=>None  2=>RO  3=>BK */
!     afs_int32 mtptCell, assocCell, hac = 0;
      afs_int32 samecell, roname, len;
  
      AFS_STATCNT(EvalMountPoint);
--- 67,73 ----
      char *cpos, *volnamep;
      char type, *buf;
      afs_int32 prefetch;		/* 1=>None  2=>RO  3=>BK */
!     afs_int32 mtptCell, assocCell = 0, hac = 0;
      afs_int32 samecell, roname, len;
  
      AFS_STATCNT(EvalMountPoint);
***************
*** 432,438 ****
  }
  
  void
! Check_AtSys(register struct vcache *avc, char *aname,
  	    struct sysname_info *state, struct vrequest *areq)
  {
      int num = 0;
--- 432,438 ----
  }
  
  void
! Check_AtSys(register struct vcache *avc, const char *aname,
  	    struct sysname_info *state, struct vrequest *areq)
  {
      int num = 0;
***************
*** 448,454 ****
  	state->offset = -1;
  	state->allocked = 0;
  	state->index = 0;
! 	state->name = aname;
      }
  }
  
--- 448,454 ----
  	state->offset = -1;
  	state->allocked = 0;
  	state->index = 0;
! 	state->name = (char *)aname;
      }
  }
  
***************
*** 500,509 ****
  	    }
  	    afs_PutUser(au, 0);
  	}
! 	if (++(state->index) >= num || !(*sysnamelist)[state->index])
  	    return 0;		/* end of list */
      }
!     strcpy(state->name + state->offset, (*sysnamelist)[state->index]);
      return 1;
  }
  
--- 500,509 ----
  	    }
  	    afs_PutUser(au, 0);
  	}
! 	if (++(state->index) >= num || !(*sysnamelist)[(unsigned int)state->index])
  	    return 0;		/* end of list */
      }
!     strcpy(state->name + state->offset, (*sysnamelist)[(unsigned int)state->index]);
      return 1;
  }
  
***************
*** 546,559 ****
      struct afs_q *tq;		/* temp queue variable */
      AFSCBFids fidParm;		/* file ID parm for bulk stat */
      AFSBulkStats statParm;	/* stat info parm for bulk stat */
!     int fidIndex;		/* which file were stating */
!     struct conn *tcp;		/* conn for call */
      AFSCBs cbParm;		/* callback parm for bulk stat */
      struct server *hostp = 0;	/* host we got callback from */
      long startTime;		/* time we started the call,
  				 * for callback expiration base
  				 */
!     afs_size_t statSeqNo;	/* Valued of file size to detect races */
      int code;			/* error code */
      long newIndex;		/* new index in the dir */
      struct DirEntry *dirEntryp;	/* dir entry we are examining */
--- 546,559 ----
      struct afs_q *tq;		/* temp queue variable */
      AFSCBFids fidParm;		/* file ID parm for bulk stat */
      AFSBulkStats statParm;	/* stat info parm for bulk stat */
!     int fidIndex = 0;		/* which file were stating */
!     struct conn *tcp = 0;	/* conn for call */
      AFSCBs cbParm;		/* callback parm for bulk stat */
      struct server *hostp = 0;	/* host we got callback from */
      long startTime;		/* time we started the call,
  				 * for callback expiration base
  				 */
!     afs_size_t statSeqNo = 0;	/* Valued of file size to detect races */
      int code;			/* error code */
      long newIndex;		/* new index in the dir */
      struct DirEntry *dirEntryp;	/* dir entry we are examining */
***************
*** 564,570 ****
      long volStates;		/* flags from vol structure */
      struct volume *volp = 0;	/* volume ptr */
      struct VenusFid dotdot;
!     int flagIndex;		/* First file with bulk fetch flag set */
      int inlinebulk = 0;		/* Did we use InlineBulk RPC or not? */
      XSTATS_DECLS;
      /* first compute some basic parameters.  We dont want to prefetch more
--- 564,570 ----
      long volStates;		/* flags from vol structure */
      struct volume *volp = 0;	/* volume ptr */
      struct VenusFid dotdot;
!     int flagIndex = 0;		/* First file with bulk fetch flag set */
      int inlinebulk = 0;		/* Did we use InlineBulk RPC or not? */
      XSTATS_DECLS;
      /* first compute some basic parameters.  We dont want to prefetch more
***************
*** 606,617 ****
    tagain:
      code = afs_VerifyVCache(adp, areqp);
      if (code)
! 	goto done;
  
      dcp = afs_GetDCache(adp, (afs_size_t) 0, areqp, &temp, &temp, 1);
      if (!dcp) {
  	code = ENOENT;
! 	goto done;
      }
  
      /* lock the directory cache entry */
--- 606,617 ----
    tagain:
      code = afs_VerifyVCache(adp, areqp);
      if (code)
! 	goto done2;
  
      dcp = afs_GetDCache(adp, (afs_size_t) 0, areqp, &temp, &temp, 1);
      if (!dcp) {
  	code = ENOENT;
! 	goto done2;
      }
  
      /* lock the directory cache entry */
***************
*** 1067,1072 ****
--- 1067,1073 ----
      } else {
  	code = 0;
      }
+   done2:
      osi_FreeLargeSpace(statMemp);
      osi_FreeLargeSpace(cbfMemp);
      return code;
Index: openafs/src/afs/VNOPS/afs_vnop_remove.c
diff -c openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.3 openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.4
*** openafs/src/afs/VNOPS/afs_vnop_remove.c:1.31.2.3	Tue Nov  9 12:15:04 2004
--- openafs/src/afs/VNOPS/afs_vnop_remove.c	Tue Dec  7 01:12:14 2004
***************
*** 23,29 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.3 2004/11/09 17:15:04 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 23,29 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.31.2.4 2004/12/07 06:12:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 459,465 ****
--- 459,467 ----
      struct VenusFid dirFid;
      register struct dcache *tdc;
      afs_int32 code = 0;
+ #ifdef AFS_DARWIN14_ENV
      int oldref;
+ #endif
  
      if (NBObtainWriteLock(&avc->lock, 423))
  	return 0;
Index: openafs/src/afs/VNOPS/afs_vnop_write.c
diff -c openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.1 openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.2
*** openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.1	Wed Aug 25 03:09:35 2004
--- openafs/src/afs/VNOPS/afs_vnop_write.c	Tue Dec  7 01:12:14 2004
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v 1.36.2.1 2004/08/25 07:09:35 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 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 */
***************
*** 181,187 ****
       * high-level write op.
       */
      if (avc->execsOrWriters <= 0) {
! 	printf("WARNING: afs_ufswr vp=%x, exOrW=%d\n", avc,
  	       avc->execsOrWriters);
      }
  #else
--- 181,187 ----
       * high-level write op.
       */
      if (avc->execsOrWriters <= 0) {
! 	printf("WARNING: afs_ufswr vp=%lx, exOrW=%d\n", (unsigned long)avc,
  	       avc->execsOrWriters);
      }
  #else
***************
*** 432,438 ****
       * high-level write op.
       */
      if (avc->execsOrWriters <= 0) {
! 	printf("WARNING: afs_ufswr vcp=%x, exOrW=%d\n", avc,
  	       avc->execsOrWriters);
      }
  #else
--- 432,438 ----
       * high-level write op.
       */
      if (avc->execsOrWriters <= 0) {
! 	printf("WARNING: afs_ufswr vcp=%lx, exOrW=%d\n", (unsigned long)avc,
  	       avc->execsOrWriters);
      }
  #else
Index: openafs/src/afsd/afsd.c
diff -c openafs/src/afsd/afsd.c:1.43 openafs/src/afsd/afsd.c:1.43.2.1
*** openafs/src/afsd/afsd.c:1.43	Wed Jul 28 18:47:58 2004
--- openafs/src/afsd/afsd.c	Tue Dec  7 13:25:08 2004
***************
*** 56,62 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43 2004/07/28 22:47:58 shadow Exp $");
  
  #define VFS 1
  
--- 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
  
***************
*** 1384,1390 ****
  	/* -chunksize */
  	chunkSize = atoi(as->parms[12].items->data);
  	if (chunkSize < 0 || chunkSize > 30) {
! 	    printf("afsd:invalid chunk size spec'd, using default\n");
  	    chunkSize = 0;
  	}
      }
--- 1384,1390 ----
  	/* -chunksize */
  	chunkSize = atoi(as->parms[12].items->data);
  	if (chunkSize < 0 || chunkSize > 30) {
! 	    printf("afsd:invalid chunk size (not in range 0-30), using default\n");
  	    chunkSize = 0;
  	}
      }
Index: openafs/src/aklog/aklog.c
diff -c /dev/null openafs/src/aklog/aklog.c:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/aklog.c	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,114 ----
+ /* 
+  * $Id: aklog.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $
+  *
+  * Copyright 1990,1991 by the Massachusetts Institute of Technology
+  * For distribution and copying rights, see the file "mit-copyright.h"
+  */
+ 
+ #if !defined(lint) && !defined(SABER)
+ static char *rcsid = "$Id: aklog.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint || SABER */
+ 
+ #include "aklog.h"
+ 
+ #ifndef WINDOWS
+ 
+ #ifdef __STDC__
+ main(int argc, char *argv[])
+ #else
+ main(argc, argv)
+   int argc;
+   char *argv[];
+ #endif /* __STDC__ */
+ {
+     aklog_params params;
+ 
+     aklog_init_params(&params);
+     aklog(argc, argv, &params);
+ }
+ 
+ #else /* WINDOWS */
+ 
+ #include <windows.h>
+ #include <windowsx.h>
+ 
+ static void parse_cmdline();
+ 
+ 
+ int PASCAL
+ WinMain(HINSTANCE hinst, HINSTANCE hprevinstance, LPSTR cmdline, int noshow)
+ {
+ 	int argc = 0;
+ 	char **argv;
+ 
+     aklog_params params;
+ 
+ 	parse_cmdline(cmdline, &argv, &argc);
+ 
+     aklog_init_params(&params);
+     aklog(argc, argv, &params);
+ 
+ 	return 0;
+ }
+ 
+ /*
+  * Generate agrv/argc here from command line.
+  * Note that windows doesn't pass us the executible name, so
+  * we need to fill that in manually.
+  */
+ 
+ static void
+ parse_cmdline(char *cmdline, char ***pargv, int *pargc)
+ {
+ 	char **argv;
+ 	int argc = 0;
+ 	char *arg, *sep = " \t";
+ 	int argv_size = 10;		/* to start with */
+ 
+ 
+ 	argv = malloc(argv_size * sizeof(char *));
+ 
+ 	if (!argv) {
+ 		MessageBox(NULL, "Fatal Error: Out of memory", AKLOG_DIALOG_NAME, 
+ 				   MB_OK | MB_ICONSTOP);
+ 		exit(1);
+ 	}
+ 
+ 	argv[argc++] = "aklog";
+ 
+ 	arg = strtok(cmdline, sep);
+ 
+ 	while(arg) {
+ 		argv[argc] = strdup(arg);
+ 
+ 		if (!argv[argc]) {
+ 			MessageBox(NULL, "Fatal Error: Out of memory", AKLOG_DIALOG_NAME, 
+ 					   MB_OK | MB_ICONSTOP);
+ 			exit(1);
+ 		}
+ 
+ 		argc++;
+ 
+ 		if (argc == argv_size) {
+ 			argv_size += 10;
+ 			argv = realloc(argv, argv_size * sizeof(char *));
+ 
+ 			if (!argv) {
+ 				MessageBox(NULL, "Fatal Error: Out of memory",
+ 						   AKLOG_DIALOG_NAME, 
+ 						   MB_OK | MB_ICONSTOP);
+ 				exit(1);
+ 			}
+ 		}
+ 
+ 		arg = strtok(NULL, sep);
+ 	}
+ 
+ 	argv[argc] = NULL;
+ 
+ 	*pargv = argv;
+ 	*pargc = argc;
+ }
+ 
+ #endif /* WINDOWS */
+ 
Index: openafs/src/aklog/aklog.h
diff -c /dev/null openafs/src/aklog/aklog.h:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/aklog.h	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,71 ----
+ /* 
+  * $Id: aklog.h,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $
+  *
+  * Copyright 1990,1991 by the Massachusetts Institute of Technology
+  * For distribution and copying rights, see the file "mit-copyright.h"
+  */
+ 
+ #ifndef __AKLOG_H__
+ #define __AKLOG_H__
+ 
+ #if !defined(lint) && !defined(SABER)
+ static char *rcsid_aklog_h = "$Id: aklog.h,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint || SABER */
+ 
+ #include <krb5.h>
+ #include <kerberosIV/krb.h>
+ #include "linked_list.h"
+ 
+ #ifdef __STDC__
+ #define ARGS(x) x
+ #else
+ #define ARGS(x) ()
+ #endif /* __STDC__ */
+ 
+ typedef struct {
+     int (*readlink)ARGS((char *, char *, size_t));
+     int (*isdir)ARGS((char *, unsigned char *));
+     char *(*getwd)ARGS((char *));
+     int (*get_cred)ARGS((krb5_context, char *, char *, char *, CREDENTIALS *,
+ 		krb5_creds **));
+     int (*get_user_realm)ARGS((krb5_context, char *));
+     void (*pstderr)ARGS((char *));
+     void (*pstdout)ARGS((char *));
+     void (*exitprog)ARGS((char));
+ } aklog_params;
+ 
+ void aklog ARGS((int, char *[], aklog_params *));
+ void aklog_init_params ARGS((aklog_params *));
+ 
+ #ifdef WINDOWS
+ /*
+  * Complete server info for one cell.
+  *
+  * Normally this is defined in afs/cellconfig.h, but the Windows header
+  * files and API don't use this structure. So, I'll include it here so
+  * I don't have to rewrite large chunks of code.
+  */
+ #define MAXCELLCHARS    64
+ #define MAXHOSTCHARS    64
+ #define MAXHOSTSPERCELL  8
+ 
+ struct afsconf_cell {
+     char name[MAXCELLCHARS];        /* Cell name */
+     short numServers;               /* Num active servers for the cell*/
+     short flags;                    /* useful flags */
+     struct sockaddr_in hostAddr[MAXHOSTSPERCELL];
+ 	                            /* IP addresses for cell's servers*/
+     char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];       
+                                     /* Names for cell's servers */
+     char *linkedCell;               /* Linked cell name, if any */
+ };
+ 
+ /* Windows krb5 libraries don't seem to have this call */
+ #define krb5_xfree(p)	free(p)
+ 
+ /* Title for dialog boxes */
+ #define AKLOG_DIALOG_NAME		"aklog"
+ 
+ #endif /* WINDOWS */
+ 
+ #endif /* __AKLOG_H__ */
Index: openafs/src/aklog/aklog_main.c
diff -c /dev/null openafs/src/aklog/aklog_main.c:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/aklog_main.c	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,1610 ----
+ /* 
+  * $Id: aklog_main.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $
+  *
+  * Copyright 1990,1991 by the Massachusetts Institute of Technology
+  * For distribution and copying rights, see the file "mit-copyright.h"
+  */
+ 
+ #if !defined(lint) && !defined(SABER)
+ static char *rcsid =
+ 	"$Id: aklog_main.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint || SABER */
+ 
+ #include <stdio.h>
+ #include <string.h>
+ #include <ctype.h>
+ #include <sys/types.h>
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
+ #ifdef HAVE_MEMORY_H
+ #include <memory.h>
+ #endif
+ #include <errno.h>
+ 
+ #include <sys/stat.h>
+ #include <fcntl.h>
+ 
+ #ifndef WINDOWS
+ #include <sys/param.h>
+ #include <sys/errno.h>
+ #include <netdb.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <pwd.h>
+ #endif /* WINDOWS */
+ 
+ /* on AIX AFS has an unresolved reference to osi_audit. We will define
+  * it here as extern. It also trys to call the ntohl and htonl routines
+  * as routines rather then macros. We need a real routine here. 
+  * We do this before the ntohl and htonl macros are defined in net/in.h
+  */
+ int osi_audit()
+     { return(0);}
+ 
+ #if 0
+ #ifdef _AIX
+ u_long htonl(u_long x)
+     { return(x);}
+ 
+ u_long ntohl(u_long x)
+     { return(x);}
+ #endif
+ 
+ #include <netinet/in.h>
+ /* #include <krb.h> */
+ #endif /* 0 */
+ 
+ #include <krb5.h>
+ 
+ #ifdef WINDOWS
+ 
+ #ifdef PRE_AFS35
+ #include "afs_tokens.h"
+ #include "rxkad.h"
+ #else /* !PRE_AFS35 */
+ #include <afs/stds.h>
+ #include <afs/auth.h>
+ #include <rx/rxkad.h>
+ #include <afs/dirpath.h>
+ #endif /* PRE_AFS35 */
+ 
+ #else /* !WINDOWS */
+ #include <afs/stds.h>
+ #include <afs/com_err.h>
+ 
+ #include <afs/param.h>
+ #ifdef AFS_SUN5_ENV
+ #include <sys/ioccom.h>
+ #endif
+ #include <afs/auth.h>
+ #include <afs/cellconfig.h>
+ #include <afs/vice.h>
+ #include <afs/venus.h>
+ #include <afs/ptserver.h>
+ #include <afs/dirpath.h>
+ #endif /* WINDOWS */
+ 
+ #include "aklog.h"
+ #include "linked_list.h"
+ 
+ #define AFSKEY "afs"
+ #define AFSINST ""
+ 
+ #ifndef AFS_TRY_FULL_PRINC
+ #define AFS_TRY_FULL_PRINC 0
+ #endif /* AFS_TRY_FULL_PRINC */
+ 
+ #define AKLOG_SUCCESS 0
+ #define AKLOG_USAGE 1
+ #define AKLOG_SOMETHINGSWRONG 2
+ #define AKLOG_AFS 3
+ #define AKLOG_KERBEROS 4
+ #define AKLOG_TOKEN 5
+ #define AKLOG_BADPATH 6
+ #define AKLOG_MISC 7
+ 
+ #ifndef NULL
+ #define NULL 0
+ #endif
+ 
+ #ifndef TRUE
+ #define TRUE 1
+ #endif
+ 
+ #ifndef FALSE
+ #define FALSE 0
+ #endif
+ 
+ #ifndef MAXSYMLINKS
+ /* RedHat 4.x doesn't seem to define this */
+ #define MAXSYMLINKS	5
+ #endif
+ 
+ #define DIR '/'			/* Character that divides directories */
+ #define DIRSTRING "/"		/* String form of above */
+ #define VOLMARKER ':'		/* Character separating cellname from mntpt */
+ #define VOLMARKERSTRING ":"	/* String form of above */
+ 
+ typedef struct {
+     char cell[BUFSIZ];
+     char realm[REALM_SZ];
+ } cellinfo_t;
+ 
+ struct afsconf_cell ak_cellconfig; /* General information about the cell */
+ static char linkedcell[MAXCELLCHARS+1];
+ static char linkedcell2[MAXCELLCHARS+1];
+ 
+ #ifdef WINDOWS
+ 
+ /* libafsconf.dll */
+ extern long cm_GetRootCellName();
+ extern long cm_SearchCellFile();
+ 
+ static long cm_SearchCellFile_CallBack();
+ 
+ #else /* !WINDOWS */
+ 
+ /*
+  * Why doesn't AFS provide these prototypes?
+  */
+ 
+ #ifdef AFS_INT32
+ typedef afs_int32 int32 ;
+ #endif
+ 
+ extern int afsconf_GetLocalCell(struct afsconf_dir *, char *, afs_int32);
+ extern int afsconf_GetCellInfo(struct afsconf_dir *, char *, char *,
+ 			       struct afsconf_cell *);
+ extern int afsconf_Close(struct afsconf_dir *);
+ extern int ktc_GetToken(struct ktc_principal *, struct ktc_token *, int,
+ 			struct ktc_principal *);
+ extern int ktc_SetToken(struct ktc_principal *, struct ktc_token *,
+ 			struct ktc_principal *, int);
+ extern afs_int32 pr_Initialize(afs_int32, char *, char *, afs_int32);
+ extern int pr_SNameToId(char *, afs_int32 *);
+ extern int pr_CreateUser(char *, afs_int32 *);
+ extern int pr_End();
+ extern int pioctl(char *, afs_int32, struct ViceIoctl *, afs_int32);
+ 
+ /*
+  * Other prototypes
+  */
+ 
+ extern char *afs_realm_of_cell(krb5_context, struct afsconf_cell *);
+ 
+ #endif /* WINDOWS */
+ 
+ /*
+  * Provide a replacement for strerror if we don't have it
+  */
+ 
+ #ifndef HAVE_STRERROR
+ extern char *sys_errlist[];
+ #define strerror(x) sys_errlist[x]
+ #endif /* HAVE_STRERROR */
+ 
+ static aklog_params params;	/* Various aklog functions */
+ static char msgbuf[BUFSIZ];	/* String for constructing error messages */
+ static char *progname = NULL;	/* Name of this program */
+ static int dflag = FALSE;	/* Give debugging information */
+ static int noauth = FALSE;	/* If true, don't try to get tokens */
+ static int zsubs = FALSE;	/* Are we keeping track of zephyr subs? */
+ static int hosts = FALSE;	/* Are we keeping track of hosts? */
+ static int noprdb = FALSE;	/* Skip resolving name to id? */
+ static int linked = FALSE;  /* try for both AFS nodes */
+ static int afssetpag = FALSE; /* setpag for AFS */
+ static int force = FALSE;	/* Bash identical tokens? */
+ static linked_list zsublist;	/* List of zephyr subscriptions */
+ static linked_list hostlist;	/* List of host addresses */
+ static linked_list authedcells;	/* List of cells already logged to */
+ 
+ /* ANL - CMU lifetime convert routine */
+ /* for K5.4.1 don't use this for now. Need to see if it is needed */
+ /* maybe needed in the krb524d module as well */
+ /* extern unsigned long krb_life_to_time(); */
+ 
+ #ifdef __STDC__
+ static char *copy_cellinfo(cellinfo_t *cellinfo)
+ #else
+ static char *copy_cellinfo(cellinfo)
+   cellinfo_t *cellinfo;
+ #endif /* __STDC__ */
+ {
+     cellinfo_t *new_cellinfo;
+ 
+     if ((new_cellinfo = (cellinfo_t *)malloc(sizeof(cellinfo_t))))
+ 	memcpy(new_cellinfo, cellinfo, sizeof(cellinfo_t));
+     
+     return ((char *)new_cellinfo);
+ }
+ 
+ 
+ #ifdef __STDC__
+ static char *copy_string(char *string)    
+ #else
+ static char *copy_string(string)
+   char *string;
+ #endif /* __STDC__ */
+ {
+     char *new_string;
+ 
+     if ((new_string = (char *)calloc(strlen(string) + 1, sizeof(char))))
+ 	(void) strcpy(new_string, string);
+ 
+     return (new_string);
+ }
+ 
+ 
+ #ifdef __STDC__
+ static int get_cellconfig(char *cell, struct afsconf_cell *cellconfig, char *local_cell, char *linkedcell)
+ #else
+ static int get_cellconfig(cell, cellconfig, local_cell, linkedcell)
+     char *cell;
+     struct afsconf_cell *cellconfig;
+     char *local_cell;
+ 	char *linkedcell;
+ #endif /* __STDC__ */
+ {
+     int status = AKLOG_SUCCESS;
+     struct afsconf_dir *configdir;
+ #ifndef PRE_AFS35
+     char *dirpath;
+ #endif /* ! PRE_AFS35 */
+ 
+     memset(local_cell, 0, sizeof(local_cell));
+     memset((char *)cellconfig, 0, sizeof(*cellconfig));
+ 
+ #ifndef WINDOWS
+ 
+     if (!(configdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))) {
+ 	sprintf(msgbuf, 
+ 		"%s: can't get afs configuration (afsconf_Open(%s))\n",
+ 		progname, AFSDIR_CLIENT_ETC_DIRPATH);
+ 	params.pstderr(msgbuf);
+ 	params.exitprog(AKLOG_AFS);
+     }
+ 
+     if (afsconf_GetLocalCell(configdir, local_cell, MAXCELLCHARS)) {
+ 	sprintf(msgbuf, "%s: can't determine local cell.\n", progname);
+ 	params.pstderr(msgbuf);
+ 	params.exitprog(AKLOG_AFS);
+     }
+ 
+     if ((cell == NULL) || (cell[0] == 0))
+ 	cell = local_cell;
+ 
+ 	linkedcell[0] = '\0';
+     if (afsconf_GetCellInfo(configdir, cell, NULL, cellconfig)) {
+ 	sprintf(msgbuf, "%s: Can't get information about cell %s.\n",
+ 		progname, cell);
+ 	params.pstderr(msgbuf);
+ 	status = AKLOG_AFS;
+     }
+ 	if (cellconfig->linkedCell) 
+ 		strncpy(linkedcell,cellconfig->linkedCell,MAXCELLCHARS);
+ 
+     (void) afsconf_Close(configdir);
+ 
+ #else /* WINDOWS */
+     /*
+      * We'll try to mimic the GetCellInfo call here and fill in as much
+      * of the afsconf_cell structure as we can.
+      */
+     if (cm_GetRootCellName(local_cell)) {
+ 	sprintf(msgbuf, "%s: can't get local cellname\n", progname);
+ 	params.pstderr(msgbuf);
+ 	params.exitprog(AKLOG_AFS);
+     }
+ 
+     if ((cell == NULL) || (cell[0] == 0))
+ 	cell = local_cell;
+ 
+     strcpy(cellconfig->name, cell);
+ 
+     /* No way of figuring this out as far as I can tell */
+     linkedcell[0] = '\0';
+ 
+     /* Initialize server info */
+     cellconfig->numServers = 0;
+     cellconfig->hostName[0][0] = "\0";
+ 
+     /*
+      * Get servers of cell. cm_SearchCellFile_CallBack() gets call with
+      * each server.
+      */
+ #ifdef PRE_AFS35
+     status = (int) cm_SearchCellFile(cell, &cm_SearchCellFile_CallBack,
+ #else
+     status = (int) cm_SearchCellFile(cell, NULL, &cm_SearchCellFile_CallBack,
+ #endif
+ 				     cellconfig /* rock */);
+ 
+     switch(status) {
+     case 0:
+ 	break;
+ 
+     case -1:
+ 	sprintf(msgbuf, "%s: GetWindowsDirectory() failed.\n", progname);
+ 	break;
+ 
+     case -2:
+ 	sprintf(msgbuf, "%s: Couldn't open afsdcells.ini for reading\n",
+ 		progname);
+ 	break;
+ 
+     case -3:
+ 	sprintf(msgbuf, "%s: Couldn't find any servers for cell %s\n",
+ 		progname, cell);
+ 	break;
+ 
+     case -4:
+ 	sprintf(msgbuf, "%s: Badly formatted line in afsdcells.ini (does not begin with a \">\" or contain \"#\"\n",
+ 		progname);
+ 	break;
+ 
+     default:
+ 	sprintf(msgbuf, "%s cm_SearchCellFile returned unknown error %d\n",
+ 		status);
+     }
+ 
+     if (status) {
+ 	params.pstderr(msgbuf);
+ 	params.exitprog(AKLOG_AFS);
+     }
+ 
+     status = AKLOG_SUCCESS;
+ 
+     
+ #endif /* WINDOWS */
+ 
+     return(status);
+ }
+ 
+ 
+ #ifdef WINDOWS
+ /*
+  * Callback function for cm_SearchCellFile() in get_cellconfig() above.
+  * This function gets called once for each server that is found for the cell.
+  */
+ static long
+ cm_SearchCellFile_CallBack(void *rock /* cellconfig */,
+ 			   struct sockaddr_in *addr, /* Not used */
+ 			   char *server)
+ {
+     struct afsconf_cell *cellconfig = rock;
+ 
+ 
+     /*
+      * Save server name and increment count of servers
+      */
+     strcpy(cellconfig->hostName[cellconfig->numServers++], server);
+     
+     return (long) 0;
+ }
+ 
+     
+ #endif /* WINDOWS */
+ 
+ 
+ /* 
+  * Log to a cell.  If the cell has already been logged to, return without
+  * doing anything.  Otherwise, log to it and mark that it has been logged
+  * to.
+  */
+ #ifdef __STDC__
+ static int auth_to_cell(krb5_context context, char *cell, char *realm)
+ #else
+ static int auth_to_cell(context, cell, realm)
+ 
+   krb5_context context;
+   char *cell;
+   char *realm;
+ #endif /* __STDC__ */
+ {
+     int status = AKLOG_SUCCESS;
+     char username[BUFSIZ];	/* To hold client username structure */
+     long viceId;		/* AFS uid of user */
+ 
+     char name[ANAME_SZ];	/* Name of afs key */
+     char primary_instance[INST_SZ];	/* Instance of afs key */
+     char secondary_instance[INST_SZ];	/* Backup instance to try */
+     int try_secondary = 0;		/* Flag to indicate if we try second */
+     char realm_of_user[REALM_SZ]; /* Kerberos realm of user */
+     char realm_of_cell[REALM_SZ]; /* Kerberos realm of cell */
+     char local_cell[MAXCELLCHARS+1];
+     char cell_to_use[MAXCELLCHARS+1]; /* Cell to authenticate to */
+     static char lastcell[MAXCELLCHARS+1] = { 0 };
+ #ifndef WINDOWS
+     static char confname[512] = { 0 };
+ #endif
+     krb5_creds *v5cred = NULL;
+     CREDENTIALS c;
+     struct ktc_principal aserver;
+     struct ktc_principal aclient;
+     struct ktc_token atoken, btoken;
+ 
+ #ifdef ALLOW_REGISTER
+     afs_int32 id;
+ #endif /* ALLOW_REGISTER */
+ 
+     memset(name, 0, sizeof(name));
+     memset(primary_instance, 0, sizeof(primary_instance));
+     memset(secondary_instance, 0, sizeof(secondary_instance));
+     memset(realm_of_user, 0, sizeof(realm_of_user));
+     memset(realm_of_cell, 0, sizeof(realm_of_cell));
+ 
+ #ifndef WINDOWS
+     if (confname[0] == '\0') {
+ 	strncpy(confname, AFSDIR_CLIENT_ETC_DIRPATH, sizeof(confname));
+ 	confname[sizeof(confname) - 2] = '\0';
+     }
+ #endif /* WINDOWS */
+ 
+     /* NULL or empty cell returns information on local cell */
+     if ((status = get_cellconfig(cell, &ak_cellconfig,
+ 			 local_cell, linkedcell)))
+ 	return(status);
+ 
+     strncpy(cell_to_use, ak_cellconfig.name, MAXCELLCHARS);
+     cell_to_use[MAXCELLCHARS] = 0;
+ 
+     if (ll_string(&authedcells, ll_s_check, cell_to_use)) {
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Already authenticated to %s (or tried to)\n", 
+ 		    cell_to_use);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 	return(AKLOG_SUCCESS);
+     }
+ 
+     /* 
+      * Record that we have attempted to log to this cell.  We do this
+      * before we try rather than after so that we will not try
+      * and fail repeatedly for one cell.
+      */
+     (void)ll_string(&authedcells, ll_s_add, cell_to_use);
+ 
+     /* 
+      * Record this cell in the list of zephyr subscriptions.  We may
+      * want zephyr subscriptions even if authentication fails.
+      * If this is done after we attempt to get tokens, aklog -zsubs
+      * can return something different depending on whether or not we
+      * are in -noauth mode.
+      */
+     if (ll_string(&zsublist, ll_s_add, cell_to_use) == LL_FAILURE) {
+ 	sprintf(msgbuf, 
+ 		"%s: failure adding cell %s to zephyr subscriptions list.\n",
+ 		progname, cell_to_use);
+ 	params.pstderr(msgbuf);
+ 	params.exitprog(AKLOG_MISC);
+     }
+     if (ll_string(&zsublist, ll_s_add, local_cell) == LL_FAILURE) {
+ 	sprintf(msgbuf, 
+ 		"%s: failure adding cell %s to zephyr subscriptions list.\n",
+ 		progname, local_cell);
+ 	params.pstderr(msgbuf);
+ 	params.exitprog(AKLOG_MISC);
+     }
+ 
+     if (!noauth) {
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Authenticating to cell %s (server %s).\n",
+ 		    cell_to_use, ak_cellconfig.hostName[0]);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 
+ 	/*
+ 	 * Find out which realm we're supposed to authenticate to.  If one
+ 	 * is not included, use the kerberos realm found in the credentials
+ 	 * cache.
+ 	 */
+ 
+ 	if (realm && realm[0]) {
+ 	    strcpy(realm_of_cell, realm);
+ 	    if (dflag) {
+ 		sprintf(msgbuf, "We were told to authenticate to realm %s.\n",
+ 			realm);
+ 		params.pstdout(msgbuf);
+ 	    }
+ 	}
+ 	else {
+ 	    char *realm = afs_realm_of_cell(context, &ak_cellconfig);
+ 
+ 	    if (!realm) {
+ 		sprintf(msgbuf, 
+ 			"%s: Couldn't figure out realm for cell %s.\n",
+ 			progname, cell_to_use);
+ 		params.pstderr(msgbuf);
+ 		params.exitprog(AKLOG_MISC);
+ 	    }
+ 
+ 	    strcpy(realm_of_cell, realm);
+ 
+ 	    if (dflag) {
+ 		sprintf(msgbuf, "We've deduced that we need to authenticate to"
+ 			" realm %s.\n", realm_of_cell);
+ 		params.pstdout(msgbuf);
+ 	    }
+ 	}
+ 
+ 	/* We use the afs.<cellname> convention here... 
+ 	 *
+ 	 * Doug Engert's original code had principals of the form:
+ 	 *
+ 	 * "afsx/cell@realm"
+ 	 *
+ 	 * in the KDC, so the name wouldn't conflict with DFS.  Since we're
+ 	 * not using DFS, I changed it just to look for the following
+ 	 * principals:
+ 	 *
+ 	 * afs/<cell>@<realm>
+ 	 * afs@<realm>
+ 	 *
+ 	 * Because people are transitioning from afs@realm to afs/cell,
+ 	 * we configure things so that if the first one isn't found, we
+ 	 * try the second one.  You can select which one you prefer with
+ 	 * a configure option.
+ 	 */
+ 
+ 	strcpy(name, AFSKEY);
+ 
+ 	if (AFS_TRY_FULL_PRINC || strcasecmp(cell_to_use, realm_of_cell) != 0) {
+ 	    strncpy(primary_instance, cell_to_use, sizeof(primary_instance));
+ 	    primary_instance[sizeof(primary_instance)-1] = '\0';
+ 	    if (strcasecmp(cell_to_use, realm_of_cell) == 0) {
+ 		try_secondary = 1;
+ 		secondary_instance[0] = '\0';
+ 	    }
+ 	} else {
+ 	    primary_instance[0] = '\0';
+ 	    try_secondary = 1;
+ 	    strncpy(secondary_instance, cell_to_use,
+ 		    sizeof(secondary_instance));
+ 	    secondary_instance[sizeof(secondary_instance)-1] = '\0';
+ 	}
+ 
+ 	/* 
+ 	 * Extract the session key from the ticket file and hand-frob an
+ 	 * afs style authenticator.
+ 	 */
+ 
+ 	/*
+ 	 * Try to obtain AFS tickets.  Because there are two valid service
+ 	 * names, we will try both, but trying the more specific first.
+ 	 *
+ 	 *	afs/<cell>@<realm> i.e. allow for single name with "."
+ 	 * 	afs@<realm>
+ 	 */
+ #if 0
+ 	if (dflag) {
+ 		dee_gettokens(); /* DEBUG */
+ 	}
+ #endif
+ 
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Getting tickets: %s/%s@%s\n", name,
+ 		    primary_instance, realm_of_cell);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 
+ 	status = params.get_cred(context, name, primary_instance, realm_of_cell,
+ 			 &c, &v5cred);
+ 
+ 	if (status == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN) {
+ 	    if (try_secondary) {
+ 		if (dflag) {
+ 		    sprintf(msgbuf, "Principal not found, trying alternate "
+ 			    "service name: %s/%s@%s\n", name,
+ 			    secondary_instance, realm_of_cell);
+ 		    params.pstdout(msgbuf);
+ 		}
+ 		status = params.get_cred(context, name, secondary_instance,
+ 					 realm_of_cell, &c, &v5cred);
+ 	    }
+ 	}
+ 
+ 	if (status != KSUCCESS) {
+ 	    if (dflag) {
+ 		sprintf(msgbuf, 
+ 			"Kerberos error code returned by get_cred: %d\n",
+ 			status);
+ 		params.pstdout(msgbuf);
+ 	    }
+ 	    sprintf(msgbuf, "%s: Couldn't get %s AFS tickets:\n",
+ 		    progname, cell_to_use);
+ 	    params.pstderr(msgbuf);
+ 		com_err(progname, status, "while getting AFS tickets");
+ 	    return(AKLOG_KERBEROS);
+ 	}
+ 
+ 	strncpy(aserver.name, AFSKEY, MAXKTCNAMELEN - 1);
+ 	strncpy(aserver.instance, AFSINST, MAXKTCNAMELEN - 1);
+ 	strncpy(aserver.cell, cell_to_use, MAXKTCREALMLEN - 1);
+ 
+ 	strcpy (username, c.pname);
+ 	if (c.pinst[0]) {
+ 	    strcat (username, ".");
+ 	    strcat (username, c.pinst);
+ 	}
+ 
+ 	atoken.kvno = c.kvno;
+ 	atoken.startTime = c.issue_date;
+ 	/*
+ 	 * It seems silly to go through a bunch of contortions to
+ 	 * extract the expiration time, when the v5 credentials already
+ 	 * has the exact time!  Let's use that instead.
+ 	 *
+ 	 * Note that this isn't a security hole, as the expiration time
+ 	 * is also contained in the encrypted token
+ 	 */
+ 	atoken.endTime = v5cred->times.endtime;
+ 	memcpy(&atoken.sessionKey, c.session, 8);
+ 	atoken.ticketLen = c.ticket_st.length;
+ 	memcpy(atoken.ticket, c.ticket_st.dat, atoken.ticketLen);
+ 	
+ 	if (!force &&
+ 	    !ktc_GetToken(&aserver, &btoken, sizeof(btoken), &aclient) &&
+ 	    atoken.kvno == btoken.kvno &&
+ 	    atoken.ticketLen == btoken.ticketLen &&
+ 	    !memcmp(&atoken.sessionKey, &btoken.sessionKey, sizeof(atoken.sessionKey)) &&
+ 	    !memcmp(atoken.ticket, btoken.ticket, atoken.ticketLen)) {
+ 
+ 	    if (dflag) {
+ 		sprintf(msgbuf, "Identical tokens already exist; skipping.\n");
+ 		params.pstdout(msgbuf);
+ 	    }
+ 	    return 0;
+ 	}
+ 
+ #ifdef FORCE_NOPRDB
+ 	noprdb = 1;
+ #endif
+ 
+ #ifndef WINDOWS
+ 	if (noprdb) {
+ #endif
+ 	    if (dflag) {
+ 		sprintf(msgbuf, "Not resolving name %s to id (-noprdb set)\n",
+ 			username);
+ 		params.pstdout(msgbuf);
+ 	    }
+ #ifndef WINDOWS
+ 	}
+ 	else {
+ 	    if ((status = params.get_user_realm(context, realm_of_user)) != KSUCCESS) {
+ 		sprintf(msgbuf, "%s: Couldn't determine realm of user:)",
+ 			progname);
+ 		params.pstderr(msgbuf);
+ 		com_err(progname, status, " while getting realm");
+ 		return(AKLOG_KERBEROS);
+ 	    }
+ 	    if (strcmp(realm_of_user, realm_of_cell)) {
+ 		strcat(username, "@");
+ 		strcat(username, realm_of_user);
+ 	    }
+ 
+ 	    if (dflag) {
+ 		sprintf(msgbuf, "About to resolve name %s to id in cell %s.\n", 
+ 			username, aserver.cell);
+ 		params.pstdout(msgbuf);
+ 	    }
+ 
+ 	    /*
+ 	     * Talk about DUMB!  It turns out that there is a bug in
+ 	     * pr_Initialize -- even if you give a different cell name
+ 	     * to it, it still uses a connection to a previous AFS server
+ 	     * if one exists.  The way to fix this is to change the
+ 	     * _filename_ argument to pr_Initialize - that forces it to
+ 	     * re-initialize the connection.  We do this by adding and
+ 	     * removing a "/" on the end of the configuration directory name.
+ 	     */
+ 
+ 	    if (lastcell[0] != '\0' && (strcmp(lastcell, aserver.cell) != 0)) {
+ 		int i = strlen(confname);
+ 		if (confname[i - 1] == '/') {
+ 		    confname[i - 1] = '\0';
+ 		} else {
+ 		    confname[i] = '/';
+ 		    confname[i + 1] = '\0';
+ 		}
+ 	    }
+ 
+ 	    strcpy(lastcell, aserver.cell);
+ 
+ 	    if (!pr_Initialize (0, confname, aserver.cell, 0))
+ 		    status = pr_SNameToId (username, &viceId);
+ 	    
+ 	    if (dflag) {
+ 		if (status) 
+ 		    sprintf(msgbuf, "Error %d\n", status);
+ 		else
+ 		    sprintf(msgbuf, "Id %d\n", (int) viceId);
+ 		params.pstdout(msgbuf);
+ 	    }
+ 	    
+ 		/*
+ 		 * This is a crock, but it is Transarc's crock, so
+ 		 * we have to play along in order to get the
+ 		 * functionality.  The way the afs id is stored is
+ 		 * as a string in the username field of the token.
+ 		 * Contrary to what you may think by looking at
+ 		 * the code for tokens, this hack (AFS ID %d) will
+ 		 * not work if you change %d to something else.
+ 		 */
+ 
+ 		/*
+ 		 * This code is taken from cklog -- it lets people
+ 		 * automatically register with the ptserver in foreign cells
+ 		 */
+ 
+ #ifdef ALLOW_REGISTER
+ 	if (status == 0) {
+ 	    if (viceId != ANONYMOUSID) {
+ #else /* ALLOW_REGISTER */
+ 	    if ((status == 0) && (viceId != ANONYMOUSID))
+ #endif /* ALLOW_REGISTER */
+ 		sprintf (username, "AFS ID %d", (int) viceId);
+ #ifdef ALLOW_REGISTER
+ 	    } else if (strcmp(realm_of_user, realm_of_cell) != 0) {
+ 		if (dflag) {
+ 		    sprintf(msgbuf, "doing first-time registration of %s "
+ 			    "at %s\n", username, cell_to_use);
+ 		    params.pstdout(msgbuf);
+ 		}
+ 		id = 0;
+ 		strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
+ 		strcpy(aclient.instance, "");
+ 		strncpy(aclient.cell, c.realm, MAXKTCREALMLEN - 1);
+ 		if ((status = ktc_SetToken(&aserver, &atoken, &aclient, 0))) {
+ 		    sprintf(msgbuf, "%s: unable to obtain tokens for cell %s "
+ 			    "(status: %d).\n", progname, cell_to_use, status);
+ 		    params.pstderr(msgbuf);
+ 		    status = AKLOG_TOKEN;
+ 		}
+ 
+ 		/*
+ 		 * In case you're wondering, we don't need to change the
+ 		 * filename here because we're still connecting to the
+ 		 * same cell -- we're just using a different authentication
+ 		 * level
+ 		 */
+ 
+ 		if ((status = pr_Initialize(1L, confname, aserver.cell, 0))) {
+ 		    sprintf(msgbuf, "Error %d\n", status);
+ 		    params.pstdout(msgbuf);
+ 		}
+ 
+ 		if ((status = pr_CreateUser(username, &id))) {
+ 		    sprintf(msgbuf, "%s: %s so unable to create remote PTS "
+ 			    "user %s in cell %s (status: %d).\n", progname,
+ 			    error_message(status), username, cell_to_use,
+ 			    status);
+ 		    params.pstdout(msgbuf);
+ 		} else {
+ 		    sprintf(msgbuf, "created cross-cell entry for %s at %s\n",
+ 			    username, cell_to_use);
+ 		    params.pstdout(msgbuf);
+ 		    sprintf(username, "AFS ID %d", (int) id);
+ 		}
+ 	    }
+ 	}
+ #endif /* ALLOW_REGISTER */
+ 
+ 	}
+ #endif /* !WINDOWS */
+ 
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Set username to %s\n", username);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 
+ 	/* Reset the "aclient" structure before we call ktc_SetToken.
+ 	 * This structure was first set by the ktc_GetToken call when
+ 	 * we were comparing whether identical tokens already existed.
+ 	 */
+ 	strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
+ 	strcpy(aclient.instance, "");
+ 	strncpy(aclient.cell, c.realm, MAXKTCREALMLEN - 1);
+ 
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Setting tokens. %s / %s @ %s \n",
+ 			aclient.name, aclient.instance, aclient.cell );
+ 	    params.pstdout(msgbuf);
+ 	}
+ 	/* on AIX 4.1.4 with AFS 3.4a+ if a write is not done before 
+ 	 * this routine, it will not add the token. It is not clear what 
+ 	 * is going on here! So we will do the following operation
+ 	 */
+ 	write(2,"",0); /* dummy write */
+ #ifndef WINDOWS
+ 	if ((status = ktc_SetToken(&aserver, &atoken, &aclient, afssetpag))) {
+ 	    sprintf(msgbuf, 
+ 		    "%s: unable to obtain tokens for cell %s (status: %d).\n",
+ 		    progname, cell_to_use, status);
+ 	    params.pstderr(msgbuf);
+ 	    status = AKLOG_TOKEN;
+ 	}
+ #else /* WINDOWS */
+ 	/* Note switched 2nd and 3rd args */
+ #ifdef PRE_AFS35
+ 	if ((status = ktc_SetToken(&aserver, &aclient, &atoken, afssetpag))) {
+ #else
+ 	if ((status = ktc_SetToken(&aserver, &atoken, &aclient, afssetpag))) {
+ #endif
+ 	    switch(status) {
+ 	    case KTC_INVAL:
+ 		sprintf(msgbuf, "%s: Bad ticket length", progname);
+ 		break;
+ 	    case KTC_PIOCTLFAIL:
+ 		sprintf(msgbuf, "%s: Unknown error contacting AFS service",
+ 			progname);
+ 		break;
+ 	    case KTC_NOCELL:
+ 		sprintf(msgbuf, "%s: Cell name (%s) not recognized by AFS service",
+ 			progname, realm_of_cell);
+ 		break;
+ 	    case KTC_NOCM:
+ 		sprintf(msgbuf, "%s: AFS service is unavailable", progname);
+ 		break;
+ 	    default:
+ 		sprintf(msgbuf, "%s: Undocumented error (%d) contacting AFS service", progname, status);
+ 		break;	
+ 	    }
+ 	    params.pstderr(msgbuf);
+ 	    status = AKLOG_TOKEN;	    
+ 	}
+ #endif /* !WINDOWS */
+     }
+     else
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Noauth mode; not authenticating.\n");
+ 	    params.pstdout(msgbuf);
+ 	}
+ 	
+     return(status);
+ }
+ 
+ #ifndef WINDOWS /* struct ViceIoctl missing */
+ 
+ #ifdef __STDC__
+ static int get_afs_mountpoint(char *file, char *mountpoint, int size)
+ #else
+ static int get_afs_mountpoint(file, mountpoint, size)
+   char *file;
+   char *mountpoint;
+   int size;
+ #endif /* __STDC__ */
+ {
+ #ifdef AFS_SUN_ENV
+ 	char V ='V'; /* AFS has problem on Sun with pioctl */
+ #endif
+     char our_file[MAXPATHLEN + 1];
+     char *parent_dir;
+     char *last_component;
+     struct ViceIoctl vio;
+     char cellname[BUFSIZ];
+ 
+     memset(our_file, 0, sizeof(our_file));
+     strcpy(our_file, file);
+ 
+     if ((last_component = strrchr(our_file, DIR))) {
+ 	*last_component++ = 0;
+ 	parent_dir = our_file;
+     }
+     else {
+ 	last_component = our_file;
+ 	parent_dir = ".";
+     }    
+     
+     memset(cellname, 0, sizeof(cellname));
+ 
+     vio.in = last_component;
+     vio.in_size = strlen(last_component)+1;
+     vio.out_size = size;
+     vio.out = mountpoint;
+ 
+     if (!pioctl(parent_dir, VIOC_AFS_STAT_MT_PT, &vio, 0)) {
+ 	if (strchr(mountpoint, VOLMARKER) == NULL) {
+ 	    vio.in = file;
+ 	    vio.in_size = strlen(file) + 1;
+ 	    vio.out_size = sizeof(cellname);
+ 	    vio.out = cellname;
+ 	    
+ 	    if (!pioctl(file, VIOC_FILE_CELL_NAME, &vio, 1)) {
+ 		strcat(cellname, VOLMARKERSTRING);
+ 		strcat(cellname, mountpoint + 1);
+ 		memset(mountpoint + 1, 0, size - 1);
+ 		strcpy(mountpoint + 1, cellname);
+ 	    }
+ 	}
+ 	return(TRUE);
+     }
+     else
+ 	return(FALSE);
+ }
+ 
+ /* 
+  * This routine each time it is called returns the next directory 
+  * down a pathname.  It resolves all symbolic links.  The first time
+  * it is called, it should be called with the name of the path
+  * to be descended.  After that, it should be called with the arguemnt
+  * NULL.
+  */
+ #ifdef __STDC__
+ static char *next_path(char *origpath)
+ #else
+ static char *next_path(origpath)
+   char *origpath;
+ #endif /* __STDC__ */
+ {
+     static char path[MAXPATHLEN + 1];
+     static char pathtocheck[MAXPATHLEN + 1];
+ 
+     int link = FALSE;		/* Is this a symbolic link? */
+     char linkbuf[MAXPATHLEN + 1];
+     char tmpbuf[MAXPATHLEN + 1];
+ 
+     static char *last_comp;	/* last component of directory name */
+     static char *elast_comp;	/* End of last component */
+     char *t;
+     int len;
+     
+     static int symlinkcount = 0; /* We can't exceed MAXSYMLINKS */
+     
+     /* If we are given something for origpath, we are initializing only. */
+     if (origpath) {
+ 	memset(path, 0, sizeof(path));
+ 	memset(pathtocheck, 0, sizeof(pathtocheck));
+ 	strcpy(path, origpath);
+ 	last_comp = path;
+ 	symlinkcount = 0;
+ 	return(NULL);
+     }
+ 
+     /* We were not given origpath; find then next path to check */
+     
+     /* If we've gotten all the way through already, return NULL */
+     if (last_comp == NULL)
+ 	return(NULL);
+ 
+     do {
+ 	while (*last_comp == DIR)
+ 	    strncat(pathtocheck, last_comp++, 1);
+ 	len = (elast_comp = strchr(last_comp, DIR)) 
+ 	    ? elast_comp - last_comp : strlen(last_comp);
+ 	strncat(pathtocheck, last_comp, len);
+ 	memset(linkbuf, 0, sizeof(linkbuf));
+ 	if ((link = (params.readlink(pathtocheck, linkbuf, 
+ 				    sizeof(linkbuf)) > 0))) {
+ 	    if (++symlinkcount > MAXSYMLINKS) {
+ 		sprintf(msgbuf, "%s: %s\n", progname, strerror(ELOOP));
+ 		params.pstderr(msgbuf);
+ 		params.exitprog(AKLOG_BADPATH);
+ 	    }
+ 	    memset(tmpbuf, 0, sizeof(tmpbuf));
+ 	    if (elast_comp)
+ 		strcpy(tmpbuf, elast_comp);
+ 	    if (linkbuf[0] == DIR) {
+ 		/* 
+ 		 * If this is a symbolic link to an absolute path, 
+ 		 * replace what we have by the absolute path.
+ 		 */
+ 		memset(path, 0, strlen(path));
+ 		memcpy(path, linkbuf, sizeof(linkbuf));
+ 		strcat(path, tmpbuf);
+ 		last_comp = path;
+ 		elast_comp = NULL;
+ 		memset(pathtocheck, 0, sizeof(pathtocheck));
+ 	    }
+ 	    else {
+ 		/* 
+ 		 * If this is a symbolic link to a relative path, 
+ 		 * replace only the last component with the link name.
+ 		 */
+ 		strncpy(last_comp, linkbuf, strlen(linkbuf) + 1);
+ 		strcat(path, tmpbuf);
+ 		elast_comp = NULL;
+ 		if ((t = strrchr(pathtocheck, DIR))) {
+ 		    t++;
+ 		    memset(t, 0, strlen(t));
+ 		}
+ 		else
+ 		    memset(pathtocheck, 0, sizeof(pathtocheck));
+ 	    }
+ 	}
+ 	else
+ 	    last_comp = elast_comp;
+     }
+     while(link);
+ 
+     return(pathtocheck);
+ }
+ 
+ #endif /* WINDOWS */
+ 
+ #if 0
+ /*****************************************/
+ int dee_gettokens()
+ {
+ #ifdef AFS_SUN_ENV
+ 	char V = 'V'; /* AFS has problem on SunOS */
+ #endif
+    struct ViceIoctl vio;
+    char outbuf[BUFSIZ];
+    long ind;
+    int fd;
+ 
+    memset(outbuf, 0, sizeof(outbuf));
+ 
+    vio.out_size = sizeof(outbuf);
+    vio.in_size = sizeof(ind);
+    vio.out = outbuf;
+    vio.in = &ind;
+ 
+    ind = 0;
+    fd = open("dee.tok",O_WRONLY);
+    while(!pioctl(0,VIOCGETTOK,&vio,0)) {
+ 	write(fd,&outbuf,sizeof(outbuf)); 
+        ind++;
+    }
+    close(fd);
+ }
+ /*****************************************/
+ #endif
+ 
+ #ifndef WINDOWS /* struct ViceIoctl missing */
+ 
+ #ifdef __STDC__
+ static void add_hosts(char *file)
+ #else
+ static void add_hosts(file)
+   char *file;
+ #endif /* __STDC__ */
+ {
+ #ifdef AFS_SUN_ENV
+ 	char V = 'V'; /* AFS has problem on SunOS */
+ #endif
+     struct ViceIoctl vio;
+     char outbuf[BUFSIZ];
+     long *phosts;
+     int i;
+     struct hostent *hp;
+     struct in_addr in;
+     
+     memset(outbuf, 0, sizeof(outbuf));
+ 
+     vio.out_size = sizeof(outbuf);
+     vio.in_size = 0;
+     vio.out = outbuf;
+ 
+     if (dflag) {
+ 	sprintf(msgbuf, "Getting list of hosts for %s\n", file);
+ 	params.pstdout(msgbuf);
+     }
+     /* Don't worry about errors. */
+     if (!pioctl(file, VIOCWHEREIS, &vio, 1)) {
+ 	phosts = (long *) outbuf;
+ 
+ 	/*
+ 	 * Lists hosts that we care about.  If ALLHOSTS is defined,
+ 	 * then all hosts that you ever may possible go through are
+ 	 * included in this list.  If not, then only hosts that are
+ 	 * the only ones appear.  That is, if a volume you must use
+ 	 * is replaced on only one server, that server is included.
+ 	 * If it is replicated on many servers, then none are included.
+ 	 * This is not perfect, but the result is that people don't
+ 	 * get subscribed to a lot of instances of FILSRV that they
+ 	 * probably won't need which reduces the instances of 
+ 	 * people getting messages that don't apply to them.
+ 	 */
+ #ifndef ALLHOSTS
+ 	if (phosts[1] != '\0')
+ 	    return;
+ #endif
+ 	for (i = 0; phosts[i]; i++) {
+ 	    if (hosts) {
+ 		in.s_addr = phosts[i];
+ 		if (dflag) {
+ 		    sprintf(msgbuf, "Got host %s\n", inet_ntoa(in));
+ 		    params.pstdout(msgbuf);
+ 		}
+ 		ll_string(&hostlist, ll_s_add, (char *)inet_ntoa(in));
+ 	    }
+ 	    if (zsubs && (hp=gethostbyaddr((char *) &phosts[i],sizeof(long),AF_INET))) {
+ 		if (dflag) {
+ 		    sprintf(msgbuf, "Got host %s\n", hp->h_name);
+ 		    params.pstdout(msgbuf);
+ 		}
+ 		ll_string(&zsublist, ll_s_add, hp->h_name);
+ 	    }
+ 	}
+     }
+ }
+ 
+ #endif /* WINDOWS */
+ 
+ #ifndef WINDOWS /* next_path(), get_afs_mountpoint() */
+ 
+ /*
+  * This routine descends through a path to a directory, logging to 
+  * every cell it encounters along the way.
+  */
+ #ifdef __STDC__
+ static int auth_to_path(krb5_context context, char *path)
+ #else
+ static int auth_to_path(context, path)
+   krb5_context context;
+   char *path;			/* The path to which we try to authenticate */
+ #endif /* __STDC__ */
+ {
+     int status = AKLOG_SUCCESS;
+     int auth_to_cell_status = AKLOG_SUCCESS;
+ 
+     char *nextpath;
+     char pathtocheck[MAXPATHLEN + 1];
+     char mountpoint[MAXPATHLEN + 1];
+ 
+     char *cell;
+     char *endofcell;
+ 
+     u_char isdir;
+ 
+     /* Initialize */
+     if (path[0] == DIR)
+ 	strcpy(pathtocheck, path);
+     else {
+ 	if (params.getwd(pathtocheck) == NULL) {
+ 	    sprintf(msgbuf, "Unable to find current working directory:\n");
+ 	    params.pstderr(msgbuf);
+ 	    sprintf(msgbuf, "%s\n", pathtocheck);
+ 	    params.pstderr(msgbuf);
+ 	    sprintf(msgbuf, "Try an absolute pathname.\n");
+ 	    params.pstderr(msgbuf);
+ 	    params.exitprog(AKLOG_BADPATH);
+ 	}
+ 	else {
+ 	    strcat(pathtocheck, DIRSTRING);
+ 	    strcat(pathtocheck, path);
+ 	}
+     }
+     next_path(pathtocheck);
+ 
+     /* Go on to the next level down the path */
+     while ((nextpath = next_path(NULL))) {
+ 	strcpy(pathtocheck, nextpath);
+ 	if (dflag) {
+ 	    sprintf(msgbuf, "Checking directory %s\n", pathtocheck);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 	/* 
+ 	 * If this is an afs mountpoint, determine what cell from 
+ 	 * the mountpoint name which is of the form 
+ 	 * #cellname:volumename or %cellname:volumename.
+ 	 */
+ 	if (get_afs_mountpoint(pathtocheck, mountpoint, sizeof(mountpoint))) {
+ 	    /* skip over the '#' or '%' */
+ 	    cell = mountpoint + 1;
+ 	    /* Add this (cell:volumename) to the list of zsubs */
+ 	    if (zsubs)
+ 		ll_string(&zsublist, ll_s_add, cell);
+ 	    if (zsubs || hosts)
+ 		add_hosts(pathtocheck);
+ 	    if ((endofcell = strchr(mountpoint, VOLMARKER))) {
+ 		*endofcell = '\0';
+ 		if ((auth_to_cell_status = auth_to_cell(context, cell, NULL))) {
+ 		    if (status == AKLOG_SUCCESS)
+ 			status = auth_to_cell_status;
+ 		    else if (status != auth_to_cell_status)
+ 			status = AKLOG_SOMETHINGSWRONG;
+ 		}
+ 	    }
+ 	}
+ 	else {
+ 	    if (params.isdir(pathtocheck, &isdir) < 0) {
+ 		/*
+ 		 * If we've logged and still can't stat, there's
+ 		 * a problem... 
+ 		 */
+ 		sprintf(msgbuf, "%s: stat(%s): %s\n", progname, 
+ 			pathtocheck, strerror(errno));
+ 		params.pstderr(msgbuf);
+ 		return(AKLOG_BADPATH);
+ 	    }
+ 	    else if (! isdir) {
+ 		/* Allow only directories */
+ 		sprintf(msgbuf, "%s: %s: %s\n", progname, pathtocheck,
+ 			strerror(ENOTDIR));
+ 		params.pstderr(msgbuf);
+ 		return(AKLOG_BADPATH);
+ 	    }
+ 	}
+     }
+     
+ 
+     return(status);
+ }
+ 
+ #endif /* WINDOWS */
+ 
+ 
+ /* Print usage message and exit */
+ #ifdef __STDC__
+ static void usage(void)
+ #else
+ static void usage()
+ #endif /* __STDC__ */
+ {
+     sprintf(msgbuf, "\nUsage: %s %s%s%s\n", progname,
+ 	    "[-d] [[-cell | -c] cell [-k krb_realm]] ",
+ 	    "[[-p | -path] pathname]\n",
+ 	    "    [-zsubs] [-hosts] [-noauth] [-noprdb] [-force] [-setpag] [-linked]\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -d gives debugging information.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    krb_realm is the kerberos realm of a cell.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    pathname is the name of a directory to which ");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "you wish to authenticate.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -zsubs gives zephyr subscription information.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -hosts gives host address information.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -noauth does not attempt to get tokens.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -noprdb means don't try to determine AFS ID.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -force means replace identical tickets. \n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -linked means if AFS node is linked, try both. \n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    -setpag set the AFS process authentication group.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "    No commandline arguments means ");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "authenticate to the local cell.\n");
+     params.pstderr(msgbuf);
+     sprintf(msgbuf, "\n");
+     params.pstderr(msgbuf);
+     params.exitprog(AKLOG_USAGE);
+ }
+ 
+ #ifdef __STDC__
+ void aklog(int argc, char *argv[], aklog_params *a_params)
+ #else
+ void aklog(argc, argv, a_params)
+   int argc;
+   char *argv[];
+   aklog_params *a_params;
+ #endif /* __STDC__ */
+ {
+ 	krb5_context context;
+     int status = AKLOG_SUCCESS;
+     int i;
+     int somethingswrong = FALSE;
+ 
+     cellinfo_t cellinfo;
+ 
+     extern char *progname;	/* Name of this program */
+ 
+     extern int dflag;		/* Debug mode */
+ 
+     int cmode = FALSE;		/* Cellname mode */
+     int pmode = FALSE;		/* Path name mode */
+ 
+     char realm[REALM_SZ];	/* Kerberos realm of afs server */
+     char cell[BUFSIZ];		/* Cell to which we are authenticating */
+     char path[MAXPATHLEN + 1];		/* Path length for path mode */
+ 
+     linked_list cells;		/* List of cells to log to */
+     linked_list paths;		/* List of paths to log to */
+     ll_node *cur_node;
+ 
+     memset(&cellinfo, 0, sizeof(cellinfo));
+ 
+     memset(realm, 0, sizeof(realm));
+     memset(cell, 0, sizeof(cell));
+     memset(path, 0, sizeof(path));
+ 
+     ll_init(&cells);
+     ll_init(&paths);
+ 
+     ll_init(&zsublist);
+     ll_init(&hostlist);
+ 
+     /* Store the program name here for error messages */
+     if ((progname = strrchr(argv[0], DIR)))
+ 	progname++;
+     else
+ 	progname = argv[0];
+ 
+     krb5_init_context(&context);
+ #ifndef WINDOWS
+ 	initialize_ktc_error_table ();
+ #endif
+ 
+     memcpy((char *)&params, (char *)a_params, sizeof(aklog_params));
+ 
+     /* Initialize list of cells to which we have authenticated */
+     (void)ll_init(&authedcells);
+ 
+     /* Parse commandline arguments and make list of what to do. */
+     for (i = 1; i < argc; i++) {
+ 	if (strcmp(argv[i], "-d") == 0)
+ 	    dflag++;
+ 	else if (strcmp(argv[i], "-noauth") == 0) 
+ 	    noauth++;
+ 	else if (strcmp(argv[i], "-zsubs") == 0)
+ 	    zsubs++;
+ 	else if (strcmp(argv[i], "-hosts") == 0)
+ 	    hosts++;
+ 	else if (strcmp(argv[i], "-noprdb") == 0)
+ 	    noprdb++;
+ 	else if (strcmp(argv[i], "-linked") == 0)
+ 		linked++;
+ 	else if (strcmp(argv[i], "-force") == 0)
+ 	    force++;
+     else if (strcmp(argv[i], "-setpag") == 0)
+ 	    afssetpag++;
+ 	else if (((strcmp(argv[i], "-cell") == 0) ||
+ 		  (strcmp(argv[i], "-c") == 0)) && !pmode)
+ 	    if (++i < argc) {
+ 		cmode++;
+ 		strcpy(cell, argv[i]);
+ 	    }
+ 	    else
+ 		usage();
+ 	else if (((strcmp(argv[i], "-path") == 0) ||
+ 		  (strcmp(argv[i], "-p") == 0)) && !cmode)
+ #ifndef WINDOWS
+ 	    if (++i < argc) {
+ 		pmode++;
+ 		strcpy(path, argv[i]);
+ 	    }
+ 	    else
+ 		usage();
+ #else /* WINDOWS */
+ 	{
+ 	    sprintf(msgbuf, "%s: path mode not supported.\n", progname);
+ 	    params.pstderr(msgbuf);
+ 	    params.exitprog(AKLOG_MISC);
+ 	}
+ #endif /* WINDOWS */
+ 	    
+ 	else if (argv[i][0] == '-')
+ 	    usage();
+ 	else if (!pmode && !cmode) {
+ 	    if (strchr(argv[i], DIR) || (strcmp(argv[i], ".") == 0) ||
+ 		(strcmp(argv[i], "..") == 0)) {
+ #ifndef WINDOWS
+ 		pmode++;
+ 		strcpy(path, argv[i]);
+ #else /* WINDOWS */
+ 		sprintf(msgbuf, "%s: path mode not supported.\n", progname);
+ 		params.pstderr(msgbuf);
+ 		params.exitprog(AKLOG_MISC);
+ #endif /* WINDOWS */
+ 	    }
+ 	    else { 
+ 		cmode++;
+ 		strcpy(cell, argv[i]);
+ 	    }
+ 	}
+ 	else
+ 	    usage();
+ 
+ 	if (cmode) {
+ 	    if (((i + 1) < argc) && (strcmp(argv[i + 1], "-k") == 0)) {
+ 		i+=2;
+ 		if (i < argc)
+ 		    strcpy(realm, argv[i]);
+ 		else
+ 		    usage();
+ 	    }
+ 	    /* Add this cell to list of cells */
+ 	    strcpy(cellinfo.cell, cell);
+ 	    strcpy(cellinfo.realm, realm);
+ 	    if ((cur_node = ll_add_node(&cells, ll_tail))) {
+ 		char *new_cellinfo;
+ 		if ((new_cellinfo = copy_cellinfo(&cellinfo)))
+ 		    ll_add_data(cur_node, new_cellinfo);
+ 		else {
+ 		    sprintf(msgbuf, 
+ 			    "%s: failure copying cellinfo.\n", progname);
+ 		    params.pstderr(msgbuf);
+ 		    params.exitprog(AKLOG_MISC);
+ 		}
+ 	    }
+ 	    else {
+ 		sprintf(msgbuf, "%s: failure adding cell to cells list.\n",
+ 			progname);
+ 		params.pstderr(msgbuf);
+ 		params.exitprog(AKLOG_MISC);
+ 	    }
+ 	    memset(&cellinfo, 0, sizeof(cellinfo));
+ 	    cmode = FALSE;
+ 	    memset(cell, 0, sizeof(cell));
+ 	    memset(realm, 0, sizeof(realm));
+ 	}
+ #ifndef WINDOWS
+ 	else if (pmode) {
+ 	    /* Add this path to list of paths */
+ 	    if ((cur_node = ll_add_node(&paths, ll_tail))) {
+ 		char *new_path; 
+ 		if ((new_path = copy_string(path)))
+ 		    ll_add_data(cur_node, new_path);
+ 		else {
+ 		    sprintf(msgbuf, "%s: failure copying path name.\n",
+ 			    progname);
+ 		    params.pstderr(msgbuf);
+ 		    params.exitprog(AKLOG_MISC);
+ 		}
+ 	    }
+ 	    else {
+ 		sprintf(msgbuf, "%s: failure adding path to paths list.\n",
+ 			progname);
+ 		params.pstderr(msgbuf);
+ 		params.exitprog(AKLOG_MISC);
+ 	    }
+ 	    pmode = FALSE;
+ 	    memset(path, 0, sizeof(path));
+ 	}
+ #endif /* WINDOWS */
+     }
+ 
+     /*
+      * The code that _used_ to be here called setpag().  When you think
+      * about this, doing this makes no sense!  setpag() allocates a PAG
+      * only for the current process, so the token installed would have
+      * not be usable in the parent!  Since ktc_SetToken() now takes a
+      * 4th argument to control whether or not we're going to allocate
+      * a PAG (and since when you do it _that_ way, it modifies the cred
+      * structure of your parent)), why don't we use that instead?
+      */
+ 
+ #if 0
+     if (afssetpag) {
+ 	   status = setpag();
+ 	   if (dflag) { 
+ 	     int i,j;
+ 		 int gidsetlen = 50;
+          int gidset[50];
+ 
+ 		 printf("setpag %d\n",status);
+ 	     j = getgroups(gidsetlen,gidset);
+          printf("Groups(%d):",j);
+          for (i = 0; i<j; i++) {
+            printf("%d",gidset[i]);
+            if((i+1)<j) printf(",");
+          }
+          printf("\n");
+ 	   }
+ 	}
+ #endif
+     /* If nothing was given, log to the local cell. */
+     if ((cells.nelements + paths.nelements) == 0) {
+ 		struct passwd *pwd;
+ 
+ 		status = auth_to_cell(context, NULL, NULL);
+ 	
+ 	 	/* If this cell is linked to a DCE cell, and user 
+ 		 * requested -linked, get tokens for both 
+ 		 * This is very usefull when the AFS cell is linked to a DFS 
+ 	         * cell and this system does not also have DFS. 
+ 	         */
+ 
+ 		if (!status && linked && linkedcell[0]) {
+ 				strncpy(linkedcell2,linkedcell,MAXCELLCHARS);
+ 			    if (dflag) {
+ 			        sprintf(msgbuf, "Linked cell: %s\n",
+ 			            linkedcell);
+ 			        params.pstdout(msgbuf);
+ 			    }
+ 				status = auth_to_cell(context, linkedcell2, NULL);
+ 		}
+ 
+ #ifndef WINDOWS
+ 		/*
+ 		 * Local hack - if the person has a file in their home
+ 		 * directory called ".xlog", read that for a list of
+ 		 * extra cells to authenticate to
+ 		 */
+ 
+ 		if ((pwd = getpwuid(getuid())) != NULL) {
+ 		    struct stat sbuf;
+ 		    FILE *f;
+ 		    char fcell[100], xlog_path[512];
+ 
+ 		    strcpy(xlog_path, pwd->pw_dir);
+ 		    strcat(xlog_path, "/.xlog");
+ 
+ 		    if ((stat(xlog_path, &sbuf) == 0) &&
+ 			((f = fopen(xlog_path, "r")) != NULL)) {
+ 
+ 			if (dflag) {
+ 			    sprintf(msgbuf, "Reading %s for cells to "
+ 				    "authenticate to.\n", xlog_path);
+ 			    params.pstdout(msgbuf);
+ 			}
+ 
+ 			while (fgets(fcell, 100, f) != NULL) {
+ 			    int auth_status;
+ 
+ 			    fcell[strlen(fcell) - 1] = '\0';
+ 
+ 			    if (dflag) {
+ 				sprintf(msgbuf, "Found cell %s in %s.\n",
+ 					fcell, xlog_path);
+ 				params.pstdout(msgbuf);
+ 			    }
+ 
+ 			    auth_status = auth_to_cell(context, fcell, NULL);
+ 			    if (status == AKLOG_SUCCESS)
+ 				status = auth_status;
+ 			    else
+ 				status = AKLOG_SOMETHINGSWRONG;
+ 			}
+ 		    }
+ 		}
+ #endif /* WINDOWS */
+ 	}
+     else {
+ 	/* Log to all cells in the cells list first */
+ 	for (cur_node = cells.first; cur_node; cur_node = cur_node->next) {
+ 	    memcpy((char *)&cellinfo, cur_node->data, sizeof(cellinfo));
+ 	    if ((status = auth_to_cell(context, cellinfo.cell, cellinfo.realm)))
+ 		somethingswrong++;
+ 		else {
+ 			if (linked && linkedcell[0]) {
+ 				strncpy(linkedcell2,linkedcell,MAXCELLCHARS);
+                 if (dflag) {
+                     sprintf(msgbuf, "Linked cell: %s\n",
+                         linkedcell);
+                     params.pstdout(msgbuf);
+                 }
+ 				if ((status = auth_to_cell(context,linkedcell2,
+ 							 cellinfo.realm)))
+ 				somethingswrong++;
+ 			}
+ 		}
+ 	}
+ 	
+ #ifndef WINDOWS
+ 	/* Then, log to all paths in the paths list */
+ 	for (cur_node = paths.first; cur_node; cur_node = cur_node->next) {
+ 	    if ((status = auth_to_path(context, cur_node->data)))
+ 		somethingswrong++;
+ 	}
+ #endif /* WINDOWS */
+ 	
+ 	/* 
+ 	 * If only one thing was logged to, we'll return the status 
+ 	 * of the single call.  Otherwise, we'll return a generic
+ 	 * something failed status.
+ 	 */
+ 	if (somethingswrong && ((cells.nelements + paths.nelements) > 1))
+ 	    status = AKLOG_SOMETHINGSWRONG;
+     }
+ 
+     /* If we are keeping track of zephyr subscriptions, print them. */
+     if (zsubs) 
+ 	for (cur_node = zsublist.first; cur_node; cur_node = cur_node->next) {
+ 	    sprintf(msgbuf, "zsub: %s\n", cur_node->data);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 
+     /* If we are keeping track of host information, print it. */
+     if (hosts)
+ 	for (cur_node = hostlist.first; cur_node; cur_node = cur_node->next) {
+ 	    sprintf(msgbuf, "host: %s\n", cur_node->data);
+ 	    params.pstdout(msgbuf);
+ 	}
+ 
+     params.exitprog(status);
+ }
Index: openafs/src/aklog/aklog_param.c
diff -c /dev/null openafs/src/aklog/aklog_param.c:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/aklog_param.c	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,218 ----
+ /* 
+  * $Id: aklog_param.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $
+  * 
+  * Copyright 1990,1991 by the Massachusetts Institute of Technology
+  * For distribution and copying rights, see the file "mit-copyright.h"
+  */
+ 
+ #if !defined(lint) && !defined(SABER)
+ static char *rcsid = "$Id: aklog_param.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint || SABER */
+ 
+ #include "aklog.h"
+ #include <stdio.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
+ #include <string.h>
+ #ifdef HAVE_UNISTD_H
+ #include <unistd.h>
+ #endif
+ #ifdef HAVE_MEMORY_H
+ #include <memory.h>
+ #endif
+ #ifdef HAVE_STDLIB_H
+ #include <stdlib.h>
+ #endif
+ #ifdef HAVE_MALLOC_H
+ #include <malloc.h>
+ #endif
+ #include <kerberosIV/krb.h>
+ #include <krb5.h>
+ 
+ 
+ #ifndef TRUE
+ #define TRUE 1
+ #endif
+ 
+ #ifndef FALSE
+ #define FALSE 0
+ #endif
+ 
+ #ifndef WINDOWS
+ #if !defined(HAVE_UNISTD_H) || (defined(__sun__) && ! defined(__svr4__))
+ extern int readlink ARGS((char *, char *, size_t));
+ #endif
+ /* extern int lstat ARGS((char *, struct stat *)); */
+ extern char *getwd ARGS((char *));
+ #endif /* WINDOWS */
+ 
+ static krb5_ccache  _krb425_ccache = 0;
+ 
+ #ifndef WINDOWS		/* Don't have lstat() */
+ #ifdef __STDC__
+ static int isdir(char *path, unsigned char *val)
+ #else
+ static int isdir(path, val)
+   char *path;
+   unsigned char *val;
+ #endif /* __STDC__ */
+ {
+     struct stat statbuf;
+ 
+     if (lstat(path, &statbuf) < 0)
+ 	return (-1);
+     else {
+ 	if ((statbuf.st_mode & S_IFMT) == S_IFDIR) 
+ 	    *val = TRUE;
+ 	else
+ 	    *val = FALSE;
+ 	return (0);
+     }  
+ }
+ #endif /* WINDOWS */
+ 
+ #ifdef __STDC__
+ static int get_cred(krb5_context context, 
+ 			char *name, char *inst, char *realm, CREDENTIALS *c,
+ 			krb5_creds **creds)
+ #else
+ static int get_cred(context, name, inst, realm, c, creds)
+   krb5_context context;
+   char *name;
+   char *inst;
+   char *realm;
+   CREDENTIALS *c;
+   krb5_creds **creds;
+ #endif /* __STDC__ */
+ {
+     krb5_creds increds;
+     krb5_error_code r;
+     static krb5_principal client_principal = 0;
+ 
+     memset((char *)&increds, 0, sizeof(increds));
+ /* ANL - instance may be ptr to a null string. Pass null then */
+     if ((r = krb5_build_principal(context, &increds.server,
+                      strlen(realm), realm,
+                      name,
+            (inst && strlen(inst)) ? inst : (void *) NULL,
+                      (void *) NULL))) {
+         return((int)r);
+     }
+ 
+     if (!_krb425_ccache)
+         krb5_cc_default(context, &_krb425_ccache);
+     if (!client_principal)
+         krb5_cc_get_principal(context, _krb425_ccache, &client_principal);
+ 
+     increds.client = client_principal;
+     increds.times.endtime = 0;
+ 	/* Ask for DES since that is what V4 understands */
+     /* increds.keyblock.enctype = ENCTYPE_DES_CBC_CRC; */
+ 
+     r = krb5_get_credentials(context, 0, _krb425_ccache, &increds, creds);
+     if (r)
+         return((int)r);
+ 
+ /*       This requires krb524d to be running with the KDC */
+     r = krb5_524_convert_creds(context, *creds, c);
+     return((int)r);
+ }
+ 
+ 
+ #ifdef __STDC__
+ static int get_user_realm(krb5_context context,char *realm)
+ #else
+ static int get_user_realm(context, realm)
+   krb5_context context;
+   char *realm;
+ 
+ #endif /* __STDC__ */
+ {
+     static krb5_principal client_principal = 0;
+     int i;
+ 
+     if (!_krb425_ccache)
+         krb5_cc_default(context, &_krb425_ccache);
+     if (!client_principal)
+         krb5_cc_get_principal(context, _krb425_ccache, &client_principal);
+ 
+     i = krb5_princ_realm(context, client_principal)->length;
+     if (i > REALM_SZ-1) i = REALM_SZ-1;
+     strncpy(realm,krb5_princ_realm(context, client_principal)->data,i);
+     realm[i] = 0;
+     return(KSUCCESS);
+ }
+ 
+ 
+ #ifndef WINDOWS
+ 
+ #ifdef __STDC__
+ static void pstderr(char *string)
+ #else
+ static void pstderr(string)
+   char *string;
+ #endif /* __STDC__ */
+ {
+     write(2, string, strlen(string));
+ }
+ 
+ 
+ #ifdef __STDC__
+ static void pstdout(char *string)
+ #else
+ static void pstdout(string)
+   char *string;
+ #endif /* __STDC__ */
+ {
+     write(1, string, strlen(string));
+ }
+ 
+ #else /* WINDOWS */
+ 
+ static void pstderr(char *string)
+ {
+     if (_isatty(_fileno(stderr)))
+ 	fprintf(stderr, "%s\r\n", string);
+     else
+ 	MessageBox(NULL, string, AKLOG_DIALOG_NAME, MB_OK | MB_ICONSTOP);
+ }
+ 
+ static void pstdout(char *string)
+ {
+     if (_isatty(_fileno(stdout)))
+ 	fprintf(stdout, "%s\r\n", string);
+     else
+ 	MessageBox(NULL, string, AKLOG_DIALOG_NAME, MB_OK);
+ }
+ 
+ #endif /* WINDOWS */
+ 
+ #ifdef __STDC__
+ static void exitprog(char status)
+ #else
+ static void exitprog(status)
+   char status;
+ #endif /* __STDC__ */
+ {
+     exit(status);
+ }
+ 
+ 
+ #ifdef __STDC__
+ void aklog_init_params(aklog_params *params)
+ #else
+ void aklog_init_params(params)
+   aklog_params *params;
+ #endif /* __STDC__ */
+ {
+ #ifndef WINDOWS
+     params->readlink = readlink;
+     params->isdir = isdir;
+     params->getwd = getwd;
+ #endif
+     params->get_cred = get_cred;
+     params->get_user_realm = get_user_realm;
+     params->pstderr = pstderr;
+     params->pstdout = pstdout;
+     params->exitprog = exitprog;
+ }
Index: openafs/src/aklog/krb_util.c
diff -c /dev/null openafs/src/aklog/krb_util.c:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/krb_util.c	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,60 ----
+ /*
+  * This file replaces some of the routines in the Kerberos utilities.
+  * It is based on the Kerberos library modules:
+  * 	send_to_kdc.c
+  * 
+  * Copyright 1987, 1988, 1992 by the Massachusetts Institute of Technology.
+  *
+  * For copying and distribution information, please see the file
+  * <mit-copyright.h>.
+  */
+ 
+ #ifndef lint
+ static char rcsid_send_to_kdc_c[] =
+ "$Id: krb_util.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint */
+ 
+ #if 0
+ #include <kerberosIV/mit-copyright.h>
+ #endif
+ #include <krb5.h>
+ #include <kerberosIV/krb.h> 
+ 
+ #ifndef MAX_HSTNM
+ #define MAX_HSTNM 100
+ #endif
+ 
+ #ifdef WINDOWS
+ 
+ #include "aklog.h"		/* for struct afsconf_cell */
+ 
+ #else /* !WINDOWS */
+ 
+ #include <afs/param.h>
+ #include <afs/cellconfig.h>
+ 
+ #endif /* WINDOWS */
+ 
+ #define S_AD_SZ sizeof(struct sockaddr_in)
+ 
+ char *afs_realm_of_cell(context, cellconfig)
+     krb5_context context;
+     struct afsconf_cell *cellconfig;
+ {
+     char krbhst[MAX_HSTNM];
+     static char krbrlm[REALM_SZ+1];
+ 	char **hrealms = 0;
+ 	krb5_error_code retval;
+ 
+     if (!cellconfig)
+ 	return 0;
+     if (retval = krb5_get_host_realm(context,
+ 				cellconfig->hostName[0], &hrealms))
+ 		return 0; 
+ 	if(!hrealms[0]) return 0;
+ 	strcpy(krbrlm, hrealms[0]);
+ 
+ 	if (hrealms) krb5_free_host_realm(context, hrealms);
+     
+     return krbrlm;
+ }
Index: openafs/src/aklog/linked_list.c
diff -c /dev/null openafs/src/aklog/linked_list.c:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/linked_list.c	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,212 ----
+ /* 
+  * $Id: linked_list.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $
+  * 
+  * This file contains general linked list routines.
+  * 
+  * Copyright 1990,1991 by the Massachusetts Institute of Technology
+  * For distribution and copying rights, see the file "mit-copyright.h"
+  */
+ 
+ #if !defined(lint) && !defined(SABER)
+ static char *rcsid_list_c = "$Id: linked_list.c,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint || SABER */
+ 
+ #include <stdio.h>
+ #include "linked_list.h"
+ 
+ #ifndef NULL
+ #define NULL 0
+ #endif
+ 
+ #ifndef TRUE
+ #define TRUE 1
+ #endif
+ 
+ #ifndef FALSE
+ #define FALSE 0
+ #endif
+ 
+ char *calloc();
+ 
+ #ifdef __STDC__
+ void ll_init(linked_list *list)
+   /* 
+    * Requires:
+    *   List must point to a linked list structure.  It is not acceptable
+    *   to pass a null pointer to this routine.
+    * Modifies:
+    *   list
+    * Effects:
+    *   Initializes the list to be one with no elements.  If list is
+    *   NULL, prints an error message and causes the program to crash.
+    */
+ #else
+ void ll_init(list)
+   linked_list *list;
+ #endif /* __STDC__ */
+ {
+     if (list == NULL) {
+ 	fprintf(stderr, "Error: calling ll_init with null pointer.\n");
+ 	abort();
+     }
+ 
+     /* This sets everything to zero, which is what we want. */
+ #ifdef WINDOWS
+ 	memset(list, 0, sizeof(linked_list));
+ #else
+     bzero((char *)list, sizeof(linked_list));
+ #endif /* WINDOWS */
+ }
+ 
+ #ifdef __STDC__
+ ll_node *ll_add_node(linked_list *list, ll_end which_end)
+   /*
+    * Modifies:
+    *   list
+    * Effects: 
+    *   Adds a node to one end of the list (as specified by which_end)
+    *   and returns a pointer to the node added.  which_end is of type
+    *   ll_end and should be either ll_head or ll_tail as specified in 
+    *   list.h.  If there is not enough memory to allocate a node, 
+    *   the program returns NULL.
+    */
+ #else
+ ll_node *ll_add_node(list, which_end)
+   linked_list *list;
+   ll_end which_end;
+ #endif /* __STDC__ */
+ {
+     ll_node *node = NULL;
+     
+     if ((node = (ll_node *)calloc(1, sizeof(ll_node))) != NULL) {
+ 	if (list->nelements == 0) {
+ 	    list->first = node;
+ 	    list->last = node;
+ 	    list->nelements = 1;
+ 	}
+ 	else {
+ 	    switch (which_end) {
+ 	      case ll_head:
+ 		list->first->prev = node;
+ 		node->next = list->first;
+ 		list->first = node;
+ 		break;
+ 	      case ll_tail:
+ 		list->last->next = node;
+ 		node->prev = list->last;
+ 		list->last = node;
+ 		break;
+ 	      default:
+ 		fprintf(stderr, "%s%s",
+ 			"ll_add_node got a which_end parameter that ",
+ 			"it can't handle.\n");
+ 		abort();
+ 	    }
+ 	    list->nelements++;
+ 	}
+     }
+ 	
+     return(node);
+ }
+ 
+ 
+ #ifdef __STDC__
+ int ll_delete_node(linked_list *list, ll_node *node)
+   /* 
+    * Modifies: 
+    *   list
+    * Effects:
+    *   If node is in list, deletes node and returns LL_SUCCESS.  
+    *   Otherwise, returns LL_FAILURE.  If node contains other data,
+    *   it is the responsibility of the caller to free it.  Also, since
+    *   this routine frees node, after the routine is called, "node"
+    *   won't point to valid data.
+    */
+ #else
+ int ll_delete_node(list, node)
+   linked_list *list;
+   ll_node *node;
+ #endif /* __STDC__ */
+ {
+     int status = LL_SUCCESS;
+     ll_node *cur_node = NULL;
+     int found = FALSE;
+ 
+     if (list->nelements == 0)
+ 	status = LL_FAILURE;
+     else {
+ 	for (cur_node = list->first; (cur_node != NULL) && !found;
+ 	     cur_node = cur_node->next) {
+ 	    if (cur_node == node) {
+ 
+ 		if (cur_node->prev)
+ 		    cur_node->prev->next = cur_node->next;
+ 		else
+ 		    list->first = cur_node->next;
+ 
+ 		if (cur_node->next)
+ 		    cur_node->next->prev = cur_node->prev;
+ 		else
+ 		    list->last = cur_node->prev;
+ 
+ 		free(cur_node);
+ 		list->nelements--;
+ 		found = TRUE;
+ 	    }
+ 	}
+     }
+ 
+     if (!found)
+ 	status = LL_FAILURE;
+ 
+     return(status);
+ }
+ 
+ 
+ /* ll_add_data is a macro defined in linked_list.h */
+ 
+ /* This routine maintains a list of strings preventing duplication. */
+ #ifdef __STDC__
+ int ll_string(linked_list *list, ll_s_action action, char *string)
+ #else
+ int ll_string(list, action, string)
+   linked_list *list;
+   ll_s_action action;
+   char *string;
+ #endif /* __STDC__ */
+ {
+     int status = LL_SUCCESS;
+     ll_node *cur_node;
+ 
+     switch(action) {
+       case ll_s_check:
+ 	/* Scan the list until we find the string in question */
+ 	for (cur_node = list->first; cur_node && (status == FALSE); 
+ 	     cur_node = cur_node->next)
+ 	    status = (strcmp(string, cur_node->data) == 0);
+ 	break;
+       case ll_s_add:
+ 	/* Add a string to the list. */
+ 	if (!ll_string(list, ll_s_check, string)) {
+ 	    if (cur_node = ll_add_node(list, ll_tail)) {
+ 		char *new_string;
+ 		if (new_string = (char *)calloc(strlen(string) + 1, 
+ 						sizeof(char))) {
+ 		    strcpy(new_string, string);
+ 		    ll_add_data(cur_node, new_string);
+ 		}
+ 		else 
+ 		    status = LL_FAILURE;
+ 	    }
+ 	    else
+ 		status = LL_FAILURE;
+ 	}
+ 	break;
+       default:
+ 	/* This should never happen */
+ 	status = LL_FAILURE;
+ 	break;
+     }
+ 
+     return(status);
+ }
Index: openafs/src/aklog/linked_list.h
diff -c /dev/null openafs/src/aklog/linked_list.h:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/aklog/linked_list.h	Tue Dec  7 00:51:24 2004
***************
*** 0 ****
--- 1,59 ----
+ /* 
+  * $Id: linked_list.h,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $
+  *
+  * This is the header file for a general list linked package.
+  * 
+  * Copyright 1990,1991 by the Massachusetts Institute of Technology
+  * For distribution and copying rights, see the file "mit-copyright.h"
+  */
+ 
+ #ifndef __LINKED_LIST_H__
+ #define __LINKED_LIST_H__
+ 
+ #if !defined(lint) && !defined(SABER)
+ static char *rcsid_linked_list_h = "$Id: linked_list.h,v 1.1.2.1 2004/12/07 05:51:24 shadow Exp $";
+ #endif /* lint || SABER */
+ 
+ #define LL_SUCCESS 0
+ #define LL_FAILURE -1
+ 
+ typedef struct _ll_node {
+     struct _ll_node *prev;
+     struct _ll_node *next;
+     char *data;
+ } ll_node;
+ 
+ typedef struct {
+     ll_node *first;
+     ll_node *last;
+     int nelements;
+ } linked_list;
+ 
+ typedef enum {ll_head, ll_tail} ll_end;
+ typedef enum {ll_s_add, ll_s_check} ll_s_action;
+ 
+ 
+ /*
+  * ll_add_data just assigns the data field of node to be d.
+  * If this were c++, this would be an inline function and d
+  * would be a void *, but we'll take what we can get...
+  */
+ #define ll_add_data(n,d) (((n)->data)=(char*)(d))
+ 
+ #ifdef __STDC__
+ 
+ void ll_init(linked_list *list);
+ ll_node *ll_add_node(linked_list *list, ll_end which_end);
+ int ll_delete_node(linked_list *list, ll_node *node);
+ int ll_string(linked_list *, ll_s_action, char *);
+ 
+ #else /* __STDC__ */
+ 
+ void ll_init();
+ ll_node *ll_add_node();
+ int ll_delete_node();
+ int ll_string();
+ 
+ #endif /* __STDC__ */
+ 
+ #endif /* __LINKED_LIST_H__ */
Index: openafs/src/cf/linux-test1.m4
diff -c openafs/src/cf/linux-test1.m4:1.3 openafs/src/cf/linux-test1.m4:1.3.2.1
*** openafs/src/cf/linux-test1.m4:1.3	Thu Jun  3 01:13:29 2004
--- openafs/src/cf/linux-test1.m4	Tue Dec  7 01:12:14 2004
***************
*** 14,16 ****
--- 14,123 ----
  ac_cv_linux_func_inode_setattr_returns_int=no)])
  AC_MSG_RESULT($ac_cv_linux_func_inode_setattr_returns_int)
  CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_WRITE_INODE_RETURN_TYPE],[
+ AC_MSG_CHECKING(for write_inode return type)
+ 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_func_write_inode_returns_int,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>],
+ [struct inode _inode; 
+ struct super_operations _sops;
+ int i; 
+ i = _sops.write_inode(&_inode, 0);], 
+ ac_cv_linux_func_write_inode_returns_int=yes,
+ ac_cv_linux_func_write_inode_returns_int=no)])
+ AC_MSG_RESULT($ac_cv_linux_func_write_inode_returns_int)
+ CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_IOP_NAMEIDATA],[
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -I${LINUX_KERNEL_PATH}/include/asm/mach-${SUBARCH} -D__KERNEL__ $CPPFLAGS"
+ AC_MSG_CHECKING(whether inode_operations.create takes a nameidata)
+ AC_CACHE_VAL(ac_cv_linux_func_i_create_takes_nameidata,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>
+ #include <linux/namei.h>],
+ [struct inode _inode; 
+ struct dentry _dentry;
+ struct nameidata _nameidata;
+ (void)_inode.i_op->create(&_inode, &_dentry, 0, &_nameidata);],
+ ac_cv_linux_func_i_create_takes_nameidata=yes,
+ ac_cv_linux_func_i_create_takes_nameidata=no)])
+ AC_MSG_RESULT($ac_cv_linux_func_i_create_takes_nameidata)
+ if test "x$ac_cv_linux_func_i_create_takes_nameidata" = "xyes" ; then
+ AC_DEFINE(IOP_CREATE_TAKES_NAMEIDATA, 1, [define if your iops.create takes a nameidata argument])
+ fi
+ AC_MSG_CHECKING(whether inode_operations.lookup takes a nameidata)
+ AC_CACHE_VAL(ac_cv_linux_func_i_lookup_takes_nameidata,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>
+ #include <linux/namei.h>],
+ [struct inode _inode; 
+ struct dentry _dentry;
+ struct nameidata _nameidata;
+ (void)_inode.i_op->lookup(&_inode, &_dentry, &_nameidata);],
+ ac_cv_linux_func_i_lookup_takes_nameidata=yes,
+ ac_cv_linux_func_i_lookup_takes_nameidata=no)])
+ AC_MSG_RESULT($ac_cv_linux_func_i_lookup_takes_nameidata)
+ if test "x$ac_cv_linux_func_i_lookup_takes_nameidata" = "xyes" ; then
+ AC_DEFINE(IOP_LOOKUP_TAKES_NAMEIDATA, 1, [define if your iops.lookup takes a nameidata argument])
+ fi
+ AC_MSG_CHECKING(whether inode_operations.permission takes a nameidata)
+ AC_CACHE_VAL(ac_cv_linux_func_i_permission_takes_nameidata,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>
+ #include <linux/namei.h>],
+ [struct inode _inode; 
+ struct nameidata _nameidata;
+ (void)_inode.i_op->permission(&_inode, 0, &_nameidata);],
+ ac_cv_linux_func_i_permission_takes_nameidata=yes,
+ ac_cv_linux_func_i_permission_takes_nameidata=no)])
+ AC_MSG_RESULT($ac_cv_linux_func_i_permission_takes_nameidata)
+ if test "x$ac_cv_linux_func_i_permission_takes_nameidata" = "xyes" ; then
+ AC_DEFINE(IOP_PERMISSION_TAKES_NAMEIDATA, 1, [define if your iops.permission takes a nameidata argument])
+ fi
+ AC_MSG_CHECKING(whether dentry_operations.d_revalidate takes a nameidata)
+ CPPFLAGS="$CPPFLAGS -Werror"
+ AC_CACHE_VAL(ac_cv_linux_func_d_revalidate_takes_nameidata,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>
+ #include <linux/namei.h>],
+ [struct dentry _dentry; 
+ struct nameidata _nameidata;
+ (void)_dentry.d_op->d_revalidate(&_dentry, &_nameidata);],
+ ac_cv_linux_func_d_revalidate_takes_nameidata=yes,
+ ac_cv_linux_func_d_revalidate_takes_nameidata=no)])
+ AC_MSG_RESULT($ac_cv_linux_func_d_revalidate_takes_nameidata)
+ if test "x$ac_cv_linux_func_d_revalidate_takes_nameidata" = "xyes" ; then
+   AC_DEFINE(DOP_REVALIDATE_TAKES_NAMEIDATA, 1, [define if your dops.d_revalidate takes a nameidata argument])
+ fi
+ CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_AOP_WRITEBACK_CONTROL],[
+ save_CPPFLAGS="$CPPFLAGS"
+ CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -I${LINUX_KERNEL_PATH}/include/asm/mach-${SUBARCH} -D__KERNEL__ $CPPFLAGS"
+ AC_MSG_CHECKING(whether address_space_operations.writepage takes a writeback_control)
+ AC_CACHE_VAL(ac_cv_linux_func_a_writepage_takes_writeback_control,
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>
+ #include <linux/mm.h>
+ #include <linux/writeback.h>],
+ [struct address_space_operations _aops; 
+ struct page _page;
+ struct writeback_control _writeback_control;
+ (void)_aops.writepage(&_page, &_writeback_control);],
+ ac_cv_linux_func_a_writepage_takes_writeback_control=yes,
+ ac_cv_linux_func_a_writepage_takes_writeback_control=no)])
+ AC_MSG_RESULT($ac_cv_linux_func_a_writepage_takes_writeback_control)
+ if test "x$ac_cv_linux_func_a_writepage_takes_writeback_control" = "xyes" ; then
+ AC_DEFINE(AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL, 1, [define if your aops.writepage takes a struct writeback_control argument])
+ fi
+ CPPFLAGS="$save_CPPFLAGS"])
Index: openafs/src/cf/linux-test3.m4
diff -c openafs/src/cf/linux-test3.m4:1.8.2.2 openafs/src/cf/linux-test3.m4:1.8.2.3
*** openafs/src/cf/linux-test3.m4:1.8.2.2	Sat Oct  9 01:05:06 2004
--- openafs/src/cf/linux-test3.m4	Tue Dec  7 01:05:44 2004
***************
*** 45,51 ****
  [#include <linux/version.h>
  #include <linux/config.h>
  ],
! [#if !defined(CONFIG_MODVERSIONS) || (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0))
  lose;
  #endif
  ],
--- 45,51 ----
  [#include <linux/version.h>
  #include <linux/config.h>
  ],
! [#if !defined(CONFIG_MODVERSIONS)
  lose;
  #endif
  ],
***************
*** 53,59 ****
    ac_cv_linux_config_modversions=no)])
    AC_MSG_RESULT($ac_cv_linux_config_modversions)
    AC_MSG_CHECKING(which kernel modules to build)
!   if test "x$ac_linux_rhconfig" = "xyes" -o "x$ac_cv_linux_config_modversions" = "xno"; then
        MPS="MP SP"
    else
    AC_CACHE_VAL(ac_cv_linux_config_smp, [
--- 53,61 ----
    ac_cv_linux_config_modversions=no)])
    AC_MSG_RESULT($ac_cv_linux_config_modversions)
    AC_MSG_CHECKING(which kernel modules to build)
!   if test "x$ac_linux_rhconfig" = "xyes"; then
!       MPS="MP SP"
!   elif test "x$ac_cv_linux_config_modversions" = "xno" -a "$AFS_SYSKVERS" -lt 26; then
        MPS="MP SP"
    else
    AC_CACHE_VAL(ac_cv_linux_config_smp, [
Index: openafs/src/cf/osconf.m4
diff -c openafs/src/cf/osconf.m4:1.51.2.5 openafs/src/cf/osconf.m4:1.51.2.7
*** openafs/src/cf/osconf.m4:1.51.2.5	Tue Nov  9 12:19:55 2004
--- openafs/src/cf/osconf.m4	Tue Dec  7 01:08:42 2004
***************
*** 195,201 ****
  		YACC="byacc"
  		;;
  
! 	*nbsd20)
  		LEX="flex -l"
  		MT_CFLAGS='${XCFLAGS} -DAFS_PTHREAD_ENV -D_REENTRANT '
  		MT_LIBS="-lpthread" # XXX -pthread soon
--- 195,201 ----
  		YACC="byacc"
  		;;
  
! 	*nbsd2*)
  		LEX="flex -l"
  		MT_CFLAGS='${XCFLAGS} -DAFS_PTHREAD_ENV -D_REENTRANT '
  		MT_LIBS="-lpthread" # XXX -pthread soon
***************
*** 324,329 ****
--- 324,349 ----
  		SHLIB_LINKER="${MT_CC} -shared"
  		;;
  
+ 	i386_umlinux26)
+ 		CC="gcc -pipe"
+ 		CCOBJ="gcc -pipe"
+ 		MT_CC="gcc -pipe"
+ 		KERN_OPTMZ=-O2
+ 		LEX="flex -l"
+ 		MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}'
+ 		MT_LIBS="-lpthread"
+ 		DBG=-g
+ 		KERN_DBG=-g
+ 		LWP_DBG=-g
+ 		LWP_OPTMZ=-O2
+ 		OPTMZ=-O2
+ 		PAM_CFLAGS="-g -O2 -Dlinux -DLINUX_PAM -fPIC"
+ 		SHLIB_LDFLAGS="-shared -Xlinker -x"
+ 		TXLIBS="-lncurses"
+ 		XCFLAGS="-g -O2 -D_LARGEFILE64_SOURCE"
+ 		SHLIB_LINKER="${MT_CC} -shared"
+ 		;;
+ 
  	*_obsd*)
  		LEX="flex -l"
  		MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}'
Index: openafs/src/comerr/Makefile.in
diff -c openafs/src/comerr/Makefile.in:1.10 openafs/src/comerr/Makefile.in:1.10.2.1
*** openafs/src/comerr/Makefile.in:1.10	Sat Jan 11 02:34:03 2003
--- openafs/src/comerr/Makefile.in	Tue Dec  7 01:08:45 2004
***************
*** 15,21 ****
  
  compile_et:	compile_et.o error_table.o
  	case $(SYS_NAME) in \
! 	*_linux* ) \
  	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -L${TOP_LIBDIR} -lafsutil;; \
  	* ) \
  	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -L${TOP_LIBDIR} -lafsutil -ll;; \
--- 15,21 ----
  
  compile_et:	compile_et.o error_table.o
  	case $(SYS_NAME) in \
! 	*_linux* | *_umlinux* ) \
  	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -L${TOP_LIBDIR} -lafsutil;; \
  	* ) \
  	${CC} ${CFLAGS} -o compile_et compile_et.o error_table.o -L${TOP_LIBDIR} -lafsutil -ll;; \
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.46.2.9 openafs/src/config/NTMakefile.i386_nt40:1.46.2.12
*** openafs/src/config/NTMakefile.i386_nt40:1.46.2.9	Tue Nov  9 12:09:08 2004
--- openafs/src/config/NTMakefile.i386_nt40	Wed Dec  8 04:12:09 2004
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=7400
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
--- 80,86 ----
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=7500
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
Index: openafs/src/config/NTVersioninfo.rc
diff -c openafs/src/config/NTVersioninfo.rc:1.4 openafs/src/config/NTVersioninfo.rc:1.4.2.1
*** openafs/src/config/NTVersioninfo.rc:1.4	Thu Jun 19 15:02:26 2003
--- openafs/src/config/NTVersioninfo.rc	Tue Dec  7 00:55:57 2004
***************
*** 24,30 ****
      /* Internalname and originalfilename must be specified or explorer won't
         show version and description */
      BEGIN
!         BLOCK "040904E4"
          BEGIN
              VALUE "CompanyName",        "OpenAFS Project", "\0"
              VALUE "LegalCopyright",     "Copyright \251 IBM Corporation and others, 1998, 1999, 2000, 2001, 2002, 2003.", "\0"
--- 24,30 ----
      /* Internalname and originalfilename must be specified or explorer won't
         show version and description */
      BEGIN
!         BLOCK "000004E4"
          BEGIN
              VALUE "CompanyName",        "OpenAFS Project", "\0"
              VALUE "LegalCopyright",     "Copyright \251 IBM Corporation and others, 1998, 1999, 2000, 2001, 2002, 2003.", "\0"
Index: openafs/src/config/afs_args.h
diff -c openafs/src/config/afs_args.h:1.13 openafs/src/config/afs_args.h:1.13.2.1
*** openafs/src/config/afs_args.h:1.13	Thu Jul  8 01:35:27 2004
--- openafs/src/config/afs_args.h	Tue Dec  7 00:50:12 2004
***************
*** 180,185 ****
--- 180,186 ----
  #define PROC_SYSCALL_NAME "afs_ioctl"
  #define PROC_SYSCALL_FNAME "/proc/fs/openafs/afs_ioctl"
  #define PROC_SYSCALL_ARLA_FNAME "/proc/fs/nnpfs/afs_ioctl"
+ #define PROC_CELLSERVDB_NAME "CellServDB"
  #define VIOC_SYSCALL_TYPE 'C' 
  #define VIOC_SYSCALL _IOW(VIOC_SYSCALL_TYPE,1,void *)
   
Index: openafs/src/config/afs_sysnames.h
diff -c openafs/src/config/afs_sysnames.h:1.50.2.3 openafs/src/config/afs_sysnames.h:1.50.2.5
*** openafs/src/config/afs_sysnames.h:1.50.2.3	Tue Nov  9 12:19:58 2004
--- openafs/src/config/afs_sysnames.h	Tue Dec  7 01:08:46 2004
***************
*** 196,201 ****
--- 196,202 ----
  #define SYS_NAME_ID_sparc_nbsd20	2522
  #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_obsd31		2600
  #define SYS_NAME_ID_i386_obsd32		2601
***************
*** 212,217 ****
--- 213,219 ----
  #define SYS_NAME_ID_i386_umlinux2	2800
  #define SYS_NAME_ID_i386_umlinux22	2801
  #define SYS_NAME_ID_i386_umlinux24	2802
+ #define SYS_NAME_ID_i386_umlinux26	2803
  
  #define SYS_NAME_ID_ppc64_linux2	2900
  #define SYS_NAME_ID_ppc64_linux22	2901
Index: openafs/src/config/param.amd64_linux26.h
diff -c openafs/src/config/param.amd64_linux26.h:1.1.2.1 openafs/src/config/param.amd64_linux26.h:1.1.2.2
*** openafs/src/config/param.amd64_linux26.h:1.1.2.1	Mon Oct 18 03:11:54 2004
--- openafs/src/config/param.amd64_linux26.h	Tue Dec  7 01:09:26 2004
***************
*** 19,24 ****
--- 19,25 ----
  #define AFS_AMD64_LINUX22_ENV   1
  #define AFS_AMD64_LINUX24_ENV   1
  #define AFS_AMD64_LINUX26_ENV   1
+ #define AFS_LINUX_64BIT_KERNEL 1
  #define AFS_NONFSTRANS 1
  
  #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
Index: openafs/src/config/param.i386_nbsd21.h
diff -c /dev/null openafs/src/config/param.i386_nbsd21.h:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/config/param.i386_nbsd21.h	Tue Dec  7 00:56:52 2004
***************
*** 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_nbsd21"
+ #define SYS_NAME_ID    SYS_NAME_ID_i386_nbsd21
+ 
+ #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.i386_umlinux26.h
diff -c /dev/null openafs/src/config/param.i386_umlinux26.h:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/config/param.i386_umlinux26.h	Tue Dec  7 01:08:46 2004
***************
*** 0 ****
--- 1,152 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ /* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel,
+  * it's a judgment call. If something is obviously i386 specific, use that
+  * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2"
+  * in the sysname is the current version of the client. This takes into
+  * account the perferred OS user space configuration as well as the kernel.
+  */
+ 
+ #define AFS_LINUX20_ENV        1
+ #define AFS_LINUX22_ENV        1
+ #define AFS_LINUX24_ENV        1
+ #define AFS_LINUX26_ENV        1
+ #define AFS_I386_LINUX20_ENV   1
+ #define AFS_I386_LINUX22_ENV   1
+ #define AFS_I386_LINUX24_ENV   1
+ #define AFS_I386_LINUX26_ENV   1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 137
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ #define AFS_64BIT_ENV		1
+ #define AFS_64BIT_CLIENT	1
+ 
+ #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
+ #include <linux/threads.h>
+ 
+ #include <linux/config.h>
+ #ifdef CONFIG_SMP
+ #ifndef AFS_SMP
+ #define AFS_SMP 1
+ #endif
+ #endif
+ /* Using "AFS_SMP" to map to however many #define's are required to get
+  * MP to compile for Linux
+  */
+ #ifdef AFS_SMP
+ #ifndef CONFIG_SMP
+ #define CONFIG_SMP 1
+ #endif
+ #ifndef CONFIG_X86_LOCAL_APIC
+ #define CONFIG_X86_LOCAL_APIC 1
+ #endif
+ #ifndef __SMP__
+ #define __SMP__
+ #endif
+ #define AFS_GLOBAL_SUNLOCK
+ #endif
+ 
+ #endif /* __KERNEL__  && !DUMP_KERNEL */
+ 
+ #include <afs/afs_sysnames.h>
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS       2	/* Set to Userdisabled, allow sysctl to override */
+ 
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV            1	/* read/write implemented via VM */
+ 
+ #ifdef KERNEL
+ #ifndef MIN
+ #define MIN(A,B) ((A) < (B) ? (A) : (B))
+ #endif
+ #ifndef MAX
+ #define MAX(A,B) ((A) > (B) ? (A) : (B))
+ #endif
+ #endif /* KERNEL */
+ 
+ #ifndef KERNEL
+ #define __USE_LARGEFILE64 1
+ #if !defined off64_t
+ #define off64_t __off64_t
+ #endif
+ #endif
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME       "i386_umlinux26"
+ #define SYS_NAME_ID    SYS_NAME_ID_i386_umlinux26
+ 
+ #endif /* AFS_PARAM_H */
+ 
+ 
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ /* In user space the AFS_LINUX20_ENV should be sufficient. In the kernel,
+  * it's a judgment call. If something is obviously i386 specific, use that
+  * #define instead. Note that "20" refers to the linux 2.0 kernel. The "2"
+  * in the sysname is the current version of the client. This takes into
+  * account the perferred OS user space configuration as well as the kernel.
+  */
+ 
+ #define UKERNEL                        1	/* user space kernel */
+ #define AFS_ENV                        1
+ #define AFS_USR_LINUX20_ENV    1
+ #define AFS_USR_LINUX22_ENV    1
+ #define AFS_USR_LINUX24_ENV    1
+ #define AFS_USR_LINUX26_ENV    1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 137
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS             0	/* if nonzero, garbage collect PAGs */
+ 
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME       "i386_umlinux26"
+ #define SYS_NAME_ID    SYS_NAME_ID_i386_umlinux26
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV            1	/* read/write implemented via VM */
+ 
+ #define        afsio_iov       uio_iov
+ #define        afsio_iovcnt    uio_iovcnt
+ #define        afsio_offset    uio_offset
+ #define        afsio_seg       uio_segflg
+ #define        afsio_fmode     uio_fmode
+ #define        afsio_resid     uio_resid
+ #define        AFS_UIOSYS      1
+ #define        AFS_UIOUSER     UIO_USERSPACE
+ #define        AFS_CLBYTES     MCLBYTES
+ #define        AFS_MINCHANGE   2
+ #define        VATTR_NULL      usr_vattr_null
+ 
+ #define AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #endif /* AFS_PARAM_H */
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/config/param.nbsd21.h
diff -c /dev/null openafs/src/config/param.nbsd21.h:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:04 2004
--- openafs/src/config/param.nbsd21.h	Tue Dec  7 00:56:52 2004
***************
*** 0 ****
--- 1,162 ----
+ /* 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)
+ #if __NetBSD_Version__ >= 200040000
+ #define AFS_HAVE_STATVFS    1	/* System supports statvfs */
+ #else
+ #define AFS_HAVE_STATVFS    0	/* System doesn't supports statvfs */
+ #endif
+ #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.sun4x_510.h
diff -c openafs/src/config/param.sun4x_510.h:1.2 openafs/src/config/param.sun4x_510.h:1.2.2.1
*** openafs/src/config/param.sun4x_510.h:1.2	Sun Aug  8 14:14:08 2004
--- openafs/src/config/param.sun4x_510.h	Tue Dec  7 13:30:42 2004
***************
*** 23,29 ****
--- 23,35 ----
  #define AFS_SUN510_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ /*
+  * Only define on 64 bit kernel, until problems with 32 bit
+  * and large file support are resolved
+  */
+ #if defined(__sparcv9)
  #define AFS_64BIT_CLIENT	1	
+ #endif
  
  #define AFS_HAVE_FLOCK_SYSID	1
  
Index: openafs/src/config/param.sun4x_58.h
diff -c openafs/src/config/param.sun4x_58.h:1.11 openafs/src/config/param.sun4x_58.h:1.11.2.1
*** openafs/src/config/param.sun4x_58.h:1.11	Sun Aug  8 14:14:08 2004
--- openafs/src/config/param.sun4x_58.h	Tue Dec  7 13:30:42 2004
***************
*** 21,27 ****
--- 21,33 ----
  #define AFS_SUN58_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ /*
+  * Only define on 64 bit kernel, until problems with 32 bit
+  * and large file support are resolved
+  */
+ #if defined(__sparcv9)
  #define AFS_64BIT_CLIENT	1	
+ #endif
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
Index: openafs/src/config/param.sun4x_59.h
diff -c openafs/src/config/param.sun4x_59.h:1.5 openafs/src/config/param.sun4x_59.h:1.5.2.1
*** openafs/src/config/param.sun4x_59.h:1.5	Sun Aug  8 14:14:08 2004
--- openafs/src/config/param.sun4x_59.h	Tue Dec  7 13:30:42 2004
***************
*** 22,28 ****
--- 22,34 ----
  #define AFS_SUN59_ENV		1
  
  #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
+ /*
+  * Only define on 64 bit kernel, until problems with 32 bit
+  * and large file support are resolved
+  */
+ #if defined(__sparcv9)
  #define AFS_64BIT_CLIENT	1	
+ #endif
  
  #define AFS_HAVE_FLOCK_SYSID    1
  
Index: openafs/src/des/Makefile.in
diff -c openafs/src/des/Makefile.in:1.11.2.2 openafs/src/des/Makefile.in:1.11.2.3
*** openafs/src/des/Makefile.in:1.11.2.2	Mon Oct 18 13:43:56 2004
--- openafs/src/des/Makefile.in	Tue Dec  7 00:49:33 2004
***************
*** 85,96 ****
  make_s:	make_s.o misc.o main.o 
  	${CC} make_s.o misc.o main.o ${LDFLAGS} -o make_s
  
! crypt.o: crypt.c
  	case ${SYS_NAME} in \
  	rs_aix*)\
! 		${CCOBJ} -c ${COMMON_INCL} -o crypt.o crypt.c ;;\
  	*)\
! 		${CCOBJ} -c ${CFLAGS} -o crypt.o crypt.c ;;\
  	esac
  #
  # Table/code generation targets
--- 85,96 ----
  make_s:	make_s.o misc.o main.o 
  	${CC} make_s.o misc.o main.o ${LDFLAGS} -o make_s
  
! crypt.o: ${srcdir}/crypt.c
  	case ${SYS_NAME} in \
  	rs_aix*)\
! 		${CCOBJ} -c ${COMMON_INCL} -o crypt.o ${srcdir}/crypt.c ;;\
  	*)\
! 		${CCOBJ} -c ${CFLAGS} -o crypt.o ${srcdir}/crypt.c ;;\
  	esac
  #
  # Table/code generation targets
Index: openafs/src/export/cfgexport.c
diff -c openafs/src/export/cfgexport.c:1.11 openafs/src/export/cfgexport.c:1.11.2.1
*** openafs/src/export/cfgexport.c:1.11	Wed Sep  3 12:47:16 2003
--- openafs/src/export/cfgexport.c	Tue Dec  7 11:48:42 2004
***************
*** 14,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/export/cfgexport.c,v 1.11 2003/09/03 16:47:16 rees Exp $");
  
  #include <errno.h>
  #include <stdio.h>
--- 14,20 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/export/cfgexport.c,v 1.11.2.1 2004/12/07 16:48:42 shadow Exp $");
  
  #include <errno.h>
  #include <stdio.h>
***************
*** 202,208 ****
      FILE *fp;
      int xsym_compar();
  
!     fp = fopen(syms, "r");
      if (fp == NULL)
  	sys_error(syms);
  
--- 202,210 ----
      FILE *fp;
      int xsym_compar();
  
!     if (syms == NULL)
!       sys_error("syms is NULL");
!     fp = fopen(syms, "r"); 
      if (fp == NULL)
  	sys_error(syms);
  
***************
*** 375,380 ****
--- 377,383 ----
   *	strp	-	^ to ^ to EXPORT string table
   *	szp	-	^ to EXPORT string table size
   */
+ #define SYMBUFSIZE 262144
  xlate_xtok(xp, kp, strp, szp)
       register struct syment *xp;
       register sym_t *kp;
***************
*** 386,398 ****
      static left, offset, sz;
  
      if (!export_strings) {
! 	export_strings = malloc(sz = 1024);
  	if (!export_strings)
  	    error("no memory for EXPORT string table");
  
  	*strp = export_strings;
  	*szp = offset = sizeof(uint);
! 	left = 1024 - offset;
  
  	export_strings += offset;
  
--- 389,401 ----
      static left, offset, sz;
  
      if (!export_strings) {
! 	export_strings = malloc(sz = SYMBUFSIZE);
  	if (!export_strings)
  	    error("no memory for EXPORT string table");
  
  	*strp = export_strings;
  	*szp = offset = sizeof(uint);
! 	left = SYMBUFSIZE - offset;
  
  	export_strings += offset;
  
***************
*** 417,427 ****
  	 */
  	len = strlen(xstrings + xp->n_offset) + 1;
  	while (len >= left) {
! 	    export_strings = (char *)realloc(*strp, sz += 1024);
  	    if (!export_strings)
  		error("no memory for EXPORT string table");
  	    *strp = export_strings;
! 	    left += 1024;
  	    prev = "";		/* lazy */
  	}
  
--- 420,430 ----
  	 */
  	len = strlen(xstrings + xp->n_offset) + 1;
  	while (len >= left) {
! 	    export_strings = (char *)realloc(*strp, sz += SYMBUFSIZE);
  	    if (!export_strings)
  		error("no memory for EXPORT string table");
  	    *strp = export_strings;
! 	    left += SYMBUFSIZE;
  	    prev = "";		/* lazy */
  	}
  
***************
*** 452,462 ****
  	 */
  	len = strlen(xp->n_nptr) + 1;
  	while (len >= left) {
! 	    export_strings = (char *)realloc(*strp, sz += 1024);
  	    if (!export_strings)
  		error("no memory for EXPORT string table");
  	    *strp = export_strings;
! 	    left += 1024;
  	    prev = "";		/* lazy */
  	}
  
--- 455,465 ----
  	 */
  	len = strlen(xp->n_nptr) + 1;
  	while (len >= left) {
! 	    export_strings = (char *)realloc(*strp, sz += SYMBUFSIZE);
  	    if (!export_strings)
  		error("no memory for EXPORT string table");
  	    *strp = export_strings;
! 	    left += SYMBUFSIZE;
  	    prev = "";		/* lazy */
  	}
  
Index: openafs/src/kauth/admin_tools.c
diff -c openafs/src/kauth/admin_tools.c:1.16.2.1 openafs/src/kauth/admin_tools.c:1.16.2.2
*** openafs/src/kauth/admin_tools.c:1.16.2.1	Wed Aug 25 03:03:39 2004
--- openafs/src/kauth/admin_tools.c	Tue Dec  7 01:07:20 2004
***************
*** 16,22 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/admin_tools.c,v 1.16.2.1 2004/08/25 07:03:39 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/debug.h>
--- 16,22 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/admin_tools.c,v 1.16.2.2 2004/12/07 06:07:20 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/debug.h>
***************
*** 514,519 ****
--- 514,520 ----
  	code =
  	    ubik_CallIter(KAM_LockStatus, conn, UPUBIKONLY, &count, name,
  			  instance, &tempwhen, /*spares */ 0, 0, 0,
+ 			  0, 0, 0, 0, 0, 0, 0, 0,
  			  0);
  	if (code) {
  	    if (seriouserror(code))
Index: openafs/src/kauth/authclient.c
diff -c openafs/src/kauth/authclient.c:1.14.2.2 openafs/src/kauth/authclient.c:1.14.2.3
*** openafs/src/kauth/authclient.c:1.14.2.2	Wed Aug 25 03:09:38 2004
--- openafs/src/kauth/authclient.c	Tue Dec  7 01:07:20 2004
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/authclient.c,v 1.14.2.2 2004/08/25 07:09:38 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/authclient.c,v 1.14.2.3 2004/12/07 06:07:20 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
***************
*** 476,482 ****
  	    lcode = code;
  	    code =
  		ubik_CallIter(aproc, aclient, aflags, &count, p1, p2, p3, p4,
! 			      p5, p6, p7, p8);
  	} while ((code == UNOQUORUM) || (code == UNOTSYNC)
  		 || (code == KALOCKED) || (code == -1));
  
--- 476,482 ----
  	    lcode = code;
  	    code =
  		ubik_CallIter(aproc, aclient, aflags, &count, p1, p2, p3, p4,
! 			      p5, p6, p7, p8, 0, 0, 0, 0, 0, 0, 0, 0);
  	} while ((code == UNOQUORUM) || (code == UNOTSYNC)
  		 || (code == KALOCKED) || (code == -1));
  
Index: openafs/src/libadmin/kas/afs_kasAdmin.c
diff -c openafs/src/libadmin/kas/afs_kasAdmin.c:1.9 openafs/src/libadmin/kas/afs_kasAdmin.c:1.9.2.1
*** openafs/src/libadmin/kas/afs_kasAdmin.c:1.9	Sun Dec  7 17:49:30 2003
--- openafs/src/libadmin/kas/afs_kasAdmin.c	Tue Dec  7 01:07:27 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/kas/afs_kasAdmin.c,v 1.9 2003/12/07 22:49:30 jaltman Exp $");
  
  #include <stdio.h>
  
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/kas/afs_kasAdmin.c,v 1.9.2.1 2004/12/07 06:07:27 shadow Exp $");
  
  #include <stdio.h>
  
***************
*** 718,724 ****
  	tst =
  	    ubik_CallIter(KAM_LockStatus, kaserver->servers, UPUBIKONLY,
  			  &count, who->principal, who->instance, &locked, 0,
! 			  0, 0, 0);
  	if (tst == 0) {
  	    if (locked) {
  		if ((locked < *lockedUntil) || !once) {
--- 718,724 ----
  	tst =
  	    ubik_CallIter(KAM_LockStatus, kaserver->servers, UPUBIKONLY,
  			  &count, who->principal, who->instance, &locked, 0,
! 			  0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  	if (tst == 0) {
  	    if (locked) {
  		if ((locked < *lockedUntil) || !once) {
Index: openafs/src/libafs/MakefileProto.LINUX.in
diff -c openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.2 openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.4
*** openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.2	Mon Oct 18 13:43:56 2004
--- openafs/src/libafs/MakefileProto.LINUX.in	Tue Dec  7 10:59:32 2004
***************
*** 49,58 ****
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mcmodel=kernel
  DEFINES = $(COMMON_DEFINES) 
  
! <i386_umlinux22 i386_umlinux24>
! CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@ -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
  DEFINES = $(COMMON_DEFINES) -DCPU=586
  
  <alpha_linux_22 alpha_linux_24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mno-fp-regs -ffixed-8
  DEFINES = $(COMMON_DEFINES)
--- 49,61 ----
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mcmodel=kernel
  DEFINES = $(COMMON_DEFINES) 
  
! <i386_umlinux22 i386_umlinux24 i386_umlinux26>
! CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@ -Wno-strict-prototypes -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
  DEFINES = $(COMMON_DEFINES) -DCPU=586
  
+ <i386_umlinux26>
+ EXTRA_CFLAGS = -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
+ 
  <alpha_linux_22 alpha_linux_24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mno-fp-regs -ffixed-8
  DEFINES = $(COMMON_DEFINES)
***************
*** 108,116 ****
  
  include Makefile.common
  
! <linux26>
  LINUX_MODULE_EXT=ko
! <all -linux26>
  LINUX_MODULE_EXT=o
  <all>
  
--- 111,119 ----
  
  include Makefile.common
  
! <linux26 umlinux26>
  LINUX_MODULE_EXT=ko
! <all -linux26 -umlinux26>
  LINUX_MODULE_EXT=o
  <all>
  
***************
*** 152,157 ****
--- 155,161 ----
  	ln -fs ${LINUX_KERNEL_PATH}/include/asm-i386 asm
  <i386_umlinux22 i386_umlinux24 i386_umlinux26>
  	ln -fs ${LINUX_KERNEL_PATH}/include/asm-um asm
+ 	ln -fs ${LINUX_KERNEL_PATH}/arch/um/include/sysdep
  <amd64_linux24 amd64_linux26>
  	ln -fs ${LINUX_KERNEL_PATH}/include/asm-x86_64 asm
  <s390_linux22 s390_linux24 s390_linux26>
***************
*** 235,251 ****
  libafs.bm: $(LIBAFS_BM)
  	echo BM Build Complete
  
! <linux26>
  ${LIBAFS} ${LIBAFS_MP} ${LIBAFS_EP} ${LIBAFS_BM}: libafs.ko
  	cp libafs.ko $@
  
  .FORCE:
  libafs.ko: .FORCE
! 	../$(srcdir)/make_kbuild_makefile.pl ${KDIR} $@ \
! 	  @TOP_OBJDIR@/src/config/Makefile.config Makefile.afs Makefile.common
! 	$(MAKE) -C ${LINUX_KERNEL_PATH} M=@TOP_OBJDIR@/src/libafs/${KDIR} modules
          
! <all -linux26>
  ${LIBAFS}: $(AFSAOBJS) $(AFSNONFSOBJS)
  	$(RM) -f $@
  	$(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)
--- 239,254 ----
  libafs.bm: $(LIBAFS_BM)
  	echo BM Build Complete
  
! <linux26 umlinux26>
  ${LIBAFS} ${LIBAFS_MP} ${LIBAFS_EP} ${LIBAFS_BM}: libafs.ko
  	cp libafs.ko $@
  
  .FORCE:
  libafs.ko: .FORCE
! 	env EXTRA_CFLAGS="${EXTRA_CFLAGS}" ../$(srcdir)/make_kbuild_makefile.pl ${KDIR} $@ @TOP_OBJDIR@/src/config/Makefile.config Makefile.afs Makefile.common
! 	env EXTRA_CFLAGS="${EXTRA_CFLAGS}" $(MAKE) -C ${LINUX_KERNEL_PATH} M=@TOP_OBJDIR@/src/libafs/${KDIR} modules
          
! <all -linux26 -umlinux26>
  ${LIBAFS}: $(AFSAOBJS) $(AFSNONFSOBJS)
  	$(RM) -f $@
  	$(LD) -r -o $@ $(AFSAOBJS) $(AFSNONFSOBJS)
Index: openafs/src/libafsauthent/Makefile.in
diff -c openafs/src/libafsauthent/Makefile.in:1.9.2.1 openafs/src/libafsauthent/Makefile.in:1.9.2.2
*** openafs/src/libafsauthent/Makefile.in:1.9.2.1	Mon Oct 18 03:11:59 2004
--- openafs/src/libafsauthent/Makefile.in	Tue Dec  7 01:04:18 2004
***************
*** 58,65 ****
  	pthread_glock.o \
  	get_krbrlm.o \
  	dirpath.o \
! 	fileutil.o \
! 	casestrcpy.o
  
  RXKADOBJS = \
  	rxkad_errs.o
--- 58,64 ----
  	pthread_glock.o \
  	get_krbrlm.o \
  	dirpath.o \
! 	fileutil.o
  
  RXKADOBJS = \
  	rxkad_errs.o
***************
*** 182,190 ****
  fileutil.o: ${UTIL}/fileutil.c
  	${CCRULE}
  
- casestrcpy.o: ${UTIL}/casestrcpy.c
- 	${CCRULE}
- 
  pthread_glock.o: ${UTIL}/pthread_glock.c
  	${CCRULE}
  
--- 181,186 ----
Index: openafs/src/libafsauthent/NTMakefile
diff -c openafs/src/libafsauthent/NTMakefile:1.10.2.1 openafs/src/libafsauthent/NTMakefile:1.10.2.2
*** openafs/src/libafsauthent/NTMakefile:1.10.2.1	Mon Oct 18 03:11:59 2004
--- openafs/src/libafsauthent/NTMakefile	Tue Dec  7 01:15:56 2004
***************
*** 142,148 ****
      $(DESTDIR)\lib\lanahelper.lib
  
  $(LIBFILE): $(DLLOBJS) $(DLLLIBS) $(RXOBJS)
! 	$(DLLCONLINK) /DEF:afsauthent.def rpcrt4.lib dnsapi.lib mpr.lib
  	$(DLLPREP)
  
  # Definitions for generating versioninfo resources
--- 142,148 ----
      $(DESTDIR)\lib\lanahelper.lib
  
  $(LIBFILE): $(DLLOBJS) $(DLLLIBS) $(RXOBJS)
! 	$(DLLCONLINK) /DEF:afsauthent.def rpcrt4.lib dnsapi.lib mpr.lib secur32.lib
  	$(DLLPREP)
  
  # Definitions for generating versioninfo resources
Index: openafs/src/libafsrpc/Makefile.in
diff -c openafs/src/libafsrpc/Makefile.in:1.29.2.1 openafs/src/libafsrpc/Makefile.in:1.29.2.5
*** openafs/src/libafsrpc/Makefile.in:1.29.2.1	Mon Oct 18 03:12:01 2004
--- openafs/src/libafsrpc/Makefile.in	Wed Dec  8 05:52:33 2004
***************
*** 32,37 ****
--- 32,38 ----
  	syscall.o
  
  UTILOBJS =\
+ 	assert.o \
  	casestrcpy.o \
  	base64.o
  
***************
*** 202,212 ****
  md5.o: ${RXKAD}/md5.c
  	${CCRULE} ${RXKAD}/md5.c
  
! fcrypt.o: ${TOP_OBJDIR}/src/rxkad/domestic/fcrypt.c
! 	${CCRULE} ${TOP_OBJDIR}/src/rxkad/domestic/fcrypt.c
  
! crypt_conn.o: ${TOP_OBJDIR}/src/rxkad/domestic/crypt_conn.c
! 	${CCRULE} ${TOP_OBJDIR}/src/rxkad/domestic/crypt_conn.c
  
  AFS_component_version_number.o: ${TOP_OBJDIR}/src/rx/AFS_component_version_number.c
  	${CCRULE} ${TOP_OBJDIR}/src/rx/AFS_component_version_number.c
--- 203,213 ----
  md5.o: ${RXKAD}/md5.c
  	${CCRULE} ${RXKAD}/md5.c
  
! fcrypt.o: ${RXKAD}/domestic/fcrypt.c
! 	${CCRULE} ${RXKAD}/domestic/fcrypt.c
  
! crypt_conn.o: ${RXKAD}/domestic/crypt_conn.c
! 	${CCRULE} ${RXKAD}/domestic/crypt_conn.c
  
  AFS_component_version_number.o: ${TOP_OBJDIR}/src/rx/AFS_component_version_number.c
  	${CCRULE} ${TOP_OBJDIR}/src/rx/AFS_component_version_number.c
***************
*** 266,272 ****
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.29.2.1 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
--- 267,273 ----
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.29.2.5 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
***************
*** 336,341 ****
--- 337,345 ----
  casestrcpy.o: ${UTIL}/casestrcpy.c
  	${CCRULE} ${UTIL}/casestrcpy.c
  
+ assert.o: ${UTIL}/assert.c
+ 	${CCRULE} ${UTIL}/assert.c
+ 
  base64.o: ${UTIL}/base64.c
  	${CCRULE} ${UTIL}/base64.c
  
Index: openafs/src/libuafs/MakefileProto.AIX.in
diff -c openafs/src/libuafs/MakefileProto.AIX.in:1.8 openafs/src/libuafs/MakefileProto.AIX.in:1.8.2.1
*** openafs/src/libuafs/MakefileProto.AIX.in:1.8	Sun Apr 18 02:10:33 2004
--- openafs/src/libuafs/MakefileProto.AIX.in	Tue Dec  7 11:48:42 2004
***************
*** 30,36 ****
  LIBAFSWEB = nsafs.a
  LIBAFSWEBKRB = nsafs.krb.a
  
! OPTF=-O
  WEBOPTS = -I../nsapi -qarch=com -DNETSCAPE_NSAPI -DAIX -DNET_SSL -DXP_UNIX -DMCC_HTTPD
  
  include Makefile.common
--- 30,38 ----
  LIBAFSWEB = nsafs.a
  LIBAFSWEBKRB = nsafs.krb.a
  
! # To get __file__ (afs_osi_pag.c) you need to specify language level 
! # C99 to xlc_r like this:
! OPTF=-O -qlanglvl=stdc99
  WEBOPTS = -I../nsapi -qarch=com -DNETSCAPE_NSAPI -DAIX -DNET_SSL -DXP_UNIX -DMCC_HTTPD
  
  include Makefile.common
Index: openafs/src/lwp/Makefile.in
diff -c openafs/src/lwp/Makefile.in:1.29.2.2 openafs/src/lwp/Makefile.in:1.29.2.3
*** openafs/src/lwp/Makefile.in:1.29.2.2	Wed Aug 25 03:39:33 2004
--- openafs/src/lwp/Makefile.in	Tue Dec  7 09:24:14 2004
***************
*** 60,66 ****
  		${AS} process.ss -o process.o ;  \
  		$(RM) -f process.S ;;\
  	ncrx86_* | sunx86_*) \
! 		/usr/ccs/lib/cpp -P -D__i386 -DIGNORE_STDS_H -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s process.ss; \
  		${AS} -o process.o process.ss; \
  		$(RM) process.ss ;; \
  	alpha_nbsd* ) \
--- 60,66 ----
  		${AS} process.ss -o process.o ;  \
  		$(RM) -f process.S ;;\
  	ncrx86_* | sunx86_*) \
! 		/usr/ccs/lib/cpp -P -D__sun -D__i386 -DIGNORE_STDS_H -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s process.ss; \
  		${AS} -o process.o process.ss; \
  		$(RM) process.ss ;; \
  	alpha_nbsd* ) \
Index: openafs/src/lwp/lwp.h
diff -c openafs/src/lwp/lwp.h:1.14 openafs/src/lwp/lwp.h:1.14.2.1
*** openafs/src/lwp/lwp.h:1.14	Tue Jul 15 19:15:45 2003
--- openafs/src/lwp/lwp.h	Tue Dec  7 11:48:43 2004
***************
*** 302,310 ****
--- 302,314 ----
  #if defined(AFS_LINUX22_ENV)
  #define AFS_LWP_MINSTACKSIZE	(192 * 1024)
  #else
+ #if defined(AFS_AIX52_ENV)
+ #define AFS_LWP_MINSTACKSIZE	(128 * 1024)
+ #else
  #define AFS_LWP_MINSTACKSIZE	(48 * 1024)
  #endif
  #endif
+ #endif
  
  /* Action to take on stack overflow. */
  #define LWP_SOQUIET	1	/* do nothing */
Index: openafs/src/lwp/lwp_elf.h
diff -c openafs/src/lwp/lwp_elf.h:1.3 openafs/src/lwp/lwp_elf.h:1.3.2.2
*** openafs/src/lwp/lwp_elf.h:1.3	Tue Aug  3 10:45:49 2004
--- openafs/src/lwp/lwp_elf.h	Tue Dec  7 17:27:16 2004
***************
*** 35,63 ****
   * This file is mis-named. It is used by both a.out and elf platforms.
   * It either adds the leading underscore or not as needed.
   *
!  * $Id: lwp_elf.h,v 1.3 2004/08/03 14:45:49 rees Exp $
   */
  
  #ifndef _C_LABEL
! #if !defined(SYSV) && !defined(__ELF__) && !defined(AFS_SUN5_ENV)
  #ifdef __STDC__
  #define _C_LABEL(name)     _##name
  #else
  #define _C_LABEL(name)  _/**/name
  #endif
- #else /* SYSV || __ELF__ || AFS_SUN5_ENV */
- #define _C_LABEL(name)  name
  #endif
  #endif /* _C_LABEL */
  
  #ifndef ENTRY
! #if !defined(SYSV) && !defined(__ELF__) && !defined(AFS_SUN5_ENV)
  #ifdef __STDC__
  #define ENTRY(name)    _##name##:
  #else
  #define ENTRY(name)     _/**/name/**/:
  #endif
- #else /* SYSV || __ELF__ || AFS_SUN5_ENV */
- #define ENTRY(name)     name:
  #endif
  #endif /* _C_LABEL */
--- 35,63 ----
   * This file is mis-named. It is used by both a.out and elf platforms.
   * It either adds the leading underscore or not as needed.
   *
!  * $Id: lwp_elf.h,v 1.3.2.2 2004/12/07 22:27:16 shadow Exp $
   */
  
  #ifndef _C_LABEL
! #if defined(SYSV) || defined(__ELF__) || defined(__sun)
! #define _C_LABEL(name)  name
! #else /* SYSV || __ELF__ || __sun */
  #ifdef __STDC__
  #define _C_LABEL(name)     _##name
  #else
  #define _C_LABEL(name)  _/**/name
  #endif
  #endif
  #endif /* _C_LABEL */
  
  #ifndef ENTRY
! #if defined(SYSV) || defined(__ELF__) || defined(__sun)
! #define ENTRY(name)     name:
! #else
  #ifdef __STDC__
  #define ENTRY(name)    _##name##:
  #else
  #define ENTRY(name)     _/**/name/**/:
  #endif
  #endif
  #endif /* _C_LABEL */
Index: openafs/src/packaging/MacOS/OpenAFS.Info.plist
diff -c openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.1 openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.2
*** openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.1	Tue Nov  9 14:31:02 2004
--- openafs/src/packaging/MacOS/OpenAFS.Info.plist	Wed Dec  8 06:12:23 2004
***************
*** 3,15 ****
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.74</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.74</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
--- 3,15 ----
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.75</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.75</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.1 openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.2
*** openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.1	Tue Nov  9 14:31:02 2004
--- openafs/src/packaging/MacOS/OpenAFS.info	Wed Dec  8 06:12:23 2004
***************
*** 1,5 ****
  Title OpenAFS
! Version 1.3.74
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
--- 1,5 ----
  Title OpenAFS
! Version 1.3.75
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
Index: openafs/src/rx/rx.c
diff -c openafs/src/rx/rx.c:1.58.2.3 openafs/src/rx/rx.c:1.58.2.4
*** openafs/src/rx/rx.c:1.58.2.3	Mon Oct 18 13:43:57 2004
--- openafs/src/rx/rx.c	Tue Dec  7 01:10:05 2004
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.3 2004/10/18 17:43:57 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
--- 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"
***************
*** 1788,1797 ****
   */
  void
  rx_SetArrivalProc(register struct rx_call *call,
! 		  register VOID(*proc) (register struct rx_call * call,
! 					register struct multi_handle * mh,
  					register int index),
! 		  register VOID * handle, register VOID * arg)
  {
      call->arrivalProc = proc;
      call->arrivalProcHandle = handle;
--- 1788,1797 ----
   */
  void
  rx_SetArrivalProc(register struct rx_call *call,
! 		  register void (*proc) (register struct rx_call * call,
! 					register VOID * mh,
  					register int index),
! 		  register VOID * handle, register int arg)
  {
      call->arrivalProc = proc;
      call->arrivalProcHandle = handle;
***************
*** 1823,1829 ****
  	call->abortCount = 0;
      }
  
!     call->arrivalProc = (VOID(*)())0;
      if (rc && call->error == 0) {
  	rxi_CallError(call, rc);
  	/* Send an abort message to the peer if this error code has
--- 1823,1829 ----
  	call->abortCount = 0;
      }
  
!     call->arrivalProc = (void (*)())0;
      if (rc && call->error == 0) {
  	rxi_CallError(call, rc);
  	/* Send an abort message to the peer if this error code has
***************
*** 3188,3195 ****
  	     * (e.g. multi rx) */
  	    if (call->arrivalProc) {
  		(*call->arrivalProc) (call, call->arrivalProcHandle,
! 				      (int)call->arrivalProcArg);
! 		call->arrivalProc = (VOID(*)())0;
  	    }
  
  	    /* Update last packet received */
--- 3188,3195 ----
  	     * (e.g. multi rx) */
  	    if (call->arrivalProc) {
  		(*call->arrivalProc) (call, call->arrivalProcHandle,
! 				      call->arrivalProcArg);
! 		call->arrivalProc = (void (*)())0;
  	    }
  
  	    /* Update last packet received */
***************
*** 3869,3875 ****
  	call->state = RX_STATE_DALLY;
  	rxi_ClearTransmitQueue(call, 0);
      } else if (!queue_IsEmpty(&call->tq)) {
! 	rxi_Start(0, call, istack);
      }
      return np;
  }
--- 3869,3875 ----
  	call->state = RX_STATE_DALLY;
  	rxi_ClearTransmitQueue(call, 0);
      } else if (!queue_IsEmpty(&call->tq)) {
! 	rxi_Start(0, call, 0, istack);
      }
      return np;
  }
***************
*** 4374,4381 ****
      /* Notify anyone who is waiting for asynchronous packet arrival */
      if (call->arrivalProc) {
  	(*call->arrivalProc) (call, call->arrivalProcHandle,
! 			      (int)call->arrivalProcArg);
! 	call->arrivalProc = (VOID(*)())0;
      }
  
      if (call->delayedAbortEvent) {
--- 4374,4381 ----
      /* Notify anyone who is waiting for asynchronous packet arrival */
      if (call->arrivalProc) {
  	(*call->arrivalProc) (call, call->arrivalProcHandle,
! 			      call->arrivalProcArg);
! 	call->arrivalProc = (void (*)())0;
      }
  
      if (call->delayedAbortEvent) {
***************
*** 4907,4916 ****
  /* Call rxi_Start, below, but with the call lock held. */
  void
  rxi_StartUnlocked(struct rxevent *event, register struct rx_call *call,
! 		  int istack)
  {
      MUTEX_ENTER(&call->lock);
!     rxi_Start(event, call, istack);
      MUTEX_EXIT(&call->lock);
  }
  #endif /* RX_ENABLE_LOCKS */
--- 4907,4916 ----
  /* Call rxi_Start, below, but with the call lock held. */
  void
  rxi_StartUnlocked(struct rxevent *event, register struct rx_call *call,
! 		  void *arg1, int istack)
  {
      MUTEX_ENTER(&call->lock);
!     rxi_Start(event, call, arg1, istack);
      MUTEX_EXIT(&call->lock);
  }
  #endif /* RX_ENABLE_LOCKS */
***************
*** 4921,4927 ****
   * better optimized for new packets, the usual case, now that we've
   * got rid of queues of send packets. XXXXXXXXXXX */
  void
! rxi_Start(struct rxevent *event, register struct rx_call *call, int istack)
  {
      struct rx_packet *p;
      register struct rx_packet *nxp;	/* Next pointer for queue_Scan */
--- 4921,4928 ----
   * better optimized for new packets, the usual case, now that we've
   * got rid of queues of send packets. XXXXXXXXXXX */
  void
! rxi_Start(struct rxevent *event, register struct rx_call *call,
! 	  void *arg1, int istack)
  {
      struct rx_packet *p;
      register struct rx_packet *nxp;	/* Next pointer for queue_Scan */
***************
*** 5196,5207 ****
  #ifdef RX_ENABLE_LOCKS
  			CALL_HOLD(call, RX_CALL_REFCOUNT_RESEND);
  			call->resendEvent =
! 			    rxevent_Post(&retryTime, rxi_StartUnlocked,
! 					 (void *)call, (void *)istack);
  #else /* RX_ENABLE_LOCKS */
  			call->resendEvent =
! 			    rxevent_Post(&retryTime, rxi_Start, (void *)call,
! 					 (void *)istack);
  #endif /* RX_ENABLE_LOCKS */
  		    }
  		}
--- 5197,5208 ----
  #ifdef RX_ENABLE_LOCKS
  			CALL_HOLD(call, RX_CALL_REFCOUNT_RESEND);
  			call->resendEvent =
! 			    rxevent_Post2(&retryTime, rxi_StartUnlocked,
! 					 (void *)call, 0, istack);
  #else /* RX_ENABLE_LOCKS */
  			call->resendEvent =
! 			    rxevent_Post2(&retryTime, rxi_Start, (void *)call,
! 					 0, istack);
  #endif /* RX_ENABLE_LOCKS */
  		    }
  		}
***************
*** 5472,5480 ****
   * security object associated with the connection */
  void
  rxi_ChallengeEvent(struct rxevent *event, register struct rx_connection *conn,
! 		   void *atries)
  {
-     int tries = (int)atries;
      conn->challengeEvent = NULL;
      if (RXS_CheckAuthentication(conn->securityObject, conn) != 0) {
  	register struct rx_packet *packet;
--- 5473,5480 ----
   * security object associated with the connection */
  void
  rxi_ChallengeEvent(struct rxevent *event, register struct rx_connection *conn,
! 		   void *arg1, int tries)
  {
      conn->challengeEvent = NULL;
      if (RXS_CheckAuthentication(conn->securityObject, conn) != 0) {
  	register struct rx_packet *packet;
***************
*** 5514,5521 ****
  	clock_GetTime(&when);
  	when.sec += RX_CHALLENGE_TIMEOUT;
  	conn->challengeEvent =
! 	    rxevent_Post(&when, rxi_ChallengeEvent, conn,
! 			 (void *)(tries - 1));
      }
  }
  
--- 5514,5521 ----
  	clock_GetTime(&when);
  	when.sec += RX_CHALLENGE_TIMEOUT;
  	conn->challengeEvent =
! 	    rxevent_Post2(&when, rxi_ChallengeEvent, conn, 0,
! 			 (tries - 1));
      }
  }
  
***************
*** 5530,5536 ****
  {
      if (!conn->challengeEvent) {
  	RXS_CreateChallenge(conn->securityObject, conn);
! 	rxi_ChallengeEvent(NULL, conn, (void *)RX_CHALLENGE_MAXTRIES);
      };
  }
  
--- 5530,5536 ----
  {
      if (!conn->challengeEvent) {
  	RXS_CreateChallenge(conn->securityObject, conn);
! 	rxi_ChallengeEvent(NULL, conn, 0, RX_CHALLENGE_MAXTRIES);
      };
  }
  
Index: openafs/src/rx/rx.h
diff -c openafs/src/rx/rx.h:1.22.2.1 openafs/src/rx/rx.h:1.22.2.2
*** openafs/src/rx/rx.h:1.22.2.1	Mon Oct 18 03:12:06 2004
--- openafs/src/rx/rx.h	Tue Dec  7 01:10:05 2004
***************
*** 507,515 ****
      int abortCount;		/* number of times last error was sent */
      u_int lastSendTime;		/* Last time a packet was sent on this call */
      u_int lastReceiveTime;	/* Last time a packet was received for this call */
!       VOID(*arrivalProc) (register struct rx_call * call, register struct multi_handle * mh, register int index);	/* Procedure to call when reply is received */
      VOID *arrivalProcHandle;	/* Handle to pass to replyFunc */
!     VOID *arrivalProcArg;	/* Additional arg to pass to reply Proc */
      afs_uint32 lastAcked;	/* last packet "hard" acked by receiver */
      afs_uint32 startWait;	/* time server began waiting for input data/send quota */
      struct clock traceWait;	/* time server began waiting for input data/send quota */
--- 507,515 ----
      int abortCount;		/* number of times last error was sent */
      u_int lastSendTime;		/* Last time a packet was sent on this call */
      u_int lastReceiveTime;	/* Last time a packet was received for this call */
!     void (*arrivalProc) (register struct rx_call * call, register VOID * mh, register int index);	/* Procedure to call when reply is received */
      VOID *arrivalProcHandle;	/* Handle to pass to replyFunc */
!     int arrivalProcArg;         /* Additional arg to pass to reply Proc */
      afs_uint32 lastAcked;	/* last packet "hard" acked by receiver */
      afs_uint32 startWait;	/* time server began waiting for input data/send quota */
      struct clock traceWait;	/* time server began waiting for input data/send quota */
Index: openafs/src/rx/rx_event.c
diff -c openafs/src/rx/rx_event.c:1.14.2.1 openafs/src/rx/rx_event.c:1.14.2.2
*** openafs/src/rx/rx_event.c:1.14.2.1	Wed Aug 25 03:09:41 2004
--- openafs/src/rx/rx_event.c	Tue Dec  7 01:10:06 2004
***************
*** 19,25 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_event.c,v 1.14.2.1 2004/08/25 07:09:41 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 19,25 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_event.c,v 1.14.2.2 2004/12/07 06:10:06 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 188,195 ****
  			   struct rx_connection * conn,
  			   struct rx_call * acall), void *arg, void *arg1)
  #else
! struct rxevent *
! rxevent_Post(struct clock *when, void (*func) (), void *arg, void *arg1)
  #endif
  {
      register struct rxevent *ev, *evqe, *evqpr;
--- 188,196 ----
  			   struct rx_connection * conn,
  			   struct rx_call * acall), void *arg, void *arg1)
  #else
! static struct rxevent *
! _rxevent_Post(struct clock *when, void (*func) (), void *arg, void *arg1,
! 	      int arg2, int newargs)
  #endif
  {
      register struct rxevent *ev, *evqe, *evqpr;
***************
*** 202,210 ****
      if (rx_Log_event) {
  	struct clock now;
  	clock_GetTime(&now);
! 	fprintf(rx_Log_event, "%d.%d: rxevent_Post(%d.%d, %x, %x)\n",
  		(int)now.sec, (int)now.usec, (int)when->sec, (int)when->usec,
! 		(unsigned int)func, (unsigned int)arg);
      }
  #endif
  
--- 203,212 ----
      if (rx_Log_event) {
  	struct clock now;
  	clock_GetTime(&now);
! 	fprintf(rx_Log_event, "%d.%d: rxevent_Post(%d.%d, %lx, %lx, %lx, %d)\n",
  		(int)now.sec, (int)now.usec, (int)when->sec, (int)when->usec,
! 		(unsigned long)func, (unsigned long)arg,
! 		(unsigned long)arg1, arg2);
      }
  #endif
  
***************
*** 262,267 ****
--- 264,271 ----
      ev->func = func;
      ev->arg = arg;
      ev->arg1 = arg1;
+     ev->arg2 = arg2;
+     ev->newargs = newargs;
      rxevent_nPosted += 1;	/* Rather than ++, to shut high-C up
  				 *  regarding never-set variables
  				 */
***************
*** 291,296 ****
--- 295,313 ----
      return ev;
  }
  
+ struct rxevent *
+ rxevent_Post(struct clock *when, void (*func) (), void *arg, void *arg1)
+ {
+     return _rxevent_Post(when, func, arg, arg1, 0, 0);
+ }
+ 
+ struct rxevent *
+ rxevent_Post2(struct clock *when, void (*func) (), void *arg, void *arg1,
+ 	      int arg2)
+ {
+     return _rxevent_Post(when, func, arg, arg1, arg2, 1);
+ }
+ 
  /* Cancel an event by moving it from the event queue to the free list.
   * Warning, the event must be on the event queue!  If not, this should core
   * dump (reference through 0).  This routine should be called using the macro
***************
*** 311,320 ****
      if (rx_Log_event) {
  	struct clock now;
  	clock_GetTime(&now);
! 	fprintf(rx_Log_event, "%d.%d: rxevent_Cancel_1(%d.%d, %x, %x)\n",
  		(int)now.sec, (int)now.usec, (int)ev->eventTime.sec,
! 		(int)ev->eventTime.usec, (unsigned int)ev->func,
! 		(unsigned int)ev->arg);
      }
  #endif
      /* Append it to the free list (rather than prepending) to keep the free
--- 328,337 ----
      if (rx_Log_event) {
  	struct clock now;
  	clock_GetTime(&now);
! 	fprintf(rx_Log_event, "%d.%d: rxevent_Cancel_1(%d.%d, %lx, %lx)\n",
  		(int)now.sec, (int)now.usec, (int)ev->eventTime.sec,
! 		(int)ev->eventTime.usec, (unsigned long)ev->func,
! 		(unsigned long)ev->arg);
      }
  #endif
      /* Append it to the free list (rather than prepending) to keep the free
***************
*** 395,401 ****
  	    queue_Remove(ev);
  	    rxevent_nPosted--;
  	    MUTEX_EXIT(&rxevent_lock);
! 	    ev->func(ev, ev->arg, ev->arg1);
  	    MUTEX_ENTER(&rxevent_lock);
  	    queue_Append(&rxevent_free, ev);
  	    rxevent_nFree++;
--- 412,422 ----
  	    queue_Remove(ev);
  	    rxevent_nPosted--;
  	    MUTEX_EXIT(&rxevent_lock);
! 	    if (ev->newargs) {
! 		ev->func(ev, ev->arg, ev->arg1, ev->arg2);
! 	    } else {
! 		ev->func(ev, ev->arg, ev->arg1);
! 	    }
  	    MUTEX_ENTER(&rxevent_lock);
  	    queue_Append(&rxevent_free, ev);
  	    rxevent_nFree++;
Index: openafs/src/rx/rx_event.h
diff -c openafs/src/rx/rx_event.h:1.5 openafs/src/rx/rx_event.h:1.5.2.1
*** openafs/src/rx/rx_event.h:1.5	Tue Jul 15 19:16:09 2003
--- openafs/src/rx/rx_event.h	Tue Dec  7 01:10:06 2004
***************
*** 28,33 ****
--- 28,35 ----
      void (*func) ();		/* Function to call when this expires */
      char *arg;			/* Argument to the function */
      char *arg1;			/* Another argument */
+     int arg2;			/* An integer argument */
+     int newargs;		/* Nonzero if new-form arguments should be used */
  };
  
  /* We used to maintain a sorted list of events, but the amount of CPU
Index: openafs/src/rx/rx_getaddr.c
diff -c openafs/src/rx/rx_getaddr.c:1.15.2.2 openafs/src/rx/rx_getaddr.c:1.15.2.3
*** openafs/src/rx/rx_getaddr.c:1.15.2.2	Tue Nov  9 12:16:12 2004
--- openafs/src/rx/rx_getaddr.c	Tue Dec  7 00:48:55 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_getaddr.c,v 1.15.2.2 2004/11/09 17:16:12 shadow Exp $");
  
  #ifndef AFS_DJGPP_ENV
  #ifndef KERNEL
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_getaddr.c,v 1.15.2.3 2004/12/07 05:48:55 shadow Exp $");
  
  #ifndef AFS_DJGPP_ENV
  #ifndef KERNEL
***************
*** 456,461 ****
--- 456,464 ----
  		continue;	/* ignore this address */
  	    }
  
+             if (a->sin_addr.s_addr == htonl(0x7f000001) )
+                 continue;   /* skip loopback address as well. */
+ 
  	    if (count >= maxSize) {	/* no more space */
  		printf("Too many interfaces..ignoring 0x%x\n",
  		       a->sin_addr.s_addr);
Index: openafs/src/rx/rx_globals.c
diff -c openafs/src/rx/rx_globals.c:1.8 openafs/src/rx/rx_globals.c:1.8.2.1
*** openafs/src/rx/rx_globals.c:1.8	Mon Jul 19 10:39:42 2004
--- openafs/src/rx/rx_globals.c	Tue Dec  7 01:10:06 2004
***************
*** 14,20 ****
   * Its value should be as large as the maximum file descriptor limit we
   * are likely to run into on any platform.  Right now, that is 65536
   * which is the default hard fd limit on Solaris 9 */
! #ifndef _WIN32
  #define FD_SETSIZE 65536
  #endif
  
--- 14,20 ----
   * Its value should be as large as the maximum file descriptor limit we
   * are likely to run into on any platform.  Right now, that is 65536
   * which is the default hard fd limit on Solaris 9 */
! #if !defined(_WIN32) && !defined(KERNEL)
  #define FD_SETSIZE 65536
  #endif
  
***************
*** 26,32 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_globals.c,v 1.8 2004/07/19 14:39:42 jaltman Exp $");
  
  /* Enable data initialization when the header file is included */
  #define INIT(stuff) = stuff
--- 26,32 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_globals.c,v 1.8.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  /* Enable data initialization when the header file is included */
  #define INIT(stuff) = stuff
Index: openafs/src/rx/rx_lwp.c
diff -c openafs/src/rx/rx_lwp.c:1.17 openafs/src/rx/rx_lwp.c:1.17.2.1
*** openafs/src/rx/rx_lwp.c:1.17	Mon Jul 19 10:39:42 2004
--- openafs/src/rx/rx_lwp.c	Tue Dec  7 01:10:06 2004
***************
*** 22,28 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_lwp.c,v 1.17 2004/07/19 14:39:42 jaltman Exp $");
  
  # include <sys/types.h>		/* fd_set on older platforms */
  # include <errno.h>
--- 22,28 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_lwp.c,v 1.17.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  # include <sys/types.h>		/* fd_set on older platforms */
  # include <errno.h>
***************
*** 75,81 ****
  }
  
  PROCESS rx_listenerPid = 0;	/* LWP process id of socket listener process */
! static void rx_ListenerProc(void *dummy);
  
  /*
   * Delay the current thread the specified number of seconds.
--- 75,81 ----
  }
  
  PROCESS rx_listenerPid = 0;	/* LWP process id of socket listener process */
! static int rx_ListenerProc(void *dummy);
  
  /*
   * Delay the current thread the specified number of seconds.
***************
*** 126,132 ****
      char name[32];
  
      sprintf(name, "srv_%d", ++number);
!     LWP_CreateProcess(proc, stacksize, RX_PROCESS_PRIORITY, (void *)0,
  		      "rx_ServerProc", &scratchPid);
      if (registerProgram)
  	(*registerProgram) (scratchPid, name);
--- 126,132 ----
      char name[32];
  
      sprintf(name, "srv_%d", ++number);
!     LWP_CreateProcess((int (*)(void *))proc, stacksize, RX_PROCESS_PRIORITY, (void *)0,
  		      "rx_ServerProc", &scratchPid);
      if (registerProgram)
  	(*registerProgram) (scratchPid, name);
***************
*** 320,326 ****
  /* This is the listener process request loop. The listener process loop
   * becomes a server thread when rxi_ListenerProc returns, and stays
   * server thread until rxi_ServerProc returns. */
! static void
  rx_ListenerProc(void *dummy)
  {
      int threadID;
--- 320,326 ----
  /* This is the listener process request loop. The listener process loop
   * becomes a server thread when rxi_ListenerProc returns, and stays
   * server thread until rxi_ServerProc returns. */
! static int
  rx_ListenerProc(void *dummy)
  {
      int threadID;
Index: openafs/src/rx/rx_multi.c
diff -c openafs/src/rx/rx_multi.c:1.8 openafs/src/rx/rx_multi.c:1.8.2.1
*** openafs/src/rx/rx_multi.c:1.8	Tue Nov 11 14:03:09 2003
--- openafs/src/rx/rx_multi.c	Tue Dec  7 01:10:06 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_multi.c,v 1.8 2003/11/11 19:03:09 rees Exp $");
  
  #ifdef	KERNEL
  #include "afs/sysincludes.h"
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_multi.c,v 1.8.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  #ifdef	KERNEL
  #include "afs/sysincludes.h"
***************
*** 55,61 ****
      for (i = 0; i < nConns; i++) {
  	register struct rx_call *call;
  	call = mh->calls[i] = rx_NewCall(conns[i]);
! 	rx_SetArrivalProc(call, multi_Ready, (VOID *) mh, (VOID *) i);
      }
      return mh;
  }
--- 55,61 ----
      for (i = 0; i < nConns; i++) {
  	register struct rx_call *call;
  	call = mh->calls[i] = rx_NewCall(conns[i]);
! 	rx_SetArrivalProc(call, multi_Ready, (VOID *) mh, i);
      }
      return mh;
  }
***************
*** 95,103 ****
  
  /* Called by Rx when the first reply packet of a call is received, or the call is aborted. */
  void
! multi_Ready(register struct rx_call *call, register struct multi_handle *mh,
  	    register int index)
  {
  #ifdef RX_ENABLE_LOCKS
      MUTEX_ENTER(&mh->lock);
  #endif /* RX_ENABLE_LOCKS */
--- 95,104 ----
  
  /* Called by Rx when the first reply packet of a call is received, or the call is aborted. */
  void
! multi_Ready(register struct rx_call *call, register VOID *amh,
  	    register int index)
  {
+     register struct multi_handle *mh = (struct multi_handle *)amh;
  #ifdef RX_ENABLE_LOCKS
      MUTEX_ENTER(&mh->lock);
  #endif /* RX_ENABLE_LOCKS */
Index: openafs/src/rx/rx_packet.c
diff -c openafs/src/rx/rx_packet.c:1.35.2.2 openafs/src/rx/rx_packet.c:1.35.2.3
*** openafs/src/rx/rx_packet.c:1.35.2.2	Mon Oct 18 13:43:58 2004
--- openafs/src/rx/rx_packet.c	Tue Dec  7 01:10:06 2004
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.35.2.2 2004/10/18 17:43:58 shadow Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
--- 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)
***************
*** 480,486 ****
  void
  rxi_FreePacketNoLock(struct rx_packet *p)
  {
!     dpf(("Free %x\n", (int)p));
  
      if (p->flags & RX_PKTFLAG_FREE)
  	osi_Panic("rxi_FreePacketNoLock: packet already free\n");
--- 480,486 ----
  void
  rxi_FreePacketNoLock(struct rx_packet *p)
  {
!     dpf(("Free %lx\n", (unsigned long)p));
  
      if (p->flags & RX_PKTFLAG_FREE)
  	osi_Panic("rxi_FreePacketNoLock: packet already free\n");
***************
*** 652,658 ****
      if (!(p->flags & RX_PKTFLAG_FREE))
  	osi_Panic("rxi_AllocPacket: packet not free\n");
  
!     dpf(("Alloc %x, class %d\n", (int)p, class));
  
      queue_Remove(p);
      p->flags = 0;		/* clear RX_PKTFLAG_FREE, initialize the rest */
--- 652,658 ----
      if (!(p->flags & RX_PKTFLAG_FREE))
  	osi_Panic("rxi_AllocPacket: packet not free\n");
  
!     dpf(("Alloc %lx, class %d\n", (unsigned long)p, class));
  
      queue_Remove(p);
      p->flags = 0;		/* clear RX_PKTFLAG_FREE, initialize the rest */
***************
*** 1653,1659 ****
  	AFS_RXGLOCK();
  #ifdef RXDEBUG
      }
!     dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
  #endif
      MUTEX_ENTER(&rx_stats_mutex);
      rx_stats.packetsSent[p->header.type - 1]++;
--- 1653,1659 ----
  	AFS_RXGLOCK();
  #ifdef RXDEBUG
      }
!     dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (unsigned long)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
  #endif
      MUTEX_ENTER(&rx_stats_mutex);
      rx_stats.packetsSent[p->header.type - 1]++;
***************
*** 1832,1838 ****
  
      assert(p != NULL);
  
!     dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %x resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (int)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
  
  #endif
      MUTEX_ENTER(&rx_stats_mutex);
--- 1832,1838 ----
  
      assert(p != NULL);
  
!     dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %lx resend %d.%0.3d len %d", deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], peer->host, peer->port, p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber, p->header.seq, p->header.flags, (unsigned long)p, p->retryTime.sec, p->retryTime.usec / 1000, p->length));
  
  #endif
      MUTEX_ENTER(&rx_stats_mutex);
Index: openafs/src/rx/rx_prototypes.h
diff -c openafs/src/rx/rx_prototypes.h:1.14.2.1 openafs/src/rx/rx_prototypes.h:1.14.2.2
*** openafs/src/rx/rx_prototypes.h:1.14.2.1	Mon Oct 18 03:12:06 2004
--- openafs/src/rx/rx_prototypes.h	Tue Dec  7 01:10:06 2004
***************
*** 13,18 ****
--- 13,19 ----
  /* rx.c */
  extern void rx_SetEpoch(afs_uint32 epoch);
  extern int rx_Init(u_int port);
+ extern int rx_InitHost(u_int host, u_int port);
  #ifndef KERNEL
  extern void rxi_StartServerProcs(int nExistingProcs);
  #endif
***************
*** 48,59 ****
  extern struct rx_call *rx_GetCall(int tno, struct rx_service *cur_service,
  				  osi_socket * socketp);
  extern void rx_SetArrivalProc(register struct rx_call *call,
! 			      register VOID(*proc) (register struct rx_call *
  						    call,
! 						    register struct
! 						    multi_handle * mh,
  						    register int index),
! 			      register VOID * handle, register VOID * arg);
  extern afs_int32 rx_EndCall(register struct rx_call *call, afs_int32 rc);
  extern void rx_Finalize(void);
  extern void rxi_PacketsUnWait(void);
--- 49,59 ----
  extern struct rx_call *rx_GetCall(int tno, struct rx_service *cur_service,
  				  osi_socket * socketp);
  extern void rx_SetArrivalProc(register struct rx_call *call,
! 			      register void (*proc) (register struct rx_call *
  						    call,
! 						    register VOID * mh,
  						    register int index),
! 			      register VOID * handle, register int arg);
  extern afs_int32 rx_EndCall(register struct rx_call *call, afs_int32 rc);
  extern void rx_Finalize(void);
  extern void rxi_PacketsUnWait(void);
***************
*** 128,136 ****
  				     *optionalPacket, int serial, int reason,
  				     int istack);
  extern void rxi_StartUnlocked(struct rxevent *event,
! 			      register struct rx_call *call, int istack);
  extern void rxi_Start(struct rxevent *event, register struct rx_call *call,
! 		      int istack);
  extern void rxi_Send(register struct rx_call *call,
  		     register struct rx_packet *p, int istack);
  #ifdef RX_ENABLE_LOCKS
--- 128,137 ----
  				     *optionalPacket, int serial, int reason,
  				     int istack);
  extern void rxi_StartUnlocked(struct rxevent *event,
! 			      register struct rx_call *call,
! 			      void *arg1, int istack);
  extern void rxi_Start(struct rxevent *event, register struct rx_call *call,
! 		      void *arg1, int istack);
  extern void rxi_Send(register struct rx_call *call,
  		     register struct rx_packet *p, int istack);
  #ifdef RX_ENABLE_LOCKS
***************
*** 150,156 ****
  				     char *dummy);
  extern void rxi_ChallengeEvent(struct rxevent *event,
  			       register struct rx_connection *conn,
! 			       void *atries);
  extern void rxi_ChallengeOn(register struct rx_connection *conn);
  extern void rxi_ComputeRoundTripTime(register struct rx_packet *p,
  				     register struct clock *sentp,
--- 151,157 ----
  				     char *dummy);
  extern void rxi_ChallengeEvent(struct rxevent *event,
  			       register struct rx_connection *conn,
! 			       void *arg1, int atries);
  extern void rxi_ChallengeOn(register struct rx_connection *conn);
  extern void rxi_ComputeRoundTripTime(register struct rx_packet *p,
  				     register struct clock *sentp,
***************
*** 284,289 ****
--- 285,292 ----
  #else
  extern struct rxevent *rxevent_Post(struct clock *when, void (*func) (),
  				    void *arg, void *arg1);
+ extern struct rxevent *rxevent_Post2(struct clock *when, void (*func) (),
+ 				    void *arg, void *arg1, int arg2);
  #endif
  extern void shutdown_rxevent(void);
  extern struct rxepoch *rxepoch_Allocate(struct clock *when);
***************
*** 416,422 ****
  				       register int nConns);
  extern int multi_Select(register struct multi_handle *mh);
  extern void multi_Ready(register struct rx_call *call,
! 			register struct multi_handle *mh, register int index);
  extern void multi_Finalize(register struct multi_handle *mh);
  extern void multi_Finalize_Ignore(register struct multi_handle *mh);
  
--- 419,425 ----
  				       register int nConns);
  extern int multi_Select(register struct multi_handle *mh);
  extern void multi_Ready(register struct rx_call *call,
! 			register VOID *mh, register int index);
  extern void multi_Finalize(register struct multi_handle *mh);
  extern void multi_Finalize_Ignore(register struct multi_handle *mh);
  
Index: openafs/src/rx/rx_rdwr.c
diff -c openafs/src/rx/rx_rdwr.c:1.21.2.1 openafs/src/rx/rx_rdwr.c:1.21.2.2
*** openafs/src/rx/rx_rdwr.c:1.21.2.1	Mon Oct 18 03:12:06 2004
--- openafs/src/rx/rx_rdwr.c	Tue Dec  7 01:10:06 2004
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.21.2.1 2004/10/18 07:12:06 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.21.2.2 2004/12/07 06:10:06 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 724,730 ****
  		    (call->
  		     flags & (RX_CALL_FAST_RECOVER |
  			      RX_CALL_FAST_RECOVER_WAIT))) {
! 		    rxi_Start(0, call, 0);
  		}
  	    }
  	    /* Wait for transmit window to open up */
--- 724,730 ----
  		    (call->
  		     flags & (RX_CALL_FAST_RECOVER |
  			      RX_CALL_FAST_RECOVER_WAIT))) {
! 		    rxi_Start(0, call, 0, 0);
  		}
  	    }
  	    /* Wait for transmit window to open up */
***************
*** 1196,1202 ****
      }
  
      if (!(call->flags & (RX_CALL_FAST_RECOVER | RX_CALL_FAST_RECOVER_WAIT))) {
! 	rxi_Start(0, call, 0);
      }
  
      /* Wait for the length of the transmit queue to fall below call->twind */
--- 1196,1202 ----
      }
  
      if (!(call->flags & (RX_CALL_FAST_RECOVER | RX_CALL_FAST_RECOVER_WAIT))) {
! 	rxi_Start(0, call, 0, 0);
      }
  
      /* Wait for the length of the transmit queue to fall below call->twind */
***************
*** 1312,1318 ****
  	if (!
  	    (call->
  	     flags & (RX_CALL_FAST_RECOVER | RX_CALL_FAST_RECOVER_WAIT))) {
! 	    rxi_Start(0, call, 0);
  	}
      }
  }
--- 1312,1318 ----
  	if (!
  	    (call->
  	     flags & (RX_CALL_FAST_RECOVER | RX_CALL_FAST_RECOVER_WAIT))) {
! 	    rxi_Start(0, call, 0, 0);
  	}
      }
  }
Index: openafs/src/rx/rxdebug.c
diff -c openafs/src/rx/rxdebug.c:1.15.2.2 openafs/src/rx/rxdebug.c:1.15.2.3
*** openafs/src/rx/rxdebug.c:1.15.2.2	Mon Oct 18 13:43:59 2004
--- openafs/src/rx/rxdebug.c	Tue Dec  7 01:06:50 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rxdebug.c,v 1.15.2.2 2004/10/18 17:43:59 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.3 2004/12/07 06:06:50 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
***************
*** 113,118 ****
--- 113,119 ----
      int withPeers;
      struct rx_debugStats tstats;
      char *portName, *hostName;
+     char hoststr[20];
      struct rx_debugConn tconn;
      short noConns;
      short showPeers;
***************
*** 213,219 ****
      dallyCounter = 0;
  
      hostAddr.s_addr = host;
!     printf("Trying %s (port %d):\n", inet_ntoa(hostAddr), ntohs(port));
      s = socket(AF_INET, SOCK_DGRAM, 0);
      taddr.sin_family = AF_INET;
      taddr.sin_port = 0;
--- 214,221 ----
      dallyCounter = 0;
  
      hostAddr.s_addr = host;
!     afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
!     printf("Trying %s (port %d):\n", hoststr, ntohs(port));
      s = socket(AF_INET, SOCK_DGRAM, 0);
      taddr.sin_family = AF_INET;
      taddr.sin_port = 0;
***************
*** 322,329 ****
  	}
  	if (onlyHost != -1) {
  	    hostAddr.s_addr = onlyHost;
  	    printf("Showing only connections from host %s\n",
! 		   inet_ntoa(hostAddr));
  	}
  	if (onlyPort != -1)
  	    printf("Showing only connections on port %u\n", ntohs(onlyPort));
--- 324,332 ----
  	}
  	if (onlyHost != -1) {
  	    hostAddr.s_addr = onlyHost;
+ 	    afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
  	    printf("Showing only connections from host %s\n",
! 		   hoststr);
  	}
  	if (onlyPort != -1)
  	    printf("Showing only connections on port %u\n", ntohs(onlyPort));
***************
*** 382,388 ****
  
  	    /* now display the connection */
  	    hostAddr.s_addr = tconn.host;
! 	    printf("Connection from host %s, port %hu, ", inet_ntoa(hostAddr),
  		   ntohs(tconn.port));
  	    if (tconn.epoch)
  		printf("Cuid %x/%x", tconn.epoch, tconn.cid);
--- 385,392 ----
  
  	    /* now display the connection */
  	    hostAddr.s_addr = tconn.host;
! 	    afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
! 	    printf("Connection from host %s, port %hu, ", hoststr,
  		   ntohs(tconn.port));
  	    if (tconn.epoch)
  		printf("Cuid %x/%x", tconn.epoch, tconn.cid);
***************
*** 544,550 ****
  
  	    /* now display the peer */
  	    hostAddr.s_addr = tpeer.host;
! 	    printf("Peer at host %s, port %hu\n", inet_ntoa(hostAddr),
  		   ntohs(tpeer.port));
  	    printf("\tifMTU %hu\tnatMTU %hu\tmaxMTU %hu\n", tpeer.ifMTU,
  		   tpeer.natMTU, tpeer.maxMTU);
--- 548,555 ----
  
  	    /* now display the peer */
  	    hostAddr.s_addr = tpeer.host;
! 	    afs_inet_ntoa_r(hostAddr.s_addr, hoststr);
! 	    printf("Peer at host %s, port %hu\n", hoststr, 
  		   ntohs(tpeer.port));
  	    printf("\tifMTU %hu\tnatMTU %hu\tmaxMTU %hu\n", tpeer.ifMTU,
  		   tpeer.natMTU, tpeer.maxMTU);
Index: openafs/src/rx/xdr.c
diff -c openafs/src/rx/xdr.c:1.9 openafs/src/rx/xdr.c:1.9.2.1
*** openafs/src/rx/xdr.c:1.9	Sat Nov 29 17:08:16 2003
--- openafs/src/rx/xdr.c	Tue Dec  7 01:10:06 2004
***************
*** 35,41 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr.c,v 1.9 2003/11/29 22:08:16 jaltman Exp $");
  
  /*
   * xdr.c, Generic XDR routines implementation.
--- 35,41 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr.c,v 1.9.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  /*
   * xdr.c, Generic XDR routines implementation.
***************
*** 80,205 ****
      return (TRUE);
  }
  
- #if !defined(AFS_OSF20_ENV) && !defined(AFS_SGI61_ENV)
  /*
!  * XDR afs_int32 integers
!  * same as xdr_u_long - open coded to save a proc call!
   */
  bool_t
  xdr_int(register XDR * xdrs, int *ip)
  {
  
!     if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (long *)ip));
  
!     if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (long *)ip));
  
!     if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
  
!     return (FALSE);
! }
! 
! /*
!  * XDR unsigned afs_int32 integers
!  * same as xdr_long - open coded to save a proc call!
!  */
! bool_t
! xdr_u_int(register XDR * xdrs, u_int * up)
! {
! 
!     if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (long *)up));
! 
!     if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (long *)up));
! 
!     if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
! 
      return (FALSE);
  }
  
- #else
  /*
!  * XDR afs_int32 integers
!  * same as xdr_u_long - open coded to save a proc call!
   */
  bool_t
! xdr_int(register XDR * xdrs, int *lp)
  {
  
!     if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (long *)lp));
  
!     if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (long *)lp));
  
!     if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
  
      return (FALSE);
  }
  
  /*
!  * XDR unsigned afs_int32 integers
!  * same as xdr_long - open coded to save a proc call!
   */
  bool_t
! xdr_u_int(register XDR * xdrs, u_int * ulp)
  {
  
!     if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (long *)ulp));
  
!     if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (long *)ulp));
  
!     if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
  
      return (FALSE);
  }
- #endif
  
  /*
!  * XDR afs_int32 integers
!  * same as xdr_u_long - open coded to save a proc call!
   */
  bool_t
! xdr_long(register XDR * xdrs, long *lp)
  {
  
!     if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, lp));
  
!     if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, lp));
  
!     if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
  
!     return (FALSE);
! }
! 
! /*
!  * XDR unsigned afs_int32 integers
!  * same as xdr_long - open coded to save a proc call!
!  */
! bool_t
! xdr_u_long(register XDR * xdrs, u_long * ulp)
! {
! 
!     if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, ulp));
!     if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, ulp));
!     if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
      return (FALSE);
  }
  
  /*
   * XDR chars
   */
--- 80,195 ----
      return (TRUE);
  }
  
  /*
!  * XDR integers
   */
  bool_t
  xdr_int(register XDR * xdrs, int *ip)
  {
+     afs_int32 l;
  
!     switch (xdrs->x_op) {
  
!     case XDR_ENCODE:
! 	l = (afs_int32) * ip;
! 	return (XDR_PUTINT32(xdrs, &l));
  
!     case XDR_DECODE:
! 	if (!XDR_GETINT32(xdrs, &l)) {
! 	    return (FALSE);
! 	}
! 	*ip = (int)l;
  	return (TRUE);
  
!     case XDR_FREE:
  	return (TRUE);
!     }
      return (FALSE);
  }
  
  /*
!  * XDR unsigned integers
   */
  bool_t
! xdr_u_int(register XDR * xdrs, u_int * uip)
  {
+     afs_uint32 l;
  
!     switch (xdrs->x_op) {
  
!     case XDR_ENCODE:
! 	l = (afs_uint32) * uip;
! 	return (XDR_PUTINT32(xdrs, &l));
  
!     case XDR_DECODE:
! 	if (!XDR_GETINT32(xdrs, &l)) {
! 	    return (FALSE);
! 	}
! 	*uip = (u_int) l;
  	return (TRUE);
  
+     case XDR_FREE:
+ 	return (TRUE);
+     }
      return (FALSE);
  }
  
+ 
  /*
!  * XDR long integers
   */
  bool_t
! xdr_long(register XDR * xdrs, long *lp)
  {
+     afs_int32 l;
  
!     switch (xdrs->x_op) {
  
!     case XDR_ENCODE:
! 	l = (afs_int32) * lp;
! 	return (XDR_PUTINT32(xdrs, &l));
  
!     case XDR_DECODE:
! 	if (!XDR_GETINT32(xdrs, &l)) {
! 	    return (FALSE);
! 	}
! 	*lp = (long)l;
  	return (TRUE);
  
+     case XDR_FREE:
+ 	return (TRUE);
+     }
      return (FALSE);
  }
  
  /*
!  * XDR unsigned long integers
   */
  bool_t
! xdr_u_long(register XDR * xdrs, u_long * ulp)
  {
+     afs_uint32 l;
  
!     switch (xdrs->x_op) {
  
!     case XDR_ENCODE:
! 	l = (afs_uint32) * ulp;
! 	return (XDR_PUTINT32(xdrs, &l));
  
!     case XDR_DECODE:
! 	if (!XDR_GETINT32(xdrs, &l)) {
! 	    return (FALSE);
! 	}
! 	*ulp = (u_long) l;
  	return (TRUE);
  
!     case XDR_FREE:
  	return (TRUE);
+     }
      return (FALSE);
  }
  
+ 
  /*
   * XDR chars
   */
***************
*** 384,390 ****
  	}
  	if (rndup == 0)
  	    return (TRUE);
! 	return (XDR_GETBYTES(xdrs, crud, rndup));
      }
  
      if (xdrs->x_op == XDR_ENCODE) {
--- 374,380 ----
  	}
  	if (rndup == 0)
  	    return (TRUE);
! 	return (XDR_GETBYTES(xdrs, (caddr_t)crud, rndup));
      }
  
      if (xdrs->x_op == XDR_ENCODE) {
***************
*** 538,543 ****
--- 528,535 ----
      case XDR_ENCODE:
  	size = strlen(sp);
  	break;
+     case XDR_DECODE:
+ 	break;
      }
  
      if (!xdr_u_int(xdrs, &size)) {
Index: openafs/src/rx/xdr_afsuuid.c
diff -c openafs/src/rx/xdr_afsuuid.c:1.8 openafs/src/rx/xdr_afsuuid.c:1.8.2.1
*** openafs/src/rx/xdr_afsuuid.c:1.8	Sat May 15 00:53:30 2004
--- openafs/src/rx/xdr_afsuuid.c	Tue Dec  7 01:10:06 2004
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_afsuuid.c,v 1.8 2004/05/15 04:53:30 shadow Exp $");
  
  #if defined(KERNEL) && !defined(UKERNEL)
  #ifdef AFS_LINUX20_ENV
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_afsuuid.c,v 1.8.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  #if defined(KERNEL) && !defined(UKERNEL)
  #ifdef AFS_LINUX20_ENV
***************
*** 55,61 ****
      if (!xdr_char(xdrs, &objp->clock_seq_low)) {
  	return (FALSE);
      }
!     if (!xdr_vector(xdrs, (char *)objp->node, 6, sizeof(char), xdr_char)) {
  	return (FALSE);
      }
      return (TRUE);
--- 55,62 ----
      if (!xdr_char(xdrs, &objp->clock_seq_low)) {
  	return (FALSE);
      }
!     /* Cast needed here because xdrproc_t officially takes 3 args :-( */
!     if (!xdr_vector(xdrs, (char *)objp->node, 6, sizeof(char), (xdrproc_t)xdr_char)) {
  	return (FALSE);
      }
      return (TRUE);
Index: openafs/src/rx/xdr_array.c
diff -c openafs/src/rx/xdr_array.c:1.9 openafs/src/rx/xdr_array.c:1.9.2.1
*** openafs/src/rx/xdr_array.c:1.9	Sat Nov 29 17:08:16 2003
--- openafs/src/rx/xdr_array.c	Tue Dec  7 01:10:06 2004
***************
*** 30,36 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_array.c,v 1.9 2003/11/29 22:08:16 jaltman Exp $");
  
  #ifndef	NeXT
  
--- 30,36 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_array.c,v 1.9.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  #ifndef	NeXT
  
***************
*** 119,124 ****
--- 119,127 ----
  
  	case XDR_FREE:
  	    return (TRUE);
+ 
+ 	case XDR_ENCODE:
+ 	    break;
  	}
  
      /*
Index: openafs/src/rx/xdr_arrayn.c
diff -c openafs/src/rx/xdr_arrayn.c:1.8 openafs/src/rx/xdr_arrayn.c:1.8.2.1
*** openafs/src/rx/xdr_arrayn.c:1.8	Tue Jul 15 19:16:12 2003
--- openafs/src/rx/xdr_arrayn.c	Tue Dec  7 01:10:06 2004
***************
*** 30,36 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_arrayn.c,v 1.8 2003/07/15 23:16:12 shadow Exp $");
  
  #if !defined(NeXT)
  
--- 30,36 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_arrayn.c,v 1.8.2.1 2004/12/07 06:10:06 shadow Exp $");
  
  #if !defined(NeXT)
  
***************
*** 123,128 ****
--- 123,131 ----
  
  	case XDR_FREE:
  	    return (TRUE);
+ 
+ 	case XDR_ENCODE:
+ 	    break;
  	}
  
      /*
Index: openafs/src/rx/xdr_int32.c
diff -c openafs/src/rx/xdr_int32.c:1.5 openafs/src/rx/xdr_int32.c:1.5.2.1
*** openafs/src/rx/xdr_int32.c:1.5	Tue Jul 15 19:16:12 2003
--- openafs/src/rx/xdr_int32.c	Tue Dec  7 01:10:07 2004
***************
*** 35,41 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_int32.c,v 1.5 2003/07/15 23:16:12 shadow Exp $");
  
  #ifndef	NeXT
  
--- 35,41 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_int32.c,v 1.5.2.1 2004/12/07 06:10:07 shadow Exp $");
  
  #ifndef	NeXT
  
***************
*** 55,64 ****
  {
  
      if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (long *)lp));
  
      if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (long *)lp));
  
      if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
--- 55,64 ----
  {
  
      if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, lp));
  
      if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, lp));
  
      if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
***************
*** 75,83 ****
  {
  
      if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (long *)ulp));
      if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (long *)ulp));
      if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
      return (FALSE);
--- 75,83 ----
  {
  
      if (xdrs->x_op == XDR_DECODE)
! 	return (XDR_GETINT32(xdrs, (afs_int32 *)ulp));
      if (xdrs->x_op == XDR_ENCODE)
! 	return (XDR_PUTINT32(xdrs, (afs_int32 *)ulp));
      if (xdrs->x_op == XDR_FREE)
  	return (TRUE);
      return (FALSE);
Index: openafs/src/rx/xdr_rx.c
diff -c openafs/src/rx/xdr_rx.c:1.10 openafs/src/rx/xdr_rx.c:1.10.2.1
*** openafs/src/rx/xdr_rx.c:1.10	Sat May 15 00:53:30 2004
--- openafs/src/rx/xdr_rx.c	Tue Dec  7 01:10:07 2004
***************
*** 19,25 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_rx.c,v 1.10 2004/05/15 04:53:30 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 19,25 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/xdr_rx.c,v 1.10.2.1 2004/12/07 06:10:07 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 73,83 ****
--- 73,93 ----
  #if defined(KERNEL)
  /*
   * kernel version needs to agree with <rpc/xdr.h>
+  * except on Linux which does XDR differently from everyone else
   */
+ # if defined(AFS_LINUX20_ENV) && !defined(UKERNEL)
+ #  define AFS_XDRS_T void *
+ # else
+ #  define AFS_XDRS_T XDR *
+ # endif
  # if defined(AFS_SUN57_ENV)
  #  define AFS_RPC_INLINE_T rpc_inline_t
  # elif defined(AFS_DUX40_ENV)
  #  define AFS_RPC_INLINE_T int
+ # elif defined(AFS_LINUX20_ENV) && !defined(UKERNEL)
+ #  define AFS_RPC_INLINE_T afs_int32
+ # elif defined(AFS_LINUX20_ENV)
+ #  define AFS_RPC_INLINE_T int32_t *
  # else
  #  define AFS_RPC_INLINE_T long
  # endif
***************
*** 85,107 ****
  /*
   * user version needs to agree with "xdr.h", i.e. <rx/xdr.h>
   */
  #  define AFS_RPC_INLINE_T afs_int32
  #endif /* KERNEL */
  
  /* Static prototypes */
  #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
! static bool_t xdrrx_getint64(XDR * xdrs, long *lp);
! static bool_t xdrrx_putint64(XDR * xdrs, long *lp);
  #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
  
! static bool_t xdrrx_getint32(XDR * xdrs, afs_int32 * lp);
! static bool_t xdrrx_putint32(register XDR * xdrs, register afs_int32 * lp);
! static bool_t xdrrx_getbytes(register XDR * xdrs, register caddr_t addr,
  			     register u_int len);
! static bool_t xdrrx_putbytes(register XDR * xdrs, register caddr_t addr,
  			     register u_int len);
! static AFS_RPC_INLINE_T *xdrrx_inline(register XDR * xdrs,
! 				      register u_int len);
  
  
  /*
--- 95,117 ----
  /*
   * user version needs to agree with "xdr.h", i.e. <rx/xdr.h>
   */
+ #  define AFS_XDRS_T void *
  #  define AFS_RPC_INLINE_T afs_int32
  #endif /* KERNEL */
  
  /* Static prototypes */
  #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
! static bool_t xdrrx_getint64(AFS_XDRS_T axdrs, long *lp);
! static bool_t xdrrx_putint64(AFS_XDRS_T axdrs, long *lp);
  #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
  
! static bool_t xdrrx_getint32(AFS_XDRS_T axdrs, afs_int32 * lp);
! static bool_t xdrrx_putint32(AFS_XDRS_T axdrs, register afs_int32 * lp);
! static bool_t xdrrx_getbytes(AFS_XDRS_T axdrs, register caddr_t addr,
  			     register u_int len);
! static bool_t xdrrx_putbytes(AFS_XDRS_T axdrs, register caddr_t addr,
  			     register u_int len);
! static AFS_RPC_INLINE_T *xdrrx_inline(AFS_XDRS_T axdrs, register u_int len);
  
  
  /*
***************
*** 149,156 ****
  
  #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
  static bool_t
! xdrrx_getint64(XDR * xdrs, long *lp)
  {
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
      afs_int32 i;
  
--- 159,167 ----
  
  #if (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV)
  static bool_t
! xdrrx_getint64(AFS_XDRS_T axdrs, long *lp)
  {
+     XDR * xdrs = (XDR *)axdrs;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
      afs_int32 i;
  
***************
*** 162,169 ****
  }
  
  static bool_t
! xdrrx_putint64(XDR * xdrs, long *lp)
  {
      afs_int32 code, i = htonl(*lp);
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  
--- 173,181 ----
  }
  
  static bool_t
! xdrrx_putint64(AFS_XDRS_T axdrs, long *lp)
  {
+     XDR * xdrs = (XDR *)axdrs;
      afs_int32 code, i = htonl(*lp);
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  
***************
*** 173,181 ****
  #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
  
  static bool_t
! xdrrx_getint32(XDR * xdrs, afs_int32 * lp)
  {
      afs_int32 l;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&l;
--- 185,194 ----
  #endif /* (defined(AFS_SGI61_ENV) && (_MIPS_SZLONG != _MIPS_SZINT)) || defined(AFS_HPUX_64BIT_ENV) */
  
  static bool_t
! xdrrx_getint32(AFS_XDRS_T axdrs, afs_int32 * lp)
  {
      afs_int32 l;
+     XDR * xdrs = (XDR *)axdrs;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&l;
***************
*** 211,219 ****
  }
  
  static bool_t
! xdrrx_putint32(register XDR * xdrs, register afs_int32 * lp)
  {
      afs_int32 code, l = htonl(*lp);
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&code;
--- 224,233 ----
  }
  
  static bool_t
! xdrrx_putint32(register AFS_XDRS_T axdrs, register afs_int32 * lp)
  {
      afs_int32 code, l = htonl(*lp);
+     XDR * xdrs = (XDR *)axdrs;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&code;
***************
*** 241,249 ****
  }
  
  static bool_t
! xdrrx_getbytes(register XDR * xdrs, register caddr_t addr, register u_int len)
  {
      afs_int32 code;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&code;
--- 255,264 ----
  }
  
  static bool_t
! xdrrx_getbytes(register AFS_XDRS_T axdrs, register caddr_t addr, register u_int len)
  {
      afs_int32 code;
+     XDR * xdrs = (XDR *)axdrs;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&code;
***************
*** 272,280 ****
  }
  
  static bool_t
! xdrrx_putbytes(register XDR * xdrs, register caddr_t addr, register u_int len)
  {
      afs_int32 code;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&code;
--- 287,296 ----
  }
  
  static bool_t
! xdrrx_putbytes(register AFS_XDRS_T axdrs, register caddr_t addr, register u_int len)
  {
      afs_int32 code;
+     XDR * xdrs = (XDR *)axdrs;
      register struct rx_call *call = ((struct rx_call *)(xdrs)->x_private);
  #if	defined(KERNEL) && defined(AFS_AIX32_ENV)
      char *saddr = (char *)&code;
***************
*** 319,325 ****
  #endif
  
  static AFS_RPC_INLINE_T *
! xdrrx_inline(register XDR * xdrs, register u_int len)
  {
      /* I don't know what this routine is supposed to do, but the stdio module returns null, so we will, too */
      return (0);
--- 335,341 ----
  #endif
  
  static AFS_RPC_INLINE_T *
! xdrrx_inline(AFS_XDRS_T axdrs, register u_int len)
  {
      /* I don't know what this routine is supposed to do, but the stdio module returns null, so we will, too */
      return (0);
Index: openafs/src/rx/LINUX/rx_knet.c
diff -c openafs/src/rx/LINUX/rx_knet.c:1.23.2.3 openafs/src/rx/LINUX/rx_knet.c:1.23.2.4
*** openafs/src/rx/LINUX/rx_knet.c:1.23.2.3	Mon Oct 18 13:43:59 2004
--- openafs/src/rx/LINUX/rx_knet.c	Tue Dec  7 01:10:11 2004
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/LINUX/rx_knet.c,v 1.23.2.3 2004/10/18 17:43:59 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.4 2004/12/07 06:10:11 shadow Exp $");
  
  #include <linux/version.h>
  #ifdef AFS_LINUX22_ENV
***************
*** 67,73 ****
      }
  
      TO_USER_SPACE();
!     sockp->ops->setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, &pmtu, sizeof(pmtu));
      TO_KERNEL_SPACE();
      return (struct osi_socket *)sockp;
  }
--- 67,74 ----
      }
  
      TO_USER_SPACE();
!     sockp->ops->setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu,
!                            sizeof(pmtu));
      TO_KERNEL_SPACE();
      return (struct osi_socket *)sockp;
  }
***************
*** 208,215 ****
      read_unlock(&tasklist_lock);
  #endif
      while (rxk_ListenerPid) {
- 	struct task_struct *p;
- 
  	flush_signals(listener);
  	force_sig(SIGKILL, listener);
  	afs_osi_Sleep(&rxk_ListenerPid);
--- 209,214 ----
Index: openafs/src/rxdebug/rxdebug.c
diff -c openafs/src/rxdebug/rxdebug.c:1.5 openafs/src/rxdebug/rxdebug.c:1.5.2.1
*** openafs/src/rxdebug/rxdebug.c:1.5	Tue Jul 15 19:16:38 2003
--- openafs/src/rxdebug/rxdebug.c	Tue Dec  7 01:17:15 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxdebug/rxdebug.c,v 1.5 2003/07/15 23:16:38 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxdebug/rxdebug.c,v 1.5.2.1 2004/12/07 06:17:15 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
***************
*** 21,26 ****
--- 21,27 ----
  #include <sys/socket.h>
  #include <sys/file.h>
  #include <netdb.h>
+ #include <arpa/inet.h>
  #endif
  #ifdef HAVE_NETINET_IN_H
  #include <netinet/in.h>
Index: openafs/src/rxkad/Makefile.in
diff -c openafs/src/rxkad/Makefile.in:1.19.2.1 openafs/src/rxkad/Makefile.in:1.19.2.2
*** openafs/src/rxkad/Makefile.in:1.19.2.1	Mon Oct 18 03:12:08 2004
--- openafs/src/rxkad/Makefile.in	Tue Dec  7 00:49:39 2004
***************
*** 87,100 ****
   
  md5.o: md5.c ${INCLS}
  
! fcrypt.o: domestic/fcrypt.c fcrypt.h sboxes.h rxkad.h rxkad_prototypes.h
! 	${CCOBJ} ${CFLAGS} -c domestic/fcrypt.c
  
! crypt_conn.o: domestic/crypt_conn.c fcrypt.h private_data.h ${INCLS}
! 	${CCOBJ} ${CFLAGS} -c domestic/crypt_conn.c
  
! tcrypt.o: domestic/tcrypt.c AFS_component_version_number.o
! 	${CCOBJ} ${CFLAGS} -c domestic/fcrypt.c
  
  tcrypt: tcrypt.o librxkad.a 
  	${CC} -o tcrypt tcrypt.o librxkad.a
--- 87,100 ----
   
  md5.o: md5.c ${INCLS}
  
! fcrypt.o: ${srcdir}/domestic/fcrypt.c fcrypt.h sboxes.h rxkad.h rxkad_prototypes.h
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/domestic/fcrypt.c
  
! crypt_conn.o: ${srcdir}/domestic/crypt_conn.c fcrypt.h private_data.h ${INCLS}
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/domestic/crypt_conn.c
  
! tcrypt.o: ${srcdir}/domestic/tcrypt.c AFS_component_version_number.o
! 	${CCOBJ} ${CFLAGS} -c ${srcdir}/domestic/fcrypt.c
  
  tcrypt: tcrypt.o librxkad.a 
  	${CC} -o tcrypt tcrypt.o librxkad.a
Index: openafs/src/rxkad/rxkad.p.h
diff -c openafs/src/rxkad/rxkad.p.h:1.11.2.3 openafs/src/rxkad/rxkad.p.h:1.11.2.4
*** openafs/src/rxkad/rxkad.p.h:1.11.2.3	Mon Oct 18 13:44:00 2004
--- openafs/src/rxkad/rxkad.p.h	Tue Dec  7 11:48:43 2004
***************
*** 16,22 ****
--- 16,32 ----
  		/* no ticket good for longer than 30 days */
  #define MAXKTCTICKETLIFETIME (30*24*3600)
  #define MINKTCTICKETLEN	      32
+ 
+ #if defined(AFS_AIX52_ENV)
+ #ifdef __XCOFF64__
  #define	MAXKTCTICKETLEN	      12000	/* was 344 */
+ #else
+ #define MAXKTCTICKETLEN		344
+ #endif
+ #else
+ #define	MAXKTCTICKETLEN	      12000	/* was 344 */
+ #endif
+ 
  #define	MAXKTCNAMELEN	      64	/* name & inst should be 256 */
  #define MAXKTCREALMLEN	      64	/* should be 256 */
  #define KTC_TIME_UNCERTAINTY (15*60)	/* max skew bet. machines' clocks */
Index: openafs/src/rxkad/rxkad_common.c
diff -c openafs/src/rxkad/rxkad_common.c:1.20.2.1 openafs/src/rxkad/rxkad_common.c:1.20.2.2
*** openafs/src/rxkad/rxkad_common.c:1.20.2.1	Wed Aug 25 03:09:42 2004
--- openafs/src/rxkad/rxkad_common.c	Tue Dec  7 01:10:16 2004
***************
*** 23,29 ****
  #define INCLUDE_RXKAD_PRIVATE_DECLS
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxkad/rxkad_common.c,v 1.20.2.1 2004/08/25 07:09:42 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 23,29 ----
  #define INCLUDE_RXKAD_PRIVATE_DECLS
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxkad/rxkad_common.c,v 1.20.2.2 2004/12/07 06:10:16 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 83,89 ****
  #endif
  /* variable initialization for the benefit of darwin compiler; if it causes
     problems elsewhere, conditionalize for darwin or fc_test compile breaks */
! struct rxkad_stats rxkad_stats = { 0 };
  
  /* static prototypes */
  static afs_int32 ComputeSum(struct rx_packet *apacket,
--- 83,89 ----
  #endif
  /* variable initialization for the benefit of darwin compiler; if it causes
     problems elsewhere, conditionalize for darwin or fc_test compile breaks */
! struct rxkad_stats rxkad_stats = { { 0 } };
  
  /* static prototypes */
  static afs_int32 ComputeSum(struct rx_packet *apacket,
***************
*** 421,427 ****
      fc_KeySchedule *schedule;
      fc_InitializationVector *ivec;
      int len;
!     int nlen;
      int word;
      afs_int32 code;
      afs_int32 *preSeq;
--- 421,427 ----
      fc_KeySchedule *schedule;
      fc_InitializationVector *ivec;
      int len;
!     int nlen = 0;
      int word;
      afs_int32 code;
      afs_int32 *preSeq;
Index: openafs/src/rxkad/rxkad_prototypes.h
diff -c openafs/src/rxkad/rxkad_prototypes.h:1.9.2.2 openafs/src/rxkad/rxkad_prototypes.h:1.9.2.3
*** openafs/src/rxkad/rxkad_prototypes.h:1.9.2.2	Mon Oct 18 13:44:00 2004
--- openafs/src/rxkad/rxkad_prototypes.h	Tue Dec  7 01:10:16 2004
***************
*** 50,63 ****
  extern void rxkad_ResetState(void);
  
  /* rxkad_common.c */
! #if 0
! /* can't prototype these due to types */
  extern int rxkad_SetupEndpoint(struct rx_connection *aconnp,
  			       struct rxkad_endpoint *aendpointp);
  extern afs_uint32 rxkad_CksumChallengeResponse(struct
  					       rxkad_v2ChallengeResponse
  					       *v2r);
- #endif
  extern int rxkad_DeriveXORInfo(struct rx_connection *aconnp,
  			       fc_KeySchedule * aschedule, char *aivec,
  			       char *aresult);
--- 50,62 ----
  extern void rxkad_ResetState(void);
  
  /* rxkad_common.c */
! struct rxkad_endpoint;
  extern int rxkad_SetupEndpoint(struct rx_connection *aconnp,
  			       struct rxkad_endpoint *aendpointp);
+ struct rxkad_v2ChallengeResponse;
  extern afs_uint32 rxkad_CksumChallengeResponse(struct
  					       rxkad_v2ChallengeResponse
  					       *v2r);
  extern int rxkad_DeriveXORInfo(struct rx_connection *aconnp,
  			       fc_KeySchedule * aschedule, char *aivec,
  			       char *aresult);
Index: openafs/src/shlibafsauthent/Makefile.in
diff -c openafs/src/shlibafsauthent/Makefile.in:1.9.2.1 openafs/src/shlibafsauthent/Makefile.in:1.9.2.2
*** openafs/src/shlibafsauthent/Makefile.in:1.9.2.1	Mon Oct 18 03:12:12 2004
--- openafs/src/shlibafsauthent/Makefile.in	Tue Dec  7 01:04:29 2004
***************
*** 63,70 ****
  	pthread_glock.o \
  	get_krbrlm.o \
  	dirpath.o \
! 	fileutil.o \
! 	casestrcpy.o
  
  RXKADOBJS = \
  	rxkad_errs.o
--- 63,69 ----
  	pthread_glock.o \
  	get_krbrlm.o \
  	dirpath.o \
! 	fileutil.o
  
  RXKADOBJS = \
  	rxkad_errs.o
***************
*** 197,205 ****
  fileutil.o: ${UTIL}/fileutil.c
  	${CCRULE}
  
- casestrcpy.o: ${UTIL}/casestrcpy.c
- 	${CCRULE}
- 
  pthread_glock.o: ${UTIL}/pthread_glock.c
  	${CCRULE}
  
--- 196,201 ----
Index: openafs/src/shlibafsrpc/Makefile.in
diff -c openafs/src/shlibafsrpc/Makefile.in:1.15.2.1 openafs/src/shlibafsrpc/Makefile.in:1.15.2.3
*** openafs/src/shlibafsrpc/Makefile.in:1.15.2.1	Mon Oct 18 03:12:14 2004
--- openafs/src/shlibafsrpc/Makefile.in	Tue Dec  7 09:24:16 2004
***************
*** 37,42 ****
--- 37,43 ----
  	syscall.o
  
  UTILOBJS =\
+ 	assert.o \
  	casestrcpy.o \
  	base64.o
  
***************
*** 273,279 ****
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.15.2.1 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
--- 274,280 ----
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.15.2.3 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
***************
*** 343,348 ****
--- 344,352 ----
  casestrcpy.o: ${UTIL}/casestrcpy.c
  	${CCRULE}
  
+ assert.o: ${UTIL}/assert.c
+ 	${CCRULE}
+ 
  base64.o: ${UTIL}/base64.c
  	${CCRULE}
  
Index: openafs/src/sys/NTMakefile
diff -c openafs/src/sys/NTMakefile:1.6 openafs/src/sys/NTMakefile:1.6.2.1
*** openafs/src/sys/NTMakefile:1.6	Fri Mar  5 18:09:36 2004
--- openafs/src/sys/NTMakefile	Tue Dec  7 01:15:58 2004
***************
*** 24,30 ****
  	$(OUT)\pioctl_nt.obj
  
  $(LIBFILE): $(LIBOBJS) $(DESTDIR)\lib\lanahelper.lib
! 	$(LIBARCH) $(DESTDIR)\lib\lanahelper.lib
  
  ############################################################################
  # Install target; primary makefile target
--- 24,30 ----
  	$(OUT)\pioctl_nt.obj
  
  $(LIBFILE): $(LIBOBJS) $(DESTDIR)\lib\lanahelper.lib
! 	$(LIBARCH) $(DESTDIR)\lib\lanahelper.lib secur32.lib
  
  ############################################################################
  # Install target; primary makefile target
Index: openafs/src/sys/pioctl_nt.c
diff -c openafs/src/sys/pioctl_nt.c:1.18.2.3 openafs/src/sys/pioctl_nt.c:1.18.2.5
*** openafs/src/sys/pioctl_nt.c:1.18.2.3	Fri Nov  5 14:21:58 2004
--- openafs/src/sys/pioctl_nt.c	Tue Dec  7 01:15:58 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/sys/pioctl_nt.c,v 1.18.2.3 2004/11/05 19:21:58 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <windows.h>
--- 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>
***************
*** 22,27 ****
--- 22,29 ----
  #include <string.h>
  #include <winioctl.h>
  #include <winsock2.h>
+ #define SECURITY_WIN32
+ #include <security.h>
  #include <nb30.h>
  
  #include <osi.h>
***************
*** 129,134 ****
--- 131,145 ----
      char netbiosName[MAX_NB_NAME_LENGTH];
      char tbuffer[256]="";
      HANDLE fh;
+     HKEY hk;
+     char szUser[128] = "";
+     char szClient[MAX_PATH] = "";
+     char szPath[MAX_PATH] = "";
+     NETRESOURCE nr;
+     DWORD res;
+     DWORD ioctlDebug = IoctlDebug();
+     DWORD gle;
+     DWORD dwSize = sizeof(szUser);
  
      if (fileNamep) {
          drivep = strchr(fileNamep, ':');
***************
*** 188,202 ****
  		    FILE_FLAG_WRITE_THROUGH, NULL);
      fflush(stdout);
      if (fh == INVALID_HANDLE_VALUE) {
-         HKEY hk;
-         char szUser[64] = "";
-         char szClient[MAX_PATH] = "";
-         char szPath[MAX_PATH] = "";
-         NETRESOURCE nr;
-         DWORD res;
-         DWORD ioctlDebug = IoctlDebug();
-         DWORD gle;
- 
          gle = GetLastError();
          if (gle && ioctlDebug ) {
              char buf[4096];
--- 199,204 ----
***************
*** 210,271 ****
                                 (va_list *) NULL
                                 ) )
              {
!                 fprintf(stderr,"pioctl CreateFile(%s) failed: [%s]\r\n",tbuffer,buf);
              }
          }
          if (gle != ERROR_DOWNGRADE_DETECTED)
              return -1;                                   
  
          lana_GetNetbiosName(szClient, LANA_NETBIOS_NAME_FULL);
-         sprintf(szPath, "\\\\%s", szClient);
  
-         /* We should probably be using GetUserNameEx() for this */
          if (RegOpenKey (HKEY_CURRENT_USER, 
!                         TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"), &hk) == 0)
          {
-             DWORD dwSize = sizeof(szUser);
              DWORD dwType = REG_SZ;
              RegQueryValueEx (hk, TEXT("Logon User Name"), NULL, &dwType, (PBYTE)szUser, &dwSize);
              RegCloseKey (hk);
          }
-         if ( ioctlDebug )
-             fprintf(stderr, "pioctl logon user: [%s]\r\n",szUser);
  
!         memset (&nr, 0x00, sizeof(NETRESOURCE));
!         nr.dwType=RESOURCETYPE_DISK;
!         nr.lpLocalName=0;
!         nr.lpRemoteName=szPath;
!         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,
!                          FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
!                          FILE_FLAG_WRITE_THROUGH, NULL);
!         fflush(stdout);
!         if (fh == INVALID_HANDLE_VALUE) {
!             gle = GetLastError();
!             if (gle && ioctlDebug ) {
!                 char buf[4096];
! 
!                 if ( FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
!                                     NULL,
!                                     gle,
!                                     MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
!                                     buf,
!                                     4096,
!                                     (va_list *) NULL
!                                     ) )
!                 {
!                     fprintf(stderr,"pioctl CreateFile(%s) failed: [%s]\r\n",tbuffer,buf);
                  }
              }
-             return -1;
          }
      }
  
--- 212,342 ----
                                 (va_list *) NULL
                                 ) )
              {
!                 fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%8X\r\n\t[%s]\r\n",
!                         tbuffer,gle,buf);
              }
          }
+ #ifdef COMMENT
          if (gle != ERROR_DOWNGRADE_DETECTED)
              return -1;                                   
+ #endif
  
          lana_GetNetbiosName(szClient, LANA_NETBIOS_NAME_FULL);
  
          if (RegOpenKey (HKEY_CURRENT_USER, 
!                          TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer"), &hk) == 0)
          {
              DWORD dwType = REG_SZ;
              RegQueryValueEx (hk, TEXT("Logon User Name"), NULL, &dwType, (PBYTE)szUser, &dwSize);
              RegCloseKey (hk);
          }
  
!         if ( szUser[0] ) {
!             if ( ioctlDebug )
!                 fprintf(stderr, "pioctl logon user: [%s]\r\n",szUser);
! 
!             sprintf(szPath, "\\\\%s", szClient);
!             memset (&nr, 0x00, sizeof(NETRESOURCE));
!             nr.dwType=RESOURCETYPE_DISK;
!             nr.lpLocalName=0;
!             nr.lpRemoteName=szPath;
!             res = WNetAddConnection2(&nr,NULL,szUser,0);
!             if (res) {
!                 if ( ioctlDebug ) {
!                     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);
!             fflush(stdout);
!             if (fh == INVALID_HANDLE_VALUE) {
!                 gle = GetLastError();
!                 if (gle && ioctlDebug ) {
!                     char buf[4096];
! 
!                     if ( FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
!                                         NULL,
!                                         gle,
!                                         MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
!                                         buf,
!                                         4096,
!                                         (va_list *) NULL
!                                         ) )
!                     {
!                         fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%8X\r\n\t[%s]\r\n",
!                                  tbuffer,gle,buf);
!                     }
!                 }
              }
          }
+     }
+ 
+   next_attempt:
+     if ( fh == INVALID_HANDLE_VALUE ) {
+         if (GetUserNameEx(NameSamCompatible, szUser, &dwSize)) {
+             if ( ioctlDebug )
+                 fprintf(stderr, "pioctl logon user: [%s]\r\n",szUser);
+ 
+             sprintf(szPath, "\\\\%s", szClient);
+             memset (&nr, 0x00, sizeof(NETRESOURCE));
+             nr.dwType=RESOURCETYPE_DISK;
+             nr.lpLocalName=0;
+             nr.lpRemoteName=szPath;
+             res = WNetAddConnection2(&nr,NULL,szUser,0);
+             if (res) {
+                 if ( ioctlDebug ) {
+                     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,
!                              FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING,
!                              FILE_FLAG_WRITE_THROUGH, NULL);
!             fflush(stdout);
!             if (fh == INVALID_HANDLE_VALUE) {
!                 gle = GetLastError();
!                 if (gle && ioctlDebug ) {
!                     char buf[4096];
! 
!                     if ( FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,
!                                         NULL,
!                                         gle,
!                                         MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),
!                                         buf,
!                                         4096,
!                                         (va_list *) NULL
!                                         ) )
!                     {
!                         fprintf(stderr,"pioctl CreateFile(%s) failed: 0x%8X\r\n\t[%s]\r\n",
!                                  tbuffer,gle,buf);
!                     }
                  }
+                 return -1;
              }
          }
      }
  
Index: openafs/src/vol/Makefile.in
diff -c openafs/src/vol/Makefile.in:1.18 openafs/src/vol/Makefile.in:1.18.2.1
*** openafs/src/vol/Makefile.in:1.18	Thu Apr  1 17:26:24 2004
--- openafs/src/vol/Makefile.in	Tue Dec  7 01:06:17 2004
***************
*** 25,31 ****
  	 clone.o nuke.o devname.o listinodes.o common.o ihandle.o \
  	 namei_ops.o fstab.o
  
! OBJECTS=${VLIBOBJS} physio.o vol-salvage.o vol-info.o vol-dump.o
  
  all: gi \
  	${TOP_LIBDIR}/vlib.a \
--- 25,31 ----
  	 clone.o nuke.o devname.o listinodes.o common.o ihandle.o \
  	 namei_ops.o fstab.o
  
! OBJECTS=${VLIBOBJS} physio.o vol-salvage.o vol-info.o vol-dump.o vol-bless.o
  
  all: gi \
  	${TOP_LIBDIR}/vlib.a \
***************
*** 164,169 ****
--- 164,172 ----
  	${CC} ${CFLAGS} -o volinfo vol-info.o physio.o \
  		ihandle.o fstab.o ${LIBS} ${XLIBS}
  
+ vol-bless: vol-bless.o physio.o ihandle.o ${LIBS}
+ 	${CC} ${CFLAGS} -o vol-bless vol-bless.o physio.o ${LIBS} ${XLIBS}
+ 
  fs_conv_dux40D: fs_conv_411.o
  	${CC} ${CFLAGS} ${TOP_LIBDIR}/libcmd.a -o fs_conv_dux40D fs_conv_411.o  ${LIBS} ${XLIBS}
  
***************
*** 282,285 ****
  	    vnode.c volume.c vutil.c partition.c fssync.c purge.c \
  	    clone.c nuke.c devname.c listinodes.c common.c ihandle.c \
  	    namei_ops.c \
! 	    physio.c vol-salvage.c vol-info.c
--- 285,288 ----
  	    vnode.c volume.c vutil.c partition.c fssync.c purge.c \
  	    clone.c nuke.c devname.c listinodes.c common.c ihandle.c \
  	    namei_ops.c \
! 	    physio.c vol-salvage.c vol-info.c vol-bless.c
Index: openafs/src/vol/NTMakefile
diff -c openafs/src/vol/NTMakefile:1.5 openafs/src/vol/NTMakefile:1.5.2.1
*** openafs/src/vol/NTMakefile:1.5	Fri Nov 21 03:01:37 2003
--- openafs/src/vol/NTMakefile	Tue Dec  7 01:06:17 2004
***************
*** 90,95 ****
--- 90,103 ----
  	$(EXEPREP)
  
  ############################################################################
+ # build volinfo
+ VOLBLESS = $(DESTDIR)\root.server\usr\afs\bin\vol-bless.exe
+ 
+ $(VOLBLESS): $(OUT)\vol-bless.obj $(OUT)\physio.obj $(OUT)\vol-bless.res $(EXEC_LIBS)
+ 	$(EXECONLINK)
+ 	$(EXEPREP)
+ 
+ ############################################################################
  # generate versioninfo resources
  $(OUT)\salvager.res: salvager.rc AFS_component_version_number.h
  
Index: openafs/src/vol/vol-bless.c
diff -c /dev/null openafs/src/vol/vol-bless.c:1.1.2.1
*** /dev/null	Wed Dec  8 12:55:05 2004
--- openafs/src/vol/vol-bless.c	Tue Dec  7 01:06:17 2004
***************
*** 0 ****
--- 1,86 ----
+ /*
+  * 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
+  */
+ 
+ #include <afsconfig.h>
+ #include <afs/param.h>
+ 
+ RCSID
+     ("$Header: /cvs/openafs/src/vol/vol-bless.c,v 1.1.2.1 2004/12/07 06:06:17 shadow Exp $");
+ 
+ #include <stdio.h>
+ 
+ #include <afs/cmd.h>
+ 
+ #include <rx/xdr.h>
+ #include <afs/afsint.h>
+ #include "nfs.h"
+ #include "lock.h"
+ #include "ihandle.h"
+ #include "vnode.h"
+ #include "volume.h"
+ 
+ int VolumeChanged; /* to keep physio happy */
+ 
+ static int
+ handleit(struct cmd_syndesc *as, char *arock)
+ {
+     Volume *vp;
+     Error ec;
+     int bless, unbless, nofssync;
+     int volumeId;
+ 
+     volumeId = atoi(as->parms[0].items->data);
+     bless    = !!(as->parms[1].items);
+     unbless  = !!(as->parms[2].items);
+     nofssync = !!(as->parms[3].items);
+ 
+     if (bless && unbless) {
+ 	fprintf(stderr,"Cannot use both -bless and -unbless\n");
+ 	exit(1);
+     }
+ 
+     if (VInitVolumePackage(nofssync ? salvager : volumeUtility, 5, 5, 1, 0)) {
+ 	fprintf(stderr,"Unable to initialize volume package\n");
+ 	exit(1);
+     }
+ 
+     vp = VAttachVolume(&ec, volumeId, V_VOLUPD);
+     if (ec) {
+ 	fprintf(stderr,"VAttachVolume failed: %d\n", ec);
+ 	exit(1);
+     }
+     if (bless) V_blessed(vp) = 1;
+     if (unbless) V_blessed(vp) = 0;
+     VUpdateVolume(&ec, vp);
+     if (ec) {
+ 	fprintf(stderr,"VUpdateVolume failed: %d\n", ec);
+ 	VPutVolume(vp);
+ 	exit(1);
+     }
+     VPutVolume(vp);
+     return 0;
+ }
+ 
+ int
+ main(int argc, char **argv)
+ {
+     register struct cmd_syndesc *ts;
+     afs_int32 code;
+ 
+     ts = cmd_CreateSyntax(NULL, handleit, 0, "Manipulate volume blessed bit");
+     cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_REQUIRED, "Volume id");
+     cmd_AddParm(ts, "-bless", CMD_FLAG, CMD_OPTIONAL, "Set blessed bit");
+     cmd_AddParm(ts, "-unbless", CMD_FLAG, CMD_OPTIONAL, "Clear blessed bit");
+     cmd_AddParm(ts, "-nofssync", CMD_FLAG, CMD_OPTIONAL,
+ 		"Don't communicate with running fileserver");
+     code = cmd_Dispatch(argc, argv);
+     return code;
+ }
+ 
+ 
Index: openafs/src/volser/vsutils.c
diff -c openafs/src/volser/vsutils.c:1.16.2.1 openafs/src/volser/vsutils.c:1.16.2.2
*** openafs/src/volser/vsutils.c:1.16.2.1	Mon Oct 18 03:12:29 2004
--- openafs/src/volser/vsutils.c	Tue Dec  7 11:37:09 2004
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsutils.c,v 1.16.2.1 2004/10/18 07:12:29 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsutils.c,v 1.16.2.2 2004/12/07 16:37:09 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef AFS_NT40_ENV
***************
*** 490,556 ****
       afs_int32 *errp;
       char *astring;
  {
!     afs_uint32 tc, value;
! 
!     char *str, *ptr, volname[VOLSER_OLDMAXVOLNAME + 1];
!     int tryname, curval;
      struct nvldbentry entry;
      afs_int32 vcode = 0;
      int total;
  
      *errp = 0;
!     total = strlen(astring);
!     str = astring;
!     ptr = astring;
!     tryname = 0;
!     while ((curval = *str++)) {
! 	if (curval < '0' || curval > '9')
! 	    tryname = 1;
!     }
! 
!     if (tryname) {
! 	vsu_ExtractName(volname, astring);
! 	vcode = VLDB_GetEntryByName(volname, &entry);
! 	if (!vcode) {
! 	    if (!strcmp(&astring[total - 9], ".readonly"))
! 		return entry.volumeId[ROVOL];
! 	    else if ((!strcmp(&astring[total - 7], ".backup")))
! 		return entry.volumeId[BACKVOL];
! 	    else
! 		return (entry.volumeId[RWVOL]);
! 	} else {
! 	    *errp = vcode;
! 	    return 0;		/* can't find volume */
! 	}
      }
  
!     value = 0;
!     while ((tc = *astring++)) {
! 	if (tc & 0x80) {
! 	    if (!tryname)
! 		fprintf(STDERR, "goofed in volid \n");
! 	    else {
! 		fprintf(STDERR, "Could not get entry from vldb for %s\n",
! 			ptr);
! 		PrintError("", vcode);
! 	    }
! 	    *errp = EINVAL;
! 	    return 0;
! 	}
! 	if (tc < '0' || tc > '9') {
! 	    if (!tryname)
! 		fprintf(STDERR,
! 			"internal error: out of range char in vol ID\n");
! 	    else {
! 		fprintf(STDERR, "Could not get entry from vldb for %s\n",
! 			ptr);
! 		PrintError("", vcode);
! 	    }
! 	    *errp = ERANGE;
! 	    return 0;
! 	}
! 	value *= 10;
! 	value += (tc - '0');
      }
!     return value;
  }
--- 490,523 ----
       afs_int32 *errp;
       char *astring;
  {
!     afs_uint32 value;
!     char volname[VOLSER_OLDMAXVOLNAME + 1];
      struct nvldbentry entry;
      afs_int32 vcode = 0;
      int total;
  
      *errp = 0;
! 
!     if (isdigit(astring[0])) {
! 	char *end;
! 	afs_uint32 result;
! 	result = strtoul(astring, &end, 10);
! 	if (result != ULONG_MAX && *end == '\0')
! 	    return result;
      }
  
!     /* It was not a volume number but something else */
!     total = strlen(astring);
!     vsu_ExtractName(volname, astring);
!     vcode = VLDB_GetEntryByName(volname, &entry);
!     if (!vcode) {
!       if (!strcmp(&astring[total - 9], ".readonly"))
! 	return entry.volumeId[ROVOL];
!       else if ((!strcmp(&astring[total - 7], ".backup")))
! 	return entry.volumeId[BACKVOL];
!       else
! 	return (entry.volumeId[RWVOL]);
      }
!     *errp = vcode;
!     return 0;		/* can't find volume */
  }
