Index: openafs/src/libafsdep
diff -c openafs/src/libafsdep:1.2 openafs/src/libafsdep:1.2.2.1
*** openafs/src/libafsdep:1.2	Sun Mar  9 20:51:13 2003
--- openafs/src/libafsdep	Tue Jun 21 16:16:29 2005
***************
*** 3,8 ****
--- 3,9 ----
  util/uuid.c
  util/unified_afs.*
  dir/dir.c
+ des/stats.h
  fsint/afsaux.c
  fsint/K*.[ch]
  fsint/*.xg
Index: openafs/src/ntbuild.bat
diff -c openafs/src/ntbuild.bat:1.16 openafs/src/ntbuild.bat:1.16.2.1
*** openafs/src/ntbuild.bat:1.16	Mon Aug  9 00:20:12 2004
--- openafs/src/ntbuild.bat	Wed Jul  6 10:11:58 2005
***************
*** 20,27 ****
  REM ########################################################################
  REM General required definitions:
  REM     SYS_NAME = AFS system name
! REM Choose one of "i386_win95" or "i386_nt40"
! SET SYS_NAME=i386_nt40
  
  REM Specify the targeted version of Windows and IE: 0x400 for Win9x/NT4 
  REM and above; 0x500 for Windows 2000 and above
--- 20,27 ----
  REM ########################################################################
  REM General required definitions:
  REM     SYS_NAME = AFS system name
! REM Choose one of "i386_w2k", "amd64_w2k", or "i64_w2k"
! SET SYS_NAME=i386_w2k
  
  REM Specify the targeted version of Windows and IE: 0x400 for Win9x/NT4 
  REM and above; 0x500 for Windows 2000 and above
***************
*** 83,95 ****
  :checked
  set AFSBLD_TYPE=CHECKED
  set AFSDEV_CRTDEBUG=1
! goto args_done
  
  :free
  set AFSBLD_TYPE=FREE
  set AFSDEV_CRTDEBUG=0
  goto args_done
  
  :args_done
  
  REM #######################################################################
--- 83,107 ----
  :checked
  set AFSBLD_TYPE=CHECKED
  set AFSDEV_CRTDEBUG=1
! goto ifs_arg
  
  :free
  set AFSBLD_TYPE=FREE
  set AFSDEV_CRTDEBUG=0
+ goto ifs_arg
+ 
+ :ifs_arg
+ 
+ set AFSIFS=
+ if "%2"=="ifs" goto is_ifs
+ if "%2"=="IFS" goto is_ifs
+ 
  goto args_done
  
+ :is_ifs
+ 
+ set AFSIFS=TRUE
+ 
  :args_done
  
  REM #######################################################################
Index: openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrCallback.cpp
diff -c openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrCallback.cpp:1.3 openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrCallback.cpp:1.3.2.1
*** openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrCallback.cpp:1.3	Sat Feb 28 21:38:26 2004
--- openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrCallback.cpp	Wed Jul  6 20:28:59 2005
***************
*** 77,83 ****
        AfsAdmSvr_Enter();
  
        LPHASHLIST pList = New (HASHLIST);
!       for (LPENUM pEnum = l.pListCallbacks->FindFirst(); pEnum; pEnum = pEnum->FindNext())
           {
           LPCALLBACKDATA pData = (LPCALLBACKDATA)( pEnum->GetObject() );
           pList->Add (pData);
--- 77,84 ----
        AfsAdmSvr_Enter();
  
        LPHASHLIST pList = New (HASHLIST);
!       LPENUM pEnum;
!       for (pEnum = l.pListCallbacks->FindFirst(); pEnum; pEnum = pEnum->FindNext())
           {
           LPCALLBACKDATA pData = (LPCALLBACKDATA)( pEnum->GetObject() );
           pList->Add (pData);
Index: openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientNotify.cpp
diff -c openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientNotify.cpp:1.2 openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientNotify.cpp:1.2.20.1
*** openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientNotify.cpp:1.2	Sat Nov  4 05:01:14 2000
--- openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientNotify.cpp	Wed Jul  6 20:28:59 2005
***************
*** 193,203 ****
  BOOL SetActionNotification (HWND hNotify, BOOL fSet)
  {
     BOOL rc = TRUE;
     asc_Enter();
  
     if (!fSet)
        {
!       for (size_t ii = 0; ii < l.chActionListeners; ++ii)
           {
           if (l.ahActionListeners[ ii ] == hNotify)
              l.ahActionListeners[ ii ] = NULL;
--- 193,205 ----
  BOOL SetActionNotification (HWND hNotify, BOOL fSet)
  {
     BOOL rc = TRUE;
+    size_t ii = 0;
+ 
     asc_Enter();
  
     if (!fSet)
        {
!       for (ii = 0; ii < l.chActionListeners; ++ii)
           {
           if (l.ahActionListeners[ ii ] == hNotify)
              l.ahActionListeners[ ii ] = NULL;
***************
*** 205,211 ****
        }
     else // (fSet)
        {
!       for (size_t ii = 0; ii < l.chActionListeners; ++ii)
           {
           if (l.ahActionListeners[ ii ] == NULL)
              break;
--- 207,213 ----
        }
     else // (fSet)
        {
!       for (ii = 0; ii < l.chActionListeners; ++ii)
           {
           if (l.ahActionListeners[ ii ] == NULL)
              break;
Index: openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientPing.cpp
diff -c openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientPing.cpp:1.2 openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientPing.cpp:1.2.20.1
*** openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientPing.cpp:1.2	Sat Nov  4 05:01:15 2000
--- openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrClientPing.cpp	Wed Jul  6 20:28:59 2005
***************
*** 51,57 ****
  {
     asc_Enter();
  
!    for (size_t ii = 0; ii < l.cdwClients; ++ii)
        {
        if (!l.adwClients[ ii ])
           break;
--- 51,58 ----
  {
     asc_Enter();
  
!    size_t ii;
!    for (ii = 0; ii < l.cdwClients; ++ii)
        {
        if (!l.adwClients[ ii ])
           break;
Index: openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp
diff -c openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp:1.2 openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp:1.2.20.1
*** openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp:1.2	Sat Nov  4 05:01:16 2000
--- openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp	Wed Jul  6 20:28:59 2005
***************
*** 128,134 ****
  BOOL AfsAdmSvr_AttachClient (LPCTSTR pszName, DWORD *pidClient, ULONG *pStatus)
  {
     AfsAdmSvr_Enter();
!    for (size_t iClient = 0; iClient < l.cClientsAllocated; ++iClient)
        {
        if (!l.aClients[ iClient ])
           break;
--- 128,135 ----
  BOOL AfsAdmSvr_AttachClient (LPCTSTR pszName, DWORD *pidClient, ULONG *pStatus)
  {
     AfsAdmSvr_Enter();
!    size_t iClient;
!    for (iClient = 0; iClient < l.cClientsAllocated; ++iClient)
        {
        if (!l.aClients[ iClient ])
           break;
***************
*** 160,166 ****
  void AfsAdmSvr_DetachClient (DWORD idClient)
  {
     AfsAdmSvr_Enter();
!    for (size_t iClient = 0; iClient < l.cClientsAllocated; ++iClient)
        {
        if (idClient == (DWORD)(l.aClients[ iClient ]))
           break;
--- 161,168 ----
  void AfsAdmSvr_DetachClient (DWORD idClient)
  {
     AfsAdmSvr_Enter();
!    size_t iClient;
!    for (iClient = 0; iClient < l.cClientsAllocated; ++iClient)
        {
        if (idClient == (DWORD)(l.aClients[ iClient ]))
           break;
***************
*** 464,470 ****
  
     ++l.cOperations;
  
!    for (size_t iOp = 0; iOp < l.cOperationsAllocated; ++iOp)
        {
        if (!l.aOperations[ iOp ].fInUse)
           break;
--- 466,473 ----
  
     ++l.cOperations;
  
!    size_t iOp;
!    for (iOp = 0; iOp < l.cOperationsAllocated; ++iOp)
        {
        if (!l.aOperations[ iOp ].fInUse)
           break;
Index: openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrProperties.cpp
diff -c openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrProperties.cpp:1.2 openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrProperties.cpp:1.2.20.1
*** openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrProperties.cpp:1.2	Sat Nov  4 05:01:16 2000
--- openafs/src/WINNT/afsadmsvr/TaAfsAdmSvrProperties.cpp	Wed Jul  6 20:28:59 2005
***************
*** 108,114 ****
     AfsAdmSvr_PrepCellRefresh();
     EnterCriticalSection (l.pcsRefreshThreads);
  
!    for (size_t iThread = 0; iThread < l.cRefreshThreads; ++iThread)
        {
        LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
        if (pThread->idCell == idCell)
--- 108,115 ----
     AfsAdmSvr_PrepCellRefresh();
     EnterCriticalSection (l.pcsRefreshThreads);
  
!    size_t iThread;
!    for (iThread = 0; iThread < l.cRefreshThreads; ++iThread)
        {
        LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
        if (pThread->idCell == idCell)
***************
*** 119,125 ****
        }
     if (iThread == l.cRefreshThreads)
        {
!       for (size_t iThread = 0; iThread < l.cRefreshThreads; ++iThread)
           {
           LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
           if (pThread->idCell == 0)
--- 120,126 ----
        }
     if (iThread == l.cRefreshThreads)
        {
!       for (iThread = 0; iThread < l.cRefreshThreads; ++iThread)
           {
           LPREFRESHTHREAD pThread = &l.aRefreshThreads[ iThread ];
           if (pThread->idCell == 0)
Index: openafs/src/WINNT/afsapplib/NTMakefile
diff -c openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.4 openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.5
*** openafs/src/WINNT/afsapplib/NTMakefile:1.5.2.4	Fri Mar 11 01:58:36 2005
--- openafs/src/WINNT/afsapplib/NTMakefile	Wed Jul  6 20:28:59 2005
***************
*** 84,89 ****
--- 84,94 ----
  
  DLLFILE = $(DESTDIR)\root.server\usr\afs\bin\TaAfsAppLib.dll
  
+ !IF ("$(AFSVER_CL)"<"1400")
+ DEFFILE = TaAfsAppLib.def
+ !ELSE
+ DEFFILE = TaAfsAppLib2005.def
+ !ENDIF
  
  # Since AfsAppLib links with TaAfsAdmSvrClient.lib--and both need stuff
  # like the HashList code--we'll get lots of unnecessary 4049 warnings from
***************
*** 93,99 ****
  
  # AfsAppLib needs to use an explicit .DEF file to get its entry points public
  
! LOCALLINKFLAGS = $(LOCALLINKFLAGS) /DEF:TaAfsAppLib.def
  
  # Also, AfsAppLib has a specific DLL entry-point which should be used
  
--- 98,104 ----
  
  # AfsAppLib needs to use an explicit .DEF file to get its entry points public
  
! LOCALLINKFLAGS = $(LOCALLINKFLAGS) /DEF:$(DEFFILE)
  
  # Also, AfsAppLib has a specific DLL entry-point which should be used
  
Index: openafs/src/WINNT/afsapplib/TaAfsAppLib2005.def
diff -c /dev/null openafs/src/WINNT/afsapplib/TaAfsAppLib2005.def:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:11 2005
--- openafs/src/WINNT/afsapplib/TaAfsAppLib2005.def	Wed Jul  6 20:28:59 2005
***************
*** 0 ****
--- 1,100 ----
+ LIBRARY TAAFSAPPLIB
+ 
+ DESCRIPTION 'Transarc Application Base DLL'
+ 
+ EXPORTS
+ 
+     DllEntryPoint
+ 
+    ?TaLocaleReallocFunction@@YAHPAPAXIPAIII@Z
+    ?TaLocale_EnumModule@@YAHIPAPAUHINSTANCE__@@PAG@Z
+    ?TaLocale_GetDialogResource@@YAPBUDLGTEMPLATE@@HPAPAUHINSTANCE__@@@Z
+    ?TaLocale_GetLanguage@@YAGXZ
+    ?TaLocale_LoadCorrespondingModule@@YAPAUHINSTANCE__@@PAU1@G@Z
+    ?TaLocale_GetLanguageOverride@@YAGXZ
+    ?TaLocale_RemoveLanguageOverride@@YAXXZ
+    ?TaLocale_SetLanguageOverride@@YAXG@Z
+    ?TaLocale_LoadImage@@YAPAXHIHHI@Z
+    ?TaLocale_LoadMenu@@YAPAUHMENU__@@H@Z
+    ?TaLocale_LoadIcon@@YAPAUHICON__@@H@Z
+    ?TaLocale_LoadAccelerators@@YAPAUHACCEL__@@H@Z
+    ?TaLocale_GetResource@@YAPBXPBD0GPAPAUHINSTANCE__@@@Z
+    ?TaLocale_GetResourceEx@@YAPBXPBD0GPAPAUHINSTANCE__@@H@Z
+    ?TaLocale_GetStringResource@@YAPBUSTRINGTEMPLATE@@HPAPAUHINSTANCE__@@@Z
+    ?TaLocale_Initialize@@YAXXZ
+    ?TaLocale_SetLanguage@@YAXG@Z
+    ?TaLocale_SpecifyModule@@YAXPAUHINSTANCE__@@G@Z
+    ?Message@@YAHIHHPBDZZ
+    ?Message@@YAHIHPBD0ZZ
+    ?Message@@YAHIPBD00ZZ
+    ?Message@@YAHIPBDH0ZZ
+    ?Message_ThreadProc@@YGKPAX@Z
+    ?ModalDialog@@YAHHPAUHWND__@@P6GH0IIJ@Z@Z
+    ?ModalDialogParam@@YAHHPAUHWND__@@P6GH0IIJ@ZJ@Z
+    ?ModelessDialog@@YAPAUHWND__@@HPAU1@P6GH0IIJ@Z@Z
+    ?ModelessDialogParam@@YAPAUHWND__@@HPAU1@P6GH0IIJ@ZJ@Z
+    ?vMessage@@YAHIHHPBDPAD@Z
+    ?vMessage@@YAHIHPBD0PAD@Z
+    ?vMessage@@YAHIJJPBDPAD@Z
+    ?vMessage@@YAHIPBD00PAD@Z
+    ?vMessage@@YAHIPBDH0PAD@Z
+    ?AnsiToString@@YAPADPBD@Z
+    ?AnsiToUnicode@@YAPA_WPBD@Z
+    ?ChangeExtension@@YAXPADPBD1H@Z
+    ?CloneAnsi@@YAPADPAD@Z
+    ?CloneMultiString@@YAPADPBD@Z
+    ?CloneString@@YAPADPAD@Z
+    ?CloneUnicode@@YAPADPA_W@Z
+    ?CopyAnsiToString@@YAXPADPBDI@Z
+    ?CopyStringToAnsi@@YAXPADPBDI@Z
+    ?CopyAnsiToUnicode@@YAXPA_WPBDI@Z
+    ?CopyBaseFileName@@YAXPADPBD@Z
+    ?CopyStringToAnsi@@YAXPADPBDI@Z
+    ?CopyStringToUnicode@@YAXPA_WPBDI@Z
+    ?CopyUnicodeToAnsi@@YAXPADPB_WI@Z
+    ?CopyUnicodeToString@@YAXPADPB_WI@Z
+    ?FindBaseFileName@@YAPBDPBD@Z
+    ?FindExtension@@YAPBDPBD@Z
+    ?FixFormatString@@YAPADPAD@Z
+    ?FormatBytes@@YAXPAD0N@Z
+    ?FormatDouble@@YAXPAD0N@Z
+    ?FormatElapsed@@YAHPAD0PAU_SYSTEMTIME@@@Z
+    ?FormatError@@YAHPAD0K@Z
+    ?FormatLargeInt@@YAXPAD0PAT_LARGE_INTEGER@@@Z
+    ?FormatMultiString@@YAXPAPADHHPBDZZ
+    ?FormatMultiString@@YAXPAPADHPBD1ZZ
+    ?FormatSockAddr@@YAXPAD0PAUsockaddr_in@@@Z
+    ?FormatString@@YAPADHPBDZZ
+    ?FormatString@@YAPADPBD0ZZ
+    ?FormatTime@@YAHPAD0PAU_SYSTEMTIME@@HH@Z
+    ?FreeString@@YAXPBX0@Z
+    ?GetString@@YAXPADHH@Z
+    ?GetStringLength@@YAIH@Z
+    ?SearchMultiString@@YAHPBD0H@Z
+    ?SetErrorTranslationFunction@@YAXP6GHPADKG@Z@Z
+    ?StringToAnsi@@YAPADPBD@Z
+    ?StringToUnicode@@YAPA_WPBD@Z
+    ?TranslateError@@YAHPADK@Z
+    ?TranslateErrorFunc@@YAHPADKG@Z
+    ?UnicodeToAnsi@@YAPADPB_W@Z
+    ?UnicodeToString@@YAPADPB_W@Z
+    ?lsplitpath@@YAXPBDPAD111@Z
+    ?lstrchr@@YAPBDPBDD@Z
+    ?lstrncmpi@@YAHPBD0I@Z
+    ?lstrncpy@@YAXPADPBDI@Z
+    ?lstrrchr@@YAPBDPBDD@Z
+    ?lstrupr@@YAXPAD@Z
+    ?lstrzcpy@@YAXPADPBDI@Z
+    ?vFormatMultiString@@YAXPAPADHHPBDPAD@Z
+    ?vFormatMultiString@@YAXPAPADHJPBDPAD@Z
+    ?vFormatMultiString@@YAXPAPADHPBD1PAD@Z
+    ?vFormatString@@YAPADHPBDPAD@Z
+    ?vFormatString@@YAPADJPBDPAD@Z
+    ?vFormatString@@YAPADPBD0PAD@Z
+    ShowMemoryManager
+    WhileMemoryManagerShowing
+    IsMemoryManagerMessage
+    MemMgr_AllocateMemory
+    MemMgr_FreeMemory
+    MemMgr_TrackNew
+    MemMgr_TrackDelete
Index: openafs/src/WINNT/afsapplib/al_help.cpp
diff -c openafs/src/WINNT/afsapplib/al_help.cpp:1.2 openafs/src/WINNT/afsapplib/al_help.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/al_help.cpp:1.2	Sat Nov  4 05:01:19 2000
--- openafs/src/WINNT/afsapplib/al_help.cpp	Wed Jul  6 20:28:59 2005
***************
*** 56,62 ****
  
  void AfsAppLib_RegisterHelp (int idd, DWORD *adwContext, int idhOverview)
  {
!    for (size_t ih = 0; ih < g_cdh; ++ih)
        {
        if (!g_adh[ ih ].fInUse)
           continue;
--- 56,63 ----
  
  void AfsAppLib_RegisterHelp (int idd, DWORD *adwContext, int idhOverview)
  {
!    size_t ih;
!    for (ih = 0; ih < g_cdh; ++ih)
        {
        if (!g_adh[ ih ].fInUse)
           continue;
Index: openafs/src/WINNT/afsapplib/al_misc.cpp
diff -c openafs/src/WINNT/afsapplib/al_misc.cpp:1.2.20.1 openafs/src/WINNT/afsapplib/al_misc.cpp:1.2.20.2
*** openafs/src/WINNT/afsapplib/al_misc.cpp:1.2.20.1	Wed May 18 18:57:06 2005
--- openafs/src/WINNT/afsapplib/al_misc.cpp	Wed Jul  6 20:28:59 2005
***************
*** 281,287 ****
     TCHAR szDefCell[ cchNAME ];
     if (AfsAppLib_GetLocalCell (szDefCell))
        {
!       for (size_t iclDef = 0; iclDef < lpcl->nCells; ++iclDef)
           {
           if (lpcl->aCells[ iclDef ] == NULL)
              continue;
--- 281,288 ----
     TCHAR szDefCell[ cchNAME ];
     if (AfsAppLib_GetLocalCell (szDefCell))
        {
!       size_t iclDef;
!       for (iclDef = 0; iclDef < lpcl->nCells; ++iclDef)
           {
           if (lpcl->aCells[ iclDef ] == NULL)
              continue;
Index: openafs/src/WINNT/afsapplib/al_pump.cpp
diff -c openafs/src/WINNT/afsapplib/al_pump.cpp:1.2 openafs/src/WINNT/afsapplib/al_pump.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/al_pump.cpp:1.2	Sat Nov  4 05:01:20 2000
--- openafs/src/WINNT/afsapplib/al_pump.cpp	Wed Jul  6 20:28:59 2005
***************
*** 131,137 ****
  
     EnterCriticalSection (pcsPump);
  
!    for (size_t ii = 0; ii < cModeless; ++ii)
        {
        if (aModeless[ ii ] == hDlg)
           break;
--- 131,138 ----
  
     EnterCriticalSection (pcsPump);
  
!    size_t ii;
!    for (ii = 0; ii < cModeless; ++ii)
        {
        if (aModeless[ ii ] == hDlg)
           break;
***************
*** 227,233 ****
        }
     EnterCriticalSection (pcsData);
  
!    for (size_t ii = 0; ii < cFields; ++ii)
        {
        if (!lstrcmpi (aFields[ ii ].szField, pszField))
           break;
--- 228,235 ----
        }
     EnterCriticalSection (pcsData);
  
!    size_t ii;
!    for (ii = 0; ii < cFields; ++ii)
        {
        if (!lstrcmpi (aFields[ ii ].szField, pszField))
           break;
***************
*** 302,308 ****
     size_t iField;
     if ((iField = GetWindowDataField (pszField)) != (size_t)-1)
        {
!       for (size_t ii = 0; ii < cWindows; ++ii)
           {
           if (aWindows[ ii ].hWnd == hWnd)
              {
--- 304,311 ----
     size_t iField;
     if ((iField = GetWindowDataField (pszField)) != (size_t)-1)
        {
!       size_t ii;
!       for (ii = 0; ii < cWindows; ++ii)
           {
           if (aWindows[ ii ].hWnd == hWnd)
              {
Index: openafs/src/WINNT/afsapplib/al_wizard.cpp
diff -c openafs/src/WINNT/afsapplib/al_wizard.cpp:1.3 openafs/src/WINNT/afsapplib/al_wizard.cpp:1.3.2.1
*** openafs/src/WINNT/afsapplib/al_wizard.cpp:1.3	Sat Nov 29 17:07:57 2003
--- openafs/src/WINNT/afsapplib/al_wizard.cpp	Wed Jul  6 20:28:59 2005
***************
*** 260,266 ****
        {
        if (stOriginal <= stNew)
           {
!          for (int st = stNew+1; st < (int)m_cStates; ++st)
              {
              LPWIZARD_STATE pState;
              if ((pState = FindState (st)) != NULL)
--- 260,267 ----
        {
        if (stOriginal <= stNew)
           {
!          int st;
!          for (st = stNew+1; st < (int)m_cStates; ++st)
              {
              LPWIZARD_STATE pState;
              if ((pState = FindState (st)) != NULL)
***************
*** 277,283 ****
           }
        else // (moving backwards?)
           {
!          for (int st = stNew-1; st >= 0; --st)
              {
              LPWIZARD_STATE pState;
              if ((pState = FindState (st)) != NULL)
--- 278,285 ----
           }
        else // (moving backwards?)
           {
!          int st;
!          for (st = stNew-1; st >= 0; --st)
              {
              LPWIZARD_STATE pState;
              if ((pState = FindState (st)) != NULL)
***************
*** 574,580 ****
        pPal->palVersion = 0x300;
        pPal->palNumEntries = 256;
  
!       for (size_t ii = 0; ii < 256; ++ii)
           {
           pPal->palPalEntry[ ii ].peRed   = (argb) ? argb[ ii ].rgbRed : 0;
           pPal->palPalEntry[ ii ].peGreen = (argb) ? argb[ ii ].rgbGreen : 0;
--- 576,583 ----
        pPal->palVersion = 0x300;
        pPal->palNumEntries = 256;
  
!       size_t ii;
!       for (ii = 0; ii < 256; ++ii)
           {
           pPal->palPalEntry[ ii ].peRed   = (argb) ? argb[ ii ].rgbRed : 0;
           pPal->palPalEntry[ ii ].peGreen = (argb) ? argb[ ii ].rgbGreen : 0;
***************
*** 583,590 ****
           }
  
        for (COLORREF clr = clrWASH_DARKEST; clr <= clrWASH_BRIGHTEST; clr += clrWASH_INCREMENT)
!          {
!          for (size_t ii = 0; ii < 256; ++ii)
              {
              if ( (pPal->palPalEntry[ ii ].peRed   == GetRValue (clr)) &&
                   (pPal->palPalEntry[ ii ].peGreen == GetGValue (clr)) &&
--- 586,593 ----
           }
  
        for (COLORREF clr = clrWASH_DARKEST; clr <= clrWASH_BRIGHTEST; clr += clrWASH_INCREMENT)
!          {            
!          for (ii = 0; ii < 256; ++ii)
              {
              if ( (pPal->palPalEntry[ ii ].peRed   == GetRValue (clr)) &&
                   (pPal->palPalEntry[ ii ].peGreen == GetGValue (clr)) &&
***************
*** 593,599 ****
              }
           if (ii == 256)
              {
!             for (size_t ii = 10; ii < 246; ++ii)
                 {
                 if ( (pPal->palPalEntry[ ii ].peRed == 0) &&
                      (pPal->palPalEntry[ ii ].peGreen == 0) &&
--- 596,602 ----
              }
           if (ii == 256)
              {
!             for (ii = 10; ii < 246; ++ii)
                 {
                 if ( (pPal->palPalEntry[ ii ].peRed == 0) &&
                      (pPal->palPalEntry[ ii ].peGreen == 0) &&
Index: openafs/src/WINNT/afsapplib/ctl_date.cpp
diff -c openafs/src/WINNT/afsapplib/ctl_date.cpp:1.2 openafs/src/WINNT/afsapplib/ctl_date.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/ctl_date.cpp:1.2	Sat Nov  4 05:01:21 2000
--- openafs/src/WINNT/afsapplib/ctl_date.cpp	Wed Jul  6 20:28:59 2005
***************
*** 162,168 ****
  
     if (msg == WM_CREATE)
        {
!       for (size_t iDate = 0; iDate < cDate; ++iDate)
           {
           if (aDate[ iDate ].hDate == NULL)
              break;
--- 162,169 ----
  
     if (msg == WM_CREATE)
        {
!       size_t iDate;
!       for (iDate = 0; iDate < cDate; ++iDate)
           {
           if (aDate[ iDate ].hDate == NULL)
              break;
Index: openafs/src/WINNT/afsapplib/ctl_elapsed.cpp
diff -c openafs/src/WINNT/afsapplib/ctl_elapsed.cpp:1.2 openafs/src/WINNT/afsapplib/ctl_elapsed.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/ctl_elapsed.cpp:1.2	Sat Nov  4 05:01:21 2000
--- openafs/src/WINNT/afsapplib/ctl_elapsed.cpp	Wed Jul  6 20:28:59 2005
***************
*** 167,173 ****
  
     if (msg == WM_CREATE)
        {
!       for (size_t iElapsed = 0; iElapsed < cElapsed; ++iElapsed)
           {
           if (aElapsed[ iElapsed ].hElapsed == NULL)
              break;
--- 167,174 ----
  
     if (msg == WM_CREATE)
        {
!       size_t iElapsed;
!       for (iElapsed = 0; iElapsed < cElapsed; ++iElapsed)
           {
           if (aElapsed[ iElapsed ].hElapsed == NULL)
              break;
Index: openafs/src/WINNT/afsapplib/ctl_sockaddr.cpp
diff -c openafs/src/WINNT/afsapplib/ctl_sockaddr.cpp:1.2 openafs/src/WINNT/afsapplib/ctl_sockaddr.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/ctl_sockaddr.cpp:1.2	Sat Nov  4 05:01:21 2000
--- openafs/src/WINNT/afsapplib/ctl_sockaddr.cpp	Wed Jul  6 20:28:59 2005
***************
*** 164,170 ****
  
     if (msg == WM_CREATE)
        {
!       for (size_t iSockAddr = 0; iSockAddr < cSockAddr; ++iSockAddr)
           {
           if (aSockAddr[ iSockAddr ].hSockAddr == NULL)
              break;
--- 164,171 ----
  
     if (msg == WM_CREATE)
        {
!       size_t iSockAddr;
!       for (iSockAddr = 0; iSockAddr < cSockAddr; ++iSockAddr)
           {
           if (aSockAddr[ iSockAddr ].hSockAddr == NULL)
              break;
Index: openafs/src/WINNT/afsapplib/ctl_spinner.cpp
diff -c openafs/src/WINNT/afsapplib/ctl_spinner.cpp:1.2 openafs/src/WINNT/afsapplib/ctl_spinner.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/ctl_spinner.cpp:1.2	Sat Nov  4 05:01:21 2000
--- openafs/src/WINNT/afsapplib/ctl_spinner.cpp	Wed Jul  6 20:28:59 2005
***************
*** 183,189 ****
  
     EnterCriticalSection (&csSpinners);
  
!    for (size_t ii = 0; ii < cSpinners; ++ii)
        {
        if (!aSpinners[ ii ].hSpinner)
           break;
--- 183,190 ----
  
     EnterCriticalSection (&csSpinners);
  
!    size_t ii;
!    for (ii = 0; ii < cSpinners; ++ii)
        {
        if (!aSpinners[ ii ].hSpinner)
           break;
Index: openafs/src/WINNT/afsapplib/ctl_time.cpp
diff -c openafs/src/WINNT/afsapplib/ctl_time.cpp:1.2 openafs/src/WINNT/afsapplib/ctl_time.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/ctl_time.cpp:1.2	Sat Nov  4 05:01:22 2000
--- openafs/src/WINNT/afsapplib/ctl_time.cpp	Wed Jul  6 20:28:59 2005
***************
*** 166,172 ****
  
     if (msg == WM_CREATE)
        {
!       for (size_t iTime = 0; iTime < cTime; ++iTime)
           {
           if (aTime[ iTime ].hTime == NULL)
              break;
--- 166,173 ----
  
     if (msg == WM_CREATE)
        {
!       size_t iTime;
!       for (iTime = 0; iTime < cTime; ++iTime)
           {
           if (aTime[ iTime ].hTime == NULL)
              break;
Index: openafs/src/WINNT/afsapplib/dialog.cpp
diff -c openafs/src/WINNT/afsapplib/dialog.cpp:1.3 openafs/src/WINNT/afsapplib/dialog.cpp:1.3.6.1
*** openafs/src/WINNT/afsapplib/dialog.cpp:1.3	Tue Aug  6 14:21:56 2002
--- openafs/src/WINNT/afsapplib/dialog.cpp	Wed Jul  6 20:28:59 2005
***************
*** 140,146 ****
  
     if (IsWindow (hTab))
        {
!       for (size_t ii = 0; ii < cPropSheets; ++ii)
           {
           if (aPropSheets[ii].fInUse && (aPropSheets[ii].hSheet == hSheet))
              break;
--- 140,147 ----
  
     if (IsWindow (hTab))
        {
!       size_t ii;
!       for (ii = 0; ii < cPropSheets; ++ii)
           {
           if (aPropSheets[ii].fInUse && (aPropSheets[ii].hSheet == hSheet))
              break;
***************
*** 158,164 ****
           }
        if (ii < cPropSheets)
           {
!          for (size_t iTab = 0; iTab < aPropSheets[ii].psh->cTabs; ++iTab)
              {
              if (aPropSheets[ii].psh->aTabs[iTab].hDlg == hDlg)
                 break;
--- 159,166 ----
           }
        if (ii < cPropSheets)
           {
!          size_t iTab;
!          for (iTab = 0; iTab < aPropSheets[ii].psh->cTabs; ++iTab)
              {
              if (aPropSheets[ii].psh->aTabs[iTab].hDlg == hDlg)
                 break;
***************
*** 346,352 ****
  
  LPARAM PropSheet_FindTabParam (HWND hTab)
  {
!    for (size_t ii = 0; ii < cPropSheets; ++ii)
        {
        if (aPropSheets[ii].fInUse && (aPropSheets[ii].hSheet == hTab))
           return aPropSheets[ii].psh->lpUser;
--- 348,355 ----
  
  LPARAM PropSheet_FindTabParam (HWND hTab)
  {
!    size_t ii;
!    for (ii = 0; ii < cPropSheets; ++ii)
        {
        if (aPropSheets[ii].fInUse && (aPropSheets[ii].hSheet == hTab))
           return aPropSheets[ii].psh->lpUser;
***************
*** 440,446 ****
     // Otherwise, we'd have to wait until the WM_INITDIALOG/IDINIT
     // messages were finished.
     //
!    for (size_t ii = 0; ii < cPropSheets; ++ii)
        {
        if (!aPropSheets[ ii ].fInUse)
           break;
--- 443,450 ----
     // Otherwise, we'd have to wait until the WM_INITDIALOG/IDINIT
     // messages were finished.
     //
!    size_t ii;
!    for (ii = 0; ii < cPropSheets; ++ii)
        {
        if (!aPropSheets[ ii ].fInUse)
           break;
***************
*** 789,795 ****
     va_start (arg, iImage1);
  
     LPTSTR apszColumns[ nCOLUMNS_MAX ];
!    for (size_t iColumn = 0; iColumn < lpvi->nColsAvail; ++iColumn)
        {
        apszColumns[ iColumn ] = va_arg (arg, LPTSTR);
        }
--- 793,800 ----
     va_start (arg, iImage1);
  
     LPTSTR apszColumns[ nCOLUMNS_MAX ];
!    size_t iColumn;
!    for (iColumn = 0; iColumn < lpvi->nColsAvail; ++iColumn)
        {
        apszColumns[ iColumn ] = va_arg (arg, LPTSTR);
        }
***************
*** 828,834 ****
  
  BOOL FL_HitTestForHeaderBar (HWND hList, POINT ptClient)
  {
!    for (HWND hHeader = GetWindow (hList, GW_CHILD);
          hHeader != NULL;
          hHeader = GetWindow (hHeader, GW_HWNDNEXT))
        {
--- 833,840 ----
  
  BOOL FL_HitTestForHeaderBar (HWND hList, POINT ptClient)
  {
!    HWND hHeader;
!    for (hHeader = GetWindow (hList, GW_CHILD);
          hHeader != NULL;
          hHeader = GetWindow (hHeader, GW_HWNDNEXT))
        {
***************
*** 1163,1169 ****
  
  void LV_SortView (HWND hList, LPVIEWINFO lpvi)
  {
!    for (size_t iColSort = 0; iColSort < lpvi->nColsShown; ++iColSort)
        {
        if ((lpvi->iSort & (~COLUMN_SORTREV)) == lpvi->aColumns[ iColSort ])
           break;
--- 1169,1176 ----
  
  void LV_SortView (HWND hList, LPVIEWINFO lpvi)
  {
!    size_t iColSort;
!    for (iColSort = 0; iColSort < lpvi->nColsShown; ++iColSort)
        {
        if ((lpvi->iSort & (~COLUMN_SORTREV)) == lpvi->aColumns[ iColSort ])
           break;
***************
*** 1191,1197 ****
     va_start (arg, iImage);
  
     LPTSTR apszColumns[ nCOLUMNS_MAX ];
!    for (size_t iColumn = 0; iColumn < lpvi->nColsAvail; ++iColumn)
        {
        apszColumns[ iColumn ] = va_arg (arg, LPTSTR);
        }
--- 1198,1205 ----
     va_start (arg, iImage);
  
     LPTSTR apszColumns[ nCOLUMNS_MAX ];
!    size_t iColumn;
!    for (iColumn = 0; iColumn < lpvi->nColsAvail; ++iColumn)
        {
        apszColumns[ iColumn ] = va_arg (arg, LPTSTR);
        }
***************
*** 1232,1238 ****
  
  BOOL LV_HitTestForHeaderBar (HWND hList, POINT ptClient)
  {
!    for (HWND hHeader = GetWindow (hList, GW_CHILD);
          hHeader != NULL;
          hHeader = GetWindow (hHeader, GW_HWNDNEXT))
        {
--- 1240,1247 ----
  
  BOOL LV_HitTestForHeaderBar (HWND hList, POINT ptClient)
  {
!    HWND hHeader;
!    for (hHeader = GetWindow (hList, GW_CHILD);
          hHeader != NULL;
          hHeader = GetWindow (hHeader, GW_HWNDNEXT))
        {
***************
*** 1546,1553 ****
           int iItemSkip = (int)wp;
           int iItemMax = SendMessage (hList, LB_GETCOUNT, 0, 0);
           int cchMax = 0;
  
!          for (int iItem = 0; iItem < iItemMax; iItem++)
              {
              if (iItem == iItemSkip)
                 continue;
--- 1555,1563 ----
           int iItemSkip = (int)wp;
           int iItemMax = SendMessage (hList, LB_GETCOUNT, 0, 0);
           int cchMax = 0;
+          int iItem;
  
!          for (iItem = 0; iItem < iItemMax; iItem++)
              {
              if (iItem == iItemSkip)
                 continue;
Index: openafs/src/WINNT/afsapplib/fastlist.cpp
diff -c openafs/src/WINNT/afsapplib/fastlist.cpp:1.4 openafs/src/WINNT/afsapplib/fastlist.cpp:1.4.2.1
*** openafs/src/WINNT/afsapplib/fastlist.cpp:1.4	Sun Dec  7 17:49:11 2003
--- openafs/src/WINNT/afsapplib/fastlist.cpp	Wed Jul  6 20:29:00 2005
***************
*** 3826,3832 ****
           if (fLevel)
              {
              size_t iLevelItem = 0;
!             for (HLISTITEM hParent = hItem->hTreeParent; hParent; hParent = hParent->hTreeParent)
                 ++iLevelItem;
  
              size_t iLevelSelected = 0;
--- 3826,3833 ----
           if (fLevel)
              {
              size_t iLevelItem = 0;
!             HLISTITEM hParent;
!             for (hParent = hItem->hTreeParent; hParent; hParent = hParent->hTreeParent)
                 ++iLevelItem;
  
              size_t iLevelSelected = 0;
***************
*** 3840,3846 ****
           if (fSibling)
              {
              BOOL fFound = FALSE;
!             for (HLISTITEM hSearch = hItem->hTreePrevious; !fFound && hSearch; hSearch = hSearch->hTreePrevious)
                 {
                 if (hSearch == pfl->hSelectFirst)
                    fFound = TRUE;
--- 3841,3848 ----
           if (fSibling)
              {
              BOOL fFound = FALSE;
!             HLISTITEM hSearch;
!             for (hSearch = hItem->hTreePrevious; !fFound && hSearch; hSearch = hSearch->hTreePrevious)
                 {
                 if (hSearch == pfl->hSelectFirst)
                    fFound = TRUE;
Index: openafs/src/WINNT/afsapplib/hashlist.cpp
diff -c openafs/src/WINNT/afsapplib/hashlist.cpp:1.4 openafs/src/WINNT/afsapplib/hashlist.cpp:1.4.2.1
*** openafs/src/WINNT/afsapplib/hashlist.cpp:1.4	Mon Aug 25 14:23:50 2003
--- openafs/src/WINNT/afsapplib/hashlist.cpp	Wed Jul  6 20:29:00 2005
***************
*** 436,442 ****
     LPHASHLISTKEY pKey = NULL;
     Enter();
  
!    for (size_t iKey = 0; iKey < m_cpKeys; ++iKey)
        {
        if (m_apKeys[ iKey ] == NULL)
           break;
--- 436,443 ----
     LPHASHLISTKEY pKey = NULL;
     Enter();
  
!    size_t iKey;
!    for (iKey = 0; iKey < m_cpKeys; ++iKey)
        {
        if (m_apKeys[ iKey ] == NULL)
           break;
***************
*** 855,861 ****
        m_aBuckets[ iBucket ].iLast = iINVALID;
        }
  
!    for (size_t iObject = 0; ; ++iObject)
        {
        LPHASHLISTENTRY pEntry;
        if ((pEntry = GetEntry(m_aObjects,iObject)) == NULL)
--- 856,863 ----
        m_aBuckets[ iBucket ].iLast = iINVALID;
        }
  
!    size_t iObject;
!    for (iObject = 0; ; ++iObject)
        {
        LPHASHLISTENTRY pEntry;
        if ((pEntry = GetEntry(m_aObjects,iObject)) == NULL)
***************
*** 903,909 ****
     //
     REALLOC (pInfo->aBuckets, pInfo->cBuckets, m_cBuckets, 1);
  
!    for (size_t iBucket = 0; iBucket < pInfo->cBuckets; ++iBucket)
        {
        for (size_t iObject = m_aBuckets[ iBucket ].iFirst;
             iObject != iINVALID;
--- 905,912 ----
     //
     REALLOC (pInfo->aBuckets, pInfo->cBuckets, m_cBuckets, 1);
  
!    size_t iBucket;
!    for (iBucket = 0; iBucket < pInfo->cBuckets; ++iBucket)
        {
        for (size_t iObject = m_aBuckets[ iBucket ].iFirst;
             iObject != iINVALID;
***************
*** 1085,1091 ****
  {
     HASHVALUE hv = 0;
  
!    for (size_t cch = lstrlenA(pszStringA); cch >= 4; pszStringA += 4, cch -= 4)
        hv += *(DWORD *)pszStringA;
  
     for (; cch; pszStringA++, cch--)
--- 1088,1095 ----
  {
     HASHVALUE hv = 0;
  
!    size_t cch;
!    for (cch = lstrlenA(pszStringA); cch >= 4; pszStringA += 4, cch -= 4)
        hv += *(DWORD *)pszStringA;
  
     for (; cch; pszStringA++, cch--)
***************
*** 1098,1104 ****
  {
     HASHVALUE hv = 0;
  
!    for (size_t cch = lstrlenW(pszStringW); cch >= 2; pszStringW += 2, cch -= 2)
        {
        hv += *(DWORD *)pszStringW;   // since HIBYTE(*psz) is usually zero,
        hv = (hv >> 24) | (hv << 8);  // rotate {hv} high-ward by 8 bits
--- 1102,1109 ----
  {
     HASHVALUE hv = 0;
  
!    size_t cch;
!    for (cch = lstrlenW(pszStringW); cch >= 2; pszStringW += 2, cch -= 2)
        {
        hv += *(DWORD *)pszStringW;   // since HIBYTE(*psz) is usually zero,
        hv = (hv >> 24) | (hv << 8);  // rotate {hv} high-ward by 8 bits
Index: openafs/src/WINNT/afsapplib/regexp.cpp
diff -c openafs/src/WINNT/afsapplib/regexp.cpp:1.2 openafs/src/WINNT/afsapplib/regexp.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/regexp.cpp:1.2	Sat Nov  4 05:01:24 2000
--- openafs/src/WINNT/afsapplib/regexp.cpp	Wed Jul  6 20:29:00 2005
***************
*** 119,125 ****
  
     // Start stripping characters from the expression
     //
!    for (BOOL rc = TRUE; rc; )
        {
        TCHAR ch;
  
--- 119,126 ----
  
     // Start stripping characters from the expression
     //
!    BOOL rc;
!    for (rc = TRUE; rc; )
        {
        TCHAR ch;
  
Index: openafs/src/WINNT/afsapplib/resize.cpp
diff -c openafs/src/WINNT/afsapplib/resize.cpp:1.2 openafs/src/WINNT/afsapplib/resize.cpp:1.2.20.1
*** openafs/src/WINNT/afsapplib/resize.cpp:1.2	Sat Nov  4 05:01:24 2000
--- openafs/src/WINNT/afsapplib/resize.cpp	Wed Jul  6 20:29:00 2005
***************
*** 307,313 ****
  {
              // Is the window handle listed in awl[] already?
              //
!    for (int ii = 0; ii < (int)cwl; ii++)
        {
        if (awl[ii].hWnd == hWnd)
           {
--- 307,314 ----
  {
              // Is the window handle listed in awl[] already?
              //
!    int ii;
!    for (ii = 0; ii < (int)cwl; ii++)
        {
        if (awl[ii].hWnd == hWnd)
           {
Index: openafs/src/WINNT/afsapplib/subclass.cpp
diff -c openafs/src/WINNT/afsapplib/subclass.cpp:1.4 openafs/src/WINNT/afsapplib/subclass.cpp:1.4.2.1
*** openafs/src/WINNT/afsapplib/subclass.cpp:1.4	Mon Aug 25 14:23:50 2003
--- openafs/src/WINNT/afsapplib/subclass.cpp	Wed Jul  6 20:29:00 2005
***************
*** 93,99 ****
  
  BOOL Subclass_AddHook (HWND hTarget, PVOID wndProc)
  {
!    for (size_t iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
--- 93,100 ----
  
  BOOL Subclass_AddHook (HWND hTarget, PVOID wndProc)
  {
!    size_t iTarget;
!    for (iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
***************
*** 114,121 ****
  
     aTargets[ iTarget ].hTarget = hTarget;
  
! 
!    for (size_t iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
        {
        if (aTargets[ iTarget ].aHooks[ iHook ].wndProc == wndProc)
           break;
--- 115,122 ----
  
     aTargets[ iTarget ].hTarget = hTarget;
  
!    size_t iHook;
!    for (iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
        {
        if (aTargets[ iTarget ].aHooks[ iHook ].wndProc == wndProc)
           break;
***************
*** 150,163 ****
  
  void Subclass_RemoveHook (HWND hTarget, PVOID wndProc)
  {
!    for (size_t iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
        }
     if (iTarget < nTargets)
        {
!       for (size_t iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
           {
           if (aTargets[ iTarget ].aHooks[ iHook ].wndProc == wndProc)
              break;
--- 151,166 ----
  
  void Subclass_RemoveHook (HWND hTarget, PVOID wndProc)
  {
!    size_t iTarget;
!    for (iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
        }
     if (iTarget < nTargets)
        {
!       size_t iHook;
!       for (iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
           {
           if (aTargets[ iTarget ].aHooks[ iHook ].wndProc == wndProc)
              break;
***************
*** 183,189 ****
  
  PVOID Subclass_FindNextHook (HWND hTarget, PVOID wndProc)
  {
!    for (size_t iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
--- 186,193 ----
  
  PVOID Subclass_FindNextHook (HWND hTarget, PVOID wndProc)
  {
!    size_t iTarget;
!    for (iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
***************
*** 191,197 ****
     if (iTarget >= nTargets)
        return NULL;
  
!    for (size_t iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
        {
        if (aTargets[ iTarget ].aHooks[ iHook ].wndProc == wndProc)
           break;
--- 195,202 ----
     if (iTarget >= nTargets)
        return NULL;
  
!    size_t iHook;
!    for (iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
        {
        if (aTargets[ iTarget ].aHooks[ iHook ].wndProc == wndProc)
           break;
***************
*** 211,217 ****
  
  LONG CALLBACK Subclass_WndProc (HWND hTarget, UINT msg, WPARAM wp, LPARAM lp)
  {
!    for (size_t iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
--- 216,223 ----
  
  LONG CALLBACK Subclass_WndProc (HWND hTarget, UINT msg, WPARAM wp, LPARAM lp)
  {
!    size_t iTarget;
!    for (iTarget = 0; iTarget < nTargets; ++iTarget)
        {
        if (aTargets[ iTarget ].hTarget == hTarget)
           break;
***************
*** 219,225 ****
     if (iTarget >= nTargets)
        return DefWindowProc (hTarget, msg, wp, lp);
  
!    for (size_t iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
        {
        if (aTargets[ iTarget ].aHooks[ iHook ].wndProc != NULL)
           break;
--- 225,232 ----
     if (iTarget >= nTargets)
        return DefWindowProc (hTarget, msg, wp, lp);
  
!    size_t iHook;
!    for (iHook = 0; iHook < aTargets[iTarget].nHooks; ++iHook)
        {
        if (aTargets[ iTarget ].aHooks[ iHook ].wndProc != NULL)
           break;
Index: openafs/src/WINNT/afsclass/afsclassfn.cpp
diff -c openafs/src/WINNT/afsclass/afsclassfn.cpp:1.4 openafs/src/WINNT/afsclass/afsclassfn.cpp:1.4.14.1
*** openafs/src/WINNT/afsclass/afsclassfn.cpp:1.4	Thu Sep  6 23:32:56 2001
--- openafs/src/WINNT/afsclass/afsclassfn.cpp	Wed Jul  6 20:29:00 2005
***************
*** 82,88 ****
              //
              for (LPTSTR psz = wp.wpBosLogGet.pszLogData; psz && *psz; )
                 {
!                for (LPTSTR pszNext = psz; *pszNext && (*pszNext != TEXT('\r')) && (*pszNext != TEXT('\n')); ++pszNext)
                    ;
                 DWORD cbWrite;
                 DWORD cbWrote;
--- 82,89 ----
              //
              for (LPTSTR psz = wp.wpBosLogGet.pszLogData; psz && *psz; )
                 {
!                LPTSTR pszNext;
!                for (pszNext = psz; *pszNext && (*pszNext != TEXT('\r')) && (*pszNext != TEXT('\n')); ++pszNext)
                    ;
                 DWORD cbWrite;
                 DWORD cbWrote;
***************
*** 2495,2501 ****
  
     if (lpList)
        {
!       for (size_t iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
           {
           if (!lpList->aEntries[ iEntry ].szAdmin[0])
              break;
--- 2496,2503 ----
  
     if (lpList)
        {
!       size_t iEntry;
!       for (iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
           {
           if (!lpList->aEntries[ iEntry ].szAdmin[0])
              break;
***************
*** 3610,3616 ****
  
     if (lpList)
        {
!       for (size_t iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
           {
           if (!lpList->aEntries[ iEntry ].szHost[0])
              break;
--- 3612,3619 ----
  
     if (lpList)
        {
!       size_t iEntry;
!       for (iEntry = 0; iEntry < lpList->cEntries; ++iEntry)
           {
           if (!lpList->aEntries[ iEntry ].szHost[0])
              break;
Index: openafs/src/WINNT/afsclass/c_cell.cpp
diff -c openafs/src/WINNT/afsclass/c_cell.cpp:1.2 openafs/src/WINNT/afsclass/c_cell.cpp:1.2.20.1
*** openafs/src/WINNT/afsclass/c_cell.cpp:1.2	Sat Nov  4 05:01:30 2000
--- openafs/src/WINNT/afsclass/c_cell.cpp	Wed Jul  6 20:29:00 2005
***************
*** 135,141 ****
  
  void CELL::FreeUsers (BOOL fNotify)
  {
!    for (LPENUM pEnum = m_lGroups->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
        {
        LPPTSGROUP lpGroup = (LPPTSGROUP)(pEnum->GetObject());
        if (fNotify)
--- 135,142 ----
  
  void CELL::FreeUsers (BOOL fNotify)
  {
!    LPENUM pEnum;
!    for (pEnum = m_lGroups->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
        {
        LPPTSGROUP lpGroup = (LPPTSGROUP)(pEnum->GetObject());
        if (fNotify)
***************
*** 590,596 ****
           }
  
        size_t cServers = 0;
!       for (LPENUM pEnum = m_lServers->FindFirst(); pEnum; pEnum = pEnum->FindNext())
           ++cServers;
  
        if (cServers)
--- 591,598 ----
           }
  
        size_t cServers = 0;
!       LPENUM pEnum;
!       for (pEnum = m_lServers->FindFirst(); pEnum; pEnum = pEnum->FindNext())
           ++cServers;
  
        if (cServers)
***************
*** 1873,1879 ****
        //
        if (fNotify)
           {
!          for (LPENUM pEnum = m_lGroups->FindFirst(); pEnum; pEnum = pEnum->FindNext())
              {
              LPPTSGROUP lpGroup = (LPPTSGROUP)(pEnum->GetObject());
              NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpGroup->GetIdentifier());
--- 1875,1882 ----
        //
        if (fNotify)
           {
!          LPENUM pEnum;
!          for (pEnum = m_lGroups->FindFirst(); pEnum; pEnum = pEnum->FindNext())
              {
              LPPTSGROUP lpGroup = (LPPTSGROUP)(pEnum->GetObject());
              NOTIFYCALLBACK::SendNotificationToAll (evtCreate, lpGroup->GetIdentifier());
Index: openafs/src/WINNT/afsclass/c_notify.cpp
diff -c openafs/src/WINNT/afsclass/c_notify.cpp:1.2 openafs/src/WINNT/afsclass/c_notify.cpp:1.2.20.1
*** openafs/src/WINNT/afsclass/c_notify.cpp:1.2	Sat Nov  4 05:01:32 2000
--- openafs/src/WINNT/afsclass/c_notify.cpp	Wed Jul  6 20:29:01 2005
***************
*** 48,55 ****
  {
     procSupplied = procUser;
     lpSupplied = lpUser;
  
!    for (size_t iNotify = 0; iNotify < nNotifyList; ++iNotify)
        {
        if (aNotifyList[ iNotify ] == NULL)
           break;
--- 48,56 ----
  {
     procSupplied = procUser;
     lpSupplied = lpUser;
+    size_t iNotify;
  
!    for (iNotify = 0; iNotify < nNotifyList; ++iNotify)
        {
        if (aNotifyList[ iNotify ] == NULL)
           break;
Index: openafs/src/WINNT/afsclass/c_svr.cpp
diff -c openafs/src/WINNT/afsclass/c_svr.cpp:1.3 openafs/src/WINNT/afsclass/c_svr.cpp:1.3.2.1
*** openafs/src/WINNT/afsclass/c_svr.cpp:1.3	Sat Nov 29 17:08:03 2003
--- openafs/src/WINNT/afsclass/c_svr.cpp	Wed Jul  6 20:29:01 2005
***************
*** 158,164 ****
  
  void SERVER::SendDeleteNotifications (void)
  {
!    for (LPENUM pEnum = m_lAggregates->FindFirst(); pEnum; pEnum = pEnum->FindNext())
        {
        LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject());
        lpAggregate->SendDeleteNotifications ();
--- 158,165 ----
  
  void SERVER::SendDeleteNotifications (void)
  {
!    LPENUM pEnum;
!    for (pEnum = m_lAggregates->FindFirst(); pEnum; pEnum = pEnum->FindNext())
        {
        LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject());
        lpAggregate->SendDeleteNotifications ();
***************
*** 372,378 ****
           // First thing is to forget about what aggregates we think we have
           // now.
           //
!          for (LPENUM pEnum = m_lAggregates->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
              {
              LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject());
              lpAggregate->SendDeleteNotifications();
--- 373,380 ----
           // First thing is to forget about what aggregates we think we have
           // now.
           //
!          LPENUM pEnum;
!          for (pEnum = m_lAggregates->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
              {
              LPAGGREGATE lpAggregate = (LPAGGREGATE)(pEnum->GetObject());
              lpAggregate->SendDeleteNotifications();
***************
*** 465,471 ****
  
           // First thing is to forget about what services we think we have now.
           //
!          for (LPENUM pEnum = m_lServices->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
              {
              LPSERVICE lpService = (LPSERVICE)(pEnum->GetObject());
              lpService->SendDeleteNotifications();
--- 467,474 ----
  
           // First thing is to forget about what services we think we have now.
           //
!          LPENUM pEnum;
!          for (pEnum = m_lServices->FindLast(); pEnum; pEnum = pEnum->FindPrevious())
              {
              LPSERVICE lpService = (LPSERVICE)(pEnum->GetObject());
              lpService->SendDeleteNotifications();
***************
*** 939,945 ****
     AfsClass_InitRefreshSections();
     EnterCriticalSection (pcsRefSec);
  
!    for (int idSection = 0; idSection < (int)cRefSec; ++idSection)
        {
        if (!aRefSec[ idSection ].fInUse)
           break;
--- 942,949 ----
     AfsClass_InitRefreshSections();
     EnterCriticalSection (pcsRefSec);
  
!    int idSection;
!    for (idSection = 0; idSection < (int)cRefSec; ++idSection)
        {
        if (!aRefSec[ idSection ].fInUse)
           break;
***************
*** 994,1000 ****
     // Wait for that thread to terminate, or for our
     // newly-allocated RefSec entry to be marked Canceled.
     //
!    for (DWORD dw = STILL_ACTIVE; dw == STILL_ACTIVE; )
        {
        EnterCriticalSection (pcsRefSec);
  
--- 998,1005 ----
     // Wait for that thread to terminate, or for our
     // newly-allocated RefSec entry to be marked Canceled.
     //
!    DWORD dw;
!    for (dw = STILL_ACTIVE; dw == STILL_ACTIVE; )
        {
        EnterCriticalSection (pcsRefSec);
  
***************
*** 1072,1078 ****
              size_t nAggregates = 0;
              size_t iAggregate = 0;
              HENUM hEnum;
!             for (LPAGGREGATE lpAggregate = AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = AggregateFindNext (&hEnum))
                 {
                 ++nAggregates;
                 lpAggregate->Close();
--- 1077,1084 ----
              size_t nAggregates = 0;
              size_t iAggregate = 0;
              HENUM hEnum;
!             LPAGGREGATE lpAggregate;
!             for (lpAggregate = AggregateFindFirst (&hEnum); lpAggregate; lpAggregate = AggregateFindNext (&hEnum))
                 {
                 ++nAggregates;
                 lpAggregate->Close();
***************
*** 1103,1109 ****
              size_t nServices = 0;
              size_t iService = 0;
              HENUM hEnum;
!             for (LPSERVICE lpService = ServiceFindFirst (&hEnum); lpService; lpService = ServiceFindNext (&hEnum))
                 {
                 ++nServices;
                 lpService->Close();
--- 1109,1116 ----
              size_t nServices = 0;
              size_t iService = 0;
              HENUM hEnum;
!             LPSERVICE lpService;
!             for (lpService = ServiceFindFirst (&hEnum); lpService; lpService = ServiceFindNext (&hEnum))
                 {
                 ++nServices;
                 lpService->Close();
Index: openafs/src/WINNT/afsclass/internal.cpp
diff -c openafs/src/WINNT/afsclass/internal.cpp:1.2 openafs/src/WINNT/afsclass/internal.cpp:1.2.20.1
*** openafs/src/WINNT/afsclass/internal.cpp:1.2	Sat Nov  4 05:01:33 2000
--- openafs/src/WINNT/afsclass/internal.cpp	Wed Jul  6 20:29:01 2005
***************
*** 238,244 ****
  
        TCHAR szComponent[ cchRESOURCE ];
        lstrcpy (szComponent, pszTime);
!       for (LPTSTR pch = szComponent; isdigit(*pch); ++pch)
           ;
        *pch = TEXT('\0');
  
--- 238,245 ----
  
        TCHAR szComponent[ cchRESOURCE ];
        lstrcpy (szComponent, pszTime);
!       LPTSTR pch;
!       for (pch = szComponent; isdigit(*pch); ++pch)
           ;
        *pch = TEXT('\0');
  
Index: openafs/src/WINNT/afsd/afskfw.c
diff -c openafs/src/WINNT/afsd/afskfw.c:1.8.2.13 openafs/src/WINNT/afsd/afskfw.c:1.8.2.15
*** openafs/src/WINNT/afsd/afskfw.c:1.8.2.13	Tue May 31 10:19:06 2005
--- openafs/src/WINNT/afsd/afskfw.c	Fri Jul  1 15:34:14 2005
***************
*** 2542,2571 ****
          confname[sizeof(confname) - 2] = '\0';
      }
  
-     /*
-      * 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))
!         status = pr_SNameToId (username, &viceId);
  
      /*
       * This is a crock, but it is Transarc's crock, so
--- 2542,2555 ----
          confname[sizeof(confname) - 2] = '\0';
      }
  
      strcpy(lastcell, aserver->cell);
  
!     if (!pr_Initialize (0, confname, aserver->cell)) {
!         char sname[PR_MAXNAMELEN];
!         strncpy(sname, username, PR_MAXNAMELEN);
!         sname[PR_MAXNAMELEN-1] = '\0';    
!         status = pr_SNameToId (sname, &viceId);
!     }
  
      /*
       * This is a crock, but it is Transarc's crock, so
***************
*** 2602,2615 ****
              strncpy(aclient->cell, realm_of_user, MAXKTCREALMLEN - 1);
              if (status = ktc_SetToken(aserver, atoken, aclient, 0))
                  return status;
- 
-             /*                                    
-              * 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))
                  return status;
              if (status = pr_CreateUser(username, &id))
--- 2586,2591 ----
***************
*** 2976,2982 ****
          strcpy(aclient.cell, realm_of_cell);
  
          len = min(k5creds->client->realm.length,strlen(realm_of_cell));
!         if ( strncmp(realm_of_cell, k5creds->client->realm.data, len) ) {
              char * p;
              strcat(aclient.name, "@");
              p = aclient.name + strlen(aclient.name);
--- 2952,2959 ----
          strcpy(aclient.cell, realm_of_cell);
  
          len = min(k5creds->client->realm.length,strlen(realm_of_cell));
!         /* For Khimaira, always append the realm name */
!         if ( 1 /* strncmp(realm_of_cell, k5creds->client->realm.data, len) */ ) {
              char * p;
              strcat(aclient.name, "@");
              p = aclient.name + strlen(aclient.name);
Index: openafs/src/WINNT/afsd/afslogon.c
diff -c openafs/src/WINNT/afsd/afslogon.c:1.24.2.11 openafs/src/WINNT/afsd/afslogon.c:1.24.2.14
*** openafs/src/WINNT/afsd/afslogon.c:1.24.2.11	Tue May 31 10:19:06 2005
--- openafs/src/WINNT/afsd/afslogon.c	Fri Jul  1 14:40:50 2005
***************
*** 279,285 ****
          CloseServiceHandle (hManager);
      }
      DebugEvent("AFS AfsLogon - Test Service Start Pending","Return Code[%x] ?Start Pending[%d]",Status.dwCurrentState,(Status.dwCurrentState == SERVICE_START_PENDING));
!     return (Status.dwCurrentState == SERVICE_RUNNING);
  }   
  
  /* LOOKUPKEYCHAIN: macro to look up the value in the list of keys in order until it's found
--- 279,285 ----
          CloseServiceHandle (hManager);
      }
      DebugEvent("AFS AfsLogon - Test Service Start Pending","Return Code[%x] ?Start Pending[%d]",Status.dwCurrentState,(Status.dwCurrentState == SERVICE_START_PENDING));
!     return (Status.dwCurrentState == SERVICE_START_PENDING);
  }   
  
  /* LOOKUPKEYCHAIN: macro to look up the value in the list of keys in order until it's found
***************
*** 781,788 ****
      }
  
      /* loop until AFS is started. */
!     while (TRUE) {
!         DebugEvent("while(TRUE) LogonOption[%x], Service AutoStart[%d]",
                      opt.LogonOption,afsWillAutoStart);
  
          if (ISADREALM(opt.flags)) {
--- 781,788 ----
      }
  
      /* loop until AFS is started. */
!     while (IsServiceRunning() || IsServiceStartPending()) {
!         DebugEvent("while(autostart) LogonOption[%x], Service AutoStart[%d]",
                      opt.LogonOption,afsWillAutoStart);
  
          if (ISADREALM(opt.flags)) {
***************
*** 847,860 ****
              * client is set to autostart (and therefore it makes sense for
              * us to wait for it to start) then sleep a while and try again. 
              * If the error was something else, then give up. */
!             if (code != KTC_NOCM && code != KTC_NOCMRPC || !afsWillAutoStart)
                  break;
          }
          else {  
              /*JUST check to see if its running*/
              if (IsServiceRunning())
                  break;
!             if (afsWillAutoStart && !IsServiceStartPending()) {
                  code = KTC_NOCMRPC;
                  reason = "AFS Service start failed";
                  break;
--- 847,860 ----
              * client is set to autostart (and therefore it makes sense for
              * us to wait for it to start) then sleep a while and try again. 
              * If the error was something else, then give up. */
!             if (code != KTC_NOCM && code != KTC_NOCMRPC)
                  break;
          }
          else {  
              /*JUST check to see if its running*/
              if (IsServiceRunning())
                  break;
!             if (!IsServiceStartPending()) {
                  code = KTC_NOCMRPC;
                  reason = "AFS Service start failed";
                  break;
***************
*** 1007,1058 ****
      DWORD  len = 1024;
      PTOKEN_USER  tokenUser = NULL;
      DWORD  retLen;
  
      /* Make sure the AFS Libraries are initialized */
      AfsLogonInit();
  
      DebugEvent0("AFS_Logoff_Event - Start");
  
!     if (!GetTokenInformation(pInfo->hToken, TokenUser, NULL, 0, &retLen))
!     {
!         if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER ) {
!             tokenUser = (PTOKEN_USER) LocalAlloc(LPTR, retLen);
  
!             if (!GetTokenInformation(pInfo->hToken, TokenUser, tokenUser, retLen, &retLen))
!             {
!                 DebugEvent("AFS_Logoff_Event - GetTokenInformation failed: GLE = %lX", GetLastError());
              }
          }
-     }
  
!     /* We can't use pInfo->Domain for the domain since in the cross realm case 
!      * this is source domain and not the destination domain.
!      */
!     if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
!         WCHAR Domain[64]=L"";
!         GetLocalShortDomain(Domain, sizeof(Domain));
!         if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
!             if (NetUserGetProfilePath(pInfo->Domain, pInfo->UserName, profileDir, len))
!                 GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
          }
!     }
!     
!     if (strlen(profileDir)) {
!         DebugEvent("AFS_Logoff_Event - Profile Directory: %s", profileDir);
!         if (!IsPathInAfs(profileDir)) {
!             if (code = ktc_ForgetAllTokens())
!                 DebugEvent("AFS_Logoff_Event - ForgetAllTokens failed [%lX]",code);
!             else
!                 DebugEvent0("AFS_Logoff_Event - ForgetAllTokens succeeded");
          } else {
!             DebugEvent0("AFS_Logoff_Event - Tokens left in place; profile in AFS");
          }
-     } else {
-         DebugEvent0("AFS_Logoff_Event - Unable to load profile");
-     }
  
!     if ( tokenUser )
!         LocalFree(tokenUser);
  
      DebugEvent0("AFS_Logoff_Event - End");
  }   
--- 1007,1070 ----
      DWORD  len = 1024;
      PTOKEN_USER  tokenUser = NULL;
      DWORD  retLen;
+     DWORD LSPtype, LSPsize;
+     HKEY NPKey;
+     DWORD LogoffPreserveTokens = 0;
  
      /* Make sure the AFS Libraries are initialized */
      AfsLogonInit();
  
      DebugEvent0("AFS_Logoff_Event - Start");
  
!     (void) RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY,
!                          0, KEY_QUERY_VALUE, &NPKey);
!     LSPsize=sizeof(LogoffPreserveTokens);
!     RegQueryValueEx(NPKey, REG_CLIENT_LOGOFF_TOKENS_PARM, NULL,
!                      &LSPtype, (LPBYTE)&LogoffPreserveTokens, &LSPsize);
!     RegCloseKey (NPKey);
  
!     if (LogoffPreserveTokens) {
!         if (!GetTokenInformation(pInfo->hToken, TokenUser, NULL, 0, &retLen))
!         {
!             if ( GetLastError() == ERROR_INSUFFICIENT_BUFFER ) {
!                 tokenUser = (PTOKEN_USER) LocalAlloc(LPTR, retLen);
! 
!                 if (!GetTokenInformation(pInfo->hToken, TokenUser, tokenUser, retLen, &retLen))
!                 {
!                     DebugEvent("AFS_Logoff_Event - GetTokenInformation failed: GLE = %lX", GetLastError());
!                 }
              }
          }
  
!         /* We can't use pInfo->Domain for the domain since in the cross realm case 
!          * this is source domain and not the destination domain.
!          */
!         if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, pInfo->Domain)) {
!             WCHAR Domain[64]=L"";
!             GetLocalShortDomain(Domain, sizeof(Domain));
!             if (QueryAdHomePathFromSid( profileDir, sizeof(profileDir), tokenUser->User.Sid, Domain)) {
!                 if (NetUserGetProfilePath(pInfo->Domain, pInfo->UserName, profileDir, len))
!                     GetUserProfileDirectory(pInfo->hToken, profileDir, &len);
!             }
          }
! 
!         if (strlen(profileDir)) {
!             DebugEvent("AFS_Logoff_Event - Profile Directory: %s", profileDir);
!             if (!IsPathInAfs(profileDir)) {
!                 if (code = ktc_ForgetAllTokens())
!                     DebugEvent("AFS_Logoff_Event - ForgetAllTokens failed [%lX]",code);
!                 else
!                     DebugEvent0("AFS_Logoff_Event - ForgetAllTokens succeeded");
!             } else {
!                 DebugEvent0("AFS_Logoff_Event - Tokens left in place; profile in AFS");
!             }
          } else {
!             DebugEvent0("AFS_Logoff_Event - Unable to load profile");
          }
  
!         if ( tokenUser )
!             LocalFree(tokenUser);
!     }
  
      DebugEvent0("AFS_Logoff_Event - End");
  }   
Index: openafs/src/WINNT/afsd/afslogon.h
diff -c openafs/src/WINNT/afsd/afslogon.h:1.5.2.2 openafs/src/WINNT/afsd/afslogon.h:1.5.2.4
*** openafs/src/WINNT/afsd/afslogon.h:1.5.2.2	Fri Mar 11 01:58:39 2005
--- openafs/src/WINNT/afsd/afslogon.h	Wed Jul  6 20:29:03 2005
***************
*** 29,34 ****
--- 29,35 ----
  #include <windows.h>
  #include <npapi.h>
  #include <ntsecapi.h>
+ #include <tchar.h>
  #include <strsafe.h>
  
  
***************
*** 40,45 ****
--- 41,47 ----
  #define REG_CLIENT_LOGON_OPTION_PARM	"LogonOptions"
  #define REG_CLIENT_LOGON_SCRIPT_PARMW	L"LogonScript"
  #define REG_CLIENT_THESE_CELLS_PARM     "TheseCells"
+ #define REG_CLIENT_LOGOFF_TOKENS_PARM	"LogoffPreserveTokens"
  #define DEFAULT_RETRY_INTERVAL          60                        /* seconds*/
  #define DEFAULT_FAIL_SILENTLY           FALSE
  #define DEFAULT_SLEEP_INTERVAL          5                         /* seconds*/
Index: openafs/src/WINNT/afsd/cm_buf.c
diff -c openafs/src/WINNT/afsd/cm_buf.c:1.13.2.10 openafs/src/WINNT/afsd/cm_buf.c:1.13.2.11
*** openafs/src/WINNT/afsd/cm_buf.c:1.13.2.10	Sun Jun  5 02:45:31 2005
--- openafs/src/WINNT/afsd/cm_buf.c	Sun Jun 12 07:45:49 2005
***************
*** 463,468 ****
--- 463,471 ----
              bp->waitRequests = 0;
          }
  
+         if ( !scp ) {
+             scp = cm_FindSCache(&bp->fid);
+         }
          if ( scp ) {
              lock_ObtainMutex(&scp->mx);
              if (scp->flags & CM_SCACHEFLAG_WAITING) {
Index: openafs/src/WINNT/afsd/cm_conn.c
diff -c openafs/src/WINNT/afsd/cm_conn.c:1.25.2.10 openafs/src/WINNT/afsd/cm_conn.c:1.25.2.11
*** openafs/src/WINNT/afsd/cm_conn.c:1.25.2.10	Sun Jun  5 02:45:31 2005
--- openafs/src/WINNT/afsd/cm_conn.c	Sun Jun 12 07:45:49 2005
***************
*** 143,156 ****
             cm_serverRef_t * serversp,
             cm_callbackRequest_t *cbrp, long errorCode)
  {
!     cm_server_t *serverp = 0;
!     cm_serverRef_t **serverspp = 0;
      cm_serverRef_t *tsrp;
      cm_ucell_t *ucellp;
      int retry = 0;
      int free_svr_list = 0;
      int dead_session;
      long timeUsed, timeLeft;
          
      osi_Log2(afsd_logp, "cm_Analyze connp 0x%x, code 0x%x",
               (long) connp, errorCode);
--- 143,157 ----
             cm_serverRef_t * serversp,
             cm_callbackRequest_t *cbrp, long errorCode)
  {
!     cm_server_t *serverp = NULL;
!     cm_serverRef_t **serverspp = NULL;
      cm_serverRef_t *tsrp;
      cm_ucell_t *ucellp;
      int retry = 0;
      int free_svr_list = 0;
      int dead_session;
      long timeUsed, timeLeft;
+     long code;
          
      osi_Log2(afsd_logp, "cm_Analyze connp 0x%x, code 0x%x",
               (long) connp, errorCode);
***************
*** 226,240 ****
          if (timeLeft > 7) {
              osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE.");
              thrd_Sleep(5000);
              /* cm_ForceUpdateVolume marks all servers as non_busy */
              /* No it doesn't and it won't do anything if all of the 
               * the servers are marked as DOWN.  So clear the DOWN
               * flag and reset the busy state as well.
               */
              if (!serversp) {
!                 cm_GetServerList(fidp, userp, reqp, &serverspp);
!                 serversp = *serverspp;
!                 free_svr_list = 1;
              }
              if (serversp) {
                  lock_ObtainWrite(&cm_serverLock);
--- 227,244 ----
          if (timeLeft > 7) {
              osi_Log0(afsd_logp, "cm_Analyze passed CM_ERROR_ALLOFFLINE.");
              thrd_Sleep(5000);
+             
              /* cm_ForceUpdateVolume marks all servers as non_busy */
              /* No it doesn't and it won't do anything if all of the 
               * the servers are marked as DOWN.  So clear the DOWN
               * flag and reset the busy state as well.
               */
              if (!serversp) {
!                 code = cm_GetServerList(fidp, userp, reqp, &serverspp);
!                 if (code == 0) {
!                     serversp = *serverspp;
!                     free_svr_list = 1;
!                 }
              }
              if (serversp) {
                  lock_ObtainWrite(&cm_serverLock);
***************
*** 253,258 ****
--- 257,264 ----
  
              if (fidp != NULL)   /* Not a VLDB call */
                  cm_ForceUpdateVolume(fidp, userp, reqp);
+ 			else
+ 				retry = 0;
          }
      }
  
***************
*** 261,269 ****
          if (timeLeft > 7) {
              thrd_Sleep(5000);
              if (!serversp) {
!                 cm_GetServerList(fidp, userp, reqp, &serverspp);
!                 serversp = *serverspp;
!                 free_svr_list = 1;
              }
              lock_ObtainWrite(&cm_serverLock);
              for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
--- 267,277 ----
          if (timeLeft > 7) {
              thrd_Sleep(5000);
              if (!serversp) {
!                 code = cm_GetServerList(fidp, userp, reqp, &serverspp);
!                 if (code == 0) {
!                     serversp = *serverspp;
!                     free_svr_list = 1;
!                 }
              }
              lock_ObtainWrite(&cm_serverLock);
              for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
***************
*** 282,290 ****
      /* special codes:  VBUSY and VRESTARTING */
      else if (errorCode == VBUSY || errorCode == VRESTARTING) {
          if (!serversp) {
!             cm_GetServerList(fidp, userp, reqp, &serverspp);
!             serversp = *serverspp;
!             free_svr_list = 1;
          }
          lock_ObtainWrite(&cm_serverLock);
          for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
--- 290,300 ----
      /* special codes:  VBUSY and VRESTARTING */
      else if (errorCode == VBUSY || errorCode == VRESTARTING) {
          if (!serversp) {
!             code = cm_GetServerList(fidp, userp, reqp, &serverspp);
!             if (code == 0) {
!                 serversp = *serverspp;
!                 free_svr_list = 1;
!             }
          }
          lock_ObtainWrite(&cm_serverLock);
          for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
***************
*** 332,340 ****
  
          /* Mark server offline for this volume */
          if (!serversp) {
!             cm_GetServerList(fidp, userp, reqp, &serverspp);
!             serversp = *serverspp;
!             free_svr_list = 1;
          }
          for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
              if (tsrp->server == serverp)
--- 342,352 ----
  
          /* Mark server offline for this volume */
          if (!serversp) {
!             code = cm_GetServerList(fidp, userp, reqp, &serverspp);
!             if (code == 0) {
!                 serversp = *serverspp;
!                 free_svr_list = 1;
!             }
          }
          for (tsrp = serversp; tsrp; tsrp=tsrp->next) {
              if (tsrp->server == serverp)
Index: openafs/src/WINNT/afsd/cm_dcache.c
diff -c openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.12 openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.13
*** openafs/src/WINNT/afsd/cm_dcache.c:1.11.2.12	Sun Jun  5 02:45:31 2005
--- openafs/src/WINNT/afsd/cm_dcache.c	Sun Jun 12 07:45:49 2005
***************
*** 1089,1095 ****
          lock_ObtainMutex(&bufp->mx);
          lock_ObtainMutex(&scp->mx);
          cm_SyncOpDone(scp, bufp, flags);
-         lock_ReleaseMutex(&scp->mx);
                  
          /* turn off writing and wakeup users */
          if (isStore) {
--- 1089,1094 ----
***************
*** 1100,1105 ****
--- 1099,1105 ----
              bufp->flags &= ~(CM_BUF_WRITING | CM_BUF_DIRTY);
          }
  
+         lock_ReleaseMutex(&scp->mx);
          lock_ReleaseMutex(&bufp->mx);
          buf_Release(bufp);
      }
Index: openafs/src/WINNT/afsd/cm_dns.c
diff -c openafs/src/WINNT/afsd/cm_dns.c:1.9.2.1 openafs/src/WINNT/afsd/cm_dns.c:1.9.2.2
*** openafs/src/WINNT/afsd/cm_dns.c:1.9.2.1	Wed Mar 16 16:37:52 2005
--- openafs/src/WINNT/afsd/cm_dns.c	Fri Jul  1 22:46:28 2005
***************
*** 702,783 ****
    else
      return 0;
  #else /* DNSAPI_ENV */
! 	PDNS_RECORD pDnsCell, pDnsIter, pDnsVol,pDnsVolIter, pDnsCIter;
! 	DWORD i;
      struct sockaddr_in vlSockAddr;
  
      *numServers = 0; 
      *ttl = 0;
  
      /* query the AFSDB records of cell */
! 	if (DnsQuery_A(cellName, DNS_TYPE_AFSDB, DNS_QUERY_STANDARD, NULL, &pDnsCell, NULL) == ERROR_SUCCESS) {
  
! 		memset((void*) &vlSockAddr, 0, sizeof(vlSockAddr));
  		
! 		/* go through the returned records */
! 		for (pDnsIter = pDnsCell;pDnsIter; pDnsIter = pDnsIter->pNext) {
! 			/* if we find an AFSDB record with Preference set to 1, we found a volserver */
! 			if (pDnsIter->wType == DNS_TYPE_AFSDB && pDnsIter->Data.Afsdb.wPreference == 1) {
! 				strncpy(cellHostNames[*numServers], pDnsIter->Data.Afsdb.pNameExchange, MAXHOSTCHARS);
                  cellHostNames[*numServers][MAXHOSTCHARS-1]='\0';
! 				(*numServers)++;
                  
! 				if (!*ttl) 
                      *ttl = pDnsIter->dwTtl;
! 				if (*numServers == AFSMAXCELLHOSTS) 
                      break;
! 			}
! 		}
  
! 		for (i=0;i<*numServers;i++) 
              cellHostAddrs[i] = 0;
  
! 		/* now check if there are any A records in the results */
! 		for (pDnsIter = pDnsCell; pDnsIter; pDnsIter = pDnsIter->pNext) {
! 			if(pDnsIter->wType == DNS_TYPE_A)
! 				/* check if its for one of the volservers */
! 				for (i=0;i<*numServers;i++)
! 					if(stricmp(pDnsIter->pName, cellHostNames[i]) == 0)
! 						cellHostAddrs[i] = pDnsIter->Data.A.IpAddress;
! 		}
! 
! 		for (i=0;i<*numServers;i++) {
! 			/* if we don't have an IP yet, then we should try resolving the volserver hostname
! 			   in a separate query. */
! 			if (!cellHostAddrs[i]) {
! 				if (DnsQuery_A(cellHostNames[i], DNS_TYPE_A, DNS_QUERY_STANDARD, NULL, &pDnsVol, NULL) == ERROR_SUCCESS) {
! 					for (pDnsVolIter = pDnsVol; pDnsVolIter; pDnsVolIter=pDnsVolIter->pNext) {
! 						/* if we get an A record, keep it */
! 						if (pDnsVolIter->wType == DNS_TYPE_A && stricmp(cellHostNames[i], pDnsVolIter->pName)==0) {
! 							cellHostAddrs[i] = pDnsVolIter->Data.A.IpAddress;
! 							break;
! 						}
! 						/* if we get a CNAME, look for a corresponding A record */
! 						if (pDnsVolIter->wType == DNS_TYPE_CNAME && stricmp(cellHostNames[i], pDnsVolIter->pName)==0) {
! 							for (pDnsCIter=pDnsVolIter; pDnsCIter; pDnsCIter=pDnsCIter->pNext) {
! 								if (pDnsCIter->wType == DNS_TYPE_A && stricmp(pDnsVolIter->Data.CNAME.pNameHost, pDnsCIter->pName)==0) {
! 									cellHostAddrs[i] = pDnsCIter->Data.A.IpAddress;
! 									break;
! 								}
! 							}
! 							if (cellHostAddrs[i]) 
                                  break;
! 							/* TODO: if the additional section is missing, then do another lookup for the CNAME */
! 						}
! 					}
! 					/* we are done with the volserver lookup */
! 					DnsRecordListFree(pDnsVol, DnsFreeRecordListDeep);
! 				}
! 			}
! 		}
! 		DnsRecordListFree(pDnsCell, DnsFreeRecordListDeep);
! 	}
  
      if ( *numServers > 0 )
          return 0;
!     else
          return -1;
  #endif /* DNSAPI_ENV */
  }
- 
  #endif /* AFS_AFSDB_ENV */
--- 702,789 ----
    else
      return 0;
  #else /* DNSAPI_ENV */
!     PDNS_RECORD pDnsCell, pDnsIter, pDnsVol,pDnsVolIter, pDnsCIter;
!     DWORD i;
      struct sockaddr_in vlSockAddr;
+     char query[1024];
  
      *numServers = 0; 
      *ttl = 0;
  
      /* query the AFSDB records of cell */
!     strncpy(query, cellName, 1024);
!     query[1023] = 0;
!     if (query[strlen(query)-1] != '.') {
!         strncat(query,".",1024);
!         query[1023] = 0;
!     }
  
!     if (DnsQuery_A(query, DNS_TYPE_AFSDB, DNS_QUERY_STANDARD, NULL, &pDnsCell, NULL) == ERROR_SUCCESS) {
!         memset((void*) &vlSockAddr, 0, sizeof(vlSockAddr));
  		
!         /* go through the returned records */
!         for (pDnsIter = pDnsCell;pDnsIter; pDnsIter = pDnsIter->pNext) {
!             /* if we find an AFSDB record with Preference set to 1, we found a volserver */
!             if (pDnsIter->wType == DNS_TYPE_AFSDB && pDnsIter->Data.Afsdb.wPreference == 1) {
!                 strncpy(cellHostNames[*numServers], pDnsIter->Data.Afsdb.pNameExchange, MAXHOSTCHARS);
                  cellHostNames[*numServers][MAXHOSTCHARS-1]='\0';
!                 (*numServers)++;
                  
!                 if (!*ttl) 
                      *ttl = pDnsIter->dwTtl;
!                 if (*numServers == AFSMAXCELLHOSTS) 
                      break;
!             }
!         }
  
!         for (i=0;i<*numServers;i++) 
              cellHostAddrs[i] = 0;
  
!         /* now check if there are any A records in the results */
!         for (pDnsIter = pDnsCell; pDnsIter; pDnsIter = pDnsIter->pNext) {
!             if(pDnsIter->wType == DNS_TYPE_A)
!                 /* check if its for one of the volservers */
!                 for (i=0;i<*numServers;i++)
!                     if(stricmp(pDnsIter->pName, cellHostNames[i]) == 0)
!                         cellHostAddrs[i] = pDnsIter->Data.A.IpAddress;
!         }       
! 
!         for (i=0;i<*numServers;i++) {
!             /* if we don't have an IP yet, then we should try resolving the volserver hostname
!             in a separate query. */
!             if (!cellHostAddrs[i]) {
!                 if (DnsQuery_A(cellHostNames[i], DNS_TYPE_A, DNS_QUERY_STANDARD, NULL, &pDnsVol, NULL) == ERROR_SUCCESS) {
!                     for (pDnsVolIter = pDnsVol; pDnsVolIter; pDnsVolIter=pDnsVolIter->pNext) {
!                         /* if we get an A record, keep it */
!                         if (pDnsVolIter->wType == DNS_TYPE_A && stricmp(cellHostNames[i], pDnsVolIter->pName)==0) {
!                             cellHostAddrs[i] = pDnsVolIter->Data.A.IpAddress;
!                             break;
!                         }
!                         /* if we get a CNAME, look for a corresponding A record */
!                         if (pDnsVolIter->wType == DNS_TYPE_CNAME && stricmp(cellHostNames[i], pDnsVolIter->pName)==0) {
!                             for (pDnsCIter=pDnsVolIter; pDnsCIter; pDnsCIter=pDnsCIter->pNext) {
!                                 if (pDnsCIter->wType == DNS_TYPE_A && stricmp(pDnsVolIter->Data.CNAME.pNameHost, pDnsCIter->pName)==0) {
!                                     cellHostAddrs[i] = pDnsCIter->Data.A.IpAddress;
!                                     break;
!                                 }
!                             }
!                             if (cellHostAddrs[i]) 
                                  break;
!                             /* TODO: if the additional section is missing, then do another lookup for the CNAME */
!                         }
!                     }
!                     /* we are done with the volserver lookup */
!                     DnsRecordListFree(pDnsVol, DnsFreeRecordListDeep);
!                 }
!             }
!         }
!         DnsRecordListFree(pDnsCell, DnsFreeRecordListDeep);
!     }
  
      if ( *numServers > 0 )
          return 0;
!     else        
          return -1;
  #endif /* DNSAPI_ENV */
  }
  #endif /* AFS_AFSDB_ENV */
Index: openafs/src/WINNT/afsd/cm_scache.c
diff -c openafs/src/WINNT/afsd/cm_scache.c:1.14.2.10 openafs/src/WINNT/afsd/cm_scache.c:1.14.2.11
*** openafs/src/WINNT/afsd/cm_scache.c:1.14.2.10	Sun Jun  5 09:39:29 2005
--- openafs/src/WINNT/afsd/cm_scache.c	Sun Jun 12 07:45:49 2005
***************
*** 1027,1041 ****
      if (!(flags & CM_MERGEFLAG_FORCE)
           && statusp->DataVersion < (unsigned long) scp->dataVersion) {
          struct cm_cell *cellp;
-         struct cm_volume *volp;
  
          cellp = cm_FindCellByID(scp->fid.cell);
!         cm_GetVolumeByID(cellp, scp->fid.volume, userp,
!                           (cm_req_t *) NULL, &volp);
!         if (scp->cbServerp)
              osi_Log2(afsd_logp, "old data from server %x volume %s",
                        scp->cbServerp->addr.sin_addr.s_addr,
!                       volp->namep);
          osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d",
                    scp, scp->dataVersion, statusp->DataVersion);
          /* we have a number of data fetch/store operations running
--- 1027,1045 ----
      if (!(flags & CM_MERGEFLAG_FORCE)
           && statusp->DataVersion < (unsigned long) scp->dataVersion) {
          struct cm_cell *cellp;
  
          cellp = cm_FindCellByID(scp->fid.cell);
!         if (scp->cbServerp) {
!             struct cm_volume *volp = NULL;
! 
!             cm_GetVolumeByID(cellp, scp->fid.volume, userp,
!                               (cm_req_t *) NULL, &volp);
              osi_Log2(afsd_logp, "old data from server %x volume %s",
                        scp->cbServerp->addr.sin_addr.s_addr,
!                       volp ? volp->namep : "(unknown)");
!             if (volp)
!                 cm_PutVolume(volp);
!         }
          osi_Log3(afsd_logp, "Bad merge, scp %x, scp dv %d, RPC dv %d",
                    scp, scp->dataVersion, statusp->DataVersion);
          /* we have a number of data fetch/store operations running
Index: openafs/src/WINNT/afsd/smb.c
diff -c openafs/src/WINNT/afsd/smb.c:1.55.2.24 openafs/src/WINNT/afsd/smb.c:1.55.2.25
*** openafs/src/WINNT/afsd/smb.c:1.55.2.24	Sun Jun  5 02:45:32 2005
--- openafs/src/WINNT/afsd/smb.c	Sun Jun 12 07:45:49 2005
***************
*** 2433,2439 ****
      } 
      else if (code == CM_ERROR_ALLBUSY) {
          NTStatus = 0xC00000BFL; /* Network Busy */
!     } else {
          NTStatus = 0xC0982001L;	/* SMB non-specific error */
      }
  
--- 2433,2443 ----
      } 
      else if (code == CM_ERROR_ALLBUSY) {
          NTStatus = 0xC00000BFL; /* Network Busy */
!     } 
!     else if (code == CM_ERROR_ALLOFFLINE) {
!         NTStatus = 0xC0000350L; /* Remote Host Down */
!     } 
!     else {
          NTStatus = 0xC0982001L;	/* SMB non-specific error */
      }
  
Index: openafs/src/WINNT/afssvrcfg/config_server_page.cpp
diff -c openafs/src/WINNT/afssvrcfg/config_server_page.cpp:1.5 openafs/src/WINNT/afssvrcfg/config_server_page.cpp:1.5.2.1
*** openafs/src/WINNT/afssvrcfg/config_server_page.cpp:1.5	Wed Dec 10 22:21:20 2003
--- openafs/src/WINNT/afssvrcfg/config_server_page.cpp	Wed Jul  6 20:29:04 2005
***************
*** 119,155 ****
  #define IF_WIZ(x)	{ if (g_pWiz) (x); }
  
  // Global variables
! static HWND			m_hDlg =			0;		// Window handle of this dialog
! static BOOL			m_bConfiguring =	FALSE;	// TRUE if configuring
! static BOOL			m_bConfigured =		FALSE;	// TRUE if configuration was successful
! static BOOL			m_bConfigFailed =	FALSE;	// TRUE if configuration failed
! static BOOL			m_bCheckCancel =	FALSE;	// TRUE if user pressed cancel - we will ask for confirmation
! static BOOL			m_bCancel =			FALSE;	// TRUE if user confirmed cancel - we will cancel configuration
! static void*		m_hvosServer =		0;		// vos library server handle
! static const		MAX_STEPS =			34;		// Max number of config steps
! static afs_status_t	m_nStatus;					// Error code if a cfg library function fails
! static int			m_nResult;					// Boolean return code from cfg library calls
! static int			m_nNumSteps;				// Number of config steps that will be performed
! static BOOL			m_bDbServersRestarted;		// TRUE if all Database servers were restarted
! static BOOL			m_bMustChangeClientCell;	// TRUE if client is in different cell than server
  static HANDLE		m_hCellServDBUpdateEvent;
! static LPCTSTR      m_pszCellServDBUpdateEventName = TEXT("CellServDBUpdateEvent");
! static const 		m_CallBackID = 6;
! static UINT			m_nPartitionID = INVALID_PARTITION_ID;
! static BOOL			m_bCellServDbUpdateErr = FALSE;
  static TCHAR		m_szCellServDbUpdateErrMsg[cchRESOURCE];
! static LONG			m_nServerUpdates = 0;
  static char *		m_pszCellDbHosts = 0;
! static BOOL			m_bNoAuthMode = TRUE;
  static char 		m_szVicepName[9];
! static BOOL			m_bMustExit;
! static BOOL			m_bCfgInfoInvalidated;
! static BOOL			m_bUnconfiguringLastDBServer;
! static BOOL         m_bClientTokensSet;
! static BOOL         m_bRootAfsDriveMappingCreated;
! static char         m_szDriveToMapTo[3];
! static BOOL         m_bWeCreatedRootAfs;
! static BOOL         m_bWeCreatedRootCell;
  
  static CRITICAL_SECTION m_CritSec;
  
--- 119,155 ----
  #define IF_WIZ(x)	{ if (g_pWiz) (x); }
  
  // Global variables
! static HWND		m_hDlg =		0;	// Window handle of this dialog
! static BOOL		m_bConfiguring =	FALSE;	// TRUE if configuring
! static BOOL		m_bConfigured =		FALSE;	// TRUE if configuration was successful
! static BOOL		m_bConfigFailed =	FALSE;	// TRUE if configuration failed
! static BOOL		m_bCheckCancel =	FALSE;	// TRUE if user pressed cancel - we will ask for confirmation
! static BOOL		m_bCancel =		FALSE;	// TRUE if user confirmed cancel - we will cancel configuration
! static void*		m_hvosServer =		0;	// vos library server handle
! static const int	MAX_STEPS =		34;	// Max number of config steps
! static afs_status_t	m_nStatus;			// Error code if a cfg library function fails
! static int		m_nResult;			// Boolean return code from cfg library calls
! static int		m_nNumSteps;			// Number of config steps that will be performed
! static BOOL		m_bDbServersRestarted;		// TRUE if all Database servers were restarted
! static BOOL		m_bMustChangeClientCell;	// TRUE if client is in different cell than server
  static HANDLE		m_hCellServDBUpdateEvent;
! static LPCTSTR          m_pszCellServDBUpdateEventName = TEXT("CellServDBUpdateEvent");
! static const int	m_CallBackID = 6;
! static UINT		m_nPartitionID = INVALID_PARTITION_ID;
! static BOOL		m_bCellServDbUpdateErr = FALSE;
  static TCHAR		m_szCellServDbUpdateErrMsg[cchRESOURCE];
! static LONG		m_nServerUpdates = 0;
  static char *		m_pszCellDbHosts = 0;
! static BOOL		m_bNoAuthMode = TRUE;
  static char 		m_szVicepName[9];
! static BOOL		m_bMustExit;
! static BOOL		m_bCfgInfoInvalidated;
! static BOOL		m_bUnconfiguringLastDBServer;
! static BOOL             m_bClientTokensSet;
! static BOOL             m_bRootAfsDriveMappingCreated;
! static char             m_szDriveToMapTo[3];
! static BOOL             m_bWeCreatedRootAfs;
! static BOOL             m_bWeCreatedRootCell;
  
  static CRITICAL_SECTION m_CritSec;
  
Index: openafs/src/WINNT/afssvrcfg/get_cur_config.cpp
diff -c openafs/src/WINNT/afssvrcfg/get_cur_config.cpp:1.4 openafs/src/WINNT/afssvrcfg/get_cur_config.cpp:1.4.2.1
*** openafs/src/WINNT/afssvrcfg/get_cur_config.cpp:1.4	Sun Dec  7 17:49:14 2003
--- openafs/src/WINNT/afssvrcfg/get_cur_config.cpp	Wed Jul  6 20:29:04 2005
***************
*** 227,233 ****
  
  	char *psz = pszCellServDB;
  
! 	for (int i = 0; *psz; psz += strlen(psz) + 1)
  		i++;
  
  	if (i == 1) {
--- 227,234 ----
  
  	char *psz = pszCellServDB;
  
!         int i;
! 	for (i = 0; *psz; psz += strlen(psz) + 1)
  		i++;
  
  	if (i == 1) {
***************
*** 430,436 ****
  
  static void NextStep(UINT uiMsgID)
  {
! 	static nCurStep = 1;
  
  	if (bCancel)
  		return;
--- 431,437 ----
  
  static void NextStep(UINT uiMsgID)
  {
! 	static int nCurStep = 1;
  
  	if (bCancel)
  		return;
Index: openafs/src/WINNT/afssvrmgr/action.cpp
diff -c openafs/src/WINNT/afssvrmgr/action.cpp:1.3 openafs/src/WINNT/afssvrmgr/action.cpp:1.3.2.1
*** openafs/src/WINNT/afssvrmgr/action.cpp:1.3	Sat Nov 29 15:23:31 2003
--- openafs/src/WINNT/afssvrmgr/action.cpp	Wed Jul  6 20:29:06 2005
***************
*** 793,799 ****
  
  PACTION Action_Begin (ACTIONTYPE Type, PNOTIFYPARAMS pParams)
  {
!    for (size_t ii = 0; ii < l.cActions; ++ii)
        {
        if (!l.aActions[ii])
           break;
--- 793,800 ----
  
  PACTION Action_Begin (ACTIONTYPE Type, PNOTIFYPARAMS pParams)
  {
!    size_t ii;
!    for (ii = 0; ii < l.cActions; ++ii)
        {
        if (!l.aActions[ii])
           break;
Index: openafs/src/WINNT/afssvrmgr/alert.cpp
diff -c openafs/src/WINNT/afssvrmgr/alert.cpp:1.4 openafs/src/WINNT/afssvrmgr/alert.cpp:1.4.2.1
*** openafs/src/WINNT/afssvrmgr/alert.cpp:1.4	Sat Feb 28 21:38:31 2004
--- openafs/src/WINNT/afssvrmgr/alert.cpp	Wed Jul  6 20:29:06 2005
***************
*** 139,145 ****
           BOOL fNeedBadCredsWarning = FALSE;
           BOOL fHaveBadCredsWarning = FALSE;
  
!          for (size_t iAlert = 0; iAlert < lpoaServer->nAlerts; ++iAlert)
              {
              if (lpoaServer->aAlerts[ iAlert ].alert == alertSECONDARY)
                 {
--- 139,146 ----
           BOOL fNeedBadCredsWarning = FALSE;
           BOOL fHaveBadCredsWarning = FALSE;
  
!          size_t iAlert;
!          for (iAlert = 0; iAlert < lpoaServer->nAlerts; ++iAlert)
              {
              if (lpoaServer->aAlerts[ iAlert ].alert == alertSECONDARY)
                 {
***************
*** 226,232 ****
     LPOBJECTALERTS lpoa;
     if ((lpoa = Alert_GetObjectAlerts (lpiChild, TRUE)) != NULL)
        {
!       for (size_t iAlert = 0; iAlert < lpoa->nAlerts; )
           {
           if ( (lpoa->aAlerts[ iAlert ].alert == alertSECONDARY) &&
                (lpoa->aAlerts[ iAlert ].aiSECONDARY.lpiSecondary == lpiChild) )
--- 227,234 ----
     LPOBJECTALERTS lpoa;
     if ((lpoa = Alert_GetObjectAlerts (lpiChild, TRUE)) != NULL)
        {
!       size_t iAlert;
!       for (iAlert = 0; iAlert < lpoa->nAlerts; )
           {
           if ( (lpoa->aAlerts[ iAlert ].alert == alertSECONDARY) &&
                (lpoa->aAlerts[ iAlert ].aiSECONDARY.lpiSecondary == lpiChild) )
***************
*** 342,348 ****
           if (lpoa->nAlerts && (lpoa->aAlerts[0].alert == alertBADCREDS))
              iInsert = 1;
  
!          for (size_t iHole = iInsert; iHole < lpoa->nAlerts; ++iHole)
              {
              if (lpoa->aAlerts[ iHole ].alert == alertINVALID)
                 break;
--- 344,351 ----
           if (lpoa->nAlerts && (lpoa->aAlerts[0].alert == alertBADCREDS))
              iInsert = 1;
  
!          size_t iHole;
!          for (iHole = iInsert; iHole < lpoa->nAlerts; ++iHole)
              {
              if (lpoa->aAlerts[ iHole ].alert == alertINVALID)
                 break;
Index: openafs/src/WINNT/afssvrmgr/cmdline.cpp
diff -c openafs/src/WINNT/afssvrmgr/cmdline.cpp:1.5 openafs/src/WINNT/afssvrmgr/cmdline.cpp:1.5.2.1
*** openafs/src/WINNT/afssvrmgr/cmdline.cpp:1.5	Thu Apr  1 14:38:37 2004
--- openafs/src/WINNT/afssvrmgr/cmdline.cpp	Wed Jul  6 20:29:06 2005
***************
*** 74,80 ****
  
  CMDLINEOP ParseCommandLine (LPTSTR pszCmdLine)
  {
!    for (size_t ii = 0; ii < nSWITCHES; ++ii)
        aSWITCHES[ ii ].fPresent = FALSE;
  
     // Search through pszCmdLine for switches; each switch must be
--- 74,81 ----
  
  CMDLINEOP ParseCommandLine (LPTSTR pszCmdLine)
  {
!    size_t ii;
!    for (ii = 0; ii < nSWITCHES; ++ii)
        aSWITCHES[ ii ].fPresent = FALSE;
  
     // Search through pszCmdLine for switches; each switch must be
***************
*** 121,127 ****
           {
           TCHAR szCopy[ cchRESOURCE ];
           lstrcpy (szCopy, pszCmdLine);
!          for (LPTSTR pch = szCopy;
                *pch && !iswhite(*pch) && !(*pch == TEXT('/')) && !(*pch == TEXT(':'));
                ++pch)
              ;
--- 122,129 ----
           {
           TCHAR szCopy[ cchRESOURCE ];
           lstrcpy (szCopy, pszCmdLine);
!          LPTSTR pch;
!          for (pch = szCopy;
                *pch && !iswhite(*pch) && !(*pch == TEXT('/')) && !(*pch == TEXT(':'));
                ++pch)
              ;
***************
*** 161,167 ****
              return opCLOSEAPP;
              }
           BOOL fQuoted = FALSE;
!          for (LPTSTR pszTarget = aSWITCHES[ ii ].szValue;
                *pszCmdLine && !(*pszCmdLine == TEXT('/') && !fQuoted)
                            && !(iswhite(*pszCmdLine) && !fQuoted); )
              {
--- 163,170 ----
              return opCLOSEAPP;
              }
           BOOL fQuoted = FALSE;
!          LPTSTR pszTarget;
!          for (pszTarget = aSWITCHES[ ii ].szValue;
                *pszCmdLine && !(*pszCmdLine == TEXT('/') && !fQuoted)
                            && !(iswhite(*pszCmdLine) && !fQuoted); )
              {
Index: openafs/src/WINNT/afssvrmgr/columns.cpp
diff -c openafs/src/WINNT/afssvrmgr/columns.cpp:1.3 openafs/src/WINNT/afssvrmgr/columns.cpp:1.3.2.1
*** openafs/src/WINNT/afssvrmgr/columns.cpp:1.3	Sat Nov 29 15:23:32 2003
--- openafs/src/WINNT/afssvrmgr/columns.cpp	Wed Jul  6 20:29:06 2005
***************
*** 250,258 ****
     hList = GetDlgItem (hDlg, IDC_COL_AVAIL);
     LB_StartChange (hList);
  
!    for (size_t iAvail = 0; iAvail < lpvi->nColsAvail; ++iAvail)
        {
!       for (size_t iShown = 0; iShown < lpvi->nColsShown; ++iShown)
           {
           if (lpvi->aColumns[ iShown ] == iAvail)
              break;
--- 250,260 ----
     hList = GetDlgItem (hDlg, IDC_COL_AVAIL);
     LB_StartChange (hList);
  
!    size_t iAvail;
!    size_t iShown;
!    for (iAvail = 0; iAvail < lpvi->nColsAvail; ++iAvail)
        {
!       for (iShown = 0; iShown < lpvi->nColsShown; ++iShown)
           {
           if (lpvi->aColumns[ iShown ] == iAvail)
              break;
***************
*** 271,277 ****
     hList = GetDlgItem (hDlg, IDC_COL_SHOWN);
     LB_StartChange (hList);
  
!    for (size_t iShown = 0; iShown < lpvi->nColsShown; ++iShown)
        {
        iAvail = lpvi->aColumns[ iShown ];
        LB_AddItem (hList, lpvi->idsColumns[ iAvail ], (LPARAM)iAvail);
--- 273,279 ----
     hList = GetDlgItem (hDlg, IDC_COL_SHOWN);
     LB_StartChange (hList);
  
!    for (iShown = 0; iShown < lpvi->nColsShown; ++iShown)
        {
        iAvail = lpvi->aColumns[ iShown ];
        LB_AddItem (hList, lpvi->idsColumns[ iAvail ], (LPARAM)iAvail);
Index: openafs/src/WINNT/afssvrmgr/dispatch.cpp
diff -c openafs/src/WINNT/afssvrmgr/dispatch.cpp:1.2 openafs/src/WINNT/afssvrmgr/dispatch.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/dispatch.cpp:1.2	Sat Nov  4 05:02:03 2000
--- openafs/src/WINNT/afssvrmgr/dispatch.cpp	Wed Jul  6 20:29:06 2005
***************
*** 494,500 ****
  {
     EnterCriticalSection (&csDispatch);
  
!    for (size_t iDispatch = 0; iDispatch < nDispatchList; ++iDispatch)
        {
        if ( (aDispatchList[ iDispatch ].hWnd == hWnd) &&
             (aDispatchList[ iDispatch ].when == when) &&
--- 494,501 ----
  {
     EnterCriticalSection (&csDispatch);
  
!    size_t iDispatch;
!    for (iDispatch = 0; iDispatch < nDispatchList; ++iDispatch)
        {
        if ( (aDispatchList[ iDispatch ].hWnd == hWnd) &&
             (aDispatchList[ iDispatch ].when == when) &&
Index: openafs/src/WINNT/afssvrmgr/display.cpp
diff -c openafs/src/WINNT/afssvrmgr/display.cpp:1.2 openafs/src/WINNT/afssvrmgr/display.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/display.cpp:1.2	Sat Nov  4 05:02:04 2000
--- openafs/src/WINNT/afssvrmgr/display.cpp	Wed Jul  6 20:29:06 2005
***************
*** 146,152 ****
        }
     EnterCriticalSection (pcsWindowActOnDone);
  
!    for (size_t ii = 0; ii < cWindowActOnDone; ++ii)
        {
        if (aWindowActOnDone[ ii ].hWnd == hWnd)
           break;
--- 146,153 ----
        }
     EnterCriticalSection (pcsWindowActOnDone);
  
!    size_t ii;
!    for (ii = 0; ii < cWindowActOnDone; ++ii)
        {
        if (aWindowActOnDone[ ii ].hWnd == hWnd)
           break;
***************
*** 228,234 ****
  
     EnterCriticalSection (pcsDisplayQueue);
  
!    for (size_t idq = 0; idq < cDisplayQueue; ++idq)
        {
        if (!aDisplayQueue[idq].hChild)
           break;
--- 229,236 ----
  
     EnterCriticalSection (pcsDisplayQueue);
  
!    size_t idq;
!    for (idq = 0; idq < cDisplayQueue; ++idq)
        {
        if (!aDisplayQueue[idq].hChild)
           break;
***************
*** 329,335 ****
           }
        else
           {
!          for (size_t idq = 0; idq < cDisplayQueue; ++idq)
              {
              if (aDisplayQueue[idq].hChild)
                 {
--- 331,338 ----
           }
        else
           {
!          size_t idq;
!          for (idq = 0; idq < cDisplayQueue; ++idq)
              {
              if (aDisplayQueue[idq].hChild)
                 {
Index: openafs/src/WINNT/afssvrmgr/general.cpp
diff -c openafs/src/WINNT/afssvrmgr/general.cpp:1.2 openafs/src/WINNT/afssvrmgr/general.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/general.cpp:1.2	Sat Nov  4 05:02:04 2000
--- openafs/src/WINNT/afssvrmgr/general.cpp	Wed Jul  6 20:29:06 2005
***************
*** 53,59 ****
  
     EnterCriticalSection (pcsWindowList);
  
!    for (size_t ii = 0; !lpdw && ii < cWindowList; ++ii)
        {
        if (aWindowList[ ii ].hWnd == hWnd)
           lpdw = &aWindowList[ ii ].dw;
--- 53,60 ----
  
     EnterCriticalSection (pcsWindowList);
  
!    size_t ii;
!    for (ii = 0; !lpdw && ii < cWindowList; ++ii)
        {
        if (aWindowList[ ii ].hWnd == hWnd)
           lpdw = &aWindowList[ ii ].dw;
Index: openafs/src/WINNT/afssvrmgr/helpfunc.cpp
diff -c openafs/src/WINNT/afssvrmgr/helpfunc.cpp:1.2 openafs/src/WINNT/afssvrmgr/helpfunc.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/helpfunc.cpp:1.2	Sat Nov  4 05:02:04 2000
--- openafs/src/WINNT/afssvrmgr/helpfunc.cpp	Wed Jul  6 20:29:06 2005
***************
*** 220,226 ****
           ++pszKeyword;
  
        // find the end of this word
!       for (LPTSTR pszNext = pszKeyword; *pszNext && !iswhite(*pszNext); )
           ++pszNext;
        if (!*pszNext)  // last word?  Gotta use it.
           break;
--- 220,227 ----
           ++pszKeyword;
  
        // find the end of this word
!       LPTSTR pszNext;
!       for (pszNext = pszKeyword; *pszNext && !iswhite(*pszNext); )
           ++pszNext;
        if (!*pszNext)  // last word?  Gotta use it.
           break;
***************
*** 542,555 ****
     GetDlgItemText (hDlg, 0x051F, szSys, cchRESOURCE);
     if ((dw = NextSearch (cmd)) != 0)
        {
!       for (LPTSTR psz = &szSys[ lstrlen(szSys)-1 ]; *(psz-1) != TEXT('\n'); --psz);
        lstrcpy (szSys2, psz);
        wsprintf (psz, TEXT("%c%s"), (TCHAR)dw, szSys2);
        SetDlgItemText (hDlg, 0x051F, szSys);
        }
     else // (dw == 0)
        {
!       for (LPTSTR psz = szSys; *psz && (*psz != TEXT('\n')); ++psz);
        wsprintf (szSys2, TEXT("%s\n"), 1+psz);
        SetDlgItemText (hDlg, 0x051F, szSys2);
        }
--- 543,558 ----
     GetDlgItemText (hDlg, 0x051F, szSys, cchRESOURCE);
     if ((dw = NextSearch (cmd)) != 0)
        {
!       LPTSTR psz;
!       for (psz = &szSys[ lstrlen(szSys)-1 ]; *(psz-1) != TEXT('\n'); --psz);
        lstrcpy (szSys2, psz);
        wsprintf (psz, TEXT("%c%s"), (TCHAR)dw, szSys2);
        SetDlgItemText (hDlg, 0x051F, szSys);
        }
     else // (dw == 0)
        {
!       LPTSTR psz;
!       for (psz = szSys; *psz && (*psz != TEXT('\n')); ++psz);
        wsprintf (szSys2, TEXT("%s\n"), 1+psz);
        SetDlgItemText (hDlg, 0x051F, szSys2);
        }
Index: openafs/src/WINNT/afssvrmgr/propcache.cpp
diff -c openafs/src/WINNT/afssvrmgr/propcache.cpp:1.2 openafs/src/WINNT/afssvrmgr/propcache.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/propcache.cpp:1.2	Sat Nov  4 05:02:06 2000
--- openafs/src/WINNT/afssvrmgr/propcache.cpp	Wed Jul  6 20:29:06 2005
***************
*** 36,42 ****
  {
     if (!PropCache_Search (pcType, pv))
        {
!       for (size_t iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
           {
           if (!PropCache_apce[ iEntry ].fInUse)
              break;
--- 36,43 ----
  {
     if (!PropCache_Search (pcType, pv))
        {
!       size_t iEntry;
!       for (iEntry = 0; iEntry < PropCache_nEntries; ++iEntry)
           {
           if (!PropCache_apce[ iEntry ].fInUse)
              break;
Index: openafs/src/WINNT/afssvrmgr/svc_prop.cpp
diff -c openafs/src/WINNT/afssvrmgr/svc_prop.cpp:1.2 openafs/src/WINNT/afssvrmgr/svc_prop.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/svc_prop.cpp:1.2	Sat Nov  4 05:02:11 2000
--- openafs/src/WINNT/afssvrmgr/svc_prop.cpp	Wed Jul  6 20:29:06 2005
***************
*** 256,262 ****
        SetDlgItemText (hDlg, IDC_SVC_TYPE, szText);
  
        LPTSTR pszParams = CloneString (TASKDATA(ptp)->cs.szParams);
!       for (LPTSTR pch = pszParams; pch && *pch; ++pch)
           {
           if (*pch == TEXT('\r') || *pch == TEXT('\t') || *pch == TEXT('\n'))
              *pch = TEXT(' ');
--- 256,263 ----
        SetDlgItemText (hDlg, IDC_SVC_TYPE, szText);
  
        LPTSTR pszParams = CloneString (TASKDATA(ptp)->cs.szParams);
!       LPTSTR pch;
!       for (pch = pszParams; pch && *pch; ++pch)
           {
           if (*pch == TEXT('\r') || *pch == TEXT('\t') || *pch == TEXT('\n'))
              *pch = TEXT(' ');
Index: openafs/src/WINNT/afssvrmgr/svr_address.cpp
diff -c openafs/src/WINNT/afssvrmgr/svr_address.cpp:1.2 openafs/src/WINNT/afssvrmgr/svr_address.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/svr_address.cpp:1.2	Sat Nov  4 05:02:12 2000
--- openafs/src/WINNT/afssvrmgr/svr_address.cpp	Wed Jul  6 20:29:06 2005
***************
*** 291,297 ****
              // First see if the new IP address is already in the server's
              // list of IP addresses--if so, just delete the old address.
              //
!             for (size_t iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr)
                 {
                 int OldAddrInt;
                 AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]);
--- 291,298 ----
              // First see if the new IP address is already in the server's
              // list of IP addresses--if so, just delete the old address.
              //
!             size_t iAddr;
!             for (iAddr = 0; iAddr < lpp->ssOld.nAddresses; ++iAddr)
                 {
                 int OldAddrInt;
                 AfsClass_AddressToInt (&OldAddrInt, &lpp->ssOld.aAddresses[iAddr]);
Index: openafs/src/WINNT/afssvrmgr/svr_hosts.cpp
diff -c openafs/src/WINNT/afssvrmgr/svr_hosts.cpp:1.2 openafs/src/WINNT/afssvrmgr/svr_hosts.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/svr_hosts.cpp:1.2	Sat Nov  4 05:02:13 2000
--- openafs/src/WINNT/afssvrmgr/svr_hosts.cpp	Wed Jul  6 20:29:06 2005
***************
*** 271,277 ****
  
     if (ModalDialogParam (IDD_SVR_ADDHOST, hDlg, (DLGPROC)Server_AddHost_DlgProc, (LPARAM)pAdd) == IDOK)
        {
!       for (size_t iEntry = 0; iEntry < lpp->lpList->cEntries; ++iEntry)
           {
           LPHOSTLISTENTRY pEntry = &lpp->lpList->aEntries[ iEntry ];
           if (pEntry->szHost[0] == TEXT('\0'))
--- 271,278 ----
  
     if (ModalDialogParam (IDD_SVR_ADDHOST, hDlg, (DLGPROC)Server_AddHost_DlgProc, (LPARAM)pAdd) == IDOK)
        {
!       size_t iEntry;
!       for (iEntry = 0; iEntry < lpp->lpList->cEntries; ++iEntry)
           {
           LPHOSTLISTENTRY pEntry = &lpp->lpList->aEntries[ iEntry ];
           if (pEntry->szHost[0] == TEXT('\0'))
Index: openafs/src/WINNT/afssvrmgr/svr_security.cpp
diff -c openafs/src/WINNT/afssvrmgr/svr_security.cpp:1.2 openafs/src/WINNT/afssvrmgr/svr_security.cpp:1.2.20.1
*** openafs/src/WINNT/afssvrmgr/svr_security.cpp:1.2	Sat Nov  4 05:02:14 2000
--- openafs/src/WINNT/afssvrmgr/svr_security.cpp	Wed Jul  6 20:29:07 2005
***************
*** 347,353 ****
  
     AfsAppLib_FreeCellList (pp.lpcl);
  
!    for (size_t iEntry = 0; iEntry < lpp->lpAdmList->cEntries; ++iEntry)
        {
        LPADMINLISTENTRY pEntry = &lpp->lpAdmList->aEntries[ iEntry ];
        if (pEntry->szAdmin[0] == TEXT('\0'))
--- 347,354 ----
  
     AfsAppLib_FreeCellList (pp.lpcl);
  
!    size_t iEntry;
!    for (iEntry = 0; iEntry < lpp->lpAdmList->cEntries; ++iEntry)
        {
        LPADMINLISTENTRY pEntry = &lpp->lpAdmList->aEntries[ iEntry ];
        if (pEntry->szAdmin[0] == TEXT('\0'))
***************
*** 624,630 ****
  
  void FormatServerKey (LPTSTR psz, LPENCRYPTIONKEY pKey)
  {
!    for (size_t ii = 0; ii < ENCRYPTIONKEY_LEN; ++ii)
        {
        if (pKey->key[ii])
           break;
--- 625,632 ----
  
  void FormatServerKey (LPTSTR psz, LPENCRYPTIONKEY pKey)
  {
!    size_t ii;
!    for (ii = 0; ii < ENCRYPTIONKEY_LEN; ++ii)
        {
        if (pKey->key[ii])
           break;
***************
*** 650,656 ****
  
  BOOL ScanServerKey (LPENCRYPTIONKEY pKey, LPTSTR psz)
  {
!    for (size_t ich = 0; psz && *psz; )
        {
        if (ich == ENCRYPTIONKEY_LEN)
           return FALSE;
--- 652,659 ----
  
  BOOL ScanServerKey (LPENCRYPTIONKEY pKey, LPTSTR psz)
  {
!    size_t ich;
!    for (ich = 0; psz && *psz; )
        {
        if (ich == ENCRYPTIONKEY_LEN)
           return FALSE;
Index: openafs/src/WINNT/afsusrmgr/browse.cpp
diff -c openafs/src/WINNT/afsusrmgr/browse.cpp:1.2 openafs/src/WINNT/afsusrmgr/browse.cpp:1.2.20.1
*** openafs/src/WINNT/afsusrmgr/browse.cpp:1.2	Sat Nov  4 05:02:22 2000
--- openafs/src/WINNT/afsusrmgr/browse.cpp	Wed Jul  6 20:29:10 2005
***************
*** 341,346 ****
--- 341,347 ----
  void Browse_OnEndTask_EnumObjects (HWND hDlg, LPTASKPACKET ptp)
  {
     LPBROWSE_PARAMS lpp;
+    size_t ii;
     if ((lpp = (LPBROWSE_PARAMS)GetWindowLong (hDlg, DWL_USER)) != NULL)
        {
        HWND hList = GetDlgItem (hDlg, IDC_BROWSE_LIST);
***************
*** 359,365 ****
              {
              LPHASHLIST pListToSkip = New (HASHLIST);
  
!             for (size_t ii = 0; ii < lpp->pObjectsToSkip->cEntries; ++ii)
                 pListToSkip->AddUnique ((PVOID)(lpp->pObjectsToSkip->aEntries[ii].idObject));
  
              for (ii = 0; ii < TASKDATA(ptp)->pAsidList->cEntries; )
--- 360,366 ----
              {
              LPHASHLIST pListToSkip = New (HASHLIST);
  
!             for (ii = 0; ii < lpp->pObjectsToSkip->cEntries; ++ii)
                 pListToSkip->AddUnique ((PVOID)(lpp->pObjectsToSkip->aEntries[ii].idObject));
  
              for (ii = 0; ii < TASKDATA(ptp)->pAsidList->cEntries; )
***************
*** 376,382 ****
  
        // OK, we're ready to go--populate that list!
        //
!       for (size_t ii = 0; ii < TASKDATA(ptp)->pAsidList->cEntries; ++ii)
           {
           ULONG status;
           ASOBJPROP Properties;
--- 377,383 ----
  
        // OK, we're ready to go--populate that list!
        //
!       for (ii = 0; ii < TASKDATA(ptp)->pAsidList->cEntries; ++ii)
           {
           ULONG status;
           ASOBJPROP Properties;
Index: openafs/src/WINNT/afsusrmgr/cmdline.cpp
diff -c openafs/src/WINNT/afsusrmgr/cmdline.cpp:1.3 openafs/src/WINNT/afsusrmgr/cmdline.cpp:1.3.2.1
*** openafs/src/WINNT/afsusrmgr/cmdline.cpp:1.3	Sat Nov 29 15:23:32 2003
--- openafs/src/WINNT/afsusrmgr/cmdline.cpp	Wed Jul  6 20:29:10 2005
***************
*** 64,70 ****
  
  CMDLINEOP ParseCommandLine (LPTSTR pszCmdLine)
  {
!    for (size_t ii = 0; ii < nSWITCHES; ++ii)
        aSWITCHES[ ii ].fPresent = FALSE;
  
     // Search through pszCmdLine for switches; each switch must be
--- 64,71 ----
  
  CMDLINEOP ParseCommandLine (LPTSTR pszCmdLine)
  {
!    size_t ii;
!    for (ii = 0; ii < nSWITCHES; ++ii)
        aSWITCHES[ ii ].fPresent = FALSE;
  
     // Search through pszCmdLine for switches; each switch must be
***************
*** 111,117 ****
           {
           TCHAR szCopy[ cchRESOURCE ];
           lstrcpy (szCopy, pszCmdLine);
!          for (LPTSTR pch = szCopy;
                *pch && !iswhite(*pch) && !(*pch == TEXT('/')) && !(*pch == TEXT(':'));
                ++pch)
              ;
--- 112,119 ----
           {
           TCHAR szCopy[ cchRESOURCE ];
           lstrcpy (szCopy, pszCmdLine);
!          LPTSTR pch;
!          for (pch = szCopy;
                *pch && !iswhite(*pch) && !(*pch == TEXT('/')) && !(*pch == TEXT(':'));
                ++pch)
              ;
***************
*** 151,157 ****
              return opCLOSEAPP;
              }
           BOOL fQuoted = FALSE;
!          for (LPTSTR pszTarget = aSWITCHES[ ii ].szValue;
                *pszCmdLine && !(*pszCmdLine == TEXT('/') && !fQuoted)
                            && !(iswhite(*pszCmdLine) && !fQuoted); )
              {
--- 153,160 ----
              return opCLOSEAPP;
              }
           BOOL fQuoted = FALSE;
!          LPTSTR pszTarget;
!          for (pszTarget = aSWITCHES[ ii ].szValue;
                *pszCmdLine && !(*pszCmdLine == TEXT('/') && !fQuoted)
                            && !(iswhite(*pszCmdLine) && !fQuoted); )
              {
Index: openafs/src/WINNT/afsusrmgr/columns.cpp
diff -c openafs/src/WINNT/afsusrmgr/columns.cpp:1.3 openafs/src/WINNT/afsusrmgr/columns.cpp:1.3.2.1
*** openafs/src/WINNT/afsusrmgr/columns.cpp:1.3	Sat Nov 29 15:23:32 2003
--- openafs/src/WINNT/afsusrmgr/columns.cpp	Wed Jul  6 20:29:10 2005
***************
*** 221,229 ****
     hList = GetDlgItem (hDlg, IDC_COL_AVAIL);
     LB_StartChange (hList);
  
!    for (size_t iAvail = 0; iAvail < lpvi->nColsAvail; ++iAvail)
        {
!       for (size_t iShown = 0; iShown < lpvi->nColsShown; ++iShown)
           {
           if (lpvi->aColumns[ iShown ] == iAvail)
              break;
--- 221,231 ----
     hList = GetDlgItem (hDlg, IDC_COL_AVAIL);
     LB_StartChange (hList);
  
!    size_t iAvail;
!    size_t iShown;
!    for (iAvail = 0; iAvail < lpvi->nColsAvail; ++iAvail)
        {
!       for (iShown = 0; iShown < lpvi->nColsShown; ++iShown)
           {
           if (lpvi->aColumns[ iShown ] == iAvail)
              break;
***************
*** 242,248 ****
     hList = GetDlgItem (hDlg, IDC_COL_SHOWN);
     LB_StartChange (hList);
  
!    for (size_t iShown = 0; iShown < lpvi->nColsShown; ++iShown)
        {
        iAvail = lpvi->aColumns[ iShown ];
        LB_AddItem (hList, lpvi->idsColumns[ iAvail ], (LPARAM)iAvail);
--- 244,250 ----
     hList = GetDlgItem (hDlg, IDC_COL_SHOWN);
     LB_StartChange (hList);
  
!    for (iShown = 0; iShown < lpvi->nColsShown; ++iShown)
        {
        iAvail = lpvi->aColumns[ iShown ];
        LB_AddItem (hList, lpvi->idsColumns[ iAvail ], (LPARAM)iAvail);
Index: openafs/src/WINNT/afsusrmgr/general.cpp
diff -c openafs/src/WINNT/afsusrmgr/general.cpp:1.2 openafs/src/WINNT/afsusrmgr/general.cpp:1.2.20.1
*** openafs/src/WINNT/afsusrmgr/general.cpp:1.2	Sat Nov  4 05:02:24 2000
--- openafs/src/WINNT/afsusrmgr/general.cpp	Wed Jul  6 20:29:10 2005
***************
*** 156,162 ****
  
  void FormatServerKey (LPTSTR psz, PBYTE pKey)
  {
!    for (size_t ii = 0; ii < ENCRYPTIONKEYLENGTH; ++ii)
        {
        if (pKey[ii])
           break;
--- 156,163 ----
  
  void FormatServerKey (LPTSTR psz, PBYTE pKey)
  {
!    size_t ii;
!    for (ii = 0; ii < ENCRYPTIONKEYLENGTH; ++ii)
        {
        if (pKey[ii])
           break;
***************
*** 182,188 ****
  
  BOOL ScanServerKey (PBYTE pKey, LPTSTR psz)
  {
!    for (size_t ich = 0; psz && *psz; )
        {
        if (ich == ENCRYPTIONKEYLENGTH)
           return FALSE;
--- 183,190 ----
  
  BOOL ScanServerKey (PBYTE pKey, LPTSTR psz)
  {
!    size_t ich;
!    for (ich = 0; psz && *psz; )
        {
        if (ich == ENCRYPTIONKEYLENGTH)
           return FALSE;
Index: openafs/src/WINNT/afsusrmgr/helpfunc.cpp
diff -c openafs/src/WINNT/afsusrmgr/helpfunc.cpp:1.2 openafs/src/WINNT/afsusrmgr/helpfunc.cpp:1.2.20.1
*** openafs/src/WINNT/afsusrmgr/helpfunc.cpp:1.2	Sat Nov  4 05:02:26 2000
--- openafs/src/WINNT/afsusrmgr/helpfunc.cpp	Wed Jul  6 20:29:10 2005
***************
*** 176,182 ****
           ++pszKeyword;
  
        // find the end of this word
!       for (LPTSTR pszNext = pszKeyword; *pszNext && !iswhite(*pszNext); )
           ++pszNext;
        if (!*pszNext)  // last word?  Gotta use it.
           break;
--- 176,183 ----
           ++pszKeyword;
  
        // find the end of this word
!       LPTSTR pszNext;
!       for (pszNext = pszKeyword; *pszNext && !iswhite(*pszNext); )
           ++pszNext;
        if (!*pszNext)  // last word?  Gotta use it.
           break;
***************
*** 485,501 ****
     DWORD dw;
     TCHAR szSys[cchRESOURCE];
     TCHAR szSys2[cchRESOURCE];
     GetDlgItemText (hDlg, 0x07E6, szSys, cchRESOURCE);
     if ((dw = NextSearch (cmd)) != 0)
        {
!       for (LPTSTR psz = &szSys[ lstrlen(szSys)-1 ]; *(psz-1) != TEXT('\n'); --psz);
        lstrcpy (szSys2, psz);
        wsprintf (psz, TEXT("%c%s"), (TCHAR)dw, szSys2);
        SetDlgItemText (hDlg, 0x07E6, szSys);
        }
     else // (dw == 0)
        {
!       for (LPTSTR psz = szSys; *psz && (*psz != TEXT('\n')); ++psz);
        wsprintf (szSys2, TEXT("%s\n"), 1+psz);
        SetDlgItemText (hDlg, 0x07E6, szSys2);
        }
--- 486,503 ----
     DWORD dw;
     TCHAR szSys[cchRESOURCE];
     TCHAR szSys2[cchRESOURCE];
+    LPTSTR psz;
     GetDlgItemText (hDlg, 0x07E6, szSys, cchRESOURCE);
     if ((dw = NextSearch (cmd)) != 0)
        {
!       for (psz = &szSys[ lstrlen(szSys)-1 ]; *(psz-1) != TEXT('\n'); --psz);
        lstrcpy (szSys2, psz);
        wsprintf (psz, TEXT("%c%s"), (TCHAR)dw, szSys2);
        SetDlgItemText (hDlg, 0x07E6, szSys);
        }
     else // (dw == 0)
        {
!       for (psz = szSys; *psz && (*psz != TEXT('\n')); ++psz);
        wsprintf (szSys2, TEXT("%s\n"), 1+psz);
        SetDlgItemText (hDlg, 0x07E6, szSys2);
        }
Index: openafs/src/WINNT/afsusrmgr/task.cpp
diff -c openafs/src/WINNT/afsusrmgr/task.cpp:1.3 openafs/src/WINNT/afsusrmgr/task.cpp:1.3.2.1
*** openafs/src/WINNT/afsusrmgr/task.cpp:1.3	Sun Dec  7 17:49:15 2003
--- openafs/src/WINNT/afsusrmgr/task.cpp	Wed Jul  6 20:29:11 2005
***************
*** 625,631 ****
     // test it for inclusion of a particular group.
     //
     LPHASHLIST pGroupsAllow = New (HASHLIST);
!    for (size_t iGroup = 0; iGroup < lpp->pGroups->cEntries; ++iGroup)
        pGroupsAllow->AddUnique ((PVOID)(lpp->pGroups->aEntries[ iGroup ].idObject));
  
     // We'll have to do this next bit for each user in the supplied user-list
--- 625,632 ----
     // test it for inclusion of a particular group.
     //
     LPHASHLIST pGroupsAllow = New (HASHLIST);
!    size_t iGroup;
!    for (iGroup = 0; iGroup < lpp->pGroups->cEntries; ++iGroup)
        pGroupsAllow->AddUnique ((PVOID)(lpp->pGroups->aEntries[ iGroup ].idObject));
  
     // We'll have to do this next bit for each user in the supplied user-list
***************
*** 1182,1188 ****
     // test it to see if a particular member should remain in a group.
     //
     LPHASHLIST pMembersAllow = New (HASHLIST);
!    for (size_t iMember = 0; iMember < lpp->pMembers->cEntries; ++iMember)
        pMembersAllow->AddUnique ((PVOID)(lpp->pMembers->aEntries[ iMember ].idObject));
  
     // We'll have to do this next bit for each group in the supplied group-list
--- 1183,1190 ----
     // test it to see if a particular member should remain in a group.
     //
     LPHASHLIST pMembersAllow = New (HASHLIST);
!    size_t iMember;
!    for (iMember = 0; iMember < lpp->pMembers->cEntries; ++iMember)
        pMembersAllow->AddUnique ((PVOID)(lpp->pMembers->aEntries[ iMember ].idObject));
  
     // We'll have to do this next bit for each group in the supplied group-list
***************
*** 1357,1363 ****
     // quickly test it for inclusion of a particular group.
     //
     LPHASHLIST pGroupsAllow = New (HASHLIST);
!    for (size_t iGroup = 0; iGroup < lpp->pOwnedGroups->cEntries; ++iGroup)
        pGroupsAllow->AddUnique ((PVOID)(lpp->pOwnedGroups->aEntries[ iGroup ].idObject));
  
     // Obtain the current list-of-groups-owned for this group
--- 1359,1366 ----
     // quickly test it for inclusion of a particular group.
     //
     LPHASHLIST pGroupsAllow = New (HASHLIST);
!    size_t iGroup;
!    for (iGroup = 0; iGroup < lpp->pOwnedGroups->cEntries; ++iGroup)
        pGroupsAllow->AddUnique ((PVOID)(lpp->pOwnedGroups->aEntries[ iGroup ].idObject));
  
     // Obtain the current list-of-groups-owned for this group
Index: openafs/src/WINNT/afsusrmgr/winlist.cpp
diff -c openafs/src/WINNT/afsusrmgr/winlist.cpp:1.2 openafs/src/WINNT/afsusrmgr/winlist.cpp:1.2.20.1
*** openafs/src/WINNT/afsusrmgr/winlist.cpp:1.2	Sat Nov  4 05:02:32 2000
--- openafs/src/WINNT/afsusrmgr/winlist.cpp	Wed Jul  6 20:29:11 2005
***************
*** 43,49 ****
  {
     // See if this window is already in the list
     //
!    for (size_t ii = 0; ii < cWindowList; ++ii)
        {
        if (aWindowList[ ii ].hWnd == hWnd)
           return;
--- 43,50 ----
  {
     // See if this window is already in the list
     //
!    size_t ii;
!    for (ii = 0; ii < cWindowList; ++ii)
        {
        if (aWindowList[ ii ].hWnd == hWnd)
           return;
Index: openafs/src/WINNT/aklog/NTMakefile
diff -c openafs/src/WINNT/aklog/NTMakefile:1.2 openafs/src/WINNT/aklog/NTMakefile:1.2.2.1
*** openafs/src/WINNT/aklog/NTMakefile:1.2	Thu Aug  5 12:31:37 2004
--- openafs/src/WINNT/aklog/NTMakefile	Sun Jun 12 07:26:15 2005
***************
*** 15,26 ****
  # BUILD TARGETS
  #
  
! EXEFILE = $(DESTDIR)\root.client\usr\vice\etc\aklog.exe
  
! EXEOBJS = \
  	$(OUT)\aklog.obj \
  	$(OUT)\linked_list.obj
  
  EXELIBS = \
  	$(DESTDIR)\lib\afs\afspioctl.lib \
      $(DESTDIR)\lib\afsauthent.lib \
--- 15,31 ----
  # BUILD TARGETS
  #
  
! AKLOG = $(DESTDIR)\root.client\usr\vice\etc\aklog.exe
  
! AKLOGOBJS = \
  	$(OUT)\aklog.obj \
  	$(OUT)\linked_list.obj
  
+ ASETKEY = $(DESTDIR)\root.server\usr\afs\bin\asetkey.exe
+ 
+ ASETKEYOBJS = \
+ 	$(OUT)\asetkey.obj
+ 
  EXELIBS = \
  	$(DESTDIR)\lib\afs\afspioctl.lib \
      $(DESTDIR)\lib\afsauthent.lib \
***************
*** 29,48 ****
  OTHERLIBS = \
      ..\kfw\lib\i386\krbv4w32.lib \
      ..\kfw\lib\i386\krb5_32.lib \
      dnsapi.lib mpr.lib
  
  afscflags = -I..\kfw\inc\krb5 -I..\kfw\inc\krb4 $(afscflags)
  
! $(EXEOBJS): $$(@B).c
  	$(C2OBJ) $**
  
  ############################################################################
  
! $(EXEFILE) : $(EXEOBJS) $(EXELIBS) $(OUT)\aklog.res
  	$(EXECONLINK) $(EXELIBS) $(OTHERLIBS)
  	$(EXEPREP) 
  
! install : $(COPYHEADERS) $(EXEFILE)
  
  ############################################################################
  #
--- 34,61 ----
  OTHERLIBS = \
      ..\kfw\lib\i386\krbv4w32.lib \
      ..\kfw\lib\i386\krb5_32.lib \
+     ..\kfw\lib\i386\comerr32.lib \
      dnsapi.lib mpr.lib
  
  afscflags = -I..\kfw\inc\krb5 -I..\kfw\inc\krb4 $(afscflags)
  
! $(AKLOGOBJS): $$(@B).c
! 	$(C2OBJ) $**
! 
! $(ASETKEYOBJS): $$(@B).c
  	$(C2OBJ) $**
  
  ############################################################################
  
! $(AKLOG) : $(AKLOGOBJS) $(EXELIBS) $(OUT)\aklog.res
  	$(EXECONLINK) $(EXELIBS) $(OTHERLIBS)
  	$(EXEPREP) 
  
! $(ASETKEY) : $(ASETKEYOBJS) $(EXELIBS) $(OUT)\asetkey.res
! 	$(EXECONLINK) $(EXELIBS) $(OTHERLIBS)
! 	$(EXEPREP) 
! 
! install : $(COPYHEADERS) $(AKLOG) $(ASETKEY)
  
  ############################################################################
  #
***************
*** 51,59 ****
--- 64,75 ----
  
  $(OUT)\aklog.res : aklog.rc AFS_component_version_number.h
  
+ $(OUT)\asetkey.res : asetkey.rc AFS_component_version_number.h
+ 
  mkdir:
  	-mkdir $(OUT)\lang
  	cd lang
  	nmake /nologo /f ntmakefile SRC=$(SRC) OBJ=$(OBJ) mkdir
  	cd ..
  
+                                              
\ No newline at end of file
Index: openafs/src/WINNT/aklog/aklog.c
diff -c openafs/src/WINNT/aklog/aklog.c:1.5.2.6 openafs/src/WINNT/aklog/aklog.c:1.5.2.11
*** openafs/src/WINNT/aklog/aklog.c:1.5.2.6	Fri Mar 11 01:59:57 2005
--- openafs/src/WINNT/aklog/aklog.c	Mon Jul 11 15:39:55 2005
***************
*** 196,201 ****
--- 196,202 ----
      if (dflag)
          printf("About to resolve name %s to id\n", username);
  
+ #ifdef COMMENT
      /*
      * Talk about DUMB!  It turns out that there is a bug in
      * pr_Initialize -- even if you give a different cell name
***************
*** 215,225 ****
              confname[i + 1] = '\0';
          }
      }
  
      strcpy(lastcell, aserver->cell);
  
!     if (!pr_Initialize (0, confname, aserver->cell))
!         *status = pr_SNameToId (username, &viceId);
  
      if (dflag)
      {
--- 216,231 ----
              confname[i + 1] = '\0';
          }
      }
+ #endif
  
      strcpy(lastcell, aserver->cell);
  
! 	if (!pr_Initialize (0, confname, aserver->cell)) {
! 		char sname[PR_MAXNAMELEN];
! 		strncpy(sname, username, PR_MAXNAMELEN);
! 		sname[PR_MAXNAMELEN-1] = '\0';
!         *status = pr_SNameToId (sname, &viceId);
! 	}
  
      if (dflag)
      {
***************
*** 761,767 ****
              }
          }
  
!         if (strcmp(realm_of_user, realm_of_cell))
          {
              strcat(username, "@");
              strcat(username, realm_of_user);
--- 767,774 ----
              }
          }
  
!         /* For Khimaira we want to always append the realm to the name */
!         if (1 /* strcmp(realm_of_user, realm_of_cell) */)
          {
              strcat(username, "@");
              strcat(username, realm_of_user);
Index: openafs/src/WINNT/aklog/asetkey.c
diff -c /dev/null openafs/src/WINNT/aklog/asetkey.c:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:13 2005
--- openafs/src/WINNT/aklog/asetkey.c	Sun Jun 12 07:26:15 2005
***************
*** 0 ****
--- 1,125 ----
+ /*
+  * $Id: asetkey.c,v 1.1.2.2 2005/06/12 11:26:15 jaltman Exp $
+  *
+  * asetkey - Manipulates an AFS KeyFile
+  *
+  * Updated for Kerberos 5
+  */
+ 
+ #include <winsock.h>
+ 
+ #include <sys/types.h>
+ #include <krb5.h>
+ 
+ #include <afs/stds.h>
+ #include <afs/cellconfig.h>
+ #include <afs/keys.h>
+ #ifndef PRE_AFS35
+ #include <afs/dirpath.h>
+ #endif /* !PRE_AFS35 */
+ 
+ int
+ main(int argc, char **argv)
+ {
+     struct afsconf_dir *tdir;
+     register long code;
+     const char *confdir;
+ 
+     if (argc == 1) {
+ 	printf("asetkey: usage is 'setkey <opcode> options, e.g.\n");
+ 	printf("    asetkey add <kvno> <keyfile> <princ>\n");
+ 	printf("    asetkey delete <kvno>\n");
+ 	printf("    asetkey list\n");
+ 	exit(1);
+     }
+ 
+ #ifdef PRE_AFS35
+     confdir = AFSCONF_SERVERNAME;
+ #else /* PRE_AFS35 */
+     confdir = AFSDIR_SERVER_ETC_DIRPATH;
+ #endif /* PRE_AFS35 */
+ 
+     tdir = afsconf_Open(confdir);
+     if (!tdir) {
+ 	printf("asetkey: can't initialize conf dir '%s'\n", confdir);
+ 	exit(1);
+     }
+     if (strcmp(argv[1], "add")==0) {
+ 	krb5_context context;
+ 	krb5_principal principal;
+ 	krb5_keyblock *key;
+ 	krb5_error_code retval;
+ 	int kvno;
+ 
+ 	if (argc != 5) {
+ 	    printf("asetkey add: usage is 'asetkey add <kvno> <keyfile> <princ>\n");
+ 	    exit(1);
+ 	}
+ 
+ 	krb5_init_context(&context);
+ 
+ 	kvno = atoi(argv[2]);
+ 	retval = krb5_parse_name(context, argv[4], &principal);
+ 	if (retval != 0) {
+ 		com_err(argv[0], retval, "while parsing AFS principal");
+ 		exit(1);
+ 	}
+ 	retval = krb5_kt_read_service_key(context, argv[3], principal, kvno,
+ 					  ENCTYPE_DES_CBC_CRC, &key);
+ 	if (retval != 0) {
+ 		com_err(argv[0], retval, "while extracting AFS service key");
+ 		exit(1);
+ 	}
+ 
+ 	if (key->length != 8) {
+ 		printf("Key length should be 8, but is really %d!\n",
+ 		       key->length);
+ 		exit(1);
+ 	}
+ 
+ 	code = afsconf_AddKey(tdir, kvno, key->contents, 1);
+ 	if (code) {
+ 	    printf("asetkey: failed to set key, code %d.\n", code);
+ 	    exit(1);
+ 	}
+ 	krb5_free_principal(context, principal);
+ 	krb5_free_keyblock(context, key);
+     }
+     else if (strcmp(argv[1], "delete")==0) {
+ 	long kvno;
+ 	if (argc != 3) {
+ 	    printf("asetkey delete: usage is 'asetkey delete <kvno>\n");
+ 	    exit(1);
+ 	}
+ 	kvno = atoi(argv[2]);
+ 	code = afsconf_DeleteKey(tdir, kvno);
+ 	if (code) {
+ 	    printf("asetkey: failed to delete key %d, (code %d)\n", kvno, code);
+ 	    exit(1);
+ 	}
+     }
+     else if (strcmp(argv[1], "list") == 0) {
+ 	struct afsconf_keys tkeys;
+ 	register int i, j;
+ 	
+ 	code = afsconf_GetKeys(tdir, &tkeys);
+ 	if (code) {
+ 	    printf("asetkey: failed to get keys, code %d\n", code);
+ 	    exit(1);
+ 	}
+ 	for(i=0;i<tkeys.nkeys;i++) {
+ 	    if (tkeys.key[i].kvno != -1) {
+ 		printf("kvno %4d: key is: ", tkeys.key[i].kvno);
+ 		for (j = 0; j < 8; j++)
+ 			printf("%02x", (unsigned char) tkeys.key[i].key[j]);
+ 		printf("\n");
+ 	    }
+ 	}
+ 	printf("All done.\n");
+     }
+     else {
+ 	printf("asetkey: unknown operation '%s', type 'asetkey' for assistance\n", argv[1]);
+ 	exit(1);
+     }
+     exit(0);
+ }
Index: openafs/src/WINNT/aklog/asetkey.rc
diff -c /dev/null openafs/src/WINNT/aklog/asetkey.rc:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:13 2005
--- openafs/src/WINNT/aklog/asetkey.rc	Sun Jun 12 07:26:15 2005
***************
*** 0 ****
--- 1,17 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ /* Define VERSIONINFO resource */
+ 
+ #define  AFS_VERINFO_FILE_DESCRIPTION "AFS Set Key Command"
+ #define AFS_VERINFO_NAME "asetkey"
+ #define AFS_VERINFO_FILENAME "asetkey.exe"
+ 
+ #include "AFS_component_version_number.h"
+ #include "..\..\config\NTVersioninfo.rc"
Index: openafs/src/WINNT/client_config/config.cpp
diff -c openafs/src/WINNT/client_config/config.cpp:1.5.2.2 openafs/src/WINNT/client_config/config.cpp:1.5.2.3
*** openafs/src/WINNT/client_config/config.cpp:1.5.2.2	Fri Mar 11 02:00:00 2005
--- openafs/src/WINNT/client_config/config.cpp	Wed Jul  6 20:29:12 2005
***************
*** 43,49 ****
  
  static DWORD log2 (DWORD dwValue)
  {
!    for (DWORD dwLog = 0; (DWORD)(1<<dwLog) < dwValue; ++dwLog)
        ;
     return dwLog;
  }
--- 43,50 ----
  
  static DWORD log2 (DWORD dwValue)
  {
!    DWORD dwLog;
!    for (dwLog = 0; (DWORD)(1<<dwLog) < dwValue; ++dwLog)
        ;
     return dwLog;
  }
***************
*** 349,355 ****
  {
     Config_WriteUserNum (TEXT("ShowTrayIcon"), fFlag);
  
!    for (HWND hSearch = GetWindow (GetDesktopWindow(), GW_CHILD);
          hSearch && IsWindow(hSearch);
          hSearch = GetWindow (hSearch, GW_HWNDNEXT))
        {
--- 350,357 ----
  {
     Config_WriteUserNum (TEXT("ShowTrayIcon"), fFlag);
  
!    HWND hSearch;
!    for (hSearch = GetWindow (GetDesktopWindow(), GW_CHILD);
          hSearch && IsWindow(hSearch);
          hSearch = GetWindow (hSearch, GW_HWNDNEXT))
        {
***************
*** 434,440 ****
     if (pPrefs)
        {
        size_t cChanged = 0;
!       for (size_t ii = 0; ii < pPrefs->cPrefs; ++ii)
           {
           if (pPrefs->aPrefs[ ii ].fChanged)
              ++cChanged;
--- 436,443 ----
     if (pPrefs)
        {
        size_t cChanged = 0;
!       size_t ii;
!       for (ii = 0; ii < pPrefs->cPrefs; ++ii)
           {
           if (pPrefs->aPrefs[ ii ].fChanged)
              ++cChanged;
Index: openafs/src/WINNT/client_config/drivemap.cpp
diff -c openafs/src/WINNT/client_config/drivemap.cpp:1.27.2.5 openafs/src/WINNT/client_config/drivemap.cpp:1.27.2.6
*** openafs/src/WINNT/client_config/drivemap.cpp:1.27.2.5	Fri Mar 11 02:00:01 2005
--- openafs/src/WINNT/client_config/drivemap.cpp	Wed Jul  6 20:29:12 2005
***************
*** 465,471 ****
              if ( submountPath[0] != TEXT('\0') ) {
                  AdjustAfsPath (Submount.szMapping, submountPath, FALSE, TRUE);
  
!                 for (size_t ii = 0; ii < pList->cSubmounts; ++ii)
                  {
                      if (!pList->aSubmounts[ii].szSubmount[0])
                          break;
--- 465,472 ----
              if ( submountPath[0] != TEXT('\0') ) {
                  AdjustAfsPath (Submount.szMapping, submountPath, FALSE, TRUE);
  
!                 size_t ii;
!                 for (ii = 0; ii < pList->cSubmounts; ++ii)
                  {
                      if (!pList->aSubmounts[ii].szSubmount[0])
                          break;
Index: openafs/src/WINNT/client_config/tab_advanced.cpp
diff -c openafs/src/WINNT/client_config/tab_advanced.cpp:1.3 openafs/src/WINNT/client_config/tab_advanced.cpp:1.3.2.1
*** openafs/src/WINNT/client_config/tab_advanced.cpp:1.3	Thu Feb 26 14:22:46 2004
--- openafs/src/WINNT/client_config/tab_advanced.cpp	Wed Jul  6 20:29:12 2005
***************
*** 69,75 ****
  
  static DWORD log2 (DWORD dwValue)
  {
!    for (DWORD dwLog = 0; (DWORD)(1<<dwLog) < dwValue; ++dwLog)
        ;
     return dwLog;
  }
--- 69,76 ----
  
  static DWORD log2 (DWORD dwValue)
  {
!    DWORD dwLog;
!    for (dwLog = 0; (DWORD)(1<<dwLog) < dwValue; ++dwLog)
        ;
     return dwLog;
  }
Index: openafs/src/WINNT/client_config/tab_prefs.cpp
diff -c openafs/src/WINNT/client_config/tab_prefs.cpp:1.2 openafs/src/WINNT/client_config/tab_prefs.cpp:1.2.20.1
*** openafs/src/WINNT/client_config/tab_prefs.cpp:1.2	Sat Nov  4 05:02:40 2000
--- openafs/src/WINNT/client_config/tab_prefs.cpp	Wed Jul  6 20:29:12 2005
***************
*** 463,469 ****
                    // and the ranking.
                    //
                    TCHAR szServer[ MAX_PATH ];
!                   for (LPTSTR pszOut = szServer; *pszStart && !iswhite(*pszStart); )
                       *pszOut++ = *pszStart++;
                    *pszOut = TEXT('\0');
  
--- 463,470 ----
                    // and the ranking.
                    //
                    TCHAR szServer[ MAX_PATH ];
!                   LPTSTR pszOut;
!                   for (pszOut = szServer; *pszStart && !iswhite(*pszStart); )
                       *pszOut++ = *pszStart++;
                    *pszOut = TEXT('\0');
  
***************
*** 502,508 ****
     LPHASHLIST pList = New (HASHLIST);
     LPHASHLISTKEY pKey = pList->CreateKey (TEXT("IP Address"), IPKey_Compare, IPKey_HashObject, IPKey_HashData);
  
!    for (size_t ii = 0; ii < pGlobal->cPrefs; ++ii)
        {
        if (!pGlobal->aPrefs[ ii ].ipServer)
           continue;
--- 503,510 ----
     LPHASHLIST pList = New (HASHLIST);
     LPHASHLISTKEY pKey = pList->CreateKey (TEXT("IP Address"), IPKey_Compare, IPKey_HashObject, IPKey_HashData);
  
!    size_t ii;
!    for (ii = 0; ii < pGlobal->cPrefs; ++ii)
        {
        if (!pGlobal->aPrefs[ ii ].ipServer)
           continue;
***************
*** 544,550 ****
     BOOL fVLServers = IsDlgButtonChecked (hDlg, IDC_SHOW_VLS);
     PSERVERPREFS pPrefs = (fVLServers) ? g.Configuration.pVLServers : g.Configuration.pFServers;
  
!    for (size_t ii = 0; ii < pPrefs->cPrefs; ++ii)
        {
        if (pPrefs->aPrefs[ ii ].ipServer == pPref->ipServer)
           break;
--- 546,553 ----
     BOOL fVLServers = IsDlgButtonChecked (hDlg, IDC_SHOW_VLS);
     PSERVERPREFS pPrefs = (fVLServers) ? g.Configuration.pVLServers : g.Configuration.pFServers;
  
!    size_t ii;
!    for (ii = 0; ii < pPrefs->cPrefs; ++ii)
        {
        if (pPrefs->aPrefs[ ii ].ipServer == pPref->ipServer)
           break;
Index: openafs/src/WINNT/client_creds/creds.cpp
diff -c openafs/src/WINNT/client_creds/creds.cpp:1.11.2.2 openafs/src/WINNT/client_creds/creds.cpp:1.11.2.3
*** openafs/src/WINNT/client_creds/creds.cpp:1.11.2.2	Fri Mar 11 02:00:24 2005
--- openafs/src/WINNT/client_creds/creds.cpp	Wed Jul  6 20:29:13 2005
***************
*** 312,318 ****
           // credentials within a certain cell under the certain name.
           // Stick that knowledge in our g.aCreds array.
           //
!          for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
              {
              if (!lstrcmpi (g.aCreds[ iCreds ].szCell, szCell))
                 break;
--- 312,319 ----
           // credentials within a certain cell under the certain name.
           // Stick that knowledge in our g.aCreds array.
           //
!          size_t iCreds;
!          for (iCreds = 0; iCreds < g.cCreds; ++iCreds)
              {
              if (!lstrcmpi (g.aCreds[ iCreds ].szCell, szCell))
                 break;
Index: openafs/src/WINNT/client_creds/credstab.cpp
diff -c openafs/src/WINNT/client_creds/credstab.cpp:1.5.2.1 openafs/src/WINNT/client_creds/credstab.cpp:1.5.2.2
*** openafs/src/WINNT/client_creds/credstab.cpp:1.5.2.1	Tue Dec  7 00:54:00 2004
--- openafs/src/WINNT/client_creds/credstab.cpp	Wed Jul  6 20:29:13 2005
***************
*** 90,96 ****
  {
     LPTSTR pszCell = (LPTSTR)GetWindowLong (hDlg, DWL_USER);
     lock_ObtainMutex(&g.credsLock);
!    for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (!lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell))
           break;
--- 90,97 ----
  {
     LPTSTR pszCell = (LPTSTR)GetWindowLong (hDlg, DWL_USER);
     lock_ObtainMutex(&g.credsLock);
!    size_t iCreds;
!    for (iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (!lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell))
           break;
***************
*** 118,124 ****
        }
  
     lock_ObtainMutex(&g.credsLock);
!    for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (!lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell))
           break;
--- 119,126 ----
        }
  
     lock_ObtainMutex(&g.credsLock);
!    size_t iCreds;
!    for (iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (!lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell))
           break;
***************
*** 305,311 ****
        }
  
     lock_ObtainMutex(&g.credsLock);
!    for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (*pszCell && !lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell))
           break;
--- 307,314 ----
        }
  
     lock_ObtainMutex(&g.credsLock);
!    size_t iCreds;
!    for (iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (*pszCell && !lstrcmpi (g.aCreds[ iCreds ].szCell, pszCell))
           break;
***************
*** 413,418 ****
  
        if (hChildDlg)
           CheckDlgButton (hChildDlg, IDC_CREDS_REMIND, FALSE);
! 	  }
  }
  
--- 416,421 ----
  
        if (hChildDlg)
           CheckDlgButton (hChildDlg, IDC_CREDS_REMIND, FALSE);
!       }
  }
  
Index: openafs/src/WINNT/client_creds/shortcut.cpp
diff -c openafs/src/WINNT/client_creds/shortcut.cpp:1.8.2.1 openafs/src/WINNT/client_creds/shortcut.cpp:1.8.2.2
*** openafs/src/WINNT/client_creds/shortcut.cpp:1.8.2.1	Fri Mar 11 02:00:25 2005
--- openafs/src/WINNT/client_creds/shortcut.cpp	Wed Jul  6 20:29:13 2005
***************
*** 65,72 ****
                     rc = ppf->Save (pszTarget, TRUE);
  #else
                     WORD wsz[ MAX_PATH ];
!                    MultiByteToWideChar (CP_ACP, 0, pszTarget, -1, wsz, MAX_PATH);
!                    rc = ppf->Save (wsz, TRUE);
  #endif
                     }
                 }
--- 65,72 ----
                     rc = ppf->Save (pszTarget, TRUE);
  #else
                     WORD wsz[ MAX_PATH ];
!                    MultiByteToWideChar (CP_ACP, 0, pszTarget, -1, (LPWSTR)wsz, MAX_PATH);
!                    rc = ppf->Save ((LPCOLESTR)wsz, TRUE);
  #endif
                     }
                 }
Index: openafs/src/WINNT/client_creds/window.cpp
diff -c openafs/src/WINNT/client_creds/window.cpp:1.11.2.1 openafs/src/WINNT/client_creds/window.cpp:1.11.2.2
*** openafs/src/WINNT/client_creds/window.cpp:1.11.2.1	Fri Mar 11 02:00:25 2005
--- openafs/src/WINNT/client_creds/window.cpp	Wed Jul  6 20:29:13 2005
***************
*** 333,339 ****
  {
     BOOL fRemind = FALSE;
     lock_ObtainMutex(&g.credsLock);
!    for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (g.aCreds[ iCreds ].fRemind)
           fRemind = TRUE;
--- 333,340 ----
  {
     BOOL fRemind = FALSE;
     lock_ObtainMutex(&g.credsLock);
!    size_t iCreds;
!    for (iCreds = 0; iCreds < g.cCreds; ++iCreds)
        {
        if (g.aCreds[ iCreds ].fRemind)
           fRemind = TRUE;
***************
*** 498,504 ****
  
        size_t nCreds = 0;
        lock_ObtainMutex(&g.credsLock);
!       for (size_t iCreds = 0; iCreds < g.cCreds; ++iCreds)
           {
           if (g.aCreds[ iCreds ].szCell[0])
              ++nCreds;
--- 499,506 ----
  
        size_t nCreds = 0;
        lock_ObtainMutex(&g.credsLock);
!       size_t iCreds;
!       for (iCreds = 0; iCreds < g.cCreds; ++iCreds)
           {
           if (g.aCreds[ iCreds ].szCell[0])
              ++nCreds;
***************
*** 531,537 ****
           {
           if (g.aCreds[ iCreds ].szCell[0])
              {
!             for (size_t ii = 0; ii < iTabOut; ++ii)
                 {
                 if (!ISCELLTAB (aTabs[ii]))
                    continue;
--- 533,540 ----
           {
           if (g.aCreds[ iCreds ].szCell[0])
              {
!             size_t ii;
!             for (ii = 0; ii < iTabOut; ++ii)
                 {
                 if (!ISCELLTAB (aTabs[ii]))
                    continue;
Index: openafs/src/WINNT/client_exp/fs.h
diff -c openafs/src/WINNT/client_exp/fs.h:1.2 openafs/src/WINNT/client_exp/fs.h:1.2.20.1
*** openafs/src/WINNT/client_exp/fs.h:1.2	Sat Nov  4 05:02:52 2000
--- openafs/src/WINNT/client_exp/fs.h	Wed Jul  6 20:29:13 2005
***************
*** 23,28 ****
  
  extern void Die(int, char *);
  
! static SetVolCmd(struct cmd_syndesc *);
  
  #endif /* FS_H_ENV */
--- 23,28 ----
  
  extern void Die(int, char *);
  
! static int SetVolCmd(struct cmd_syndesc *);
  
  #endif /* FS_H_ENV */
Index: openafs/src/WINNT/client_exp/gui2fs.cpp
diff -c openafs/src/WINNT/client_exp/gui2fs.cpp:1.10.2.3 openafs/src/WINNT/client_exp/gui2fs.cpp:1.10.2.4
*** openafs/src/WINNT/client_exp/gui2fs.cpp:1.10.2.3	Wed Apr 20 22:20:05 2005
--- openafs/src/WINNT/client_exp/gui2fs.cpp	Wed Jul  6 20:29:14 2005
***************
*** 418,424 ****
  }
  
  /* tell if a name is 23 or -45 (digits or minus digits), which are bad names we must prune */
! static BadName(register char *aname)
  {
      register int tc;
  
--- 418,424 ----
  }
  
  /* tell if a name is 23 or -45 (digits or minus digits), which are bad names we must prune */
! static int BadName(register char *aname)
  {
      register int tc;
  
***************
*** 813,819 ****
      pAcl = EmptyAcl(strCellName);
  
      // Set its normal rights
!     for (int i = 0; i < normal.GetSize(); i += 2) {
          rights = Convert(normal[i + 1], 0, &rtype);
          ChangeList(pAcl, TRUE, normal[i], rights);
      }
--- 813,820 ----
      pAcl = EmptyAcl(strCellName);
  
      // Set its normal rights
!     int i;
!     for (i = 0; i < normal.GetSize(); i += 2) {
          rights = Convert(normal[i + 1], 0, &rtype);
          ChangeList(pAcl, TRUE, normal[i], rights);
      }
***************
*** 878,884 ****
      enum rtype rtype;
  
      // Set normal rights
!     for (int i = 0; i < normal.GetSize(); i += 2) {
          LONG rights = Convert(normal[i + 1], 0, &rtype);
          ChangeList(pToAcl, TRUE, normal[i], rights);
      }
--- 879,886 ----
      enum rtype rtype;
  
      // Set normal rights
!     int i;
!     for (i = 0; i < normal.GetSize(); i += 2) {
          LONG rights = Convert(normal[i + 1], 0, &rtype);
          ChangeList(pToAcl, TRUE, normal[i], rights);
      }
Index: openafs/src/WINNT/client_exp/set_afs_acl.cpp
diff -c openafs/src/WINNT/client_exp/set_afs_acl.cpp:1.2 openafs/src/WINNT/client_exp/set_afs_acl.cpp:1.2.20.1
*** openafs/src/WINNT/client_exp/set_afs_acl.cpp:1.2	Sat Nov  4 05:02:54 2000
--- openafs/src/WINNT/client_exp/set_afs_acl.cpp	Wed Jul  6 20:29:14 2005
***************
*** 99,105 ****
  	m_NormalRights.SetTabStops(58);
  	m_NegativeRights.SetTabStops(58);
  
! 	for (int i = 0; i < m_Normal.GetSize(); i += 2)
  		m_NormalRights.AddString(m_Normal[i + 1] + "\t" + m_Normal[i]);
  
  	for (i = 0; i < m_Negative.GetSize(); i += 2)
--- 99,106 ----
  	m_NormalRights.SetTabStops(58);
  	m_NegativeRights.SetTabStops(58);
  
!         int i;
! 	for (i = 0; i < m_Normal.GetSize(); i += 2)
  		m_NormalRights.AddString(m_Normal[i + 1] + "\t" + m_Normal[i]);
  
  	for (i = 0; i < m_Negative.GetSize(); i += 2)
Index: openafs/src/WINNT/client_osi/osifd.h
diff -c openafs/src/WINNT/client_osi/osifd.h:1.3 openafs/src/WINNT/client_osi/osifd.h:1.3.2.1
*** openafs/src/WINNT/client_osi/osifd.h:1.3	Sun Mar  9 20:59:15 2003
--- openafs/src/WINNT/client_osi/osifd.h	Wed Jul  6 20:29:15 2005
***************
*** 79,94 ****
  
  extern long osi_UnregisterFDType(char *);
  
! extern osi_AddFDFormatInfo(osi_fdType_t *typep, long region, long index,
  	char *labelp, long format);
  
! extern osi_InitFD(void);
  
  extern osi_fd_t *osi_AllocFD(char *);
  
  extern osi_fd_t *osi_FindFD(long);
  
! extern osi_CloseFD(osi_fd_t *);
  
  extern long osi_FDTypeCreate(osi_fdType_t *, osi_fd_t **);
  
--- 79,94 ----
  
  extern long osi_UnregisterFDType(char *);
  
! extern int osi_AddFDFormatInfo(osi_fdType_t *typep, long region, long index,
  	char *labelp, long format);
  
! extern int osi_InitFD(void);
  
  extern osi_fd_t *osi_AllocFD(char *);
  
  extern osi_fd_t *osi_FindFD(long);
  
! extern int osi_CloseFD(osi_fd_t *);
  
  extern long osi_FDTypeCreate(osi_fdType_t *, osi_fd_t **);
  
Index: openafs/src/WINNT/install/NSIS/OpenAFS.nsi
diff -c openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.69.2.9 openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.69.2.11
*** openafs/src/WINNT/install/NSIS/OpenAFS.nsi:1.69.2.9	Sun May 29 23:58:34 2005
--- openafs/src/WINNT/install/NSIS/OpenAFS.nsi	Fri Jul  1 14:40:31 2005
***************
*** 1,5 ****
! ;OpenAFS Install Script for NSIS
! ;                             This version compiles with NSIS v2.0
  ;
  ; Originally written by Rob Murawski <rsm4@ieee.org>
  ;
--- 1,5 ----
! ; OpenAFS Install Script for NSIS
! ; This version compiles with NSIS v2.07
  ;
  ; Originally written by Rob Murawski <rsm4@ieee.org>
  ;
***************
*** 70,76 ****
    OutFile "${AFS_DESTDIR}\WinInstall\OpenAFSforWindows-DEBUG.exe"
  !endif
    SilentInstall normal
!   SetCompressor lzma
    !define MUI_ICON "..\..\client_config\afs_config.ico"
    !define MUI_UNICON "..\..\client_config\afs_config.ico"
    !define AFS_COMPANY_NAME "OpenAFS"
--- 70,76 ----
    OutFile "${AFS_DESTDIR}\WinInstall\OpenAFSforWindows-DEBUG.exe"
  !endif
    SilentInstall normal
!   SetCompressor /solid lzma
    !define MUI_ICON "..\..\client_config\afs_config.ico"
    !define MUI_UNICON "..\..\client_config\afs_config.ico"
    !define AFS_COMPANY_NAME "OpenAFS"
***************
*** 490,496 ****
  
  ;----------------------
  ; OpenAFS CLIENT
! Section "AFS Client" secClient
  
    SetShellVarContext all
  
--- 490,496 ----
  
  ;----------------------
  ; OpenAFS CLIENT
! Section "!AFS Client" secClient
  
    SetShellVarContext all
  
***************
*** 735,740 ****
--- 735,741 ----
    SetRebootFlag true
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"  
    Call CreateDesktopIni
    
  SectionEnd
***************
*** 742,748 ****
  
  
  ; MS Loopback adapter
! Section "MS Loopback Adapter" secLoopback
  
  Call afs.InstallMSLoopback
  
--- 743,749 ----
  
  
  ; MS Loopback adapter
! Section "!MS Loopback Adapter" secLoopback
  
  Call afs.InstallMSLoopback
  
***************
*** 751,757 ****
  
  ;------------------------
  ; OpenAFS SERVER  
! Section "AFS Server" secServer
  
    SetShellVarContext all
  
--- 752,758 ----
  
  ;------------------------
  ; OpenAFS SERVER  
! Section /o "AFS Server" secServer
  
    SetShellVarContext all
  
***************
*** 787,792 ****
--- 788,794 ----
    SetOutPath "$INSTDIR\Server\usr\afs\bin"  
    File "${AFS_SERVER_BUILDDIR}\afskill.exe"
    File "${AFS_SERVER_BUILDDIR}\afssvrcfg.exe"
+   File "${AFS_SERVER_BUILDDIR}\asetkey.exe"
    File "${AFS_SERVER_BUILDDIR}\bosctlsvc.exe"
    File "${AFS_SERVER_BUILDDIR}\bosserver.exe"
    File "${AFS_SERVER_BUILDDIR}\buserver.exe"
***************
*** 873,885 ****
    
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
  
  SectionEnd
  
  
  ;----------------------------
  ; OpenAFS Control Center
! Section "AFS Control Center" secControl
  
    SetShellVarContext all
  
--- 875,888 ----
    
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"  
  
  SectionEnd
  
  
  ;----------------------------
  ; OpenAFS Control Center
! Section /o "AFS Control Center" secControl
  
    SetShellVarContext all
  
***************
*** 919,931 ****
    CreateShortCut "$SMPROGRAMS\OpenAFS\Control Center\Server Manager.lnk" "$INSTDIR\Control Center\TaAfsServerManager.exe"
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
  
  SectionEnd   
  
  
  ;----------------------------
  ; OpenAFS Supplemental Documentation
! Section "Supplemental Documentation" secDocs
    SetShellVarContext all
  
     StrCmp $LANGUAGE ${LANG_ENGLISH} DoEnglish
--- 922,935 ----
    CreateShortCut "$SMPROGRAMS\OpenAFS\Control Center\Server Manager.lnk" "$INSTDIR\Control Center\TaAfsServerManager.exe"
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"  
  
  SectionEnd   
  
  
  ;----------------------------
  ; OpenAFS Supplemental Documentation
! Section /o "Supplemental Documentation" secDocs
    SetShellVarContext all
  
     StrCmp $LANGUAGE ${LANG_ENGLISH} DoEnglish
***************
*** 1075,1086 ****
    
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
    CreateShortCut "$SMPROGRAMS\OpenAFS\Uninstall OpenAFS.lnk" "$INSTDIR\Uninstall.exe"
    Call AFSCommon.Install
  SectionEnd  
    
  
! Section "Software Development Kit (SDK)" secSDK
  
      SetOutPath "$INSTDIR\Client\Program\lib"
      File /r "${AFS_CLIENT_LIBDIR}\*.*"
--- 1079,1091 ----
    
    
    WriteUninstaller "$INSTDIR\Uninstall.exe"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"  
    CreateShortCut "$SMPROGRAMS\OpenAFS\Uninstall OpenAFS.lnk" "$INSTDIR\Uninstall.exe"
    Call AFSCommon.Install
  SectionEnd  
    
  
! Section /o "Software Development Kit (SDK)" secSDK
  
      SetOutPath "$INSTDIR\Client\Program\lib"
      File /r "${AFS_CLIENT_LIBDIR}\*.*"
***************
*** 1104,1118 ****
    WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS SDK\${AFS_VERSION}" "PatchLevel" ${AFS_PATCHLEVEL}
  
    WriteUninstaller "$INSTDIR\Uninstall.exe"
    SetOutPath "$SMPROGRAMS\OpenAFS"
    CreateShortCut "$SMPROGRAMS\OpenAFS\Uninstall OpenAFS.lnk" "$INSTDIR\Uninstall.exe"
  
!    Call AFSCommon.Install
  SectionEnd
  
  
! Section "Debug symbols" secDebug
!   	SectionGetFlags ${secClient} $R0
     IntOp $R0 $R0 & ${SF_SELECTED}
     IntCmp $R0 ${SF_SELECTED} +1 DoServer
    
--- 1109,1125 ----
    WriteRegDWORD HKLM "${AFS_REGKEY_ROOT}\AFS SDK\${AFS_VERSION}" "PatchLevel" ${AFS_PATCHLEVEL}
  
    WriteUninstaller "$INSTDIR\Uninstall.exe"
+   WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\OpenAFS" "DisplayIcon" "$INSTDIR\Uninstall.exe,0"  
+ 
    SetOutPath "$SMPROGRAMS\OpenAFS"
    CreateShortCut "$SMPROGRAMS\OpenAFS\Uninstall OpenAFS.lnk" "$INSTDIR\Uninstall.exe"
  
!   Call AFSCommon.Install
  SectionEnd
  
  
! Section /o "Debug symbols" secDebug
!    SectionGetFlags ${secClient} $R0
     IntOp $R0 $R0 & ${SF_SELECTED}
     IntCmp $R0 ${SF_SELECTED} +1 DoServer
    
***************
*** 1147,1153 ****
    File "${AFS_CLIENT_BUILDDIR}\afslogon.pdb"
    
  DoServer:
!   	SectionGetFlags ${secServer} $R0
     IntOp $R0 $R0 & ${SF_SELECTED}
     IntCmp $R0 ${SF_SELECTED} +1 DoControl
  
--- 1154,1160 ----
    File "${AFS_CLIENT_BUILDDIR}\afslogon.pdb"
    
  DoServer:
!    SectionGetFlags ${secServer} $R0
     IntOp $R0 $R0 & ${SF_SELECTED}
     IntCmp $R0 ${SF_SELECTED} +1 DoControl
  
***************
*** 1155,1160 ****
--- 1162,1168 ----
    SetOutPath "$INSTDIR\Server\usr\afs\bin"  
    File "${AFS_SERVER_BUILDDIR}\afskill.pdb"
    File "${AFS_SERVER_BUILDDIR}\afssvrcfg.pdb"
+   File "${AFS_SERVER_BUILDDIR}\asetkey.pdb"
    File "${AFS_SERVER_BUILDDIR}\bosctlsvc.pdb"
    File "${AFS_SERVER_BUILDDIR}\bosserver.pdb"
    File "${AFS_SERVER_BUILDDIR}\buserver.pdb"
***************
*** 1182,1188 ****
  
     ; Do control center components
  DoControl:
!   	SectionGetFlags ${secControl} $R0
     IntOp $R0 $R0 & ${SF_SELECTED}
     IntCmp $R0 ${SF_SELECTED} +1 DoCommon
  
--- 1190,1196 ----
  
     ; Do control center components
  DoControl:
!    SectionGetFlags ${secControl} $R0
     IntOp $R0 $R0 & ${SF_SELECTED}
     IntCmp $R0 ${SF_SELECTED} +1 DoCommon
  
***************
*** 1258,1263 ****
--- 1266,1290 ----
     
  contInstall:
  
+    ; Set Install Type text
+    InstTypeSetText 0 "AFS Client"
+    InstTypeSetText 1 "AFS Administrator"
+    InstTypeSetText 2 "AFS Server"
+    InstTypeSetText 3 "AFS Developer Tools"
+ 
+    ; Set sections in each install type
+    SectionSetInstTypes 0 15		; AFS Client
+    SectionSetInstTypes 1 15		; Loopback adapter
+    SectionSetInstTypes 2 4              ; AFS Server
+    SectionSetInstTypes 3 6              ; AFS Control Center
+    SectionSetInstTypes 4 14		; Documentation
+    SectionSetInstTypes 5 8		; SDK
+ !ifndef DEBUG
+    SectionSetInstTypes 6 8		; Debug symbols
+ !else
+    SectionSetInstTypes 6 15		; Debug symbols
+ !endif
+ 
     ; Check that RPC functions are installed (I believe any one of these can be present for
     ; OpenAFS to work)
     ReadRegStr $R0 HKLM "SOFTWARE\Microsoft\RPC\ClientProtocols" "ncacn_np"
***************
*** 1272,1278 ****
  
  
  contInstall2:
- DoLoop:
     ; If the Loopback is already installed, we mark the option OFF and Read Only
     ; so the user can not select it.
     Call afs.isLoopbackInstalled
--- 1299,1304 ----
***************
*** 1281,1286 ****
--- 1307,1314 ----
     IntOp $0 $0 & ${SECTION_OFF}
     IntOp $0 $0 | ${SF_RO}
     SectionSetFlags ${secLoopback} $0
+    ; And disable the loopback in the types
+    SectionSetInstTypes 1 0		; Loopback adapter
     
  SkipLoop:
     ; Never install debug symbols unless explicitly selected, except in DEBUG mode
***************
*** 1363,1372 ****
     StrCmp $R2 "2" UpgradeServer
     StrCmp $R2 "3" DowngradeServer
     
! 	SectionGetFlags ${secServer} $0
! 	IntOp $0 $0 | ${SF_SELECTED}
! 	SectionSetFlags ${secServer} $0
! 	;# !insertmacro UnselectSection ${secServer}
     goto skipServer
  
  UpgradeServer:
--- 1391,1400 ----
     StrCmp $R2 "2" UpgradeServer
     StrCmp $R2 "3" DowngradeServer
     
!    SectionGetFlags ${secServer} $0
!    IntOp $0 $0 | ${SF_SELECTED}
!    SectionSetFlags ${secServer} $0
!    ;# !insertmacro UnselectSection ${secServer}
     goto skipServer
  
  UpgradeServer:
***************
*** 1391,1400 ****
     goto skipServer
     
  NoServer:
! 	SectionGetFlags ${secServer} $0
! 	IntOp $0 $0 & ${SECTION_OFF}
! 	SectionSetFlags ${secServer} $0
! 	;# !insertmacro UnselectSection ${secServer}
     goto skipServer
     
  skipServer:
--- 1419,1428 ----
     goto skipServer
     
  NoServer:
!    SectionGetFlags ${secServer} $0
!    IntOp $0 $0 & ${SECTION_OFF}
!    SectionSetFlags ${secServer} $0
!    ;# !insertmacro UnselectSection ${secServer}
     goto skipServer
     
  skipServer:
***************
*** 1403,1433 ****
     Pop $R2
     StrCmp $R2 "0" NoControl
  
! 	SectionGetFlags ${secControl} $0
! 	IntOp $0 $0 | ${SF_SELECTED}
! 	SectionSetFlags ${secControl} $0
     goto CheckDocs
     
  NoControl:   
! 	SectionGetFlags ${secControl} $0
! 	IntOp $0 $0 & ${SECTION_OFF}
! 	SectionSetFlags ${secControl} $0
! 	;# !insertmacro UnselectSection ${secControl}
  
  CheckDocs:
     ; Check Documentation
     Call IsDocumentationInstalled
     Pop $R2
     StrCmp $R2 "0" NoDocs
! 	SectionGetFlags ${secDocs} $0
! 	IntOp $0 $0 | ${SF_SELECTED}
! 	SectionSetFlags ${secDocs} $0
     goto CheckSDK
     
  NoDocs:
! 	SectionGetFlags ${secDocs} $0
! 	IntOp $0 $0 & ${SECTION_OFF}
! 	SectionSetFlags ${secDocs} $0
     goto CheckSDK
     
  ; To check the SDK, we simply look to see if the files exist.  If they do,
--- 1431,1461 ----
     Pop $R2
     StrCmp $R2 "0" NoControl
  
!    SectionGetFlags ${secControl} $0
!    IntOp $0 $0 | ${SF_SELECTED}
!    SectionSetFlags ${secControl} $0
     goto CheckDocs
     
  NoControl:   
!    SectionGetFlags ${secControl} $0
!    IntOp $0 $0 & ${SECTION_OFF}
!    SectionSetFlags ${secControl} $0
!    ;# !insertmacro UnselectSection ${secControl}
  
  CheckDocs:
     ; Check Documentation
     Call IsDocumentationInstalled
     Pop $R2
     StrCmp $R2 "0" NoDocs
!    SectionGetFlags ${secDocs} $0
!    IntOp $0 $0 | ${SF_SELECTED}
!    SectionSetFlags ${secDocs} $0
     goto CheckSDK
     
  NoDocs:
!    SectionGetFlags ${secDocs} $0
!    IntOp $0 $0 & ${SECTION_OFF}
!    SectionSetFlags ${secDocs} $0
     goto CheckSDK
     
  ; To check the SDK, we simply look to see if the files exist.  If they do,
***************
*** 1448,1473 ****
     
  DefaultOptions:
     ; Client Selected
! 	SectionGetFlags ${secClient} $0
! 	IntOp $0 $0 | ${SF_SELECTED}
! 	SectionSetFlags ${secClient} $0
  
     ; Server NOT selected
! 	SectionGetFlags ${secServer} $0
! 	IntOp $0 $0 & ${SECTION_OFF}
! 	SectionSetFlags ${secServer} $0
     
     ; Control Center NOT selected
! 	SectionGetFlags ${secControl} $0
! 	IntOp $0 $0 & ${SECTION_OFF}
! 	SectionSetFlags ${secControl} $0
! 	;# !insertmacro UnselectSection ${secControl}
  
!    ; Documentation selected
! 	SectionGetFlags ${secDocs} $0
! 	IntOp $0 $0 | ${SF_SELECTED}
! 	SectionSetFlags ${secDocs} $0
! 	;# !insertmacro UnselectSection ${secDocs}
     
     ; SDK not selected
     SectionGetFlags ${secSDK} $0
--- 1476,1501 ----
     
  DefaultOptions:
     ; Client Selected
!    SectionGetFlags ${secClient} $0
!    IntOp $0 $0 | ${SF_SELECTED}
!    SectionSetFlags ${secClient} $0
  
     ; Server NOT selected
!    SectionGetFlags ${secServer} $0
!    IntOp $0 $0 & ${SECTION_OFF}
!    SectionSetFlags ${secServer} $0
     
     ; Control Center NOT selected
!    SectionGetFlags ${secControl} $0
!    IntOp $0 $0 & ${SECTION_OFF}
!    SectionSetFlags ${secControl} $0
!    ;# !insertmacro UnselectSection ${secControl}
  
!    ; Documentation NOT selected
!    SectionGetFlags ${secDocs} $0
!    IntOp $0 $0 & ${SECTION_OFF}
!    SectionSetFlags ${secDocs} $0
!    ;# !insertmacro UnselectSection ${secDocs}
     
     ; SDK not selected
     SectionGetFlags ${secSDK} $0
***************
*** 1478,1484 ****
     goto end
  
  end:
! 	Pop $0
    
     Push $R0
    
--- 1506,1512 ----
     goto end
  
  end:
!    Pop $0
    
     Push $R0
    
***************
*** 1537,1545 ****
  FunctionEnd
  
  
- 
- 
- 
  ;--------------------------------
  ; These are our cleanup functions
  Function .onInstFailed
--- 1565,1570 ----
***************
*** 2617,2622 ****
--- 2642,2648 ----
  FunctionEnd
  
  
+ !ifdef USE_GETPARAMETERS
  ; GetParameters
  ; input, none
  ; output, top of stack (replaces, with e.g. whatever)
***************
*** 2646,2651 ****
--- 2672,2678 ----
    Pop $R1
    Exch $R0
  FunctionEnd
+ !endif
  
  
  ;Check to see if any AFS component is installed
Index: openafs/src/WINNT/install/loopback/loopbackutils.cpp
diff -c openafs/src/WINNT/install/loopback/loopbackutils.cpp:1.6.2.1 openafs/src/WINNT/install/loopback/loopbackutils.cpp:1.6.2.2
*** openafs/src/WINNT/install/loopback/loopbackutils.cpp:1.6.2.1	Tue May 24 01:13:06 2005
--- openafs/src/WINNT/install/loopback/loopbackutils.cpp	Sun Jun 12 07:23:14 2005
***************
*** 57,63 ****
      GUID netGuid;
      HDEVINFO hDeviceInfo = INVALID_HANDLE_VALUE;
      SP_DEVINFO_DATA DeviceInfoData;
-     TCHAR* deviceDesc;
      DWORD index = 0;
      BOOL found = FALSE;
      DWORD size = 0;
--- 57,62 ----
***************
*** 74,118 ****
      if (hDeviceInfo == INVALID_HANDLE_VALUE)
          return GetLastError();
  
-     deviceDesc = (TCHAR *)malloc(MAX_PATH*sizeof(TCHAR));
      // enumerate the driver info list
!     while (SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData))
      {
          // try to get the DeviceDesc registry property
!         ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, &DeviceInfoData,
!                                               SPDRP_DEVICEDESC,
!                                               NULL, (PBYTE)deviceDesc,
!                                               MAX_PATH * sizeof(TCHAR), &size);
          if (!ok)
          {
              ret = GetLastError();
!             if (ret != ERROR_INSUFFICIENT_BUFFER)
!                 break;
!             // if the buffer is too small, reallocate
!             free(deviceDesc);
!             deviceDesc = (TCHAR *)malloc(size);
              ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo,
                                                    &DeviceInfoData,
!                                                   SPDRP_DEVICEDESC,
!                                                   NULL, (PBYTE)deviceDesc,
!                                                   size, NULL);
!             if (!ok)
!                 break;
!         }
  
!         // case insensitive comparison
!         _tcslwr(deviceDesc);
!         if( _tcsstr(deviceDesc, DRIVER))
!         {
!             found = TRUE;
!             break;
!         }
  
          index++;
      }
  
-     free(deviceDesc);
-     
      if (found == FALSE)
      {
          ret = GetLastError();
--- 73,152 ----
      if (hDeviceInfo == INVALID_HANDLE_VALUE)
          return GetLastError();
  
      // enumerate the driver info list
!     while (TRUE)
      {
+         TCHAR * deviceHwid;
+ 
+         ok = SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData);
+ 
+ 	if(!ok) 
+ 	{
+ 	  if(GetLastError() == ERROR_NO_MORE_ITEMS)
+ 	      break;
+ 	  else 
+ 	  {
+    	      index++;
+ 	      continue;
+ 	  }
+ 	}
+ 
          // try to get the DeviceDesc registry property
!         ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo, 
! 					      &DeviceInfoData,
!                                               SPDRP_HARDWAREID,
!                                               NULL,
! 					      NULL,
!                                               0, 
! 					      &size);
          if (!ok)
          {
              ret = GetLastError();
!             if (ret != ERROR_INSUFFICIENT_BUFFER) {
!                 index++;
!                 continue;
! 	    }
! 
!             deviceHwid = (TCHAR *)malloc(size);
              ok = SetupDiGetDeviceRegistryProperty(hDeviceInfo,
                                                    &DeviceInfoData,
!                                                   SPDRP_HARDWAREID,
!                                                   NULL, 
! 						  (PBYTE)deviceHwid,
!                                                   size, 
! 						  NULL);
!             if (!ok) {
! 	        free(deviceHwid);
! 	        deviceHwid = NULL;
! 	        index++;
! 	        continue;
! 	    }
!         } else {
! 	    // something is wrong.  This shouldn't have worked with a NULL buffer
! 	    ReportMessage(0, "GetDeviceRegistryProperty succeeded with a NULL buffer", NULL,  NULL, 0);
! 	    index++;
! 	    continue;
! 	}
  
! 	for (TCHAR *t = deviceHwid; t && *t && t < &deviceHwid[size / sizeof(TCHAR)]; t += _tcslen(t) + 1)
! 	{
! 	    if(!_tcsicmp(DRIVERHWID, t)) {
! 	        found = TRUE;
! 		break;
! 	    }
! 	}
! 
! 	if (deviceHwid) {
! 	    free(deviceHwid);
! 	    deviceHwid = NULL;
! 	}
  
+ 	if (found)
+             break;
+ 	
          index++;
      }
  
      if (found == FALSE)
      {
          ret = GetLastError();
***************
*** 126,131 ****
--- 160,166 ----
          ret = GetLastError();
          goto cleanup;
      }
+ 
      ok = SetupDiCallClassInstaller(DIF_REMOVE, hDeviceInfo, &DeviceInfoData);
      if (!ok)
      {
***************
*** 133,138 ****
--- 168,175 ----
          goto cleanup;
      }
  
+     ret = 0;
+ 
  cleanup:
      // clean up the device info set
      if (hDeviceInfo != INVALID_HANDLE_VALUE)
***************
*** 143,149 ****
  
  BOOL IsLoopbackInstalled(void)
  {
-     TCHAR * hwid = _T("*MSLOOP");
      HDEVINFO DeviceInfoSet;
      SP_DEVINFO_DATA DeviceInfoData;
      DWORD i,err;
--- 180,185 ----
***************
*** 163,173 ****
      //
      found = FALSE;
      DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
!     for (i=0; SetupDiEnumDeviceInfo(DeviceInfoSet,i,&DeviceInfoData); i++)
      {
          DWORD DataT;
          TCHAR *p, *buffer = NULL;
          DWORD buffersize = 0;
          
          //
          // We won't know the size of the HardwareID buffer until we call
--- 199,219 ----
      //
      found = FALSE;
      DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA);
!     for (i=0; ;i++)
      {
+         BOOL ok;
          DWORD DataT;
          TCHAR *p, *buffer = NULL;
          DWORD buffersize = 0;
+ 
+ 	ok = SetupDiEnumDeviceInfo(DeviceInfoSet, i, &DeviceInfoData);
+ 
+ 	if(!ok) {
+ 	  if(GetLastError() == ERROR_NO_MORE_ITEMS)
+ 	    break;
+ 	  else
+ 	    continue;
+ 	}
          
          //
          // We won't know the size of the HardwareID buffer until we call
***************
*** 175,181 ****
          // use the required buffer size to Alloc the nessicary space.
          // Keep calling we have success or an unknown failure.
          //
!         while (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,&DeviceInfoData,SPDRP_HARDWAREID,&DataT,(PBYTE)buffer,buffersize,&buffersize))
          {
              if (GetLastError() == ERROR_INVALID_DATA)
              {
--- 221,233 ----
          // use the required buffer size to Alloc the nessicary space.
          // Keep calling we have success or an unknown failure.
          //
!         while (!SetupDiGetDeviceRegistryProperty(DeviceInfoSet,
! 						 &DeviceInfoData,
! 						 SPDRP_HARDWAREID,
! 						 &DataT,
! 						 (PBYTE)buffer,
! 						 buffersize,
! 						 &buffersize))
          {
              if (GetLastError() == ERROR_INVALID_DATA)
              {
***************
*** 191,215 ****
              }
              else
              {
                  goto cleanup_DeviceInfo;
!             }            
          }
          
!         if (GetLastError() == ERROR_INVALID_DATA) 
              continue;
          
          // Compare each entry in the buffer multi-sz list with our hwid.
          for (p=buffer; *p && (p < &buffer[buffersize]); p += _tcslen(p)+1)
          {
!             if (!_tcsicmp(hwid,p))
              {
                  found = TRUE;
                  break;
              }
          }
          
!         if (buffer) LocalFree(buffer);
!         if (found) break;
      }
      
      //  Cleanup.
--- 243,274 ----
              }
              else
              {
+ 	        if (buffer)
+                     LocalFree(buffer);
                  goto cleanup_DeviceInfo;
!             }
          }
          
!         if (GetLastError() == ERROR_INVALID_DATA) {
! 	    if (buffer)
!                 LocalFree(buffer);
              continue;
+ 	}
          
          // Compare each entry in the buffer multi-sz list with our hwid.
          for (p=buffer; *p && (p < &buffer[buffersize]); p += _tcslen(p)+1)
          {
!             if (!_tcsicmp(DRIVERHWID,p))
              {
                  found = TRUE;
                  break;
              }
          }
          
!         if (buffer)
! 	    LocalFree(buffer);
!         if (found) 
! 	    break;
      }
      
      //  Cleanup.
***************
*** 323,338 ****
  
  	// if we successfully find the hardware ID and it turns out to
  	// be the one for the loopback driver, then we are done.
! 	if(SetupDiGetDriverInfoDetail(hDeviceInfo,
  				      &DeviceInfoData,
  				      &DriverInfoData,
  				      pDriverInfoDetail,
  				      sizeof(detailBuf),
! 				      NULL) &&
! 	   !_tcsicmp(pDriverInfoDetail->HardwareID, DRIVERHWID)) {
  
! 	  found = TRUE;
! 	  break;
  	}
  
          index++;
--- 382,409 ----
  
  	// if we successfully find the hardware ID and it turns out to
  	// be the one for the loopback driver, then we are done.
! 	if (SetupDiGetDriverInfoDetail(hDeviceInfo,
  				      &DeviceInfoData,
  				      &DriverInfoData,
  				      pDriverInfoDetail,
  				      sizeof(detailBuf),
! 				      NULL)) {
!             TCHAR * t;
  
! 	    // pDriverInfoDetail->HardwareID is a MULTISZ string.  Go through the
! 	    // whole list and see if there is a match somewhere.
! 	    t = pDriverInfoDetail->HardwareID;
! 	    while (t && *t && t < (TCHAR *) &detailBuf[sizeof(detailBuf)/sizeof(detailBuf[0])]) {
! 	      if (!_tcsicmp(t, DRIVERHWID))
! 		break;
! 
! 	      t += _tcslen(t) + 1;
! 	    }
! 
! 	    if (t && *t && t < (TCHAR *) &detailBuf[sizeof(detailBuf)/sizeof(detailBuf[0])]) {
! 	      found = TRUE;
! 	      break;
! 	    }
  	}
  
          index++;
Index: openafs/src/WINNT/install/wix/NTMakefile
diff -c openafs/src/WINNT/install/wix/NTMakefile:1.2.2.3 openafs/src/WINNT/install/wix/NTMakefile:1.2.2.5
*** openafs/src/WINNT/install/wix/NTMakefile:1.2.2.3	Fri Nov  5 14:21:56 2004
--- openafs/src/WINNT/install/wix/NTMakefile	Sun Jun 12 11:57:46 2005
***************
*** 1,3 ****
--- 1,10 ----
+ # Copyright 2004, OpenAFS.ORG 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
+ 
  RELDIR=WINNT\install\wix
  !INCLUDE ..\..\..\config\NTMakefile.$(SYS_NAME)
  !INCLUDE ..\..\..\config\NTMakefile.version
***************
*** 32,43 ****
  
  lang:: lang_clean $(MSIFILE)
  
  customactions:
  	$(CD) custom
  	$(MAKE) /f NTMakefile /nologo install
  	$(CD) ..
  
! install: customactions languages
  
  $(MSIFILE): $(WIXOBJ)
  	light -nologo -out $(MSIFILE) \
--- 39,55 ----
  
  lang:: lang_clean $(MSIFILE)
  
+ uninst: 
+         $(CD) uninstall
+         $(MAKE) /f NTMakefile /nologo install
+         $(CD) ..
+ 
  customactions:
  	$(CD) custom
  	$(MAKE) /f NTMakefile /nologo install
  	$(CD) ..
  
! install: uninst customactions languages 
  
  $(MSIFILE): $(WIXOBJ)
  	light -nologo -out $(MSIFILE) \
***************
*** 67,72 ****
--- 79,87 ----
  	$(CD) custom
  	$(MAKE) /f NTMakefile /nologo clean
  	$(CD) ..
+ 	$(CD) uninstall
+ 	$(MAKE) /f NTMakefile /nologo clean
+ 	$(CD) ..
  	
  lang_clean:
  	-$(DEL) $(WIXOBJ)
Index: openafs/src/WINNT/install/wix/feature.wxi
diff -c openafs/src/WINNT/install/wix/feature.wxi:1.5.2.5 openafs/src/WINNT/install/wix/feature.wxi:1.5.2.6
*** openafs/src/WINNT/install/wix/feature.wxi:1.5.2.5	Thu Apr 28 08:05:45 2005
--- openafs/src/WINNT/install/wix/feature.wxi	Sun Jun 12 07:23:15 2005
***************
*** 5,10 ****
--- 5,11 ----
              Title="OpenAFS">
             <ComponentRef Id="efl_desktop_INI" />
             <ComponentRef Id="efl_replace_afs_CMD" />
+            <ComponentRef Id="efl_uninstall_EXE" />
              <Feature Id="feaClient" AllowAdvertise="no" Description="$(loc.StrAFSClientLongDesc)" Display="expand"
                  InstallDefault="followParent" Level="30" Title="$(loc.StrAFSClientDesc)">
                  
***************
*** 124,129 ****
--- 125,131 ----
                  <ComponentRef Id="cmf_volserver_EXE" />
                  <ComponentRef Id="cmf_afskill_EXE" />
                  <ComponentRef Id="cmf_afssvrcfg_EXE" />
+                 <ComponentRef Id="cmf_asetkey_EXE" />
                  <ComponentRef Id="cmf_bosctlsvc_EXE" />
                  <ComponentRef Id="cmf_bosserver_EXE" />
                  <ComponentRef Id="cmf_buserver_EXE" />
Index: openafs/src/WINNT/install/wix/files.wxi
diff -c openafs/src/WINNT/install/wix/files.wxi:1.9.2.6 openafs/src/WINNT/install/wix/files.wxi:1.9.2.7
*** openafs/src/WINNT/install/wix/files.wxi:1.9.2.6	Sun May 29 23:58:38 2005
--- openafs/src/WINNT/install/wix/files.wxi	Sun Jun 12 07:23:15 2005
***************
*** 32,37 ****
--- 32,42 ----
              <Component Id="efl_replace_afs_CMD" Guid="C9C93F3E-EEBA-4056-9669-5EF78D748D50">
                 <File Id="filreplace_afs_CMD" Name="replafs.cmd" LongName="replace_afs.cmd" KeyPath="yes" DiskId="1" src="$(var.SrcDir)\WINNT\install\wix\replace_afs.cmd" />
              </Component>
+ 	    <Component Id="efl_uninstall_EXE" Guid="8B99B979-03F4-4AB5-9CE8-1DA97DB6613A">
+ 		<File Id="filuninstall_EXE" Name="uninst.exe" LongName="uninstall.exe" KeyPath="yes" DiskId="1" src="$(var.ClientDir)\uninstall.exe">
+ 			<Shortcut Id="scUninstall" Directory="dirShortCut" Name="Uninst.lnk" LongName="Uninstall OpenAFS.lnk" Description="$(loc.StrUninstallDesc)" Icon="ico_OpenAFS" IconIndex="0" Show="normal" />
+                 </File>
+ 	    </Component>
              <Directory Id="dirCommon" Name="Common">
                  <Component Id="cmp_CommonDir" Guid="C86B03A1-AE97-48B1-A77B-1B2395F1E117" KeyPath="yes">
                      <Environment Id="envCommon" Name="PATH" Action="create" System="yes" Permanent="no" Part="last" Separator=";" Value="[AFSDIR]Common" />
***************
*** 1219,1224 ****
--- 1224,1232 ----
  									<Shortcut Id="scSvrCfgWizard" Directory="dirShortCut" Name="SvrCfgWz.lnk" LongName="Server Configuration Wizard.lnk" Description="$(loc.StrCfgWzdDesc)" Arguments="/wizard" Icon="ico_afssvrcfg" IconIndex="0" Show="normal" WorkingDirectory="dirCommon" />
                                  </File>
                              </Component>
+                             <Component Id="cmf_asetkey_EXE" Guid="9B7694A2-DCAE-4DBA-84F2-09DC796C20B2">
+                                 <File Id="fileasetkey_EXE" Name="asetk.exe" LongName="asetkey.exe" KeyPath="yes" DiskId="1" />
+                             </Component>
                              <Component Id="cmf_bosctlsvc_EXE" Guid="8F6F62A8-BB6D-46C1-BA80-4F207AA24F0D">
                                  <File Id="filebosctlsvc_EXE" Name="bosct.exe" LongName="bosctlsvc.exe" KeyPath="yes" DiskId="1" />
                                  <ServiceControl Id="TransarcAFSServer" Name="TransarcAFSServer" Stop="both" Remove="both" Wait="yes" />
***************
*** 1277,1282 ****
--- 1285,1291 ----
                                  <File Id="filevolserver_PDB" Name="volse.pdb" LongName="volserver.pdb" DiskId="1" />
                                  <File Id="fileafskill_PDB" Name="afski.pdb" LongName="afskill.pdb" DiskId="1" />
                                  <File Id="fileafssvrcfg_PDB" Name="afssv.pdb" LongName="afssvrcfg.pdb" DiskId="1" />
+                                 <File Id="fileasetkey_PDB" Name="asetk.pdb" LongName="asetkey.pdb" DiskId="1" />
                                  <File Id="filebosctlsvc_PDB" Name="bosct.pdb" LongName="bosctlsvc.pdb" DiskId="1" />
                                  <File Id="filebosserver_PDB" Name="bosse.pdb" LongName="bosserver.pdb" DiskId="1" />
                                  <File Id="filebuserver_PDB" Name="buser.pdb" LongName="buserver.pdb" DiskId="1" />
Index: openafs/src/WINNT/install/wix/Icon/ico_OpenAFS.ico
Index: openafs/src/WINNT/install/wix/lang/en_US/strings.wxl
diff -c openafs/src/WINNT/install/wix/lang/en_US/strings.wxl:1.1.2.2 openafs/src/WINNT/install/wix/lang/en_US/strings.wxl:1.1.2.3
*** openafs/src/WINNT/install/wix/lang/en_US/strings.wxl:1.1.2.2	Mon Aug 23 11:55:10 2004
--- openafs/src/WINNT/install/wix/lang/en_US/strings.wxl	Sun Jun 12 07:23:16 2005
***************
*** 54,58 ****
  	<String Id="ActRemoveNsisInstallation">Removing existing installation of OpenAFS</String>
  	
  	<String Id="StrNsisAbortReason">Installation of OpenAFS for Windows was prematurely terminated because OpenAFS [NSISVERSION] was already installed.</String>
! 	
  </WixLocalization>
--- 54,58 ----
  	<String Id="ActRemoveNsisInstallation">Removing existing installation of OpenAFS</String>
  	
  	<String Id="StrNsisAbortReason">Installation of OpenAFS for Windows was prematurely terminated because OpenAFS [NSISVERSION] was already installed.</String>
! 	<String Id="StrUninstallDesc">Uninstall OpenAFS from the local machine.</String>
  </WixLocalization>
Index: openafs/src/WINNT/install/wix/lang/en_US/ui.wxi
diff -c openafs/src/WINNT/install/wix/lang/en_US/ui.wxi:1.6.2.2 openafs/src/WINNT/install/wix/lang/en_US/ui.wxi:1.6.2.3
*** openafs/src/WINNT/install/wix/lang/en_US/ui.wxi:1.6.2.2	Mon Aug 23 11:55:10 2004
--- openafs/src/WINNT/install/wix/lang/en_US/ui.wxi	Sun Jun 12 21:07:39 2005
***************
*** 1084,1087 ****
--- 1084,1088 ----
      <Icon Id="ico_Help" src="Icon\ico_Help.ico" />
      <Icon Id="ico_ServerManager" src="Icon\ico_ServerManager.ico" />
      <Icon Id="ico_afssvrcfg" src="Icon\ico_afssvrcfg.ico" />
+     <Icon Id="ico_OpenAFS" src="Icon\ico_OpenAFS.ico" />
  </Include>
Index: openafs/src/WINNT/talocale/tal_main.cpp
diff -c openafs/src/WINNT/talocale/tal_main.cpp:1.3 openafs/src/WINNT/talocale/tal_main.cpp:1.3.2.1
*** openafs/src/WINNT/talocale/tal_main.cpp:1.3	Thu Apr  1 14:45:03 2004
--- openafs/src/WINNT/talocale/tal_main.cpp	Wed Jul  6 20:29:17 2005
***************
*** 182,188 ****
     // so, remove it (its priority may be changing, or we may actually
     // have been asked to remove it).
     //
!    for (size_t iModule = 0; iModule < l_cModules; ++iModule)
        {
        if (l_aModules[ iModule ].wPriority == 0)  // end of list?
           break;
--- 182,189 ----
     // so, remove it (its priority may be changing, or we may actually
     // have been asked to remove it).
     //
!    size_t iModule;
!    for (iModule = 0; iModule < l_cModules; ++iModule)
        {
        if (l_aModules[ iModule ].wPriority == 0)  // end of list?
           break;
***************
*** 211,217 ****
              break;
           }
  
!       for (size_t iTarget = iModule; iTarget < l_cModules; ++iTarget)
           {
           if (l_aModules[ iTarget ].wPriority == 0)  // end of list?
              break;
--- 212,219 ----
              break;
           }
  
!       size_t iTarget;
!       for (iTarget = iModule; iTarget < l_cModules; ++iTarget)
           {
           if (l_aModules[ iTarget ].wPriority == 0)  // end of list?
              break;
Index: openafs/src/WINNT/talocale/tal_string.cpp
diff -c openafs/src/WINNT/talocale/tal_string.cpp:1.6 openafs/src/WINNT/talocale/tal_string.cpp:1.6.2.1
*** openafs/src/WINNT/talocale/tal_string.cpp:1.6	Tue Apr  6 18:26:37 2004
--- openafs/src/WINNT/talocale/tal_string.cpp	Wed Jul  6 20:29:17 2005
***************
*** 12,17 ****
--- 12,19 ----
  #include <afs/stds.h>
  }
  
+ #include <windows.h>
+ #include <windowsx.h>
  #include <WINNT/talocale.h>
  #include <stdlib.h>
  
***************
*** 371,377 ****
        if ((psz = (LPTSTR)lstrchr (&szFmt[1], TEXT('%'))) != NULL)
           *psz = 0;
  
!       for (int ii = 1; szFmt[ii] == TEXT('-') || szFmt[ii] == TEXT(','); ii++)
           ;
        cchMin = _ttol (&szFmt[ii]);
  
--- 373,380 ----
        if ((psz = (LPTSTR)lstrchr (&szFmt[1], TEXT('%'))) != NULL)
           *psz = 0;
  
!       int ii;
!       for (ii = 1; szFmt[ii] == TEXT('-') || szFmt[ii] == TEXT(','); ii++)
           ;
        cchMin = _ttol (&szFmt[ii]);
  
***************
*** 962,968 ****
        {
        lstrcpy (szFormat, pszFormatUser);
  
!       for (LPTSTR pch = &szFormat[1]; *pch; ++pch)
           {
           if (!isfmtgarbage(*pch))
              {
--- 965,972 ----
        {
        lstrcpy (szFormat, pszFormatUser);
  
!       LPTSTR pch;
!       for (pch = &szFormat[1]; *pch; ++pch)
           {
           if (!isfmtgarbage(*pch))
              {
***************
*** 988,995 ****
              // Cheesy bit: if all we have are 0's and "."'s, just
              // make the number read "0".
              //
! 
!    for (TCHAR *pch = szJustTheNumber; *pch; ++pch)
        {
        if (*pch != TEXT('0') && *pch != TEXT('.'))
           break;
--- 992,999 ----
              // Cheesy bit: if all we have are 0's and "."'s, just
              // make the number read "0".
              //
!    TCHAR * pch;
!    for (pch = szJustTheNumber; *pch; ++pch)
        {
        if (*pch != TEXT('0') && *pch != TEXT('.'))
           break;
***************
*** 1654,1660 ****
        {
        lstrcpy (szFormat, pszFormat);
  
!       for (LPTSTR pch = &szFormat[1]; *pch; ++pch)
           {
           if (!isfmtgarbage(*pch))
              {
--- 1658,1665 ----
        {
        lstrcpy (szFormat, pszFormat);
  
!       LPTSTR pch;
!       for (pch = &szFormat[1]; *pch; ++pch)
           {
           if (!isfmtgarbage(*pch))
              {
Index: openafs/src/WINNT/talocale/tal_string.h
diff -c openafs/src/WINNT/talocale/tal_string.h:1.2 openafs/src/WINNT/talocale/tal_string.h:1.2.20.1
*** openafs/src/WINNT/talocale/tal_string.h:1.2	Sat Nov  4 05:03:07 2000
--- openafs/src/WINNT/talocale/tal_string.h	Wed Jul  6 20:29:17 2005
***************
*** 104,110 ****
  
  extern void lsplitpath (LPCTSTR pszSource,
                   LPTSTR pszDrive, LPTSTR pszPath, LPTSTR pszBase, LPTSTR pszExt);
- 
- 
  #endif
  
--- 104,108 ----
Index: openafs/src/afs/afs.h
diff -c openafs/src/afs/afs.h:1.48.2.19 openafs/src/afs/afs.h:1.48.2.21
*** openafs/src/afs/afs.h:1.48.2.19	Mon May 30 00:05:40 2005
--- openafs/src/afs/afs.h	Mon Jul 11 15:29:55 2005
***************
*** 558,567 ****
  #endif /* AFS_XBSD_ENV */
  
  #if defined(AFS_LINUX24_ENV)
! #define VREFCOUNT(v)		atomic_read(&((vnode_t *) v)->v_count)
! #define VREFCOUNT_SET(v, c)	atomic_set(&((vnode_t *) v)->v_count, c)
! #define VREFCOUNT_DEC(v)	atomic_dec(&((vnode_t *) v)->v_count)
! #define VREFCOUNT_INC(v)	atomic_inc(&((vnode_t *) v)->v_count)
  #else
  #define VREFCOUNT(v)		((v)->vrefCount)
  #define VREFCOUNT_SET(v, c)	(v)->vrefCount = c;
--- 558,567 ----
  #endif /* AFS_XBSD_ENV */
  
  #if defined(AFS_LINUX24_ENV)
! #define VREFCOUNT(v)		atomic_read(&(AFSTOV(v)->v_count))
! #define VREFCOUNT_SET(v, c)	atomic_set(&(AFSTOV(v)->v_count), c)
! #define VREFCOUNT_DEC(v)	atomic_dec(&(AFSTOV(v)->v_count))
! #define VREFCOUNT_INC(v)	atomic_inc(&(AFSTOV(v)->v_count))
  #else
  #define VREFCOUNT(v)		((v)->vrefCount)
  #define VREFCOUNT_SET(v, c)	(v)->vrefCount = c;
***************
*** 580,586 ****
  
  extern afs_int32 vmPageHog;	/* counter for # of vnodes which are page hogs. */
  
! #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV)
  #define VTOAFS(v) ((struct vcache *)(v)->v_data)
  #define AFSTOV(vc) ((vc)->v)
  #else
--- 580,586 ----
  
  extern afs_int32 vmPageHog;	/* counter for # of vnodes which are page hogs. */
  
! #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_HAS_ALLOC_INODE))
  #define VTOAFS(v) ((struct vcache *)(v)->v_data)
  #define AFSTOV(vc) ((vc)->v)
  #else
***************
*** 588,612 ****
  #define AFSTOV(V) (&(V)->v)
  #endif
  
- #ifdef AFS_LINUX22_ENV
- #define ITOAFS(V) ((struct vcache*)(V))
- #define AFSTOI(V) (struct inode *)(&(V)->v)
- #endif
- 
  /* INVARIANTs: (vlruq.next != NULL) == (vlruq.prev != NULL)
   *             nextfree => !vlruq.next && ! vlruq.prev
   * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree)
   */
  struct vcache {
! #if defined(AFS_XBSD_ENV)||defined(AFS_DARWIN_ENV)
      struct vnode *v;
  #else
      struct vnode v;		/* Has reference count in v.v_count */
  #endif
      struct afs_q vlruq;		/* lru q next and prev */
      struct vcache *nextfree;	/* next on free list (if free) */
      struct vcache *hnext;	/* Hash next */
!     struct vcache *vhnext; /* vol hash next */
      struct VenusFid fid;
      struct mstat {
  	afs_size_t Length;
--- 588,609 ----
  #define AFSTOV(V) (&(V)->v)
  #endif
  
  /* INVARIANTs: (vlruq.next != NULL) == (vlruq.prev != NULL)
   *             nextfree => !vlruq.next && ! vlruq.prev
   * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree)
   */
  struct vcache {
! #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_HAS_ALLOC_INODE))
      struct vnode *v;
  #else
      struct vnode v;		/* Has reference count in v.v_count */
  #endif
      struct afs_q vlruq;		/* lru q next and prev */
+ #if !defined(AFS_LINUX22_ENV)
      struct vcache *nextfree;	/* next on free list (if free) */
+ #endif
      struct vcache *hnext;	/* Hash next */
!     struct vcache *vhnext;	/* vol hash next */
      struct VenusFid fid;
      struct mstat {
  	afs_size_t Length;
***************
*** 814,822 ****
  
  #define	NULLIDX	    (-1)	/* null index definition */
  /* struct dcache states bits */
- #define DRO         1
- #define DBackup     2
- #define DRW         4
  #define	DWriting    8		/* file being written (used for cache validation) */
  
  /* dcache data flags */
--- 811,816 ----
***************
*** 941,947 ****
      char dflags;		/* Data flags */
      char mflags;		/* Meta flags */
      struct fcache f;		/* disk image */
!     afs_int32 bucket;           /* which bucket these dcache entries are in */
      /*
       * Locking rules:
       *
--- 935,941 ----
      char dflags;		/* Data flags */
      char mflags;		/* Meta flags */
      struct fcache f;		/* disk image */
! 
      /*
       * Locking rules:
       *
***************
*** 1069,1079 ****
   * GetVCache incantation, and could eliminate even this code from afs_UFSRead 
   * by making intentionally invalidating quick.stamp in the various callbacks
   * expiration/breaking code */
- #ifdef AFS_LINUX20_ENV
- #define afs_VerifyVCache(avc, areq)  \
-   (((avc)->states & CStatd) ? (vcache2inode(avc), 0) : \
-    afs_VerifyVCache2((avc),areq))
- #else
  #ifdef AFS_DARWIN_ENV
  #define afs_VerifyVCache(avc, areq)  \
    (((avc)->states & CStatd) ? (osi_VM_Setup(avc, 0), 0) : \
--- 1063,1068 ----
***************
*** 1082,1088 ****
  #define afs_VerifyVCache(avc, areq)  \
    (((avc)->states & CStatd) ? 0 : afs_VerifyVCache2((avc),areq))
  #endif
- #endif
  
  #define DO_STATS 1		/* bits used by FindVCache */
  #define DO_VLRU 2
--- 1071,1076 ----
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.74.2.9 openafs/src/afs/afs_call.c:1.74.2.10
*** openafs/src/afs/afs_call.c:1.74.2.9	Mon May 23 17:16:08 2005
--- openafs/src/afs/afs_call.c	Tue Jun 21 16:13:48 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.9 2005/05/23 21:16:08 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.10 2005/06/21 20:13:48 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 517,534 ****
  	DInit(temp);
  	afs_rootFid.Fid.Volume = 0;
  	code = 0;
-     } else if (parm == AFSOP_BUCKETPCT) {
- 	/* need to enable this now, will disable again before GO
- 	   if we don't have 100% */
- 	splitdcache = 1;
- 	switch (parm2) {
- 	case 1:
- 	    afs_tpct1 = parm3;
- 	    break;
- 	case 2:
- 	    afs_tpct2 = parm3;
- 	    break;
- 	}           
      } else if (parm == AFSOP_ADDCELL) {
  	/* add a cell.  Parameter 2 is 8 hosts (in net order),  parm 3 is the null-terminated
  	 * name.  Parameter 4 is the length of the name, including the null.  Parm 5 is the
--- 517,522 ----
***************
*** 705,717 ****
  	    afs_osi_Sleep(&afs_initState);
  	afs_initState = 101;
  	afs_setTime = parm2;
- 	if (afs_tpct1 + afs_tpct2 != 100) {
- 	    afs_tpct1 = 0;
- 	    afs_tpct2 = 0;
- 	    splitdcache = 0;
- 	} else {        
- 	    splitdcache = 1;
- 	}
  	afs_osi_Wakeup(&afs_initState);
  #if	(!defined(AFS_NONFSTRANS)) || defined(AFS_AIX_IAUTH_ENV)
  	afs_nfsclient_init();
--- 693,698 ----
Index: openafs/src/afs/afs_dcache.c
diff -c openafs/src/afs/afs_dcache.c:1.42.2.13 openafs/src/afs/afs_dcache.c:1.42.2.14
*** openafs/src/afs/afs_dcache.c:1.42.2.13	Sun Jun  5 11:34:49 2005
--- openafs/src/afs/afs_dcache.c	Tue Jun 21 16:13:48 2005
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.13 2005/06/05 15:34:49 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.14 2005/06/21 20:13:48 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 23,53 ****
  #include "afs/afs_osidnlc.h"
  
  /* Forward declarations. */
! static void afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint);
  static void afs_FreeDiscardedDCache(void);
  static void afs_DiscardDCache(struct dcache *);
  static void afs_FreeDCache(struct dcache *);
- /* For split cache */
- static afs_int32 afs_DCGetBucket(struct vcache *);
- static void afs_DCAdjustSize(struct dcache *, afs_int32, afs_int32);
- static void afs_DCMoveBucket(struct dcache *, afs_int32, afs_int32);
- static void afs_DCSizeInit(void);
- static afs_int32 afs_DCWhichBucket(afs_int32, afs_int32);
- 
  
  /*
   * --------------------- Exported definitions ---------------------
   */
- /* For split cache */
- afs_int32 afs_blocksUsed_0;    /*1K blocks in cache - in theory is zero */
- afs_int32 afs_blocksUsed_1;    /*1K blocks in cache */
- afs_int32 afs_blocksUsed_2;    /*1K blocks in cache */
- afs_int32 afs_pct1 = -1;
- afs_int32 afs_pct2 = -1;
- afs_uint32 afs_tpct1 = 0;
- afs_uint32 afs_tpct2 = 0;
- afs_uint32 splitdcache = 0;
- 
  afs_lock_t afs_xdcache;		/*Lock: alloc new disk cache entries */
  afs_int32 afs_freeDCList;	/*Free list for disk cache entries */
  afs_int32 afs_freeDCCount;	/*Count of elts in freeDCList */
--- 23,36 ----
  #include "afs/afs_osidnlc.h"
  
  /* Forward declarations. */
! static void afs_GetDownD(int anumber, int *aneedSpace);
  static void afs_FreeDiscardedDCache(void);
  static void afs_DiscardDCache(struct dcache *);
  static void afs_FreeDCache(struct dcache *);
  
  /*
   * --------------------- Exported definitions ---------------------
   */
  afs_lock_t afs_xdcache;		/*Lock: alloc new disk cache entries */
  afs_int32 afs_freeDCList;	/*Free list for disk cache entries */
  afs_int32 afs_freeDCCount;	/*Count of elts in freeDCList */
***************
*** 136,247 ****
  int cacheDiskType;		/*Type of backing disk for cache */
  struct afs_cacheOps *afs_cacheType;
  
- static afs_int32
- afs_DCGetBucket(struct vcache *avc) 
- {
-   /* This should be replaced with some sort of user configurable function */
-   if (avc->states & CRO) {
-       return 2;
-   } else if (avc->states & CBackup) {
-       return 1;
-   } else {
-     /* RW */
-   }
-   /* main bucket */
-   return 1;
- }
- 
- static void 
- afs_DCAdjustSize(struct dcache *adc, afs_int32 oldSize, afs_int32 newSize)
- {
-     afs_int32 adjustSize = newSize - oldSize;
- 
-     if (!splitdcache) 
- 	return;
- 
-     switch (adc->bucket) 
-     {
-     case 0:
- 	afs_blocksUsed_0 += adjustSize;
- 	afs_stats_cmperf.cacheBucket0_Discarded += oldSize;
- 	break;
-     case 1:
- 	afs_blocksUsed_1 += adjustSize;
- 	afs_stats_cmperf.cacheBucket1_Discarded += oldSize;
- 	break;
-     case 2:
- 	afs_blocksUsed_2 += adjustSize;
- 	afs_stats_cmperf.cacheBucket2_Discarded += oldSize;
- 	break;
-     }
- 
-     return;
- }
- 
- static void 
- afs_DCMoveBucket(struct dcache *adc, afs_int32 size, afs_int32 newBucket)
- {
-     if (!splitdcache) 
- 	return;
- 
-     switch (adc->bucket) 
-     {
-     case 0:
- 	afs_blocksUsed_0 -= size;
- 	break;
-     case 1:
- 	afs_blocksUsed_1 -= size;
- 	break;
-     case 2:
- 	afs_blocksUsed_2 -= size;
- 	break;
-     }
- 
-     adc->bucket = newBucket;
- 
-     switch (adc->bucket) 
-     {
-     case 0:
- 	afs_blocksUsed_0 += size;
- 	break;
-     case 1:
- 	afs_blocksUsed_1 += size;
- 	break;
-     case 2:
- 	afs_blocksUsed_2 += size;
- 	break;
-     }
-     
-     return;
- }
- 
- static void 
- afs_DCSizeInit(void) 
- {
-     afs_blocksUsed_0 = afs_blocksUsed_1 = afs_blocksUsed_2 = 0;
- }
- 
- static afs_int32
- afs_DCWhichBucket(afs_int32 phase, afs_int32 bucket) 
- {
-     if (!splitdcache) 
- 	return 0;
- 
-     afs_pct1 = afs_blocksUsed_1*100/afs_cacheBlocks;    
-     afs_pct2 = afs_blocksUsed_2*100/afs_cacheBlocks;
- 
-     /* Short cut: if we don't know about it, try to kill it */
-     if (phase < 2 && afs_blocksUsed_0) 
- 	return 0;
-     
-     if (afs_pct1 > afs_tpct1) 
- 	return 1;
-     if (afs_pct2 > afs_tpct2)
- 	return 2;
-     return 0; /* unlikely */
- }
- 
- 
  /*
   * afs_StoreWarn
   *
--- 119,124 ----
***************
*** 365,371 ****
  		    afs_blocksUsed - afs_blocksDiscarded - cb_lowat;
  		slots_needed =
  		    dc_hiwat - afs_freeDCCount - afs_discardDCCount;
! 		afs_GetDownD(slots_needed, &space_needed, 0);
  		if ((space_needed <= 0) && (slots_needed <= 0)) {
  		    break;
  		}
--- 242,248 ----
  		    afs_blocksUsed - afs_blocksDiscarded - cb_lowat;
  		slots_needed =
  		    dc_hiwat - afs_freeDCCount - afs_discardDCCount;
! 		afs_GetDownD(slots_needed, &space_needed);
  		if ((space_needed <= 0) && (slots_needed <= 0)) {
  		    break;
  		}
***************
*** 460,466 ****
      if (!newSize)
  	adc->validPos = 0;
      newSize = ((newSize + afs_fsfragsize) ^ afs_fsfragsize) >> 10;	/* round up */
-     afs_DCAdjustSize(adc, oldSize, newSize);
      if (newSize > oldSize) {
  	/* We're growing the file, wakeup the daemon */
  	afs_MaybeWakeupTruncateDaemon();
--- 337,342 ----
***************
*** 497,503 ****
  
  #define	MAXATONCE   16		/* max we can obtain at once */
  static void
! afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint)
  {
  
      struct dcache *tdc;
--- 373,379 ----
  
  #define	MAXATONCE   16		/* max we can obtain at once */
  static void
! afs_GetDownD(int anumber, int *aneedSpace)
  {
  
      struct dcache *tdc;
***************
*** 513,519 ****
      afs_hyper_t maxVictimTime;	/* youngest (largest LRU time) victim */
      afs_uint32 maxVictimPtr;	/* where it is */
      int discard;
-     int curbucket;
  
      AFS_STATCNT(afs_GetDownD);
      if (CheckLock(&afs_xdcache) != -1)
--- 389,394 ----
***************
*** 530,549 ****
      if (anumber > MAXATONCE)
  	anumber = MAXATONCE;	/* all we can do */
  
-     /* rewrite so phases include a better eligiblity for gc test*/
      /*
       * The phase variable manages reclaims.  Set to 0, the first pass,
!      * we don't reclaim active entries, or other than target bucket.  
!      * Set to 1, we reclaim even active ones in target bucket.
!      * Set to 2, we reclaim any inactive one.
!      * Set to 3, we reclaim even active ones.
       */
!     if (splitdcache) {
! 	phase = 0;
!     } else {
! 	phase = 4;
!     }
! 
      for (i = 0; i < afs_cacheFiles; i++)
  	/* turn off all flags */
  	afs_indexFlags[i] &= ~IFFlag;
--- 405,416 ----
      if (anumber > MAXATONCE)
  	anumber = MAXATONCE;	/* all we can do */
  
      /*
       * The phase variable manages reclaims.  Set to 0, the first pass,
!      * we don't reclaim active entries.  Set to 1, we reclaim even active
!      * ones.
       */
!     phase = 0;
      for (i = 0; i < afs_cacheFiles; i++)
  	/* turn off all flags */
  	afs_indexFlags[i] &= ~IFFlag;
***************
*** 552,558 ****
  	/* find oldest entries for reclamation */
  	maxVictimPtr = victimPtr = 0;
  	hzero(maxVictimTime);
- 	curbucket = afs_DCWhichBucket(phase, buckethint);
  	/* select victims from access time array */
  	for (i = 0; i < afs_cacheFiles; i++) {
  	    if (afs_indexFlags[i] & (IFDataMod | IFFree | IFDiscarded)) {
--- 419,424 ----
***************
*** 560,570 ****
  		continue;
  	    }
  	    tdc = afs_indexTable[i];
- 	    if (tdc && (curbucket != tdc->bucket) && (phase < 4))
- 	    {
- 		/* Wrong bucket; can't use it! */
- 	        continue;
- 	    }
  	    if (tdc && (tdc->refCount != 0)) {
  		/* Referenced; can't use it! */
  		continue;
--- 426,431 ----
***************
*** 646,657 ****
  		if (tvc) {
  		    tchunkoffset = AFS_CHUNKTOBASE(tdc->f.chunk);
  		    chunkFlags = afs_indexFlags[tdc->index];
! 		    if (((phase & 1) == 0) && osi_Active(tvc))
!                         skip = 1;
! 		    if (((phase & 1) == 1) && osi_Active(tvc)
!                         && (tvc->states & CDCLock)
!                         && (chunkFlags & IFAnyPages))
!                         skip = 1;
  		    if (chunkFlags & IFDataMod)
  			skip = 1;
  		    afs_Trace4(afs_iclSetp, CM_TRACE_GETDOWND,
--- 507,518 ----
  		if (tvc) {
  		    tchunkoffset = AFS_CHUNKTOBASE(tdc->f.chunk);
  		    chunkFlags = afs_indexFlags[tdc->index];
! 		    if (phase == 0 && osi_Active(tvc))
! 			skip = 1;
! 		    if (phase > 0 && osi_Active(tvc)
! 			&& (tvc->states & CDCLock)
! 			&& (chunkFlags & IFAnyPages))
! 			skip = 1;
  		    if (chunkFlags & IFDataMod)
  			skip = 1;
  		    afs_Trace4(afs_iclSetp, CM_TRACE_GETDOWND,
***************
*** 783,800 ****
  	    afs_PutDCache(tdc);
  	}
  
! 	if (phase < 5) {
  	    /* Phase is 0 and no one was found, so try phase 1 (ignore
  	     * osi_Active flag) */
  	    if (j == 0) {
! 		phase++;
  		for (i = 0; i < afs_cacheFiles; i++)
  		    /* turn off all flags */
  		    afs_indexFlags[i] &= ~IFFlag;
  	    }
  	} else {
! 	    /* found no one in phases 0-5, we're hosed */
! 	    if (j == 0)
  		break;
  	}
      }				/* big while loop */
--- 644,661 ----
  	    afs_PutDCache(tdc);
  	}
  
! 	if (phase == 0) {
  	    /* Phase is 0 and no one was found, so try phase 1 (ignore
  	     * osi_Active flag) */
  	    if (j == 0) {
! 		phase = 1;
  		for (i = 0; i < afs_cacheFiles; i++)
  		    /* turn off all flags */
  		    afs_indexFlags[i] &= ~IFFlag;
  	    }
  	} else {
! 	    /* found no one in phase 1, we're hosed */
! 	    if (victimPtr == 0)
  		break;
  	}
      }				/* big while loop */
***************
*** 1052,1059 ****
      afs_CFileTruncate(tfile, 0);
      afs_CFileClose(tfile);
      afs_AdjustSize(tdc, 0);
-     tdc->f.states &= ~(DRO|DBackup|DRW);
-     afs_DCMoveBucket(tdc, 0, 0);
  
      /*
       * Free the element we just truncated
--- 913,918 ----
***************
*** 1341,1347 ****
  		break;		/* leaving refCount high for caller */
  	    }
  	    afs_PutDCache(tdc);
- 	    tdc = NULL;
  	}
  	index = afs_dcnextTbl[index];
      }
--- 1200,1205 ----
***************
*** 1829,1836 ****
  		while (1) {
  		    if (!setLocks)
  			avc->states |= CDCLock;
! 		    /* just need slots */
! 		    afs_GetDownD(5, (int *)0, afs_DCGetBucket(avc));
  		    if (!setLocks)
  			avc->states &= ~CDCLock;
  		    if (afs_discardDCList != NULLIDX
--- 1687,1693 ----
  		while (1) {
  		    if (!setLocks)
  			avc->states |= CDCLock;
! 		    afs_GetDownD(5, (int *)0);	/* just need slots */
  		    if (!setLocks)
  			avc->states &= ~CDCLock;
  		    if (afs_discardDCList != NULLIDX
***************
*** 1871,1878 ****
  		size =
  		    ((tdc->f.chunkBytes +
  		      afs_fsfragsize) ^ afs_fsfragsize) >> 10;
- 		tdc->f.states &= ~(DRO|DBackup|DRW);
- 		afs_DCMoveBucket(tdc, size, 0);
  		afs_blocksDiscarded -= size;
  		afs_stats_cmperf.cacheBlocksDiscarded = afs_blocksDiscarded;
  		if (aflags & 2) {
--- 1728,1733 ----
***************
*** 1897,1909 ****
  	     */
  	    afs_indexFlags[tdc->index] &= ~(IFDirtyPages | IFAnyPages);
  	    tdc->f.fid = avc->fid;
- 	    if (avc->states & CRO) 
- 		tdc->f.states = DRO;
- 	    else if (avc->states & CBackup) 
- 		tdc->f.states = DBackup;
- 	    else 
- 		tdc->f.states = DRW;
- 	    afs_DCMoveBucket(tdc, 0, afs_DCGetBucket(avc));
  	    afs_indexUnique[tdc->index] = tdc->f.fid.Fid.Unique;
  	    hones(tdc->f.versionNo);	/* invalid value */
  	    tdc->f.chunk = chunk;
--- 1752,1757 ----
***************
*** 1923,1928 ****
--- 1771,1777 ----
  	    afs_dvhashTbl[i] = tdc->index;
  	    tdc->dflags = DFEntryMod;
  	    tdc->mflags = 0;
+ 	    tdc->f.states = 0;
  	    afs_MaybeWakeupTruncateDaemon();
  	    MReleaseWriteLock(&afs_xdcache);
  	    ConvertWToSLock(&tdc->lock);
***************
*** 2532,2539 ****
  	    if (vType(avc) == VDIR) {
  		DZap(tdc);
  	    }
- 	    tdc->f.states &= ~(DRO|DBackup|DRW);
- 	    afs_DCMoveBucket(tdc, 0, 0);
  	    ReleaseWriteLock(&tdc->lock);
  	    afs_PutDCache(tdc);
  	    ObtainWriteLock(&afs_xcbhash, 454);
--- 2381,2386 ----
***************
*** 2547,2554 ****
  	     * avc->lock(W); assert(!setLocks || slowPass)
  	     */
  	    osi_Assert(!setLocks || slowPass);
- 	    tdc->f.states &= ~(DRO|DBackup|DRW);
- 	    afs_DCMoveBucket(tdc, 0, 0);
  	    tdc = NULL;
  	    goto done;
  	}
--- 2394,2399 ----
***************
*** 2958,2975 ****
  #endif
  	lasterrtime = osi_Time();
  	afs_indexUnique[aslot] = tdc->f.fid.Fid.Unique;
- 	tdc->f.states &= ~(DRO|DBackup|DRW);
- 	afs_DCMoveBucket(tdc, 0, 0);
-     } else {
- 	if (&tdc->f != 0) {
- 	    if (tdc->f.states & DRO) {
- 		afs_DCMoveBucket(tdc, 0, 2);
- 	    } else if (tdc->f.states & DBackup) {
- 		afs_DCMoveBucket(tdc, 0, 1);
- 	    } else {
- 		afs_DCMoveBucket(tdc, 0, 1); 
- 	    }
- 	} 
      }
      tdc->refCount = 1;
      tdc->index = aslot;
--- 2803,2808 ----
***************
*** 3193,3200 ****
  	tdc->f.fid.Fid.Volume = 0;	/* not in the hash table */
  	if (tstat.size != 0)
  	    osi_UFSTruncate(tfile, 0);
- 	tdc->f.states &= ~(DRO|DBackup|DRW);
- 	afs_DCMoveBucket(tdc, 0, 0);
  	/* put entry in free cache slot list */
  	afs_dvnextTbl[tdc->index] = afs_freeDCList;
  	afs_freeDCList = index;
--- 3026,3031 ----
***************
*** 3369,3378 ****
  
      afs_dcentries = aDentries;
      afs_blocksUsed = 0;
-     afs_stats_cmperf.cacheBucket0_Discarded = 
- 	afs_stats_cmperf.cacheBucket1_Discarded = 
- 	afs_stats_cmperf.cacheBucket2_Discarded = 0;
-     afs_DCSizeInit();
      QInit(&afs_DLRU);
  }
  
--- 3200,3205 ----
***************
*** 3413,3421 ****
      afs_osi_Free(afs_dchashTbl, afs_dhashsize * sizeof(afs_int32));
  
      afs_blocksUsed = afs_dcentries = 0;
-     afs_stats_cmperf.cacheBucket0_Discarded = 
- 	afs_stats_cmperf.cacheBucket1_Discarded = 
- 	afs_stats_cmperf.cacheBucket2_Discarded = 0;
      hzero(afs_indexCounter);
  
      afs_freeDCCount = 0;
--- 3240,3245 ----
Index: openafs/src/afs/afs_osi.h
diff -c openafs/src/afs/afs_osi.h:1.22.2.9 openafs/src/afs/afs_osi.h:1.22.2.10
*** openafs/src/afs/afs_osi.h:1.22.2.9	Mon May 23 17:09:37 2005
--- openafs/src/afs/afs_osi.h	Mon Jul 11 15:29:55 2005
***************
*** 48,54 ****
  
  struct osi_file {
      afs_int32 size;		/* file size in bytes XXX Must be first field XXX */
! #ifdef AFS_LINUX24_ENV
      struct file *filp;		/* May need this if we really open the file. */
  #else
  #ifdef AFS_LINUX22_ENV
--- 48,54 ----
  
  struct osi_file {
      afs_int32 size;		/* file size in bytes XXX Must be first field XXX */
! #ifdef AFS_LINUX26_ENV
      struct file *filp;		/* May need this if we really open the file. */
  #else
  #ifdef AFS_LINUX22_ENV
***************
*** 123,129 ****
  /*
   * Vnode related macros
   */
! #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  #define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
  #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
  #define vType(vc)               AFSTOV(vc)->v_type
--- 123,129 ----
  /*
   * Vnode related macros
   */
! #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_LINUX22_ENV)
  #define vSetVfsp(vc, vfsp)      AFSTOV(vc)->v_mount = (vfsp)
  #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
  #define vType(vc)               AFSTOV(vc)->v_type
***************
*** 263,269 ****
     calling VREF does not */
  #define AFS_FAST_HOLD(vp) osi_vnhold((vp),0)
  #else
! #define AFS_FAST_HOLD(vp) VN_HOLD(&(vp)->v)
  #endif
  #define AFS_FAST_RELE(vp) AFS_RELE(AFSTOV(vp))
  
--- 263,269 ----
     calling VREF does not */
  #define AFS_FAST_HOLD(vp) osi_vnhold((vp),0)
  #else
! #define AFS_FAST_HOLD(vp) VN_HOLD(AFSTOV(vp))
  #endif
  #define AFS_FAST_RELE(vp) AFS_RELE(AFSTOV(vp))
  
Index: openafs/src/afs/afs_prototypes.h
diff -c openafs/src/afs/afs_prototypes.h:1.53.2.8 openafs/src/afs/afs_prototypes.h:1.53.2.10
*** openafs/src/afs/afs_prototypes.h:1.53.2.8	Sun May  8 01:04:14 2005
--- openafs/src/afs/afs_prototypes.h	Mon Jul 11 15:29:55 2005
***************
*** 297,303 ****
  extern afs_int32 afs_blocksDiscarded;
  extern int afs_WaitForCacheDrain;
  extern int cacheDiskType;
- extern afs_uint32 afs_tpct1, afs_tpct2, splitdcache;
  extern unsigned char *afs_indexFlags;
  extern struct afs_cacheOps *afs_cacheType;
  extern ino_t cacheInode;
--- 297,302 ----
***************
*** 547,554 ****
  		      uio_seg_t seg);
  extern int uiomove(char *dp, int length, uio_flag_t rw, uio_t * uiop);
  extern void osi_linux_free_inode_pages(void);
- extern void osi_clear_inode(struct inode *ip);
- extern void check_bad_parent(struct dentry *dp);
  #endif
  extern void osi_linux_mask(void);
  extern void osi_linux_unmask(void);
--- 546,551 ----
Index: openafs/src/afs/afs_stats.h
diff -c openafs/src/afs/afs_stats.h:1.11.2.3 openafs/src/afs/afs_stats.h:1.11.2.4
*** openafs/src/afs/afs_stats.h:1.11.2.3	Sun May  8 01:04:14 2005
--- openafs/src/afs/afs_stats.h	Tue Jun 21 16:13:48 2005
***************
*** 802,815 ****
      afs_uint32 cbloops;
      afs_uint32 osiread_efaults;
      afs_int32 cacheBlocksDiscarded;	/*# cache blocks free but not truncated */
-     afs_int32 cacheBucket0_Discarded;  
-     afs_int32 cacheBucket1_Discarded;  
-     afs_int32 cacheBucket2_Discarded;  
- 
      /*
       * Spares for future expansion.
       */
!     afs_int32 spare[10];	/*Spares */
  };
  
  
--- 802,811 ----
      afs_uint32 cbloops;
      afs_uint32 osiread_efaults;
      afs_int32 cacheBlocksDiscarded;	/*# cache blocks free but not truncated */
      /*
       * Spares for future expansion.
       */
!     afs_int32 spare[13];	/*Spares */
  };
  
  
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.65.2.20 openafs/src/afs/afs_vcache.c:1.65.2.21
*** openafs/src/afs/afs_vcache.c:1.65.2.20	Mon May 30 00:05:41 2005
--- openafs/src/afs/afs_vcache.c	Mon Jul 11 15:29:55 2005
***************
*** 39,45 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.20 2005/05/30 04:05:41 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 39,45 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.21 2005/07/11 19:29:55 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 47,53 ****
  #include "afs/afs_cbqueue.h"
  #include "afs/afs_osidnlc.h"
  
! #ifdef AFS_OSF_ENV
  afs_int32 afs_maxvcount = 0;	/* max number of vcache entries */
  afs_int32 afs_vcount = 0;	/* number of vcache in use now */
  #endif /* AFS_OSF_ENV */
--- 47,53 ----
  #include "afs/afs_cbqueue.h"
  #include "afs/afs_osidnlc.h"
  
! #if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
  afs_int32 afs_maxvcount = 0;	/* max number of vcache entries */
  afs_int32 afs_vcount = 0;	/* number of vcache in use now */
  #endif /* AFS_OSF_ENV */
***************
*** 63,70 ****
  /* Exported variables */
  afs_rwlock_t afs_xvcache;	/*Lock: alloc new stat cache entries */
  afs_lock_t afs_xvcb;		/*Lock: fids on which there are callbacks */
! struct vcache *freeVCList;	/*Free list for stat cache entries */
! struct vcache *Initial_freeVCList;	/*Initial list for above */
  struct afs_q VLRU;		/*vcache LRU */
  afs_int32 vcachegen = 0;
  unsigned int afs_paniconwarn = 0;
--- 63,72 ----
  /* Exported variables */
  afs_rwlock_t afs_xvcache;	/*Lock: alloc new stat cache entries */
  afs_lock_t afs_xvcb;		/*Lock: fids on which there are callbacks */
! #if !defined(AFS_LINUX22_ENV)
! static struct vcache *freeVCList;	/*Free list for stat cache entries */
! static struct vcache *Initial_freeVCList;	/*Initial list for above */
! #endif
  struct afs_q VLRU;		/*vcache LRU */
  afs_int32 vcachegen = 0;
  unsigned int afs_paniconwarn = 0;
***************
*** 151,159 ****
--- 153,163 ----
  	code = EBUSY;
  	goto bad;
      }
+ #if !defined(AFS_LINUX22_ENV)
      if (avc->nextfree || !avc->vlruq.prev || !avc->vlruq.next) {	/* qv afs.h */
  	refpanic("LRU vs. Free inconsistency");
      }
+ #endif
      avc->states |= CVFlushed;
      /* pull the entry out of the lruq and put it on the free list */
      QRemove(&avc->vlruq);
***************
*** 231,262 ****
      else
  	afs_evenZaps++;
  
! #if	!defined(AFS_OSF_ENV)
      /* put the entry in the free list */
      avc->nextfree = freeVCList;
      freeVCList = avc;
      if (avc->vlruq.prev || avc->vlruq.next) {
  	refpanic("LRU vs. Free inconsistency");
      }
  #else
      /* This should put it back on the vnode free list since usecount is 1 */
      afs_vcount--;
      vSetType(avc, VREG);
      if (VREFCOUNT(avc) > 0) {
  	VN_UNLOCK(AFSTOV(avc));
  	AFS_RELE(AFSTOV(avc));
      } else {
  	if (afs_norefpanic) {
  	    printf("flush vc refcnt < 1");
  	    afs_norefpanic++;
  	    (void)vgone(avc, VX_NOSLEEP, NULL);
  	    AFS_GLOCK();
  	    VN_UNLOCK(AFSTOV(avc));
  	} else
  	    osi_Panic("flush vc refcnt < 1");
      }
  #endif /* AFS_OSF_ENV */
-     avc->states |= CVFlushed;
      return 0;
  
    bad:
--- 235,270 ----
      else
  	afs_evenZaps++;
  
! #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      /* put the entry in the free list */
      avc->nextfree = freeVCList;
      freeVCList = avc;
      if (avc->vlruq.prev || avc->vlruq.next) {
  	refpanic("LRU vs. Free inconsistency");
      }
+     avc->states |= CVFlushed;
  #else
      /* This should put it back on the vnode free list since usecount is 1 */
      afs_vcount--;
      vSetType(avc, VREG);
      if (VREFCOUNT(avc) > 0) {
+ #if defined(AFS_OSF_ENV)
  	VN_UNLOCK(AFSTOV(avc));
+ #endif
  	AFS_RELE(AFSTOV(avc));
      } else {
  	if (afs_norefpanic) {
  	    printf("flush vc refcnt < 1");
  	    afs_norefpanic++;
+ #if defined(AFS_OSF_ENV)
  	    (void)vgone(avc, VX_NOSLEEP, NULL);
  	    AFS_GLOCK();
  	    VN_UNLOCK(AFSTOV(avc));
+ #endif
  	} else
  	    osi_Panic("flush vc refcnt < 1");
      }
  #endif /* AFS_OSF_ENV */
      return 0;
  
    bad:
***************
*** 599,607 ****
      int code, fv_slept;
  
      AFS_STATCNT(afs_NewVCache);
! #ifdef	AFS_OSF_ENV
! #ifdef	AFS_OSF30_ENV
!     if (afs_vcount >= afs_maxvcount) {
  #else
      /*
       * If we are using > 33 % of the total system vnodes for AFS vcache
--- 607,615 ----
      int code, fv_slept;
  
      AFS_STATCNT(afs_NewVCache);
! #if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
! #if defined(AFS_OSF30_ENV) || defined(AFS_LINUX22_ENV)
!     if (afs_vcount >= afs_maxvcount)
  #else
      /*
       * If we are using > 33 % of the total system vnodes for AFS vcache
***************
*** 610,617 ****
       * our usage is > afs_maxvcount, set elsewhere to 0.5*nvnode,
       * we _must_ free some -- no choice).
       */
!     if (((3 * afs_vcount) > nvnode) || (afs_vcount >= afs_maxvcount)) {
  #endif
  	struct afs_q *tq, *uq;
  	int i;
  	char *panicstr;
--- 618,626 ----
       * our usage is > afs_maxvcount, set elsewhere to 0.5*nvnode,
       * we _must_ free some -- no choice).
       */
!     if (((3 * afs_vcount) > nvnode) || (afs_vcount >= afs_maxvcount))
  #endif
+     {
  	struct afs_q *tq, *uq;
  	int i;
  	char *panicstr;
***************
*** 620,633 ****
  	for (tq = VLRU.prev; tq != &VLRU && anumber > 0; tq = uq) {
  	    tvc = QTOV(tq);
  	    uq = QPrev(tq);
! 	    if (tvc->states & CVFlushed)
  		refpanic("CVFlushed on VLRU");
! 	    else if (i++ > afs_maxvcount)
  		refpanic("Exceeded pool of AFS vnodes(VLRU cycle?)");
! 	    else if (QNext(uq) != tq)
  		refpanic("VLRU inconsistent");
! 	    else if (VREFCOUNT(tvc) < 1)
  		refpanic("refcnt 0 on VLRU");
  
  	    if (VREFCOUNT(tvc) == 1 && tvc->opens == 0
  		&& (tvc->states & CUnlinkedDel) == 0) {
--- 629,687 ----
  	for (tq = VLRU.prev; tq != &VLRU && anumber > 0; tq = uq) {
  	    tvc = QTOV(tq);
  	    uq = QPrev(tq);
! 	    if (tvc->states & CVFlushed) {
  		refpanic("CVFlushed on VLRU");
! 	    } else if (i++ > afs_maxvcount) {
  		refpanic("Exceeded pool of AFS vnodes(VLRU cycle?)");
! 	    } else if (QNext(uq) != tq) {
  		refpanic("VLRU inconsistent");
! 	    } else if (VREFCOUNT(tvc) < 1) {
  		refpanic("refcnt 0 on VLRU");
+ 	    }
+ 
+ #if defined(AFS_LINUX22_ENV)
+ 	    if (tvc != afs_globalVp && VREFCOUNT(tvc) > 1 && tvc->opens == 0) {
+                 struct dentry *dentry;
+                 struct list_head *cur, *head;
+                 AFS_FAST_HOLD(tvc);
+                 AFS_GUNLOCK();
+ #if defined(AFS_LINUX24_ENV)
+                 spin_lock(&dcache_lock);
+ #endif
+ 		head = &(AFSTOV(tvc))->i_dentry;
+ 
+ restart:
+                 cur = head;
+                 while ((cur = cur->next) != head) {
+                     dentry = list_entry(cur, struct dentry, d_alias);
+ 
+ 		    if (d_unhashed(dentry))
+ 			continue;
+ 
+ 		    dget_locked(dentry);
+ 
+ #if defined(AFS_LINUX24_ENV)
+ 		    spin_unlock(&dcache_lock);
+ #endif
+ 		    if (d_invalidate(dentry) == -EBUSY) {
+ 			dput(dentry);
+ 			/* perhaps lock and try to continue? (use cur as head?) */
+ 			goto inuse;
+ 		    }
+ 		    dput(dentry);
+ #if defined(AFS_LINUX24_ENV)
+ 		    spin_lock(&dcache_lock);
+ #endif
+ 		    goto restart;
+ 		}		    
+ #if defined(AFS_LINUX24_ENV)
+ 		spin_unlock(&dcache_lock);
+ #endif
+ 	    inuse:
+ 		AFS_GLOCK();
+ 		AFS_FAST_RELE(tvc);
+ 	    }
+ #endif
  
  	    if (VREFCOUNT(tvc) == 1 && tvc->opens == 0
  		&& (tvc->states & CUnlinkedDel) == 0) {
***************
*** 655,660 ****
--- 709,732 ----
  	}
      }
  
+ #if defined(AFS_LINUX22_ENV)
+ {
+     struct inode *ip;
+ 
+     AFS_GUNLOCK();
+     ip = new_inode(afs_globalVFS);
+     if (!ip)
+ 	osi_Panic("afs_NewVCache: no more inodes");
+     AFS_GLOCK();
+ #if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+     tvc = VTOAFS(ip);
+ #else
+     tvc = afs_osi_Alloc(sizeof(struct vcache));
+     ip->u.generic_ip = tvc;
+     tvc->v = ip;
+ #endif
+ }
+ #else
      AFS_GUNLOCK();
      if (getnewvnode(MOUNT_AFS, &Afs_vnodeops, &nvc)) {
  	/* What should we do ???? */
***************
*** 664,669 ****
--- 736,742 ----
  
      tvc = nvc;
      tvc->nextfree = NULL;
+ #endif
      afs_vcount++;
  #else /* AFS_OSF_ENV */
      /* pull out a free cache entry */
***************
*** 682,726 ****
  	    } else if (QNext(uq) != tq) {
  		refpanic("VLRU inconsistent");
  	    }
- #if defined(AFS_LINUX22_ENV)
- 	    if (tvc != afs_globalVp && VREFCOUNT(tvc) && tvc->opens == 0) {
-                 struct dentry *dentry;
-                 struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry;
-                 AFS_FAST_HOLD(tvc);
-                 AFS_GUNLOCK();
- 
- restart:
- #if defined(AFS_LINUX24_ENV)
-                 spin_lock(&dcache_lock);
- #endif
-                 cur = head;
-                 while ((cur = cur->next) != head) {
-                     dentry = list_entry(cur, struct dentry, d_alias);
- 
- 		    if (d_unhashed(dentry))
- 			continue;
- 
- 		    dget_locked(dentry);
- 
- #if defined(AFS_LINUX24_ENV)
- 		    spin_unlock(&dcache_lock);
- #endif
- 		    if (d_invalidate(dentry) == -EBUSY) {
- 			dput(dentry);
- 			/* perhaps lock and try to continue? (use cur as head?) */
- 			goto inuse;
- 		    }
- 		    dput(dentry);
- 		    goto restart;
- 		}		    
- #if defined(AFS_LINUX24_ENV)
- 		spin_unlock(&dcache_lock);
- #endif
- 	    inuse:
- 		AFS_GLOCK();
- 		AFS_FAST_RELE(tvc);
- 	    }
- #endif
  
  	    if (((VREFCOUNT(tvc) == 0) 
  #if defined(AFS_DARWIN_ENV) && !defined(UKERNEL) 
--- 755,760 ----
***************
*** 797,803 ****
  	panic("afs_NewVCache(): free vcache with vnode attached");
  #endif
  
! #if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV)
      memset((char *)tvc, 0, sizeof(struct vcache));
  #else
      tvc->uncred = 0;
--- 831,837 ----
  	panic("afs_NewVCache(): free vcache with vnode attached");
  #endif
  
! #if !defined(AFS_SGI_ENV) && !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      memset((char *)tvc, 0, sizeof(struct vcache));
  #else
      tvc->uncred = 0;
***************
*** 871,962 ****
      hzero(tvc->mapDV);
      tvc->truncPos = AFS_NOTRUNC;	/* don't truncate until we need to */
      hzero(tvc->m.DataVersion);	/* in case we copy it into flushDV */
- #if defined(AFS_LINUX22_ENV)
-     {
- 	struct inode *ip = AFSTOI(tvc);
- #if defined(AFS_LINUX24_ENV)
- 	struct address_space *mapping = &ip->i_data;
- #endif
- 
- #if defined(AFS_LINUX26_ENV)
- 	inode_init_once(ip);
- #else
- 	sema_init(&ip->i_sem, 1);
- 	INIT_LIST_HEAD(&ip->i_hash);
- 	INIT_LIST_HEAD(&ip->i_dentry);
- #if defined(AFS_LINUX24_ENV)
- 	sema_init(&ip->i_zombie, 1);
- 	init_waitqueue_head(&ip->i_wait);
- 	spin_lock_init(&ip->i_data.i_shared_lock);
- #ifdef STRUCT_ADDRESS_SPACE_HAS_PAGE_LOCK
- 	spin_lock_init(&ip->i_data.page_lock);
- #endif
- 	INIT_LIST_HEAD(&ip->i_data.clean_pages);
- 	INIT_LIST_HEAD(&ip->i_data.dirty_pages);
- 	INIT_LIST_HEAD(&ip->i_data.locked_pages);
- 	INIT_LIST_HEAD(&ip->i_dirty_buffers);
- #ifdef STRUCT_INODE_HAS_I_DIRTY_DATA_BUFFERS
- 	INIT_LIST_HEAD(&ip->i_dirty_data_buffers);
- #endif
- #ifdef STRUCT_INODE_HAS_I_DEVICES
- 	INIT_LIST_HEAD(&ip->i_devices);
- #endif
- #ifdef STRUCT_INODE_HAS_I_TRUNCATE_SEM
- 	init_rwsem(&ip->i_truncate_sem);
- #endif
- #ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
- 	init_rwsem(&ip->i_alloc_sem);
- #endif
- 
- #else /* AFS_LINUX22_ENV */
- 	sema_init(&ip->i_atomic_write, 1);
- 	init_waitqueue(&ip->i_wait);
- #endif
- #endif
- 
- #if defined(AFS_LINUX24_ENV)
- 	mapping->host = ip;
- 	ip->i_mapping = mapping;
- #ifdef STRUCT_ADDRESS_SPACE_HAS_GFP_MASK
- 	ip->i_data.gfp_mask = GFP_HIGHUSER;
- #endif
- #if defined(AFS_LINUX26_ENV)
- 	mapping_set_gfp_mask(mapping, GFP_HIGHUSER);
- 	{
- 	    extern struct backing_dev_info afs_backing_dev_info;
- 
- 	    mapping->backing_dev_info = &afs_backing_dev_info;
- 	}
- #endif
- #endif
  
! #if !defined(AFS_LINUX26_ENV)
! 	if (afs_globalVFS)
! 	    ip->i_dev = afs_globalVFS->s_dev;
! #else
! #ifdef STRUCT_INODE_HAS_I_SECURITY
! 	ip->i_security = NULL;
! 	if (security_inode_alloc(ip))
! 	    panic("Cannot allocate inode security");
! #endif
! #endif
! 	ip->i_sb = afs_globalVFS;
! 	put_inode_on_dummy_list(ip);
! #ifdef STRUCT_INODE_HAS_I_SB_LIST
! 	list_add(&ip->i_sb_list, &ip->i_sb->s_inodes);
! #endif
! #if defined(STRUCT_INODE_HAS_INOTIFY_LOCK) || defined(STRUCT_INODE_HAS_INOTIFY_SEM)
! 	INIT_LIST_HEAD(&ip->inotify_watches); 
! #if defined(STRUCT_INODE_HAS_INOTIFY_SEM) 
! 	sema_init(&ip->inotify_sem, 1); 
! #else
! 	spin_lock_init(&ip->inotify_lock); 
! #endif 
! #endif 
!     }
! #endif
! 
! #ifdef	AFS_OSF_ENV
      /* Hold it for the LRU (should make count 2) */
      VN_HOLD(AFSTOV(tvc));
  #else /* AFS_OSF_ENV */
--- 905,912 ----
      hzero(tvc->mapDV);
      tvc->truncPos = AFS_NOTRUNC;	/* don't truncate until we need to */
      hzero(tvc->m.DataVersion);	/* in case we copy it into flushDV */
  
! #if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
      /* Hold it for the LRU (should make count 2) */
      VN_HOLD(AFSTOV(tvc));
  #else /* AFS_OSF_ENV */
***************
*** 1040,1046 ****
--- 990,998 ----
  	tvc->mvstat = 2;
      if (afs_globalVFS == 0)
  	osi_Panic("afs globalvfs");
+ #if !defined(AFS_LINUX22_ENV)
      vSetVfsp(tvc, afs_globalVFS);
+ #endif
      vSetType(tvc, VREG);
  #ifdef	AFS_AIX_ENV
      tvc->v.v_vfsnext = afs_globalVFS->vfs_vnodes;	/* link off vfs */
***************
*** 1576,1585 ****
  	else			/* not found, add a new one if possible */
  	    afs_AddAxs(avc->Access, areq->uid, astat->CallerAccess);
      }
- #ifdef AFS_LINUX22_ENV
-     vcache2inode(avc);		/* Set the inode attr cache */
- #endif
- 
  }				/*afs_ProcessFS */
  
  
--- 1528,1533 ----
***************
*** 1709,1717 ****
      ObtainWriteLock(&tvc->lock, 54);
  
      if (tvc->states & CStatd) {
- #ifdef AFS_LINUX22_ENV
- 	vcache2inode(tvc);
- #endif
  	ReleaseWriteLock(&tvc->lock);
  	return tvc;
      }
--- 1657,1662 ----
***************
*** 2572,2581 ****
  	else
  	    afs_stats_cmperf.vremoteAccesses++;
      }
- #ifdef AFS_LINUX22_ENV
-     if (tvc && (tvc->states & CStatd))
- 	vcache2inode(tvc);	/* mainly to reset i_nlink */
- #endif
      return tvc;
  }				/*afs_FindVCache */
  
--- 2517,2522 ----
***************
*** 2730,2738 ****
  {
      register struct vcache *tvp;
      int i;
! #if	defined(AFS_OSF_ENV)
      if (!afs_maxvcount) {
! #if	defined(AFS_OSF30_ENV)
  	afs_maxvcount = max_vnodes / 2;	/* limit ourselves to half the total */
  #else
  	afs_maxvcount = nvnode / 2;	/* limit ourselves to half the total */
--- 2671,2681 ----
  {
      register struct vcache *tvp;
      int i;
! #if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
      if (!afs_maxvcount) {
! #if defined(AFS_LINUX22_ENV)
! 	afs_maxvcount = astatSize;	/* no particular limit on linux? */
! #elif defined(AFS_OSF30_ENV)
  	afs_maxvcount = max_vnodes / 2;	/* limit ourselves to half the total */
  #else
  	afs_maxvcount = nvnode / 2;	/* limit ourselves to half the total */
***************
*** 2748,2765 ****
      RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
      LOCK_INIT(&afs_xvcb, "afs_xvcb");
  
! #if	!defined(AFS_OSF_ENV)
! #ifdef AFS_LINUX26_ENV
!     printf("old style would have needed %d contiguous bytes\n", astatSize *
! 	   sizeof(struct vcache));
!     Initial_freeVCList = freeVCList = tvp = (struct vcache *)
! 	afs_osi_Alloc(sizeof(struct vcache));
!     for (i = 0; i < astatSize; i++) {
! 	tvp->nextfree = (struct vcache *) afs_osi_Alloc(sizeof(struct vcache));
! 	tvp = tvp->nextfree;
!     }
!     tvp->nextfree = NULL;
! #else
      /* Allocate and thread the struct vcache entries */
      tvp = (struct vcache *)afs_osi_Alloc(astatSize * sizeof(struct vcache));
      memset((char *)tvp, 0, sizeof(struct vcache) * astatSize);
--- 2691,2697 ----
      RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
      LOCK_INIT(&afs_xvcb, "afs_xvcb");
  
! #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      /* Allocate and thread the struct vcache entries */
      tvp = (struct vcache *)afs_osi_Alloc(astatSize * sizeof(struct vcache));
      memset((char *)tvp, 0, sizeof(struct vcache) * astatSize);
***************
*** 2774,2780 ****
      pin((char *)tvp, astatSize * sizeof(struct vcache));	/* XXX */
  #endif
  #endif
- #endif
  
  #if defined(AFS_SGI_ENV)
      for (i = 0; i < astatSize; i++) {
--- 2706,2711 ----
***************
*** 2884,2909 ****
      }
      afs_cbrSpace = 0;
  
- #ifdef AFS_LINUX26_ENV
-     {
- 	struct vcache *tvp = Initial_freeVCList;
- 	while (tvp) {
- 	    struct vcache *next = tvp->nextfree;
- 	    
- 	    afs_osi_Free(tvp, sizeof(struct vcache));
- 	    tvp = next;
- 	}
-     }
- #else
  #ifdef  KERNEL_HAVE_PIN
      unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
! #if	!defined(AFS_OSF_ENV)
      afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
- #endif
  
! #if	!defined(AFS_OSF_ENV)
      freeVCList = Initial_freeVCList = 0;
  #endif
      RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
--- 2815,2828 ----
      }
      afs_cbrSpace = 0;
  
  #ifdef  KERNEL_HAVE_PIN
      unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
! #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
  
! #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      freeVCList = Initial_freeVCList = 0;
  #endif
      RWLOCK_INIT(&afs_xvcache, "afs_xvcache");
Index: openafs/src/afs/sysincludes.h
diff -c openafs/src/afs/sysincludes.h:1.28.2.6 openafs/src/afs/sysincludes.h:1.28.2.7
*** openafs/src/afs/sysincludes.h:1.28.2.6	Sun Apr  3 14:18:54 2005
--- openafs/src/afs/sysincludes.h	Mon Jul 11 15:13:47 2005
***************
*** 74,86 ****
   */
  #ifndef _LINUX_CODA_FS_I
  #define _LINUX_CODA_FS_I
! #endif
  #define _CFS_HEADER_
  struct coda_inode_info {
  };
  #define _LINUX_XFS_FS_I
  struct xfs_inode_info {
  };
  #include <asm/uaccess.h>
  #include <linux/list.h>
  #include <linux/dcache.h>
--- 74,89 ----
   */
  #ifndef _LINUX_CODA_FS_I
  #define _LINUX_CODA_FS_I
! #define _CODA_HEADER_
  #define _CFS_HEADER_
  struct coda_inode_info {
  };
+ #endif
+ #ifndef _LINUX_XFS_FS_I
  #define _LINUX_XFS_FS_I
  struct xfs_inode_info {
  };
+ #endif
  #include <asm/uaccess.h>
  #include <linux/list.h>
  #include <linux/dcache.h>
Index: openafs/src/afs/FBSD/osi_vfsops.c
diff -c openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.4 openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.5
*** openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.4	Mon May 23 17:26:40 2005
--- openafs/src/afs/FBSD/osi_vfsops.c	Mon Jul 11 15:27:27 2005
***************
*** 2,8 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vfsops.c,v 1.16.2.4 2005/05/23 21:26:40 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 2,8 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vfsops.c,v 1.16.2.5 2005/07/11 19:27:27 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 155,161 ****
  }
  
  int
! #ifdef AFS_FBSD53_ENV
  afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
  #else
  afs_root(struct mount *mp, struct vnode **vpp)
--- 155,163 ----
  }
  
  int
! #if defined(AFS_FBSD60_ENV)
! afs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
! #elif defined(AFS_FBSD53_ENV)
  afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
  #else
  afs_root(struct mount *mp, struct vnode **vpp)
***************
*** 224,230 ****
  	*vpp = vp;
      }
  
!     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, *vpp,
  	       ICL_TYPE_INT32, error);
      AFS_GUNLOCK();
      crfree(cr);
--- 226,232 ----
  	*vpp = vp;
      }
  
!     afs_Trace2(afs_iclSetp, CM_TRACE_VFSROOT, ICL_TYPE_POINTER, tvp ? AFSTOV(tvp) : NULL,
  	       ICL_TYPE_INT32, error);
      AFS_GUNLOCK();
      crfree(cr);
Index: openafs/src/afs/LINUX/osi_file.c
diff -c openafs/src/afs/LINUX/osi_file.c:1.19.2.7 openafs/src/afs/LINUX/osi_file.c:1.19.2.8
*** openafs/src/afs/LINUX/osi_file.c:1.19.2.7	Sun Apr 24 16:12:22 2005
--- openafs/src/afs/LINUX/osi_file.c	Mon Jul 11 15:29:56 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.19.2.7 2005/04/24 20:12:22 shadow Exp $");
  
  #ifdef AFS_LINUX24_ENV
  #include "h/module.h" /* early to avoid printf->printk mapping */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.19.2.8 2005/07/11 19:29:56 shadow Exp $");
  
  #ifdef AFS_LINUX24_ENV
  #include "h/module.h" /* early to avoid printf->printk mapping */
***************
*** 31,60 ****
  #endif
  extern struct super_block *afs_cacheSBp;
  
! /*#if defined(AFS_LINUX26_ENV) && (defined(CONFIG_EXPORTFS) || defined(CONFIG_EXPORTFS_MODULE))
! #define HAS_UFSOPEN
! extern struct export_operations export_op_default;
! 
! #define CALL(ops,fun) ((ops->fun)?(ops->fun):export_op_default.fun)
! 
! XXX something based on encode_fh / find_exported_dentry 
! This would require us to store an inode -> fh mapping (acquired by
! afs_InitCacheFile or lookupname), but probably solves the resiserfs issue.
! #elif... */
! 
! #if defined(AFS_LINUX24_ENV) && !defined(HAS_UFSOPEN)
! #define HAS_UFSOPEN
  void *
  osi_UFSOpen(afs_int32 ainode)
  {
      register struct osi_file *afile = NULL;
      extern int cacheDiskType;
      struct inode *tip = NULL;
- #ifndef AFS_LINUX26_ENV
-     afs_int32 code = 0;
-     struct list_head *lp = NULL;
-     struct dentry *tdp = NULL;
- #endif
      struct dentry *dp = NULL;
      struct file *filp = NULL;
      AFS_STATCNT(osi_UFSOpen);
--- 31,43 ----
  #endif
  extern struct super_block *afs_cacheSBp;
  
! #if defined(AFS_LINUX26_ENV) 
  void *
  osi_UFSOpen(afs_int32 ainode)
  {
      register struct osi_file *afile = NULL;
      extern int cacheDiskType;
      struct inode *tip = NULL;
      struct dentry *dp = NULL;
      struct file *filp = NULL;
      AFS_STATCNT(osi_UFSOpen);
***************
*** 79,111 ****
  	osi_Panic("Can't get inode %d\n", ainode);
      tip->i_flags |= MS_NOATIME;	/* Disable updating access times. */
  
- #ifdef AFS_LINUX26_ENV
      dp = d_alloc_anon(tip);
- #else
-     spin_lock(&dcache_lock);
-     for (lp = tip->i_dentry.next;  lp != &tip->i_dentry; lp = lp->next) {
-         tdp = list_entry(lp, struct dentry, d_alias);
-         if ( !(tdp->d_flags & DCACHE_NFSD_DISCONNECTED)) {
-              dget_locked(tdp);
-              dp=tdp;
-              break;
-         }
-     }
-     if (tdp && !dp) {
-              dget_locked(tdp);
-              dp=tdp;
-     }
-     tdp = NULL;
-     spin_unlock(&dcache_lock);
-     if (!dp)
-            dp = d_alloc_root(tip);
-     iput(tip);
- #endif
      if (!dp) 
             osi_Panic("Can't get dentry for inode %d\n", ainode);          
  
      filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
- 
      if (IS_ERR(filp))
  	osi_Panic("Can't open inode %d\n", ainode);
      afile->filp = filp;
--- 62,72 ----
***************
*** 116,124 ****
      afile->inum = ainode;	/* for hint validity checking */
      return (void *)afile;
  }
! #endif
! 
! #if !defined(HAS_UFSOPEN)
  void *
  osi_UFSOpen(afs_int32 ainode)
  {
--- 77,83 ----
      afile->inum = ainode;	/* for hint validity checking */
      return (void *)afile;
  }
! #else
  void *
  osi_UFSOpen(afs_int32 ainode)
  {
***************
*** 152,160 ****
      FILE_INODE(filp) = tip;
      tip->i_flags |= MS_NOATIME;	/* Disable updating access times. */
      filp->f_flags = O_RDWR;
- #if defined(AFS_LINUX26_ENV)
-     filp->f_mapping = tip->i_mapping;
- #endif
  #if defined(AFS_LINUX24_ENV)
      filp->f_mode = FMODE_READ|FMODE_WRITE;
      filp->f_op = fops_get(tip->i_fop);
--- 111,116 ----
***************
*** 194,207 ****
      return code;
  }
  
! #ifdef AFS_LINUX24_ENV
  int
  osi_UFSClose(register struct osi_file *afile)
  {
      AFS_STATCNT(osi_Close);
      if (afile) {
  	if (OSIFILE_INODE(afile)) {
!              filp_close(afile->filp, NULL);
  	}
      }
  
--- 150,163 ----
      return code;
  }
  
! #ifdef AFS_LINUX26_ENV
  int
  osi_UFSClose(register struct osi_file *afile)
  {
      AFS_STATCNT(osi_Close);
      if (afile) {
  	if (OSIFILE_INODE(afile)) {
! 	    filp_close(afile->filp, NULL);
  	}
      }
  
Index: openafs/src/afs/LINUX/osi_machdep.h
diff -c openafs/src/afs/LINUX/osi_machdep.h:1.22.2.9 openafs/src/afs/LINUX/osi_machdep.h:1.22.2.11
*** openafs/src/afs/LINUX/osi_machdep.h:1.22.2.9	Sun May  8 01:48:40 2005
--- openafs/src/afs/LINUX/osi_machdep.h	Mon Jul 11 15:29:56 2005
***************
*** 74,112 ****
  #undef gop_lookupname
  #define gop_lookupname osi_lookupname
  
! #define osi_vnhold(v, n) do { VN_HOLD(AFSTOV(v)); } while (0)
! 
! #if defined(AFS_LINUX24_ENV)
! #define VN_HOLD(V) atomic_inc(&((vnode_t *) V)->i_count)
! #else
! #define VN_HOLD(V) ((vnode_t *) V)->i_count++
! #endif
! 
! #if defined(AFS_LINUX26_ENV)
! #define VN_RELE(V) iput((struct inode *) V)
! #else
! #define VN_RELE(V) osi_iput((struct inode *) V)
! #endif
! 
! #define osi_AllocSmall afs_osi_Alloc
! #define osi_FreeSmall afs_osi_Free
  
  #define afs_suser(x) capable(CAP_SYS_ADMIN)
  #define wakeup afs_osi_Wakeup
  
  #undef vType
! #define vType(V) ((( vnode_t *)V)->v_type & S_IFMT)
  
- /* IsAfsVnode relies on the fast that there is only one vnodeop table for AFS.
-  * Use the same type of test as other OS's for compatibility.
-  */
  #undef IsAfsVnode
! extern struct vnodeops afs_file_iops, afs_dir_iops, afs_symlink_iops;
! #define IsAfsVnode(v) (((v)->v_op == &afs_file_iops) ? 1 : \
! 			((v)->v_op == &afs_dir_iops) ? 1 : \
! 			((v)->v_op == &afs_symlink_iops))
  #undef SetAfsVnode
! #define SetAfsVnode(v)
  
  /* We often need to pretend we're in user space to get memory transfers
   * right for the kernel calls we use.
--- 74,95 ----
  #undef gop_lookupname
  #define gop_lookupname osi_lookupname
  
! #define osi_vnhold(V, N) do { VN_HOLD(AFSTOV(V)); } while (0)
! #define VN_HOLD(V) osi_Assert(igrab((V)) == (V))
! #define VN_RELE(V) iput((V))
  
  #define afs_suser(x) capable(CAP_SYS_ADMIN)
  #define wakeup afs_osi_Wakeup
  
  #undef vType
! #define vType(V) ((AFSTOV((V)))->i_mode & S_IFMT)
! #undef vSetType
! #define vSetType(V, type) AFSTOV((V))->i_mode = ((type) | (AFSTOV((V))->i_mode & ~S_IFMT))	/* preserve mode */
  
  #undef IsAfsVnode
! #define IsAfsVnode(V) ((V)->i_sb == afs_globalVFS)	/* test superblock instead */
  #undef SetAfsVnode
! #define SetAfsVnode(V)					/* unnecessary */
  
  /* We often need to pretend we're in user space to get memory transfers
   * right for the kernel calls we use.
***************
*** 183,189 ****
  /* Get/set the inode in the osifile struct. */
  #define FILE_INODE(F) (F)->f_dentry->d_inode
  
! #ifdef AFS_LINUX24_ENV
  #define OSIFILE_INODE(a) FILE_INODE((a)->filp)
  #else
  #define OSIFILE_INODE(a) FILE_INODE(&(a)->file)
--- 166,172 ----
  /* Get/set the inode in the osifile struct. */
  #define FILE_INODE(F) (F)->f_dentry->d_inode
  
! #ifdef AFS_LINUX26_ENV
  #define OSIFILE_INODE(a) FILE_INODE((a)->filp)
  #else
  #define OSIFILE_INODE(a) FILE_INODE(&(a)->file)
Index: openafs/src/afs/LINUX/osi_misc.c
diff -c openafs/src/afs/LINUX/osi_misc.c:1.34.2.8 openafs/src/afs/LINUX/osi_misc.c:1.34.2.10
*** openafs/src/afs/LINUX/osi_misc.c:1.34.2.8	Wed Apr 27 23:11:51 2005
--- openafs/src/afs/LINUX/osi_misc.c	Mon Jul 11 15:29:56 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_misc.c,v 1.34.2.8 2005/04/28 03:11:51 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.10 2005/07/11 19:29:56 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 141,147 ****
  int
  osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
  {
! #ifdef AFS_LINUX24_ENV
      struct file *filp = osifile->filp;
  #else
      struct file *filp = &osifile->file;
--- 141,147 ----
  int
  osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw)
  {
! #ifdef AFS_LINUX26_ENV
      struct file *filp = osifile->filp;
  #else
      struct file *filp = &osifile->file;
***************
*** 324,477 ****
  #endif
  }
  
! /* Free all the pages on any of the vnodes in the vlru. Must be done before
!  * freeing all memory.
   */
  void
  osi_linux_free_inode_pages(void)
  {
      int i;
!     struct vcache *tvc;
!     struct inode *ip;
      extern struct vcache *afs_vhashT[VCSIZE];
  
      for (i = 0; i < VCSIZE; i++) {
! 	for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
! 	    ip = AFSTOI(tvc);
! #if defined(AFS_LINUX24_ENV)
! 	    if (ip->i_data.nrpages) {
! #else
! 	    if (ip->i_nrpages) {
! #endif
! #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
! 		truncate_inode_pages(&ip->i_data, 0);
! #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
! 		truncate_inode_pages(ip, 0);
! #else
! 		invalidate_inode_pages(ip);
! #endif
! #if defined(AFS_LINUX24_ENV)
! 		if (ip->i_data.nrpages) {
! #else
! 		if (ip->i_nrpages) {
! #endif
! 		    printf("Failed to invalidate all pages on inode 0x%lx\n",
! 			   (unsigned long)ip);
! 		}
! 	    }
! 	}
!     }
! }
! 
! void
! osi_clear_inode(struct inode *ip)
! {
!     cred_t *credp = crref();
!     struct vcache *vcp = ITOAFS(ip);
! 
! #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);
!     ip->i_nlink = 0;		/* iput checks this after calling this routine. */
! #ifdef I_CLEAR
!     ip->i_state = I_CLEAR;
! #endif
!     ReleaseWriteLock(&vcp->lock);
!     crfree(credp);
! }
! 
! #if !defined(AFS_LINUX26_ENV)
! /* iput an inode. Since we still have a separate inode pool, we don't want
!  * to call iput on AFS inodes, since they would then end up on Linux's
!  * inode_unsed list.
!  */
! void
! osi_iput(struct inode *ip)
! {
!     extern struct vfs *afs_globalVFS;
! 
!     AFS_GLOCK();
! 
!     if (afs_globalVFS && ip->i_sb != afs_globalVFS)
! 	osi_Panic("IPUT Not an afs inode\n");
! 
! #if defined(AFS_LINUX24_ENV)
!     if (atomic_read(&ip->i_count) == 0)
! #else
!     if (ip->i_count == 0)
! #endif
! 	osi_Panic("IPUT Bad refCount %d on inode 0x%x\n",
! #if defined(AFS_LINUX24_ENV)
! 		  atomic_read(&ip->i_count),
! #else
! 		  ip->i_count,
! #endif
! 				ip);
! 
! #if defined(AFS_LINUX24_ENV)
!     if (atomic_dec_and_test(&ip->i_count))
! #else
!     if (!--ip->i_count)
! #endif
! 					   {
! 	osi_clear_inode(ip);
! 	ip->i_state = 0;
!     }
!     AFS_GUNLOCK();
! }
! #endif
! 
! /* check_bad_parent() : Checks if this dentry's vcache is a root vcache
!  * that has its mvid (parent dir's fid) pointer set to the wrong directory
!  * due to being mounted in multiple points at once. If so, check_bad_parent()
!  * calls afs_lookup() to correct the vcache's mvid, as well as the volume's
!  * dotdotfid and mtpoint fid members.
!  * Parameters:
!  *  dp - dentry to be checked.
!  * Return Values:
!  *  None.
!  * Sideeffects:
!  *   This dentry's vcache's mvid will be set to the correct parent directory's
!  *   fid.
!  *   This root vnode's volume will have its dotdotfid and mtpoint fids set
!  *    to the correct parent and mountpoint fids.
!  */
! 
! void
! check_bad_parent(struct dentry *dp)
! {
!     cred_t *credp;
!     struct vcache *vcp = ITOAFS(dp->d_inode), *avc = NULL;
!     struct vcache *pvc = ITOAFS(dp->d_parent->d_inode);
! 
!     if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) {	/* bad parent */
! 	credp = crref();
! 
! 
! 	/* force a lookup, so vcp->mvid is fixed up */
! 	afs_lookup(pvc, dp->d_name.name, &avc, credp);
! 	if (!avc || vcp != avc) {	/* bad, very bad.. */
! 	    afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING,
! 		       "check_bad_parent: bad pointer returned from afs_lookup origvc newvc dentry",
! 		       ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc,
! 		       ICL_TYPE_POINTER, dp);
  	}
- 	if (avc)
- 	    AFS_RELE(avc);
- 	crfree(credp);
      }
-     /* if bad parent */
-     return;
  }
  
  struct task_struct *rxk_ListenerTask;
--- 324,351 ----
  #endif
  }
  
! /* osi_linux_free_inode_pages
!  *
!  * Free all vnodes remaining in the afs hash.  Must be done before
!  * shutting down afs and freeing all memory.
   */
  void
  osi_linux_free_inode_pages(void)
  {
      int i;
!     struct vcache *tvc, *nvc;
      extern struct vcache *afs_vhashT[VCSIZE];
  
      for (i = 0; i < VCSIZE; i++) {
! 	for (tvc = afs_vhashT[i]; tvc; ) {
! 	    int slept;
! 	
! 	    nvc = tvc->hnext;
! 	    if (afs_FlushVCache(tvc, &slept))		/* slept always 0 for linux? */
! 		printf("Failed to invalidate all pages on inode 0x%p\n", tvc);
! 	    tvc = nvc;
  	}
      }
  }
  
  struct task_struct *rxk_ListenerTask;
Index: openafs/src/afs/LINUX/osi_module.c
diff -c openafs/src/afs/LINUX/osi_module.c:1.52.2.18 openafs/src/afs/LINUX/osi_module.c:1.52.2.19
*** openafs/src/afs/LINUX/osi_module.c:1.52.2.18	Mon May 30 01:28:19 2005
--- openafs/src/afs/LINUX/osi_module.c	Mon Jul 11 15:29:56 2005
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.18 2005/05/30 05:28:19 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.19 2005/07/11 19:29:56 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
***************
*** 342,348 ****
  init_module(void)
  #endif
  {
!     int e;
      RWLOCK_INIT(&afs_xosi, "afs_xosi");
  
  #if !defined(AFS_LINUX24_ENV)
--- 342,348 ----
  init_module(void)
  #endif
  {
!     int err;
      RWLOCK_INIT(&afs_xosi, "afs_xosi");
  
  #if !defined(AFS_LINUX24_ENV)
***************
*** 360,367 ****
  
      osi_Init();
  
!     e = osi_syscall_init();
!     if (e) return e;
      register_filesystem(&afs_fs_type);
      osi_sysctl_init();
  #ifdef AFS_LINUX24_ENV
--- 360,371 ----
  
      osi_Init();
  
!     err = osi_syscall_init();
!     if (err)
! 	return err;
!     err = afs_init_inodecache();
!     if (err)
! 	return err;
      register_filesystem(&afs_fs_type);
      osi_sysctl_init();
  #ifdef AFS_LINUX24_ENV
***************
*** 383,389 ****
      osi_syscall_clean();
      unregister_filesystem(&afs_fs_type);
  
!     osi_linux_free_inode_pages();	/* Invalidate all pages using AFS inodes. */
      osi_linux_free_afs_memory();
  
  #ifdef AFS_LINUX24_ENV
--- 387,393 ----
      osi_syscall_clean();
      unregister_filesystem(&afs_fs_type);
  
!     afs_destroy_inodecache();
      osi_linux_free_afs_memory();
  
  #ifdef AFS_LINUX24_ENV
Index: openafs/src/afs/LINUX/osi_prototypes.h
diff -c openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.6 openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.7
*** openafs/src/afs/LINUX/osi_prototypes.h:1.6.2.6	Sun Apr 24 16:11:15 2005
--- openafs/src/afs/LINUX/osi_prototypes.h	Mon Jul 11 15:29:56 2005
***************
*** 37,43 ****
  extern int osi_rdwr(struct osi_file *osifile, uio_t * uiop, int rw);
  extern void afs_osi_SetTime(osi_timeval_t * tvp);
  extern void osi_linux_free_inode_pages(void);
- extern void check_bad_parent(struct dentry *dp);
  
  /* osi_probe.c */
  extern void *osi_find_syscall_table(int which);
--- 37,42 ----
***************
*** 61,72 ****
  			    struct AFS_UCRED *acred);
  
  /* 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_ */
--- 60,70 ----
  			    struct AFS_UCRED *acred);
  
  /* osi_vfsops.c */
  extern void vattr2inode(struct inode *ip, struct vattr *vp);
+ extern int afs_init_inodecache(void);
+ extern void afs_destroy_inodecache(void);
  
  /* osi_vnodeops.c */
! extern void afs_fill_inode(struct inode *ip, struct vattr *vattr);
  
  #endif /* _OSI_PROTO_H_ */
Index: openafs/src/afs/LINUX/osi_sysctl.c
diff -c openafs/src/afs/LINUX/osi_sysctl.c:1.7.2.1 openafs/src/afs/LINUX/osi_sysctl.c:1.7.2.2
*** openafs/src/afs/LINUX/osi_sysctl.c:1.7.2.1	Sun May  8 01:04:14 2005
--- openafs/src/afs/LINUX/osi_sysctl.c	Tue Jun 21 16:13:50 2005
***************
*** 1,7 ****
  /*
   * osi_sysctl.c: Linux sysctl interface to OpenAFS
   *
!  * $Id: osi_sysctl.c,v 1.7.2.1 2005/05/08 05:04:14 shadow Exp $
   *
   * Written Jan 30, 2002 by Kris Van Hees (Sine Nomine Associates)
   */
--- 1,7 ----
  /*
   * osi_sysctl.c: Linux sysctl interface to OpenAFS
   *
!  * $Id: osi_sysctl.c,v 1.7.2.2 2005/06/21 20:13:50 shadow Exp $
   *
   * Written Jan 30, 2002 by Kris Van Hees (Sine Nomine Associates)
   */
***************
*** 20,30 ****
  extern afs_int32 hm_retry_RO;
  extern afs_int32 hm_retry_RW;
  extern afs_int32 hm_retry_int;
- extern afs_int32 afs_blocksUsed_0;
- extern afs_int32 afs_blocksUsed_1;
- extern afs_int32 afs_blocksUsed_2;
- extern afs_int32 afs_pct1;
- extern afs_int32 afs_pct2;
  
  #ifdef CONFIG_SYSCTL
  static struct ctl_table_header *afs_sysctl = NULL;
--- 20,25 ----
***************
*** 54,87 ****
       &afs_bkvolpref, sizeof(afs_int32), 0644, NULL,
       &proc_dointvec}
      ,
-     {7, "afs_blocksUsed",
-      &afs_blocksUsed, sizeof(afs_int32), 0444, NULL,
-      &proc_dointvec}
-     ,
-     {8, "afs_blocksUsed_0",
-      &afs_blocksUsed_0, sizeof(afs_int32), 0644, NULL,
-      &proc_dointvec}
-     ,
-     {9, "afs_blocksUsed_1",
-      &afs_blocksUsed_1, sizeof(afs_int32), 0644, NULL,
-      &proc_dointvec}
-     ,
-     {10, "afs_blocksUsed_2",
-      &afs_blocksUsed_2, sizeof(afs_int32), 0644, NULL,
-      &proc_dointvec}
-     ,
-     {11, "afs_pct1",
-      &afs_pct1, sizeof(afs_int32), 0644, NULL,
-      &proc_dointvec}
-     ,
-     {12, "afs_pct2",
-      &afs_pct2, sizeof(afs_int32), 0644, NULL,
-      &proc_dointvec}
-     ,
-     {13, "afs_cacheBlocks",
-      &afs_cacheBlocks, sizeof(afs_int32), 0644, NULL,
-      &proc_dointvec}
-     ,
      {0}
  };
  
--- 49,54 ----
Index: openafs/src/afs/LINUX/osi_vfs.hin
diff -c openafs/src/afs/LINUX/osi_vfs.hin:1.6.2.1 openafs/src/afs/LINUX/osi_vfs.hin:1.6.2.2
*** openafs/src/afs/LINUX/osi_vfs.hin:1.6.2.1	Tue Dec  7 01:12:13 2004
--- openafs/src/afs/LINUX/osi_vfs.hin	Mon Jul 11 15:29:56 2005
***************
*** 9,47 ****
  
  /*
   * Linux interpretations of vnode and vfs structs.
-  *
-  * The Linux "inode" has been abstracted to the fs independent part to avoid
-  * wasting 100+bytes per vnode.
   */
  
  #ifndef OSI_VFS_H_
  #define OSI_VFS_H_
  
- #if !defined(AFS_LINUX26_ENV)
- /* The vnode should match the current implementation of the fs independent
-  * part of the Linux inode.
-  */
- /* The first cut is to continue to use a separate vnode pool. */
- /* LINUX VNODE INCLUDED BELOW -- DO NOT MODIFY */
- 
- typedef struct vnode vnode_t;
- #else
  typedef struct inode vnode_t;
  #define vnode inode
- #endif
  
! /* Map vnode fields to inode fields. */
  #define i_number	i_ino
  #define v_count		i_count
  #define v_op		i_op
- #if defined(AFS_LINUX24_ENV)
  #define v_fop           i_fop
- #endif
  #define v_type		i_mode
  #define v_vfsp		i_sb
! #define vfs_vnodecovered s_covered
  
! /* v_type bits map to mode bits: */
  #define VNON 0
  #define VREG S_IFREG
  #define VDIR S_IFDIR
--- 9,32 ----
  
  /*
   * Linux interpretations of vnode and vfs structs.
   */
  
  #ifndef OSI_VFS_H_
  #define OSI_VFS_H_
  
  typedef struct inode vnode_t;
  #define vnode inode
  
! /* Map vnode fields to inode fields */
  #define i_number	i_ino
  #define v_count		i_count
  #define v_op		i_op
  #define v_fop           i_fop
  #define v_type		i_mode
  #define v_vfsp		i_sb
! #define v_data		u.generic_ip
  
! /* v_type bits map to mode bits */
  #define VNON 0
  #define VREG S_IFREG
  #define VDIR S_IFDIR
***************
*** 58,72 ****
  #define FWRITE	O_WRONLY|O_RDWR|O_APPEND
  #define FTRUNC	O_TRUNC
  
- 
  #define IO_APPEND O_APPEND
  #define FSYNC O_SYNC
  
! #define VTOI(V)  ((struct inode*)V)
  #define VFS_STATFS(V, S) ((V)->s_op->statfs)((V), (S), sizeof(*(S)))
  
- 
- 
  /* Various mode bits */
  #define VWRITE	S_IWUSR
  #define VREAD	S_IRUSR
--- 43,54 ----
  #define FWRITE	O_WRONLY|O_RDWR|O_APPEND
  #define FTRUNC	O_TRUNC
  
  #define IO_APPEND O_APPEND
  #define FSYNC O_SYNC
  
! #define VTOI(V)	(V)
  #define VFS_STATFS(V, S) ((V)->s_op->statfs)((V), (S), sizeof(*(S)))
  
  /* Various mode bits */
  #define VWRITE	S_IWUSR
  #define VREAD	S_IRUSR
***************
*** 74,80 ****
  #define VSUID	S_ISUID
  #define VSGID	S_ISGID
  
- 
  #define vfs super_block
  
  typedef struct vattr {
--- 56,61 ----
***************
*** 97,103 ****
  
  #define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
  
- 
- #define vnodeops inode_operations
- 
  #endif /* OSI_VFS_H_ */
--- 78,81 ----
Index: openafs/src/afs/LINUX/osi_vfsops.c
diff -c openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.4 openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.6
*** openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.4	Sun Jun  5 11:34:42 2005
--- openafs/src/afs/LINUX/osi_vfsops.c	Mon Jul 11 15:29:56 2005
***************
*** 16,22 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.4 2005/06/05 15:34:42 shadow Exp $");
  
  #define __NO_VERSION__		/* don't define kernel_version in module.h */
  #include <linux/module.h> /* early to avoid printf->printk mapping */
--- 16,22 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.6 2005/07/11 19:29:56 shadow Exp $");
  
  #define __NO_VERSION__		/* don't define kernel_version in module.h */
  #include <linux/module.h> /* early to avoid printf->printk mapping */
***************
*** 46,52 ****
  
  /* Forward declarations */
  static void iattr2vattr(struct vattr *vattrp, struct iattr *iattrp);
- static void update_inode_cache(struct inode *ip, struct vattr *vp);
  static int afs_root(struct super_block *afsp);
  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);
--- 46,51 ----
***************
*** 180,202 ****
  	if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) {
  	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
  	    if (tvp) {
! 		extern struct inode_operations afs_dir_iops;
! #if defined(AFS_LINUX24_ENV)
! 		extern struct file_operations afs_dir_fops;
! #endif
  
! 		/* "/afs" is a directory, reset inode ops accordingly. */
! 		AFSTOV(tvp)->v_op = &afs_dir_iops;
! #if defined(AFS_LINUX24_ENV)
! 		AFSTOV(tvp)->v_fop = &afs_dir_fops;
! #endif
  
  		/* setup super_block and mount point inode. */
  		afs_globalVp = tvp;
  #if defined(AFS_LINUX24_ENV)
! 		afsp->s_root = d_alloc_root(AFSTOI(tvp));
  #else
! 		afsp->s_root = d_alloc_root(AFSTOI(tvp), NULL);
  #endif
  		afsp->s_root->d_op = &afs_dentry_operations;
  	    } else
--- 179,196 ----
  	if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) {
  	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
  	    if (tvp) {
! 		struct inode *ip = AFSTOV(tvp);
! 		struct vattr vattr;
  
! 		afs_getattr(tvp, &vattr, credp);
! 		afs_fill_inode(ip, &vattr);
  
  		/* setup super_block and mount point inode. */
  		afs_globalVp = tvp;
  #if defined(AFS_LINUX24_ENV)
! 		afsp->s_root = d_alloc_root(ip);
  #else
! 		afsp->s_root = d_alloc_root(ip, NULL);
  #endif
  		afsp->s_root->d_op = &afs_dentry_operations;
  	    } else
***************
*** 220,330 ****
  afs_notify_change(struct dentry *dp, struct iattr *iattrp)
  {
      struct vattr vattr;
-     int code;
      cred_t *credp = crref();
      struct inode *ip = dp->d_inode;
  
-     AFS_GLOCK();
- #if defined(AFS_LINUX26_ENV)
-     lock_kernel();
- #endif
      VATTR_NULL(&vattr);
      iattr2vattr(&vattr, iattrp);	/* Convert for AFS vnodeops call. */
-     update_inode_cache(ip, &vattr);
-     code = afs_setattr(ITOAFS(ip), &vattr, credp);
-     afs_CopyOutAttrs(ITOAFS(ip), &vattr);
-     /* Note that the inode may still not have all the correct info. But at
-      * least we've got the newest version of what was supposed to be set.
-      */
  
  #if defined(AFS_LINUX26_ENV)
!     unlock_kernel();
  #endif
      AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
  
  
! /* This list is simply used to initialize the i_list member of the
!  * linux inode. This stops linux inode syncing code from choking on our
!  * inodes.
!  */
! static LIST_HEAD(dummy_inode_list);
  
  
- /* This is included for documentation only. */
- /* afs_write_inode
-  * Used to flush in core inode to disk. We don't need to do this. Top level
-  * write_inode() routine will clear i_dirt. If this routine is in the table,
-  * it's expected to do the cleaning and clear i_dirt.
-  * 
-  * 9/24/99: This is what we thought until we discovered msync() does end up calling
-  * this function to sync a single inode to disk. msync() only flushes selective
-  * pages to disk. So it needs an inode syncing function to update metadata when it
-  * 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
! afs_write_inode(struct inode *ip)
! #endif
  {
!     list_del(&ip->i_list);
!     /* and put it back on our dummy list. */
!     put_inode_on_dummy_list(ip);
  
!     /* 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
  }
  
! #if defined(AFS_LINUX26_ENV)
! static void
! afs_drop_inode(struct inode *ip)
  {
! 	generic_delete_inode(ip);
! 	AFS_GUNLOCK();		/* locked by afs_delete_inode() */
  }
  #endif
  
  static void
! afs_destroy_inode(struct inode *ip)
  {
!     ip->i_state = 0;
! }
  
  
  /* afs_put_inode
!  * called from iput when count goes to zero. Linux version of inactive.
!  * For Linux 2.2, this funcionality has moved to the delete inode super op.
!  * If we use the common inode pool, we'll need to set i_nlink to 0 here.
!  * That will trigger the call to delete routine.
   */
  
  static void
! afs_delete_inode(struct inode *ip)
  {
! #if defined(AFS_LINUX26_ENV)
!     AFS_GLOCK();		/* after spin_unlock(inode_lock) */
!     put_inode_on_dummy_list(ip);
!     osi_clear_inode(ip);
! #else
      AFS_GLOCK();
!     osi_clear_inode(ip);
      AFS_GUNLOCK();
! #endif
  }
  
- 
  /* afs_put_super
   * Called from unmount to release super_block. */
  static void
--- 214,347 ----
  afs_notify_change(struct dentry *dp, struct iattr *iattrp)
  {
      struct vattr vattr;
      cred_t *credp = crref();
      struct inode *ip = dp->d_inode;
+     int code;
  
      VATTR_NULL(&vattr);
      iattr2vattr(&vattr, iattrp);	/* Convert for AFS vnodeops call. */
  
  #if defined(AFS_LINUX26_ENV)
!     lock_kernel();
  #endif
+     AFS_GLOCK();
+     code = afs_setattr(VTOAFS(ip), &vattr, credp);
+     if (!code) {
+ 	afs_getattr(VTOAFS(ip), &vattr, credp);
+ 	vattr2inode(ip, &vattr);
+     }
      AFS_GUNLOCK();
+ #if defined(AFS_LINUX26_ENV)
+     unlock_kernel();
+ #endif
      crfree(credp);
      return -code;
  }
  
  
! #if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
! static kmem_cache_t *afs_inode_cachep;
  
+ static struct inode *
+ afs_alloc_inode(struct super_block *sb)
+ {
+     struct vcache *vcp;
+ 
+     vcp = (struct vcache *) kmem_cache_alloc(afs_inode_cachep, SLAB_KERNEL);
+     if (!vcp)
+ 	return NULL;
+ 
+     return AFSTOV(vcp);
+ }
  
  static void
! afs_destroy_inode(struct inode *inode)
! {
!     kmem_cache_free(afs_inode_cachep, inode);
! }
! 
  static void
! init_once(void * foo, kmem_cache_t * cachep, unsigned long flags)
  {
!     struct vcache *vcp = (struct vcache *) foo;
  
!     if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
! 	SLAB_CTOR_CONSTRUCTOR)
! 	inode_init_once(AFSTOV(vcp));
! }
! 
! int
! afs_init_inodecache(void)
! {
! #ifndef SLAB_RECLAIM_ACCOUNT
! #define SLAB_RECLAIM_ACCOUNT 0
  #endif
+ 
+     afs_inode_cachep = kmem_cache_create("afs_inode_cache",
+ 					 sizeof(struct vcache),
+ 					 0, SLAB_HWCACHE_ALIGN | SLAB_RECLAIM_ACCOUNT,
+ 					 init_once, NULL);
+     if (afs_inode_cachep == NULL)
+ 	return -ENOMEM;
+     return 0;
  }
  
! void
! afs_destroy_inodecache(void)
! {
!     if (kmem_cache_destroy(afs_inode_cachep))
! 	printk(KERN_INFO "afs_inode_cache: not all structures were freed\n");
! }
! #else
! int
! afs_init_inodecache(void)
! {
!     return 0;
! }
! 
! void
! afs_destroy_inodecache(void)
  {
!     return;
  }
  #endif
  
  static void
! afs_clear_inode(struct inode *ip)
  {
!     struct vcache *vcp = VTOAFS(ip);
  
+     if (vcp->vlruq.prev || vcp->vlruq.next)
+ 	osi_Panic("inode freed while on LRU");
+     if (vcp->hnext || vcp->vhnext)
+ 	osi_Panic("inode freed while still hashed");
+ 
+ #if !defined(STRUCT_SUPER_HAS_ALLOC_INODE)
+     afs_osi_Free(ip->u.generic_ip, sizeof(struct vcache));
+ #endif
+ }
  
  /* afs_put_inode
!  * Linux version of inactive.  When refcount == 2, we are about to
!  * decrement to 1 and the only reference remaining should be for
!  * the VLRU
   */
  
  static void
! afs_put_inode(struct inode *ip)
  {
!     cred_t *credp = crref();
!     struct vcache *vcp = VTOAFS(ip);
! 
      AFS_GLOCK();
!     ObtainReadLock(&vcp->lock);
!     if (VREFCOUNT(vcp) == 2)
! 	afs_InactiveVCache(vcp, credp);
!     ReleaseReadLock(&vcp->lock);
      AFS_GUNLOCK();
!     crfree(credp);
  }
  
  /* afs_put_super
   * Called from unmount to release super_block. */
  static void
***************
*** 344,349 ****
--- 361,368 ----
  
      afs_globalVFS = 0;
      afs_globalVp = 0;
+ 
+     osi_linux_free_inode_pages();	/* invalidate and release remaining AFS inodes. */
      afs_shutdown();
  #if defined(AFS_LINUX24_ENV)
      mntput(afs_cacheMnt);
***************
*** 413,424 ****
  }
  
  struct super_operations afs_sops = {
! #if defined(AFS_LINUX26_ENV)
!   .drop_inode =		afs_drop_inode,
    .destroy_inode =	afs_destroy_inode,
  #endif
!   .delete_inode =	afs_delete_inode,
!   .write_inode =	afs_write_inode,
    .put_super =		afs_put_super,
    .statfs =		afs_statfs,
    .umount_begin =	afs_umount_begin
--- 432,443 ----
  }
  
  struct super_operations afs_sops = {
! #if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
!   .alloc_inode =	afs_alloc_inode,
    .destroy_inode =	afs_destroy_inode,
  #endif
!   .clear_inode =	afs_clear_inode,
!   .put_inode =		afs_put_inode,
    .put_super =		afs_put_super,
    .statfs =		afs_statfs,
    .umount_begin =	afs_umount_begin
***************
*** 470,510 ****
      }
  }
  
- /* update_inode_cache
-  * Update inode with info from vattr struct. Use va_mask to determine what
-  * to update.
-  */
- static void
- update_inode_cache(struct inode *ip, struct vattr *vp)
- {
-     if (vp->va_mask & ATTR_MODE)
- 	ip->i_mode = vp->va_mode;
-     if (vp->va_mask & ATTR_UID)
- 	ip->i_uid = vp->va_uid;
-     if (vp->va_mask & ATTR_GID)
- 	ip->i_gid = vp->va_gid;
-     if (vp->va_mask & ATTR_SIZE)
- 	ip->i_size = vp->va_size;
-     if (vp->va_mask & ATTR_ATIME)
- #if defined(AFS_LINUX26_ENV)
- 	ip->i_atime.tv_sec = vp->va_atime.tv_sec;
- #else
- 	ip->i_atime = vp->va_atime.tv_sec;
- #endif
-     if (vp->va_mask & ATTR_MTIME)
- #if defined(AFS_LINUX26_ENV)
- 	ip->i_mtime.tv_sec = vp->va_mtime.tv_sec;
- #else
- 	ip->i_mtime = vp->va_mtime.tv_sec;
- #endif
-     if (vp->va_mask & ATTR_CTIME)
- #if defined(AFS_LINUX26_ENV)
- 	ip->i_ctime.tv_sec = vp->va_ctime.tv_sec;
- #else
- 	ip->i_ctime = vp->va_ctime.tv_sec;
- #endif
- }
- 
  /* vattr2inode
   * Rewrite the inode cache from the attr. Assumes all vattr fields are valid.
   */
--- 489,494 ----
***************
*** 530,564 ****
      ip->i_ctime = vp->va_ctime.tv_sec;
  #endif
  }
- 
- /* Put this afs inode on our own dummy list. Linux expects to see inodes
-  * nicely strung up in lists. Linux inode syncing code chokes on our inodes if
-  * they're not on any lists.
-  */
- void
- put_inode_on_dummy_list(struct inode *ip)
- {
-     /* Initialize list. See explanation above. */
-     list_add(&ip->i_list, &dummy_inode_list);
- }
- 
- /* And yet another routine to update the inode cache - called from ProcessFS */
- void
- vcache2inode(struct vcache *avc)
- {
-     struct vattr vattr;
- 
-     VATTR_NULL(&vattr);
-     afs_CopyOutAttrs(avc, &vattr);	/* calls vattr2inode */
- }
- 
- /* Yet another one for fakestat'ed mountpoints */
- void
- vcache2fakeinode(struct vcache *rootvp, struct vcache *mpvp)
- {
-     struct vattr vattr;
- 
-     VATTR_NULL(&vattr);
-     afs_CopyOutAttrs(rootvp, &vattr);
-     vattr2inode(AFSTOI(mpvp), &vattr);
- }
--- 514,516 ----
Index: openafs/src/afs/LINUX/osi_vm.c
diff -c openafs/src/afs/LINUX/osi_vm.c:1.16 openafs/src/afs/LINUX/osi_vm.c:1.16.2.1
*** openafs/src/afs/LINUX/osi_vm.c:1.16	Mon Apr 12 12:04:32 2004
--- openafs/src/afs/LINUX/osi_vm.c	Mon Jul 11 15:29:56 2005
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vm.c,v 1.16 2004/04/12 16:04:32 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_vm.c,v 1.16.2.1 2005/07/11 19:29:56 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 43,51 ****
  int
  osi_VM_FlushVCache(struct vcache *avc, int *slept)
  {
!     struct inode *ip = AFSTOI(avc);
  
!     if (VREFCOUNT(avc) != 0)
  	return EBUSY;
  
      if (avc->opens != 0)
--- 43,51 ----
  int
  osi_VM_FlushVCache(struct vcache *avc, int *slept)
  {
!     struct inode *ip = AFSTOV(avc);
  
!     if (VREFCOUNT(avc) > 1)
  	return EBUSY;
  
      if (avc->opens != 0)
***************
*** 73,79 ****
  void
  osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync)
  {
!     struct inode *ip = AFSTOI(avc);
  
  #if defined(AFS_LINUX26_ENV)
      invalidate_inode_pages(ip->i_mapping);
--- 73,79 ----
  void
  osi_VM_TryToSmush(struct vcache *avc, struct AFS_UCRED *acred, int sync)
  {
!     struct inode *ip = AFSTOV(avc);
  
  #if defined(AFS_LINUX26_ENV)
      invalidate_inode_pages(ip->i_mapping);
***************
*** 100,106 ****
  void
  osi_VM_StoreAllSegments(struct vcache *avc)
  {
!     struct inode *ip = AFSTOI(avc);
  
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)
      /* filemap_fdatasync() only exported in 2.4.5 and above */
--- 100,106 ----
  void
  osi_VM_StoreAllSegments(struct vcache *avc)
  {
!     struct inode *ip = AFSTOV(avc);
  
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,5)
      /* filemap_fdatasync() only exported in 2.4.5 and above */
***************
*** 125,139 ****
  osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
  {
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
!     struct inode *ip = AFSTOI(avc);
  
      truncate_inode_pages(&ip->i_data, 0);
  #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
!     struct inode *ip = AFSTOI(avc);
  
      truncate_inode_pages(ip, 0);
  #else
!     invalidate_inode_pages(AFSTOI(avc));
  #endif
  }
  
--- 125,139 ----
  osi_VM_FlushPages(struct vcache *avc, struct AFS_UCRED *credp)
  {
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
!     struct inode *ip = AFSTOV(avc);
  
      truncate_inode_pages(&ip->i_data, 0);
  #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
!     struct inode *ip = AFSTOV(avc);
  
      truncate_inode_pages(ip, 0);
  #else
!     invalidate_inode_pages(AFSTOV(avc));
  #endif
  }
  
***************
*** 147,160 ****
  osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
  {
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
!     struct inode *ip = AFSTOI(avc);
  
      truncate_inode_pages(&ip->i_data, alen);
  #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
!     struct inode *ip = AFSTOI(avc);
  
      truncate_inode_pages(ip, alen);
  #else
!     invalidate_inode_pages(AFSTOI(avc));
  #endif
  }
--- 147,160 ----
  osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
  {
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
!     struct inode *ip = AFSTOV(avc);
  
      truncate_inode_pages(&ip->i_data, alen);
  #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
!     struct inode *ip = AFSTOV(avc);
  
      truncate_inode_pages(ip, alen);
  #else
!     invalidate_inode_pages(AFSTOV(avc));
  #endif
  }
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.23 openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.25
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.23	Tue May 31 17:12:51 2005
--- openafs/src/afs/LINUX/osi_vnodeops.c	Mon Jul 11 15:29:56 2005
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.23 2005/05/31 21:12:51 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.25 2005/07/11 19:29:56 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 50,71 ****
  #endif
  
  extern struct vcache *afs_globalVp;
- extern afs_rwlock_t afs_xvcache;
- 
- #if defined(AFS_LINUX24_ENV)
- extern struct inode_operations afs_file_iops;
- extern struct address_space_operations afs_file_aops;
- struct address_space_operations afs_symlink_aops;
- #endif
- extern struct inode_operations afs_dir_iops;
- extern struct inode_operations afs_symlink_iops;
  
  
  static ssize_t
  afs_linux_read(struct file *fp, char *buf, size_t count, loff_t * offp)
  {
      ssize_t code;
!     struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode);
      cred_t *credp = crref();
      struct vrequest treq;
  
--- 50,62 ----
  #endif
  
  extern struct vcache *afs_globalVp;
  
  
  static ssize_t
  afs_linux_read(struct file *fp, char *buf, size_t count, loff_t * offp)
  {
      ssize_t code;
!     struct vcache *vcp = VTOAFS(fp->f_dentry->d_inode);
      cred_t *credp = crref();
      struct vrequest treq;
  
***************
*** 147,153 ****
  {
      ssize_t code = 0;
      int code2 = 0;
!     struct vcache *vcp = ITOAFS(fp->f_dentry->d_inode);
      struct vrequest treq;
      cred_t *credp = crref();
      afs_offs_t toffs;
--- 138,144 ----
  {
      ssize_t code = 0;
      int code2 = 0;
!     struct vcache *vcp = VTOAFS(fp->f_dentry->d_inode);
      struct vrequest treq;
      cred_t *credp = crref();
      afs_offs_t toffs;
***************
*** 263,269 ****
  afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
  {
      extern struct DirEntry *afs_dir_GetBlob();
!     struct vcache *avc = ITOAFS(FILE_INODE(fp));
      struct vrequest treq;
      register struct dcache *tdc;
      int code;
--- 254,260 ----
  afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
  {
      extern struct DirEntry *afs_dir_GetBlob();
!     struct vcache *avc = VTOAFS(FILE_INODE(fp));
      struct vrequest treq;
      register struct dcache *tdc;
      int code;
***************
*** 443,449 ****
  static struct vm_operations_struct afs_shared_mmap_ops;
  static int afs_shared_mmap_ops_inited = 0;
  
! void
  afs_linux_vma_close(struct vm_area_struct *vmap)
  {
      struct vcache *vcp;
--- 434,440 ----
  static struct vm_operations_struct afs_shared_mmap_ops;
  static int afs_shared_mmap_ops_inited = 0;
  
! static void
  afs_linux_vma_close(struct vm_area_struct *vmap)
  {
      struct vcache *vcp;
***************
*** 453,459 ****
      if (!vmap->vm_file)
  	return;
  
!     vcp = ITOAFS(FILE_INODE(vmap->vm_file));
      if (!vcp)
  	return;
  
--- 444,450 ----
      if (!vmap->vm_file)
  	return;
  
!     vcp = VTOAFS(FILE_INODE(vmap->vm_file));
      if (!vcp)
  	return;
  
***************
*** 502,508 ****
  static int
  afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap)
  {
!     struct vcache *vcp = ITOAFS(FILE_INODE(fp));
      cred_t *credp = crref();
      struct vrequest treq;
      int code;
--- 493,499 ----
  static int
  afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap)
  {
!     struct vcache *vcp = VTOAFS(FILE_INODE(fp));
      cred_t *credp = crref();
      struct vrequest treq;
      int code;
***************
*** 576,592 ****
      return code;
  }
  
! int
  afs_linux_open(struct inode *ip, struct file *fp)
  {
!     int code;
      cred_t *credp = crref();
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_open((struct vcache **)&ip, fp->f_flags, credp);
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
--- 567,584 ----
      return code;
  }
  
! static int
  afs_linux_open(struct inode *ip, struct file *fp)
  {
!     struct vcache *vcp = VTOAFS(ip);
      cred_t *credp = crref();
+     int code;
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_open(&vcp, fp->f_flags, credp);
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
***************
*** 599,605 ****
  static int
  afs_linux_release(struct inode *ip, struct file *fp)
  {
!     struct vcache *vcp = ITOAFS(ip);
      cred_t *credp = crref();
      int code = 0;
  
--- 591,597 ----
  static int
  afs_linux_release(struct inode *ip, struct file *fp)
  {
!     struct vcache *vcp = VTOAFS(ip);
      cred_t *credp = crref();
      int code = 0;
  
***************
*** 617,627 ****
      return -code;
  }
  
- #if defined(AFS_LINUX24_ENV)
  static int
  afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync)
  #else
- static int
  afs_linux_fsync(struct file *fp, struct dentry *dp)
  #endif
  {
--- 609,618 ----
      return -code;
  }
  
  static int
+ #if defined(AFS_LINUX24_ENV)
  afs_linux_fsync(struct file *fp, struct dentry *dp, int datasync)
  #else
  afs_linux_fsync(struct file *fp, struct dentry *dp)
  #endif
  {
***************
*** 633,639 ****
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_fsync(ITOAFS(ip), credp);
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
--- 624,630 ----
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_fsync(VTOAFS(ip), credp);
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
      unlock_kernel();
***************
*** 648,654 ****
  afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp)
  {
      int code = 0;
!     struct vcache *vcp = ITOAFS(FILE_INODE(fp));
      cred_t *credp = crref();
      struct AFS_FLOCK flock;
      /* Convert to a lock format afs_lockctl understands. */
--- 639,645 ----
  afs_linux_lock(struct file *fp, int cmd, struct file_lock *flp)
  {
      int code = 0;
!     struct vcache *vcp = VTOAFS(FILE_INODE(fp));
      cred_t *credp = crref();
      struct AFS_FLOCK flock;
      /* Convert to a lock format afs_lockctl understands. */
***************
*** 689,699 ****
   * code for the sys_close() here, not afs_linux_release(), so call
   * afs_StoreAllSegments() with AFS_LASTSTORE
   */
! int
  afs_linux_flush(struct file *fp)
  {
      struct vrequest treq;
!     struct vcache *vcp = ITOAFS(FILE_INODE(fp));
      cred_t *credp = crref();
      int code;
  
--- 680,690 ----
   * code for the sys_close() here, not afs_linux_release(), so call
   * afs_StoreAllSegments() with AFS_LASTSTORE
   */
! static int
  afs_linux_flush(struct file *fp)
  {
      struct vrequest treq;
!     struct vcache *vcp = VTOAFS(FILE_INODE(fp));
      cred_t *credp = crref();
      int code;
  
***************
*** 778,817 ****
   * AFS Linux dentry operations
   **********************************************************************/
  
  /* afs_linux_revalidate
   * Ensure vcache is stat'd before use. Return 0 if entry is valid.
   */
  static int
  afs_linux_revalidate(struct dentry *dp)
  {
!     int code;
      cred_t *credp;
!     struct vrequest treq;
!     struct vcache *vcp = ITOAFS(dp->d_inode);
!     struct vcache *rootvp = NULL;
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      AFS_GLOCK();
  
-     if (afs_fakestat_enable && vcp->mvstat == 1 && vcp->mvid
- 	&& (vcp->states & CMValid) && (vcp->states & CStatd)) {
- 	ObtainSharedLock(&afs_xvcache, 680);
- 	rootvp = afs_FindVCache(vcp->mvid, 0, 0);
- 	ReleaseSharedLock(&afs_xvcache);
-     }
- 
      /* Make this a fast path (no crref), since it's called so often. */
      if (vcp->states & CStatd) {
  	if (*dp->d_name.name != '/' && vcp->mvstat == 2)	/* root vnode */
  	    check_bad_parent(dp);	/* check and correct mvid */
! 	if (rootvp)
! 	    vcache2fakeinode(rootvp, vcp);
! 	else
! 	    vcache2inode(vcp);
! 	if (rootvp)
! 	    afs_PutVCache(rootvp);
  	AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
  	unlock_kernel();
--- 769,839 ----
   * AFS Linux dentry operations
   **********************************************************************/
  
+ /* check_bad_parent() : Checks if this dentry's vcache is a root vcache
+  * that has its mvid (parent dir's fid) pointer set to the wrong directory
+  * due to being mounted in multiple points at once. If so, check_bad_parent()
+  * calls afs_lookup() to correct the vcache's mvid, as well as the volume's
+  * dotdotfid and mtpoint fid members.
+  * Parameters:
+  *   dp - dentry to be checked.
+  * Return Values:
+  *   None.
+  * Sideeffects:
+  *   This dentry's vcache's mvid will be set to the correct parent directory's
+  *   fid.
+  *   This root vnode's volume will have its dotdotfid and mtpoint fids set
+  *   to the correct parent and mountpoint fids.
+  */
+ 
+ static inline void
+ check_bad_parent(struct dentry *dp)
+ {
+     cred_t *credp;
+     struct vcache *vcp = VTOAFS(dp->d_inode), *avc = NULL;
+     struct vcache *pvc = VTOAFS(dp->d_parent->d_inode);
+ 
+     if (vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume) {	/* bad parent */
+ printk("check_bad_parent(%s): bad parent vcp->mvid->Fid.Volume != pvc->fid.Fid.Volume\n", dp->d_name.name);
+ 	credp = crref();
+ 
+ 	/* force a lookup, so vcp->mvid is fixed up */
+ 	afs_lookup(pvc, dp->d_name.name, &avc, credp);
+ 	if (!avc || vcp != avc) {	/* bad, very bad.. */
+ 	    afs_Trace4(afs_iclSetp, CM_TRACE_TMP_1S3L, ICL_TYPE_STRING,
+ 		       "check_bad_parent: bad pointer returned from afs_lookup origvc newvc dentry",
+ 		       ICL_TYPE_POINTER, vcp, ICL_TYPE_POINTER, avc,
+ 		       ICL_TYPE_POINTER, dp);
+ 	}
+ 	if (avc)
+ 	    AFS_RELE(AFSTOV(avc));
+ 	crfree(credp);
+     }
+ 
+     return;
+ }
+ 
  /* afs_linux_revalidate
   * Ensure vcache is stat'd before use. Return 0 if entry is valid.
   */
  static int
  afs_linux_revalidate(struct dentry *dp)
  {
!     struct vattr vattr;
!     struct vcache *vcp = VTOAFS(dp->d_inode);
      cred_t *credp;
!     int code;
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      AFS_GLOCK();
  
      /* Make this a fast path (no crref), since it's called so often. */
      if (vcp->states & CStatd) {
+ 
  	if (*dp->d_name.name != '/' && vcp->mvstat == 2)	/* root vnode */
  	    check_bad_parent(dp);	/* check and correct mvid */
! 
  	AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
  	unlock_kernel();
***************
*** 820,828 ****
      }
  
      credp = crref();
!     code = afs_InitReq(&treq, credp);
      if (!code)
! 	code = afs_VerifyVCache(vcp, &treq);
  
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
--- 842,850 ----
      }
  
      credp = crref();
!     code = afs_getattr(vcp, &vattr, credp);
      if (!code)
!         vattr2inode(AFSTOV(vcp), &vattr);
  
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
***************
*** 838,845 ****
  afs_linux_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
  {
          int err = afs_linux_revalidate(dentry);
!         if (!err)
                  generic_fillattr(dentry->d_inode, stat);
          return err;
  }
  #endif
--- 860,868 ----
  afs_linux_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
  {
          int err = afs_linux_revalidate(dentry);
!         if (!err) {
                  generic_fillattr(dentry->d_inode, stat);
+ }
          return err;
  }
  #endif
***************
*** 851,870 ****
   * it is a directory. But since the kernel itself checks these possibilities
   * 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
  {
!     struct vrequest treq;
      cred_t *credp = NULL;
      struct vcache *vcp, *pvcp, *tvc = NULL;
      int valid;
--- 874,891 ----
   * it is a directory. But since the kernel itself checks these possibilities
   * later on, we shouldn't have to do it until later. Perhaps in the future..
   */
+ static int
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
  #ifdef DOP_REVALIDATE_TAKES_NAMEIDATA
  afs_linux_dentry_revalidate(struct dentry *dp, struct nameidata *nd)
  #else
  afs_linux_dentry_revalidate(struct dentry *dp, int flags)
  #endif
  #else
  afs_linux_dentry_revalidate(struct dentry *dp)
  #endif
  {
!     struct vattr vattr;
      cred_t *credp = NULL;
      struct vcache *vcp, *pvcp, *tvc = NULL;
      int valid;
***************
*** 874,889 ****
  #endif
      AFS_GLOCK();
  
!     vcp = ITOAFS(dp->d_inode);
!     pvcp = ITOAFS(dp->d_parent->d_inode);		/* dget_parent()? */
  
!     if (vcp) {
  
- 	/* If it's the AFS root no chance it needs revalidating */
  	if (vcp == afs_globalVp)
  	    goto good_dentry;
  
! 	/* check_bad_parent()? */
  
  #ifdef notdef
  	/* If the last looker changes, we should make sure the current
--- 895,910 ----
  #endif
      AFS_GLOCK();
  
!     if (dp->d_inode) {
  
! 	vcp = VTOAFS(dp->d_inode);
! 	pvcp = VTOAFS(dp->d_parent->d_inode);		/* dget_parent()? */
  
  	if (vcp == afs_globalVp)
  	    goto good_dentry;
  
! 	if (*dp->d_name.name != '/' && vcp->mvstat == 2)	/* root vnode */
! 	    check_bad_parent(dp);	/* check and correct mvid */
  
  #ifdef notdef
  	/* If the last looker changes, we should make sure the current
***************
*** 902,928 ****
  	 * is longer valid, we need to do a full lookup.  VerifyVCache
  	 * isn't enough since the vnode may have been renamed.
  	 */
  	if (hgetlo(pvcp->m.DataVersion) > dp->d_time || !(vcp->states & CStatd)) {
  
  	    credp = crref();
- 	    if (afs_InitReq(&treq, credp))
- 		goto bad_dentry;
  	    afs_lookup(pvcp, dp->d_name.name, &tvc, credp);
  	    if (!tvc || tvc != vcp)
  		goto bad_dentry;
! 	    if (afs_VerifyVCache(vcp, &treq))	/* update inode attributes */
  		goto bad_dentry;
  
  	    dp->d_time = hgetlo(pvcp->m.DataVersion);
  	}
  
      } else {
  	if (hgetlo(pvcp->m.DataVersion) > dp->d_time)
  	    goto bad_dentry;
  
  	/* No change in parent's DataVersion so this negative
! 	 * lookup is still valid.
  	 */
      }
  
    good_dentry:
--- 923,960 ----
  	 * is longer valid, we need to do a full lookup.  VerifyVCache
  	 * isn't enough since the vnode may have been renamed.
  	 */
+ 
  	if (hgetlo(pvcp->m.DataVersion) > dp->d_time || !(vcp->states & CStatd)) {
  
  	    credp = crref();
  	    afs_lookup(pvcp, dp->d_name.name, &tvc, credp);
  	    if (!tvc || tvc != vcp)
  		goto bad_dentry;
! 
! 	    if (afs_getattr(vcp, &vattr, credp))
  		goto bad_dentry;
  
+ 	    vattr2inode(AFSTOV(vcp), &vattr);
  	    dp->d_time = hgetlo(pvcp->m.DataVersion);
  	}
  
+ 	/* should we always update the attributes at this point? */
+ 	/* unlikely--the vcache entry hasn't changed */
+ 
      } else {
+ #ifdef notyet
+ 	pvcp = VTOAFS(dp->d_parent->d_inode);		/* dget_parent()? */
  	if (hgetlo(pvcp->m.DataVersion) > dp->d_time)
  	    goto bad_dentry;
+ #endif
  
  	/* No change in parent's DataVersion so this negative
! 	 * lookup is still valid.  BUT, if a server is down a
! 	 * negative lookup can result so there should be a
! 	 * liftime as well.  For now, always expire.
  	 */
+ 
+ 	goto bad_dentry;
      }
  
    good_dentry:
***************
*** 950,968 ****
      goto done;
  }
  
- #if !defined(AFS_LINUX26_ENV)
- /* afs_dentry_iput */
  static void
  afs_dentry_iput(struct dentry *dp, struct inode *ip)
  {
!     osi_iput(ip);
  }
- #endif
  
  static int
  afs_dentry_delete(struct dentry *dp)
  {
!     if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked))
  	return 1;		/* bad inode? */
  
      return 0;
--- 982,1004 ----
      goto done;
  }
  
  static void
  afs_dentry_iput(struct dentry *dp, struct inode *ip)
  {
!     struct vcache *vcp = VTOAFS(ip);
! 
!     AFS_GLOCK();
!     if (vcp->states & CUnlinked)
! 	(void) afs_remunlink(vcp, 1);		/* perhaps afs_InactiveVCache() instead */
!     AFS_GUNLOCK();
! 
!     iput(ip);
  }
  
  static int
  afs_dentry_delete(struct dentry *dp)
  {
!     if (dp->d_inode && (VTOAFS(dp->d_inode)->states & CUnlinked))
  	return 1;		/* bad inode? */
  
      return 0;
***************
*** 971,979 ****
  struct dentry_operations afs_dentry_operations = {
    .d_revalidate =	afs_linux_dentry_revalidate,
    .d_delete =		afs_dentry_delete,
- #if !defined(AFS_LINUX26_ENV)
    .d_iput =		afs_dentry_iput,
- #endif
  };
  
  /**********************************************************************
--- 1007,1013 ----
***************
*** 988,1049 ****
   *
   * 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;
  
      VATTR_NULL(&vattr);
      vattr.va_mode = mode;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code =
! 	afs_create(ITOAFS(dip), (char *)name, &vattr, NONEXCL, mode,
! 		   (struct vcache **)&ip, credp);
  
      if (!code) {
! 	vattr2inode(ip, &vattr);
! 	/* Reset ops if symlink or directory. */
! #if defined(AFS_LINUX24_ENV)
! 	if (S_ISREG(ip->i_mode)) {
! 	    ip->i_op = &afs_file_iops;
! 	    ip->i_fop = &afs_file_fops;
! 	    ip->i_data.a_ops = &afs_file_aops;
! 	} else if (S_ISDIR(ip->i_mode)) {
! 	    ip->i_op = &afs_dir_iops;
! 	    ip->i_fop = &afs_dir_fops;
! 	} else if (S_ISLNK(ip->i_mode)) {
! 	    ip->i_op = &afs_symlink_iops;
! 	    ip->i_data.a_ops = &afs_symlink_aops;
! 	    ip->i_mapping = &ip->i_data;
! 	} else
! 	    printk("afs_linux_create: FIXME\n");
! #else
! 	if (S_ISDIR(ip->i_mode))
! 	    ip->i_op = &afs_dir_iops;
! 	else if (S_ISLNK(ip->i_mode))
! 	    ip->i_op = &afs_symlink_iops;
! #endif
  
  	dp->d_op = &afs_dentry_operations;
! 	dp->d_time = hgetlo(ITOAFS(dip)->m.DataVersion);
  	d_instantiate(dp, ip);
      }
- 
      AFS_GUNLOCK();
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
--- 1022,1063 ----
   *
   * name is in kernel space at this point.
   */
+ static int
  #ifdef IOP_CREATE_TAKES_NAMEIDATA
  afs_linux_create(struct inode *dip, struct dentry *dp, int mode,
  		 struct nameidata *nd)
  #else
  afs_linux_create(struct inode *dip, struct dentry *dp, int mode)
  #endif
  {
      struct vattr vattr;
+     cred_t *credp = crref();
      const char *name = dp->d_name.name;
!     struct vcache *vcp;
!     int code;
  
      VATTR_NULL(&vattr);
      vattr.va_mode = mode;
+     vattr.va_type = mode & S_IFMT;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_create(VTOAFS(dip), (char *)name, &vattr, NONEXCL, mode,
! 		      &vcp, credp);
  
      if (!code) {
! 	struct inode *ip = AFSTOV(vcp);
  
+ 	afs_getattr(vcp, &vattr, credp);
+ 	afs_fill_inode(ip, &vattr);
  	dp->d_op = &afs_dentry_operations;
! 	dp->d_time = hgetlo(VTOAFS(dip)->m.DataVersion);
  	d_instantiate(dp, ip);
      }
      AFS_GUNLOCK();
+ 
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
  #endif
***************
*** 1053,1129 ****
  
  /* 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)
  #endif
  {
!     int code = 0;
      cred_t *credp = crref();
      struct vcache *vcp = NULL;
      const char *comp = dp->d_name.name;
! #if 1
!     struct dentry *res = 0;
! #endif
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_lookup(ITOAFS(dip), comp, &vcp, credp);
!     AFS_GUNLOCK();
      
      if (vcp) {
! 	struct inode *ip = AFSTOI(vcp);
! 	/* Reset ops if symlink or directory. */
  #if defined(AFS_LINUX24_ENV)
! 	if (S_ISREG(ip->i_mode)) {
! 	    ip->i_op = &afs_file_iops;
! 	    ip->i_fop = &afs_file_fops;
! 	    ip->i_data.a_ops = &afs_file_aops;
! 	} else if (S_ISDIR(ip->i_mode)) {
! 	    ip->i_op = &afs_dir_iops;
! 	    ip->i_fop = &afs_dir_fops;
              d_prune_aliases(ip);
              res = d_find_alias(ip);
- 	} else if (S_ISLNK(ip->i_mode)) {
- 	    ip->i_op = &afs_symlink_iops;
- 	    ip->i_data.a_ops = &afs_symlink_aops;
- 	    ip->i_mapping = &ip->i_data;
- 	} else
- 	    printk
- 		("afs_linux_lookup: ip->i_mode 0x%x  dp->d_name.name %s  code %d\n",
- 		 ip->i_mode, dp->d_name.name, code);
- #ifdef STRUCT_INODE_HAS_I_SECURITY
-        if (ip->i_security == NULL) {
-            if (security_inode_alloc(ip))
-                panic("afs_linux_lookup: Cannot allocate inode security");
-        }
- #endif
- #else
- 	if (S_ISDIR(ip->i_mode))
- 	    ip->i_op = &afs_dir_iops;
- 	else if (S_ISLNK(ip->i_mode))
- 	    ip->i_op = &afs_symlink_iops;
- #endif
      }
-     dp->d_op = &afs_dentry_operations;
-     dp->d_time = hgetlo(ITOAFS(dip)->m.DataVersion);
- #if defined(AFS_LINUX24_ENV)
      if (res) {
  	if (d_unhashed(res))
  	    d_rehash(res);
      } else
  #endif
!     d_add(dp, AFSTOI(vcp));
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
--- 1067,1118 ----
  
  /* afs_linux_lookup */
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
+ static struct dentry *
  #ifdef IOP_LOOKUP_TAKES_NAMEIDATA
  afs_linux_lookup(struct inode *dip, struct dentry *dp,
  		 struct nameidata *nd)
  #else
  afs_linux_lookup(struct inode *dip, struct dentry *dp)
  #endif
  #else
! static int
  afs_linux_lookup(struct inode *dip, struct dentry *dp)
  #endif
  {
!     struct vattr vattr;
      cred_t *credp = crref();
      struct vcache *vcp = NULL;
      const char *comp = dp->d_name.name;
!     struct dentry *res = NULL;
!     struct inode *ip = NULL;
!     int code;
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_lookup(VTOAFS(dip), comp, &vcp, credp);
      
      if (vcp) {
! 	ip = AFSTOV(vcp);
! 
! 	afs_getattr(vcp, &vattr, credp);
! 	afs_fill_inode(ip, &vattr);
!     }
!     dp->d_op = &afs_dentry_operations;
!     dp->d_time = hgetlo(VTOAFS(dip)->m.DataVersion);
!     AFS_GUNLOCK();
  #if defined(AFS_LINUX24_ENV)
!     if (ip && S_ISDIR(ip->i_mode)) {
              d_prune_aliases(ip);
              res = d_find_alias(ip);
      }
      if (res) {
  	if (d_unhashed(res))
  	    d_rehash(res);
      } else
  #endif
!     d_add(dp, ip);
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
***************
*** 1149,1155 ****
  #endif
  }
  
! int
  afs_linux_link(struct dentry *olddp, struct inode *dip, struct dentry *newdp)
  {
      int code;
--- 1138,1144 ----
  #endif
  }
  
! static int
  afs_linux_link(struct dentry *olddp, struct inode *dip, struct dentry *newdp)
  {
      int code;
***************
*** 1163,1182 ****
      d_drop(newdp);
  
      AFS_GLOCK();
!     code = afs_link(ITOAFS(oldip), ITOAFS(dip), name, credp);
  
      AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
  
! int
  afs_linux_unlink(struct inode *dip, struct dentry *dp)
  {
      int code = EBUSY;
      cred_t *credp = crref();
      const char *name = dp->d_name.name;
!     struct vcache *tvc = ITOAFS(dp->d_inode);
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
--- 1152,1171 ----
      d_drop(newdp);
  
      AFS_GLOCK();
!     code = afs_link(VTOAFS(oldip), VTOAFS(dip), name, credp);
  
      AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
  
! static int
  afs_linux_unlink(struct inode *dip, struct dentry *dp)
  {
      int code = EBUSY;
      cred_t *credp = crref();
      const char *name = dp->d_name.name;
!     struct vcache *tvc = VTOAFS(dp->d_inode);
  
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
***************
*** 1205,1213 ****
  	} while (__dp->d_inode != NULL);
  
  	AFS_GLOCK();
! 	code = afs_rename(ITOAFS(dip), dp->d_name.name, ITOAFS(dip), __dp->d_name.name, credp);
  	if (!code) {
!             tvc->mvid = __name;
              crhold(credp);
              if (tvc->uncred) {
                  crfree(tvc->uncred);
--- 1194,1202 ----
  	} while (__dp->d_inode != NULL);
  
  	AFS_GLOCK();
! 	code = afs_rename(VTOAFS(dip), dp->d_name.name, VTOAFS(dip), __dp->d_name.name, credp);
  	if (!code) {
!             tvc->mvid = (void *) __name;
              crhold(credp);
              if (tvc->uncred) {
                  crfree(tvc->uncred);
***************
*** 1218,1224 ****
  	AFS_GUNLOCK();
  
  	if (!code) {
! 	    __dp->d_time = hgetlo(ITOAFS(dip)->m.DataVersion);
  	    d_move(dp, __dp);
  	}
  	dput(__dp);
--- 1207,1213 ----
  	AFS_GUNLOCK();
  
  	if (!code) {
! 	    __dp->d_time = hgetlo(VTOAFS(dip)->m.DataVersion);
  	    d_move(dp, __dp);
  	}
  	dput(__dp);
***************
*** 1227,1233 ****
      }
  
      AFS_GLOCK();
!     code = afs_remove(ITOAFS(dip), name, credp);
      AFS_GUNLOCK();
      if (!code)
  	d_drop(dp);
--- 1216,1222 ----
      }
  
      AFS_GLOCK();
!     code = afs_remove(VTOAFS(dip), name, credp);
      AFS_GUNLOCK();
      if (!code)
  	d_drop(dp);
***************
*** 1240,1246 ****
  }
  
  
! int
  afs_linux_symlink(struct inode *dip, struct dentry *dp, const char *target)
  {
      int code;
--- 1229,1235 ----
  }
  
  
! static int
  afs_linux_symlink(struct inode *dip, struct dentry *dp, const char *target)
  {
      int code;
***************
*** 1253,1267 ****
       */
      d_drop(dp);
  
-     AFS_GLOCK();
      VATTR_NULL(&vattr);
!     code = afs_symlink(ITOAFS(dip), name, &vattr, target, credp);
      AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
  
! int
  afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode)
  {
      int code;
--- 1242,1256 ----
       */
      d_drop(dp);
  
      VATTR_NULL(&vattr);
!     AFS_GLOCK();
!     code = afs_symlink(VTOAFS(dip), name, &vattr, target, credp);
      AFS_GUNLOCK();
      crfree(credp);
      return -code;
  }
  
! static int
  afs_linux_mkdir(struct inode *dip, struct dentry *dp, int mode)
  {
      int code;
***************
*** 1273,1294 ****
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
-     AFS_GLOCK();
      VATTR_NULL(&vattr);
      vattr.va_mask = ATTR_MODE;
      vattr.va_mode = mode;
!     code = afs_mkdir(ITOAFS(dip), name, &vattr, &tvcp, credp);
!     AFS_GUNLOCK();
  
      if (tvcp) {
! 	tvcp->v.v_op = &afs_dir_iops;
! #if defined(AFS_LINUX24_ENV)
! 	tvcp->v.v_fop = &afs_dir_fops;
! #endif
  	dp->d_op = &afs_dentry_operations;
! 	dp->d_time = hgetlo(ITOAFS(dip)->m.DataVersion);
! 	d_instantiate(dp, AFSTOI(tvcp));
      }
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
--- 1262,1284 ----
  #if defined(AFS_LINUX26_ENV)
      lock_kernel();
  #endif
      VATTR_NULL(&vattr);
      vattr.va_mask = ATTR_MODE;
      vattr.va_mode = mode;
!     AFS_GLOCK();
!     code = afs_mkdir(VTOAFS(dip), name, &vattr, &tvcp, credp);
  
      if (tvcp) {
! 	struct inode *ip = AFSTOV(tvcp);
! 
! 	afs_getattr(tvcp, &vattr, credp);
! 	afs_fill_inode(ip, &vattr);
! 
  	dp->d_op = &afs_dentry_operations;
! 	dp->d_time = hgetlo(VTOAFS(dip)->m.DataVersion);
! 	d_instantiate(dp, ip);
      }
+     AFS_GUNLOCK();
  
  #if defined(AFS_LINUX26_ENV)
      unlock_kernel();
***************
*** 1297,1303 ****
      return -code;
  }
  
! int
  afs_linux_rmdir(struct inode *dip, struct dentry *dp)
  {
      int code;
--- 1287,1293 ----
      return -code;
  }
  
! static int
  afs_linux_rmdir(struct inode *dip, struct dentry *dp)
  {
      int code;
***************
*** 1308,1314 ****
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_rmdir(ITOAFS(dip), name, credp);
      AFS_GUNLOCK();
  
      /* Linux likes to see ENOTEMPTY returned from an rmdir() syscall
--- 1298,1304 ----
      lock_kernel();
  #endif
      AFS_GLOCK();
!     code = afs_rmdir(VTOAFS(dip), name, credp);
      AFS_GUNLOCK();
  
      /* Linux likes to see ENOTEMPTY returned from an rmdir() syscall
***************
*** 1331,1338 ****
  }
  
  
! 
! int
  afs_linux_rename(struct inode *oldip, struct dentry *olddp,
  		 struct inode *newip, struct dentry *newdp)
  {
--- 1321,1327 ----
  }
  
  
! static int
  afs_linux_rename(struct inode *oldip, struct dentry *olddp,
  		 struct inode *newip, struct dentry *newdp)
  {
***************
*** 1369,1375 ****
  #endif
  
      AFS_GLOCK();
!     code = afs_rename(ITOAFS(oldip), oldname, ITOAFS(newip), newname, credp);
      AFS_GUNLOCK();
  
      if (rehash)
--- 1358,1364 ----
  #endif
  
      AFS_GLOCK();
!     code = afs_rename(VTOAFS(oldip), oldname, VTOAFS(newip), newname, credp);
      AFS_GUNLOCK();
  
      if (rehash)
***************
*** 1397,1403 ****
      struct iovec iov;
  
      setup_uio(&tuio, &iov, target, (afs_offs_t) 0, maxlen, UIO_READ, seg);
!     code = afs_readlink(ITOAFS(ip), &tuio, credp);
      crfree(credp);
  
      if (!code)
--- 1386,1392 ----
      struct iovec iov;
  
      setup_uio(&tuio, &iov, target, (afs_offs_t) 0, maxlen, UIO_READ, seg);
!     code = afs_readlink(VTOAFS(ip), &tuio, credp);
      crfree(credp);
  
      if (!code)
***************
*** 1410,1416 ****
  /* afs_linux_readlink 
   * Fill target (which is in user space) with contents of symlink.
   */
! int
  afs_linux_readlink(struct dentry *dp, char *target, int maxlen)
  {
      int code;
--- 1399,1405 ----
  /* afs_linux_readlink 
   * Fill target (which is in user space) with contents of symlink.
   */
! static int
  afs_linux_readlink(struct dentry *dp, char *target, int maxlen)
  {
      int code;
***************
*** 1426,1432 ****
  /* afs_linux_follow_link
   * a file system dependent link following routine.
   */
! struct dentry *
  afs_linux_follow_link(struct dentry *dp, struct dentry *basep,
  		      unsigned int follow)
  {
--- 1415,1421 ----
  /* afs_linux_follow_link
   * a file system dependent link following routine.
   */
! static struct dentry *
  afs_linux_follow_link(struct dentry *dp, struct dentry *basep,
  		      unsigned int follow)
  {
***************
*** 1464,1470 ****
  /* afs_linux_readpage
   * all reads come through here. A strategy-like read call.
   */
! int
  afs_linux_readpage(struct file *fp, struct page *pp)
  {
      int code;
--- 1453,1459 ----
  /* afs_linux_readpage
   * all reads come through here. A strategy-like read call.
   */
! static int
  afs_linux_readpage(struct file *fp, struct page *pp)
  {
      int code;
***************
*** 1480,1486 ****
      struct iovec iovec;
      struct inode *ip = FILE_INODE(fp);
      int cnt = page_count(pp);
!     struct vcache *avc = ITOAFS(ip);
  
  
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
--- 1469,1475 ----
      struct iovec iovec;
      struct inode *ip = FILE_INODE(fp);
      int cnt = page_count(pp);
!     struct vcache *avc = VTOAFS(ip);
  
  
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
***************
*** 1551,1639 ****
      return -code;
  }
  
- #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;
-     unsigned long end_index;
-     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));
-     }
- #endif
- 
-     inode = (struct inode *)mapping->host;
-     end_index = inode->i_size >> PAGE_CACHE_SHIFT;
- 
-     /* easy case */
-     if (pp->index < end_index)
- 	goto do_it;
-     /* things got complicated... */
-     offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
-     /* OK, are we completely out? */
-     if (pp->index >= end_index + 1 || !offset)
- 	return -EIO;
-   do_it:
-     status = afs_linux_writepage_sync(inode, pp, 0, offset);
-     SetPageUptodate(pp);
-     UnlockPage(pp);
-     if (status == offset)
- 	return 0;
-     else
- 	return status;
- }
- #endif
- 
- /* 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();
-     int tmp = 0;
- 
-     AFS_GLOCK();
-     if (mode & MAY_EXEC)
- 	tmp |= VEXEC;
-     if (mode & MAY_READ)
- 	tmp |= VREAD;
-     if (mode & MAY_WRITE)
- 	tmp |= VWRITE;
-     code = afs_access(ITOAFS(ip), tmp, credp);
- 
-     AFS_GUNLOCK();
-     crfree(credp);
-     return -code;
- }
- 
  
  #if defined(AFS_LINUX24_ENV)
! int
  afs_linux_writepage_sync(struct inode *ip, struct page *pp,
  			 unsigned long offset, unsigned int count)
  {
!     struct vcache *vcp = ITOAFS(ip);
      char *buffer;
      afs_offs_t base;
      int code = 0;
--- 1540,1552 ----
      return -code;
  }
  
  
  #if defined(AFS_LINUX24_ENV)
! static int
  afs_linux_writepage_sync(struct inode *ip, struct page *pp,
  			 unsigned long offset, unsigned int count)
  {
!     struct vcache *vcp = VTOAFS(ip);
      char *buffer;
      afs_offs_t base;
      int code = 0;
***************
*** 1656,1662 ****
  
      code = afs_write(vcp, &tuio, f_flags, credp, 0);
  
!     vcache2inode(vcp);
  
      if (!code
  	&& afs_stats_cmperf.cacheCurrDirtyChunks >
--- 1569,1576 ----
  
      code = afs_write(vcp, &tuio, f_flags, credp, 0);
  
!     ip->i_size = vcp->m.Length;
!     ip->i_blocks = ((vcp->m.Length + 1023) >> 10) << 1;
  
      if (!code
  	&& afs_stats_cmperf.cacheCurrDirtyChunks >
***************
*** 1682,1698 ****
      return code;
  }
  
  #else
  /* afs_linux_updatepage
   * What one would have thought was writepage - write dirty page to file.
   * Called from generic_file_write. buffer is still in user space. pagep
   * has been filled in with old data if we're updating less than a page.
   */
! int
  afs_linux_updatepage(struct file *fp, struct page *pp, unsigned long offset,
  		     unsigned int count, int sync)
  {
!     struct vcache *vcp = ITOAFS(FILE_INODE(fp));
      u8 *page_addr = (u8 *) afs_linux_page_address(pp);
      int code = 0;
      cred_t *credp;
--- 1596,1656 ----
      return code;
  }
  
+ 
+ static int
+ #ifdef AOP_WRITEPAGE_TAKES_WRITEBACK_CONTROL
+ afs_linux_writepage(struct page *pp, struct writeback_control *wbc)
+ #else
+ afs_linux_writepage(struct page *pp)
+ #endif
+ {
+     struct address_space *mapping = pp->mapping;
+     struct inode *inode;
+     unsigned long end_index;
+     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));
+     }
+ #endif
+ 
+     inode = (struct inode *)mapping->host;
+     end_index = inode->i_size >> PAGE_CACHE_SHIFT;
+ 
+     /* easy case */
+     if (pp->index < end_index)
+ 	goto do_it;
+     /* things got complicated... */
+     offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
+     /* OK, are we completely out? */
+     if (pp->index >= end_index + 1 || !offset)
+ 	return -EIO;
+   do_it:
+     status = afs_linux_writepage_sync(inode, pp, 0, offset);
+     SetPageUptodate(pp);
+     UnlockPage(pp);
+     if (status == offset)
+ 	return 0;
+     else
+ 	return status;
+ }
  #else
  /* afs_linux_updatepage
   * What one would have thought was writepage - write dirty page to file.
   * Called from generic_file_write. buffer is still in user space. pagep
   * has been filled in with old data if we're updating less than a page.
   */
! static int
  afs_linux_updatepage(struct file *fp, struct page *pp, unsigned long offset,
  		     unsigned int count, int sync)
  {
!     struct vcache *vcp = VTOAFS(FILE_INODE(fp));
      u8 *page_addr = (u8 *) afs_linux_page_address(pp);
      int code = 0;
      cred_t *credp;
***************
*** 1712,1718 ****
  
      code = afs_write(vcp, &tuio, fp->f_flags, credp, 0);
  
!     vcache2inode(vcp);
  
      code = code ? -code : count - tuio.uio_resid;
      afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
--- 1670,1677 ----
  
      code = afs_write(vcp, &tuio, fp->f_flags, credp, 0);
  
!     ip->i_size = vcp->m.Length;
!     ip->i_blocks = ((vcp->m.Length + 1023) >> 10) << 1;
  
      code = code ? -code : count - tuio.uio_resid;
      afs_Trace4(afs_iclSetp, CM_TRACE_UPDATEPAGE, ICL_TYPE_POINTER, vcp,
***************
*** 1727,1732 ****
--- 1686,1719 ----
  }
  #endif
  
+ /* afs_linux_permission
+  * Check access rights - returns error if can't check or permission denied.
+  */
+ static int
+ #ifdef IOP_PERMISSION_TAKES_NAMEIDATA
+ afs_linux_permission(struct inode *ip, int mode, struct nameidata *nd)
+ #else
+ afs_linux_permission(struct inode *ip, int mode)
+ #endif
+ {
+     int code;
+     cred_t *credp = crref();
+     int tmp = 0;
+ 
+     AFS_GLOCK();
+     if (mode & MAY_EXEC)
+ 	tmp |= VEXEC;
+     if (mode & MAY_READ)
+ 	tmp |= VREAD;
+     if (mode & MAY_WRITE)
+ 	tmp |= VWRITE;
+     code = afs_access(VTOAFS(ip), tmp, credp);
+ 
+     AFS_GUNLOCK();
+     crfree(credp);
+     return -code;
+ }
+ 
  #if defined(AFS_LINUX24_ENV)
  static int
  afs_linux_commit_write(struct file *file, struct page *page, unsigned offset,
***************
*** 1758,1764 ****
  extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp);
  #endif
  
! struct inode_operations afs_file_iops = {
  #if defined(AFS_LINUX26_ENV)
    .permission =		afs_linux_permission,
    .getattr =		afs_linux_getattr,
--- 1745,1751 ----
  extern int afs_notify_change(struct dentry *dp, struct iattr *iattrp);
  #endif
  
! static struct inode_operations afs_file_iops = {
  #if defined(AFS_LINUX26_ENV)
    .permission =		afs_linux_permission,
    .getattr =		afs_linux_getattr,
***************
*** 1776,1782 ****
  };
  
  #if defined(AFS_LINUX24_ENV)
! struct address_space_operations afs_file_aops = {
    .readpage =		afs_linux_readpage,
    .writepage =		afs_linux_writepage,
    .commit_write =	afs_linux_commit_write,
--- 1763,1769 ----
  };
  
  #if defined(AFS_LINUX24_ENV)
! static struct address_space_operations afs_file_aops = {
    .readpage =		afs_linux_readpage,
    .writepage =		afs_linux_writepage,
    .commit_write =	afs_linux_commit_write,
***************
*** 1789,1795 ****
   * by what sort of operation is allowed.....
   */
  
! struct inode_operations afs_dir_iops = {
  #if !defined(AFS_LINUX24_ENV)
    .default_file_ops =	&afs_dir_fops,
  #else
--- 1776,1782 ----
   * by what sort of operation is allowed.....
   */
  
! static struct inode_operations afs_dir_iops = {
  #if !defined(AFS_LINUX24_ENV)
    .default_file_ops =	&afs_dir_fops,
  #else
***************
*** 1846,1857 ****
      return code;
  }
  
! struct address_space_operations afs_symlink_aops = {
    .readpage =	afs_symlink_filler
  };
  #endif
  
! struct inode_operations afs_symlink_iops = {
  #if defined(AFS_LINUX24_ENV)
    .readlink = 		page_readlink,
  #if defined(HAVE_KERNEL_PAGE_FOLLOW_LINK)
--- 1833,1844 ----
      return code;
  }
  
! static struct address_space_operations afs_symlink_aops = {
    .readpage =	afs_symlink_filler
  };
  #endif
  
! static struct inode_operations afs_symlink_iops = {
  #if defined(AFS_LINUX24_ENV)
    .readlink = 		page_readlink,
  #if defined(HAVE_KERNEL_PAGE_FOLLOW_LINK)
***************
*** 1868,1870 ****
--- 1855,1889 ----
    .revalidate =		afs_linux_revalidate,
  #endif
  };
+ 
+ void
+ afs_fill_inode(struct inode *ip, struct vattr *vattr)
+ {
+ 	
+     if (vattr)
+ 	vattr2inode(ip, vattr);
+ 
+ /* Reset ops if symlink or directory. */
+     if (S_ISREG(ip->i_mode)) {
+ 	ip->i_op = &afs_file_iops;
+ #if defined(AFS_LINUX24_ENV)
+ 	ip->i_fop = &afs_file_fops;
+ 	ip->i_data.a_ops = &afs_file_aops;
+ #endif
+ 
+     } else if (S_ISDIR(ip->i_mode)) {
+ 	ip->i_op = &afs_dir_iops;
+ #if defined(AFS_LINUX24_ENV)
+ 	ip->i_fop = &afs_dir_fops;
+ #endif
+ 
+     } else if (S_ISLNK(ip->i_mode)) {
+ 	ip->i_op = &afs_symlink_iops;
+ #if defined(AFS_LINUX24_ENV)
+ 	ip->i_data.a_ops = &afs_symlink_aops;
+ 	ip->i_mapping = &ip->i_data;
+ #endif
+     }
+ 
+     /* insert_inode_hash(ip);	-- this would make iget() work (if we used it) */
+ }
Index: openafs/src/afs/VNOPS/afs_vnop_attrs.c
diff -c openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.7 openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.8
*** openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.7	Mon Apr  4 00:18:41 2005
--- openafs/src/afs/VNOPS/afs_vnop_attrs.c	Mon Jul 11 15:29:59 2005
***************
*** 24,30 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.7 2005/04/04 04:18:41 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.8 2005/07/11 19:29:59 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 177,186 ****
  #endif
  #endif /* ! AFS_OSF_ENV && !AFS_DARWIN_ENV && !AFS_XBSD_ENV */
  
- #ifdef AFS_LINUX22_ENV
-     /* And linux has its own stash as well. */
-     vattr2inode(AFSTOV(avc), attrs);
- #endif
      return 0;
  }
  
--- 177,182 ----
***************
*** 297,304 ****
  		     * confuses getwd()... */
  #ifdef AFS_LINUX22_ENV
  		    if (avc == afs_globalVp) {
! 			struct inode *ip = avc->v.i_sb->s_root->d_inode;
! 			attrs->va_nodeid = ip->i_ino;
  		    }
  #else
  		    if (AFSTOV(avc)->v_flag & VROOT) {
--- 293,300 ----
  		     * confuses getwd()... */
  #ifdef AFS_LINUX22_ENV
  		    if (avc == afs_globalVp) {
! 			struct inode *ip = AFSTOV(avc)->i_sb->s_root->d_inode;
! 			attrs->va_nodeid = ip->i_ino;	/* VTOI()? */
  		    }
  #else
  		    if (AFSTOV(avc)->v_flag & VROOT) {
Index: openafs/src/afs/VNOPS/afs_vnop_lookup.c
diff -c openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.8 openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.9
*** openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.8	Sun Apr 24 10:03:24 2005
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	Mon Jul 11 15:29:59 2005
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.8 2005/04/24 14:03:24 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.9 2005/07/11 19:29:59 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 31,40 ****
  
  extern struct DirEntry *afs_dir_GetBlob();
  
- #ifdef AFS_LINUX22_ENV
- extern struct inode_operations afs_symlink_iops, afs_dir_iops;
- #endif
- 
  
  afs_int32 afs_bkvolpref = 0;
  afs_int32 afs_bulkStatsDone;
--- 31,36 ----
***************
*** 974,985 ****
  	 * We only do this if the entry looks clear.
  	 */
  	afs_ProcessFS(tvcp, &statsp[i], areqp);
! #ifdef AFS_LINUX22_ENV
! 	/* overwrite the ops if it's a directory or symlink. */
! 	if (vType(tvcp) == VDIR)
! 	    tvcp->v.v_op = &afs_dir_iops;
! 	else if (vType(tvcp) == VLNK)
! 	    tvcp->v.v_op = &afs_symlink_iops;
  #endif
  
  	/* do some accounting for bulk stats: mark this entry as
--- 970,977 ----
  	 * We only do this if the entry looks clear.
  	 */
  	afs_ProcessFS(tvcp, &statsp[i], areqp);
! #if defined(AFS_LINUX22_ENV)
! 	afs_fill_inode(AFSTOV(tvcp), NULL);	/* reset inode operations */
  #endif
  
  	/* do some accounting for bulk stats: mark this entry as
Index: openafs/src/afs/VNOPS/afs_vnop_rename.c
diff -c openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.6 openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.7
*** openafs/src/afs/VNOPS/afs_vnop_rename.c:1.16.2.6	Mon May 30 00:05:44 2005
--- openafs/src/afs/VNOPS/afs_vnop_rename.c	Fri Jun 10 17:11:49 2005
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_rename.c,v 1.16.2.6 2005/05/30 04:05:44 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_rename.c,v 1.16.2.7 2005/06/10 21:11:49 jaltman Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 358,364 ****
  
  int
  #if defined(AFS_SGI_ENV)
! afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, achar *name2, struct pathname *npnp, struct AFS_UCRED *acred)
  #else
  afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, char *aname2, struct AFS_UCRED *acred)
  #endif
--- 358,364 ----
  
  int
  #if defined(AFS_SGI_ENV)
! afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, char *aname2, struct pathname *npnp, struct AFS_UCRED *acred)
  #else
  afs_rename(OSI_VC_DECL(aodp), char *aname1, struct vcache *andp, char *aname2, struct AFS_UCRED *acred)
  #endif
Index: openafs/src/afsd/afsd.c
diff -c openafs/src/afsd/afsd.c:1.43.2.9 openafs/src/afsd/afsd.c:1.43.2.10
*** openafs/src/afsd/afsd.c:1.43.2.9	Mon May 23 17:26:40 2005
--- openafs/src/afsd/afsd.c	Tue Jun 21 16:13:52 2005
***************
*** 57,63 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.9 2005/05/23 21:26:40 shadow Exp $");
  
  #define VFS 1
  
--- 57,63 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.10 2005/06/21 20:13:52 shadow Exp $");
  
  #define VFS 1
  
***************
*** 230,237 ****
  afs_int32 afs_shutdown = 0;
  afs_int32 cacheBlocks;		/*Num blocks in the cache */
  afs_int32 cacheFiles = 1000;	/*Optimal # of files in workstation cache */
- afs_int32 rwpct = 0;
- afs_int32 ropct = 0;
  afs_int32 cacheStatEntries = 300;	/*Number of stat cache entries */
  char cacheBaseDir[1024];	/*Where the workstation AFS cache lives */
  char confDir[1024];		/*Where the workstation AFS configuration lives */
--- 230,235 ----
***************
*** 277,283 ****
  static int enable_fakestat = 0;	/* enable fakestat support */
  static int enable_backuptree = 0;	/* enable backup tree support */
  static int enable_nomount = 0;	/* do not mount */
- static int enable_splitcache = 0;
  #ifdef notdef
  static int inodes = 60;		/* VERY conservative, but has to be */
  #endif
--- 275,280 ----
***************
*** 1538,1558 ****
  	exit(1);
  	}
      }
!     if (as->parms[34].items) {
! 	char *c;
! 	if (!as->parms[34].items->data ||
! 	    ((c = strchr(as->parms[34].items->data, '/')) == NULL)) 
!            printf("ignoring splitcache (specify as RW/RO percentages: 60/40)\n"); 
!        else {
!            ropct = atoi((char *)c+1);
! 	   *c = '\0'; 
!            rwpct = atoi((char *)as->parms[30].items->data);
!            if ((rwpct != 0) && (ropct != 0) && (ropct+rwpct == 100)) {
!                /* -splitcache */
!                enable_splitcache = 1;
! 	   }
!        }
!     }    
      /*
       * Pull out all the configuration info for the workstation's AFS cache and
       * the cellular community we're willing to let our users see.
--- 1535,1541 ----
  	exit(1);
  	}
      }
!     
      /*
       * Pull out all the configuration info for the workstation's AFS cache and
       * the cellular community we're willing to let our users see.
***************
*** 1830,1842 ****
      cparams.inodes = inodes;
  #endif
      call_syscall(AFSOP_CACHEINIT, &cparams);
- 
-     /* do it before we init the cache inodes */
-     if (enable_splitcache) {
- 	call_syscall(AFSOP_BUCKETPCT, 1, rwpct);
- 	call_syscall(AFSOP_BUCKETPCT, 2, ropct);
-     }
- 
      if (afsd_CloseSynch)
  	call_syscall(AFSOP_CLOSEWAIT);
  
--- 1813,1818 ----
***************
*** 2204,2211 ****
      cmd_AddParm(ts, "-settime", CMD_FLAG, CMD_OPTIONAL,
                 "don't set the time");
      cmd_AddParm(ts, "-rxpck", CMD_SINGLE, CMD_OPTIONAL, "set rx_extraPackets to this value");
-     cmd_AddParm(ts, "-splitcache", CMD_SINGLE, CMD_OPTIONAL, "Percentage RW versus RO in cache (specify as 60/40)");
- 
      return (cmd_Dispatch(argc, argv));
  }
  
--- 2180,2185 ----
Index: openafs/src/aklog/Makefile.in
diff -c /dev/null openafs/src/aklog/Makefile.in:1.1.2.4
*** /dev/null	Mon Jul 11 23:46:15 2005
--- openafs/src/aklog/Makefile.in	Mon Jul 11 15:07:00 2005
***************
*** 0 ****
--- 1,47 ----
+ #
+ # This Makefile in in the public domain
+ #
+ 
+ srcdir=@srcdir@
+ include @TOP_OBJDIR@/src/config/Makefile.config
+ 
+ OPTMZ += @KRB5CFLAGS@ -DALLOW_REGISTER
+ LIBS += @KRB5LIBS@
+ AFSLIBS = ${TOP_LIBDIR}/libprot.a ${TOP_LIBDIR}/libubik.a \
+ 	  ${TOP_LIBDIR}/libauth.a ${TOP_LIBDIR}/librxkad.a \
+ 	  ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a \
+ 	  ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libdes.a \
+ 	  ${TOP_LIBDIR}/libafsutil.a
+ 
+ SRCS=	aklog.c aklog_main.c  krb_util.c linked_list.c
+ OBJS=   aklog.o aklog_main.o krb_util.o linked_list.o
+ 
+ all: aklog
+ 
+ aklog:	${OBJS} ${AFSLIBS}
+ 	${CC} -o $@ ${CFLAGS} ${OBJS} ${LIBS} ${AFSLIBS} ${XLIBS}
+ 
+ 
+ #
+ # Installation targets
+ #
+ install: \
+ 	${DESTDIR}${bindir}/aklog
+ 
+ ${DESTDIR}${bindir}/aklog: aklog
+ 	${INSTALL} $? $@
+ 
+ dest: \
+ 	${DEST}/bin/aklog
+ 
+ ${DEST}/bin/aklog: aklog
+ 	${INSTALL} $? $@
+ 
+ #
+ # Misc. targets
+ #
+ clean:
+ 	$(RM) -f *.o ${OBJS} aklog
+ 
+ include ../config/Makefile.version
+ 
Index: openafs/src/aklog/aklog.c
diff -c openafs/src/aklog/aklog.c:1.1.2.1 openafs/src/aklog/aklog.c:1.1.2.4
*** openafs/src/aklog/aklog.c:1.1.2.1	Tue Dec  7 00:51:24 2004
--- openafs/src/aklog/aklog.c	Mon Jul 11 15:07:00 2005
***************
*** 1,14 ****
  /* 
!  * $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
--- 1,15 ----
  /* 
!  * $Id: aklog.c,v 1.1.2.4 2005/07/11 19:07:00 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.4 2005/07/11 19:07:00 shadow Exp $";
  #endif /* lint || SABER */
  
+ #include <afs/stds.h>
  #include "aklog.h"
  
  #ifndef WINDOWS
***************
*** 21,30 ****
    char *argv[];
  #endif /* __STDC__ */
  {
!     aklog_params params;
! 
!     aklog_init_params(&params);
!     aklog(argc, argv, &params);
  }
  
  #else /* WINDOWS */
--- 22,28 ----
    char *argv[];
  #endif /* __STDC__ */
  {
!     aklog(argc, argv);
  }
  
  #else /* WINDOWS */
***************
*** 45,51 ****
  
  	parse_cmdline(cmdline, &argv, &argc);
  
-     aklog_init_params(&params);
      aklog(argc, argv, &params);
  
  	return 0;
--- 43,48 ----
Index: openafs/src/aklog/aklog.h
diff -c openafs/src/aklog/aklog.h:1.1.2.1 openafs/src/aklog/aklog.h:1.1.2.4
*** openafs/src/aklog/aklog.h:1.1.2.1	Tue Dec  7 00:51:24 2004
--- openafs/src/aklog/aklog.h	Mon Jul 11 15:07:00 2005
***************
*** 1,5 ****
  /* 
!  * $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"
--- 1,5 ----
  /* 
!  * $Id: aklog.h,v 1.1.2.4 2005/07/11 19:07:00 shadow Exp $
   *
   * Copyright 1990,1991 by the Massachusetts Institute of Technology
   * For distribution and copying rights, see the file "mit-copyright.h"
***************
*** 9,20 ****
  #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
--- 9,20 ----
  #define __AKLOG_H__
  
  #if !defined(lint) && !defined(SABER)
! static char *rcsid_aklog_h = "$Id: aklog.h,v 1.1.2.4 2005/07/11 19:07:00 shadow Exp $";
  #endif /* lint || SABER */
  
  #include <krb5.h>
  #include "linked_list.h"
+ #include <afsconfig.h>
  
  #ifdef __STDC__
  #define ARGS(x) x
***************
*** 22,41 ****
  #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
  /*
--- 22,77 ----
  #define ARGS(x) ()
  #endif /* __STDC__ */
  
! void aklog ARGS((int, char *[]));
! 
! /*
!  * If we have krb.h, use the definition of CREDENTIAL from there.  Otherwise,
!  * inline it.  When we inline it we're using the inline definition from the
!  * Heimdal sources (since Heimdal doesn't include a definition of struct
!  * credentials with the sources
!  */
! 
! #ifdef HAVE_KERBEROSIV_KRB_H
! #include <kerberosIV/krb.h>
! #else /* HAVE_KERBEROSIV_KRB_H */
! 
! #ifndef MAX_KTXT_LEN
! #define MAX_KTXT_LEN 1250
! #endif /* MAX_KTXT_LEN */
! #ifndef ANAME_SZ
! #define ANAME_SZ 40
! #endif /* ANAME_SZ */
! #ifndef REALM_SZ
! #define REALM_SZ 40
! #endif /* REALM_SZ */
! #ifndef SNAME_SZ
! #define SNAME_SZ 40
! #endif /* SNAME_SZ */
! #ifndef INST_SZ
! #define INST_SZ 40
! #endif /* INST_SZ */
! 
! struct ktext {
!     unsigned int length;
!     unsigned char dat[MAX_KTXT_LEN];
!     u_int32_t mbz;
! };
! 
! struct credentials {
!     char    service[ANAME_SZ];
!     char    instance[INST_SZ];
!     char    realm[REALM_SZ];
!     char    session[8];
!     int     lifetime;
!     int     kvno;
!     struct ktext ticket_st;
!     int32_t    issue_date;
!     char    pname[ANAME_SZ];
!     char    pinst[INST_SZ];
! };
  
! typedef struct credentials CREDENTIALS;
! #endif /* ! HAVE_KERBEROSIV_KRB_H */
  
  #ifdef WINDOWS
  /*
Index: openafs/src/aklog/aklog_main.c
diff -c openafs/src/aklog/aklog_main.c:1.1.2.1 openafs/src/aklog/aklog_main.c:1.1.2.8
*** openafs/src/aklog/aklog_main.c:1.1.2.1	Tue Dec  7 00:51:24 2004
--- openafs/src/aklog/aklog_main.c	Mon Jul 11 15:07:46 2005
***************
*** 1,5 ****
  /* 
!  * $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"
--- 1,5 ----
  /* 
!  * $Id: aklog_main.c,v 1.1.2.8 2005/07/11 19:07:46 shadow Exp $
   *
   * Copyright 1990,1991 by the Massachusetts Institute of Technology
   * For distribution and copying rights, see the file "mit-copyright.h"
***************
*** 7,13 ****
  
  #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>
--- 7,13 ----
  
  #if !defined(lint) && !defined(SABER)
  static char *rcsid =
! 	"$Id: aklog_main.c,v 1.1.2.8 2005/07/11 19:07:46 shadow Exp $";
  #endif /* lint || SABER */
  
  #include <stdio.h>
***************
*** 63,77 ****
  
  #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>
--- 63,72 ----
***************
*** 96,102 ****
  #define AFSINST ""
  
  #ifndef AFS_TRY_FULL_PRINC
! #define AFS_TRY_FULL_PRINC 0
  #endif /* AFS_TRY_FULL_PRINC */
  
  #define AKLOG_SUCCESS 0
--- 91,97 ----
  #define AFSINST ""
  
  #ifndef AFS_TRY_FULL_PRINC
! #define AFS_TRY_FULL_PRINC 1
  #endif /* AFS_TRY_FULL_PRINC */
  
  #define AKLOG_SUCCESS 0
***************
*** 138,143 ****
--- 133,139 ----
  struct afsconf_cell ak_cellconfig; /* General information about the cell */
  static char linkedcell[MAXCELLCHARS+1];
  static char linkedcell2[MAXCELLCHARS+1];
+ static krb5_ccache  _krb425_ccache = NULL;
  
  #ifdef WINDOWS
  
***************
*** 153,174 ****
   * 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);
  
  /*
--- 149,154 ----
***************
*** 176,181 ****
--- 156,207 ----
   */
  
  extern char *afs_realm_of_cell(krb5_context, struct afsconf_cell *);
+ static int isdir(char *, unsigned char *);
+ static krb5_error_code get_credv5(krb5_context context, char *, char *,
+ 				  char *, krb5_creds **);
+ static int get_user_realm(krb5_context, char *);
+ 
+ #if defined(HAVE_KRB5_PRINC_SIZE) || defined(krb5_princ_size)
+ 
+ #define get_princ_str(c, p, n) krb5_princ_component(c, p, n)->data
+ #define get_princ_len(c, p, n) krb5_princ_component(c, p, n)->length
+ #define second_comp(c, p) (krb5_princ_size(c, p) > 1)
+ #define realm_data(c, p) krb5_princ_realm(c, p)->data
+ #define realm_len(c, p) krb5_princ_realm(c, p)->length
+ 
+ #elif defined(HAVE_KRB5_PRINCIPAL_GET_COMP_STRING)
+ 
+ #define get_princ_str(c, p, n) krb5_principal_get_comp_string(c, p, n)
+ #define get_princ_len(c, p, n) strlen(krb5_principal_get_comp_string(c, p, n))
+ #define second_comp(c, p) (krb5_principal_get_comp_string(c, p, 1) != NULL)
+ #define realm_data(c, p) krb5_realm_data(krb5_principal_get_realm(c, p))
+ #define realm_len(c, p) krb5_realm_length(krb5_principal_get_realm(c, p))
+ 
+ #else
+ #error "Must have either krb5_princ_size or krb5_principal_get_comp_string"
+ #endif
+ 
+ #if defined(HAVE_KRB5_CREDS_KEYBLOCK)
+ 
+ #define get_cred_keydata(c) c->keyblock.contents
+ #define get_cred_keylen(c) c->keyblock.length
+ #define get_creds_enctype(c) c->keyblock.enctype
+ 
+ #elif defined(HAVE_KRB5_CREDS_SESSION)
+ 
+ #define get_cred_keydata(c) c->session.keyvalue.data
+ #define get_cred_keylen(c) c->session.keyvalue.length
+ #define get_creds_enctype(c) c->session.keytype
+ 
+ #else
+ #error "Must have either keyblock or session member of krb5_creds"
+ #endif
+ 
+ #if !defined(HAVE_KRB5_524_CONVERT_CREDS) && defined(HAVE_KRB524_CONVERT_CREDS_KDC)
+ #define krb5_524_convert_creds krb524_convert_creds_kdc
+ #elif !defined(HAVE_KRB5_524_CONVERT_CREDS) && !defined(HAVE_KRB524_CONVERT_CREDS_KDC)
+ #error "You must have one of krb5_524_convert_creds or krb524_convert_creds_kdc available"
+ #endif
  
  #endif /* WINDOWS */
  
***************
*** 188,195 ****
  #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 */
--- 214,219 ----
***************
*** 199,204 ****
--- 223,229 ----
  static int linked = FALSE;  /* try for both AFS nodes */
  static int afssetpag = FALSE; /* setpag for AFS */
  static int force = FALSE;	/* Bash identical tokens? */
+ static int do524 = FALSE;	/* Should we do 524 instead of rxkad2b? */
  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 */
***************
*** 208,219 ****
  /* 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;
  
--- 233,239 ----
***************
*** 224,235 ****
  }
  
  
- #ifdef __STDC__
  static char *copy_string(char *string)    
- #else
- static char *copy_string(string)
-   char *string;
- #endif /* __STDC__ */
  {
      char *new_string;
  
--- 244,250 ----
***************
*** 240,260 ****
  }
  
  
- #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));
--- 255,265 ----
***************
*** 262,278 ****
  #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))
--- 267,281 ----
  #ifndef WINDOWS
  
      if (!(configdir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH))) {
! 	fprintf(stderr, 
  		"%s: can't get afs configuration (afsconf_Open(%s))\n",
  		progname, AFSDIR_CLIENT_ETC_DIRPATH);
! 	exit(AKLOG_AFS);
      }
  
      if (afsconf_GetLocalCell(configdir, local_cell, MAXCELLCHARS)) {
! 	fprintf(stderr, "%s: can't determine local cell.\n", progname);
! 	exit(AKLOG_AFS);
      }
  
      if ((cell == NULL) || (cell[0] == 0))
***************
*** 280,288 ****
  
  	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) 
--- 283,290 ----
  
  	linkedcell[0] = '\0';
      if (afsconf_GetCellInfo(configdir, cell, NULL, cellconfig)) {
! 	fprintf(stderr, "%s: Can't get information about cell %s.\n",
  		progname, cell);
  	status = AKLOG_AFS;
      }
  	if (cellconfig->linkedCell) 
***************
*** 296,304 ****
       * 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))
--- 298,305 ----
       * of the afsconf_cell structure as we can.
       */
      if (cm_GetRootCellName(local_cell)) {
! 	fprintf(stderr, "%s: can't get local cellname\n", progname);
! 	exit(AKLOG_AFS);
      }
  
      if ((cell == NULL) || (cell[0] == 0))
***************
*** 317,327 ****
       * 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) {
--- 318,324 ----
***************
*** 329,360 ****
  	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;
--- 326,356 ----
  	break;
  
      case -1:
! 	fprintf(stderr, "%s: GetWindowsDirectory() failed.\n", progname);
  	break;
  
      case -2:
! 	fprintf(stderr, "%s: Couldn't open afsdcells.ini for reading\n",
  		progname);
  	break;
  
      case -3:
! 	fprintf(stderr, "%s: Couldn't find any servers for cell %s\n",
  		progname, cell);
  	break;
  
      case -4:
! 	fprintf(stderr, "%s: Badly formatted line in afsdcells.ini (does not begin with a \">\" or contain \"#\"\n",
  		progname);
  	break;
  
      default:
! 	fprintf(stderr, "%s cm_SearchCellFile returned unknown error %d\n",
  		status);
      }
  
      if (status) {
! 	exit(AKLOG_AFS);
      }
  
      status = AKLOG_SUCCESS;
***************
*** 423,429 ****
      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;
--- 419,424 ----
***************
*** 455,463 ****
  
      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);
      }
--- 450,457 ----
  
      if (ll_string(&authedcells, ll_s_check, cell_to_use)) {
  	if (dflag) {
! 	    printf("Already authenticated to %s (or tried to)\n", 
! 		   cell_to_use);
  	}
  	return(AKLOG_SUCCESS);
      }
***************
*** 477,501 ****
       * 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);
  	}
  
  	/*
--- 471,492 ----
       * are in -noauth mode.
       */
      if (ll_string(&zsublist, ll_s_add, cell_to_use) == LL_FAILURE) {
! 	fprintf(stderr, 
  		"%s: failure adding cell %s to zephyr subscriptions list.\n",
  		progname, cell_to_use);
! 	exit(AKLOG_MISC);
      }
      if (ll_string(&zsublist, ll_s_add, local_cell) == LL_FAILURE) {
! 	fprintf(stderr, 
  		"%s: failure adding cell %s to zephyr subscriptions list.\n",
  		progname, local_cell);
! 	exit(AKLOG_MISC);
      }
  
      if (!noauth) {
  	if (dflag) {
! 	    printf("Authenticating to cell %s (server %s).\n",
! 		   cell_to_use, ak_cellconfig.hostName[0]);
  	}
  
  	/*
***************
*** 507,534 ****
  	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);
  	    }
  	}
  
--- 498,521 ----
  	if (realm && realm[0]) {
  	    strcpy(realm_of_cell, realm);
  	    if (dflag) {
! 		printf("We were told to authenticate to realm %s.\n", realm);
  	    }
  	}
  	else {
  	    char *realm = afs_realm_of_cell(context, &ak_cellconfig);
  
  	    if (!realm) {
! 		fprintf(stderr, 
  			"%s: Couldn't figure out realm for cell %s.\n",
  			progname, cell_to_use);
! 		exit(AKLOG_MISC);
  	    }
  
  	    strcpy(realm_of_cell, realm);
  
  	    if (dflag) {
! 		printf("We've deduced that we need to authenticate to"
! 		       " realm %s.\n", realm_of_cell);
  	    }
  	}
  
***************
*** 580,623 ****
  	 *	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);
  	}
--- 567,600 ----
  	 *	afs/<cell>@<realm> i.e. allow for single name with "."
  	 * 	afs@<realm>
  	 */
  
  	if (dflag) {
! 	    printf("Getting tickets: %s/%s@%s\n", name,
! 		   primary_instance, realm_of_cell);
  	}
  
! 	status = get_credv5(context, name, primary_instance, realm_of_cell,
! 			    &v5cred);
  
  	if (status == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN) {
  	    if (try_secondary) {
  		if (dflag) {
! 		    printf("Principal not found, trying alternate "
! 			   "service name: %s/%s@%s\n", name,
  			    secondary_instance, realm_of_cell);
  		}
! 		status = get_credv5(context, name, secondary_instance,
! 				    realm_of_cell, &v5cred);
  	    }
  	}
  
! 	if (status) {
  	    if (dflag) {
! 		printf("Kerberos error code returned by get_cred: %d\n",
  			status);
  	    }
! 	    fprintf(stderr, "%s: Couldn't get %s AFS tickets:\n",
  		    progname, cell_to_use);
  		com_err(progname, status, "while getting AFS tickets");
  	    return(AKLOG_KERBEROS);
  	}
***************
*** 626,651 ****
  	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) &&
--- 603,679 ----
  	strncpy(aserver.instance, AFSINST, MAXKTCNAMELEN - 1);
  	strncpy(aserver.cell, cell_to_use, MAXKTCREALMLEN - 1);
  
  	/*
!  	 * The default is to use rxkad2b, which means we put in a full
! 	 * V5 ticket.  If the user specifies -524, we talk to the
! 	 * 524 ticket converter.
  	 */
! 
! 	if (! do524) {
! 	    char *p;
! 	    int len;
! 
! 	    if (dflag)
! 	    	printf("Using Kerberos V5 ticket natively\n");
! 
! 	    len = min(get_princ_len(context, v5cred->client, 0),
! 	    	      second_comp(context, v5cred->client) ?
! 					MAXKTCNAMELEN - 2 : MAXKTCNAMELEN - 1);
! 	    strncpy(username, get_princ_str(context, v5cred->client, 0), len);
! 	    username[len] = '\0';
! 
! 	    if (second_comp(context, v5cred->client)) {
! 	    	strcat(username, ".");
! 		p = username + strlen(username);
! 		len = min(get_princ_len(context, v5cred->client, 1),
! 			  MAXKTCNAMELEN - strlen(username) - 1);
! 		strncpy(p, get_princ_str(context, v5cred->client, 1), len);
! 		p[len] = '\0';
! 	    }
! 
! 	    memset(&atoken, 0, sizeof(atoken));
! 	    atoken.kvno = RXKAD_TKT_TYPE_KERBEROS_V5;
! 	    atoken.startTime = v5cred->times.starttime;;
! 	    atoken.endTime = v5cred->times.endtime;
! 	    memcpy(&atoken.sessionKey, get_cred_keydata(v5cred),
! 		   get_cred_keylen(v5cred));
! 	    atoken.ticketLen = v5cred->ticket.length;
! 	    memcpy(atoken.ticket, v5cred->ticket.data, atoken.ticketLen);
! 	} else {
!     	    CREDENTIALS cred;
! 
! 	    if (dflag)
! 	    	printf("Using Kerberos 524 translator service\n");
! 
! 	    status = krb5_524_convert_creds(context, v5cred, &cred);
! 
! 	    if (status) {
! 		com_err(progname, status, "while converting tickets "
! 			"to Kerberos V4 format");
! 		return(AKLOG_KERBEROS);
! 	    }
! 
! 	    strcpy (username, cred.pname);
! 	    if (cred.pinst[0]) {
! 		strcat (username, ".");
! 		strcat (username, cred.pinst);
! 	    }
! 
! 	    atoken.kvno = cred.kvno;
! 	    atoken.startTime = cred.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, cred.session, 8);
! 	    atoken.ticketLen = cred.ticket_st.length;
! 	    memcpy(atoken.ticket, cred.ticket_st.dat, atoken.ticketLen);
! 	}
  	
  	if (!force &&
  	    !ktc_GetToken(&aserver, &btoken, sizeof(btoken), &aclient) &&
***************
*** 655,662 ****
  	    !memcmp(atoken.ticket, btoken.ticket, atoken.ticketLen)) {
  
  	    if (dflag) {
! 		sprintf(msgbuf, "Identical tokens already exist; skipping.\n");
! 		params.pstdout(msgbuf);
  	    }
  	    return 0;
  	}
--- 683,689 ----
  	    !memcmp(atoken.ticket, btoken.ticket, atoken.ticketLen)) {
  
  	    if (dflag) {
! 		printf("Identical tokens already exist; skipping.\n");
  	    }
  	    return 0;
  	}
***************
*** 669,685 ****
  	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);
  	    }
--- 696,710 ----
  	if (noprdb) {
  #endif
  	    if (dflag) {
! 		printf("Not resolving name %s to id (-noprdb set)\n",
  			username);
  	    }
  #ifndef WINDOWS
  	}
  	else {
! 	    if ((status = get_user_realm(context, realm_of_user))) {
! 		fprintf(stderr, "%s: Couldn't determine realm of user:)",
  			progname);
  		com_err(progname, status, " while getting realm");
  		return(AKLOG_KERBEROS);
  	    }
***************
*** 689,717 ****
  	    }
  
  	    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);
--- 714,721 ----
  	    }
  
  	    if (dflag) {
! 		printf("About to resolve name %s to id in cell %s.\n", 
  			username, aserver.cell);
  	    }
  
  	    strcpy(lastcell, aserver.cell);
***************
*** 721,730 ****
  	    
  	    if (dflag) {
  		if (status) 
! 		    sprintf(msgbuf, "Error %d\n", status);
  		else
! 		    sprintf(msgbuf, "Id %d\n", (int) viceId);
! 		params.pstdout(msgbuf);
  	    }
  	    
  		/*
--- 725,733 ----
  	    
  	    if (dflag) {
  		if (status) 
! 		    printf("Error %d\n", status);
  		else
! 		    printf("Id %d\n", (int) viceId);
  	    }
  	    
  		/*
***************
*** 752,769 ****
  #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;
  		}
  
--- 755,770 ----
  #ifdef ALLOW_REGISTER
  	    } else if (strcmp(realm_of_user, realm_of_cell) != 0) {
  		if (dflag) {
! 		    printf("doing first-time registration of %s "
  			    "at %s\n", username, cell_to_use);
  		}
  		id = 0;
  		strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
  		strcpy(aclient.instance, "");
! 		strncpy(aclient.cell, realm_of_user, MAXKTCREALMLEN - 1);
  		if ((status = ktc_SetToken(&aserver, &atoken, &aclient, 0))) {
! 		    fprintf(stderr, "%s: unable to obtain tokens for cell %s "
  			    "(status: %d).\n", progname, cell_to_use, status);
  		    status = AKLOG_TOKEN;
  		}
  
***************
*** 775,794 ****
  		 */
  
  		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);
  		}
  	    }
--- 776,792 ----
  		 */
  
  		if ((status = pr_Initialize(1L, confname, aserver.cell, 0))) {
! 		    printf("Error %d\n", status);
  		}
  
  		if ((status = pr_CreateUser(username, &id))) {
! 		    fprintf(stderr, "%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);
  		} else {
! 		    printf("created cross-cell entry for %s at %s\n",
! 			   username, cell_to_use);
  		    sprintf(username, "AFS ID %d", (int) id);
  		}
  	    }
***************
*** 799,806 ****
  #endif /* !WINDOWS */
  
  	if (dflag) {
! 	    sprintf(msgbuf, "Set username to %s\n", username);
! 	    params.pstdout(msgbuf);
  	}
  
  	/* Reset the "aclient" structure before we call ktc_SetToken.
--- 797,803 ----
  #endif /* !WINDOWS */
  
  	if (dflag) {
! 	    fprintf(stdout, "Set username to %s\n", username);
  	}
  
  	/* Reset the "aclient" structure before we call ktc_SetToken.
***************
*** 809,820 ****
  	 */
  	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 
--- 806,816 ----
  	 */
  	strncpy(aclient.name, username, MAXKTCNAMELEN - 1);
  	strcpy(aclient.instance, "");
! 	strncpy(aclient.cell, realm_of_user, MAXKTCREALMLEN - 1);
  
  	if (dflag) {
! 	    printf("Setting tokens. %s / %s @ %s \n",
! 		    aclient.name, aclient.instance, aclient.cell );
  	}
  	/* 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 
***************
*** 823,869 ****
  	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);
--- 819,858 ----
  	write(2,"",0); /* dummy write */
  #ifndef WINDOWS
  	if ((status = ktc_SetToken(&aserver, &atoken, &aclient, afssetpag))) {
! 	    fprintf(stderr, 
  		    "%s: unable to obtain tokens for cell %s (status: %d).\n",
  		    progname, cell_to_use, status);
  	    status = AKLOG_TOKEN;
  	}
  #else /* WINDOWS */
  	/* Note switched 2nd and 3rd args */
  	if ((status = ktc_SetToken(&aserver, &atoken, &aclient, afssetpag))) {
  	    switch(status) {
  	    case KTC_INVAL:
! 		fprintf(stderr, "%s: Bad ticket length", progname);
  		break;
  	    case KTC_PIOCTLFAIL:
! 		fprintf(stderr, "%s: Unknown error contacting AFS service",
  			progname);
  		break;
  	    case KTC_NOCELL:
! 		fprintf(stderr, "%s: Cell name (%s) not recognized by AFS service",
  			progname, realm_of_cell);
  		break;
  	    case KTC_NOCM:
! 		fprintf(stderr, "%s: AFS service is unavailable", progname);
  		break;
  	    default:
! 		fprintf(stderr, "%s: Undocumented error (%d) contacting AFS service", progname, status);
  		break;	
  	    }
  	    status = AKLOG_TOKEN;	    
  	}
  #endif /* !WINDOWS */
      }
      else
  	if (dflag) {
! 	    printf("Noauth mode; not authenticating.\n");
  	}
  	
      return(status);
***************
*** 979,990 ****
  	    ? 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)
--- 968,978 ----
  	    ? elast_comp - last_comp : strlen(last_comp);
  	strncat(pathtocheck, last_comp, len);
  	memset(linkbuf, 0, sizeof(linkbuf));
! 	if ((link = readlink(pathtocheck, linkbuf, 
! 				    sizeof(linkbuf))) > 0) {
  	    if (++symlinkcount > MAXSYMLINKS) {
! 		fprintf(stderr, "%s: %s\n", progname, strerror(ELOOP));
! 		exit(AKLOG_BADPATH);
  	    }
  	    memset(tmpbuf, 0, sizeof(tmpbuf));
  	    if (elast_comp)
***************
*** 1083,1090 ****
      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)) {
--- 1071,1077 ----
      vio.out = outbuf;
  
      if (dflag) {
! 	printf("Getting list of hosts for %s\n", file);
      }
      /* Don't worry about errors. */
      if (!pioctl(file, VIOCWHEREIS, &vio, 1)) {
***************
*** 1110,1124 ****
  	    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);
  	    }
--- 1097,1109 ----
  	    if (hosts) {
  		in.s_addr = phosts[i];
  		if (dflag) {
! 		    printf("Got host %s\n", inet_ntoa(in));
  		}
  		ll_string(&hostlist, ll_s_add, (char *)inet_ntoa(in));
  	    }
  	    if (zsubs && (hp=gethostbyaddr((char *) &phosts[i],sizeof(long),AF_INET))) {
  		if (dflag) {
! 		    printf("Got host %s\n", hp->h_name);
  		}
  		ll_string(&zsublist, ll_s_add, hp->h_name);
  	    }
***************
*** 1152,1171 ****
      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);
--- 1137,1153 ----
      char *cell;
      char *endofcell;
  
!     u_char isdirectory;
  
      /* Initialize */
      if (path[0] == DIR)
  	strcpy(pathtocheck, path);
      else {
! 	if (getwd(pathtocheck) == NULL) {
! 	    fprintf(stderr, "Unable to find current working directory:\n");
! 	    fprintf(stderr, "%s\n", pathtocheck);
! 	    fprintf(stderr, "Try an absolute pathname.\n");
! 	    exit(AKLOG_BADPATH);
  	}
  	else {
  	    strcat(pathtocheck, DIRSTRING);
***************
*** 1178,1185 ****
      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 
--- 1160,1166 ----
      while ((nextpath = next_path(NULL))) {
  	strcpy(pathtocheck, nextpath);
  	if (dflag) {
! 	    printf("Checking directory %s\n", pathtocheck);
  	}
  	/* 
  	 * If this is an afs mountpoint, determine what cell from 
***************
*** 1205,1225 ****
  	    }
  	}
  	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);
  	    }
  	}
--- 1186,1204 ----
  	    }
  	}
  	else {
! 	    if (isdir(pathtocheck, &isdirectory) < 0) {
  		/*
  		 * If we've logged and still can't stat, there's
  		 * a problem... 
  		 */
! 		fprintf(stderr, "%s: stat(%s): %s\n", progname, 
  			pathtocheck, strerror(errno));
  		return(AKLOG_BADPATH);
  	    }
! 	    else if (! isdirectory) {
  		/* Allow only directories */
! 		fprintf(stderr, "%s: %s: %s\n", progname, pathtocheck,
  			strerror(ENOTDIR));
  		return(AKLOG_BADPATH);
  	    }
  	}
***************
*** 1239,1288 ****
  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;
--- 1218,1247 ----
  static void usage()
  #endif /* __STDC__ */
  {
!     fprintf(stderr, "\nUsage: %s %s%s%s\n", progname,
  	    "[-d] [[-cell | -c] cell [-k krb_realm]] ",
  	    "[[-p | -path] pathname]\n",
! 	    "    [-zsubs] [-hosts] [-noauth] [-noprdb] [-force] [-setpag] \n"
! 	    "    [-linked] [-524]\n");
!     fprintf(stderr, "    -d gives debugging information.\n");
!     fprintf(stderr, "    krb_realm is the kerberos realm of a cell.\n");
!     fprintf(stderr, "    pathname is the name of a directory to which ");
!     fprintf(stderr, "you wish to authenticate.\n");
!     fprintf(stderr, "    -zsubs gives zephyr subscription information.\n");
!     fprintf(stderr, "    -hosts gives host address information.\n");
!     fprintf(stderr, "    -noauth does not attempt to get tokens.\n");
!     fprintf(stderr, "    -noprdb means don't try to determine AFS ID.\n");
!     fprintf(stderr, "    -force means replace identical tickets. \n");
!     fprintf(stderr, "    -linked means if AFS node is linked, try both. \n");
!     fprintf(stderr, "    -setpag set the AFS process authentication group.\n");
!     fprintf(stderr, "    -524 means use the 524 converter instead of V5 directly\n");
!     fprintf(stderr, "    No commandline arguments means ");
!     fprintf(stderr, "authenticate to the local cell.\n");
!     fprintf(stderr, "\n");
!     exit(AKLOG_USAGE);
  }
  
! void aklog(int argc, char *argv[])
  {
  	krb5_context context;
      int status = AKLOG_SUCCESS;
***************
*** 1329,1336 ****
  	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);
  
--- 1288,1293 ----
***************
*** 1350,1355 ****
--- 1307,1314 ----
  		linked++;
  	else if (strcmp(argv[i], "-force") == 0)
  	    force++;
+ 	else if (strcmp(argv[i], "-524") == 0)
+ 	    do524++;
      else if (strcmp(argv[i], "-setpag") == 0)
  	    afssetpag++;
  	else if (((strcmp(argv[i], "-cell") == 0) ||
***************
*** 1371,1379 ****
  		usage();
  #else /* WINDOWS */
  	{
! 	    sprintf(msgbuf, "%s: path mode not supported.\n", progname);
! 	    params.pstderr(msgbuf);
! 	    params.exitprog(AKLOG_MISC);
  	}
  #endif /* WINDOWS */
  	    
--- 1330,1337 ----
  		usage();
  #else /* WINDOWS */
  	{
! 	    fprintf(stderr, "%s: path mode not supported.\n", progname);
! 	    exit(AKLOG_MISC);
  	}
  #endif /* WINDOWS */
  	    
***************
*** 1386,1394 ****
  		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 { 
--- 1344,1351 ----
  		pmode++;
  		strcpy(path, argv[i]);
  #else /* WINDOWS */
! 		fprintf(stderr, "%s: path mode not supported.\n", progname);
! 		exit(AKLOG_MISC);
  #endif /* WINDOWS */
  	    }
  	    else { 
***************
*** 1415,1431 ****
  		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;
--- 1372,1386 ----
  		if ((new_cellinfo = copy_cellinfo(&cellinfo)))
  		    ll_add_data(cur_node, new_cellinfo);
  		else {
! 		    fprintf(stderr, 
  			    "%s: failure copying cellinfo.\n", progname);
! 		    exit(AKLOG_MISC);
  		}
  	    }
  	    else {
! 		fprintf(stderr, "%s: failure adding cell to cells list.\n",
  			progname);
! 		exit(AKLOG_MISC);
  	    }
  	    memset(&cellinfo, 0, sizeof(cellinfo));
  	    cmode = FALSE;
***************
*** 1440,1456 ****
  		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));
--- 1395,1409 ----
  		if ((new_path = copy_string(path)))
  		    ll_add_data(cur_node, new_path);
  		else {
! 		    fprintf(stderr, "%s: failure copying path name.\n",
  			    progname);
! 		    exit(AKLOG_MISC);
  		}
  	    }
  	    else {
! 		fprintf(stderr, "%s: failure adding path to paths list.\n",
  			progname);
! 		exit(AKLOG_MISC);
  	    }
  	    pmode = FALSE;
  	    memset(path, 0, sizeof(path));
***************
*** 1502,1510 ****
  		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);
  		}
--- 1455,1461 ----
  		if (!status && linked && linkedcell[0]) {
  				strncpy(linkedcell2,linkedcell,MAXCELLCHARS);
  			    if (dflag) {
! 			        printf("Linked cell: %s\n", linkedcell);
  			    }
  				status = auth_to_cell(context, linkedcell2, NULL);
  		}
***************
*** 1528,1536 ****
  			((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) {
--- 1479,1486 ----
  			((f = fopen(xlog_path, "r")) != NULL)) {
  
  			if (dflag) {
! 			    printf("Reading %s for cells to "
  				    "authenticate to.\n", xlog_path);
  			}
  
  			while (fgets(fcell, 100, f) != NULL) {
***************
*** 1539,1547 ****
  			    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);
--- 1489,1496 ----
  			    fcell[strlen(fcell) - 1] = '\0';
  
  			    if (dflag) {
! 				printf("Found cell %s in %s.\n",
  					fcell, xlog_path);
  			    }
  
  			    auth_status = auth_to_cell(context, fcell, NULL);
***************
*** 1564,1572 ****
  			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)))
--- 1513,1520 ----
  			if (linked && linkedcell[0]) {
  				strncpy(linkedcell2,linkedcell,MAXCELLCHARS);
                  if (dflag) {
!                     printf("Linked cell: %s\n",
                          linkedcell);
                  }
  				if ((status = auth_to_cell(context,linkedcell2,
  							 cellinfo.realm)))
***************
*** 1595,1610 ****
      /* 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);
  }
--- 1543,1646 ----
      /* If we are keeping track of zephyr subscriptions, print them. */
      if (zsubs) 
  	for (cur_node = zsublist.first; cur_node; cur_node = cur_node->next) {
! 	    printf("zsub: %s\n", cur_node->data);
  	}
  
      /* If we are keeping track of host information, print it. */
      if (hosts)
  	for (cur_node = hostlist.first; cur_node; cur_node = cur_node->next) {
! 	    printf("host: %s\n", cur_node->data);
  	}
  
!     exit(status);
! }
! 
! #ifndef HAVE_ADD_TO_ERROR_TABLE
! 
! #define error_table error_table_compat
! #include <afs/error_table.h>
! #undef error_table
! 
! #ifndef HAVE_ADD_ERROR_TABLE
! void add_error_table (const struct error_table *);
! #endif /* !HAVE_ADD_ERROR_TABLE */
! 
! void
! add_to_error_table(struct et_list *new_table)
! {
! 	add_error_table((struct error_table *) new_table->table);
! }
! #endif /* HAVE_ADD_TO_ERROR_TABLE */
! 
! static int isdir(char *path, unsigned char *val)
! {
!     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);
!     }  
! }
! 
! static krb5_error_code get_credv5(krb5_context context, 
! 			char *name, char *inst, char *realm,
! 			krb5_creds **creds)
! {
!     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 r;
!     }
! 
!     if (!_krb425_ccache) {
!         r = krb5_cc_default(context, &_krb425_ccache);
! 	if (r)
! 	    return r;
!     }
!     if (!client_principal) {
!         r = krb5_cc_get_principal(context, _krb425_ccache, &client_principal);
! 	if (r)
! 	    return r;
!     }
! 
!     increds.client = client_principal;
!     increds.times.endtime = 0;
! 	/* Ask for DES since that is what V4 understands */
!     get_creds_enctype((&increds)) = ENCTYPE_DES_CBC_CRC;
! 
!     r = krb5_get_credentials(context, 0, _krb425_ccache, &increds, creds);
! 
!     return r;
! }
! 
! 
! static int get_user_realm(krb5_context context, char *realm)
! {
!     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 = realm_len(context, client_principal);
!     if (i > REALM_SZ-1) i = REALM_SZ-1;
!     strncpy(realm,realm_data(context, client_principal), i);
!     realm[i] = 0;
! 
!     return(0);
  }
Index: openafs/src/aklog/aklog_param.c
diff -c openafs/src/aklog/aklog_param.c:1.1.2.1 openafs/src/aklog/aklog_param.c:removed
*** openafs/src/aklog/aklog_param.c:1.1.2.1	Tue Dec  7 00:51:24 2004
--- openafs/src/aklog/aklog_param.c	Mon Jul 11 23:46:15 2005
***************
*** 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;
- }
--- 0 ----
Index: openafs/src/aklog/krb_util.c
diff -c openafs/src/aklog/krb_util.c:1.1.2.1 openafs/src/aklog/krb_util.c:1.1.2.3
*** openafs/src/aklog/krb_util.c:1.1.2.1	Tue Dec  7 00:51:24 2004
--- openafs/src/aklog/krb_util.c	Mon Jul 11 15:07:00 2005
***************
*** 11,24 ****
  
  #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
--- 11,25 ----
  
  #ifndef lint
  static char rcsid_send_to_kdc_c[] =
! "$Id: krb_util.c,v 1.1.2.3 2005/07/11 19:07:00 shadow Exp $";
  #endif /* lint */
  
  #if 0
  #include <kerberosIV/mit-copyright.h>
  #endif
+ #include <afs/stds.h>
+ #include "aklog.h"
  #include <krb5.h>
  
  #ifndef MAX_HSTNM
  #define MAX_HSTNM 100
Index: openafs/src/audit/audit.c
diff -c openafs/src/audit/audit.c:1.8 openafs/src/audit/audit.c:1.8.2.4
*** openafs/src/audit/audit.c:1.8	Tue Jul 15 19:14:38 2003
--- openafs/src/audit/audit.c	Mon Jul 11 18:13:39 2005
***************
*** 11,22 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/audit/audit.c,v 1.8 2003/07/15 23:14:38 shadow Exp $");
  
  #include <fcntl.h>
  #include <stdarg.h>
  #ifdef AFS_AIX32_ENV
  #include <sys/audit.h>
  #endif /* AFS_AIX32_ENV */
  #include <errno.h>
  
--- 11,29 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/audit/audit.c,v 1.8.2.4 2005/07/11 22:13:39 shadow Exp $");
  
  #include <fcntl.h>
  #include <stdarg.h>
+ #include <string.h>
  #ifdef AFS_AIX32_ENV
  #include <sys/audit.h>
+ #else
+ #define AUDIT_OK 0
+ #define AUDIT_FAIL 1
+ #define AUDIT_FAIL_AUTH 2
+ #define AUDIT_FAIL_ACCESS 3
+ #define AUDIT_FAIL_PRIV 4
  #endif /* AFS_AIX32_ENV */
  #include <errno.h>
  
***************
*** 35,68 ****
  int osi_audit_all = (-1);	/* Not determined yet */
  int osi_echo_trail = (-1);
  
! #ifdef AFS_AIX_ENV /** all these functions are only defined for AIX */
  
! #ifndef	AFS_OSF_ENV
! /*
!  * These variadic functions work under AIX, and not all systems (osf1)
!  */
! /* ************************************************************************** */
! /* AIX requires a buffer filled with values to record with each audit event.
!  * aixmakebuf creates that buffer from the variable list of values we are given.
!  * ************************************************************************** */
! static
! aixmakebuf(audEvent, vaList)
!      char *audEvent;
!      char *vaList;
  {
      int code;
      int vaEntry;
      int vaInt;
      afs_int32 vaLong;
      char *vaStr;
      char *vaLst;
-     char hname[20];
      struct AFSFid *vaFid;
  
      vaEntry = va_arg(vaList, int);
      while (vaEntry != AUD_END) {
  	switch (vaEntry) {
  	case AUD_STR:		/* String */
  	    vaStr = (char *)va_arg(vaList, int);
  	    if (vaStr) {
  		strcpy(bufferPtr, vaStr);
--- 42,70 ----
  int osi_audit_all = (-1);	/* Not determined yet */
  int osi_echo_trail = (-1);
  
! FILE *auditout = NULL;
  
! int osi_audit_check();
! 
! static void
! audmakebuf(char *audEvent, va_list vaList)
  {
+ #ifdef AFS_AIX32_ENV
      int code;
+ #endif
      int vaEntry;
      int vaInt;
      afs_int32 vaLong;
      char *vaStr;
      char *vaLst;
      struct AFSFid *vaFid;
  
      vaEntry = va_arg(vaList, int);
      while (vaEntry != AUD_END) {
  	switch (vaEntry) {
  	case AUD_STR:		/* String */
+         case AUD_NAME:          /* Name */
+         case AUD_ACL:           /* ACL */
  	    vaStr = (char *)va_arg(vaList, int);
  	    if (vaStr) {
  		strcpy(bufferPtr, vaStr);
***************
*** 73,78 ****
--- 75,81 ----
  	    }
  	    break;
  	case AUD_INT:		/* Integer */
+         case AUD_ID:            /* ViceId */
  	    vaInt = va_arg(vaList, int);
  	    *(int *)bufferPtr = vaInt;
  	    bufferPtr += sizeof(vaInt);
***************
*** 86,92 ****
  	    break;
  	case AUD_LST:		/* Ptr to another list */
  	    vaLst = (char *)va_arg(vaList, int);
! 	    aixmakebuf(audEvent, vaLst);
  	    break;
  	case AUD_FID:		/* AFSFid - contains 3 entries */
  	    vaFid = (struct AFSFid *)va_arg(vaList, int);
--- 89,95 ----
  	    break;
  	case AUD_LST:		/* Ptr to another list */
  	    vaLst = (char *)va_arg(vaList, int);
! 	    audmakebuf(audEvent, vaLst);
  	    break;
  	case AUD_FID:		/* AFSFid - contains 3 entries */
  	    vaFid = (struct AFSFid *)va_arg(vaList, int);
***************
*** 112,118 ****
  		    memcpy(bufferPtr, Fids->AFSCBFids_val,
  			   sizeof(struct AFSFid));
  		} else {
- 		    struct AFSFid dummy;
  		    *((u_int *) bufferPtr) = 0;
  		    bufferPtr += sizeof(u_int);
  		    memset(bufferPtr, 0, sizeof(struct AFSFid));
--- 115,120 ----
***************
*** 134,161 ****
      }				/* end while */
  }
  
! static
! printbuf(audEvent, errCode, vaList)
!      char *audEvent;
!      afs_int32 errCode;
!      char *vaList;
  {
      int vaEntry;
      int vaInt;
      afs_int32 vaLong;
      char *vaStr;
      char *vaLst;
-     char hname[20];
      struct AFSFid *vaFid;
      struct AFSCBFids *vaFids;
  
!     if (osi_echo_trail < 0)
! 	osi_audit_check();
!     if (!osi_echo_trail)
! 	return;
! 
      if (strcmp(audEvent, "VALST") != 0)
! 	printf("%s %d ", audEvent, errCode);
  
      vaEntry = va_arg(vaList, int);
      while (vaEntry != AUD_END) {
--- 136,171 ----
      }				/* end while */
  }
  
! static void
! printbuf(FILE *out, int rec, char *audEvent, afs_int32 errCode, va_list vaList)
  {
      int vaEntry;
      int vaInt;
      afs_int32 vaLong;
      char *vaStr;
      char *vaLst;
      struct AFSFid *vaFid;
      struct AFSCBFids *vaFids;
+     int num = LogThreadNum();
+     struct in_addr hostAddr;
+     time_t currenttime;
+     char *timeStamp;
+     char tbuffer[26];
+     
+     /* Don't print the timestamp or thread id if we recursed */
+     if (rec == 0) {
+ 	currenttime = time(0);
+ 	timeStamp = afs_ctime(&currenttime, tbuffer,
+ 			      sizeof(tbuffer));
+ 	timeStamp[24] = ' ';   /* ts[24] is the newline, 25 is the null */
+ 	fprintf(out, timeStamp);
  
! 	if (num > -1)
! 	    fprintf(out, "[%d] ", num);
!     }
!     
      if (strcmp(audEvent, "VALST") != 0)
! 	fprintf(out,  "EVENT %s CODE %d ", audEvent, errCode);
  
      vaEntry = va_arg(vaList, int);
      while (vaEntry != AUD_END) {
***************
*** 163,240 ****
  	case AUD_STR:		/* String */
  	    vaStr = (char *)va_arg(vaList, int);
  	    if (vaStr)
! 		printf("%s ", vaStr);
  	    else
! 		printf("<null>", vaStr);
  	    break;
  	case AUD_INT:		/* Integer */
  	    vaInt = va_arg(vaList, int);
! 	    printf("%d ", vaInt);
  	    break;
  	case AUD_DATE:		/* Date    */
  	case AUD_HOST:		/* Host ID */
  	    vaLong = va_arg(vaList, afs_int32);
! 	    printf("%u ", vaLong);
  	    break;
  	case AUD_LONG:		/* afs_int32    */
  	    vaLong = va_arg(vaList, afs_int32);
! 	    printf("%d ", vaLong);
  	    break;
  	case AUD_LST:		/* Ptr to another list */
  	    vaLst = (char *)va_arg(vaList, int);
! 	    printbuf("VALST", 0, vaLst);
  	    break;
  	case AUD_FID:		/* AFSFid - contains 3 entries */
  	    vaFid = (struct AFSFid *)va_arg(vaList, int);
  	    if (vaFid)
! 		printf("%u:%u:%u ", vaFid->Volume, vaFid->Vnode,
  		       vaFid->Unique);
  	    else
! 		printf("%u:%u:%u ", 0, 0, 0);
  	    break;
  	case AUD_FIDS:		/* array of Fids */
  	    vaFids = (struct AFSCBFids *)va_arg(vaList, int);
  	    vaFid = NULL;
  
! 	    if (vaFids)
! 		vaFid = vaFids->AFSCBFids_val;
! 	    if (vaFid)
! 		printf("%u %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume,
! 		       vaFid->Vnode, vaFid->Unique);
! 	    else
! 		printf("0 0:0:0 ");
  	    break;
  	default:
! 	    printf("--badval-- ");
  	    break;
  	}			/* end switch */
  	vaEntry = va_arg(vaList, int);
      }				/* end while */
  
      if (strcmp(audEvent, "VALST") != 0)
! 	printf("\n");
! }
! #else
! static
! aixmakebuf(audEvent, vaList)
!      char *audEvent;
!      va_list vaList;
! {
!     return;
! }
! 
! static
! printbuf(audEvent, errCode, vaList)
!      char *audEvent;
!      long errCode;
!      va_list vaList;
! {
!     return;
  }
  
- #endif
- 
- 
  /* ************************************************************************** */
  /* The routine that acually does the audit call.
   * ************************************************************************** */
--- 173,262 ----
  	case AUD_STR:		/* String */
  	    vaStr = (char *)va_arg(vaList, int);
  	    if (vaStr)
! 		fprintf(out,  "STR %s ", vaStr);
! 	    else
! 		fprintf(out,  "STR <null>");
! 	    break;
! 	case AUD_NAME:		/* Name */
! 	    vaStr = (char *)va_arg(vaList, int);
! 	    if (vaStr)
! 		fprintf(out,  "NAME %s ", vaStr);
! 	    else
! 		fprintf(out,  "NAME <null>");
! 	    break;
! 	case AUD_ACL:		/* ACL */
! 	    vaStr = (char *)va_arg(vaList, int);
! 	    if (vaStr)
! 		fprintf(out,  "ACL %s ", vaStr);
  	    else
! 		fprintf(out,  "ACL <null>");
  	    break;
  	case AUD_INT:		/* Integer */
  	    vaInt = va_arg(vaList, int);
! 	    fprintf(out,  "INT %d ", vaInt);
! 	    break;
! 	case AUD_ID:		/* ViceId */
! 	    vaInt = va_arg(vaList, int);
! 	    fprintf(out,  "ID %d ", vaInt);
  	    break;
  	case AUD_DATE:		/* Date    */
+ 	    vaLong = va_arg(vaList, afs_int32);
+ 	    fprintf(out, "DATE %u ", vaLong);
+ 	    break;
  	case AUD_HOST:		/* Host ID */
  	    vaLong = va_arg(vaList, afs_int32);
!             hostAddr.s_addr = vaLong;
! 	    fprintf(out, "HOST %s ", inet_ntoa(hostAddr));
  	    break;
  	case AUD_LONG:		/* afs_int32    */
  	    vaLong = va_arg(vaList, afs_int32);
! 	    fprintf(out, "LONG %d ", vaLong);
  	    break;
  	case AUD_LST:		/* Ptr to another list */
  	    vaLst = (char *)va_arg(vaList, int);
! 	    printbuf(out, 1, "VALST", 0, vaLst);
  	    break;
  	case AUD_FID:		/* AFSFid - contains 3 entries */
  	    vaFid = (struct AFSFid *)va_arg(vaList, int);
  	    if (vaFid)
! 		fprintf(out, "FID %u:%u:%u ", vaFid->Volume, vaFid->Vnode,
  		       vaFid->Unique);
  	    else
! 		fprintf(out, "FID %u:%u:%u ", 0, 0, 0);
  	    break;
  	case AUD_FIDS:		/* array of Fids */
  	    vaFids = (struct AFSCBFids *)va_arg(vaList, int);
  	    vaFid = NULL;
  
! 	    if (vaFids) {
!                 int i;
!                 if (vaFid)
!                     fprintf(out, "FIDS %u FID %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume,
!                              vaFid->Vnode, vaFid->Unique);
!                 else
!                     fprintf(out, "FIDS 0 FID 0:0:0 ");
! 
!                 for ( i = 1; i < vaFids->AFSCBFids_len; i++ ) {
!                     vaFid = vaFids->AFSCBFids_val;
!                     if (vaFid)
!                         fprintf(out, "FID %u:%u:%u ", vaFid->Volume,
!                                  vaFid->Vnode, vaFid->Unique);
!                     else
!                         fprintf(out, "FID 0:0:0 ");
!                 }
!             }
  	    break;
  	default:
! 	    fprintf(out, "--badval-- ");
  	    break;
  	}			/* end switch */
  	vaEntry = va_arg(vaList, int);
      }				/* end while */
  
      if (strcmp(audEvent, "VALST") != 0)
! 	fprintf(out, "\n");
  }
  
  /* ************************************************************************** */
  /* The routine that acually does the audit call.
   * ************************************************************************** */
***************
*** 246,254 ****
--- 268,278 ----
  #ifdef AFS_AIX32_ENV
      afs_int32 code;
      afs_int32 err;
+ #endif
      int result;
  
      va_list vaList;
+ #ifdef AFS_AIX32_ENV
      static struct Lock audbuflock = { 0, 0, 0, 0,
  #ifdef AFS_PTHREAD_ENV
  	PTHREAD_MUTEX_INITIALIZER,
***************
*** 257,267 ****
  #endif /* AFS_PTHREAD_ENV */
      };
      static char BUFFER[32768];
  
!     if (osi_audit_all < 0)
  	osi_audit_check();
!     if (!osi_audit_all)
! 	return;
  
      switch (errCode) {
      case 0:
--- 281,292 ----
  #endif /* AFS_PTHREAD_ENV */
      };
      static char BUFFER[32768];
+ #endif
  
!     if ((osi_audit_all < 0) || (osi_echo_trail < 0))
  	osi_audit_check();
!     if (!osi_audit_all && !auditout)
! 	return 0;
  
      switch (errCode) {
      case 0:
***************
*** 278,284 ****
  	break;
      case VL_PERM:		/* vlserver.h  */
      case BUDB_NOTPERMITTED:	/* budb_errs.h */
- /*  case KRB_RD_AP_UNAUTHOR : */
      case BZACCESS:		/* bnode.h     */
      case VOLSERBAD_ACCESS:	/* volser.h    */
  	result = AUDIT_FAIL_PRIV;
--- 303,308 ----
***************
*** 288,293 ****
--- 312,318 ----
  	break;
      }
  
+ #ifdef AFS_AIX32_ENV
      ObtainWriteLock(&audbuflock);
      bufferPtr = BUFFER;
  
***************
*** 296,306 ****
      bufferPtr += sizeof(errCode);
  
      va_start(vaList, errCode);
!     aixmakebuf(audEvent, vaList);
  
!     va_start(vaList, errCode);
!     printbuf(audEvent, errCode, vaList);
  
      bufferLen = (int)((afs_int32) bufferPtr - (afs_int32) & BUFFER[0]);
      code = auditlog(audEvent, result, BUFFER, bufferLen);
  #ifdef notdef
--- 321,335 ----
      bufferPtr += sizeof(errCode);
  
      va_start(vaList, errCode);
!     audmakebuf(audEvent, vaList);
! #endif
  
!     if (osi_echo_trail) {
! 	va_start(vaList, errCode);
! 	printbuf(stdout, 0, audEvent, errCode, vaList);
!     }
  
+ #ifdef AFS_AIX32_ENV
      bufferLen = (int)((afs_int32) bufferPtr - (afs_int32) & BUFFER[0]);
      code = auditlog(audEvent, result, BUFFER, bufferLen);
  #ifdef notdef
***************
*** 312,318 ****
--- 341,355 ----
      }
  #endif /* notdef */
      ReleaseWriteLock(&audbuflock);
+ #else
+     if (auditout) {
+ 	va_start(vaList, errCode);
+ 	printbuf(auditout, 0, audEvent, errCode, vaList);
+ 	fflush(auditout);
+     }
  #endif
+ 
+     return 0;
  }
  
  /* ************************************************************************** */
***************
*** 330,340 ****
      afs_int32 hostId;
      va_list vaList;
  
- 
      if (osi_audit_all < 0)
  	osi_audit_check();
!     if (!osi_audit_all)
! 	return;
  
      strcpy(afsName, "--Unknown--");
      hostId = 0;
--- 367,376 ----
      afs_int32 hostId;
      va_list vaList;
  
      if (osi_audit_all < 0)
  	osi_audit_check();
!     if (!osi_audit_all && !auditout)
! 	return 0;
  
      strcpy(afsName, "--Unknown--");
      hostId = 0;
***************
*** 342,383 ****
      if (call) {
  	conn = rx_ConnectionOf(call);	/* call -> conn) */
  	if (conn) {
! 	    secClass = rx_SecurityClassOf(conn);	/* conn -> securityIndex */
  	    if (secClass == 0) {	/* unauthenticated */
  		osi_audit("AFS_Aud_Unauth", (-1), AUD_STR, audEvent, AUD_END);
  		strcpy(afsName, "--UnAuth--");
  	    } else if (secClass == 2) {	/* authenticated */
! 		code =
! 		    rxkad_GetServerInfo(conn, NULL, NULL, afsName, NULL, NULL,
  					NULL);
  		if (code) {
! 		    osi_audit("AFS_Aud_NoAFSId", (-1), AUD_STR, audEvent,
! 			      AUD_END);
  		    strcpy(afsName, "--NoName--");
! 		}
  	    } else {		/* Unauthenticated & unknown */
! 
! 		osi_audit("AFS_Aud_UnknSec", (-1), AUD_STR, audEvent,
! 			  AUD_END);
  	    }
! 
  	    peer = rx_PeerOf(conn);	/* conn -> peer */
  	    if (peer)
  		hostId = rx_HostOf(peer);	/* peer -> host */
  	    else
  		osi_audit("AFS_Aud_NoHost", (-1), AUD_STR, audEvent, AUD_END);
  	} else {		/* null conn */
- 
  	    osi_audit("AFS_Aud_NoConn", (-1), AUD_STR, audEvent, AUD_END);
  	}
      } else {			/* null call */
- 
  	osi_audit("AFS_Aud_NoCall", (-1), AUD_STR, audEvent, AUD_END);
      }
- 
      va_start(vaList, errCode);
!     osi_audit(audEvent, errCode, AUD_STR, afsName, AUD_HOST, hostId, AUD_LST,
! 	      vaList, AUD_END);
  }
  
  /* ************************************************************************** */
--- 378,446 ----
      if (call) {
  	conn = rx_ConnectionOf(call);	/* call -> conn) */
  	if (conn) {
!             secClass = rx_SecurityClassOf(conn);	/* conn -> securityIndex */
  	    if (secClass == 0) {	/* unauthenticated */
  		osi_audit("AFS_Aud_Unauth", (-1), AUD_STR, audEvent, AUD_END);
  		strcpy(afsName, "--UnAuth--");
  	    } else if (secClass == 2) {	/* authenticated */
!                 char tcell[MAXKTCREALMLEN];
!                 char name[MAXKTCNAMELEN];
!                 char inst[MAXKTCNAMELEN];
!                 char vname[256];
!                 int  ilen, clen;
! 
!                 code =
! 		    rxkad_GetServerInfo(conn, NULL, NULL, name, inst, tcell,
  					NULL);
  		if (code) {
! 		    osi_audit("AFS_Aud_NoAFSId", (-1), AUD_STR, audEvent, AUD_END);
  		    strcpy(afsName, "--NoName--");
! 		} else {
!                     strncpy(vname, name, sizeof(vname));
!                     if ((ilen = strlen(inst))) {
!                         if (strlen(vname) + 1 + ilen >= sizeof(vname))
!                             goto done;
!                         strcat(vname, ".");
!                         strcat(vname, inst);
!                     }
!                     if ((clen = strlen(tcell))) {
! #if defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
!                         static char local_realm[AFS_REALM_SZ] = "";
!                         if (!local_realm[0]) {
!                             if (afs_krb_get_lrealm(local_realm, 0) != 0 /*KSUCCESS*/)
!                                 strncpy(local_realm, "UNKNOWN.LOCAL.REALM", AFS_REALM_SZ);
!                         }
!                         if (strcasecmp(local_realm, tcell)) {
!                             if (strlen(vname) + 1 + clen >= sizeof(vname))
!                                 goto done;
!                             strcat(vname, "@");
!                             strcat(vname, tcell);
!                         }
! #endif
!                     }
!                     strcpy(afsName, vname);
!                 }
  	    } else {		/* Unauthenticated & unknown */
! 		osi_audit("AFS_Aud_UnknSec", (-1), AUD_STR, audEvent, AUD_END);
!                 strcpy(afsName, "--Unknown--");
  	    }
! 	done:
  	    peer = rx_PeerOf(conn);	/* conn -> peer */
  	    if (peer)
  		hostId = rx_HostOf(peer);	/* peer -> host */
  	    else
  		osi_audit("AFS_Aud_NoHost", (-1), AUD_STR, audEvent, AUD_END);
  	} else {		/* null conn */
  	    osi_audit("AFS_Aud_NoConn", (-1), AUD_STR, audEvent, AUD_END);
  	}
      } else {			/* null call */
  	osi_audit("AFS_Aud_NoCall", (-1), AUD_STR, audEvent, AUD_END);
      }
      va_start(vaList, errCode);
!     osi_audit(audEvent, errCode, AUD_NAME, afsName, AUD_HOST, hostId, 
!               AUD_LST, vaList, AUD_END);
! 
!     return 0;
  }
  
  /* ************************************************************************** */
***************
*** 418,438 ****
  
      /* Now set whether we audit all events from here on out */
      osi_audit_all = onoff;
- }
- 
  
- #else /* ! AFS_AIX_ENV */
- 
- int
- osi_audit(char *audEvent, afs_int32 errCode, ...)
- {
      return 0;
  }
  
  int
! osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...)
  {
      return 0;
  }
- 
- #endif
--- 481,493 ----
  
      /* Now set whether we audit all events from here on out */
      osi_audit_all = onoff;
  
      return 0;
  }
  
  int
! osi_audit_file(FILE *out)
  {
+     auditout = out;
      return 0;
  }
Index: openafs/src/audit/audit.h
diff -c openafs/src/audit/audit.h:1.5 openafs/src/audit/audit.h:1.5.2.3
*** openafs/src/audit/audit.h:1.5	Tue Jul 15 19:14:38 2003
--- openafs/src/audit/audit.h	Mon Jul 11 15:29:18 2005
***************
*** 7,13 ****
   * directory or online at http://www.openafs.org/dl/license10.html
   */
  
! #define AUD_END  0		/* End           of veriable list */
  #define AUD_STR  1		/* String        in variable list */
  #define AUD_INT  2		/* int           in variable list */
  #define AUD_LST  3		/* Variable list in a variable list */
--- 7,13 ----
   * directory or online at http://www.openafs.org/dl/license10.html
   */
  
! #define AUD_END  0		/* End           of variable list */
  #define AUD_STR  1		/* String        in variable list */
  #define AUD_INT  2		/* int           in variable list */
  #define AUD_LST  3		/* Variable list in a variable list */
***************
*** 16,21 ****
--- 16,24 ----
  #define AUD_DATE 6		/* date (unsigned long)           */
  #define AUD_FID  7		/* File ID                        */
  #define AUD_FIDS 8		/* array of Fids                  */
+ #define AUD_NAME 9              /* Name */
+ #define AUD_ID   10             /* Id (Vice, PTS, ...) */
+ #define AUD_ACL  11             /* ACL */
  /* next 3 lines on behalf of MR-AFS */
  #define AUD_RESID 20		/* resid         in variable list */
  #define AUD_RSSIZERANGE 21	/* rssizerange   in variable list */
***************
*** 94,99 ****
--- 97,103 ----
  #define PTS_LstEleEvent    "AFS_PTS_LstEle"
  #define PTS_LstOwnEvent    "AFS_PTS_LstOwn"
  #define PTS_IsMemOfEvent   "AFS_PTS_IsMemOf"
+ #define PTS_UpdEntEvent    "AFS_PTS_UpdEnt"
  
  #define BUDB_StartEvent    "AFS_BUDB_Start"
  #define BUDB_FinishEvent   "AFS_BUDB_Finish"
***************
*** 171,176 ****
--- 175,181 ----
  #define SetLockEvent		"AFS_SRX_SetLock"
  #define ExtendLockEvent		"AFS_SRX_ExtLock"
  #define ReleaseLockEvent	"AFS_SRX_RelLock"
+ #define GetVolumeStatusEvent    "AFS_SRX_GetVolS"
  #define SetVolumeStatusEvent    "AFS_SRX_SetVolS"
  #define FlushCPSEvent           "AFS_SRX_FlusCPS"
  #define InlineBulkFetchStatusEvent     "AFS_SRX_BIFchSt"
***************
*** 182,187 ****
--- 187,194 ----
  #define ImportResidenciesEvent  "AFS_SRX_Import"
  #define GetExtendedVolumeAttributesEvent "AFS_SRX_GetVA"
  #define SetExtendedVolumeAttributesEvent "AFS_SRX_SetVA"
+ #define GetStatisticsEvent      "AFS_SRX_GetStats"
+ #define XStatsVersionEvent      "AFS_SRX_XStatsVer"
  
  #define NoAuthEvent             "AFS_RunNoAuth"
  #define NoAuthDisableEvent      "AFS_NoAuthDsbl"
***************
*** 283,285 ****
--- 290,293 ----
  /* prototypes for audit functions */
  int osi_audit(char *audEvent, afs_int32 errCode, ...);
  int osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...);
+ int osi_audit_file(FILE *out);
Index: openafs/src/bozo/bnode.c
diff -c openafs/src/bozo/bnode.c:1.17 openafs/src/bozo/bnode.c:1.17.2.1
*** openafs/src/bozo/bnode.c:1.17	Tue Jul 15 19:14:42 2003
--- openafs/src/bozo/bnode.c	Mon Jul 11 15:29:32 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bozo/bnode.c,v 1.17 2003/07/15 23:14:42 shadow Exp $");
  
  #include <stddef.h>
  #include <stdlib.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bozo/bnode.c,v 1.17.2.1 2005/07/11 19:29:32 shadow Exp $");
  
  #include <stddef.h>
  #include <stdlib.h>
***************
*** 713,719 ****
      bufp += strlen(bufp);
      (void)sprintf(bufp, "END bnode\n");
      bufp += strlen(bufp);
!     len = (int)bufp - (int)buffer;
      if (write(fd, buffer, len) < 0) {
  	return -1;
      }
--- 713,719 ----
      bufp += strlen(bufp);
      (void)sprintf(bufp, "END bnode\n");
      bufp += strlen(bufp);
!     len = (int)(bufp - buffer);
      if (write(fd, buffer, len) < 0) {
  	return -1;
      }
Index: openafs/src/bozo/bosserver.c
diff -c openafs/src/bozo/bosserver.c:1.23.2.3 openafs/src/bozo/bosserver.c:1.23.2.5
*** openafs/src/bozo/bosserver.c:1.23.2.3	Tue Apr 26 21:37:04 2005
--- openafs/src/bozo/bosserver.c	Mon Jul 11 15:08:36 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bozo/bosserver.c,v 1.23.2.3 2005/04/27 01:37:04 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bozo/bosserver.c,v 1.23.2.5 2005/07/11 19:08:36 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
***************
*** 811,827 ****
--- 811,859 ----
  	    bozo_isrestricted = 1;
  	}
  #endif
+ 	else if (strcmp(argv[code], "-auditlog") == 0) {
+ 	    int tempfd, flags;
+ 	    FILE *auditout;
+ 	    char oldName[MAXPATHLEN];
+ 	    char *fileName = argv[++code];
+ 
+ #ifndef AFS_NT40_ENV
+ 	    struct stat statbuf;
+ 	    
+ 	    if ((lstat(fileName, &statbuf) == 0) 
+ 		&& (S_ISFIFO(statbuf.st_mode))) {
+ 		flags = O_WRONLY | O_NONBLOCK;
+ 	    } else 
+ #endif
+ 	    {
+ 		strcpy(oldName, fileName);
+ 		strcat(oldName, ".old");
+ 		renamefile(fileName, oldName);
+ 		flags = O_WRONLY | O_TRUNC | O_CREAT;
+ 	    }
+ 	    tempfd = open(fileName, flags, 0666);
+ 	    if (tempfd > -1) {
+ 		auditout = fdopen(tempfd, "a");
+ 		if (auditout) {
+ 		    osi_audit_file(auditout);
+ 		} else
+ 		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	    } else
+ 		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	}
  	else {
  
  	    /* hack to support help flag */
  
  #ifndef AFS_NT40_ENV
  	    printf("Usage: bosserver [-noauth] [-log] "
+ 		   "[-auditlog <log path>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-nofork] " "[-help]\n");
  #else
  	    printf("Usage: bosserver [-noauth] [-log] "
+ 		   "[-auditlog <log path>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #endif
***************
*** 870,877 ****
  
      if ((!DoSyslog)
  #ifndef AFS_NT40_ENV
! 	&& (!(fstat(AFSDIR_BOZLOG_FILE, &sb) == 0) && 
! 	(S_ISFIFO(sb.st_mode)))
  #endif
  	) {
  	strcpy(namebuf, AFSDIR_BOZLOG_FILE);
--- 902,909 ----
  
      if ((!DoSyslog)
  #ifndef AFS_NT40_ENV
! 	&& ((lstat(AFSDIR_BOZLOG_FILE, &sb) == 0) && 
! 	!(S_ISFIFO(sb.st_mode)))
  #endif
  	) {
  	strcpy(namebuf, AFSDIR_BOZLOG_FILE);
Index: openafs/src/bucoord/commands.c
diff -c openafs/src/bucoord/commands.c:1.14.2.2 openafs/src/bucoord/commands.c:1.14.2.3
*** openafs/src/bucoord/commands.c:1.14.2.2	Sun Apr  3 14:15:43 2005
--- openafs/src/bucoord/commands.c	Mon Jul 11 15:29:33 2005
***************
*** 11,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bucoord/commands.c,v 1.14.2.2 2005/04/03 18:15:43 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
  #include <afs/cmd.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
--- 11,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bucoord/commands.c,v 1.14.2.3 2005/07/11 19:29:33 shadow Exp $");
  
  #include <afs/stds.h>
+ #if defined(AFS_LINUX24_ENV)
+ #define _REGEX_RE_COMP
+ #endif
  #include <sys/types.h>
+ #if defined(AFS_LINUX24_ENV)
+ #include <regex.h>
+ #endif
  #include <afs/cmd.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
Index: openafs/src/budb/db_text.c
diff -c openafs/src/budb/db_text.c:1.10.2.1 openafs/src/budb/db_text.c:1.10.2.2
*** openafs/src/budb/db_text.c:1.10.2.1	Sun Apr  3 14:15:44 2005
--- openafs/src/budb/db_text.c	Mon Jul 11 15:29:34 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/budb/db_text.c,v 1.10.2.1 2005/04/03 18:15:44 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/budb/db_text.c,v 1.10.2.2 2005/07/11 19:29:34 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
***************
*** 441,447 ****
  
  	    /* now have to update the previous block's link */
  	    linkOffset =
! 		(afs_int32) & diskBlock.h.next - (afs_int32) & diskBlock;
  	    linkValue = htonl(diskBlockAddr);
  
  	    code =
--- 441,447 ----
  
  	    /* now have to update the previous block's link */
  	    linkOffset =
! 		(afs_int32) ((char*)& diskBlock.h.next - (char*)& diskBlock);
  	    linkValue = htonl(diskBlockAddr);
  
  	    code =
Index: openafs/src/budb/server.c
diff -c openafs/src/budb/server.c:1.14 openafs/src/budb/server.c:1.14.2.1
*** openafs/src/budb/server.c:1.14	Thu Mar 11 02:31:46 2004
--- openafs/src/budb/server.c	Mon Jul 11 15:08:36 2005
***************
*** 11,21 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/budb/server.c,v 1.14 2004/03/11 07:31:46 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
- #include <fcntl.h>
  #include <WINNT/afsevent.h>
  #else
  #include <netinet/in.h>
--- 11,22 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/budb/server.c,v 1.14.2.1 2005/07/11 19:08:36 shadow Exp $");
  
+ #include <fcntl.h>
+ #include <sys/stat.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
  #include <WINNT/afsevent.h>
  #else
  #include <netinet/in.h>
***************
*** 75,80 ****
--- 76,89 ----
  /* debugging control */
  int debugging = 0;
  
+ #if defined(AFS_PTHREAD_ENV)
+ char *
+ threadNum(void)
+ {
+     return pthread_getspecific(rx_thread_id_key);
+ }
+ #endif
+ 
  /* check whether caller is authorized to manage RX statistics */
  int
  BU_rxstat_userok(call)
***************
*** 159,164 ****
--- 168,176 ----
      cmd_AddParm(cptr, "-ubikbuffers", CMD_SINGLE, CMD_OPTIONAL,
  		"the number of ubik buffers");
  
+     cmd_AddParm(cptr, "-auditlog", CMD_SINGLE, CMD_OPTIONAL,
+ 		"audit log path");
+ 
  }
  
  int
***************
*** 212,217 ****
--- 224,259 ----
      else
  	ubik_nBuffers = 0;
  
+     if (as->parms[7].items != 0) {
+ 	int tempfd, flags;
+ 	FILE *auditout;
+ 	char oldName[MAXPATHLEN];
+ 	char *fileName = as->parms[7].items->data;
+ #ifndef AFS_NT40_ENV
+ 	struct stat statbuf;
+ 
+ 	if ((lstat(fileName, &statbuf) == 0) 
+ 	    && (S_ISFIFO(statbuf.st_mode))) {
+ 	    flags = O_WRONLY | O_NONBLOCK;
+ 	} else 
+ #endif
+ 	{
+ 	    strcpy(oldName, fileName);
+ 	    strcat(oldName, ".old");
+ 	    renamefile(fileName, oldName);
+ 	    flags = O_WRONLY | O_TRUNC | O_CREAT;
+ 	}
+ 	tempfd = open(fileName, flags, 0666);
+ 	if (tempfd > -1) {
+ 	    auditout = fdopen(tempfd, "a");
+ 	    if (auditout) {
+ 		osi_audit_file(auditout);
+ 	    } else
+ 		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	} else
+ 	    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+     }
+ 
      return 0;
  }
  
***************
*** 389,394 ****
--- 431,440 ----
  
      srandom(1);
  
+ #ifdef AFS_PTHREAD_ENV
+     SetLogThreadNumProgram( threadNum );
+ #endif
+ 
      /* process the user supplied args */
      helpOption = 1;
      code = cmd_Dispatch(argc, argv);
Index: openafs/src/butc/lwps.c
diff -c openafs/src/butc/lwps.c:1.12.2.1 openafs/src/butc/lwps.c:1.12.2.2
*** openafs/src/butc/lwps.c:1.12.2.1	Mon Oct 18 03:11:51 2004
--- openafs/src/butc/lwps.c	Mon Jul 11 15:29:36 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/lwps.c,v 1.12.2.1 2004/10/18 07:11:51 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/lwps.c,v 1.12.2.2 2005/07/11 19:29:36 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 2418,2424 ****
  
  {
      struct volumeHeader vhptr, *tempvhptr;
!     afs_int32 firstSplice = (afs_int32) & vhptr.pad - (afs_int32) & vhptr;
      int padLen = sizeof(vhptr.pad);	/* pad to achieve 4 byte alignment */
      int nextSplice = sizeof(struct volumeHeader) - firstSplice - padLen;
  
--- 2418,2424 ----
  
  {
      struct volumeHeader vhptr, *tempvhptr;
!     afs_int32 firstSplice = (afs_int32) ((char*)& vhptr.pad - (char*) & vhptr);
      int padLen = sizeof(vhptr.pad);	/* pad to achieve 4 byte alignment */
      int nextSplice = sizeof(struct volumeHeader) - firstSplice - padLen;
  
Index: openafs/src/butc/recoverDb.c
diff -c openafs/src/butc/recoverDb.c:1.10.2.2 openafs/src/butc/recoverDb.c:1.10.2.3
*** openafs/src/butc/recoverDb.c:1.10.2.2	Sun Apr  3 14:48:29 2005
--- openafs/src/butc/recoverDb.c	Mon Jul 11 15:29:36 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/recoverDb.c,v 1.10.2.2 2005/04/03 18:48:29 shadow Exp $");
  
  #include <stdio.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/recoverDb.c,v 1.10.2.3 2005/07/11 19:29:36 shadow Exp $");
  
  #include <stdio.h>
  #ifdef AFS_NT40_ENV
***************
*** 909,915 ****
      if (!sptr)
  	return (0);
  
!     c = (int)((afs_int32) sptr - (afs_int32) tapeName);
      if (strncmp(tapeName, DUMP_TAPE_NAME, c) == 0)
  	return (1);
  
--- 909,915 ----
      if (!sptr)
  	return (0);
  
!     c = (int)((char *) sptr - (char *) tapeName);
      if (strncmp(tapeName, DUMP_TAPE_NAME, c) == 0)
  	return (1);
  
Index: openafs/src/cf/kerberos.m4
diff -c /dev/null openafs/src/cf/kerberos.m4:1.1.2.7
*** /dev/null	Mon Jul 11 23:46:15 2005
--- openafs/src/cf/kerberos.m4	Mon Jul 11 15:16:42 2005
***************
*** 0 ****
--- 1,100 ----
+ dnl
+ dnl $Id: kerberos.m4,v 1.1.2.7 2005/07/11 19:16:42 shadow Exp $
+ dnl
+ dnl Kerberos autoconf glue
+ dnl
+ 
+ AC_DEFUN([OPENAFS_KRB5CONF],[
+ 
+ dnl AC_ARG_VAR(KRB5CFLAGS, [C flags to compile Kerberos 5 programs])
+ dnl AC_ARG_VAR(KRB5LIBS, [Libraries and flags to compile Kerberos 5 programs])
+ dnl AC_ARG_VAR(KRB5_CONFIG, [Location of krb5-config script])
+ 
+ AC_ARG_WITH([krb5-conf],[--with-krb5-conf[=krb5-config-location]    Use a krb5-config script to configure Kerberos])
+ if test X$with_krb5_conf != X; then
+ 		conf_krb5=YES
+ 		if test X$with_krb5_conf = Xyes; then
+ 			AC_PATH_PROG(KRB5_CONFIG, krb5-config, not_found)
+ 			if test X$KRB5_CONFIG = Xnot_found; then
+ 				AC_MSG_ERROR([cannot find krb5-config script, you must configure Kerberos manually])
+ 			fi
+ 		else
+ 			KRB5_CONFIG=$withval
+ 		fi
+ 		KRB5CFLAGS=`$KRB5_CONFIG --cflags krb5`
+ 		retval=$?
+ 		if test $retval -ne 0; then
+ 			AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
+ 		fi
+ 		KRB5LIBS=`$KRB5_CONFIG --libs krb5`
+ 		retval=$?
+ 		if test $retval -ne 0; then
+ 			AC_MSG_ERROR([$KRB5_CONFIG failed with an error code of $retval])
+ 		fi
+ 		AC_MSG_RESULT([Adding $KRB5CFLAGS to KRB5CFLAGS])
+ 		AC_MSG_RESULT([Adding $KRB5LIBS to KRB5LIBS])
+ fi
+ 
+ AC_ARG_WITH([krb5], [--with-krb5 Support for Kerberos 5 (manual configuration)])
+ 
+ if test X$with_krb5 = Xyes; then
+         if test X$conf_krb5 = XYES; then
+ 		AC_MSG_ERROR([--with-krb5-config and --with-krb5 are mutually exclusive, choose only one])
+ 	fi
+ 	if test "X$KRB5CFLAGS" = X; then
+ 		AC_MSG_WARN([KRB5CFLAGS is not set])
+ 	fi
+ 	if test "X$KRB5LIBS" = X; then
+ 		AC_MSG_WARN([KRB5LIBS is not set])
+ 	fi
+ 	conf_krb5=YES
+ fi
+ 
+ BUILD_KRB5=no
+ if test X$conf_krb5 = XYES; then
+ 	AC_MSG_RESULT([Configuring support for Kerberos 5 utilities])
+ 	BUILD_KRB5=yes
+ 	save_CPPFLAGS="$CPPFLAGS"
+ 	CPPFLAGS="$CPPFLAGS $KRB5CFLAGS"
+ 	save_LIBS="$LIBS"
+ 	LIBS="$LIBS $KRB5LIBS"
+ 	AC_CHECK_FUNCS([add_to_error_table add_error_table krb5_princ_size krb5_principal_get_comp_string krb5_524_convert_creds krb524_convert_creds_kdc])
+ 	AC_CHECK_HEADERS([kerberosIV/krb.h])
+ 
+ AC_MSG_CHECKING(for krb5_creds.keyblock existence)
+ AC_CACHE_VAL(ac_cv_krb5_creds_keyblock_exists,
+ [
+ AC_TRY_COMPILE(
+ [#include <krb5.h>],
+ [krb5_creds _c;
+ printf("%x\n", _c.keyblock);], 
+ ac_cv_krb5_creds_keyblock_exists=yes,
+ ac_cv_krb5_creds_keyblock_exists=no)])
+ AC_MSG_RESULT($ac_cv_krb5_creds_keyblock_exists)
+ 	
+ AC_MSG_CHECKING(for krb5_creds.session existence)
+ AC_CACHE_VAL(ac_cv_krb5_creds_session_exists,
+ [
+ AC_TRY_COMPILE(
+ [#include <krb5.h>],
+ [krb5_creds _c;
+ printf("%x\n", _c.session);], 
+ ac_cv_krb5_creds_session_exists=yes,
+ ac_cv_krb5_creds_session_exists=no)])
+ AC_MSG_RESULT($ac_cv_krb5_creds_session_exists)
+ 
+ if test "x$ac_cv_krb5_creds_keyblock_exists" = "xyes"; then
+ 	AC_DEFINE(HAVE_KRB5_CREDS_KEYBLOCK, 1, [define if krb5_creds has keyblock])
+ fi
+ if test "x$ac_cv_krb5_creds_session_exists" = "xyes"; then
+ 	AC_DEFINE(HAVE_KRB5_CREDS_SESSION, 1, [define if krb5_creds has session])
+ fi
+ 	
+ dnl	AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.session],,, [#include <krb5.h>])
+ 	CPPFLAGS="$save_CPPFLAGS"
+ 	LIBS="$save_LIBS"
+ fi
+ AC_SUBST(BUILD_KRB5)
+ AC_SUBST(KRB5CFLAGS)
+ AC_SUBST(KRB5LIBS)
+ ])dnl
Index: openafs/src/cf/linux-test2.m4
diff -c openafs/src/cf/linux-test2.m4:1.9 openafs/src/cf/linux-test2.m4:1.9.2.1
*** openafs/src/cf/linux-test2.m4:1.9	Thu Jun  3 01:13:29 2004
--- openafs/src/cf/linux-test2.m4	Mon Jul 11 15:30:01 2005
***************
*** 82,87 ****
  configdir=ifelse([$1], ,[src/config],$1)
  outputdir=ifelse([$2], ,[src/afs/LINUX],$2)
  tmpldir=ifelse([$3], ,[src/afs/LINUX],$3)
! chmod +x $configdir/make_vnode.pl
! $configdir/make_vnode.pl -i $LINUX_KERNEL_PATH -t ${tmpldir} -o $outputdir
  ])
--- 82,88 ----
  configdir=ifelse([$1], ,[src/config],$1)
  outputdir=ifelse([$2], ,[src/afs/LINUX],$2)
  tmpldir=ifelse([$3], ,[src/afs/LINUX],$3)
! cp  $tmpldir/osi_vfs.hin $outputdir/osi_vfs.h
! # chmod +x $configdir/make_vnode.pl
! # $configdir/make_vnode.pl -i $LINUX_KERNEL_PATH -t ${tmpldir} -o $outputdir
  ])
Index: openafs/src/cf/linux-test3.m4
diff -c openafs/src/cf/linux-test3.m4:1.8.2.7 openafs/src/cf/linux-test3.m4:1.8.2.8
*** openafs/src/cf/linux-test3.m4:1.8.2.7	Sun May  8 02:05:27 2005
--- openafs/src/cf/linux-test3.m4	Mon Jul 11 15:41:27 2005
***************
*** 39,62 ****
  else
    save_CPPFLAGS="$CPPFLAGS"
    CPPFLAGS="-I${LINUX_KERNEL_PATH}/include -D__KERNEL__ $RHCONFIG_SP $CPPFLAGS"
-   AC_MSG_CHECKING(if kernel uses MODVERSIONS)
-   AC_CACHE_VAL(ac_cv_linux_config_modversions,[
-   AC_TRY_COMPILE(
- [#include <linux/version.h>
- #include <linux/config.h>
- ],
- [#if !defined(CONFIG_MODVERSIONS)
- lose;
- #endif
- ],
-   ac_cv_linux_config_modversions=yes,
-   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, [
    AC_TRY_COMPILE(
--- 39,47 ----
Index: openafs/src/cf/linux-test4.m4
diff -c openafs/src/cf/linux-test4.m4:1.20.2.6 openafs/src/cf/linux-test4.m4:1.20.2.7
*** openafs/src/cf/linux-test4.m4:1.20.2.6	Wed Apr 13 21:18:49 2005
--- openafs/src/cf/linux-test4.m4	Mon Jul 11 15:30:01 2005
***************
*** 467,469 ****
--- 467,484 ----
  ac_cv_linux_sched_struct_task_struct_has_exit_state=no)])
  AC_MSG_RESULT($ac_cv_linux_sched_struct_task_struct_has_exit_state)
  CPPFLAGS="$save_CPPFLAGS"])
+ 
+ AC_DEFUN([LINUX_FS_STRUCT_SUPER_HAS_ALLOC_INODE], [
+ AC_MSG_CHECKING(for alloc_inode in struct super_operations)
+ 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_fs_struct_super_has_alloc_inode, 
+ [
+ AC_TRY_COMPILE(
+ [#include <linux/fs.h>],
+ [struct super_operations _super;
+ printf("%p\n", _super.alloc_inode);], 
+ ac_cv_linux_fs_struct_super_has_alloc_inode=yes,
+ ac_cv_linux_fs_struct_super_has_alloc_inode=no)])
+ AC_MSG_RESULT($ac_cv_linux_fs_struct_super_has_alloc_inode)
+ CPPFLAGS="$save_CPPFLAGS"])
Index: openafs/src/config/NTMakefile
diff -c openafs/src/config/NTMakefile:1.15.2.1 openafs/src/config/NTMakefile:1.15.2.2
*** openafs/src/config/NTMakefile:1.15.2.1	Mon May 30 01:41:30 2005
--- openafs/src/config/NTMakefile	Sun Jun 12 11:56:49 2005
***************
*** 359,364 ****
--- 359,367 ----
  !	IF (!EXIST($(OJT)\WINNT\install\wix\custom))
  		$(MKDIR) $(OJT)\WINNT\install\wix\custom
  !	ENDIF
+ !	IF (!EXIST($(OJT)\WINNT\install\wix\uninstall))
+ 		$(MKDIR) $(OJT)\WINNT\install\wix\uninstall
+ !	ENDIF
  !	IF (!EXIST($(OJT)\WINNT\install\Win9x))
  		$(MKDIR) $(OJT)\WINNT\install\Win9x
  !	ENDIF
Index: openafs/src/config/NTMakefile.amd64_w2k
diff -c openafs/src/config/NTMakefile.amd64_w2k:1.1.2.9 openafs/src/config/NTMakefile.amd64_w2k:1.1.2.10
*** openafs/src/config/NTMakefile.amd64_w2k:1.1.2.9	Sun Jun  5 10:52:45 2005
--- openafs/src/config/NTMakefile.amd64_w2k	Fri Jul  1 15:47:14 2005
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=8400
  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=8500
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
***************
*** 251,260 ****
  !ENDIF
  
  !IF ("$(AFSVER_CL)"!="1200")
! afscdefs = $(afscdefs) /GT /GS
  #/Wp64
  !IF ("$(AFSVER_CL)"!="1400")
! afscdefs = $(afscdefs) /G7
  !ENDIF
  !ENDIF
  
--- 251,260 ----
  !ENDIF
  
  !IF ("$(AFSVER_CL)"!="1200")
! afscflags = $(afscflags) /GT /GS
  #/Wp64
  !IF ("$(AFSVER_CL)"!="1400")
! afscflags = $(afscflags) /G7
  !ENDIF
  !ENDIF
  
***************
*** 269,277 ****
  cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
  
  !IF ("$(AFSVER_CL)"=="1200")
! afscdefs = $(afscdefs) -DDEBUG /GZ
  !ELSE 
! afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
  !ENDIF
  
  !IFDEF _CRTDBG_MAP_ALLOC
--- 269,279 ----
  cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
  
  !IF ("$(AFSVER_CL)"=="1200")
! afscdefs = $(afscdefs) -DDEBUG
! afscflags = $(afscflags) /GZ
  !ELSE 
! afscdefs = $(afscdefs) -DDEBUG
! afscflags = $(afscflags) /RTCs /RTCu
  !ENDIF
  
  !IFDEF _CRTDBG_MAP_ALLOC
Index: openafs/src/config/NTMakefile.i386_nt40
diff -c openafs/src/config/NTMakefile.i386_nt40:1.46.2.24 openafs/src/config/NTMakefile.i386_nt40:1.46.2.25
*** openafs/src/config/NTMakefile.i386_nt40:1.46.2.24	Sun Jun  5 10:52:45 2005
--- openafs/src/config/NTMakefile.i386_nt40	Fri Jul  1 15:47:14 2005
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=8400
  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=8500
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
***************
*** 249,258 ****
  !ENDIF
  
  !IF ("$(AFSVER_CL)"!="1200")
! afscdefs = $(afscdefs) /GT /GS
  #/Wp64
  !IF ("$(AFSVER_CL)"!="1400")
! afscdefs = $(afscdefs) /G7
  !ENDIF
  !ENDIF
  
--- 249,258 ----
  !ENDIF
  
  !IF ("$(AFSVER_CL)"!="1200")
! afscflags = $(afscflags) /GT /GS
  #/Wp64
  !IF ("$(AFSVER_CL)"!="1400")
! afscflags = $(afscflags) /G7
  !ENDIF
  !ENDIF
  
***************
*** 267,275 ****
  cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
  
  !IF ("$(AFSVER_CL)"=="1200")
! afscdefs = $(afscdefs) -DDEBUG /GZ
  !ELSE 
! afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
  !ENDIF
  
  !IFDEF _CRTDBG_MAP_ALLOC
--- 267,277 ----
  cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
  
  !IF ("$(AFSVER_CL)"=="1200")
! afscdefs = $(afscdefs) -DDEBUG
! afscflags = $(afscflags) /GZ
  !ELSE 
! afscdefs = $(afscdefs) -DDEBUG
! afscflags = $(afscflags) /RTCs /RTCu
  !ENDIF
  
  !IFDEF _CRTDBG_MAP_ALLOC
Index: openafs/src/config/NTMakefile.i386_w2k
diff -c openafs/src/config/NTMakefile.i386_w2k:1.1.2.9 openafs/src/config/NTMakefile.i386_w2k:1.1.2.10
*** openafs/src/config/NTMakefile.i386_w2k:1.1.2.9	Sun Jun  5 10:52:45 2005
--- openafs/src/config/NTMakefile.i386_w2k	Fri Jul  1 15:47:14 2005
***************
*** 80,86 ****
  #define used in WinNT/2000 installation and program version display
  AFSPRODUCT_VER_MAJOR=1
  AFSPRODUCT_VER_MINOR=3
! AFSPRODUCT_VER_PATCH=8400
  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=8500
  AFSPRODUCT_VER_BUILD=0
  
  # For MSI installer, each major release should have a different GUID
***************
*** 249,258 ****
  !ENDIF
  
  !IF ("$(AFSVER_CL)"!="1200")
! afscdefs = $(afscdefs) /GT /GS
  #/Wp64
  !IF ("$(AFSVER_CL)"!="1400")
! afscdefs = $(afscdefs) /G7
  !ENDIF
  !ENDIF
  
--- 249,258 ----
  !ENDIF
  
  !IF ("$(AFSVER_CL)"!="1200")
! afscflags = $(afscflags) /GT /GS
  #/Wp64
  !IF ("$(AFSVER_CL)"!="1400")
! afscflags = $(afscflags) /G7
  !ENDIF
  !ENDIF
  
***************
*** 267,275 ****
  cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
  
  !IF ("$(AFSVER_CL)"=="1200")
! afscdefs = $(afscdefs) -DDEBUG /GZ
  !ELSE 
! afscdefs = $(afscdefs) -DDEBUG /RTCs /RTCu
  !ENDIF
  
  !IFDEF _CRTDBG_MAP_ALLOC
--- 267,277 ----
  cdebug = $(cdebug:-Z7=-Zi)  # avoid annoying override warning (D4025)
  
  !IF ("$(AFSVER_CL)"=="1200")
! afscdefs = $(afscdefs) -DDEBUG
! afscflags = $(afscflags) /GZ
  !ELSE 
! afscdefs = $(afscdefs) -DDEBUG
! afscflags = $(afscflags) /RTCs /RTCu
  !ENDIF
  
  !IFDEF _CRTDBG_MAP_ALLOC
Index: openafs/src/config/afs_args.h
diff -c openafs/src/config/afs_args.h:1.13.2.5 openafs/src/config/afs_args.h:1.13.2.6
*** openafs/src/config/afs_args.h:1.13.2.5	Sun May  8 01:04:17 2005
--- openafs/src/config/afs_args.h	Tue Jun 21 16:13:54 2005
***************
*** 47,53 ****
  #define AFSOP_BASIC_INIT	 36	/* used to be part of START_AFS */
  #define AFSOP_SET_BACKUPTREE	 37	/* enable backup tree support */
  #define AFSOP_SET_RXPCK		 38	/*set rx_extraPackets*/
- #define AFSOP_BUCKETPCT          39     /* bucket percentage */
  
  /* The range 20-30 is reserved for AFS system offsets in the afs_syscall */
  #define	AFSCALL_PIOCTL		20
--- 47,52 ----
Index: openafs/src/config/param.amd64_w2k.h
diff -c /dev/null openafs/src/config/param.amd64_w2k.h:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:15 2005
--- openafs/src/config/param.amd64_w2k.h	Wed Jul  6 01:11:31 2005
***************
*** 0 ****
--- 1,73 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ 
+ #define AFS_NT40_ENV        1
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV       1	/* User space interface to file system */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ 
+ #include <afs/afs_sysnames.h>
+ #define SYS_NAME_ID	SYS_NAME_ID_amd64_w2k
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stddef.h>
+ 
+ /*
+  * NT makes size_t a typedef for unsigned int (e.g. in <stddef.h>)
+  * and has no typedef for ssize_t (a signed size_t).
+  * So, we make our own.
+  */
+ typedef int ssize_t;
+ 
+ /* these macros define Unix-style functions missing in  VC++5.0/NT4.0 */
+ #define MAXPATHLEN _MAX_PATH
+ 
+ #if 0
+ #define memset(A, 0, S) memset((void*)(A), 0, (size_t)(S))
+ #define memcpy(B, A, S) memcpy((void*)(B), (void*)(A), (size_t)(S))
+ /* There is a minor syntactic difference between memcmp and bcmp... */
+ #define memcmp(A, B, S) (memcmp((void*)(A), (void*)(B), (size_t)(S)) ? 1 : 0)
+ #define strchr(s, c)             strchr(s, c)
+ #define strrchr(s, c)            strrchr(s, c)
+ #endif
+ #define strcasecmp(s1,s2)       _stricmp(s1,s2)
+ #define strncasecmp(s1,s2,n)    _strnicmp(s1,s2,n)
+ #define sleep(seconds)          Sleep((seconds) * 1000)
+ #define fsync(fileno)           _commit(fileno)
+ #define ftruncate(fd, size)     _chsize((fd), (long)(size))
+ #define strtoll(str, cp, base)  strtoi64((str), (cp), (base))
+ #define strtoull(str, cp, base) strtoui64((str), (cp), (base))
+ 
+ #define random()                rand()
+ #define srandom(a)              srand(a)
+ 
+ #define popen(cmd, mode)        _popen((cmd), (mode))
+ #define pclose(stream)          _pclose(stream)
+ typedef char *caddr_t;
+ 
+ #define pipe(fdp)               _pipe(fdp, 4096, _O_BINARY)
+ 
+ #define snprintf                _snprintf
+ #endif /* AFS_PARAM_H */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/config/param.i386_w2k.h
diff -c /dev/null openafs/src/config/param.i386_w2k.h:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:15 2005
--- openafs/src/config/param.i386_w2k.h	Wed Jul  6 01:11:31 2005
***************
*** 0 ****
--- 1,73 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ 
+ #define AFS_NT40_ENV        1
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV       1	/* User space interface to file system */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ 
+ #include <afs/afs_sysnames.h>
+ #define SYS_NAME_ID	SYS_NAME_ID_i386_w2k
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stddef.h>
+ 
+ /*
+  * NT makes size_t a typedef for unsigned int (e.g. in <stddef.h>)
+  * and has no typedef for ssize_t (a signed size_t).
+  * So, we make our own.
+  */
+ typedef int ssize_t;
+ 
+ /* these macros define Unix-style functions missing in  VC++5.0/NT4.0 */
+ #define MAXPATHLEN _MAX_PATH
+ 
+ #if 0
+ #define memset(A, 0, S) memset((void*)(A), 0, (size_t)(S))
+ #define memcpy(B, A, S) memcpy((void*)(B), (void*)(A), (size_t)(S))
+ /* There is a minor syntactic difference between memcmp and bcmp... */
+ #define memcmp(A, B, S) (memcmp((void*)(A), (void*)(B), (size_t)(S)) ? 1 : 0)
+ #define strchr(s, c)             strchr(s, c)
+ #define strrchr(s, c)            strrchr(s, c)
+ #endif
+ #define strcasecmp(s1,s2)       _stricmp(s1,s2)
+ #define strncasecmp(s1,s2,n)    _strnicmp(s1,s2,n)
+ #define sleep(seconds)          Sleep((seconds) * 1000)
+ #define fsync(fileno)           _commit(fileno)
+ #define ftruncate(fd, size)     _chsize((fd), (long)(size))
+ #define strtoll(str, cp, base)  strtoi64((str), (cp), (base))
+ #define strtoull(str, cp, base) strtoui64((str), (cp), (base))
+ 
+ #define random()                rand()
+ #define srandom(a)              srand(a)
+ 
+ #define popen(cmd, mode)        _popen((cmd), (mode))
+ #define pclose(stream)          _pclose(stream)
+ typedef char *caddr_t;
+ 
+ #define pipe(fdp)               _pipe(fdp, 4096, _O_BINARY)
+ 
+ #define snprintf                _snprintf
+ #endif /* AFS_PARAM_H */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/config/param.i64_w2k.h
diff -c /dev/null openafs/src/config/param.i64_w2k.h:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:15 2005
--- openafs/src/config/param.i64_w2k.h	Wed Jul  6 01:11:31 2005
***************
*** 0 ****
--- 1,73 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef AFS_PARAM_H
+ #define AFS_PARAM_H
+ 
+ 
+ #define AFS_NT40_ENV        1
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_64BIT_IOPS_ENV  1
+ #define AFS_NAMEI_ENV       1	/* User space interface to file system */
+ #define AFS_HAVE_STATVFS    0	/* System doesn't support statvfs */
+ 
+ #include <afs/afs_sysnames.h>
+ #define SYS_NAME_ID	SYS_NAME_ID_i64_w2k
+ 
+ #include <stdlib.h>
+ #include <string.h>
+ #include <stddef.h>
+ 
+ /*
+  * NT makes size_t a typedef for unsigned int (e.g. in <stddef.h>)
+  * and has no typedef for ssize_t (a signed size_t).
+  * So, we make our own.
+  */
+ typedef int ssize_t;
+ 
+ /* these macros define Unix-style functions missing in  VC++5.0/NT4.0 */
+ #define MAXPATHLEN _MAX_PATH
+ 
+ #if 0
+ #define memset(A, 0, S) memset((void*)(A), 0, (size_t)(S))
+ #define memcpy(B, A, S) memcpy((void*)(B), (void*)(A), (size_t)(S))
+ /* There is a minor syntactic difference between memcmp and bcmp... */
+ #define memcmp(A, B, S) (memcmp((void*)(A), (void*)(B), (size_t)(S)) ? 1 : 0)
+ #define strchr(s, c)             strchr(s, c)
+ #define strrchr(s, c)            strrchr(s, c)
+ #endif
+ #define strcasecmp(s1,s2)       _stricmp(s1,s2)
+ #define strncasecmp(s1,s2,n)    _strnicmp(s1,s2,n)
+ #define sleep(seconds)          Sleep((seconds) * 1000)
+ #define fsync(fileno)           _commit(fileno)
+ #define ftruncate(fd, size)     _chsize((fd), (long)(size))
+ #define strtoll(str, cp, base)  strtoi64((str), (cp), (base))
+ #define strtoull(str, cp, base) strtoui64((str), (cp), (base))
+ 
+ #define random()                rand()
+ #define srandom(a)              srand(a)
+ 
+ #define popen(cmd, mode)        _popen((cmd), (mode))
+ #define pclose(stream)          _pclose(stream)
+ typedef char *caddr_t;
+ 
+ #define pipe(fdp)               _pipe(fdp, 4096, _O_BINARY)
+ 
+ #define snprintf                _snprintf
+ #endif /* AFS_PARAM_H */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/des/key_sched.c
diff -c openafs/src/des/key_sched.c:1.6.2.3 openafs/src/des/key_sched.c:1.6.2.4
*** openafs/src/des/key_sched.c:1.6.2.3	Mon May 30 14:30:36 2005
--- openafs/src/des/key_sched.c	Tue Jun 21 16:19:48 2005
***************
*** 31,37 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/des/key_sched.c,v 1.6.2.3 2005/05/30 18:30:36 shadow Exp $");
  
  #include <mit-cpyright.h>
  #include "des_internal.h"
--- 31,37 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/des/key_sched.c,v 1.6.2.4 2005/06/21 20:19:48 shadow Exp $");
  
  #include <mit-cpyright.h>
  #include "des_internal.h"
***************
*** 44,53 ****
  
  typedef char key[64];
  
- #ifndef AFS_PTHREAD_ENV 
- struct rxkad_stats rxkad_stats = { { 0 } }; 
- #endif
- 
  /* the following are really void but cc86 doesnt allow it */
  static int make_key_sched();
  
--- 44,49 ----
Index: openafs/src/des/util.c
diff -c openafs/src/des/util.c:1.6 openafs/src/des/util.c:1.6.2.2
*** openafs/src/des/util.c:1.6	Tue Jul 15 19:15:00 2003
--- openafs/src/des/util.c	Tue Jun 21 16:19:58 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/des/util.c,v 1.6 2003/07/15 23:15:00 shadow Exp $");
  
  #include "mit-cpyright.h"
  #ifndef KERNEL
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/des/util.c,v 1.6.2.2 2005/06/21 20:19:58 shadow Exp $");
  
  #include "mit-cpyright.h"
  #ifndef KERNEL
Index: openafs/src/dir/dir.c
diff -c openafs/src/dir/dir.c:1.21.2.1 openafs/src/dir/dir.c:1.21.2.2
*** openafs/src/dir/dir.c:1.21.2.1	Sun Apr  3 14:15:49 2005
--- openafs/src/dir/dir.c	Mon Jul 11 15:27:28 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/dir/dir.c,v 1.21.2.1 2005/04/03 18:15:49 shadow Exp $");
  
  #ifdef KERNEL
  #if !defined(UKERNEL)
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/dir/dir.c,v 1.21.2.2 2005/07/11 19:27:28 shadow Exp $");
  
  #ifdef KERNEL
  #if !defined(UKERNEL)
***************
*** 25,48 ****
  #include "h/errno.h"
  #endif
  #include "h/time.h"
! #if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV)
  #include "h/errno.h"
  #else
  #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
  #include "h/kernel.h"
  #endif
  #endif
! #if	defined(AFS_SUN56_ENV) || defined(AFS_HPUX_ENV)
  #include "afs/sysincludes.h"
  #endif
- #if defined(AFS_FBSD_ENV)
- #include "h/libkern.h"
- #include "h/lock.h"
- #include "vm/vm.h"
- #include "vm/vm_extern.h"
- #include "vm/pmap.h"
- #include "vm/vm_map.h"
- #endif /* AFS_FBSD_ENV */
  #if !defined(AFS_SGI64_ENV) && !defined(AFS_DARWIN60_ENV)
  #include "h/user.h"
  #endif /* AFS_SGI64_ENV */
--- 25,40 ----
  #include "h/errno.h"
  #endif
  #include "h/time.h"
! #if defined(AFS_AIX_ENV) || defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX20_ENV)
  #include "h/errno.h"
  #else
  #if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV)
  #include "h/kernel.h"
  #endif
  #endif
! #if	defined(AFS_SUN56_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_FBSD_ENV)
  #include "afs/sysincludes.h"
  #endif
  #if !defined(AFS_SGI64_ENV) && !defined(AFS_DARWIN60_ENV)
  #include "h/user.h"
  #endif /* AFS_SGI64_ENV */
Index: openafs/src/gtx/gtxtest.c
diff -c openafs/src/gtx/gtxtest.c:1.6 openafs/src/gtx/gtxtest.c:1.6.2.1
*** openafs/src/gtx/gtxtest.c:1.6	Tue Jul 15 19:15:12 2003
--- openafs/src/gtx/gtxtest.c	Mon Jul 11 15:29:37 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/gtx/gtxtest.c,v 1.6 2003/07/15 23:15:12 shadow Exp $");
  
  
  #ifdef HAVE_STRING_H
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/gtx/gtxtest.c,v 1.6.2.1 2005/07/11 19:29:37 shadow Exp $");
  
  
  #ifdef HAVE_STRING_H
***************
*** 26,31 ****
--- 26,32 ----
  #include "gtxobjects.h"
  #include "gtxtextobj.h"
  #include "gtxlightobj.h"
+ #include "gtxkeymap.h"
  #include "gtxframe.h"
  
  struct gtx_frame *frameA, *frameB;
Index: openafs/src/kauth/client.c
diff -c openafs/src/kauth/client.c:1.12.2.1 openafs/src/kauth/client.c:1.12.2.2
*** openafs/src/kauth/client.c:1.12.2.1	Wed Aug 25 03:09:38 2004
--- openafs/src/kauth/client.c	Mon Jul 11 15:29:38 2005
***************
*** 15,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/client.c,v 1.12.2.1 2004/08/25 07:09:38 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "afs/stds.h"
--- 15,26 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/client.c,v 1.12.2.2 2005/07/11 19:29:38 shadow Exp $");
  
  #if defined(UKERNEL)
+ #ifdef HAVE_UNISTD_H
+ #define __USE_XOPEN
+ #endif
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
  #include "afs/stds.h"
Index: openafs/src/kauth/kaserver.c
diff -c openafs/src/kauth/kaserver.c:1.17 openafs/src/kauth/kaserver.c:1.17.2.1
*** openafs/src/kauth/kaserver.c:1.17	Sun Dec  7 17:49:26 2003
--- openafs/src/kauth/kaserver.c	Mon Jul 11 15:08:37 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/kaserver.c,v 1.17 2003/12/07 22:49:26 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/kauth/kaserver.c,v 1.17.2.1 2005/07/11 19:08:37 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
***************
*** 48,53 ****
--- 48,54 ----
  #include <lock.h>
  #include <afs/afsutil.h>
  #include <ubik.h>
+ #include <sys/stat.h>
  #include "kauth.h"
  #include "kautils.h"
  #include "kaserver.h"
***************
*** 200,205 ****
--- 201,207 ----
      if (argc == 0) {
        usage:
  	printf("Usage: kaserver [-noAuth] [-fastKeys] [-database <dbpath>] "
+ 	       "[-auditlog <log path>] "
  	       "[-localfiles <lclpath>] [-minhours <n>] [-servers <serverlist>] "
  	       "[-crossrealm]"
  	       /*" [-enable_peer_stats] [-enable_process_stats] " */
***************
*** 243,248 ****
--- 245,280 ----
  	    dbpath = argv[++a];
  	    if (strcmp(lclpath, default_lclpath) == 0)
  		lclpath = dbpath;
+ 	}
+ 	else if (strncmp(arg, "-auditlog", arglen) == 0) {
+ 	    int tempfd, flags;
+ 	    FILE *auditout;
+ 	    char oldName[MAXPATHLEN];
+ 	    char *fileName = argv[++a];
+ 	    
+ #ifndef AFS_NT40_ENV
+ 	    struct stat statbuf;
+ 	    
+ 	    if ((lstat(fileName, &statbuf) == 0) 
+ 		&& (S_ISFIFO(statbuf.st_mode))) {
+ 		flags = O_WRONLY | O_NONBLOCK;
+ 	    } else 
+ #endif
+ 	    {
+ 		strcpy(oldName, fileName);
+ 		strcat(oldName, ".old");
+ 		renamefile(fileName, oldName);
+ 		flags = O_WRONLY | O_TRUNC | O_CREAT;
+ 	    }
+ 	    tempfd = open(fileName, flags, 0666);
+ 	    if (tempfd > -1) {
+ 		auditout = fdopen(tempfd, "a");
+ 		if (auditout) {
+ 		    osi_audit_file(auditout);
+ 		} else
+ 		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	    } else
+ 		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
  	} else if (strcmp(arg, "-localfiles") == 0)
  	    lclpath = argv[++a];
  	else if (strcmp(arg, "-servers") == 0)
Index: openafs/src/libadmin/adminutil/NTMakefile
diff -c openafs/src/libadmin/adminutil/NTMakefile:1.6 openafs/src/libadmin/adminutil/NTMakefile:1.6.2.1
*** openafs/src/libadmin/adminutil/NTMakefile:1.6	Fri Nov 21 03:00:52 2003
--- openafs/src/libadmin/adminutil/NTMakefile	Mon Jul 11 15:08:38 2005
***************
*** 138,144 ****
  DLLLIBS =\
  	$(DESTDIR)\lib\afspthread.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
! 	$(DESTDIR)\lib\afsauthent.lib
  
  $(DLLFILE): $(DLLOBJS) $(DLLLIBS)
  	$(DLLCONLINK) /DEF:afsadminutil.def
--- 138,146 ----
  DLLLIBS =\
  	$(DESTDIR)\lib\afspthread.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
!         $(DESTDIR)\lib\afs\afsutil.lib \
! 	$(DESTDIR)\lib\afsauthent.lib \
!         $(DESTDIR)\lib\afs\afsreg.lib
  
  $(DLLFILE): $(DLLOBJS) $(DLLLIBS)
  	$(DLLCONLINK) /DEF:afsadminutil.def
Index: openafs/src/libadmin/adminutil/afs_utilAdmin.c
diff -c openafs/src/libadmin/adminutil/afs_utilAdmin.c:1.7.2.1 openafs/src/libadmin/adminutil/afs_utilAdmin.c:1.7.2.2
*** openafs/src/libadmin/adminutil/afs_utilAdmin.c:1.7.2.1	Wed Aug 25 03:09:38 2004
--- openafs/src/libadmin/adminutil/afs_utilAdmin.c	Mon Jul 11 15:09:46 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/adminutil/afs_utilAdmin.c,v 1.7.2.1 2004/08/25 07:09:38 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/afs_Admin.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/adminutil/afs_utilAdmin.c,v 1.7.2.2 2005/07/11 19:09:46 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/afs_Admin.h>
***************
*** 450,456 ****
  	server = gethostbyname(serverName);
  	if (server != NULL) {
  	    memcpy((void *)serverAddress, (const void *)server->h_addr,
! 		   sizeof(serverAddress));
  	    *serverAddress = ntohl(*serverAddress);
  	} else {
  	    tst = ADMUTILCANTGETSERVERNAME;
--- 450,456 ----
  	server = gethostbyname(serverName);
  	if (server != NULL) {
  	    memcpy((void *)serverAddress, (const void *)server->h_addr,
! 		   sizeof(int));
  	    *serverAddress = ntohl(*serverAddress);
  	} else {
  	    tst = ADMUTILCANTGETSERVERNAME;
Index: openafs/src/libadmin/client/NTMakefile
diff -c openafs/src/libadmin/client/NTMakefile:1.5 openafs/src/libadmin/client/NTMakefile:1.5.2.1
*** openafs/src/libadmin/client/NTMakefile:1.5	Fri Nov 21 03:00:58 2003
--- openafs/src/libadmin/client/NTMakefile	Mon Jul 11 15:08:39 2005
***************
*** 26,32 ****
  	$(DESTDIR)\lib\afs\afsadminutil.lib \
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
! 	$(DESTDIR)\lib\afspthread.lib
  
  $(DLLFILE): $(DLLOBJS) $(DLLLIBS)
  	$(DLLCONLINK) /DEF:clientadmin.def
--- 26,33 ----
  	$(DESTDIR)\lib\afs\afsadminutil.lib \
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
! 	$(DESTDIR)\lib\afspthread.lib \
!         $(DESTDIR)\lib\afs\afsutil.lib
  
  $(DLLFILE): $(DLLOBJS) $(DLLLIBS)
  	$(DLLCONLINK) /DEF:clientadmin.def
Index: openafs/src/libadmin/test/NTMakefile
diff -c openafs/src/libadmin/test/NTMakefile:1.5 openafs/src/libadmin/test/NTMakefile:1.5.2.1
*** openafs/src/libadmin/test/NTMakefile:1.5	Fri Nov 21 03:01:03 2003
--- openafs/src/libadmin/test/NTMakefile	Mon Jul 11 15:08:46 2005
***************
*** 22,27 ****
--- 22,28 ----
  	$(DESTDIR)\lib\afs\afsptsadmin.lib \
  	$(DESTDIR)\lib\afsauthent.lib \
  	$(DESTDIR)\lib\afsrpc.lib \
+         $(DESTDIR)\lib\afs\afsutil.lib \
  	$(DESTDIR)\lib\afs\afscmd.lib  # static library
  
  AFSCP_EXEOBJS =\
Index: openafs/src/libafs/afs.ppc_darwin_70.plist.in
diff -c openafs/src/libafs/afs.ppc_darwin_70.plist.in:1.2.2.3 openafs/src/libafs/afs.ppc_darwin_70.plist.in:1.2.2.4
*** openafs/src/libafs/afs.ppc_darwin_70.plist.in:1.2.2.3	Sun Jun  5 11:43:42 2005
--- openafs/src/libafs/afs.ppc_darwin_70.plist.in	Mon Jul 11 16:03:42 2005
***************
*** 15,25 ****
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.84</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.3.84</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kernel.bsd</key>
--- 15,25 ----
  	<key>CFBundlePackageType</key>
  	<string>KEXT</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.85</string>
  	<key>CFBundleSignature</key>
  	<string>????</string>
  	<key>CFBundleVersion</key>
! 	<string>1.3.85</string>
  	<key>OSBundleLibraries</key>
  	<dict>
  		<key>com.apple.kernel.bsd</key>
Index: openafs/src/libafsauthent/NTMakefile
diff -c openafs/src/libafsauthent/NTMakefile:1.10.2.3 openafs/src/libafsauthent/NTMakefile:1.10.2.4
*** openafs/src/libafsauthent/NTMakefile:1.10.2.3	Thu Apr 28 08:08:24 2005
--- openafs/src/libafsauthent/NTMakefile	Mon Jul 11 15:08:47 2005
***************
*** 139,145 ****
  	$(DESTDIR)\lib\afs\afsutil.lib \
  	$(DESTDIR)\lib\afs\afsreg.lib \
  	$(DESTDIR)\lib\afs\afseventlog.lib \
!     $(DESTDIR)\lib\lanahelper.lib
  
  $(LIBFILE): $(DLLOBJS) $(DLLLIBS) $(RXOBJS)
  	$(DLLCONLINK) /DEF:afsauthent.def rpcrt4.lib dnsapi.lib mpr.lib secur32.lib
--- 139,147 ----
  	$(DESTDIR)\lib\afs\afsutil.lib \
  	$(DESTDIR)\lib\afs\afsreg.lib \
  	$(DESTDIR)\lib\afs\afseventlog.lib \
!         $(DESTDIR)\lib\afs\afsprocmgmt.lib \
!         $(DESTDIR)\lib\afslwp.lib \
!         $(DESTDIR)\lib\lanahelper.lib
  
  $(LIBFILE): $(DLLOBJS) $(DLLLIBS) $(RXOBJS)
  	$(DLLCONLINK) /DEF:afsauthent.def rpcrt4.lib dnsapi.lib mpr.lib secur32.lib
Index: openafs/src/libafsrpc/afsrpc.def
diff -c openafs/src/libafsrpc/afsrpc.def:1.3.2.4 openafs/src/libafsrpc/afsrpc.def:1.3.2.5
*** openafs/src/libafsrpc/afsrpc.def:1.3.2.4	Mon May 30 00:57:35 2005
--- openafs/src/libafsrpc/afsrpc.def	Mon Jul 11 15:08:48 2005
***************
*** 71,77 ****
  	com_err					@75
  	error_message				@76
  	rx_socket				@77 DATA
! 	AssertionFailed				@79
  	afs_winsockInit				@80
  	rxevent_debugFile			@81 DATA
  	rx_debugFile				@82 DATA
--- 71,77 ----
  	com_err					@75
  	error_message				@76
  	rx_socket				@77 DATA
! ;	AssertionFailed				@79
  	afs_winsockInit				@80
  	rxevent_debugFile			@81 DATA
  	rx_debugFile				@82 DATA
Index: openafs/src/libuafs/Makefile.common.in
diff -c openafs/src/libuafs/Makefile.common.in:1.12.2.2 openafs/src/libuafs/Makefile.common.in:1.12.2.3
*** openafs/src/libuafs/Makefile.common.in:1.12.2.2	Sun Jan 30 23:34:44 2005
--- openafs/src/libuafs/Makefile.common.in	Tue Jun 21 16:19:59 2005
***************
*** 62,68 ****
  	${TOP_LIBDIR}/$(LIBAFSWEBKRB) 
  
  linktest: UAFS/$(LIBUAFS) ${TOP_OBJDIR}/lib/libdes.a
! 	$(CC) $(TEST_CFLAGS) $(TEST_LDFLAGS) -o linktest ${srcdir}/linktest.c $(COMMON_INCLUDE) -DUKERNEL UAFS/$(LIBUAFS) ${TOP_OBJDIR}/lib/libdes.a $(TEST_LIBS) $(XLIBS)
  
  install: \
  	${DESTDIR}${libdir}/$(LIBUAFS) \
--- 62,68 ----
  	${TOP_LIBDIR}/$(LIBAFSWEBKRB) 
  
  linktest: UAFS/$(LIBUAFS) ${TOP_OBJDIR}/lib/libdes.a
! 	$(CC) $(TEST_CFLAGS) $(TEST_LDFLAGS) -o linktest ${srcdir}/linktest.c $(COMMON_INCLUDE) -DUKERNEL UAFS/$(LIBUAFS) ${TOP_LIBDIR}/libdes.a ${TOP_LIBDIR}/libafsutil.a $(TEST_LIBS) $(XLIBS)
  
  install: \
  	${DESTDIR}${libdir}/$(LIBUAFS) \
Index: openafs/src/log/kseal.c
diff -c openafs/src/log/kseal.c:1.7 openafs/src/log/kseal.c:1.7.2.1
*** openafs/src/log/kseal.c:1.7	Tue Jul 15 19:15:40 2003
--- openafs/src/log/kseal.c	Mon Jul 11 15:46:16 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/log/kseal.c,v 1.7 2003/07/15 23:15:40 shadow Exp $");
  
  #include <sys/types.h>
  #include <netinet/in.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/log/kseal.c,v 1.7.2.1 2005/07/11 19:46:16 shadow Exp $");
  
  #include <sys/types.h>
  #include <netinet/in.h>
***************
*** 37,45 ****
  
  #include "AFS_component_version_number.c"
  
! main(argc, argv)
!      int argc;
!      char **argv;
  {
      struct ktc_token token;
      struct ktc_principal sname;
--- 37,44 ----
  
  #include "AFS_component_version_number.c"
  
! int
! main(int argc, char **argv)
  {
      struct ktc_token token;
      struct ktc_principal sname;
Index: openafs/src/log/tokens.c
diff -c openafs/src/log/tokens.c:1.6 openafs/src/log/tokens.c:1.6.2.1
*** openafs/src/log/tokens.c:1.6	Tue Jul 15 19:15:41 2003
--- openafs/src/log/tokens.c	Mon Jul 11 15:46:16 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/log/tokens.c,v 1.6 2003/07/15 23:15:41 shadow Exp $");
  
  #include <stdio.h>
  #ifdef	AFS_AIX32_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/log/tokens.c,v 1.6.2.1 2005/07/11 19:46:16 shadow Exp $");
  
  #include <stdio.h>
  #ifdef	AFS_AIX32_ENV
***************
*** 46,55 ****
  
  #include "AFS_component_version_number.c"
  
! main(argc, argv)
!      int argc;
!      char **argv;
! 
  {				/*Main program */
      int cellNum;		/*Cell entry number */
      int rc;			/*Return value from U_CellGetLocalTokens */
--- 46,53 ----
  
  #include "AFS_component_version_number.c"
  
! int
! main(int argc, char **argv)
  {				/*Main program */
      int cellNum;		/*Cell entry number */
      int rc;			/*Return value from U_CellGetLocalTokens */
Index: openafs/src/log/unlog.c
diff -c openafs/src/log/unlog.c:1.6 openafs/src/log/unlog.c:1.6.2.1
*** openafs/src/log/unlog.c:1.6	Tue Jul 15 19:15:41 2003
--- openafs/src/log/unlog.c	Mon Jul 11 15:46:16 2005
***************
*** 30,36 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/log/unlog.c,v 1.6 2003/07/15 23:15:41 shadow Exp $");
  
  #include <stdio.h>
  #include <potpourri.h>
--- 30,36 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/log/unlog.c,v 1.6.2.1 2005/07/11 19:46:16 shadow Exp $");
  
  #include <stdio.h>
  #include <potpourri.h>
***************
*** 70,78 ****
  };
  
  
! CommandProc(as, arock)
!      char *arock;
!      struct cmd_syndesc *as;
  {
  #define	MAXCELLS 20		/* XXX */
      struct cmd_item *itp;
--- 70,77 ----
  };
  
  
! int 
! CommandProc(struct cmd_syndesc *as, char *arock)
  {
  #define	MAXCELLS 20		/* XXX */
      struct cmd_item *itp;
***************
*** 102,111 ****
  
  #include "AFS_component_version_number.c"
  
! main(argc, argv)
!      int argc;
!      char *argv[];
! 
  {				/*Main routine */
      struct cmd_syndesc *ts;
      register afs_int32 code;
--- 101,108 ----
  
  #include "AFS_component_version_number.c"
  
! int
! main(int argc, char *argv[])
  {				/*Main routine */
      struct cmd_syndesc *ts;
      register afs_int32 code;
***************
*** 143,151 ****
   *           then re-register the good ones.  Ugly, but it works.
   */
  
! unlog_ForgetCertainTokens(list, listSize)
!      char **list;
!      int listSize;
  {
      unsigned count, index, index2;
      afs_int32 code;
--- 140,147 ----
   *           then re-register the good ones.  Ugly, but it works.
   */
  
! int
! unlog_ForgetCertainTokens(char **list, int listSize)
  {
      unsigned count, index, index2;
      afs_int32 code;
***************
*** 212,221 ****
  /*
   * 0 if not in list, 1 if in list
   */
! unlog_CheckUnlogList(list, count, principal)
!      char **list;
!      int count;
!      struct ktc_principal *principal;
  {
      do {
  	if (strcmp(*list, principal->cell) == 0)
--- 208,215 ----
  /*
   * 0 if not in list, 1 if in list
   */
! int
! unlog_CheckUnlogList(char **list, int count, struct ktc_principal *principal)
  {
      do {
  	if (strcmp(*list, principal->cell) == 0)
***************
*** 232,240 ****
   *         because it assumes it isn't a problem.
   */
  
! unlog_NormalizeCellNames(list, size)
!      char **list;
!      int size;
  {
      char *newCellName, *lcstring();
      unsigned index;
--- 226,233 ----
   *         because it assumes it isn't a problem.
   */
  
! int
! unlog_NormalizeCellNames(char **list, int size)
  {
      char *newCellName, *lcstring();
      unsigned index;
***************
*** 279,289 ****
   * check given list to assure tokens were held for specified cells
   * prints warning messages for those cells without such entries.
   */
! unlog_VerifyUnlog(cellList, cellListSize, tokenList, tokenListSize)
!      char **cellList;
!      int cellListSize;
!      struct tokenInfo *tokenList;
!      int tokenListSize;
  {
      int index;
  
--- 272,279 ----
   * check given list to assure tokens were held for specified cells
   * prints warning messages for those cells without such entries.
   */
! int
! unlog_VerifyUnlog(char **cellList, int cellListSize, struct tokenInfo *tokenList, int tokenListSize)
  {
      int index;
  
Index: openafs/src/lwp/lwp.c
diff -c openafs/src/lwp/lwp.c:1.27.2.5 openafs/src/lwp/lwp.c:1.27.2.6
*** openafs/src/lwp/lwp.c:1.27.2.5	Sun Mar 27 15:22:03 2005
--- openafs/src/lwp/lwp.c	Mon Jul 11 14:59:55 2005
***************
*** 17,23 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/lwp.c,v 1.27.2.5 2005/03/27 20:22:03 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 17,23 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/lwp.c,v 1.27.2.6 2005/07/11 18:59:55 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
***************
*** 145,153 ****
  int lwp_MinStackSize = 0;
  
  static int
! lwp_remove(p, q)
!      register PROCESS p;
!      register struct QUEUE *q;
  {
      /* Special test for only element on queue */
      if (q->count == 1)
--- 145,151 ----
  int lwp_MinStackSize = 0;
  
  static int
! lwp_remove(register PROCESS p, register struct QUEUE *q)
  {
      /* Special test for only element on queue */
      if (q->count == 1)
***************
*** 166,174 ****
  }
  
  static int
! insert(p, q)
!      register PROCESS p;
!      register struct QUEUE *q;
  {
      if (q->head == NULL) {	/* Queue is empty */
  	q->head = p;
--- 164,170 ----
  }
  
  static int
! insert(register PROCESS p, register struct QUEUE *q)
  {
      if (q->head == NULL) {	/* Queue is empty */
  	q->head = p;
***************
*** 184,192 ****
  }
  
  static int
! move(p, from, to)
!      PROCESS p;
!      struct QUEUE *from, *to;
  {
  
      lwp_remove(p, from);
--- 180,186 ----
  }
  
  static int
! move(PROCESS p, struct QUEUE *from, struct QUEUE *to)
  {
  
      lwp_remove(p, from);
***************
*** 248,255 ****
  }
  
  int
! LWP_QSignal(pid)
!      register PROCESS pid;
  {
      if (pid->status == QWAITING) {
  	pid->status = READY;
--- 242,248 ----
  }
  
  int
! LWP_QSignal(register PROCESS pid)
  {
      if (pid->status == QWAITING) {
  	pid->status = READY;
Index: openafs/src/lwp/preempt.c
diff -c openafs/src/lwp/preempt.c:1.16 openafs/src/lwp/preempt.c:1.16.2.1
*** openafs/src/lwp/preempt.c:1.16	Tue Jul 15 19:15:45 2003
--- openafs/src/lwp/preempt.c	Mon Jul 11 14:59:55 2005
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/lwp/preempt.c,v 1.16 2003/07/15 23:15:45 shadow Exp $");
  
  
  #include "lwp.h"
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/lwp/preempt.c,v 1.16.2.1 2005/07/11 18:59:55 shadow Exp $");
  
  
  #include "lwp.h"
***************
*** 28,35 ****
  
  
  int
! PRE_InitPreempt(slice)
!      struct timeval *slice;
  {
      return LWP_SUCCESS;
  }
--- 28,34 ----
  
  
  int
! PRE_InitPreempt(struct timeval *slice)
  {
      return LWP_SUCCESS;
  }
***************
*** 55,69 ****
  
  #if HAVE_SIGACTION && defined(SA_SIGINFO)
  static void
! AlarmHandler(sig, st, scp)
!      int sig;
!      siginfo_t *st;
!      ucontext_t *scp;
  #else
  static void
! AlarmHandler(sig, code, scp)
!      int sig, code;
!      struct sigcontext *scp;
  #endif
  {
      if (PRE_Block == 0 && lwp_cpptr->level == 0) {
--- 54,63 ----
  
  #if HAVE_SIGACTION && defined(SA_SIGINFO)
  static void
! AlarmHandler(int sig, siginfo_t *st, ucontext_t *scp)
  #else
  static void
! AlarmHandler(int sig, int code, struct sigcontext *scp)
  #endif
  {
      if (PRE_Block == 0 && lwp_cpptr->level == 0) {
***************
*** 80,87 ****
  }
  
  int
! PRE_InitPreempt(slice)
!      struct timeval *slice;
  {
      struct itimerval itv;
  #if HAVE_SIGACTION && defined(SA_SIGINFO)
--- 74,80 ----
  }
  
  int
! PRE_InitPreempt(struct timeval *slice)
  {
      struct itimerval itv;
  #if HAVE_SIGACTION && defined(SA_SIGINFO)
Index: openafs/src/lwp/timer.c
diff -c openafs/src/lwp/timer.c:1.9 openafs/src/lwp/timer.c:1.9.2.1
*** openafs/src/lwp/timer.c:1.9	Sun Dec  7 17:49:33 2003
--- openafs/src/lwp/timer.c	Mon Jul 11 14:59:55 2005
***************
*** 22,28 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/lwp/timer.c,v 1.9 2003/12/07 22:49:33 jaltman Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
--- 22,28 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/lwp/timer.c,v 1.9.2.1 2005/07/11 18:59:55 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
***************
*** 53,60 ****
  
  /* t1 = t2 - t3 */
  static void
! subtract(t1, t2, t3)
!      register struct timeval *t1, *t2, *t3;
  {
      register int sec2, usec2, sec3, usec3;
  
--- 53,60 ----
  
  /* t1 = t2 - t3 */
  static void
! subtract(register struct timeval *t1, register struct timeval *t2, 
! 	 register struct timeval *t3)
  {
      register int sec2, usec2, sec3, usec3;
  
***************
*** 86,93 ****
  /* t1 += t2; */
  
  static void
! add(t1, t2)
!      register struct timeval *t1, *t2;
  {
      t1->tv_usec += t2->tv_usec;
      t1->tv_sec += t2->tv_sec;
--- 86,92 ----
  /* t1 += t2; */
  
  static void
! add(register struct timeval *t1, register struct timeval *t2)
  {
      t1->tv_usec += t2->tv_usec;
      t1->tv_sec += t2->tv_sec;
***************
*** 109,116 ****
  
  /*
  obsolete, commentless procedure, all done by hand expansion now.
! static bool geq(t1, t2)
!     register struct timeval *t1, *t2;
  {
      return (t1->tv_sec > t2->tv_sec) ||
  	   (t1->tv_sec == t2->tv_sec && t1->tv_usec >= t2->tv_usec);
--- 108,114 ----
  
  /*
  obsolete, commentless procedure, all done by hand expansion now.
! static bool geq(register struct timeval *t1, register struct timeval *t2)
  {
      return (t1->tv_sec > t2->tv_sec) ||
  	   (t1->tv_sec == t2->tv_sec && t1->tv_usec >= t2->tv_usec);
***************
*** 118,125 ****
  */
  
  static bool
! blocking(t)
!      register struct TM_Elem *t;
  {
      return (t->TotalTime.tv_sec < 0 || t->TotalTime.tv_usec < 0);
  }
--- 116,122 ----
  */
  
  static bool
! blocking(register struct TM_Elem *t)
  {
      return (t->TotalTime.tv_sec < 0 || t->TotalTime.tv_usec < 0);
  }
***************
*** 131,138 ****
  */
  
  int
! TM_Init(list)
!      register struct TM_Elem **list;
  {
      if (!globalInitDone) {
  	FT_Init(0, 0);
--- 128,134 ----
  */
  
  int
! TM_Init(register struct TM_Elem **list)
  {
      if (!globalInitDone) {
  	FT_Init(0, 0);
***************
*** 155,162 ****
  }
  
  int
! TM_Final(list)
!      register struct TM_Elem **list;
  {
      if (list == NULL || *list == NULL)
  	return -1;
--- 151,157 ----
  }
  
  int
! TM_Final(register struct TM_Elem **list)
  {
      if (list == NULL || *list == NULL)
  	return -1;
***************
*** 172,180 ****
  */
  
  void
! TM_Insert(tlistPtr, elem)
!      struct TM_Elem *tlistPtr;	/* pointer to head pointer of timer list */
!      struct TM_Elem *elem;	/* element to be inserted */
  {
      register struct TM_Elem *next;
  
--- 167,173 ----
  */
  
  void
! TM_Insert(struct TM_Elem *tlistPtr, struct TM_Elem *elem)
  {
      register struct TM_Elem *next;
  
***************
*** 214,221 ****
  */
  
  int
! TM_Rescan(tlist)
!      struct TM_Elem *tlist;	/* head pointer of timer list */
  {
      struct timeval time;
      register int expired;
--- 207,213 ----
  */
  
  int
! TM_Rescan(struct TM_Elem *tlist)	/* head pointer of timer list */
  {
      struct timeval time;
      register int expired;
***************
*** 243,250 ****
  */
  
  struct TM_Elem *
! TM_GetExpired(tlist)
!      struct TM_Elem *tlist;	/* head pointer of timer list */
  {
      FOR_ALL_ELTS(e, tlist, {
  		 if (!blocking(e)
--- 235,241 ----
  */
  
  struct TM_Elem *
! TM_GetExpired(struct TM_Elem *tlist)	/* head pointer of timer list */
  {
      FOR_ALL_ELTS(e, tlist, {
  		 if (!blocking(e)
***************
*** 263,270 ****
  */
  
  struct TM_Elem *
! TM_GetEarliest(tlist)
!      struct TM_Elem *tlist;
  {
      register struct TM_Elem *e;
  
--- 254,260 ----
  */
  
  struct TM_Elem *
! TM_GetEarliest(struct TM_Elem *tlist)
  {
      register struct TM_Elem *e;
  
Index: openafs/src/packaging/MacOS/OpenAFS.Info.plist
diff -c openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.11 openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.12
*** openafs/src/packaging/MacOS/OpenAFS.Info.plist:1.2.2.11	Sun Jun  5 11:43:43 2005
--- openafs/src/packaging/MacOS/OpenAFS.Info.plist	Mon Jul 11 16:03:43 2005
***************
*** 3,19 ****
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.84</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.84</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
! 	<integer>2</integer>
  	<key>IFPkgFlagAllowBackRev</key>
  	<false/>
  	<key>IFPkgFlagAuthorizationAction</key>
--- 3,19 ----
  <plist version="1.0">
  <dict>
  	<key>CFBundleGetInfoString</key>
! 	<string>OpenAFS 1.3.85</string>
  	<key>CFBundleIdentifier</key>
  	<string>org.openafs.OpenAFS.pkg</string>
  	<key>CFBundleName</key>
  	<string>OpenAFS</string>
  	<key>CFBundleShortVersionString</key>
! 	<string>1.3.85</string>
  	<key>IFMajorVersion</key>
  	<integer>1</integer>
  	<key>IFMinorVersion</key>
! 	<integer>3</integer>
  	<key>IFPkgFlagAllowBackRev</key>
  	<false/>
  	<key>IFPkgFlagAuthorizationAction</key>
Index: openafs/src/packaging/MacOS/OpenAFS.info
diff -c openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.11 openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.12
*** openafs/src/packaging/MacOS/OpenAFS.info:1.1.4.11	Sun Jun  5 11:43:43 2005
--- openafs/src/packaging/MacOS/OpenAFS.info	Mon Jul 11 16:03:43 2005
***************
*** 1,5 ****
  Title OpenAFS
! Version 1.3.84
  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.85
  Description The OpenAFS distributed filesystem. This package installs an almost-ready-to-run client for OpenAFS. see http://www.openafs.org for more information.
  DefaultLocation /
  Diskname (null)
Index: openafs/src/ptserver/NTMakefile
diff -c openafs/src/ptserver/NTMakefile:1.9.2.2 openafs/src/ptserver/NTMakefile:1.9.2.3
*** openafs/src/ptserver/NTMakefile:1.9.2.2	Fri Mar 11 02:03:27 2005
--- openafs/src/ptserver/NTMakefile	Mon Jul 11 15:02:35 2005
***************
*** 83,93 ****
--- 83,99 ----
  # build pts.exe
  
  PTS = $(DESTDIR)\bin\pts.exe
+ PTCLIENT = $(DESTDIR)\bin\ptclient.exe
  
  PTS_EXEOBJS =\
  	$(OUT)\pts.obj \
  	$(OUT)\pts.res
  
+ PTCLIENT_EXEOBJS =\
+ 	$(OUT)\ptclient.obj \
+         $(OUT)\display.obj \
+ 	$(OUT)\pts.res
+ 
  PTS_EXELIBS =\
  	$(DESTDIR)\lib\afsubik.lib \
  	$(DESTDIR)\lib\afs\afsauth.lib \
***************
*** 108,113 ****
--- 114,123 ----
  	$(EXECONLINK) dnsapi.lib mpr.lib iphlpapi.lib
  	$(EXEPREP) 
  
+ $(PTCLIENT): $(PTCLIENT_EXEOBJS) $(PTS_EXELIBS)
+ 	$(EXECONLINK) dnsapi.lib mpr.lib iphlpapi.lib
+ 	$(EXEPREP) 
+ 
  
  
  ############################################################################
***************
*** 137,145 ****
  ############################################################################
  # install pts, ptserver and afsprot.lib
  
! install: $(INCFILES) ptint.ss.c ptint.cs.c ptint.xdr.c $(LIBFILE) $(PTSERVER) $(PTS) $(OUT)\readgroup.exe \
  	$(OUT)\readpwd.exe  $(OUT)\testpt.exe $(OUT)\db_verify.exe  \
  	$(DESTDIR)\root.server\usr\afs\bin\pts.exe \
  	$(INCFILEDIR)\afs\prserver.h $(INCFILEDIR)\afs\print.h \
  	$(INCFILEDIR)\afs\prerror.h $(INCFILEDIR)\afs\prclient.h
  
--- 147,156 ----
  ############################################################################
  # install pts, ptserver and afsprot.lib
  
! install: $(INCFILES) ptint.ss.c ptint.cs.c ptint.xdr.c $(LIBFILE) $(PTSERVER) $(PTS) $(PTCLIENT) $(OUT)\readgroup.exe \
  	$(OUT)\readpwd.exe  $(OUT)\testpt.exe $(OUT)\db_verify.exe  \
  	$(DESTDIR)\root.server\usr\afs\bin\pts.exe \
+ 	$(DESTDIR)\root.server\usr\afs\bin\ptclient.exe \
  	$(INCFILEDIR)\afs\prserver.h $(INCFILEDIR)\afs\print.h \
  	$(INCFILEDIR)\afs\prerror.h $(INCFILEDIR)\afs\prclient.h
  
***************
*** 154,159 ****
--- 165,173 ----
  $(DESTDIR)\root.server\usr\afs\bin\pts.exe: $(PTS)
  	$(COPY) $(PTS) $(DESTDIR)\root.server\usr\afs\bin\pts.exe
  
+ $(DESTDIR)\root.server\usr\afs\bin\ptclient.exe: $(PTCLIENT)
+ 	$(COPY) $(PTCLIENT) $(DESTDIR)\root.server\usr\afs\bin\ptclient.exe
+ 
  $(INCFILEDIR)\afs\prserver.h: $(INCFILEDIR)\afs\ptserver.h
  	$(COPY)	$(INCFILEDIR)\afs\ptserver.h $(INCFILEDIR)\afs\prserver.h
  
Index: openafs/src/ptserver/ptprocs.c
diff -c openafs/src/ptserver/ptprocs.c:1.21.2.2 openafs/src/ptserver/ptprocs.c:1.21.2.7
*** openafs/src/ptserver/ptprocs.c:1.21.2.2	Tue Apr 26 21:55:54 2005
--- openafs/src/ptserver/ptprocs.c	Mon Jul 11 15:54:50 2005
***************
*** 51,57 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptprocs.c,v 1.21.2.2 2005/04/27 01:55:54 shadow Exp $");
  
  #include <afs/stds.h>
  #include <ctype.h>
--- 51,57 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptprocs.c,v 1.21.2.7 2005/07/11 19:54:50 shadow Exp $");
  
  #include <afs/stds.h>
  #include <ctype.h>
***************
*** 229,254 ****
       afs_int32 oid;
  {
      afs_int32 code;
  
!     code = iNewEntry(call, aname, aid, oid);
!     osi_auditU(call, PTS_INewEntEvent, code, AUD_LONG, aid, AUD_STR, aname,
! 	       AUD_LONG, oid, AUD_END);
      return code;
  }
  
  afs_int32
! iNewEntry(call, aname, aid, oid)
       struct rx_call *call;
       char aname[PR_MAXNAMELEN];
       afs_int32 aid;
       afs_int32 oid;
  {
      /* used primarily for conversion - not intended to be used as usual means
       * of entering people into the database. */
      struct ubik_trans *tt;
      register afs_int32 code;
      afs_int32 gflag = 0;
-     afs_int32 cid;
      int admin;
  
      stolower(aname);
--- 229,256 ----
       afs_int32 oid;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = iNewEntry(call, aname, aid, oid, &cid);
!     osi_auditU(call, PTS_INewEntEvent, code, AUD_ID, aid, AUD_STR, aname,
! 	       AUD_ID, oid, AUD_END);
!     ViceLog(25, ("PTS_INewEntry: code %d cid %d aid %d aname %s oid %d", code, cid, aid, aname, oid));
      return code;
  }
  
  afs_int32
! iNewEntry(call, aname, aid, oid, cid)
       struct rx_call *call;
       char aname[PR_MAXNAMELEN];
       afs_int32 aid;
       afs_int32 oid;
+      afs_int32 * cid;
  {
      /* used primarily for conversion - not intended to be used as usual means
       * of entering people into the database. */
      struct ubik_trans *tt;
      register afs_int32 code;
      afs_int32 gflag = 0;
      int admin;
  
      stolower(aname);
***************
*** 265,274 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     admin = IsAMemberOf(tt, cid, SYSADMINID);
  
      /* first verify the id is good */
      if (aid == 0)
--- 267,276 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     admin = IsAMemberOf(tt, *cid, SYSADMINID);
  
      /* first verify the id is good */
      if (aid == 0)
***************
*** 283,292 ****
  	ABORT_WITH(tt, PRIDEXIST);
  
      /* check a few other things */
!     if (!CreateOK(tt, cid, oid, gflag, admin))
  	ABORT_WITH(tt, PRPERM);
  
!     code = CreateEntry(tt, aname, &aid, 1, gflag, oid, cid);
      if (code != PRSUCCESS)
  	ABORT_WITH(tt, code);
  
--- 285,294 ----
  	ABORT_WITH(tt, PRIDEXIST);
  
      /* check a few other things */
!     if (!CreateOK(tt, *cid, oid, gflag, admin))
  	ABORT_WITH(tt, PRPERM);
  
!     code = CreateEntry(tt, aname, &aid, 1, gflag, oid, *cid);
      if (code != PRSUCCESS)
  	ABORT_WITH(tt, code);
  
***************
*** 307,330 ****
       afs_int32 *aid;
  {
      afs_int32 code;
  
!     code = newEntry(call, aname, flag, oid, aid);
!     osi_auditU(call, PTS_NewEntEvent, code, AUD_LONG, *aid, AUD_STR, aname,
! 	       AUD_LONG, oid, AUD_END);
      return code;
  }
  
  afs_int32
! newEntry(call, aname, flag, oid, aid)
       struct rx_call *call;
       char aname[PR_MAXNAMELEN];
       afs_int32 flag;
       afs_int32 oid;
       afs_int32 *aid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      int admin;
      extern afs_int32 WhoIsThisWithName();
      char cname[PR_MAXNAMELEN];
--- 309,334 ----
       afs_int32 *aid;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = newEntry(call, aname, flag, oid, aid, &cid);
!     osi_auditU(call, PTS_NewEntEvent, code, AUD_ID, *aid, AUD_STR, aname,
! 	       AUD_ID, oid, AUD_END);
!     ViceLog(25, ("PTS_NewEntry: code %d cid %d aid %d aname %s oid %d", code, cid, *aid, aname, oid));
      return code;
  }
  
  afs_int32
! newEntry(call, aname, flag, oid, aid, cid)
       struct rx_call *call;
       char aname[PR_MAXNAMELEN];
       afs_int32 flag;
       afs_int32 oid;
       afs_int32 *aid;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      int admin;
      extern afs_int32 WhoIsThisWithName();
      char cname[PR_MAXNAMELEN];
***************
*** 346,364 ****
       * SPR_INewEntry because we want self-registration to only do 
       * automatic id assignment.
       */
!     code = WhoIsThisWithName(call, tt, &cid, cname);
      if (code != 2) {		/* 2 specifies that this is a foreign cell request */
  	if (code)
  	    ABORT_WITH(tt, PRPERM);
! 	admin = IsAMemberOf(tt, cid, SYSADMINID);
      } else {
! 	admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, cid, SYSADMINID);
! 	oid = cid = SYSADMINID;
      }
!     if (!CreateOK(tt, cid, oid, flag, admin))
  	ABORT_WITH(tt, PRPERM);
  
!     code = CreateEntry(tt, aname, aid, 0, flag, oid, cid);
      if (code != PRSUCCESS)
  	ABORT_WITH(tt, code);
  
--- 350,368 ----
       * SPR_INewEntry because we want self-registration to only do 
       * automatic id assignment.
       */
!     code = WhoIsThisWithName(call, tt, cid, cname);
      if (code != 2) {		/* 2 specifies that this is a foreign cell request */
  	if (code)
  	    ABORT_WITH(tt, PRPERM);
! 	admin = IsAMemberOf(tt, *cid, SYSADMINID);
      } else {
! 	admin = ((!restricted && !strcmp(aname, cname))) || IsAMemberOf(tt, *cid, SYSADMINID);
! 	oid = *cid = SYSADMINID;
      }
!     if (!CreateOK(tt, *cid, oid, flag, admin))
  	ABORT_WITH(tt, PRPERM);
  
!     code = CreateEntry(tt, aname, aid, 0, flag, oid, *cid);
      if (code != PRSUCCESS)
  	ABORT_WITH(tt, code);
  
***************
*** 377,394 ****
       afs_int32 *apos;
  {
      afs_int32 code;
  
!     code = whereIsIt(call, aid, apos);
!     osi_auditU(call, PTS_WheIsItEvent, code, AUD_LONG, aid, AUD_LONG, *apos,
  	       AUD_END);
      return code;
  }
  
  afs_int32
! whereIsIt(call, aid, apos)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 *apos;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
--- 381,401 ----
       afs_int32 *apos;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = whereIsIt(call, aid, apos, &cid);
!     osi_auditU(call, PTS_WheIsItEvent, code, AUD_ID, aid, AUD_LONG, *apos,
  	       AUD_END);
+     ViceLog(125, ("PTS_WhereIsIt: code %d cid %d aid %d apos %d", code, cid, aid, *apos));
      return code;
  }
  
  afs_int32
! whereIsIt(call, aid, apos, cid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 *apos;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
***************
*** 407,412 ****
--- 414,423 ----
      if (code)
  	ABORT_WITH(tt, code);
  
+     code = WhoIsThis(call, tt, cid);
+     if (code)
+ 	ABORT_WITH(tt, PRPERM);
+ 
      temp = FindByID(tt, aid);
      if (!temp)
  	ABORT_WITH(tt, PRNOENT);
***************
*** 425,444 ****
       struct prdebugentry *aentry;
  {
      afs_int32 code;
  
!     code = dumpEntry(call, apos, aentry);
      osi_auditU(call, PTS_DmpEntEvent, code, AUD_LONG, apos, AUD_END);
      return code;
  }
  
  afs_int32
! dumpEntry(call, apos, aentry)
       struct rx_call *call;
       afs_int32 apos;
       struct prdebugentry *aentry;
  {
      register afs_int32 code;
-     afs_int32 cid;
      struct ubik_trans *tt;
  
      code = Initdb();
--- 436,457 ----
       struct prdebugentry *aentry;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = dumpEntry(call, apos, aentry, &cid);
      osi_auditU(call, PTS_DmpEntEvent, code, AUD_LONG, apos, AUD_END);
+     ViceLog(125, ("PTS_DumpEntry: code %d cid %d apos %d", code, cid, apos));
      return code;
  }
  
  afs_int32
! dumpEntry(call, apos, aentry, cid)
       struct rx_call *call;
       afs_int32 apos;
       struct prdebugentry *aentry;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
  
      code = Initdb();
***************
*** 454,467 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      code = pr_ReadEntry(tt, 0, apos, aentry);
      if (code)
  	ABORT_WITH(tt, code);
  
!     if (!AccessOK(tt, cid, 0, PRP_STATUS_MEM, 0))
  	ABORT_WITH(tt, PRPERM);
  
      /* Since prdebugentry is in the form of a prentry not a coentry, we will
--- 467,480 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      code = pr_ReadEntry(tt, 0, apos, aentry);
      if (code)
  	ABORT_WITH(tt, code);
  
!     if (!AccessOK(tt, *cid, 0, PRP_STATUS_MEM, 0))
  	ABORT_WITH(tt, PRPERM);
  
      /* Since prdebugentry is in the form of a prentry not a coentry, we will
***************
*** 486,503 ****
       afs_int32 gid;
  {
      afs_int32 code;
  
!     code = addToGroup(call, aid, gid);
!     osi_auditU(call, PTS_AdToGrpEvent, code, AUD_LONG, gid, AUD_LONG, aid,
  	       AUD_END);
      return code;
  }
  
  afs_int32
! addToGroup(call, aid, gid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 gid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
--- 499,519 ----
       afs_int32 gid;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = addToGroup(call, aid, gid, &cid);
!     osi_auditU(call, PTS_AdToGrpEvent, code, AUD_ID, gid, AUD_ID, aid,
  	       AUD_END);
+     ViceLog(5, ("PTS_AddToGroup: code %d cid %d gid %d aid %d", code, cid, gid, aid));
      return code;
  }
  
  afs_int32
! addToGroup(call, aid, gid, cid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 gid;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
***************
*** 505,511 ****
      afs_int32 tempg;
      struct prentry tentry;
      struct prentry uentry;
-     afs_int32 cid;
  
      code = Initdb();
      if (code != PRSUCCESS)
--- 521,526 ----
***************
*** 524,530 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      tempu = FindByID(tt, aid);
--- 539,545 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      tempu = FindByID(tt, aid);
***************
*** 550,556 ****
      /* make sure that this is a group */
      if (!(tentry.flags & PRGRP))
  	ABORT_WITH(tt, PRNOTGROUP);
!     if (!AccessOK(tt, cid, &tentry, PRP_ADD_MEM, PRP_ADD_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = AddToEntry(tt, &tentry, tempg, aid);
--- 565,571 ----
      /* make sure that this is a group */
      if (!(tentry.flags & PRGRP))
  	ABORT_WITH(tt, PRNOTGROUP);
!     if (!AccessOK(tt, *cid, &tentry, PRP_ADD_MEM, PRP_ADD_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = AddToEntry(tt, &tentry, tempg, aid);
***************
*** 582,587 ****
--- 597,603 ----
  
      code = nameToID(call, aname, aid);
      osi_auditU(call, PTS_NmToIdEvent, code, AUD_END);
+     ViceLog(125, ("PTS_NameToID: code %d", code));
      return code;
  }
  
***************
*** 628,633 ****
--- 644,654 ----
  	code = NameToID(tt, aname->namelist_val[i], &aid->idlist_val[i]);
  	if (code != PRSUCCESS)
  	    aid->idlist_val[i] = ANONYMOUSID;
+         osi_audit(PTS_NmToIdEvent, code, AUD_STR,
+ 		   aname->namelist_val[i], AUD_ID, aid->idlist_val[i], 
+ 		   AUD_END);
+ 	ViceLog(125, ("PTS_NameToID: code %d aname %s aid %d", code,
+ 		      aname->namelist_val[i], aid->idlist_val[i]));
  	if (count++ > 50)
  	    IOMGR_Poll(), count = 0;
      }
***************
*** 653,659 ****
      afs_int32 code;
  
      code = idToName(call, aid, aname);
!     osi_auditU(call, PTS_IdToNmEvent, code, AUD_LONG, aid, AUD_END);
      return code;
  }
  
--- 674,681 ----
      afs_int32 code;
  
      code = idToName(call, aid, aname);
!     osi_auditU(call, PTS_IdToNmEvent, code, AUD_END);
!     ViceLog(125, ("PTS_IDToName: code %d", code));
      return code;
  }
  
***************
*** 701,706 ****
--- 723,732 ----
  	code = IDToName(tt, aid->idlist_val[i], aname->namelist_val[i]);
  	if (code != PRSUCCESS)
  	    sprintf(aname->namelist_val[i], "%d", aid->idlist_val[i]);
+         osi_audit(PTS_IdToNmEvent, code, AUD_ID, aid->idlist_val[i],
+ 		  AUD_STR, aname->namelist_val[i], AUD_END);
+ 	ViceLog(125, ("PTS_idToName: code %d aid %d aname %s", code,
+ 		      aid->idlist_val[i], aname->namelist_val[i]));
  	if (count++ > 50)
  	    IOMGR_Poll(), count = 0;
      }
***************
*** 718,737 ****
       afs_int32 aid;
  {
      afs_int32 code;
  
!     code = Delete(call, aid);
!     osi_auditU(call, PTS_DelEvent, code, AUD_LONG, aid, AUD_END);
      return code;
  }
  
  afs_int32
! Delete(call, aid)
       struct rx_call *call;
       afs_int32 aid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      struct prentry tentry;
      afs_int32 loc, nptr;
      int count;
--- 744,765 ----
       afs_int32 aid;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = Delete(call, aid, &cid);
!     osi_auditU(call, PTS_DelEvent, code, AUD_ID, aid, AUD_END);
!     ViceLog(25, ("PTS_Delete: code %d cid %d aid %d", code, cid, aid));
      return code;
  }
  
  afs_int32
! Delete(call, aid, cid)
       struct rx_call *call;
       afs_int32 aid;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      struct prentry tentry;
      afs_int32 loc, nptr;
      int count;
***************
*** 754,760 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
--- 782,788 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
***************
*** 767,774 ****
  	ABORT_WITH(tt, PRDBFAIL);
  
      /* Do some access checking */
!     if (tentry.owner != cid && !IsAMemberOf(tt, cid, SYSADMINID)
! 	&& !IsAMemberOf(tt, cid, tentry.owner) && !pr_noAuth)
  	ABORT_WITH(tt, PRPERM);
  
      /* Delete each continuation block as a separate transaction so that no one
--- 795,802 ----
  	ABORT_WITH(tt, PRDBFAIL);
  
      /* Do some access checking */
!     if (tentry.owner != *cid && !IsAMemberOf(tt, *cid, SYSADMINID)
! 	&& !IsAMemberOf(tt, *cid, tentry.owner) && !pr_noAuth)
  	ABORT_WITH(tt, PRPERM);
  
      /* Delete each continuation block as a separate transaction so that no one
***************
*** 957,965 ****
       char *name;
       struct PrUpdateEntry *uentry;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      struct prentry tentry;
      afs_int32 loc;
      int id = 0;
--- 985,1009 ----
       char *name;
       struct PrUpdateEntry *uentry;
  {
+     afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
+ 
+     code = UpdateEntry(call, aid, name, uentry, &cid);
+     osi_auditU(call, PTS_UpdEntEvent, code, AUD_ID, aid, AUD_STR, name, AUD_END);
+     ViceLog(5, ("PTS_UpdateEntry: code %d cid %d aid %d name %s", code, cid, aid, name));
+     return code;
+ }
+ 
+ afs_int32
+ UpdateEntry(call, aid, name, uentry, cid)
+      struct rx_call *call;
+      afs_int32 aid;
+      char *name;
+      struct PrUpdateEntry *uentry;
+      afs_int32 *cid;
+ {
      register afs_int32 code;
      struct ubik_trans *tt;
      struct prentry tentry;
      afs_int32 loc;
      int id = 0;
***************
*** 985,994 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     code = IsAMemberOf(tt, cid, SYSADMINID);
      if (!code && !pr_noAuth)
  	ABORT_WITH(tt, PRPERM);
  
--- 1029,1038 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     code = IsAMemberOf(tt, *cid, SYSADMINID);
      if (!code && !pr_noAuth)
  	ABORT_WITH(tt, PRPERM);
  
***************
*** 1039,1056 ****
       afs_int32 gid;
  {
      afs_int32 code;
  
!     code = removeFromGroup(call, aid, gid);
!     osi_auditU(call, PTS_RmFmGrpEvent, code, AUD_LONG, gid, AUD_LONG, aid,
  	       AUD_END);
      return code;
  }
  
  afs_int32
! removeFromGroup(call, aid, gid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 gid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
--- 1083,1103 ----
       afs_int32 gid;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = removeFromGroup(call, aid, gid, &cid);
!     osi_auditU(call, PTS_RmFmGrpEvent, code, AUD_ID, gid, AUD_ID, aid,
  	       AUD_END);
+     ViceLog(5, ("PTS_RemoveFromGroup: code %d cid %d gid %d aid %d", code, cid, gid, aid));
      return code;
  }
  
  afs_int32
! removeFromGroup(call, aid, gid, cid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 gid;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
***************
*** 1058,1064 ****
      afs_int32 tempg;
      struct prentry uentry;
      struct prentry gentry;
-     afs_int32 cid;
  
      code = Initdb();
      if (code != PRSUCCESS)
--- 1105,1110 ----
***************
*** 1073,1079 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      tempu = FindByID(tt, aid);
--- 1119,1125 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      tempu = FindByID(tt, aid);
***************
*** 1096,1102 ****
      if (uentry.flags & PRGRP)
  	ABORT_WITH(tt, PRNOTUSER);
  #endif
!     if (!AccessOK(tt, cid, &gentry, PRP_REMOVE_MEM, 0))
  	ABORT_WITH(tt, PRPERM);
      code = RemoveFromEntry(tt, aid, gid);
      if (code != PRSUCCESS)
--- 1142,1148 ----
      if (uentry.flags & PRGRP)
  	ABORT_WITH(tt, PRNOTUSER);
  #endif
!     if (!AccessOK(tt, *cid, &gentry, PRP_REMOVE_MEM, 0))
  	ABORT_WITH(tt, PRPERM);
      code = RemoveFromEntry(tt, aid, gid);
      if (code != PRSUCCESS)
***************
*** 1127,1149 ****
       afs_int32 *over;
  {
      afs_int32 code;
  
!     code = getCPS(call, aid, alist, over);
!     osi_auditU(call, PTS_GetCPSEvent, code, AUD_LONG, aid, AUD_END);
      return code;
  }
  
  afs_int32
! getCPS(call, aid, alist, over)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *over;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
-     afs_int32 cid;
      struct prentry tentry;
  
      *over = 0;
--- 1173,1197 ----
       afs_int32 *over;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = getCPS(call, aid, alist, over, &cid);
!     osi_auditU(call, PTS_GetCPSEvent, code, AUD_ID, aid, AUD_END);
!     ViceLog(125, ("PTS_GetCPS: code %d cid %d aid %d", code, cid, aid));
      return code;
  }
  
  afs_int32
! getCPS(call, aid, alist, over, cid)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *over;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
      struct prentry tentry;
  
      *over = 0;
***************
*** 1170,1177 ****
  	ABORT_WITH(tt, code);
  
      /* afs does authenticate now */
!     code = WhoIsThis(call, tt, &cid);
!     if (code || !AccessOK(tt, cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = GetList(tt, &tentry, alist, 1);
--- 1218,1225 ----
  	ABORT_WITH(tt, code);
  
      /* afs does authenticate now */
!     code = WhoIsThis(call, tt, cid);
!     if (code || !AccessOK(tt, *cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = GetList(tt, &tentry, alist, 1);
***************
*** 1209,1233 ****
       afs_int32 *over;
  {
      afs_int32 code;
  
!     code = getCPS2(call, aid, ahost, alist, over);
!     osi_auditU(call, PTS_GetCPS2Event, code, AUD_LONG, aid, AUD_HOST, ahost,
  	       AUD_END);
      return code;
  }
  
  afs_int32
! getCPS2(call, aid, ahost, alist, over)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 ahost;
       prlist *alist;
       afs_int32 *over;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
-     afs_int32 cid;
      struct prentry tentry;
      struct prentry host_tentry;
      afs_int32 hostid;
--- 1257,1283 ----
       afs_int32 *over;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = getCPS2(call, aid, ahost, alist, over, &cid);
!     osi_auditU(call, PTS_GetCPS2Event, code, AUD_ID, aid, AUD_HOST, ahost,
  	       AUD_END);
+     ViceLog(125, ("PTS_GetCPS2: code %d cid %d aid %d ahost %d", code, cid, aid, ahost));
      return code;
  }
  
  afs_int32
! getCPS2(call, aid, ahost, alist, over, cid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 ahost;
       prlist *alist;
       afs_int32 *over;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
      struct prentry tentry;
      struct prentry host_tentry;
      afs_int32 hostid;
***************
*** 1263,1271 ****
  	    ABORT_WITH(tt, code);
  
  	/* afs does authenticate now */
! 	code = WhoIsThis(call, tt, &cid);
  	if (code
! 	    || !AccessOK(tt, cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	    ABORT_WITH(tt, PRPERM);
      }
      code = NameToID(tt, inet_ntoa(iaddr), &hostid);
--- 1313,1321 ----
  	    ABORT_WITH(tt, code);
  
  	/* afs does authenticate now */
! 	code = WhoIsThis(call, tt, cid);
  	if (code
! 	    || !AccessOK(tt, *cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	    ABORT_WITH(tt, PRPERM);
      }
      code = NameToID(tt, inet_ntoa(iaddr), &hostid);
***************
*** 1307,1312 ****
--- 1357,1363 ----
  
      code = getHostCPS(call, ahost, alist, over);
      osi_auditU(call, PTS_GetHCPSEvent, code, AUD_HOST, ahost, AUD_END);
+     ViceLog(125, ("PTS_GetHostCPS: code %d ahost %d", code, ahost));
      return code;
  }
  
***************
*** 1379,1384 ****
--- 1430,1436 ----
  
      code = listMax(call, uid, gid);
      osi_auditU(call, PTS_LstMaxEvent, code, AUD_END);
+     ViceLog(125, ("PTS_ListMax: code %d", code));
      return code;
  }
  
***************
*** 1421,1442 ****
       afs_int32 gflag;
  {
      afs_int32 code;
  
!     code = setMax(call, aid, gflag);
!     osi_auditU(call, PTS_SetMaxEvent, code, AUD_LONG, aid, AUD_LONG, gflag,
  	       AUD_END);
      return code;
  }
  
  afs_int32
! setMax(call, aid, gflag)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 gflag;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
  
      code = Initdb();
      if (code != PRSUCCESS)
--- 1473,1496 ----
       afs_int32 gflag;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = setMax(call, aid, gflag, &cid);
!     osi_auditU(call, PTS_SetMaxEvent, code, AUD_ID, aid, AUD_LONG, gflag,
  	       AUD_END);
+     ViceLog(125, ("PTS_SetMax: code %d cid %d aid %d gflag %d", code, cid, aid, gflag));
      return code;
  }
  
  afs_int32
! setMax(call, aid, gflag, cid)
       struct rx_call *call;
       afs_int32 aid;
       afs_int32 gflag;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
  
      code = Initdb();
      if (code != PRSUCCESS)
***************
*** 1451,1460 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     if (!AccessOK(tt, cid, 0, 0, 0))
  	ABORT_WITH(tt, PRPERM);
      if (((gflag & PRGRP) && (aid > 0)) || (!(gflag & PRGRP) && (aid < 0)))
  	ABORT_WITH(tt, PRBADARG);
--- 1505,1514 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     if (!AccessOK(tt, *cid, 0, 0, 0))
  	ABORT_WITH(tt, PRPERM);
      if (((gflag & PRGRP) && (aid > 0)) || (!(gflag & PRGRP) && (aid < 0)))
  	ABORT_WITH(tt, PRBADARG);
***************
*** 1476,1496 ****
       struct prcheckentry *aentry;
  {
      afs_int32 code;
  
!     code = listEntry(call, aid, aentry);
!     osi_auditU(call, PTS_LstEntEvent, code, AUD_LONG, aid, AUD_END);
      return code;
  }
  
  afs_int32
! listEntry(call, aid, aentry)
       struct rx_call *call;
       afs_int32 aid;
       struct prcheckentry *aentry;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      afs_int32 temp;
      struct prentry tentry;
  
--- 1530,1552 ----
       struct prcheckentry *aentry;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = listEntry(call, aid, aentry, &cid);
!     osi_auditU(call, PTS_LstEntEvent, code, AUD_ID, aid, AUD_END);
!     ViceLog(125, ("PTS_ListEntry: code %d cid %d aid %d", code, cid, aid));
      return code;
  }
  
  afs_int32
! listEntry(call, aid, aentry, cid)
       struct rx_call *call;
       afs_int32 aid;
       struct prcheckentry *aentry;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
      struct prentry tentry;
  
***************
*** 1507,1513 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      temp = FindByID(tt, aid);
--- 1563,1569 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      temp = FindByID(tt, aid);
***************
*** 1516,1522 ****
      code = pr_ReadEntry(tt, 0, temp, &tentry);
      if (code != 0)
  	ABORT_WITH(tt, code);
!     if (!AccessOK(tt, cid, &tentry, PRP_STATUS_MEM, PRP_STATUS_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      aentry->flags = tentry.flags >> PRIVATE_SHIFT;
--- 1572,1578 ----
      code = pr_ReadEntry(tt, 0, temp, &tentry);
      if (code != 0)
  	ABORT_WITH(tt, code);
!     if (!AccessOK(tt, *cid, &tentry, PRP_STATUS_MEM, PRP_STATUS_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      aentry->flags = tentry.flags >> PRIVATE_SHIFT;
***************
*** 1549,1571 ****
       afs_int32 *nextstartindex;
  {
      afs_int32 code;
  
!     code = listEntries(call, flag, startindex, bulkentries, nextstartindex);
      osi_auditU(call, PTS_LstEntsEvent, code, AUD_LONG, flag, AUD_END);
      return code;
  }
  
  afs_int32
! listEntries(call, flag, startindex, bulkentries, nextstartindex)
       struct rx_call *call;
       afs_int32 flag;
       afs_int32 startindex;
       prentries *bulkentries;
       afs_int32 *nextstartindex;
  {
      afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      afs_int32 i, eof, pos, maxentries, f;
      struct prentry tentry;
      afs_int32 pollcount = 0;
--- 1605,1629 ----
       afs_int32 *nextstartindex;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = listEntries(call, flag, startindex, bulkentries, nextstartindex, &cid);
      osi_auditU(call, PTS_LstEntsEvent, code, AUD_LONG, flag, AUD_END);
+     ViceLog(125, ("PTS_ListEntries: code %d cid %d flag %d", code, cid, flag));
      return code;
  }
  
  afs_int32
! listEntries(call, flag, startindex, bulkentries, nextstartindex, cid)
       struct rx_call *call;
       afs_int32 flag;
       afs_int32 startindex;
       prentries *bulkentries;
       afs_int32 *nextstartindex;
+      afs_int32 *cid;
  {
      afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 i, eof, pos, maxentries, f;
      struct prentry tentry;
      afs_int32 pollcount = 0;
***************
*** 1590,1599 ****
      /* Make sure we are an authenticated caller and that we are on the
       * SYSADMIN list.
       */
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     code = IsAMemberOf(tt, cid, SYSADMINID);
      if (!code && !pr_noAuth)
  	ABORT_WITH(tt, PRPERM);
  
--- 1648,1657 ----
      /* Make sure we are an authenticated caller and that we are on the
       * SYSADMIN list.
       */
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
!     code = IsAMemberOf(tt, *cid, SYSADMINID);
      if (!code && !pr_noAuth)
  	ABORT_WITH(tt, PRPERM);
  
***************
*** 1692,1716 ****
       afs_int32 newid;
  {
      afs_int32 code;
  
!     code = changeEntry(call, aid, name, oid, newid);
!     osi_auditU(call, PTS_ChgEntEvent, code, AUD_LONG, aid, AUD_STR, name,
  	       AUD_LONG, oid, AUD_LONG, newid, AUD_END);
      return code;
  }
  
  afs_int32
! changeEntry(call, aid, name, oid, newid)
       struct rx_call *call;
       afs_int32 aid;
       char *name;
       afs_int32 oid;
       afs_int32 newid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 pos;
-     afs_int32 cid;
  
      if (!name)
  	return PRPERM;
--- 1750,1776 ----
       afs_int32 newid;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = changeEntry(call, aid, name, oid, newid, &cid);
!     osi_auditU(call, PTS_ChgEntEvent, code, AUD_ID, aid, AUD_STR, name,
  	       AUD_LONG, oid, AUD_LONG, newid, AUD_END);
+     ViceLog(5, ("PTS_ChangeEntry: code %d cid %d aid %d name %s oid %d newid %d", code, cid, aid, name, oid, newid));
      return code;
  }
  
  afs_int32
! changeEntry(call, aid, name, oid, newid, cid)
       struct rx_call *call;
       afs_int32 aid;
       char *name;
       afs_int32 oid;
       afs_int32 newid;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 pos;
  
      if (!name)
  	return PRPERM;
***************
*** 1734,1747 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      pos = FindByID(tt, aid);
      if (!pos)
  	ABORT_WITH(tt, PRNOENT);
      /* protection check in changeentry */
!     code = ChangeEntry(tt, aid, cid, name, oid, newid);
      if (code != PRSUCCESS)
  	ABORT_WITH(tt, code);
  
--- 1794,1807 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      pos = FindByID(tt, aid);
      if (!pos)
  	ABORT_WITH(tt, PRNOENT);
      /* protection check in changeentry */
!     code = ChangeEntry(tt, aid, *cid, name, oid, newid);
      if (code != PRSUCCESS)
  	ABORT_WITH(tt, code);
  
***************
*** 1758,1783 ****
       afs_int32 spare1, spare2;
  {
      afs_int32 code;
  
      code =
  	setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1,
! 		       spare2);
!     osi_auditU(call, PTS_SetFldEntEvent, code, AUD_LONG, id, AUD_END);
      return code;
  }
  
  afs_int32
! setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2)
       struct rx_call *call;
       afs_int32 id;
       afs_int32 mask;		/* specify which fields to update */
       afs_int32 flags, ngroups, nusers;
       afs_int32 spare1, spare2;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 pos;
-     afs_int32 cid;
      struct prentry tentry;
      afs_int32 tflags;
  
--- 1818,1845 ----
       afs_int32 spare1, spare2;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
      code =
  	setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1,
! 		       spare2, &cid);
!     osi_auditU(call, PTS_SetFldEntEvent, code, AUD_ID, id, AUD_END);
!     ViceLog(5, ("PTS_SetFieldsEntry: code %d cid %d id %d", code, cid, id));
      return code;
  }
  
  afs_int32
! setFieldsEntry(call, id, mask, flags, ngroups, nusers, spare1, spare2, cid)
       struct rx_call *call;
       afs_int32 id;
       afs_int32 mask;		/* specify which fields to update */
       afs_int32 flags, ngroups, nusers;
       afs_int32 spare1, spare2;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 pos;
      struct prentry tentry;
      afs_int32 tflags;
  
***************
*** 1800,1806 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      pos = FindByID(tt, id);
--- 1862,1868 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
      pos = FindByID(tt, id);
***************
*** 1812,1824 ****
      tflags = tentry.flags;
  
      if (mask & (PR_SF_NGROUPS | PR_SF_NUSERS)) {
! 	if (!AccessOK(tt, cid, 0, 0, 0))
  	    ABORT_WITH(tt, PRPERM);
  	if ((tflags & PRQUOTA) == 0) {	/* default if only setting one */
  	    tentry.ngroups = tentry.nusers = 20;
  	}
      } else {
! 	if (!AccessOK(tt, cid, &tentry, 0, 0))
  	    ABORT_WITH(tt, PRPERM);
      }
  
--- 1874,1886 ----
      tflags = tentry.flags;
  
      if (mask & (PR_SF_NGROUPS | PR_SF_NUSERS)) {
! 	if (!AccessOK(tt, *cid, 0, 0, 0))
  	    ABORT_WITH(tt, PRPERM);
  	if ((tflags & PRQUOTA) == 0) {	/* default if only setting one */
  	    tentry.ngroups = tentry.nusers = 20;
  	}
      } else {
! 	if (!AccessOK(tt, *cid, &tentry, 0, 0))
  	    ABORT_WITH(tt, PRPERM);
      }
  
***************
*** 1860,1881 ****
       afs_int32 *over;
  {
      afs_int32 code;
  
!     code = listElements(call, aid, alist, over);
!     osi_auditU(call, PTS_LstEleEvent, code, AUD_LONG, aid, AUD_END);
      return code;
  }
  
  afs_int32
! listElements(call, aid, alist, over)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *over;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      afs_int32 temp;
      struct prentry tentry;
  
--- 1922,1945 ----
       afs_int32 *over;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = listElements(call, aid, alist, over, &cid);
!     osi_auditU(call, PTS_LstEleEvent, code, AUD_ID, aid, AUD_END);
!     ViceLog(125, ("PTS_ListElements: code %d cid %d aid %d", code, cid, aid));
      return code;
  }
  
  afs_int32
! listElements(call, aid, alist, over, cid)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *over;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
      struct prentry tentry;
  
***************
*** 1896,1902 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
--- 1960,1966 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
***************
*** 1906,1912 ****
      code = pr_ReadEntry(tt, 0, temp, &tentry);
      if (code)
  	ABORT_WITH(tt, code);
!     if (!AccessOK(tt, cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = GetList(tt, &tentry, alist, 0);
--- 1970,1976 ----
      code = pr_ReadEntry(tt, 0, temp, &tentry);
      if (code)
  	ABORT_WITH(tt, code);
!     if (!AccessOK(tt, *cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = GetList(tt, &tentry, alist, 0);
***************
*** 1927,1935 ****
  {
  #if defined(SUPERGROUPS)
      afs_int32 code;
  
!     code = listSuperGroups(call, aid, alist, over);
!     osi_auditU(call, "PTS_LstSGrps", code, AUD_LONG, aid, AUD_END);
      return code;
  #else
      return RXGEN_OPCODE;
--- 1991,2001 ----
  {
  #if defined(SUPERGROUPS)
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = listSuperGroups(call, aid, alist, over, &cid);
!     osi_auditU(call, PTS_LstSGrps, code, AUD_ID, aid, AUD_END);
!     ViceLog(125, ("PTS_ListSuperGroups: code %d cid %d aid %d", code, cid, aid));
      return code;
  #else
      return RXGEN_OPCODE;
***************
*** 1938,1952 ****
  
  #if defined(SUPERGROUPS)
  afs_int32
! listSuperGroups(call, aid, alist, over)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *over;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      afs_int32 temp;
      struct prentry tentry;
  
--- 2004,2018 ----
  
  #if defined(SUPERGROUPS)
  afs_int32
! listSuperGroups(call, aid, alist, over, cid)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *over;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      afs_int32 temp;
      struct prentry tentry;
  
***************
*** 1962,1968 ****
      code = ubik_SetLock(tt, 1, 1, LOCKREAD);
      if (code)
  	ABORT_WITH(tt, code);
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
--- 2028,2034 ----
      code = ubik_SetLock(tt, 1, 1, LOCKREAD);
      if (code)
  	ABORT_WITH(tt, code);
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
***************
*** 1972,1978 ****
      code = pr_ReadEntry(tt, 0, temp, &tentry);
      if (code)
  	ABORT_WITH(tt, code);
!     if (!AccessOK(tt, cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = GetSGList(tt, &tentry, alist);
--- 2038,2044 ----
      code = pr_ReadEntry(tt, 0, temp, &tentry);
      if (code)
  	ABORT_WITH(tt, code);
!     if (!AccessOK(tt, *cid, &tentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	ABORT_WITH(tt, PRPERM);
  
      code = GetSGList(tt, &tentry, alist);
***************
*** 2005,2026 ****
       afs_int32 *lastP;
  {
      afs_int32 code;
  
!     code = listOwned(call, aid, alist, lastP);
!     osi_auditU(call, PTS_LstOwnEvent, code, AUD_LONG, aid, AUD_END);
      return code;
  }
  
  afs_int32
! listOwned(call, aid, alist, lastP)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *lastP;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
-     afs_int32 cid;
      struct prentry tentry;
      afs_int32 head = 0;
      afs_int32 start;
--- 2071,2094 ----
       afs_int32 *lastP;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = listOwned(call, aid, alist, lastP, &cid);
!     osi_auditU(call, PTS_LstOwnEvent, code, AUD_ID, aid, AUD_END);
!     ViceLog(125, ("PTS_ListOwned: code %d cid %d aid %d", code, cid, aid));
      return code;
  }
  
  afs_int32
! listOwned(call, aid, alist, lastP, cid)
       struct rx_call *call;
       afs_int32 aid;
       prlist *alist;
       afs_int32 *lastP;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
      struct prentry tentry;
      afs_int32 head = 0;
      afs_int32 start;
***************
*** 2046,2052 ****
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, &cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
--- 2114,2120 ----
      if (code)
  	ABORT_WITH(tt, code);
  
!     code = WhoIsThis(call, tt, cid);
      if (code)
  	ABORT_WITH(tt, PRPERM);
  
***************
*** 2065,2075 ****
  	    if (code)
  		ABORT_WITH(tt, code);
  
! 	    if (!AccessOK(tt, cid, &tentry, -1, PRP_OWNED_ANY))
  		ABORT_WITH(tt, PRPERM);
  	    head = tentry.owned;
  	} else {
! 	    if (!AccessOK(tt, cid, 0, 0, 0))
  		ABORT_WITH(tt, PRPERM);
  	    head = ntohl(cheader.orphan);
  	}
--- 2133,2143 ----
  	    if (code)
  		ABORT_WITH(tt, code);
  
! 	    if (!AccessOK(tt, *cid, &tentry, -1, PRP_OWNED_ANY))
  		ABORT_WITH(tt, PRPERM);
  	    head = tentry.owned;
  	} else {
! 	    if (!AccessOK(tt, *cid, 0, 0, 0))
  		ABORT_WITH(tt, PRPERM);
  	    head = ntohl(cheader.orphan);
  	}
***************
*** 2095,2113 ****
       afs_int32 *flag;
  {
      afs_int32 code;
  
!     code = isAMemberOf(call, uid, gid, flag);
      osi_auditU(call, PTS_IsMemOfEvent, code, AUD_LONG, uid, AUD_LONG, gid,
  	       AUD_END);
      return code;
  }
  
  afs_int32
! isAMemberOf(call, uid, gid, flag)
       struct rx_call *call;
       afs_int32 uid;
       afs_int32 gid;
       afs_int32 *flag;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
--- 2163,2184 ----
       afs_int32 *flag;
  {
      afs_int32 code;
+     afs_int32 cid = ANONYMOUSID;
  
!     code = isAMemberOf(call, uid, gid, flag, &cid);
      osi_auditU(call, PTS_IsMemOfEvent, code, AUD_LONG, uid, AUD_LONG, gid,
  	       AUD_END);
+     ViceLog(125, ("PTS_IsAMemberOf: code %d cid %d uid %d gid %d", code, cid, uid, gid));
      return code;
  }
  
  afs_int32
! isAMemberOf(call, uid, gid, flag, cid)
       struct rx_call *call;
       afs_int32 uid;
       afs_int32 gid;
       afs_int32 *flag;
+      afs_int32 *cid;
  {
      register afs_int32 code;
      struct ubik_trans *tt;
***************
*** 2126,2139 ****
  	ABORT_WITH(tt, code);
  
      {
- 	afs_int32 cid;
  	afs_int32 uloc = FindByID(tt, uid);
  	afs_int32 gloc = FindByID(tt, gid);
  	struct prentry uentry, gentry;
  
  	if (!uloc || !gloc)
  	    ABORT_WITH(tt, PRNOENT);
! 	code = WhoIsThis(call, tt, &cid);
  	if (code)
  	    ABORT_WITH(tt, PRPERM);
  	code = pr_ReadEntry(tt, 0, uloc, &uentry);
--- 2197,2209 ----
  	ABORT_WITH(tt, code);
  
      {
  	afs_int32 uloc = FindByID(tt, uid);
  	afs_int32 gloc = FindByID(tt, gid);
  	struct prentry uentry, gentry;
  
  	if (!uloc || !gloc)
  	    ABORT_WITH(tt, PRNOENT);
! 	code = WhoIsThis(call, tt, cid);
  	if (code)
  	    ABORT_WITH(tt, PRPERM);
  	code = pr_ReadEntry(tt, 0, uloc, &uentry);
***************
*** 2149,2156 ****
  	if (!(gentry.flags & PRGRP))
  	    ABORT_WITH(tt, PRBADARG);
  #endif
! 	if (!AccessOK(tt, cid, &uentry, 0, PRP_MEMBER_ANY)
! 	    && !AccessOK(tt, cid, &gentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	    ABORT_WITH(tt, PRPERM);
      }
  
--- 2219,2226 ----
  	if (!(gentry.flags & PRGRP))
  	    ABORT_WITH(tt, PRBADARG);
  #endif
! 	if (!AccessOK(tt, *cid, &uentry, 0, PRP_MEMBER_ANY)
! 	    && !AccessOK(tt, *cid, &gentry, PRP_MEMBER_MEM, PRP_MEMBER_ANY))
  	    ABORT_WITH(tt, PRPERM);
      }
  
Index: openafs/src/ptserver/ptserver.c
diff -c openafs/src/ptserver/ptserver.c:1.21.2.1 openafs/src/ptserver/ptserver.c:1.21.2.2
*** openafs/src/ptserver/ptserver.c:1.21.2.1	Fri Apr 15 15:40:43 2005
--- openafs/src/ptserver/ptserver.c	Mon Jul 11 15:08:49 2005
***************
*** 112,118 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptserver.c,v 1.21.2.1 2005/04/15 19:40:43 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef	AFS_AIX32_ENV
--- 112,118 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptserver.c,v 1.21.2.2 2005/07/11 19:08:49 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef	AFS_AIX32_ENV
***************
*** 120,125 ****
--- 120,127 ----
  #endif
  #include <sys/types.h>
  #include <stdio.h>
+ #include <fcntl.h>
+ #include <sys/stat.h>
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
  #include <WINNT/afsevent.h>
***************
*** 315,326 ****
--- 317,360 ----
  	    serverLogSyslogFacility = atoi(arg + 8);
  	}
  #endif
+ 	else if (strncmp(arg, "-auditlog", alen) == 0) {
+ 	    int tempfd, flags;
+ 	    FILE *auditout;
+ 	    char oldName[MAXPATHLEN];
+ 	    char *fileName = argv[++a];
+ 
+ #ifndef AFS_NT40_ENV
+ 	    struct stat statbuf;
+ 
+ 	    if ((lstat(fileName, &statbuf) == 0) 
+ 		&& (S_ISFIFO(statbuf.st_mode))) {
+ 		flags = O_WRONLY | O_NONBLOCK;
+ 	    } else 
+ #endif
+ 	    {
+ 		strcpy(oldName, fileName);
+ 		strcat(oldName, ".old");
+ 		renamefile(fileName, oldName);
+ 		flags = O_WRONLY | O_TRUNC | O_CREAT;
+ 	    }
+ 	    tempfd = open(fileName, flags, 0666);
+ 	    if (tempfd > -1) {
+ 		auditout = fdopen(tempfd, "a");
+ 		if (auditout) {
+ 		    osi_audit_file(auditout);
+ 		    osi_audit(PTS_StartEvent, 0, AUD_END);
+ 		} else
+ 		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	    } else
+ 		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	}
  	else if (*arg == '-') {
  	    /* hack in help flag support */
  
  #if defined(SUPERGROUPS)
  #ifndef AFS_NT40_ENV
  	    printf("Usage: ptserver [-database <db path>] "
+ 		   "[-auditlog <log path>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-groupdepth <depth>] "
***************
*** 330,335 ****
--- 364,370 ----
  		   "[-help]\n");
  #else /* AFS_NT40_ENV */
  	    printf("Usage: ptserver [-database <db path>] "
+ 		   "[-auditlog <log path>] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-default_access default_user_access default_group_access] "
  		   "[-restricted] "
***************
*** 338,343 ****
--- 373,379 ----
  #else
  #ifndef AFS_NT40_ENV
  	    printf("Usage: ptserver [-database <db path>] "
+ 		   "[-auditlog <log path>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
***************
*** 346,351 ****
--- 382,388 ----
  		   "[-help]\n");
  #else /* AFS_NT40_ENV */
  	    printf("Usage: ptserver [-database <db path>] "
+ 		   "[-auditlog <log path>] "
  		   "[-default_access default_user_access default_group_access] "
  		   "[-restricted] "
  		   "[-p <number of processes>] [-rebuild] " "[-help]\n");
Index: openafs/src/ptserver/ptuser.c
diff -c openafs/src/ptserver/ptuser.c:1.16.2.2 openafs/src/ptserver/ptuser.c:1.16.2.6
*** openafs/src/ptserver/ptuser.c:1.16.2.2	Sun Jan 30 22:58:39 2005
--- openafs/src/ptserver/ptuser.c	Mon Jul 11 15:28:43 2005
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.2 2005/01/31 03:58:39 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.16.2.6 2005/07/11 19:28:43 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "afs/sysincludes.h"
***************
*** 71,124 ****
      afs_int32 code;
      struct rx_connection *serverconns[MAXSERVERS];
      struct rx_securityClass *sc[3];
!     static struct afsconf_dir *tdir = 0;	/* only do this once */
!     static char tconfDir[100];
      struct ktc_token ttoken;
      afs_int32 scIndex;
      static struct afsconf_cell info;
      afs_int32 i;
      char cellstr[64];
  
      initialize_PT_error_table();
      initialize_RXK_error_table();
      initialize_ACFG_error_table();
      initialize_KTC_error_table();
  
!     if (strcmp(confDir, tconfDir)) {
  	/*
! 	 * Different conf dir; force re-evaluation.
  	 */
! 	if (tdir) 
  	    afsconf_Close(tdir);
! 	tdir = (struct afsconf_dir *)0;
  	pruclient = (struct ubik_client *)0;
      }
!     if (tdir == 0) {
  	strncpy(tconfDir, confDir, sizeof(tconfDir));
  #if defined(UKERNEL)
  	tdir = afs_cdir;
- 	if (!cell) {
- 	    cell = afs_LclCellName;
- 	}
  #else /* defined(UKERNEL) */
! 	tdir = afsconf_Open(confDir);
  	if (!tdir) {
  	    if (confDir && strcmp(confDir, ""))
  		fprintf(stderr,
  			"libprot: Could not open configuration directory: %s.\n",
  			confDir);
! 	    return -1;
! 	}
! 
! 	if (!cell) {
! 	    code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
! 	    if (code) {
  		fprintf(stderr,
! 			"vos: can't get local cell name - check %s/%s\n",
! 			confDir, AFSDIR_THISCELL_FILE);
! 		exit(1);
! 	    }
! 	    cell = cellstr;
  	}
  #endif /* defined(UKERNEL) */
  
--- 71,153 ----
      afs_int32 code;
      struct rx_connection *serverconns[MAXSERVERS];
      struct rx_securityClass *sc[3];
!     static struct afsconf_dir *tdir = (struct afsconf_dir *)0;	/* only do this once */
!     static char tconfDir[100] = "";
!     static char tcell[64] = "";
      struct ktc_token ttoken;
      afs_int32 scIndex;
      static struct afsconf_cell info;
      afs_int32 i;
      char cellstr[64];
+     afs_int32 gottdir = 0;
+     afs_int32 refresh = 0;
  
      initialize_PT_error_table();
      initialize_RXK_error_table();
      initialize_ACFG_error_table();
      initialize_KTC_error_table();
  
! #if defined(UKERNEL)
!     if (!cell) {
!         cell = afs_LclCellName;
!     }
! #else /* defined(UKERNEL) */
!     if (!cell) {
!         if (!tdir) 
!             tdir = afsconf_Open(confDir);
! 	if (!tdir) {
! 	    if (confDir && strcmp(confDir, ""))
! 		fprintf(stderr,
! 			"libprot: Could not open configuration directory: %s.\n",
! 			confDir);
!             else
! 		fprintf(stderr,
! 			"libprot: No configuration directory specified.\n");
! 	    return -1;
! 	}
!         gottdir = 1;
! 
!         code = afsconf_GetLocalCell(tdir, cellstr, sizeof(cellstr));
!         if (code) {
!             fprintf(stderr,
!                      "libprot: Could not get local cell. [%d]\n", code);
!             return code;
!         }
!         cell = cellstr;
!     }
! #endif /* defined(UKERNEL) */
! 
!     if (tdir == 0 || strcmp(confDir, tconfDir) || strcmp(cell, tcell)) {
  	/*
! 	 * force re-evaluation.  we either don't have an afsconf_dir,
!          * the directory has changed or the cell has changed.
  	 */
! 	if (tdir && !gottdir) {
  	    afsconf_Close(tdir);
!             tdir = (struct afsconf_dir *)0;
!         }
  	pruclient = (struct ubik_client *)0;
+         refresh = 1;
      }
! 
!     if (refresh) {
  	strncpy(tconfDir, confDir, sizeof(tconfDir));
+         strncpy(tcell, cell, sizeof(tcell));
+ 
  #if defined(UKERNEL)
  	tdir = afs_cdir;
  #else /* defined(UKERNEL) */
!         if (!gottdir)
!             tdir = afsconf_Open(confDir);
  	if (!tdir) {
  	    if (confDir && strcmp(confDir, ""))
  		fprintf(stderr,
  			"libprot: Could not open configuration directory: %s.\n",
  			confDir);
!             else
  		fprintf(stderr,
! 			"libprot: No configuration directory specified.\n");
! 	    return -1;
  	}
  #endif /* defined(UKERNEL) */
  
Index: openafs/src/rx/rx_kcommon.h
diff -c openafs/src/rx/rx_kcommon.h:1.27.2.2 openafs/src/rx/rx_kcommon.h:1.27.2.3
*** openafs/src/rx/rx_kcommon.h:1.27.2.2	Fri Dec 17 10:34:05 2004
--- openafs/src/rx/rx_kcommon.h	Mon Jul 11 15:13:48 2005
***************
*** 21,31 ****
  #ifdef AFS_LINUX22_ENV
  #ifndef _LINUX_CODA_FS_I
  #define _LINUX_CODA_FS_I 1
- #endif
  #define _CODA_HEADER_ 1
  struct coda_inode_info {
  };
  #endif
  #ifdef AFS_DARWIN_ENV
  #ifndef _MACH_ETAP_H_
  #define _MACH_ETAP_H_
--- 21,31 ----
  #ifdef AFS_LINUX22_ENV
  #ifndef _LINUX_CODA_FS_I
  #define _LINUX_CODA_FS_I 1
  #define _CODA_HEADER_ 1
  struct coda_inode_info {
  };
  #endif
+ #endif
  #ifdef AFS_DARWIN_ENV
  #ifndef _MACH_ETAP_H_
  #define _MACH_ETAP_H_
Index: openafs/src/ubik/udebug.c
diff -c openafs/src/ubik/udebug.c:1.16.2.1 openafs/src/ubik/udebug.c:1.16.2.2
*** openafs/src/ubik/udebug.c:1.16.2.1	Mon Oct 18 03:12:16 2004
--- openafs/src/ubik/udebug.c	Tue Jun 21 18:20:52 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/udebug.c,v 1.16.2.1 2004/10/18 07:12:16 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdlib.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/udebug.c,v 1.16.2.2 2005/06/21 22:20:52 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdlib.h>
***************
*** 34,39 ****
--- 34,40 ----
  #include <unistd.h>
  #endif
  #include <signal.h>
+ #include <afs/afsutil.h>
  #include <time.h>
  
  #include <lock.h>
***************
*** 93,103 ****
  {
      char *hostName, *portName, *times;
      afs_int32 hostAddr;
-     struct in_addr inhostAddr;
      register afs_int32 i, j, code;
      short port;
      int int32p;
!     time_t now, diff, newtime;
      struct hostent *th;
      struct rx_connection *tconn;
      struct rx_securityClass *sc;
--- 94,103 ----
  {
      char *hostName, *portName, *times;
      afs_int32 hostAddr;
      register afs_int32 i, j, code;
      short port;
      int int32p;
!     time_t now, then, diff, newtime;
      struct hostent *th;
      struct rx_connection *tconn;
      struct rx_securityClass *sc;
***************
*** 161,171 ****
  	exit(0);
      }
      now = time(0);
  
      /* now print the main info */
!     times = ctime((time_t *) & udebug.now);
      times[24] = 0;
-     inhostAddr.s_addr = hostAddr;
      if (!oldServer) {
  	printf("Host's addresses are: ");
  	for (j = 0; udebug.interfaceAddr[j] && (j < UBIK_MAX_INTERFACE_ADDR);
--- 161,171 ----
  	exit(0);
      }
      now = time(0);
+     then = udebug.now;
  
      /* now print the main info */
!     times = ctime(&then);
      times[24] = 0;
      if (!oldServer) {
  	printf("Host's addresses are: ");
  	for (j = 0; udebug.interfaceAddr[j] && (j < UBIK_MAX_INTERFACE_ADDR);
***************
*** 173,179 ****
  	    printf("%s ", afs_inet_ntoa(htonl(udebug.interfaceAddr[j])));
  	printf("\n");
      }
!     printf("Host's %s time is %s\n", inet_ntoa(inhostAddr), times);
  
      times = ctime(&now);
      times[24] = 0;
--- 173,179 ----
  	    printf("%s ", afs_inet_ntoa(htonl(udebug.interfaceAddr[j])));
  	printf("\n");
      }
!     printf("Host's %s time is %s\n", afs_inet_ntoa(hostAddr), times);
  
      times = ctime(&now);
      times[24] = 0;
***************
*** 196,205 ****
      if (udebug.lastYesHost == 0xffffffff) {
  	printf("Last yes vote not cast yet \n");
      } else {
- 	inhostAddr.s_addr = htonl(udebug.lastYesHost);
  	diff = udebug.now - udebug.lastYesTime;
  	printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
! 	       inet_ntoa(inhostAddr), diff,
  	       ((udebug.lastYesState) ? "" : "not "));
  
  	diff = udebug.now - udebug.lastYesClaim;
--- 196,204 ----
      if (udebug.lastYesHost == 0xffffffff) {
  	printf("Last yes vote not cast yet \n");
      } else {
  	diff = udebug.now - udebug.lastYesTime;
  	printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
! 	       afs_inet_ntoa(htonl(udebug.lastYesHost)), diff,
  	       ((udebug.lastYesState) ? "" : "not "));
  
  	diff = udebug.now - udebug.lastYesClaim;
***************
*** 236,249 ****
  	    printf("I am a clone and never can become sync site\n");
  	else
  	    printf("I am not sync site\n");
- 	inhostAddr.s_addr = htonl(udebug.lowestHost);
  	diff = udebug.now - udebug.lowestTime;
! 	printf("Lowest host %s was set %d secs ago\n", inet_ntoa(inhostAddr),
  	       diff);
  
- 	inhostAddr.s_addr = htonl(udebug.syncHost);
  	diff = udebug.now - udebug.syncTime;
! 	printf("Sync host %s was set %d secs ago\n", inet_ntoa(inhostAddr),
  	       diff);
      }
  
--- 235,248 ----
  	    printf("I am a clone and never can become sync site\n");
  	else
  	    printf("I am not sync site\n");
  	diff = udebug.now - udebug.lowestTime;
! 	printf("Lowest host %s was set %d secs ago\n",
! 	       afs_inet_ntoa(htonl(udebug.lowestHost)),
  	       diff);
  
  	diff = udebug.now - udebug.syncTime;
! 	printf("Sync host %s was set %d secs ago\n",
! 	       afs_inet_ntoa(htonl(udebug.syncHost)),
  	       diff);
      }
  
***************
*** 293,299 ****
  		printf("error code %d from VOTE_SDebug\n", code);
  		break;
  	    }
- 	    inhostAddr.s_addr = htonl(usdebug.addr);
  	    /* otherwise print the structure */
  	    printf("\nServer (%s", afs_inet_ntoa(htonl(usdebug.addr)));
  	    for (j = 0;
--- 292,297 ----
Index: openafs/src/util/Makefile.in
diff -c openafs/src/util/Makefile.in:1.24.2.3 openafs/src/util/Makefile.in:1.24.2.4
*** openafs/src/util/Makefile.in:1.24.2.3	Sun Apr 24 10:27:58 2005
--- openafs/src/util/Makefile.in	Tue Jun 21 16:20:00 2005
***************
*** 14,20 ****
  	 hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \
  	 dirpath.o fileutil.o netutils.o flipbase64.o \
  	 afs_atomlist.o afs_lhash.o snprintf.o strlcat.o strlcpy.o \
! 	 daemon.o ${REGEX_OBJ}
  
  includes = \
  	${TOP_INCDIR}/afs/dirpath.h \
--- 14,20 ----
  	 hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \
  	 dirpath.o fileutil.o netutils.o flipbase64.o \
  	 afs_atomlist.o afs_lhash.o snprintf.o strlcat.o strlcpy.o \
! 	 daemon.o rxkstats.o ${REGEX_OBJ}
  
  includes = \
  	${TOP_INCDIR}/afs/dirpath.h \
***************
*** 134,139 ****
--- 134,142 ----
  daemon.o: ${srcdir}/daemon.c ${includes}
  	${CCOBJ} ${CFLAGS} -c ${srcdir}/daemon.c
  
+ rxkstats.o: ${srcdir}/rxkstats.c ${includes}
+ 	${CCOBJ} ${CFLAGS} -c ${srcdir}/rxkstats.c
+ 
  #
  # Install targets
  #
Index: openafs/src/util/afsutil.h
diff -c openafs/src/util/afsutil.h:1.17 openafs/src/util/afsutil.h:1.17.2.2
*** openafs/src/util/afsutil.h:1.17	Tue Jul 15 19:17:15 2003
--- openafs/src/util/afsutil.h	Mon Jul 11 15:08:49 2005
***************
*** 25,36 ****
--- 25,39 ----
  #include <stdio.h>
  #include <stdarg.h>
  extern int LogLevel;
+ extern int mrafsStyleLogs;
  #ifndef AFS_NT40_ENV
  extern int serverLogSyslog;
  extern int serverLogSyslogFacility;
  extern char *serverLogSyslogTag;
  #endif
  extern void vFSLog(const char *format, va_list args);
+ extern void SetLogThreadNumProgram(int (*func) () );
+ 
  /*@printflike@*/ extern void FSLog(const char *format, ...);
  #define ViceLog(level, str)  if ((level) <= LogLevel) (FSLog str)
  #define vViceLog(level, str) if ((level) <= LogLevel) (vFSLog str)
Index: openafs/src/util/afsutil_prototypes.h
diff -c openafs/src/util/afsutil_prototypes.h:1.7.2.2 openafs/src/util/afsutil_prototypes.h:1.7.2.4
*** openafs/src/util/afsutil_prototypes.h:1.7.2.2	Sun May  8 02:10:26 2005
--- openafs/src/util/afsutil_prototypes.h	Mon Jul 11 15:27:28 2005
***************
*** 101,106 ****
--- 101,108 ----
  extern int util_isint(char *str);
  
  /* kreltime.c */
+ struct ktime;
+ struct ktime_date;
  extern afs_int32 ktimeRelDate_ToInt32(struct ktime_date *kdptr);
  extern int Int32To_ktimeRelDate(afs_int32 int32Date,
  				struct ktime_date *kdptr);
***************
*** 157,162 ****
--- 159,165 ----
  extern void SetupLogSignals(void);
  extern int OpenLog(const char *fileName);
  extern int ReOpenLog(const char *fileName);
+ extern int LogThreadNum();
  
  /* snprintf.c */
  
Index: openafs/src/util/rxkstats.c
diff -c /dev/null openafs/src/util/rxkstats.c:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:16 2005
--- openafs/src/util/rxkstats.c	Tue Jun 21 16:20:00 2005
***************
*** 0 ****
--- 1,9 ----
+ #include <afsconfig.h>
+ #include <afs/param.h>
+ 
+ #include <des.h>
+ #include <des/stats.h>
+ 
+ #ifndef AFS_PTHREAD_ENV 
+ struct rxkad_stats rxkad_stats = { { 0 } }; 
+ #endif
Index: openafs/src/util/serverLog.c
diff -c openafs/src/util/serverLog.c:1.22.2.5 openafs/src/util/serverLog.c:1.22.2.10
*** openafs/src/util/serverLog.c:1.22.2.5	Tue Apr 19 01:14:40 2005
--- openafs/src/util/serverLog.c	Mon Jul 11 15:29:39 2005
***************
*** 20,26 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/util/serverLog.c,v 1.22.2.5 2005/04/19 05:14:40 jaltman Exp $");
  
  #include <stdio.h>
  #ifdef AFS_NT40_ENV
--- 20,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/util/serverLog.c,v 1.22.2.10 2005/07/11 19:29:39 shadow Exp $");
  
  #include <stdio.h>
  #ifdef AFS_NT40_ENV
***************
*** 70,76 ****
  #define O_NONBLOCK 0
  #endif
  
! char *(*threadNameProgram) ();
  
  static int serverLogFD = -1;
  
--- 70,81 ----
  #define O_NONBLOCK 0
  #endif
  
! static int
! dummyThreadNum(void)
! {
!     return -1;
! }
! static int (*threadNumProgram) () = dummyThreadNum;
  
  static int serverLogFD = -1;
  
***************
*** 83,92 ****
--- 88,104 ----
  #include <stdarg.h>
  int LogLevel;
  int mrafsStyleLogs = 0;
+ static int threadIdLogs = 0;
  int printLocks = 0;
  static char ourName[MAXPATHLEN];
  
  void
+ SetLogThreadNumProgram(int (*func) () )
+ {
+     threadNumProgram = func;
+ }
+ 
+ void
  WriteLogBuffer(char *buf, afs_uint32 len)
  {
      LOCK_SERVERLOG();
***************
*** 95,100 ****
--- 107,118 ----
      UNLOCK_SERVERLOG();
  }
  
+ int
+ LogThreadNum(void) 
+ {
+   return (*threadNumProgram) ();
+ }
+ 
  void
  vFSLog(const char *format, va_list args)
  {
***************
*** 102,108 ****
      char *timeStamp;
      char tbuffer[1024];
      char *info;
!     int len;
      char *name;
  
      currenttime = time(0);
--- 120,126 ----
      char *timeStamp;
      char tbuffer[1024];
      char *info;
!     int len, num;
      char *name;
  
      currenttime = time(0);
***************
*** 110,121 ****
      timeStamp[24] = ' ';	/* ts[24] is the newline, 25 is the null */
      info = &timeStamp[25];
  
!     if (mrafsStyleLogs) {
! 	name = (*threadNameProgram) ();
! 	(void)afs_snprintf(info, (sizeof tbuffer) - strlen(tbuffer), "[%s] ",
! 			   name);
  	info += strlen(info);
      }
  
      (void)afs_vsnprintf(info, (sizeof tbuffer) - strlen(tbuffer), format,
  			args);
--- 128,141 ----
      timeStamp[24] = ' ';	/* ts[24] is the newline, 25 is the null */
      info = &timeStamp[25];
  
!     if (mrafsStyleLogs || threadIdLogs) {
! 	num = (*threadNumProgram) ();
!         if (num > -1) {
! 	(void)afs_snprintf(info, (sizeof tbuffer) - strlen(tbuffer), "[%d] ",
! 			   num);
  	info += strlen(info);
      }
+     }
  
      (void)afs_vsnprintf(info, (sizeof tbuffer) - strlen(tbuffer), format,
  			args);
***************
*** 171,178 ****
--- 191,210 ----
  
      if (LogLevel > 0) {
  	LogLevel *= 5;
+ 
+ #if defined(AFS_PTHREAD_ENV)
+         if (LogLevel > 1 && threadNumProgram != NULL && 
+             threadIdLogs == 0) {
+             threadIdLogs = 1;
+         }
+ #endif
      } else {
  	LogLevel = 1;
+ 
+ #if defined(AFS_PTHREAD_ENV)
+         if (threadIdLogs == 1)
+             threadIdLogs = 0;
+ #endif
      }
      printLocks = 2;
  #if defined(AFS_PTHREAD_ENV)
***************
*** 196,208 ****
  #if defined(AFS_PTHREAD_ENV)
      DebugOn(LogLevel);
  #else /* AFS_PTHREAD_ENV */
!     IOMGR_SoftSig(DebugOn, (void *)LogLevel);
  #endif /* AFS_PTHREAD_ENV */
  
      (void)signal(signo, ResetDebug_Signal);	/* on some platforms,
  						 * this signal handler
  						 * needs to be set
  						 * again */
      if (mrafsStyleLogs)
  	OpenLog((char *)&ourName);
  }				/*ResetDebug_Signal */
--- 228,244 ----
  #if defined(AFS_PTHREAD_ENV)
      DebugOn(LogLevel);
  #else /* AFS_PTHREAD_ENV */
!     IOMGR_SoftSig(DebugOn, LogLevel);
  #endif /* AFS_PTHREAD_ENV */
  
      (void)signal(signo, ResetDebug_Signal);	/* on some platforms,
  						 * this signal handler
  						 * needs to be set
  						 * again */
+ #if defined(AFS_PTHREAD_ENV)
+     if (threadIdLogs == 1)
+         threadIdLogs = 0;
+ #endif
      if (mrafsStyleLogs)
  	OpenLog((char *)&ourName);
  }				/*ResetDebug_Signal */
***************
*** 241,254 ****
      }
  
      /* Support named pipes as logs by not rotating them */
!     if ((fstat(fileName, &statbuf) == 0)  && (S_ISFIFO(statbuf.st_mode))) {
  	isfifo = 1;
      }
  #endif
  
      if (mrafsStyleLogs) {
!         time_t t = Start.tv_sec;
  	TM_GetTimeOfDay(&Start, 0);
  	TimeFields = localtime(&t);
  	if (fileName) {
  	    if (strncmp(fileName, (char *)&ourName, strlen(fileName)))
--- 277,291 ----
      }
  
      /* Support named pipes as logs by not rotating them */
!     if ((lstat(fileName, &statbuf) == 0)  && (S_ISFIFO(statbuf.st_mode))) {
  	isfifo = 1;
      }
  #endif
  
      if (mrafsStyleLogs) {
!         time_t t;
  	TM_GetTimeOfDay(&Start, 0);
+         t = Start.tv_sec;	
  	TimeFields = localtime(&t);
  	if (fileName) {
  	    if (strncmp(fileName, (char *)&ourName, strlen(fileName)))
***************
*** 314,320 ****
      }
  
      /* Support named pipes as logs by not rotating them */
!     if ((fstat(fileName, &statbuf) == 0)  && (S_ISFIFO(statbuf.st_mode))) {
  	isfifo = 1;
      }
  #endif
--- 351,357 ----
      }
  
      /* Support named pipes as logs by not rotating them */
!     if ((lstat(fileName, &statbuf) == 0)  && (S_ISFIFO(statbuf.st_mode))) {
  	isfifo = 1;
      }
  #endif
Index: openafs/src/venus/fs.c
diff -c openafs/src/venus/fs.c:1.24.2.2 openafs/src/venus/fs.c:1.24.2.3
*** openafs/src/venus/fs.c:1.24.2.2	Sun May  8 02:18:14 2005
--- openafs/src/venus/fs.c	Mon Jul 11 15:03:42 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fs.c,v 1.24.2.2 2005/05/08 06:18:14 shadow Exp $");
  
  #include <afs/afs_args.h>
  #include <rx/xdr.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fs.c,v 1.24.2.3 2005/07/11 19:03:42 shadow Exp $");
  
  #include <afs/afs_args.h>
  #include <rx/xdr.h>
***************
*** 3420,3426 ****
      cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
  
      ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0,
! 			  "set cache manager encryption flag");
  
      ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
  			  "Manage per process RX statistics");
--- 3420,3426 ----
      cmd_AddParm(ts, "-crypt", CMD_SINGLE, 0, "on or off");
  
      ts = cmd_CreateSyntax("getcrypt", GetCryptCmd, 0,
! 			  "get cache manager encryption flag");
  
      ts = cmd_CreateSyntax("rxstatproc", RxStatProcCmd, 0,
  			  "Manage per process RX statistics");
Index: openafs/src/venus/fstrace.c
diff -c openafs/src/venus/fstrace.c:1.16.2.3 openafs/src/venus/fstrace.c:1.16.2.4
*** openafs/src/venus/fstrace.c:1.16.2.3	Sun Apr  3 14:15:53 2005
--- openafs/src/venus/fstrace.c	Mon Jul 11 15:29:40 2005
***************
*** 14,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.16.2.3 2005/04/03 18:15:53 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 14,20 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/fstrace.c,v 1.16.2.4 2005/07/11 19:29:40 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 1491,1497 ****
--- 1491,1501 ----
      char nls_filename[11];
      char alt_filename[80];
      char *message;
+ #if defined(AFS_64BITPOINTER_ENV)
+     long J;
+ #else
      int J;
+ #endif
      static char *facility_names[] = {
  	"xxx",
  	"afs"
***************
*** 1558,1564 ****
--- 1562,1572 ----
      catd = (nl_catd) catopen1(nls_filename, 0);
  #endif
  #else
+ #if defined(AFS_64BITPOINTER_ENV)
+     J = (long)catopen(nls_filename, 0);
+ #else
      J = (int)catopen(nls_filename, 0);
+ #endif
      catd = (nl_catd) J;
  #endif
      if (catd == (nl_catd) - 1) {
***************
*** 1581,1587 ****
--- 1589,1599 ----
  	catd = (nl_catd) catopen1(alt_filename, 0);
  #endif
  #else
+ #if defined(AFS_64BITPOINTER_ENV)
+         J = (long)catopen(alt_filename, 0);
+ #else
  	J = (int)catopen(alt_filename, 0);
+ #endif
  	catd = (nl_catd) J;
  #endif
  	if (catd == (nl_catd) - 1) {
Index: openafs/src/venus/kdump.c
diff -c openafs/src/venus/kdump.c:1.33.2.3 openafs/src/venus/kdump.c:1.33.2.5
*** openafs/src/venus/kdump.c:1.33.2.3	Mon Apr  4 03:36:32 2005
--- openafs/src/venus/kdump.c	Mon Jul 11 15:30:02 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/kdump.c,v 1.33.2.3 2005/04/04 07:36:32 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/kdump.c,v 1.33.2.5 2005/07/11 19:30:02 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 2885,2891 ****
  	    printf("\n");
  #ifdef	AFS33
  	printf("%lx: refC=%d, pv=%d, pu=%d, flushDv=%d.%d, mapDV=%d.%d, ",
! 	       ptr, vep->vrefCount, vep->parentVnode, vep->parentUnique,
  	       vep->flushDV.high, vep->flushDV.low, vep->mapDV.high,
  	       vep->mapDV.low);
  #ifdef AFS_64BIT_CLIENT
--- 2885,2891 ----
  	    printf("\n");
  #ifdef	AFS33
  	printf("%lx: refC=%d, pv=%d, pu=%d, flushDv=%d.%d, mapDV=%d.%d, ",
! 	       ptr, VREFCOUNT(vep), vep->parentVnode, vep->parentUnique,
  	       vep->flushDV.high, vep->flushDV.low, vep->mapDV.high,
  	       vep->mapDV.low);
  #ifdef AFS_64BIT_CLIENT
***************
*** 2903,2914 ****
  #ifdef	AFS_SUN5_ENV
  	printf("vstates=x%x, ", vep->vstates);
  #endif /* AFS_SUN5_ENV */
! 	printf("dchint=%x, anyA=0x%x\n", vep->h1.dchint, vep->anyAccess);
  #ifdef AFS_64BIT_CLIENT
- 	printf("\tquick[dc=%x, stamp=%x, f=%x, min=%d, len=(0x%x, 0x%x)]\n",
- 	       vep->quick.dc, vep->quick.stamp, vep->quick.f,
- 	       vep->quick.minLoc, (int)(vep->quick.len >> 32),
- 	       (int)(vep->quick.len & 0xffffffff));
  	printf
  	    ("\tmstat[len=(0x%x, 0x%x), DV=%d.%d, Date=%d, Owner=%d, Group=%d, Mode=0%o, linkc=%d]\n",
  	     (int)(vep->m.Length >> 32), (int)(vep->m.Length & 0xffffffff),
--- 2903,2910 ----
  #ifdef	AFS_SUN5_ENV
  	printf("vstates=x%x, ", vep->vstates);
  #endif /* AFS_SUN5_ENV */
! 	printf("dchint=%x, anyA=0x%x\n", vep->dchint, vep->anyAccess);
  #ifdef AFS_64BIT_CLIENT
  	printf
  	    ("\tmstat[len=(0x%x, 0x%x), DV=%d.%d, Date=%d, Owner=%d, Group=%d, Mode=0%o, linkc=%d]\n",
  	     (int)(vep->m.Length >> 32), (int)(vep->m.Length & 0xffffffff),
***************
*** 3024,3040 ****
  #endif
  #ifdef AFS_SGI62_ENV
      printf
! 	("\tf.chunk=%d, f.inode=%lld, f.chunkBytes=%d, f.states=%x, stamp=%x\n",
! 	 dcp->f.chunk, dcp->f.inode, dcp->f.chunkBytes, dcp->f.states,
! 	 dcp->stamp);
  #else
      printf
! 	("\tf.chunk=%d, f.inode=%d, f.chunkBytes=%d, f.states=%x, stamp=%x\n",
! 	 dcp->f.chunk, dcp->f.inode, dcp->f.chunkBytes, dcp->f.states,
! 	 dcp->stamp);
  #endif
!     printf("\tlruq.prev=%lx, lruq.next=%lx, index=%d, ihint=%x\n",
! 	   dcp->lruq.prev, dcp->lruq.next, dcp->index, dcp->ihint);
  }
  
  void
--- 3020,3034 ----
  #endif
  #ifdef AFS_SGI62_ENV
      printf
! 	("\tf.chunk=%d, f.inode=%lld, f.chunkBytes=%d, f.states=%x",
! 	 dcp->f.chunk, dcp->f.inode, dcp->f.chunkBytes, dcp->f.states);
  #else
      printf
! 	("\tf.chunk=%d, f.inode=%d, f.chunkBytes=%d, f.states=%x\n",
! 	 dcp->f.chunk, dcp->f.inode, dcp->f.chunkBytes, dcp->f.states);
  #endif
!     printf("\tlruq.prev=%lx, lruq.next=%lx, index=%d\n",
! 	   dcp->lruq.prev, dcp->lruq.next, dcp->index);
  }
  
  void
Index: openafs/src/vfsck/libfs.h
diff -c /dev/null openafs/src/vfsck/libfs.h:1.1.2.2
*** /dev/null	Mon Jul 11 23:46:16 2005
--- openafs/src/vfsck/libfs.h	Wed Jun 22 09:48:47 2005
***************
*** 0 ****
--- 1,6 ----
+ #include <sys/fs.h>        /* For UFS_*(fs) macro definitions */
+ 
+ #define BLKSEEK_PROCESSING_ERROR   (-2)
+ #define BLKSEEK_FILE_WRITEONLY     (-1)
+ #define BLKSEEK_NOT_ENABLED         0
+ #define BLKSEEK_ENABLED             1
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.81.2.6 openafs/src/viced/afsfileprocs.c:1.81.2.9
*** openafs/src/viced/afsfileprocs.c:1.81.2.6	Sun Apr  3 16:19:22 2005
--- openafs/src/viced/afsfileprocs.c	Mon Jul 11 15:29:20 2005
***************
*** 29,35 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.6 2005/04/03 20:19:22 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 29,35 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.9 2005/07/11 19:29:20 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 594,600 ****
--- 594,603 ----
  	*anyrights = 0;
      }
      *rights = 0;
+ 
+     ObtainWriteLock(&client->lock);
      acl_CheckRights(ACL, &client->CPS, rights);
+     ReleaseWriteLock(&client->lock);
  
      /* wait if somebody else is already doing the getCPS call */
      H_LOCK;
***************
*** 811,817 ****
  #endif
  	} else {		/*  !VanillaUser(client) && !FetchData */
  
! 	    osi_audit(PrivilegeEvent, 0, AUD_INT,
  		      (client ? client->ViceId : 0), AUD_INT, CallingRoutine,
  		      AUD_END);
  	}
--- 814,820 ----
  #endif
  	} else {		/*  !VanillaUser(client) && !FetchData */
  
! 	    osi_audit(PrivilegeEvent, 0, AUD_ID,
  		      (client ? client->ViceId : 0), AUD_INT, CallingRoutine,
  		      AUD_END);
  	}
***************
*** 829,841 ****
  		else if (VanillaUser(client))
  		    return (EPERM);	/* Was EACCES */
  		else
! 		    osi_audit(PrivilegeEvent, 0, AUD_INT,
  			      (client ? client->ViceId : 0), AUD_INT,
  			      CallingRoutine, AUD_END);
  	    }
  	} else {
  	    if (CallingRoutine != CHK_STOREDATA && !VanillaUser(client)) {
! 		osi_audit(PrivilegeEvent, 0, AUD_INT,
  			  (client ? client->ViceId : 0), AUD_INT,
  			  CallingRoutine, AUD_END);
  	    } else {
--- 832,844 ----
  		else if (VanillaUser(client))
  		    return (EPERM);	/* Was EACCES */
  		else
! 		    osi_audit(PrivilegeEvent, 0, AUD_ID,
  			      (client ? client->ViceId : 0), AUD_INT,
  			      CallingRoutine, AUD_END);
  	    }
  	} else {
  	    if (CallingRoutine != CHK_STOREDATA && !VanillaUser(client)) {
! 		osi_audit(PrivilegeEvent, 0, AUD_ID,
  			  (client ? client->ViceId : 0), AUD_INT,
  			  CallingRoutine, AUD_END);
  	    } else {
***************
*** 855,861 ****
  			else if (VanillaUser(client))
  			    return (EPERM);	/* Was EACCES */
  			else
! 			    osi_audit(PrivilegeEvent, 0, AUD_INT,
  				      (client ? client->ViceId : 0), AUD_INT,
  				      CallingRoutine, AUD_END);
  		    }
--- 858,864 ----
  			else if (VanillaUser(client))
  			    return (EPERM);	/* Was EACCES */
  			else
! 			    osi_audit(PrivilegeEvent, 0, AUD_ID,
  				      (client ? client->ViceId : 0), AUD_INT,
  				      CallingRoutine, AUD_END);
  		    }
***************
*** 871,877 ****
  			if (VanillaUser(client))
  			    return (EACCES);
  			else
! 			    osi_audit(PrivSetID, 0, AUD_INT,
  				      (client ? client->ViceId : 0), AUD_INT,
  				      CallingRoutine, AUD_END);
  		    }
--- 874,880 ----
  			if (VanillaUser(client))
  			    return (EACCES);
  			else
! 			    osi_audit(PrivSetID, 0, AUD_ID,
  				      (client ? client->ViceId : 0), AUD_INT,
  				      CallingRoutine, AUD_END);
  		    }
***************
*** 911,917 ****
  			    if (VanillaUser(client))
  				return (EACCES);
  			    else
! 				osi_audit(PrivilegeEvent, 0, AUD_INT,
  					  (client ? client->ViceId : 0),
  					  AUD_INT, CallingRoutine, AUD_END);
  			}
--- 914,920 ----
  			    if (VanillaUser(client))
  				return (EACCES);
  			    else
! 				osi_audit(PrivilegeEvent, 0, AUD_ID,
  					  (client ? client->ViceId : 0),
  					  AUD_INT, CallingRoutine, AUD_END);
  			}
***************
*** 1499,1510 ****
  	    targetptr->disk.modeBits = modebits;
  	    switch (Caller) {
  	    case TVS_SDATA:
! 		osi_audit(PrivSetID, 0, AUD_INT, client->ViceId, AUD_INT,
  			  CHK_STOREDATA, AUD_END);
  		break;
  	    case TVS_CFILE:
  	    case TVS_SSTATUS:
! 		osi_audit(PrivSetID, 0, AUD_INT, client->ViceId, AUD_INT,
  			  CHK_STORESTATUS, AUD_END);
  		break;
  	    default:
--- 1502,1513 ----
  	    targetptr->disk.modeBits = modebits;
  	    switch (Caller) {
  	    case TVS_SDATA:
! 		osi_audit(PrivSetID, 0, AUD_ID, client->ViceId, AUD_INT,
  			  CHK_STOREDATA, AUD_END);
  		break;
  	    case TVS_CFILE:
  	    case TVS_SSTATUS:
! 		osi_audit(PrivSetID, 0, AUD_ID, client->ViceId, AUD_INT,
  			  CHK_STORESTATUS, AUD_END);
  		break;
  	    default:
***************
*** 2078,2084 ****
      struct client *client;	/* pointer to the client data */
      struct rx_connection *tcon;	/* the connection we're part of */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
--- 2081,2087 ----
      struct client *client;	/* pointer to the client data */
      struct rx_connection *tcon;	/* the connection we're part of */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client = NULL;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
***************
*** 2285,2291 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, FetchDataEvent, errorCode, AUD_FID, Fid, AUD_END);
      return (errorCode);
  
  }				/*SRXAFS_FetchData */
--- 2288,2296 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, FetchDataEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_END);
      return (errorCode);
  
  }				/*SRXAFS_FetchData */
***************
*** 2295,2306 ****
  		 afs_int32 Len, struct AFSFetchStatus * OutStatus,
  		 struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
  {
!     int code;
! 
!     code =
! 	common_FetchData64(acall, Fid, Pos, Len, OutStatus, CallBack, Sync,
! 			   0);
!     return code;
  }
  
  afs_int32
--- 2300,2307 ----
  		 afs_int32 Len, struct AFSFetchStatus * OutStatus,
  		 struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
  {
!     return common_FetchData64(acall, Fid, Pos, Len, OutStatus, CallBack, 
!                               Sync, 0);
  }
  
  afs_int32
***************
*** 2343,2349 ****
      struct client *client;	/* pointer to the client data */
      afs_int32 rights, anyrights;	/* rights for this and any user */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
!     struct client *t_client;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
--- 2344,2350 ----
      struct client *client;	/* pointer to the client data */
      afs_int32 rights, anyrights;	/* rights for this and any user */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
!     struct client *t_client = NULL;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
***************
*** 2438,2444 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, FetchACLEvent, errorCode, AUD_FID, Fid, AUD_END);
      return errorCode;
  }				/*SRXAFS_FetchACL */
  
--- 2439,2447 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, FetchACLEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_END);
      return errorCode;
  }				/*SRXAFS_FetchACL */
  
***************
*** 2459,2465 ****
      Volume *volptr = 0;		/* pointer to the volume */
      struct client *client;	/* pointer to the client data */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
  
--- 2462,2468 ----
      Volume *volptr = 0;		/* pointer to the volume */
      struct client *client;	/* pointer to the client data */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client = NULL;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
  
***************
*** 2536,2541 ****
--- 2539,2545 ----
      afs_int32 rights, anyrights;	/* rights for this and any user */
      register struct AFSFid *tfid;	/* file id we're dealing with now */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
+     struct client *t_client = NULL;     /* tmp pointer to the client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 2637,2642 ****
--- 2641,2648 ----
  			   volptr);
      errorCode = CallPostamble(tcon, errorCode);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (errorCode == 0) {
***************
*** 2657,2664 ****
  
    Audit_and_Return:
      ViceLog(2, ("SAFS_BulkStatus	returns	%d\n", errorCode));
!     osi_auditU(acall, BulkFetchStatusEvent, errorCode, AUD_FIDS, Fids,
! 	       AUD_END);
      return errorCode;
  
  }				/*SRXAFS_BulkStatus */
--- 2663,2671 ----
  
    Audit_and_Return:
      ViceLog(2, ("SAFS_BulkStatus	returns	%d\n", errorCode));
!     osi_auditU(acall, BulkFetchStatusEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FIDS, Fids, AUD_END);
      return errorCode;
  
  }				/*SRXAFS_BulkStatus */
***************
*** 2679,2684 ****
--- 2686,2692 ----
      afs_int32 rights, anyrights;	/* rights for this and any user */
      register struct AFSFid *tfid;	/* file id we're dealing with now */
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
      AFSFetchStatus *tstatus;
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
***************
*** 2796,2801 ****
--- 2804,2811 ----
  			   volptr);
      errorCode = CallPostamble(tcon, errorCode);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (errorCode == 0) {
***************
*** 2816,2823 ****
  
    Audit_and_Return:
      ViceLog(2, ("SAFS_InlineBulkStatus	returns	%d\n", errorCode));
!     osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode, AUD_FIDS, Fids,
! 	       AUD_END);
      return 0;
  
  }				/*SRXAFS_InlineBulkStatus */
--- 2826,2834 ----
  
    Audit_and_Return:
      ViceLog(2, ("SAFS_InlineBulkStatus	returns	%d\n", errorCode));
!     osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FIDS, Fids, AUD_END);
      return 0;
  
  }				/*SRXAFS_InlineBulkStatus */
***************
*** 2830,2835 ****
--- 2841,2847 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 2854,2859 ****
--- 2866,2873 ----
    Bad_FetchStatus:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 2872,2878 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, FetchStatusEvent, code, AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_FetchStatus */
--- 2886,2894 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, FetchStatusEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_FetchStatus */
***************
*** 2892,2898 ****
      Volume *volptr = 0;		/* pointer to the volume header */
      struct client *client;	/* pointer to client structure */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
      struct rx_connection *tcon;
  #if FS_STATS_DETAILED
--- 2908,2914 ----
      Volume *volptr = 0;		/* pointer to the volume header */
      struct client *client;	/* pointer to client structure */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client = NULL;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
      struct rx_connection *tcon;
  #if FS_STATS_DETAILED
***************
*** 3091,3100 ****
  	FS_UNLOCK;
      }
  #endif /* FS_STATS_DETAILED */
! 
!     osi_auditU(acall, StoreDataEvent, errorCode, AUD_FID, Fid, AUD_END);
      return (errorCode);
- 
  }				/*common_StoreData64 */
  
  afs_int32
--- 3107,3116 ----
  	FS_UNLOCK;
      }
  #endif /* FS_STATS_DETAILED */
!     osi_auditU(acall, StoreDataEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_END);
      return (errorCode);
  }				/*common_StoreData64 */
  
  afs_int32
***************
*** 3103,3115 ****
  		 afs_uint32 Length, afs_uint32 FileLength,
  		 struct AFSFetchStatus * OutStatus, struct AFSVolSync * Sync)
  {
!     int code;
! 
!     code =
! 	common_StoreData64(acall, Fid, InStatus, Pos, Length, FileLength,
! 			   OutStatus, Sync);
!     return code;
! 
  }				/*SRXAFS_StoreData */
  
  afs_int32
--- 3119,3126 ----
  		 afs_uint32 Length, afs_uint32 FileLength,
  		 struct AFSFetchStatus * OutStatus, struct AFSVolSync * Sync)
  {
!     return common_StoreData64(acall, Fid, InStatus, Pos, Length, FileLength,
! 	                      OutStatus, Sync);
  }				/*SRXAFS_StoreData */
  
  afs_int32
***************
*** 3159,3165 ****
      struct client *client;	/* pointer to client structure */
      afs_int32 rights, anyrights;	/* rights for this and any user */
      struct rx_connection *tcon;
!     struct client *t_client;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
--- 3170,3176 ----
      struct client *client;	/* pointer to client structure */
      afs_int32 rights, anyrights;	/* rights for this and any user */
      struct rx_connection *tcon;
!     struct client *t_client = NULL;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
***************
*** 3253,3259 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, StoreACLEvent, errorCode, AUD_FID, Fid, AUD_END);
      return errorCode;
  
  }				/*SRXAFS_StoreACL */
--- 3264,3272 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, StoreACLEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_ACL, AccessList->AFSOpaque_val, AUD_END);
      return errorCode;
  
  }				/*SRXAFS_StoreACL */
***************
*** 3274,3280 ****
      Volume *volptr = 0;		/* pointer to the volume header */
      struct client *client;	/* pointer to client structure */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
  
--- 3287,3293 ----
      Volume *volptr = 0;		/* pointer to the volume header */
      struct client *client;	/* pointer to client structure */
      afs_int32 rights, anyrights;	/* rights for this and any user */
!     struct client *t_client = NULL;	/* tmp ptr to client data */
      struct in_addr logHostAddr;	/* host ip holder for inet_ntoa */
      struct rx_connection *tcon = rx_ConnectionOf(acall);
  
***************
*** 3350,3355 ****
--- 3363,3369 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 3374,3379 ****
--- 3388,3395 ----
    Bad_StoreStatus:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 3392,3398 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, StoreStatusEvent, code, AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_StoreStatus */
--- 3408,3416 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, StoreStatusEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_StoreStatus */
***************
*** 3506,3511 ****
--- 3524,3530 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 3530,3535 ****
--- 3549,3556 ----
    Bad_RemoveFile:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 3548,3555 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, RemoveFileEvent, code, AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_END);
      return code;
  
  }				/*SRXAFS_RemoveFile */
--- 3569,3577 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, RemoveFileEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name, AUD_END);
      return code;
  
  }				/*SRXAFS_RemoveFile */
***************
*** 3668,3673 ****
--- 3690,3696 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 3694,3699 ****
--- 3717,3724 ----
    Bad_CreateFile:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 3712,3719 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, CreateFileEvent, code, AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_END);
      return code;
  
  }				/*SRXAFS_CreateFile */
--- 3737,3745 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, CreateFileEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name, AUD_END);
      return code;
  
  }				/*SRXAFS_CreateFile */
***************
*** 4153,4158 ****
--- 4179,4185 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 4179,4184 ****
--- 4206,4213 ----
    Bad_Rename:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 4197,4204 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, RenameFileEvent, code, AUD_FID, OldDirFid, AUD_STR,
! 	       OldName, AUD_FID, NewDirFid, AUD_STR, NewName, AUD_END);
      return code;
  
  }				/*SRXAFS_Rename */
--- 4226,4235 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, RenameFileEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, OldDirFid, AUD_STR, OldName, 
!                AUD_FID, NewDirFid, AUD_STR, NewName, AUD_END);
      return code;
  
  }				/*SRXAFS_Rename */
***************
*** 4353,4358 ****
--- 4384,4390 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 4379,4384 ****
--- 4411,4418 ----
    Bad_Symlink:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 4397,4404 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, SymlinkEvent, code, AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_END);
      return code;
  
  }				/*SRXAFS_Symlink */
--- 4431,4440 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, SymlinkEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0, 
!                AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_FID, OutFid, AUD_STR, LinkContents, AUD_END);
      return code;
  
  }				/*SRXAFS_Symlink */
***************
*** 4548,4553 ****
--- 4584,4590 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 4574,4579 ****
--- 4611,4618 ----
    Bad_Link:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 4592,4598 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, LinkEvent, code, AUD_FID, DirFid, AUD_STR, Name,
  	       AUD_FID, ExistingFid, AUD_END);
      return code;
  
--- 4631,4639 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, LinkEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name,
  	       AUD_FID, ExistingFid, AUD_END);
      return code;
  
***************
*** 4743,4748 ****
--- 4784,4790 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 4768,4773 ****
--- 4810,4817 ----
    Bad_MakeDir:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 4786,4793 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, MakeDirEvent, code, AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_END);
      return code;
  
  }				/*SRXAFS_MakeDir */
--- 4830,4839 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, MakeDirEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_FID, OutFid, AUD_END);
      return code;
  
  }				/*SRXAFS_MakeDir */
***************
*** 4900,4905 ****
--- 4946,4952 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 4924,4929 ****
--- 4971,4978 ----
    Bad_RemoveDir:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 4942,4949 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, RemoveDirEvent, code, AUD_FID, DirFid, AUD_STR, Name,
! 	       AUD_END);
      return code;
  
  }				/*SRXAFS_RemoveDir */
--- 4991,4999 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, RemoveDirEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, DirFid, AUD_STR, Name, AUD_END);
      return code;
  
  }				/*SRXAFS_RemoveDir */
***************
*** 5018,5024 ****
  		  ViceLockType type, struct AFSVolSync * Sync)
  {
      return SRXAFS_SetLock(acall, Fid, type, Sync);
- 
  }				/*SRXAFS_OldSetLock */
  
  
--- 5068,5073 ----
***************
*** 5028,5033 ****
--- 5077,5083 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 5052,5057 ****
--- 5102,5109 ----
    Bad_SetLock:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 5070,5079 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, SetLockEvent, code, AUD_FID, Fid, AUD_LONG, type,
! 	       AUD_END);
      return code;
- 
  }				/*SRXAFS_SetLock */
  
  
--- 5122,5131 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, SetLockEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0, 
!                AUD_FID, Fid, AUD_LONG, type, AUD_END);
      return code;
  }				/*SRXAFS_SetLock */
  
  
***************
*** 5141,5147 ****
  		     struct AFSVolSync * Sync)
  {
      return SRXAFS_ExtendLock(acall, Fid, Sync);
- 
  }				/*SRXAFS_OldExtendLock */
  
  
--- 5193,5198 ----
***************
*** 5151,5156 ****
--- 5202,5208 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 5175,5180 ****
--- 5227,5234 ----
    Bad_ExtendLock:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 5193,5199 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, ExtendLockEvent, code, AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_ExtendLock */
--- 5247,5255 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, ExtendLockEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_ExtendLock */
***************
*** 5272,5278 ****
  		      struct AFSVolSync * Sync)
  {
      return SRXAFS_ReleaseLock(acall, Fid, Sync);
- 
  }				/*SRXAFS_OldReleaseLock */
  
  
--- 5328,5333 ----
***************
*** 5282,5287 ****
--- 5337,5343 ----
  {
      afs_int32 code;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 5306,5311 ****
--- 5362,5369 ----
    Bad_ReleaseLock:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 5324,5330 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, ReleaseLockEvent, code, AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_ReleaseLock */
--- 5382,5390 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, ReleaseLockEvent, code, 
!                AUD_ID, t_client ? t_client->ViceId : 0, 
!                AUD_FID, Fid, AUD_END);
      return code;
  
  }				/*SRXAFS_ReleaseLock */
***************
*** 5410,5416 ****
  SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
  {
      afs_int32 code;
!     struct rx_connection *tcon;
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
--- 5470,5477 ----
  SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
  {
      afs_int32 code;
!     struct rx_connection *tcon = rx_ConnectionOf(acall);
!     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 5442,5447 ****
--- 5503,5510 ----
    Bad_GetStatistics:
      code = CallPostamble(tcon, code);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (code == 0) {
***************
*** 5460,5467 ****
      }
  #endif /* FS_STATS_DETAILED */
  
      return code;
- 
  }				/*SRXAFS_GetStatistics */
  
  
--- 5523,5531 ----
      }
  #endif /* FS_STATS_DETAILED */
  
+     osi_auditU(acall, GetStatisticsEvent, code, 
+                AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
      return code;
  }				/*SRXAFS_GetStatistics */
  
  
***************
*** 5489,5494 ****
--- 5553,5560 ----
  SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
  {				/*SRXAFS_XStatsVersion */
  
+     struct client *t_client = NULL;	/* tmp ptr to client data */
+     struct rx_connection *tcon;
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 5507,5512 ****
--- 5573,5580 ----
  
      *a_versionP = AFS_XSTAT_VERSION;
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
***************
*** 5522,5529 ****
      (opP->numSuccesses)++;
      FS_UNLOCK;
  #endif /* FS_STATS_DETAILED */
-     return (0);
  
  }				/*SRXAFS_XStatsVersion */
  
  
--- 5590,5599 ----
      (opP->numSuccesses)++;
      FS_UNLOCK;
  #endif /* FS_STATS_DETAILED */
  
+     osi_auditU(a_call, XStatsVersionEvent, 0, 
+                AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
+     return (0);
  }				/*SRXAFS_XStatsVersion */
  
  
***************
*** 6229,6234 ****
--- 6299,6305 ----
      afs_int32 rights, anyrights;	/* rights for this and any user */
      AFSFid dummyFid;
      struct rx_connection *tcon;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 6291,6296 ****
--- 6362,6369 ----
      }
      errorCode = CallPostamble(tcon, errorCode);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (errorCode == 0) {
***************
*** 6308,6313 ****
--- 6381,6390 ----
  	FS_UNLOCK;
      }
  #endif /* FS_STATS_DETAILED */
+ 
+     osi_auditU(acall, GetVolumeStatusEvent, errorCode, 
+                AUD_ID, t_client ? t_client->ViceId : 0,
+                AUD_LONG, avolid, AUD_STR, *Name, AUD_END);
      return (errorCode);
  
  }				/*SRXAFS_GetVolumeStatus */
***************
*** 6326,6331 ****
--- 6403,6409 ----
      afs_int32 rights, anyrights;	/* rights for this and any user */
      AFSFid dummyFid;
      struct rx_connection *tcon = rx_ConnectionOf(acall);
+     struct client *t_client = NULL;	/* tmp ptr to client data */
  #if FS_STATS_DETAILED
      struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
      struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
***************
*** 6380,6385 ****
--- 6458,6465 ----
      ViceLog(2, ("SAFS_SetVolumeStatus returns %d\n", errorCode));
      errorCode = CallPostamble(tcon, errorCode);
  
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
  #if FS_STATS_DETAILED
      TM_GetTimeOfDay(&opStopTime, 0);
      if (errorCode == 0) {
***************
*** 6398,6407 ****
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, SetVolumeStatusEvent, errorCode, AUD_LONG, avolid,
! 	       AUD_STR, Name, AUD_END);
      return (errorCode);
- 
  }				/*SRXAFS_SetVolumeStatus */
  
  #define	DEFAULTVOLUME	"root.afs"
--- 6478,6487 ----
      }
  #endif /* FS_STATS_DETAILED */
  
!     osi_auditU(acall, SetVolumeStatusEvent, errorCode, 
!                AUD_ID, t_client ? t_client->ViceId : 0,
!                AUD_LONG, avolid, AUD_STR, Name, AUD_END);
      return (errorCode);
  }				/*SRXAFS_SetVolumeStatus */
  
  #define	DEFAULTVOLUME	"root.afs"
***************
*** 7249,7256 ****
  #ifndef __EXPERIMENTAL_CALLBACK_CONN_MOVING
      errorCode = 1;
  #else
! 
!     H_LOCK
      tclient = h_FindClient_r(tcon);
      thost = tclient->host;
      
--- 7329,7335 ----
  #ifndef __EXPERIMENTAL_CALLBACK_CONN_MOVING
      errorCode = 1;
  #else
!     H_LOCK;
      tclient = h_FindClient_r(tcon);
      thost = tclient->host;
      
***************
*** 7283,7291 ****
  			     thost->port, 1, sc, 0);
      rx_SetConnDeadTime(conn, 2); 
      rx_SetConnHardDeadTime(conn, AFS_HARDDEADTIME); 
!     H_UNLOCK
      errorCode = RXAFSCB_Probe(conn);
!     H_LOCK
      if (!errorCode) {
  	if ( thost->callback_rxcon )
  	    rx_DestroyConnection(thost->callback_rxcon);
--- 7362,7370 ----
  			     thost->port, 1, sc, 0);
      rx_SetConnDeadTime(conn, 2); 
      rx_SetConnHardDeadTime(conn, AFS_HARDDEADTIME); 
!     H_UNLOCK;
      errorCode = RXAFSCB_Probe(conn);
!     H_LOCK;
      if (!errorCode) {
  	if ( thost->callback_rxcon )
  	    rx_DestroyConnection(thost->callback_rxcon);
***************
*** 7299,7308 ****
      } else {
  	rx_DestroyConnection(conn);
      }	    
  #endif
  
-  Bad_CallBackRxConnAddr:
-     H_UNLOCK;
      errorCode = CallPostamble(tcon, errorCode);
   Bad_CallBackRxConnAddr1:
      return errorCode;          /* failure */
--- 7378,7387 ----
      } else {
  	rx_DestroyConnection(conn);
      }	    
+   Bad_CallBackRxConnAddr:
+     H_UNLOCK;
  #endif
  
      errorCode = CallPostamble(tcon, errorCode);
   Bad_CallBackRxConnAddr1:
      return errorCode;          /* failure */
Index: openafs/src/viced/host.c
diff -c openafs/src/viced/host.c:1.57.2.3 openafs/src/viced/host.c:1.57.2.4
*** openafs/src/viced/host.c:1.57.2.3	Sun Apr  3 16:19:22 2005
--- openafs/src/viced/host.c	Tue Jun 21 16:20:41 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.3 2005/04/03 20:19:22 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.4 2005/06/21 20:20:41 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 1452,1457 ****
--- 1452,1458 ----
      if (!client) {
  	host = h_GetHost_r(tcon);	/* Returns it h_Held */
  
+     retryfirstclient:
  	/* First try to find the client structure */
  	for (client = host->FirstClient; client; client = client->next) {
  	    if (!client->deleted && (client->sid == rxr_CidOf(tcon))
***************
*** 1485,1490 ****
--- 1486,1500 ----
  
  	/* Still no client structure - get one */
  	if (!client) {
+ 	    h_Lock_r(host);
+ 	    /* Retry to find the client structure */
+ 	    for (client = host->FirstClient; client; client = client->next) {
+ 		if (!client->deleted && (client->sid == rxr_CidOf(tcon))
+ 		    && (client->VenusEpoch == rxr_GetEpoch(tcon))) {
+ 		    h_Unlock_r(host);
+ 		    goto retryfirstclient;
+ 		}
+ 	    }
  	    client = GetCE();
  	    ObtainWriteLock(&client->lock);
  	    client->refCount = 1;
***************
*** 1501,1506 ****
--- 1511,1517 ----
  	    client->VenusEpoch = rxr_GetEpoch(tcon);
  	    client->CPS.prlist_val = 0;
  	    client->CPS.prlist_len = 0;
+ 	    h_Unlock_r(host);
  	    CurrentConnections++;	/* increment number of connections */
  	}
      }
Index: openafs/src/viced/viced.c
diff -c openafs/src/viced/viced.c:1.58.2.5 openafs/src/viced/viced.c:1.58.2.7
*** openafs/src/viced/viced.c:1.58.2.5	Mon May 30 00:41:28 2005
--- openafs/src/viced/viced.c	Mon Jul 11 15:08:50 2005
***************
*** 20,26 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.5 2005/05/30 04:41:28 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 20,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.7 2005/07/11 19:08:50 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 28,35 ****
  #include <sys/types.h>
  #include <afs/procmgmt.h>	/* signal(), kill(), wait(), etc. */
  #include <sys/stat.h>
- #ifdef AFS_NT40_ENV
  #include <fcntl.h>
  #include <io.h>
  #include <windows.h>
  #include <WINNT/afsevent.h>
--- 28,35 ----
  #include <sys/types.h>
  #include <afs/procmgmt.h>	/* signal(), kill(), wait(), etc. */
  #include <sys/stat.h>
  #include <fcntl.h>
+ #ifdef AFS_NT40_ENV
  #include <io.h>
  #include <windows.h>
  #include <WINNT/afsevent.h>
***************
*** 88,94 ****
  #include "host.h"
  #ifdef AFS_PTHREAD_ENV
  #include "softsig.h"
- char *(*threadNameProgram) ();
  #endif
  #if defined(AFS_SGI_ENV)
  #include "sys/schedctl.h"
--- 88,93 ----
***************
*** 318,331 ****
  
  #if defined(AFS_PTHREAD_ENV)
  char *
! threadName(void)
  {
!     char threadid[16];
!     if (LogLevel > 999) {
! 	afs_snprintf(threadid, 16, "%d", pthread_getspecific(rx_thread_id_key));
! 	return threadid;
!     } else 
! 	return NULL;
  }
  #endif
  
--- 317,325 ----
  
  #if defined(AFS_PTHREAD_ENV)
  char *
! threadNum(void)
  {
!     return pthread_getspecific(rx_thread_id_key);
  }
  #endif
  
***************
*** 718,723 ****
--- 712,718 ----
      /* default supports help flag */
  
      strcpy(buffer, "Usage: fileserver ");
+     strcpy(buffer, "[-auditlog <log path>] ");
      strcat(buffer, "[-d <debug level>] ");
      strcat(buffer, "[-p <number of processes>] ");
      strcat(buffer, "[-spare <number of spare blocks>] ");
***************
*** 1096,1101 ****
--- 1091,1126 ----
  	} else if (!strcmp(argv[i], "-enable_process_stats")) {
  	    rx_enableProcessRPCStats();
  	}
+ 	else if (strcmp(argv[i], "-auditlog") == 0) {
+ 	    int tempfd, flags;
+ 	    FILE *auditout;
+ 	    char oldName[MAXPATHLEN];
+ 	    char *fileName = argv[++i];
+ 	    
+ #ifndef AFS_NT40_ENV
+ 	    struct stat statbuf;
+ 	    
+ 	    if ((lstat(fileName, &statbuf) == 0) 
+ 		&& (S_ISFIFO(statbuf.st_mode))) {
+ 		flags = O_WRONLY | O_NONBLOCK;
+ 	    } else 
+ #endif
+ 	    {
+ 		strcpy(oldName, fileName);
+ 		strcat(oldName, ".old");
+ 		renamefile(fileName, oldName);
+ 		flags = O_WRONLY | O_TRUNC | O_CREAT;
+ 	    }
+ 	    tempfd = open(fileName, flags, 0666);
+ 	    if (tempfd > -1) {
+ 		auditout = fdopen(tempfd, "a");
+ 		if (auditout) {
+ 		    osi_audit_file(auditout);
+ 		} else
+ 		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	    } else
+ 		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	}
  #ifndef AFS_NT40_ENV
  	else if (strcmp(argv[i], "-syslog") == 0) {
  	    /* set syslog logging flag */
***************
*** 1105,1110 ****
--- 1130,1139 ----
  	    serverLogSyslogFacility = atoi(argv[i] + 8);
  	}
  #endif
+ 	else if (strcmp(argv[i], "-mrafslogs") == 0) {
+ 	    /* set syslog logging flag */
+ 	    mrafsStyleLogs = 1;
+ 	} 
  	else {
  	    return (-1);
  	}
***************
*** 1726,1733 ****
  	V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
      }
  
! #if defined(AFS_PTHREAD_ENV)
!     threadNameProgram = threadName;
  #endif
  
      /* initialize libacl routines */
--- 1755,1762 ----
  	V_BreakVolumeCallbacks = BreakVolumeCallBacksLater;
      }
  
! #ifdef AFS_PTHREAD_ENV
!     SetLogThreadNumProgram( threadNum );
  #endif
  
      /* initialize libacl routines */
Index: openafs/src/vlserver/vlprocs.c
diff -c openafs/src/vlserver/vlprocs.c:1.13.2.1 openafs/src/vlserver/vlprocs.c:1.13.2.2
*** openafs/src/vlserver/vlprocs.c:1.13.2.1	Tue Apr 26 21:37:06 2005
--- openafs/src/vlserver/vlprocs.c	Tue Jun 21 16:19:29 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vlprocs.c,v 1.13.2.1 2005/04/27 01:37:06 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vlprocs.c,v 1.13.2.2 2005/06/21 20:19:29 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
***************
*** 97,103 ****
  	rxkad_GetServerInfo(rxcall->conn, NULL, &exp, tname, tinst, tcell,
  			    NULL);
      if (!code)
! 	sprintf(rxinfo_str, "%s %s", inet_ntoa(hostAddr), tname);
      else
  	sprintf(rxinfo_str, "%s noauth", inet_ntoa(hostAddr));
      return (rxinfo_str);
--- 97,104 ----
  	rxkad_GetServerInfo(rxcall->conn, NULL, &exp, tname, tinst, tcell,
  			    NULL);
      if (!code)
! 	sprintf(rxinfo_str, "%s %s%s%s%s%s", inet_ntoa(hostAddr), tname,
! 		tinst?".":"", tinst?tinst:"", tcell?"@":"", tcell?tcell:"");
      else
  	sprintf(rxinfo_str, "%s noauth", inet_ntoa(hostAddr));
      return (rxinfo_str);
Index: openafs/src/vlserver/vlserver.c
diff -c openafs/src/vlserver/vlserver.c:1.18 openafs/src/vlserver/vlserver.c:1.18.2.1
*** openafs/src/vlserver/vlserver.c:1.18	Sun Dec  7 17:49:42 2003
--- openafs/src/vlserver/vlserver.c	Mon Jul 11 15:08:50 2005
***************
*** 11,21 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vlserver.c,v 1.18 2003/12/07 22:49:42 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
  #include <signal.h>
  #ifdef HAVE_FCNTL_H
  #include <fcntl.h>
  #endif
--- 11,22 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vlserver.c,v 1.18.2.1 2005/07/11 19:08:50 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
  #include <signal.h>
+ #include <sys/stat.h>
  #ifdef HAVE_FCNTL_H
  #include <fcntl.h>
  #endif
***************
*** 182,187 ****
--- 183,217 ----
  	    extern char rxi_tracename[80];
  	    strcpy(rxi_tracename, argv[++index]);
  
+        } else if (strcmp(argv[index], "-auditlog") == 0) {
+ 	   int tempfd, flags;
+            FILE *auditout;
+            char oldName[MAXPATHLEN];
+            char *fileName = argv[++index];
+ 
+ #ifndef AFS_NT40_ENV
+            struct stat statbuf;
+ 
+            if ((lstat(fileName, &statbuf) == 0) 
+                && (S_ISFIFO(statbuf.st_mode))) {
+                flags = O_WRONLY | O_NONBLOCK;
+            } else 
+ #endif
+            {
+                strcpy(oldName, fileName);
+                strcat(oldName, ".old");
+                renamefile(fileName, oldName);
+                flags = O_WRONLY | O_TRUNC | O_CREAT;
+            }
+            tempfd = open(fileName, flags, 0666);
+            if (tempfd > -1) {
+                auditout = fdopen(tempfd, "a");
+                if (auditout) {
+                    osi_audit_file(auditout);
+                } else
+                    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+            } else
+                printf("Warning: auditlog %s not writable, ignored.\n", fileName);
  	} else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
  	    rx_enablePeerRPCStats();
  	} else if (strcmp(argv[index], "-enable_process_stats") == 0) {
***************
*** 198,208 ****
--- 228,240 ----
  	    /* support help flag */
  #ifndef AFS_NT40_ENV
  	    printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+ 		   "[-auditlog <log path>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #else
  	    printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
+ 		   "[-auditlog <log path>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #endif
Index: openafs/src/vol/vnode.c
diff -c openafs/src/vol/vnode.c:1.19.2.2 openafs/src/vol/vnode.c:1.19.2.3
*** openafs/src/vol/vnode.c:1.19.2.2	Sun Apr 24 10:21:36 2005
--- openafs/src/vol/vnode.c	Tue Jun 21 16:19:41 2005
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vnode.c,v 1.19.2.2 2005/04/24 14:21:36 shadow Exp $");
  
  #include <errno.h>
  #include <stdio.h>
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vnode.c,v 1.19.2.3 2005/06/21 20:19:41 shadow Exp $");
  
  #include <errno.h>
  #include <stdio.h>
***************
*** 321,326 ****
--- 321,327 ----
  	return NULL;
      vnodeNumber = bitNumberToVnodeNumber(bitNumber, class);
  
+  vnrehash:
      VNLog(2, 1, vnodeNumber);
      /* Prepare to move it to the new hash chain */
      newHash = VNODE_HASH(vp, vnodeNumber);
***************
*** 349,354 ****
--- 350,357 ----
  	    VOL_UNLOCK;
  	    ObtainWriteLock(&vnp->lock);
  	    VOL_LOCK;
+ 	    if (vnp->volumePtr->cacheCheck != vnp->cacheCheck)
+ 		goto vnrehash;
  	}
  #ifdef AFS_PTHREAD_ENV
  	vnp->writer = pthread_self();
Index: openafs/src/volser/volmain.c
diff -c openafs/src/volser/volmain.c:1.18.2.1 openafs/src/volser/volmain.c:1.18.2.2
*** openafs/src/volser/volmain.c:1.18.2.1	Mon Oct 18 03:12:29 2004
--- openafs/src/volser/volmain.c	Mon Jul 11 15:08:51 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.1 2004/10/18 07:12:29 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.2 2005/07/11 19:08:51 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 59,64 ****
--- 59,66 ----
  #include <afs/cellconfig.h>
  #include <afs/keys.h>
  #include <ubik.h>
+ #include <fcntl.h>
+ #include <sys/stat.h>
  
  #include "volser.h"
  #include <errno.h>
***************
*** 99,104 ****
--- 101,113 ----
  			  exit(code);                             \
  		       }
  
+ #if defined(AFS_PTHREAD_ENV)
+ char *
+ threadNum(void)
+ {
+     return pthread_getspecific(rx_thread_id_key);
+ }
+ #endif
  
  static afs_int32
  MyBeforeProc(struct rx_call *acall)
***************
*** 284,289 ****
--- 293,328 ----
  		       lwps, MAXLWP);
  		lwps = MAXLWP;
  	    }
+ 	} else if (strcmp(argv[code], "-auditlog") == 0) {
+ 	    int tempfd, flags;
+ 	    FILE *auditout;
+ 	    char oldName[MAXPATHLEN];
+ 	    char *fileName = argv[++code];
+ 
+ #ifndef AFS_NT40_ENV
+ 	    struct stat statbuf;
+ 	    
+ 	    if ((lstat(fileName, &statbuf) == 0) 
+ 		&& (S_ISFIFO(statbuf.st_mode))) {
+ 		flags = O_WRONLY | O_NONBLOCK;
+ 	    } else 
+ #endif
+ 	    {
+ 		strcpy(oldName, fileName);
+ 		strcat(oldName, ".old");
+ 		renamefile(fileName, oldName);
+ 		flags = O_WRONLY | O_TRUNC | O_CREAT;
+ 	    }
+ 	    tempfd = open(fileName, flags, 0666);
+ 	    if (tempfd > -1) {
+ 		auditout = fdopen(tempfd, "a");
+ 		if (auditout) {
+ 		    osi_audit_file(auditout);
+ 		    osi_audit(VS_StartEvent, 0, AUD_END);
+ 		} else
+ 		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+ 	    } else
+ 		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
  	} else if (strcmp(argv[code], "-nojumbo") == 0) {
  	    rxJumbograms = 0;
  	} else if (strcmp(argv[code], "-sleep") == 0) {
***************
*** 324,335 ****
--- 363,376 ----
  	  usage:
  #ifndef AFS_NT40_ENV
  	    printf("Usage: volserver [-log] [-p <number of processes>] "
+ 		   "[-auditlog <log path>] "
  		   "[-udpsize <size of socket buffer in bytes>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #else
  	    printf("Usage: volserver [-log] [-p <number of processes>] "
+ 		   "[-auditlog <log path>] "
  		   "[-udpsize <size of socket buffer in bytes>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
***************
*** 346,351 ****
--- 387,396 ----
  #endif
      InitErrTabs();
  
+ #ifdef AFS_PTHREAD_ENV
+     SetLogThreadNumProgram( threadNum );
+ #endif
+ 
  #ifdef AFS_NT40_ENV
      if (afs_winsockInit() < 0) {
  	ReportErrorEventAlt(AFSEVT_SVR_WINSOCK_INIT_FAILED, 0, argv[0], 0);
Index: openafs/src/volser/volser.p.h
diff -c openafs/src/volser/volser.p.h:1.8 openafs/src/volser/volser.p.h:1.8.2.1
*** openafs/src/volser/volser.p.h:1.8	Wed Jul 28 23:44:08 2004
--- openafs/src/volser/volser.p.h	Mon Jul 11 15:27:29 2005
***************
*** 170,175 ****
--- 170,176 ----
  #define RV_NOVLDB	0x40000
  #define RV_NOCLONE	0x80000
  
+ struct ubik_client;
  extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp);
  extern int vsu_ExtractName(char rname[], char name[]);
  extern afs_int32 vsu_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth, struct ubik_client **uclientp, int (*secproc)());
Index: openafs/src/volser/vos.c
diff -c openafs/src/volser/vos.c:1.40.2.9 openafs/src/volser/vos.c:1.40.2.10
*** openafs/src/volser/vos.c:1.40.2.9	Fri Apr 15 14:46:25 2005
--- openafs/src/volser/vos.c	Mon Jul 11 15:10:34 2005
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.9 2005/04/15 18:46:25 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.10 2005/07/11 19:10:34 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 444,449 ****
--- 444,460 ----
      return (error);
  }
  
+ #if SIZEOF_TIME_T!=4
+ static char *
+ vos_ctime(afs_int32 *timep)
+ {
+     time_t *foo = timep;
+     return ctime(foo);
+ }
+ #else
+ #define vos_ctime ctime
+ #endif
+ 
  static void
  DisplayFormat(pntr, server, part, totalOK, totalNotOK, totalBusy, fast,
  	      longlist, disp)
***************
*** 486,509 ****
  		    (unsigned long)pntr->backupID);
  	    fprintf(STDOUT, "    MaxQuota %10d K \n", pntr->maxquota);
  	    fprintf(STDOUT, "    Creation    %s",
! 		    ctime((time_t *) & pntr->creationDate));
  #ifdef FULL_LISTVOL_SWITCH
  	    fprintf(STDOUT, "    Copy        %s",
! 		    ctime((time_t *) & pntr->copyDate));
  	    if (!pntr->backupDate)
  		fprintf(STDOUT, "    Backup      Never\n");
  	    else
  		fprintf(STDOUT, "    Backup      %s",
! 			ctime((time_t *) & pntr->backupDate));
  	    if (pntr->accessDate)
  		fprintf(STDOUT, "    Last Access %s",
! 			ctime((time_t *) & pntr->accessDate));
  #endif
  	    if (!pntr->updateDate)
  		fprintf(STDOUT, "    Last Update Never\n");
  	    else {
  		fprintf(STDOUT, "    Last Update %s",
! 			ctime((time_t *) & pntr->updateDate));
  		fprintf(STDOUT,
  			"    %d accesses in the past day (i.e., vnode references)\n",
  			pntr->dayUse);
--- 497,520 ----
  		    (unsigned long)pntr->backupID);
  	    fprintf(STDOUT, "    MaxQuota %10d K \n", pntr->maxquota);
  	    fprintf(STDOUT, "    Creation    %s",
! 		    vos_ctime(& pntr->creationDate));
  #ifdef FULL_LISTVOL_SWITCH
  	    fprintf(STDOUT, "    Copy        %s",
! 		    vos_ctime( & pntr->copyDate));
  	    if (!pntr->backupDate)
  		fprintf(STDOUT, "    Backup      Never\n");
  	    else
  		fprintf(STDOUT, "    Backup      %s",
! 			vos_ctime( & pntr->backupDate));
  	    if (pntr->accessDate)
  		fprintf(STDOUT, "    Last Access %s",
! 			vos_ctime( & pntr->accessDate));
  #endif
  	    if (!pntr->updateDate)
  		fprintf(STDOUT, "    Last Update Never\n");
  	    else {
  		fprintf(STDOUT, "    Last Update %s",
! 			vos_ctime( & pntr->updateDate));
  		fprintf(STDOUT,
  			"    %d accesses in the past day (i.e., vnode references)\n",
  			pntr->dayUse);
***************
*** 643,666 ****
  		    (unsigned long)a_xInfoP->backupID);
  	    fprintf(STDOUT, "    MaxQuota %10d K \n", a_xInfoP->maxquota);
  	    fprintf(STDOUT, "    Creation    %s",
! 		    ctime((time_t *) & a_xInfoP->creationDate));
  #ifdef FULL_LISTVOL_SWITCH
  	    fprintf(STDOUT, "    Copy        %s",
! 		    ctime((time_t *) & a_xInfoP->copyDate));
  	    if (!a_xInfoP->backupDate)
  		fprintf(STDOUT, "    Backup      Never\n");
  	    else
  		fprintf(STDOUT, "    Backup      %s",
! 			ctime((time_t *) & a_xInfoP->backupDate));
  	    if (a_xInfoP->accessDate)
  		fprintf(STDOUT, "    Last Access %s",
! 			ctime((time_t *) & a_xInfoP->accessDate));
  #endif
  	    if (!a_xInfoP->updateDate)
  		fprintf(STDOUT, "    Last Update Never\n");
  	    else {
  		fprintf(STDOUT, "    Last Update %s",
! 			ctime((time_t *) & a_xInfoP->updateDate));
  		fprintf(STDOUT,
  			"    %d accesses in the past day (i.e., vnode references)\n",
  			a_xInfoP->dayUse);
--- 654,677 ----
  		    (unsigned long)a_xInfoP->backupID);
  	    fprintf(STDOUT, "    MaxQuota %10d K \n", a_xInfoP->maxquota);
  	    fprintf(STDOUT, "    Creation    %s",
! 		    vos_ctime( & a_xInfoP->creationDate));
  #ifdef FULL_LISTVOL_SWITCH
  	    fprintf(STDOUT, "    Copy        %s",
! 		    vos_ctime( & a_xInfoP->copyDate));
  	    if (!a_xInfoP->backupDate)
  		fprintf(STDOUT, "    Backup      Never\n");
  	    else
  		fprintf(STDOUT, "    Backup      %s",
! 			vos_ctime( & a_xInfoP->backupDate));
  	    if (a_xInfoP->accessDate)
  		fprintf(STDOUT, "    Last Access %s",
! 			vos_ctime( & a_xInfoP->accessDate));
  #endif
  	    if (!a_xInfoP->updateDate)
  		fprintf(STDOUT, "    Last Update Never\n");
  	    else {
  		fprintf(STDOUT, "    Last Update %s",
! 			vos_ctime( & a_xInfoP->updateDate));
  		fprintf(STDOUT,
  			"    %d accesses in the past day (i.e., vnode references)\n",
  			a_xInfoP->dayUse);
***************
*** 906,920 ****
  			break;
  		}
  		fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
! 			ctime(&a_xInfoP->creationDate));
  		fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
! 			ctime(&a_xInfoP->accessDate));
  		fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
! 			ctime(&a_xInfoP->updateDate));
  		fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
! 			ctime(&a_xInfoP->backupDate));
  		fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
! 			ctime(&a_xInfoP->copyDate));
  		
  		fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
  		fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
--- 917,931 ----
  			break;
  		}
  		fprintf(STDOUT, "creationDate\t%-9lu\t%s", a_xInfoP->creationDate,
! 			vos_ctime(&a_xInfoP->creationDate));
  		fprintf(STDOUT, "accessDate\t%-9lu\t%s", a_xInfoP->accessDate,
! 			vos_ctime(&a_xInfoP->accessDate));
  		fprintf(STDOUT, "updateDate\t%-9lu\t%s", a_xInfoP->updateDate,
! 			vos_ctime(&a_xInfoP->updateDate));
  		fprintf(STDOUT, "backupDate\t%-9lu\t%s", a_xInfoP->backupDate,
! 			vos_ctime(&a_xInfoP->backupDate));
  		fprintf(STDOUT, "copyDate\t%-9lu\t%s", a_xInfoP->copyDate,
! 			vos_ctime(&a_xInfoP->copyDate));
  		
  		fprintf(STDOUT, "diskused\t%u\n", a_xInfoP->size);
  		fprintf(STDOUT, "maxquota\t%u\n", a_xInfoP->maxquota);
***************
*** 1058,1072 ****
  	break;
      }
      fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
! 	    ctime(&pntr->creationDate));
      fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
! 	    ctime(&pntr->accessDate));
      fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
! 	    ctime(&pntr->updateDate));
      fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
! 	    ctime(&pntr->backupDate));
      fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
! 	    ctime(&pntr->copyDate));
      fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
      fprintf(STDOUT, "diskused\t%u\n", pntr->size);
      fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
--- 1069,1083 ----
  	break;
      }
      fprintf(STDOUT, "creationDate\t%-9lu\t%s", pntr->creationDate,
! 	    vos_ctime(&pntr->creationDate));
      fprintf(STDOUT, "accessDate\t%-9lu\t%s", pntr->accessDate,
! 	    vos_ctime(&pntr->accessDate));
      fprintf(STDOUT, "updateDate\t%-9lu\t%s", pntr->updateDate,
! 	    vos_ctime(&pntr->updateDate));
      fprintf(STDOUT, "backupDate\t%-9lu\t%s", pntr->backupDate,
! 	    vos_ctime(&pntr->backupDate));
      fprintf(STDOUT, "copyDate\t%-9lu\t%s", pntr->copyDate,
! 	    vos_ctime(&pntr->copyDate));
      fprintf(STDOUT, "flags\t\t%#lx\t(Optional)\n", pntr->flags);
      fprintf(STDOUT, "diskused\t%u\n", pntr->size);
      fprintf(STDOUT, "maxquota\t%u\n", pntr->maxquota);
***************
*** 3937,3943 ****
  	/*print out the relevant info */
  	fprintf(STDOUT, "--------------------------------------\n");
  	fprintf(STDOUT, "transaction: %lu  created: %s",
! 		(unsigned long)pntr->tid, ctime((time_t *) & pntr->time));
  	if (pntr->returnCode) {
  	    fprintf(STDOUT, "returnCode: %lu\n",
  		    (unsigned long)pntr->returnCode);
--- 3948,3954 ----
  	/*print out the relevant info */
  	fprintf(STDOUT, "--------------------------------------\n");
  	fprintf(STDOUT, "transaction: %lu  created: %s",
! 		(unsigned long)pntr->tid, vos_ctime( & pntr->time));
  	if (pntr->returnCode) {
  	    fprintf(STDOUT, "returnCode: %lu\n",
  		    (unsigned long)pntr->returnCode);
Index: openafs/src/xstat/xstat_cm_test.c
diff -c openafs/src/xstat/xstat_cm_test.c:1.8.2.1 openafs/src/xstat/xstat_cm_test.c:1.8.2.2
*** openafs/src/xstat/xstat_cm_test.c:1.8.2.1	Sun May  8 01:04:18 2005
--- openafs/src/xstat/xstat_cm_test.c	Tue Jun 21 16:13:55 2005
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/xstat/xstat_cm_test.c,v 1.8.2.1 2005/05/08 05:04:18 shadow Exp $");
  
  #include "xstat_cm.h"		/*Interface for xstat_cm module */
  #include <cmd.h>		/*Command line interpreter */
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/xstat/xstat_cm_test.c,v 1.8.2.2 2005/06/21 20:13:55 shadow Exp $");
  
  #include "xstat_cm.h"		/*Interface for xstat_cm module */
  #include <cmd.h>		/*Command line interpreter */
***************
*** 755,764 ****
      printf("\t%10d srvMaxChainLengthHWM\n", a_ovP->srvMaxChainLengthHWM);
      printf("\t%10d srvRecordsHWM\n", a_ovP->srvRecordsHWM);
  
-     printf("\t%10d cacheBucket0_Discarded\n",  a_ovP->cacheBucket0_Discarded);
-     printf("\t%10d cacheBucket1_Discarded\n",  a_ovP->cacheBucket1_Discarded);
-     printf("\t%10d cacheBucket2_Discarded\n",  a_ovP->cacheBucket2_Discarded);
- 
      printf("\t%10d sysName_ID\n", a_ovP->sysName_ID);
  
      printf("\tFile Server up/downtimes, same cell:\n");
--- 755,760 ----
