Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.14.2.24 openafs/src/afs/afs_call.c:1.14.2.25
*** openafs/src/afs/afs_call.c:1.14.2.24	Thu May 22 11:52:58 2003
--- openafs/src/afs/afs_call.c	Mon Oct 18 02:04:18 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.14.2.24 2003/05/22 15:52:58 shadow Exp $");
  
  #include "../afs/sysincludes.h"	/* Standard vendor system headers */
  #include "../afs/afsincludes.h"	/* Afs-based standard headers */
--- 10,16 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.14.2.25 2004/10/18 06:04:18 shadow Exp $");
  
  #include "../afs/sysincludes.h"	/* Standard vendor system headers */
  #include "../afs/afsincludes.h"	/* Afs-based standard headers */
***************
*** 838,844 ****
  	char *cellname = afs_osi_Alloc(cellLen);
  
  #ifndef UKERNEL
! 	afs_osi_MaskSignals();
  #endif
  	AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code);
  	AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code);
--- 838,844 ----
  	char *cellname = afs_osi_Alloc(cellLen);
  
  #ifndef UKERNEL
! 	afs_osi_MaskUserLoop();
  #endif
  	AFS_COPYIN((afs_int32 *)parm2, cellname, cellLen, code);
  	AFS_COPYIN((afs_int32 *)parm3, kmsg, kmsgLen, code);
Index: openafs/src/afs/afs_osi.c
diff -c openafs/src/afs/afs_osi.c:1.8.2.15 openafs/src/afs/afs_osi.c:1.8.2.16
*** openafs/src/afs/afs_osi.c:1.8.2.15	Fri May 23 02:52:15 2003
--- openafs/src/afs/afs_osi.c	Mon Oct 18 02:04:18 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.8.2.15 2003/05/23 06:52:15 shadow Exp $");
  
  #include "../afs/sysincludes.h"	/* Standard vendor system headers */
  #include "../afs/afsincludes.h"	/* Afs-based standard headers */
--- 10,16 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.8.2.16 2004/10/18 06:04:18 shadow Exp $");
  
  #include "../afs/sysincludes.h"	/* Standard vendor system headers */
  #include "../afs/afsincludes.h"	/* Afs-based standard headers */
***************
*** 291,296 ****
--- 291,316 ----
  void afs_osi_UnmaskRxkSignals(){
  }
      
+ /* Two hacks to try and fix afsdb */
+ void 
+ afs_osi_MaskUserLoop()
+ {
+ #ifdef AFS_DARWIN_ENV
+     afs_osi_Invisible();
+     afs_osi_fullSigMask();
+ #else
+     afs_osi_MaskSignals();
+ #endif
+ }
+ 
+ void 
+ afs_osi_UnmaskUserLoop()
+ {
+ #ifdef AFS_DARWIN_ENV
+     afs_osi_fullSigRestore();
+ #endif
+ }
+ 
  /* register rxk listener proc info */
  void afs_osi_RxkRegister(){
  #ifdef AFS_LINUX22_ENV
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.9.2.20 openafs/src/afs/afs_vcache.c:1.9.2.22
*** openafs/src/afs/afs_vcache.c:1.9.2.20	Tue Jul  1 18:24:17 2003
--- openafs/src/afs/afs_vcache.c	Mon Oct 18 01:55:40 2004
***************
*** 38,44 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.9.2.20 2003/07/01 22:24:17 shadow Exp $");
  
  #include "../afs/sysincludes.h" /*Standard vendor system headers*/
  #include "../afs/afsincludes.h" /*AFS-based standard headers*/
--- 38,44 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.9.2.22 2004/10/18 05:55:40 shadow Exp $");
  
  #include "../afs/sysincludes.h" /*Standard vendor system headers*/
  #include "../afs/afsincludes.h" /*AFS-based standard headers*/
***************
*** 566,576 ****
      while ((cur = cur->next) != head) {
  	dentry = list_entry(cur, struct dentry, d_alias);
  
- 	afs_Trace3(afs_iclSetp, CM_TRACE_TRYFLUSHDCACHECHILDREN,
- 		   ICL_TYPE_POINTER, ip,
- 		   ICL_TYPE_STRING, dentry->d_parent->d_name.name,
- 		   ICL_TYPE_STRING, dentry->d_name.name);
- 
          if (!list_empty(&dentry->d_hash) && !list_empty(&dentry->d_subdirs))
              __shrink_dcache_parent(dentry);
  
--- 566,571 ----
***************
*** 787,794 ****
  		refpanic("VLRU inconsistent");
  
  #ifdef AFS_DARWIN_ENV
! 	   if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0) &&
!                 VREFCOUNT(tvc) == 1 && UBCINFOEXISTS(&tvc->v)) {
                 osi_VM_TryReclaim(tvc, &fv_slept);
                 if (fv_slept) {
                    uq = VLRU.prev;
--- 782,796 ----
  		refpanic("VLRU inconsistent");
  
  #ifdef AFS_DARWIN_ENV
!            if ((VREFCOUNT(tvc) < DARWIN_REFBASE) || 
!                (VREFCOUNT(tvc) < 1+DARWIN_REFBASE && 
!                 UBCINFOEXISTS(&tvc->v))) {
!                VREFCOUNT_SET(tvc, 
!                              DARWIN_REFBASE + (UBCINFOEXISTS(&tvc->v) ? 1 : 0));
!            }
! 	   if (tvc->opens == 0 && ((tvc->states & CUnlinkedDel) == 0)
!                && VREFCOUNT(tvc) == DARWIN_REFBASE+1 
!                && UBCINFOEXISTS(&tvc->v)) {
                 osi_VM_TryReclaim(tvc, &fv_slept);
                 if (fv_slept) {
                    uq = VLRU.prev;
***************
*** 802,809 ****
  		afs_TryFlushDcacheChildren(tvc);
  #endif
  
! 	   if (VREFCOUNT(tvc) == 0 && tvc->opens == 0
! 	       && (tvc->states & CUnlinkedDel) == 0) {
  		code = afs_FlushVCache(tvc, &fv_slept);
  		if (code == 0) {
  		  anumber--;
--- 804,817 ----
  		afs_TryFlushDcacheChildren(tvc);
  #endif
  
! 	    if (VREFCOUNT(tvc) == 
! #ifdef AFS_DARWIN_ENV
! 		DARWIN_REFBASE
! #else
! 		0 
! #endif
! 		&& tvc->opens == 0
! 		&& (tvc->states & CUnlinkedDel) == 0) {
  		code = afs_FlushVCache(tvc, &fv_slept);
  		if (code == 0) {
  		  anumber--;
***************
*** 975,981 ****
      /* VLISTNONE(&tvc->v); */
      tvc->v.v_freelist.tqe_next=0;
      tvc->v.v_freelist.tqe_prev=(struct vnode **)0xdeadb;
!     /*tvc->vrefCount++;*/
  #endif 
  #ifdef AFS_FBSD_ENV
      lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0);
--- 983,989 ----
      /* VLISTNONE(&tvc->v); */
      tvc->v.v_freelist.tqe_next=0;
      tvc->v.v_freelist.tqe_prev=(struct vnode **)0xdeadb;
!     tvc->vrefCount+=DARWIN_REFBASE;
  #endif 
  #ifdef AFS_FBSD_ENV
      lockinit(&tvc->rwlock, PINOD, "vcache rwlock", 0, 0);
***************
*** 1250,1256 ****
  		}
  	    }	       
  #ifdef AFS_DARWIN_ENV
!             if (VREFCOUNT(tvc) == 1 && UBCINFOEXISTS(&tvc->v)) {
  		if (tvc->opens) panic("flushactive open, hasubc, but refcnt 1");
  		osi_VM_TryReclaim(tvc,0);
  	    }
--- 1258,1265 ----
  		}
  	    }	       
  #ifdef AFS_DARWIN_ENV
! 	    if (VREFCOUNT(tvc) == 1+DARWIN_REFBASE 
! 		&& UBCINFOEXISTS(&tvc->v)) {
  		if (tvc->opens) panic("flushactive open, hasubc, but refcnt 1");
  		osi_VM_TryReclaim(tvc,0);
  	    }
***************
*** 2035,2040 ****
--- 2044,2065 ----
  	    if (vg)
                  continue;
  #endif	/* AFS_OSF_ENV */
+ #ifdef AFS_DARWIN14_ENV
+ 	    /* It'd really suck if we allowed duplicate vcaches for the 
+ 	       same fid to happen. Wonder if this will work? */
+ 	    struct vnode *vp = AFSTOV(tvc);
+ 	    if (vp->v_flag & (VXLOCK|VORECLAIM|VTERMINATE)) {
+ 		printf("precluded FindVCache on %x (%d:%d:%d)\n", 
+ 		       vp, tvc->fid.Fid.Volume, tvc->fid.Fid.Vnode,
+ 		       tvc->fid.Fid.Unique);
+ 		simple_lock(&vp->v_interlock);
+ 		SET(vp->v_flag, VTERMWANT);
+ 		simple_unlock(&vp->v_interlock);
+ 		(void)tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "vget1", 0);
+ 		printf("VTERMWANT ended on %x\n", vp);
+ 		continue;
+ 	    }
+ #endif
  	    break;
  	}
      }
Index: openafs/src/afs/DARWIN/osi_prototypes.h
diff -c openafs/src/afs/DARWIN/osi_prototypes.h:1.1.8.1 openafs/src/afs/DARWIN/osi_prototypes.h:1.1.8.2
*** openafs/src/afs/DARWIN/osi_prototypes.h:1.1.8.1	Wed Aug 21 16:53:22 2002
--- openafs/src/afs/DARWIN/osi_prototypes.h	Mon Oct 18 02:04:25 2004
***************
*** 17,22 ****
--- 17,27 ----
  /* osi_misc.c */
  extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
  	                  struct vnode **dirvpp, struct vnode **vpp);
+ 
+ /* osi_sleep.c */
+ extern void afs_osi_fullSigMask(void);
+ extern void afs_osi_fullSigRestore(void);
+  
  /* osi_vm.c */
  extern void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size);
  extern int osi_VM_Setup(struct vcache *avc, int force);
Index: openafs/src/afs/DARWIN/osi_sleep.c
diff -c openafs/src/afs/DARWIN/osi_sleep.c:1.3.4.1 openafs/src/afs/DARWIN/osi_sleep.c:1.3.4.2
*** openafs/src/afs/DARWIN/osi_sleep.c:1.3.4.1	Sat Nov 10 18:22:52 2001
--- openafs/src/afs/DARWIN/osi_sleep.c	Mon Oct 18 02:04:25 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/DARWIN/osi_sleep.c,v 1.3.4.1 2001/11/10 23:22:52 shadow Exp $");
  
  #include "../afs/sysincludes.h" /* Standard vendor system headers */
  #include "../afs/afsincludes.h" /* Afs-based standard headers */
--- 10,16 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/DARWIN/osi_sleep.c,v 1.3.4.2 2004/10/18 06:04:25 shadow Exp $");
  
  #include "../afs/sysincludes.h" /* Standard vendor system headers */
  #include "../afs/afsincludes.h" /* Afs-based standard headers */
***************
*** 211,213 ****
--- 211,241 ----
      }
      relevent(evp);
  }
+ 
+ void 
+ afs_osi_fullSigMask()
+ {
+     struct uthread *user_thread = (struct uthread *)get_bsdthread_info(current_act());
+     
+     /* Protect original sigmask */
+     if (!user_thread->uu_oldmask) {
+ 	/* Back up current sigmask */
+ 	user_thread->uu_oldmask = user_thread->uu_sigmask;
+ 	/* Mask all signals */
+ 	user_thread->uu_sigmask = ~(sigset_t)0;
+     }
+ }
+ 
+ void 
+ afs_osi_fullSigRestore()
+ {
+     struct uthread *user_thread = (struct uthread *)get_bsdthread_info(current_act());
+     
+     /* Protect original sigmask */
+     if (user_thread->uu_oldmask) {
+ 	/* Restore original sigmask */
+ 	user_thread->uu_sigmask = user_thread->uu_oldmask;
+ 	/* Clear the oldmask */
+ 	user_thread->uu_oldmask = (sigset_t)0;
+     }
+ }
Index: openafs/src/afs/DARWIN/osi_vm.c
diff -c openafs/src/afs/DARWIN/osi_vm.c:1.3.4.4 openafs/src/afs/DARWIN/osi_vm.c:1.3.4.5
*** openafs/src/afs/DARWIN/osi_vm.c:1.3.4.4	Wed Aug 21 16:53:22 2002
--- openafs/src/afs/DARWIN/osi_vm.c	Mon Oct 18 01:45:38 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/DARWIN/osi_vm.c,v 1.3.4.4 2002/08/21 20:53:22 shadow Exp $");
  
  #include "../afs/sysincludes.h" /* Standard vendor system headers */
  #include "../afs/afsincludes.h" /* Afs-based standard headers */
--- 10,16 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/DARWIN/osi_vm.c,v 1.3.4.5 2004/10/18 05:45:38 shadow Exp $");
  
  #include "../afs/sysincludes.h" /* Standard vendor system headers */
  #include "../afs/afsincludes.h" /* Afs-based standard headers */
***************
*** 43,49 ****
      if (UBCINFOEXISTS(vp))
  	return EBUSY;
  #endif
!     if (avc->vrefCount)
  	return EBUSY;
  
      if (avc->opens)
--- 43,49 ----
      if (UBCINFOEXISTS(vp))
  	return EBUSY;
  #endif
!     if (avc->vrefCount > DARWIN_REFBASE)
  	return EBUSY;
  
      if (avc->opens)
***************
*** 179,184 ****
--- 179,187 ----
      struct proc *p=current_proc();
      struct vnode *vp=AFSTOV(avc);
      void *obj;
+ #ifdef AFS_DARWIN14_ENV
+     int didhold;
+ #endif
  
      if (slept)
         *slept=0;
***************
*** 187,193 ****
          AFS_RELE(vp);
          return;
      }
!     if (!UBCINFOEXISTS(vp) || vp->v_count != 2) {
          simple_unlock(&vp->v_interlock);
          AFS_RELE(vp);
          return;
--- 190,196 ----
          AFS_RELE(vp);
          return;
      }
!     if (!UBCINFOEXISTS(vp) || vp->v_usecount != 2+DARWIN_REFBASE) {
          simple_unlock(&vp->v_interlock);
          AFS_RELE(vp);
          return;
***************
*** 198,203 ****
--- 201,211 ----
          AFS_RELE(vp);
          return;
      }
+     if (ISSET(vp->v_flag, VORECLAIM)) {
+ 	simple_unlock(&vp->v_interlock);
+ 	AFS_RELE(vp);
+ 	return;
+     }
  #else
      if (vp->v_ubcinfo->ui_holdcnt) {
          simple_unlock(&vp->v_interlock);
***************
*** 212,218 ****
--- 220,228 ----
          return;
      }
  
+ #ifndef AFS_DARWIN14_ENV
      vp->v_usecount--; /* we want the usecount to be 1 */
+ #endif
  
      if (slept) {
          ReleaseWriteLock(&afs_xvcache);
***************
*** 229,276 ****
          ubc_release(vp);
  #endif
          if (ubc_issetflags(vp, UI_HASOBJREF))
!             printf("ubc_release didn't release the reference?!\n");
!     } else if (!vn_lock(vp, LK_EXCLUSIVE|LK_INTERLOCK,current_proc())) {
  #ifdef AFS_DARWIN14_ENV
!         obj = ubc_getobject(vp,UBC_HOLDOBJECT);
  #else
  #ifdef AFS_DARWIN13_ENV
!         obj = ubc_getobject(vp,(UBC_NOREACTIVATE|UBC_HOLDOBJECT));
  #else
!         obj = ubc_getobject(vp);
  #endif
  #endif
!         (void)ubc_clean(vp, 1);
!         vinvalbuf(vp, V_SAVE, &afs_osi_cred, p, 0, 0);
!         if (vp->v_usecount == 1)
!            VOP_INACTIVE(vp, p);
!         else
!            VOP_UNLOCK(vp, 0, p);
!         if (obj) {
!         if (ISSET(vp->v_flag, VTERMINATE))
!             panic("afs_vnreclaim: already teminating");
!         SET(vp->v_flag, VTERMINATE);
!         memory_object_destroy(obj, 0);
!         while (ISSET(vp->v_flag, VTERMINATE)) {
!               SET(vp->v_flag, VTERMWANT);
!               tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "afs_vnreclaim", 0);
!         }
!         }
!    } else {
!         if (simple_lock_try(&vp->v_interlock))
!             panic("afs_vnreclaim: slept, but did no work :(");
!         if (UBCINFOEXISTS(vp) && vp->v_count == 1) {
!            vp->v_usecount++;
!            simple_unlock(&vp->v_interlock);
!            VN_RELE(vp);
!         } else 
!            simple_unlock(&vp->v_interlock);
!    }
!    AFS_GLOCK();
!    if (slept)
!       ObtainWriteLock(&afs_xvcache,175);
!    else
!       ObtainReadLock(&afs_xvcache);
  }
  
  void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) {
--- 239,330 ----
          ubc_release(vp);
  #endif
          if (ubc_issetflags(vp, UI_HASOBJREF))
! 	    printf("ubc_release didn't release the reference?!\n");
!     } else {
! #ifdef AFS_DARWIN14_ENV
! 	SET(vp->v_flag, VORECLAIM);
! #endif
! 	if (!vn_lock(vp, LK_EXCLUSIVE|LK_INTERLOCK,current_proc())) {
  #ifdef AFS_DARWIN14_ENV
! 	    obj = ubc_getobject(vp,UBC_HOLDOBJECT);
! 	    if ((didhold = ubc_hold(vp)))
! 		(void)ubc_clean(vp, 0);
  #else
  #ifdef AFS_DARWIN13_ENV
! 	    obj = ubc_getobject(vp,(UBC_NOREACTIVATE|UBC_HOLDOBJECT));
  #else
! 	    obj = ubc_getobject(vp);
  #endif
+ 	    (void)ubc_clean(vp, 1);
  #endif
! 	    vinvalbuf(vp, V_SAVE, &afs_osi_cred, p, 0, 0);
! 	    if (vp->v_usecount ==
! #ifdef AFS_DARWIN14_ENV
! 		2 + DARWIN_REFBASE
! #else
! 		1
! #endif
! 		)
! 		VOP_INACTIVE(vp, p);
! 	    else
! 		VOP_UNLOCK(vp, 0, p);
! #ifdef AFS_DARWIN14_ENV
! 	    if (didhold)
! 		ubc_rele(vp);
! #endif
! 	    if (obj) {
! 		if (ISSET(vp->v_flag, VTERMINATE))
! 		    panic("afs_vnreclaim: already teminating");
! 		SET(vp->v_flag, VTERMINATE);
! 		memory_object_destroy(obj, 0);
! 		while (ISSET(vp->v_flag, VTERMINATE)) {
! 		    SET(vp->v_flag, VTERMWANT);
! 		    tsleep((caddr_t)&vp->v_ubcinfo, PINOD, "afs_vnreclaim", 0);
! 		}
! 	    }
! #ifdef AFS_DARWIN14_ENV
! 	    simple_lock(&vp->v_interlock);
! 	    CLR(vp->v_flag, VORECLAIM);
! 	    if (ISSET((vp)->v_flag, VXWANT)) {
! 		CLR((vp)->v_flag, VXWANT);
! 		wakeup((caddr_t)(vp));
! 	    }       
! 	    vp->v_usecount--;
! 	    simple_unlock(&vp->v_interlock);
! #endif
! 	} else {
! #ifdef AFS_DARWIN14_ENV
! 	    CLR(vp->v_flag, VORECLAIM);
! #endif
! 	    if (simple_lock_try(&vp->v_interlock))
! 		panic("afs_vnreclaim: slept, but did no work :(");
! 	    if (UBCINFOEXISTS(vp) && vp->v_count == DARWIN_REFBASE +
! #ifdef AFS_DARWIN14_ENV
! 		2
! #else
! 		1
! #endif
! 		) {
! #ifndef AFS_DARWIN14_ENV
! 		/* We left the refcount high in 1.4 */
! 		vp->v_usecount++;
! #endif
! 		simple_unlock(&vp->v_interlock);
! 		VN_RELE(vp);
! 	    } else {
! #ifdef AFS_DARWIN14_ENV
! 		/* We left the refcount high in 1.4 */
! 		vp->v_usecount--;
! #endif
! 		simple_unlock(&vp->v_interlock);
! 	    }
! 	}
!     }
!     AFS_GLOCK();
!     if (slept)
!         ObtainWriteLock(&afs_xvcache,175);
!     else
!         ObtainReadLock(&afs_xvcache);
  }
  
  void osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size) {
Index: openafs/src/afs/DARWIN/osi_vnodeops.c
diff -c openafs/src/afs/DARWIN/osi_vnodeops.c:1.4.2.8 openafs/src/afs/DARWIN/osi_vnodeops.c:1.4.2.12
*** openafs/src/afs/DARWIN/osi_vnodeops.c:1.4.2.8	Fri Oct 24 01:24:39 2003
--- openafs/src/afs/DARWIN/osi_vnodeops.c	Mon Oct 18 02:38:18 2004
***************
*** 4,10 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/afs/DARWIN/osi_vnodeops.c,v 1.4.2.8 2003/10/24 05:24:39 shadow Exp $");
  
  #include <afs/sysincludes.h>            /* Standard vendor system headers */
  #include <afs/afsincludes.h>            /* Afs-based standard headers */
--- 4,10 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/afs/DARWIN/osi_vnodeops.c,v 1.4.2.12 2004/10/18 06:38:18 shadow Exp $");
  
  #include <afs/sysincludes.h>            /* Standard vendor system headers */
  #include <afs/afsincludes.h>            /* Afs-based standard headers */
***************
*** 352,357 ****
--- 352,368 ----
           printf("afs: WARNING: ui_refcount panic averted\n");
         }
      }
+     if (UBCINFOMISSING(ap->a_vp) ||
+ 	UBCINFORECLAIMED(ap->a_vp)) {
+       if (UBCINFORECLAIMED(ap->a_vp) && ISSET(ap->a_vp->v_flag, 
+ 					      (VXLOCK|VORECLAIM))) {
+ 	printf("no ubc for %x in close, reclaim set\n", ap->a_vp);
+ 	return (ENXIO);
+       } else {
+ 	printf("no ubc for %x in close, put back\n", ap->a_vp);
+ 	ubc_info_init(ap->a_vp);
+       }
+     }
  #endif
  
      return code;
***************
*** 568,573 ****
--- 579,585 ----
      struct iovec    aiov;
      struct uio * uio = &auio;
      int nocommit = flags & UPL_NOCOMMIT;
+     int iosize;
  
      int code;
      struct vcache *tvc=VTOAFS(vp);
***************
*** 584,590 ****
              panic("afs_vop_pageout: no upl");
      }
  #if 1
!     { int lbn, iosize, s;
        struct buf *bp;
        int biosize = DEV_BSIZE;
  
--- 596,602 ----
              panic("afs_vop_pageout: no upl");
      }
  #if 1
!     { int lbn, s;
        struct buf *bp;
        int biosize = DEV_BSIZE;
  
***************
*** 634,639 ****
--- 646,664 ----
      if (f_offset & PAGE_MASK)
              panic("afs_vop_pageout: offset not page aligned");
  
+     /* size will always be a multiple of PAGE_SIZE */
+     /* pageout isn't supposed to extend files */
+     if (f_offset + size > tvc->m.Length) 
+ 	iosize = tvc->m.Length - f_offset;
+     else
+ 	iosize = size;
+     
+     if (size > (iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK && !nocommit)  {
+ 	int iosize_rnd=(iosize + (PAGE_SIZE - 1)) & ~PAGE_MASK;
+ 	kernel_upl_abort_range(pl, pl_offset + iosize_rnd,
+ 			       size - iosize_rnd,
+ 			       UPL_ABORT_FREE_ON_EMPTY);
+     }
      auio.uio_iov = &aiov;
      auio.uio_iovcnt = 1;
      auio.uio_offset = f_offset;
***************
*** 642,648 ****
      auio.uio_procp = NULL;
      kernel_upl_map(kernel_map, pl, &ioaddr);
      ioaddr += pl_offset;
!     auio.uio_resid = aiov.iov_len = size;
      aiov.iov_base = (caddr_t)ioaddr;
  #if 1 /* USV [ */
          {
--- 667,673 ----
      auio.uio_procp = NULL;
      kernel_upl_map(kernel_map, pl, &ioaddr);
      ioaddr += pl_offset;
!     auio.uio_resid = aiov.iov_len = iosize;
      aiov.iov_base = (caddr_t)ioaddr;
  #if 1 /* USV [ */
          {
***************
*** 807,813 ****
      cache_purge(vp);
      if (!error && UBCINFOEXISTS(vp)) {
  #ifdef AFS_DARWIN14_ENV
!              (void) ubc_uncache(vp); 
  #else
               int wasmapped=ubc_issetflags(vp, UI_WASMAPPED);
               int hasobjref=ubc_issetflags(vp, UI_HASOBJREF);
--- 832,839 ----
      cache_purge(vp);
      if (!error && UBCINFOEXISTS(vp)) {
  #ifdef AFS_DARWIN14_ENV
! 	/* If crashes continue in ubc_hold, comment this out */
! 	/* (void)ubc_uncache(vp);*/
  #else
               int wasmapped=ubc_issetflags(vp, UI_WASMAPPED);
               int hasobjref=ubc_issetflags(vp, UI_HASOBJREF);
***************
*** 887,892 ****
--- 913,927 ----
      register struct vnode *fdvp = ap->a_fdvp;
      struct proc *p=fcnp->cn_proc;
  
+     /* Check for cross-device rename.
+      * For AFS, this means anything not in AFS-space
+      */
+     if ((0 != strcmp(tdvp->v_mount->mnt_stat.f_fstypename, "afs")) ||
+ 	(tvp && (0 != strcmp(tvp->v_mount->mnt_stat.f_fstypename, "afs")))) {
+ 	error = EXDEV;
+ 	goto abortit;
+     }
+  
      /*
       * if fvp == tvp, we're just removing one name of a pair of
       * directory entries for the same element.  convert call into rename.
Index: openafs/src/afs/LINUX/osi_alloc.c
diff -c openafs/src/afs/LINUX/osi_alloc.c:1.9.2.8 openafs/src/afs/LINUX/osi_alloc.c:1.9.2.9
*** openafs/src/afs/LINUX/osi_alloc.c:1.9.2.8	Wed May 28 19:49:21 2003
--- openafs/src/afs/LINUX/osi_alloc.c	Mon Oct 18 01:54:37 2004
***************
*** 14,20 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v 1.9.2.8 2003/05/28 23:49:21 shadow Exp $");
  
  #include "../afs/sysincludes.h"
  #include "../afs/afsincludes.h"
--- 14,20 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/LINUX/osi_alloc.c,v 1.9.2.9 2004/10/18 05:54:37 shadow Exp $");
  
  #include "../afs/sysincludes.h"
  #include "../afs/afsincludes.h"
***************
*** 330,338 ****
  
    free_error:
      if (new) {
- 	up(&afs_linux_alloc_sem);
  	linux_free(new);
- 	down(&afs_linux_alloc_sem);
      }
      new = NULL;
      goto error;
--- 330,336 ----
Index: openafs/src/afs/LINUX/osi_vfsops.c
diff -c openafs/src/afs/LINUX/osi_vfsops.c:1.11.2.6 openafs/src/afs/LINUX/osi_vfsops.c:1.11.2.7
*** openafs/src/afs/LINUX/osi_vfsops.c:1.11.2.6	Thu May 15 13:00:24 2003
--- openafs/src/afs/LINUX/osi_vfsops.c	Mon Oct 18 00:55:17 2004
***************
*** 15,21 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.11.2.6 2003/05/15 17:00:24 shadow Exp $");
  
  #include "../afs/sysincludes.h"
  #include "../afs/afsincludes.h"
--- 15,21 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.11.2.7 2004/10/18 04:55:17 shadow Exp $");
  
  #include "../afs/sysincludes.h"
  #include "../afs/afsincludes.h"
***************
*** 99,106 ****
      sb->s_maxbytes = MAX_NON_LFS;
  #endif
      code = afs_root(sb);
!     if (code)
  	MOD_DEC_USE_COUNT;
  
  #if !defined(AFS_LINUX24_ENV)
      unlock_super(sb);
--- 99,112 ----
      sb->s_maxbytes = MAX_NON_LFS;
  #endif
      code = afs_root(sb);
!     if (code) {
! 	afs_globalVFS = NULL;
! #if defined(AFS_LINUX26_ENV)
! 	module_put(THIS_MODULE);
! #else
  	MOD_DEC_USE_COUNT;
+ #endif
+     }
  
  #if !defined(AFS_LINUX24_ENV)
      unlock_super(sb);
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.29.2.22 openafs/src/afs/LINUX/osi_vnodeops.c:1.29.2.25
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.29.2.22	Thu Jan 16 20:30:37 2003
--- openafs/src/afs/LINUX/osi_vnodeops.c	Thu Oct 21 11:01:20 2004
***************
*** 23,29 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.29.2.22 2003/01/17 01:30:37 shadow Exp $");
  
  #include "../afs/sysincludes.h"
  #include "../afs/afsincludes.h"
--- 23,29 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.29.2.25 2004/10/21 15:01:20 shadow Exp $");
  
  #include "../afs/sysincludes.h"
  #include "../afs/afsincludes.h"
***************
*** 851,863 ****
  /* afs_dentry_iput */
  static void afs_dentry_iput(struct dentry *dp, struct inode *ip)
  {
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYIPUT,
  		   ICL_TYPE_POINTER, ip,
  		   ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	AFS_GUNLOCK();
      }
  
      osi_iput(ip);
--- 851,864 ----
  /* afs_dentry_iput */
  static void afs_dentry_iput(struct dentry *dp, struct inode *ip)
  {
+     int isglock;
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	if (!isglock) AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYIPUT,
  		   ICL_TYPE_POINTER, ip,
  		   ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	if (!isglock) AFS_GUNLOCK();
      }
  
      osi_iput(ip);
***************
*** 865,876 ****
  
  static int afs_dentry_delete(struct dentry *dp)
  {
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER, 
  		   dp->d_inode, ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	AFS_GUNLOCK();
      }
  
      if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked))
--- 866,878 ----
  
  static int afs_dentry_delete(struct dentry *dp)
  {
+     int isglock;
      if (ICL_SETACTIVE(afs_iclSetp)) {
! 	if (!isglock) AFS_GLOCK();
  	afs_Trace3(afs_iclSetp, CM_TRACE_DENTRYDELETE, ICL_TYPE_POINTER, 
  		   dp->d_inode, ICL_TYPE_STRING, dp->d_parent->d_name.name,
  		   ICL_TYPE_STRING, dp->d_name.name);
! 	if (!isglock) AFS_GUNLOCK();
      }
  
      if (dp->d_inode && (ITOAFS(dp->d_inode)->states & CUnlinked))
***************
*** 1330,1335 ****
--- 1332,1343 ----
      unsigned offset = PAGE_CACHE_SIZE;
      long status;
   
+ #ifdef PageLaunder
+     if (PageLaunder(pp)) {
+         return(fail_writepage(pp));
+     }
+ #endif
+ 
      inode = (struct inode *) mapping->host;
      end_index = inode->i_size >> PAGE_CACHE_SHIFT;
  
Index: openafs/src/afs/SOLARIS/osi_vnodeops.c
diff -c openafs/src/afs/SOLARIS/osi_vnodeops.c:1.7.2.4 openafs/src/afs/SOLARIS/osi_vnodeops.c:1.7.2.5
*** openafs/src/afs/SOLARIS/osi_vnodeops.c:1.7.2.4	Thu Nov 14 16:58:40 2002
--- openafs/src/afs/SOLARIS/osi_vnodeops.c	Mon Oct 18 00:30:39 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vnodeops.c,v 1.7.2.4 2002/11/14 21:58:40 zacheiss Exp $");
  
  #if	defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
  /*
--- 10,16 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vnodeops.c,v 1.7.2.5 2004/10/18 04:30:39 shadow Exp $");
  
  #if	defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
  /*
***************
*** 926,935 ****
  
      didFakeOpen=0;	/* keep track of open so we can do close */
      if (arw == UIO_WRITE) {
! 	/* do ulimit processing; shrink resid or fail */
! #if	defined(AFS_SUN56_ENV)
! 	if (auio->uio_loffset + auio->afsio_resid > auio->uio_llimit) {
! 	    if (auio->uio_llimit >= auio->uio_llimit) {
                  ReleaseWriteLock(&avc->lock);
                  afs_BozonUnlock(&avc->pvnLock, avc);
                  return EFBIG;
--- 926,935 ----
  
      didFakeOpen=0;	/* keep track of open so we can do close */
      if (arw == UIO_WRITE) {
!       /* do ulimit processing; shrink resid or fail */
! #if   defined(AFS_SUN56_ENV)
!         if (auio->uio_loffset + auio->afsio_resid > auio->uio_llimit) {
! 	    if (auio->uio_loffset >= auio->uio_llimit) {
                  ReleaseWriteLock(&avc->lock);
                  afs_BozonUnlock(&avc->pvnLock, avc);
                  return EFBIG;
Index: openafs/src/afs/VNOPS/afs_vnop_remove.c
diff -c openafs/src/afs/VNOPS/afs_vnop_remove.c:1.4.4.10 openafs/src/afs/VNOPS/afs_vnop_remove.c:1.4.4.11
*** openafs/src/afs/VNOPS/afs_vnop_remove.c:1.4.4.10	Mon Jul 22 19:47:11 2002
--- openafs/src/afs/VNOPS/afs_vnop_remove.c	Mon Oct 18 01:45:40 2004
***************
*** 22,28 ****
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.4.4.10 2002/07/22 23:47:11 zacheiss Exp $");
  
  #include "../afs/sysincludes.h"	/* Standard vendor system headers */
  #include "../afs/afsincludes.h"	/* Afs-based standard headers */
--- 22,28 ----
  #include <afsconfig.h>
  #include "../afs/param.h"
  
! RCSID("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_remove.c,v 1.4.4.11 2004/10/18 05:45:40 shadow Exp $");
  
  #include "../afs/sysincludes.h"	/* Standard vendor system headers */
  #include "../afs/afsincludes.h"	/* Afs-based standard headers */
***************
*** 367,376 ****
      Tadp1 = adp; Tadpr = VREFCOUNT(adp); Ttvc = tvc; Tnam = aname; Tnam1 = 0;
      if (tvc) Ttvcr = VREFCOUNT(tvc);
  #ifdef	AFS_AIX_ENV
!     if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0 && !(tvc->states & CUnlinked)) {
  #else
!     if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0 && !(tvc->states & CUnlinked)) {
  #endif
  	char *unlname = newname();
  
  	ReleaseWriteLock(&adp->lock);
--- 367,384 ----
      Tadp1 = adp; Tadpr = VREFCOUNT(adp); Ttvc = tvc; Tnam = aname; Tnam1 = 0;
      if (tvc) Ttvcr = VREFCOUNT(tvc);
  #ifdef	AFS_AIX_ENV
!     if (tvc && (VREFCOUNT(tvc) > 2) && tvc->opens > 0
! 	&& !(tvc->states & CUnlinked)) 
  #else
! #ifdef AFS_DARWIN14_ENV
!       if (tvc && (VREFCOUNT(tvc) > 1 + DARWIN_REFBASE) && tvc->opens > 0 && !(tvc->states & CUnlinked)) 
! #else
!       if (tvc && (VREFCOUNT(tvc) > 1) && tvc->opens > 0
! 	  && !(tvc->states & CUnlinked)) 
! #endif
  #endif
+       {
+ 
  	char *unlname = newname();
  
  	ReleaseWriteLock(&adp->lock);
***************
*** 417,422 ****
--- 425,431 ----
      struct VenusFid dirFid;
      register struct dcache *tdc;
      afs_int32 offset, len, code=0;
+     int oldref;
  
      if (NBObtainWriteLock(&avc->lock, 423))
  	return 0;
***************
*** 434,440 ****
  	    cred = avc->uncred;
  	    avc->uncred = NULL;
  
! #ifdef AFS_DARWIN_ENV
             /* this is called by vrele (via VOP_INACTIVE) when the refcount
                is 0. we can't just call VN_HOLD since vref will panic.
                we can't just call osi_vnhold because a later AFS_RELE will call
--- 443,449 ----
  	    cred = avc->uncred;
  	    avc->uncred = NULL;
  
! #if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN14_ENV)
             /* this is called by vrele (via VOP_INACTIVE) when the refcount
                is 0. we can't just call VN_HOLD since vref will panic.
                we can't just call osi_vnhold because a later AFS_RELE will call
***************
*** 452,457 ****
--- 461,472 ----
  	     */
  	    avc->states  &= ~(CUnlinked | CUnlinkedDel);
  
+ #ifdef AFS_DARWIN14_ENV
+ 	    if (VREFCOUNT(avc) < 4) {
+ 		oldref = 4 - VREFCOUNT(avc);
+ 		VREFCOUNT_SET(avc, 4);
+ 	    }
+ #endif
  	    ReleaseWriteLock(&avc->lock);
  
  	    dirFid.Cell = avc->fid.Cell;
***************
*** 475,482 ****
--- 490,504 ----
  	    osi_FreeSmallSpace(unlname);
  	    crfree(cred);
  #ifdef AFS_DARWIN_ENV
+ #ifndef AFS_DARWIN14_ENV
  	    osi_Assert(VREFCOUNT(avc) == 1);
  	    VREFCOUNT_SET(avc, 0);
+ #else
+ 	    if (oldref) {
+ 		int newref = VREFCOUNT(avc) - oldref;
+ 		VREFCOUNT_SET(avc, newref);
+ 	    }
+ #endif
  #endif
          }
      }
Index: openafs/src/auth/cellconfig.c
diff -c openafs/src/auth/cellconfig.c:1.14.2.9 openafs/src/auth/cellconfig.c:1.14.2.10
*** openafs/src/auth/cellconfig.c:1.14.2.9	Wed May 21 10:45:27 2003
--- openafs/src/auth/cellconfig.c	Mon Oct 18 01:08:04 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.14.2.9 2003/05/21 14:45:27 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
--- 10,16 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/auth/cellconfig.c,v 1.14.2.10 2004/10/18 05:08:04 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/pthread_glock.h>
***************
*** 35,40 ****
--- 35,43 ----
  #include <sys/time.h>
  #ifdef AFS_AFSDB_ENV
  #include <arpa/nameser.h>
+ #ifdef HAVE_ARPA_NAMESER_COMPAT_H
+ #include <arpa/nameser_compat.h>
+ #endif
  #include <resolv.h>
  #endif /* AFS_AFSDB_ENV */
  #endif /* AFS_NT40_ENV */
Index: openafs/src/cf/ressearch.m4
diff -c openafs/src/cf/ressearch.m4:1.1.2.2 openafs/src/cf/ressearch.m4:1.1.2.3
*** openafs/src/cf/ressearch.m4:1.1.2.2	Sat Jan 10 12:42:19 2004
--- openafs/src/cf/ressearch.m4	Mon Oct 18 01:08:06 2004
***************
*** 4,9 ****
--- 4,12 ----
  #include <sys/types.h>
  #include <netinet/in.h>
  #include <arpa/nameser.h>
+ #ifdef HAVE_ARPA_NAMESER_COMPAT_H
+ #include <arpa/nameser_compat.h>
+ #endif
  #include <resolv.h>],
    [
  const char host[11]="openafs.org";
Index: openafs/src/config/param.ppc_darwin_12.h
diff -c openafs/src/config/param.ppc_darwin_12.h:1.3 openafs/src/config/param.ppc_darwin_12.h:1.3.4.1
*** openafs/src/config/param.ppc_darwin_12.h:1.3	Thu Jul  5 11:20:18 2001
--- openafs/src/config/param.ppc_darwin_12.h	Mon Oct 18 01:45:41 2004
***************
*** 11,16 ****
--- 11,17 ----
  #define AFS_DARWIN_ENV
  #define AFS_NONFSTRANS
  #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_12_usr.h
diff -c openafs/src/config/param.ppc_darwin_12_usr.h:1.3 openafs/src/config/param.ppc_darwin_12_usr.h:1.3.4.1
*** openafs/src/config/param.ppc_darwin_12_usr.h:1.3	Thu Jul  5 11:20:18 2001
--- openafs/src/config/param.ppc_darwin_12_usr.h	Mon Oct 18 01:45:41 2004
***************
*** 11,16 ****
--- 11,17 ----
  #define AFS_USR_DARWIN_ENV
  #define AFS_NONFSTRANS 
  #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_13.h
diff -c openafs/src/config/param.ppc_darwin_13.h:1.3 openafs/src/config/param.ppc_darwin_13.h:1.3.4.1
*** openafs/src/config/param.ppc_darwin_13.h:1.3	Thu Jul  5 11:20:18 2001
--- openafs/src/config/param.ppc_darwin_13.h	Mon Oct 18 01:45:41 2004
***************
*** 12,17 ****
--- 12,18 ----
  #define AFS_DARWIN13_ENV
  #define AFS_NONFSTRANS
  #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_13_usr.h
diff -c openafs/src/config/param.ppc_darwin_13_usr.h:1.3 openafs/src/config/param.ppc_darwin_13_usr.h:1.3.4.1
*** openafs/src/config/param.ppc_darwin_13_usr.h:1.3	Thu Jul  5 11:20:18 2001
--- openafs/src/config/param.ppc_darwin_13_usr.h	Mon Oct 18 01:45:41 2004
***************
*** 12,17 ****
--- 12,18 ----
  #define AFS_USR_DARWIN13_ENV
  #define AFS_NONFSTRANS 
  #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_14.h
diff -c openafs/src/config/param.ppc_darwin_14.h:1.1.2.2 openafs/src/config/param.ppc_darwin_14.h:1.1.2.3
*** openafs/src/config/param.ppc_darwin_14.h:1.1.2.2	Mon Apr 29 11:33:27 2002
--- openafs/src/config/param.ppc_darwin_14.h	Mon Oct 18 01:45:41 2004
***************
*** 14,19 ****
--- 14,20 ----
  #define AFS_NONFSTRANS
  #define AFS_SYSCALL             230
  #define AFS_NAMEI_ENV 1
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_14_usr.h
diff -c openafs/src/config/param.ppc_darwin_14_usr.h:1.1.2.1 openafs/src/config/param.ppc_darwin_14_usr.h:1.1.2.2
*** openafs/src/config/param.ppc_darwin_14_usr.h:1.1.2.1	Sat Nov 10 18:22:55 2001
--- openafs/src/config/param.ppc_darwin_14_usr.h	Mon Oct 18 01:45:41 2004
***************
*** 13,18 ****
--- 13,19 ----
  #define AFS_USR_DARWIN14_ENV
  #define AFS_NONFSTRANS 
  #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_70.h
diff -c openafs/src/config/param.ppc_darwin_70.h:1.1.2.1 openafs/src/config/param.ppc_darwin_70.h:1.1.2.2
*** openafs/src/config/param.ppc_darwin_70.h:1.1.2.1	Fri Oct 24 01:24:46 2003
--- openafs/src/config/param.ppc_darwin_70.h	Mon Oct 18 01:45:41 2004
***************
*** 20,25 ****
--- 20,26 ----
  #define AFS_NONFSTRANS
  #define AFS_SYSCALL             230
  #define AFS_NAMEI_ENV 1
+ #define DARWIN_REFBASE 3
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/config/param.ppc_darwin_70_usr.h
diff -c openafs/src/config/param.ppc_darwin_70_usr.h:1.1.2.1 openafs/src/config/param.ppc_darwin_70_usr.h:1.1.2.2
*** openafs/src/config/param.ppc_darwin_70_usr.h:1.1.2.1	Fri Oct 24 01:24:46 2003
--- openafs/src/config/param.ppc_darwin_70_usr.h	Mon Oct 18 01:45:41 2004
***************
*** 18,23 ****
--- 18,24 ----
  #define AFS_USR_DARWIN70_ENV
  #define AFS_NONFSTRANS 
  #define AFS_SYSCALL             230
+ #define DARWIN_REFBASE 0
  
  /* File system entry (used if mount.h doesn't define MOUNT_AFS */
  #define AFS_MOUNT_AFS    "afs"
Index: openafs/src/kauth/kaprocs.c
diff -c openafs/src/kauth/kaprocs.c:1.8.2.4 openafs/src/kauth/kaprocs.c:1.8.2.5
*** openafs/src/kauth/kaprocs.c:1.8.2.4	Mon Mar 17 22:56:57 2003
--- openafs/src/kauth/kaprocs.c	Mon Oct 18 00:59:07 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/kauth/kaprocs.c,v 1.8.2.4 2003/03/18 03:56:57 shadow Exp $");
  
  #include <afs/stds.h>
  #include <errno.h>
--- 10,16 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/kauth/kaprocs.c,v 1.8.2.5 2004/10/18 04:59:07 shadow Exp $");
  
  #include <afs/stds.h>
  #include <errno.h>
***************
*** 928,934 ****
      afs_int32 cksum;
  
      code = KAANSWERTOOLONG;
!     if (oanswer->MaxSeqLen < sizeof(struct ka_ticketAnswer) - 5*MAXKTCNAMELEN)
  	return code;
  
      answer = (struct ka_ticketAnswer *)oanswer->SeqBody;
--- 928,935 ----
      afs_int32 cksum;
  
      code = KAANSWERTOOLONG;
!     if (oanswer->MaxSeqLen <
! 	sizeof(struct ka_ticketAnswer) - 5 * MAXKTCNAMELEN - MAXKTCTICKETLEN + ticketLen)
  	return code;
  
      answer = (struct ka_ticketAnswer *)oanswer->SeqBody;
***************
*** 1762,1769 ****
      switch (version) {
        case 0:
  	code = KAANSWERTOOLONG;
! 	if (oanswer->MaxSeqLen <
! 	    sizeof(struct ka_getTicketAnswer) - 5*MAXKTCNAMELEN) goto abort;
  	
  	answer = (struct ka_getTicketAnswer *)oanswer->SeqBody;
  	memcpy(&answer->sessionKey, &sessionKey, sizeof(struct ktc_encryptionKey));
--- 1763,1771 ----
      switch (version) {
        case 0:
  	code = KAANSWERTOOLONG;
!         if (oanswer->MaxSeqLen < sizeof(struct ka_getTicketAnswer) - 5 
! 	    * MAXKTCNAMELEN - MAXKTCTICKETLEN + ticketLen)
! 	    goto abort;
  	
  	answer = (struct ka_getTicketAnswer *)oanswer->SeqBody;
  	memcpy(&answer->sessionKey, &sessionKey, sizeof(struct ktc_encryptionKey));
Index: openafs/src/lwp/iomgr.c
diff -c openafs/src/lwp/iomgr.c:1.7 openafs/src/lwp/iomgr.c:1.7.2.1
*** openafs/src/lwp/iomgr.c:1.7	Tue Aug  7 20:03:52 2001
--- openafs/src/lwp/iomgr.c	Mon Oct 18 01:52:23 2004
***************
*** 21,30 ****
  	IO Manager routines & server process for VICE server.
  */
  
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/iomgr.c,v 1.7 2001/08/08 00:03:52 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 21,42 ----
  	IO Manager routines & server process for VICE server.
  */
  
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ /* We don't do this on Windows because on that platform there is code
+  * which allocates fd_set's on the stack (IOMGR_Sleep on Win9x, and
+  * FDSetAnd on WinNT) */
+ #ifndef _WIN32
+ #define FD_SETSIZE 65536
+ #endif
+  
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/lwp/iomgr.c,v 1.7.2.1 2004/10/18 05:52:23 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 177,183 ****
  
  /* fd_set pool managment. 
   * Use the pool instead of creating fd_set's on the stack. fd_set's can be
!  * 2K in size, so making three could put 6K in the limited space of an LWP
   * stack.
   */
  struct IOMGR_fd_set {
--- 189,195 ----
  
  /* fd_set pool managment. 
   * Use the pool instead of creating fd_set's on the stack. fd_set's can be
!  * 8K in size, so making three could put 24K in the limited space of an LWP
   * stack.
   */
  struct IOMGR_fd_set {
Index: openafs/src/ptserver/ptuser.c
diff -c openafs/src/ptserver/ptuser.c:1.6.2.2 openafs/src/ptserver/ptuser.c:1.6.2.3
*** openafs/src/ptserver/ptuser.c:1.6.2.2	Sat Oct 13 00:21:47 2001
--- openafs/src/ptserver/ptuser.c	Mon Oct 18 00:32:24 2004
***************
*** 14,20 ****
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.6.2.2 2001/10/13 04:21:47 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "../afs/sysincludes.h"
--- 14,20 ----
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/ptserver/ptuser.c,v 1.6.2.3 2004/10/18 04:32:24 shadow Exp $");
  
  #if defined(UKERNEL)
  #include "../afs/sysincludes.h"
***************
*** 87,92 ****
--- 87,94 ----
  	/*
  	 * Different conf dir; force re-evaluation.
  	 */
+ 	if (tdir) 
+ 	    afsconf_Close(tdir);
  	tdir = (struct afsconf_dir *)0;
  	pruclient = (struct ubik_client *)0;
      }
Index: openafs/src/rx/rx.c
diff -c openafs/src/rx/rx.c:1.22.2.23 openafs/src/rx/rx.c:1.22.2.30
*** openafs/src/rx/rx.c:1.22.2.23	Thu Jun  5 17:42:41 2003
--- openafs/src/rx/rx.c	Mon Oct 18 01:20:48 2004
***************
*** 16,22 ****
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/rx/rx.c,v 1.22.2.23 2003/06/05 21:42:41 shadow Exp $");
  
  #ifdef KERNEL
  #include "../afs/sysincludes.h"
--- 16,22 ----
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/rx/rx.c,v 1.22.2.30 2004/10/18 05:20:48 shadow Exp $");
  
  #ifdef KERNEL
  #include "../afs/sysincludes.h"
***************
*** 796,810 ****
       * idle (refCount == 0) after rx_idlePeerTime (60 seconds) have passed.
       */
      MUTEX_ENTER(&rx_peerHashTable_lock);
!     if (--conn->peer->refCount <= 0) {
! 	conn->peer->idleWhen = clock_Sec();
!    	if (conn->peer->refCount < 0) {
! 	    conn->peer->refCount = 0; 
! 	    MUTEX_ENTER(&rx_stats_mutex);
! 	    rxi_lowPeerRefCount ++;
! 	    MUTEX_EXIT(&rx_stats_mutex);
! 	}
      }
      MUTEX_EXIT(&rx_peerHashTable_lock);
  
      MUTEX_ENTER(&rx_stats_mutex);
--- 796,811 ----
       * idle (refCount == 0) after rx_idlePeerTime (60 seconds) have passed.
       */
      MUTEX_ENTER(&rx_peerHashTable_lock);
!     if (conn->peer->refCount < 2) {
!         conn->peer->idleWhen = clock_Sec();
! 	if (conn->peer->refCount < 1) {
!             conn->peer->refCount = 1;
!             MUTEX_ENTER(&rx_stats_mutex);
!             rxi_lowPeerRefCount++;
!             MUTEX_EXIT(&rx_stats_mutex);
!         }
      }
+     conn->peer->refCount--;
      MUTEX_EXIT(&rx_peerHashTable_lock);
  
      MUTEX_ENTER(&rx_stats_mutex);
***************
*** 992,997 ****
--- 993,1012 ----
      USERPRI;
  }
  
+ void
+ rx_GetConnection(register struct rx_connection *conn)
+ {
+     SPLVAR;
+     
+     NETPRI;
+     AFS_RXGLOCK();
+     MUTEX_ENTER(&conn->conn_data_lock);
+     conn->refCount++;
+     MUTEX_EXIT(&conn->conn_data_lock);
+     AFS_RXGUNLOCK();
+     USERPRI;
+ }
+ 
  /* Start a new rx remote procedure call, on the specified connection.
   * If wait is set to 1, wait for a free call channel; otherwise return
   * 0.  Maxtime gives the maximum number of seconds this call may take,
***************
*** 2276,2282 ****
  	    break;
  	if (type == RX_CLIENT_CONNECTION && pp->port == port)
  	    break;
! 	if (type == RX_CLIENT_CONNECTION && (conn->epoch & 0x80000000))
  	    break;
        }
        if ( !flag )
--- 2291,2298 ----
  	    break;
  	if (type == RX_CLIENT_CONNECTION && pp->port == port)
  	    break;
! 	/* So what happens when it's a callback connection? */
! 	if (/*type == RX_CLIENT_CONNECTION &&*/ (conn->epoch & 0x80000000))
  	    break;
        }
        if ( !flag )
***************
*** 3973,3982 ****
  	if (call->flags & RX_CALL_WAIT_PROC) {
  	    /* Conservative:  I don't think this should happen */
  	    call->flags &= ~RX_CALL_WAIT_PROC;
! 	    MUTEX_ENTER(&rx_stats_mutex);
! 	    rx_nWaiting--;
! 	    MUTEX_EXIT(&rx_stats_mutex);
! 	    queue_Remove(call);
  	}
  	call->state = RX_STATE_ACTIVE;
  	call->mode = RX_MODE_RECEIVING;
--- 3989,4000 ----
  	if (call->flags & RX_CALL_WAIT_PROC) {
  	    /* Conservative:  I don't think this should happen */
  	    call->flags &= ~RX_CALL_WAIT_PROC;
! 	    if (queue_IsOnQueue(call)) {
! 		queue_Remove(call);
! 		MUTEX_ENTER(&rx_stats_mutex);
! 		rx_nWaiting--;
! 		MUTEX_EXIT(&rx_stats_mutex);
! 	    }
  	}
  	call->state = RX_STATE_ACTIVE;
  	call->mode = RX_MODE_RECEIVING;
***************
*** 5680,5686 ****
  		    MUTEX_ENTER(&rx_stats_mutex);
  		    rx_stats.nPeerStructs--;
  		    MUTEX_EXIT(&rx_stats_mutex);
! 		    if (prev == *peer_ptr) {
  			*peer_ptr = next;
  			prev = next;
  		    }
--- 5698,5704 ----
  		    MUTEX_ENTER(&rx_stats_mutex);
  		    rx_stats.nPeerStructs--;
  		    MUTEX_EXIT(&rx_stats_mutex);
! 		    if (peer == *peer_ptr) {
  			*peer_ptr = next;
  			prev = next;
  		    }
***************
*** 6157,6170 ****
  	tv.tv_sec = 1;
  	tv.tv_usec = 0;
  	code = select(socket+1, &imask, 0, 0, &tv);
! 	if (code > 0) {
  	    /* now receive a packet */
  	    faddrLen = sizeof(struct sockaddr_in);
  	    code = recvfrom(socket, tbuffer, sizeof(tbuffer), 0,
  			    (struct sockaddr *) &faddr, &faddrLen);
  
! 	    memcpy(&theader, tbuffer, sizeof(struct rx_header));
! 	    if (counter == ntohl(theader.callNumber)) break;
  	}
  
  	/* see if we've timed out */
--- 6175,6191 ----
  	tv.tv_sec = 1;
  	tv.tv_usec = 0;
  	code = select(socket+1, &imask, 0, 0, &tv);
! 	if (code == 1 && FD_ISSET(socket,&imask)) {
  	    /* now receive a packet */
  	    faddrLen = sizeof(struct sockaddr_in);
  	    code = recvfrom(socket, tbuffer, sizeof(tbuffer), 0,
  			    (struct sockaddr *) &faddr, &faddrLen);
  
! 	    if (code > 0) {
! 		memcpy(&theader, tbuffer, sizeof(struct rx_header));
! 		if (counter == ntohl(theader.callNumber))
! 		    break;
! 	    }
  	}
  
  	/* see if we've timed out */
Index: openafs/src/rx/rx.h
diff -c openafs/src/rx/rx.h:1.7.2.7 openafs/src/rx/rx.h:1.7.2.9
*** openafs/src/rx/rx.h:1.7.2.7	Wed Aug 21 21:47:45 2002
--- openafs/src/rx/rx.h	Sun Oct 17 23:27:42 2004
***************
*** 253,258 ****
--- 253,260 ----
  #define rx_EnableHotThread()		(rx_enable_hot_thread = 1)
  #define rx_DisableHotThread()		(rx_enable_hot_thread = 0)
  
+ #define rx_PutConnection(conn) rx_DestroyConnection(conn)
+ 
  struct rx_securityObjectStats {
      char type;				/* 0:unk 1:null,2:vab 3:kad */
      char level;
***************
*** 411,417 ****
  
      /* For garbage collection */
      afs_uint32 idleWhen;		    /* When the refcountwent to zero */
!     short refCount;		    /* Reference count for this structure */
  
      /* Congestion control parameters */
      u_char burstSize;		    /* Reinitialization size for the burst parameter */
--- 413,419 ----
  
      /* For garbage collection */
      afs_uint32 idleWhen;		    /* When the refcountwent to zero */
!     afs_uint32 refCount;		    /* Reference count for this structure */
  
      /* Congestion control parameters */
      u_char burstSize;		    /* Reinitialization size for the burst parameter */
***************
*** 496,502 ****
                                      /* client-- to retransmit the challenge */
      struct rx_service *service;	    /* used by servers only */
      u_short serviceId;		    /* To stamp on requests (clients only) */
!     u_short refCount;		    /* Reference count */
      u_char flags;		    /* Defined below */
      u_char type;		    /* Type of connection, defined below */
      u_char secondsUntilPing;	    /* how often to ping for each active call */
--- 498,504 ----
                                      /* client-- to retransmit the challenge */
      struct rx_service *service;	    /* used by servers only */
      u_short serviceId;		    /* To stamp on requests (clients only) */
!     afs_uint32 refCount;		    /* Reference count */
      u_char flags;		    /* Defined below */
      u_char type;		    /* Type of connection, defined below */
      u_char secondsUntilPing;	    /* how often to ping for each active call */
***************
*** 619,625 ****
      struct clock traceStart;	    /* time the call started running */
      u_short MTU;                    /* size of packets currently sending */
  #ifdef RX_ENABLE_LOCKS
!     short refCount;		    /* Used to keep calls from disappearring
  				       when we get them from a queue. */
  #endif /* RX_ENABLE_LOCKS */
  /* Call refcount modifiers */
--- 621,627 ----
      struct clock traceStart;	    /* time the call started running */
      u_short MTU;                    /* size of packets currently sending */
  #ifdef RX_ENABLE_LOCKS
!     u_short refCount;		    /* Used to keep calls from disappearring
  				       when we get them from a queue. */
  #endif /* RX_ENABLE_LOCKS */
  /* Call refcount modifiers */
***************
*** 633,639 ****
  #define RX_CALL_REFCOUNT_ABORT  7 /* delayed abort */
  #define RX_CALL_REFCOUNT_MAX    8 /* array size. */
  #ifdef RX_REFCOUNT_CHECK
!     short refCDebug[RX_CALL_REFCOUNT_MAX];
  #endif  /* RX_REFCOUNT_CHECK */
      int iovNBytes;		/* byte count for current iovec */
      int iovMax;			/* number elements in current iovec */
--- 635,641 ----
  #define RX_CALL_REFCOUNT_ABORT  7 /* delayed abort */
  #define RX_CALL_REFCOUNT_MAX    8 /* array size. */
  #ifdef RX_REFCOUNT_CHECK
!     u_short refCDebug[RX_CALL_REFCOUNT_MAX];
  #endif  /* RX_REFCOUNT_CHECK */
      int iovNBytes;		/* byte count for current iovec */
      int iovMax;			/* number elements in current iovec */
***************
*** 921,927 ****
      u_short port;
      u_short ifMTU;
      afs_uint32 idleWhen;
!     short refCount;
      u_char burstSize;
      u_char burst;
      struct clock burstWait;
--- 923,929 ----
      u_short port;
      u_short ifMTU;
      afs_uint32 idleWhen;
!     u_short refCount;
      u_char burstSize;
      u_char burst;
      struct clock burstWait;
Index: openafs/src/rx/rx_globals.c
diff -c openafs/src/rx/rx_globals.c:1.4 openafs/src/rx/rx_globals.c:1.4.4.1
*** openafs/src/rx/rx_globals.c:1.4	Thu Jul 12 15:58:56 2001
--- openafs/src/rx/rx_globals.c	Mon Oct 18 01:53:13 2004
***************
*** 9,14 ****
--- 9,21 ----
  
  /* RX:  Globals for internal use, basically */
  
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ #define FD_SETSIZE 65536
+  
  #include <afsconfig.h>
  #ifdef KERNEL
  #include "../afs/param.h"
***************
*** 16,22 ****
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/rx/rx_globals.c,v 1.4 2001/07/12 19:58:56 shadow Exp $");
  
  /* Enable data initialization when the header file is included */
  #define INIT(stuff) = stuff
--- 23,29 ----
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/rx/rx_globals.c,v 1.4.4.1 2004/10/18 05:53:13 shadow Exp $");
  
  /* Enable data initialization when the header file is included */
  #define INIT(stuff) = stuff
Index: openafs/src/rx/rx_lwp.c
diff -c openafs/src/rx/rx_lwp.c:1.10.4.1 openafs/src/rx/rx_lwp.c:1.10.4.2
*** openafs/src/rx/rx_lwp.c:1.10.4.1	Wed Jul 31 18:36:11 2002
--- openafs/src/rx/rx_lwp.c	Mon Oct 18 01:52:25 2004
***************
*** 9,18 ****
  
  /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
  
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/rx/rx_lwp.c,v 1.10.4.1 2002/07/31 22:36:11 shadow Exp $");
  
  # include <sys/types.h>		/* fd_set on older platforms */
  # include <errno.h>
--- 9,25 ----
  
  /* rx_user.c contains routines specific to the user space UNIX implementation of rx */
  
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ #define FD_SETSIZE 65536
+  
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/rx/rx_lwp.c,v 1.10.4.2 2004/10/18 05:52:25 shadow Exp $");
  
  # include <sys/types.h>		/* fd_set on older platforms */
  # include <errno.h>
Index: openafs/src/rx/rx_packet.c
diff -c openafs/src/rx/rx_packet.c:1.14.2.6 openafs/src/rx/rx_packet.c:1.14.2.7
*** openafs/src/rx/rx_packet.c:1.14.2.6	Fri May 23 02:52:31 2003
--- openafs/src/rx/rx_packet.c	Mon Oct 18 01:12:45 2004
***************
*** 14,20 ****
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.14.2.6 2003/05/23 06:52:31 shadow Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
--- 14,20 ----
  #include <afs/param.h>
  #endif
  
! RCSID("$Header: /cvs/openafs/src/rx/rx_packet.c,v 1.14.2.7 2004/10/18 05:12:45 shadow Exp $");
  
  #ifdef KERNEL
  #if defined(UKERNEL)
***************
*** 1142,1147 ****
--- 1142,1148 ----
  #ifndef	RX_ENABLE_LOCKS
  	    tstat.waitingForPackets = rx_waitingForPackets;
  #endif
+ 	    MUTEX_ENTER(&rx_serverPool_lock);
  	    tstat.nFreePackets = htonl(rx_nFreePackets);
  	    tstat.callsExecuted = htonl(rxi_nCalls);
  	    tstat.packetReclaims = htonl(rx_packetReclaims);
***************
*** 1149,1154 ****
--- 1150,1156 ----
  	    tstat.nWaiting = htonl(rx_nWaiting);
  	    queue_Count( &rx_idleServerQueue, np, nqe, 
  				rx_serverQueueEntry, tstat.idleThreads); 
+ 	    MUTEX_EXIT(&rx_serverPool_lock);
  	    tstat.idleThreads = htonl(tstat.idleThreads);
  	    tl = sizeof(struct rx_debugStats) - ap->length;
  	    if (tl > 0)
Index: openafs/src/ubik/beacon.c
diff -c openafs/src/ubik/beacon.c:1.9.2.5 openafs/src/ubik/beacon.c:1.9.2.6
*** openafs/src/ubik/beacon.c:1.9.2.5	Sat Jan 10 12:02:40 2004
--- openafs/src/ubik/beacon.c	Mon Oct 18 00:53:03 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/ubik/beacon.c,v 1.9.2.5 2004/01/10 17:02:40 zacheiss Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 10,16 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/ubik/beacon.c,v 1.9.2.6 2004/10/18 04:53:03 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 549,555 ****
      {
  	for ( i=0; i < totalServers; i++) {
              if (info)
! 		tmpAddr = ntohl((afs_uint32) info->hostAddr[i].sin_addr.s_addr);
  	    else 
  		tmpAddr = aservers[i];
              if ( myAddr[j] == tmpAddr) {
--- 549,555 ----
      {
  	for ( i=0; i < totalServers; i++) {
              if (info)
! 		tmpAddr = (afs_uint32) info->hostAddr[i].sin_addr.s_addr;
  	    else 
  		tmpAddr = aservers[i];
              if ( myAddr[j] == tmpAddr) {
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.10.2.11 openafs/src/viced/afsfileprocs.c:1.10.2.12
*** openafs/src/viced/afsfileprocs.c:1.10.2.11	Fri Mar 28 04:17:18 2003
--- openafs/src/viced/afsfileprocs.c	Sun Oct 17 23:15:42 2004
***************
*** 28,34 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.10.2.11 2003/03/28 09:17:18 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 28,34 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.10.2.12 2004/10/18 03:15:42 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 2256,2262 ****
       * directory structure.  This is to prevent removing a subtree alltogether
       */
      if ((oldvptr != newvptr) && (fileptr->disk.type == vDirectory)) {
! 	for (testnode = newvptr->disk.parent; testnode != 0;) {
  	    if (testnode == oldvptr->vnodeNumber) {
  		testnode = oldvptr->disk.parent;
  		continue;
--- 2256,2268 ----
       * directory structure.  This is to prevent removing a subtree alltogether
       */
      if ((oldvptr != newvptr) && (fileptr->disk.type == vDirectory)) {
!         afs_int32 forpass = 0, vnum = 0, top = 0;
!         for (testnode = newvptr->disk.parent; testnode != 0; forpass++) {
!             if (testnode > vnum) vnum = testnode;
!             if (forpass > vnum) {
!                 errorCode = FSERR_ELOOP;
!                 goto Bad_Rename;
!             }
  	    if (testnode == oldvptr->vnodeNumber) {
  		testnode = oldvptr->disk.parent;
  		continue;
***************
*** 2270,2279 ****
--- 2276,2291 ----
  		errorCode = FSERR_ELOOP;
  		goto Bad_Rename;
  	    }
+ 	    if (testnode == 1) top = 1;
  	    testvptr = VGetVnode(&errorCode, volptr, testnode, READ_LOCK);
  	    assert(errorCode == 0);
  	    testnode = testvptr->disk.parent;
  	    VPutVnode(&errorCode, testvptr);
+             if ((top == 1) && (testnode != 0)) {
+                 VTakeOffline(volptr);
+                 errorCode = EIO;
+                 goto Bad_Rename;
+             }
  	    assert(errorCode == 0);
  	}
      }
Index: openafs/src/viced/callback.c
diff -c openafs/src/viced/callback.c:1.6.2.9 openafs/src/viced/callback.c:1.6.2.11
*** openafs/src/viced/callback.c:1.6.2.9	Thu May 15 11:51:59 2003
--- openafs/src/viced/callback.c	Wed Oct 20 03:41:29 2004
***************
*** 82,88 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/viced/callback.c,v 1.6.2.9 2003/05/15 15:51:59 shadow Exp $");
  
  #include <stdio.h> 
  #include <stdlib.h>      /* for malloc() */
--- 82,88 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/viced/callback.c,v 1.6.2.11 2004/10/20 07:41:29 shadow Exp $");
  
  #include <stdio.h> 
  #include <stdlib.h>      /* for malloc() */
***************
*** 772,777 ****
--- 772,778 ----
      if (!thishost || (thishost->hostFlags & HOSTDELETED)) {
        continue;
      }
+     rx_GetConnection(thishost->callback_rxcon);
      conns[j++] = thishost->callback_rxcon;
  	
  #ifdef	ADAPT_MTU
***************
*** 842,849 ****
    for (i=0; i<ncbas; i++) {
      struct host *hp;
      hp = cba[i].hp;
!     if (hp && xhost != hp)
        h_Release_r(hp);
    }
  
  return ;
--- 843,852 ----
    for (i=0; i<ncbas; i++) {
      struct host *hp;
      hp = cba[i].hp;
!     if (hp && xhost != hp) {
!       rx_PutConnection(hp->callback_rxcon);
        h_Release_r(hp);
+     }
    }
  
  return ;
***************
*** 1376,1392 ****
--- 1379,1401 ----
  
  
  static struct host *lih_host;
+ static int lih_host_held = 0;
  
  static int lih_r(host, held, hostp)
      register struct host *host, *hostp;
      register int held;
  
  {
+     lih_host_held = 0;
      if (host->cblist
  	   && ((hostp && host != hostp) || (!held && !h_OtherHolds_r(host)))
             && (!lih_host || host->ActiveCall < lih_host->ActiveCall) ) {
  	lih_host = host;
      }
+     if (!held) {
+         held = 1;
+         lih_host_held = 1;
+     }
      return held;
  
  } /*lih*/
***************
*** 1415,1422 ****
  	hp = lih_host;
  	if (hp) {
  	    cbstuff.GSS4++;
! 	    if ( ! ClearHostCallbacks_r(hp, 0 /* not locked or held */) )
! 		return;
  	    hp2 = hp->next;
  	} else {
  	    hp2 = hostList;
--- 1424,1436 ----
  	hp = lih_host;
  	if (hp) {
  	    cbstuff.GSS4++;
!             if (!ClearHostCallbacks_r(hp, 0 /* not locked or held */ )) {
!                 if (lih_host_held) 
!                     h_Release_r(hp);
!                 return 0;
!             }
!             if (lih_host_held) 
!                 h_Release_r(hp);
  	    hp2 = hp->next;
  	} else {
  	    hp2 = hostList;
Index: openafs/src/viced/host.c
diff -c openafs/src/viced/host.c:1.7.2.20 openafs/src/viced/host.c:1.7.2.23
*** openafs/src/viced/host.c:1.7.2.20	Thu May 15 11:52:46 2003
--- openafs/src/viced/host.c	Mon Oct 18 02:36:08 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/viced/host.c,v 1.7.2.20 2003/05/15 15:52:46 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 10,16 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/viced/host.c,v 1.7.2.23 2004/10/18 06:36:08 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 814,819 ****
--- 814,820 ----
  				*hp = th->next;
  				h_DeleteList_r(host); 
  				FreeHT(host);
+ 				free(th);
  				break;
  			}		
  		}
***************
*** 1465,1470 ****
--- 1466,1474 ----
       */
      if (oldClient = (struct client *) rx_GetSpecific(tcon, rxcon_client_key)) {
  	oldClient->tcon = (struct rx_connection *) 0;
+         ViceLog(0, ("FindClient: client %x(%x) already had conn %x (host %x), stolen by client %x(%x)\n", 
+                     oldClient, oldClient->sid, tcon, 
+                     rx_HostOf(rx_PeerOf(tcon)), client, client->sid));
  	/* rx_SetSpecific will be done immediately below */
      }
      client->tcon = tcon;
Index: openafs/src/vol/fssync.c
diff -c openafs/src/vol/fssync.c:1.5.2.5 openafs/src/vol/fssync.c:1.5.2.6
*** openafs/src/vol/fssync.c:1.5.2.5	Mon Feb  3 15:46:20 2003
--- openafs/src/vol/fssync.c	Mon Oct 18 01:52:28 2004
***************
*** 35,44 ****
     fsync.c
     File server synchronization with external volume utilities.
   */
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/fssync.c,v 1.5.2.5 2003/02/03 20:46:20 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
--- 35,52 ----
     fsync.c
     File server synchronization with external volume utilities.
   */
+ 
+ /* This controls the size of an fd_set; it must be defined early before
+  * the system headers define that type and the macros that operate on it.
+  * Its value should be as large as the maximum file descriptor limit we
+  * are likely to run into on any platform.  Right now, that is 65536
+  * which is the default hard fd limit on Solaris 9 */
+ #define FD_SETSIZE 65536
+  
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/fssync.c,v 1.5.2.6 2004/10/18 05:52:28 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
***************
*** 246,251 ****
--- 254,261 ----
      return sd;
  }
  
+ static fd_set FSYNC_readfds;
+  
  static void FSYNC_sync() {
      struct sockaddr_in addr;
      int on = 1;
***************
*** 293,310 ****
      InitHandler();
      AcceptOn();
      for(;;) {
- 	fd_set readfds;
  	int maxfd;
! 	GetHandler(&readfds, &maxfd);
  	/* Note: check for >= 1 below is essential since IOMGR_select
  	 * doesn't have exactly same semantics as select.
  	 */
  #ifdef AFS_PTHREAD_ENV
!         if (select(maxfd+1, &readfds, NULL, NULL, NULL) >= 1)
  #else /* AFS_PTHREAD_ENV */
!         if (IOMGR_Select(maxfd+1, &readfds, NULL, NULL, NULL) >= 1)
  #endif /* AFS_PTHREAD_ENV */
!             CallHandler(&readfds);
      }
  }
  
--- 303,319 ----
      InitHandler();
      AcceptOn();
      for(;;) {
  	int maxfd;
! 	GetHandler(&FSYNC_readfds, &maxfd);
  	/* Note: check for >= 1 below is essential since IOMGR_select
  	 * doesn't have exactly same semantics as select.
  	 */
  #ifdef AFS_PTHREAD_ENV
! 	if (select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1)
  #else /* AFS_PTHREAD_ENV */
! 	if (IOMGR_Select(maxfd + 1, &FSYNC_readfds, NULL, NULL, NULL) >= 1)
  #endif /* AFS_PTHREAD_ENV */
! 	    CallHandler(&FSYNC_readfds);
      }
  }
  
Index: openafs/src/vol/listinodes.c
diff -c openafs/src/vol/listinodes.c:1.8.4.3 openafs/src/vol/listinodes.c:1.8.4.4
*** openafs/src/vol/listinodes.c:1.8.4.3	Wed Aug 21 15:25:07 2002
--- openafs/src/vol/listinodes.c	Mon Oct 18 00:50:01 2004
***************
*** 20,26 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.8.4.3 2002/08/21 19:25:07 shadow Exp $");
  
  #ifndef AFS_NAMEI_ENV
  #if defined(AFS_LINUX20_ENV) || defined(AFS_SUN4_ENV)
--- 20,26 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.8.4.4 2004/10/18 04:50:01 shadow Exp $");
  
  #ifndef AFS_NAMEI_ENV
  #if defined(AFS_LINUX20_ENV) || defined(AFS_SUN4_ENV)
***************
*** 31,40 ****
   * -1 - Unable to read the inodes.
   * -2 - Unable to completely write temp file. Produces warning message in log.
   */
! ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep, forceR, wpath)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
  {
      Log("ListViceInodes not implemented for this platform!\n");
      return -1;
--- 31,41 ----
   * -1 - Unable to read the inodes.
   * -2 - Unable to completely write temp file. Produces warning message in log.
   */
! ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep, forceR, wpath, rock)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
+ void *rock;
  {
      Log("ListViceInodes not implemented for this platform!\n");
      return -1;
***************
*** 164,172 ****
  
  
  
! ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep, forceR, wpath)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR; {
  	FILE *inodeFile = NULL;
  	char dev[50], rdev[51];
--- 165,174 ----
  
  
  
! ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep, forceR, wpath, rock)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
+ void *rock;
  int *forcep, forceR; {
  	FILE *inodeFile = NULL;
  	char dev[50], rdev[51];
***************
*** 300,306 ****
  		info.u.param[2]  = p->di_vicep3;
  		info.u.param[3]  = p->di_vicep4;
  
! 		if (judgeInode && (*judgeInode)(&info, judgeParam) == 0)
  			continue;
  
  		if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
--- 302,308 ----
  		info.u.param[2]  = p->di_vicep3;
  		info.u.param[3]  = p->di_vicep4;
  
! 		if (judgeInode && (*judgeInode)(&info, judgeParam, rock) == 0)
  			continue;
  
  		if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
***************
*** 459,468 ****
  
  int
  efs_ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam,
! 		   forcep, forceR, wpath)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
  {
  	FILE *inodeFile = NULL;
  	char dev[50], rdev[51];
--- 461,471 ----
  
  int
  efs_ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam,
! 		   forcep, forceR, wpath, rock)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
+ void *rock;
  {
  	FILE *inodeFile = NULL;
  	char dev[50], rdev[51];
***************
*** 559,565 ****
  Log("Ino=%d, bytes=%d, linkCnt=%d, [%x,%x,%x,%x]\n", inum, p->di_size, p->di_nlink,
         info.u.param[0],info.u.param[1],info.u.param[2],info.u.param[3]);
  #endif
! 		if (judgeInode && (*judgeInode)(&info, judgeParam) == 0)
  			continue;
  
  		if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
--- 562,568 ----
  Log("Ino=%d, bytes=%d, linkCnt=%d, [%x,%x,%x,%x]\n", inum, p->di_size, p->di_nlink,
         info.u.param[0],info.u.param[1],info.u.param[2],info.u.param[3]);
  #endif
! 		if (judgeInode && (*judgeInode)(&info, judgeParam, rock) == 0)
  			continue;
  
  		if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
***************
*** 806,815 ****
  
  
  xfs_ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam,
! 		   forcep, forceR, wpath)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
  {
      FILE *inodeFile = NULL;
      i_list_inode_t info;
--- 809,819 ----
  
  
  xfs_ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam,
! 		   forcep, forceR, wpath, rock)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
+ void *rock;
  {
      FILE *inodeFile = NULL;
      i_list_inode_t info;
***************
*** 917,923 ****
  		goto err1_exit;
  	    }
  
! 	    if (judgeInode && (*judgeInode)(&info.ili_info, judgeParam) == 0)
  		continue;
  	
  	    rename = 0;
--- 921,927 ----
  		goto err1_exit;
  	    }
  
! 	    if (judgeInode && (*judgeInode)(&info.ili_info, judgeParam, rock) == 0)
  		continue;
  	
  	    rename = 0;
***************
*** 1021,1030 ****
  #endif
  
  ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep,
! 	       forceR, wpath)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
  {
  	FILE *inodeFile = NULL;
  	char dev[50], rdev[51];
--- 1025,1035 ----
  #endif
  
  ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep,
! 	       forceR, wpath, rock)
  char *devname, *mountedOn, *resultFile, *wpath;
  int (*judgeInode)(); 
  int *forcep, forceR;
+ void *rock;
  {
  	FILE *inodeFile = NULL;
  	char dev[50], rdev[51];
***************
*** 1055,1061 ****
  	if (!strcmp("xfs", root_inode.st_fstype)) {
  	    return xfs_ListViceInodes(devname, mountedOn, resultFile,
  				     judgeInode, judgeParam,
! 				     forcep, forceR, wpath);
  	}
  	else
  #endif
--- 1060,1066 ----
  	if (!strcmp("xfs", root_inode.st_fstype)) {
  	    return xfs_ListViceInodes(devname, mountedOn, resultFile,
  				     judgeInode, judgeParam,
! 				     forcep, forceR, wpath, rock);
  	}
  	else
  #endif
***************
*** 1063,1069 ****
  	  if (root_inode.st_ino == EFS_ROOTINO) {
  	    return efs_ListViceInodes(devname, mountedOn, resultFile,
  				      judgeInode, judgeParam,
! 				     forcep, forceR, wpath);
  	}
  	else
  #endif
--- 1068,1074 ----
  	  if (root_inode.st_ino == EFS_ROOTINO) {
  	    return efs_ListViceInodes(devname, mountedOn, resultFile,
  				      judgeInode, judgeParam,
! 				     forcep, forceR, wpath, rock);
  	}
  	else
  #endif
***************
*** 1099,1107 ****
  #endif /* AFS_HPUX_ENV */
  
  extern char *afs_rawname();
! int ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep, forceR, wpath)
      char *devname, *mountedOn, *resultFile, *wpath;
      int (*judgeInode)(), *forcep, forceR;
  {
     union {
  #ifdef	AFS_AIX_ENV
--- 1104,1113 ----
  #endif /* AFS_HPUX_ENV */
  
  extern char *afs_rawname();
! int ListViceInodes(devname, mountedOn, resultFile, judgeInode, judgeParam, forcep, forceR, wpath, rock)
      char *devname, *mountedOn, *resultFile, *wpath;
      int (*judgeInode)(), *forcep, forceR;
+     void *rock;
  {
     union {
  #ifdef	AFS_AIX_ENV
***************
*** 1201,1207 ****
         info.u.param[1] = auxp->aux_param2;
         info.u.param[2] = auxp->aux_param3;
         info.u.param[3] = auxp->aux_param4;
!        if (judgeInode && (*judgeInode)(&info, judgeParam) == 0)
  	   continue;
         if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
  	   Log("Error writing inode file for partition %s\n", partition);
--- 1207,1213 ----
         info.u.param[1] = auxp->aux_param2;
         info.u.param[2] = auxp->aux_param3;
         info.u.param[3] = auxp->aux_param4;
!        if (judgeInode && (*judgeInode)(&info, judgeParam, rock) == 0)
  	   continue;
         if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
  	   Log("Error writing inode file for partition %s\n", partition);
***************
*** 1401,1407 ****
  	            info.inodeNumber = i;
  	            info.byteCount = p->di_size;
  	            info.linkCount = p->di_nlink;
! 		    if (judgeInode && (*judgeInode)(&info, judgeParam) == 0)
  		        continue;
  	            if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
  	                Log("Error writing inode file for partition %s\n", partition);
--- 1407,1413 ----
  	            info.inodeNumber = i;
  	            info.byteCount = p->di_size;
  	            info.linkCount = p->di_nlink;
! 		    if (judgeInode && (*judgeInode)(&info, judgeParam, rock) == 0)
  		        continue;
  	            if (fwrite(&info, sizeof info, 1, inodeFile) != 1) {
  	                Log("Error writing inode file for partition %s\n", partition);
Index: openafs/src/vol/namei_ops.c
diff -c openafs/src/vol/namei_ops.c:1.9.4.2 openafs/src/vol/namei_ops.c:1.9.4.3
*** openafs/src/vol/namei_ops.c:1.9.4.2	Tue Aug 27 23:57:37 2002
--- openafs/src/vol/namei_ops.c	Mon Oct 18 00:50:01 2004
***************
*** 12,18 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.9.4.2 2002/08/28 03:57:37 zacheiss Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
--- 12,18 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.9.4.3 2004/10/18 04:50:01 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
***************
*** 984,991 ****
  			     int (*write_fun)(FILE *, struct ViceInodeInfo *,
  					      char *, char *),
  			     FILE *fp,
! 			     int (*judgeFun)(struct ViceInodeInfo *, int vid),
! 			     int singleVolumeNumber);
  
  
  /* WriteInodeInfo
--- 984,991 ----
  			     int (*write_fun)(FILE *, struct ViceInodeInfo *,
  					      char *, char *),
  			     FILE *fp,
! 			     int (*judgeFun)(struct ViceInodeInfo *, int vid, void *),
! 			     int singleVolumeNumber, void *rock);
  
  
  /* WriteInodeInfo
***************
*** 1035,1043 ****
   * If the resultFile is NULL, then don't call the write routine.
   */
  int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
! 		   int (*judgeInode)(struct ViceInodeInfo *info, int vid),
  		   int singleVolumeNumber, int *forcep,
! 		   int forceR, char *wpath)
  {
      FILE *fp = (FILE*)-1;
      int ninodes;
--- 1035,1043 ----
   * If the resultFile is NULL, then don't call the write routine.
   */
  int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
! 		   int (*judgeInode)(struct ViceInodeInfo *info, int vid, void *rock),
  		   int singleVolumeNumber, int *forcep,
! 		   int forceR, char *wpath, void *rock)
  {
      FILE *fp = (FILE*)-1;
      int ninodes;
***************
*** 1056,1062 ****
      VerifyDirPerms(mountedOn);
  
      ninodes = namei_ListAFSFiles(mountedOn, WriteInodeInfo, fp,
! 			   judgeInode, singleVolumeNumber);
  
      if (!resultFile)
  	return ninodes;
--- 1056,1062 ----
      VerifyDirPerms(mountedOn);
  
      ninodes = namei_ListAFSFiles(mountedOn, WriteInodeInfo, fp,
! 			   judgeInode, singleVolumeNumber, rock);
  
      if (!resultFile)
  	return ninodes;
***************
*** 1109,1116 ****
  		    int (*writeFun)(FILE *, struct ViceInodeInfo *, char *,
  				     char *),
  		    FILE *fp,
! 		    int (*judgeFun)(struct ViceInodeInfo *, int),
! 		    int singleVolumeNumber)
  {
      IHandle_t ih;
      namei_t name;
--- 1109,1116 ----
  		    int (*writeFun)(FILE *, struct ViceInodeInfo *, char *,
  				     char *),
  		    FILE *fp,
! 		    int (*judgeFun)(struct ViceInodeInfo *, int, void *rock),
! 		    int singleVolumeNumber, void *rock)
  {
      IHandle_t ih;
      namei_t name;
***************
*** 1129,1135 ****
  	ih.ih_vid = singleVolumeNumber;
  	namei_HandleToVolDir(&name, &ih);
  	ninodes = namei_ListAFSSubDirs(&ih, writeFun, fp,
! 				 judgeFun, singleVolumeNumber);
  	if (ninodes < 0)
  	    return ninodes;
      }
--- 1129,1135 ----
  	ih.ih_vid = singleVolumeNumber;
  	namei_HandleToVolDir(&name, &ih);
  	ninodes = namei_ListAFSSubDirs(&ih, writeFun, fp,
! 				 judgeFun, singleVolumeNumber, rock);
  	if (ninodes < 0)
  	    return ninodes;
      }
***************
*** 1151,1157 ****
  		    if (*dp2->d_name == '.') continue;
  		    if (!DecodeVolumeName(dp2->d_name, &ih.ih_vid)) {
  			ninodes += namei_ListAFSSubDirs(&ih, writeFun, fp,
! 						       judgeFun, 0);
  		    }
  		}
  		closedir(dirp2);
--- 1151,1157 ----
  		    if (*dp2->d_name == '.') continue;
  		    if (!DecodeVolumeName(dp2->d_name, &ih.ih_vid)) {
  			ninodes += namei_ListAFSSubDirs(&ih, writeFun, fp,
! 						       judgeFun, 0, rock);
  		    }
  		}
  		closedir(dirp2);
***************
*** 1178,1185 ****
  			     int (*writeFun)(FILE *, struct ViceInodeInfo *,
  					      char *, char *),
  			     FILE *fp,
! 			     int (*judgeFun)(struct ViceInodeInfo *, int),
! 			     int singleVolumeNumber)
  {
      IHandle_t myIH = *dirIH;
      namei_t name;
--- 1178,1185 ----
  			     int (*writeFun)(FILE *, struct ViceInodeInfo *,
  					      char *, char *),
  			     FILE *fp,
! 			     int (*judgeFun)(struct ViceInodeInfo *, int, void *),
! 			     int singleVolumeNumber, void *rock)
  {
      IHandle_t myIH = *dirIH;
      namei_t name;
***************
*** 1220,1226 ****
  		linkHandle.fd_fd = open(path2, O_RDONLY, 0666);
  		info.linkCount = namei_GetLinkCount(&linkHandle, (Inode)0, 0);
  	    }
! 	    if (judgeFun && !(*judgeFun)(&info, singleVolumeNumber))
  		continue;
  
  	    if ((*writeFun)(fp, &info, path1, dp1->d_name)<0) {
--- 1220,1226 ----
  		linkHandle.fd_fd = open(path2, O_RDONLY, 0666);
  		info.linkCount = namei_GetLinkCount(&linkHandle, (Inode)0, 0);
  	    }
! 	    if (judgeFun && !(*judgeFun)(&info, singleVolumeNumber, rock))
  		continue;
  
  	    if ((*writeFun)(fp, &info, path1, dp1->d_name)<0) {
***************
*** 1279,1285 ****
  				continue;
  			    }
  			    if (judgeFun
! 				&& !(*judgeFun)(&info, singleVolumeNumber))
  				continue;
  
  			    if ((*writeFun)(fp, &info, path3, dp3->d_name)<0) {
--- 1279,1285 ----
  				continue;
  			    }
  			    if (judgeFun
! 				&& !(*judgeFun)(&info, singleVolumeNumber, rock))
  				continue;
  
  			    if ((*writeFun)(fp, &info, path3, dp3->d_name)<0) {
Index: openafs/src/vol/namei_ops.h
diff -c openafs/src/vol/namei_ops.h:1.2 openafs/src/vol/namei_ops.h:1.2.8.1
*** openafs/src/vol/namei_ops.h:1.2	Sat Nov  4 05:06:23 2000
--- openafs/src/vol/namei_ops.h	Mon Oct 18 00:50:01 2004
***************
*** 46,57 ****
  		    int (*write_fun)(FILE *fp, struct ViceInodeInfo *info,
  				     char *dir, char *file),
  		    FILE *fp,
! 		    int (*judge_fun)(struct ViceInodeInfo *info, int vid),
! 		    int singleVolumeNumber);
  int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
! 		   int (*judgeInode)(struct ViceInodeInfo *info, int vid),
  		   int singleVolumeNumber, int *forcep,
! 		   int forceR, char *wpath);
  
  
  #define NAMEI_LCOMP_LEN 32
--- 46,57 ----
  		    int (*write_fun)(FILE *fp, struct ViceInodeInfo *info,
  				     char *dir, char *file),
  		    FILE *fp,
! 		    int (*judge_fun)(struct ViceInodeInfo *info, int vid, void *rock),
! 		    int singleVolumeNumber, void *rock);
  int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
! 		   int (*judgeInode)(struct ViceInodeInfo *info, int vid, void *rock),
  		   int singleVolumeNumber, int *forcep,
! 		   int forceR, char *wpath, void *rock);
  
  
  #define NAMEI_LCOMP_LEN 32
Index: openafs/src/vol/ntops.c
diff -c openafs/src/vol/ntops.c:1.4 openafs/src/vol/ntops.c:1.4.4.1
*** openafs/src/vol/ntops.c:1.4	Thu Jul 12 15:59:33 2001
--- openafs/src/vol/ntops.c	Mon Oct 18 00:50:01 2004
***************
*** 12,18 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/ntops.c,v 1.4 2001/07/12 19:59:33 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <stdio.h>
--- 12,18 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/ntops.c,v 1.4.4.1 2004/10/18 04:50:01 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <stdio.h>
***************
*** 940,946 ****
  int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
  		   int (*judgeInode)(struct ViceInodeInfo *info, int vid),
  		   int singleVolumeNumber, int *forcep,
! 		   int forceR, char *wpath)
  {
      FILE *fp = (FILE*)-1;
      int ninodes;
--- 940,946 ----
  int ListViceInodes(char *devname, char *mountedOn, char *resultFile,
  		   int (*judgeInode)(struct ViceInodeInfo *info, int vid),
  		   int singleVolumeNumber, int *forcep,
! 		   int forceR, char *wpath, void *rock)
  {
      FILE *fp = (FILE*)-1;
      int ninodes;
***************
*** 954,960 ****
  	}
      }
      ninodes = nt_ListAFSFiles(wpath, WriteInodeInfo, fp,
! 			   judgeInode, singleVolumeNumber);
  
      if (!resultFile)
  	return ninodes;
--- 954,960 ----
  	}
      }
      ninodes = nt_ListAFSFiles(wpath, WriteInodeInfo, fp,
! 			   judgeInode, singleVolumeNumber, rock);
  
      if (!resultFile)
  	return ninodes;
***************
*** 1008,1014 ****
  				     char *),
  		    FILE *fp,
  		    int (*judgeFun)(struct ViceInodeInfo *, int),
! 		    int singleVolumeNumber)
  {
      IHandle_t h;
      char name[MAX_PATH];
--- 1008,1014 ----
  				     char *),
  		    FILE *fp,
  		    int (*judgeFun)(struct ViceInodeInfo *, int),
! 		    int singleVolumeNumber, void *rock)
  {
      IHandle_t h;
      char name[MAX_PATH];
***************
*** 1025,1031 ****
  	if (nt_HandleToVolDir(name, &h)<0)
  	    return -1;
  	ninodes = nt_ListAFSSubDirs(&h, writeFun, fp,
! 				 judgeFun, singleVolumeNumber);
  	if (ninodes < 0)
  	    return ninodes;
      }
--- 1025,1031 ----
  	if (nt_HandleToVolDir(name, &h)<0)
  	    return -1;
  	ninodes = nt_ListAFSSubDirs(&h, writeFun, fp,
! 				 judgeFun, singleVolumeNumber, rock);
  	if (ninodes < 0)
  	    return ninodes;
      }
***************
*** 1040,1046 ****
  	while (dp = readdir(dirp)) {
  	    if (!DecodeVolumeName(dp->d_name, &h.ih_vid)) {
  		ninodes += nt_ListAFSSubDirs(&h, writeFun, fp,
! 				 judgeFun, 0);
  	    }
  	}
      }
--- 1040,1046 ----
  	while (dp = readdir(dirp)) {
  	    if (!DecodeVolumeName(dp->d_name, &h.ih_vid)) {
  		ninodes += nt_ListAFSSubDirs(&h, writeFun, fp,
! 				 judgeFun, 0, rock);
  	    }
  	}
      }
***************
*** 1062,1069 ****
  			     int (*writeFun)(FILE *, struct ViceInodeInfo *,
  					      char *, char *),
  			     FILE *fp,
! 			     int (*judgeFun)(struct ViceInodeInfo *, int),
! 			     int singleVolumeNumber)
  {
      int i;
      IHandle_t myIH = *dirIH;
--- 1062,1069 ----
  			     int (*writeFun)(FILE *, struct ViceInodeInfo *,
  					      char *, char *),
  			     FILE *fp,
! 			     int (*judgeFun)(struct ViceInodeInfo *, int, void *rock),
! 			     int singleVolumeNumber, void *rock)
  {
      int i;
      IHandle_t myIH = *dirIH;
***************
*** 1151,1157 ****
  		    info.u.param[2] = data.ftCreationTime.dwHighDateTime;
  		    info.u.param[3] = data.ftCreationTime.dwLowDateTime;
  		}
! 		if (judgeFun && !(*judgeFun)(&info, singleVolumeNumber))
  		    goto next_file;
  		if ((*writeFun)(fp, &info, path, data.cFileName)<0) {
  		    nt_close(linkHandle.fd_fd);
--- 1151,1157 ----
  		    info.u.param[2] = data.ftCreationTime.dwHighDateTime;
  		    info.u.param[3] = data.ftCreationTime.dwLowDateTime;
  		}
! 		if (judgeFun && !(*judgeFun)(&info, singleVolumeNumber, rock))
  		    goto next_file;
  		if ((*writeFun)(fp, &info, path, data.cFileName)<0) {
  		    nt_close(linkHandle.fd_fd);
Index: openafs/src/vol/nuke.c
diff -c openafs/src/vol/nuke.c:1.5.2.1 openafs/src/vol/nuke.c:1.5.2.2
*** openafs/src/vol/nuke.c:1.5.2.1	Fri Feb 28 20:22:49 2003
--- openafs/src/vol/nuke.c	Mon Oct 18 00:50:01 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/nuke.c,v 1.5.2.1 2003/03/01 01:22:49 shadow Exp $");
  
  #include <rx/xdr.h>
  #include <afs/afsint.h>
--- 10,16 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/nuke.c,v 1.5.2.2 2004/10/18 04:50:01 shadow Exp $");
  
  #include <rx/xdr.h>
  #include <afs/afsint.h>
***************
*** 56,69 ****
      afs_int32 freePtr;				/* first free index in this table */
      Inode inode[MAXATONCE];			/* inode # */
      afs_int32 count[MAXATONCE];			/* link count */
! } *allInodes = 0;
  
  /* called with a structure specifying info about the inode, and our rock (which
   * is the volume ID.  Returns true if we should keep this inode, otherwise false.
   * Note that ainfo->u.param[0] is always the volume ID, for any vice inode.
   */
! static NukeProc(ainfo, avolid)
  struct ViceInodeInfo *ainfo;
  afs_int32 avolid; {
      struct ilist *ti;
      register afs_int32 i;
--- 56,70 ----
      afs_int32 freePtr;				/* first free index in this table */
      Inode inode[MAXATONCE];			/* inode # */
      afs_int32 count[MAXATONCE];			/* link count */
! };
  
  /* called with a structure specifying info about the inode, and our rock (which
   * is the volume ID.  Returns true if we should keep this inode, otherwise false.
   * Note that ainfo->u.param[0] is always the volume ID, for any vice inode.
   */
! static NukeProc(ainfo, avolid, allInodes)
  struct ViceInodeInfo *ainfo;
+ struct ilist *allInodes;
  afs_int32 avolid; {
      struct ilist *ti;
      register afs_int32 i;
***************
*** 103,109 ****
  afs_int32 avolid; {
      /* first process the partition containing this junk */
      struct stat tstat;
!     struct ilist *ti, *ni;
      register afs_int32 code;
      char *tfile;
      int i, j, forceSal;
--- 104,110 ----
  afs_int32 avolid; {
      /* first process the partition containing this junk */
      struct stat tstat;
!     struct ilist *ti, *ni, *li=NULL;
      register afs_int32 code;
      char *tfile;
      int i, j, forceSal;
***************
*** 118,123 ****
--- 119,125 ----
  #endif
  #endif /* AFS_NAMEI_ENV */
      IHandle_t *fileH;
+     struct ilist *allInodes = 0;
  
      if (avolid == 0) return EINVAL;
      code = stat(aname, &tstat);
***************
*** 155,163 ****
       */
  #ifdef AFS_NAMEI_ENV
      code = ListViceInodes(lastDevComp, aname, NULL, NukeProc, avolid,
! 			  &forceSal, 0, wpath);
  #else
!     code = ListViceInodes(lastDevComp, aname, "/tmp/vNukeXX", NukeProc, avolid, &forceSal, 0, wpath);
      unlink("/tmp/vNukeXX");	/* clean it up now */
  #endif
      if (code == 0) {
--- 157,165 ----
       */
  #ifdef AFS_NAMEI_ENV
      code = ListViceInodes(lastDevComp, aname, NULL, NukeProc, avolid,
! 			  &forceSal, 0, wpath, allInodes);
  #else
!     code = ListViceInodes(lastDevComp, aname, "/tmp/vNukeXX", NukeProc, avolid, &forceSal, 0, wpath, allInodes);
      unlink("/tmp/vNukeXX");	/* clean it up now */
  #endif
      if (code == 0) {
***************
*** 193,200 ****
  #endif /* AFS_NAMEI_ENV */
  	    }
  	    ni = ti->next;
! 	    free(ti);
  	}
  	code = 0;	/* we really don't care about it except for debugging */
  	allInodes = (struct ilist *) 0;
  
--- 195,204 ----
  #endif /* AFS_NAMEI_ENV */
  	    }
  	    ni = ti->next;
! 	    if (li) free(li);
! 	    li = ti;
  	}
+ 	if (li) free(li);
  	code = 0;	/* we really don't care about it except for debugging */
  	allInodes = (struct ilist *) 0;
  
***************
*** 216,223 ****
  	/* just free things */
  	for(ti=allInodes; ti; ti = ni) {
  	    ni = ti->next;
! 	    free(ti);
  	}
  	allInodes = (struct ilist *) 0;
      }
      ReleaseWriteLock(&localLock);
--- 220,229 ----
  	/* just free things */
  	for(ti=allInodes; ti; ti = ni) {
  	    ni = ti->next;
! 	    if (li) free(li);
! 	    li = ti;
  	}
+ 	if (li) free(li);
  	allInodes = (struct ilist *) 0;
      }
      ReleaseWriteLock(&localLock);
Index: openafs/src/vol/vol-salvage.c
diff -c openafs/src/vol/vol-salvage.c:1.10.2.11 openafs/src/vol/vol-salvage.c:1.10.2.13
*** openafs/src/vol/vol-salvage.c:1.10.2.11	Thu May 15 12:24:25 2003
--- openafs/src/vol/vol-salvage.c	Mon Oct 18 02:26:34 2004
***************
*** 91,97 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.10.2.11 2003/05/15 16:24:25 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 91,97 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.10.2.13 2004/10/18 06:26:34 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
***************
*** 1414,1422 ****
      summary->maxUniquifier = maxunique;
  }
  
! int OnlyOneVolume(inodeinfo, singleVolumeNumber)
      struct ViceInodeInfo *inodeinfo;
      VolumeId singleVolumeNumber;
  {
      if (inodeinfo->u.vnode.vnodeNumber == INODESPECIAL)
  	return (inodeinfo->u.special.parentId == singleVolumeNumber);
--- 1414,1423 ----
      summary->maxUniquifier = maxunique;
  }
  
! int OnlyOneVolume(inodeinfo, singleVolumeNumber, rock)
      struct ViceInodeInfo *inodeinfo;
      VolumeId singleVolumeNumber;
+     void *rock;
  {
      if (inodeinfo->u.vnode.vnodeNumber == INODESPECIAL)
  	return (inodeinfo->u.special.parentId == singleVolumeNumber);
***************
*** 1448,1454 ****
      char *tdir;
  
      /* This file used to come from vfsck; cobble it up ourselves now... */
!     if ((err = ListViceInodes(dev, fileSysPath, path, singleVolumeNumber?OnlyOneVolume:0, singleVolumeNumber, &forceSal, forceR, wpath)) < 0) {
         if (err == -2) {
  	    Log("*** I/O error %d when writing a tmp inode file %s; Not salvaged %s ***\nIncrease space on partition or use '-tmpdir'\n",
  		errno, path, dev);
--- 1449,1455 ----
      char *tdir;
  
      /* This file used to come from vfsck; cobble it up ourselves now... */
!     if ((err = ListViceInodes(dev, fileSysPath, path, singleVolumeNumber?OnlyOneVolume:0, singleVolumeNumber, &forceSal, forceR, wpath, NULL)) < 0) {
         if (err == -2) {
  	    Log("*** I/O error %d when writing a tmp inode file %s; Not salvaged %s ***\nIncrease space on partition or use '-tmpdir'\n",
  		errno, path, dev);
Index: openafs/src/volser/vsprocs.c
diff -c openafs/src/volser/vsprocs.c:1.6.2.6 openafs/src/volser/vsprocs.c:1.6.2.7
*** openafs/src/volser/vsprocs.c:1.6.2.6	Thu Nov 14 16:40:43 2002
--- openafs/src/volser/vsprocs.c	Mon Oct 18 01:23:13 2004
***************
*** 10,16 ****
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.6.2.6 2002/11/14 21:40:43 zacheiss Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 10,16 ----
  #include <afsconfig.h>
  #include <afs/param.h>
  
! RCSID("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.6.2.7 2004/10/18 05:23:13 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 352,357 ****
--- 352,359 ----
  	   if (entry->serverFlags[i] & NEW_REPSITE)
  	      fprintf(STDOUT," -- New release");
  	   else
+ 	       if (!(entry->serverFlags[i] & ITSRWVOL))
+                    fprintf(STDOUT," -- Old release");
  	      fprintf(STDOUT," -- Old release");
  	} else {
  	   if (entry->serverFlags[i] & RO_DONTUSE)
***************
*** 2008,2018 ****
    }
  
    /* Will we be completing a previously unfinished release. -force overrides */
!   for (fullrelease=1, i=0; (fullrelease && (i<entry.nServers)); i++) {
!      if (entry.serverFlags[i] & NEW_REPSITE)
!         fullrelease = 0;
    }
!   if (forceflag && !fullrelease)
      fullrelease = 1;
  
    /* Determine which volume id to use and see if it exists */
--- 2010,2022 ----
    }
  
    /* Will we be completing a previously unfinished release. -force overrides */
!   for (s = 0, m = 0, fullrelease=0, i=0; (i<entry.nServers); i++) {
!       if (entry.serverFlags[i] & ITSROVOL) {
! 	  m++;
! 	  if (entry.serverFlags[i] & NEW_REPSITE) s++;
!       }
    }
!   if ((forceflag && !fullrelease) || (s == m) || (s == 0))
      fullrelease = 1;
  
    /* Determine which volume id to use and see if it exists */
