Index: openafs/src/afs/afs.h
diff -c openafs/src/afs/afs.h:1.48.2.31 openafs/src/afs/afs.h:1.48.2.32
*** openafs/src/afs/afs.h:1.48.2.31	Mon Nov 26 16:21:44 2007
--- openafs/src/afs/afs.h	Sat Jun 28 23:26:03 2008
***************
*** 86,96 ****
--- 86,98 ----
  #define	AFS_NRXPACKETS	80
  #define	AFS_RXDEADTIME	50
  #define AFS_HARDDEADTIME	120
+ #define	AFS_IDLEDEADTIME	50
  #define AFS_BLKBITS	12
  #define AFS_BLKSIZE	(1 << AFS_BLKBITS)
  
  extern afs_int32 afs_rx_deadtime;
  extern afs_int32 afs_rx_harddead;
+ extern afs_int32 afs_rx_idledead;
  
  struct sysname_info {
      char *name;
***************
*** 186,191 ****
--- 188,196 ----
      char volumeError;		/* encountered a missing or busy volume */
      char networkError;		/* encountered network problems */
      char permWriteError;	/* fileserver returns permenent error. */
+     char tokenError;            /* a token error other than expired. */
+     char idleError;             /* the server idled too long */
+     char skipserver[MAXHOSTS];
  };
  #define VOLMISSING 1
  #define VOLBUSY 2
Index: openafs/src/afs/afs_analyze.c
diff -c openafs/src/afs/afs_analyze.c:1.22.2.2 openafs/src/afs/afs_analyze.c:1.22.2.5
*** openafs/src/afs/afs_analyze.c:1.22.2.2	Tue Jan  9 10:28:19 2007
--- openafs/src/afs/afs_analyze.c	Fri Aug 22 14:53:16 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_analyze.c,v 1.22.2.2 2007/01/09 15:28:19 jaltman Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_analyze.c,v 1.22.2.5 2008/08/22 18:53:16 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 215,224 ****
--- 215,233 ----
  void
  afs_CopyError(register struct vrequest *afrom, register struct vrequest *ato)
  {
+     int i = 0;
      AFS_STATCNT(afs_CopyError);
      if (!afrom->initd)
  	return;
      afs_FinalizeReq(ato);
+     while (i < MAXHOSTS) {
+ 	ato->skipserver[i] = afrom->skipserver[i];
+ 	i++;
+     }
+     if (afrom->tokenError)
+ 	ato->tokenError = afrom->tokenError;
+     if (afrom->idleError)
+ 	ato->idleError = afrom->idleError;
      if (afrom->accessError)
  	ato->accessError = 1;
      if (afrom->volumeError)
***************
*** 233,242 ****
--- 242,258 ----
  void
  afs_FinalizeReq(register struct vrequest *areq)
  {
+     int i = 0;
      AFS_STATCNT(afs_FinalizeReq);
      if (areq->initd)
  	return;
+     while (i < MAXHOSTS) {
+ 	areq->skipserver[i] = 0;
+ 	i++;
+     }
      areq->busyCount = 0;
+     areq->idleError = 0;
+     areq->tokenError = 0;
      areq->accessError = 0;
      areq->volumeError = 0;
      areq->networkError = 0;
***************
*** 425,430 ****
--- 441,507 ----
      return (changed ? DIFFERENT : SAME);
  }				/*VLDB_Same */
  
+ /*------------------------------------------------------------------------
+  * afs_BlackListOnce
+  *
+  * Description:
+  *	Mark a server as invalid for further attempts of this request only.
+  *
+  * Arguments:
+  *	areq  : The request record associated with this operation.
+  *	afid  : The FID of the file involved in the action.  This argument
+  *		may be null if none was involved.
+  *      tsp   : pointer to a server struct for the server we wish to 
+  *              blacklist. 
+  *
+  * Returns:
+  *	Non-zero value if further servers are available to try,
+  *	zero otherwise.
+  *
+  * Environment:
+  *	This routine is typically called in situations where we believe
+  *      one server out of a pool may have an error condition.
+  *
+  * Side Effects:
+  *	As advertised.
+  *
+  * NOTE:
+  *	The afs_Conn* routines use the list of invalidated servers to 
+  *      avoid reusing a server marked as invalid for this request.
+  *------------------------------------------------------------------------*/
+ static afs_int32 
+ afs_BlackListOnce(struct vrequest *areq, struct VenusFid *afid, 
+ 		  struct server *tsp)
+ {
+     struct volume *tvp;
+     afs_int32 i;
+     afs_int32 serversleft = 0;
+ 
+     if (afid) {
+ 	tvp = afs_FindVolume(afid, READ_LOCK);
+ 	if (tvp) {
+ 	    for (i = 0; i < MAXHOSTS; i++) {
+ 		if (tvp->serverHost[i] == tsp) {
+ 		    areq->skipserver[i] = 1;
+ 		}
+ 		if (tvp->serverHost[i] &&
+ 		    !(tvp->serverHost[i]->addr->sa_flags & 
+ 		      SRVR_ISDOWN)) {
+ 		    areq->skipserver[i] = 1;
+ 		}
+ 	    }
+ 	    afs_PutVolume(tvp, READ_LOCK);
+ 	}
+     }
+     for (i = 0; i < MAXHOSTS; i++) {
+ 	if (areq->skipserver[i] == 0) {
+ 	    serversleft = 1;
+ 	    break;
+ 	}
+     }
+     return serversleft;
+ }
+ 
  
  /*------------------------------------------------------------------------
   * EXPORTED afs_Analyze
***************
*** 468,474 ****
--- 545,553 ----
      struct server *tsp;
      struct volume *tvp;
      afs_int32 shouldRetry = 0;
+     afs_int32 serversleft = 1;
      struct afs_stats_RPCErrors *aerrP;
+     afs_int32 markeddown;
  
      AFS_STATCNT(afs_Analyze);
      afs_Trace4(afs_iclSetp, CM_TRACE_ANALYZE, ICL_TYPE_INT32, op,
***************
*** 519,525 ****
  	return shouldRetry;	/* should retry */
      }
  
!     if (!aconn) {
  	if (!areq->volumeError) {
  	    if (aerrP)
  		(aerrP->err_Network)++;
--- 598,604 ----
  	return shouldRetry;	/* should retry */
      }
  
!     if (!aconn || !aconn->srvr) {
  	if (!areq->volumeError) {
  	    if (aerrP)
  		(aerrP->err_Network)++;
***************
*** 592,601 ****
  	acode = 455;
  #endif /* AFS_64BIT_CLIENT */
      if ((acode < 0) && (acode != VRESTARTING)) {
! 	afs_ServerDown(sa);
! 	ForceNewConnections(sa);	/*multi homed clients lock:afs_xsrvAddr? */
  	if (aerrP)
  	    (aerrP->err_Server)++;
      }
  
      if (acode == VBUSY || acode == VRESTARTING) {
--- 671,703 ----
  	acode = 455;
  #endif /* AFS_64BIT_CLIENT */
      if ((acode < 0) && (acode != VRESTARTING)) {
! 	if (acode == RX_CALL_TIMEOUT) {
! 	    serversleft = afs_BlackListOnce(areq, afid, tsp);
! 	    areq->idleError++;
! 	    if (serversleft) {
! 		shouldRetry = 1;
! 	    } else {
! 		shouldRetry = 0;
! 	    }
! 	    /* By doing this, we avoid ever marking a server down
! 	     * in an idle timeout case. That's because the server is 
! 	     * still responding and may only be letting a single vnode
! 	     * time out. We otherwise risk having the server continually
! 	     * be marked down, then up, then down again... 
! 	     */
! 	    goto out;
! 	} 
! 	markeddown = afs_ServerDown(sa);
! 	ForceNewConnections(sa); /**multi homed clients lock:afs_xsrvAddr? */
  	if (aerrP)
  	    (aerrP->err_Server)++;
+ #if 0
+ 	/* retry *once* when the server is timed out in case of NAT */
+ 	if (markeddown && acode == RX_CALL_DEAD) {
+ 	    aconn->forceConnectFS = 1;
+ 	    shouldRetry = 1;
+ 	}
+ #endif
      }
  
      if (acode == VBUSY || acode == VRESTARTING) {
***************
*** 626,632 ****
  	       || (acode & ~0xff) == ERROR_TABLE_BASE_RXK) {
  	/* any rxkad error is treated as token expiration */
  	struct unixuser *tu;
- 
  	/*
  	 * I'm calling these errors protection errors, since they involve
  	 * faulty authentication.
--- 728,733 ----
***************
*** 645,655 ****
  		    ("afs: Tokens for user of AFS id %d for cell %s have expired\n",
  		     tu->vid, aconn->srvr->server->cell->cellName);
  	    } else {
! 		aconn->forceConnectFS = 0;	/* don't check until new tokens set */
! 		aconn->user->states |= UTokensBad;
! 		afs_warnuser
! 		    ("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n",
! 		     tu->vid, aconn->srvr->server->cell->cellName, acode);
  	    }
  	    afs_PutUser(tu, READ_LOCK);
  	} else {
--- 746,767 ----
  		    ("afs: Tokens for user of AFS id %d for cell %s have expired\n",
  		     tu->vid, aconn->srvr->server->cell->cellName);
  	    } else {
! 		serversleft = afs_BlackListOnce(areq, afid, tsp);
! 		areq->tokenError++;
! 
! 		if (serversleft) {
! 		    afs_warnuser
! 			("afs: Tokens for user of AFS id %d for cell %s: rxkad error=%d\n",
! 			 tu->vid, aconn->srvr->server->cell->cellName, acode);
! 		    shouldRetry = 1;
! 		} else {
! 		    areq->tokenError = 0;
! 		    aconn->forceConnectFS = 0;	/* don't check until new tokens set */
! 		    aconn->user->states |= UTokensBad;
! 		    afs_warnuser
! 			("afs: Tokens for user of AFS id %d for cell %s are discarded (rxkad error=%d)\n",
! 			 tu->vid, aconn->srvr->server->cell->cellName, acode);
! 		}
  	    }
  	    afs_PutUser(tu, READ_LOCK);
  	} else {
***************
*** 745,751 ****
  	VSleep(1);		/* Just a hack for desperate times. */
  	shouldRetry = 1;
      }
! 
      /* now unlock the connection and return */
      afs_PutConn(aconn, locktype);
      return (shouldRetry);
--- 857,863 ----
  	VSleep(1);		/* Just a hack for desperate times. */
  	shouldRetry = 1;
      }
! out:
      /* now unlock the connection and return */
      afs_PutConn(aconn, locktype);
      return (shouldRetry);
Index: openafs/src/afs/afs_call.c
diff -c openafs/src/afs/afs_call.c:1.74.2.30 openafs/src/afs/afs_call.c:1.74.2.32
*** openafs/src/afs/afs_call.c:1.74.2.30	Fri Apr 18 10:06:50 2008
--- openafs/src/afs/afs_call.c	Sat Jun 28 23:26:03 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.30 2008/04/18 14:06:50 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.32 2008/06/29 03:26:03 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 110,115 ****
--- 110,116 ----
  
  afs_int32 afs_rx_deadtime = AFS_RXDEADTIME;
  afs_int32 afs_rx_harddead = AFS_HARDDEADTIME;
+ afs_int32 afs_rx_idledead = AFS_IDLEDEADTIME;
  
  static int
    Afscall_icl(long opcode, long p1, long p2, long p3, long p4, long *retval);
***************
*** 2901,2910 ****
      ObtainWriteLock(&logp->lock, 189);
      if (--logp->setCount == 0) {
  	/* no more users -- free it (but keep log structure around) */
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
- 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  	logp->firstUsed = logp->firstFree = 0;
  	logp->logElements = 0;
  	logp->datap = NULL;
--- 2902,2911 ----
      ObtainWriteLock(&logp->lock, 189);
      if (--logp->setCount == 0) {
  	/* no more users -- free it (but keep log structure around) */
+ 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
  	logp->firstUsed = logp->firstFree = 0;
  	logp->logElements = 0;
  	logp->datap = NULL;
***************
*** 2927,2936 ****
  	logp->logElements = 0;
  
  	/* free and allocate a new one */
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
- 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  	logp->datap =
  	    (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
  #ifdef	KERNEL_HAVE_PIN
--- 2928,2937 ----
  	logp->logElements = 0;
  
  	/* free and allocate a new one */
+ 	afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  #ifdef	KERNEL_HAVE_PIN
  	unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
  	logp->datap =
  	    (afs_int32 *) afs_osi_Alloc(sizeof(afs_int32) * logSize);
  #ifdef	KERNEL_HAVE_PIN
***************
*** 2954,2963 ****
  	    /* found the dude we want to remove */
  	    *lpp = logp->nextp;
  	    osi_FreeSmallSpace(logp->name);
  #ifdef KERNEL_HAVE_PIN
  	    unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
- 	    afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  	    osi_FreeSmallSpace(logp);
  	    break;		/* won't find it twice */
  	}
--- 2955,2964 ----
  	    /* found the dude we want to remove */
  	    *lpp = logp->nextp;
  	    osi_FreeSmallSpace(logp->name);
+ 	    afs_osi_Free(logp->datap, sizeof(afs_int32) * logp->logSize);
  #ifdef KERNEL_HAVE_PIN
  	    unpin((char *)logp->datap, sizeof(afs_int32) * logp->logSize);
  #endif
  	    osi_FreeSmallSpace(logp);
  	    break;		/* won't find it twice */
  	}
***************
*** 3215,3224 ****
  	    /* found the dude we want to remove */
  	    *lpp = setp->nextp;
  	    osi_FreeSmallSpace(setp->name);
  #ifdef	KERNEL_HAVE_PIN
  	    unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
  #endif
- 	    afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
  	    for (i = 0; i < ICL_LOGSPERSET; i++) {
  		if ((tlp = setp->logs[i]))
  		    afs_icl_LogReleNL(tlp);
--- 3216,3225 ----
  	    /* found the dude we want to remove */
  	    *lpp = setp->nextp;
  	    osi_FreeSmallSpace(setp->name);
+ 	    afs_osi_Free(setp->eventFlags, ICL_DEFAULTEVENTS);
  #ifdef	KERNEL_HAVE_PIN
  	    unpin((char *)setp->eventFlags, ICL_DEFAULTEVENTS);
  #endif
  	    for (i = 0; i < ICL_LOGSPERSET; i++) {
  		if ((tlp = setp->logs[i]))
  		    afs_icl_LogReleNL(tlp);
Index: openafs/src/afs/afs_conn.c
diff -c openafs/src/afs/afs_conn.c:1.13.2.2 openafs/src/afs/afs_conn.c:1.13.2.3
*** openafs/src/afs/afs_conn.c:1.13.2.2	Mon Feb 26 17:18:28 2007
--- openafs/src/afs/afs_conn.c	Sat Jun 28 23:26:04 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_conn.c,v 1.13.2.2 2007/02/26 22:18:28 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_conn.c,v 1.13.2.3 2008/06/29 03:26:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 83,89 ****
  
      /* First is always lowest rank, if it's up */
      if ((tv->status[0] == not_busy) && tv->serverHost[0]
! 	&& !(tv->serverHost[0]->addr->sa_flags & SRVR_ISDOWN))
  	lowp = tv->serverHost[0]->addr;
  
      /* Otherwise we look at all of them. There are seven levels of
--- 83,91 ----
  
      /* First is always lowest rank, if it's up */
      if ((tv->status[0] == not_busy) && tv->serverHost[0]
! 	&& !(tv->serverHost[0]->addr->sa_flags & SRVR_ISDOWN) &&
! 	!(((areq->idleError > 0) || (areq->tokenError > 0))
! 	  && (areq->skipserver[0] == 1)))
  	lowp = tv->serverHost[0]->addr;
  
      /* Otherwise we look at all of them. There are seven levels of
***************
*** 95,100 ****
--- 97,105 ----
       */
      for (notbusy = not_busy; (!lowp && (notbusy <= end_not_busy)); notbusy++) {
  	for (i = 0; i < MAXHOSTS && tv->serverHost[i]; i++) {
+ 	    if (((areq->tokenError > 0)||(areq->idleError > 0)) 
+ 		&& (areq->skipserver[i] == 1))
+ 		continue;
  	    if (tv->status[i] != notbusy) {
  		if (tv->status[i] == rd_busy || tv->status[i] == rdwr_busy) {
  		    if (!areq->busyCount)
***************
*** 234,239 ****
--- 239,245 ----
  	if (service == 52) {
  	    rx_SetConnHardDeadTime(tc->id, afs_rx_harddead);
  	}
+ 	rx_SetConnIdleDeadTime(tc->id, afs_rx_idledead);
  
  	tc->forceConnectFS = 0;	/* apparently we're appropriately connected now */
  	if (csec)
Index: openafs/src/afs/afs_dcache.c
diff -c openafs/src/afs/afs_dcache.c:1.42.2.23 openafs/src/afs/afs_dcache.c:1.42.2.24
*** openafs/src/afs/afs_dcache.c:1.42.2.23	Sat Dec  8 13:00:44 2007
--- openafs/src/afs/afs_dcache.c	Tue Aug 26 10:02:10 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.23 2007/12/08 18:00:44 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_dcache.c,v 1.42.2.24 2008/08/26 14:02:10 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 387,392 ****
--- 387,397 ----
      afs_hyper_t maxVictimTime;	/* youngest (largest LRU time) victim */
      afs_uint32 maxVictimPtr;	/* where it is */
      int discard;
+     int vfslocked;
+ 
+ #if defined(AFS_FBSD80_ENV) && !defined(UKERNEL)
+     vfslocked = VFS_LOCK_GIANT(afs_globalVFS);
+ #endif
  
      AFS_STATCNT(afs_GetDownD);
      if (CheckLock(&afs_xdcache) != -1)
***************
*** 396,404 ****
       * because we should try to free space even if anumber <=0 */
      if (!aneedSpace || *aneedSpace <= 0) {
  	anumber -= afs_freeDCCount;
! 	if (anumber <= 0)
  	    return;		/* enough already free */
      }
      /* bounds check parameter */
      if (anumber > MAXATONCE)
  	anumber = MAXATONCE;	/* all we can do */
--- 401,414 ----
       * because we should try to free space even if anumber <=0 */
      if (!aneedSpace || *aneedSpace <= 0) {
  	anumber -= afs_freeDCCount;
! 	if (anumber <= 0) {
! #if defined(AFS_FBSD80_ENV) && !defined(UKERNEL)
! 	  VFS_UNLOCK_GIANT(vfslocked);
! #endif
  	    return;		/* enough already free */
+ 	}
      }
+ 
      /* bounds check parameter */
      if (anumber > MAXATONCE)
  	anumber = MAXATONCE;	/* all we can do */
***************
*** 657,662 ****
--- 667,677 ----
  		break;
  	}
      }				/* big while loop */
+ 
+ #if defined(AFS_FBSD80_ENV) && !defined(UKERNEL)
+     VFS_UNLOCK_GIANT(vfslocked);
+ #endif
+ 
      return;
  
  }				/*afs_GetDownD */
Index: openafs/src/afs/afs_init.c
diff -c openafs/src/afs/afs_init.c:1.28.2.7 openafs/src/afs/afs_init.c:1.28.2.8
*** openafs/src/afs/afs_init.c:1.28.2.7	Wed Oct 10 13:43:35 2007
--- openafs/src/afs/afs_init.c	Thu Jun 12 13:25:03 2008
***************
*** 17,23 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28.2.7 2007/10/10 17:43:35 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 17,23 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28.2.8 2008/06/12 17:25:03 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 116,123 ****
       */
      if (aVolumes < 50)
  	aVolumes = 50;
!     else if (aVolumes > 3000)
! 	aVolumes = 3000;
  
      tv = (struct volume *)afs_osi_Alloc(aVolumes * sizeof(struct volume));
      for (i = 0; i < aVolumes - 1; i++)
--- 116,123 ----
       */
      if (aVolumes < 50)
  	aVolumes = 50;
!     else if (aVolumes > 32767)
! 	aVolumes = 32767;
  
      tv = (struct volume *)afs_osi_Alloc(aVolumes * sizeof(struct volume));
      for (i = 0; i < aVolumes - 1; i++)
Index: openafs/src/afs/afs_nfsdisp.c
diff -c openafs/src/afs/afs_nfsdisp.c:1.18.2.3 openafs/src/afs/afs_nfsdisp.c:1.18.2.4
*** openafs/src/afs/afs_nfsdisp.c:1.18.2.3	Thu Oct 13 14:26:06 2005
--- openafs/src/afs/afs_nfsdisp.c	Wed Aug 13 19:49:37 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18.2.3 2005/10/13 18:26:06 shadow Exp $");
  
  /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
  #define __XDR_INCLUDE__
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18.2.4 2008/08/13 23:49:37 shadow Exp $");
  
  /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
  #define __XDR_INCLUDE__
***************
*** 177,183 ****
      }
  
      /* Ok if arg 1 is in AFS or if 2 args and arg 2 is in AFS */
!     if (is_afs_fh(fhp1)) {
  	*fhpp = fhp1;
  	if (fhp2)
  	    *fh2pp = fhp2;
--- 177,183 ----
      }
  
      /* Ok if arg 1 is in AFS or if 2 args and arg 2 is in AFS */
!     if (fhp1 && is_afs_fh(fhp1)) {
  	*fhpp = fhp1;
  	if (fhp2)
  	    *fh2pp = fhp2;
***************
*** 237,243 ****
  	return NULL;
      }
  
!     if (is_afs_fh(fhp)) {
  	*fhpp = fhp;
  	return 1;
      }
--- 237,243 ----
  	return NULL;
      }
  
!     if (fhp && is_afs_fh(fhp)) {
  	*fhpp = fhp;
  	return 1;
      }
***************
*** 972,978 ****
  	return NULL;
      }
  
!     if (is_afs_fh3(fhp1)) {
  	*fhpp = fhp1;
  	if (fhp2)
  	    *fh2pp = fhp2;
--- 972,978 ----
  	return NULL;
      }
  
!     if (fhp1 && is_afs_fh3(fhp1)) {
  	*fhpp = fhp1;
  	if (fhp2)
  	    *fh2pp = fhp2;
***************
*** 1016,1022 ****
  	return NULL;
      }
  
!     if (is_afs_fh3(fhp)) {
  	*fhpp = fhp;
  	return 1;
      }
--- 1016,1022 ----
  	return NULL;
      }
  
!     if (fhp && is_afs_fh3(fhp)) {
  	*fhpp = fhp;
  	return 1;
      }
Index: openafs/src/afs/afs_osi.c
diff -c openafs/src/afs/afs_osi.c:1.48.2.15 openafs/src/afs/afs_osi.c:1.48.2.16
*** openafs/src/afs/afs_osi.c:1.48.2.15	Tue Feb  5 20:43:44 2008
--- openafs/src/afs/afs_osi.c	Tue Aug 26 10:02:10 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.15 2008/02/06 01:43:44 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.16 2008/08/26 14:02:10 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 58,63 ****
--- 58,68 ----
      usimple_lock_init(&afs_global_lock);
      afs_global_owner = (thread_t) 0;
  #elif defined(AFS_FBSD50_ENV)
+ #if defined(AFS_FBSD80_ENV) && defined(WITNESS)
+     /* "lock_initalized" (sic) can panic, checks a flag bit
+      * is unset _before_ init */
+     memset(&afs_global_mtx, 0, sizeof(struct mtx));
+ #endif
      mtx_init(&afs_global_mtx, "AFS global lock", NULL, MTX_DEF);
  #elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
  #if !defined(AFS_DARWIN80_ENV)
***************
*** 134,139 ****
--- 139,145 ----
  void
  osi_FlushPages(register struct vcache *avc, struct AFS_UCRED *credp)
  {
+     int vfslocked;
      afs_hyper_t origDV;
      ObtainReadLock(&avc->lock);
      /* If we've already purged this version, or if we're the ones
***************
*** 164,172 ****
--- 170,188 ----
  	       ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->m.Length);
  
      ReleaseWriteLock(&avc->lock);
+ #ifdef AFS_FBSD70_ENV
+     vfslocked = VFS_LOCK_GIANT(AFSTOV(avc)->v_mount);
+ #endif
+ #ifndef AFS_FBSD70_ENV
      AFS_GUNLOCK();
+ #endif
      osi_VM_FlushPages(avc, credp);
+ #ifndef AFS_FBSD70_ENV
      AFS_GLOCK();
+ #endif
+ #ifdef AFS_FBSD70_ENV
+     VFS_UNLOCK_GIANT(vfslocked);
+ #endif
      ObtainWriteLock(&avc->lock, 88);
  
      /* do this last, and to original version, since stores may occur
Index: openafs/src/afs/afs_osi.h
diff -c openafs/src/afs/afs_osi.h:1.22.2.19 openafs/src/afs/afs_osi.h:1.22.2.20
*** openafs/src/afs/afs_osi.h:1.22.2.19	Thu Feb  8 17:41:20 2007
--- openafs/src/afs/afs_osi.h	Tue Jul  1 16:57:21 2008
***************
*** 150,164 ****
  #endif
  #endif
  
- #ifdef AFS_SGI65_ENV
- #define	gop_lookupname(fnamep,segflg,followlink,compvpp) \
-              lookupname((fnamep),(segflg),(followlink),NULL,(compvpp),\
- 			NULL)
- #else
- #define	gop_lookupname(fnamep,segflg,followlink,compvpp) \
-              lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
- #endif
- 
  /*
   * In IRIX 6.5 we cannot have DEBUG turned on since certain
   * system-defined structures are a different size with DEBUG on, the
--- 150,155 ----
Index: openafs/src/afs/afs_osi_alloc.c
diff -c openafs/src/afs/afs_osi_alloc.c:1.10.2.3 openafs/src/afs/afs_osi_alloc.c:1.10.2.5
*** openafs/src/afs/afs_osi_alloc.c:1.10.2.3	Thu Dec 13 14:18:47 2007
--- openafs/src/afs/afs_osi_alloc.c	Tue Aug 26 10:02:10 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_alloc.c,v 1.10.2.3 2007/12/13 19:18:47 shadow Exp $");
  
  
  
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osi_alloc.c,v 1.10.2.5 2008/08/26 14:02:10 shadow Exp $");
  
  
  
***************
*** 19,25 ****
  #include "afsincludes.h"	/* Afs-based standard headers */
  #include "afs/afs_stats.h"	/* afs statistics */
  
! #ifndef AFS_FBSD_ENV
  
  #ifdef AFS_AIX41_ENV
  #include "sys/lockl.h"
--- 19,25 ----
  #include "afsincludes.h"	/* Afs-based standard headers */
  #include "afs/afs_stats.h"	/* afs statistics */
  
! 
  
  #ifdef AFS_AIX41_ENV
  #include "sys/lockl.h"
***************
*** 146,163 ****
  
  	while ((tp = freePacketList)) {
  	    freePacketList = tp->next;
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_LRALLOCSIZ);
  #endif
- 	    afs_osi_Free(tp, AFS_LRALLOCSIZ);
  	}
  
  	while ((tp = freeSmallList)) {
  	    freeSmallList = tp->next;
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_SMALLOCSIZ);
  #endif
- 	    afs_osi_Free(tp, AFS_SMALLOCSIZ);
  	}
  	LOCK_INIT(&osi_fsplock, "osi_fsplock");
  	LOCK_INIT(&osi_flplock, "osi_flplock");
--- 146,163 ----
  
  	while ((tp = freePacketList)) {
  	    freePacketList = tp->next;
+ 	    afs_osi_Free(tp, AFS_LRALLOCSIZ);
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_LRALLOCSIZ);
  #endif
  	}
  
  	while ((tp = freeSmallList)) {
  	    freeSmallList = tp->next;
+ 	    afs_osi_Free(tp, AFS_SMALLOCSIZ);
  #ifdef  KERNEL_HAVE_PIN
  	    unpin(tp, AFS_SMALLOCSIZ);
  #endif
  	}
  	LOCK_INIT(&osi_fsplock, "osi_fsplock");
  	LOCK_INIT(&osi_flplock, "osi_flplock");
***************
*** 170,173 ****
  		 afs_stats_cmperf.SmallBlocksActive);
      }
  }
! #endif
--- 170,173 ----
  		 afs_stats_cmperf.SmallBlocksActive);
      }
  }
! 
Index: openafs/src/afs/afs_osidnlc.c
diff -c openafs/src/afs/afs_osidnlc.c:1.8.2.6 openafs/src/afs/afs_osidnlc.c:1.8.2.7
*** openafs/src/afs/afs_osidnlc.c:1.8.2.6	Fri Oct 19 16:40:52 2007
--- openafs/src/afs/afs_osidnlc.c	Tue Aug 26 10:02:10 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osidnlc.c,v 1.8.2.6 2007/10/19 20:40:52 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_osidnlc.c,v 1.8.2.7 2008/08/26 14:02:10 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 63,68 ****
--- 63,76 ----
  
  #define dnlcHash(ts, hval) for (hval=0; *ts; ts++) { hval *= 173;  hval  += *ts;   }
  
+ #if defined(AFS_FBSD80_ENV) && !defined(UKERNEL)
+ #define ma_critical_enter critical_enter
+ #define ma_critical_exit critical_exit
+ #else
+ #define ma_critical_enter() {}
+ #define ma_critical_exit() {}
+ #endif
+ 
  static struct nc *
  GetMeAnEntry(void)
  {
***************
*** 201,212 ****
      vnode_t tvp;
  #endif
  
!     if (!afs_usednlc)
! 	return 0;
  
      dnlcHash(ts, key);		/* leaves ts pointing at the NULL */
      if (ts - aname >= AFSNCNAMESIZE) {
! 	return 0;
      }
      skey = key & (NHSIZE - 1);
  
--- 209,225 ----
      vnode_t tvp;
  #endif
  
!     ma_critical_enter();
! 
!     if (!afs_usednlc) {
!       ma_critical_exit();
!       return 0;
!     }
  
      dnlcHash(ts, key);		/* leaves ts pointing at the NULL */
      if (ts - aname >= AFSNCNAMESIZE) {
!       ma_critical_exit();
!       return 0;
      }
      skey = key & (NHSIZE - 1);
  
***************
*** 231,236 ****
--- 244,250 ----
  	    ReleaseReadLock(&afs_xdnlc);
  	    ReleaseReadLock(&afs_xvcache);
  	    osi_dnlc_purge();
+ 	    ma_critical_exit();
  	    return (0);
  	}
      }
***************
*** 251,256 ****
--- 265,271 ----
  	    ReleaseReadLock(&afs_xvcache);
  	    dnlcstats.misses++;
  	    osi_dnlc_remove(adp, aname, tvc);
+ 	    ma_critical_exit();
  	    return 0;
  	}
  #ifdef	AFS_OSF_ENV
***************
*** 262,267 ****
--- 277,283 ----
  	    ReleaseReadLock(&afs_xvcache);
  	    dnlcstats.misses++;
  	    osi_dnlc_remove(adp, aname, tvc);
+ 	    ma_critical_exit();
  	    return 0;
  	}
  	if (vnode_ref(tvp)) {
***************
*** 271,280 ****
--- 287,304 ----
  	    AFS_GLOCK();
  	    dnlcstats.misses++;
  	    osi_dnlc_remove(adp, aname, tvc);
+ 	    ma_critical_exit();
  	    return 0;
  	}
  #else
+ #ifdef AFS_FBSD50_ENV
+ 	/* can't sleep in a critical section */
+ 	ma_critical_exit();
+ 	osi_vnhold(tvc, 0);
+ 	ma_critical_enter();
+ #else
  	osi_vnhold(tvc, 0);
+ #endif /* AFS_FBSD80_ENV */
  #endif
  #endif
  	ReleaseReadLock(&afs_xvcache);
***************
*** 313,318 ****
--- 337,343 ----
  #endif
      }
  
+     ma_critical_exit();
      return tvc;
  }
  
Index: openafs/src/afs/afs_prototypes.h
diff -c openafs/src/afs/afs_prototypes.h:1.53.2.24 openafs/src/afs/afs_prototypes.h:1.53.2.25
*** openafs/src/afs/afs_prototypes.h:1.53.2.24	Fri Apr 18 02:04:01 2008
--- openafs/src/afs/afs_prototypes.h	Sat Jun 28 23:26:04 2008
***************
*** 700,706 ****
  				    afs_int32 addr_uniquifier);
  extern void ForceAllNewConnections(void);
  extern void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown);
! extern void afs_ServerDown(struct srvAddr *sa);
  extern void afs_CountServers(void);
  extern void afs_CheckServers(int adown, struct cell *acellp);
  extern unsigned int afs_random(void);
--- 700,706 ----
  				    afs_int32 addr_uniquifier);
  extern void ForceAllNewConnections(void);
  extern void afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown);
! extern afs_int32 afs_ServerDown(struct srvAddr *sa);
  extern void afs_CountServers(void);
  extern void afs_CheckServers(int adown, struct cell *acellp);
  extern unsigned int afs_random(void);
Index: openafs/src/afs/afs_server.c
diff -c openafs/src/afs/afs_server.c:1.33.2.12 openafs/src/afs/afs_server.c:1.33.2.13
*** openafs/src/afs/afs_server.c:1.33.2.12	Tue Dec 11 16:31:52 2007
--- openafs/src/afs/afs_server.c	Sat Jun 28 23:26:04 2008
***************
*** 33,39 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.33.2.12 2007/12/11 21:31:52 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
--- 33,39 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_server.c,v 1.33.2.13 2008/06/29 03:26:04 shadow Exp $");
  
  #include "afs/stds.h"
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
***************
*** 239,252 ****
  }				/*MarkServerUpOrDown */
  
  
! void
  afs_ServerDown(struct srvAddr *sa)
  {
      register struct server *aserver = sa->server;
  
      AFS_STATCNT(ServerDown);
!     if (aserver->flags & SRVR_ISDOWN || sa->sa_flags & SRVADDR_ISDOWN)
! 	return;
      afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
      if (sa->sa_portal == aserver->cell->vlport)
  	print_internet_address
--- 239,252 ----
  }				/*MarkServerUpOrDown */
  
  
! afs_int32
  afs_ServerDown(struct srvAddr *sa)
  {
      register struct server *aserver = sa->server;
  
      AFS_STATCNT(ServerDown);
!     if (aserver->flags & SRVR_ISDOWN || sa->sa_flags & SRVADDR_ISDOWN) 
! 	return 0;
      afs_MarkServerUpOrDown(sa, SRVR_ISDOWN);
      if (sa->sa_portal == aserver->cell->vlport)
  	print_internet_address
***************
*** 254,260 ****
      else
  	print_internet_address("afs: Lost contact with file server ", sa, "",
  			       1);
! 
  }				/*ServerDown */
  
  
--- 254,260 ----
      else
  	print_internet_address("afs: Lost contact with file server ", sa, "",
  			       1);
!     return 1;
  }				/*ServerDown */
  
  
Index: openafs/src/afs/afs_vcache.c
diff -c openafs/src/afs/afs_vcache.c:1.65.2.48 openafs/src/afs/afs_vcache.c:1.65.2.50
*** openafs/src/afs/afs_vcache.c:1.65.2.48	Thu Dec 13 14:49:30 2007
--- openafs/src/afs/afs_vcache.c	Tue Aug 26 10:02:11 2008
***************
*** 39,45 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.48 2007/12/13 19:49:30 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
--- 39,45 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.50 2008/08/26 14:02:11 shadow Exp $");
  
  #include "afs/sysincludes.h"	/*Standard vendor system headers */
  #include "afsincludes.h"	/*AFS-based standard headers */
***************
*** 1122,1127 ****
--- 1122,1132 ----
      insmntque(tvc, afs_globalVFS);
  #endif /* AFS_OSF_ENV */
  #endif /* AFS_DUX40_ENV */
+ #ifdef AFS_FBSD70_ENV
+ #ifndef AFS_FBSD80_ENV /* yup.  they put it back. */
+     insmntque(AFSTOV(tvc), afs_globalVFS);
+ #endif
+ #endif
  #if defined(AFS_SGI_ENV)
      VN_SET_DPAGES(&(tvc->v), (struct pfdat *)NULL);
      osi_Assert((tvc->v.v_flag & VINACT) == 0);
***************
*** 1821,1826 ****
--- 1826,1845 ----
  	  ObtainWriteLock(&tvc->lock, 954);
  	if (!iheldthelock)
  	    VOP_UNLOCK(vp, LK_EXCLUSIVE, current_proc());
+ #elif defined(AFS_FBSD80_ENV)
+ 	iheldthelock = VOP_ISLOCKED(vp);
+ 	if (!iheldthelock) {
+ 	    /* nosleep/sleep lock order reversal */
+ 	    int glocked = ISAFS_GLOCK();
+ 	    if (glocked)
+ 		AFS_GUNLOCK();
+ 	    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+ 	    if (glocked)
+ 		AFS_GLOCK();
+ 	}
+ 	vinvalbuf(vp, V_SAVE, curthread, PINOD, 0);
+ 	if (!iheldthelock)
+ 	    VOP_UNLOCK(vp, 0);
  #elif defined(AFS_FBSD60_ENV)
  	iheldthelock = VOP_ISLOCKED(vp, curthread);
  	if (!iheldthelock)
***************
*** 3072,3083 ****
      }
      afs_cbrSpace = 0;
  
- #ifdef  KERNEL_HAVE_PIN
-     unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
- #endif
  #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
  
  #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      freeVCList = Initial_freeVCList = 0;
--- 3091,3102 ----
      }
      afs_cbrSpace = 0;
  
  #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      afs_osi_Free(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
  #endif
+ #ifdef  KERNEL_HAVE_PIN
+     unpin(Initial_freeVCList, afs_cacheStats * sizeof(struct vcache));
+ #endif
  
  #if !defined(AFS_OSF_ENV) && !defined(AFS_LINUX22_ENV)
      freeVCList = Initial_freeVCList = 0;
Index: openafs/src/afs/sysincludes.h
diff -c openafs/src/afs/sysincludes.h:1.28.2.15 openafs/src/afs/sysincludes.h:1.28.2.16
*** openafs/src/afs/sysincludes.h:1.28.2.15	Fri Nov 23 08:45:04 2007
--- openafs/src/afs/sysincludes.h	Sat Aug 16 15:43:15 2008
***************
*** 108,114 ****
--- 108,118 ----
  #include <linux/mm.h>
  #include <linux/slab.h>
  #include <linux/string.h>
+ #if defined(LINUX_SEMAPHORE_H)
+ #include <linux/semaphore.h>
+ #else
  #include <asm/semaphore.h>
+ #endif
  #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,16)
  #include <linux/mutex.h>
  #endif
Index: openafs/src/afs/DARWIN/osi_vfsops.c
diff -c openafs/src/afs/DARWIN/osi_vfsops.c:1.11.2.5 openafs/src/afs/DARWIN/osi_vfsops.c:1.11.2.7
*** openafs/src/afs/DARWIN/osi_vfsops.c:1.11.2.5	Thu Jan  4 17:09:50 2007
--- openafs/src/afs/DARWIN/osi_vfsops.c	Tue Oct  7 17:30:43 2008
***************
*** 5,11 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vfsops.c,v 1.11.2.5 2007/01/04 22:09:50 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 5,11 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/DARWIN/osi_vfsops.c,v 1.11.2.7 2008/10/07 21:30:43 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 118,124 ****
      afs_globalVFS = mp;
  #ifdef AFS_DARWIN80_ENV
      vfs_ioattr(mp, &ioattr);
!     ioattr.io_devblocksize = 8192;
      vfs_setioattr(mp, &ioattr);
      /* f_iosize is handled in VFS_GETATTR */
  #else
--- 118,124 ----
      afs_globalVFS = mp;
  #ifdef AFS_DARWIN80_ENV
      vfs_ioattr(mp, &ioattr);
!     ioattr.io_devblocksize = (16 * 32768);
      vfs_setioattr(mp, &ioattr);
      /* f_iosize is handled in VFS_GETATTR */
  #else
***************
*** 366,393 ****
      AFS_GLOCK();
      AFS_STATCNT(afs_statfs);
  
- #if 0
-     abp->f_type = MOUNT_AFS;
- #endif
  #ifdef AFS_DARWIN80_ENV
!     abp->f_bsize = abp->f_iosize = vfs_devblocksize(mp);
  #else
      abp->f_bsize = mp->vfs_bsize;
      abp->f_iosize = mp->vfs_bsize;
  #endif
  
      /* Fake a high number below to satisfy programs that use the statfs call
       * to make sure that there's enough space in the device partition before
       * storing something there.
       */
      abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
! 	abp->f_ffree = 
! #ifdef AFS_DARWIN80_ENV
! 	2147483648
! #else
! 	2000000
! #endif
! 	;
  
      if (abp != sysstat) {
          abp->f_fsid.val[0] = sysstat->f_fsid.val[0];
--- 366,388 ----
      AFS_GLOCK();
      AFS_STATCNT(afs_statfs);
  
  #ifdef AFS_DARWIN80_ENV
!     abp->f_iosize = (256 * 1024);
!     abp->f_bsize = vfs_devblocksize(mp);
  #else
      abp->f_bsize = mp->vfs_bsize;
      abp->f_iosize = mp->vfs_bsize;
  #endif
+ #if 0
+     abp->f_type = MOUNT_AFS;
+ #endif
  
      /* Fake a high number below to satisfy programs that use the statfs call
       * to make sure that there's enough space in the device partition before
       * storing something there.
       */
      abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
! 	abp->f_ffree = 0x7fffffff;
  
      if (abp != sysstat) {
          abp->f_fsid.val[0] = sysstat->f_fsid.val[0];
Index: openafs/src/afs/FBSD/osi_file.c
diff -c openafs/src/afs/FBSD/osi_file.c:1.13.2.2 openafs/src/afs/FBSD/osi_file.c:1.13.2.3
*** openafs/src/afs/FBSD/osi_file.c:1.13.2.2	Thu Dec 13 14:18:50 2007
--- openafs/src/afs/FBSD/osi_file.c	Tue Aug 26 10:02:14 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_file.c,v 1.13.2.2 2007/12/13 19:18:50 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_file.c,v 1.13.2.3 2008/08/26 14:02:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 50,56 ****
  	osi_FreeSmallSpace(afile);
  	osi_Panic("UFSOpen: igetinode failed");
      }
! #if defined(AFS_FBSD50_ENV)
      VOP_UNLOCK(vp, 0, curthread);
  #else
      VOP_UNLOCK(vp, 0, curproc);
--- 50,58 ----
  	osi_FreeSmallSpace(afile);
  	osi_Panic("UFSOpen: igetinode failed");
      }
! #if defined(AFS_FBSD80_ENV)
!     VOP_UNLOCK(vp, 0);
! #elif defined(AFS_FBSD50_ENV)
      VOP_UNLOCK(vp, 0, curthread);
  #else
      VOP_UNLOCK(vp, 0, curproc);
***************
*** 71,77 ****
      AFS_STATCNT(osi_Stat);
      MObtainWriteLock(&afs_xosi, 320);
      AFS_GUNLOCK();
! #if defined(AFS_FBSD50_ENV)
      vn_lock(afile->vnode, LK_EXCLUSIVE | LK_RETRY, curthread);
      code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
      VOP_UNLOCK(afile->vnode, LK_EXCLUSIVE, curthread);
--- 73,83 ----
      AFS_STATCNT(osi_Stat);
      MObtainWriteLock(&afs_xosi, 320);
      AFS_GUNLOCK();
! #if defined(AFS_FBSD80_ENV)
!     vn_lock(afile->vnode, LK_EXCLUSIVE | LK_RETRY);
!     code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
!     VOP_UNLOCK(afile->vnode, 0);
! #elif defined(AFS_FBSD50_ENV)
      vn_lock(afile->vnode, LK_EXCLUSIVE | LK_RETRY, curthread);
      code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
      VOP_UNLOCK(afile->vnode, LK_EXCLUSIVE, curthread);
***************
*** 105,111 ****
  {
      struct vattr tvattr;
      struct vnode *vp;
!     register afs_int32 code;
      AFS_STATCNT(osi_Truncate);
  
      MObtainWriteLock(&afs_xosi, 321);
--- 111,117 ----
  {
      struct vattr tvattr;
      struct vnode *vp;
!     register afs_int32 code, glocked;
      AFS_STATCNT(osi_Truncate);
  
      MObtainWriteLock(&afs_xosi, 321);
***************
*** 115,122 ****
       * have very slow truncates, even when the file is already
       * small enough.  Check now and save some time.
       */
!     AFS_GUNLOCK();
! #if defined(AFS_FBSD50_ENV)
      vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
      code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
  #else
--- 121,133 ----
       * have very slow truncates, even when the file is already
       * small enough.  Check now and save some time.
       */
!     glocked = ISAFS_GLOCK();
!     if (glocked)
!       AFS_GUNLOCK();
! #if defined(AFS_FBSD80_ENV)
!     vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
!     code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
! #elif defined(AFS_FBSD50_ENV)
      vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
      code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
  #else
***************
*** 135,146 ****
  #endif
  
  out:
! #if defined(AFS_FBSD50_ENV)
      VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
  #else
      VOP_UNLOCK(vp, LK_EXCLUSIVE, curproc);
  #endif
!     AFS_GLOCK();
      MReleaseWriteLock(&afs_xosi);
      return code;
  }
--- 146,160 ----
  #endif
  
  out:
! #if defined(AFS_FBSD80_ENV)
!     VOP_UNLOCK(vp, 0);
! #elif defined(AFS_FBSD50_ENV)
      VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
  #else
      VOP_UNLOCK(vp, LK_EXCLUSIVE, curproc);
  #endif
!     if (glocked)
!       AFS_GLOCK();
      MReleaseWriteLock(&afs_xosi);
      return code;
  }
Index: openafs/src/afs/FBSD/osi_machdep.h
diff -c openafs/src/afs/FBSD/osi_machdep.h:1.9.2.6 openafs/src/afs/FBSD/osi_machdep.h:1.9.2.7
*** openafs/src/afs/FBSD/osi_machdep.h:1.9.2.6	Thu Nov  9 19:08:53 2006
--- openafs/src/afs/FBSD/osi_machdep.h	Tue Aug 26 10:02:14 2008
***************
*** 59,65 ****
  #undef afs_osi_Alloc_NoSleep
  #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
  
! #define VN_RELE(vp)		vrele(vp)
  #define VN_HOLD(vp)		VREF(vp)
  
  #ifdef AFS_FBSD60_ENV
--- 59,72 ----
  #undef afs_osi_Alloc_NoSleep
  #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
  
! #ifdef AFS_FBSD80_ENV
! #define VN_RELE(vp)				\
!   do {						\
!     vrele(vp);					\
!   } while(0);
! #else
! #define VN_RELE(vp)             vrele(vp)
! #endif
  #define VN_HOLD(vp)		VREF(vp)
  
  #ifdef AFS_FBSD60_ENV
***************
*** 84,93 ****
  #define AFS_GLOCK() mtx_lock(&afs_global_mtx)
  #define AFS_GUNLOCK() mtx_unlock(&afs_global_mtx)
  #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
- 
  #else /* FBSD50 */
  extern struct lock afs_global_lock;
- 
  #define osi_curcred()	(curproc->p_cred->pc_ucred)
  #define afs_suser(x)	(!suser(curproc))
  #define osi_getpid()	(curproc->p_pid)
--- 91,98 ----
Index: openafs/src/afs/FBSD/osi_misc.c
diff -c openafs/src/afs/FBSD/osi_misc.c:1.9.2.1 openafs/src/afs/FBSD/osi_misc.c:1.9.2.2
*** openafs/src/afs/FBSD/osi_misc.c:1.9.2.1	Fri Mar 11 01:50:37 2005
--- openafs/src/afs/FBSD/osi_misc.c	Tue Aug 26 10:02:14 2008
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_misc.c,v 1.9.2.1 2005/03/11 06:50:37 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_misc.c,v 1.9.2.2 2008/08/26 14:02:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 35,46 ****
  	       struct vnode **vpp)
  {
      struct nameidata n;
!     int flags, error, wasowned;
  
  #ifdef AFS_FBSD50_ENV
!     wasowned = mtx_owned(&afs_global_mtx);
!     if (wasowned)
! 	mtx_unlock(&afs_global_mtx);
  #endif
  
      flags = 0;
--- 35,46 ----
  	       struct vnode **vpp)
  {
      struct nameidata n;
!     int flags, error, glocked;
  
  #ifdef AFS_FBSD50_ENV
!     glocked = ISAFS_GLOCK();
!     if (glocked)
! 	AFS_GUNLOCK();
  #endif
  
      flags = 0;
***************
*** 49,69 ****
  	flags |= FOLLOW;
      else
  	flags |= NOFOLLOW;
      NDINIT(&n, LOOKUP, flags, seg, aname, curproc);
      if ((error = namei(&n)) != 0) {
  #ifdef AFS_FBSD50_ENV
! 	if (wasowned)
! 	    mtx_lock(&afs_global_mtx);
  #endif
  	return error;
      }
      *vpp = n.ni_vp;
!     /* should we do this? */
      VOP_UNLOCK(n.ni_vp, 0, curproc);
      NDFREE(&n, NDF_ONLY_PNBUF);
  #ifdef AFS_FBSD50_ENV
!     if (wasowned)
! 	mtx_lock(&afs_global_mtx);
  #endif
      return 0;
  }
--- 49,78 ----
  	flags |= FOLLOW;
      else
  	flags |= NOFOLLOW;
+ #ifdef AFS_FBSD80_ENV
+     flags |= MPSAFE; /* namei must take GIANT if needed */
+ #endif
      NDINIT(&n, LOOKUP, flags, seg, aname, curproc);
      if ((error = namei(&n)) != 0) {
  #ifdef AFS_FBSD50_ENV
! 	if (glocked)
! 	    AFS_GLOCK();
  #endif
  	return error;
      }
      *vpp = n.ni_vp;
!     /* XXX should we do this?  Usually NOT (matt) */
! #if defined(AFS_FBSD80_ENV)
!     /*VOP_UNLOCK(n.ni_vp, 0);*/
! #elif defined(AFS_FBSD50_ENV)
!     VOP_UNLOCK(n.ni_vp, 0, curthread);
! #else
      VOP_UNLOCK(n.ni_vp, 0, curproc);
+ #endif
      NDFREE(&n, NDF_ONLY_PNBUF);
  #ifdef AFS_FBSD50_ENV
!     if (glocked)
! 	AFS_GLOCK();
  #endif
      return 0;
  }
***************
*** 105,122 ****
  {
  	void *rv;
  #ifdef AFS_FBSD50_ENV
! 	int wasowned;
  
  	if (dropglobal) {
! 		wasowned = mtx_owned(&afs_global_mtx);
! 		if (wasowned)
! 			mtx_unlock(&afs_global_mtx);
! 		rv = malloc(size, M_AFS, M_WAITOK);
! 		if (wasowned)
! 			mtx_lock(&afs_global_mtx);
  	} else
  #endif
! 		rv = malloc(size, M_AFS, M_NOWAIT);
  
  	return (rv);
  }
--- 114,131 ----
  {
  	void *rv;
  #ifdef AFS_FBSD50_ENV
! 	int glocked;
  
  	if (dropglobal) {
! 	    glocked = ISAFS_GLOCK();
! 	    if (glocked)
! 		AFS_GUNLOCK();
! 	    rv = malloc(size, M_AFS, M_WAITOK);
! 	    if (glocked)
! 		AFS_GLOCK();
  	} else
  #endif
! 	    rv = malloc(size, M_AFS, M_NOWAIT);
  
  	return (rv);
  }
***************
*** 124,169 ****
  void
  osi_fbsd_free(void *p)
  {
! 
! 	free(p, M_AFS);
! }
! 
! void
! osi_AllocMoreSSpace(afs_int32 preallocs)
! {
! 	;
! }
! 
! void
! osi_FreeLargeSpace(void *p)
! {
! 	osi_fbsd_free(p);
! }
! 
! void
! osi_FreeSmallSpace(void *p)
! {
! 	osi_fbsd_free(p);
! }
! 
! void *
! osi_AllocLargeSpace(size_t size)
! {
! 	AFS_ASSERT_GLOCK();
! 	AFS_STATCNT(osi_AllocLargeSpace);
! 	return (osi_fbsd_alloc(size, 1));
! }
! 
! void *
! osi_AllocSmallSpace(size_t size)
! {
! 	AFS_ASSERT_GLOCK();
! 	AFS_STATCNT(osi_AllocSmallSpace);
! 	return (osi_fbsd_alloc(size, 1));
! }
! 
! void
! shutdown_osinet(void)
! {
! 	;
  }
--- 133,137 ----
  void
  osi_fbsd_free(void *p)
  {
!        free(p, M_AFS);
  }
Index: openafs/src/afs/FBSD/osi_vfsops.c
diff -c openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.5 openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.6
*** openafs/src/afs/FBSD/osi_vfsops.c:1.16.2.5	Mon Jul 11 15:27:27 2005
--- openafs/src/afs/FBSD/osi_vfsops.c	Tue Aug 26 10:02:14 2008
***************
*** 2,8 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vfsops.c,v 1.16.2.5 2005/07/11 19:27:27 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 2,8 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vfsops.c,v 1.16.2.6 2008/08/26 14:02:14 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 98,103 ****
--- 98,108 ----
      afs_globalVFS = mp;
      mp->vfs_bsize = 8192;
      vfs_getnewfsid(mp);
+ #ifdef AFS_FBSD70_ENV /* XXX 70? */
+     MNT_ILOCK(mp);
+     mp->mnt_flag &= ~MNT_LOCAL;
+     mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
+ #endif
      mp->mnt_stat.f_iosize = 8192;
  
      if (path != NULL)
***************
*** 109,116 ****
--- 114,125 ----
      strcpy(mp->mnt_stat.f_mntfromname, "AFS");
      /* null terminated string "AFS" will fit, just leave it be. */
      strcpy(mp->mnt_stat.f_fstypename, "afs");
+ #ifdef AFS_FBSD70_ENV
+     MNT_IUNLOCK(mp);
+ #endif
      AFS_GUNLOCK();
      afs_statfs(mp, &mp->mnt_stat, p);
+ 
      return 0;
  }
  
***************
*** 140,146 ****
       * the root vnode (this is just a guess right now).
       * This has to be done outside the global lock.
       */
! #ifdef AFS_FBSD53_ENV
      vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
  #else
      vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
--- 149,157 ----
       * the root vnode (this is just a guess right now).
       * This has to be done outside the global lock.
       */
! #if defined(AFS_FBSD80_ENV)
!   /* do nothing */
! #elif defined(AFS_FBSD53_ENV)
      vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
  #else
      vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
***************
*** 184,195 ****
  	error = 0;
      } else {
  tryagain:
  	if (afs_globalVp) {
  	    afs_PutVCache(afs_globalVp);
  	    /* vrele() needed here or not? */
  	    afs_globalVp = NULL;
  	}
! 
  	if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
  	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
  	    /* we really want this to stay around */
--- 195,207 ----
  	error = 0;
      } else {
  tryagain:
+ #ifndef AFS_FBSD80_ENV
  	if (afs_globalVp) {
  	    afs_PutVCache(afs_globalVp);
  	    /* vrele() needed here or not? */
  	    afs_globalVp = NULL;
  	}
! #endif
  	if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
  	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
  	    /* we really want this to stay around */
Index: openafs/src/afs/FBSD/osi_vm.c
diff -c openafs/src/afs/FBSD/osi_vm.c:1.11.2.2 openafs/src/afs/FBSD/osi_vm.c:1.11.2.3
*** openafs/src/afs/FBSD/osi_vm.c:1.11.2.2	Mon May 23 17:23:53 2005
--- openafs/src/afs/FBSD/osi_vm.c	Tue Aug 26 10:02:14 2008
***************
*** 20,28 ****
  
  #include <afsconfig.h>
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vm.c,v 1.11.2.2 2005/05/23 21:23:53 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 20,34 ----
  
  #include <afsconfig.h>
  #include "afs/param.h"
+ #ifdef AFS_FBSD70_ENV
+ #include <sys/param.h>
+ #include <sys/vnode.h>
+      void
+      vgonel(struct vnode *vp, struct thread *td);
+ #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vm.c,v 1.11.2.3 2008/08/26 14:02:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 52,58 ****
  #define VOP_GETVOBJECT(vp, objp) (*(objp) = (vp)->v_object)
  #endif
  
! #ifdef AFS_FBSD50_ENV
  #define	lock_vnode(v)	vn_lock((v), LK_EXCLUSIVE | LK_RETRY, curthread)
  #define unlock_vnode(v)	VOP_UNLOCK((v), 0, curthread)
  #else
--- 58,67 ----
  #define VOP_GETVOBJECT(vp, objp) (*(objp) = (vp)->v_object)
  #endif
  
! #if defined(AFS_FBSD80_ENV)
! #define	lock_vnode(v)	vn_lock((v), LK_EXCLUSIVE | LK_RETRY)
! #define unlock_vnode(v)	VOP_UNLOCK((v), 0)
! #elif defined(AFS_FBSD50_ENV)
  #define	lock_vnode(v)	vn_lock((v), LK_EXCLUSIVE | LK_RETRY, curthread)
  #define unlock_vnode(v)	VOP_UNLOCK((v), 0, curthread)
  #else
***************
*** 96,118 ****
      if (CheckLock(&avc->lock))
  	return EBUSY;
  
      AFS_GUNLOCK();
      vp = AFSTOV(avc);
      lock_vnode(vp);
      if (VOP_GETVOBJECT(vp, &obj) == 0) {
  	VM_OBJECT_LOCK(obj);
  	vm_object_page_remove(obj, 0, 0, FALSE);
! #if 0
  	if (obj->ref_count == 0) {
- 	    vgonel(vp, curproc);
  	    simple_lock(&vp->v_interlock);
  	    vp->v_tag = VT_AFS;
  	    SetAfsVnode(vp);
  	}
  #endif
  	VM_OBJECT_UNLOCK(obj);
      }
      unlock_vnode(vp);
      AFS_GLOCK();
  
      return 0;
--- 105,133 ----
      if (CheckLock(&avc->lock))
  	return EBUSY;
  
+     return(0);
+ 
      AFS_GUNLOCK();
      vp = AFSTOV(avc);
+ #ifndef AFS_FBSD70_ENV
      lock_vnode(vp);
+ #endif
      if (VOP_GETVOBJECT(vp, &obj) == 0) {
  	VM_OBJECT_LOCK(obj);
  	vm_object_page_remove(obj, 0, 0, FALSE);
! #if 1
  	if (obj->ref_count == 0) {
  	    simple_lock(&vp->v_interlock);
+ 	    vgonel(vp, curthread);
  	    vp->v_tag = VT_AFS;
  	    SetAfsVnode(vp);
  	}
  #endif
  	VM_OBJECT_UNLOCK(obj);
      }
+ #ifndef AFS_FBSD70_ENV
      unlock_vnode(vp);
+ #endif
      AFS_GLOCK();
  
      return 0;
***************
*** 146,170 ****
       */
      do {
  	anyio = 0;
  	lock_vnode(vp);
  	if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) {
! 	    /* XXX - obj locking? */
  	    unlock_vnode(vp);
  #ifdef AFS_FBSD50_ENV
  	    if (!vget(vp, LK_EXCLUSIVE | LK_RETRY, curthread)) {
  #else
! 	    if (!vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) {
  #endif
! 		if (VOP_GETVOBJECT(vp, &obj) == 0) {
! 		    VM_OBJECT_LOCK(obj);
! 		    vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
! 		    VM_OBJECT_UNLOCK(obj);
! 		    anyio = 1;
  		}
- 		vput(vp);
  	    }
! 	} else
! 	    unlock_vnode(vp);
      } while (anyio && (--tries > 0));
      AFS_GLOCK();
      ObtainWriteLock(&avc->lock, 94);
--- 161,191 ----
       */
      do {
  	anyio = 0;
+ #ifdef AFS_FBSD80_ENV
  	lock_vnode(vp);
+ #endif
  	if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) {
! #ifdef AFS_FBSD80_ENV
  	    unlock_vnode(vp);
+ #endif
  #ifdef AFS_FBSD50_ENV
  	    if (!vget(vp, LK_EXCLUSIVE | LK_RETRY, curthread)) {
  #else
! 		if (!vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) {
  #endif
! 		    if (VOP_GETVOBJECT(vp, &obj) == 0) {
! 			VM_OBJECT_LOCK(obj);
! 			vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
! 			VM_OBJECT_UNLOCK(obj);
! 			anyio = 1;
! 		    }
! 		    vput(vp);
  		}
  	    }
! #ifdef AFS_FBSD80_ENV
! 	    else
! 		unlock_vnode(vp);
! #endif
      } while (anyio && (--tries > 0));
      AFS_GLOCK();
      ObtainWriteLock(&avc->lock, 94);
***************
*** 184,235 ****
  {
      struct vnode *vp;
      struct vm_object *obj;
!     int anyio, tries;
  
-     ReleaseWriteLock(&avc->lock);
-     AFS_GUNLOCK();
-     tries = 5;
      vp = AFSTOV(avc);
!     do {
! 	anyio = 0;
! 	lock_vnode(vp);
! 	/* See the comments above. */
! 	if (VOP_GETVOBJECT(vp, &obj) == 0 && (obj->flags & OBJ_MIGHTBEDIRTY)) {
! 	    /* XXX - obj locking */
! 	    unlock_vnode(vp);
! #ifdef AFS_FBSD50_ENV
! 	    if (!vget(vp, LK_EXCLUSIVE | LK_RETRY, curthread)) {
! #else
! 	    if (!vget(vp, LK_EXCLUSIVE | LK_RETRY | LK_NOOBJ, curproc)) {
! #endif
! 		if (VOP_GETVOBJECT(vp, &obj) == 0) {
! 		    VM_OBJECT_LOCK(obj);
! 		    /*
! 		     * Do we really want OBJPC_SYNC?  OBJPC_INVAL would be
! 		     * faster, if invalidation is really what we are being
! 		     * asked to do.  (It would make more sense, too, since
! 		     * otherwise this function is practically identical to
! 		     * osi_VM_StoreAllSegments().)  -GAW
! 		     */
! 		    vm_object_page_clean(obj, 0, 0, OBJPC_SYNC);
! 		    VM_OBJECT_UNLOCK(obj);
! 		    anyio = 1;
! 		}
! 		vput(vp);
! 	    }
! 	} else
! 	    unlock_vnode(vp);
!     } while (anyio && (--tries > 0));
!     lock_vnode(vp);
!     if (VOP_GETVOBJECT(vp, &obj) == 0) {
! 	VM_OBJECT_LOCK(obj);
! 	vm_object_page_remove(obj, 0, 0, FALSE);
! 	VM_OBJECT_UNLOCK(obj);
      }
!     unlock_vnode(vp);
!     /*vinvalbuf(AFSTOV(avc),0, NOCRED, curproc, 0,0); */
!     AFS_GLOCK();
!     ObtainWriteLock(&avc->lock, 59);
  }
  
  /* Purge VM for a file when its callback is revoked.
--- 205,248 ----
  {
      struct vnode *vp;
      struct vm_object *obj;
!     int anyio, tries, code;
! 
!     SPLVAR;
  
      vp = AFSTOV(avc);
! 
!     if (vp->v_iflag & VI_DOOMED) {
!       USERPRI;
!       return 0;
      }
! 
!     if (vp->v_bufobj.bo_object != NULL) {
!       VM_OBJECT_LOCK(vp->v_bufobj.bo_object);
!       /*
!        * Do we really want OBJPC_SYNC?  OBJPC_INVAL would be
!        * faster, if invalidation is really what we are being
!        * asked to do.  (It would make more sense, too, since
!        * otherwise this function is practically identical to
!        * osi_VM_StoreAllSegments().)  -GAW
!        */
! 
!       /*
!        * Dunno.  We no longer resemble osi_VM_StoreAllSegments,
!        * though maybe that's wrong, now.  And OBJPC_SYNC is the
!        * common thing in 70 file systems, it seems.  Matt.
!        */
! 
!       vm_object_page_clean(vp->v_bufobj.bo_object, 0, 0, OBJPC_SYNC);
!       VM_OBJECT_UNLOCK(vp->v_bufobj.bo_object);
!     }
! 
!     tries = 5;
!     code = vinvalbuf(vp, V_SAVE, curthread, PCATCH, 0);
!     while (code && (tries > 0)) {
!       code = vinvalbuf(vp, V_SAVE, curthread, PCATCH, 0);
!       --tries;
!     }
!     USERPRI;
  }
  
  /* Purge VM for a file when its callback is revoked.
Index: openafs/src/afs/FBSD/osi_vnodeops.c
diff -c openafs/src/afs/FBSD/osi_vnodeops.c:1.18.2.4 openafs/src/afs/FBSD/osi_vnodeops.c:1.18.2.5
*** openafs/src/afs/FBSD/osi_vnodeops.c:1.18.2.4	Mon May 23 17:26:40 2005
--- openafs/src/afs/FBSD/osi_vnodeops.c	Tue Aug 26 10:02:14 2008
***************
*** 48,54 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vnodeops.c,v 1.18.2.4 2005/05/23 21:26:40 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
--- 48,54 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/FBSD/osi_vnodeops.c,v 1.18.2.5 2008/08/26 14:02:14 shadow Exp $");
  
  #include <afs/sysincludes.h>	/* Standard vendor system headers */
  #include <afsincludes.h>	/* Afs-based standard headers */
***************
*** 95,100 ****
--- 95,105 ----
  static vop_strategy_t	afs_vop_strategy;
  static vop_symlink_t	afs_vop_symlink;
  static vop_write_t	afs_vop_write;
+ #if defined(AFS_FBSD70_ENV) && !defined(AFS_FBSD90_ENV)
+ static vop_lock1_t      afs_vop_lock;
+ static vop_unlock_t     afs_vop_unlock;
+ static vop_islocked_t   afs_vop_islocked;
+ #endif
  
  struct vop_vector afs_vnodeops = {
  	.vop_default =		&default_vnodeops,
***************
*** 128,133 ****
--- 133,143 ----
  	.vop_strategy =		afs_vop_strategy,
  	.vop_symlink =		afs_vop_symlink,
  	.vop_write =		afs_vop_write,
+ #if defined(AFS_FBSD70_ENV) && !defined(AFS_FBSD90_ENV)
+ 	.vop_lock1 =            afs_vop_lock,
+ 	.vop_unlock =           afs_vop_unlock,
+ 	.vop_islocked =         afs_vop_islocked,
+ #endif
  };
  
  #else /* AFS_FBSD60_ENV */
***************
*** 213,218 ****
--- 223,233 ----
      {&vop_write_desc, (vop_t *) afs_vop_write},	/* write */
      {&vop_ioctl_desc, (vop_t *) afs_vop_ioctl},	/* XXX ioctl */
      /*{ &vop_seek_desc, afs_vop_seek }, *//* seek */
+ #if defined(AFS_FBSD70_ENV) && !defined(AFS_FBSD90_ENV)
+     {&vop_lock1_desc, (vop_t *) afs_vop_lock}, /* lock */
+     {&vop_unlock_desc, (vop_t *) afs_vop_unlock}, /* unlock */
+     {&vop_islocked_desc, (vop_t *) afs_vop_islocked}, /* islocked */
+ #endif
      {NULL, NULL}
  };
  struct vnodeopv_desc afs_vnodeop_opv_desc =
***************
*** 233,238 ****
--- 248,370 ----
  #define a_p a_td
  #endif
  
+ #if defined(AFS_FBSD80_ENV)
+ #define ma_vn_lock(vp, flags, p) (vn_lock(vp, flags))
+ #define MA_VOP_LOCK(vp, flags, p) (VOP_LOCK(vp, flags))
+ #define MA_VOP_UNLOCK(vp, flags, p) (VOP_UNLOCK(vp, flags))
+ #else
+ #define ma_vn_lock(vp, flags, p) (vn_lock(vp, flags, p))
+ #define MA_VOP_LOCK(vp, flags, p) (VOP_LOCK(vp, flags, p))
+ #define MA_VOP_UNLOCK(vp, flags, p) (VOP_UNLOCK(vp, flags, p))
+ #endif
+ 
+ #ifdef AFS_FBSD70_ENV
+ #ifndef AFS_FBSD80_ENV
+ /* From kern_lock.c */
+ #define	COUNT(td, x)	if ((td)) (td)->td_locks += (x)
+ #define LK_ALL (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE | \
+ 	LK_SHARE_NONZERO | LK_WAIT_NONZERO)
+ 
+ static __inline void
+ sharelock(struct thread *td, struct lock *lkp, int incr) {
+ 	lkp->lk_flags |= LK_SHARE_NONZERO;
+ 	lkp->lk_sharecount += incr;
+ 	COUNT(td, incr);
+ }
+ #endif
+ 
+ /*
+  * Standard lock, unlock and islocked functions.
+  */
+ int
+ afs_vop_lock(ap)
+     struct vop_lock1_args /* {
+ 			     struct vnode *a_vp;
+ 			     int a_flags;
+ 			     struct thread *a_td;
+ 			     char *file;
+ 			     int line;
+ 			     } */ *ap;
+ {
+     struct vnode *vp = ap->a_vp;
+     struct lock *lkp = vp->v_vnlock;
+ 
+ #if 0 && defined(AFS_FBSD80_ENV) && !defined(UKERNEL)
+     afs_warn("afs_vop_lock: tid %d pid %d \"%s\"\n", curthread->td_tid,
+ 	     curthread->td_proc->p_pid, curthread->td_name);
+     kdb_backtrace();
+ #endif
+ 
+ #ifdef AFS_FBSD80_ENV
+     return (_lockmgr_args(lkp, ap->a_flags, VI_MTX(vp),
+ 			  LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT,
+ 			  ap->a_file, ap->a_line));
+ #else
+     return (_lockmgr(lkp, ap->a_flags, VI_MTX(vp), ap->a_td, ap->a_file, ap->a_line));
+ #endif
+ }
+ 
+ /* See above. */
+ int
+ afs_vop_unlock(ap)
+     struct vop_unlock_args /* {
+ 			      struct vnode *a_vp;
+ 			      int a_flags;
+ 			      struct thread *a_td;
+ 			      } */ *ap;
+ {
+     struct vnode *vp = ap->a_vp;
+     struct lock *lkp = vp->v_vnlock;
+ 
+ #ifdef AFS_FBSD80_ENV
+     int code;
+     u_int op;
+     op = ((ap->a_flags) | LK_RELEASE) & LK_TYPE_MASK;
+     int glocked = ISAFS_GLOCK();
+     if (glocked)
+ 	AFS_GUNLOCK();
+     if ((op & (op - 1)) != 0) {
+       afs_warn("afs_vop_unlock: Shit.\n");
+       goto done;
+     }
+     code = lockmgr(lkp, ap->a_flags | LK_RELEASE, VI_MTX(vp));
+  done:
+     if (glocked)
+ 	AFS_GLOCK();
+     return(code);
+ #else
+     /* possibly in current code path where this
+      * forces trace, we should have had a (shared? not
+      * necessarily, see _lockmgr in kern_lock.c) lock
+      * and that's the real bug.  but. 
+      */
+     critical_enter();
+     if ((lkp->lk_exclusivecount == 0) &&
+ 	(!(lkp->lk_flags & LK_SHARE_NONZERO))) {
+ 	sharelock(ap->a_td, lkp, 1);
+     }
+     critical_exit();
+     return (lockmgr(lkp, ap->a_flags | LK_RELEASE, VI_MTX(vp),
+ 		    ap->a_td));
+ #endif
+ }
+ 
+ /* See above. */
+ int
+ afs_vop_islocked(ap)
+     struct vop_islocked_args /* {
+ 				struct vnode *a_vp;
+ 				struct thread *a_td; (not in 80)
+ 				} */ *ap;
+ {
+ #ifdef AFS_FBSD80_ENV
+     return (lockstatus(ap->a_vp->v_vnlock));
+ #else
+     return (lockstatus(ap->a_vp->v_vnlock, ap->a_td));
+ #endif
+ }
+ #endif /* 70 */
+ 
  /*
   * Mosty copied from sys/ufs/ufs/ufs_vnops.c:ufs_pathconf().
   * We should know the correct answers to these questions with
***************
*** 346,370 ****
  #else
      struct proc *p = ap->a_cnp->cn_proc;
  #endif
      GETNAME();
  
      lockparent = flags & LOCKPARENT;
      wantparent = flags & (LOCKPARENT | WANTPARENT);
  
!     if (ap->a_dvp->v_type != VDIR) {
! 	*ap->a_vpp = 0;
! 	DROPNAME();
! 	return ENOTDIR;
!     }
!     dvp = ap->a_dvp;
      if (flags & ISDOTDOT)
  	VOP_UNLOCK(dvp, 0, p);
      AFS_GLOCK();
      error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
      AFS_GUNLOCK();
      if (error) {
  	if (flags & ISDOTDOT)
! 	    VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
  	if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
  	    && (flags & ISLASTCN) && error == ENOENT)
  	    error = EJUSTRETURN;
--- 478,516 ----
  #else
      struct proc *p = ap->a_cnp->cn_proc;
  #endif
+ 
+     dvp = ap->a_dvp;
+     if (dvp->v_type != VDIR) {
+ #ifndef AFS_FBSD70_ENV
+ 	*ap->a_vpp = 0;
+ #endif
+ 	return ENOTDIR;
+     }
+ 
+     if ((flags & ISDOTDOT) && (dvp->v_vflag & VV_ROOT))
+ 	return EIO;
+ 
      GETNAME();
  
      lockparent = flags & LOCKPARENT;
      wantparent = flags & (LOCKPARENT | WANTPARENT);
  
! #ifdef AFS_FBSD80_ENV
!     cnp->cn_flags |= MPSAFE; /* steel */
! #endif
! 
! #ifndef AFS_FBSD70_ENV
      if (flags & ISDOTDOT)
  	VOP_UNLOCK(dvp, 0, p);
+ #endif
+ 
      AFS_GLOCK();
      error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
      AFS_GUNLOCK();
+ 
      if (error) {
  	if (flags & ISDOTDOT)
! 	    MA_VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
  	if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
  	    && (flags & ISLASTCN) && error == ENOENT)
  	    error = EJUSTRETURN;
***************
*** 381,390 ****
       * we also always return the vnode locked. */
  
      if (flags & ISDOTDOT) {
! 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
  	/* always return the child locked */
  	if (lockparent && (flags & ISLASTCN)
! 	    && (error = vn_lock(dvp, LK_EXCLUSIVE, p))) {
  	    vput(vp);
  	    DROPNAME();
  	    return (error);
--- 527,536 ----
       * we also always return the vnode locked. */
  
      if (flags & ISDOTDOT) {
! 	ma_vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
  	/* always return the child locked */
  	if (lockparent && (flags & ISLASTCN)
! 	    && (error = ma_vn_lock(dvp, LK_EXCLUSIVE, p))) {
  	    vput(vp);
  	    DROPNAME();
  	    return (error);
***************
*** 393,401 ****
  	/* they're the same; afs_lookup() already ref'ed the leaf.
  	 * It came in locked, so we don't need to ref OR lock it */
      } else {
! 	if (!lockparent || !(flags & ISLASTCN))
! 	    VOP_UNLOCK(dvp, 0, p);	/* done with parent. */
! 	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
  	/* always return the child locked */
      }
      *ap->a_vpp = vp;
--- 539,550 ----
  	/* they're the same; afs_lookup() already ref'ed the leaf.
  	 * It came in locked, so we don't need to ref OR lock it */
      } else {
! 	if (!lockparent || !(flags & ISLASTCN)) {
! #ifndef AFS_FBSD70_ENV /* 6 too? */
! 	    MA_VOP_UNLOCK(dvp, 0, p);	/* done with parent. */
! #endif
! 	}
! 	ma_vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
  	/* always return the child locked */
      }
      *ap->a_vpp = vp;
***************
*** 440,446 ****
  
      if (vcp) {
  	*ap->a_vpp = AFSTOV(vcp);
! 	vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p);
      } else
  	*ap->a_vpp = 0;
  
--- 589,595 ----
  
      if (vcp) {
  	*ap->a_vpp = AFSTOV(vcp);
! 	ma_vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p);
      } else
  	*ap->a_vpp = 0;
  
***************
*** 746,752 ****
  	     * now tell them that it is ok to use.
  	     */
  	    if (!code) {
! 		if (m->flags & PG_WANTED)
  		    vm_page_activate(m);
  		else
  		    vm_page_deactivate(m);
--- 895,905 ----
  	     * now tell them that it is ok to use.
  	     */
  	    if (!code) {
! #if defined(AFS_FBSD70_ENV)
! 		if (m->oflags & VPO_WANTED)
! #else
! 	        if (m->flags & PG_WANTED)
! #endif
  		    vm_page_activate(m);
  		else
  		    vm_page_deactivate(m);
***************
*** 1008,1021 ****
  	error = EISDIR;
  	goto out;
      }
!     if ((error = vn_lock(vp, LK_EXCLUSIVE, p)) != 0) {
  	goto out;
      }
      AFS_GLOCK();
      error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
      AFS_GUNLOCK();
      if (dvp != vp)
! 	VOP_UNLOCK(vp, 0, p);
    out:
      DROPNAME();
      return error;
--- 1161,1174 ----
  	error = EISDIR;
  	goto out;
      }
!     if ((error = ma_vn_lock(vp, LK_EXCLUSIVE, p)) != 0) {
  	goto out;
      }
      AFS_GLOCK();
      error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
      AFS_GUNLOCK();
      if (dvp != vp)
! 	MA_VOP_UNLOCK(vp, 0, p);
    out:
      DROPNAME();
      return error;
***************
*** 1104,1110 ****
  	vput(fvp);
  	return (error);
      }
!     if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0)
  	goto abortit;
  
      MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
--- 1257,1263 ----
  	vput(fvp);
  	return (error);
      }
!     if ((error = ma_vn_lock(fvp, LK_EXCLUSIVE, p)) != 0)
  	goto abortit;
  
      MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
***************
*** 1167,1173 ****
      }
      if (vcp) {
  	*ap->a_vpp = AFSTOV(vcp);
! 	vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p);
      } else
  	*ap->a_vpp = 0;
      DROPNAME();
--- 1320,1326 ----
      }
      if (vcp) {
  	*ap->a_vpp = AFSTOV(vcp);
! 	ma_vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p);
      } else
  	*ap->a_vpp = 0;
      DROPNAME();
***************
*** 1222,1230 ****
  	if (error == 0) {
  	    newvp = AFSTOV(vcp);
  #ifdef AFS_FBSD50_ENV
! 	    vn_lock(newvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_thread);
  #else
! 	    vn_lock(newvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_proc);
  #endif
  	}
      }
--- 1375,1383 ----
  	if (error == 0) {
  	    newvp = AFSTOV(vcp);
  #ifdef AFS_FBSD50_ENV
! 	    ma_vn_lock(newvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_thread);
  #else
! 	    ma_vn_lock(newvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_proc);
  #endif
  	}
      }
***************
*** 1317,1323 ****
      AFS_GLOCK();
      afs_InactiveVCache(VTOAFS(vp), 0);	/* decrs ref counts */
      AFS_GUNLOCK();
!     VOP_UNLOCK(vp, 0, ap->a_p);
      return 0;
  }
  
--- 1470,1478 ----
      AFS_GLOCK();
      afs_InactiveVCache(VTOAFS(vp), 0);	/* decrs ref counts */
      AFS_GUNLOCK();
! #ifndef AFS_FBSD80_ENV
!     MA_VOP_UNLOCK(vp, 0, ap->a_p);
! #endif
      return 0;
  }
  
***************
*** 1358,1365 ****
      if (code)
  	printf("afs_vop_reclaim: afs_FlushVCache failed code %d\n", code);
  #ifdef AFS_FBSD60_ENV
!     else
  	vnode_destroy_vobject(vp);
  #endif
      return 0;
  }
--- 1513,1525 ----
      if (code)
  	printf("afs_vop_reclaim: afs_FlushVCache failed code %d\n", code);
  #ifdef AFS_FBSD60_ENV
!     else {
  	vnode_destroy_vobject(vp);
+ #ifndef AFS_FBSD70_ENV
+ 	vfs_hash_remove(vp);
+ #endif
+ 	vp->v_data = 0;
+     }
  #endif
      return 0;
  }
Index: openafs/src/afs/IRIX/osi_machdep.h
diff -c openafs/src/afs/IRIX/osi_machdep.h:1.7.2.5 openafs/src/afs/IRIX/osi_machdep.h:1.7.2.6
*** openafs/src/afs/IRIX/osi_machdep.h:1.7.2.5	Thu Nov  9 19:08:54 2006
--- openafs/src/afs/IRIX/osi_machdep.h	Tue Jul  1 16:57:22 2008
***************
*** 29,34 ****
--- 29,37 ----
  /* This gets redefined from ucred to cred in osi_vfs.h, just do it right */
  #define	AFS_UCRED	cred
  
+ #undef gop_lookupname
+ #define gop_lookupname(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),NULL,(compvpp), NULL)
+ 
  #define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
  
  #undef afs_osi_Alloc_NoSleep
Index: openafs/src/afs/LINUX/osi_groups.c
diff -c openafs/src/afs/LINUX/osi_groups.c:1.25.2.15 openafs/src/afs/LINUX/osi_groups.c:1.25.2.16
*** openafs/src/afs/LINUX/osi_groups.c:1.25.2.15	Sat Apr 19 17:56:11 2008
--- openafs/src/afs/LINUX/osi_groups.c	Sun Jun  8 23:39:44 2008
***************
*** 20,26 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.15 2008/04/19 21:56:11 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 20,26 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.16 2008/06/09 03:39:44 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 646,652 ****
--- 646,656 ----
  #  endif
  	    rcu_read_lock();
  # endif
+ #if defined(EXPORTED_FIND_TASK_BY_PID)
  	p = find_task_by_pid(1);
+ #else
+ 	p = find_task_by_vpid(1);
+ #endif
  	if (p && p->user->session_keyring)
  	    __key_type_keyring = p->user->session_keyring->type;
  # ifdef EXPORTED_TASKLIST_LOCK
Index: openafs/src/afs/LINUX/osi_module.c
diff -c openafs/src/afs/LINUX/osi_module.c:1.52.2.29 openafs/src/afs/LINUX/osi_module.c:1.52.2.31
*** openafs/src/afs/LINUX/osi_module.c:1.52.2.29	Wed Oct 24 14:09:50 2007
--- openafs/src/afs/LINUX/osi_module.c	Fri Aug 22 15:17:02 2008
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.29 2007/10/24 18:09:50 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.31 2008/08/22 19:17:02 shadow Exp $");
  
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #include "afs/sysincludes.h"
***************
*** 237,244 ****
--- 237,252 ----
  {
      struct proc_dir_entry *entry1;
      struct proc_dir_entry *entry2;
+ #if !defined(EXPORTED_PROC_ROOT_FS)
+     char path[64];
+ #endif
  
+ #if defined(EXPORTED_PROC_ROOT_FS)
      openafs_procfs = proc_mkdir(PROC_FSDIRNAME, proc_root_fs);
+ #else
+     sprintf(path, "fs/%s", PROC_FSDIRNAME);
+     openafs_procfs = proc_mkdir(path, NULL);
+ #endif
      entry1 = create_proc_entry(PROC_SYSCALL_NAME, 0666, openafs_procfs);
  
      entry1->proc_fops = &afs_syscall_fops;
***************
*** 263,275 ****
  static void
  afsproc_exit(void)
  {
      remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs);
      remove_proc_entry(PROC_SYSCALL_NAME, openafs_procfs);
-     remove_proc_entry(PROC_FSDIRNAME, proc_root_fs);
  #if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
      if (ioctl32_done)
  	    unregister_ioctl32_conversion(VIOC_SYSCALL32);
  #endif
  }
  #endif
  
--- 271,292 ----
  static void
  afsproc_exit(void)
  {
+ #if !defined(EXPORTED_PROC_ROOT_FS)
+     char path[64];
+ #endif
+ 
      remove_proc_entry(PROC_CELLSERVDB_NAME, openafs_procfs);
      remove_proc_entry(PROC_SYSCALL_NAME, openafs_procfs);
  #if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
      if (ioctl32_done)
  	    unregister_ioctl32_conversion(VIOC_SYSCALL32);
  #endif
+ #if defined(EXPORTED_PROC_ROOT_FS)
+     remove_proc_entry(PROC_FSDIRNAME, proc_root_fs);
+ #else
+     sprintf(path, "fs/%s", PROC_FSDIRNAME);
+     remove_proc_entry(path, NULL);
+ #endif
  }
  #endif
  
Index: openafs/src/afs/LINUX/osi_probe.c
diff -c openafs/src/afs/LINUX/osi_probe.c:1.1.2.25 openafs/src/afs/LINUX/osi_probe.c:1.1.2.26
*** openafs/src/afs/LINUX/osi_probe.c:1.1.2.25	Sun Apr  6 23:19:40 2008
--- openafs/src/afs/LINUX/osi_probe.c	Thu Jul  3 16:33:25 2008
***************
*** 45,51 ****
  
  /* Code to find the Linux syscall table */
  
- #if defined(EXPORTED_INIT_MM)
  #ifdef OSI_PROBE_STANDALONE
  #define OSI_PROBE_DEBUG
  #endif
--- 45,50 ----
***************
*** 53,58 ****
--- 52,58 ----
  #include <afsconfig.h>
  #include "afs/param.h"
  #endif
+ #if defined(EXPORTED_INIT_MM)
  #ifdef AFS_LINUX24_ENV
  #include <linux/module.h> /* early to avoid printf->printk mapping */
  #ifndef OSI_PROBE_STANDALONE
Index: openafs/src/afs/LINUX/osi_vnodeops.c
diff -c openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.64 openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.69
*** openafs/src/afs/LINUX/osi_vnodeops.c:1.81.2.64	Tue Apr 15 08:29:54 2008
--- openafs/src/afs/LINUX/osi_vnodeops.c	Tue Oct  7 15:00:56 2008
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.64 2008/04/15 12:29:54 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.69 2008/10/07 19:00:56 shadow Exp $");
  
  #include "afs/sysincludes.h"
  #include "afsincludes.h"
***************
*** 744,750 ****
      credp = crref();
      code = afs_getattr(vcp, &vattr, credp);
      if (!code)
!         vattr2inode(AFSTOV(vcp), &vattr);
  
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
--- 744,750 ----
      credp = crref();
      code = afs_getattr(vcp, &vattr, credp);
      if (!code)
!         afs_fill_inode(AFSTOV(vcp), &vattr);
  
      AFS_GUNLOCK();
  #ifdef AFS_LINUX24_ENV
***************
*** 789,799 ****
--- 789,801 ----
      cred_t *credp = NULL;
      struct vcache *vcp, *pvcp, *tvc = NULL;
      int valid;
+     struct afs_fakestat_state fakestate;
  
  #ifdef AFS_LINUX24_ENV
      lock_kernel();
  #endif
      AFS_GLOCK();
+     afs_InitFakeStat(&fakestate);
  
      if (dp->d_inode) {
  
***************
*** 805,812 ****
  
  	if (vcp->mvstat == 1) {         /* mount point */
  	    if (vcp->mvid && (vcp->states & CMValid)) {
! 		/* a mount point, not yet replaced by its directory */
! 		goto bad_dentry;
  	    }
  	} else
  	    if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */
--- 807,834 ----
  
  	if (vcp->mvstat == 1) {         /* mount point */
  	    if (vcp->mvid && (vcp->states & CMValid)) {
! 		int tryEvalOnly = 0;
! 		int code = 0;
! 		struct vrequest treq;
! 
! 		credp = crref();
! 		code = afs_InitReq(&treq, credp);
! 		if (
! #ifdef AFS_DARWIN_ENV
! 		    (strcmp(dp->d_name.name, ".DS_Store") == 0) ||
! 		    (strcmp(dp->d_name.name, "Contents") == 0) ||
! #endif
! 		    (strcmp(dp->d_name.name, ".directory") == 0)) {
! 		    tryEvalOnly = 1;
! 		}
! 		if (tryEvalOnly)
! 		    code = afs_TryEvalFakeStat(&vcp, &fakestate, &treq);
! 		else
! 		    code = afs_EvalFakeStat(&vcp, &fakestate, &treq);
! 		if ((tryEvalOnly && vcp->mvstat == 1) || code) {
! 		    /* a mount point, not yet replaced by its directory */
! 		    goto bad_dentry;
! 		}
  	    }
  	} else
  	    if (*dp->d_name.name != '/' && vcp->mvstat == 2) /* root vnode */
***************
*** 870,875 ****
--- 892,898 ----
      /* Clean up */
      if (tvc)
  	afs_PutVCache(tvc);
+     afs_PutFakeStat(&fakestate);
      AFS_GUNLOCK();
      if (credp)
  	crfree(credp);
***************
*** 884,890 ****
      return valid;
  
    bad_dentry:
!     valid = 0;
      goto done;
  }
  
--- 907,916 ----
      return valid;
  
    bad_dentry:
!     if (have_submounts(dp))
! 	valid = 1;
!     else 
! 	valid = 0;
      goto done;
  }
  
***************
*** 1012,1018 ****
  	ip = AFSTOV(vcp);
  	afs_getattr(vcp, &vattr, credp);
  	afs_fill_inode(ip, &vattr);
! 	if (hlist_unhashed(&ip->i_hash))
  	    insert_inode_hash(ip);
      }
      dp->d_op = &afs_dentry_operations;
--- 1038,1052 ----
  	ip = AFSTOV(vcp);
  	afs_getattr(vcp, &vattr, credp);
  	afs_fill_inode(ip, &vattr);
! 	if (
! #ifdef HAVE_KERNEL_HLIST_UNHASHED
! 	    hlist_unhashed(&ip->i_hash)
! #elif defined(AFS_LINUX26_ENV)
! 	    ip->i_hash.pprev == NULL
! #else
! 	    ip->i_hash.prev == NULL
! #endif
! 	    )
  	    insert_inode_hash(ip);
      }
      dp->d_op = &afs_dentry_operations;
***************
*** 1263,1275 ****
  #if defined(AFS_LINUX26_ENV)
      /* Prevent any new references during rename operation. */
      lock_kernel();
! #endif
!     /* Remove old and new entries from name hash. New one will change below.
!      * While it's optimal to catch failures and re-insert newdp into hash,
!      * it's also error prone and in that case we're already dealing with error
!      * cases. Let another lookup put things right, if need be.
!      */
! #if defined(AFS_LINUX26_ENV)
      if (!d_unhashed(newdp)) {
  	d_drop(newdp);
  	rehash = newdp;
--- 1297,1303 ----
  #if defined(AFS_LINUX26_ENV)
      /* Prevent any new references during rename operation. */
      lock_kernel();
! 
      if (!d_unhashed(newdp)) {
  	d_drop(newdp);
  	rehash = newdp;
***************
*** 1290,1295 ****
--- 1318,1326 ----
      code = afs_rename(VTOAFS(oldip), oldname, VTOAFS(newip), newname, credp);
      AFS_GUNLOCK();
  
+     if (!code)
+ 	olddp->d_time = 0;      /* force to revalidate */
+ 
      if (rehash)
  	d_rehash(rehash);
  
Index: openafs/src/afs/NBSD/osi_machdep.h
diff -c openafs/src/afs/NBSD/osi_machdep.h:1.1.8.3 openafs/src/afs/NBSD/osi_machdep.h:1.1.8.4
*** openafs/src/afs/NBSD/osi_machdep.h:1.1.8.3	Thu Nov  9 19:08:56 2006
--- openafs/src/afs/NBSD/osi_machdep.h	Tue Jul  1 16:57:23 2008
***************
*** 37,42 ****
--- 37,45 ----
  
  #define afs_bufferpages bufpages
  
+ #undef gop_lookupname
+ #define gop_lookupname(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),NULL,(compvpp))
+ 
  #define osi_vnhold(avc,r)  do { \
         if ((avc)->vrefCount) { VN_HOLD((struct vnode *)(avc)); } \
         else osi_Panic("refcnt==0");  } while(0)
Index: openafs/src/afs/SOLARIS/osi_vfsops.c
diff -c openafs/src/afs/SOLARIS/osi_vfsops.c:1.18.2.6 openafs/src/afs/SOLARIS/osi_vfsops.c:1.18.2.7
*** openafs/src/afs/SOLARIS/osi_vfsops.c:1.18.2.6	Mon Mar 17 11:28:55 2008
--- openafs/src/afs/SOLARIS/osi_vfsops.c	Mon Jul  7 13:16:26 2008
***************
*** 14,20 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vfsops.c,v 1.18.2.6 2008/03/17 15:28:55 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 14,20 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vfsops.c,v 1.18.2.7 2008/07/07 17:16:26 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 418,424 ****
  
  #ifdef AFS_SUN510_ENV
  #ifdef AFS_SUN511_ENV
! static struct vfsdef_v4 afs_vfsdef = {
      VFSDEF_VERSION,
      "afs",
      afsinit,
--- 418,424 ----
  
  #ifdef AFS_SUN510_ENV
  #ifdef AFS_SUN511_ENV
! static vfsdef_t afs_vfsdef = {
      VFSDEF_VERSION,
      "afs",
      afsinit,
Index: openafs/src/afs/UKERNEL/afs_usrops.c
diff -c openafs/src/afs/UKERNEL/afs_usrops.c:1.27.2.7 openafs/src/afs/UKERNEL/afs_usrops.c:1.27.2.8
*** openafs/src/afs/UKERNEL/afs_usrops.c:1.27.2.7	Thu Jan 31 15:18:51 2008
--- openafs/src/afs/UKERNEL/afs_usrops.c	Tue Jul  1 16:57:23 2008
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/UKERNEL/afs_usrops.c,v 1.27.2.7 2008/01/31 20:18:51 shadow Exp $");
  
  
  #ifdef	UKERNEL
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/UKERNEL/afs_usrops.c,v 1.27.2.8 2008/07/01 20:57:23 shadow Exp $");
  
  
  #ifdef	UKERNEL
***************
*** 1641,1647 ****
      /*
       * Set the primary cell name.
       */
!     call_syscall(AFSOP_SET_THISCELL, (long)afs_LclCellName, 0, 0, 0, 0);
  
      if ((logfd = fopen(fullpn_AFSLogFile, "r+")) == 0) {
  	if (afsd_verbose)
--- 1641,1647 ----
      /*
       * Set the primary cell name.
       */
!     call_syscall(AFSCALL_CALL, AFSOP_SET_THISCELL, (long)afs_LclCellName, 0, 0, 0);
  
      if ((logfd = fopen(fullpn_AFSLogFile, "r+")) == 0) {
  	if (afsd_verbose)
Index: openafs/src/afs/UKERNEL/osi_machdep.h
diff -c openafs/src/afs/UKERNEL/osi_machdep.h:1.6 openafs/src/afs/UKERNEL/osi_machdep.h:1.6.2.2
*** openafs/src/afs/UKERNEL/osi_machdep.h:1.6	Wed Jul 28 23:13:50 2004
--- openafs/src/afs/UKERNEL/osi_machdep.h	Tue Jul  1 18:28:59 2008
***************
*** 36,41 ****
--- 36,44 ----
  #define	afs_hz	    HZ
  #define osi_Time() (time(NULL))
  
+ #undef gop_lookupname
+ #define gop_lookupname(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),(compvpp))
+ 
  #define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
  #define	afs_suser(x)	    suser(x)
  
Index: openafs/src/afs/VNOPS/afs_vnop_lookup.c
diff -c openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.21 openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.22
*** openafs/src/afs/VNOPS/afs_vnop_lookup.c:1.50.2.21	Tue Apr 15 08:29:56 2008
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	Tue Aug 26 10:02:14 2008
***************
*** 18,24 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.21 2008/04/15 12:29:56 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 18,24 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_lookup.c,v 1.50.2.22 2008/08/26 14:02:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 1270,1276 ****
--- 1270,1278 ----
      if (tvc) {
  	if (no_read_access && vType(tvc) != VDIR && vType(tvc) != VLNK) {
  	    /* need read access on dir to stat non-directory / non-link */
+ #ifndef AFS_FBSD80_ENV
  	    afs_PutVCache(tvc);
+ #endif
  	    *avcp = NULL;
  	    code = EACCES;
  	    goto done;
***************
*** 1416,1422 ****
  
  	    /* if the vcache isn't usable, release it */
  	    if (tvc && !(tvc->states & CStatd)) {
! 		afs_PutVCache(tvc);
  		tvc = NULL;
  	    }
  	} else {
--- 1418,1426 ----
  
  	    /* if the vcache isn't usable, release it */
  	    if (tvc && !(tvc->states & CStatd)) {
! #ifndef  AFS_FBSD80_ENV
! 	      afs_PutVCache(tvc);
! #endif
  		tvc = NULL;
  	    }
  	} else {
***************
*** 1479,1485 ****
--- 1483,1491 ----
  		ReleaseWriteLock(&tvc->lock);
  
  		if (code) {
+ #ifndef AFS_FBSD80_ENV
  		    afs_PutVCache(tvc);
+ #endif
  		    if (tvolp)
  			afs_PutVolume(tvolp, WRITE_LOCK);
  		    goto done;
***************
*** 1501,1507 ****
--- 1507,1515 ----
  		    } else {
  			tvc = afs_GetVCache(tvc->mvid, &treq, NULL, NULL);
  		    }
+ #ifndef AFS_FBSD80_ENV
  		    afs_PutVCache(uvc);	/* we're done with it */
+ #endif
  
  		    if (!tvc) {
  			code = ENOENT;
***************
*** 1526,1532 ****
--- 1534,1542 ----
  			afs_PutVolume(tvolp, WRITE_LOCK);
  		    }
  		} else {
+ #ifndef AFS_FBSD80_ENV
  		    afs_PutVCache(tvc);
+ #endif
  		    code = ENOENT;
  		    if (tvolp)
  			afs_PutVolume(tvolp, WRITE_LOCK);
Index: openafs/src/afs/VNOPS/afs_vnop_read.c
diff -c openafs/src/afs/VNOPS/afs_vnop_read.c:1.26.2.6 openafs/src/afs/VNOPS/afs_vnop_read.c:1.26.2.7
*** openafs/src/afs/VNOPS/afs_vnop_read.c:1.26.2.6	Sat Apr 26 23:54:27 2008
--- openafs/src/afs/VNOPS/afs_vnop_read.c	Tue Aug 26 10:02:14 2008
***************
*** 19,25 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v 1.26.2.6 2008/04/27 03:54:27 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 19,25 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_read.c,v 1.26.2.7 2008/08/26 14:02:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 878,883 ****
--- 878,889 ----
  	    code = VOP_READ(tfile->vnode, &tuio, 0, afs_osi_credp);
  	    VOP_UNLOCK(tfile->vnode, 0, current_proc());
  	    AFS_GLOCK();
+ #elif defined(AFS_FBSD80_ENV)
+ 	    AFS_GUNLOCK();
+ 	    VOP_LOCK(tfile->vnode, LK_EXCLUSIVE);
+ 	    code = VOP_READ(tfile->vnode, &tuio, 0, afs_osi_credp);
+ 	    VOP_UNLOCK(tfile->vnode, 0);
+ 	    AFS_GLOCK();
  #elif defined(AFS_FBSD50_ENV)
  	    AFS_GUNLOCK();
  	    VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread);
Index: openafs/src/afs/VNOPS/afs_vnop_symlink.c
diff -c openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.6 openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.7
*** openafs/src/afs/VNOPS/afs_vnop_symlink.c:1.19.2.6	Sat Dec  8 13:00:45 2007
--- openafs/src/afs/VNOPS/afs_vnop_symlink.c	Sun Jun  8 23:30:59 2008
***************
*** 22,28 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.6 2007/12/08 18:00:45 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 22,28 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_symlink.c,v 1.19.2.7 2008/06/09 03:30:59 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 107,113 ****
      InStatus.Mask = AFS_SETMODTIME | AFS_SETMODE;
      InStatus.ClientModTime = osi_Time();
      alen = strlen(atargetName);	/* we want it to include the null */
!     if (*atargetName == '#' || *atargetName == '%') {
  	InStatus.UnixModeBits = 0644;	/* mt pt: null from "." at end */
  	if (alen == 1)
  	    alen++;		/* Empty string */
--- 107,113 ----
      InStatus.Mask = AFS_SETMODTIME | AFS_SETMODE;
      InStatus.ClientModTime = osi_Time();
      alen = strlen(atargetName);	/* we want it to include the null */
!     if ( (*atargetName == '#' || *atargetName == '%') && alen > 1 && atargetName[alen-1] == '.') {
  	InStatus.UnixModeBits = 0644;	/* mt pt: null from "." at end */
  	if (alen == 1)
  	    alen++;		/* Empty string */
Index: openafs/src/afs/VNOPS/afs_vnop_write.c
diff -c openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.9 openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.10
*** openafs/src/afs/VNOPS/afs_vnop_write.c:1.36.2.9	Mon Feb 27 15:37:47 2006
--- openafs/src/afs/VNOPS/afs_vnop_write.c	Tue Aug 26 10:02:14 2008
***************
*** 21,27 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v 1.36.2.9 2006/02/27 20:37:47 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
--- 21,27 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_write.c,v 1.36.2.10 2008/08/26 14:02:14 shadow Exp $");
  
  #include "afs/sysincludes.h"	/* Standard vendor system headers */
  #include "afsincludes.h"	/* Afs-based standard headers */
***************
*** 610,615 ****
--- 610,621 ----
  	code = VOP_WRITE(tfile->vnode, &tuio, 0, afs_osi_credp);
  	VOP_UNLOCK(tfile->vnode, 0, current_proc());
  	AFS_GLOCK();
+ #elif defined(AFS_FBSD80_ENV)
+ 	AFS_GUNLOCK();
+ 	VOP_LOCK(tfile->vnode, LK_EXCLUSIVE);
+ 	code = VOP_WRITE(tfile->vnode, &tuio, 0, afs_osi_credp);
+ 	VOP_UNLOCK(tfile->vnode, 0);
+ 	AFS_GLOCK();
  #elif defined(AFS_FBSD50_ENV)
  	AFS_GUNLOCK();
  	VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread);
Index: openafs/src/afsd/rc.afs.rs_aix
diff -c openafs/src/afsd/rc.afs.rs_aix:1.3 openafs/src/afsd/rc.afs.rs_aix:1.3.2.1
*** openafs/src/afsd/rc.afs.rs_aix:1.3	Tue Jul  1 14:37:25 2003
--- openafs/src/afsd/rc.afs.rs_aix	Wed Sep  3 14:27:40 2008
***************
*** 49,69 ****
  # find out whether we have 32 or 64 bit kernel
  
  kernel=32
! if [ -x /bin/w64 ]; then
!     /bin/w64 >/dev/null 2>&1
!     if [ $? -eq 0 ]; then
!         kernel=64
!     fi
  fi
  
  # Load AFS into the kernel
  
  cd /usr/vice/etc/dkload
  if [ $kernel -eq 32 ]; then
-     echo "32-bit kernel found"
      ./cfgexport -a export.ext${ExportExt} && ./cfgafs -a afs.ext.32
  else
-     echo "64-bit kernel assumed"
      ./cfgexport64 -a export64.ext${ExportExt} && ./cfgafs64 -a afs.ext.64
  fi
  if [ $? -ne 0 ]; then
--- 49,65 ----
  # find out whether we have 32 or 64 bit kernel
  
  kernel=32
! if [ -x /usr/sbin/bootinfo ]; then
! 	kernel=`/usr/sbin/bootinfo -K`
  fi
  
  # Load AFS into the kernel
  
+ echo "$0: Loading $kernel bit kernel AFS modules"
  cd /usr/vice/etc/dkload
  if [ $kernel -eq 32 ]; then
      ./cfgexport -a export.ext${ExportExt} && ./cfgafs -a afs.ext.32
  else
      ./cfgexport64 -a export64.ext${ExportExt} && ./cfgafs64 -a afs.ext.64
  fi
  if [ $? -ne 0 ]; then
Index: openafs/src/aklog/Makefile.in
diff -c openafs/src/aklog/Makefile.in:1.1.2.10 openafs/src/aklog/Makefile.in:1.1.2.12
*** openafs/src/aklog/Makefile.in:1.1.2.10	Thu Nov  1 12:51:58 2007
--- openafs/src/aklog/Makefile.in	Sat Jun 28 03:19:05 2008
***************
*** 32,51 ****
  # Installation targets
  #
  install: \
! 	${DESTDIR}${bindir}/aklog ${DESTDIR}${afssrvbindir}/asetkey
  
  ${DESTDIR}${bindir}/aklog: aklog
  	${INSTALL} $? $@
  
  ${DESTDIR}${afssrvbindir}/asetkey: asetkey
  	${INSTALL} $? $@
  
  dest: \
! 	${DEST}/bin/aklog ${DEST}/root.server/usr/afs/bin/asetkey
  
  ${DEST}/bin/aklog: aklog
  	${INSTALL} $? $@
  
  ${DEST}/root.server/usr/afs/bin/asetkey: asetkey
  	${INSTALL} $? $@
  
--- 32,59 ----
  # Installation targets
  #
  install: \
! 	${DESTDIR}${bindir}/aklog ${DESTDIR}${bindir}/klog.krb5 \
! 	${DESTDIR}${afssrvbindir}/asetkey
  
  ${DESTDIR}${bindir}/aklog: aklog
  	${INSTALL} $? $@
  
+ ${DESTDIR}${bindir}/klog.krb5: klog
+ 	${INSTALL} -f $? $@
+ 
  ${DESTDIR}${afssrvbindir}/asetkey: asetkey
  	${INSTALL} $? $@
  
  dest: \
! 	${DEST}/bin/aklog ${DEST}/bin/klog.krb5 \
! 	${DEST}/root.server/usr/afs/bin/asetkey
  
  ${DEST}/bin/aklog: aklog
  	${INSTALL} $? $@
  
+ ${DEST}/bin/klog.krb5: klog
+ 	${INSTALL} -f $? $@
+ 
  ${DEST}/root.server/usr/afs/bin/asetkey: asetkey
  	${INSTALL} $? $@
  
Index: openafs/src/auth/auth.p.h
diff -c openafs/src/auth/auth.p.h:1.4 openafs/src/auth/auth.p.h:1.4.2.1
*** openafs/src/auth/auth.p.h:1.4	Tue Jul 15 19:14:39 2003
--- openafs/src/auth/auth.p.h	Mon Jun 30 16:40:32 2008
***************
*** 24,30 ****
      char ticket[MAXKTCTICKETLEN];
  };
  
- #ifdef AFS_NT40_ENV
  extern int ktc_SetToken(struct ktc_principal *server, struct ktc_token *token,
  			struct ktc_principal *client, afs_int32 flags);
  
--- 24,29 ----
***************
*** 38,43 ****
--- 37,44 ----
  
  extern int ktc_ForgetAllTokens(void);
  
+ #ifdef AFS_NT40_ENV
+ 
  /* Flags for the flag word sent along with a token */
  #define PIOCTL_LOGON		0x1	/* invoked from integrated logon */
  
Index: openafs/src/bozo/bnode.c
diff -c openafs/src/bozo/bnode.c:1.17.2.8 openafs/src/bozo/bnode.c:1.17.2.9
*** openafs/src/bozo/bnode.c:1.17.2.8	Mon Mar 10 18:35:33 2008
--- openafs/src/bozo/bnode.c	Mon Jun 30 16:31:41 2008
***************
*** 11,21 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bozo/bnode.c,v 1.17.2.8 2008/03/10 22:35:33 shadow Exp $");
  
  #include <stddef.h>
  #include <stdlib.h>
  #include <stdio.h>
  #include <errno.h>
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,22 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/bozo/bnode.c,v 1.17.2.9 2008/06/30 20:31:41 rra Exp $");
  
  #include <stddef.h>
  #include <stdlib.h>
  #include <stdio.h>
+ #include <dirent.h>
  #include <errno.h>
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 99,111 ****
--- 100,144 ----
      char tbuffer[256];
      struct stat tstat;
      register afs_int32 code;
+     char *corefile = NULL;
  #ifdef BOZO_SAVE_CORES
      struct timeval Start;
      struct tm *TimeFields;
      char FileName[256];
  #endif
  
+     /* Linux always appends the PID to core dumps from threaded processes, so
+      * we have to scan the directory to find core files under another name. */
      code = stat(AFSDIR_SERVER_CORELOG_FILEPATH, &tstat);
+     if (code) {
+         DIR *logdir;
+         struct dirent *file;
+         char *p;
+         size_t length;
+         unsigned long pid;
+ 
+         logdir = opendir(AFSDIR_LOGS_DIR);
+         if (logdir == NULL)
+             return;
+         while ((file = readdir(logdir)) != NULL) {
+             if (strncmp(file->d_name, "core.", 5) != 0)
+                 continue;
+             pid = atol(file->d_name + 5);
+             if (pid == aproc->pid) {
+                 length = strlen(AFSDIR_LOGS_DIR) + strlen(file->d_name) + 2;
+                 corefile = malloc(length);
+                 if (corefile == NULL) {
+                     closedir(logdir);
+                     return;
+                 }
+                 snprintf(corefile, length, "%s/%s", AFSDIR_LOGS_DIR,
+                          file->d_name);
+                 code = 0;
+                 break;
+             }
+         }
+         closedir(logdir);
+     }
      if (code)
  	return;
  
***************
*** 118,124 ****
  	    TimeFields->tm_hour, TimeFields->tm_min, TimeFields->tm_sec);
      strcpy(tbuffer, FileName);
  #endif
!     code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer);
  }
  
  int
--- 151,162 ----
  	    TimeFields->tm_hour, TimeFields->tm_min, TimeFields->tm_sec);
      strcpy(tbuffer, FileName);
  #endif
!     if (corefile == NULL)
!         code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer);
!     else {
!         code = renamefile(corefile, tbuffer);
!         free(corefile);
!     }
  }
  
  int
Index: openafs/src/butc/afsxbsa.c
diff -c /dev/null openafs/src/butc/afsxbsa.c:1.1.6.2
*** /dev/null	Tue Oct  7 22:25:12 2008
--- openafs/src/butc/afsxbsa.c	Tue Jul 15 06:33:57 2008
***************
*** 0 ****
--- 1,2903 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifdef xbsa
+ 
+ #include <afs/param.h>
+ #include <sys/types.h>
+ #include <afs/stds.h>
+ #include <stdio.h>
+ 
+ 
+ #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV)
+ #include <dlfcn.h>
+ #endif
+ 
+ #include <errno.h>
+ #include "butc_xbsa.h"
+ #include <afs/butx.h>
+ 
+ /* Global Definations */
+ #define APPLTYPE "afs-butc"
+ #define TDP_LIBNAME "libApiDS.a"
+ #define FIRST_HANDLE 1
+ #define NOHANDLE 0
+ #define XAPI_FSINFO "FS for XOpen API"
+ #define DIR_DELIMITER '/'
+ #define STR_DIR_DELIMITER '/'
+ 
+ xGlobal xopenGbl;
+ char traceStr[DSM_MAX_RC_MSG_LENGTH+1];
+ char traceStr2[(DSM_MAX_RC_MSG_LENGTH+1) - 30];
+ char ourMsg[DSM_MAX_RC_MSG_LENGTH + 1];
+ static int dsm_init = 0 ;
+ 
+ /* >>>  TSM function pointers. */
+ dsInt16_t (* AFSdsmBeginQuery)( dsUint32_t dsmHandle, dsmQueryType queryType, dsmQueryBuff *queryBuffer);
+ dsInt16_t (* AFSdsmGetNextQObj)( dsUint32_t dsmHandle, DataBlk *dataBlkPtr) ;
+ dsInt16_t (* AFSdsmEndQuery)( dsUint32_t dsmHandle);
+ dsInt16_t (* AFSdsmRCMsg)( dsUint32_t dsmHandle, dsInt16_t dsmRC, char *msg);
+ dsInt16_t (* AFSdsmLogEventEx)( dsUint32_t dsmHandle, dsmLogExIn_t *dsmLogExInP, dsmLogExOut_t *dsmLogExOutP);
+ dsInt16_t (* AFSdsmTrace)( dsUint32_t dsmHandle, char * string );
+ dsInt16_t (* AFSdsmTerminate)( dsUint32_t dsmHandle);
+ dsInt16_t (* AFSdsmSendData)( dsUint32_t dsmHandle, DataBlk *dataBlkPtri);
+ dsInt16_t (* AFSdsmBeginTxn)( dsUint32_t dsmHandle);
+ dsInt16_t (* AFSdsmDeleteObj)( dsUint32_t dsmHandle, dsmDelType delType, dsmDelInfo delInfo);
+ dsInt16_t (* AFSdsmEndTxn)( dsUint32_t dsmHandle, dsUint8_t vote, dsUint16_t *reason);
+ void (* AFSdsmQueryApiVersion)( dsmApiVersion *apiVersionP);
+ dsInt16_t (* AFSdsmInit)( dsUint32_t *dsmHandle, dsmApiVersion *dsmApiVersionP, char *clientNodeNameP, char *clientOwnerNameP, char *clientPasswordP, char *applicationType, char *configfile, char *options);
+ dsInt16_t (* AFSdsmQuerySessInfo)( dsUint32_t dsmHandle, ApiSessInfo *SessInfoP);
+ dsInt16_t (* AFSdsmBeginGetData)(dsUint32_t dsmHandle, dsBool_t mountWait, dsmGetType getType, dsmGetList *dsmGetObjListP);
+ dsInt16_t (* AFSdsmGetObj)( dsUint32_t dsmHandle, ObjID *objIdP, DataBlk *dataBlkPtr);
+ dsInt16_t (* AFSdsmEndGetObj)( dsUint32_t dsmHandle);
+ dsInt16_t (* AFSdsmEndGetData)( dsUint32_t dsmHandle);
+ dsInt16_t (* AFSdsmGetData)( dsUint32_t dsmHandle, DataBlk *dataBlkPtr);
+ dsInt16_t (* AFSdsmEndSendObj)( dsUint32_t dsmHandle);
+ dsInt16_t (* AFSdsmRegisterFS)( dsUint32_t dsmHandle, regFSData *regFilespaceP);
+ dsInt16_t (* AFSdsmBindMC)( dsUint32_t dsmHandle, dsmObjName *objNameP, dsmSendType sendType, mcBindKey *mcBindKeyP);
+ dsInt16_t (* AFSdsmSendObj)( dsUint32_t dsmHandle, dsmSendType sendType, void *sendBuff, dsmObjName *objNameP, ObjAttr *objAttrPtr, DataBlk *dataBlkPtr);
+ dsInt16_t (* AFSdsmChangePW)( dsUint32_t dsmHandle, char *oldPW, char *newPW);
+ #if 0
+ dsInt16_t (* AFSdsmCleanUp)( dsBool_t mtFlag);
+ dsInt16_t (* AFSdsmDeleteAccess)( dsUint32_t dsmHandle, dsUint32_t ruleNum);
+ dsInt16_t (* AFSdsmDeleteFS)( dsUint32_t dsmHandle, char *fsName, dsUint8_t repository);
+ dsInt16_t (* AFSdsmEndGetDataEx)( dsmEndGetDataExIn_t *dsmEndGetDataExInP, dsmEndGetDataExOut_t *dsmEndGetDataExOutP);
+ dsInt16_t (* AFSdsmEndSendObjEx)( dsmEndSendObjExIn_t *dsmEndSendObjExInP, dsmEndSendObjExOut_t *dsmEndSendObjExOutP);
+ dsInt16_t (* AFSdsmEndTxnEx)( dsmEndTxnExIn_t *dsmEndTxnExInP, dsmEndTxnExOut_t *dsmEndTxnExOutP);
+ dsInt16_t (* AFSdsmGroupHandler)( dsmGroupHandlerIn_t *dsmGroupHandlerInP, dsmGroupHandlerOut_t  *dsmGroupHandlerOutP);
+ dsInt16_t (* AFSdsmInitEx)( dsUint32_t *dsmHandleP, dsmInitExIn_t *dsmInitExInP, dsmInitExOut_t *dsmInitExOutP);
+ dsInt16_t (* AFSdsmLogEvent)( dsUint32_t dsmHandle, logInfo *lopInfoP);
+ dsInt16_t (* AFSdsmQueryAccess)( dsUint32_t dsmHandle, qryRespAccessData **accessListP, dsUint16_t *numberOfRules);
+ void      (* AFSdsmQueryApiVersionEx)( dsmApiVersionEx *apiVersionP);
+ dsInt16_t (* AFSdsmQueryCliOptions)( optStruct *optstructP);
+ dsInt16_t (* AFSdsmQuerySessOptions)( dsUint32_t dsmHandle, optStruct *optstructP);
+ dsInt16_t (* AFSdsmRenameObj)( dsmRenameIn_t *dsmRenameInP, dsmRenameOut_t *dsmRenameOutP);
+ dsInt16_t (* AFSdsmSetAccess)( dsUint32_t dsmHandle, dsmAccessType accessType, dsmObjName *objNameP, char *node, char *owner);
+ dsInt16_t (* AFSdsmSetUp)( dsBool_t mtFlag, envSetUp *envSetUpPi);
+ dsInt16_t (* AFSdsmUpdateFS)( dsUint32_t dsmHandle, char *fs, dsmFSUpd *fsUpdP, dsUint32_t fsUpdAct);
+ dsInt16_t (* AFSdsmUpdateObj)( dsUint32_t dsmHandle, dsmSendType sendType, void *sendBuff, dsmObjName *objNameP, ObjAttr *objAttrPtr, dsUint32_t objUpdAct);
+ #endif
+ /* <<< TSM function pointers. */
+ 
+ typedef struct s_delList {
+   struct s_delList *next;
+   ObjID           objId;
+ } delList;
+ 
+ static dsInt16_t buildList(
+     dsUint32_t     dsmHandle,
+     dsmObjName     *objNameP,
+     delList        **llHeadPP,
+     delList        **llTailPP)
+ {
+    dsInt16_t            rc;
+    qryArchiveData       queryBuffer;       /* for query Archive*/
+    qryRespArchiveData   qaDataArea;
+    DataBlk              qDataBlkArea;
+    char                 descrStar[] = "*";
+    delList              *lnew = NULL, *ll = NULL;
+ 
+    queryBuffer.stVersion = qryArchiveDataVersion ;
+    queryBuffer.objName = objNameP;
+    queryBuffer.owner = xopenGbl.dsmSessInfo.owner;
+    queryBuffer.insDateLowerBound.year = DATE_MINUS_INFINITE;
+    queryBuffer.insDateUpperBound.year = DATE_PLUS_INFINITE;
+    queryBuffer.expDateLowerBound.year = DATE_MINUS_INFINITE;
+    queryBuffer.expDateUpperBound.year = DATE_PLUS_INFINITE;
+    queryBuffer.descr = descrStar;
+ 
+    if ((rc=AFSdsmBeginQuery(dsmHandle, qtArchive,
+                         (void *)&queryBuffer )) != DSM_RC_OK)
+    {
+       XOPENRETURN(dsmHandle,"buildList(AFSdsmBeginQuery)",rc,__FILE__,__LINE__);
+    }
+    qaDataArea.stVersion = qryRespArchiveDataVersion;
+    qDataBlkArea.stVersion = DataBlkVersion ;
+    qDataBlkArea.bufferPtr = (char *)&qaDataArea;
+    qDataBlkArea.bufferLen = sizeof(qryRespArchiveData);
+    while ((rc = AFSdsmGetNextQObj(dsmHandle, &qDataBlkArea)) == DSM_RC_MORE_DATA)
+    {
+      if (!(lnew = (delList *)dsMalloc(sizeof(delList))))
+         XOPENRETURN(dsmHandle,"buildList(AFSdsmGetNextQObj)",
+                     DSM_RC_NO_MEMORY,__FILE__,__LINE__);
+ 
+      if (!*llHeadPP)
+      {
+         *llHeadPP = lnew;
+         *llTailPP = lnew;
+      }
+      else
+      {
+         ll = *llTailPP;
+         ll->next = lnew;
+         *llTailPP = lnew;
+      }
+ 
+      lnew->next = NULL;
+      lnew->objId.hi = qaDataArea.objId.hi;
+      lnew->objId.lo = qaDataArea.objId.lo;
+    }
+ 
+    if (rc != DSM_RC_FINISHED)
+    {
+       AFSdsmEndQuery(dsmHandle);
+       XOPENRETURN(dsmHandle,"buildList(AFSdsmGetNextQObj)",
+                   rc,__FILE__,__LINE__);
+    }
+ 
+    if ((rc = AFSdsmEndQuery(dsmHandle)) != DSM_RC_OK)
+    {
+       sprintf(traceStr2, "buildList: AFSdsmEndQuery rc = %d", rc);
+       ourTrace(dsmHandle,TrFL,traceStr2);
+    }
+    XOPENRETURN(dsmHandle,"buildList",rc,__FILE__,__LINE__);
+ }
+ 
+ static dsInt16_t  freeList(
+     delList    **llHeadPP,
+     delList    **llTailPP)
+ {
+ 
+    delList *ll;
+    ll = *llHeadPP;
+    while (ll)
+    {
+       *llHeadPP = ll->next;
+       dsFree(ll);
+       ll = *llHeadPP;
+    }
+    *llHeadPP = NULL;
+    *llTailPP = NULL;
+    XOPENRETURN(0,"freeList",0,__FILE__,__LINE__);
+ }
+ 
+ void ourTrace(long           BSAHandle,
+               char          *fileName,
+               int            lineNumber,
+               char          *traceStr2)
+ {
+ 
+    sprintf(traceStr,"%s (%d) ",fileName, lineNumber);
+ 
+    if (traceStr2 != NULL && *traceStr2 != '\0')
+       strcat(traceStr, traceStr2);
+ 
+    AFSdsmTrace(BSAHandle, traceStr);
+    return;
+ }
+ 
+ void ourLogEvent_Ex(dsUint32_t dsmHandle, dsmLogType type, char *message,
+                     char *appMsg, dsmLogSeverity severity)
+ {
+    dsmLogExIn_t dsmLogIn;
+    dsmLogExOut_t dsmLogOut;
+    dsInt16_t    rc = 0;
+    memset(&dsmLogOut, '\0', sizeof(dsmLogExOut_t));
+ 
+    if (dsmHandle)
+    {
+       dsmLogIn.stVersion = dsmLogExInVersion;
+       dsmLogIn.severity = severity;
+       dsmLogIn.logType = type;
+ 
+       strcpy(dsmLogIn.appMsgID, appMsg);
+       dsmLogIn.message = message;
+       rc = AFSdsmLogEventEx(dsmHandle, &dsmLogIn, &dsmLogOut);
+    }
+ }
+ 
+ char* ourRCMsg(dsInt16_t ourRC, char *msgPrefix)
+ {
+    char         appStr[BSA_MAX_DESC];
+    char         *chP;
+    int          bytesToCp;
+ 
+    memset(&ourMsg, 0x00, DSM_MAX_RC_MSG_LENGTH + 1);
+    if(msgPrefix != NULL)
+    {
+        /*================================================================
+         call stdXOpenMsgMap if return code values are within the TSM
+         return code range (96 - 104). Reformat the message prefix
+         (ANS0660 - ANS0668).
+         ================================================================*/
+         if ((ourRC >= custMin_retcode) && (ourRC <= custMax_retcode))
+         {
+              stdXOpenMsgMap(ourRC, ourMsg);
+              /* set standard XOpen message prefix range: 660 - 668 */
+              ourRC = ((ourRC * 10) / 16) + (ourRC % 16) + 600;
+              sprintf(msgPrefix, "ANSO%d", ourRC);
+         }
+         else
+           /*===============================================================
+            call dsmRCMsg if return code values other then the above ranges.
+            Get message prefix from the return message of dsmRCMsg.
+            ===============================================================*/
+         {
+               AFSdsmRCMsg(NOHANDLE, ourRC, ourMsg);
+              /*=========================================================
+               search for the first ' ' and copy from beginning of string
+               until before the two charecter before ' '.
+               e.g. To get the code value from the messages of
+                    "ANS1038S Invalid option specified", we only want to
+                    get strings "ANS1038".
+               ========================================================*/
+               chP = (char *) strchr(ourMsg, ' ');
+               bytesToCp = strlen(ourMsg) - (strlen(chP) + 1);
+               strncpy(appStr, ourMsg, bytesToCp);
+               sprintf(msgPrefix, "%s", appStr);
+         }
+    }
+ return ourMsg;
+ } /* ourRCMsg() */
+ 
+ void StrUpper(char *s)
+ {
+    while (*s != '\0')
+    {
+       if (isalpha((int)(unsigned char)*s))
+          *s = (char)toupper((int)(unsigned char)*s);
+       s++;
+ 
+    } /* end while */
+ } /* StrUpper() */
+ 
+ BSA_Int16 xparsePath(
+     long           BSAHandle,
+     char          *pathname,
+     char          *hl,
+     char          *ll)
+ {
+    /*=== code taken from dscparse.c ParseDestOperand function ===*/
+ 
+    dsInt16_t    opLen;
+    dsInt16_t    x;
+ 
+    *hl = *ll = '\0';
+ 
+    strcpy(hl, pathname);   /* use hl as working area */
+    if ((opLen = strlen(hl)) > 0)
+    {
+       /*=== Find the ll portion of the name ===*/
+       #ifdef MBCS
+       {
+          char *llstart;
+          llstart = strrchr(hl,DIR_DELIMITER);
+          if (llstart == NULL)
+             x = 0;
+          else
+             x = llstart - hl;
+       }
+       #else
+          for (x = opLen-1; x>0 && hl[x]!=DIR_DELIMITER; x--);
+       #endif
+ 
+          /*=== If there is no leading delimiter then add one ===*/
+          if (hl[x] != DIR_DELIMITER)
+             strcpy(ll, STR_DIR_DELIMITER);
+ 
+          strncat(ll, hl+x, opLen-x);
+ 
+          hl[x] = '\0';          /* Shorten hl by length of ll */
+    }
+    return 0;
+ }
+ 
+ BSA_Int16 xlateRC(
+     long           BSAHandle,
+     BSA_Int16      dsmRC,
+     BSA_Int16      *bsaRCP)
+ 
+ {
+    switch (dsmRC)
+    {
+       case DSM_RC_OK:
+          *bsaRCP=BSA_RC_OK;                              break;
+ 
+       case DSM_RC_ABORT_ACTIVE_NOT_FOUND:
+          *bsaRCP=BSA_RC_ABORT_ACTIVE_NOT_FOUND;          break;
+ 
+       case DSM_RC_ABORT_SYSTEM_ERROR:
+          *bsaRCP=BSA_RC_ABORT_SYSTEM_ERROR;              break;
+ 
+       case DSM_RC_ABORT_BAD_VERIFIER:
+       case DSM_RC_AUTH_FAILURE:
+       case DSM_RC_REJECT_ID_UNKNOWN:
+       case DSM_RC_REJECT_DUPLICATE_ID:
+          *bsaRCP=BSA_RC_AUTHENTICATION_FAILURE;          break;
+ 
+       case DSM_RC_BAD_CALL_SEQUENCE:
+          *bsaRCP=BSA_RC_BAD_CALL_SEQUENCE;               break;
+ 
+       case DSM_RC_INVALID_DS_HANDLE:
+          *bsaRCP=BSA_RC_BAD_HANDLE;                      break;
+ 
+       case DSM_RC_BUFF_TOO_SMALL:
+          *bsaRCP=BSA_RC_BUFFER_TOO_SMALL;                break;
+ 
+       case DSM_RC_DESC_TOOLONG:
+          *bsaRCP=BSA_RC_DESC_TOO_LONG;                   break;
+ 
+       case DSM_RC_FILESPACE_TOOLONG:
+          *bsaRCP=BSA_RC_OBJECTSPACE_TOO_LONG;            break;
+ 
+       /* some other condition here ? */
+       case DSM_RC_PASSWD_TOOLONG:
+          *bsaRCP=BSA_RC_INVALID_TOKEN;                   break;
+ 
+       case DSM_RC_INVALID_VOTE:
+          *bsaRCP=BSA_RC_INVALID_VOTE;                    break;
+ 
+       case DSM_RC_INVALID_OPT:
+          *bsaRCP=BSA_RC_INVALID_KEYWORD;                 break;
+ 
+       /*  ? what conditions cause this - object already exists ?
+       case DSM_RC_?:
+          *bsaRCP=BSA_RC_MATCH_EXISTS;                    break;
+       */
+ 
+       case DSM_RC_MORE_DATA:
+          *bsaRCP=BSA_RC_MORE_DATA;                       break;
+ 
+       /* not supported - for QueryAccessRule
+       case :
+          *bsaRCP=BSA_RC_MORE_RULES;                      break;
+       */
+ 
+       case DSM_RC_NEWPW_REQD:
+          *bsaRCP=BSA_RC_NEWTOKEN_REQD;                   break;
+ 
+       case DSM_RC_ABORT_NO_MATCH:
+       case DSM_RC_FILE_SPACE_NOT_FOUND:
+       /*=== rc for query ===*/
+          *bsaRCP=BSA_RC_NO_MATCH;                        break;
+       /*=== if this return code comes on Delete, use OBJECT_NOT_FOUND
+             - see xopndel.c ===*/
+ 
+       case DSM_RC_FINISHED:
+          *bsaRCP=BSA_RC_NO_MORE_DATA;                    break;
+ 
+       case DSM_RC_ABORT_NO_LOG_SPACE:
+       case DSM_RC_ABORT_NO_DB_SPACE:
+       case DSM_RC_ABORT_NO_MEMORY:
+       case DSM_RC_ABORT_NO_REPOSIT_SPACE:
+       case DSM_RC_REJECT_NO_RESOURCES:
+       case DSM_RC_REJECT_NO_MEMORY:
+       case DSM_RC_REJECT_NO_DB_SPACE:
+       case DSM_RC_REJECT_NO_LOG_SPACE:
+          *bsaRCP=BSA_RC_NO_RESOURCES;                    break;
+ 
+       case DSM_RC_NULL_DATABLKPTR:
+          *bsaRCP=BSA_RC_NULL_DATABLKPTR;                 break;
+ 
+       case DSM_RC_NULL_OBJNAME:
+          *bsaRCP=BSA_RC_NULL_OBJNAME;                    break;
+ 
+       case DSM_RC_NULL_BUFPTR:
+          *bsaRCP=BSA_RC_NULL_POINTER;                    break;
+ 
+       /* not supported - for DeleteAccessRule
+       case :
+          *bsaRCP=BSA_RC_NULL_RULEID;                     break;
+       */
+ 
+       case DSM_RC_HL_TOOLONG:
+       case DSM_RC_LL_TOOLONG:
+          *bsaRCP=BSA_RC_OBJECT_NAME_TOO_LONG;            break;
+ 
+       /* not supported - for DeletePolicyDomain
+       case :
+          *bsaRCP=BSA_RC_OBJECT_NOT_EMPTY;                break;
+       */
+ 
+       /* same as NO_MATCH for DeleteObject
+       case :
+          *bsaRCP=BSA_RC_OBJECT_NOT_FOUND;                break;
+       */
+ 
+       case DSM_RC_OBJINFO_TOOLONG:
+          *bsaRCP=BSA_RC_OBJINFO_TOO_LONG;                break;
+ 
+       /* same as BSA_RC_OBJECT_NAME_TOO_LONG
+       case :
+          *bsaRCP=BSA_RC_OBJNAME_TOO_LONG;                break;
+       */
+ 
+       /* not supported - for CreatePolicySet, etc
+       case :
+          *bsaRCP=BSA_RC_OPERATION_NOT_AUTHORIZED;        break;
+       */
+ 
+       case DSM_RC_OLDPW_REQD:
+          *bsaRCP=BSA_RC_OLDTOKEN_REQD;                   break;
+ 
+       case DSM_RC_REJECT_VERIFIER_EXPIRED:
+          *bsaRCP=BSA_RC_TOKEN_EXPIRED;                   break;
+ 
+       case DSM_RC_WILL_ABORT:
+       case DSM_RC_CHECK_REASON_CODE:
+          *bsaRCP=BSA_RC_TXN_ABORTED;                     break;
+ 
+       case DSM_RC_UNMATCHED_QUOTE:
+          *bsaRCP=BSA_RC_UNMATCHED_QUOTE;                 break;
+ 
+       /* not supported - for DeleteUser
+       case :
+          *bsaRCP=BSA_RC_USER_OWNS_OBJECT;                break;
+       */
+ 
+       default:
+       {
+          /*=========================================================
+           No suitable match, so print message in log, if we still
+           have a handle.  AFSdsmInit calls ApiCleanUp in certain error
+           situations.  We lose the handle in those cases so check
+           for it.
+           =========================================================*/
+ 
+          char         rcMsg[DSM_MAX_RC_MSG_LENGTH] ;
+          char         errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+          char         ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+          dsUint32_t   dsmHandle;
+ 
+          memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+          memset(ourMessage,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+          if (BSAHandle)
+          {
+             dsmHandle = BSAHandle;
+             AFSdsmRCMsg(dsmHandle,dsmRC,rcMsg) ;
+             strcat(rcMsg, "\n");
+             sprintf(traceStr2,
+                    "xlateRC - %s", rcMsg);
+             ourTrace(BSAHandle,TrFL, traceStr2);
+             strcpy(ourMessage, ourRCMsg(dsmRC, errPrefix));
+             ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+          }
+ 
+          *bsaRCP = ADSM_RC_ERROR;
+       }
+    }
+ 
+    /*=== trace only if we have a valid handle ===*/
+    if (dsmRC && BSAHandle)
+    {
+       sprintf(traceStr2, "xlateRC: TSM rc >%d< , BSA rc >%d<", dsmRC, *bsaRCP);
+       ourTrace(BSAHandle, TrFL, traceStr2);
+    }
+    return DSM_RC_OK ;
+ }
+ 
+ void stdXOpenMsgMap(dsInt16_t  rc,  char *msg)
+ {
+    switch(rc)
+    {
+       case ADSM_RC_ERROR:
+            strcpy(msg, "TSM rc error, see ADSM error log.");
+       case ADSM_RC_INVALID_NODE:
+            strcpy(msg, "BSAObjectOwner doesn't match value session Init.");
+            break;
+ 
+       case ADSM_RC_INVALID_COPYTYPE:
+            strcpy(msg, "Invalid copy type.");
+            break;
+ 
+       case ADSM_RC_INVALID_OBJTYPE:
+            strcpy(msg, "Invalid object type.");
+            break;
+ 
+       case ADSM_RC_INVALID_STATUS:
+            strcpy(msg, "Invalid Object Status.");
+            break;
+ 
+       case ADSM_RC_INVALID_ST_VER:
+            strcpy(msg, "Invalid object descriptor structure version.");
+            break;
+ 
+       case ADSM_RC_OWNER_TOO_LONG:
+            strcpy(msg, "Object owner name too long.");
+            break;
+ 
+       case ADSM_RC_PSWD_TOO_LONG:
+            strcpy(msg, "Client password too long.");
+            break;
+ 
+      case ADSM_RC_PSWD_GEN:
+           strcpy(msg, "Password input required .");
+           break;
+ 
+      default:
+            strcpy(msg, "No message available");
+            break;
+    }
+ }
+ 
+ BSA_Int16 fillArchiveResp(
+ long                BSAHandle,
+ ObjectDescriptor   *BSAobjDescP,
+ qryRespArchiveData *respArchiveP
+ )
+ {
+    XAPIObjInfo   *xapiObjInfoP;
+ 
+    strcpy(BSAobjDescP->Owner.appObjectOwner, respArchiveP->owner);
+    strcpy(BSAobjDescP->objName.objectSpaceName, respArchiveP->objName.fs);
+ 
+    /*=== concatenate hl and ll for pathName ===*/
+    strcpy(BSAobjDescP->objName.pathName, respArchiveP->objName.hl);
+    strcat(BSAobjDescP->objName.pathName, respArchiveP->objName.ll);
+ 
+    BSAobjDescP->createTime.tm_year = respArchiveP->insDate.year-1900;
+    BSAobjDescP->createTime.tm_mon  = respArchiveP->insDate.month-1;
+    BSAobjDescP->createTime.tm_mday = respArchiveP->insDate.day  ;
+    BSAobjDescP->createTime.tm_hour = respArchiveP->insDate.hour ;
+    BSAobjDescP->createTime.tm_min  = respArchiveP->insDate.minute ;
+    BSAobjDescP->createTime.tm_sec  = respArchiveP->insDate.second ;
+ 
+    BSAobjDescP->copyId.left  = respArchiveP->objId.hi;
+    BSAobjDescP->copyId.right = respArchiveP->objId.lo;
+ 
+    BSAobjDescP->restoreOrder.left  = respArchiveP->restoreOrderExt.lo_hi;
+    BSAobjDescP->restoreOrder.right = respArchiveP->restoreOrderExt.lo_lo;
+ 
+    strcpy(BSAobjDescP->lGName, respArchiveP->mcName) ;
+ 
+    xapiObjInfoP = (XAPIObjInfo *)&(respArchiveP->objInfo);
+    BSAobjDescP->size.left = xapiObjInfoP->size.left;
+    BSAobjDescP->size.right= xapiObjInfoP->size.right;
+    strcpy(BSAobjDescP->resourceType, xapiObjInfoP->resourceType);
+    strcpy(BSAobjDescP->desc, xapiObjInfoP->partDesc);
+    strcpy(BSAobjDescP->objectInfo, xapiObjInfoP->partObjInfo);
+ 
+    if (respArchiveP->objName.objType == DSM_OBJ_DIRECTORY)
+       BSAobjDescP->objectType = BSAObjectType_DIRECTORY;
+    else
+       BSAobjDescP->objectType = BSAObjectType_FILE;
+       /*=== future - type DATABASE ?? ===*/
+ 
+       BSAobjDescP->status = BSAObjectStatus_ACTIVE;
+       XOPENRETURN(BSAHandle, "fillArchiveResp",
+                   BSA_RC_SUCCESS,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 fillBackupResp(
+ long               BSAHandle,
+ ObjectDescriptor  *BSAobjDescP,
+ qryRespBackupData *respBackupP
+ )
+ {
+    XAPIObjInfo   *xapiObjInfoP;
+ 
+    strcpy(BSAobjDescP->Owner.appObjectOwner, respBackupP->owner);
+    strcpy(BSAobjDescP->objName.objectSpaceName, respBackupP->objName.fs);
+ 
+    /*=== concatenate hl and ll for pathName ===*/
+    strcpy(BSAobjDescP->objName.pathName, respBackupP->objName.hl);
+    strcat(BSAobjDescP->objName.pathName, respBackupP->objName.ll);
+ 
+    BSAobjDescP->createTime.tm_year = respBackupP->insDate.year-1900;
+    BSAobjDescP->createTime.tm_mon  = respBackupP->insDate.month-1;
+    BSAobjDescP->createTime.tm_mday = respBackupP->insDate.day  ;
+    BSAobjDescP->createTime.tm_hour = respBackupP->insDate.hour ;
+    BSAobjDescP->createTime.tm_min  = respBackupP->insDate.minute ;
+    BSAobjDescP->createTime.tm_sec  = respBackupP->insDate.second ;
+ 
+    BSAobjDescP->copyId.left  = respBackupP->objId.hi;
+    BSAobjDescP->copyId.right = respBackupP->objId.lo;
+ 
+    BSAobjDescP->restoreOrder.left  = respBackupP->restoreOrderExt.lo_hi;
+    BSAobjDescP->restoreOrder.right = respBackupP->restoreOrderExt.lo_lo;
+ 
+    strcpy(BSAobjDescP->lGName, respBackupP->mcName) ;
+ 
+    xapiObjInfoP = (XAPIObjInfo *)&(respBackupP->objInfo);
+    BSAobjDescP->size.left = xapiObjInfoP->size.left;
+    BSAobjDescP->size.right= xapiObjInfoP->size.right;
+    strcpy(BSAobjDescP->resourceType, xapiObjInfoP->resourceType);
+    strcpy(BSAobjDescP->desc, xapiObjInfoP->partDesc);
+    strcpy(BSAobjDescP->objectInfo, xapiObjInfoP->partObjInfo);
+ 
+    if (respBackupP->objName.objType == DSM_OBJ_DIRECTORY)
+       BSAobjDescP->objectType = BSAObjectType_DIRECTORY;
+    else
+       BSAobjDescP->objectType = BSAObjectType_FILE;
+       /*=== future - type DATABASE ?? ===*/
+ 
+    if (respBackupP->objState == DSM_ACTIVE)
+       BSAobjDescP->status = BSAObjectStatus_ACTIVE;
+    else
+       BSAobjDescP->status = BSAObjectStatus_INACTIVE;
+       /*=== ?? check for any other ===*/
+ 
+    XOPENRETURN(BSAHandle, "fillRBackupResp",
+                BSA_RC_SUCCESS,__FILE__,__LINE__);
+ }
+ 
+ 
+ afs_int32 dsm_MountLibrary()
+ {
+ void * dynlib = NULL ;
+ 
+ #ifdef DEBUG_BUTC
+     printf("dsm_MountLibrary : inside function.  \n");
+ #endif
+ #if defined(AFS_AIX_ENV)
+         dynlib = dlopen("/usr/lib/libApiDS.a(dsmapish.o)", RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER);
+ #elif defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV)
+         dynlib = dlopen("/usr/lib/libApiDS.so", RTLD_NOW | RTLD_LOCAL);
+ #else
+         dynlib = NULL;
+ #endif
+ 
+     	if (dynlib == NULL) {
+         	ELog(0,"dsm_MountLibrary: The dlopen call to load the libApiDS shared library failed\n");
+         	return(BUTX_NOLIBRARY);
+     	}
+ 
+ #ifdef DEBUG_BUTC
+     	printf("dsm_MountLibrary : SUCCESS to Open the libApiDS shared library. \n");
+ #endif
+ #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV)
+ 	AFSdsmBeginQuery = (dsInt16_t (*)( dsUint32_t dsmHandle, dsmQueryType queryType, dsmQueryBuff *queryBuffer)) dlsym((void *)dynlib, "dsmBeginQuery"); 
+ 	AFSdsmGetNextQObj = (dsInt16_t (*)( dsUint32_t dsmHandle, DataBlk *dataBlkPtr))dlsym((void *)dynlib, "dsmGetNextQObj") ;
+ 	AFSdsmEndQuery = (dsInt16_t (*)( dsUint32_t dsmHandle))dlsym((void *)dynlib, "dsmEndQuery");
+ 	AFSdsmRCMsg = (dsInt16_t (*)( dsUint32_t dsmHandle, dsInt16_t dsmRC, char *msg))dlsym((void *)dynlib, "dsmRCMsg");
+ 	AFSdsmLogEventEx = (dsInt16_t (*)( dsUint32_t dsmHandle, dsmLogExIn_t *dsmLogExInP, dsmLogExOut_t *dsmLogExOutP))dlsym((void *)dynlib, "dsmLogEventEx");
+ 	AFSdsmTrace = (dsInt16_t (*)( dsUint32_t dsmHandle, char * string ))dlsym((void *)dynlib, "dsmTrace");
+ 	AFSdsmTerminate = (dsInt16_t (*)( dsUint32_t dsmHandle))dlsym((void *)dynlib, "dsmTerminate");
+ 	AFSdsmSendData = (dsInt16_t (*)( dsUint32_t dsmHandle, DataBlk *dataBlkPtri))dlsym((void *)dynlib, "dsmSendData");
+ 	AFSdsmBeginTxn = (dsInt16_t (*)( dsUint32_t dsmHandle))dlsym((void *)dynlib, "dsmBeginTxn");
+ 	AFSdsmDeleteObj = (dsInt16_t (*)( dsUint32_t dsmHandle, dsmDelType delType, dsmDelInfo delInfo))dlsym((void *)dynlib, "dsmDeleteObj");
+ 	AFSdsmEndTxn = (dsInt16_t (*)( dsUint32_t dsmHandle, dsUint8_t vote, dsUint16_t *reason))dlsym((void *)dynlib, "dsmEndTxn");
+ 	AFSdsmQueryApiVersion = (void (*)( dsmApiVersion *apiVersionP))dlsym((void *)dynlib, "dsmQueryApiVersion");
+ 	AFSdsmInit = (dsInt16_t (*)( dsUint32_t *dsmHandle, dsmApiVersion *dsmApiVersionP, char *clientNodeNameP, char *clientOwnerNameP, char *clientPasswordP, char *applicationType, char *configfile, char *options))dlsym((void *)dynlib, "dsmInit");
+ 	AFSdsmQuerySessInfo = (dsInt16_t (*)( dsUint32_t dsmHandle, ApiSessInfo *SessInfoP))dlsym((void *)dynlib, "dsmQuerySessInfo");
+ 	AFSdsmBeginGetData = (dsInt16_t (*)(dsUint32_t dsmHandle, dsBool_t mountWait, dsmGetType getType, dsmGetList *dsmGetObjListP))dlsym((void *)dynlib, "dsmBeginGetData");
+ 	AFSdsmGetObj = (dsInt16_t (*)( dsUint32_t dsmHandle, ObjID *objIdP, DataBlk *dataBlkPtr))dlsym((void *)dynlib, "dsmGetObj");
+ 	AFSdsmEndGetObj = (dsInt16_t (*)( dsUint32_t dsmHandle))dlsym((void *)dynlib, "dsmEndGetObj");
+ 	AFSdsmEndGetData = (dsInt16_t (*)( dsUint32_t dsmHandle))dlsym((void *)dynlib, "dsmEndGetData");
+ 	AFSdsmGetData = (dsInt16_t (*)( dsUint32_t dsmHandle, DataBlk *dataBlkPtr))dlsym((void *)dynlib, "dsmGetData");
+ 	AFSdsmEndSendObj = (dsInt16_t (*)( dsUint32_t dsmHandle))dlsym((void *)dynlib, "dsmEndSendObj");
+ 	AFSdsmRegisterFS = (dsInt16_t (*)( dsUint32_t dsmHandle, regFSData *regFilespaceP))dlsym((void *)dynlib, "dsmRegisterFS");
+ 	AFSdsmBindMC = (dsInt16_t (*)( dsUint32_t dsmHandle, dsmObjName *objNameP, dsmSendType sendType, mcBindKey *mcBindKeyP))dlsym((void *)dynlib, "dsmBindMC");
+ 	AFSdsmSendObj = (dsInt16_t (*)( dsUint32_t dsmHandle, dsmSendType sendType, void *sendBuff, dsmObjName *objNameP, ObjAttr *objAttrPtr, DataBlk *dataBlkPtr))dlsym((void *)dynlib, "dsmSendObj");
+ 	AFSdsmChangePW = (dsInt16_t (*)( dsUint32_t dsmHandle, char *oldPW, char *newPW))dlsym((void *)dynlib, "dsmChangePW");
+ 
+ 
+ 	if (	!AFSdsmBeginQuery || !AFSdsmGetNextQObj || !AFSdsmEndQuery ||
+ 		!AFSdsmRCMsg || !AFSdsmLogEventEx || !AFSdsmTrace || 
+ 		!AFSdsmTerminate || !AFSdsmEndGetObj || !AFSdsmSendData || 
+ 		!AFSdsmBeginTxn || !AFSdsmDeleteObj || !AFSdsmEndGetData ||
+         	!AFSdsmEndTxn || !AFSdsmQueryApiVersion || !AFSdsmInit || 
+ 		!AFSdsmGetData || !AFSdsmQuerySessInfo || !AFSdsmBeginGetData ||
+ 		!AFSdsmGetObj || !AFSdsmEndSendObj || !AFSdsmRegisterFS || 
+ 		!AFSdsmBindMC || !AFSdsmSendObj || !AFSdsmChangePW ) 
+ 	{
+         	ELog(0,"dsm_MountLibrary: The dlopen call to load the TSM shared library failed\n");
+         	return(BUTX_NOLIBRARY);
+     	}
+ #ifdef DEBUG_BUTC
+     		printf("dsm_MountLibrary : All TSM function pointers initialized. \n");
+ #endif
+ 
+ #endif
+ 	dsm_init = 1 ;
+ #ifdef DEBUG_BUTC
+     printf("dsm_MountLibrary : leaving function. \n");
+ #endif
+ 	return 0 ;
+ 
+ }
+ 
+ BSA_Int16 BSAInit( long     *BSAHandleP,
+                    SecurityToken  *clientPasswordP,
+                    ObjectOwner    *objectOwnerP,
+                    char          **envP )
+ {
+    dsInt16_t        rc = 0;
+    dsInt16_t        saverc = 0;
+    BSA_Int16        bsaRC = 0;
+    dsUint32_t       dsmHandle;   /* use diff field when talking to base
+                                    code in case either format changes */
+    dsmApiVersion    xapiHdrVer;  /* Xopen API build version           */
+    dsmApiVersion    apiLibVer;  /* Xopen API Libary version          */
+ 
+    dsUint32_t       xapiVersion, apiVersion;
+    envSetUp         dsmEnvSetUp;
+ 
+    /*==================================================================
+      Today the BSA constants have the same values as the DSM constants.
+      If this changes, use strncpy.
+      =================================================================*/
+ 
+    char            rcmsg[DSM_MAX_RC_MSG_LENGTH + 1];
+    char            dsmNode[DSM_MAX_NODE_LENGTH];
+    char            dsmOwner[DSM_MAX_OWNER_LENGTH];
+    char            dsmPswd[DSM_MAX_VERIFIER_LENGTH];
+    char           *dsmNodeP;
+    char           *dsmOwnerP;
+    char           *dsmPswdP;
+    char            options[DSM_MAX_RC_MSG_LENGTH];
+    char           *optionP = NULL;
+    char            TDPLibName[BSA_MAX_DESC];
+    char            TDPILibName[BSA_MAX_DESC];
+    int             i=0;
+    char            errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+    char            ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+    char            rcMsg[DSM_MAX_RC_MSG_LENGTH + 1];
+ 
+    dsmHandle = 0;
+   *BSAHandleP = 0;
+ 
+ #ifdef DEBUG_BUTC
+    printf("BSAInit : inside function. \n");
+ #endif
+    memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(ourMessage,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(rcMsg,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    /*==================================================================
+     Trace won't work before AFSdsmInit, moved to after call to AFSdsmInit
+     The XOpen library is built by statically linking with the API and
+     client common modules.  So, the version checking is unnecessary.
+     We'll fill in the value anyway for consistency.
+     ==================================================================*/
+    memset(&xapiHdrVer,0x00,sizeof(dsmApiVersion));
+    memset(&apiLibVer,0x00,sizeof(dsmApiVersion));
+    memset(&dsmEnvSetUp,0x00,sizeof(envSetUp));
+ 
+    AFSdsmQueryApiVersion(&apiLibVer);
+ 
+    xapiHdrVer.version = DSM_API_VERSION;  /* Set the applications    */
+    xapiHdrVer.release = DSM_API_RELEASE;  /* compile time version.   */
+    xapiHdrVer.level   = DSM_API_LEVEL;    /* version                 */
+ 
+    xapiVersion = (1000 * DSM_API_VERSION) + (100 * DSM_API_RELEASE)
+                   + DSM_API_LEVEL;
+ 
+    apiVersion  = (1000 * apiLibVer.version) + (100 * apiLibVer.release)
+                   + apiLibVer.level;
+ 
+    /* check for compatibility problems */
+    if (apiVersion < xapiVersion)
+    	return ADSM_RC_ERROR;
+ 
+    /*==== Init global area ===*/
+ 
+    memset(&xopenGbl,0x00, sizeof(xGlobal));  /* Zero out block.        */
+ 
+    memset(dsmNode,0x00,DSM_MAX_NODE_LENGTH);
+    memset(dsmOwner,0x00,DSM_MAX_OWNER_LENGTH);
+    memset(dsmPswd,0x00,DSM_MAX_VERIFIER_LENGTH);
+    memset(options,0x00,DSM_MAX_RC_MSG_LENGTH);
+    memset(TDPLibName,0x00,BSA_MAX_DESC);
+    memset(TDPILibName,0x00,BSA_MAX_DESC);
+ 
+    memset(rcmsg,         '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+ 
+    /*=== Validate the inputs ===*/
+ 
+    if (objectOwnerP)
+    {
+       if (strlen(objectOwnerP->bsaObjectOwner) > BSA_MAX_BSAOBJECT_OWNER)
+       {
+          bsaRC = ADSM_RC_OWNER_TOO_LONG;
+          return(bsaRC);
+       }
+ 
+       if (strlen(objectOwnerP->appObjectOwner) > BSA_MAX_APPOBJECT_OWNER)
+       {
+          bsaRC = ADSM_RC_OWNER_TOO_LONG;
+          return(bsaRC);
+       }
+ 
+       if (objectOwnerP->bsaObjectOwner[0] == '\0') /* empty string */
+          dsmNodeP = NULL;
+       else
+       {
+          strcpy(dsmNode, objectOwnerP->bsaObjectOwner);
+          dsmNodeP = dsmNode;
+       }
+ 
+       if (objectOwnerP->appObjectOwner[0] == '\0') /* empty string  */
+          dsmOwnerP = NULL;
+       else
+       {
+          strcpy(dsmOwner, objectOwnerP->appObjectOwner);
+          dsmOwnerP = dsmOwner;
+       }
+    }
+    else
+    {
+       dsmNodeP = NULL;
+       dsmOwnerP = NULL;
+    }
+ 
+    if (clientPasswordP != NULL)
+    {
+       if (strlen((const char *)clientPasswordP) > BSA_MAX_TOKEN_SIZE)
+       {
+          bsaRC = ADSM_RC_PSWD_TOO_LONG;
+          return(bsaRC);
+       }
+ 
+       strcpy(dsmPswd, (const char *)clientPasswordP);
+       dsmPswdP = dsmPswd;
+    }
+    else
+       dsmPswdP = NULL;
+       {
+           while ((envP[i] != NULL) && (envP[i] != '\0'))
+           {
+              strcat(options, "-");
+              strcat(options, envP[i]);
+              if ((envP[i+1] != NULL) && (envP[i+1] != '\0'))
+                 strcat(options, " ");
+                 i++;
+           }
+ 
+           if (options[0] == '\0')   /* empty string */
+              optionP = NULL;
+           else
+              optionP = options;
+ 
+           rc = AFSdsmInit(&dsmHandle,   /* On return contains session handle.   */
+                        &xapiHdrVer,   /* Version of the API we are using.     */
+                        dsmNodeP,      /* node name                            */
+                        dsmOwnerP,     /* owner name                           */
+                        dsmPswdP,      /* password                             */
+                        APPLTYPE,      /* Name of our node type.               */
+                        NULL,          /* no API config file name              */
+                        optionP);      /* option string                        */
+      }
+ 
+      if (rc == DSM_RC_OK)
+      {
+         /*=== now that AFSdsmInit issued, we can trace ===*/
+         sprintf(traceStr2,
+                 "BSAInit: original bsaOwner=%s, appOwner=%s, token=%s, Appl Type=%s, options=%s.",
+                  dsmNode, dsmOwner, dsmPswd, APPLTYPE, options);
+         ourTrace(dsmHandle, TrFL, traceStr2);
+         {
+               strcpy(TDPLibName, TDP_LIBNAME);
+               sprintf(traceStr2,
+                      "BSAInit: Using TSM Native API library : %s", TDPLibName);
+               ourTrace(dsmHandle, TrFL, traceStr2);
+         }
+      }
+ 
+ 
+      /*=================================================================
+      If the password expired, continue initialization so the session
+      can continue.
+ 
+      Save the 'password expired' rc away, so we can return it to the
+      caller.
+ 
+      The application will be responsible for issuing a BSAChangeToken()
+      to update the password.
+      =================================================================*/
+      if (rc == DSM_RC_REJECT_VERIFIER_EXPIRED)
+      {
+         /*=== don't return yet - init global so session can continue ===*/
+ 
+          saverc = rc;
+          rc = DSM_RC_OK;
+      }
+      else
+         if ((rc == DSM_RC_NO_OWNER_REQD) ||
+             (rc == DSM_RC_NO_NODE_REQD))       /* pswd=generate */
+         {
+             AFSdsmTerminate(dsmHandle);
+             bsaRC = ADSM_RC_PSWD_GEN;
+             return (bsaRC);
+         }
+ 
+ 
+    /*==================================================================
+      If we ran into any problems so far, rc will be non-zero or 'true'.
+ 
+      This is not true for password expired, since we reset rc to zero
+      in that case.  We'll have to check for that later so we return
+      the 'password expired' indication to the caller.
+      ==================================================================*/
+ 
+    if (rc)
+    {
+       AFSdsmRCMsg(dsmHandle, rc, rcmsg);
+       sprintf(traceStr2, "BSAInit(AFSdsmInit): Messages - %s ", rcmsg);
+       ourTrace(dsmHandle, TrFL, traceStr2);
+       strcpy(ourMessage, ourRCMsg(rc, errPrefix));
+       ourLogEvent_Ex(dsmHandle, logLocal, ourMessage, errPrefix, logSevError);
+       xlateRC(*BSAHandleP, rc, &bsaRC); /* BSAHandle still 0, but not used */
+       AFSdsmTerminate(dsmHandle);          /* clean up memory blocks          */
+       return (bsaRC);
+    }
+ 
+ 
+    {
+       char msg[256];                    /* format string and watch for NULLs */
+ 
+       strcpy(msg, "BSAInit for node=");
+ 
+       if (objectOwnerP)
+       {
+          if (dsmNodeP)
+             strcat(msg, dsmNodeP);
+          else
+             strcat(msg, "<empty>");
+       }
+       else
+          strcat(msg, "<NULL>");
+ 
+       strcat(msg, ", owner=");
+ 
+       if (objectOwnerP)
+       {
+          if (dsmOwnerP)
+             strcat(msg, dsmOwnerP);
+          else
+             strcat(msg, "<empty>");
+       }
+       else
+          strcat(msg, "<NULL>");
+ 
+       strcat(msg, ".\n");
+ 
+       sprintf(traceStr, msg);
+    }
+ 
+    *BSAHandleP = (long)dsmHandle;
+ 
+ 
+    /*=================================================================
+     For password expired processing the application is responsible for
+     issuing BSAChangeToken() to update the password, when they see the
+     'expired password' return code.
+ 
+     The BSAChangeToken() command will issue the AFSdsmQuerySessInfo()
+     call, so don't issue it here.
+     =================================================================*/
+ 
+    if (!saverc)               /* don't call this if we got pswd expire */
+    {
+       /*=== now query session info to populate the global structure ===*/
+ 
+       xopenGbl.dsmSessInfo.stVersion = ApiSessInfoVersion;
+       rc = AFSdsmQuerySessInfo(dsmHandle,                /* Session handle */
+                             &xopenGbl.dsmSessInfo);   /* Output struct  */
+ 
+       if (rc)
+       {
+          sprintf(traceStr2, "BSAInit(AFSdsmQuerySessInfo): error rc = %d", rc);
+          ourTrace(dsmHandle, TrFL, traceStr2);
+          AFSdsmTerminate(dsmHandle);
+          *BSAHandleP = 0;
+       }
+       else
+       {
+          sprintf(traceStr2, "BSAInit: Actual node=%s, actual DSM owner=%s, servername=%s.",
+                  xopenGbl.dsmSessInfo.id, xopenGbl.dsmSessInfo.owner,
+                  xopenGbl.dsmSessInfo.adsmServerName);
+          ourTrace(dsmHandle, TrFL, traceStr2);
+       }
+    }
+    else
+    {
+       /*============================================================
+         Indicate in the session flags that we encountered a password
+         expiration condition.  The application will know that this
+         happened via the return code.
+         ===========================================================*/
+ 
+       xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_PSWD_EXPIRE);
+    }
+ 
+    /*=== Save bsaObjectOwner (node name) value passed on Init ===*/
+ 
+    if (dsmNodeP)
+       strcpy(xopenGbl.bsaObjectOwner, dsmNodeP);
+ 
+      /*================================================================
+       Check to see if we saved away the 'expired password' return code.
+       if so, return it to the caller.
+       ================================================================*/
+ 
+    if (saverc)
+       rc = saverc;
+ 
+    xlateRC(*BSAHandleP, rc, &bsaRC);
+ #ifdef DEBUG_BUTC
+    	printf("BSAInit : Leaving Function. \n");
+ #endif
+    return (bsaRC);
+ }
+ 
+ BSA_Int16 BSATerminate(
+     long              BSAHandle
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+    sprintf(traceStr2, "BSATerminate ENTRY: BSAHandle is %d.",
+                       BSAHandle);
+    ourTrace(dsmHandle, TrFL, traceStr2);
+ 
+    rc = AFSdsmTerminate(dsmHandle);
+    dsmHandle = 0;
+    xlateRC(dsmHandle, rc, &bsaRC);
+ 
+    return (bsaRC);
+ 
+ }
+ 
+ BSA_Int16 BSAChangeToken(
+    long           BSAHandle,
+    SecurityToken *oldTokenP,
+    SecurityToken *newTokenP
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+ 
+    sprintf(traceStr2, "BSAChangeToken ENTRY: BSAHandle:%d old:>%s< new:>%s<",
+            BSAHandle,oldTokenP,newTokenP);
+    ourTrace(dsmHandle, TrFL, traceStr2);
+ 
+    rc = AFSdsmChangePW(dsmHandle, (char *)oldTokenP, (char *)newTokenP);
+ 
+    if (rc)
+    {
+       xlateRC(BSAHandle, rc, &bsaRC);
+       XOPENRETURN(BSAHandle,"BSAChangeToken(AFSdsmChangePW)",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_PSWD_EXPIRE); /* set off */
+ 
+     /*=== now query session info to populate the global structure ===*/
+ 
+    xopenGbl.dsmSessInfo.stVersion = ApiSessInfoVersion;
+    rc = AFSdsmQuerySessInfo(dsmHandle,                /* Our session handle  */
+                          &xopenGbl.dsmSessInfo);   /* Output structure.   */
+    if (rc)
+    {
+       /*=== appl should call Terminate ===*/
+       sprintf(traceStr2, "BSAChangeToken(AFSdsmQuerySessInfo): error rc = %d", rc);
+       ourTrace(BSAHandle, TrFL, traceStr2);
+    }
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle,"BSAChangeToken",
+                bsaRC,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSASetEnvironment(
+     long     BSAHandle,
+     char           **envP
+ )
+ {
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    sprintf(traceStr2, "BSASetEnvironment ENTRY: BSAHandle:%d envP:>%p< ",
+            BSAHandle,envP);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+    XOPENRETURN(BSAHandle,"BSASetEnvironment",
+                BSA_RC_BAD_CALL_SEQUENCE,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSAGetEnvironment(
+    long           BSAHandle,
+    ObjectOwner   *objOwnerP,
+    char         **envP
+ )
+ {
+    dsInt16_t   rc = 0;
+    BSA_Int16   bsaRC = 0;
+    dsUint32_t  dsmHandle;
+    char        envString[ADSM_ENV_STRS][BSA_MAX_DESC];
+    char        maxObjStr[6];  /* conversion field. value range is 16-256 */
+    dsUint32_t  maxObjNum;
+    dsInt16_t   i, j;
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    for (i=0; i<ADSM_ENV_STRS; i++)
+    {
+       memset(envString[i], 0x00, BSA_MAX_DESC);
+    }
+    sprintf(traceStr2, "BSAGetEnvironment ENTRY: BSAHandle:%d ObjOwner:'%s' appOwner:'%s' envP:>%p<.",
+            BSAHandle,
+            objOwnerP->bsaObjectOwner,
+            objOwnerP->appObjectOwner,
+            envP);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    dsmHandle = BSAHandle;
+ 
+    /*===============================================================
+     check if BSAInit has been done for now we have only one possible
+     handle value - change in future
+     ==============================================================*/
+    if ((dsmHandle != FIRST_HANDLE) ||
+       (xopenGbl.dsmSessInfo.stVersion != ApiSessInfoVersion))
+        XOPENRETURN(BSAHandle,"BSAGetEnvironment",
+                    BSA_RC_BAD_CALL_SEQUENCE, __FILE__,__LINE__);
+ 
+    if (objOwnerP)
+    {
+       strcpy(objOwnerP->bsaObjectOwner, xopenGbl.dsmSessInfo.id);
+       strcpy(objOwnerP->appObjectOwner, xopenGbl.dsmSessInfo.owner);
+    }
+    else
+       XOPENRETURN(BSAHandle,"BSAGetEnvironment",
+                   BSA_RC_NULL_POINTER, __FILE__,__LINE__);
+ 
+    rc = AFSdsmQuerySessInfo(dsmHandle,                   /* Session Handle */
+                          &xopenGbl.dsmSessInfo);       /* Output struct  */
+ 
+    if (rc)
+       {
+          sprintf(traceStr2, "BSAGetEnvironment(AFSdsmQuerySessInfo): error rc = %d", rc);
+          ourTrace(dsmHandle, TrFL, traceStr2);
+          AFSdsmTerminate(dsmHandle);
+         /* *BSAHandleP = 0; */
+       }
+       else
+       {
+          sprintf(traceStr2, "BSAGetEnvironment: Actual node=%s, actual DSM owner=%s, ServerName=%s.",
+                  xopenGbl.dsmSessInfo.id, xopenGbl.dsmSessInfo.owner, xopenGbl.dsmSessInfo.adsmServerName);
+          ourTrace(dsmHandle, TrFL, traceStr2);
+       }
+ 
+    strcpy(envString[0],"TSMSRVR=");
+    strcat(envString[0],xopenGbl.dsmSessInfo.serverHost);
+ 
+    strcpy(envString[1],"TSMMAXOBJ=");
+    maxObjNum = xopenGbl.dsmSessInfo.maxObjPerTxn;  /* convert to 32 bit */
+    sprintf(maxObjStr,"%lu", maxObjNum );
+    strcat(envString[1], maxObjStr);
+ 
+    strcpy(envString[2], "TSMSRVRSTANZA=");
+    strcat(envString[2], xopenGbl.dsmSessInfo.adsmServerName);
+ 
+    sprintf(traceStr2, "BSAGetEnvironment Value : TSM Server '%s', TSM Max Object '%s',TSM Server STANZA '%s'",
+          envString[0], envString[1], envString[2]);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    for (i=0; i< ADSM_ENV_STRS; i++) {
+      if ( *envP == NULL ) {  /* watch for NULL pointers */
+        /* Allocating memory for *envP.*/
+        *envP = (char *) malloc(sizeof(char) * BSA_MAX_DESC +1);
+ 
+        /* copy the content of envString[i] to *envP. */
+         strcpy(*envP,envString[i]);
+         envP++;
+      }
+    }
+ 
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle,"BSAGetEnvironment",
+                bsaRC,__FILE__,__LINE__)
+ }
+ 
+ BSA_Int16 BSABeginTxn(
+     long             BSAHandle
+ )
+ {
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    sprintf(traceStr2, "BSABeginTxn ENTRY: BSAHandle:%d", BSAHandle);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+   /*========================================================
+    don't actually issue BeginTxn yet, because we will do our
+    own for Get and Query
+    ========================================================*/
+ 
+    xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_IN_BSA_TXN); /* set on */
+    XOPENRETURN(BSAHandle, "BSABeginTxn",
+                BSA_RC_SUCCESS,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSAEndTxn(
+     long           BSAHandle,
+     Vote           vote
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+    dsUint8_t      dsmVote;
+    dsUint16_t     reason ;
+    char           rsMsg[DSM_MAX_RC_MSG_LENGTH + 1];
+    char           errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+    char           ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(rsMsg,        '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(ourMessage,    '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+    sprintf(traceStr2, "BSAEndTxn ENTRY: BSAHandle:%d Vote:>%d<", BSAHandle, vote);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    dsmHandle = BSAHandle;
+ 
+    if (xopenGbl.sessFlags & FL_IN_DSM_TXN)
+    {
+       if (vote == BSAVote_COMMIT)
+          dsmVote = DSM_VOTE_COMMIT;
+       else
+          if (vote == BSAVote_ABORT)
+             dsmVote = DSM_VOTE_ABORT;
+          else
+          {
+             sprintf(traceStr2, "BSAEndTxn: invalid vote (%d)", vote);
+             ourTrace(BSAHandle,TrFL, traceStr2);
+             bsaRC = BSA_RC_INVALID_VOTE;
+             XOPENRETURN(BSAHandle, "BSAEndTxn",bsaRC,__FILE__,__LINE__);
+          }
+ 
+ 
+       sprintf(traceStr2, "BSAEndTxn: issue AFSdsmEndTxn, vote=%s",
+                   dsmVote == DSM_VOTE_COMMIT ? "COMMIT" : "ABORT");
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       /*===========================================================
+         check if this EndTxn call was proceeded by a Send call which
+         returned WILL_ABORT. If so, make sure the vote is COMMIT
+         so we will get the server's reason code.
+         ===========================================================*/
+       if (xopenGbl.sessFlags & FL_RC_WILL_ABORT)
+       {
+          dsmVote = DSM_VOTE_COMMIT;
+ 
+          sprintf(traceStr2, "BSAEndTxn: sproceeded by RC_WILL_ABORT, so use vote=COMMIT");
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_RC_WILL_ABORT); /* set off*/
+       }
+ 
+       rc = AFSdsmEndTxn(dsmHandle, dsmVote, &reason);
+       xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_DSM_TXN); /* set off */
+ 
+       /*====================================================
+        if the caller wanted to Abort, then return rc=OK, not
+        our usual 2302 and reason 3
+        =====================================================*/
+       if ((dsmVote ==  DSM_VOTE_ABORT)     &&
+           (rc == DSM_RC_CHECK_REASON_CODE) &&
+           (reason == DSM_RC_ABORT_BY_CLIENT))
+ 
+          rc = DSM_RC_OK;
+ 
+       if (rc)
+       {
+          sprintf(traceStr2, "BSAEndTxn(AFSdsmEndTxn) error rc = %d", rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+          AFSdsmRCMsg(BSAHandle, reason, rsMsg);
+          sprintf(traceStr2, "BSAEndTxn: reason code = %d, Message='%s'", reason, rsMsg);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+          strcpy(ourMessage, ourRCMsg(reason, errPrefix));
+          ourLogEvent_Ex(BSAHandle,logBoth, ourMessage, errPrefix, logSevError);
+       }
+       xlateRC(BSAHandle, rc, &bsaRC);
+ 
+       if (rc == DSM_RC_CHECK_REASON_CODE) /* return reason code instead */
+       {
+          xlateRC(BSAHandle, reason, &bsaRC);
+       }
+    }
+ 
+    /*=== check if Query was terminated ===*/
+    if (xopenGbl.sessFlags & FL_IN_BSA_QRY)
+    {
+       AFSdsmEndQuery(dsmHandle);
+       xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_QRY); /* set off */
+    }
+ 
+    xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_TXN); /* set off */
+    XOPENRETURN(BSAHandle, "BSAEndTxn",
+                bsaRC,__FILE__,__LINE__);
+ }
+ 
+ void  BSAQueryApiVersion(
+ ApiVersion       *BSAapiVerP
+ )
+ 
+ {
+    /*===============================================================
+     Don't actually call the base QueryApiVersion call.
+     Use the defines from custom.h since this is what the application
+     sees in the header file. The constants should be the same,
+     but may get out of sync occasionally.
+     ===============================================================*/
+    BSAapiVerP->version = BSA_API_VERSION;
+    BSAapiVerP->release = BSA_API_RELEASE;
+    BSAapiVerP->level   = BSA_API_LEVEL;
+    return;
+ }
+ 
+ BSA_Int16 BSAQueryObject(
+ long              BSAHandle,
+ QueryDescriptor  *BSAqryDescP,
+ ObjectDescriptor *BSAobjDescP
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+    dsmObjName     objName;
+    dsUint8_t      dsmObjType;
+    dsmQueryType   query_type;
+    dsmQueryBuff   *query_buff;
+    DataBlk        qData;
+    qryArchiveData archiveData;
+    qryRespArchiveData respArchive;
+    qryBackupData  backupData;
+    qryRespBackupData  respBackup;
+    BSAObjectOwner upperNode;  /* upper cased node name */
+ 
+    char           errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+    char           ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(ourMessage,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+    dsmHandle = BSAHandle;
+ 
+    memset(&backupData, 0x00, sizeof(qryBackupData));
+ 
+    sprintf(traceStr2, "BSAQueryObject ENTRY: BSAHandle:%d ObjOwner(qryDesc):'%s' appOwner(qryDesc):'%s' \n ObjName(qryDesc):'%.*s%.*s' \n copyType:%d ObjectType:%d status:%d ",
+           BSAHandle,
+           BSAqryDescP->owner.bsaObjectOwner,
+           BSAqryDescP->owner.appObjectOwner,
+           100,BSAqryDescP->objName.objectSpaceName,
+           100,BSAqryDescP->objName.pathName,
+           BSAqryDescP->copyType,
+           BSAqryDescP->objectType,
+           BSAqryDescP->status);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    /*=====================================================
+     init objDesc area to 0's before we start to erase any
+     garbage that might be there.
+     =====================================================*/
+    memset(BSAobjDescP, 0x00, sizeof(ObjectDescriptor));
+ 
+    /*=== init global look ahead pointer to NULL ===*/
+    if (xopenGbl.nextQryP != NULL)
+    {
+       dsFree(xopenGbl.nextQryP);
+       xopenGbl.nextQryP = NULL;
+    }
+ 
+    /*=========================================================
+     if the node name is different - we won't query it compare
+     both the value passed on the BSAInit and the final value
+     used for the session (which may be different for Generate).
+     =========================================================*/
+    strcpy(upperNode, BSAqryDescP->owner.bsaObjectOwner);
+    StrUpper(upperNode);
+    if ((strcmp(upperNode, xopenGbl.dsmSessInfo.id)) &&
+       (strcmp(BSAqryDescP->owner.bsaObjectOwner, xopenGbl.bsaObjectOwner)))
+    {
+       sprintf(traceStr2,
+       "BSAQueryObject: BSAObjectOwner(%s) doesn't match value for session(%s).", upperNode, xopenGbl.dsmSessInfo.id);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = ADSM_RC_INVALID_NODE;
+       strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+       ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+       XOPENRETURN(BSAHandle, "BSAQueryObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    /*=====================================================
+      currently BSA_MAX_OSNAME = DSM_MAX_FSNAME_LENGTH
+      if this changes, use strncpy
+      ====================================================*/
+    if (strlen(BSAqryDescP->objName.objectSpaceName) > BSA_MAX_OSNAME)
+    {
+       sprintf(traceStr2, "BSAQueryObject: objectSpaceName too long (%d).",
+               strlen(BSAqryDescP->objName.objectSpaceName));
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_OBJNAME_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSAQueryObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+    /*=================================================================
+      the entire pathname gets copied into hl during parsing, so check
+      for that max len as well. For now these are the same value.
+      ================================================================*/
+    if (strlen(BSAqryDescP->objName.pathName) >
+        min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
+    {
+       sprintf(traceStr2, "BSAQueryObject: pathName too long (%d)",
+               strlen(BSAqryDescP->objName.pathName));
+       ourTrace(BSAHandle, TrFL, traceStr2);
+       bsaRC = BSA_RC_OBJNAME_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSAQueryObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+    if ((BSAqryDescP->objectType == BSAObjectType_FILE) ||
+        (BSAqryDescP->objectType == BSAObjectType_DATABASE))
+       dsmObjType = DSM_OBJ_FILE;
+    else
+       if (BSAqryDescP->objectType == BSAObjectType_DIRECTORY)
+          dsmObjType = DSM_OBJ_DIRECTORY;
+       else
+          if (BSAqryDescP->objectType == BSAObjectType_ANY)
+             dsmObjType = DSM_OBJ_ANY_TYPE;
+          else
+          {
+              sprintf(traceStr2,
+                      "BSAQueryObject: invalid objectType (%d)", BSAqryDescP->objectType);
+              ourTrace(BSAHandle,TrFL, traceStr2);
+              bsaRC = ADSM_RC_INVALID_OBJTYPE;
+              strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+              ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+              XOPENRETURN(BSAHandle, "BSAQueryObject",
+                          bsaRC,__FILE__,__LINE__);
+          }
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_BSA_TXN))
+    {
+       sprintf(traceStr2, "BSAQueryObject: issued without BSABeginTxn");
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_BAD_CALL_SEQUENCE;
+       XOPENRETURN(BSAHandle, "BSAQueryObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    /* store object name in ADSM structure */
+    strcpy(objName.fs,BSAqryDescP->objName.objectSpaceName) ;
+ 
+    if (!strcmp(BSAqryDescP->objName.pathName, "/*")) /* if they use a wildcard */
+    {  /* we need to use a wild card on both hl and ll since the path gets split */
+       strcpy(objName.hl, "*");  /* don't include delimiter in case there is
+                              no hl */
+       strcpy(objName.ll, "/*");
+    }
+    else
+       xparsePath(BSAHandle, BSAqryDescP->objName.pathName, objName.hl, objName.ll);
+ 
+       objName.objType = dsmObjType ;
+ 
+       /*=== save copy type for GetNextQuery call later ===*/
+       xopenGbl.copyType = BSAqryDescP->copyType;
+ 
+       if (BSAqryDescP->copyType == BSACopyType_ARCHIVE)
+       {
+          if (strlen(BSAqryDescP->desc) > ADSM_MAX_DESC)
+          {
+ 
+             sprintf(traceStr2, "BSAQueryObject: description longer than ADSM max (%d). ", strlen(BSAqryDescP->desc));
+             ourTrace(BSAHandle,TrFL, traceStr2);
+             bsaRC = BSA_RC_DESC_TOO_LONG;
+             XOPENRETURN(BSAHandle, "BSAQueryObject",
+                         bsaRC,__FILE__,__LINE__);
+          }
+ 
+          archiveData.stVersion = qryArchiveDataVersion;
+          archiveData.objName   = &objName;
+          archiveData.owner     = (char *)&BSAqryDescP->owner.appObjectOwner;
+ 
+          /*=================================================================
+            in the tm structure the month count starts with 0 and year is
+            the value since 1900.
+            Adjust the year value only if it isn't one of the boundary values
+            =================================================================*/
+ 
+          archiveData.insDateLowerBound.year   = BSAqryDescP->createTimeLB.tm_year;
+          if (archiveData.insDateLowerBound.year != ADSM_LOWEST_BOUND)
+             archiveData.insDateLowerBound.year  += 1900;
+          archiveData.insDateLowerBound.month  = BSAqryDescP->createTimeLB.tm_mon+1;
+          archiveData.insDateLowerBound.day    = BSAqryDescP->createTimeLB.tm_mday;
+          archiveData.insDateLowerBound.hour   = BSAqryDescP->createTimeLB.tm_hour;
+          archiveData.insDateLowerBound.minute = BSAqryDescP->createTimeLB.tm_min;
+          archiveData.insDateLowerBound.second = BSAqryDescP->createTimeLB.tm_sec;
+ 
+          archiveData.insDateUpperBound.year   = BSAqryDescP->createTimeUB.tm_year;
+          if (archiveData.insDateUpperBound.year != ADSM_HIGHEST_BOUND)
+              archiveData.insDateUpperBound.year  += 1900;
+          archiveData.insDateUpperBound.month  = BSAqryDescP->createTimeUB.tm_mon+1;
+          archiveData.insDateUpperBound.day    = BSAqryDescP->createTimeUB.tm_mday;
+          archiveData.insDateUpperBound.hour   = BSAqryDescP->createTimeUB.tm_hour;
+          archiveData.insDateUpperBound.minute = BSAqryDescP->createTimeUB.tm_min;
+          archiveData.insDateUpperBound.second = BSAqryDescP->createTimeUB.tm_sec;
+ 
+          archiveData.expDateLowerBound.year   = BSAqryDescP->expireTimeLB.tm_year;
+          if (archiveData.expDateLowerBound.year != ADSM_LOWEST_BOUND)
+              archiveData.expDateLowerBound.year  += 1900;
+          archiveData.expDateLowerBound.month  = BSAqryDescP->expireTimeLB.tm_mon+1;
+          archiveData.expDateLowerBound.day    = BSAqryDescP->expireTimeLB.tm_mday;
+          archiveData.expDateLowerBound.hour   = BSAqryDescP->expireTimeLB.tm_hour;
+          archiveData.expDateLowerBound.minute = BSAqryDescP->expireTimeLB.tm_min;
+          archiveData.expDateLowerBound.second = BSAqryDescP->expireTimeLB.tm_sec;
+ 
+          archiveData.expDateUpperBound.year   = BSAqryDescP->expireTimeUB.tm_year;
+          if (archiveData.expDateUpperBound.year != ADSM_HIGHEST_BOUND)
+             archiveData.expDateUpperBound.year  += 1900;
+          archiveData.expDateUpperBound.month  = BSAqryDescP->expireTimeUB.tm_mon+1;
+          archiveData.expDateUpperBound.day    = BSAqryDescP->expireTimeUB.tm_mday;
+          archiveData.expDateUpperBound.hour   = BSAqryDescP->expireTimeUB.tm_hour;
+          archiveData.expDateUpperBound.minute = BSAqryDescP->expireTimeUB.tm_min;
+          archiveData.expDateUpperBound.second = BSAqryDescP->expireTimeUB.tm_sec;
+ 
+          archiveData.descr = (char *)&BSAqryDescP->desc;
+          query_type = qtArchive;
+          query_buff = (dsmQueryBuff *)&archiveData;
+ 
+          qData.stVersion = DataBlkVersion;
+          qData.bufferLen = sizeof(qryRespArchiveData);
+          qData.bufferPtr = (char *)&respArchive;
+          respArchive.stVersion = qryRespArchiveDataVersion;
+    }
+    else
+       if (BSAqryDescP->copyType == BSACopyType_BACKUP)
+       {
+          if (BSAqryDescP->status == BSAObjectStatus_ACTIVE)
+             backupData.objState  = DSM_ACTIVE;
+          else
+             if (BSAqryDescP->status == BSAObjectStatus_INACTIVE)
+                backupData.objState  = DSM_INACTIVE;
+             else
+                if (BSAqryDescP->status == BSAObjectStatus_ANY)
+                   backupData.objState  = DSM_ANY_MATCH;
+                else
+                {
+                    sprintf(traceStr2,
+                            "BSAQueryObject: invalid status (%d)",
+                             BSAqryDescP->status);
+                    ourTrace(BSAHandle,TrFL, traceStr2);
+                    bsaRC = ADSM_RC_INVALID_STATUS;
+                    strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+                    ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+                    XOPENRETURN(BSAHandle, "BSAQueryObject",
+                                bsaRC,__FILE__,__LINE__);
+                }
+ 
+             backupData.stVersion = qryBackupDataVersion;
+             backupData.objName   = &objName;
+             backupData.owner     = (char *)&BSAqryDescP->owner.appObjectOwner;
+ 
+             query_type = qtBackup;
+             query_buff = (dsmQueryBuff *)&backupData;
+ 
+             qData.stVersion = DataBlkVersion;
+             qData.bufferLen = sizeof(qryRespBackupData);
+             qData.bufferPtr = (char *)&respBackup;
+             respBackup.stVersion = qryRespBackupDataVersion;;
+       }
+       else
+       {
+          sprintf(traceStr2,
+                            "BSAQueryObject: invalid copyType (%d)",
+                             BSAqryDescP->copyType);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          bsaRC = ADSM_RC_INVALID_COPYTYPE;
+          strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+          ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+          XOPENRETURN(BSAHandle, "BSAQueryObject",
+                      bsaRC,__FILE__,__LINE__);
+       }
+ 
+       /*=== now set flag for query ===*/
+       xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_IN_BSA_QRY); /* set on */
+ 
+       if ((rc = AFSdsmBeginQuery(dsmHandle,query_type,query_buff)))
+       {
+ 
+          sprintf(traceStr2, "BSAQueryObject(AFSdsmBeginQuery) error rc = %d", rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_QRY); /* set off */
+          xlateRC(BSAHandle, rc, &bsaRC);
+          XOPENRETURN(BSAHandle, "BSAQueryObject(AFSdsmBeginQuery)",
+                                  bsaRC,__FILE__,__LINE__);
+       }
+ 
+       rc = AFSdsmGetNextQObj(dsmHandle,&qData);
+       if (((rc == DSM_RC_OK) || (rc == DSM_RC_MORE_DATA)) && qData.numBytes)
+       {
+          BSAobjDescP->version = ObjectDescriptorVersion;
+          strcpy(BSAobjDescP->Owner.bsaObjectOwner, xopenGbl.dsmSessInfo.id);
+          BSAobjDescP->copyType = BSAqryDescP->copyType;
+          strcpy(BSAobjDescP->cGName, "\0");   /* no copy group name returned */
+ 
+          if (BSAqryDescP->copyType == BSACopyType_ARCHIVE)
+          {
+             fillArchiveResp(dsmHandle, BSAobjDescP, &respArchive);
+          }
+          else /* backup */
+          {
+             fillBackupResp(dsmHandle, BSAobjDescP, &respBackup);
+          }
+          /*=== look ahead and see if there is more or if this is really done ===*/
+          rc = AFSdsmGetNextQObj(dsmHandle,&qData);
+          if (( (rc == DSM_RC_OK) || (rc == DSM_RC_MORE_DATA)) && qData.numBytes)
+          { /*=== save the response we just got for later call ===*/
+             if (BSAqryDescP->copyType == BSACopyType_ARCHIVE)
+             {
+                if (!(xopenGbl.nextQryP = (char *)dsMalloc(sizeof(qryRespArchiveData))))
+                {
+ 
+                   sprintf(traceStr2, "BSAQueryObject: no memory for look ahead buffer");
+                   ourTrace(BSAHandle,TrFL, traceStr2);
+                   xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_QRY); /* set off */
+                   bsaRC = BSA_RC_NO_RESOURCES;
+                   XOPENRETURN(BSAHandle, "BSAQueryObject(AFSdsmGetNextQObj)",
+                               bsaRC,__FILE__,__LINE__);
+                }
+                memcpy(xopenGbl.nextQryP, &respArchive, sizeof(qryRespArchiveData));
+             }
+             else
+             {
+                if (!(xopenGbl.nextQryP = (char *)dsMalloc(sizeof(qryRespBackupData))))
+                {
+ 
+                   sprintf(traceStr2, "BSAQueryObject: no memory for look ahead buffer");
+                   ourTrace(BSAHandle,TrFL, traceStr2);
+                   xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_QRY); /* set off */
+                   bsaRC = BSA_RC_NO_RESOURCES;
+                   XOPENRETURN(BSAHandle, "BSAQueryObject(AFSdsmGetNextQObj)",
+                               bsaRC,__FILE__,__LINE__);
+ 
+                }
+                memcpy(xopenGbl.nextQryP, &respBackup, sizeof(qryRespBackupData));
+             }
+          }
+       else
+       {
+ 
+          sprintf(traceStr2, "BSAQueryObject(AFSdsmGetNextQObj) rc = %d", rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          AFSdsmEndQuery(dsmHandle);
+          xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_QRY); /* set off */
+       }
+ 
+    }
+    else /* could be FINISHED or an error */
+    {
+ 
+       sprintf(traceStr2, "BSAQueryObject(AFSdsmGetNextQObj) rc = %d", rc);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       AFSdsmEndQuery(dsmHandle);
+       xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_BSA_QRY); /* set off */
+    }
+ 
+    if (rc == DSM_RC_OK)
+    {
+       sprintf(traceStr2, "BSAQueryObject(AFSdsmGetNextQObj) rc = %d, ObjOwner(objDesc):'%s' appOwner(objDesc):'%s' \n ObjName(objDesc):'%.*s%.*s' \n copyType:%d copyId:'%d %d' cGName:'%s'",
+        rc,
+        BSAobjDescP->Owner.bsaObjectOwner,
+        BSAobjDescP->Owner.appObjectOwner,
+        100,BSAobjDescP->objName.objectSpaceName,
+        100,BSAobjDescP->objName.pathName,
+        BSAobjDescP->copyType,
+        BSAobjDescP->copyId.left,
+        BSAobjDescP->copyId.right,
+        BSAobjDescP->cGName == NULL ? "" : BSAobjDescP->cGName);
+        ourTrace(BSAHandle,TrFL, traceStr2);
+    }
+ 
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle, "BSAQueryObject",
+                bsaRC, __FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSAGetObject(
+     long              BSAHandle,
+     ObjectDescriptor *BSAobjDescP,
+     DataBlock        *BSAdataBlockP
+ )
+ {
+    dsInt16_t      rc = 0;
+    dsInt16_t      rc1 = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+    DataBlk        getBlk;
+    dsmGetType     getType;
+    dsmGetList     dsmObjList ;
+    char           rcMsg[DSM_MAX_RC_MSG_LENGTH + 1];
+    char           errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+    char           ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+ 
+    memset(rcMsg,         '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(ourMessage,    '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+    sprintf(traceStr2, "BSAGetObject ENTRY: BSAHandle:%d version:%d copyType:%d copyId:'%d %d' \n bufferLen:%d numBytes:%d ",
+            BSAHandle,
+            BSAobjDescP->version,
+            BSAobjDescP->copyType,
+            BSAobjDescP->copyId.left,
+            BSAobjDescP->copyId.right,
+            BSAdataBlockP->bufferLen,
+            BSAdataBlockP->numBytes);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    xopenGbl.oper = OPER_RECV_START;    /* save state for EndData later */
+ 
+    if (BSAobjDescP->version != ObjectDescriptorVersion)
+    {
+       sprintf(traceStr2,"Warning: BSAGetObject: objectDesc.version unexpected %d.", BSAobjDescP->version);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       /*==================================================================
+        don't treat this as an error now since it isn't defined in the spec
+        bsaRC = ADSM_RC_INVALID_ST_VER;
+        return(bsaRC);
+        =================================================================*/
+    }
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_BSA_TXN))
+    {
+       sprintf(traceStr2, "BSAGetObject: issued without BSABeginTxn");
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_BAD_CALL_SEQUENCE;
+       XOPENRETURN(BSAHandle, "BSAGetObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    /*=== Get the data ===*/
+    if (BSAobjDescP->copyType == BSACopyType_ARCHIVE)
+       getType = gtArchive;
+    else
+       if (BSAobjDescP->copyType == BSACopyType_BACKUP)
+          getType = gtBackup;
+       else
+       {
+          sprintf(traceStr2,
+                            "BSAGetObject: invalid copyType (%d)",
+                             BSAobjDescP->copyType);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          bsaRC = ADSM_RC_INVALID_COPYTYPE;
+          strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+          ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+          XOPENRETURN(BSAHandle, "BSAGetObject",
+                      bsaRC,__FILE__,__LINE__);
+       }
+ 
+    /*=== now update state since we'll issue a base API call ===*/
+    xopenGbl.oper = OPER_RECV_ISSUED;    /* save state for EndData later */
+    /*=== setup for a single object get ===*/
+ 
+    dsmObjList.stVersion = dsmGetListVersion ;
+    dsmObjList.numObjId = 1 ;
+    dsmObjList.objId = (ObjID *)dsMalloc(sizeof(ObjID) * dsmObjList.numObjId) ;
+ 
+    dsmObjList.objId[0].hi = BSAobjDescP->copyId.left ;
+    dsmObjList.objId[0].lo = BSAobjDescP->copyId.right ;
+ 
+    if ((rc = AFSdsmBeginGetData(dsmHandle,bTrue,   /* always say MountWait */
+                              getType,
+                              &dsmObjList)) != DSM_RC_OK)
+    {
+       sprintf(traceStr2, "BSAGetObject: Call to AFSdsmBeginGetData error rc = %d", rc);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       xlateRC(BSAHandle, rc, &bsaRC);
+       XOPENRETURN(BSAHandle, "BSAGetObject(AFSdsmBeginGetData)",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    /*********************************************************************/
+    getBlk.stVersion = DataBlkVersion ;
+    getBlk.bufferPtr = BSAdataBlockP->bufferPtr ;
+    getBlk.bufferLen = BSAdataBlockP->bufferLen;
+    getBlk.numBytes  = 0;
+ 
+    rc = AFSdsmGetObj(dsmHandle, &(dsmObjList.objId[0]), &getBlk) ;
+ 
+    if ((rc == DSM_RC_FINISHED) &&
+        (getBlk.numBytes != 0))    /* actually is data received */
+       rc = DSM_RC_MORE_DATA;      /* use different rc for consistency */
+                                   /* with Query. No data returned */
+                                   /* if rc = FINISHED.     */
+    if ((rc == DSM_RC_FINISHED) ||
+        (rc == DSM_RC_MORE_DATA))
+    {
+       /*=== data is already in the buffer ===*/
+       BSAdataBlockP->numBytes = (BSA_UInt16)getBlk.numBytes;
+    }
+    else
+    {
+       /*=== appl may call BSAEndData to clean up trxn but don't count on it... ===*/
+       rc1 = AFSdsmEndGetObj(dsmHandle);
+       rc1 = AFSdsmEndGetData(dsmHandle);
+       xopenGbl.sessFlags =
+                (xopenGbl.sessFlags | FL_END_DATA_DONE);  /* turn flag on */
+     }
+ 
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle, "BSAGetObject",
+                bsaRC,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSAGetData(
+     long              BSAHandle,
+     DataBlock        *BSAdataBlockP
+ )
+ {
+    dsInt16_t      rc = 0;
+    dsInt16_t      rc1 = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+    DataBlk        getBlk;
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+ 
+ 
+    sprintf(traceStr2, "BSAGetData ENTRY: BSAHandle:%d, bufferLen:%d, numBytes:%d",
+            BSAHandle,
+            BSAdataBlockP->bufferLen,
+            BSAdataBlockP->numBytes);
+    ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+    getBlk.stVersion = DataBlkVersion ;
+    getBlk.bufferPtr = BSAdataBlockP->bufferPtr ;
+    getBlk.bufferLen = BSAdataBlockP->bufferLen;
+    getBlk.numBytes  = 0;
+ 
+    rc = AFSdsmGetData(dsmHandle, &getBlk) ;
+ 
+    if ((rc == DSM_RC_FINISHED) &&
+        (getBlk.numBytes != 0))      /* actually is data received */
+       rc = DSM_RC_MORE_DATA;        /* use different rc for consistency */
+                                     /* with Query. No data returned */
+                                     /* if rc = FINISHED.     */
+ 
+    if ((rc == DSM_RC_FINISHED) ||
+        (rc == DSM_RC_MORE_DATA))
+    {
+       /*=== data is already in the buffer ===*/
+       BSAdataBlockP->numBytes = (BSA_UInt16)getBlk.numBytes;
+    }
+    else
+    {
+       sprintf(traceStr2, "BSAGetData: Call to AFSdsmGetData error rc = %d", rc);
+       ourTrace(BSAHandle, TrFL,traceStr2);
+ 
+       /*=== appl may call BSAEndData to clean up trxn but don't count on it... ===*/
+       rc1 = AFSdsmEndGetObj(dsmHandle);
+       rc1 = AFSdsmEndGetData(dsmHandle);
+       xopenGbl.sessFlags =
+                (xopenGbl.sessFlags | FL_END_DATA_DONE);  /* turn flag on */
+    }
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle, "BSAGetData(AFSdsmGetData)",
+                bsaRC,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSASendData(
+     long           BSAHandle,
+     DataBlock     *BSAdataBlockP
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+    DataBlk        dataBlkArea;
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+ 
+ 
+    sprintf(traceStr2, "BSASendData ENTRY: BSAHandle:%d bufferLen: %d numBytes: %d ",
+            BSAHandle,
+            BSAdataBlockP->bufferLen,
+            BSAdataBlockP->numBytes);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    /*=== check for NULL dataBlock pointer ===*/
+    if (BSAdataBlockP == NULL)
+       XOPENRETURN(BSAHandle, "BSASendData",
+                   BSA_RC_NULL_POINTER,__FILE__,__LINE__);
+       dataBlkArea.stVersion = DataBlkVersion ;
+       dataBlkArea.bufferPtr = BSAdataBlockP->bufferPtr ;
+       dataBlkArea.bufferLen = BSAdataBlockP->bufferLen;
+ 
+       rc = AFSdsmSendData(dsmHandle, &dataBlkArea);
+ 
+       if (rc)
+       {
+ 
+          sprintf(traceStr2, "BSASendData(AFSdsmSendData) error rc = %d", rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+          if (rc == DSM_RC_WILL_ABORT)  /* save flag */
+             xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_RC_WILL_ABORT);
+       }
+       BSAdataBlockP->numBytes = (BSA_UInt16)dataBlkArea.numBytes;
+       sprintf(traceStr2, "BSASendData(AFSdsmSendData): BSAHandle:%d bufferLen: %d numBytes sent: %d ",
+            BSAHandle,
+            BSAdataBlockP->bufferLen,
+            BSAdataBlockP->numBytes);
+       ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+       xlateRC(BSAHandle, rc, &bsaRC);
+       XOPENRETURN(BSAHandle, "BSASendData",
+                   BSA_RC_SUCCESS,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSAEndData(
+     long          BSAHandle
+ )
+ {
+    dsInt16_t      rc = 0;
+    dsInt16_t      rc1 = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+ 
+ 
+    sprintf(traceStr2, "BSAEndData ENTRY: BSAHandle:%d", BSAHandle);
+    ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+    /*=======================================================
+      check the state - don't issue base API call unless one
+      was called previously, or else we get a sequence error.
+      ======================================================*/
+ 
+    if (xopenGbl.oper == OPER_SEND_ISSUED)
+    {
+       rc = AFSdsmEndSendObj(dsmHandle);
+       if (rc)
+       {
+ 
+          sprintf(traceStr2, "BSAEndData(AFSdsmEndSendObj) error rc = %d", rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          xlateRC(BSAHandle, rc, &bsaRC);
+       }
+    }
+    else
+       if (xopenGbl.oper == OPER_RECV_ISSUED)
+       {
+           if (xopenGbl.sessFlags & FL_END_DATA_DONE)   /* EndData processing */
+              xopenGbl.sessFlags =                     /*  already done */
+                    (xopenGbl.sessFlags ^ FL_END_DATA_DONE);  /* turn flag off */
+          else
+          {
+             rc = AFSdsmEndGetObj(dsmHandle);
+             if (rc)
+             {
+                sprintf(traceStr2, "BSAEndData(AFSdsmEndGetObj) error rc = %d", rc);
+                ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+                /*==============================================================
+                 this may get 'Out of sequence error' if previous GetObject
+                 had rc=2 (no match). Don't return this to caller - too confusing
+                 ===============================================================*/
+                if (rc != DSM_RC_BAD_CALL_SEQUENCE)
+                xlateRC(BSAHandle, rc, &bsaRC);
+             }
+ 
+             rc = AFSdsmEndGetData(dsmHandle);
+             if (rc)
+             {
+                sprintf(traceStr2, "BSAEndData(AFSdsmEndGetData) error rc = %d", rc);
+                ourTrace(BSAHandle, TrFL, traceStr2);
+                xlateRC(BSAHandle, rc, &bsaRC);
+             }
+          }
+       }
+    else  /* invalid state */
+       if ((xopenGbl.oper != OPER_RECV_START) &&
+           (xopenGbl.oper != OPER_SEND_START))
+       {
+          sprintf(traceStr2, "BSAEndData: BSAEndData but not Send or Recv");
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          bsaRC = BSA_RC_BAD_CALL_SEQUENCE;
+       }
+ 
+    xopenGbl.oper = OPER_NONE;
+    XOPENRETURN(BSAHandle, "BSAEndData",bsaRC,__FILE__,__LINE__);
+ }
+ 
+ BSA_Int16 BSACreateObject(
+     long              BSAHandle,
+     ObjectDescriptor *BSAobjDescP,
+     DataBlock        *BSAdataBlockP
+ )
+ {
+    dsInt16_t          rc = 0;
+    BSA_Int16          bsaRC = 0;
+    dsUint32_t         dsmHandle;
+    regFSData          regFilespace ;
+    dsmObjName         objName ;
+    ObjAttr            objAttrArea;
+    sndArchiveData     archData;
+    DataBlk            dataBlkArea;
+    dsmSendType        sendType;
+    dsUint8_t          dsmObjType;
+    XAPIObjInfo        xapiObjInfo;
+    mcBindKey          mcBindKey;
+    BSAObjectOwner     upperNode;  /* upper cased node name */
+    char               errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+    char               ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(ourMessage,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+    dsmHandle = BSAHandle;
+ 
+    if (BSAobjDescP != NULL && BSAdataBlockP != NULL)
+    {
+    sprintf(traceStr2, "BSACreateObject ENTRY: BSAHandle:%d ObjOwner:'%s' appOwner:'%s' \n ObjName:'%.*s%.*s' \n objType:%d  size:'%d %d' resourceType:'%s'  \n bufferLen:%d numBytes:%d ",
+ 
+            BSAHandle,
+            BSAobjDescP->Owner.bsaObjectOwner[0] != '\0' ? BSAobjDescP->Owner.bsaObjectOwner : "",
+            BSAobjDescP->Owner.appObjectOwner[0] != '\0' ?  BSAobjDescP->Owner.appObjectOwner : "",
+            100,BSAobjDescP->objName.objectSpaceName[0] != '\0' ? BSAobjDescP->objName.objectSpaceName
+            : "",
+            100,BSAobjDescP->objName.pathName[0] != '\0' ? BSAobjDescP->objName.pathName : "",
+            BSAobjDescP->objectType,
+            BSAobjDescP->size.left,
+            BSAobjDescP->size.right,
+            BSAobjDescP->resourceType[0] != '\0' ?  BSAobjDescP->resourceType : "" ,
+            BSAdataBlockP->bufferLen,
+            BSAdataBlockP->numBytes);
+   }
+   else
+   {
+     if (BSAobjDescP == NULL)
+       {
+          bsaRC = BSA_RC_NULL_POINTER;
+          XOPENRETURN(BSAHandle, "BSACreateObject",
+                   bsaRC,__FILE__,__LINE__);
+       }
+     sprintf(traceStr2, "BSACreateObject ENTRY: BSAHandle:%d", BSAHandle);
+   }
+ 
+   ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+    xopenGbl.oper = OPER_SEND_START;    /* save state for EndData later */
+    /*=================================================================
+    if (BSAobjDescP->version != ObjectDescriptorVersion)
+        BSA spec doesn't require this currently..
+    =================================================================*/
+ 
+    /*===============================================================
+     if the node name is different - we won't create it compare both
+     the value passed on the BSAInit and the final value used for the
+     session (which may be different for Generate)
+     ===============================================================*/
+    strcpy(upperNode, BSAobjDescP->Owner.bsaObjectOwner);
+    StrUpper(upperNode);
+    if ((strcmp(upperNode, xopenGbl.dsmSessInfo.id)) &&
+       (strcmp(BSAobjDescP->Owner.bsaObjectOwner, xopenGbl.bsaObjectOwner)))
+    {
+       sprintf(traceStr2,
+              "BSACreateObject: BSAObjectOwner(%s) doesn't match value for session(%s).",
+               upperNode, xopenGbl.dsmSessInfo.id);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = ADSM_RC_INVALID_NODE;
+       strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+       ourLogEvent_Ex(BSAHandle,logLocal, ourMessage, errPrefix, logSevError);
+       XOPENRETURN(BSAHandle, "BSACreateObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    /*=== check string lengths - if this too long, it won't fit in our objInfo ===*/
+    if (strlen(BSAobjDescP->desc) > ADSM_MAX_DESC)
+    {
+       sprintf(traceStr2,"BSACreateObject: description longer than TSM max (%d). ",
+               strlen(BSAobjDescP->desc));
+       ourTrace(BSAHandle, TrFL, traceStr2);
+       bsaRC = BSA_RC_DESC_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSACreateObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+    if (strlen(BSAobjDescP->objectInfo) > ADSM_MAX_OBJINFO)
+    {
+       sprintf(traceStr2,"BSACreateObject: objInfo longer than TSM max (%d).",
+       strlen(BSAobjDescP->objectInfo));
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_OBJINFO_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSACreateObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_BSA_TXN))
+    {
+       sprintf(traceStr2, "BSACreateObject issued without BSABeginTxn");
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_BAD_CALL_SEQUENCE;
+       XOPENRETURN(BSAHandle, "BSACreateObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    if (strlen(BSAobjDescP->objName.objectSpaceName) > BSA_MAX_OSNAME)
+    {
+       sprintf(traceStr2, "BSACreateObject: objectSpaceName too long (%d)",
+                        strlen(BSAobjDescP->objName.objectSpaceName));
+       ourTrace(BSAHandle, TrFL, traceStr2);
+       bsaRC = BSA_RC_OBJNAME_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSACreateObject:",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_DSM_TXN))        /* first CreateObj */
+    { /* can't issue RegisterFS if already in Txn */
+       /*=== Register the file space ===*/
+       regFilespace.stVersion = regFSDataVersion ;
+       regFilespace.fsName = BSAobjDescP->objName.objectSpaceName ;
+ 
+       /*===  use resource type for fsType (as it was intended)  ===*/
+ 
+       regFilespace.fsType = BSAobjDescP->resourceType ;
+       regFilespace.capacity.lo = 0;
+       regFilespace.capacity.hi = 0;
+       regFilespace.occupancy.lo = 0;
+       regFilespace.occupancy.hi = 0;
+       #if _OPSYS_TYPE == DS_AIX
+          regFilespace.fsAttr.unixFSAttr.fsInfoLength = strlen(XAPI_FSINFO) ;
+          strcpy(regFilespace.fsAttr.unixFSAttr.fsInfo, XAPI_FSINFO);
+       #else
+          regFilespace.fsAttr.dosFSAttr.fsInfoLength = strlen(XAPI_FSINFO) ;
+          strcpy(regFilespace.fsAttr.dosFSAttr.fsInfo, XAPI_FSINFO);
+          regFilespace.fsAttr.dosFSAttr.driveLetter = 'X';
+       #endif
+       rc = AFSdsmRegisterFS(dsmHandle, &regFilespace) ;
+       if ((rc != 0) && (rc != DSM_RC_FS_ALREADY_REGED))
+       {
+          sprintf(traceStr2, "BSACreateObject(AFSdsmRegisterFS) error rc = %d",rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+          xlateRC(BSAHandle, rc, &bsaRC);
+          XOPENRETURN(BSAHandle, "BSACreateObject(AFSdsmRegisterFS)",
+                      bsaRC,__FILE__,__LINE__);
+       }
+    }
+ 
+    /*========================================================
+     Check for invalid copyType before sending data. Log error
+     to dsirror.log file.
+     ========================================================*/
+     if (BSAobjDescP->copyType == BSACopyType_ARCHIVE)
+        sendType = stArchiveMountWait;
+     else
+        if (BSAobjDescP->copyType == BSACopyType_BACKUP)
+           sendType = stBackupMountWait;
+        else
+        {
+            sprintf(traceStr2,
+                   "BSACreateObject: invalid copyType (%d)",
+                    BSAobjDescP->copyType);
+            ourTrace(BSAHandle,TrFL, traceStr2);
+            bsaRC = ADSM_RC_INVALID_COPYTYPE;
+            strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+            ourLogEvent_Ex(BSAHandle,logLocal, ourMessage, errPrefix, logSevError);
+            XOPENRETURN(BSAHandle, "BSACreateObject",
+                        bsaRC,__FILE__,__LINE__);
+        }
+ 
+    if ((BSAobjDescP->objectType == BSAObjectType_FILE) ||
+       (BSAobjDescP->objectType == BSAObjectType_DATABASE) ||
+       (BSAobjDescP->objectType == BSAObjectType_ANY))
+ 
+          dsmObjType = DSM_OBJ_FILE;
+    else
+       if (BSAobjDescP->objectType == BSAObjectType_DIRECTORY)
+          dsmObjType = DSM_OBJ_DIRECTORY;
+       else
+       {
+          sprintf(traceStr2,
+                "BSACreateObject: invalid objectType (%d)",
+                 BSAobjDescP->objectType);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          bsaRC = ADSM_RC_INVALID_OBJTYPE;
+          strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+          ourLogEvent_Ex(BSAHandle,logLocal, ourMessage, errPrefix, logSevError);
+          XOPENRETURN(BSAHandle, "BSACreateObject",
+                     bsaRC,__FILE__,__LINE__);
+       }
+ 
+    /*==================================================================
+     put in a check here - count the number of objects per txn
+     and compare with xopenGbl.sessInfo.maxObjPerTxn
+     If reach the limit, EndTxn and start a new one
+     OK to do this without telling the BSA caller?
+     Or should we exit with an error to tell them the limit is reached ?
+     ==================================================================*/
+ 
+     if (!(xopenGbl.sessFlags & FL_IN_DSM_TXN))
+     {
+       rc = AFSdsmBeginTxn(dsmHandle);
+ 
+       if (rc)
+       {
+          sprintf(traceStr2, "BSACreateObject(AFSdsmBeginTxn) error rc = %d", rc);
+          ourTrace(BSAHandle,TrFL, traceStr2);
+          xlateRC(BSAHandle, rc, &bsaRC);
+          XOPENRETURN(BSAHandle, "BSACreateObject(AFSdsmBeginTxn)",
+                      bsaRC,__FILE__,__LINE__);
+       }
+       xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_IN_DSM_TXN); /* set on */
+     }
+ 
+     /*=== Backup the data  ===*/
+ 
+    /*================================================================
+      the entire pathname gets copied into hl during parsing, so
+      check for that max len as well. For now these are the same value.
+      =================================================================*/
+    if (strlen(BSAobjDescP->objName.pathName) >
+             min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
+    {
+       sprintf(traceStr2, "BSACreateObject: pathName too long (%d)",
+               strlen(BSAobjDescP->objName.pathName));
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_OBJNAME_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSACreateObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    strcpy(objName.fs,BSAobjDescP->objName.objectSpaceName) ;
+    /*=== previous code to use only ll field ===*/
+    /*objName.hl[0] = '\0';
+      strcpy(objName.ll,BSAobjDescP->objName.pathName) ;
+    */
+    xparsePath(BSAHandle, BSAobjDescP->objName.pathName, objName.hl, objName.ll);
+    objName.objType = dsmObjType ;
+ 
+    objAttrArea.stVersion = ObjAttrVersion ;
+    strcpy(objAttrArea.owner,BSAobjDescP->Owner.appObjectOwner);
+    objAttrArea.sizeEstimate.hi = BSAobjDescP->size.left;
+    objAttrArea.sizeEstimate.lo = BSAobjDescP->size.right;
+    objAttrArea.objCompressed = bFalse ;  /* let COMPRESSION option decide */
+    /*=== whether there's actually compression ===*/
+    objAttrArea.objInfoLength = sizeof(XAPIObjInfo);
+    objAttrArea.objInfo = (char *)&xapiObjInfo ;
+ 
+    memset(&xapiObjInfo,0x00,sizeof(XAPIObjInfo));
+    strcpy(xapiObjInfo.resourceType, BSAobjDescP->resourceType);
+    xapiObjInfo.size.left = BSAobjDescP->size.left;
+    xapiObjInfo.size.right = BSAobjDescP->size.right;
+    strcpy(xapiObjInfo.partDesc, BSAobjDescP->desc);
+    strcpy(xapiObjInfo.partObjInfo, BSAobjDescP->objectInfo);
+ 
+    /*=== check if a lifecycle group name was passed to us ===*/
+    if (strlen(BSAobjDescP->lGName))
+       objAttrArea.mcNameP = (char *)BSAobjDescP->lGName ;
+    else
+       objAttrArea.mcNameP = NULL;
+ 
+       dataBlkArea.stVersion = DataBlkVersion ;
+       if (BSAdataBlockP == NULL)
+       {
+          dataBlkArea.bufferPtr = NULL;
+          dataBlkArea.bufferLen = 0;
+       }
+       else
+       {
+          dataBlkArea.bufferPtr = BSAdataBlockP->bufferPtr ;
+          dataBlkArea.bufferLen = BSAdataBlockP->bufferLen;
+       }
+ 
+       /*=======================================================
+        always issue BindMC because we don't expect applications
+        to call ResolveLifecycleGroup since it isn't in the
+        Data Movement subset
+        =======================================================*/
+        mcBindKey.stVersion = mcBindKeyVersion ;
+        rc = AFSdsmBindMC(dsmHandle, &objName, sendType, &mcBindKey);
+        if (rc)
+        {
+           sprintf(traceStr2, "BSACreateObject(AFSdsmBindMC): error rc = %d", rc);
+           ourTrace(BSAHandle, TrFL, traceStr2);
+           xlateRC(BSAHandle, rc, &bsaRC);
+           XOPENRETURN(BSAHandle, "BSACreateObject(dsnBindMC)",
+                       bsaRC,__FILE__,__LINE__);
+        }
+ 
+        /*=== now update state since we'll issue the base Send call ===*/
+ 
+        xopenGbl.oper = OPER_SEND_ISSUED;    /* save state for EndData later */
+ 
+        switch (sendType)
+        {
+           case (stBackupMountWait) :
+           rc = AFSdsmSendObj(dsmHandle,
+                           sendType,
+                           NULL,
+                           &objName,
+                           &objAttrArea,
+                           &dataBlkArea);
+           break;
+ 
+           case (stArchiveMountWait) :
+           archData.stVersion = sndArchiveDataVersion;
+           archData.descr = (char *)(BSAobjDescP->desc);
+           rc = AFSdsmSendObj(dsmHandle,
+                           sendType,
+                           &archData,
+                           &objName,
+                           &objAttrArea,
+                           &dataBlkArea);
+           break;
+           default : ;
+        }
+ 
+        if (rc != DSM_RC_OK)
+        {
+           sprintf(traceStr2, "BSACreateObject(AFSdsmSendObj) error rc = %d", rc);
+           ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+           if (rc == DSM_RC_WILL_ABORT)  /* save flag */
+              xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_RC_WILL_ABORT);
+ 
+           xlateRC(BSAHandle, rc, &bsaRC);
+           XOPENRETURN(BSAHandle, "BSACreateObject(AFSdsmSendObj)",
+                       bsaRC,__FILE__,__LINE__);
+        }
+    XOPENRETURN(BSAHandle, "BSACreateObject",
+                BSA_RC_SUCCESS, __FILE__,__LINE__);
+ }
+ 
+ 
+ BSA_Int16 BSADeleteObject(
+     long           BSAHandle,
+     CopyType       copyType,
+     ObjectName     *BSAobjNameP,
+     CopyId         *copyidP
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+    dsUint16_t     reason ;                   /* for AFSdsmEndTxn */
+    dsmObjName     dsmobjName;
+ 
+    dsmDelType delType;
+    dsmDelInfo delInfo;
+ 
+    delList *llHeadP = NULL;
+    delList *llTailP = NULL;
+    delList *ll = NULL;
+ 
+    char errPrefix[DSM_MAX_RC_MSG_LENGTH + 1];
+    char ourMessage[DSM_MAX_RC_MSG_LENGTH + 1];
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    memset(errPrefix,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+    memset(ourMessage,     '\0', DSM_MAX_RC_MSG_LENGTH + 1);
+ 
+    dsmHandle = BSAHandle;
+ 
+    sprintf(traceStr2, "BSADeleteObject ENTRY: BSAHandle:%d CopyType:%d \n ObjName:'%.*s%.*s' copyidP:'%d %d'.",
+            BSAHandle,
+            copyType,
+            100,BSAobjNameP->objectSpaceName,
+            100,BSAobjNameP->pathName,
+            copyidP->left,
+            copyidP->right);
+    ourTrace(BSAHandle, TrFL, traceStr2);
+    if (copyType != BSACopyType_ARCHIVE)
+    {
+       sprintf(traceStr2,
+               "BSADeleteObject: invalid copyType %d",
+                copyType);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = ADSM_RC_INVALID_COPYTYPE;
+       strcpy(ourMessage, ourRCMsg(bsaRC, errPrefix));
+       ourLogEvent_Ex(BSAHandle, logLocal, ourMessage, errPrefix, logSevError);
+       XOPENRETURN(BSAHandle, "BSADeleteObject",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_BSA_TXN))
+    {
+       sprintf(traceStr2, "BSADeleteObject issued without BSABeginTxn");
+       ourTrace(BSAHandle, TrFL, traceStr2);
+ 
+       bsaRC = BSA_RC_BAD_CALL_SEQUENCE;
+       XOPENRETURN(BSAHandle, "BSADeleteObject:",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    strcpy(dsmobjName.fs, BSAobjNameP->objectSpaceName);
+    xparsePath(BSAHandle, BSAobjNameP->pathName, dsmobjName.hl, dsmobjName.ll);
+    dsmobjName.objType = DSM_OBJ_FILE;
+ 
+    if (!copyidP)    /* NULL, so query and delete all with same name */
+    {
+       if (xopenGbl.sessFlags & FL_IN_DSM_TXN)
+       /*=== if a trxn had been started, end it before doing Query ===*/
+       {
+          rc = AFSdsmEndTxn(dsmHandle, DSM_VOTE_COMMIT, &reason);
+          xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_DSM_TXN); /* set off */
+       }
+       rc = buildList(dsmHandle, &dsmobjName, &llHeadP, &llTailP);
+       if (rc)
+       {
+          bsaRC = BSA_RC_OBJECT_NOT_FOUND;
+          XOPENRETURN(BSAHandle, "BSADeleteObject(buildList)",
+                      bsaRC,__FILE__,__LINE__);
+       }
+    }
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_DSM_TXN))        /* first call */
+    {
+       rc = AFSdsmBeginTxn(dsmHandle);
+       if (rc)
+       {
+          xlateRC(BSAHandle, rc, &bsaRC);
+          XOPENRETURN(dsmHandle,"BSADeleteObject(AFSdsmBeginTxn)",
+                      bsaRC,__FILE__,__LINE__);
+       }
+       xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_IN_DSM_TXN); /* set on */
+    }
+ 
+    delType = dtArchive;
+    delInfo.archInfo.stVersion = delArchVersion;
+ 
+    if (copyidP)   /* single ID to delete */
+    {
+       delInfo.archInfo.objId.hi  = copyidP->left;
+       delInfo.archInfo.objId.lo  = copyidP->right;
+ 
+       if ((rc = AFSdsmDeleteObj(dsmHandle,delType,delInfo)) != DSM_RC_OK)
+       {
+          sprintf(traceStr2, "BSADeleteObject: AFSdsmDeleteObj error rc = %d", rc);
+          ourTrace(dsmHandle,TrFL, traceStr2);
+       }
+    }
+    else   /* multiple IDs to delete */
+    {
+       ll = llHeadP;
+       while (ll)
+       {
+          delInfo.archInfo.objId.hi  = ll->objId.hi;
+          delInfo.archInfo.objId.lo  = ll->objId.lo;
+          if ((rc = AFSdsmDeleteObj(dsmHandle, delType, delInfo)) != DSM_RC_OK)
+          {
+             sprintf(traceStr2, "BSADeleteObject: AFSdsmDeleteObj error rc = %d", rc);
+             ourTrace(dsmHandle, TrFL, traceStr2);
+             /*=== break and get out of loop, or keep going? ===*/
+          }
+          /*=== incr to next list entry ===*/
+          ll = ll->next;
+       }
+       /*=== free list now that done ===*/
+       rc =  freeList(&llHeadP, &llTailP);
+    }
+ 
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle,"BSADeleteObject",
+                bsaRC,__FILE__,__LINE__)
+ }
+ 
+ BSA_Int16 BSAMarkObjectInactive(
+     long            BSAHandle,
+     ObjectName     *BSAobjNameP
+ )
+ {
+    dsInt16_t      rc = 0;
+    BSA_Int16      bsaRC = 0;
+    dsUint32_t     dsmHandle;
+ 
+    dsmObjName           dsmobjName;
+ 
+    qryBackupData        queryBuffer;       /* for query Backup */
+    qryRespBackupData    qbDataArea;
+    DataBlk              qDataBlkArea;
+ 
+    dsmDelType           delType;
+    dsmDelInfo           delInfo;
+ 
+    dsUint16_t           reason ;                   /* for AFSdsmEndTxn */
+    /*=== build list of all objTypes we find for this name ===*/
+    dsInt16_t            i;
+    dsInt16_t            numTypes;
+    dsUint8_t            listObjType[5];    /* only 2 objTypes defined today */
+    dsUint32_t           listCopyGroup[5];
+ 
+    if(!dsm_init)
+    {
+ #ifdef DEBUG_BUTC
+         printf("TSM library not mounted. \n");
+ #endif
+         if (dsm_MountLibrary())
+         {
+                 printf("TSM Library initialisation failed. \n");
+                 return 1 ;
+         }
+ #ifdef DEBUG_BUTC
+         printf("TSM Library initialisation SUCCESS. \n");
+ #endif
+    }
+ 
+    dsmHandle = BSAHandle;
+    memset(&delInfo, 0x00, sizeof(dsmDelInfo));
+    memset(&queryBuffer, 0x00, sizeof(qryBackupData));
+ 
+    sprintf(traceStr2, "BSAMarkObjectInactive ENTRY: BSAHandle:%d \n ObjName:'%.*s%.*s'.",
+            BSAHandle,
+            100, BSAobjNameP->objectSpaceName,
+            100, BSAobjNameP->pathName);
+    ourTrace(dsmHandle, TrFL, traceStr2);
+ 
+    if (!(xopenGbl.sessFlags & FL_IN_BSA_TXN))
+    {
+       sprintf(traceStr2, "BSAMarkObjectInactive: issued without BSABeginTxn.");
+       ourTrace(BSAHandle, TrFL, traceStr2);
+       bsaRC = BSA_RC_BAD_CALL_SEQUENCE;
+       XOPENRETURN(BSAHandle, "BSAMarkObjectInactive",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    if (strlen(BSAobjNameP->objectSpaceName) > DSM_MAX_FSNAME_LENGTH)
+    {
+       sprintf(traceStr2, "BSAMarkObjectInactive: objectSpaceName too long (%d)", strlen(BSAobjNameP->objectSpaceName));
+       ourTrace(BSAHandle,TrFL, traceStr2);
+ 
+       bsaRC = BSA_RC_OBJNAME_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSAMarkObjectInactive",
+                   bsaRC,__FILE__,__LINE__);
+    }
+    /*===============================================================
+     The entire pathname gets copied into hl during parsing, so
+     check for that max len as well. For now these are the same value.
+     =============================================================== */
+    if (strlen(BSAobjNameP->pathName) >
+        min(DSM_MAX_HL_LENGTH, BSA_MAX_PATHNAME))
+    {
+       sprintf(traceStr2, "BSAMarkObjectInactive: pathName too long (%d)",
+                          strlen(BSAobjNameP->pathName));
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       bsaRC = BSA_RC_OBJNAME_TOO_LONG;
+       XOPENRETURN(BSAHandle, "BSAMarkObjectInactive",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    /*==============================================================
+     we don't allow any wildcard in name because that could retrieve
+     LOTS of objects and make list processing more complicated.
+     XBSA spec implies a single object.
+     ==============================================================*/
+    if ( strchr(BSAobjNameP->objectSpaceName, '*') ||
+         strchr(BSAobjNameP->objectSpaceName, '?') ||
+         strchr(BSAobjNameP->pathName,        '*') ||
+         strchr(BSAobjNameP->pathName,        '?'))
+    {
+ 
+       sprintf(traceStr2, "BSAMarkObjectInactive: objName contains a wildcard.")
+ ;
+       ourTrace(BSAHandle, TrFL, traceStr2);
+       /*=== could have a more specific rc, use this for now ===*/
+       bsaRC = BSA_RC_ABORT_ACTIVE_NOT_FOUND;
+       XOPENRETURN(BSAHandle, "BSAMarkObjectInactive",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    strcpy(dsmobjName.fs, BSAobjNameP->objectSpaceName);
+    xparsePath(BSAHandle, BSAobjNameP->pathName, dsmobjName.hl, dsmobjName.ll);
+    dsmobjName.objType = DSM_OBJ_ANY_TYPE;
+ 
+    /*============================================================
+     A Backup Delete must include the copy Group and objType this
+     wasn't passed in, so we have to do a query.
+     ============================================================*/
+ 
+    queryBuffer.stVersion = qryBackupDataVersion ;
+    queryBuffer.objName = &dsmobjName;
+    queryBuffer.owner   = xopenGbl.dsmSessInfo.owner;
+    queryBuffer.objState = DSM_ACTIVE;              /* only get active one */
+ 
+    if ((rc=AFSdsmBeginQuery(dsmHandle, qtBackup,
+                         (void *)&queryBuffer )) != DSM_RC_OK)
+    {
+       sprintf(traceStr2, "BSAMarkObjectInactive: Call to AFSdsmBeginQuery for Backup error rc = %d", rc);
+       ourTrace(BSAHandle,TrFL, traceStr2);
+       xlateRC(BSAHandle, rc, &bsaRC);
+       if ((rc == DSM_RC_ABORT_NO_MATCH) ||    /* special rc for MarkInact */
+           (rc == DSM_RC_FILE_SPACE_NOT_FOUND))
+          bsaRC = BSA_RC_ABORT_ACTIVE_NOT_FOUND;
+ 
+       rc = AFSdsmEndQuery(dsmHandle);
+       XOPENRETURN(BSAHandle, "BSAMarkObjectInactive: AFSdsmBeginQuery",
+                   bsaRC,__FILE__,__LINE__);
+    }
+ 
+    qbDataArea.stVersion   = qryRespBackupDataVersion;
+    qDataBlkArea.stVersion = DataBlkVersion ;
+    qDataBlkArea.bufferPtr = (char *)&qbDataArea;
+    qDataBlkArea.bufferLen = sizeof(qryRespBackupData);
+ 
+    numTypes = 0;
+    rc = AFSdsmGetNextQObj(dsmHandle, &qDataBlkArea);
+    while (((rc == DSM_RC_MORE_DATA) ||
+          (rc == DSM_RC_FINISHED)) &&
+           qDataBlkArea.numBytes)
+    {  /* save copy Group we got */
+       listCopyGroup[numTypes] = qbDataArea.copyGroup;
+       listObjType[numTypes]   = qbDataArea.objName.objType;
+       numTypes++;
+       rc = AFSdsmGetNextQObj(dsmHandle, &qDataBlkArea);
+    }
+ 
+    if (rc != DSM_RC_FINISHED)
+    {
+       xlateRC(BSAHandle, rc, &bsaRC);
+       if ((rc == DSM_RC_ABORT_NO_MATCH) || /* special rc for MarkInact */
+           (rc == DSM_RC_FILE_SPACE_NOT_FOUND))
+          bsaRC = BSA_RC_ABORT_ACTIVE_NOT_FOUND;
+       rc = AFSdsmEndQuery(dsmHandle);
+       XOPENRETURN(BSAHandle,"BSAMarkObjectInactive: AFSdsmGetNextQObj",
+                   bsaRC,__FILE__,__LINE__);
+    }
+    rc = AFSdsmEndQuery(dsmHandle);
+ 
+    /*=== now we can do the delete ===*/
+    rc = AFSdsmBeginTxn(dsmHandle);
+ 
+    if (rc)
+    {
+      xlateRC(BSAHandle, rc, &bsaRC);
+      XOPENRETURN(BSAHandle,"BSAMarkObjectInactive: AFSdsmBeginTxn",
+                  bsaRC,__FILE__,__LINE__);
+    }
+    xopenGbl.sessFlags = (xopenGbl.sessFlags | FL_IN_DSM_TXN); /* set on */
+ 
+    delType = dtBackup;     /* this only applies to Backup */
+ 
+    delInfo.backInfo.stVersion = delBackVersion;
+    delInfo.backInfo.objNameP = &dsmobjName;
+ 
+    for (i=0; i<numTypes; i++)
+    {
+       delInfo.backInfo.copyGroup = listCopyGroup[i];
+       dsmobjName.objType         = listObjType[i];
+ 
+       if ((rc = AFSdsmDeleteObj(dsmHandle, delType, delInfo)) != DSM_RC_OK)
+       {
+ 
+          sprintf(traceStr2, "BSAMarkObjectInactive: call to AFSdsmDeleteObj error rc = %d", rc);
+          ourTrace(BSAHandle, TrFL, traceStr2);
+       }
+    }
+ 
+    /*=== issue EndTxn since these can't be nested because of Query sequence ===*/
+    AFSdsmEndTxn(dsmHandle, DSM_VOTE_COMMIT, &reason);
+    xopenGbl.sessFlags = (xopenGbl.sessFlags ^ FL_IN_DSM_TXN); /* set off */
+ 
+    xlateRC(BSAHandle, rc, &bsaRC);
+    XOPENRETURN(BSAHandle,"BSAMarkObjectInactive",
+                bsaRC,__FILE__,__LINE__);
+ }
+ 
+ #endif /*xbsa*/
Index: openafs/src/butc/afsxbsa.h
diff -c /dev/null openafs/src/butc/afsxbsa.h:1.1.6.2
*** /dev/null	Tue Oct  7 22:25:12 2008
--- openafs/src/butc/afsxbsa.h	Tue Jul 15 06:34:00 2008
***************
*** 0 ****
--- 1,866 ----
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef _BSA_XBSA_H_                                                            
+ #define _BSA_XBSA_H_                                                            
+                                                                                 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ #if (SYS_V > 3) || defined(BERK4_2) || defined(SUN4)
+ #include <sys/time.h>
+ #else
+ #include <time.h>
+ #endif
+ 
+ #ifdef bool_t
+ #undef bool_t
+ #endif
+ 
+ /* include TSM Header Files. */
+ #include <dsmapitd.h>
+ #include <dsmapifp.h>
+ #include <dsmrc.h>
+                                                                                 
+ /* BSA_Boolean  */
+ typedef char BSA_Boolean;
+ 
+ /* BSA_Int16 */
+ typedef short BSA_Int16;
+ 
+ /* BSA_Int32 */
+ typedef long BSA_Int32;     
+ 
+ /* BSA_Int64  */
+ typedef struct {    /* defined as two 32-bit integers */
+     BSA_Int32   left;
+     BSA_Int32   right;
+ } BSA_Int64;
+ 
+ /* BSA_UInt16  */
+ typedef unsigned short BSA_UInt16;
+ 
+ /* BSA_UInt32 */
+ typedef unsigned long BSA_UInt32;
+ 
+ /* BSA_UInt64  */
+ typedef struct {        /* defined as two unsigned 32-bit integers*/
+     BSA_UInt32  left;
+     BSA_UInt32  right;
+ } BSA_UInt64;
+ 
+ /*-------------------------------------------------------------------------+
+ |  ADSM specific constants and return codes                                |
+ +-------------------------------------------------------------------------*/
+ /* TSM library version, release, level
+  */
+ #define BSA_API_VERSION     5
+ #define BSA_API_RELEASE     2
+ #define BSA_API_LEVEL       0
+ 
+ /* Constants used  */
+ #define ADSM_MAX_DESC               100     /* ADSM max Desc size             */
+ #define ADSM_MAX_OBJINFO            100     /* ADSM max object info size      */
+ #define ADSM_LOWEST_BOUND           0x0000  /* value for LowerBound min       */
+ #define ADSM_HIGHEST_BOUND          0xFFFF  /* value for UpperBound max       */
+ #define ADSM_ENV_STRS               3       /* number of env strings          */
+ #define ObjectDescriptorVersion     1       /* ver for ObjectDescriptor       */
+ #define UserDescriptorVersion       1       /* ver for UserDescriptor         */
+ #define BSAObjectType_DATABASE      4       /*  ObjectType for Databases      */
+ 
+ /* Return Codes Used
+  */
+ #define BSA_RC_OK                           0x00
+ #define BSA_RC_SUCCESS                      0x00
+ 
+ #define ADSM_RC_ERROR                       0x60 /* see ADSM error log        */
+ #define ADSM_RC_INVALID_NODE                0x61 /* BSAObjOwner not match Init*/
+ #define ADSM_RC_INVALID_COPYTYPE            0x62 /* invalid copyType          */
+ #define ADSM_RC_INVALID_OBJTYPE             0x63 /* invalid objectType        */
+ #define ADSM_RC_INVALID_STATUS              0x64 /* invalid object status     */
+ #define ADSM_RC_INVALID_ST_VER              0x65 /* invalid structure version */
+ #define ADSM_RC_OWNER_TOO_LONG              0x66 /* owner too long            */
+ #define ADSM_RC_PSWD_TOO_LONG               0x67 /* pswd  too long            */
+ #define ADSM_RC_PSWD_GEN                    0x68 /* pswd access = generate    */
+ 
+ /* Constants used                                                               
+  *                                                                              
+  * Maximum string lengths (lower bound), including trailing null                
+  */                                                                             
+ #define BSA_LIST_ELEMENT_DELIMITER  null    /* Element delimiter in list      */
+ #define BSA_MAX_ADMIN_NAME          64      /* Administrator name             */
+ #define BSA_MAX_APPOBJECT_OWNER     64      /* Max end-object owner length    */
+ #define BSA_MAX_BSAOBJECT_OWNER     64      /* Max BSA object owner length    */
+ #define BSA_MAX_CG_DEST             31      /* Copy group destination         */
+ #define BSA_MAX_CG_NAME             31      /* Max copy group name length     */
+ #define BSA_MAX_COPYGROUPS          16      /* Max number of copy groups      */
+                                             /* which can be specified in a    */
+                                             /* lifecycle group                */
+ #define BSA_MAX_DESC                256     /* Description field              */
+ #define BSA_MAX_ENCODINGMETHOD      31      /* Max encoding method length     */
+ #define BSA_MAX_EVENTINFO           256     /* Max event info size            */
+ #define BSA_MAX_FILTERRULESET       8192    /* Max filter rule set size       */
+ #define BSA_MAX_OSNAME              1024    /* Max Objectspace name length    */
+ #define BSA_MAX_LG_NAME             31      /* Life cycle group name          */
+ #define BSA_MAX_LIFECYCLEGROUPS     64      /* Max number of life cycle       */
+                                             /* groups in a policy set         */
+ #define BSA_MAX_OBJINFO             512     /* Max object info size           */
+ #define BSA_MAX_PATHNAME            1024    /* Max path name length           */
+ #define BSA_MAX_POLICYDOMAINS       256     /* Max number of specific policy  */
+                                             /* domains an administrator may   */
+                                             /* be responsible for             */
+ #define BSA_MAX_POLICYDOMAIN_NAME   31      /* Policy domain name             */
+ #define BSA_MAX_POLICYSETS          16      /* Max number of policy sets      */
+                                             /* in a domain                    */
+ #define BSA_MAX_POLICYSET_NAME      31      /* Policy set name                */
+ #define BSA_MAX_RESOURCETYPE        31      /* Max resource mgr name length   */
+ #define BSA_MAX_TOKEN_SIZE          64      /* Max size of a security token   */
+ #define BSA_PUBLIC              "BSA_ANY"   /* Default string                 */
+                                                                                 
+ /* Return Codes Used                                                            
+  *                                                                              
+  * Return Code descriptions are given in Section 4.3.                           
+  */                                                                             
+ #define BSA_RC_ABORT_ACTIVE_NOT_FOUND       0x02                                
+ #define BSA_RC_ABORT_SYSTEM_ERROR           0x03                                
+ #define BSA_RC_AUTHENTICATION_FAILURE       0x04                                
+ #define BSA_RC_BAD_CALL_SEQUENCE            0x05                                
+ #define BSA_RC_BAD_HANDLE                   0x06                                
+ #define BSA_RC_BUFFER_TOO_SMALL             0x07                                
+ #define BSA_RC_DESC_TOO_LONG                0x08                                
+ #define BSA_RC_OBJECTSPACE_TOO_LONG         0x09                                
+ #define BSA_RC_INVALID_TOKEN                0x0a                                
+ #define BSA_RC_INVALID_VOTE                 0x0b                                
+ #define BSA_RC_INVALID_KEYWORD              0x0c                                
+ #define BSA_RC_MATCH_EXISTS                 0x0d                                
+ #define BSA_RC_MORE_DATA                    0x0e                                
+ #define BSA_RC_MORE_RULES                   0x0f                                
+ #define BSA_RC_NEWTOKEN_REQD                0x10                                
+ #define BSA_RC_NO_MATCH                     0x11                                
+ #define BSA_RC_NO_MORE_DATA                 0x12                                
+ #define BSA_RC_NO_RESOURCES                 0x13                                
+ #define BSA_RC_NULL_DATABLKPTR              0x14                                
+ #define BSA_RC_NULL_OBJNAME                 0x15                                
+ #define BSA_RC_NULL_POINTER                 0x16                                
+ #define BSA_RC_NULL_RULEID                  0x17                                
+ #define BSA_RC_OBJECT_NAME_TOO_LONG         0x18                                
+ #define BSA_RC_OBJECT_NOT_EMPTY             0x19                                
+ #define BSA_RC_OBJECT_NOT_FOUND             0x1a                                
+ #define BSA_RC_OBJINFO_TOO_LONG             0x1b                                
+ #define BSA_RC_OBJNAME_TOO_LONG             0x1c                                
+ #define BSA_RC_OPERATION_NOT_AUTHORIZED     0x1d                                
+ #define BSA_RC_OLDTOKEN_REQD                0x1e                                
+ #define BSA_RC_TOKEN_EXPIRED                0x1f                                
+ #define BSA_RC_TXN_ABORTED                  0x20                                
+ #define BSA_RC_UNMATCHED_QUOTE              0x21                                
+ #define BSA_RC_USER_OWNS_OBJECTS            0x22                                
+                                                                                 
+ /* AppObjectOwner                                                               
+  */                                                                             
+ typedef char AppObjectOwner[BSA_MAX_APPOBJECT_OWNER];                           
+                                                                                 
+ /* BSAObjectOwner                                                               
+  */                                                                             
+ typedef char BSAObjectOwner[BSA_MAX_BSAOBJECT_OWNER];                           
+                                                                                 
+ /* CopyGpDest                                                                   
+  */                                                                             
+ typedef char CopyGpDest[BSA_MAX_CG_DEST];                                       
+                                                                                 
+ /* CopyGpName                                                                   
+  */                                                                             
+ typedef char CopyGpName[BSA_MAX_CG_NAME];                                       
+                                                                                 
+ /* CopyMode                                                                     
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * INCREMENTAL  1         Specifies that the Backup Services should make a      
+  *                        copy only if the application object has been          
+  *                        modified since the last time this copy group was      
+  *                        used to create the object's copy.                     
+  * ABSOLUTE     2         Specifies that the Backup Services should make a      
+  *                        copy even if the application object has not been      
+  *                        modified since the last time this copy group was      
+  *                        used to create the object's copy.                     
+  */                                                                             
+ typedef enum {                                                                  
+     BSACopyMode_INCREMENTAL = 1,                                                
+     BSACopyMode_ABSOLUTE = 2                                                    
+ } CopyMode;                                                                     
+                                                                                 
+ /* CopySerialization                                                            
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * STATIC       1         Specifies that the Backup Services must create a      
+  *                        consistent (unmodified during the operation) copy of  
+  *                        the object.  If the application is unable to create a 
+  *                        consistent copy then it should skip the operation     
+  *                        (creating backup or archive copy) for the object.     
+  * SHAREDSTATIC 2         Specifies that the Backup Services must create a      
+  *                        consistent copy of the object.  It can retry the      
+  *                        operation a number of times (application dependent).  
+  *                        If the Backup Services is unable to create a          
+  *                        consistent copy even after retries, then it should    
+  *                        skip creating a backup or archive copy of the         
+  *                        object.                                               
+  * SHAREDDYNAMIC 3        Specifies that the Backup Services must create a      
+  *                        copy of the object.  It can retry the operation a     
+  *                        number of times in an attempt to create a consistent  
+  *                        copy; however, if it fails to make a consistent       
+  *                        copy, a copy must still be made, ignoring the fact    
+  *                        that the copy may have been modified during the       
+  *                        operation.  Such copies are useful for log file       
+  *                        objects which are being continuously modified.        
+  * DYNAMIC      4         Specifies that the Backup Services must create a      
+  *                        copy of the obbject even if the source object is      
+  *                        modified during the operation.  No retries should be  
+  *                        attempted to create a consistent copy.                
+  */                                                                             
+ typedef enum {                                                                  
+     BSACopySerialization_STATIC = 1,                                            
+     BSACopySerialization_SHAREDSTATIC = 2,                                      
+     BSACopySerialization_SHAREDDYNAMIC = 3,                                     
+     BSACopySerialization_DYNAMIC = 4                                            
+ } CopySerialization;                                                            
+                                                                                 
+ /* CopyType                                                                     
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * ANY          1         Used for matching any copy type (e.g. "backup" or     
+  *                        "archive" in the copy type field of structures for    
+  *                        selecting query results).                             
+  * ARCHIVE      2         Specifies that the copy type should be "archive".     
+  *                        When used in the copy type field of the CopyGroup,    
+  *                        it identifies the copy data as of type                
+  *                        ArchiveCopyData, which is used to create archive      
+  *                        copies.                                               
+  * BACKUP       3         Specifies that the copy type should be "backup".      
+  *                        When used in the copy type field of the CopyGroup,    
+  *                        it identifies the copy data as of type                
+  *                        BackupCopyData, which is used to create backup        
+  *                        copies.                                               
+  */                                                                             
+ typedef enum {                                                                  
+     BSACopyType_ANY = 1,                                                        
+     BSACopyType_ARCHIVE = 2,                                                    
+     BSACopyType_BACKUP = 3                                                      
+ } CopyType;                                                                     
+                                                                                 
+ /* Description                                                                  
+  */                                                                             
+ typedef char Description[BSA_MAX_DESC];                                         
+                                                                                 
+ /* DomainName                                                                   
+  */                                                                             
+ typedef char * DomainName[BSA_MAX_POLICYDOMAIN_NAME];                           
+                                                                                 
+ /* EventInfo                                                                    
+  */                                                                             
+ typedef char EventInfo[BSA_MAX_EVENTINFO];                                      
+                                                                                 
+ /* LGName                                                                       
+  */                                                                             
+ typedef char LGName[BSA_MAX_LG_NAME];                                           
+                                                                                 
+ /* ObjectInfo                                                                   
+  */                                                                             
+ typedef char ObjectInfo[BSA_MAX_OBJINFO];                                       
+                                                                                 
+ /* ObjectName                                                                   
+  */                                                                             
+ typedef struct {                                                                
+     char    objectSpaceName[BSA_MAX_OSNAME]; /* Highest-level name qualifier */ 
+     char    pathName[BSA_MAX_PATHNAME];      /* Object name within           */ 
+                                              /* objectspace                  */ 
+ } ObjectName;                                                                   
+                                                                                 
+ /* ObjectOwner                                                                  
+  */                                                                             
+ typedef struct {                                                                
+     BSAObjectOwner  bsaObjectOwner;    /* BSA Owner name - this is the name  */ 
+                                        /* that Backup Services authenticates */ 
+     AppObjectOwner  appObjectOwner;    /* End-owner name, this is the name   */ 
+                                        /* defined by the application         */ 
+ } ObjectOwner;                                                                  
+                                                                                 
+ /* ObjectSize                                                                   
+  */                                                                             
+ typedef BSA_UInt64 ObjectSize;         /* Unsigned 64-bit integer */            
+                                                                                 
+ /* ObjectStatus                                                                 
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * ANY          1         Provides a wild card function.  Can only be used in   
+  *                        queries.                                              
+  * ACTIVE       2         Indicates that this is the most recent backup copy    
+  *                        of an object.                                         
+  * INACTIVE     3         Indicates that this is not the most recent backup     
+  *                        copy, or that the object itself no longer exists.     
+  */                                                                             
+ typedef enum {                                                                  
+     BSAObjectStatus_ANY = 1,                                                    
+     BSAObjectStatus_ACTIVE = 2,                                                 
+     BSAObjectStatus_INACTIVE = 3                                                
+ } ObjectStatus;                                                                 
+                                                                                 
+ /* ObjectType                                                                   
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * any          1         Used for matching any object type (e.g. "file" or     
+  *                        "directory") value in the object type field of        
+  *                        structures for selecting query results.               
+  * file         2         Used by the application to indicate that the type of  
+  *                        application object is a "file" or single object.      
+  * directory    3         Used by the application to indicate that the type of  
+  *                        application object is a "directory" or container of   
+  *                        objects.                                              
+  */                                                                             
+ 
+ typedef enum {
+     BSAObjectType_ANY  = 1,
+     BSAObjectType_FILE    = 2,
+     BSAObjectType_DIRECTORY = 3
+  } ObjectType;
+                                                                                 
+ /* Operation                                                                    
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * archive      1         Used to indicate that a scheduled operation is of     
+  *                        type "archive".                                       
+  * backup       2         Used to indicate that a scheduled operation is of     
+  *                        type "backup".                                        
+  */                                                                             
+ typedef enum {                                                                  
+     BSAOperation_ARCHIVE = 1,                                                   
+     BSAOperation_BACKUP  = 2                                                    
+ } Operation;                                                                    
+                                                                                 
+ /* Period                                                                       
+  *                                                                              
+  * Use of the Period structure in a Schedule for an event:                      
+  * 1. The Schedule structure specifies 3 timing elements:                       
+  *    a. "firstStartTime" - a timestamp showing the "earliest"                  
+  *        possible time the event could take place                              
+  *    b. "day" - the day of the week the event should occur                     
+  *    c. "frequency" - the period between successive events                     
+  * 2. To determine the day the event should occur (this does                    
+  *    not change the time of the event in the day):                             
+  *    a. Determine the requested day from "firstStartTime".                     
+  *    b. If "day" does not equal XBSA_DAYOFWEEK_ANY                             
+  *       i. Compare "day" to the day of the week corresponding                  
+  *          to "firstStartTime" determined in 2a above.                         
+  *       ii.If the days match, then use "firstStartTime" else                   
+  *          use the first "day" *following* the day shown                       
+  *          in "firstStartTime" as the day of the event.                        
+  * 3. If the PeriodWhich field in the Period structure is other                 
+  *    than XBSA_PERIOD_UNDEFINED, then successive events are                    
+  *    determined using the value of "periodData".                               
+  *    a. For seconds and days, the appropriate seconds or days                  
+  *       are added to the "firstStartTime" and step 2 to correct                
+  *       for the day of the week (if needed) is applied again.                  
+  *    b. If a monthly period is specified, then the appropriate                 
+  *       number of months are added by incrementing the month index is          
+  *       made (for example, a one month increment from February to              
+  *       March).  If the monthly date is not valid (for example, January        
+  *       30 --> February 30) then the last day of the desired month is          
+  *       used (example January 30 --> February 28).  Then step 2 is             
+  *       followed to adjust for the requested day (which might move the         
+  *       event time into the following month).                                  
+  */                                                                             
+ typedef enum {                                                                  
+     BSAPeriod_SECONDS = 1,                                                      
+     BSAPeriod_DAYS = 2,                                                         
+     BSAPeriod_MONTHS = 3,                                                       
+     BSAPeriod_UNDEFINED = -9,                                                   
+     BSAPeriod_DAILY = 4, BSAPeriod_WEEKLY = 5, BSAPeriod_MONTHLY = 6,           
+     BSAPeriod_QUARTERLY = 7, BSAPeriod_ANNUALLY = 8                             
+ } PeriodWhich;                                                                  
+                                                                                 
+ typedef struct {                                                                
+     PeriodWhich     which;                                                      
+     union {                                                                     
+         time_t      nSeconds;                                                   
+         BSA_Int16   nDays;                                                      
+         BSA_Int16   nMonths;                                                    
+     } periodData;                                                               
+ } Period;                                                                       
+                                                                                 
+ /* ResourceType                                                                 
+  */                                                                             
+ typedef char ResourceType[BSA_MAX_RESOURCETYPE];                                
+                                                                                 
+ /* RuleId                                                                       
+  */                                                                             
+ typedef BSA_UInt64 RuleId;                                                      
+                                                                                 
+ /* Scheduleid                                                                   
+  */                                                                             
+ typedef BSA_UInt64 ScheduleId;                                                  
+                                                                                 
+ /* AccessRight                                                                  
+  *                                                                              
+  * Constant     Value     Explanation                                           
+  * --------     -----     -----------                                           
+  * GET          1         Access right for getting an object from Backup        
+  *                        Services, also includes access right for querying     
+  *                        (getting attributes) an object from Backup Services.  
+  * QUERY        2         Access right for querying (getting attributes) an     
+  *                        object from Backup Services.                          
+  */                                                                             
+ typedef enum {                                                                  
+     BSAAccessRight_GET  = 1,                                                    
+     BSAAcessRight_QUERY = 2                                                     
+ } AccessRight;                                                                  
+                                                                                 
+ /* AccessRule                                                                   
+  */                                                                             
+ typedef struct {                                                                
+     RuleId          ruleId;         /* Provided by Backup Services            */
+     ObjectName      objName;        /* Object name to be given access         */
+     ObjectOwner     objectOwner;    /* BSA object owner and Applicaton object */
+                                     /* owner to be given access               */
+     AccessRight     rights;         /* The access rights to be given          */
+ } AccessRule;                                                                   
+                                                                                 
+ /* ApiVersion                                                                   
+  */                                                                             
+ typedef struct {                                                                
+     BSA_UInt16      version;        /* Version of this API                    */
+     BSA_UInt16      release;        /* Release of this API                    */
+     BSA_UInt16      level;          /* Level of this API                      */
+ } ApiVersion;                                                                   
+                                                                                 
+ /* ArchiveCopyData                                                              
+  */                                                                             
+ typedef struct {                                                                
+     CopyGpName          cGName;     /* Copy group name                        */
+     BSA_UInt16          freq;       /* Archive frequency                      */
+     CopySerialization   copySer;    /* Copy serialization code                */
+     CopyMode            copyMode;   /* Copy mode                              */
+     CopyGpDest          destName;   /* Copy destination name                  */
+     BSA_UInt16          retVersion; /* Retention time for the version         */
+ } ArchiveCopyData;                                                              
+                                                                                 
+ /* BackupCopyData                                                               
+  */                                                                             
+ typedef struct {                                                                
+     CopyGpName          cGName;     /* Copy group name                        */
+     BSA_UInt16          freq;       /* Backup frequency                       */
+     CopySerialization   copySer;    /* Copy serialization code                */
+     CopyMode            copyMode;   /* Copy mode: 1=modified, 2=absolute      */
+     CopyGpDest          destName;   /* Copy destination name                  */
+     BSA_UInt16          verDataEx;  /* Versions (number of versions           */
+                                     /* retained)                              */
+     BSA_UInt16          verDataDel; /* Versions (data deleted)                */
+     Period              retXtraVer; /* Retain extra versions                  */
+     Period              retOnlyVer; /* Retain only versions                   */
+ } BackupCopyData;                                                               
+                                                                                 
+ /* CopyGroup                                                                    
+  */                                                                             
+ typedef struct {                                                                
+     CopyType    copyType;       /* Type of copy group: archive, backup, etc   */
+     union {                                                                     
+         ArchiveCopyData archive;                                                
+         BackupCopyData  backup;                                                 
+     } copyData;                                                                 
+ } CopyGroup;                                                                    
+                                                                                 
+ /* CopyId                                                                       
+  */                                                                             
+ typedef BSA_UInt64      CopyId;                                                 
+                                                                                 
+ /* DataBlock                                                                    
+  */                                                                             
+ typedef struct {                                                                
+     BSA_UInt16  bufferLen;                                                      
+     BSA_UInt16  numBytes;       /* Actual number of bytes read from */          
+                                 /* or written to the buffer, or the */          
+                                 /* minimum number of bytes needed   */          
+     char *      bufferPtr;                                                      
+ } DataBlock;                                                                    
+                                                                                 
+ /* DayOfWeek                                                                    
+  */                                                                             
+ typedef enum {                                                                  
+     BSADayOfWeek_Monday = 1,    BSADayOfWeek_Tuesday = 2,                       
+     BSADayOfWeek_Wednesday = 3, BSADayOfWeek_Thursday = 4,                      
+     BSADayOfWeek_Friday = 5,    BSADayOfWeek_Saturday = 6,                      
+     BSADayOfWeek_Sunday = 7                                                     
+ } DayOfWeek;                                                                    
+                                                                                 
+ /* Environment                                                                  
+  */                                                                             
+ typedef struct {                                                                
+     char * envVariables; /* Identifies the Backup Services instance and other */
+                          /* implementation-dependent variables such as        */
+                          /* communication ports, etc.  Each variable is a     */
+                          /* (keyword, value) pair separated by a space.       */
+                          /* If a value contains spaces, it must be            */
+                          /* enclosed in single or double quotes.              */
+ } BSAEnvironment;                                                               
+                                                                                 
+ /* Event                                                                        
+  */                                                                             
+ typedef struct {                                                                
+     BSA_UInt32      eventId;    /* This is an internal (to Backup Services) id*/
+     ObjectOwner     objectOwner;/* Identifies the owner of the event          */
+     struct tm       time;       /* Identifies the time the action is to start */
+     Operation       action;     /* Identifies the action (backup, archive)    */
+     ObjectName      objName;    /* Identifies objects to be acted on          */
+     ResourceType    resourceType;/* Identifies the resource manager for the   */
+                                  /* event                                     */
+     EventInfo       eventInfo;  /* User- and resource-manager-specific info   */
+ } BSAEvent;                                                                     
+                                                                                 
+ /* MethodName                                                                   
+  */                                                                             
+ typedef char EncodingMethod[BSA_MAX_ENCODINGMETHOD];                            
+                                                                                 
+ /* ObjectDescriptor                                                             
+  */                                                                             
+ typedef struct {                                                                
+     BSA_UInt32      version;        /* Version number for this structure      */
+     ObjectOwner     Owner;          /* Owner of the object                    */
+     ObjectName      objName;        /* Object name                            */
+     struct tm       createTime;     /* Supplied by Backup Services            */
+     CopyType        copyType;       /* Copy type: archive or backup           */
+     CopyId          copyId;         /* Supplied by Backup Services            */
+     BSA_UInt64      restoreOrder;   /* Supplied by Backup Services            */
+     LGName          lGName;         /* Associated Lifecycle Group name        */
+     CopyGpName      cGName;         /* Copy group within the lifecycle group  */
+     ObjectSize      size;           /* Object size may be up to 63 bits       */
+     ResourceType    resourceType;   /* e.g. UNIX file system                  */
+     ObjectType      objectType;     /* e.g. file, directory, etc.             */
+     ObjectStatus    status;         /* Active/inactive, supplied by           */
+                                     /* Backup Services                        */
+     EncodingMethod * encodingList;  /* List of encoding Methods used, in      */
+                                     /* application-defined order,             */
+                                     /* terminated with a null entry           */
+     Description     desc;           /* Descriptive label for the object       */
+     ObjectInfo      objectInfo;     /* Application information                */
+ } ObjectDescriptor;                                                             
+                                                                                 
+ /* QueryDescriptor                                                              
+  */                                                                             
+ typedef struct {                                                                
+     ObjectOwner     owner;          /* Owner of the object                    */
+     ObjectName      objName;        /* Object name                            */
+     struct tm       createTimeLB;   /* Lower bound on create time             */
+     struct tm       createTimeUB;   /* Upper bound on create time             */
+     struct tm       expireTimeLB;   /* Lower bound on expiration time         */
+     struct tm       expireTimeUB;   /* Upper bound on expiration time         */
+     CopyType        copyType;       /* Copy type: archive or backup           */
+     LGName          lGName;         /* Associated Lifecycle Group name        */
+     CopyGpName      cGName;         /* Copy group within the lifecycle group  */
+     ResourceType    resourceType;   /* e.g. UNIX file system                  */
+     ObjectType      objectType;     /* e.g. file, directory, etc.             */
+     ObjectStatus    status;         /* Active/inactive, supplied by Backup    */
+                                     /* Services                               */
+     Description     desc;           /* Descriptive label for the object       */
+ } QueryDescriptor;                  /* "*" is interpreted as a meta character */
+                                     /* wild card.                             */
+                                     /* Any undefined value is interpreted as  */
+                                     /* an error.                              */
+                                                                                 
+ /* Schedule                                                                     
+  */                                                                             
+ typedef struct {                                                                
+     ScheduleId      schedId;        /* Provided by Backup Services            */
+     ObjectOwner     objectOwner;    /* Specifies the owner of the schedule    */
+     Operation       operation;      /* Specifies the action to be taken       */
+     struct tm       firstStartTime; /* Specifies the first time the action    */
+                                     /* is to take place                       */
+     DayOfWeek       day;            /* Specifies the day of week for the event*/
+     Period          frequency;      /* Specifies the frequency, e.g. daily    */
+     ObjectName      objectName;     /* Identifies objects to be acted on      */
+     ResourceType    resourceType;   /* Identifies the resource manager for the*/
+                                     /* schedule                               */
+     EventInfo       scheduleInfo;   /* Resource manager specific information  */
+ } Schedule;                                                                     
+                                                                                 
+ /* Security Token                                                               
+  */                                                                             
+ typedef char SecurityToken[BSA_MAX_TOKEN_SIZE];                                 
+                                                                                 
+ /* StreamHandle                                                                 
+  */                                                                             
+ typedef int StreamHandle;                                                       
+                                                                                 
+ /* UserDescriptor                                                               
+  */                                                                             
+ typedef struct t_UserDescriptor {                                               
+     BSA_UInt16      version;        /* Version num of this structure          */
+     BSAObjectOwner  bsaObjectOwner; /* BSA Object owner name              */    
+     DomainName      domainName;     /* Policy domain for the user         */    
+     Description     desc;           /* User information                   */    
+ } UserDescriptor;                                                               
+                                                                                 
+ /* Vote                                                                         
+  */                                                                             
+ typedef enum {                                                                  
+     BSAVote_COMMIT = 1,                                                         
+     BSAVote_ABORT  = 2                                                          
+ } Vote;                                                                         
+                                                                                 
+ /* Function Prototypes for Data Movement API Subset
+  * Note that int and long have been replaced with typedefs
+  * from custom.h.
+  */                                                                             
+ 
+ extern BSA_Int16 
+ BSABeginTxn
+ (      long              bsaHandle
+ );
+ 
+ extern BSA_Int16 
+ BSAChangeToken
+ (      long              bsaHandle,
+        SecurityToken    *oldTokenPtr,
+        SecurityToken    *newTokenPtr
+ );
+ 
+ extern BSA_Int16 
+ BSACreateObject
+ (      long              bsaHandle,
+        ObjectDescriptor *objectDescriptorPtr,
+        DataBlock        *dataBlockPtr
+ );
+ 
+ extern BSA_Int16 
+ BSACreateObjectF
+ (      long              bsaHandle,
+        ObjectDescriptor *objectDescriptorPtr,
+        StreamHandle     *streamPtr
+ );
+ 
+ extern BSA_Int16 
+ BSADeleteObject
+ (      long              bsaHandle,
+        CopyType          copyType,
+        ObjectName       *objectName,
+        CopyId           *copyId
+ );
+ 
+ extern BSA_Int16 
+ BSAEndData
+ (      long              bsaHandle
+ );
+ 
+ extern BSA_Int16 
+ BSAEndTxn
+ (      long              bsaHandle,
+        Vote              vote
+ );
+ 
+ extern BSA_Int16
+ BSAGetData
+ (      long              bsaHandle,
+        DataBlock        *dataBlockPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAGetEnvironment
+ (      long              bsaHandle,
+        ObjectOwner      *objectOwnerPtr,
+        char            **environmentPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAGetNextQueryObject
+ (      long              bsaHandle,
+        ObjectDescriptor *objectDescriptorPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAGetObject
+ (      long              bsaHandle,
+        ObjectDescriptor *objectDescriptorPtr,
+        DataBlock        *dataBlockPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAGetObjectF
+ (      long              bsaHandle,
+        ObjectDescriptor *objectDescriptorPtr,
+        StreamHandle     *streamPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAInit
+ (      long             *bsaHandleP,
+        SecurityToken    *tokenPtr,
+        ObjectOwner      *objectOwnerPtr,
+        char            **environmentPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAMarkObjectInactive
+ (      long              bsaHandle,
+        ObjectName       *objectNamePtr
+ );
+ 
+ extern void 
+ BSAQueryApiVersion
+ (      ApiVersion       *apiVersionPtr
+ );
+ 
+ extern BSA_Int16 
+ BSAQueryObject
+ (      long              bsaHandle,
+        QueryDescriptor  *queryDescriptorPtr,
+        ObjectDescriptor *objectDescriptorPtr
+ );
+ 
+ extern BSA_Int16 
+ BSASendData
+ (      long              bsaHandle,
+        DataBlock        *dataBlockPtr
+ );
+ 
+ extern BSA_Int16 
+ BSASetEnvironment
+ (      long              bsaHandle,
+        char            **environmentPtr
+ );
+ 
+ extern BSA_Int16 
+ BSATerminate
+ (      long              bsaHandle
+ );
+ 
+ extern BSA_Int16
+ BSAResolveLifecycleGroup(
+     long              BSAHandle,
+     ObjectDescriptor *BSAobjDescP
+ );
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ typedef struct
+ {
+   ApiSessInfo      dsmSessInfo;
+   BSAObjectOwner   bsaObjectOwner; /* node value on BSAInit */
+   dsUint16_t       sessFlags;      /* misc flags            */
+   dsUint8_t        oper;        /* send or recv operation */
+   CopyType         copyType;    /* Backup or Archive type */
+   char             *nextQryP;    /* ptr to respArchive or respBackup */
+ } xGlobal;
+ 
+ /*  flag masks for sessFlags    */
+ /*  to set on use   sessFlags = (sessFlags | FL_IN_BSA_TXN) */
+ /*  to set off use  sessFlags = (sessFlags ^ FL_IN_BSA_TXN) */
+ /*  to test on use  if (sessFlags & FL_IN_BSA_TXN) */
+ #define  FL_IN_BSA_TXN     0x0001  /* within a BSA type txn            */
+ #define  FL_IN_DSM_TXN     0x0002  /* within a actual ADSM txn         */
+ #define  FL_IN_BSA_QRY     0x0004  /* within a query txn               */
+ #define  FL_PSWD_EXPIRE    0x0008  /* pswd has expired                 */
+ #define  FL_RC_WILL_ABORT  0x0010  /* recvd 157 on SendObj or SendData */
+ #define  FL_END_DATA_DONE  0x0020  /* Get error already did EndData    */
+ 
+ #define OPER_NONE            0    /* values for oper field  */
+ #define OPER_SEND_START      1
+ #define OPER_SEND_ISSUED     2
+ #define OPER_RECV_START      3
+ #define OPER_RECV_ISSUED     4
+ 
+ /*  structure def for objInfo  - max len = 255 */
+ typedef struct
+ {
+   ResourceType     resourceType;                       /*  31 bytes */
+   ObjectSize       size;                               /*   8 bytes */
+   char             partDesc[ADSM_MAX_DESC];            /* 100 bytes */
+   char             partObjInfo[ADSM_MAX_OBJINFO];      /* 100 bytes */
+ } XAPIObjInfo;
+ 
+ /* ******* G l o b a l s  ********  */
+ 
+ /* xGlobal xopenGbl; */
+ 
+ extern BSA_Int16 xlateRC(
+     long      BSAHandle,
+     BSA_Int16 dsmRC,
+     BSA_Int16 *bsaRCP);
+ 
+ extern BSA_Int16 xparsePath(
+     long     BSAHandle,
+     char          *pathname,
+     char          *hl,
+     char          *ll);
+ 
+ extern xGlobal        xopenGbl;
+ extern char           traceStr[];
+ extern char           traceStr1[];
+ extern char           traceStr2[];
+ 
+ #define dsMalloc(a)   malloc(a)
+ #define dsFree(a)     free(a)
+ 
+ extern void StrUpper(char *s);
+ /* Min() and Max() macros */
+ #ifndef min
+ #define min(a,b)  (((a) < (b)) ? (a) : (b))
+ #endif
+ 
+ #ifndef max
+ #define max(a,b)  (((a) > (b)) ? (a) : (b))
+ #endif
+ 
+ /* Combined file name w/ line number */
+ #define TrFL __FILE__, __LINE__
+ 
+ /*=== MACRO for exit tracing ===*/
+ #define XOPENRETURN(BSAHandle,functionName,bsaRC,fileName,lineNumber) {sprintf(traceStr2,"%s EXIT: rc = >%d<.",functionName, bsaRC); ourTrace(BSAHandle,fileName,lineNumber,traceStr2); return(bsaRC);}
+ 
+ /* Define license error log file name */
+ #define TSMLicLog "tsmlic.log"
+ 
+ #define custMin_retcode  96
+ #define custMax_retcode  104
+ 
+ /*=======================================================
+  Function to places a trace message in the API tracefile,
+  the message includes the xopen file name and line number.
+  ======================================================*/
+ void ourTrace(long           BSAHandle,
+               char          *fileName,
+               int            lineNumber,
+               char          *traceStr2);
+ 
+ /*================================================
+  Function to log events with call to dsmLogEventEx
+  ===============================================*/
+ void ourLogEvent_Ex(dsUint32_t handle, dsmLogType type, char* msg,
+                  char *appMsg, dsmLogSeverity severity);
+ 
+ /*=================================================================
+  Function to retrieve a message by routing to dsmRCMsg or stdXOpenMsgMap.
+  ===============================================================*/
+ char* ourRCMsg(dsInt16_t dsmRC, char *msg);
+ 
+ /*====================================================
+  Function to build fully qualified license file name.
+  void build_lfname(char *lfname
+  ========================================================*/
+ extern void build_lfname(char *lfname);
+ 
+ /*=== Function to deliver standard XOpen API message above API range. */
+ void stdXOpenMsgMap(dsInt16_t, char*);
+ 
+ 
+ #endif /* xbsa */
Index: openafs/src/butc/butc_xbsa.c
diff -c openafs/src/butc/butc_xbsa.c:1.8.2.1 openafs/src/butc/butc_xbsa.c:1.8.2.2
*** openafs/src/butc/butc_xbsa.c:1.8.2.1	Mon Jul 16 16:43:31 2007
--- openafs/src/butc/butc_xbsa.c	Fri Jul 11 05:54:43 2008
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/butc_xbsa.c,v 1.8.2.1 2007/07/16 20:43:31 shadow Exp $");
  
  #include <sys/types.h>
  #include <afs/stds.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/butc_xbsa.c,v 1.8.2.2 2008/07/11 09:54:43 shadow Exp $");
  
  #include <sys/types.h>
  #include <afs/stds.h>
***************
*** 34,39 ****
--- 34,55 ----
  char resourceType[20] = "LFS FILE SYSTEM";
  #define GOODSTR(s) ((s)?(s):"<NULL>")
  
+ #ifdef NEW_XBSA
+ BSA_Int16 (*XBSAInit)(long *, SecurityToken *, ObjectOwner *, char **);
+ BSA_Int16 (*XBSABeginTxn)(long);
+ BSA_Int16 (*XBSAEndTxn)(long, Vote);
+ BSA_Int16 (*XBSATerminate)(long);
+ BSA_Int16 (*XBSAQueryObject)(long, QueryDescriptor *, ObjectDescriptor *);
+ BSA_Int16 (*XBSAGetObject)(long, ObjectDescriptor *, DataBlock *);
+ BSA_Int16 (*XBSAEndData)(long);
+ BSA_Int16 (*XBSACreateObject)(long, ObjectDescriptor *, DataBlock *);
+ BSA_Int16 (*XBSADeleteObject)(long, CopyType, ObjectName *, CopyId *);
+ BSA_Int16 (*XBSAMarkObjectInactive)(long, ObjectName *);
+ BSA_Int16 (*XBSASendData)(long, DataBlock *);
+ BSA_Int16 (*XBSAGetData)(long, DataBlock *);
+ void (*XBSAQueryApiVersion)(ApiVersion *);
+ BSA_Int16 (*XBSAGetEnvironment)(long, ObjectOwner *, char **);
+ #else
  BSA_Int16(*XBSAInit) (BSA_UInt32 *, SecurityToken *, ObjectOwner *, char **);
  BSA_Int16(*XBSABeginTxn) (BSA_UInt32);
  BSA_Int16(*XBSAEndTxn) (BSA_UInt32, Vote);
***************
*** 49,55 ****
  BSA_Int16(*XBSAGetData) (BSA_UInt32, DataBlock *);
  BSA_Int16(*XBSAQueryApiVersion) (ApiVersion *);
  BSA_Int16(*XBSAGetEnvironment) (BSA_UInt32, ObjectOwner *, char **);
! 
  
  xbsa_error(int rc, struct butx_transactionInfo *info)
  {
--- 65,71 ----
  BSA_Int16(*XBSAGetData) (BSA_UInt32, DataBlock *);
  BSA_Int16(*XBSAQueryApiVersion) (ApiVersion *);
  BSA_Int16(*XBSAGetEnvironment) (BSA_UInt32, ObjectOwner *, char **);
! #endif
  
  xbsa_error(int rc, struct butx_transactionInfo *info)
  {
***************
*** 122,127 ****
--- 138,144 ----
  
      switch (serverType) {
      case XBSA_SERVER_TYPE_ADSM:
+ #ifndef NEW_XBSA
  #if defined(AFS_AIX_ENV)
  	dynlib =
  	    dlopen("/usr/lib/libXApi.a(bsashr10.o)",
***************
*** 137,142 ****
--- 154,160 ----
  #else
  	dynlib = NULL;
  #endif
+ #endif
  	break;
      default:
  	ELog(0, "xbsa_MountLibrary: The serverType %d is not recognized\n",
***************
*** 145,159 ****
--- 163,180 ----
  	break;
      }
  
+ #ifndef NEW_XBSA
      if (dynlib == NULL) {
  	ELog(0,
  	     "xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n");
  	return (BUTX_NOLIBRARY);
      }
+ #endif
  
      memset(info, 0, sizeof(struct butx_transactionInfo));
      XBSA_SET_SERVER_TYPE(info->serverType, serverType);
  
+ #ifndef NEW_XBSA
  #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
      XBSAInit = (BSA_Int16(*)
  		(BSA_UInt32 *, SecurityToken *, ObjectOwner *,
***************
*** 204,213 ****
  	     "xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n");
  	return (BUTX_NOLIBRARY);
      }
- 
      XBSAQueryApiVersion(&(info->apiVersion));
  #endif
  
      /*
       * Verify the API version
       */
--- 225,264 ----
  	     "xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n");
  	return (BUTX_NOLIBRARY);
      }
      XBSAQueryApiVersion(&(info->apiVersion));
  #endif
+ #else
+ #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV)
+     XBSAInit                    = BSAInit;
+     XBSABeginTxn                = BSABeginTxn;
+     XBSAEndTxn                  = BSAEndTxn;
+     XBSATerminate               = BSATerminate;
+     XBSAQueryObject             = BSAQueryObject;
+     XBSAGetObject               = BSAGetObject;
+     XBSAEndData                 = BSAEndData;
+     XBSACreateObject            = BSACreateObject;
+     XBSAMarkObjectInactive      = BSAMarkObjectInactive;
+     XBSADeleteObject            = BSADeleteObject;
+     XBSASendData                = BSASendData;
+     XBSAGetData                 = BSAGetData;
+     XBSAQueryApiVersion         = BSAQueryApiVersion;
+     XBSAGetEnvironment          = BSAGetEnvironment;
+     
+     if (!XBSAInit || !XBSABeginTxn || !XBSAEndTxn || !XBSATerminate ||
+ 	!XBSAQueryObject || !XBSAGetObject || !XBSAEndData ||
+ 	!XBSACreateObject || !XBSADeleteObject || !XBSAMarkObjectInactive ||
+ 	!XBSASendData || !XBSAGetData || !XBSAQueryApiVersion ||
+ 	!XBSAGetEnvironment) {
+ 	ELog(0,"xbsa_MountLibrary: The dlopen call to load the XBSA shared library failed\n");
+ 	return(BUTX_NOLIBRARY);
+     }
+     XBSAQueryApiVersion(&(info->apiVersion));
+ #endif
+ #endif
  
+ #ifdef DEBUG_BUTC
+ 	printf("xbsa_MountLibrary : XBSA function Pointers initialised. \n");
+ #endif
      /*
       * Verify the API version
       */
Index: openafs/src/butc/butc_xbsa.h
diff -c openafs/src/butc/butc_xbsa.h:1.4.2.1 openafs/src/butc/butc_xbsa.h:1.4.2.2
*** openafs/src/butc/butc_xbsa.h:1.4.2.1	Wed Aug 25 03:12:37 2004
--- openafs/src/butc/butc_xbsa.h	Fri Jul 11 05:54:43 2008
***************
*** 38,44 ****
--- 38,48 ----
  #define XBSADFLTBUFFER 16384	/* default size is 16KB */
  #define XBSAMAXBUFFER  65535	/* maximum size in 64KB-1; has to fit in 16bit integer */
  
+ #ifdef NEW_XBSA
+ #include "afsxbsa.h"
+ #else
  #include <xbsa.h>
+ #endif
  
  #define XBSA_NUM_ENV_STRS ADSM_ENV_STRS
  #define XBSA_MAX_OSNAME   BSA_MAX_OSNAME
Index: openafs/src/butc/dump.c
diff -c openafs/src/butc/dump.c:1.17.2.3 openafs/src/butc/dump.c:1.17.2.4
*** openafs/src/butc/dump.c:1.17.2.3	Mon Mar 10 18:35:34 2008
--- openafs/src/butc/dump.c	Thu May  1 20:59:48 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/dump.c,v 1.17.2.3 2008/03/10 22:35:34 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/butc/dump.c,v 1.17.2.4 2008/05/02 00:59:48 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 2215,2220 ****
  	code = BUTX_DELETENOVOL;
  	setStatus(taskId, TASK_ERROR);
      }
!     return (code);
  }
  #endif
--- 2215,2220 ----
  	code = BUTX_DELETENOVOL;
  	setStatus(taskId, TASK_ERROR);
      }
!     return (void *)(code);
  }
  #endif
Index: openafs/src/cf/linux-test4.m4
diff -c openafs/src/cf/linux-test4.m4:1.20.2.47 openafs/src/cf/linux-test4.m4:1.20.2.50
*** openafs/src/cf/linux-test4.m4:1.20.2.47	Sat Apr 19 17:56:08 2008
--- openafs/src/cf/linux-test4.m4	Sat Aug 16 15:43:15 2008
***************
*** 502,507 ****
--- 502,519 ----
      CPPFLAGS="$save_CPPFLAGS"])
    AC_MSG_RESULT($ac_cv_linux_kernel_page_follow_link)])
  
+ AC_DEFUN([LINUX_KERNEL_HLIST_UNHASHED], [
+   AC_MSG_CHECKING([for hlist_unhashed])
+   AC_CACHE_VAL([ac_cv_linux_kernel_hlist_unhashed], [
+     save_CPPFLAGS="$CPPFLAGS"
+     CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
+     AC_TRY_KBUILD(
+ [#include <linux/list.h>],
+ [hlist_unhashed(0);],
+       ac_cv_linux_kernel_hlist_unhashed=yes,
+       ac_cv_linux_kernel_hlist_unhashed=no)
+     CPPFLAGS="$save_CPPFLAGS"])
+   AC_MSG_RESULT($ac_cv_linux_kernel_hlist_unhashed)])
  
  AC_DEFUN([LINUX_FS_STRUCT_ADDRESS_SPACE_HAS_GFP_MASK], [
    AC_MSG_CHECKING([for gfp_mask in struct address_space])
***************
*** 993,995 ****
--- 1005,1047 ----
      AC_DEFINE([EXPORTED_RCU_READ_LOCK], 1, [define if rcu_read_lock() is usable])
    fi])
   
+ AC_DEFUN([LINUX_EXPORTS_FIND_TASK_BY_PID], [
+   AC_MSG_CHECKING([if find_task_by_pid is usable])
+   AC_CACHE_VAL([ac_cv_linux_exports_find_task_by_pid], [
+     AC_TRY_KBUILD(
+ [#include <linux/sched.h>],
+ [pid_t p;
+ find_task_by_pid(p);],
+       ac_cv_linux_exports_find_task_by_pid=yes,
+       ac_cv_linux_exports_find_task_by_pid=no)])
+   AC_MSG_RESULT($ac_cv_linux_exports_find_task_by_pid)
+   if test "x$ac_cv_linux_exports_find_task_by_pid" = "xyes"; then
+     AC_DEFINE([EXPORTED_FIND_TASK_BY_PID], 1, [define if find_task_by_pid() is usable])
+   fi])
+  
+ AC_DEFUN([LINUX_EXPORTS_PROC_ROOT_FS], [
+   AC_MSG_CHECKING([if proc_root_fs is defined and exported])
+   AC_CACHE_VAL([ac_cv_linux_exports_proc_root_fs], [
+     AC_TRY_KBUILD(
+ [#include <linux/proc_fs.h>],
+ [struct proc_dir_entry *p = proc_root_fs;],
+       ac_cv_linux_exports_proc_root_fs=yes,
+       ac_cv_linux_exports_proc_root_fs=no)])
+   AC_MSG_RESULT($ac_cv_linux_exports_proc_root_fs)
+   if test "x$ac_cv_linux_exports_proc_root_fs" = "xyes"; then
+     AC_DEFINE([EXPORTED_PROC_ROOT_FS], 1, [define if proc_root_fs is exported])
+   fi])
+  
+ AC_DEFUN([LINUX_SEMAPHORE_H_EXISTS], [
+   AC_MSG_CHECKING([for linux/semaphore.h existance])
+   AC_CACHE_VAL([ac_cv_linux_semaphore_h_exists], [
+     AC_TRY_KBUILD(
+ [#include <linux/semaphore.h>],
+ [return;],
+       ac_cv_linux_semaphore_h_exists=yes,
+       ac_cv_linux_semaphore_h_exists=no)])
+   AC_MSG_RESULT($ac_cv_linux_semaphore_h_exists)
+   if test "x$ac_cv_linux_semaphore_h_exists" = "xyes"; then
+     AC_DEFINE([LINUX_SEMAPHORE_H], 1, [define if linux/semaphore.h exists])
+   fi])
+ 
Index: openafs/src/cf/osconf.m4
diff -c openafs/src/cf/osconf.m4:1.51.2.36 openafs/src/cf/osconf.m4:1.51.2.38
*** openafs/src/cf/osconf.m4:1.51.2.36	Thu Feb 28 09:28:52 2008
--- openafs/src/cf/osconf.m4	Wed Sep  3 14:27:39 2008
***************
*** 7,13 ****
  CC="cc"
  CCOBJ="cc"
  MT_CC="cc"
! XLIBS="${LIB_AFSDB}"
  
  dnl debugging and optimization flag defaults
  dnl Note, these are all the defaults for if debug/optimize turned on, and
--- 7,13 ----
  CC="cc"
  CCOBJ="cc"
  MT_CC="cc"
! XLIBS="${LIB_AFSDB} ${XBSA_XLIBS}"
  
  dnl debugging and optimization flag defaults
  dnl Note, these are all the defaults for if debug/optimize turned on, and
***************
*** 199,205 ****
  		XCFLAGS="${XCFLAGS0} +DA1.0"
  		XLIBELFA="-lelf"
  		#XLIBS="${LIB_AFSDB} -lnsl"
- 		XLIBS="${LIB_AFSDB}"
  		YACC="/opt/langtools/bin/yacc"
  		SHLIB_LINKER="ld -b"
  		;;
--- 199,204 ----
***************
*** 231,237 ****
  		XCFLAGS="${XCFLAGS0}"
  		XLIBELFA="-lelf"
  		#XLIBS="${LIB_AFSDB} -lnsl"
- 		XLIBS="${LIB_AFSDB}"
  		YACC="/opt/langtools/bin/yacc"
  		SHLIB_LINKER="ld -b"
  		;;
--- 230,235 ----
***************
*** 551,556 ****
--- 549,555 ----
  		XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
  		XLIBS="${LIB_AFSDB} -ldl"
  		SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
+ 		AIX32=""
  		AIX64="#"
  		;;
  
***************
*** 567,572 ****
--- 566,572 ----
  		XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
  		XLIBS="${LIB_AFSDB} -ldl"
  		SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
+ 		AIX32=""
  		AIX64=""
  		;;
  
***************
*** 597,602 ****
--- 597,620 ----
  		XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
  		XLIBS="${LIB_AFSDB} -ldl"
  		SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
+ 		AIX32=""
+ 		AIX32=""
+ 		AIX64=""
+ 		;;
+ 
+ 	rs_aix61)	
+ 		DBG="-g"
+ 		LEX="lex"
+ 		LIBSYS_AIX_EXP="afsl.exp"
+ 		MT_CC="xlc_r"
+ 		MT_CFLAGS='-DAFS_PTHREAD_ENV ${XCFLAGS}'
+ 		MT_LIBS="-lpthreads"
+ 		SHLIB_SUFFIX="o"
+ 		TXLIBS="-lcurses"
+ 		XCFLAGS="-K -D_NONSTD_TYPES -D_MBI=void"
+ 		XLIBS="${LIB_AFSDB} -ldl"
+ 		SHLIB_LINKER="${MT_CC} -bM:SRE -berok"
+ 		AIX32="#"
  		AIX64=""
  		;;
  
***************
*** 1101,1106 ****
--- 1119,1125 ----
  AC_SUBST(CCOBJ)
  AC_SUBST(AFSD_LIBS)
  AC_SUBST(AFSD_LDFLAGS)
+ AC_SUBST(AIX32)
  AC_SUBST(AIX64)
  AC_SUBST(AR)
  AC_SUBST(AS)
Index: openafs/src/config/Makefile.config.in
diff -c openafs/src/config/Makefile.config.in:1.10.2.3 openafs/src/config/Makefile.config.in:1.10.2.4
*** openafs/src/config/Makefile.config.in:1.10.2.3	Tue Jan  8 13:57:27 2008
--- openafs/src/config/Makefile.config.in	Mon Jun 30 19:57:45 2008
***************
*** 65,70 ****
--- 65,71 ----
  PAM_LIBS = @PAM_LIBS@
  PINSTALL_LIBS = @PINSTALL_LIBS@
  RANLIB = @RANLIB@
+ PATH_CPP = @PATH_CPP@
  REGEX_OBJ = @REGEX_OBJ@
  RM = @RM@
  SHLIB_CFLAGS = @SHLIB_CFLAGS@
Index: openafs/src/config/afs_sysnames.h
diff -c openafs/src/config/afs_sysnames.h:1.50.2.29 openafs/src/config/afs_sysnames.h:1.50.2.31
*** openafs/src/config/afs_sysnames.h:1.50.2.29	Tue Jan 15 00:14:02 2008
--- openafs/src/config/afs_sysnames.h	Wed Sep  3 14:27:39 2008
***************
*** 73,78 ****
--- 73,79 ----
  #define SYS_NAME_ID_rs_aix43		 705
  #define SYS_NAME_ID_rs_aix52		 706
  #define SYS_NAME_ID_rs_aix53		 707
+ #define SYS_NAME_ID_rs_aix61		 708
  
  #define SYS_NAME_ID_sun3_411		 906
  #define SYS_NAME_ID_sun3x_411		 912
***************
*** 184,189 ****
--- 185,193 ----
  #define SYS_NAME_ID_i386_fbsd_53        2108
  #define SYS_NAME_ID_i386_fbsd_60        2112
  #define SYS_NAME_ID_i386_fbsd_61        2113
+ #define SYS_NAME_ID_i386_fbsd_62        2114
+ #define SYS_NAME_ID_i386_fbsd_70        2115
+ #define SYS_NAME_ID_i386_fbsd_80        2116
  
  #define SYS_NAME_ID_ia64_linux2		2200
  #define SYS_NAME_ID_ia64_linux22	2201
Index: openafs/src/config/param.alpha_linux_26.h
diff -c openafs/src/config/param.alpha_linux_26.h:1.1.2.5 openafs/src/config/param.alpha_linux_26.h:1.1.2.6
*** openafs/src/config/param.alpha_linux_26.h:1.1.2.5	Thu Nov  9 18:18:31 2006
--- openafs/src/config/param.alpha_linux_26.h	Mon Jun 30 16:52:22 2008
***************
*** 80,86 ****
  #define SYS_NAME       "alpha_linux_26"
  #define SYS_NAME_ID    SYS_NAME_ID_alpha_linux_26
  
! 
  #endif /* AFS_PARAM_H */
  				     
  #else /* !defined(UKERNEL) */
--- 80,90 ----
  #define SYS_NAME       "alpha_linux_26"
  #define SYS_NAME_ID    SYS_NAME_ID_alpha_linux_26
  
! #ifdef __GLIBC__
! #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 3)
! #define USE_UCONTEXT
! #endif
! #endif
  #endif /* AFS_PARAM_H */
  				     
  #else /* !defined(UKERNEL) */
Index: openafs/src/config/param.i386_fbsd_62.h
diff -c /dev/null openafs/src/config/param.i386_fbsd_62.h:1.1.6.2
*** /dev/null	Tue Oct  7 22:25:13 2008
--- openafs/src/config/param.i386_fbsd_62.h	Tue Aug 26 10:02:15 2008
***************
*** 0 ****
--- 1,209 ----
+ #ifndef	AFS_PARAM_H
+ #define	AFS_PARAM_H
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME	"i386_fbsd_62"
+ #define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_62
+ 
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    1	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV	    1	/* read/write implemented via VM */
+ 
+ 
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #ifndef IGNORE_STDS_H
+ #include <sys/param.h>
+ #endif
+ 
+ #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
+ #define AFS_X86_XBSD_ENV 1
+ 
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ #define AFS_64BIT_ENV 1
+ #define AFS_64BIT_CLIENT 1
+ #define AFS_64BIT_IOPS_ENV 1	/* Needed for NAMEI */
+ #define AFS_FBSD_ENV 1
+ #define AFS_FBSD40_ENV 1
+ #define AFS_FBSD42_ENV 1
+ #define AFS_FBSD43_ENV 1
+ #define AFS_FBSD44_ENV 1
+ #define AFS_FBSD45_ENV 1
+ #define AFS_FBSD46_ENV 1
+ #define AFS_FBSD47_ENV 1
+ #define AFS_FBSD50_ENV 1
+ #define AFS_FBSD51_ENV 1
+ #define AFS_FBSD52_ENV 1
+ #define AFS_FBSD53_ENV 1
+ #define AFS_FBSD60_ENV 1
+ #define AFS_FBSD61_ENV 1
+ #define AFS_FBSD62_ENV 1
+ #define AFS_X86_FBSD_ENV 1
+ #define AFS_X86_FBSD40_ENV 1
+ #define AFS_X86_FBSD42_ENV 1
+ #define AFS_X86_FBSD43_ENV 1
+ #define AFS_X86_FBSD46_ENV 1
+ #define AFS_X86_FBSD47_ENV 1
+ #define AFS_X86_FBSD50_ENV 1
+ #define AFS_X86_FBSD60_ENV 1
+ #define AFS_X86_FBSD62_ENV 1
+ #define AFS_X86_ENV 1
+ #define AFS_NONFSTRANS 1
+ #define FTRUNC O_TRUNC
+ 
+ #define IUPD 0x0010
+ #define IACC 0x0020
+ #define ICHG 0x0040
+ #define IMOD 0x0080
+ 
+ #define IN_LOCK(ip)     lockmgr(&ip->i_lock, LK_EXCLUSIVE, \
+                                 NULL, curproc)
+ #define IN_UNLOCK(ip)   lockmgr(&ip->i_lock, LK_RELEASE, \
+                                 NULL, curproc)
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_VFS_ENV	1
+ #define AFS_VFSINCL_ENV 1
+ #define AFS_GREEDY43_ENV	1
+ #define AFS_ENV  	1
+ 
+ #define AFS_SYSCALL	339
+ #define AFS_MOUNT_AFS	"afs"
+ 
+ #ifndef MOUNT_UFS
+ #define MOUNT_UFS "ufs"
+ #endif
+ 
+ #ifndef	MOUNT_AFS
+ #define	MOUNT_AFS AFS_MOUNT_AFS
+ #endif
+ 
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS	        0	/* if nonzero, garbage collect PAGs */
+ #define AFS_USE_GETTIMEOFDAY    1	/* use gettimeofday to implement rx clock */
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef _KERNEL
+ #define AFS_GLOBAL_SUNLOCK        1
+ #define	AFS_VFS34	1	/* What is VFS34??? */
+ #define	AFS_SHORTGID	0	/* are group id's short? */
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	UIO_SYSSPACE
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	CLBYTES
+ #define	osi_GetTime(x)	microtime(x)
+ #define AFS_KALLOC(x)   osi_fbsd_alloc((x), 1)
+ #undef	AFS_KALLOC_NOSLEEP
+ #define	AFS_KALLOC_NOSLEEP(x) osi_fbsd_alloc((x), 0)
+ #define AFS_KFREE(x,y)  osi_fbsd_free((x))
+ #define	v_count		v_usecount
+ #define v_vfsp		v_mount
+ #define vfs_bsize	mnt_stat.f_bsize
+ #define vfs_fsid	mnt_stat.f_fsid
+ #define va_nodeid	va_fileid
+ #define vfs_vnodecovered mnt_vnodecovered
+ #define direct		dirent
+ #define vnode_t		struct vnode
+ 
+ #ifndef MUTEX_DEFAULT
+ #define MUTEX_DEFAULT   0
+ #endif /* MUTEX_DEFAULT */
+ 
+ #ifndef SSYS
+ #define SSYS            0x00002
+ #endif /* SSYS */
+ 
+ #define p_rcred         p_ucred
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__)
+ enum vcexcl { NONEXCL, EXCL };
+ 
+ #ifdef KERNEL
+ #ifndef MIN
+ #define MIN(A,B) ((A) < (B) ? (A) : (B))
+ #endif
+ #ifndef MAX
+ #define MAX(A,B) ((A) > (B) ? (A) : (B))
+ #endif
+ #endif /* KERNEL */
+ 
+ #endif /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ */
+ #endif /* _KERNEL */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #define UKERNEL			1	/* user space kernel */
+ #define AFS_ENV			1
+ #define AFS_VFSINCL_ENV         1
+ #define AFS_USR_FBSD40_ENV	1
+ #define AFS_USR_FBSD42_ENV	1
+ #define AFS_USR_FBSD43_ENV	1
+ #define AFS_USR_FBSD44_ENV	1
+ #define AFS_USR_FBSD45_ENV	1
+ #define AFS_USR_FBSD46_ENV	1
+ #define AFS_USR_FBSD47_ENV	1
+ #define AFS_USR_FBSD50_ENV	1
+ #define AFS_USR_FBSD51_ENV	1
+ #define AFS_USR_FBSD52_ENV	1
+ #define AFS_USR_FBSD53_ENV	1
+ #define AFS_USR_FBSD60_ENV	1
+ #define AFS_USR_FBSD61_ENV	1
+ #define AFS_USR_FBSD62_ENV	1
+ #define AFS_USR_FBSD_ENV	1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 339
+ #define AFS_NAMEI_ENV         1	/* User space interface to file system */
+ #define AFS_64BIT_ENV 1
+ #define AFS_64BIT_IOPS_ENV    1	/* Needed for NAMEI */
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV      1
+ #define AFS_GCPAGS	      0	/* if nonzero, garbage collect PAGs */
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_fmode	uio_fmode
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	1
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	MCLBYTES
+ #define	AFS_MINCHANGE	2
+ #define	VATTR_NULL	usr_vattr_null
+ 
+ #define AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/mount.h>
+ #include <sys/fcntl.h>
+ #include <sys/uio.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <limits.h>
+ 
+ #endif /* !defined(UKERNEL) */
+ 
+ /* general user-space compiles */
+ 
+ #if defined(UKERNEL) || !defined(KERNEL)
+ #define STDLIB_HAS_MALLOC_PROTOS 1
+ #endif
+ 
+ #endif /* AFS_PARAM_H */
Index: openafs/src/config/param.i386_fbsd_70.h
diff -c /dev/null openafs/src/config/param.i386_fbsd_70.h:1.1.6.2
*** /dev/null	Tue Oct  7 22:25:13 2008
--- openafs/src/config/param.i386_fbsd_70.h	Tue Aug 26 10:02:15 2008
***************
*** 0 ****
--- 1,211 ----
+ #ifndef	AFS_PARAM_H
+ #define	AFS_PARAM_H
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME	"i386_fbsd_70"
+ #define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_70
+ 
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    1	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV	    1	/* read/write implemented via VM */
+ 
+ 
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #ifndef IGNORE_STDS_H
+ #include <sys/param.h>
+ #endif
+ 
+ #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
+ #define AFS_X86_XBSD_ENV 1
+ 
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ #define AFS_64BIT_ENV 1
+ #define AFS_64BIT_CLIENT 1
+ #define AFS_64BIT_IOPS_ENV 1	/* Needed for NAMEI */
+ #define AFS_FBSD_ENV 1
+ #define AFS_FBSD40_ENV 1
+ #define AFS_FBSD42_ENV 1
+ #define AFS_FBSD43_ENV 1
+ #define AFS_FBSD44_ENV 1
+ #define AFS_FBSD45_ENV 1
+ #define AFS_FBSD46_ENV 1
+ #define AFS_FBSD47_ENV 1
+ #define AFS_FBSD50_ENV 1
+ #define AFS_FBSD51_ENV 1
+ #define AFS_FBSD52_ENV 1
+ #define AFS_FBSD53_ENV 1
+ #define AFS_FBSD60_ENV 1
+ #define AFS_FBSD61_ENV 1
+ #define AFS_FBSD62_ENV 1
+ #define AFS_FBSD70_ENV 1
+ #define AFS_X86_FBSD_ENV 1
+ #define AFS_X86_FBSD40_ENV 1
+ #define AFS_X86_FBSD42_ENV 1
+ #define AFS_X86_FBSD43_ENV 1
+ #define AFS_X86_FBSD46_ENV 1
+ #define AFS_X86_FBSD47_ENV 1
+ #define AFS_X86_FBSD50_ENV 1
+ #define AFS_X86_FBSD60_ENV 1 /* added at 70--ie, some changes should port <-- */
+ #define AFS_X86_FBSD62_ENV 1
+ #define AFS_X86_FBSD70_ENV 1
+ #define AFS_X86_ENV 1
+ #define AFS_NONFSTRANS 1
+ #define FTRUNC O_TRUNC
+ 
+ #define IUPD 0x0010
+ #define IACC 0x0020
+ #define ICHG 0x0040
+ #define IMOD 0x0080
+ 
+ #define IN_LOCK(ip)     lockmgr(&ip->i_lock, LK_EXCLUSIVE, \
+                                 NULL, curproc)
+ #define IN_UNLOCK(ip)   lockmgr(&ip->i_lock, LK_RELEASE, \
+                                 NULL, curproc)
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_VFS_ENV	1
+ #define AFS_VFSINCL_ENV 1
+ #define AFS_GREEDY43_ENV	1
+ #define AFS_ENV  	1
+ 
+ #define AFS_SYSCALL	339
+ #define AFS_MOUNT_AFS	"afs"
+ 
+ #ifndef MOUNT_UFS
+ #define MOUNT_UFS "ufs"
+ #endif
+ 
+ #ifndef	MOUNT_AFS
+ #define	MOUNT_AFS AFS_MOUNT_AFS
+ #endif
+ 
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS	        0	/* if nonzero, garbage collect PAGs */
+ #define AFS_USE_GETTIMEOFDAY    1	/* use gettimeofday to implement rx clock */
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef _KERNEL
+ #define AFS_GLOBAL_SUNLOCK        1
+ #define	AFS_VFS34	1	/* What is VFS34??? */
+ #define	AFS_SHORTGID	0	/* are group id's short? */
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	UIO_SYSSPACE
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	CLBYTES
+ #define	osi_GetTime(x)	microtime(x)
+ #define AFS_KALLOC(x)   osi_fbsd_alloc((x), 1)
+ #undef	AFS_KALLOC_NOSLEEP
+ #define	AFS_KALLOC_NOSLEEP(x) osi_fbsd_alloc((x), 0)
+ #define AFS_KFREE(x,y)  osi_fbsd_free((x))
+ #define	v_count		v_usecount
+ #define v_vfsp		v_mount
+ #define vfs_bsize	mnt_stat.f_bsize
+ #define vfs_fsid	mnt_stat.f_fsid
+ #define va_nodeid	va_fileid
+ #define vfs_vnodecovered mnt_vnodecovered
+ #define direct		dirent
+ #define vnode_t		struct vnode
+ 
+ #ifndef MUTEX_DEFAULT
+ #define MUTEX_DEFAULT   0
+ #endif /* MUTEX_DEFAULT */
+ 
+ #ifndef SSYS
+ #define SSYS            0x00002
+ #endif /* SSYS */
+ 
+ #define p_rcred         p_ucred
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__)
+ enum vcexcl { NONEXCL, EXCL };
+ 
+ #ifdef KERNEL
+ #ifndef MIN
+ #define MIN(A,B) ((A) < (B) ? (A) : (B))
+ #endif
+ #ifndef MAX
+ #define MAX(A,B) ((A) > (B) ? (A) : (B))
+ #endif
+ #endif /* KERNEL */
+ 
+ #endif /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ */
+ #endif /* _KERNEL */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #define UKERNEL			1	/* user space kernel */
+ #define AFS_ENV			1
+ #define AFS_VFSINCL_ENV         1
+ #define AFS_USR_FBSD40_ENV	1
+ #define AFS_USR_FBSD42_ENV	1
+ #define AFS_USR_FBSD43_ENV	1
+ #define AFS_USR_FBSD44_ENV	1
+ #define AFS_USR_FBSD45_ENV	1
+ #define AFS_USR_FBSD46_ENV	1
+ #define AFS_USR_FBSD47_ENV	1
+ #define AFS_USR_FBSD50_ENV	1
+ #define AFS_USR_FBSD51_ENV	1
+ #define AFS_USR_FBSD52_ENV	1
+ #define AFS_USR_FBSD53_ENV	1
+ #define AFS_USR_FBSD60_ENV	1
+ #define AFS_USR_FBSD61_ENV	1
+ #define AFS_USR_FBSD70_ENV	1
+ #define AFS_USR_FBSD_ENV	1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 339
+ #define AFS_NAMEI_ENV         1	/* User space interface to file system */
+ #define AFS_64BIT_ENV 1
+ #define AFS_64BIT_IOPS_ENV    1	/* Needed for NAMEI */
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV      1
+ #define AFS_GCPAGS	      0	/* if nonzero, garbage collect PAGs */
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_fmode	uio_fmode
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	1
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	MCLBYTES
+ #define	AFS_MINCHANGE	2
+ #define	VATTR_NULL	usr_vattr_null
+ 
+ #define AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/mount.h>
+ #include <sys/fcntl.h>
+ #include <sys/uio.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <limits.h>
+ 
+ #endif /* !defined(UKERNEL) */
+ 
+ /* general user-space compiles */
+ 
+ #if defined(UKERNEL) || !defined(KERNEL)
+ #define STDLIB_HAS_MALLOC_PROTOS 1
+ #endif
+ 
+ #endif /* AFS_PARAM_H */
Index: openafs/src/config/param.i386_fbsd_80.h
diff -c /dev/null openafs/src/config/param.i386_fbsd_80.h:1.1.2.2
*** /dev/null	Tue Oct  7 22:25:13 2008
--- openafs/src/config/param.i386_fbsd_80.h	Tue Aug 26 10:02:15 2008
***************
*** 0 ****
--- 1,214 ----
+ #ifndef	AFS_PARAM_H
+ #define	AFS_PARAM_H
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME	"i386_fbsd_80"
+ #define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_80
+ 
+ #define AFSLITTLE_ENDIAN    1
+ #define AFS_HAVE_FFS        1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS    1	/* System doesn't support statvfs */
+ #define AFS_VM_RDWR_ENV	    1	/* read/write implemented via VM */
+ 
+ 
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ #ifndef IGNORE_STDS_H
+ #include <sys/param.h>
+ #endif
+ 
+ #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
+ #define AFS_X86_XBSD_ENV 1
+ 
+ #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+ #define AFS_64BIT_ENV 1
+ #define AFS_64BIT_CLIENT 1
+ #define AFS_64BIT_IOPS_ENV 1	/* Needed for NAMEI */
+ #define AFS_FBSD_ENV 1
+ #define AFS_FBSD40_ENV 1
+ #define AFS_FBSD42_ENV 1
+ #define AFS_FBSD43_ENV 1
+ #define AFS_FBSD44_ENV 1
+ #define AFS_FBSD45_ENV 1
+ #define AFS_FBSD46_ENV 1
+ #define AFS_FBSD47_ENV 1
+ #define AFS_FBSD50_ENV 1
+ #define AFS_FBSD51_ENV 1
+ #define AFS_FBSD52_ENV 1
+ #define AFS_FBSD53_ENV 1
+ #define AFS_FBSD60_ENV 1
+ #define AFS_FBSD61_ENV 1
+ #define AFS_FBSD62_ENV 1
+ #define AFS_FBSD70_ENV 1
+ #define AFS_FBSD80_ENV 1
+ #define AFS_X86_FBSD_ENV 1
+ #define AFS_X86_FBSD40_ENV 1
+ #define AFS_X86_FBSD42_ENV 1
+ #define AFS_X86_FBSD43_ENV 1
+ #define AFS_X86_FBSD46_ENV 1
+ #define AFS_X86_FBSD47_ENV 1
+ #define AFS_X86_FBSD50_ENV 1
+ #define AFS_X86_FBSD60_ENV 1 /* added at 70--ie, some changes should port <-- */
+ #define AFS_X86_FBSD62_ENV 1
+ #define AFS_X86_FBSD70_ENV 1
+ #define AFS_X86_FBSD80_ENV 1
+ #define AFS_X86_ENV 1
+ #define AFS_NONFSTRANS 1
+ #define FTRUNC O_TRUNC
+ 
+ #define IUPD 0x0010
+ #define IACC 0x0020
+ #define ICHG 0x0040
+ #define IMOD 0x0080
+ 
+ #define IN_LOCK(ip)     lockmgr(&ip->i_lock, LK_EXCLUSIVE, \
+                                 NULL, curproc)
+ #define IN_UNLOCK(ip)   lockmgr(&ip->i_lock, LK_RELEASE, \
+                                 NULL, curproc)
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define AFS_VFS_ENV	1
+ #define AFS_VFSINCL_ENV 1
+ #define AFS_GREEDY43_ENV	1
+ #define AFS_ENV  	1
+ 
+ #define AFS_SYSCALL	339
+ #define AFS_MOUNT_AFS	"afs"
+ 
+ #ifndef MOUNT_UFS
+ #define MOUNT_UFS "ufs"
+ #endif
+ 
+ #ifndef	MOUNT_AFS
+ #define	MOUNT_AFS AFS_MOUNT_AFS
+ #endif
+ 
+ #define RXK_LISTENER_ENV 1
+ #define AFS_GCPAGS	        0	/* if nonzero, garbage collect PAGs */
+ #define AFS_USE_GETTIMEOFDAY    1	/* use gettimeofday to implement rx clock */
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef _KERNEL
+ #define AFS_GLOBAL_SUNLOCK        1
+ #define	AFS_VFS34	1	/* What is VFS34??? */
+ #define	AFS_SHORTGID	0	/* are group id's short? */
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	UIO_SYSSPACE
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	CLBYTES
+ #define	osi_GetTime(x)	microtime(x)
+ #define AFS_KALLOC(x)   osi_fbsd_alloc((x), 1)
+ #undef	AFS_KALLOC_NOSLEEP
+ #define	AFS_KALLOC_NOSLEEP(x) osi_fbsd_alloc((x), 0)
+ #define AFS_KFREE(x,y)  osi_fbsd_free((x))
+ #define	v_count		v_usecount
+ #define v_vfsp		v_mount
+ #define vfs_bsize	mnt_stat.f_bsize
+ #define vfs_fsid	mnt_stat.f_fsid
+ #define va_nodeid	va_fileid
+ #define vfs_vnodecovered mnt_vnodecovered
+ #define direct		dirent
+ #define vnode_t		struct vnode
+ 
+ #ifndef MUTEX_DEFAULT
+ #define MUTEX_DEFAULT   0
+ #endif /* MUTEX_DEFAULT */
+ 
+ #ifndef SSYS
+ #define SSYS            0x00002
+ #endif /* SSYS */
+ 
+ #define p_rcred         p_ucred
+ 
+ #if	!defined(ASSEMBLER) && !defined(__LANGUAGE_ASSEMBLY__)
+ enum vcexcl { NONEXCL, EXCL };
+ 
+ #ifdef KERNEL
+ #ifndef MIN
+ #define MIN(A,B) ((A) < (B) ? (A) : (B))
+ #endif
+ #ifndef MAX
+ #define MAX(A,B) ((A) > (B) ? (A) : (B))
+ #endif
+ #endif /* KERNEL */
+ 
+ #endif /* ! ASSEMBLER & ! __LANGUAGE_ASSEMBLY__ */
+ #endif /* _KERNEL */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ #define UKERNEL			1	/* user space kernel */
+ #define AFS_ENV			1
+ #define AFS_VFSINCL_ENV         1
+ #define AFS_USR_FBSD40_ENV	1
+ #define AFS_USR_FBSD42_ENV	1
+ #define AFS_USR_FBSD43_ENV	1
+ #define AFS_USR_FBSD44_ENV	1
+ #define AFS_USR_FBSD45_ENV	1
+ #define AFS_USR_FBSD46_ENV	1
+ #define AFS_USR_FBSD47_ENV	1
+ #define AFS_USR_FBSD50_ENV	1
+ #define AFS_USR_FBSD51_ENV	1
+ #define AFS_USR_FBSD52_ENV	1
+ #define AFS_USR_FBSD53_ENV	1
+ #define AFS_USR_FBSD60_ENV	1
+ #define AFS_USR_FBSD61_ENV	1
+ #define AFS_USR_FBSD70_ENV	1
+ #define AFS_USR_FBSD80_ENV	1
+ #define AFS_USR_FBSD_ENV	1
+ #define AFS_NONFSTRANS 1
+ 
+ #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
+ #define AFS_SYSCALL 339
+ #define AFS_NAMEI_ENV         1	/* User space interface to file system */
+ #define AFS_64BIT_ENV 1
+ #define AFS_64BIT_IOPS_ENV    1	/* Needed for NAMEI */
+ #define AFS_USERSPACE_IP_ADDR 1
+ #define RXK_LISTENER_ENV      1
+ #define AFS_GCPAGS	      0	/* if nonzero, garbage collect PAGs */
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_fmode	uio_fmode
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	1
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	MCLBYTES
+ #define	AFS_MINCHANGE	2
+ #define	VATTR_NULL	usr_vattr_null
+ 
+ #define AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #include <sys/param.h>
+ #include <sys/types.h>
+ #include <sys/mount.h>
+ #include <sys/fcntl.h>
+ #include <sys/uio.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <limits.h>
+ 
+ #endif /* !defined(UKERNEL) */
+ 
+ /* general user-space compiles */
+ 
+ #if defined(UKERNEL) || !defined(KERNEL)
+ #define STDLIB_HAS_MALLOC_PROTOS 1
+ #endif
+ 
+ #endif /* AFS_PARAM_H */
Index: openafs/src/config/param.rs_aix61.h
diff -c /dev/null openafs/src/config/param.rs_aix61.h:1.1.4.2
*** /dev/null	Tue Oct  7 22:25:13 2008
--- openafs/src/config/param.rs_aix61.h	Wed Sep  3 14:27:39 2008
***************
*** 0 ****
--- 1,181 ----
+ #ifndef UKERNEL
+ /* This section for kernel libafs compiles only */
+ 
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef	AFS_PARAM_H
+ #define	AFS_PARAM_H
+ 
+ #define	AFS_AIX_ENV		1
+ #define	AFS_AIX32_ENV		1
+ #define	AFS_AIX41_ENV		1
+ #define AFS_AIX42_ENV		1
+ #define AFS_AIX51_ENV		1
+ #define AFS_AIX52_ENV		1
+ #define AFS_AIX53_ENV		1
+ #define AFS_AIX61_ENV		1
+ 
+ #define AFS_64BIT_ENV		1
+ #define AFS_64BIT_CLIENT	1
+ #define AFS_NAMEI_ENV		1
+ #ifdef AFS_NAMEI_ENV
+ #define AFS_64BIT_IOPS_ENV	1
+ #endif
+ 
+ #define AFS_HAVE_FLOCK_SYSID    1
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ /* Global lock in AFS part of client. */
+ #define AFS_GLOBAL_SUNLOCK 1
+ #define AFS_GCPAGS		1	/* if nonzero, garbage collect PAGs */
+ 
+ /* File system entry (used if vmount.h doesn't define MNT_AFS */
+ #define AFS_MOUNT_AFS	4
+ #define AFS_SYSCALL    31
+ 
+ /* Machine / Operating system information */
+ #define SYS_NAME	"rs_aix61"
+ #define SYS_NAME_ID	SYS_NAME_ID_rs_aix61
+ #define AFSBIG_ENDIAN	1
+ #define RIOS		1	/* POWERseries 6000. (sj/pc)    */
+ #define AFS_VM_RDWR_ENV 1	/* read/write implemented via VM */
+ #define AFS_USE_GETTIMEOFDAY 1	/* use gettimeofday to implement rx clock */
+ #define AFS_HAVE_STATVFS	1	/* System supports statvfs */
+ 
+ #ifndef _POWER
+ #define _POWER		1	/* _POWERseries!                */
+ #endif
+ #ifndef COMPAT_43
+ #define COMPAT_43
+ #endif
+ 
+ #define KERNEL_HAVE_UERROR 1
+ #define KERNEL_HAVE_PIN 1
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef _KERNEL
+ #define	AFS_SHORTGID	1
+ #define	AFS_UIOFMODE	1
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_fmode	uio_fmode
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	UIO_SYSSPACE
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	CLBYTES
+ #define	AFS_MINCHANGE	2
+ #define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
+ #define	osi_GTime(x)	time	/* something for the silly time(0)?? */
+ #define	AFS_KALLOC	kmem_alloc
+ #define	AFS_KFREE	kmem_free
+ #define	VATTR_NULL(V)	memset((void*)V, -1, sizeof(*(V)))
+ #define va_nodeid	va_serialno
+ #endif /* !_KERNEL      */
+ #define	AFS_DIRENT
+ #endif /* AFS_PARAM_H */
+ 
+ #else /* !defined(UKERNEL) */
+ 
+ /* This section for user space compiles only */
+ 
+ /*
+  * Copyright 2000, International Business Machines Corporation and others.
+  * All Rights Reserved.
+  * 
+  * This software has been released under the terms of the IBM Public
+  * License.  For details, see the LICENSE file in the top-level source
+  * directory or online at http://www.openafs.org/dl/license10.html
+  */
+ 
+ #ifndef	AFS_PARAM_H
+ #define	AFS_PARAM_H
+ 
+ #define AFS_64BIT_ENV           1
+ #define AFS_64BIT_CLIENT        1
+ #define AFS_NAMEI_ENV           1
+ #ifdef AFS_NAMEI_ENV
+ #define AFS_64BIT_IOPS_ENV	1
+ #endif
+ #define BITMAP_LATER            1
+ #define FAST_RESTART            1
+ 
+ #define AFS_VFS_ENV	1
+ /* Used only in vfsck code; is it needed any more???? */
+ #define RXK_LISTENER_ENV	1
+ #define AFS_USERSPACE_IP_ADDR	1
+ #define AFS_GCPAGS		0	/* if nonzero, garbage collect PAGs */
+ 
+ #ifdef KERNEL
+ 
+ #define UKERNEL			1	/* user space kernel */
+ #define AFS_ENV			1
+ #define AFS_USR_AIX_ENV		1
+ #define AFS_USR_AIX41_ENV	1
+ #define AFS_USR_AIX42_ENV	1
+ #define AFS_USR_AIX51_ENV		1
+ 
+ #else /* KERNEL */
+ 
+ #define	AFS_AIX_ENV		1
+ #define	AFS_AIX32_ENV		1
+ #define	AFS_AIX41_ENV		1
+ #define AFS_AIX42_ENV		1
+ #define AFS_AIX51_ENV		1
+ 
+ #define AFS_HAVE_FLOCK_SYSID    1
+ 
+ #endif /* KERNEL */
+ 
+ #include <afs/afs_sysnames.h>
+ 
+ 													       /*#define AFS_GLOBAL_SUNLOCK    1 *//* For global locking */
+ 
+ #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
+ #define	AFS_SYSCALL		105
+ 
+ /* File system entry (used if mount.h doesn't define MOUNT_AFS */
+ #define AFS_MOUNT_AFS	 4
+ 
+ /* Machine / Operating system information */
+ #define sys_rs_aix51	1
+ #define SYS_NAME	"rs_aix51"
+ #define SYS_NAME_ID	SYS_NAME_ID_rs_aix51
+ #define AFSBIG_ENDIAN	1
+ #define AFS_HAVE_FFS            1	/* Use system's ffs. */
+ #define AFS_HAVE_STATVFS	0	/* System doesn't support statvfs */
+ 
+ /* Extra kernel definitions (from kdefs file) */
+ #ifdef KERNEL
+ #define	AFS_UIOFMODE		1	/* Only in afs/afs_vnodeops.c (afs_ustrategy) */
+ #define	AFS_SYSVLOCK		1	/* sys v locking supported */
+ /*#define	AFS_USEBUFFERS	1*/
+ #define	afsio_iov	uio_iov
+ #define	afsio_iovcnt	uio_iovcnt
+ #define	afsio_offset	uio_offset
+ #define	afsio_seg	uio_segflg
+ #define	afsio_fmode	uio_fmode
+ #define	afsio_resid	uio_resid
+ #define	AFS_UIOSYS	1
+ #define	AFS_UIOUSER	UIO_USERSPACE
+ #define	AFS_CLBYTES	MCLBYTES
+ #define	AFS_MINCHANGE	2
+ #define	VATTR_NULL	usr_vattr_null
+ #endif /* KERNEL */
+ #define	AFS_DIRENT
+ #ifndef CMSERVERPREF
+ #define CMSERVERPREF
+ #endif
+ 
+ #endif /* AFS_PARAM_H */
+ 
+ #endif /* !defined(UKERNEL) */
Index: openafs/src/config/param.s390_linux26.h
diff -c openafs/src/config/param.s390_linux26.h:1.1.2.4 openafs/src/config/param.s390_linux26.h:1.1.2.5
*** openafs/src/config/param.s390_linux26.h:1.1.2.4	Thu Nov  9 18:18:31 2006
--- openafs/src/config/param.s390_linux26.h	Mon Jun 30 16:52:22 2008
***************
*** 86,91 ****
--- 86,96 ----
  #endif
  #endif /* KERNEL */
  
+ #ifdef __GLIBC__
+ #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 3)
+ #define USE_UCONTEXT
+ #endif
+ #endif
  #endif /* AFS_PARAM_H */
  
  #else /* !defined(UKERNEL) */
Index: openafs/src/config/param.s390x_linux26.h
diff -c openafs/src/config/param.s390x_linux26.h:1.1.2.6 openafs/src/config/param.s390x_linux26.h:1.1.2.7
*** openafs/src/config/param.s390x_linux26.h:1.1.2.6	Thu Nov  9 18:18:31 2006
--- openafs/src/config/param.s390x_linux26.h	Mon Jun 30 16:52:22 2008
***************
*** 89,94 ****
--- 89,99 ----
  #endif
  #endif /* KERNEL */
  
+ #ifdef __GLIBC__
+ #if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 3)
+ #define USE_UCONTEXT
+ #endif
+ #endif
  #endif /* AFS_PARAM_H */
  
  #else /* !defined(UKERNEL) */
Index: openafs/src/config/stds.h
diff -c openafs/src/config/stds.h:1.21.2.1 openafs/src/config/stds.h:1.21.2.4
*** openafs/src/config/stds.h:1.21.2.1	Sun May  8 02:01:12 2005
--- openafs/src/config/stds.h	Sat Aug 16 15:15:50 2008
***************
*** 44,49 ****
--- 44,54 ----
  #error We require size of long and pointers to be equal
  #endif */
  
+ #define MAX_AFS_INT32 0x7FFFFFFFL
+ #define MAX_AFS_UINT32 0xFFFFFFFFL
+ #define MAX_AFS_INT64 0x7FFFFFFFFFFFFFFFL
+ #define MAX_AFS_UINT64 0xFFFFFFFFFFFFFFFFL
+ 
  typedef short afs_int16;
  typedef unsigned short afs_uint16;
  #ifdef  AFS_64BIT_ENV
***************
*** 65,73 ****
  #define CompareInt64(a,b) (afs_int64)(a) - (afs_int64)(b)
  #define CompareUInt64(a,b) (afs_uint64)(a) - (afs_uint64)(b)
  #define NonZeroInt64(a)                (a)
! #define Int64ToInt32(a)    (a) & 0xFFFFFFFFL
! #define FillInt64(t,h,l) (t) = (h); (t) <<= 32; (t) |= (l);
! #define SplitInt64(t,h,l) (h) = (t) >> 32; (l) = (t) & 0xFFFFFFFF;
  #else /* AFS_64BIT_ENV */
  typedef long afs_int32;
  typedef unsigned long afs_uint32;
--- 70,80 ----
  #define CompareInt64(a,b) (afs_int64)(a) - (afs_int64)(b)
  #define CompareUInt64(a,b) (afs_uint64)(a) - (afs_uint64)(b)
  #define NonZeroInt64(a)                (a)
! #define Int64ToInt32(a)    (a) & MAX_AFS_UINT32
! #define FillInt64(t,h,l) (t) = ((afs_int64)(h) << 32) | (l);
! #define SplitInt64(t,h,l) (h) = ((afs_int64)t) >> 32; (l) = (t) & MAX_AFS_UINT32;
! #define RoundInt64ToInt32(a)    (a > MAX_AFS_UINT32) ? MAX_AFS_UINT32 : a;
! #define RoundInt64ToInt31(a)    (a > MAX_AFS_INT32) ? MAX_AFS_INT32 : a;
  #else /* AFS_64BIT_ENV */
  typedef long afs_int32;
  typedef unsigned long afs_uint32;
***************
*** 95,100 ****
--- 102,109 ----
  #define Int64ToInt32(a)    (a).low
  #define FillInt64(t,h,l) (t).high = (h); (t).low = (l);
  #define SplitInt64(t,h,l) (h) = (t).high; (l) = (t).low;
+ #define RoundInt64ToInt32(a)    (a.high > 0) ? MAX_AFS_UINT32 : a.low;
+ #define RoundInt64ToInt31(a)    (a.high > 0) ? MAX_AFS_INT32 : (a.low & MAX_AFS_INT32);
  #endif /* AFS_64BIT_ENV */
  
  /* AFS_64BIT_CLIENT should presently be set only for AFS_64BIT_ENV systems */
Index: openafs/src/export/Makefile.in
diff -c openafs/src/export/Makefile.in:1.15.2.6 openafs/src/export/Makefile.in:1.15.2.9
*** openafs/src/export/Makefile.in:1.15.2.6	Tue Jun 20 17:40:46 2006
--- openafs/src/export/Makefile.in	Sat Sep  6 07:59:27 2008
***************
*** 12,48 ****
    IMPORTS = /lib/kernex.exp /lib/syscalls.exp ${srcdir}/extras.exp
       KOBJ = export.o symtab.o
  
! include ../config/Makefile.version
  
! all: ${TOP_LIBDIR}/export.exp ${TOP_LIBDIR}/export64.exp ${TOP_LIBDIR}/extras.exp cfgexport cfgafs
! 	${INSTALL} ${srcdir}/export.h ${KERNELDIR}
! 	${INSTALL} export.exp ${KERNELDIR}
! 	${INSTALL} export64.exp ${KERNELDIR}
! 	${INSTALL} ${srcdir}/export.h ${UKERNELDIR}
! 	${INSTALL} export64.exp ${UKERNELDIR}
! 	${INSTALL} export.exp ${UKERNELDIR}
  
! noversion system: install
  
! install:    ${DESTDIR}${afskerneldir}/export.ext \
! 	${DESTDIR}${afskerneldir}/export.ext.nonfs \
! 	${DESTDIR}${afskerneldir}/export64.ext.nonfs \
! 	${DESTDIR}${libdir}/afs/export.exp \
! 	${DESTDIR}${libdir}/afs/export64.exp \
! 	${DESTDIR}${libdir}/afs/extras.exp \
! 	${DESTDIR}${afskerneldir}/cfgexport \
! 	${DESTDIR}${afskerneldir}/cfgafs \
! 	${DESTDIR}${afskerneldir}/export64.ext \
! 	${DESTDIR}${afskerneldir}/cfgexport64 \
! 	${DESTDIR}${afskerneldir}/cfgafs64 
  
  export.exp: ${srcdir}/export4.exp ${srcdir}/export5.exp
  	case ${SYS_NAME} in \
  	rs_aix4* ) \
! 		cp -p ${srcdir}/export4.exp export.exp ; \
  		cp -p ${srcdir}/export4-64.exp export64.exp ;; \
  	rs_aix5* ) \
! 		cp -p ${srcdir}/export5.exp export.exp ; \
  		cp -p ${srcdir}/export5-64.exp export64.exp ;; \
  	esac
  
--- 12,56 ----
    IMPORTS = /lib/kernex.exp /lib/syscalls.exp ${srcdir}/extras.exp
       KOBJ = export.o symtab.o
  
! EXPORTS32 = @AIX32@export.exp export.ext.nonfs export.ext cfgexport cfgafs
! EXPORTS64 = @AIX64@export64.exp export64.ext.nonfs export64.ext cfgexport64 cfgafs64
! TOPEXP32  = @AIX32@${TOP_LIBDIR}/export.exp
! TOPEXP64  = @AIX64@${TOP_LIBDIR}/export64.exp
! 
! all: $(TOPEXP32) $(TOPEXP64) ${TOP_LIBDIR}/extras.exp
! 	${INSTALL} ${srcdir}/export.h ${KERNELDIR}/export.h
! 	@AIX32@${INSTALL} export.exp ${KERNELDIR}/export.exp
! 	@AIX64@${INSTALL} export64.exp ${KERNELDIR}/export64.exp
! 	${INSTALL} ${srcdir}/export.h ${UKERNELDIR}/export.h
! 	@AIX32@${INSTALL} export.exp ${UKERNELDIR}/export.exp
! 	@AIX64@${INSTALL} export64.exp ${UKERNELDIR}/export64.exp
  
! ${TOP_LIBDIR}/export.exp: export.exp
! 	${INSTALL} $? $@
  
! ${TOP_LIBDIR}/export64.exp: export64.exp
! 	${INSTALL} $? $@
  
! ${TOP_LIBDIR}/extras.exp: ${srcdir}/extras.exp
! 	${INSTALL} $? $@
! 
! noversion system: install
  
  export.exp: ${srcdir}/export4.exp ${srcdir}/export5.exp
  	case ${SYS_NAME} in \
  	rs_aix4* ) \
! 		cp -p ${srcdir}/export4.exp export.exp ;; \
! 	rs_aix5* ) \
! 		cp -p ${srcdir}/export5.exp export.exp ;; \
! 	esac
! 
! export64.exp: ${srcdir}/export4-64.exp ${srcdir}/export5-64.exp
! 	case ${SYS_NAME} in \
! 	rs_aix4* ) \
  		cp -p ${srcdir}/export4-64.exp export64.exp ;; \
  	rs_aix5* ) \
! 		cp -p ${srcdir}/export5-64.exp export64.exp ;; \
! 	rs_aix6* ) \
  		cp -p ${srcdir}/export5-64.exp export64.exp ;; \
  	esac
  
***************
*** 69,74 ****
--- 77,85 ----
  		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/symtab.c ; \
  		mv symtab.o symtab64.o ; \
  		${CC} ${CFLAGS} -DAFS_AIX51_ENV -c ${srcdir}/symtab.c ;; \
+ 	rs_aix6* ) \
+ 		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/symtab.c ; \
+ 		mv symtab.o symtab64.o ;; \
  	esac
  
  export.o export64.o: ${srcdir}/export.c
***************
*** 79,96 ****
  		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
  		mv export.o export64.o ; \
  		${CC} ${CFLAGS} -DAFS_AIX51_ENV -c ${srcdir}/export.c ;; \
  	esac
!                
  export.nonfs.o export64.nonfs.o: ${srcdir}/export.c
  	case ${SYS_NAME} in \
  	rs_aix4* ) \
! 		${CC} ${INCS} -DAFS_NONFSTRANS -c ${srcdir}/export.c ;; \
  	rs_aix5* ) \
  		${CC} -q64 ${INCS} -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
  		mv export.o export64.nonfs.o ; \
! 		${CC} ${INCS} -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ;; \
  	esac
- 	-mv export.o export.nonfs.o
  
  cfgexport: cfgexport.o
  	${CC} -g ${INCS} -o cfgexport cfgexport.o
--- 90,114 ----
  		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
  		mv export.o export64.o ; \
  		${CC} ${CFLAGS} -DAFS_AIX51_ENV -c ${srcdir}/export.c ;; \
+ 	rs_aix6* ) \
+ 		${CC} ${CFLAGS} -q64 -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
+ 		mv export.o export64.o ;; \
  	esac
! 
  export.nonfs.o export64.nonfs.o: ${srcdir}/export.c
  	case ${SYS_NAME} in \
  	rs_aix4* ) \
! 		${CC} ${INCS} -DAFS_NONFSTRANS -c ${srcdir}/export.c ; \
! 		mv export.o export.nonfs.o ;; \
  	rs_aix5* ) \
  		${CC} -q64 ${INCS} -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
  		mv export.o export64.nonfs.o ; \
! 		${CC} ${INCS} -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
! 		mv export.o export.nonfs.o ;; \
! 	rs_aix6* ) \
! 		${CC} -q64 ${INCS} -D__XCOFF64__ -DAFS_64BIT_KERNEL -DAFS_NONFSTRANS -DAFS_AIX51_ENV -c ${srcdir}/export.c ; \
! 		mv export.o export64.nonfs.o ;; \
  	esac
  
  cfgexport: cfgexport.o
  	${CC} -g ${INCS} -o cfgexport cfgexport.o
***************
*** 119,209 ****
  	$(RM) -f cfgafs cfgafs64
  	$(RM) -f *.ext *.ext.nonfs
  
! ${DEST}/root.client/usr/vice/etc/dkload/export.ext: export.ext
! 	${INSTALL} $? $@
! 
! ${DEST}/root.client/usr/vice/etc/dkload/export64.ext: @AIX64@export64.ext
! @AIX64@	${INSTALL} $? $@
! 
! ${DEST}/root.client/usr/vice/etc/dkload/export.ext.nonfs: export.ext.nonfs
! 	${INSTALL} $? $@
! 
! ${DEST}/root.client/usr/vice/etc/dkload/export64.ext.nonfs: @AIX64@export64.ext.nonfs
! @AIX64@	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/export.ext: export.ext
! 	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/export64.ext: @AIX64@export64.ext
! @AIX64@	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/export.ext.nonfs: export.ext.nonfs
! 	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/export64.ext.nonfs: @AIX64@export64.ext.nonfs
! @AIX64@	${INSTALL} $? $@
! 
! ${DEST}/lib/afs/export.exp: export.exp
! 	${INSTALL} $? $@
  
! ${DEST}/lib/afs/export64.exp: export64.exp
! 	${INSTALL} $? $@
! 
! ${DESTDIR}${libdir}/afs/export.exp: export.exp
! 	${INSTALL} $? $@ 
! 
! ${DESTDIR}${libdir}/afs/export64.exp: export64.exp
! 	${INSTALL} $? $@ 
! 
! ${TOP_LIBDIR}/export.exp: export.exp
! 	${INSTALL} $? $@
! 
! ${TOP_LIBDIR}/export64.exp: export64.exp
! 	${INSTALL} $? $@
! 
! ${DEST}/lib/afs/extras.exp: ${srcdir}/extras.exp
! 	${INSTALL} $? $@
! 
! ${DESTDIR}${libdir}/afs/extras.exp: ${srcdir}/extras.exp
! 	${INSTALL} $? $@
! 
! 
! ${TOP_LIBDIR}/extras.exp: ${srcdir}/extras.exp
! 	${INSTALL} $? $@
! 
! 
! ${DEST}/root.client/usr/vice/etc/dkload/cfgexport: cfgexport
! 	${INSTALL} $? $@
! 
! ${DEST}/root.client/usr/vice/etc/dkload/cfgexport64: @AIX64@cfgexport64
! @AIX64@	${INSTALL} $? $@
! 
! ${DEST}/root.client/usr/vice/etc/dkload/cfgafs: cfgafs
! 	${INSTALL} $? $@
! 
! ${DEST}/root.client/usr/vice/etc/dkload/cfgafs64: @AIX64@cfgafs64
! @AIX64@	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/cfgexport: cfgexport
! 	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/cfgexport64: @AIX64@cfgexport64
! @AIX64@	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/cfgafs: cfgafs
! 	${INSTALL} $? $@
! 
! ${DESTDIR}${afskerneldir}/cfgafs64: @AIX64@cfgafs64
! @AIX64@	${INSTALL} $? $@
! 
! dest:    ${DEST}/root.client/usr/vice/etc/dkload/export.ext \
! 	${DEST}/root.client/usr/vice/etc/dkload/export.ext.nonfs \
! 	${DEST}/root.client/usr/vice/etc/dkload/export64.ext.nonfs \
! 	${DEST}/lib/afs/export.exp \
! 	${DEST}/lib/afs/export64.exp \
! 	${DEST}/lib/afs/extras.exp \
! 	${DEST}/root.client/usr/vice/etc/dkload/cfgexport \
! 	${DEST}/root.client/usr/vice/etc/dkload/cfgafs \
! 	${DEST}/root.client/usr/vice/etc/dkload/export64.ext \
! 	${DEST}/root.client/usr/vice/etc/dkload/cfgexport64 \
! 	${DEST}/root.client/usr/vice/etc/dkload/cfgafs64 
--- 137,166 ----
  	$(RM) -f cfgafs cfgafs64
  	$(RM) -f *.ext *.ext.nonfs
  
! install: $(EXPORTS32) $(EXPORTS64)
! 	${INSTALL} ${srcdir}/extras.exp ${DESTDIR}${libdir}/afs/extras.exp
! 	@AIX32@${INSTALL} export.exp ${DESTDIR}${libdir}/afs/export.exp
! 	@AIX32@${INSTALL} export.ext ${DESTDIR}${afskerneldir}/export.ext
! 	@AIX32@${INSTALL} export.ext.nonfs ${DESTDIR}${afskerneldir}/export.ext.nonfs
! 	@AIX32@${INSTALL} cfgexport ${DESTDIR}${afskerneldir}/cfgexport
! 	@AIX32@${INSTALL} cfgafs ${DESTDIR}${afskerneldir}/cfgafs
! 	@AIX64@${INSTALL} export64.exp ${DESTDIR}${libdir}/afs/export64.exp
! 	@AIX64@${INSTALL} export64.ext ${DESTDIR}${afskerneldir}/export64.ext
! 	@AIX64@${INSTALL} export64.ext.nonfs ${DESTDIR}${afskerneldir}/export64.ext.nonfs
! 	@AIX64@${INSTALL} cfgexport64 ${DESTDIR}${afskerneldir}/cfgexport64
! 	@AIX64@${INSTALL} cfgafs64 ${DESTDIR}${afskerneldir}/cfgafs64
! 
! dest: $(EXPORTS32) $(EXPORTS64)
! 	${INSTALL} ${srcdir}/extras.exp ${DEST}/lib/afs/extras.exp
! 	@AIX32@${INSTALL} export.exp ${DEST}/lib/afs/export.exp
! 	@AIX32@${INSTALL} export.ext ${DEST}/root.client/usr/vice/etc/dkload/export.ext
! 	@AIX32@${INSTALL} export.ext.nonfs ${DEST}/root.client/usr/vice/etc/dkload/export.ext.nonfs
! 	@AIX32@${INSTALL} cfgexport ${DEST}/root.client/usr/vice/etc/dkload/cfgexport
! 	@AIX32@${INSTALL} cfgafs ${DEST}/root.client/usr/vice/etc/dkload/cfgafs
! 	@AIX64@${INSTALL} export64.exp ${DEST}/lib/afs/export64.exp
! 	@AIX64@${INSTALL} export64.ext ${DEST}/root.client/usr/vice/etc/dkload/export64.ext
! 	@AIX64@${INSTALL} export64.ext.nonfs ${DEST}/root.client/usr/vice/etc/dkload/export64.ext.nonfs
! 	@AIX64@${INSTALL} cfgexport64 ${DEST}/root.client/usr/vice/etc/dkload/cfgexport64
! 	@AIX64@${INSTALL} cfgafs64 ${DEST}/root.client/usr/vice/etc/dkload/cfgafs64
  
! include ../config/Makefile.version
Index: openafs/src/export/cfgexport.c
diff -c openafs/src/export/cfgexport.c:1.11.2.1 openafs/src/export/cfgexport.c:1.11.2.2
*** openafs/src/export/cfgexport.c:1.11.2.1	Tue Dec  7 11:48:42 2004
--- openafs/src/export/cfgexport.c	Wed Sep  3 14:27:40 2008
***************
*** 14,20 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/export/cfgexport.c,v 1.11.2.1 2004/12/07 16:48:42 shadow Exp $");
  
  #include <errno.h>
  #include <stdio.h>
--- 14,20 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/export/cfgexport.c,v 1.11.2.2 2008/09/03 18:27:40 shadow Exp $");
  
  #include <errno.h>
  #include <stdio.h>
***************
*** 377,383 ****
   *	strp	-	^ to ^ to EXPORT string table
   *	szp	-	^ to EXPORT string table size
   */
! #define SYMBUFSIZE 262144
  xlate_xtok(xp, kp, strp, szp)
       register struct syment *xp;
       register sym_t *kp;
--- 377,383 ----
   *	strp	-	^ to ^ to EXPORT string table
   *	szp	-	^ to EXPORT string table size
   */
! #define SYMBUFSIZE 1048576
  xlate_xtok(xp, kp, strp, szp)
       register struct syment *xp;
       register sym_t *kp;
***************
*** 420,431 ****
--- 420,437 ----
  	 */
  	len = strlen(xstrings + xp->n_offset) + 1;
  	while (len >= left) {
+ 	    fprintf(stderr, "cfgexport: Out of memory. Increase SYMBUFSIZE and recompile\n");
+ 	    exit(1);
+ #if 0
+ 	    /* Something is broken with this code, after being here
+ 	       cfgexport segfaults */
  	    export_strings = (char *)realloc(*strp, sz += SYMBUFSIZE);
  	    if (!export_strings)
  		error("no memory for EXPORT string table");
  	    *strp = export_strings;
  	    left += SYMBUFSIZE;
  	    prev = "";		/* lazy */
+ #endif
  	}
  
  	strcpy(prev = *strp + offset, xstrings + xp->n_offset);
Index: openafs/src/fsint/afsint.xg
diff -c openafs/src/fsint/afsint.xg:1.13.2.1 openafs/src/fsint/afsint.xg:1.13.2.2
*** openafs/src/fsint/afsint.xg:1.13.2.1	Tue Feb  5 13:56:27 2008
--- openafs/src/fsint/afsint.xg	Sat Aug 16 15:15:45 2008
***************
*** 702,704 ****
--- 702,781 ----
  CallBackRxConnAddr(
    IN afs_int32 *addr
  ) = 65541;
+ 
+ %#define STATS64_CURRENTTIME 0
+ %#define STATS64_BOOTTIME 1
+ %#define STATS64_STARTTIME 2
+ %#define STATS64_CURRENTCONNECTIONS 3
+ %#define STATS64_TOTALFETCHES 4
+ %#define STATS64_FETCHDATAS 5
+ %#define STATS64_FETCHEDBYTES 6
+ %#define STATS64_FETCHDATARATE 7
+ %#define STATS64_TOTALSTORES 8
+ %#define STATS64_STOREDATAS 9
+ %#define STATS64_STOREDBYTES 10
+ %#define STATS64_STOREDATARATE 11
+ %#define STATS64_TOTALVICECALLS 12
+ %#define STATS64_WORKSTATIONS 13
+ %#define STATS64_ACTIVEWORKSTATIONS 14
+ %#define STATS64_PROCESSSIZE 15
+ 
+ const STATS64_VERSION = 16;
+ typedef afs_uint64 ViceStatistics64<STATS64_VERSION>;
+ 
+ /* the "version" is a number representing the number of 
+    array elements to return, from 0 to N-1 */
+ 
+ GetStatistics64(
+     IN afs_int32 statsVersion,
+     OUT ViceStatistics64 *Statistics
+ ) = 65542;
+ 
+ /* rx osd. put here now to hold version numbers.
+ ServerPath(
+   IN  AFSFid *Fid,
+   afs_int32 writing,
+   OUT FilePath *NameiInfo,
+   AFSFetchStatus *OutStatus,
+   AFSCallBack *CallBack
+ ) = 65551;
+ 
+ PerfTest(
+   IN  afs_int32 type,
+   afs_int64 bytes,
+   afs_int32 bufsize
+ ) split = 65552;
+ 
+ GetOSDlocation(
+   IN AFSFid *Fid,
+   afs_uint64 offset,
+   afs_uint64 length,
+   afs_int32 flag,
+   afsUUID uuid,
+   OUT AFSFetchStatus *OutStatus,
+   AFSCallBack *CallBack,
+   struct osd_file *osd
+ ) = 65557;
+ 
+ InverseLookup(
+   IN AFSFid *Fid,
+   afs_uint32 parent,
+   OUT struct afs_filename *file,
+   afs_uint32 *nextparent
+ ) = 65558;
+ 
+ CheckOSDconns() = 65559;
+ 
+ OsdPolicy(IN AFSFid *Fid,
+   afs_uint64 length,
+   OUT afs_uint32 *protocol
+ ) = 65560;
+ 
+ SetOsdFileReady(
+   IN AFSFid *Fid
+ ) = 65561;
+ 
+ GetOsdMetadata(
+   IN AFSFid *Fid
+ ) split = 65562;
+ */
Index: openafs/src/fsprobe/fsprobe.c
diff -c openafs/src/fsprobe/fsprobe.c:1.9.2.2 openafs/src/fsprobe/fsprobe.c:1.9.2.3
*** openafs/src/fsprobe/fsprobe.c:1.9.2.2	Mon Mar 10 18:35:34 2008
--- openafs/src/fsprobe/fsprobe.c	Sat Aug 16 15:15:47 2008
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/fsprobe/fsprobe.c,v 1.9.2.2 2008/03/10 22:35:34 shadow Exp $");
  
  
  #include <string.h>
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/fsprobe/fsprobe.c,v 1.9.2.3 2008/08/16 19:15:47 shadow Exp $");
  
  
  #include <string.h>
***************
*** 25,30 ****
--- 25,31 ----
  #include <fsprobe.h>		/*Interface for this module */
  #include <lwp.h>		/*Lightweight process package */
  #include <afs/cellconfig.h>
+ #include <afs/afsint.h>
  
  #define LWP_STACK_SIZE	(16 * 1024)
  
***************
*** 240,248 ****
      struct timeval tv;		/*Time structure */
      int conn_idx;		/*Connection index */
      struct fsprobe_ConnectionInfo *curr_conn;	/*Current connection */
!     struct ProbeViceStatistics *curr_stats;	/*Current stats region */
      int *curr_probeOK;		/*Current probeOK field */
! 
      while (1) {			/*Service loop */
  	/*
  	 * Iterate through the server connections, gathering data.
--- 241,251 ----
      struct timeval tv;		/*Time structure */
      int conn_idx;		/*Connection index */
      struct fsprobe_ConnectionInfo *curr_conn;	/*Current connection */
!     struct ProbeViceStatistics *curr_stats;    /*Current stats region */
      int *curr_probeOK;		/*Current probeOK field */
!     ViceStatistics64 stats64;
!     stats64.ViceStatistics64_val = (afs_uint64 *)malloc(STATS64_VERSION *
! 							sizeof(afs_uint64));
      while (1) {			/*Service loop */
  	/*
  	 * Iterate through the server connections, gathering data.
***************
*** 273,281 ****
  		    fprintf(stderr,
  			    "[%s] Connection valid, calling RXAFS_GetStatistics\n",
  			    rn);
! 		*curr_probeOK =
! 		    RXAFS_GetStatistics(curr_conn->rxconn, curr_stats);
! 
  	    }
  
  	    /*Valid Rx connection */
--- 276,295 ----
  		    fprintf(stderr,
  			    "[%s] Connection valid, calling RXAFS_GetStatistics\n",
  			    rn);
! 		*curr_probeOK = RXGEN_OPCODE;
! 		RXAFS_GetStatistics64(curr_conn->rxconn, STATS64_VERSION, &stats64);
! 		if (*curr_probeOK == RXGEN_OPCODE)
! 		    *curr_probeOK =
! 			RXAFS_GetStatistics(curr_conn->rxconn, curr_stats);
! 		else if (*curr_probeOK == 0) {
! 		    curr_stats->CurrentTime = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_CURRENTTIME]);
! 		    curr_stats->BootTime = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_BOOTTIME]);
! 		    curr_stats->StartTime = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_STARTTIME]);
! 		    curr_stats->CurrentConnections = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_CURRENTCONNECTIONS]);
! 		    curr_stats->TotalFetchs = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_TOTALFETCHES]);
! 		    curr_stats->TotalStores = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_TOTALSTORES]);
! 		    curr_stats->WorkStations = RoundInt64ToInt32(stats64.ViceStatistics64_val[STATS64_WORKSTATIONS]);
! 		}
  	    }
  
  	    /*Valid Rx connection */
***************
*** 289,294 ****
--- 303,310 ----
  		int i, code;
  		char pname[10];
  		struct diskPartition partition;
+ 		struct diskPartition64 *partition64p =
+ 		    (struct diskPartition64 *)malloc(sizeof(struct diskPartition64));
  
  		if (fsprobe_debug)
  		    fprintf(stderr,
***************
*** 298,320 ****
  		    if (curr_conn->partList.partFlags[i] & PARTVALID) {
  			MapPartIdIntoName(curr_conn->partList.partId[i],
  					  pname);
! 			code =
! 			    AFSVolPartitionInfo(curr_conn->rxVolconn, pname,
! 						&partition);
  			if (code) {
  			    fprintf(stderr,
  				    "Could not get information on server %s partition %s\n",
  				    curr_conn->hostName, pname);
- 			} else {
- 			    curr_stats->Disk[i].BlocksAvailable =
- 				partition.free;
- 			    curr_stats->Disk[i].TotalBlocks =
- 				partition.minFree;
- 			    strcpy(curr_stats->Disk[i].Name, pname);
  			}
  		    }
- 
  		}
  	    }
  
  
--- 314,350 ----
  		    if (curr_conn->partList.partFlags[i] & PARTVALID) {
  			MapPartIdIntoName(curr_conn->partList.partId[i],
  					  pname);
! 			code = 
! 			    AFSVolPartitionInfo64(curr_conn->rxVolconn, pname,
! 						  partition64p);
! 
! 			if (!code) {
! 			    curr_stats->Disk[i].BlocksAvailable =
! 				RoundInt64ToInt31(partition64p->free);
! 			    curr_stats->Disk[i].TotalBlocks =
! 				RoundInt64ToInt31(partition64p->minFree);
! 			    strcpy(curr_stats->Disk[i].Name, pname);
! 			}
! 			if (code == RXGEN_OPCODE) {
! 			    code = 
! 				AFSVolPartitionInfo(curr_conn->rxVolconn, 
! 						    pname, &partition);
! 			    if (!code) {
! 				curr_stats->Disk[i].BlocksAvailable =
! 				    partition.free;
! 				curr_stats->Disk[i].TotalBlocks =
! 				    partition.minFree;
! 				strcpy(curr_stats->Disk[i].Name, pname);
! 			    }
! 			}
  			if (code) {
  			    fprintf(stderr,
  				    "Could not get information on server %s partition %s\n",
  				    curr_conn->hostName, pname);
  			}
  		    }
  		}
+ 		free(partition64p);
  	    }
  
  
***************
*** 358,363 ****
--- 388,394 ----
  	if (code)
  	    fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn, code);
      }				/*Service loop */
+     free(stats64.ViceStatistics64_val);
  
      return NULL;
  }				/*fsprobe_LWP */
Index: openafs/src/libadmin/adminutil/afs_utilAdmin.c
diff -c openafs/src/libadmin/adminutil/afs_utilAdmin.c:1.7.2.3 openafs/src/libadmin/adminutil/afs_utilAdmin.c:1.7.2.4
*** openafs/src/libadmin/adminutil/afs_utilAdmin.c:1.7.2.3	Tue Apr 10 14:43:44 2007
--- openafs/src/libadmin/adminutil/afs_utilAdmin.c	Sat Sep 27 16:54:49 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/adminutil/afs_utilAdmin.c,v 1.7.2.3 2007/04/10 18:43:44 shadow Exp $");
  
  #include <afs/stds.h>
  #include <afs/afs_Admin.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/adminutil/afs_utilAdmin.c,v 1.7.2.4 2008/09/27 20:54:49 jaltman Exp $");
  
  #include <afs/stds.h>
  #include <afs/afs_Admin.h>
***************
*** 2508,2514 ****
   */
  
  int ADMINAPI
! util_RXDebugRxStats(rxdebugHandle_p handle, struct rx_stats *stats,
  		    afs_uint32 * supportedValues, afs_status_p st)
  {
      int rc = 0;
--- 2508,2514 ----
   */
  
  int ADMINAPI
! util_RXDebugRxStats(rxdebugHandle_p handle, struct rx_statistics *stats,
  		    afs_uint32 * supportedValues, afs_status_p st)
  {
      int rc = 0;
Index: openafs/src/libadmin/adminutil/afs_utilAdmin.h
diff -c openafs/src/libadmin/adminutil/afs_utilAdmin.h:1.6 openafs/src/libadmin/adminutil/afs_utilAdmin.h:1.6.2.1
*** openafs/src/libadmin/adminutil/afs_utilAdmin.h:1.6	Tue Jul 15 19:15:23 2003
--- openafs/src/libadmin/adminutil/afs_utilAdmin.h	Sat Sep 27 16:54:49 2008
***************
*** 136,142 ****
  					   afs_status_p st);
  
  extern int ADMINAPI util_RXDebugRxStats(rxdebugHandle_p handle,
! 					struct rx_stats *stats,
  					afs_uint32 * supportedStats,
  					afs_status_p st);
  
--- 136,142 ----
  					   afs_status_p st);
  
  extern int ADMINAPI util_RXDebugRxStats(rxdebugHandle_p handle,
! 					struct rx_statistics *stats,
  					afs_uint32 * supportedStats,
  					afs_status_p st);
  
Index: openafs/src/libadmin/samples/rxdebug_rx_stats.c
diff -c openafs/src/libadmin/samples/rxdebug_rx_stats.c:1.7.2.1 openafs/src/libadmin/samples/rxdebug_rx_stats.c:1.7.2.2
*** openafs/src/libadmin/samples/rxdebug_rx_stats.c:1.7.2.1	Tue Oct 30 11:23:57 2007
--- openafs/src/libadmin/samples/rxdebug_rx_stats.c	Sat Sep 27 16:54:54 2008
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/samples/rxdebug_rx_stats.c,v 1.7.2.1 2007/10/30 15:23:57 shadow Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/libadmin/samples/rxdebug_rx_stats.c,v 1.7.2.2 2008/09/27 20:54:54 jaltman Exp $");
  
  #ifdef AFS_NT40_ENV
  #include <winsock2.h>
***************
*** 68,74 ****
      rxdebugHandle_p handle;
      char *srvrName;
      long srvrPort;
!     struct rx_stats stats;
      afs_uint32 supportedStats;
      char tstr[32];
      int i;
--- 68,74 ----
      rxdebugHandle_p handle;
      char *srvrName;
      long srvrPort;
!     struct rx_statistics stats;
      afs_uint32 supportedStats;
      char tstr[32];
      int i;
Index: openafs/src/libafs/MakefileProto.AIX.in
diff -c openafs/src/libafs/MakefileProto.AIX.in:1.23.2.3 openafs/src/libafs/MakefileProto.AIX.in:1.23.2.4
*** openafs/src/libafs/MakefileProto.AIX.in:1.23.2.3	Tue Jun 20 17:40:46 2006
--- openafs/src/libafs/MakefileProto.AIX.in	Wed Sep  3 14:27:40 2008
***************
*** 76,81 ****
--- 76,83 ----
  KMODS=32 
  <rs_aix50 rs_aix51 rs_aix52 rs_aix53>
  KMODS=32 64
+ <rs_aix61>
+ KMODS=64
  <all>
  
  include Makefile.common
Index: openafs/src/libafs/MakefileProto.FBSD.in
diff -c openafs/src/libafs/MakefileProto.FBSD.in:1.24 openafs/src/libafs/MakefileProto.FBSD.in:1.24.2.1
*** openafs/src/libafs/MakefileProto.FBSD.in:1.24	Wed Mar 10 18:01:53 2004
--- openafs/src/libafs/MakefileProto.FBSD.in	Tue Aug 26 10:02:16 2008
***************
*** 30,40 ****
  # System specific build commands and flags
  KSRC = @BSD_KERNEL_PATH@
  KBLD = @BSD_KERNEL_BUILD@
! KDEFS=-Wall -ansi -nostdinc -I/usr/include -D_KERNEL -DKLD_MODULE \
! 	-elf -mpreferred-stack-boundary=2 \
  <i386_fbsd_42 i386_fbsd_43 i386_fbsd_44 i386_fbsd_45 i386_fbsd_46 i386_fbsd_47>
! 	-fformat-extensions \
! 	-include ${KBLD}/opt_global.h
  <all -i386_fbsd_42 -i386_fbsd_43 -i386_fbsd_44 -i386_fbsd_45 -i386_fbsd_46 -i386_fbsd_47>
  	-mno-align-long-strings -fformat-extensions -fno-common -ffreestanding \
  	-I${KBLD} -include opt_global.h -fno-strict-aliasing
--- 30,40 ----
  # System specific build commands and flags
  KSRC = @BSD_KERNEL_PATH@
  KBLD = @BSD_KERNEL_BUILD@
! KDEFS=-Wall -nostdinc -I/usr/include -D_KERNEL -DKLD_MODULE \
! 	    -elf -mpreferred-stack-boundary=2 \
  <i386_fbsd_42 i386_fbsd_43 i386_fbsd_44 i386_fbsd_45 i386_fbsd_46 i386_fbsd_47>
! 	     -fformat-extensions \
! <i386_fbsd_42 i386_fbsd_43 i386_fbsd_44 i386_fbsd_45 i386_fbsd_46 i386_fbsd_47>	-include ${KBLD}/opt_global.h
  <all -i386_fbsd_42 -i386_fbsd_43 -i386_fbsd_44 -i386_fbsd_45 -i386_fbsd_46 -i386_fbsd_47>
  	-mno-align-long-strings -fformat-extensions -fno-common -ffreestanding \
  	-I${KBLD} -include opt_global.h -fno-strict-aliasing
***************
*** 68,74 ****
--- 68,78 ----
  	-ln -fs ${KSRC}/i386/include machine
  	-ln -fs ${KSRC}/netinet netinet
  	-ln -fs ${KSRC}/nfs nfs
+ <all -i386_fbsd_80>
  	-ln -fs /usr/include/rpc rpc
+ <i386_fbsd_80>
+ 	-ln -fs ${KSRC}/rpc rpc
+ <all>
  	-ln -fs ${KSRC}/sys sys
  	-ln -fs ${KSRC}/ufs/ufs ufs
  	-ln -fs ${KSRC}/sys h
Index: openafs/src/libafs/MakefileProto.LINUX.in
diff -c openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.14 openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.15
*** openafs/src/libafs/MakefileProto.LINUX.in:1.40.2.14	Tue Feb 19 10:07:48 2008
--- openafs/src/libafs/MakefileProto.LINUX.in	Wed Sep  3 12:59:29 2008
***************
*** 50,75 ****
  CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@
  DEFINES = $(COMMON_DEFINES) -DCPU=586
  
! <amd64_linux24 amd64_linux26>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mcmodel=kernel -mno-red-zone
  DEFINES = $(COMMON_DEFINES) 
  
! <i386_umlinux22 i386_umlinux24 i386_umlinux26>
  CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@ -Wno-strict-prototypes -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
  DEFINES = $(COMMON_DEFINES) -DCPU=586
  
  <i386_umlinux26>
  EXTRA_CFLAGS = -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
  
! <alpha_linux_22 alpha_linux_24 alpha_linux_26>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mno-fp-regs -ffixed-8
  DEFINES = $(COMMON_DEFINES)
  
! <s390_linux22 s390_linux24 s390_linux26>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char
  DEFINES = $(COMMON_DEFINES) -D__s390__ 
  
! <s390x_linux22 s390x_linux24 s390x_linux26>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char
  DEFINES = $(COMMON_DEFINES) -D__s390x__ 
  
--- 50,75 ----
  CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@
  DEFINES = $(COMMON_DEFINES) -DCPU=586
  
! <amd64_linux22 amd64_linux24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mcmodel=kernel -mno-red-zone
  DEFINES = $(COMMON_DEFINES) 
  
! <i386_umlinux22 i386_umlinux24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) @P5PLUS_KOPTS@ -Wno-strict-prototypes -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
  DEFINES = $(COMMON_DEFINES) -DCPU=586
  
  <i386_umlinux26>
  EXTRA_CFLAGS = -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/tt/include -I$(LINUX_KERNEL_PATH)/arch/um/kernel/skas/include
  
! <alpha_linux_22 alpha_linux_24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -mno-fp-regs -ffixed-8
  DEFINES = $(COMMON_DEFINES)
  
! <s390_linux22 s390_linux24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char
  DEFINES = $(COMMON_DEFINES) -D__s390__ 
  
! <s390x_linux22 s390x_linux24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char
  DEFINES = $(COMMON_DEFINES) -D__s390x__ 
  
***************
*** 85,91 ****
        -mcpu=ultrasparc -m64 -mno-fpu -mcmodel=medlow -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare
  DEFINES = $(COMMON_DEFINES) -DCPU=sparc64
  
! <ppc_linux22 ppc_linux24 ppc64_linux24 ppc64_linux26>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char -msoft-float -fno-builtin -ffixed-r2
  DEFINES = $(COMMON_DEFINES) -D__powerpc__
  
--- 85,91 ----
        -mcpu=ultrasparc -m64 -mno-fpu -mcmodel=medlow -ffixed-g4 -fcall-used-g5 -fcall-used-g7 -Wno-sign-compare
  DEFINES = $(COMMON_DEFINES) -DCPU=sparc64
  
! <ppc_linux22 ppc_linux24 ppc64_linux22 ppc64_linux24>
  CCFLAGS = $(COMMON_KERN_CFLAGS) -fsigned-char -msoft-float -fno-builtin -ffixed-r2
  DEFINES = $(COMMON_DEFINES) -D__powerpc__
  
Index: openafs/src/libafsrpc/Makefile.in
diff -c openafs/src/libafsrpc/Makefile.in:1.29.2.9 openafs/src/libafsrpc/Makefile.in:1.29.2.11
*** openafs/src/libafsrpc/Makefile.in:1.29.2.9	Tue Jan  8 13:57:27 2008
--- openafs/src/libafsrpc/Makefile.in	Tue Jul  1 14:17:07 2008
***************
*** 272,278 ****
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.29.2.9 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
--- 272,278 ----
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.29.2.11 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
***************
*** 354,360 ****
  syscall.o: ${SYS}/syscall.s
  	case "$(SYS_NAME)" in \
  	     sun4x_5* | sunx86_5*) \
! 		$(CPP)  ${SFLAGS} ${SYS}/syscall.s syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	 sgi_* | *_darwin_* ) \
--- 354,360 ----
  syscall.o: ${SYS}/syscall.s
  	case "$(SYS_NAME)" in \
  	     sun4x_5* | sunx86_5*) \
! 		$(PATH_CPP)  ${SFLAGS} ${SYS}/syscall.s > syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	 sgi_* | *_darwin_* ) \
***************
*** 366,372 ****
  	 *bsd* ) \
  		touch syscall.o ;; \
  	 *) \
! 		$(CPP)  ${SFLAGS} ${SYS}/syscall.s syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	esac
--- 366,372 ----
  	 *bsd* ) \
  		touch syscall.o ;; \
  	 *) \
! 		$(PATH_CPP) ${SFLAGS} ${SYS}/syscall.s > syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	esac
Index: openafs/src/libuafs/MakefileProto.FBSD.in
diff -c openafs/src/libuafs/MakefileProto.FBSD.in:1.11 openafs/src/libuafs/MakefileProto.FBSD.in:1.11.2.1
*** openafs/src/libuafs/MakefileProto.FBSD.in:1.11	Sun Apr 18 02:10:33 2004
--- openafs/src/libuafs/MakefileProto.FBSD.in	Tue Aug 26 10:02:15 2008
***************
*** 19,25 ****
--- 19,29 ----
  
  TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_FBSD40_ENV
  TEST_LDFLAGS=
+ <all -i386_fbsd_62 -i386_fbsd_70 -i386_fbsd_80>
  TEST_LIBS=-lc_r
+ <i386_fbsd_62 i386_fbsd_70 i386_fbsd_80>
+ TEST_LIBS=-lpthread
+ <all>
  
  LIBUAFS = libuafs.a
  LIBJUAFS = libjuafs.a
Index: openafs/src/lwp/Makefile.in
diff -c openafs/src/lwp/Makefile.in:1.29.2.10 openafs/src/lwp/Makefile.in:1.29.2.11
*** openafs/src/lwp/Makefile.in:1.29.2.10	Wed Feb 27 17:31:37 2008
--- openafs/src/lwp/Makefile.in	Tue Jul  1 14:17:08 2008
***************
*** 37,43 ****
  	pmax_he1) \
  		$(CCOBJ) ${LWP_DBG} ${LWP_OPTMZ} -c -I${TOP_INCDIR} process.s;; \
  	sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53  | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5* | arm_linux* ) \
! 		$(CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s process.ss; \
  		${AS} process.ss -o process.o; \
  			$(RM) process.ss ;; \
  	sgi_5* ) \
--- 37,43 ----
  	pmax_he1) \
  		$(CCOBJ) ${LWP_DBG} ${LWP_OPTMZ} -c -I${TOP_INCDIR} process.s;; \
  	sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53  | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5* | arm_linux* ) \
! 		$(PATH_CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s > process.ss; \
  		${AS} process.ss -o process.o; \
  			$(RM) process.ss ;; \
  	sgi_5* ) \
***************
*** 45,55 ****
  	sgi_61 | sgi_62 | sgi_63 ) \
  		$(CCOBJ) ${LWP_DBG} ${LWP_OPTMZ} -c ${XCFLAGS} ${ARCHFLAGS} -I${TOP_INCDIR} -KPIC -G0  ${srcdir}/process.s;; \
  	s390_*) \
! 		$(CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s390.s >process.ss; \
  		${AS} -ahlns process.ss -o process.o >process.lst; \
  		$(RM) process.ss ;; \
  	s390x_*) \
! 		$(CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s390x.s >process.ss; \
  		${AS} -ahlns process.ss -o process.o >process.lst; \
  		$(RM) process.ss ;; \
  	*_darwin* ) \
--- 45,55 ----
  	sgi_61 | sgi_62 | sgi_63 ) \
  		$(CCOBJ) ${LWP_DBG} ${LWP_OPTMZ} -c ${XCFLAGS} ${ARCHFLAGS} -I${TOP_INCDIR} -KPIC -G0  ${srcdir}/process.s;; \
  	s390_*) \
! 		$(PATH_CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s390.s >process.ss; \
  		${AS} -ahlns process.ss -o process.o >process.lst; \
  		$(RM) process.ss ;; \
  	s390x_*) \
! 		$(PATH_CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s390x.s >process.ss; \
  		${AS} -ahlns process.ss -o process.o >process.lst; \
  		$(RM) process.ss ;; \
  	*_darwin* ) \
***************
*** 88,98 ****
  		${AS} process.ss -o process.o ;  \
  		$(RM) -f process.S ;;\
  	ncrx86_* | sunx86_*) \
! 		$(CPP) -P -D__sun -D__i386 -DIGNORE_STDS_H -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s process.ss; \
  		${AS} -o process.o process.ss; \
  		$(RM) process.ss ;; \
  	alpha_nbsd* ) \
! 		$(CPP) -DASSEMBLER -P -I${TOP_INCDIR} ${srcdir}/process.s > process.ss; \
  		${AS} -o process.o process.ss; \
  		$(RM) process.ss ;; \
  	hp* | *_linux* | *_umlinux* | sgi_64 | sgi_65 ) \
--- 88,98 ----
  		${AS} process.ss -o process.o ;  \
  		$(RM) -f process.S ;;\
  	ncrx86_* | sunx86_*) \
! 		$(PATH_CPP) -P -D__sun -D__i386 -DIGNORE_STDS_H -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s > process.ss; \
  		${AS} -o process.o process.ss; \
  		$(RM) process.ss ;; \
  	alpha_nbsd* ) \
! 		$(PATH_CPP) -DASSEMBLER -P -I${TOP_INCDIR} ${srcdir}/process.s > process.ss; \
  		${AS} -o process.o process.ss; \
  		$(RM) process.ss ;; \
  	hp* | *_linux* | *_umlinux* | sgi_64 | sgi_65 ) \
***************
*** 103,113 ****
  	ia64_hpux11* | hp_ux11* ) \
  		${CC} ${CFLAGS} -c ${srcdir}/process.c;; \
  	i386_*) \
! 		$(CPP) -P -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s process.ss; \
  		${AS} process.ss -o process.o; \
  		$(RM) process.ss ;; \
  	*) \
! 		$(CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s process.ss; \
  		${AS} process.ss -o process.o; \
  		$(RM) process.ss ;; \
  	esac
--- 103,113 ----
  	ia64_hpux11* | hp_ux11* ) \
  		${CC} ${CFLAGS} -c ${srcdir}/process.c;; \
  	i386_*) \
! 		$(PATH_CPP) -P -I${TOP_INCDIR} -I${srcdir} ${srcdir}/process.i386.s > process.ss; \
  		${AS} process.ss -o process.o; \
  		$(RM) process.ss ;; \
  	*) \
! 		$(PATH_CPP) -P -I${TOP_INCDIR} ${srcdir}/process.s > process.ss; \
  		${AS} process.ss -o process.o; \
  		$(RM) process.ss ;; \
  	esac
Index: openafs/src/packaging/MacOS/decode-panic
diff -c openafs/src/packaging/MacOS/decode-panic:1.1.4.2 openafs/src/packaging/MacOS/decode-panic:1.1.4.3
*** openafs/src/packaging/MacOS/decode-panic:1.1.4.2	Sun Jan 27 13:48:12 2008
--- openafs/src/packaging/MacOS/decode-panic	Sun Sep 21 09:03:50 2008
***************
*** 113,119 ****
          chomp $line;
      
          #skip lines until "Backtrace" is seen
!         $line =~ /^\s*(Backtrace,|Backtrace:)/;
          $backtrace = $1;
          last if $backtrace;
      }
--- 113,119 ----
          chomp $line;
      
          #skip lines until "Backtrace" is seen
!         $line =~ /^\s*(Backtrace,|Backtrace:|Backtrace \()/;
          $backtrace = $1;
          last if $backtrace;
      }
***************
*** 257,263 ****
  
  =head1 VERSION
  
! This documentation refers to decode-panic version $Revision: 1.1.4.2 $
  
  =head1 SYNOPSIS
   
--- 257,263 ----
  
  =head1 VERSION
  
! This documentation refers to decode-panic version $Revision: 1.1.4.3 $
  
  =head1 SYNOPSIS
   
Index: openafs/src/packaging/RedHat/makesrpm.pl
diff -c openafs/src/packaging/RedHat/makesrpm.pl:1.1.4.4 openafs/src/packaging/RedHat/makesrpm.pl:1.1.4.5
*** openafs/src/packaging/RedHat/makesrpm.pl:1.1.4.4	Tue Apr  8 14:36:28 2008
--- openafs/src/packaging/RedHat/makesrpm.pl	Tue Jul  1 15:41:50 2008
***************
*** 29,36 ****
  
  my $tmpdir = File::Temp::tempdir(CLEANUP => 1);
  
! system("tar -C $tmpdir -xvjf $srcball \*/configure.in ".
!        "\*/src/packaging/RedHat > /dev/null")==0
    or die "Unable to unpack src tar ball\n";
  
  my $dirh = IO::Dir->new($tmpdir);
--- 29,36 ----
  
  my $tmpdir = File::Temp::tempdir(CLEANUP => 1);
  
! system("tar -C $tmpdir -xvjf $srcball '\*/configure.in' ".
!        "'\*/src/packaging/RedHat' > /dev/null")==0
    or die "Unable to unpack src tar ball\n";
  
  my $dirh = IO::Dir->new($tmpdir);
Index: openafs/src/packaging/RedHat/mockbuild.pl
diff -c openafs/src/packaging/RedHat/mockbuild.pl:1.1.2.4 openafs/src/packaging/RedHat/mockbuild.pl:1.1.2.5
*** openafs/src/packaging/RedHat/mockbuild.pl:1.1.2.4	Tue Apr 22 08:50:56 2008
--- openafs/src/packaging/RedHat/mockbuild.pl	Fri Sep 12 09:07:52 2008
***************
*** 68,129 ****
  				      kmod => '1',
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => 'fc5/i386' },
  		 "fedora-5-x86_64" => { osver => "fc5",
  				       kmod => '1',
  				       basearch => 'x86_64',
  				       updaterepo => 'updates-released',
! 				       results => 'fc5/x86_64' },
  		 "fedora-6-i386" => { osver => "fc6", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => "fc6/i386" },
  		 "fedora-6-x86_64" => { osver => "fc6",
  					kmod => '1',
  					basearch => 'x86_64',
  				        updaterepo => 'updates-released',
! 					results => "fc6/x86_64" },
  		 "fedora-7-i386" => { osver => "fc7", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => "fc7/i386" },
  		 "fedora-7-x86_64" => { osver => "fc7",
  					kmod => '1',
  					basearch => 'x86_64',
  				        updaterepo => 'updates-released',
! 					results => "fc7/x86_64" },
  		 "fedora-8-i386" => { osver => "fc8", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => "fc8/i386" },
  		 "fedora-8-x86_64" => { osver => "fc8",
  					kmod => '1',
  					basearch => 'x86_64',
  				        updaterepo => 'updates-released',
! 					results => "fc8/x86_64" },
  		 "centos-4-i386" => { osver => "el4",
  				     kmod => '1',
  				     basearch => 'i386',
  				     updaterepo => 'update',
! 				     results => 'el4/i386' },
  		 "centos-4-x86_64" => { osver => "el4",
  				       kmod => '1',
  				       basearch => 'x86_64',
  				       updaterepo => 'update',
! 				       results => "el4/x86_64" },
  		 "centos-5-i386" => { osver => "el5", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'update',
! 				      results => "el5/i386" },
  		 "centos-5-x86_64" => { osver => "el5",
  					kmod => '1',
  				   	basearch => 'x86_64',
  				        updaterepo => 'update',
! 					results => "el5/x86_64" },
  		 "fedora-development-i386" => { osver => "fcd",
  					  kmod => '1',
  					  basearch => 'i386',
--- 68,139 ----
  				      kmod => '1',
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => 'fedora-5/i386' },
  		 "fedora-5-x86_64" => { osver => "fc5",
  				       kmod => '1',
  				       basearch => 'x86_64',
  				       updaterepo => 'updates-released',
! 				       results => 'fedora-5/x86_64' },
  		 "fedora-6-i386" => { osver => "fc6", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => "fedora-6/i386" },
  		 "fedora-6-x86_64" => { osver => "fc6",
  					kmod => '1',
  					basearch => 'x86_64',
  				        updaterepo => 'updates-released',
! 					results => "fedora-6/x86_64" },
  		 "fedora-7-i386" => { osver => "fc7", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => "fedora-7/i386" },
  		 "fedora-7-x86_64" => { osver => "fc7",
  					kmod => '1',
  					basearch => 'x86_64',
  				        updaterepo => 'updates-released',
! 					results => "fedora-7/x86_64" },
  		 "fedora-8-i386" => { osver => "fc8", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'updates-released',
! 				      results => "fedora-8/i386" },
  		 "fedora-8-x86_64" => { osver => "fc8",
  					kmod => '1',
  					basearch => 'x86_64',
  				        updaterepo => 'updates-released',
! 					results => "fedora-8/x86_64" },
  		 "centos-4-i386" => { osver => "el4",
  				     kmod => '1',
  				     basearch => 'i386',
  				     updaterepo => 'update',
! 				     results => 'rhel4/i386' },
  		 "centos-4-x86_64" => { osver => "el4",
  				       kmod => '1',
  				       basearch => 'x86_64',
  				       updaterepo => 'update',
! 				       results => "rhel4/x86_64" },
  		 "centos-5-i386" => { osver => "el5", 
  				      kmod => '1', 
  				      basearch => 'i386',
  				      updaterepo => 'update',
! 				      results => "rhel5/i386" },
  		 "centos-5-x86_64" => { osver => "el5",
  					kmod => '1',
  				   	basearch => 'x86_64',
  				        updaterepo => 'update',
! 					results => "rhel5/x86_64" },
! 		 "fedora-9-i386" => { osver => "fc9",
! 				      kmod => '1',
! 				      basearch => 'i386',
! 				      updaterepo => "updates-released",
! 				      results => 'fedora-9/i386' },
! 		 "fedora-9-x86_64" => { osver => "fc9",
! 					kmod => "1",
! 					basearch => "x86_64",
! 					updaterepo => "updates-released",
! 					results => "fedora-9/x86_64" },
  		 "fedora-development-i386" => { osver => "fcd",
  					  kmod => '1',
  					  basearch => 'i386',
***************
*** 177,183 ****
    my $osver = $platconf{$platform}{'osver'};
    my $root = $rootbase.$platform."/root";
    my $mockresults = $rootbase.$platform."/result";
!   my $resultdir = $resultbase.$platconf{$platform}{'results'};
    my $basearch = $platconf{$platform}{'basearch'};
    my $rpmstashdir = $stashbase.$platconf{$platform}{'results'}."/";
  
--- 187,193 ----
    my $osver = $platconf{$platform}{'osver'};
    my $root = $rootbase.$platform."/root";
    my $mockresults = $rootbase.$platform."/result";
!   my $resultdir = $resultbase."/".$platconf{$platform}{'results'};
    my $basearch = $platconf{$platform}{'basearch'};
    my $rpmstashdir = $stashbase.$platconf{$platform}{'results'}."/";
  
***************
*** 240,256 ****
  
    print "-------------------------------------------------------------------\n";
    print "Building the userland RPMs\n";
!   my @rpms = ('', '-authlibs', '-authlibs-devel', '-client', '-compat',
! 	      '-debuginfo', '-devel', '-docs', '-kernel-source', '-kpasswd',
! 	      '-krb5', '-server');
  
    my $missing = 0;
    foreach my $rpm (@rpms) {
!     if (! -f $resultdir."/openafs".$rpm."-".$oafsversion."-".$osver.".".
  	     $oafsrelease.".".$basearch.".rpm") {
        $missing++;
!       print $resultdir."/openafs".$rpm."-".$oafsversion."-".$osver.".".
! 	    $oafsrelease.".".$basearch.".rpm is missing!\n"
      }
    }
    if ($missing) {
--- 250,270 ----
  
    print "-------------------------------------------------------------------\n";
    print "Building the userland RPMs\n";
!   my @rpms = ('openafs', 'openafs-authlibs', 'openafs-authlibs-devel', 
! 	      'openafs-client', 'openafs-compat', 'openafs-debuginfo', 
! 	      'openafs-devel', 'openafs-docs', 'openafs-kernel-source', 
! 	      'openafs-kpasswd', 'openafs-krb5', 'openafs-server',
! 	      'dkms-openafs');
!   my @missingrpms=();
  
    my $missing = 0;
    foreach my $rpm (@rpms) {
!     if (! -f $resultdir."/".$rpm."-".$oafsversion."-".$osver.".".
  	     $oafsrelease.".".$basearch.".rpm") {
        $missing++;
!       print $resultdir."/".$rpm."-".$oafsversion."-".$osver.".".
! 	    $oafsrelease.".".$basearch.".rpm is missing!\n";
!       push @missingrpms, $rpm;
      }
    }
    if ($missing) {
***************
*** 263,274 ****
  		        ' --define "build_authlibs 1" '.
  		        $srpm) == 0
        or die "build failed with : $!\n";
!     foreach my $rpm (@rpms) {
!       system("cp ".$mockresults."/openafs".$rpm."-".$oafsversion."-".
  		   $osver.".".$oafsrelease.".".$basearch.".rpm ".
  		   $resultdir) == 0
            or die "Copy failed with : $!\n";
!       push @newrpms, $mockresults."/openafs".$rpm."-".$oafsversion."-".
  		     $osver.".".$oafsrelease.".".$basearch.".rpm";
      }
    } else {
--- 277,288 ----
  		        ' --define "build_authlibs 1" '.
  		        $srpm) == 0
        or die "build failed with : $!\n";
!     foreach my $rpm (@missingrpms) {
!       system("cp ".$mockresults."/".$rpm."-".$oafsversion."-".
  		   $osver.".".$oafsrelease.".".$basearch.".rpm ".
  		   $resultdir) == 0
            or die "Copy failed with : $!\n";
!       push @newrpms, $mockresults."/".$rpm."-".$oafsversion."-".
  		     $osver.".".$oafsrelease.".".$basearch.".rpm";
      }
    } else {
Index: openafs/src/packaging/RedHat/openafs.spec.in
diff -c openafs/src/packaging/RedHat/openafs.spec.in:1.1.2.22 openafs/src/packaging/RedHat/openafs.spec.in:1.1.2.26
*** openafs/src/packaging/RedHat/openafs.spec.in:1.1.2.22	Sun Apr 27 00:00:46 2008
--- openafs/src/packaging/RedHat/openafs.spec.in	Tue Aug 26 09:44:54 2008
***************
*** 1,4 ****
! # Openafs Spec $Revision: 1.1.2.22 $
  
  %define afsvers @VERSION@
  %define pkgvers @LINUX_PKGVER@
--- 1,4 ----
! # Openafs Spec $Revision: 1.1.2.26 $
  
  %define afsvers @VERSION@
  %define pkgvers @LINUX_PKGVER@
***************
*** 19,24 ****
--- 19,25 ----
  %define kernvers_on_cmdline %{?kernvers:1}%{!?kernvers:0}
  %define build_userspace_on_cmdline %{?build_userspace:1}%{!?build_userspace:0}
  %define build_modules_on_cmdline %{?build_modules:1}%{!?build_modules:0}
+ %define build_authlibs_on_cmdline %{?build_authlibs:1}%{!?build_authlibs:0}
  
  # Determine the version of the kernel to build against
  # - automatically select running kernel if there are sources in /lib/modules
***************
*** 28,33 ****
--- 29,43 ----
  %define kernvers %(%{_sourcedir}/openafs-kernel-version.sh)
  %endif
  
+ # If we're building for a 2.4 series kernel, then fedora style kmods aren't
+ # appropriate - disable them.
+ 
+ %define kern24 %([ `echo "%{kernvers}" | sed -e 's/^\([0-9]*\.[0-9]*\)\..*/\1/'` = "2.4" ] && echo 1 || echo 0)
+ 
+ %if %{kern24}
+ %define fedorakmod 0
+ %endif
+ 
  %if %{fedorakmod}
  %define kmodtool bash %{_sourcedir}/openafs-kmodtool
  
***************
*** 222,227 ****
--- 232,245 ----
  %endif
  %endif
  
+ %if !%{build_authlibs_on_cmdline}
+ %if %{build_userspace_on_cmdline}
+ %define build_authlibs 1
+ %else
+ %define build_authlibs 0
+ %endif
+ %endif
+ 
  # Make sure RPM doesn't complain about installed but non-packaged files.
  #define __check_files  %{nil}
  
***************
*** 1344,1350 ****
  dkms install -m %{name} -v %{dkms_version} --rpm_safe_upgrade
  
  %preun -n dkms-%{name}
! dkms remove -m %{namee} -v %{dkms_version} --rpm_safe_upgrade --all ||:
  %endif
  %endif
  
--- 1362,1368 ----
  dkms install -m %{name} -v %{dkms_version} --rpm_safe_upgrade
  
  %preun -n dkms-%{name}
! dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
  %endif
  %endif
  
***************
*** 1494,1504 ****
  %{_mandir}/man8/upclient.*
  %{_mandir}/man8/upserver.*
  %{_mandir}/man8/vldb_check.*
  %{_mandir}/man8/vlserver.*
  %{_mandir}/man8/voldump.*
  %{_mandir}/man8/volinfo.*
  %{_mandir}/man8/volserver.*
- #%{_mandir}/man8/vldb_convert.*
  
  %if %{build_authlibs}
  %files authlibs
--- 1512,1522 ----
  %{_mandir}/man8/upclient.*
  %{_mandir}/man8/upserver.*
  %{_mandir}/man8/vldb_check.*
+ %{_mandir}/man8/vldb_convert.*
  %{_mandir}/man8/vlserver.*
  %{_mandir}/man8/voldump.*
  %{_mandir}/man8/volinfo.*
  %{_mandir}/man8/volserver.*
  
  %if %{build_authlibs}
  %files authlibs
***************
*** 1568,1573 ****
--- 1586,1592 ----
  %files krb5
  %defattr(-,root,root)
  %{_bindir}/aklog
+ %{_bindir}/klog.krb5
  %{_sbindir}/asetkey
  %{_mandir}/man1/aklog.*
  %{_mandir}/man8/asetkey.*
Index: openafs/src/pam/afs_auth.c
diff -c openafs/src/pam/afs_auth.c:1.12.2.1 openafs/src/pam/afs_auth.c:1.12.2.2
*** openafs/src/pam/afs_auth.c:1.12.2.1	Sun May 29 23:37:48 2005
--- openafs/src/pam/afs_auth.c	Tue Aug 26 10:12:23 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pam/afs_auth.c,v 1.12.2.1 2005/05/30 03:37:48 shadow Exp $");
  
  #include <syslog.h>
  #include <stdlib.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pam/afs_auth.c,v 1.12.2.2 2008/08/26 14:12:23 shadow Exp $");
  
  #include <syslog.h>
  #include <stdlib.h>
***************
*** 192,197 ****
--- 192,199 ----
  #else
  #if     defined(AFS_LINUX20_ENV) || defined(AFS_FBSD_ENV) || defined(AFS_NBSD_ENV)
      upwd = getpwnam(user);
+ #elif   defined(_POSIX_PTHREAD_SEMANTICS) && defined(AFS_SUN5_ENV)
+     getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf), &upwd);
  #else
      upwd = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
  #endif
Index: openafs/src/pinstall/install.c
diff -c openafs/src/pinstall/install.c:1.23 openafs/src/pinstall/install.c:1.23.2.1
*** openafs/src/pinstall/install.c:1.23	Fri Aug  8 17:54:44 2003
--- openafs/src/pinstall/install.c	Mon Jul 28 08:17:41 2008
***************
*** 50,56 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pinstall/Attic/install.c,v 1.23 2003/08/08 21:54:44 shadow Exp $");
  
  #include <stdio.h>
  #include <pwd.h>
--- 50,56 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/pinstall/Attic/install.c,v 1.23.2.1 2008/07/28 12:17:41 shadow Exp $");
  
  #include <stdio.h>
  #include <pwd.h>
***************
*** 183,191 ****
  {
      int pid;
      pid_t status;
-     static char *env[] = {
- 	0,
-     };
      static char *strip[] = {
  	"strip", 0, 0,
      };
--- 183,188 ----
***************
*** 204,210 ****
      case 0:			/* child        */
  	copy[1] = iname;
  	copy[2] = oname;
! 	execve("/bin/cp", copy, env);
  	perror("/bin/cp");
  	exit(1);
  
--- 201,207 ----
      case 0:			/* child        */
  	copy[1] = iname;
  	copy[2] = oname;
! 	execv("/bin/cp", copy);
  	perror("/bin/cp");
  	exit(1);
  
***************
*** 249,255 ****
  #else
  #define	STRIP_BIN	"/bin/strip"
  #endif
! 	execve(STRIP_BIN, strip, env);
  	perror(STRIP_BIN);
  	exit(1);
  
--- 246,252 ----
  #else
  #define	STRIP_BIN	"/bin/strip"
  #endif
! 	execv(STRIP_BIN, strip);
  	perror(STRIP_BIN);
  	exit(1);
  
***************
*** 275,283 ****
  quickStrip(char *iname, char *oname, int ignored, int copy_only)
  {
      int pid, status;
-     static char *env[] = {
- 	0,
-     };
      static char *strip[] = {
  	"strip", 0, 0,
      };
--- 272,277 ----
***************
*** 296,302 ****
      case 0:			/* child        */
  	copy[1] = iname;
  	copy[2] = oname;
! 	execve("/bin/cp", copy, env);
  	perror("/bin/cp");
  	exit(1);
  
--- 290,296 ----
      case 0:			/* child        */
  	copy[1] = iname;
  	copy[2] = oname;
! 	execv("/bin/cp", copy);
  	perror("/bin/cp");
  	exit(1);
  
***************
*** 334,340 ****
  
      case 0:			/* child        */
  	strip[1] = oname;
! 	execve("/bin/strip", strip, env);
  	perror("/bin/strip");
  	exit(1);
  
--- 328,334 ----
  
      case 0:			/* child        */
  	strip[1] = oname;
! 	execv("/bin/strip", strip);
  	perror("/bin/strip");
  	exit(1);
  
Index: openafs/src/ptserver/map.c
diff -c openafs/src/ptserver/map.c:1.3.2.2 openafs/src/ptserver/map.c:1.3.2.3
*** openafs/src/ptserver/map.c:1.3.2.2	Sat Aug 11 19:50:02 2007
--- openafs/src/ptserver/map.c	Tue Aug 26 10:02:26 2008
***************
*** 32,43 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/map.c,v 1.3.2.2 2007/08/11 23:50:02 jaltman Exp $");
  
  #ifdef SUPERGROUPS
  #include <errno.h>
  #include "map.h"
  #include "malloc.h"
  
  #undef PRINT_MAP_ERROR
  /* #define MAP_DEBUG /**/
--- 32,47 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/map.c,v 1.3.2.3 2008/08/26 14:02:26 shadow Exp $");
  
  #ifdef SUPERGROUPS
  #include <errno.h>
  #include "map.h"
+ #ifdef STDLIB_HAS_MALLOC_PROTOS
+ #include <stdlib.h>
+ #else
  #include "malloc.h"
+ #endif
  
  #undef PRINT_MAP_ERROR
  /* #define MAP_DEBUG /**/
Index: openafs/src/ptserver/pt_util.c
diff -c openafs/src/ptserver/pt_util.c:1.9.2.6 openafs/src/ptserver/pt_util.c:1.9.2.8
*** openafs/src/ptserver/pt_util.c:1.9.2.6	Thu Mar 27 14:40:22 2008
--- openafs/src/ptserver/pt_util.c	Tue Jul  1 01:59:20 2008
***************
*** 1,4 ****
! /* $Id: pt_util.c,v 1.9.2.6 2008/03/27 18:40:22 shadow Exp $ */
  
  /*
   *
--- 1,4 ----
! /* $Id: pt_util.c,v 1.9.2.8 2008/07/01 05:59:20 rra Exp $ */
  
  /*
   *
***************
*** 23,31 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/pt_util.c,v 1.9.2.6 2008/03/27 18:40:22 shadow Exp $");
  
  #include <afs/cmd.h>		/*Command line parsing */
  #include <errno.h>
  #include <lock.h>
  #include <netinet/in.h>
--- 23,32 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/pt_util.c,v 1.9.2.8 2008/07/01 05:59:20 rra Exp $");
  
  #include <afs/cmd.h>		/*Command line parsing */
+ #include <afs/afsutil.h>
  #include <errno.h>
  #include <lock.h>
  #include <netinet/in.h>
***************
*** 137,143 ****
      struct prentry uentry, gentry;
      struct ubik_hdr *uh;
      char *dfile = 0;
!     char *pfile = "/usr/afs/db/prdb.DB0";
      struct cmd_parmdesc *tparm;
  
      tparm = a_as->parms;
--- 138,146 ----
      struct prentry uentry, gentry;
      struct ubik_hdr *uh;
      char *dfile = 0;
!     char *pbase = AFSDIR_SERVER_PRDB_FILEPATH;
!     char *pfile = NULL;
!     char pbuffer[1028];
      struct cmd_parmdesc *tparm;
  
      tparm = a_as->parms;
***************
*** 170,175 ****
--- 173,182 ----
  	dfile = tparm[8].items->data;
      }
  
+     if (pfile == NULL) {
+         afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0", pbase);
+         pfile = pbuffer;
+     }
      if ((dbase_fd = open(pfile, (wflag ? O_RDWR : O_RDONLY) | O_CREAT, 0600))
  	< 0) {
  	fprintf(stderr, "pt_util: cannot open %s: %s\n", pfile,
***************
*** 321,328 ****
      } else {
  	for (i = 0; i < HASHSIZE; i++) {
  	    upos = nflag ? ntohl(prh.nameHash[i]) : ntohl(prh.idHash[i]);
! 	    while (upos)
! 		upos = display_entry(upos);
  	}
  	if (flags & DO_GRP)
  	    display_groups();
--- 328,343 ----
      } else {
  	for (i = 0; i < HASHSIZE; i++) {
  	    upos = nflag ? ntohl(prh.nameHash[i]) : ntohl(prh.idHash[i]);
! 	    while (upos) {
! 		long newpos;
! 		newpos = display_entry(upos);
! 		if (newpos == upos) {
! 		    fprintf(stderr, "pt_util: hash error in %s chain %d\n", 
! 			    nflag ? "name":"id", i);
! 		    exit(1);
! 		} else
! 		    upos = newpos;
! 	    }
  	}
  	if (flags & DO_GRP)
  	    display_groups();
Index: openafs/src/ptserver/ptserver.c
diff -c openafs/src/ptserver/ptserver.c:1.21.2.11 openafs/src/ptserver/ptserver.c:1.21.2.12
*** openafs/src/ptserver/ptserver.c:1.21.2.11	Sun Feb  3 22:53:58 2008
--- openafs/src/ptserver/ptserver.c	Sun Aug 24 21:15:20 2008
***************
*** 113,119 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptserver.c,v 1.21.2.11 2008/02/04 03:53:58 jaltman Exp $");
  
  #include <afs/stds.h>
  #ifdef	AFS_AIX32_ENV
--- 113,119 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/ptserver.c,v 1.21.2.12 2008/08/25 01:15:20 shadow Exp $");
  
  #include <afs/stds.h>
  #ifdef	AFS_AIX32_ENV
***************
*** 161,166 ****
--- 161,167 ----
  int pr_realmNameLen;
  char *pr_realmName;
  
+ int debuglevel = 0;
  int restricted = 0;
  int rxMaxMTU = -1;
  int rxBind = 0;
***************
*** 281,286 ****
--- 282,294 ----
  	if ((strncmp(arg, "-database", alen) == 0)
  	    || (strncmp(arg, "-db", alen) == 0)) {
  	    pr_dbaseName = argv[++a];	/* specify a database */
+ 	} else if (strcmp(argv[a], "-d") == 0) {
+ 	    if ((a + 1) >= argc) {
+ 		fprintf(stderr, "missing argument for -d\n"); 
+ 		return -1; 
+ 	    }
+ 	    debuglevel = atoi(argv[++a]);
+ 	    LogLevel = debuglevel;
  	} else if (strncmp(arg, "-p", alen) == 0) {
  	    lwps = atoi(argv[++a]);
  	    if (lwps > 16) {	/* maximum of 16 */
***************
*** 379,385 ****
  #ifndef AFS_NT40_ENV
  	    printf("Usage: ptserver [-database <db path>] "
  		   "[-auditlog <log path>] "
! 		   "[-syslog[=FACILITY]] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-groupdepth <depth>] "
  		   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
--- 387,393 ----
  #ifndef AFS_NT40_ENV
  	    printf("Usage: ptserver [-database <db path>] "
  		   "[-auditlog <log path>] "
! 		   "[-syslog[=FACILITY]] [-d <debug level>] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-groupdepth <depth>] "
  		   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
***************
*** 389,395 ****
  		   "[-help]\n");
  #else /* AFS_NT40_ENV */
  	    printf("Usage: ptserver [-database <db path>] "
! 		   "[-auditlog <log path>] "
  		   "[-p <number of processes>] [-rebuild] [-rxbind] "
  		   "[-allow-dotted-principals] "
  		   "[-default_access default_user_access default_group_access] "
--- 397,403 ----
  		   "[-help]\n");
  #else /* AFS_NT40_ENV */
  	    printf("Usage: ptserver [-database <db path>] "
! 		   "[-auditlog <log path>] [-d <debug level>] "
  		   "[-p <number of processes>] [-rebuild] [-rxbind] "
  		   "[-allow-dotted-principals] "
  		   "[-default_access default_user_access default_group_access] "
***************
*** 399,405 ****
  #else
  #ifndef AFS_NT40_ENV
  	    printf("Usage: ptserver [-database <db path>] "
! 		   "[-auditlog <log path>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
--- 407,413 ----
  #else
  #ifndef AFS_NT40_ENV
  	    printf("Usage: ptserver [-database <db path>] "
! 		   "[-auditlog <log path>] [-d <debug level>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-p <number of processes>] [-rebuild] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
***************
*** 409,415 ****
  		   "[-help]\n");
  #else /* AFS_NT40_ENV */
  	    printf("Usage: ptserver [-database <db path>] "
! 		   "[-auditlog <log path>] "
  		   "[-default_access default_user_access default_group_access] "
  		   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
  		   "[-allow-dotted-principals] "
--- 417,423 ----
  		   "[-help]\n");
  #else /* AFS_NT40_ENV */
  	    printf("Usage: ptserver [-database <db path>] "
! 		   "[-auditlog <log path>] [-d <debug level>] "
  		   "[-default_access default_user_access default_group_access] "
  		   "[-restricted] [-rxmaxmtu <bytes>] [-rxbind] "
  		   "[-allow-dotted-principals] "
Index: openafs/src/ptserver/utils.c
diff -c openafs/src/ptserver/utils.c:1.15.2.2 openafs/src/ptserver/utils.c:1.15.2.3
*** openafs/src/ptserver/utils.c:1.15.2.2	Mon Feb  4 12:53:56 2008
--- openafs/src/ptserver/utils.c	Thu Jun 12 14:37:44 2008
***************
*** 7,17 ****
   * directory or online at http://www.openafs.org/dl/license10.html
   */
  
  #include <afsconfig.h>
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/utils.c,v 1.15.2.2 2008/02/04 17:53:56 shadow Exp $");
  
  #include <sys/types.h>
  #include <lock.h>
--- 7,18 ----
   * directory or online at http://www.openafs.org/dl/license10.html
   */
  
+ #include <assert.h>
  #include <afsconfig.h>
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ptserver/utils.c,v 1.15.2.3 2008/06/12 18:37:44 shadow Exp $");
  
  #include <sys/types.h>
  #include <lock.h>
***************
*** 294,299 ****
--- 295,301 ----
  	return 0;
      if (aid == tentry.id)
  	return entry;
+     assert(entry != tentry.nextID);
      entry = tentry.nextID;
      while (entry != 0) {
  	memset(&tentry, 0, sizeof(tentry));
***************
*** 302,307 ****
--- 304,310 ----
  	    return 0;
  	if (aid == tentry.id)
  	    return entry;
+ 	assert(entry != tentry.nextID);
  	entry = tentry.nextID;
      }
      return 0;
***************
*** 325,330 ****
--- 328,334 ----
  	return 0;
      if ((strncmp(aname, tentryp->name, PR_MAXNAMELEN)) == 0)
  	return entry;
+     assert(entry != tentryp->nextName);
      entry = tentryp->nextName;
      while (entry != 0) {
  	memset(tentryp, 0, sizeof(struct prentry));
***************
*** 333,338 ****
--- 337,343 ----
  	    return 0;
  	if ((strncmp(aname, tentryp->name, PR_MAXNAMELEN)) == 0)
  	    return entry;
+ 	assert(entry != tentryp->nextName);
  	entry = tentryp->nextName;
      }
      return 0;
***************
*** 462,467 ****
--- 467,473 ----
      if (code)
  	return PRDBFAIL;
      while (aid != tentry.id) {
+ 	assert(trail != current);
  	trail = current;
  	current = tentry.nextID;
  	if (current == 0)
***************
*** 539,544 ****
--- 545,551 ----
      if (code)
  	return PRDBFAIL;
      while (strcmp(aname, tentry.name)) {
+ 	assert(trail != current);
  	trail = current;
  	current = tentry.nextName;
  	if (current == 0)
Index: openafs/src/rx/rx.c
diff -c openafs/src/rx/rx.c:1.58.2.45 openafs/src/rx/rx.c:1.58.2.53
*** openafs/src/rx/rx.c:1.58.2.45	Mon Mar 17 13:57:41 2008
--- openafs/src/rx/rx.c	Thu Sep 25 13:26:47 2008
***************
*** 17,23 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.45 2008/03/17 17:57:41 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
--- 17,23 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.53 2008/09/25 17:26:47 shadow Exp $");
  
  #ifdef KERNEL
  #include "afs/sysincludes.h"
***************
*** 166,171 ****
--- 166,172 ----
  static pthread_mutex_t epoch_mutex;
  static pthread_mutex_t rx_init_mutex;
  static pthread_mutex_t rx_debug_mutex;
+ static pthread_mutex_t rx_rpc_stats;
  
  static void
  rxi_InitPthread(void)
***************
*** 211,216 ****
--- 212,236 ----
      assert(pthread_key_create(&rx_ts_info_key, NULL) == 0);
   
      rxkad_global_stats_init();
+ 
+     MUTEX_INIT(&rx_rpc_stats, "rx_rpc_stats", MUTEX_DEFAULT, 0);
+     MUTEX_INIT(&rx_freePktQ_lock, "rx_freePktQ_lock", MUTEX_DEFAULT, 0);
+ #ifdef	RX_ENABLE_LOCKS
+ #ifdef RX_LOCKS_DB
+     rxdb_init();
+ #endif /* RX_LOCKS_DB */
+     MUTEX_INIT(&freeSQEList_lock, "freeSQEList lock", MUTEX_DEFAULT, 0);
+     MUTEX_INIT(&rx_freeCallQueue_lock, "rx_freeCallQueue_lock", MUTEX_DEFAULT,
+ 	       0);
+     CV_INIT(&rx_waitingForPackets_cv, "rx_waitingForPackets_cv", CV_DEFAULT,
+ 	    0);
+     MUTEX_INIT(&rx_peerHashTable_lock, "rx_peerHashTable_lock", MUTEX_DEFAULT,
+ 	       0);
+     MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
+ 	       0);
+     MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
+     MUTEX_INIT(&rxi_keyCreate_lock, "rxi_keyCreate_lock", MUTEX_DEFAULT, 0);
+ #endif /* RX_ENABLE_LOCKS */
  }
  
  pthread_once_t rx_once_init = PTHREAD_ONCE_INIT;
***************
*** 258,264 ****
   * to manipulate the queue.
   */
  
! #ifdef RX_ENABLE_LOCKS
  static afs_kmutex_t rx_rpc_stats;
  void rxi_StartUnlocked();
  #endif
--- 278,284 ----
   * to manipulate the queue.
   */
  
! #if defined(RX_ENABLE_LOCKS) && defined(KERNEL)
  static afs_kmutex_t rx_rpc_stats;
  void rxi_StartUnlocked();
  #endif
***************
*** 411,417 ****
  	UNLOCK_RX_INIT;
  	return RX_ADDRINUSE;
      }
! #ifdef	RX_ENABLE_LOCKS
  #ifdef RX_LOCKS_DB
      rxdb_init();
  #endif /* RX_LOCKS_DB */
--- 431,437 ----
  	UNLOCK_RX_INIT;
  	return RX_ADDRINUSE;
      }
! #if defined(RX_ENABLE_LOCKS) && defined(KERNEL)
  #ifdef RX_LOCKS_DB
      rxdb_init();
  #endif /* RX_LOCKS_DB */
***************
*** 428,446 ****
      MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
  	       0);
      MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
! #ifndef KERNEL
!     MUTEX_INIT(&rxi_keyCreate_lock, "rxi_keyCreate_lock", MUTEX_DEFAULT, 0);
! #endif /* !KERNEL */
! #if defined(KERNEL) && defined(AFS_HPUX110_ENV)
      if (!uniprocessor)
  	rx_sleepLock = alloc_spinlock(LAST_HELD_ORDER - 10, "rx_sleepLock");
! #endif /* KERNEL && AFS_HPUX110_ENV */
! #endif /* RX_ENABLE_LOCKS */
  
      rxi_nCalls = 0;
      rx_connDeadTime = 12;
      rx_tranquil = 0;		/* reset flag */
!     memset((char *)&rx_stats, 0, sizeof(struct rx_stats));
      htable = (char *)
  	osi_Alloc(rx_hashTableSize * sizeof(struct rx_connection *));
      PIN(htable, rx_hashTableSize * sizeof(struct rx_connection *));	/* XXXXX */
--- 448,463 ----
      MUTEX_INIT(&rx_connHashTable_lock, "rx_connHashTable_lock", MUTEX_DEFAULT,
  	       0);
      MUTEX_INIT(&rx_serverPool_lock, "rx_serverPool_lock", MUTEX_DEFAULT, 0);
! #if defined(AFS_HPUX110_ENV)
      if (!uniprocessor)
  	rx_sleepLock = alloc_spinlock(LAST_HELD_ORDER - 10, "rx_sleepLock");
! #endif /* AFS_HPUX110_ENV */
! #endif /* RX_ENABLE_LOCKS && KERNEL */
  
      rxi_nCalls = 0;
      rx_connDeadTime = 12;
      rx_tranquil = 0;		/* reset flag */
!     memset((char *)&rx_stats, 0, sizeof(struct rx_statistics));
      htable = (char *)
  	osi_Alloc(rx_hashTableSize * sizeof(struct rx_connection *));
      PIN(htable, rx_hashTableSize * sizeof(struct rx_connection *));	/* XXXXX */
***************
*** 751,757 ****
      conn = rxi_AllocConnection();
  #ifdef	RX_ENABLE_LOCKS
      MUTEX_INIT(&conn->conn_call_lock, "conn call lock", MUTEX_DEFAULT, 0);
!     MUTEX_INIT(&conn->conn_data_lock, "conn call lock", MUTEX_DEFAULT, 0);
      CV_INIT(&conn->conn_call_cv, "conn call cv", CV_DEFAULT, 0);
  #endif
      NETPRI;
--- 768,774 ----
      conn = rxi_AllocConnection();
  #ifdef	RX_ENABLE_LOCKS
      MUTEX_INIT(&conn->conn_call_lock, "conn call lock", MUTEX_DEFAULT, 0);
!     MUTEX_INIT(&conn->conn_data_lock, "conn data lock", MUTEX_DEFAULT, 0);
      CV_INIT(&conn->conn_call_cv, "conn call cv", CV_DEFAULT, 0);
  #endif
      NETPRI;
***************
*** 1176,1182 ****
      MUTEX_ENTER(&call->lock);
      rxi_WaitforTQBusy(call);
      if (call->flags & RX_CALL_TQ_CLEARME) {
! 	rxi_ClearTransmitQueue(call, 0);
  	queue_Init(&call->tq);
      }
      MUTEX_EXIT(&call->lock);
--- 1193,1199 ----
      MUTEX_ENTER(&call->lock);
      rxi_WaitforTQBusy(call);
      if (call->flags & RX_CALL_TQ_CLEARME) {
! 	rxi_ClearTransmitQueue(call, 1);
  	queue_Init(&call->tq);
      }
      MUTEX_EXIT(&call->lock);
***************
*** 1325,1330 ****
--- 1342,1348 ----
  	    service->minProcs = 0;
  	    service->maxProcs = 1;
  	    service->idleDeadTime = 60;
+ 	    service->idleDeadErr = 0;
  	    service->connDeadTime = rx_connDeadTime;
  	    service->executeRequestProc = serviceProc;
  	    service->checkReach = 0;
***************
*** 2126,2132 ****
  #ifdef	AFS_GLOBAL_RXLOCK_KERNEL
  	/* Now, if TQ wasn't cleared earlier, do it now. */
  	if (call->flags & RX_CALL_TQ_CLEARME) {
! 	    rxi_ClearTransmitQueue(call, 0);
  	    queue_Init(&call->tq);
  	}
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
--- 2144,2150 ----
  #ifdef	AFS_GLOBAL_RXLOCK_KERNEL
  	/* Now, if TQ wasn't cleared earlier, do it now. */
  	if (call->flags & RX_CALL_TQ_CLEARME) {
! 	    rxi_ClearTransmitQueue(call, 1);
  	    queue_Init(&call->tq);
  	}
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
***************
*** 2134,2139 ****
--- 2152,2158 ----
  	call->conn = conn;
  	rxi_ResetCall(call, 1);
      } else {
+ 
  	call = (struct rx_call *)rxi_Alloc(sizeof(struct rx_call));
  
  	MUTEX_EXIT(&rx_freeCallQueue_lock);
***************
*** 2249,2255 ****
      rxi_Allocsize += size;
      MUTEX_EXIT(&rx_stats_mutex);
  
!     p = (char *)osi_Alloc(size);
  
      if (!p)
  	osi_Panic("rxi_Alloc error");
--- 2268,2280 ----
      rxi_Allocsize += size;
      MUTEX_EXIT(&rx_stats_mutex);
  
!     p = (char *)
! #if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_FBSD80_ENV)
! 	afs_osi_Alloc_NoSleep(size)
! #else
!         osi_Alloc(size)
! #endif
! 	;
  
      if (!p)
  	osi_Panic("rxi_Alloc error");
***************
*** 2399,2404 ****
--- 2424,2430 ----
  	conn->specific = NULL;
  	rx_SetConnDeadTime(conn, service->connDeadTime);
  	rx_SetConnIdleDeadTime(conn, service->idleDeadTime);
+ 	rx_SetServerConnIdleDeadErr(conn, service->idleDeadErr);
  	/* Notify security object of the new connection */
  	RXS_NewConnection(conn->securityObject, conn);
  	/* XXXX Connection timeout? */
***************
*** 2914,2919 ****
--- 2940,2946 ----
  	}
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
  	rxi_ClearTransmitQueue(call, 0);
+ 	rxevent_Cancel(call->keepAliveEvent, call, RX_CALL_REFCOUNT_ALIVE);
  	break;
      default:
  	/* Should not reach here, unless the peer is broken: send an abort
***************
*** 3920,3925 ****
--- 3947,3953 ----
  	&& call->tfirst + call->nSoftAcked >= call->tnext) {
  	call->state = RX_STATE_DALLY;
  	rxi_ClearTransmitQueue(call, 0);
+         rxevent_Cancel(call->keepAliveEvent, call, RX_CALL_REFCOUNT_ALIVE);
      } else if (!queue_IsEmpty(&call->tq)) {
  	rxi_Start(0, call, 0, istack);
      }
***************
*** 4184,4190 ****
      }
  
      rxevent_Cancel(call->resendEvent, call, RX_CALL_REFCOUNT_RESEND);
-     rxevent_Cancel(call->keepAliveEvent, call, RX_CALL_REFCOUNT_ALIVE);
      call->tfirst = call->tnext;
      call->nSoftAcked = 0;
  
--- 4212,4217 ----
***************
*** 4225,4231 ****
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
  
      rxevent_Cancel(call->resendEvent, call, RX_CALL_REFCOUNT_RESEND);
-     rxevent_Cancel(call->keepAliveEvent, call, RX_CALL_REFCOUNT_ALIVE);
      call->tfirst = call->tnext;	/* implicitly acknowledge all data already sent */
      call->nSoftAcked = 0;
  
--- 4252,4257 ----
***************
*** 4381,4387 ****
  {
      if (call->error)
  	error = call->error;
! #ifdef RX_GLOBAL_RXLOCK_KERNEL
      if (!((call->flags & RX_CALL_TQ_BUSY) || (call->tqWaiters > 0))) {
  	rxi_ResetCall(call, 0);
      }
--- 4407,4413 ----
  {
      if (call->error)
  	error = call->error;
! #ifdef AFS_GLOBAL_RXLOCK_KERNEL
      if (!((call->flags & RX_CALL_TQ_BUSY) || (call->tqWaiters > 0))) {
  	rxi_ResetCall(call, 0);
      }
***************
*** 4456,4462 ****
      MUTEX_EXIT(&peer->peer_lock);
  
      flags = call->flags;
-     rxi_ClearReceiveQueue(call);
  #ifdef	AFS_GLOBAL_RXLOCK_KERNEL
      if (flags & RX_CALL_TQ_BUSY) {
  	call->flags = RX_CALL_TQ_CLEARME | RX_CALL_TQ_BUSY;
--- 4482,4487 ----
***************
*** 4464,4471 ****
      } else
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
      {
! 	rxi_ClearTransmitQueue(call, 0);
! 	queue_Init(&call->tq);
  	if (call->tqWaiters || (flags & RX_CALL_TQ_WAIT)) {
  	    dpf(("rcall %x has %d waiters and flags %d\n", call, call->tqWaiters, call->flags));
  	}
--- 4489,4496 ----
      } else
  #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
      {
! 	rxi_ClearTransmitQueue(call, 1);
! 	/* why init the queue if you just emptied it? queue_Init(&call->tq); */
  	if (call->tqWaiters || (flags & RX_CALL_TQ_WAIT)) {
  	    dpf(("rcall %x has %d waiters and flags %d\n", call, call->tqWaiters, call->flags));
  	}
***************
*** 4479,4485 ****
  	    call->tqWaiters--;
  	}
      }
!     queue_Init(&call->rq);
      call->error = 0;
      call->rwind = rx_initReceiveWindow;
      call->twind = rx_initSendWindow;
--- 4504,4512 ----
  	    call->tqWaiters--;
  	}
      }
! 
!     rxi_ClearReceiveQueue(call);
!     /* why init the queue if you just emptied it? queue_Init(&call->rq); */
      call->error = 0;
      call->rwind = rx_initReceiveWindow;
      call->twind = rx_initSendWindow;
***************
*** 4877,4883 ****
      /* Update last send time for this call (for keep-alive
       * processing), and for the connection (so that we can discover
       * idle connections) */
!     conn->lastSendTime = call->lastSendTime = clock_Sec();
  }
  
  /* When sending packets we need to follow these rules:
--- 4904,4910 ----
      /* Update last send time for this call (for keep-alive
       * processing), and for the connection (so that we can discover
       * idle connections) */
!     call->lastSendData = conn->lastSendTime = call->lastSendTime = clock_Sec();
  }
  
  /* When sending packets we need to follow these rules:
***************
*** 5110,5116 ****
  		nXmitPackets = 0;
  		maxXmitPackets = MIN(call->twind, call->cwind);
  		xmitList = (struct rx_packet **)
! 		    osi_Alloc(maxXmitPackets * sizeof(struct rx_packet *));
  		if (xmitList == NULL)
  		    osi_Panic("rxi_Start, failed to allocate xmit list");
  		for (queue_Scan(&call->tq, p, nxp, rx_packet)) {
--- 5137,5148 ----
  		nXmitPackets = 0;
  		maxXmitPackets = MIN(call->twind, call->cwind);
  		xmitList = (struct rx_packet **)
! #if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_FBSD80_ENV)
! 		    /* XXXX else we must drop any mtx we hold */
! 		    afs_osi_Alloc_NoSleep(maxXmitPackets * sizeof(struct rx_packet *));
! #else
! 		osi_Alloc(maxXmitPackets * sizeof(struct rx_packet *));
! #endif
  		if (xmitList == NULL)
  		    osi_Panic("rxi_Start, failed to allocate xmit list");
  		for (queue_Scan(&call->tq, p, nxp, rx_packet)) {
***************
*** 5347,5352 ****
--- 5379,5387 ----
       * processing), and for the connection (so that we can discover
       * idle connections) */
      conn->lastSendTime = call->lastSendTime = clock_Sec();
+     /* Don't count keepalives here, so idleness can be tracked. */
+     if (p->header.type != RX_PACKET_TYPE_ACK)
+ 	call->lastSendData = call->lastSendTime;
  }
  
  
***************
*** 5369,5375 ****
      afs_uint32 now;
      afs_uint32 deadTime;
  
! #ifdef RX_GLOBAL_RXLOCK_KERNEL
      if (call->flags & RX_CALL_TQ_BUSY) {
  	/* Call is active and will be reset by rxi_Start if it's
  	 * in an error state.
--- 5404,5410 ----
      afs_uint32 now;
      afs_uint32 deadTime;
  
! #ifdef AFS_GLOBAL_RXLOCK_KERNEL
      if (call->flags & RX_CALL_TQ_BUSY) {
  	/* Call is active and will be reset by rxi_Start if it's
  	 * in an error state.
***************
*** 5420,5425 ****
--- 5455,5467 ----
  	    return -1;
  	}
      }
+     if (call->lastSendData && conn->idleDeadTime && (conn->idleDeadErr != 0)
+         && ((call->lastSendData + conn->idleDeadTime) < now)) {
+ 	if (call->state == RX_STATE_ACTIVE) {
+ 	    rxi_CallError(call, conn->idleDeadErr);
+ 	    return -1;
+ 	}
+     }
      /* see if we have a hard timeout */
      if (conn->hardDeadTime
  	&& (now > (conn->hardDeadTime + call->startTime.sec))) {
***************
*** 6093,6107 ****
   * checking.
   */
  void
! rx_PrintTheseStats(FILE * file, struct rx_stats *s, int size,
  		   afs_int32 freePackets, char version)
  {
      int i;
  
!     if (size != sizeof(struct rx_stats)) {
  	fprintf(file,
  		"Unexpected size of stats structure: was %d, expected %d\n",
! 		size, sizeof(struct rx_stats));
      }
  
      fprintf(file, "rx stats: free packets %d, allocs %d, ", (int)freePackets,
--- 6135,6149 ----
   * checking.
   */
  void
! rx_PrintTheseStats(FILE * file, struct rx_statistics *s, int size,
  		   afs_int32 freePackets, char version)
  {
      int i;
  
!     if (size != sizeof(struct rx_statistics)) {
  	fprintf(file,
  		"Unexpected size of stats structure: was %d, expected %d\n",
! 		size, sizeof(struct rx_statistics));
      }
  
      fprintf(file, "rx stats: free packets %d, allocs %d, ", (int)freePackets,
***************
*** 6376,6382 ****
  
  afs_int32
  rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
! 		  afs_uint16 remotePort, struct rx_stats * stat,
  		  afs_uint32 * supportedValues)
  {
      struct rx_debugIn in;
--- 6418,6424 ----
  
  afs_int32
  rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
! 		  afs_uint16 remotePort, struct rx_statistics * stat,
  		  afs_uint32 * supportedValues)
  {
      struct rx_debugIn in;
Index: openafs/src/rx/rx.h
diff -c openafs/src/rx/rx.h:1.22.2.9 openafs/src/rx/rx.h:1.22.2.11
*** openafs/src/rx/rx.h:1.22.2.9	Fri Feb  8 16:25:14 2008
--- openafs/src/rx/rx.h	Thu Sep 25 13:16:14 2008
***************
*** 145,150 ****
--- 145,153 ----
  /* Define procedure to set service dead time */
  #define rx_SetIdleDeadTime(service,time) ((service)->idleDeadTime = (time))
  
+ /* Define error to return in server connections when failing to answer */
+ #define rx_SetServerIdleDeadErr(service,err) ((service)->idleDeadErr = (err))
+ 
  /* Define procedures for getting and setting before and after execute-request procs */
  #define rx_SetAfterProc(service,proc) ((service)->afterProc = (proc))
  #define rx_SetBeforeProc(service,proc) ((service)->beforeProc = (proc))
***************
*** 165,170 ****
--- 168,174 ----
  /* Set connection hard and idle timeouts for a connection */
  #define rx_SetConnHardDeadTime(conn, seconds) ((conn)->hardDeadTime = (seconds))
  #define rx_SetConnIdleDeadTime(conn, seconds) ((conn)->idleDeadTime = (seconds))
+ #define rx_SetServerConnIdleDeadErr(conn,err) ((conn)->idleDeadErr = (err))
  
  /* Set the overload threshold and the overload error */
  #define rx_SetBusyThreshold(threshold, code) (rx_BusyThreshold=(threshold),rx_BusyError=(code))
***************
*** 263,268 ****
--- 267,273 ----
      u_short idleDeadTime;	/* max time a call can be idle (no data) */
      u_char ackRate;		/* how many packets between ack requests */
      u_char makeCallWaiters;	/* how many rx_NewCalls are waiting */
+     afs_int32 idleDeadErr;
      int nSpecific;		/* number entries in specific data */
      void **specific;		/* pointer to connection specific data */
  };
***************
*** 307,312 ****
--- 312,318 ----
      u_short connDeadTime;	/* Seconds until a client of this service will be declared dead, if it is not responding */
      u_short idleDeadTime;	/* Time a server will wait for I/O to start up again */
      u_char checkReach;		/* Check for asymmetric clients? */
+     afs_int32 idleDeadErr;
  };
  
  #endif /* KDUMP_RX_LOCK */
***************
*** 503,508 ****
--- 509,515 ----
      int abortCount;		/* number of times last error was sent */
      u_int lastSendTime;		/* Last time a packet was sent on this call */
      u_int lastReceiveTime;	/* Last time a packet was received for this call */
+     u_int lastSendData;		/* Last time a nonping was sent on this call */
      void (*arrivalProc) (register struct rx_call * call, register void * mh, register int index);	/* Procedure to call when reply is received */
      void *arrivalProcHandle;	/* Handle to pass to replyFunc */
      int arrivalProcArg;         /* Additional arg to pass to reply Proc */
***************
*** 780,786 ****
   * Clearly we assume that ntohl will work on these structures so sizeof(int)
   * must equal sizeof(afs_int32). */
  
! struct rx_stats {		/* General rx statistics */
      int packetRequests;		/* Number of packet allocation requests */
      int receivePktAllocFailures;
      int sendPktAllocFailures;
--- 787,793 ----
   * Clearly we assume that ntohl will work on these structures so sizeof(int)
   * must equal sizeof(afs_int32). */
  
! struct rx_statistics {		/* General rx statistics */
      int packetRequests;		/* Number of packet allocation requests */
      int receivePktAllocFailures;
      int sendPktAllocFailures;
Index: openafs/src/rx/rx_event.c
diff -c openafs/src/rx/rx_event.c:1.14.2.4 openafs/src/rx/rx_event.c:1.14.2.5
*** openafs/src/rx/rx_event.c:1.14.2.4	Mon Mar 17 11:38:40 2008
--- openafs/src/rx/rx_event.c	Tue Aug 26 10:02:24 2008
***************
*** 19,25 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_event.c,v 1.14.2.4 2008/03/17 15:38:40 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 19,25 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_event.c,v 1.14.2.5 2008/08/26 14:02:24 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 181,191 ****
--- 181,199 ----
  	ep = (struct rxepoch *)rxi_Alloc(sizeof(struct rxepoch));
  	queue_Append(&rxepoch_free, &ep[0]), rxepoch_nFree++;
  #else
+ #if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_FBSD80_ENV)
+ 	ep = (struct rxepoch *)
+ 	    afs_osi_Alloc_NoSleep(sizeof(struct rxepoch) * rxepoch_allocUnit);
+ 	xsp = xfreemallocs;
+ 	xfreemallocs =
+ 	    (struct xfreelist *)afs_osi_Alloc_NoSleep(sizeof(struct xfreelist));
+ #else
  	ep = (struct rxepoch *)
  	    osi_Alloc(sizeof(struct rxepoch) * rxepoch_allocUnit);
  	xsp = xfreemallocs;
  	xfreemallocs =
  	    (struct xfreelist *)osi_Alloc(sizeof(struct xfreelist));
+ #endif
  	xfreemallocs->mem = (void *)ep;
  	xfreemallocs->size = sizeof(struct rxepoch) * rxepoch_allocUnit;
  	xfreemallocs->next = xsp;
***************
*** 264,274 ****
--- 272,291 ----
  	ev = (struct rxevent *)rxi_Alloc(sizeof(struct rxevent));
  	queue_Append(&rxevent_free, &ev[0]), rxevent_nFree++;
  #else
+ 
+ #if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_FBSD80_ENV)
+ 	ev = (struct rxevent *)afs_osi_Alloc_NoSleep(sizeof(struct rxevent) *
+ 					 rxevent_allocUnit);
+ 	xsp = xfreemallocs;
+ 	xfreemallocs =
+ 	    (struct xfreelist *)afs_osi_Alloc_NoSleep(sizeof(struct xfreelist));
+ #else
  	ev = (struct rxevent *)osi_Alloc(sizeof(struct rxevent) *
  					 rxevent_allocUnit);
  	xsp = xfreemallocs;
  	xfreemallocs =
  	    (struct xfreelist *)osi_Alloc(sizeof(struct xfreelist));
+ #endif
  	xfreemallocs->mem = (void *)ev;
  	xfreemallocs->size = sizeof(struct rxevent) * rxevent_allocUnit;
  	xfreemallocs->next = xsp;
Index: openafs/src/rx/rx_globals.h
diff -c openafs/src/rx/rx_globals.h:1.9.2.15 openafs/src/rx/rx_globals.h:1.9.2.17
*** openafs/src/rx/rx_globals.h:1.9.2.15	Fri Jan  5 20:21:27 2007
--- openafs/src/rx/rx_globals.h	Thu Sep 25 13:16:14 2008
***************
*** 481,487 ****
  #endif
  EXT char rx_waitingForPackets;	/* Processes set and wait on this variable when waiting for packet buffers */
  
! EXT struct rx_stats rx_stats;
  
  EXT struct rx_peer **rx_peerHashTable;
  EXT struct rx_connection **rx_connHashTable;
--- 481,487 ----
  #endif
  EXT char rx_waitingForPackets;	/* Processes set and wait on this variable when waiting for packet buffers */
  
! EXT struct rx_statistics rx_stats;
  
  EXT struct rx_peer **rx_peerHashTable;
  EXT struct rx_connection **rx_connHashTable;
***************
*** 521,527 ****
  #ifdef DPF_FSLOG
  #define dpf(args) FSLog args
  #else
! #define dpf(args) if (rx_debugFile) rxi_DebugPrint args; else
  #endif 
  #endif
  #define rx_Log_event rxevent_debugFile
--- 521,527 ----
  #ifdef DPF_FSLOG
  #define dpf(args) FSLog args
  #else
! #define dpf(args) do { if (rx_debugFile) rxi_DebugPrint args; } while (0)
  #endif 
  #endif
  #define rx_Log_event rxevent_debugFile
Index: openafs/src/rx/rx_kcommon.c
diff -c openafs/src/rx/rx_kcommon.c:1.44.2.19 openafs/src/rx/rx_kcommon.c:1.44.2.20
*** openafs/src/rx/rx_kcommon.c:1.44.2.19	Wed Apr  9 12:40:19 2008
--- openafs/src/rx/rx_kcommon.c	Fri Aug 22 00:32:01 2008
***************
*** 15,21 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.19 2008/04/09 16:40:19 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
--- 15,21 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.20 2008/08/22 04:32:01 shadow Exp $");
  
  #include "rx/rx_kcommon.h"
  
***************
*** 479,485 ****
      pp->natMTU = MIN(pp->ifMTU, OLD_MAX_PACKET_SIZE);
      pp->ifDgramPackets =
  	MIN(rxi_nDgramPackets,
! 	    rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
      pp->maxDgramPackets = 1;
  
      /* Initialize slow start parameters */
--- 479,485 ----
      pp->natMTU = MIN(pp->ifMTU, OLD_MAX_PACKET_SIZE);
      pp->ifDgramPackets =
  	MIN(rxi_nDgramPackets,
! 	    rxi_AdjustDgramPackets(rxi_nSendFrags, pp->ifMTU));
      pp->maxDgramPackets = 1;
  
      /* Initialize slow start parameters */
Index: openafs/src/rx/rx_multi.c
diff -c openafs/src/rx/rx_multi.c:1.8.2.2 openafs/src/rx/rx_multi.c:1.8.2.3
*** openafs/src/rx/rx_multi.c:1.8.2.2	Fri Feb  8 16:25:14 2008
--- openafs/src/rx/rx_multi.c	Tue Aug 26 10:02:24 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_multi.c,v 1.8.2.2 2008/02/08 21:25:14 shadow Exp $");
  
  #ifdef	KERNEL
  #include "afs/sysincludes.h"
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_multi.c,v 1.8.2.3 2008/08/26 14:02:24 shadow Exp $");
  
  #ifdef	KERNEL
  #include "afs/sysincludes.h"
***************
*** 48,53 ****
--- 48,54 ----
      mh->nextReady = mh->firstNotReady = mh->ready = ready;
      mh->nReady = 0;
      mh->nConns = nConns;
+ 
  #ifdef RX_ENABLE_LOCKS
      MUTEX_INIT(&mh->lock, "rx_multi_lock", MUTEX_DEFAULT, 0);
      CV_INIT(&mh->cv, "rx_multi_cv", CV_DEFAULT, 0);
Index: openafs/src/rx/rx_prototypes.h
diff -c openafs/src/rx/rx_prototypes.h:1.14.2.22 openafs/src/rx/rx_prototypes.h:1.14.2.23
*** openafs/src/rx/rx_prototypes.h:1.14.2.22	Mon Mar 17 11:38:40 2008
--- openafs/src/rx/rx_prototypes.h	Thu Sep 25 13:16:14 2008
***************
*** 168,174 ****
  extern void rxi_ReapConnections(void);
  extern int rxs_Release(struct rx_securityClass *aobj);
  #ifndef KERNEL
! extern void rx_PrintTheseStats(FILE * file, struct rx_stats *s, int size,
  			       afs_int32 freePackets, char version);
  extern void rx_PrintStats(FILE * file);
  extern void rx_PrintPeerStats(FILE * file, struct rx_peer *peer);
--- 168,174 ----
  extern void rxi_ReapConnections(void);
  extern int rxs_Release(struct rx_securityClass *aobj);
  #ifndef KERNEL
! extern void rx_PrintTheseStats(FILE * file, struct rx_statistics *s, int size,
  			       afs_int32 freePackets, char version);
  extern void rx_PrintStats(FILE * file);
  extern void rx_PrintPeerStats(FILE * file, struct rx_peer *peer);
***************
*** 179,185 ****
  				   afs_uint32 * supportedValues);
  extern afs_int32 rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
  				   afs_uint16 remotePort,
! 				   struct rx_stats *stat,
  				   afs_uint32 * supportedValues);
  extern afs_int32 rx_GetServerVersion(osi_socket socket, afs_uint32 remoteAddr,
  				     afs_uint16 remotePort,
--- 179,185 ----
  				   afs_uint32 * supportedValues);
  extern afs_int32 rx_GetServerStats(osi_socket socket, afs_uint32 remoteAddr,
  				   afs_uint16 remotePort,
! 				   struct rx_statistics *stat,
  				   afs_uint32 * supportedValues);
  extern afs_int32 rx_GetServerVersion(osi_socket socket, afs_uint32 remoteAddr,
  				     afs_uint16 remotePort,
Index: openafs/src/rx/rx_rdwr.c
diff -c openafs/src/rx/rx_rdwr.c:1.21.2.9 openafs/src/rx/rx_rdwr.c:1.21.2.11
*** openafs/src/rx/rx_rdwr.c:1.21.2.9	Mon Mar 17 11:38:40 2008
--- openafs/src/rx/rx_rdwr.c	Thu Oct  2 07:55:03 2008
***************
*** 15,21 ****
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.21.2.9 2008/03/17 15:38:40 shadow Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
--- 15,21 ----
  #endif
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.21.2.11 2008/10/02 11:55:03 jaltman Exp $");
  
  #ifdef KERNEL
  #ifndef UKERNEL
***************
*** 323,328 ****
--- 323,338 ----
  	call->curpos = tcurpos + nbytes;
  	call->curlen = tcurlen - nbytes;
  	call->nLeft = tnLeft - nbytes;
+ 
+         if (!call->nLeft) {
+             /* out of packet.  Get another one. */
+             NETPRI;
+             MUTEX_ENTER(&call->lock);
+             rxi_FreePacket(call->currentPacket);
+             call->currentPacket = (struct rx_packet *)0;
+             MUTEX_EXIT(&call->lock);
+             USERPRI;
+         }
  	return nbytes;
      }
  
***************
*** 375,380 ****
--- 385,399 ----
  	call->curpos = tcurpos + sizeof(afs_int32);
  	call->curlen = tcurlen - sizeof(afs_int32);
  	call->nLeft = tnLeft - sizeof(afs_int32);
+         if (!call->nLeft) {
+             /* out of packet.  Get another one. */
+             NETPRI;
+             MUTEX_ENTER(&call->lock);
+             rxi_FreePacket(call->currentPacket);
+             call->currentPacket = (struct rx_packet *)0;
+             MUTEX_EXIT(&call->lock);
+             USERPRI;
+         }
  	return sizeof(afs_int32);
      }
  
***************
*** 1081,1086 ****
--- 1100,1106 ----
  	    hadd32(call->bytesSent, cp->length);
  	    rxi_PrepareSendPacket(call, cp, 0);
  	    queue_Append(&tmpq, cp);
+             cp = call->currentPacket = (struct rx_packet *)0;
  
  	    /* The head of the iovq is now the current packet */
  	    if (nbytes) {
Index: openafs/src/rx/rx_user.c
diff -c openafs/src/rx/rx_user.c:1.18.2.5 openafs/src/rx/rx_user.c:1.18.2.6
*** openafs/src/rx/rx_user.c:1.18.2.5	Tue Oct 30 11:24:04 2007
--- openafs/src/rx/rx_user.c	Fri Aug 22 00:32:01 2008
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_user.c,v 1.18.2.5 2007/10/30 15:24:04 shadow Exp $");
  
  # include <sys/types.h>
  # include <errno.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/rx_user.c,v 1.18.2.6 2008/08/22 04:32:01 shadow Exp $");
  
  # include <sys/types.h>
  # include <errno.h>
***************
*** 665,674 ****
      pp->natMTU = MIN((int)pp->ifMTU, OLD_MAX_PACKET_SIZE);
      pp->maxDgramPackets =
  	MIN(rxi_nDgramPackets,
! 	    rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
      pp->ifDgramPackets =
  	MIN(rxi_nDgramPackets,
! 	    rxi_AdjustDgramPackets(RX_MAX_FRAGS, pp->ifMTU));
      pp->maxDgramPackets = 1;
      /* Initialize slow start parameters */
      pp->MTU = MIN(pp->natMTU, pp->maxMTU);
--- 665,674 ----
      pp->natMTU = MIN((int)pp->ifMTU, OLD_MAX_PACKET_SIZE);
      pp->maxDgramPackets =
  	MIN(rxi_nDgramPackets,
! 	    rxi_AdjustDgramPackets(rxi_nSendFrags, pp->ifMTU));
      pp->ifDgramPackets =
  	MIN(rxi_nDgramPackets,
! 	    rxi_AdjustDgramPackets(rxi_nSendFrags, pp->ifMTU));
      pp->maxDgramPackets = 1;
      /* Initialize slow start parameters */
      pp->MTU = MIN(pp->natMTU, pp->maxMTU);
Index: openafs/src/rx/FBSD/rx_kmutex.h
diff -c openafs/src/rx/FBSD/rx_kmutex.h:1.6 openafs/src/rx/FBSD/rx_kmutex.h:1.6.2.1
*** openafs/src/rx/FBSD/rx_kmutex.h:1.6	Tue Jul 15 19:16:18 2003
--- openafs/src/rx/FBSD/rx_kmutex.h	Tue Aug 26 10:02:25 2008
***************
*** 18,24 ****
  
  #include <sys/systm.h>
  #include <sys/proc.h>
! #ifdef AFS_FBSD50_ENV
  #include <sys/lockmgr.h>
  #else
  #include <sys/lock.h>
--- 18,25 ----
  
  #include <sys/systm.h>
  #include <sys/proc.h>
! #ifdef AFS_FBSD70_ENV
! #include <sys/lock.h>
  #include <sys/lockmgr.h>
  #else
  #include <sys/lock.h>
***************
*** 27,62 ****
  #define RX_ENABLE_LOCKS         1
  #define AFS_GLOBAL_RXLOCK_KERNEL
  
- /*
-  * Condition variables
-  *
-  * In Digital Unix (OSF/1), we use something akin to the ancient sleep/wakeup
-  * mechanism.  The condition variable itself plays no role; we just use its
-  * address as a convenient unique number.
-  */
- #define CV_INIT(cv,a,b,c)
- #define CV_DESTROY(cv)
- #define CV_WAIT(cv, lck)    { \
- 	                        int isGlockOwner = ISAFS_GLOCK(); \
- 	                        if (isGlockOwner) AFS_GUNLOCK();  \
- 	                        MUTEX_EXIT(lck);        \
- 	                        tsleep(cv, PSOCK, "afs_rx_cv_wait", 0);  \
- 	                        if (isGlockOwner) AFS_GLOCK();  \
- 	                        MUTEX_ENTER(lck); \
- 	                    }
- 
- #define CV_TIMEDWAIT(cv,lck,t)  { \
- 	                        int isGlockOwner = ISAFS_GLOCK(); \
- 	                        if (isGlockOwner) AFS_GUNLOCK();  \
- 	                        MUTEX_EXIT(lck);        \
- 	                        tsleep(cv, PSOCK, "afs_rx_cv_timedwait", t); \
- 	                        if (isGlockOwner) AFS_GLOCK();  \
- 	                        MUTEX_ENTER(lck);       \
- 
- #define CV_SIGNAL(cv)           wakeup_one(cv)
- #define CV_BROADCAST(cv)        wakeup(cv)
- 
- /* #define osi_rxWakeup(cv)        wakeup(cv) */
  typedef int afs_kcondvar_t;
  
  #define HEAVY_LOCKS
--- 28,33 ----
***************
*** 89,95 ****
--- 60,106 ----
  #undef MUTEX_ISMINE
  #define MUTEX_ISMINE(a) (((afs_kmutex_t *)(a))->owner == curproc)
  
+ #elif defined(AFS_FBSD70_ENV) /* dunno about 6.x */
+ 
+ typedef struct mtx afs_kmutex_t;
+ 
+ #if defined(AFS_FBSD80_ENV) && defined(WITNESS)
+ #define WITCLEAR_MTX(a)					\
+     do { memset((a), 0, sizeof(struct mtx)); } while(0);
+ #else
+ #define WITCLEAR_MTX(a) {}
+ #endif
+ 
+ #define MUTEX_INIT(a,b,c,d)					     \
+   do {								     \
+       WITCLEAR_MTX(a);						     \
+       mtx_init((a), (b), 0 /* type defaults to name */, MTX_DEF | MTX_DUPOK);    \
+   } while(0);
+ 
+ #define MUTEX_DESTROY(a)			\
+     do {					\
+ 	mtx_destroy((a));			\
+     } while(0);
+ 
+ #define MUTEX_ENTER(a) \
+     do {	       \
+ 	mtx_lock((a)); \
+     } while(0);
+ 
+ #define MUTEX_TRYENTER(a)			\
+     ( mtx_trylock((a)) )
+ 
+ #define MUTEX_EXIT(a)	 \
+     do {		 \
+ 	mtx_unlock((a)); \
+     } while(0);
+ 
+ #undef MUTEX_ISMINE
+ #define MUTEX_ISMINE(a)				\
+     ( mtx_owned((a)) )
+ 
  #elif defined(AFS_FBSD50_ENV)
+ 
  typedef struct {
      struct lock lock;
      struct thread *owner;
***************
*** 133,139 ****
  
  #define MUTEX_INIT(a,b,c,d) \
      do { \
! 	lockinit(&(a)->lock,PSOCK, "afs rx mutex", 0, 0); \
  	(a)->owner = 0; \
      } while(0);
  #define MUTEX_DESTROY(a) \
--- 144,150 ----
  
  #define MUTEX_INIT(a,b,c,d) \
      do { \
! 	lockinit(&(a)->lock, PSOCK, "afs rx mutex", 0, 0); \
  	(a)->owner = 0; \
      } while(0);
  #define MUTEX_DESTROY(a) \
***************
*** 198,201 ****
--- 209,264 ----
  #undef osirx_AssertMine
  extern void osirx_AssertMine(afs_kmutex_t * lockaddr, char *msg);
  
+ 
+ /*
+  * Condition variables
+  *
+  * In Digital Unix (OSF/1), we use something akin to the ancient sleep/wakeup
+  * mechanism.  The condition variable itself plays no role; we just use its
+  * address as a convenient unique number.
+  */
+ #define CV_INIT(cv,a,b,c)
+ #define CV_DESTROY(cv)
+ 
+ #if defined(AFS_FBSD70_ENV)
+ 
+ #define CV_WAIT(cv, lck)    { \
+     int isGlockOwner = ISAFS_GLOCK();					\
+     if (isGlockOwner) AFS_GUNLOCK();					\
+     msleep(cv, lck, PSOCK, "afs_rx_cv_wait", 0);			\
+     if (isGlockOwner) AFS_GLOCK();					\
+   }
+ 
+ #define CV_TIMEDWAIT(cv,lck,t)  { \
+ 	                        int isGlockOwner = ISAFS_GLOCK(); \
+ 	                        if (isGlockOwner) AFS_GUNLOCK();  \
+ 	                        msleep(cv, lck, PSOCK, "afs_rx_cv_timedwait", t); \
+ 	                        if (isGlockOwner) AFS_GLOCK();  \
+ 				}
+ #else /* !AFS_FBSD70_ENV */
+ #define CV_WAIT(cv, lck)    { \
+ 	                        int isGlockOwner = ISAFS_GLOCK(); \
+ 	                        if (isGlockOwner) AFS_GUNLOCK();  \
+ 	                        MUTEX_EXIT(lck);        \
+ 	                        tsleep(cv, PSOCK, "afs_rx_cv_wait", 0);  \
+ 	                        if (isGlockOwner) AFS_GLOCK();  \
+ 	                        MUTEX_ENTER(lck); \
+ 	                    }
+ 
+ #define CV_TIMEDWAIT(cv,lck,t)  { \
+ 	                        int isGlockOwner = ISAFS_GLOCK(); \
+ 	                        if (isGlockOwner) AFS_GUNLOCK();  \
+ 	                        MUTEX_EXIT(lck);        \
+ 	                        tsleep(cv, PSOCK, "afs_rx_cv_timedwait", t); \
+ 	                        if (isGlockOwner) AFS_GLOCK();  \
+ 	                        MUTEX_ENTER(lck);       \
+ 				}
+ #endif /* AFS_FBSD80_ENV */
+ 
+ #define CV_SIGNAL(cv)           wakeup_one(cv)
+ #define CV_BROADCAST(cv)        wakeup(cv)
+ 
+ /* #define osi_rxWakeup(cv)        wakeup(cv) */
+ 
+ 
  #endif /* _RX_KMUTEX_H_ */
Index: openafs/src/rx/FBSD/rx_knet.c
diff -c openafs/src/rx/FBSD/rx_knet.c:1.14.2.1 openafs/src/rx/FBSD/rx_knet.c:1.14.2.2
*** openafs/src/rx/FBSD/rx_knet.c:1.14.2.1	Wed Apr 13 22:31:46 2005
--- openafs/src/rx/FBSD/rx_knet.c	Tue Aug 26 10:02:25 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/FBSD/rx_knet.c,v 1.14.2.1 2005/04/14 02:31:46 shadow Exp $");
  
  #ifdef AFS_FBSD40_ENV
  #include <sys/malloc.h>
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/FBSD/rx_knet.c,v 1.14.2.2 2008/08/26 14:02:25 shadow Exp $");
  
  #ifdef AFS_FBSD40_ENV
  #include <sys/malloc.h>
***************
*** 77,82 ****
--- 77,84 ----
      return code;
  }
  
+ #define so_is_disconn(so) ((so)->so_state & SS_ISDISCONNECTED)
+ 
  extern int rxk_ListenerPid;
  void
  osi_StopListener(void)
***************
*** 88,102 ****
       * soclose() is currently protected by Giant,
       * but pfind and psignal are MPSAFE.
       */
!     AFS_GUNLOCK();
      soclose(rx_socket);
      p = pfind(rxk_ListenerPid);
      if (p)
  	psignal(p, SIGUSR1);
  #ifdef AFS_FBSD50_ENV
      PROC_UNLOCK(p);
  #endif
!     AFS_GLOCK();
  }
  
  int
--- 90,132 ----
       * soclose() is currently protected by Giant,
       * but pfind and psignal are MPSAFE.
       */
!     int haveGlock = ISAFS_GLOCK();
!     if (haveGlock)
! 	AFS_GUNLOCK();
!     soshutdown(rx_socket, 2);
! #ifndef AFS_FBSD70_ENV
      soclose(rx_socket);
+ #endif
      p = pfind(rxk_ListenerPid);
+     afs_warn("osi_StopListener: rxk_ListenerPid %lx\n", p);
      if (p)
  	psignal(p, SIGUSR1);
  #ifdef AFS_FBSD50_ENV
      PROC_UNLOCK(p);
  #endif
! #ifdef AFS_FBSD70_ENV
!     {
!       /* Avoid destroying socket until osi_NetReceive has
!        * had a chance to clean up */
!       int tries;
!       struct mtx s_mtx;
! 
!       MUTEX_INIT(&s_mtx, "rx_shutdown_mutex", MUTEX_DEFAULT, 0);
!       MUTEX_ENTER(&s_mtx);
!       tries = 3;
!       while ((tries > 0) && (!so_is_disconn(rx_socket))) {
! 	msleep(&osi_StopListener, &s_mtx, PSOCK | PCATCH,
! 	       "rx_shutdown_timedwait", 1 * hz);
! 	--tries;
!       }
!       if (so_is_disconn(rx_socket))
! 	soclose(rx_socket);
!       MUTEX_EXIT(&s_mtx);
!       MUTEX_DESTROY(&s_mtx);
!     }
! #endif
!     if (haveGlock)
! 	AFS_GLOCK();
  }
  
  int
Index: openafs/src/rx/SOLARIS/rx_knet.c
diff -c openafs/src/rx/SOLARIS/rx_knet.c:1.19.2.4 openafs/src/rx/SOLARIS/rx_knet.c:1.19.2.5
*** openafs/src/rx/SOLARIS/rx_knet.c:1.19.2.4	Mon Mar 17 11:28:56 2008
--- openafs/src/rx/SOLARIS/rx_knet.c	Mon Jul  7 13:15:37 2008
***************
*** 11,17 ****
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/SOLARIS/rx_knet.c,v 1.19.2.4 2008/03/17 15:28:56 shadow Exp $");
  
  #ifdef AFS_SUN5_ENV
  #include "rx/rx_kcommon.h"
--- 11,17 ----
  #include "afs/param.h"
  
  RCSID
!     ("$Header: /cvs/openafs/src/rx/SOLARIS/rx_knet.c,v 1.19.2.5 2008/07/07 17:15:37 shadow Exp $");
  
  #ifdef AFS_SUN5_ENV
  #include "rx/rx_kcommon.h"
***************
*** 69,74 ****
--- 69,78 ----
    (struct sonode *);
  #endif
  
+ #ifndef UDP_MOD_NAME
+ #define UDP_MOD_NAME "udp"
+ #endif
+ 
  static afs_uint32 myNetAddrs[ADDRSPERSITE];
  static int myNetMTUs[ADDRSPERSITE];
  static int numMyNetAddrs = 0;
Index: openafs/src/rxdebug/rxdebug.c
diff -c openafs/src/rxdebug/rxdebug.c:1.5.2.3 openafs/src/rxdebug/rxdebug.c:1.5.2.4
*** openafs/src/rxdebug/rxdebug.c:1.5.2.3	Wed Oct 31 00:13:44 2007
--- openafs/src/rxdebug/rxdebug.c	Sat Sep 27 16:54:55 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxdebug/rxdebug.c,v 1.5.2.3 2007/10/31 04:13:44 shadow Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxdebug/rxdebug.c,v 1.5.2.4 2008/09/27 20:54:55 jaltman Exp $");
  
  #include <sys/types.h>
  #include <errno.h>
***************
*** 270,276 ****
  	    fprintf(stderr,
  		    "WARNING: Server doesn't support retrieval of Rx statistics\n");
  	} else {
! 	    struct rx_stats rxstats;
  
  	    /* should gracefully handle the case where rx_stats grows */
  	    code =
--- 270,276 ----
  	    fprintf(stderr,
  		    "WARNING: Server doesn't support retrieval of Rx statistics\n");
  	} else {
! 	    struct rx_statistics rxstats;
  
  	    /* should gracefully handle the case where rx_stats grows */
  	    code =
Index: openafs/src/rxgen/Makefile.in
diff -c openafs/src/rxgen/Makefile.in:1.8.2.1 openafs/src/rxgen/Makefile.in:1.8.2.2
*** openafs/src/rxgen/Makefile.in:1.8.2.1	Tue Jan  8 13:57:28 2008
--- openafs/src/rxgen/Makefile.in	Mon Jun 30 19:57:46 2008
***************
*** 19,25 ****
  	$(CC) $(CFLAGS) $(OBJS) $(XLIBS) -o $@
  
  rpc_main.o: rpc_main.c
! 	$(CCOBJ) $(CFLAGS) -c $< -D__PROG_CPP__="\"$(CPP)\""
  
  #
  # Install targets
--- 19,25 ----
  	$(CC) $(CFLAGS) $(OBJS) $(XLIBS) -o $@
  
  rpc_main.o: rpc_main.c
! 	$(CCOBJ) $(CFLAGS) -c $< -DPATH_CPP="\"$(PATH_CPP)\""
  
  #
  # Install targets
Index: openafs/src/rxgen/rpc_main.c
diff -c openafs/src/rxgen/rpc_main.c:1.21.2.6 openafs/src/rxgen/rpc_main.c:1.21.2.7
*** openafs/src/rxgen/rpc_main.c:1.21.2.6	Tue Jan  8 13:57:28 2008
--- openafs/src/rxgen/rpc_main.c	Mon Jun 30 19:57:46 2008
***************
*** 37,43 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxgen/rpc_main.c,v 1.21.2.6 2008/01/08 18:57:28 shadow Exp $");
  
  #include <limits.h>
  #include <stdio.h>
--- 37,43 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/rxgen/rpc_main.c,v 1.21.2.7 2008/06/30 23:57:46 rra Exp $");
  
  #include <limits.h>
  #include <stdio.h>
***************
*** 94,101 ****
  char yflag = 0;			/* if set, only emit function name arrays to xdr file */
  int debug = 0;
  static char *cmdname;
! #ifdef	__PROG_CPP__
! static char CPP[] = __PROG_CPP__;
  #else
  static char CPP[] = "/lib/cpp";
  #endif
--- 94,101 ----
  char yflag = 0;			/* if set, only emit function name arrays to xdr file */
  int debug = 0;
  static char *cmdname;
! #ifdef PATH_CPP
! static char CPP[] = PATH_CPP;
  #else
  static char CPP[] = "/lib/cpp";
  #endif
Index: openafs/src/shlibafsrpc/Makefile.in
diff -c openafs/src/shlibafsrpc/Makefile.in:1.15.2.11 openafs/src/shlibafsrpc/Makefile.in:1.15.2.13
*** openafs/src/shlibafsrpc/Makefile.in:1.15.2.11	Tue Jan  8 13:57:28 2008
--- openafs/src/shlibafsrpc/Makefile.in	Tue Jul  1 14:17:09 2008
***************
*** 284,290 ****
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.15.2.11 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
--- 284,290 ----
  #
  #   $ what /opt/langtools/bin/pxdb32
  #   /opt/langtools/bin/pxdb32:
! #           HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.15.2.13 $
  #
  # The problem occurs when -g and -O are both used when compiling des.c.
  # The simplest way to work around the problem is to leave out either -g or -O.
***************
*** 366,372 ****
  syscall.o: ${SYS}/syscall.s
  	case "$(SYS_NAME)" in \
  	     sun4x_5* | sunx86_5*) \
! 		$(CPP)  ${SFLAGS} ${SYS}/syscall.s syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	 sgi_* | *_darwin_* ) \
--- 366,372 ----
  syscall.o: ${SYS}/syscall.s
  	case "$(SYS_NAME)" in \
  	     sun4x_5* | sunx86_5*) \
! 		$(PATH_CPP)  ${SFLAGS} ${SYS}/syscall.s > syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	 sgi_* | *_darwin_* ) \
***************
*** 378,384 ****
  	 *fbsd* ) \
  		touch syscall.o ;; \
  	 *) \
! 		$(CPP)  ${SFLAGS} ${SYS}/syscall.s syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	esac
--- 378,384 ----
  	 *fbsd* ) \
  		touch syscall.o ;; \
  	 *) \
! 		$(PATH_CPP) ${SFLAGS} ${SYS}/syscall.s > syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	esac
Index: openafs/src/sys/Makefile.in
diff -c openafs/src/sys/Makefile.in:1.27.2.14 openafs/src/sys/Makefile.in:1.27.2.16
*** openafs/src/sys/Makefile.in:1.27.2.14	Mon Jan  7 15:10:51 2008
--- openafs/src/sys/Makefile.in	Wed Sep  3 14:27:40 2008
***************
*** 88,94 ****
  syscall.o: syscall.s
  	@set -x; case "$(SYS_NAME)" in \
  	 sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53  | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5? | sun4x_5?? | sunx86_5? | sunx86_5?? ) \
! 		$(CPP) -P ${SFLAGS} ${srcdir}/syscall.s syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	 sgi_* |*_darwin* ) \
--- 88,94 ----
  syscall.o: syscall.s
  	@set -x; case "$(SYS_NAME)" in \
  	 sun4c_51 | sun4c_52 | sun4m_51 | sun4m_52 | sun4c_53 | sun4m_53  | sun4_53 | sun4_52 | sun4_54 | sun4c_54 | sun4m_54 | sun4x_5? | sun4x_5?? | sunx86_5? | sunx86_5?? ) \
! 		$(PATH_CPP) -P ${SFLAGS} ${srcdir}/syscall.s > syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	 sgi_* |*_darwin* ) \
***************
*** 104,110 ****
  		${AS} syscall.S -o syscall.o ;  \
  		$(RM) -f syscall.S ;;\
  	 *) \
! 		$(CPP) -P ${SFLAGS} ${srcdir}/syscall.s syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	esac
--- 104,110 ----
  		${AS} syscall.S -o syscall.o ;  \
  		$(RM) -f syscall.S ;;\
  	 *) \
! 		$(PATH_CPP) -P ${SFLAGS} ${srcdir}/syscall.s > syscall.ss; \
  		as -o syscall.o syscall.ss;		\
  		$(RM) syscall.ss;;				\
  	esac
***************
*** 215,221 ****
  
  afs.exp: ${srcdir}/afs4.exp ${srcdir}/afs5.exp
  	@set -x; case ${SYS_NAME} in \
! 		rs_aix5* ) \
  			cp -p ${srcdir}/afs5.exp afs.exp ;; \
  		rs_aix* ) \
  			cp -p ${srcdir}/afs4.exp afs.exp ;; \
--- 215,221 ----
  
  afs.exp: ${srcdir}/afs4.exp ${srcdir}/afs5.exp
  	@set -x; case ${SYS_NAME} in \
! 		rs_aix[56]* ) \
  			cp -p ${srcdir}/afs5.exp afs.exp ;; \
  		rs_aix* ) \
  			cp -p ${srcdir}/afs4.exp afs.exp ;; \
***************
*** 225,231 ****
  
  afsl.exp: ${srcdir}/afsl4.exp ${srcdir}/afsl5.exp
  	@set -x; case ${SYS_NAME} in \
! 		rs_aix5* ) \
  			cp -p ${srcdir}/afsl5.exp afsl.exp ;; \
  		rs_aix* ) \
  			cp -p ${srcdir}/afsl4.exp afsl.exp ;; \
--- 225,231 ----
  
  afsl.exp: ${srcdir}/afsl4.exp ${srcdir}/afsl5.exp
  	@set -x; case ${SYS_NAME} in \
! 		rs_aix[56]* ) \
  			cp -p ${srcdir}/afsl5.exp afsl.exp ;; \
  		rs_aix* ) \
  			cp -p ${srcdir}/afsl4.exp afsl.exp ;; \
Index: openafs/src/tbutc/Makefile.in
diff -c openafs/src/tbutc/Makefile.in:1.13.2.3 openafs/src/tbutc/Makefile.in:1.13.2.4
*** openafs/src/tbutc/Makefile.in:1.13.2.3	Mon Apr 28 12:15:16 2008
--- openafs/src/tbutc/Makefile.in	Fri Jul 11 05:54:43 2008
***************
*** 30,36 ****
  LWPOBJS     =lock.o
  
  BUTCOBJS   =dbentries.o tcprocs.o lwps.o tcmain.o list.o recoverDb.o \
! 	    tcudbprocs.o dump.o tcstatus.o butc_xbsa.o \
              ${LWPOBJS} ${BUCOORDOBJS} ${VOLSEROBJS}
  
  BUTCINCLS=${TOP_INCDIR}/afs/partition.h \
--- 30,36 ----
  LWPOBJS     =lock.o
  
  BUTCOBJS   =dbentries.o tcprocs.o lwps.o tcmain.o list.o recoverDb.o \
! 	    tcudbprocs.o dump.o tcstatus.o butc_xbsa.o afsxbsa.o \
              ${LWPOBJS} ${BUCOORDOBJS} ${VOLSEROBJS}
  
  BUTCINCLS=${TOP_INCDIR}/afs/partition.h \
***************
*** 73,78 ****
--- 73,81 ----
  	$(AR) crv libbutm.a $(BUTMOBJS) AFS_component_version_number.o
  	${RANLIB} libbutm.a
  
+ afsxbsa.o: ${BUTC}/afsxbsa.c ${BUTC}/afsxbsa.h ${BUTCINCLS}
+ 	${CC} ${CFLAGS} -c ${BUTC}/afsxbsa.c
+ 
  dbentries.o: ${BUTC}/dbentries.c ${BUTCINCLS}
  	${CC} ${CFLAGS} -c ${BUTC}/dbentries.c
  
Index: openafs/src/ubik/phys.c
diff -c openafs/src/ubik/phys.c:1.8.2.4 openafs/src/ubik/phys.c:1.8.2.5
*** openafs/src/ubik/phys.c:1.8.2.4	Mon Apr 28 17:48:25 2008
--- openafs/src/ubik/phys.c	Tue Oct  7 13:44:31 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/phys.c,v 1.8.2.4 2008/04/28 21:48:25 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/phys.c,v 1.8.2.5 2008/10/07 17:44:31 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 108,114 ****
      }
      if (bestfd) {		/* found a usable slot */
  	tfd = bestfd;
! 	if (tfd->fd >= 0)
  	    close(tfd->fd);
  	tfd->fd = fd;
  	tfd->refCount = 1;	/* us */
--- 108,114 ----
      }
      if (bestfd) {		/* found a usable slot */
  	tfd = bestfd;
! 	if (tfd->fd >= 0) 
  	    close(tfd->fd);
  	tfd->fd = fd;
  	tfd->refCount = 1;	/* us */
***************
*** 130,139 ****
  	return EBADF;
      tfd = fdcache;
      for (i = 0; i < MAXFDCACHE; i++, tfd++) {
! 	if (tfd->fd == afd && tfd->fileID != -10000) {
! 	    tfd->refCount--;
! 	    return 0;
! 	}
      }
      return close(afd);
  }
--- 130,151 ----
  	return EBADF;
      tfd = fdcache;
      for (i = 0; i < MAXFDCACHE; i++, tfd++) {
! 	if (tfd->fd == afd) 
! 	    if (tfd->fileID != -10000) {
! 		tfd->refCount--;
! 		return 0;
! 	    } else {
! 		if (tfd->refCount > 0) {
! 		    tfd->refCount--;
! 		    if (tfd->refCount == 0) {
! 			close(tfd->fd);
! 			tfd->fd = -1;
! 		    }
! 		    return 0;
! 		}
! 		tfd->fd = -1;
! 		break;
! 	    }
      }
      return close(afd);
  }
***************
*** 293,300 ****
      for (tfd = fdcache, i = 0; i < MAXFDCACHE; i++, tfd++) {
  	if (afid == tfd->fileID) {
  	    tfd->fileID = -10000;
! 	    if (tfd->fd >= 0 && tfd->refCount == 0)
  		close(tfd->fd);
  	    return;
  	}
      }
--- 305,314 ----
      for (tfd = fdcache, i = 0; i < MAXFDCACHE; i++, tfd++) {
  	if (afid == tfd->fileID) {
  	    tfd->fileID = -10000;
! 	    if (tfd->fd >= 0 && tfd->refCount == 0) {
  		close(tfd->fd);
+ 		tfd->fd = -1;
+ 	    }
  	    return;
  	}
      }
Index: openafs/src/ubik/ubik.c
diff -c openafs/src/ubik/ubik.c:1.15.2.4 openafs/src/ubik/ubik.c:1.15.2.5
*** openafs/src/ubik/ubik.c:1.15.2.4	Mon Apr 28 17:48:25 2008
--- openafs/src/ubik/ubik.c	Mon Jun 30 23:07:27 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/ubik.c,v 1.15.2.4 2008/04/28 21:48:25 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/ubik.c,v 1.15.2.5 2008/07/01 03:07:27 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 263,269 ****
       * the "steplock" problem in ubik initialization. Defect 11037.
       */
      LWP_CreateProcess(rx_ServerProc, rx_stackSize, RX_PROCESS_PRIORITY,
! 		      (void *)0, "rx_ServerProc", &junk);
  
      /* do basic initialization */
      code = uvote_Init();
--- 263,269 ----
       * the "steplock" problem in ubik initialization. Defect 11037.
       */
      LWP_CreateProcess(rx_ServerProc, rx_stackSize, RX_PROCESS_PRIORITY,
! 		      NULL, "rx_ServerProc", &junk);
  
      /* do basic initialization */
      code = uvote_Init();
Index: openafs/src/ubik/udebug.c
diff -c openafs/src/ubik/udebug.c:1.16.2.4 openafs/src/ubik/udebug.c:1.16.2.5
*** openafs/src/ubik/udebug.c:1.16.2.4	Wed Oct 31 00:13:49 2007
--- openafs/src/ubik/udebug.c	Sat May 10 11:24:04 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/udebug.c,v 1.16.2.4 2007/10/31 04:13:49 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdlib.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/ubik/udebug.c,v 1.16.2.5 2008/05/10 15:24:04 jaltman Exp $");
  
  #include <sys/types.h>
  #include <stdlib.h>
***************
*** 192,198 ****
      } else {
  	diff = udebug.now - udebug.lastYesTime;
  	printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
! 	       afs_inet_ntoa(htonl(udebug.lastYesHost)), diff,
  	       ((udebug.lastYesState) ? "" : "not "));
  
  	diff = udebug.now - udebug.lastYesClaim;
--- 192,198 ----
      } else {
  	diff = udebug.now - udebug.lastYesTime;
  	printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
! 	       afs_inet_ntoa(udebug.lastYesHost), diff,
  	       ((udebug.lastYesState) ? "" : "not "));
  
  	diff = udebug.now - udebug.lastYesClaim;
Index: openafs/src/util/afsutil.h
diff -c openafs/src/util/afsutil.h:1.17.2.6 openafs/src/util/afsutil.h:1.17.2.7
*** openafs/src/util/afsutil.h:1.17.2.6	Wed Oct 31 00:26:29 2007
--- openafs/src/util/afsutil.h	Tue Aug 26 10:12:24 2008
***************
*** 70,76 ****
  
  /* Need a thead safe ctime for pthread builds. Use std ctime for LWP */
  #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
! #ifdef AFS_SUN5_ENV
  #define afs_ctime(C, B, L) ctime_r(C, B, L)
  #else
  /* Cast is for platforms which do not prototype ctime_r */
--- 70,76 ----
  
  /* Need a thead safe ctime for pthread builds. Use std ctime for LWP */
  #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
! #if defined(AFS_SUN5_ENV) && !defined(_POSIX_PTHREAD_SEMANTICS) && (_POSIX_C_SOURCE - 0 < 199506L)
  #define afs_ctime(C, B, L) ctime_r(C, B, L)
  #else
  /* Cast is for platforms which do not prototype ctime_r */
Index: openafs/src/util/softsig.c
diff -c openafs/src/util/softsig.c:1.8.2.3 openafs/src/util/softsig.c:1.8.2.5
*** openafs/src/util/softsig.c:1.8.2.3	Wed Oct 31 00:26:29 2007
--- openafs/src/util/softsig.c	Sat Aug 16 15:47:10 2008
***************
*** 37,43 ****
  static struct {
      void (*handler) (int);
      int pending;
! #if !defined(AFS_DARWIN60_ENV) || defined(AFS_NBSD30_ENV) || !defined(AFS_NBSD_ENV)
      int fatal;
  #endif /* !defined(AFS_DARWIN60_ENV) || !defined(AFS_NBSD_ENV) */
      int inited;
--- 37,43 ----
  static struct {
      void (*handler) (int);
      int pending;
! #if !(defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV)))
      int fatal;
  #endif /* !defined(AFS_DARWIN60_ENV) || !defined(AFS_NBSD_ENV) */
      int inited;
***************
*** 54,60 ****
      pthread_sigmask(SIG_BLOCK, &ss, &os);
      pthread_sigmask(SIG_SETMASK, &os, NULL);
      sigaddset(&ss, SIGUSR1);
! #if defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD30_ENV))
      pthread_sigmask (SIG_BLOCK, &ss, NULL);
      sigdelset (&os, SIGUSR1);
  #else /* !defined(AFS_DARWIN60_ENV) && !defined(AFS_NBSD_ENV) */
--- 54,60 ----
      pthread_sigmask(SIG_BLOCK, &ss, &os);
      pthread_sigmask(SIG_SETMASK, &os, NULL);
      sigaddset(&ss, SIGUSR1);
! #if defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV))
      pthread_sigmask (SIG_BLOCK, &ss, NULL);
      sigdelset (&os, SIGUSR1);
  #else /* !defined(AFS_DARWIN60_ENV) && !defined(AFS_NBSD_ENV) */
***************
*** 75,81 ****
  	for (i = 0; i < NSIG; i++) {
  	    if (softsig_sigs[i].handler && !softsig_sigs[i].inited) {
  		sigaddset(&ss, i);
! #if defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD30_ENV))
  		pthread_sigmask (SIG_BLOCK, &ss, NULL);
  		sigdelset (&os, i);
  #endif /* defined(AFS_DARWIN60_ENV) || defined(AFS_NBSD_ENV) */
--- 75,81 ----
  	for (i = 0; i < NSIG; i++) {
  	    if (softsig_sigs[i].handler && !softsig_sigs[i].inited) {
  		sigaddset(&ss, i);
! #if defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV))
  		pthread_sigmask (SIG_BLOCK, &ss, NULL);
  		sigdelset (&os, i);
  #endif /* defined(AFS_DARWIN60_ENV) || defined(AFS_NBSD_ENV) */
***************
*** 88,94 ****
  	    }
  	}
  	if (i == NSIG) {
! #if defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD30_ENV))
  	    sigsuspend (&os);
  #else /* !defined(AFS_DARWIN60_ENV) && !defined(AFS_NBSD_ENV) */
  	    sigwait(&ss, &sigw);
--- 88,94 ----
  	    }
  	}
  	if (i == NSIG) {
! #if defined(AFS_DARWIN60_ENV) || (defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV))
  	    sigsuspend (&os);
  #else /* !defined(AFS_DARWIN60_ENV) && !defined(AFS_NBSD_ENV) */
  	    sigwait(&ss, &sigw);
Index: openafs/src/venus/kdump.c
diff -c openafs/src/venus/kdump.c:1.33.2.8 openafs/src/venus/kdump.c:1.33.2.9
*** openafs/src/venus/kdump.c:1.33.2.8	Wed Oct 31 00:13:50 2007
--- openafs/src/venus/kdump.c	Fri Oct  3 16:40:05 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/kdump.c,v 1.33.2.8 2007/10/31 04:13:50 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/venus/kdump.c,v 1.33.2.9 2008/10/03 20:40:05 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 3408,3414 ****
      off_t symoff;
      char sysname[100];
      afs_int32 count, i;
!     struct rx_stats rx_stats;
  
      printf("\n\nPrinting some general RX stats...\n\n");
      findsym("rx_stats", &symoff);
--- 3408,3414 ----
      off_t symoff;
      char sysname[100];
      afs_int32 count, i;
!     struct rx_statistics rx_stats;
  
      printf("\n\nPrinting some general RX stats...\n\n");
      findsym("rx_stats", &symoff);
***************
*** 3473,3479 ****
      char sysname[100], c;
      afs_int32 count, i, ar[100];
      short sm;
!     struct rx_stats rx_stats;
  
      printf("\n\nPrinting some RX globals...\n\n");
      findsym("rx_extraQuota", &symoff);
--- 3473,3479 ----
      char sysname[100], c;
      afs_int32 count, i, ar[100];
      short sm;
!     struct rx_statistics rx_stats;
  
      printf("\n\nPrinting some RX globals...\n\n");
      findsym("rx_extraQuota", &symoff);
Index: openafs/src/viced/afsfileprocs.c
diff -c openafs/src/viced/afsfileprocs.c:1.81.2.47 openafs/src/viced/afsfileprocs.c:1.81.2.50
*** openafs/src/viced/afsfileprocs.c:1.81.2.47	Tue Feb 19 09:33:44 2008
--- openafs/src/viced/afsfileprocs.c	Fri Sep  5 12:58:05 2008
***************
*** 29,35 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.47 2008/02/19 14:33:44 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 29,35 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.50 2008/09/05 16:58:05 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 1919,1926 ****
      status->MinQuota = V_minquota(volptr);
      status->MaxQuota = V_maxquota(volptr);
      status->BlocksInUse = V_diskused(volptr);
!     status->PartBlocksAvail = volptr->partition->free;
!     status->PartMaxBlocks = volptr->partition->totalUsable;
      strncpy(name->SeqBody, V_name(volptr), (int)name->MaxSeqLen);
      name->SeqLen = strlen(V_name(volptr)) + 1;
      if (name->SeqLen > name->MaxSeqLen)
--- 1919,1926 ----
      status->MinQuota = V_minquota(volptr);
      status->MaxQuota = V_maxquota(volptr);
      status->BlocksInUse = V_diskused(volptr);
!     status->PartBlocksAvail = RoundInt64ToInt32(volptr->partition->free);
!     status->PartMaxBlocks = RoundInt64ToInt32(volptr->partition->totalUsable);
      strncpy(name->SeqBody, V_name(volptr), (int)name->MaxSeqLen);
      name->SeqLen = strlen(V_name(volptr)) + 1;
      if (name->SeqLen > name->MaxSeqLen)
***************
*** 5577,5589 ****
  void
  SetVolumeStats(struct AFSStatistics *stats)
  {
!     struct DiskPartition *part;
      int i = 0;
  
      for (part = DiskPartitionList; part && i < AFS_MSTATDISKS;
  	 part = part->next) {
! 	stats->Disks[i].TotalBlocks = part->totalUsable;
! 	stats->Disks[i].BlocksAvailable = part->free;
  	memset(stats->Disks[i].Name, 0, AFS_DISKNAMESIZE);
  	strncpy(stats->Disks[i].Name, part->name, AFS_DISKNAMESIZE);
  	i++;
--- 5577,5589 ----
  void
  SetVolumeStats(struct AFSStatistics *stats)
  {
!     struct DiskPartition64 *part;
      int i = 0;
  
      for (part = DiskPartitionList; part && i < AFS_MSTATDISKS;
  	 part = part->next) {
! 	stats->Disks[i].TotalBlocks = RoundInt64ToInt31(part->totalUsable);
! 	stats->Disks[i].BlocksAvailable = RoundInt64ToInt31(part->free);
  	memset(stats->Disks[i].Name, 0, AFS_DISKNAMESIZE);
  	strncpy(stats->Disks[i].Name, part->name, AFS_DISKNAMESIZE);
  	i++;
***************
*** 5658,5663 ****
--- 5658,5774 ----
  }				/*SRXAFS_GetStatistics */
  
  
+ afs_int32
+ SRXAFS_GetStatistics64(struct rx_call *acall, afs_int32 statsVersion, ViceStatistics64 *Statistics)
+ {
+     extern afs_int32 StartTime, CurrentConnections;
+     int seconds;
+     afs_int32 code;
+     struct rx_connection *tcon = rx_ConnectionOf(acall);
+     struct host *thost;
+     struct client *t_client = NULL;	/* tmp ptr to client data */
+     struct timeval time;
+ #if FS_STATS_DETAILED
+     struct fs_stats_opTimingData *opP;	/* Ptr to this op's timing struct */
+     struct timeval opStartTime, opStopTime;	/* Start/stop times for RPC op */
+     struct timeval elapsedTime;	/* Transfer time */
+ 
+     /*
+      * Set our stats pointer, remember when the RPC operation started, and
+      * tally the operation.
+      */
+     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETSTATISTICS]);
+     FS_LOCK;
+     (opP->numOps)++;
+     FS_UNLOCK;
+     TM_GetTimeOfDay(&opStartTime, 0);
+ #endif /* FS_STATS_DETAILED */
+     if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
+ 	goto Bad_GetStatistics64;
+     if (statsVersion > STATS64_VERSION) 
+      	goto Bad_GetStatistics64;
+     ViceLog(1, ("SAFS_GetStatistics64 Received\n"));
+     Statistics->ViceStatistics64_val = 
+ 	malloc(statsVersion*sizeof(afs_int64));
+     Statistics->ViceStatistics64_len = statsVersion;
+     FS_LOCK;
+     AFSCallStats.GetStatistics++, AFSCallStats.TotalCalls++;
+     Statistics->ViceStatistics64_val[STATS64_STARTTIME] = StartTime;
+     Statistics->ViceStatistics64_val[STATS64_CURRENTCONNECTIONS] =
+ 	CurrentConnections;
+     Statistics->ViceStatistics64_val[STATS64_TOTALVICECALLS] = 
+ 	AFSCallStats.TotalCalls;
+     Statistics->ViceStatistics64_val[STATS64_TOTALFETCHES] =
+        AFSCallStats.FetchData + AFSCallStats.FetchACL +
+        AFSCallStats.FetchStatus;
+     Statistics->ViceStatistics64_val[STATS64_FETCHDATAS] = 
+ 	AFSCallStats.FetchData;
+     Statistics->ViceStatistics64_val[STATS64_FETCHEDBYTES] = 
+ 	AFSCallStats.TotalFetchedBytes;
+     seconds = AFSCallStats.AccumFetchTime / 1000;
+     if (seconds <= 0)
+         seconds = 1;
+     Statistics->ViceStatistics64_val[STATS64_FETCHDATARATE] = 
+ 	AFSCallStats.TotalFetchedBytes / seconds;
+     Statistics->ViceStatistics64_val[STATS64_TOTALSTORES] =
+         AFSCallStats.StoreData + AFSCallStats.StoreACL +
+         AFSCallStats.StoreStatus;
+     Statistics->ViceStatistics64_val[STATS64_STOREDATAS] = 
+ 	AFSCallStats.StoreData;
+     Statistics->ViceStatistics64_val[STATS64_STOREDBYTES] = 
+ 	AFSCallStats.TotalStoredBytes;
+     seconds = AFSCallStats.AccumStoreTime / 1000;
+     if (seconds <= 0)
+         seconds = 1;
+     Statistics->ViceStatistics64_val[STATS64_STOREDATARATE] = 
+ 	AFSCallStats.TotalStoredBytes / seconds;
+ #ifdef AFS_NT40_ENV
+     Statistics->ViceStatistics64_val[STATS64_PROCESSSIZE] = -1;
+ #else
+     Statistics->ViceStatistics64_val[STATS64_PROCESSSIZE] = 
+ 	(afs_int32) ((long)sbrk(0) >> 10);
+ #endif
+     FS_UNLOCK;
+     h_GetWorkStats((int *)&(Statistics->ViceStatistics64_val[STATS64_WORKSTATIONS]),
+                    (int *)&(Statistics->ViceStatistics64_val[STATS64_ACTIVEWORKSTATIONS]), 
+ 		   (int *)0,
+                    (afs_int32) (FT_ApproxTime()) - (15 * 60));
+ 
+ 
+ 
+     /* this works on all system types */
+     TM_GetTimeOfDay(&time, 0);
+     Statistics->ViceStatistics64_val[STATS64_CURRENTTIME] = time.tv_sec;
+ 
+   Bad_GetStatistics64:
+     code = CallPostamble(tcon, code, thost);
+ 
+     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+ 
+ #if FS_STATS_DETAILED
+     TM_GetTimeOfDay(&opStopTime, 0);
+     if (code == 0) {
+ 	FS_LOCK;
+ 	(opP->numSuccesses)++;
+ 	fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
+ 	fs_stats_AddTo((opP->sumTime), elapsedTime);
+ 	fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
+ 	if (fs_stats_TimeLessThan(elapsedTime, (opP->minTime))) {
+ 	    fs_stats_TimeAssign((opP->minTime), elapsedTime);
+ 	}
+ 	if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
+ 	    fs_stats_TimeAssign((opP->maxTime), elapsedTime);
+ 	}
+ 	FS_UNLOCK;
+     }
+ #endif /* FS_STATS_DETAILED */
+ 
+     osi_auditU(acall, GetStatisticsEvent, code, 
+                AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
+     return code;
+ }				/*SRXAFS_GetStatistics */
+ 
+ 
  /*------------------------------------------------------------------------
   * EXPORTED SRXAFS_XStatsVersion
   *
Index: openafs/src/viced/host.c
diff -c openafs/src/viced/host.c:1.57.2.58 openafs/src/viced/host.c:1.57.2.59
*** openafs/src/viced/host.c:1.57.2.58	Mon Feb 25 15:39:04 2008
--- openafs/src/viced/host.c	Thu May  1 15:00:20 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.58 2008/02/25 20:39:04 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.59 2008/05/01 19:00:20 shadow Exp $");
  
  #include <stdio.h>
  #include <errno.h>
***************
*** 1133,1139 ****
  
      /* don't add the same entry multiple times */
      for (chain = hostUuidHashTable[index]; chain; chain = chain->next) {
! 	if (host->interface && afs_uuid_equal(&host->interface->uuid, uuid))
  	    return;
      }
  
--- 1133,1140 ----
  
      /* don't add the same entry multiple times */
      for (chain = hostUuidHashTable[index]; chain; chain = chain->next) {
! 	if (chain->hostPtr->interface && 
! 	    afs_uuid_equal(&chain->hostPtr->interface->uuid, uuid))
  	    return;
      }
  
Index: openafs/src/viced/viced.c
diff -c openafs/src/viced/viced.c:1.58.2.27 openafs/src/viced/viced.c:1.58.2.30
*** openafs/src/viced/viced.c:1.58.2.27	Tue Mar 11 13:40:55 2008
--- openafs/src/viced/viced.c	Sun Aug 24 21:15:21 2008
***************
*** 20,26 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.27 2008/03/11 17:40:55 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
--- 20,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.30 2008/08/25 01:15:21 shadow Exp $");
  
  #include <stdio.h>
  #include <stdlib.h>
***************
*** 157,163 ****
  int SawPctSpare;
  int debuglevel = 0;
  int printBanner = 0;
! int rxJumbograms = 1;		/* default is to send and receive jumbograms. */
  int rxBind = 0;		/* don't bind */
  int rxkadDisableDotCheck = 0;      /* disable check for dot in principal name */ 
  int rxMaxMTU = -1;
--- 157,163 ----
  int SawPctSpare;
  int debuglevel = 0;
  int printBanner = 0;
! int rxJumbograms = 0;		/* default is to not send and receive jumbograms. */
  int rxBind = 0;		/* don't bind */
  int rxkadDisableDotCheck = 0;      /* disable check for dot in principal name */ 
  int rxMaxMTU = -1;
***************
*** 756,761 ****
--- 756,763 ----
      strcat(buffer, "[-udpsize <size of socket buffer in bytes>] ");
      strcat(buffer, "[-sendsize <size of send buffer in bytes>] ");
      strcat(buffer, "[-abortthreshold <abort threshold>] ");
+     strcat(buffer, "[-nojumbo (disable jumbogram network packets - deprecated)] ");
+     strcat(buffer, "[-jumbo (enable jumbogram network packets)] ");
  /*   strcat(buffer, "[-enable_peer_stats] "); */
  /*   strcat(buffer, "[-enable_process_stats] "); */
      strcat(buffer, "[-help]\n");
***************
*** 1056,1061 ****
--- 1058,1065 ----
  #endif
  	else if (!strcmp(argv[i], "-nojumbo")) {
  	    rxJumbograms = 0;
+ 	} else if (!strcmp(argv[i], "-jumbo")) {
+ 	    rxJumbograms = 1;
  	} else if (!strcmp(argv[i], "-rxbind")) {
  	    rxBind = 1;
  	} else if (!strcmp(argv[i], "-allow-dotted-principals")) {
***************
*** 1192,1198 ****
  	if (!Sawcbs)
  	    numberofcbs = 64000;
  	if (!Sawlwps)
! 	    lwps = 12;
  	if (!Sawbufs)
  	    buffs = 120;
  	if (!SawVC)
--- 1196,1202 ----
  	if (!Sawcbs)
  	    numberofcbs = 64000;
  	if (!Sawlwps)
! 	    lwps = 128;
  	if (!Sawbufs)
  	    buffs = 120;
  	if (!SawVC)
***************
*** 1875,1880 ****
--- 1879,1885 ----
      rx_SetMinProcs(tservice, 3);
      rx_SetMaxProcs(tservice, lwps);
      rx_SetCheckReach(tservice, 1);
+     rx_SetServerIdleDeadErr(tservice, VNOSERVICE);
  
      tservice =
  	rx_NewService(0, RX_STATS_SERVICE_ID, "rpcstats", sc, 4,
Index: openafs/src/vlserver/vldb_check.c
diff -c openafs/src/vlserver/vldb_check.c:1.11.2.5 openafs/src/vlserver/vldb_check.c:1.11.2.6
*** openafs/src/vlserver/vldb_check.c:1.11.2.5	Tue Dec 11 15:45:29 2007
--- openafs/src/vlserver/vldb_check.c	Tue Oct  7 11:35:41 2008
***************
*** 26,31 ****
--- 26,41 ----
  #define REFBK 0x4000            /* linked from something (BK) */
  #define REFN  0x8000            /* linked from something (name) */
  
+ #define MULTRW 0x10000         /* multiply-chained (RW) */
+ #define MULTRO 0x20000         /* multiply-chained (RO) */
+ #define MULTBK 0x40000         /* multiply-chained (BK) */
+ #define MULTN  0x80000         /* multiply-chained (name) */
+ 
+ #define MISRWH 0x100000          /* mischained (RW) */
+ #define MISROH 0x200000          /* mischained (RO) */
+ #define MISBKH 0x400000          /* mischained (BK) */
+ #define MISNH  0x800000          /* mischained (name) */
+ 
  #define vldbread(x,y,z) vldbio(x,y,z,0)
  #define vldbwrite(x,y,z) vldbio(x,y,z,1)
  
***************
*** 33,39 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vldb_check.c,v 1.11.2.5 2007/12/11 20:45:29 shadow Exp $");
  
  #include <sys/types.h>
  #include <sys/stat.h>
--- 43,49 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vldb_check.c,v 1.11.2.6 2008/10/07 15:35:41 shadow Exp $");
  
  #include <sys/types.h>
  #include <sys/stat.h>
***************
*** 62,67 ****
--- 72,79 ----
  int listentries, listservers, listheader, listuheader, verbose;
  
  int fix = 0;
+ int fixed = 0;
+ int passes = 0;
  
  struct er {
      long addr;
***************
*** 404,410 ****
  
      if (verbose)
  	printf("Writing back entry at addr %u\n", addr);
! 
      for (i = 0; i < MAXTYPES; i++)
  	vlentryp->volumeId[i] = htonl(vlentryp->volumeId[i]);
      vlentryp->flags = htonl(vlentryp->flags);
--- 416,422 ----
  
      if (verbose)
  	printf("Writing back entry at addr %u\n", addr);
!     fixed++;
      for (i = 0; i < MAXTYPES; i++)
  	vlentryp->volumeId[i] = htonl(vlentryp->volumeId[i]);
      vlentryp->flags = htonl(vlentryp->flags);
***************
*** 663,672 ****
  		printf
  		    ("Name Hash %d: Bad entry '%s': Already in the name hash\n",
  		     i, vlentry.name);
  		break;
  	    }
  	    record[rindex].type |= NH;
- 
  	    record[rindex].type |= REFN;
  
  	    chainlength++;
--- 675,684 ----
  		printf
  		    ("Name Hash %d: Bad entry '%s': Already in the name hash\n",
  		     i, vlentry.name);
+ 		record[rindex].type |= MULTN;
  		break;
  	    }
  	    record[rindex].type |= NH;
  	    record[rindex].type |= REFN;
  
  	    chainlength++;
***************
*** 677,682 ****
--- 689,695 ----
  		printf
  		    ("Name Hash %d: Bad entry '%s': Incorrect name hash chain (should be in %d)\n",
  		     i, vlentry.name, NameHash(vlentry.name));
+ 		record[rindex].type |= MULTN;
  	    }
  	}
  	if (chainlength > longest)
***************
*** 703,709 ****
      int count = 0, longest = 0, shortest = -1, chainlength;
      struct nvlentry vlentry;
      afs_uint32 addr;
!     afs_int32 i, j, hash, type, rindex, ref;
  
      /* Now follow the RW, RO, and BK Hash Tables */
      if (verbose)
--- 716,722 ----
      int count = 0, longest = 0, shortest = -1, chainlength;
      struct nvlentry vlentry;
      afs_uint32 addr;
!     afs_int32 i, j, hash, type, rindex, ref, badref, badhash;
  
      /* Now follow the RW, RO, and BK Hash Tables */
      if (verbose)
***************
*** 711,716 ****
--- 724,731 ----
      for (i = 0; i < MAXTYPES; i++) {
  	hash = ((i == 0) ? RWH : ((i == 1) ? ROH : BKH));
  	ref = ((i == 0) ? REFRW : ((i == 1) ? REFRO : REFBK));
+ 	badref = ((i == 0) ? MULTRW : ((i == 1) ? MULTRO : MULTBK));
+ 	badhash = ((i == 0) ? MULTRW : ((i == 1) ? MULTRO : MULTBK));
  	count = longest = 0;
  	shortest = -1;
  
***************
*** 734,741 ****
  		}
  		if (record[rindex].type & hash) {
  		    printf
! 			("%s Id Hash %d: Bad entry '%s': Already in the the hash table\n",
  			 vtype(i), j, vlentry.name);
  		    break;
  		}
  		record[rindex].type |= hash;
--- 749,757 ----
  		}
  		if (record[rindex].type & hash) {
  		    printf
! 			("%s Id Hash %d: Bad entry '%s': Already in the hash table\n",
  			 vtype(i), j, vlentry.name);
+ 		    record[rindex].type |= badref;
  		    break;
  		}
  		record[rindex].type |= hash;
***************
*** 750,755 ****
--- 766,773 ----
  			("%s Id Hash %d: Bad entry '%s': Incorrect Id hash chain (should be in %d)\n",
  			 vtype(i), j, vlentry.name,
  			 IdHash(vlentry.volumeId[i]));
+ 		    record[rindex].type |= badhash;
+ 		    printf("%d: %x\n", rindex, record[rindex].type);
  		}
  	    }
  
***************
*** 1026,1035 ****
  
  void 
  FixBad(afs_uint32 idx, afs_uint32 addr, afs_uint32 type, afs_uint32 tmp, 
!        struct nvlentry *vlentry) {
      SetHashEnd(addr, type, tmp);
!     printf("linked unlinked chain %u (index %d) to end of chain\n", 
! 	   tmp, ADDR(tmp));
  }
  
  int
--- 1044,1053 ----
  
  void 
  FixBad(afs_uint32 idx, afs_uint32 addr, afs_uint32 type, afs_uint32 tmp, 
!        struct nvlentry *vlentry, afs_uint32 hash) {
      SetHashEnd(addr, type, tmp);
!     printf("linked unlinked chain %u (index %d) to end of chain %d for %s hash\n", 
! 	   tmp, ADDR(tmp), hash, type==NH?"Name":(type==RWH?"RW":(type==ROH?"RO":"BK")));
  }
  
  int
***************
*** 1038,1044 ****
      char *dbfile;
      afs_int32 maxentries, type, tmp;
      struct vlheader header;
!     struct nvlentry vlentry;
      int i, j, help = 0;
  
      dbfile = as->parms[0].items->data;	/* -database */
--- 1056,1062 ----
      char *dbfile;
      afs_int32 maxentries, type, tmp;
      struct vlheader header;
!     struct nvlentry vlentry, vlentry2;
      int i, j, help = 0;
  
      dbfile = as->parms[0].items->data;	/* -database */
***************
*** 1049,1054 ****
--- 1067,1073 ----
      verbose = (as->parms[5].items ? 1 : 0);	/* -verbose  */
      fix = (as->parms[6].items ? 1 : 0);	/* -fix  */
  
+  restart:
      /* open the vldb database file */
      fd = open(dbfile, (fix > 0)?O_RDWR:O_RDONLY, 0);
      if (fd < 0) {
***************
*** 1085,1091 ****
      /* Follow the chain of free entries */
      FollowFreeChain(&header);
  
!     /* Now check the record we have been keeping for inconsistancies
       * For valid vlentries, also check that the server we point to is 
       * valid (the serveraddrs array).
       */
--- 1104,1110 ----
      /* Follow the chain of free entries */
      FollowFreeChain(&header);
  
!     /* Now check the record we have been keeping for inconsistencies
       * For valid vlentries, also check that the server we point to is 
       * valid (the serveraddrs array).
       */
***************
*** 1094,1100 ****
      for (i = 0; i < maxentries; i++) {
  	int nextp;
  	int reft;
! 	int hash;
  	int *nextpp;
  	char *which;
  
--- 1113,1119 ----
      for (i = 0; i < maxentries; i++) {
  	int nextp;
  	int reft;
! 	int hash, nexthash = 0;
  	int *nextpp;
  	char *which;
  
***************
*** 1154,1159 ****
--- 1173,1230 ----
  		foundbad = 1;
  	    }
  
+ 	    if (record[ADDR(vlentry.nextNameHash)].type & MULTN) {
+ 		nextp = ADDR(vlentry.nextNameHash);
+ 		reft = REFN;
+ 		hash = NameHash(vlentry.name);
+ 		nextpp = &vlentry.nextNameHash;
+ 		which = "name";
+ 		sprintf(volidbuf, "");
+ 		readentry(nextp, &vlentry2, &type);
+ 		nexthash = NameHash(vlentry2.name);
+ 		if (hash != nexthash)
+ 		    foundbad = 1;
+ 	    }
+ 
+ 	    if ((record[ADDR(vlentry.nextIdHash[0])].type & MULTRW)) {
+ 		nextp = ADDR(vlentry.nextIdHash[0]);
+ 		reft = REFRW;
+ 		hash = IdHash(vlentry.volumeId[0]);
+ 		nextpp = &(vlentry.nextIdHash[0]);
+ 		which = "RW";
+ 		sprintf(volidbuf, "id %u ", vlentry.volumeId[0]);
+ 		readentry(nextp, &vlentry2, &type);
+ 		nexthash = IdHash(vlentry2.volumeId[0]);
+ 		if (hash != nexthash)
+ 		    foundbad = 1;
+ 	    }
+ 
+ 	    if ((record[ADDR(vlentry.nextIdHash[1])].type & MULTRO)) {
+ 		nextp = ADDR(vlentry.nextIdHash[1]);
+ 		reft = REFRO;
+ 		hash = IdHash(vlentry.volumeId[1]);
+ 		nextpp = &(vlentry.nextIdHash[1]);
+ 		which = "RO";
+ 		sprintf(volidbuf, "id %u ", vlentry.volumeId[1]);
+ 		readentry(nextp, &vlentry2, &type);
+ 		nexthash = IdHash(vlentry2.volumeId[1]);
+ 		if (hash != nexthash)
+ 		    foundbad = 1;
+ 	    }
+ 
+ 	    if ((record[ADDR(vlentry.nextIdHash[2])].type & MULTBK)) {
+ 		nextp = ADDR(vlentry.nextIdHash[2]);
+ 		reft = REFBK;
+ 		hash = IdHash(vlentry.volumeId[2]);
+ 		nextpp = &(vlentry.nextIdHash[2]);
+ 		which = "BK";
+ 		sprintf(volidbuf, "id %u ", vlentry.volumeId[2]);
+ 		readentry(nextp, &vlentry2, &type);
+ 		nexthash = IdHash(vlentry2.volumeId[2]);
+ 		if (hash != nexthash)
+ 		    foundbad = 1;
+ 	    }
+ 
  	    if (foundbad) {
  		printf("%d: Volume '%s' %snot found in %s hash %d", i, 
  		       vlentry.name, volidbuf, which, hash);
***************
*** 1217,1235 ****
  	}
      }
  
      /* By the time we get here, unchained entries are really unchained */
      printf("Scanning %u entries for possible repairs\n", maxentries);
      for (i = 0; i < maxentries; i++) {
  	if (record[i].type & VL) {
  	    readentry(record[i].addr, &vlentry, &type);
! 	    if (!(record[i].type & REFN) && (strlen(vlentry.name)>0)) {
  		printf("%d: Record %u (type 0x%x) not in a name chain\n", i, 
  		       record[i].addr, record[i].type);
! 		if (fix) {
! 		    if (header.VolnameHash[NameHash(vlentry.name)] == 0)
! 			header.VolnameHash[NameHash(vlentry.name)] = record[i].addr;
! 		    else
! 			FixBad(i, header.VolnameHash[NameHash(vlentry.name)], NH, record[i].addr, &vlentry);
  		}
  	    }
  	    if (vlentry.volumeId[0] && !(record[i].type & REFRW)) {
--- 1288,1371 ----
  	}
      }
  
+     if (verbose)
+ 	printf("Verify each chain head\n");
+ 
+     {
+ 	afs_uint32 addr;
+ 	int hash;
+ 
+ 	for (j = 0; j < HASHSIZE; j++) {
+ 	    for (addr = header.VolnameHash[j]; j < HASHSIZE; j++) {
+ 		if (record[ADDR(addr)].type & MULTN) {
+ 		    hash = NameHash(vlentry.name);
+ 		    if (hash != j) {
+ 			header.VolnameHash[j] = vlentry.nextNameHash;
+ 			vlentry.nextNameHash = 0;
+ 			if (fix)
+ 			    writeentry(record[i].addr, &vlentry);
+ 		    }
+ 		}
+ 	    }
+ 	}
+ 	for (i = 0; i <= 2; i++) {
+ 	    for (j = 0; j < HASHSIZE; j++) {
+ 		addr = header.VolidHash[i][j]; 
+ 		if (i == 0 && (record[ADDR(addr)].type & MULTRW)) {
+ 		    hash = IdHash(vlentry.volumeId[i]);
+ 		    if (hash != j) {
+ 			header.VolidHash[i][j] = vlentry.nextIdHash[i];
+ 			vlentry.nextIdHash[i] = 0;
+ 			if (fix)
+ 			    writeentry(record[i].addr, &vlentry);
+ 		    }
+ 		}
+ 
+ 		if (i == 1 && (record[ADDR(addr)].type & MULTRO)) {
+ 		    hash = IdHash(vlentry.volumeId[i]);
+ 		    if (hash != j) {
+ 			header.VolidHash[i][j] = vlentry.nextIdHash[i];
+ 			vlentry.nextIdHash[i] = 0;
+ 			if (fix)
+ 			    writeentry(record[i].addr, &vlentry);
+ 		    }
+ 		}
+ 
+ 		if (i == 2 && (record[ADDR(addr)].type & MULTBK)) {
+ 		    hash = IdHash(vlentry.volumeId[i]);
+ 		    if (hash != j) {
+ 			header.VolidHash[i][j] = vlentry.nextIdHash[i];
+ 			vlentry.nextIdHash[i] = 0;
+ 			if (fix)
+ 			    writeentry(record[i].addr, &vlentry);
+ 		    }
+ 		}
+ 	    }
+ 	}
+     }
      /* By the time we get here, unchained entries are really unchained */
      printf("Scanning %u entries for possible repairs\n", maxentries);
      for (i = 0; i < maxentries; i++) {
+ 	int *nextpp;
  	if (record[i].type & VL) {
  	    readentry(record[i].addr, &vlentry, &type);
! 	    if (!(record[i].type & REFN)) {
  		printf("%d: Record %u (type 0x%x) not in a name chain\n", i, 
  		       record[i].addr, record[i].type);
! 		if (strlen(vlentry.name)>0) {
! 		    if (fix) {
! 			if (header.VolnameHash[NameHash(vlentry.name)] == 0)
! 			    header.VolnameHash[NameHash(vlentry.name)] = record[i].addr;
! 			else
! 			    FixBad(i, header.VolnameHash[NameHash(vlentry.name)], NH, record[i].addr, &vlentry, NameHash(vlentry.name));
! 		    }
! 		} else {
! 		    nextpp = &vlentry.nextNameHash;
! 		    if (fix && *nextpp) {
! 			printf(", unchaining");
! 			*nextpp = 0;
! 			writeentry(record[i].addr, &vlentry);
! 		    }
  		}
  	    }
  	    if (vlentry.volumeId[0] && !(record[i].type & REFRW)) {
***************
*** 1239,1245 ****
  		    if (header.VolidHash[0][IdHash(vlentry.volumeId[0])] == 0)
  			header.VolidHash[0][IdHash(vlentry.volumeId[0])] = record[i].addr;
  		    else
! 			FixBad(i, header.VolidHash[0][IdHash(vlentry.volumeId[0])], RWH, record[i].addr, &vlentry);
  		}
  	    }
  	    if (vlentry.volumeId[1] && !(record[i].type & REFRO)) {
--- 1375,1381 ----
  		    if (header.VolidHash[0][IdHash(vlentry.volumeId[0])] == 0)
  			header.VolidHash[0][IdHash(vlentry.volumeId[0])] = record[i].addr;
  		    else
! 			FixBad(i, header.VolidHash[0][IdHash(vlentry.volumeId[0])], RWH, record[i].addr, &vlentry, IdHash(vlentry.volumeId[0]));
  		}
  	    }
  	    if (vlentry.volumeId[1] && !(record[i].type & REFRO)) {
***************
*** 1249,1255 ****
  		    if (header.VolidHash[1][IdHash(vlentry.volumeId[1])] == 0)
  			header.VolidHash[1][IdHash(vlentry.volumeId[1])] = record[i].addr;
  		    else
! 			FixBad(i, header.VolidHash[1][IdHash(vlentry.volumeId[1])], ROH, record[i].addr, &vlentry);
  		}
  	    }
  	    if (vlentry.volumeId[2] && !(record[i].type & REFBK)) {
--- 1385,1391 ----
  		    if (header.VolidHash[1][IdHash(vlentry.volumeId[1])] == 0)
  			header.VolidHash[1][IdHash(vlentry.volumeId[1])] = record[i].addr;
  		    else
! 			FixBad(i, header.VolidHash[1][IdHash(vlentry.volumeId[1])], ROH, record[i].addr, &vlentry, IdHash(vlentry.volumeId[1]));
  		}
  	    }
  	    if (vlentry.volumeId[2] && !(record[i].type & REFBK)) {
***************
*** 1259,1265 ****
  		    if (header.VolidHash[2][IdHash(vlentry.volumeId[2])] == 0)
  			header.VolidHash[2][IdHash(vlentry.volumeId[2])] = record[i].addr;
  		    else
! 			FixBad(i, header.VolidHash[2][IdHash(vlentry.volumeId[2])], BKH, record[i].addr, &vlentry);
  		}
  
  	    }
--- 1395,1401 ----
  		    if (header.VolidHash[2][IdHash(vlentry.volumeId[2])] == 0)
  			header.VolidHash[2][IdHash(vlentry.volumeId[2])] = record[i].addr;
  		    else
! 			FixBad(i, header.VolidHash[2][IdHash(vlentry.volumeId[2])], BKH, record[i].addr, &vlentry, IdHash(vlentry.volumeId[2]));
  		}
  
  	    }
***************
*** 1268,1273 ****
--- 1404,1419 ----
      if (fix) 
  	writeheader(&header);
  
+     close(fd);
+ 
+     if (fixed) {
+       fixed=0;
+       passes++;
+       if (passes < 20)
+ 	goto restart;
+       else
+ 	return 1;
+     }
      return 0;
  }
  
Index: openafs/src/vlserver/vlserver.c
diff -c openafs/src/vlserver/vlserver.c:1.18.2.12 openafs/src/vlserver/vlserver.c:1.18.2.13
*** openafs/src/vlserver/vlserver.c:1.18.2.12	Tue Apr  1 12:55:41 2008
--- openafs/src/vlserver/vlserver.c	Sun Aug 24 21:15:21 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vlserver.c,v 1.18.2.12 2008/04/01 16:55:41 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vlserver/vlserver.c,v 1.18.2.13 2008/08/25 01:15:21 shadow Exp $");
  
  #include <afs/stds.h>
  #include <sys/types.h>
***************
*** 63,72 ****
  static void *CheckSignal(void*);
  int LogLevel = 0;
  int smallMem = 0;
! int rxJumbograms = 1;		/* default is to send and receive jumbo grams */
  int rxMaxMTU = -1;
  afs_int32 rxBind = 0;
  int rxkadDisableDotCheck = 0;
  
  #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
  afs_uint32 SHostAddrs[ADDRSPERSITE];
--- 63,73 ----
  static void *CheckSignal(void*);
  int LogLevel = 0;
  int smallMem = 0;
! int rxJumbograms = 0;		/* default is to not send and receive jumbo grams */
  int rxMaxMTU = -1;
  afs_int32 rxBind = 0;
  int rxkadDisableDotCheck = 0;
+ int debuglevel = 0;
  
  #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
  afs_uint32 SHostAddrs[ADDRSPERSITE];
***************
*** 166,172 ****
      for (index = 1; index < argc; index++) {
  	if (strcmp(argv[index], "-noauth") == 0) {
  	    noAuth = 1;
- 
  	} else if (strcmp(argv[index], "-p") == 0) {
  	    lwps = atoi(argv[++index]);
  	    if (lwps > MAXLWP) {
--- 167,172 ----
***************
*** 174,183 ****
  		       lwps, MAXLWP);
  		lwps = MAXLWP;
  	    }
! 
  	} else if (strcmp(argv[index], "-nojumbo") == 0) {
  	    rxJumbograms = 0;
! 
  	} else if (strcmp(argv[index], "-rxbind") == 0) {
  	    rxBind = 1;
  	} else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
--- 174,190 ----
  		       lwps, MAXLWP);
  		lwps = MAXLWP;
  	    }
! 	} else if (strcmp(argv[index], "-d") == 0) {
! 	    if ((index + 1) >= argc) {
! 		fprintf(stderr, "missing argument for -d\n"); 
! 		return -1; 
! 	    }
! 	    debuglevel = atoi(argv[++index]);
! 	    LogLevel = debuglevel;
  	} else if (strcmp(argv[index], "-nojumbo") == 0) {
  	    rxJumbograms = 0;
! 	} else if (strcmp(argv[index], "-jumbo") == 0) {
! 	    rxJumbograms = 1;
  	} else if (strcmp(argv[index], "-rxbind") == 0) {
  	    rxBind = 1;
  	} else if (strcmp(argv[index], "-allow-dotted-principals") == 0) {
***************
*** 249,262 ****
  #ifndef AFS_NT40_ENV
  	    printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
  		   "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
! 		   "[-auditlog <log path>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #else
  	    printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
  		   "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
! 		   "[-auditlog <log path>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #endif
--- 256,269 ----
  #ifndef AFS_NT40_ENV
  	    printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
  		   "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
! 		   "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #else
  	    printf("Usage: vlserver [-p <number of processes>] [-nojumbo] "
  		   "[-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
! 		   "[-auditlog <log path>] [-jumbo] [-d <debug level>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #endif
Index: openafs/src/vol/clone.c
diff -c openafs/src/vol/clone.c:1.17.2.6 openafs/src/vol/clone.c:1.17.2.7
*** openafs/src/vol/clone.c:1.17.2.6	Tue Oct 30 11:24:11 2007
--- openafs/src/vol/clone.c	Sat Aug 16 15:15:48 2008
***************
*** 19,25 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/clone.c,v 1.17.2.6 2007/10/30 15:24:11 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
--- 19,25 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/clone.c,v 1.17.2.7 2008/08/16 19:15:48 shadow Exp $");
  
  #include <sys/types.h>
  #include <stdio.h>
***************
*** 175,181 ****
  
      struct VnodeClassInfo *vcp = &VnodeClassInfo[class];
      int ReadWriteOriginal = VolumeWriteable(rwvp);
-     struct DiskPartition *partition = rwvp->partition;
      Device device = rwvp->device;
  
      /* Open the RW volume's index file and seek to beginning */
--- 175,180 ----
Index: openafs/src/vol/fssync.h
diff -c openafs/src/vol/fssync.h:1.4.2.1 openafs/src/vol/fssync.h:1.4.2.2
*** openafs/src/vol/fssync.h:1.4.2.1	Sat Jun 23 09:46:53 2007
--- openafs/src/vol/fssync.h	Mon Jul 28 08:59:20 2008
***************
*** 33,41 ****
  /* Reasons (these could be communicated to venus or converted to messages) */
  
  #define FSYNC_WHATEVER		0	/* XXXX */
! #define FSYNC_SALVAGE		1	/* volume is being salvaged */
  #define FSYNC_MOVE		2	/* volume is being moved */
  #define FSYNC_OPERATOR		3	/* operator forced volume offline */
  
  
  /* Replies (1 byte) */
--- 33,42 ----
  /* Reasons (these could be communicated to venus or converted to messages) */
  
  #define FSYNC_WHATEVER		0	/* XXXX */
! #define FSYNC_READONLY		1	/* volume is readonly */
  #define FSYNC_MOVE		2	/* volume is being moved */
  #define FSYNC_OPERATOR		3	/* operator forced volume offline */
+ #define FSYNC_SALVAGE		4	/* volume is being salvaged */
  
  
  /* Replies (1 byte) */
Index: openafs/src/vol/listinodes.c
diff -c openafs/src/vol/listinodes.c:1.13.2.6 openafs/src/vol/listinodes.c:1.13.2.7
*** openafs/src/vol/listinodes.c:1.13.2.6	Tue Nov 13 17:15:34 2007
--- openafs/src/vol/listinodes.c	Sat Aug 16 15:15:48 2008
***************
*** 23,29 ****
  #include <string.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.13.2.6 2007/11/13 22:15:34 shadow Exp $");
  
  #ifndef AFS_NAMEI_ENV
  #if defined(AFS_LINUX20_ENV) || defined(AFS_SUN4_ENV)
--- 23,29 ----
  #include <string.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.13.2.7 2008/08/16 19:15:48 shadow Exp $");
  
  #ifndef AFS_NAMEI_ENV
  #if defined(AFS_LINUX20_ENV) || defined(AFS_SUN4_ENV)
***************
*** 1651,1657 ****
      char *name;
      int fd, err, forcep, len, j, code;
      struct dirent *dp;
!     struct DiskPartition *partP;
      struct ViceInodeInfo info;
      struct VolumeDiskHeader h;
      IHandle_t *ih, *ih2;
--- 1651,1657 ----
      char *name;
      int fd, err, forcep, len, j, code;
      struct dirent *dp;
!     struct DiskPartition64 *partP;
      struct ViceInodeInfo info;
      struct VolumeDiskHeader h;
      IHandle_t *ih, *ih2;
Index: openafs/src/vol/namei_ops.c
diff -c openafs/src/vol/namei_ops.c:1.21.2.16 openafs/src/vol/namei_ops.c:1.21.2.17
*** openafs/src/vol/namei_ops.c:1.21.2.16	Mon Nov 26 16:21:57 2007
--- openafs/src/vol/namei_ops.c	Sat Aug 16 15:15:48 2008
***************
*** 13,19 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.16 2007/11/26 21:21:57 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
--- 13,19 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.17 2008/08/16 19:15:48 shadow Exp $");
  
  #ifdef AFS_NAMEI_ENV
  #include <stdio.h>
***************
*** 1563,1569 ****
      DIR *dirp;
      Inode ino;
      struct dirent *dp;
!     struct DiskPartition *partP;
      struct ViceInodeInfo info;
      struct VolumeDiskHeader h;
      char volname[20];
--- 1563,1569 ----
      DIR *dirp;
      Inode ino;
      struct dirent *dp;
!     struct DiskPartition64 *partP;
      struct ViceInodeInfo info;
      struct VolumeDiskHeader h;
      char volname[20];
Index: openafs/src/vol/partition.c
diff -c openafs/src/vol/partition.c:1.30.2.6 openafs/src/vol/partition.c:1.30.2.7
*** openafs/src/vol/partition.c:1.30.2.6	Thu Nov 29 16:40:09 2007
--- openafs/src/vol/partition.c	Sat Aug 16 15:15:49 2008
***************
*** 21,27 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/partition.c,v 1.30.2.6 2007/11/29 21:40:09 shadow Exp $");
  
  #include <ctype.h>
  #include <string.h>
--- 21,27 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/partition.c,v 1.30.2.7 2008/08/16 19:15:49 shadow Exp $");
  
  #include <ctype.h>
  #include <string.h>
***************
*** 180,186 ****
  /*@printflike@*/ extern void Log(const char *format, ...);
  
  int aixlow_water = 8;		/* default 8% */
! struct DiskPartition *DiskPartitionList;
  
  #ifdef AFS_SGI_XFS_IOPS_ENV
  /* Verify that the on disk XFS inodes on the partition are large enough to
--- 180,186 ----
  /*@printflike@*/ extern void Log(const char *format, ...);
  
  int aixlow_water = 8;		/* default 8% */
! struct DiskPartition64 *DiskPartitionList;
  
  #ifdef AFS_SGI_XFS_IOPS_ENV
  /* Verify that the on disk XFS inodes on the partition are large enough to
***************
*** 224,231 ****
  static void
  VInitPartition_r(char *path, char *devname, Device dev)
  {
!     struct DiskPartition *dp, *op;
!     dp = (struct DiskPartition *)malloc(sizeof(struct DiskPartition));
      /* Add it to the end, to preserve order when we print statistics */
      for (op = DiskPartitionList; op; op = op->next) {
  	if (!op->next)
--- 224,231 ----
  static void
  VInitPartition_r(char *path, char *devname, Device dev)
  {
!     struct DiskPartition64 *dp, *op;
!     dp = (struct DiskPartition64 *)malloc(sizeof(struct DiskPartition64));
      /* Add it to the end, to preserve order when we print statistics */
      for (op = DiskPartitionList; op; op = op->next) {
  	if (!op->next)
***************
*** 710,716 ****
  int
  VAttachPartitions(void)
  {
!     struct DiskPartition *partP, *prevP, *nextP;
      struct vpt_iter iter;
      struct vptab entry;
  
--- 710,716 ----
  int
  VAttachPartitions(void)
  {
!     struct DiskPartition64 *partP, *prevP, *nextP;
      struct vpt_iter iter;
      struct vptab entry;
  
***************
*** 811,817 ****
   * is required. The canonical name is still in part->name.
   */
  char *
! VPartitionPath(struct DiskPartition *part)
  {
  #ifdef AFS_NT40_ENV
      return part->devName;
--- 811,817 ----
   * is required. The canonical name is still in part->name.
   */
  char *
! VPartitionPath(struct DiskPartition64 *part)
  {
  #ifdef AFS_NT40_ENV
      return part->devName;
***************
*** 821,830 ****
  }
  
  /* get partition structure, abortp tells us if we should abort on failure */
! struct DiskPartition *
  VGetPartition_r(char *name, int abortp)
  {
!     register struct DiskPartition *dp;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
  	if (strcmp(dp->name, name) == 0)
  	    break;
--- 821,830 ----
  }
  
  /* get partition structure, abortp tells us if we should abort on failure */
! struct DiskPartition64 *
  VGetPartition_r(char *name, int abortp)
  {
!     register struct DiskPartition64 *dp;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
  	if (strcmp(dp->name, name) == 0)
  	    break;
***************
*** 834,843 ****
      return dp;
  }
  
! struct DiskPartition *
  VGetPartition(char *name, int abortp)
  {
!     struct DiskPartition *retVal;
      VOL_LOCK;
      retVal = VGetPartition_r(name, abortp);
      VOL_UNLOCK;
--- 834,843 ----
      return dp;
  }
  
! struct DiskPartition64 *
  VGetPartition(char *name, int abortp)
  {
!     struct DiskPartition64 *retVal;
      VOL_LOCK;
      retVal = VGetPartition_r(name, abortp);
      VOL_UNLOCK;
***************
*** 846,852 ****
  
  #ifdef AFS_NT40_ENV
  void
! VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
  {
      ULARGE_INTEGER free_user, total, free_total;
      int ufree, tot, tfree;
--- 846,852 ----
  
  #ifdef AFS_NT40_ENV
  void
! VSetPartitionDiskUsage_r(register struct DiskPartition64 *dp)
  {
      ULARGE_INTEGER free_user, total, free_total;
      int ufree, tot, tfree;
***************
*** 870,878 ****
  
  #else
  void
! VSetPartitionDiskUsage_r(register struct DiskPartition *dp)
  {
!     int fd, totalblks, free, used, availblks, bsize, code;
      int reserved;
  #ifdef afs_statvfs
      struct afs_statvfs statbuf;
--- 870,879 ----
  
  #else
  void
! VSetPartitionDiskUsage_r(register struct DiskPartition64 *dp)
  {
!     afs_int64 totalblks, free, used, availblks;
!     int fd, bsize, code;
      int reserved;
  #ifdef afs_statvfs
      struct afs_statvfs statbuf;
***************
*** 935,941 ****
  #endif /* AFS_NT40_ENV */
  
  void
! VSetPartitionDiskUsage(register struct DiskPartition *dp)
  {
      VOL_LOCK;
      VSetPartitionDiskUsage_r(dp);
--- 936,942 ----
  #endif /* AFS_NT40_ENV */
  
  void
! VSetPartitionDiskUsage(register struct DiskPartition64 *dp)
  {
      VOL_LOCK;
      VSetPartitionDiskUsage_r(dp);
***************
*** 945,951 ****
  void
  VResetDiskUsage_r(void)
  {
!     struct DiskPartition *dp;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
  	VSetPartitionDiskUsage_r(dp);
  #ifndef AFS_PTHREAD_ENV
--- 946,952 ----
  void
  VResetDiskUsage_r(void)
  {
!     struct DiskPartition64 *dp;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
  	VSetPartitionDiskUsage_r(dp);
  #ifndef AFS_PTHREAD_ENV
***************
*** 1034,1040 ****
  void
  VPrintDiskStats_r(void)
  {
!     struct DiskPartition *dp;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
  	Log("Partition %s: %d available 1K blocks (minfree=%d), ", dp->name,
  	    dp->totalUsable, dp->minFree);
--- 1035,1041 ----
  void
  VPrintDiskStats_r(void)
  {
!     struct DiskPartition64 *dp;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
  	Log("Partition %s: %d available 1K blocks (minfree=%d), ", dp->name,
  	    dp->totalUsable, dp->minFree);
***************
*** 1059,1065 ****
  void
  VLockPartition_r(char *name)
  {
!     struct DiskPartition *dp = VGetPartition_r(name, 0);
      OVERLAPPED lap;
  
      if (!dp)
--- 1060,1066 ----
  void
  VLockPartition_r(char *name)
  {
!     struct DiskPartition64 *dp = VGetPartition_r(name, 0);
      OVERLAPPED lap;
  
      if (!dp)
***************
*** 1084,1090 ****
  void
  VUnlockPartition_r(char *name)
  {
!     register struct DiskPartition *dp = VGetPartition_r(name, 0);
      OVERLAPPED lap;
  
      if (!dp)
--- 1085,1091 ----
  void
  VUnlockPartition_r(char *name)
  {
!     register struct DiskPartition64 *dp = VGetPartition_r(name, 0);
      OVERLAPPED lap;
  
      if (!dp)
***************
*** 1107,1113 ****
  void
  VLockPartition_r(char *name)
  {
!     register struct DiskPartition *dp = VGetPartition_r(name, 0);
      char *partitionName;
      int retries, code;
      struct timeval pausing;
--- 1108,1114 ----
  void
  VLockPartition_r(char *name)
  {
!     register struct DiskPartition64 *dp = VGetPartition_r(name, 0);
      char *partitionName;
      int retries, code;
      struct timeval pausing;
***************
*** 1210,1216 ****
  void
  VUnlockPartition_r(char *name)
  {
!     register struct DiskPartition *dp = VGetPartition_r(name, 0);
      if (!dp)
  	return;			/* no partition, will fail later */
      close(dp->lock_fd);
--- 1211,1217 ----
  void
  VUnlockPartition_r(char *name)
  {
!     register struct DiskPartition64 *dp = VGetPartition_r(name, 0);
      if (!dp)
  	return;			/* no partition, will fail later */
      close(dp->lock_fd);
Index: openafs/src/vol/partition.h
diff -c openafs/src/vol/partition.h:1.9 openafs/src/vol/partition.h:1.9.2.1
*** openafs/src/vol/partition.h:1.9	Fri Aug  8 16:40:45 2003
--- openafs/src/vol/partition.h	Sat Aug 16 15:15:49 2008
***************
*** 48,61 ****
   * variant for VGetPartition as well. Also, the VolPartitionInfo RPC does
   * a swap before sending the data out on the wire.
   */
! struct DiskPartition {
!     struct DiskPartition *next;
      char *name;			/* Mounted partition name */
      char *devName;		/* Device mounted on */
      Device device;		/* device number */
      int lock_fd;		/* File descriptor of this partition if locked; otherwise -1;
  				 * Not used by the file server */
!     int free;			/* Total number of blocks (1K) presumed
  				 * available on this partition (accounting
  				 * for the minfree parameter for the
  				 * partition).  This is adjusted
--- 48,61 ----
   * variant for VGetPartition as well. Also, the VolPartitionInfo RPC does
   * a swap before sending the data out on the wire.
   */
! struct DiskPartition64 {
!     struct DiskPartition64 *next;
      char *name;			/* Mounted partition name */
      char *devName;		/* Device mounted on */
      Device device;		/* device number */
      int lock_fd;		/* File descriptor of this partition if locked; otherwise -1;
  				 * Not used by the file server */
!     afs_int64 free;			/* Total number of blocks (1K) presumed
  				 * available on this partition (accounting
  				 * for the minfree parameter for the
  				 * partition).  This is adjusted
***************
*** 65,71 ****
  				 * this is recomputed.  This number can
  				 * be negative, if the partition starts
  				 * out too full */
!     int totalUsable;		/* Total number of blocks available on this
  				 * partition, taking into account the minfree
  				 * parameter for the partition (see the
  				 * 4.2bsd command tunefs, but note that the
--- 65,71 ----
  				 * this is recomputed.  This number can
  				 * be negative, if the partition starts
  				 * out too full */
!     afs_int64 totalUsable;		/* Total number of blocks available on this
  				 * partition, taking into account the minfree
  				 * parameter for the partition (see the
  				 * 4.2bsd command tunefs, but note that the
***************
*** 73,82 ****
  				 * is not reread--does not apply here.  The
  				 * superblock is re-read periodically by
  				 * VSetPartitionDiskUsage().) */
!     int minFree;		/* Number blocks to be kept free, as last read
  				 * from the superblock */
      int flags;
!     int f_files;		/* total number of files in this partition */
  };
  #define	PART_DONTUPDATE	1
  #define PART_DUPLICATE  2	/* NT - used if we find more than one partition 
--- 73,82 ----
  				 * is not reread--does not apply here.  The
  				 * superblock is re-read periodically by
  				 * VSetPartitionDiskUsage().) */
!     afs_int64 minFree;		/* Number blocks to be kept free, as last read
  				 * from the superblock */
      int flags;
!     afs_int64 f_files;		/* total number of files in this partition */
  };
  #define	PART_DONTUPDATE	1
  #define PART_DUPLICATE  2	/* NT - used if we find more than one partition 
***************
*** 92,99 ****
  
  struct Volume;			/* Potentially forward definition */
  
! extern struct DiskPartition *DiskPartitionList;
! extern struct DiskPartition *VGetPartition();
  extern int VAttachPartitions(void);
  extern void VLockPartition(char *name);
  extern void VLockPartition_r(char *name);
--- 92,99 ----
  
  struct Volume;			/* Potentially forward definition */
  
! extern struct DiskPartition64 *DiskPartitionList;
! extern struct DiskPartition64 *VGetPartition();
  extern int VAttachPartitions(void);
  extern void VLockPartition(char *name);
  extern void VLockPartition_r(char *name);
***************
*** 101,109 ****
  extern void VUnlockPartition_r(char *name);
  extern void VResetDiskUsage(void);
  extern void VResetDiskUsage_r(void);
! extern void VSetPartitionDiskUsage(register struct DiskPartition *dp);
! extern void VSetPartitionDiskUsage_r(register struct DiskPartition *dp);
! extern char *VPartitionPath(struct DiskPartition *p);
  extern void VAdjustDiskUsage(Error * ec, struct Volume *vp,
  			     afs_sfsize_t blocks, afs_sfsize_t checkBlocks);
  extern int VDiskUsage(struct Volume *vp, afs_sfsize_t blocks);
--- 101,109 ----
  extern void VUnlockPartition_r(char *name);
  extern void VResetDiskUsage(void);
  extern void VResetDiskUsage_r(void);
! extern void VSetPartitionDiskUsage(register struct DiskPartition64 *dp);
! extern void VSetPartitionDiskUsage_r(register struct DiskPartition64 *dp);
! extern char *VPartitionPath(struct DiskPartition64 *p);
  extern void VAdjustDiskUsage(Error * ec, struct Volume *vp,
  			     afs_sfsize_t blocks, afs_sfsize_t checkBlocks);
  extern int VDiskUsage(struct Volume *vp, afs_sfsize_t blocks);
Index: openafs/src/vol/purge.c
diff -c openafs/src/vol/purge.c:1.9.2.3 openafs/src/vol/purge.c:1.9.2.4
*** openafs/src/vol/purge.c:1.9.2.3	Tue Oct 30 11:24:11 2007
--- openafs/src/vol/purge.c	Sat Aug 16 15:15:49 2008
***************
*** 17,23 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/purge.c,v 1.9.2.3 2007/10/30 15:24:11 shadow Exp $");
  
  #include <stdio.h>
  #ifdef AFS_NT40_ENV
--- 17,23 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/purge.c,v 1.9.2.4 2008/08/16 19:15:49 shadow Exp $");
  
  #include <stdio.h>
  #ifdef AFS_NT40_ENV
***************
*** 58,64 ****
  void
  VPurgeVolume(Error * ec, Volume * vp)
  {
!     struct DiskPartition *tpartp = vp->partition;
      char purgePath[MAXPATHLEN];
  
      /* N.B.  it's important here to use the partition pointed to by the
--- 58,64 ----
  void
  VPurgeVolume(Error * ec, Volume * vp)
  {
!     struct DiskPartition64 *tpartp = vp->partition;
      char purgePath[MAXPATHLEN];
  
      /* N.B.  it's important here to use the partition pointed to by the
Index: openafs/src/vol/vol-info.c
diff -c openafs/src/vol/vol-info.c:1.18.2.4 openafs/src/vol/vol-info.c:1.18.2.5
*** openafs/src/vol/vol-info.c:1.18.2.4	Wed Oct 31 00:13:51 2007
--- openafs/src/vol/vol-info.c	Sat Aug 16 15:15:49 2008
***************
*** 18,24 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vol-info.c,v 1.18.2.4 2007/10/31 04:13:51 shadow Exp $");
  
  #include <ctype.h>
  #include <errno.h>
--- 18,24 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vol-info.c,v 1.18.2.5 2008/08/16 19:15:49 shadow Exp $");
  
  #include <ctype.h>
  #include <errno.h>
***************
*** 87,96 ****
  /* Forward Declarations */
  void PrintHeader(register Volume * vp);
  void HandleAllPart(void);
! void HandlePart(struct DiskPartition *partP);
! void HandleVolume(struct DiskPartition *partP, char *name);
! struct DiskPartition *FindCurrentPartition(void);
! Volume *AttachVolume(struct DiskPartition *dp, char *volname,
  		     register struct VolumeHeader *header);
  #if defined(AFS_NAMEI_ENV)
  void PrintVnode(int offset, VnodeDiskObject * vnode, VnodeId vnodeNumber,
--- 87,96 ----
  /* Forward Declarations */
  void PrintHeader(register Volume * vp);
  void HandleAllPart(void);
! void HandlePart(struct DiskPartition64 *partP);
! void HandleVolume(struct DiskPartition64 *partP, char *name);
! struct DiskPartition64 *FindCurrentPartition(void);
! Volume *AttachVolume(struct DiskPartition64 *dp, char *volname,
  		     register struct VolumeHeader *header);
  #if defined(AFS_NAMEI_ENV)
  void PrintVnode(int offset, VnodeDiskObject * vnode, VnodeId vnodeNumber,
***************
*** 169,175 ****
  
  
  Volume *
! AttachVolume(struct DiskPartition * dp, char *volname,
  	     register struct VolumeHeader * header)
  {
      register Volume *vp;
--- 169,175 ----
  
  
  Volume *
! AttachVolume(struct DiskPartition64 * dp, char *volname,
  	     register struct VolumeHeader * header)
  {
      register Volume *vp;
***************
*** 223,229 ****
      int err = 0;
      int volumeId = 0;
      char *partName = 0;
!     struct DiskPartition *partP = NULL;
  
  
  #ifndef AFS_NT40_ENV
--- 223,229 ----
      int err = 0;
      int volumeId = 0;
      char *partName = 0;
!     struct DiskPartition64 *partP = NULL;
  
  
  #ifndef AFS_NT40_ENV
***************
*** 333,343 ****
  
  #ifdef AFS_NT40_ENV
  #include <direct.h>
! struct DiskPartition *
  FindCurrentPartition()
  {
      int dr = _getdrive();
!     struct DiskPartition *dp;
  
      dr--;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
--- 333,343 ----
  
  #ifdef AFS_NT40_ENV
  #include <direct.h>
! struct DiskPartition64 *
  FindCurrentPartition()
  {
      int dr = _getdrive();
!     struct DiskPartition64 *dp;
  
      dr--;
      for (dp = DiskPartitionList; dp; dp = dp->next) {
***************
*** 350,362 ****
      return dp;
  }
  #else
! struct DiskPartition *
  FindCurrentPartition()
  {
      char partName[1024];
      char tmp = '\0';
      char *p;
!     struct DiskPartition *dp;
  
      if (!getcwd(partName, 1023)) {
  	perror("pwd");
--- 350,362 ----
      return dp;
  }
  #else
! struct DiskPartition64 *
  FindCurrentPartition()
  {
      char partName[1024];
      char tmp = '\0';
      char *p;
!     struct DiskPartition64 *dp;
  
      if (!getcwd(partName, 1023)) {
  	perror("pwd");
***************
*** 380,386 ****
  void
  HandleAllPart(void)
  {
!     struct DiskPartition *partP;
  
  
      for (partP = DiskPartitionList; partP; partP = partP->next) {
--- 380,386 ----
  void
  HandleAllPart(void)
  {
!     struct DiskPartition64 *partP;
  
  
      for (partP = DiskPartitionList; partP; partP = partP->next) {
***************
*** 400,406 ****
  
  
  void
! HandlePart(struct DiskPartition *partP)
  {
      int nvols = 0;
      DIR *dirp;
--- 400,406 ----
  
  
  void
! HandlePart(struct DiskPartition64 *partP)
  {
      int nvols = 0;
      DIR *dirp;
***************
*** 445,451 ****
  
  
  void
! HandleVolume(struct DiskPartition *dp, char *name)
  {
      struct VolumeHeader header;
      struct VolumeDiskHeader diskHeader;
--- 445,451 ----
  
  
  void
! HandleVolume(struct DiskPartition64 *dp, char *name)
  {
      struct VolumeHeader header;
      struct VolumeDiskHeader diskHeader;
Index: openafs/src/vol/vol-salvage.c
diff -c openafs/src/vol/vol-salvage.c:1.41.2.14 openafs/src/vol/vol-salvage.c:1.41.2.18
*** openafs/src/vol/vol-salvage.c:1.41.2.14	Mon Nov 26 16:21:57 2007
--- openafs/src/vol/vol-salvage.c	Sat Aug 16 15:15:49 2008
***************
*** 92,98 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.14 2007/11/26 21:21:57 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
--- 92,98 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.18 2008/08/16 19:15:49 shadow Exp $");
  
  #include <stdlib.h>
  #include <stdio.h>
***************
*** 267,273 ****
  char *fileSysPathName;		/* NT needs this to make name pretty in log. */
  IHandle_t *VGLinkH;		/* Link handle for current volume group. */
  int VGLinkH_cnt;		/* # of references to lnk handle. */
! struct DiskPartition *fileSysPartition;	/* Partition  being salvaged */
  #ifndef AFS_NT40_ENV
  char *fileSysDeviceName;	/* The block device where the file system
  				 * being salvaged was mounted */
--- 267,273 ----
  char *fileSysPathName;		/* NT needs this to make name pretty in log. */
  IHandle_t *VGLinkH;		/* Link handle for current volume group. */
  int VGLinkH_cnt;		/* # of references to lnk handle. */
! struct DiskPartition64 *fileSysPartition;	/* Partition  being salvaged */
  #ifndef AFS_NT40_ENV
  char *fileSysDeviceName;	/* The block device where the file system
  				 * being salvaged was mounted */
***************
*** 449,457 ****
  void SalvageDir(char *name, VolumeId rwVid, struct VnodeInfo *dirVnodeInfo,
  		IHandle_t * alinkH, int i, struct DirSummary *rootdir,
  		int *rootdirfound);
! void SalvageFileSysParallel(struct DiskPartition *partP);
! void SalvageFileSys(struct DiskPartition *partP, VolumeId singleVolumeNumber);
! void SalvageFileSys1(struct DiskPartition *partP,
  		     VolumeId singleVolumeNumber);
  int SalvageHeader(register struct stuff *sp, struct InodeSummary *isp,
  		  int check, int *deleteMe);
--- 449,457 ----
  void SalvageDir(char *name, VolumeId rwVid, struct VnodeInfo *dirVnodeInfo,
  		IHandle_t * alinkH, int i, struct DirSummary *rootdir,
  		int *rootdirfound);
! void SalvageFileSysParallel(struct DiskPartition64 *partP);
! void SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber);
! void SalvageFileSys1(struct DiskPartition64 *partP,
  		     VolumeId singleVolumeNumber);
  int SalvageHeader(register struct stuff *sp, struct InodeSummary *isp,
  		  int check, int *deleteMe);
***************
*** 507,513 ****
      register struct cmd_item *ti;
      char pname[100], *temp;
      afs_int32 seenpart = 0, seenvol = 0, vid = 0, seenany = 0;
!     struct DiskPartition *partP;
  
  #ifdef AFS_SGI_VNODE_GLUE
      if (afs_init_kernel_config(-1) < 0) {
--- 507,513 ----
      register struct cmd_item *ti;
      char pname[100], *temp;
      afs_int32 seenpart = 0, seenvol = 0, vid = 0, seenany = 0;
!     struct DiskPartition64 *partP;
  
  #ifdef AFS_SGI_VNODE_GLUE
      if (afs_init_kernel_config(-1) < 0) {
***************
*** 954,960 ****
  #define HDSTR "\\Device\\Harddisk"
  #define HDLEN  (sizeof(HDSTR)-1)	/* Length of "\Device\Harddisk" */
  int
! SameDisk(struct DiskPartition *p1, struct DiskPartition *p2)
  {
  #define RES_LEN 256
      char res[RES_LEN];
--- 954,960 ----
  #define HDSTR "\\Device\\Harddisk"
  #define HDLEN  (sizeof(HDSTR)-1)	/* Length of "\Device\Harddisk" */
  int
! SameDisk(struct DiskPartition64 *p1, struct DiskPartition64 *p2)
  {
  #define RES_LEN 256
      char res[RES_LEN];
***************
*** 995,1004 ****
   * PartsPerDisk are on the same disk.
   */
  void
! SalvageFileSysParallel(struct DiskPartition *partP)
  {
      struct job {
! 	struct DiskPartition *partP;
  	int pid;		/* Pid for this job */
  	int jobnumb;		/* Log file job number */
  	struct job *nextjob;	/* Next partition on disk to salvage */
--- 995,1004 ----
   * PartsPerDisk are on the same disk.
   */
  void
! SalvageFileSysParallel(struct DiskPartition64 *partP)
  {
      struct job {
! 	struct DiskPartition64 *partP;
  	int pid;		/* Pid for this job */
  	int jobnumb;		/* Log file job number */
  	struct job *nextjob;	/* Next partition on disk to salvage */
***************
*** 1186,1192 ****
  
  
  void
! SalvageFileSys(struct DiskPartition *partP, VolumeId singleVolumeNumber)
  {
      if (!canfork || debug || Fork() == 0) {
  	SalvageFileSys1(partP, singleVolumeNumber);
--- 1186,1192 ----
  
  
  void
! SalvageFileSys(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
  {
      if (!canfork || debug || Fork() == 0) {
  	SalvageFileSys1(partP, singleVolumeNumber);
***************
*** 1218,1224 ****
  }
  
  void
! SalvageFileSys1(struct DiskPartition *partP, VolumeId singleVolumeNumber)
  {
      char *name, *tdir;
      char inodeListPath[256];
--- 1218,1224 ----
  }
  
  void
! SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
  {
      char *name, *tdir;
      char inodeListPath[256];
***************
*** 1788,1794 ****
  			|| vsp->header.parent == singleVolumeNumber)) {
  		    (void)afs_snprintf(nameShouldBe, sizeof nameShouldBe,
  				       VFORMAT, vsp->header.id);
! 		    if (singleVolumeNumber)
  			AskOffline(vsp->header.id);
  		    if (strcmp(nameShouldBe, dp->d_name)) {
  			if (!Showmode)
--- 1788,1795 ----
  			|| vsp->header.parent == singleVolumeNumber)) {
  		    (void)afs_snprintf(nameShouldBe, sizeof nameShouldBe,
  				       VFORMAT, vsp->header.id);
! 		    if (singleVolumeNumber
! 			&& vsp->header.id != singleVolumeNumber)
  			AskOffline(vsp->header.id);
  		    if (strcmp(nameShouldBe, dp->d_name)) {
  			if (!Showmode)
***************
*** 2812,2821 ****
--- 2813,2824 ----
      struct VnodeClassInfo *vcp = &VnodeClassInfo[vLarge];
      Inode oldinode, newinode;
      DirHandle newdir;
+     FdHandle_t *fdP;
      afs_int32 code;
      afs_sfsize_t lcode;
      afs_int32 parentUnique = 1;
      struct VnodeEssence *vnodeEssence;
+     afs_fsize_t length;
  
      if (Testing)
  	return;
***************
*** 2870,2876 ****
      }
      vnode.cloned = 0;
      VNDISK_SET_INO(&vnode, newinode);
!     VNDISK_SET_LEN(&vnode, Length(&newdir));
      lcode =
  	IH_IWRITE(vnodeInfo[vLarge].handle,
  		  vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
--- 2873,2880 ----
      }
      vnode.cloned = 0;
      VNDISK_SET_INO(&vnode, newinode);
!     length = Length(&newdir);
!     VNDISK_SET_LEN(&vnode, length);
      lcode =
  	IH_IWRITE(vnodeInfo[vLarge].handle,
  		  vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode,
***************
*** 2887,2892 ****
--- 2891,2900 ----
  #else
      vnodeInfo[vLarge].handle->ih_synced = 1;
  #endif
+     /* make sure old directory file is really closed */
+     fdP = IH_OPEN(dir->dirHandle.dirh_handle);
+     FDH_REALLYCLOSE(fdP);
+     
      code = IH_DEC(dir->ds_linkH, oldinode, dir->rwVid);
      assert(code == 0);
      dir->dirHandle = newdir;
***************
*** 3036,3062 ****
      } else {
  	if (ShowSuid && (vnodeEssence->modeBits & 06000))
  	    Log("FOUND suid/sgid file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
! 	if (ShowMounts && (vnodeEssence->type == vSymlink)
  	    && !(vnodeEssence->modeBits & 0111)) {
  	    int code, size;
! 	    char buf[1024];
  	    IHandle_t *ihP;
  	    FdHandle_t *fdP;
  
  	    IH_INIT(ihP, fileSysDevice, dir->dirHandle.dirh_handle->ih_vid,
  		    vnodeEssence->InodeNumber);
  	    fdP = IH_OPEN(ihP);
! 	    assert(fdP != NULL);
  	    size = FDH_SIZE(fdP);
! 	    assert(size != -1);
! 	    memset(buf, 0, 1024);
  	    if (size > 1024)
  		size = 1024;
  	    code = FDH_READ(fdP, buf, size);
! 	    assert(code == size);
! 	    Log("In volume %u (%s) found mountpoint %s/%s to '%s'\n",
! 		dir->dirHandle.dirh_handle->ih_vid, dir->vname,
! 		dir->name ? dir->name : "??", name, buf);
  	    FDH_REALLYCLOSE(fdP);
  	    IH_RELEASE(ihP);
  	}
--- 3044,3090 ----
      } else {
  	if (ShowSuid && (vnodeEssence->modeBits & 06000))
  	    Log("FOUND suid/sgid file: %s/%s (%u.%u %05o) author %u (vnode %u dir %u)\n", dir->name ? dir->name : "??", name, vnodeEssence->owner, vnodeEssence->group, vnodeEssence->modeBits, vnodeEssence->author, vnodeNumber, dir->vnodeNumber);
! 	if (/* ShowMounts && */ (vnodeEssence->type == vSymlink)
  	    && !(vnodeEssence->modeBits & 0111)) {
  	    int code, size;
! 	    char buf[1025];
  	    IHandle_t *ihP;
  	    FdHandle_t *fdP;
  
  	    IH_INIT(ihP, fileSysDevice, dir->dirHandle.dirh_handle->ih_vid,
  		    vnodeEssence->InodeNumber);
  	    fdP = IH_OPEN(ihP);
! 	    if (fdP == NULL) {
! 		Log("ERROR %s could not open mount point vnode %u\n", dir->vname, vnodeNumber);
! 		IH_RELEASE(ihP);
! 		return;
! 	    }
  	    size = FDH_SIZE(fdP);
! 	    if (size < 0) {
! 		Log("ERROR %s mount point has invalid size %d, vnode %u\n", dir->vname, size, vnodeNumber);
! 		FDH_REALLYCLOSE(fdP);
! 		IH_RELEASE(ihP);
! 		return;
! 	    }
! 	
  	    if (size > 1024)
  		size = 1024;
  	    code = FDH_READ(fdP, buf, size);
! 	    if (code == size) {
! 		buf[size] = '\0';
! 		if ( (*buf != '#' && *buf != '%') || buf[strlen(buf)-1] != '.' ) {
! 		    Log("Volume %u (%s) mount point %s/%s to '%s' invalid, %s to symbolic link\n",
! 			dir->dirHandle.dirh_handle->ih_vid, dir->vname, dir->name ? dir->name : "??", name, buf,
! 			Testing ? "would convert" : "converted");
! 		    vnodeEssence->modeBits |= 0111;
! 		    vnodeEssence->changed = 1;
! 		} else if (ShowMounts) Log("In volume %u (%s) found mountpoint %s/%s to '%s'\n",
! 		    dir->dirHandle.dirh_handle->ih_vid, dir->vname,
! 		    dir->name ? dir->name : "??", name, buf);
! 	    } else {
! 		Log("Volume %s cound not read mount point vnode %u size %d code %d\n",
! 		    dir->vname, vnodeNumber, size, code);
! 	    }
  	    FDH_REALLYCLOSE(fdP);
  	    IH_RELEASE(ihP);
  	}
***************
*** 3532,3537 ****
--- 3560,3567 ----
  		    if (!Showmode) {
  			Log("Vnode %u: link count incorrect (was %d, %s %d)\n", vnodeNumber, oldCount, (Testing ? "would have changed to" : "now"), vnode.linkCount);
  		    }
+ 		} else {
+ 		    vnode.modeBits = vnp->modeBits;
  		}
  
  		vnode.dataVersion++;
Index: openafs/src/vol/volume.c
diff -c openafs/src/vol/volume.c:1.35.2.10 openafs/src/vol/volume.c:1.35.2.13
*** openafs/src/vol/volume.c:1.35.2.10	Sat Jun 23 09:46:53 2007
--- openafs/src/vol/volume.c	Thu Sep  4 14:19:31 2008
***************
*** 20,26 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/volume.c,v 1.35.2.10 2007/06/23 13:46:53 shadow Exp $");
  
  #include <rx/xdr.h>
  #include <afs/afsint.h>
--- 20,26 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/volume.c,v 1.35.2.13 2008/09/04 18:19:31 shadow Exp $");
  
  #include <rx/xdr.h>
  #include <afs/afsint.h>
***************
*** 164,170 ****
  /* Forward declarations */
  static Volume *attach2(Error * ec, char *path,
  		       register struct VolumeHeader *header,
! 		       struct DiskPartition *partp, int isbusy);
  static void FreeVolume(Volume * vp);
  static void VScanUpdateList(void);
  static void InitLRU(int howMany);
--- 164,170 ----
  /* Forward declarations */
  static Volume *attach2(Error * ec, char *path,
  		       register struct VolumeHeader *header,
! 		       struct DiskPartition64 *partp, int isbusy);
  static void FreeVolume(Volume * vp);
  static void VScanUpdateList(void);
  static void InitLRU(int howMany);
***************
*** 176,185 ****
  static int VHold(Volume * vp);
  static int VHold_r(Volume * vp);
  static void GetBitmap(Error * ec, Volume * vp, VnodeClass class);
- static void GetVolumePath(Error * ec, VolId volumeId, char **partitionp,
- 			  char **namep);
  static void VReleaseVolumeHandles_r(Volume * vp);
  static void VCloseVolumeHandles_r(Volume * vp);
  
  int LogLevel;			/* Vice loglevel--not defined as extern so that it will be
  				 * defined when not linked with vice, XXXX */
--- 176,184 ----
  static int VHold(Volume * vp);
  static int VHold_r(Volume * vp);
  static void GetBitmap(Error * ec, Volume * vp, VnodeClass class);
  static void VReleaseVolumeHandles_r(Volume * vp);
  static void VCloseVolumeHandles_r(Volume * vp);
+ void VGetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep);
  
  int LogLevel;			/* Vice loglevel--not defined as extern so that it will be
  				 * defined when not linked with vice, XXXX */
***************
*** 213,219 ****
  #include "rx/rx_queue.h"
  typedef struct diskpartition_queue_t {
      struct rx_queue queue;
!     struct DiskPartition * diskP;
  } diskpartition_queue_t;
  typedef struct vinitvolumepackage_thread_t {
      struct rx_queue queue;
--- 212,218 ----
  #include "rx/rx_queue.h"
  typedef struct diskpartition_queue_t {
      struct rx_queue queue;
!     struct DiskPartition64 * diskP;
  } diskpartition_queue_t;
  typedef struct vinitvolumepackage_thread_t {
      struct rx_queue queue;
***************
*** 300,306 ****
  	return -1;
  
      if (programType == fileServer) {
! 	struct DiskPartition *diskP;
  #ifdef AFS_PTHREAD_ENV
  	struct vinitvolumepackage_thread_t params;
  	struct diskpartition_queue_t * dpq;
--- 299,305 ----
  	return -1;
  
      if (programType == fileServer) {
! 	struct DiskPartition64 *diskP;
  #ifdef AFS_PTHREAD_ENV
  	struct vinitvolumepackage_thread_t params;
  	struct diskpartition_queue_t * dpq;
***************
*** 396,402 ****
  
      DIR *dirp;
      struct dirent *dp;
!     struct DiskPartition *diskP;
      struct vinitvolumepackage_thread_t * params;
      struct diskpartition_queue_t * dpq;
  
--- 395,401 ----
  
      DIR *dirp;
      struct dirent *dp;
!     struct DiskPartition64 *diskP;
      struct vinitvolumepackage_thread_t * params;
      struct diskpartition_queue_t * dpq;
  
***************
*** 697,703 ****
      struct afs_stat status;
      struct VolumeDiskHeader diskHeader;
      struct VolumeHeader iheader;
!     struct DiskPartition *partp;
      char path[64];
      int isbusy = 0;
      *ec = 0;
--- 696,702 ----
      struct afs_stat status;
      struct VolumeDiskHeader diskHeader;
      struct VolumeHeader iheader;
!     struct DiskPartition64 *partp;
      char path[64];
      int isbusy = 0;
      *ec = 0;
***************
*** 838,844 ****
  
  private Volume *
  attach2(Error * ec, char *path, register struct VolumeHeader * header,
! 	struct DiskPartition * partp, int isbusy)
  {
      register Volume *vp;
  
--- 837,843 ----
  
  private Volume *
  attach2(Error * ec, char *path, register struct VolumeHeader * header,
! 	struct DiskPartition64 * partp, int isbusy)
  {
      register Volume *vp;
  
***************
*** 1008,1014 ****
  VAttachVolume_r(Error * ec, VolumeId volumeId, int mode)
  {
      char *part, *name;
!     GetVolumePath(ec, volumeId, &part, &name);
      if (*ec) {
  	register Volume *vp;
  	Error error;
--- 1007,1013 ----
  VAttachVolume_r(Error * ec, VolumeId volumeId, int mode)
  {
      char *part, *name;
!     VGetVolumePath(ec, volumeId, &part, &name);
      if (*ec) {
  	register Volume *vp;
  	Error error;
***************
*** 1355,1361 ****
  VDetachVolume_r(Error * ec, Volume * vp)
  {
      VolumeId volume;
!     struct DiskPartition *tpartp;
      int notifyServer, useDone;
  
      *ec = 0;			/* always "succeeds" */
--- 1354,1360 ----
  VDetachVolume_r(Error * ec, Volume * vp)
  {
      VolumeId volume;
!     struct DiskPartition64 *tpartp;
      int notifyServer, useDone;
  
      *ec = 0;			/* always "succeeds" */
***************
*** 1670,1682 ****
  #endif /* BITMAP_LATER */
  }
  
! static void
! GetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep)
  {
      static char partition[VMAXPATHLEN], name[VMAXPATHLEN];
      char path[VMAXPATHLEN];
      int found = 0;
!     struct DiskPartition *dp;
  
      *ec = 0;
      name[0] = '/';
--- 1669,1681 ----
  #endif /* BITMAP_LATER */
  }
  
! void 
! VGetVolumePath(Error * ec, VolId volumeId, char **partitionp, char **namep)
  {
      static char partition[VMAXPATHLEN], name[VMAXPATHLEN];
      char path[VMAXPATHLEN];
      int found = 0;
!     struct DiskPartition64 *dp;
  
      *ec = 0;
      name[0] = '/';
Index: openafs/src/vol/volume.h
diff -c openafs/src/vol/volume.h:1.14.2.4 openafs/src/vol/volume.h:1.14.2.6
*** openafs/src/vol/volume.h:1.14.2.4	Sat Jun 23 09:46:53 2007
--- openafs/src/vol/volume.h	Thu Sep  4 14:17:23 2008
***************
*** 301,307 ****
      VolumeId hashid;		/* Volume number -- for hash table lookup */
      struct volHeader *header;	/* Cached disk data */
      Device device;		/* Unix device for the volume */
!     struct DiskPartition
       *partition;		/* Information about the Unix partition */
      struct vnodeIndex {
  	IHandle_t *handle;	/* Unix inode holding this index */
--- 301,307 ----
      VolumeId hashid;		/* Volume number -- for hash table lookup */
      struct volHeader *header;	/* Cached disk data */
      Device device;		/* Unix device for the volume */
!     struct DiskPartition64
       *partition;		/* Information about the Unix partition */
      struct vnodeIndex {
  	IHandle_t *handle;	/* Unix inode holding this index */
***************
*** 455,469 ****
  extern void VPrintCacheStats(void);
  extern void VReleaseVnodeFiles_r(Volume * vp);
  extern void VCloseVnodeFiles_r(Volume * vp);
! extern struct DiskPartition *VGetPartition(char *name, int abortp);
! extern struct DiskPartition *VGetPartition_r(char *name, int abortp);
  extern int VInitVolumePackage(ProgramType pt, int nLargeVnodes,
  			      int nSmallVnodes, int connect, int volcache);
  extern void DiskToVolumeHeader(VolumeHeader_t * h, VolumeDiskHeader_t * dh);
  extern void VolumeHeaderToDisk(VolumeDiskHeader_t * dh, VolumeHeader_t * h);
  extern void VTakeOffline_r(register Volume * vp);
  extern void VTakeOffline(register Volume * vp);
! 
  
  /* Naive formula relating number of file size to number of 1K blocks in file */
  /* Note:  we charge 1 block for 0 length files so the user can't store
--- 455,470 ----
  extern void VPrintCacheStats(void);
  extern void VReleaseVnodeFiles_r(Volume * vp);
  extern void VCloseVnodeFiles_r(Volume * vp);
! extern struct DiskPartition64 *VGetPartition(char *name, int abortp);
! extern struct DiskPartition64 *VGetPartition_r(char *name, int abortp);
  extern int VInitVolumePackage(ProgramType pt, int nLargeVnodes,
  			      int nSmallVnodes, int connect, int volcache);
  extern void DiskToVolumeHeader(VolumeHeader_t * h, VolumeDiskHeader_t * dh);
  extern void VolumeHeaderToDisk(VolumeDiskHeader_t * dh, VolumeHeader_t * h);
  extern void VTakeOffline_r(register Volume * vp);
  extern void VTakeOffline(register Volume * vp);
! extern void VGetVolumePath(Error * ec, VolId volumeId, char **partitionp,
! 			   char **namep);
  
  /* Naive formula relating number of file size to number of 1K blocks in file */
  /* Note:  we charge 1 block for 0 length files so the user can't store
Index: openafs/src/vol/vutil.c
diff -c openafs/src/vol/vutil.c:1.15.2.1 openafs/src/vol/vutil.c:1.15.2.3
*** openafs/src/vol/vutil.c:1.15.2.1	Wed Aug 25 03:14:19 2004
--- openafs/src/vol/vutil.c	Thu Sep  4 14:17:23 2008
***************
*** 18,24 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vutil.c,v 1.15.2.1 2004/08/25 07:14:19 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 18,24 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/vol/vutil.c,v 1.15.2.3 2008/09/04 18:17:23 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 123,133 ****
      int fd, i;
      char headerName[32], volumePath[64];
      Device device;
!     struct DiskPartition *partition;
      struct VolumeDiskHeader diskHeader;
      IHandle_t *handle;
      FdHandle_t *fdP;
      Inode nearInode = 0;
  
      *ec = 0;
      memset(&vol, 0, sizeof(vol));
--- 123,134 ----
      int fd, i;
      char headerName[32], volumePath[64];
      Device device;
!     struct DiskPartition64 *partition;
      struct VolumeDiskHeader diskHeader;
      IHandle_t *handle;
      FdHandle_t *fdP;
      Inode nearInode = 0;
+     char *part, *name;
  
      *ec = 0;
      memset(&vol, 0, sizeof(vol));
***************
*** 150,155 ****
--- 151,167 ----
      nearInodeHash(volumeId, nearInode);
      nearInode %= partition->f_files;
  #endif
+     VGetVolumePath(ec, vol.id, &part, &name);
+     if (*ec == VNOVOL || !strcmp(partition->name, part)) {
+ 	/* this case is ok */
+     } else {
+ 	/* return EXDEV if it's a clone to an alternate partition
+ 	 * otherwise assume it's a move */
+ 	if (vol.parentId != vol.id) {
+ 	    *ec = EXDEV;
+ 	    return NULL;
+ 	}
+     }
      VLockPartition_r(partname);
      memset(&tempHeader, 0, sizeof(tempHeader));
      tempHeader.stamp.magic = VOLUMEHEADERMAGIC;
Index: openafs/src/volser/NTMakefile
diff -c openafs/src/volser/NTMakefile:1.8.2.2 openafs/src/volser/NTMakefile:1.8.2.3
*** openafs/src/volser/NTMakefile:1.8.2.2	Mon Jul 31 17:51:22 2006
--- openafs/src/volser/NTMakefile	Sat Aug 16 15:56:25 2008
***************
*** 16,21 ****
--- 16,23 ----
  
  INCFILES = \
  	$(INCFILEDIR)\volser_prototypes.h \
+ 	$(INCFILEDIR)\vsutils_prototypes.h \
+ 	$(INCFILEDIR)\lockprocs_prototypes.h \
  	$(INCFILEDIR)\volser.h \
  	$(INCFILEDIR)\volint.h
  
Index: openafs/src/volser/dumpstuff.c
diff -c openafs/src/volser/dumpstuff.c:1.25.2.10 openafs/src/volser/dumpstuff.c:1.25.2.11
*** openafs/src/volser/dumpstuff.c:1.25.2.10	Mon Jan 21 09:11:20 2008
--- openafs/src/volser/dumpstuff.c	Sat Aug 16 15:15:49 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/dumpstuff.c,v 1.25.2.10 2008/01/21 14:11:20 shadow Exp $");
  
  #include <sys/types.h>
  #include <ctype.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/dumpstuff.c,v 1.25.2.11 2008/08/16 19:15:49 shadow Exp $");
  
  #include <sys/types.h>
  #include <ctype.h>
***************
*** 76,82 ****
      struct rx_call *call;	/* call to which to write, might be an array */
      int device;			/* dump device ID for volume */
      int parentId;		/* dump parent ID for volume */
!     struct DiskPartition *dumpPartition;	/* Dump partition. */
      struct rx_call **calls;	/* array of pointers to calls */
      int ncalls;			/* how many calls/codes in array */
      int *codes;			/* one return code for each call */
--- 76,82 ----
      struct rx_call *call;	/* call to which to write, might be an array */
      int device;			/* dump device ID for volume */
      int parentId;		/* dump parent ID for volume */
!     struct DiskPartition64 *dumpPartition;	/* Dump partition. */
      struct rx_call **calls;	/* array of pointers to calls */
      int ncalls;			/* how many calls/codes in array */
      int *codes;			/* one return code for each call */
Index: openafs/src/volser/lockprocs.c
diff -c openafs/src/volser/lockprocs.c:1.8.2.2 openafs/src/volser/lockprocs.c:1.8.2.3
*** openafs/src/volser/lockprocs.c:1.8.2.2	Mon Nov 26 16:21:57 2007
--- openafs/src/volser/lockprocs.c	Sat Aug 16 15:56:25 2008
***************
*** 18,24 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/lockprocs.c,v 1.8.2.2 2007/11/26 21:21:57 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
--- 18,24 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/lockprocs.c,v 1.8.2.3 2008/08/16 19:56:25 shadow Exp $");
  
  #include <sys/types.h>
  #ifdef AFS_NT40_ENV
***************
*** 37,51 ****
  #include "volser.h"
  #include "lockdata.h"
  
  /* Finds an index in VLDB entry that matches the volume type, server, and partition.
   * If type is zero, will match first index of ANY type (RW, BK, or RO).
   * If server is zero, will match first index of ANY server and partition 
   * Zero is a valid partition field.
   */
  int
! FindIndex(entry, server, part, type)
!      struct nvldbentry *entry;
!      afs_int32 server, part, type;
  {
      int e;
      afs_int32 error = 0;
--- 37,52 ----
  #include "volser.h"
  #include "lockdata.h"
  
+ #include <vsutils_prototypes.h>
+ #include <lockprocs_prototypes.h>
+ 
  /* Finds an index in VLDB entry that matches the volume type, server, and partition.
   * If type is zero, will match first index of ANY type (RW, BK, or RO).
   * If server is zero, will match first index of ANY server and partition 
   * Zero is a valid partition field.
   */
  int
! FindIndex(struct nvldbentry *entry, afs_int32 server, afs_int32 part, afs_int32 type)
  {
      int e;
      afs_int32 error = 0;
***************
*** 77,85 ****
  
  /* Changes the rw site only */
  void
! SetAValue(entry, oserver, opart, nserver, npart, type)
!      struct nvldbentry *entry;
!      afs_int32 oserver, opart, nserver, npart, type;
  {
      int e;
      afs_int32 error = 0;
--- 78,85 ----
  
  /* Changes the rw site only */
  void
! SetAValue(struct nvldbentry *entry, afs_int32 oserver, afs_int32 opart,
!           afs_int32 nserver, afs_int32 npart, afs_int32 type)
  {
      int e;
      afs_int32 error = 0;
***************
*** 103,128 ****
  
  /* Changes the RW site only */
  void
! Lp_SetRWValue(entry, oserver, opart, nserver, npart)
!      struct nvldbentry *entry;
!      afs_int32 oserver, opart, nserver, npart;
  {
      SetAValue(entry, oserver, opart, nserver, npart, ITSRWVOL);
  }
  
  /* Changes the RO site only */
  void
! Lp_SetROValue(entry, oserver, opart, nserver, npart)
!      struct nvldbentry *entry;
!      afs_int32 oserver, opart, nserver, npart;
  {
      SetAValue(entry, oserver, opart, nserver, npart, ITSROVOL);
  }
  
  /* Returns success if this server and partition matches the RW entry */
! Lp_Match(server, part, entry)
!      afs_int32 server, part;
!      struct nvldbentry *entry;
  {
      if (FindIndex(entry, server, part, ITSRWVOL) == -1)
  	return 0;
--- 103,126 ----
  
  /* Changes the RW site only */
  void
! Lp_SetRWValue(struct nvldbentry *entry, afs_int32 oserver, afs_int32 opart, 
!               afs_int32 nserver, afs_int32 npart)
  {
      SetAValue(entry, oserver, opart, nserver, npart, ITSRWVOL);
  }
  
  /* Changes the RO site only */
  void
! Lp_SetROValue(struct nvldbentry *entry, afs_int32 oserver, 
!               afs_int32 opart, afs_int32 nserver, afs_int32 npart)
  {
      SetAValue(entry, oserver, opart, nserver, npart, ITSROVOL);
  }
  
  /* Returns success if this server and partition matches the RW entry */
! int 
! Lp_Match(afs_int32 server, afs_int32 part,
!          struct nvldbentry *entry)
  {
      if (FindIndex(entry, server, part, ITSRWVOL) == -1)
  	return 0;
***************
*** 130,153 ****
  }
  
  /* Return the index of the RO entry (plus 1) if it exists, else return 0 */
! Lp_ROMatch(server, part, entry)
!      afs_int32 server, part;
!      struct nvldbentry *entry;
  {
      return (FindIndex(entry, server, part, ITSROVOL) + 1);
  }
  
  /* Return the index of the RW entry if it exists, else return -1 */
! Lp_GetRwIndex(entry)
!      struct nvldbentry *entry;
  {
      return (FindIndex(entry, 0, 0, ITSRWVOL));
  }
  
  /*initialize queue pointed by <ahead>*/
  void
! Lp_QInit(ahead)
!      struct qHead *ahead;
  {
      ahead->count = 0;
      ahead->next = NULL;
--- 128,149 ----
  }
  
  /* Return the index of the RO entry (plus 1) if it exists, else return 0 */
! int 
! Lp_ROMatch(afs_int32 server, afs_int32 part, struct nvldbentry *entry)
  {
      return (FindIndex(entry, server, part, ITSROVOL) + 1);
  }
  
  /* Return the index of the RW entry if it exists, else return -1 */
! int 
! Lp_GetRwIndex(struct nvldbentry *entry)
  {
      return (FindIndex(entry, 0, 0, ITSRWVOL));
  }
  
  /*initialize queue pointed by <ahead>*/
  void
! Lp_QInit(struct qHead *ahead)
  {
      ahead->count = 0;
      ahead->next = NULL;
***************
*** 155,163 ****
  
  /*add <elem> in front of queue <ahead> */
  void
! Lp_QAdd(ahead, elem)
!      struct qHead *ahead;
!      struct aqueue *elem;
  {
      struct aqueue *temp;
  
--- 151,157 ----
  
  /*add <elem> in front of queue <ahead> */
  void
! Lp_QAdd(struct qHead *ahead, struct aqueue *elem)
  {
      struct aqueue *temp;
  
***************
*** 173,183 ****
      }
  }
  
! Lp_QScan(ahead, id, success, elem)
!      struct qHead *ahead;
!      struct aqueue **elem;
!      afs_int32 id;
!      int *success;
  {
      struct aqueue *cptr;
  
--- 167,174 ----
      }
  }
  
! int 
! Lp_QScan(struct qHead *ahead, afs_int32 id, int *success, struct aqueue **elem)
  {
      struct aqueue *cptr;
  
***************
*** 197,206 ****
  /*return the element in the beginning of the queue <ahead>, free
  *the space used by that element . <success> indicates if enumeration was ok*/
  void
! Lp_QEnumerate(ahead, success, elem)
!      struct qHead *ahead;
!      struct aqueue *elem;
!      int *success;
  {
      int i;
      struct aqueue *temp;
--- 188,194 ----
  /*return the element in the beginning of the queue <ahead>, free
  *the space used by that element . <success> indicates if enumeration was ok*/
  void
! Lp_QEnumerate(struct qHead *ahead, int *success, struct aqueue *elem)
  {
      int i;
      struct aqueue *temp;
***************
*** 223,230 ****
  }
  
  void
! Lp_QTraverse(ahead)
!      struct qHead *ahead;
  {
      int count;
      struct aqueue *old, *new;
--- 211,217 ----
  }
  
  void
! Lp_QTraverse(struct qHead *ahead)
  {
      int count;
      struct aqueue *old, *new;
Index: openafs/src/volser/lockprocs_prototypes.h
diff -c /dev/null openafs/src/volser/lockprocs_prototypes.h:1.1.4.2
*** /dev/null	Tue Oct  7 22:25:14 2008
--- openafs/src/volser/lockprocs_prototypes.h	Mon Aug 18 13:23:40 2008
***************
*** 0 ****
--- 1,18 ----
+ #ifndef	_LOCKPROCS_PROTOTYPES_H
+ #define _LOCKPROCS_PROTOTYPES_H
+ extern int FindIndex(struct nvldbentry *entry, afs_int32 server, afs_int32 part, afs_int32 type);
+ extern void SetAValue(struct nvldbentry *entry, afs_int32 oserver, afs_int32 opart,
+           afs_int32 nserver, afs_int32 npart, afs_int32 type);
+ extern void Lp_SetRWValue(struct nvldbentry *entry, afs_int32 oserver, afs_int32 opart, 
+               afs_int32 nserver, afs_int32 npart);
+ extern void Lp_SetROValue(struct nvldbentry *entry, afs_int32 oserver, 
+               afs_int32 opart, afs_int32 nserver, afs_int32 npart);
+ extern int Lp_Match(afs_int32 server, afs_int32 part, struct nvldbentry *entry);
+ extern int Lp_ROMatch(afs_int32 server, afs_int32 part, struct nvldbentry *entry);
+ extern int Lp_GetRwIndex(struct nvldbentry *entry);
+ extern void Lp_QInit(struct qHead *ahead);
+ extern void Lp_QAdd(struct qHead *ahead, struct aqueue *elem);
+ extern int Lp_QScan(struct qHead *ahead, afs_int32 id, int *success, struct aqueue **elem);
+ extern void Lp_QEnumerate(struct qHead *ahead, int *success, struct aqueue *elem);
+ extern void Lp_QTraverse(struct qHead *ahead);
+ #endif
\ No newline at end of file
Index: openafs/src/volser/vol-dump.c
diff -c openafs/src/volser/vol-dump.c:1.1.2.1 openafs/src/volser/vol-dump.c:1.1.2.2
*** openafs/src/volser/vol-dump.c:1.1.2.1	Wed Oct 31 00:13:54 2007
--- openafs/src/volser/vol-dump.c	Sat Aug 16 15:15:49 2008
***************
*** 18,24 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vol-dump.c,v 1.1.2.1 2007/10/31 04:13:54 shadow Exp $");
  
  #include <ctype.h>
  #include <errno.h>
--- 18,24 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vol-dump.c,v 1.1.2.2 2008/08/16 19:15:49 shadow Exp $");
  
  #include <ctype.h>
  #include <errno.h>
***************
*** 90,99 ****
  int verbose = 0;
  
  /* Forward Declarations */
! void HandleVolume(struct DiskPartition *partP, char *name, char *filename);
! Volume *AttachVolume(struct DiskPartition *dp, char *volname,
  		     register struct VolumeHeader *header);
! static void DoMyVolDump(Volume * vp, struct DiskPartition *dp,
  			char *dumpfile);
  
  #ifndef AFS_NT40_ENV
--- 90,99 ----
  int verbose = 0;
  
  /* Forward Declarations */
! void HandleVolume(struct DiskPartition64 *partP, char *name, char *filename);
! Volume *AttachVolume(struct DiskPartition64 *dp, char *volname,
  		     register struct VolumeHeader *header);
! static void DoMyVolDump(Volume * vp, struct DiskPartition64 *dp,
  			char *dumpfile);
  
  #ifndef AFS_NT40_ENV
***************
*** 118,124 ****
  
  
  Volume *
! AttachVolume(struct DiskPartition * dp, char *volname,
  	     register struct VolumeHeader * header)
  {
      register Volume *vp;
--- 118,124 ----
  
  
  Volume *
! AttachVolume(struct DiskPartition64 * dp, char *volname,
  	     register struct VolumeHeader * header)
  {
      register Volume *vp;
***************
*** 173,179 ****
      int volumeId = 0;
      char *partName = 0;
      char *fileName = NULL;
!     struct DiskPartition *partP = NULL;
      char name1[128];
      char tmpPartName[20];
  
--- 173,179 ----
      int volumeId = 0;
      char *partName = 0;
      char *fileName = NULL;
!     struct DiskPartition64 *partP = NULL;
      char name1[128];
      char tmpPartName[20];
  
***************
*** 237,243 ****
  }
  
  void
! HandleVolume(struct DiskPartition *dp, char *name, char *filename)
  {
      struct VolumeHeader header;
      struct VolumeDiskHeader diskHeader;
--- 237,243 ----
  }
  
  void
! HandleVolume(struct DiskPartition64 *dp, char *name, char *filename)
  {
      struct VolumeHeader header;
      struct VolumeDiskHeader diskHeader;
***************
*** 831,837 ****
  
  
  static void
! DoMyVolDump(Volume * vp, struct DiskPartition *dp, char *dumpfile)
  {
      int code = 0;
      int fromtime = 0;
--- 831,837 ----
  
  
  static void
! DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, char *dumpfile)
  {
      int code = 0;
      int fromtime = 0;
Index: openafs/src/volser/volint.xg
diff -c openafs/src/volser/volint.xg:1.4.2.1 openafs/src/volser/volint.xg:1.4.2.2
*** openafs/src/volser/volint.xg:1.4.2.1	Thu Jul 19 14:52:40 2007
--- openafs/src/volser/volint.xg	Sat Aug 16 15:15:49 2008
***************
*** 50,55 ****
--- 50,56 ----
  #define     VOLCONVERTRO        65536
  #define     VOLGETSIZE          65537
  #define     VOLDUMPV2           65538
+ #define     VOLDISKPART64       65539
  
  /* Bits for flags for DumpV2 */
  %#define     VOLDUMPV2_OMITDIRS 1
***************
*** 209,214 ****
--- 210,225 ----
  
  };
  
+ struct diskPartition64 { 
+ 	char 	name[256];
+ 	char 	devName[256];
+ 	int	lock_fd;
+ 	afs_int64	totalUsable;
+ 	afs_int64 	free;
+ 	afs_int64 	minFree;
+ 
+ };
+ 
  struct restoreCookie {
  	char name[32];
  	afs_int32 type;
***************
*** 419,421 ****
--- 430,436 ----
    IN afs_int32 flags
  ) split = VOLDUMPV2;
  
+ proc PartitionInfo64(
+   IN string name<>,
+   OUT struct diskPartition64 *partition
+ ) = VOLDISKPART64;
Index: openafs/src/volser/volmain.c
diff -c openafs/src/volser/volmain.c:1.18.2.14 openafs/src/volser/volmain.c:1.18.2.15
*** openafs/src/volser/volmain.c:1.18.2.14	Mon Mar 10 18:35:37 2008
--- openafs/src/volser/volmain.c	Sun Aug 24 21:15:18 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.14 2008/03/10 22:35:37 shadow Exp $");
  
  #include <sys/types.h>
  #include <string.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.15 2008/08/25 01:15:18 shadow Exp $");
  
  #include <sys/types.h>
  #include <string.h>
***************
*** 85,90 ****
--- 85,91 ----
  struct afsconf_dir *tdir;
  static afs_int32 runningCalls = 0;
  int DoLogging = 0;
+ int debuglevel = 0; 
  #define MAXLWP 16
  int lwps = 9;
  int udpBufSize = 0;		/* UDP buffer size for receive */
***************
*** 243,249 ****
      int rxpackets = 100;
      char commandLine[150];
      int i;
!     int rxJumbograms = 1;	/* default is to send and receive jumbograms. */
      int rxMaxMTU = -1;
      int bufSize = 0;		/* temp variable to read in udp socket buf size */
      afs_uint32 host = ntohl(INADDR_ANY);
--- 244,250 ----
      int rxpackets = 100;
      char commandLine[150];
      int i;
!     int rxJumbograms = 0;	/* default is to send and receive jumbograms. */
      int rxMaxMTU = -1;
      int bufSize = 0;		/* temp variable to read in udp socket buf size */
      afs_uint32 host = ntohl(INADDR_ANY);
***************
*** 295,300 ****
--- 296,308 ----
  	    rxBind = 1;
  	} else if (strcmp(argv[code], "-allow-dotted-principals") == 0) {
  	    rxkadDisableDotCheck = 1;
+ 	} else if (strcmp(argv[code], "-d") == 0) {
+ 	    if ((code + 1) >= argc) {
+ 		fprintf(stderr, "missing argument for -d\n"); 
+ 		return -1; 
+ 	    }
+ 	    debuglevel = atoi(argv[++code]);
+ 	    LogLevel = debuglevel;
  	} else if (strcmp(argv[code], "-p") == 0) {
  	    lwps = atoi(argv[++code]);
  	    if (lwps > MAXLWP) {
***************
*** 334,339 ****
--- 342,349 ----
  		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
  	} else if (strcmp(argv[code], "-nojumbo") == 0) {
  	    rxJumbograms = 0;
+ 	} else if (strcmp(argv[code], "-jumbo") == 0) {
+ 	    rxJumbograms = 1;
  	} else if (!strcmp(argv[code], "-rxmaxmtu")) {
  	    if ((code + 1) >= argc) {
  		fprintf(stderr, "missing argument for -rxmaxmtu\n"); 
***************
*** 385,400 ****
  	  usage:
  #ifndef AFS_NT40_ENV
  	    printf("Usage: volserver [-log] [-p <number of processes>] "
! 		   "[-auditlog <log path>] "
! 		   "[-nojumbo] [-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
  		   "[-udpsize <size of socket buffer in bytes>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #else
  	    printf("Usage: volserver [-log] [-p <number of processes>] "
! 		   "[-auditlog <log path>] "
! 		   "[-nojumbo] [-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
  		   "[-udpsize <size of socket buffer in bytes>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
--- 395,410 ----
  	  usage:
  #ifndef AFS_NT40_ENV
  	    printf("Usage: volserver [-log] [-p <number of processes>] "
! 		   "[-auditlog <log path>] [-d <debug level>] "
! 		   "[-nojumbo] [-jumbo] [-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
  		   "[-udpsize <size of socket buffer in bytes>] "
  		   "[-syslog[=FACILITY]] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
  #else
  	    printf("Usage: volserver [-log] [-p <number of processes>] "
! 		   "[-auditlog <log path>] [-d <debug level>] "
! 		   "[-nojumbo] [-jumbo] [-rxmaxmtu <bytes>] [-rxbind] [-allow-dotted-principals] "
  		   "[-udpsize <size of socket buffer in bytes>] "
  		   "[-enable_peer_stats] [-enable_process_stats] "
  		   "[-help]\n");
Index: openafs/src/volser/volprocs.c
diff -c openafs/src/volser/volprocs.c:1.34.2.13 openafs/src/volser/volprocs.c:1.34.2.17
*** openafs/src/volser/volprocs.c:1.34.2.13	Mon Mar 17 13:14:21 2008
--- openafs/src/volser/volprocs.c	Sat Aug 16 16:07:57 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volprocs.c,v 1.34.2.13 2008/03/17 17:14:21 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/volprocs.c,v 1.34.2.17 2008/08/16 20:07:57 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 98,104 ****
  int 
  VPFullUnlock()
  {
!     register struct DiskPartition *tp;
      for (tp = DiskPartitionList; tp; tp = tp->next) {
  	if (tp->lock_fd != -1) {
  	    close(tp->lock_fd);	/* releases flock held on this partition */
--- 98,104 ----
  int 
  VPFullUnlock()
  {
!     register struct DiskPartition64 *tp;
      for (tp = DiskPartitionList; tp; tp = tp->next) {
  	if (tp->lock_fd != -1) {
  	    close(tp->lock_fd);	/* releases flock held on this partition */
***************
*** 286,291 ****
--- 286,318 ----
  		     *partition)
  {
      afs_int32 code;
+     struct diskPartition64 *dp = (struct diskPartition64 *)
+       malloc(sizeof(struct diskPartition64));
+ 
+     code = VolPartitionInfo(acid, pname, dp);
+     if (!code) {
+ 	strncpy(partition->name, dp->name, 32);
+ 	strncpy(partition->devName, dp->devName, 32);
+ 	partition->lock_fd = dp->lock_fd;
+ 	if (dp->free > MAX_AFS_INT32)
+ 	    partition->free = MAX_AFS_INT32;
+ 	else
+ 	    partition->free = dp->free;
+ 	if (dp->minFree > MAX_AFS_INT32)
+ 	    partition->minFree = MAX_AFS_INT32;
+ 	else
+ 	    partition->minFree = dp->minFree;
+     }
+     free(dp);
+     osi_auditU(acid, VS_ParInfEvent, code, AUD_STR, pname, AUD_END);
+     return code;
+ }
+ 
+ afs_int32
+ SAFSVolPartitionInfo64(struct rx_call *acid, char *pname, 
+ 			struct diskPartition64 *partition)
+ {
+     afs_int32 code;
  
      code = VolPartitionInfo(acid, pname, partition);
      osi_auditU(acid, VS_ParInfEvent, code, AUD_STR, pname, AUD_END);
***************
*** 293,302 ****
  }
  
  afs_int32
! VolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition 
  		 *partition)
  {
!     register struct DiskPartition *dp;
  
  /*
      if (!afsconf_SuperUser(tdir, acid, caller)) return VOLSERBAD_ACCESS;
--- 320,329 ----
  }
  
  afs_int32
! VolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition64
  		 *partition)
  {
!     register struct DiskPartition64 *dp;
  
  /*
      if (!afsconf_SuperUser(tdir, acid, caller)) return VOLSERBAD_ACCESS;
***************
*** 425,431 ****
  	return EIO;
      }
      V_uniquifier(vp) = 1;
!     V_creationDate(vp) = V_copyDate(vp);
      V_inService(vp) = V_blessed(vp) = 1;
      V_type(vp) = atype;
      AssignVolumeName(&V_disk(vp), aname, 0);
--- 452,458 ----
  	return EIO;
      }
      V_uniquifier(vp) = 1;
!     V_updateDate(vp) = V_creationDate(vp) = V_copyDate(vp);
      V_inService(vp) = V_blessed(vp) = 1;
      V_type(vp) = atype;
      AssignVolumeName(&V_disk(vp), aname, 0);
***************
*** 821,826 ****
--- 848,858 ----
  	LogError(error);
  	goto fail;
      }
+     /* VUpdateVolume succeeded. Mark it in service so there's no window 
+      * between FSYNC_VOL_ON and VolSetFlags where it's offline with no  
+      * specialStatus; this is a reclone and this volume started online  
+      */
+     V_inService(clonevp) = 1;
      VDetachVolume(&error, clonevp);	/* allow file server to get it's hands on it */
      clonevp = NULL;
      VUpdateVolume(&error, originalvp);
***************
*** 839,845 ****
      DeleteTrans(ttc, 1);
  
      {
! 	struct DiskPartition *tpartp = originalvp->partition;
  	FSYNC_askfs(cloneId, tpartp->name, FSYNC_RESTOREVOLUME, 0);
      }
      return 0;
--- 871,877 ----
      DeleteTrans(ttc, 1);
  
      {
! 	struct DiskPartition64 *tpartp = originalvp->partition;
  	FSYNC_askfs(cloneId, tpartp->name, FSYNC_RESTOREVOLUME, 0);
      }
      return 0;
***************
*** 1658,1665 ****
      namehead[7] = '\0';
      for (i = 0; i < 26; i++) {
  	namehead[6] = i + 'a';
! 	if (VGetPartition(namehead, 0))
! 	    partIds->partIds[i] = VGetPartition(namehead, 0) ? i : -1;
      }
  
      return 0;
--- 1690,1696 ----
      namehead[7] = '\0';
      for (i = 0; i < 26; i++) {
  	namehead[6] = i + 'a';
! 	partIds->partIds[i] = VGetPartition(namehead, 0) ? i : -1;
      }
  
      return 0;
***************
*** 1683,1689 ****
      struct stat rbuf, pbuf;
      char namehead[9];
      struct partList partList;
!     struct DiskPartition *dp;
      int i, j = 0, k;
  
      strcpy(namehead, "/vicep");	/*7 including null terminator */
--- 1714,1720 ----
      struct stat rbuf, pbuf;
      char namehead[9];
      struct partList partList;
!     struct DiskPartition64 *dp;
      int i, j = 0, k;
  
      strcpy(namehead, "/vicep");	/*7 including null terminator */
***************
*** 1771,1777 ****
  {
      volintInfo *pntr;
      register struct Volume *tv;
!     struct DiskPartition *partP;
      struct volser_trans *ttc;
      char pname[9], volname[20];
      afs_int32 error = 0;
--- 1802,1808 ----
  {
      volintInfo *pntr;
      register struct Volume *tv;
!     struct DiskPartition64 *partP;
      struct volser_trans *ttc;
      char pname[9], volname[20];
      afs_int32 error = 0;
***************
*** 1945,1951 ****
      volintXInfo *xInfoP;	/*Ptr to the extended vol info */
      register struct Volume *tv;	/*Volume ptr */
      struct volser_trans *ttc;	/*Volume transaction ptr */
!     struct DiskPartition *partP;	/*Ptr to partition */
      char pname[9], volname[20];	/*Partition, volume names */
      afs_int32 error;		/*Error code */
      afs_int32 code;		/*Return code */
--- 1976,1982 ----
      volintXInfo *xInfoP;	/*Ptr to the extended vol info */
      register struct Volume *tv;	/*Volume ptr */
      struct volser_trans *ttc;	/*Volume transaction ptr */
!     struct DiskPartition64 *partP;	/*Ptr to partition */
      char pname[9], volname[20];	/*Partition, volume names */
      afs_int32 error;		/*Error code */
      afs_int32 code;		/*Return code */
***************
*** 2159,2165 ****
  {
      volintInfo *pntr;
      register struct Volume *tv;
!     struct DiskPartition *partP;
      struct volser_trans *ttc;
      afs_int32 allocSize = 1000;	/*to be changed to a larger figure */
      char pname[9], volname[20];
--- 2190,2196 ----
  {
      volintInfo *pntr;
      register struct Volume *tv;
!     struct DiskPartition64 *partP;
      struct volser_trans *ttc;
      afs_int32 allocSize = 1000;	/*to be changed to a larger figure */
      char pname[9], volname[20];
***************
*** 2364,2370 ****
  
      volintXInfo *xInfoP;	/*Ptr to the extended vol info */
      register struct Volume *tv;	/*Volume ptr */
!     struct DiskPartition *partP;	/*Ptr to partition */
      struct volser_trans *ttc;	/*Volume transaction ptr */
      afs_int32 allocSize = 1000;	/*To be changed to a larger figure */
      char pname[9], volname[20];	/*Partition, volume names */
--- 2395,2401 ----
  
      volintXInfo *xInfoP;	/*Ptr to the extended vol info */
      register struct Volume *tv;	/*Volume ptr */
!     struct DiskPartition64 *partP;	/*Ptr to partition */
      struct volser_trans *ttc;	/*Volume transaction ptr */
      afs_int32 allocSize = 1000;	/*To be changed to a larger figure */
      char pname[9], volname[20];	/*Partition, volume names */
***************
*** 2791,2797 ****
      DIR *dirp;
      register struct volser_trans *ttc;
      char pname[16], volname[20];
!     struct DiskPartition *partP;
      afs_int32 ret = ENODEV;
      afs_int32 volid;
  
--- 2822,2828 ----
      DIR *dirp;
      register struct volser_trans *ttc;
      char pname[16], volname[20];
!     struct DiskPartition64 *partP;
      afs_int32 ret = ENODEV;
      afs_int32 volid;
  
Index: openafs/src/volser/volser_prototypes.h
diff -c openafs/src/volser/volser_prototypes.h:1.4.2.3 openafs/src/volser/volser_prototypes.h:1.4.2.5
*** openafs/src/volser/volser_prototypes.h:1.4.2.3	Mon Jan 21 09:35:10 2008
--- openafs/src/volser/volser_prototypes.h	Sat Aug 16 15:56:25 2008
***************
*** 24,31 ****
  extern void SubEnumerateEntry(struct nvldbentry *entry);
  extern void EnumerateEntry(struct nvldbentry *entry);
  extern int UV_NukeVolume(afs_int32 server, afs_int32 partid, afs_int32 volid);
! extern int UV_PartitionInfo(afs_int32 server, char *pname,
! 			    struct diskPartition *partition);
  extern int UV_CreateVolume(afs_int32 aserver, afs_int32 apart, char *aname,
  			   afs_int32 * anewid);
  extern int UV_CreateVolume2(afs_int32 aserver, afs_int32 apart, char *aname,
--- 24,31 ----
  extern void SubEnumerateEntry(struct nvldbentry *entry);
  extern void EnumerateEntry(struct nvldbentry *entry);
  extern int UV_NukeVolume(afs_int32 server, afs_int32 partid, afs_int32 volid);
! extern int UV_PartitionInfo64(afs_int32 server, char *pname,
! 			    struct diskPartition64 *partition);
  extern int UV_CreateVolume(afs_int32 aserver, afs_int32 apart, char *aname,
  			   afs_int32 * anewid);
  extern int UV_CreateVolume2(afs_int32 aserver, afs_int32 apart, char *aname,
***************
*** 40,45 ****
--- 40,48 ----
  extern int UV_MoveVolume(afs_int32 afromvol, afs_int32 afromserver,
  			 afs_int32 afrompart, afs_int32 atoserver,
  			 afs_int32 atopart);
+ extern int UV_MoveVolume2(afs_int32 afromvol, afs_int32 afromserver, 
+                           afs_int32 afrompart, afs_int32 atoserver, 
+                           afs_int32 atopart, int flags);
  extern int UV_BackupVolume(afs_int32 aserver, afs_int32 apart,
  			   afs_int32 avolid);
  extern int UV_ReleaseVolume(afs_int32 afromvol, afs_int32 afromserver,
***************
*** 49,56 ****
  			 afs_int32 afrompart, afs_int32 fromdate,
  			 afs_int32(*DumpFunction) (), char *rock, afs_int32 flags);
  extern int UV_RestoreVolume(afs_int32 toserver, afs_int32 topart,
! 			    afs_int32 tovolid, char tovolname[], int flags,
  			    afs_int32(*WriteData) (), char *rock);
  extern int UV_LockRelease(afs_int32 volid);
  extern int UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid, afs_int32 valid);
  extern int UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid);
--- 52,62 ----
  			 afs_int32 afrompart, afs_int32 fromdate,
  			 afs_int32(*DumpFunction) (), char *rock, afs_int32 flags);
  extern int UV_RestoreVolume(afs_int32 toserver, afs_int32 topart,
! 			    afs_int32 tovolid, char tovolname[], int restoreflags,
  			    afs_int32(*WriteData) (), char *rock);
+ extern int UV_RestoreVolume2(afs_int32 toserver, afs_int32 topart, afs_int32 tovolid,
+                             afs_int32 toparentid, char tovolname[], int flags,
+                             afs_int32(*WriteData) (), char *rock);
  extern int UV_LockRelease(afs_int32 volid);
  extern int UV_AddSite(afs_int32 server, afs_int32 part, afs_int32 volid, afs_int32 valid);
  extern int UV_RemoveSite(afs_int32 server, afs_int32 part, afs_int32 volid);
***************
*** 99,103 ****
--- 105,124 ----
  			    afs_int32 volid, volintInfo * infop);
  extern void MapNetworkToHost(struct nvldbentry *old, struct nvldbentry *new);
  extern void MapHostToNetwork(struct nvldbentry *entry);
+ extern int UV_CopyVolume2(afs_int32 afromvol, afs_int32 afromserver, 
+                           afs_int32 afrompart, char *atovolname, 
+                           afs_int32 atoserver, afs_int32 atopart,
+                           afs_int32 atovolid, int flags);
+ extern int UV_CloneVolume(afs_int32 aserver, afs_int32 apart, afs_int32 avolid,
+                           afs_int32 acloneid, char *aname, int flags);
+ extern int UV_DumpClonedVolume(afs_int32 afromvol, afs_int32 afromserver,
+                                afs_int32 afrompart, afs_int32 fromdate,
+                                afs_int32(*DumpFunction) (), char *rock, 
+                                afs_int32 flags);
+ extern int UV_GetSize(afs_int32 afromvol, afs_int32 afromserver, 
+                       afs_int32 afrompart, afs_int32 fromdate, 
+                       struct volintSize *vol_size);
  
+ extern int verbose;
+ extern int noresolve;
  #endif
Index: openafs/src/volser/vos.c
diff -c openafs/src/volser/vos.c:1.40.2.25 openafs/src/volser/vos.c:1.40.2.27
*** openafs/src/volser/vos.c:1.40.2.25	Sun Feb 10 22:46:33 2008
--- openafs/src/volser/vos.c	Sat Aug 16 15:56:25 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.25 2008/02/11 03:46:33 shadow Exp $");
  
  #include <sys/types.h>
  #include <string.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.27 2008/08/16 19:56:25 shadow Exp $");
  
  #include <sys/types.h>
  #include <string.h>
***************
*** 59,70 ****
  #ifdef	AFS_AIX32_ENV
  #include <signal.h>
  #endif
! #include "volser_prototypes.h"
  
  #ifdef HAVE_POSIX_REGEX
  #include <regex.h>
  #endif
  
  struct tqElem {
      afs_int32 volid;
      struct tqElem *next;
--- 59,77 ----
  #ifdef	AFS_AIX32_ENV
  #include <signal.h>
  #endif
! #include <volser_prototypes.h>
! #include <vsutils_prototypes.h>
! #include <lockprocs_prototypes.h>
  
  #ifdef HAVE_POSIX_REGEX
  #include <regex.h>
  #endif
  
+ /* Local Prototypes */
+ int PrintDiagnostics(char *astring, afs_int32 acode);
+ int GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, 
+                   afs_int32 *voltype, struct nvldbentry *rentry);
+ 
  struct tqElem {
      afs_int32 volid;
      struct tqElem *next;
***************
*** 81,90 ****
  cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
  cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
  cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
  
  #define ERROR_EXIT(code) {error=(code); goto error_exit;}
  
- extern int verbose;
  int rxInitDone = 0;
  struct rx_connection *tconn;
  afs_int32 tserver;
--- 88,97 ----
  cmd_AddParm(ts, "-localauth",CMD_FLAG,CMD_OPTIONAL,"use server tickets");\
  cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");\
  cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL, "encrypt commands");\
+ cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
  
  #define ERROR_EXIT(code) {error=(code); goto error_exit;}
  
  int rxInitDone = 0;
  struct rx_connection *tconn;
  afs_int32 tserver;
***************
*** 340,346 ****
  	USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
  	hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
  	USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
! 	USD_READ(ufd, &buffer, sizeof(afs_uint32), &got);
  	if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
  	    fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
  	    error = VOLSERBADOP;
--- 347,353 ----
  	USD_SEEK(ufd, filesize, SEEK_END, &currOffset);
  	hset64(filesize, hgethi(currOffset), hgetlo(currOffset)-sizeof(afs_uint32));
  	USD_SEEK(ufd, filesize, SEEK_SET, &currOffset);
! 	USD_READ(ufd, (char *)&buffer, sizeof(afs_uint32), &got);
  	if ((got != sizeof(afs_uint32)) || (ntohl(buffer) != DUMPENDMAGIC)) {
  	    fprintf(STDERR, "Signature missing from end of file '%s'\n", filename);
  	    error = VOLSERBADOP;
***************
*** 1384,1391 ****
  }
  
  static void
! PostVolumeStats(entry)
!      struct nvldbentry *entry;
  {
      SubEnumerateEntry(entry);
      /* Check for VLOP_ALLOPERS */
--- 1391,1397 ----
  }
  
  static void
! PostVolumeStats(struct nvldbentry *entry)
  {
      SubEnumerateEntry(entry);
      /* Check for VLOP_ALLOPERS */
***************
*** 2100,2106 ****
      afs_int32 flags, code, err;
      char fromPartName[10], toPartName[10];
  
!     struct diskPartition partition;	/* for space check */
      volintInfo *p;
  
      volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
--- 2106,2112 ----
      afs_int32 flags, code, err;
      char fromPartName[10], toPartName[10];
  
!     struct diskPartition64 partition;	/* for space check */
      volintInfo *p;
  
      volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
***************
*** 2169,2175 ****
       * check target partition for space to move volume
       */
  
!     code = UV_PartitionInfo(toserver, toPartName, &partition);
      if (code) {
  	fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
  	exit(1);
--- 2175,2181 ----
       * check target partition for space to move volume
       */
  
!     code = UV_PartitionInfo64(toserver, toPartName, &partition);
      if (code) {
  	fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
  	exit(1);
***************
*** 2225,2231 ****
      afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
      char fromPartName[10], toPartName[10], *tovolume;
      struct nvldbentry entry;
!     struct diskPartition partition;	/* for space check */
      volintInfo *p;
  
      volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
--- 2231,2237 ----
      afs_int32 volid, fromserver, toserver, frompart, topart, code, err, flags;
      char fromPartName[10], toPartName[10], *tovolume;
      struct nvldbentry entry;
!     struct diskPartition64 partition;	/* for space check */
      volintInfo *p;
  
      volid = vsu_GetVolumeID(as->parms[0].items->data, cstruct, &err);
***************
*** 2320,2326 ****
       * check target partition for space to move volume
       */
  
!     code = UV_PartitionInfo(toserver, toPartName, &partition);
      if (code) {
  	fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
  	exit(1);
--- 2326,2332 ----
       * check target partition for space to move volume
       */
  
!     code = UV_PartitionInfo64(toserver, toPartName, &partition);
      if (code) {
  	fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
  	exit(1);
***************
*** 2372,2378 ****
      afs_int32 code, err, flags;
      char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
      struct nvldbentry entry;
!     struct diskPartition partition;	/* for space check */
      volintInfo *p, *q;
  
      p = (volintInfo *) 0;
--- 2378,2384 ----
      afs_int32 code, err, flags;
      char fromPartName[10], toPartName[10], toVolName[32], *tovolume;
      struct nvldbentry entry;
!     struct diskPartition64 partition;	/* for space check */
      volintInfo *p, *q;
  
      p = (volintInfo *) 0;
***************
*** 2505,2511 ****
       * check target partition for space to move volume
       */
  
!     code = UV_PartitionInfo(toserver, toPartName, &partition);
      if (code) {
  	fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
  	exit(1);
--- 2511,2517 ----
       * check target partition for space to move volume
       */
  
!     code = UV_PartitionInfo64(toserver, toPartName, &partition);
      if (code) {
  	fprintf(STDERR, "vos: cannot access partition %s\n", toPartName);
  	exit(1);
***************
*** 4075,4083 ****
      return 0;
  }
  
! GetVolumeInfo(volid, server, part, voltype, rentry)
!      afs_int32 *server, volid, *part, *voltype;
!      register struct nvldbentry *rentry;
  {
      afs_int32 vcode;
      int i, index = -1;
--- 4081,4089 ----
      return 0;
  }
  
! int
! GetVolumeInfo(afs_int32 volid, afs_int32 *server, afs_int32 *part, afs_int32 *voltype, 
!               struct nvldbentry *rentry)
  {
      afs_int32 vcode;
      int i, index = -1;
***************
*** 4992,4998 ****
      afs_int32 apart;
      afs_int32 aserver, code;
      char pname[10];
!     struct diskPartition partition;
      struct partList dummyPartList;
      int i, cnt;
      int printSummary=0, sumPartitions=0;
--- 4998,5004 ----
      afs_int32 apart;
      afs_int32 aserver, code;
      char pname[10];
!     struct diskPartition64 partition;
      struct partList dummyPartList;
      int i, cnt;
      int printSummary=0, sumPartitions=0;
***************
*** 5041,5047 ****
      for (i = 0; i < cnt; i++) {
  	if (dummyPartList.partFlags[i] & PARTVALID) {
  	    MapPartIdIntoName(dummyPartList.partId[i], pname);
! 	    code = UV_PartitionInfo(aserver, pname, &partition);
  	    if (code) {
  		fprintf(STDERR, "Could not get information on partition %s\n",
  			pname);
--- 5047,5053 ----
      for (i = 0; i < cnt; i++) {
  	if (dummyPartList.partFlags[i] & PARTVALID) {
  	    MapPartIdIntoName(dummyPartList.partId[i], pname);
! 	    code = UV_PartitionInfo64(aserver, pname, &partition);
  	    if (code) {
  		fprintf(STDERR, "Could not get information on partition %s\n",
  			pname);
***************
*** 5049,5061 ****
  		exit(1);
  	    }
  	    fprintf(STDOUT,
! 		    "Free space on partition %s: %d K blocks out of total %d\n",
  		    pname, partition.free, partition.minFree);
  	    sumPartitions++;
!             FillInt64(tmp,0,partition.free);
!             AddUInt64(sumFree,tmp,&sumFree);
!             FillInt64(tmp,0,partition.minFree);
!             AddUInt64(sumStorage,tmp,&sumStorage);
  	}
      }
      if (printSummary) {
--- 5055,5065 ----
  		exit(1);
  	    }
  	    fprintf(STDOUT,
! 		    "Free space on partition %s: %lld K blocks out of total %lld\n",
  		    pname, partition.free, partition.minFree);
  	    sumPartitions++;
!             AddUInt64(sumFree,partition.free,&sumFree);
!             AddUInt64(sumStorage,partition.minFree,&sumStorage);
  	}
      }
      if (printSummary) {
***************
*** 5134,5140 ****
  
  static void
  print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
! 	    int print, int noresolve)
  {
      afs_int32 vcode;
      afs_int32 i, j;
--- 5138,5144 ----
  
  static void
  print_addrs(const bulkaddrs * addrs, const afsUUID * m_uuid, int nentries,
! 	    int print)
  {
      afs_int32 vcode;
      afs_int32 i, j;
***************
*** 5172,5178 ****
  		m_addrs.bulkaddrs_len = 0;
  		vcode =
  		    ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
! 				      &vlcb, &m_nentries, &m_addrs);
  		if (vcode) {
  		    fprintf(STDERR,
  			    "vos: could not list the multi-homed server addresses\n");
--- 5176,5182 ----
  		m_addrs.bulkaddrs_len = 0;
  		vcode =
  		    ubik_VL_GetAddrsU(cstruct, 0, &m_attrs, &m_uuid,
! 				      (afs_int32 *)&vlcb, &m_nentries, &m_addrs);
  		if (vcode) {
  		    fprintf(STDERR,
  			    "vos: could not list the multi-homed server addresses\n");
***************
*** 5222,5228 ****
  ListAddrs(register struct cmd_syndesc *as, void *arock)
  {
      afs_int32 vcode;
!     afs_int32 i, noresolve = 0, printuuid = 0;
      struct VLCallBack vlcb;
      afs_int32 nentries;
      bulkaddrs m_addrs;
--- 5226,5232 ----
  ListAddrs(register struct cmd_syndesc *as, void *arock)
  {
      afs_int32 vcode;
!     afs_int32 i, printuuid = 0;
      struct VLCallBack vlcb;
      afs_int32 nentries;
      bulkaddrs m_addrs;
***************
*** 5260,5268 ****
  	m_attrs.ipaddr = ntohl(saddr);
      }
      if (as->parms[2].items) {
- 	noresolve = 1;
-     }
-     if (as->parms[3].items) {
  	printuuid = 1;
      }
  
--- 5264,5269 ----
***************
*** 5315,5321 ****
  	    return (vcode);
  	}
  
! 	print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid, noresolve);
  	i++;
  
  	if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
--- 5316,5322 ----
  	    return (vcode);
  	}
  
! 	print_addrs(&m_addrs, &m_uuid, m_nentries, printuuid);
  	i++;
  
  	if ((as->parms[1].items) || (as->parms[0].items) || (i > nentries))
***************
*** 5599,5607 ****
      return 0;
  }
  
! PrintDiagnostics(astring, acode)
!      char *astring;
!      afs_int32 acode;
  {
      if (acode == EACCES) {
  	fprintf(STDERR,
--- 5600,5607 ----
      return 0;
  }
  
! int
! PrintDiagnostics(char *astring, afs_int32 acode)
  {
      if (acode == EACCES) {
  	fprintf(STDERR,
***************
*** 5646,5651 ****
--- 5646,5655 ----
  	verbose = 1;
      else
  	verbose = 0;
+     if (as->parms[17].items)	/* -noresolve flag set */
+ 	noresolve = 1;
+     else
+ 	noresolve = 0;
      return 0;
  }
  
***************
*** 6002,6009 ****
  			  "list the IP address of all file servers registered in the VLDB");
      cmd_AddParm(ts, "-uuid", CMD_SINGLE, CMD_OPTIONAL, "uuid of server");
      cmd_AddParm(ts, "-host", CMD_SINGLE, CMD_OPTIONAL, "address of host");
-     cmd_AddParm(ts, "-noresolve", CMD_FLAG, CMD_OPTIONAL,
- 		"don't resolve addresses");
      cmd_AddParm(ts, "-printuuid", CMD_FLAG, CMD_OPTIONAL,
  		"print uuid of hosts");
      COMMONPARMS;
--- 6006,6011 ----
Index: openafs/src/volser/vsprocs.c
diff -c openafs/src/volser/vsprocs.c:1.33.2.18 openafs/src/volser/vsprocs.c:1.33.2.21
*** openafs/src/volser/vsprocs.c:1.33.2.18	Sun Feb 10 22:46:34 2008
--- openafs/src/volser/vsprocs.c	Sat Aug 16 15:56:25 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.33.2.18 2008/02/11 03:46:34 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsprocs.c,v 1.33.2.21 2008/08/16 19:56:25 shadow Exp $");
  
  #include <stdio.h>
  #include <sys/types.h>
***************
*** 57,65 ****
  #include <setjmp.h>
  
  #include <volser_prototypes.h>
  
  struct ubik_client *cstruct;
! int verbose = 0;
  
  struct release {
      afs_int32 crtime;
--- 57,67 ----
  #include <setjmp.h>
  
  #include <volser_prototypes.h>
+ #include <vsutils_prototypes.h>
+ #include <lockprocs_prototypes.h>
  
  struct ubik_client *cstruct;
! int verbose = 0, noresolve = 0;
  
  struct release {
      afs_int32 crtime;
***************
*** 503,508 ****
--- 505,511 ----
      int i;
      char pname[10];
      int isMixed = 0;
+     char hoststr[16];
  
  #ifdef notdef
      fprintf(STDOUT, "	readWriteID %-10u ", entry->volumeId[RWVOL]);
***************
*** 542,548 ****
      for (i = 0; i < entry->nServers; i++) {
  	MapPartIdIntoName(entry->serverPartition[i], pname);
  	fprintf(STDOUT, "       server %s partition %s ",
! 		hostutil_GetNameByINet(entry->serverNumber[i]), pname);
  	if (entry->serverFlags[i] & ITSRWVOL)
  	    fprintf(STDOUT, "RW Site ");
  	else
--- 545,552 ----
      for (i = 0; i < entry->nServers; i++) {
  	MapPartIdIntoName(entry->serverPartition[i], pname);
  	fprintf(STDOUT, "       server %s partition %s ",
! 		noresolve ? afs_inet_ntoa_r(entry->serverNumber[i], hoststr) : 
!                 hostutil_GetNameByINet(entry->serverNumber[i]), pname);
  	if (entry->serverFlags[i] & ITSRWVOL)
  	    fprintf(STDOUT, "RW Site ");
  	else
***************
*** 593,608 ****
  
  /* like df. Return usage of <pname> on <server> in <partition> */
  int
! UV_PartitionInfo(afs_int32 server, char *pname,
! 		 struct diskPartition *partition)
  {
      register struct rx_connection *aconn;
!     afs_int32 code;
  
-     code = 0;
      aconn = (struct rx_connection *)0;
      aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
!     code = AFSVolPartitionInfo(aconn, pname, partition);
      if (code) {
  	fprintf(STDERR, "Could not get information on partition %s\n", pname);
  	PrintError("", code);
--- 597,623 ----
  
  /* like df. Return usage of <pname> on <server> in <partition> */
  int
! UV_PartitionInfo64(afs_int32 server, char *pname,
! 		   struct diskPartition64 *partition)
  {
      register struct rx_connection *aconn;
!     afs_int32 code = 0;
  
      aconn = (struct rx_connection *)0;
      aconn = UV_Bind(server, AFSCONF_VOLUMEPORT);
!     code = AFSVolPartitionInfo64(aconn, pname, partition);
!     if (code == RXGEN_OPCODE) {
! 	struct diskPartition *dpp = (struct diskPartition *)malloc(sizeof(struct diskPartition));
! 	code = AFSVolPartitionInfo(aconn, pname, dpp);
! 	if (!code) {
! 	    strncpy(partition->name, dpp->name, 32);
! 	    strncpy(partition->devName, dpp->devName, 32);
! 	    partition->lock_fd = dpp->lock_fd;
! 	    partition->free = dpp->free;
! 	    partition->minFree = dpp->minFree;
! 	}
! 	free(dpp);
!     } 
      if (code) {
  	fprintf(STDERR, "Could not get information on partition %s\n", pname);
  	PrintError("", code);
***************
*** 1061,1066 ****
--- 1076,1082 ----
      afs_int32 error;
      char in, lf;		/* for test code */
      int same;
+     char hoststr[16];
  
  #ifdef	ENABLE_BUGFIX_1165
      volEntries volumeInfo;
***************
*** 1137,1143 ****
  		    char pname[10];
  		    MapPartIdIntoName(entry.serverPartition[i], pname);
  		    fprintf(STDERR, " server %s partition %s \n",
! 			    hostutil_GetNameByINet(entry.serverNumber[i]),
  			    pname);
  		}
  	    }
--- 1153,1160 ----
  		    char pname[10];
  		    MapPartIdIntoName(entry.serverPartition[i], pname);
  		    fprintf(STDERR, " server %s partition %s \n",
! 			    noresolve ? afs_inet_ntoa_r(entry.serverNumber[i], hoststr) :
!                             hostutil_GetNameByINet(entry.serverNumber[i]),
  			    pname);
  		}
  	    }
***************
*** 3016,3021 ****
--- 3033,3039 ----
      afs_int32 volid;
      struct volser_status tstatus;
      int code, rcode, tcode;
+     char hoststr[16];
  
      *connPtr = (struct rx_connection *)0;
      *transPtr = 0;
***************
*** 3037,3042 ****
--- 3055,3061 ----
      /* If the volume does not exist, create it */
      if (!volid || code) {
  	char volname[64];
+         char hoststr[16];
  
  	if (volid && (code != VNOVOL)) {
  	    PrintError("Failed to start a transaction on the RO volume.\n",
***************
*** 3051,3057 ****
  	    fprintf(STDOUT,
  		    "Creating new volume %lu on replication site %s: ",
  		    (unsigned long)volid,
! 		    hostutil_GetNameByINet(vldbEntryPtr->
  					   serverNumber[index]));
  	    fflush(STDOUT);
  	}
--- 3070,3078 ----
  	    fprintf(STDOUT,
  		    "Creating new volume %lu on replication site %s: ",
  		    (unsigned long)volid,
!                     noresolve ? afs_inet_ntoa_r(vldbEntryPtr->
!                                                 serverNumber[index], hoststr) :
!                     hostutil_GetNameByINet(vldbEntryPtr->
  					   serverNumber[index]));
  	    fflush(STDOUT);
  	}
***************
*** 3084,3090 ****
       */
      else {
  	VPRINT2("Updating existing ro volume %u on %s ...\n", volid,
! 		hostutil_GetNameByINet(vldbEntryPtr->serverNumber[index]));
  
  	code = AFSVolGetStatus(*connPtr, *transPtr, &tstatus);
  	if (code) {
--- 3105,3113 ----
       */
      else {
  	VPRINT2("Updating existing ro volume %u on %s ...\n", volid,
!                 noresolve ? afs_inet_ntoa_r(vldbEntryPtr->
!                                             serverNumber[index], hoststr) : 
!                 hostutil_GetNameByINet(vldbEntryPtr->serverNumber[index]));
  
  	code = AFSVolGetStatus(*connPtr, *transPtr, &tstatus);
  	if (code) {
***************
*** 3174,3179 ****
--- 3197,3203 ----
      } remembertime[NMAXNSERVERS];
      int releasecount = 0;
      struct volser_status volstatus;
+     char hoststr[16];
  
      memset((char *)remembertime, 0, sizeof(remembertime));
      memset((char *)&results, 0, sizeof(results));
***************
*** 3577,3588 ****
--- 3601,3616 ----
  	if (verbose) {
  	    fprintf(STDOUT, "Starting ForwardMulti from %lu to %u on %s",
  		    (unsigned long)cloneVolId, entry.volumeId[ROVOL],
+ 		    noresolve ? afs_inet_ntoa_r(entry.serverNumber[times[0].
+ 						vldbEntryIndex], hoststr) :
  		    hostutil_GetNameByINet(entry.
  					   serverNumber[times[0].
  							vldbEntryIndex]));
  
  	    for (s = 1; s < volcount; s++) {
  		fprintf(STDOUT, " and %s",
+ 			noresolve ? afs_inet_ntoa_r(entry.serverNumber[times[s].
+ 						    vldbEntryIndex], hoststr) :
  			hostutil_GetNameByINet(entry.
  					       serverNumber[times[s].
  							    vldbEntryIndex]));
***************
*** 3710,3716 ****
  	    if (!(entry.serverFlags[i] & NEW_REPSITE)) {
  		MapPartIdIntoName(entry.serverPartition[i], pname);
  		fprintf(STDERR, "\t%35s %s\n",
! 			hostutil_GetNameByINet(entry.serverNumber[i]), pname);
  	    }
  	}
  
--- 3738,3745 ----
  	    if (!(entry.serverFlags[i] & NEW_REPSITE)) {
  		MapPartIdIntoName(entry.serverPartition[i], pname);
  		fprintf(STDERR, "\t%35s %s\n",
!                         noresolve ? afs_inet_ntoa_r(entry.serverNumber[i], hoststr) :
!                         hostutil_GetNameByINet(entry.serverNumber[i]), pname);
  	    }
  	}
  
***************
*** 3781,3789 ****
  		fprintf(STDERR,
  			"Failed to end transaction on ro volume %u at server %s\n",
  			entry.volumeId[ROVOL],
! 			hostutil_GetNameByINet(htonl
! 					       (replicas[i].server.
! 						destHost)));
  		if (!error)
  		    error = code;
  	    }
--- 3810,3819 ----
  		fprintf(STDERR,
  			"Failed to end transaction on ro volume %u at server %s\n",
  			entry.volumeId[ROVOL],
!                         noresolve ? afs_inet_ntoa_r(htonl(replicas[i].server.
!                                                         destHost), hoststr) :
!                         hostutil_GetNameByINet(htonl
! 					       (replicas[i].server.destHost)));
  		if (!error)
  		    error = code;
  	    }
***************
*** 4088,4094 ****
      afs_int32 oldCreateDate, oldUpdateDate, newCreateDate, newUpdateDate;
      int index, same, errcode;
      char apartName[10];
! 
  
      memset(&cookie, 0, sizeof(cookie));
      islocked = 0;
--- 4118,4124 ----
      afs_int32 oldCreateDate, oldUpdateDate, newCreateDate, newUpdateDate;
      int index, same, errcode;
      char apartName[10];
!     char hoststr[16];
  
      memset(&cookie, 0, sizeof(cookie));
      islocked = 0;
***************
*** 4165,4170 ****
--- 4195,4201 ----
      MapPartIdIntoName(topart, partName);
      fprintf(STDOUT, "Restoring volume %s Id %lu on server %s partition %s ..",
  	    tovolreal, (unsigned long)pvolid,
+             noresolve ? afs_inet_ntoa_r(toserver, hoststr) :
  	    hostutil_GetNameByINet(toserver), partName);
      fflush(STDOUT);
      code =
***************
*** 4416,4421 ****
--- 4447,4453 ----
  			VPRINT2
  			    ("Not deleting the previous volume %u on server %s, ...",
  			     pvolid,
+                              noresolve ? afs_inet_ntoa_r(entry.serverNumber[index], hoststr) :
  			     hostutil_GetNameByINet(entry.serverNumber[index]));
  		    } else {
  			tempconn =
***************
*** 4427,4432 ****
--- 4459,4465 ----
  			VPRINT3
  			    ("Deleting the previous volume %u on server %s, partition %s ...",
  			     pvolid,
+                              noresolve ? afs_inet_ntoa_r(entry.serverNumber[index], hoststr) :
  			     hostutil_GetNameByINet(entry.serverNumber[index]),
  			     apartName);
  			code =
***************
*** 5270,5275 ****
--- 5303,5309 ----
      char pname[10];
      int pass = 0, islocked = 0, createentry, addvolume, modified, mod, doit = 1;
      afs_int32 rwvolid;
+     char hoststr[16]; 
  
      if (modentry) {
  	if (*modentry == 1)
***************
*** 5358,5369 ****
--- 5392,5407 ----
  			    fprintf(STDERR,
  				    "*** Warning: Orphaned RW volume %lu exists on %s %s\n",
  				    (unsigned long)rwvolid,
+                                     noresolve ?
+                                     afs_inet_ntoa_r(aserver, hoststr) :
  				    hostutil_GetNameByINet(aserver), pname);
  			    MapPartIdIntoName(entry.serverPartition[idx],
  					      pname);
  			    fprintf(STDERR,
  				    "    VLDB reports RW volume %lu exists on %s %s\n",
  				    (unsigned long)rwvolid,
+                                     noresolve ? 
+                                     afs_inet_ntoa_r(entry.serverNumber[idx], hoststr) :
  				    hostutil_GetNameByINet(entry.
  							   serverNumber[idx]),
  				    pname);
***************
*** 5380,5385 ****
--- 5418,5425 ----
  				fprintf(STDERR,
  					"*** Warning: Orphaned BK volume %u exists on %s %s\n",
  					entry.volumeId[BACKVOL],
+                                         noresolve ?
+                                         afs_inet_ntoa_r(entry.serverNumber[idx], hoststr) :
  					hostutil_GetNameByINet(entry.
  							       serverNumber
  							       [idx]), pname);
***************
*** 5387,5392 ****
--- 5427,5434 ----
  				fprintf(STDERR,
  					"    VLDB reports its RW volume %lu exists on %s %s\n",
  					(unsigned long)rwvolid,
+                                         noresolve ? 
+                                         afs_inet_ntoa_r(aserver, hoststr) :
  					hostutil_GetNameByINet(aserver),
  					pname);
  			    }
***************
*** 5457,5467 ****
--- 5499,5513 ----
  			fprintf(STDERR,
  				"*** Warning: Orphaned BK volume %lu exists on %s %s\n",
  				(unsigned long)volumeinfo->volid,
+                                 noresolve ?
+                                 afs_inet_ntoa_r(aserver, hoststr) :
  				hostutil_GetNameByINet(aserver), pname);
  			MapPartIdIntoName(entry.serverPartition[idx], pname);
  			fprintf(STDERR,
  				"    VLDB reports its RW/BK volume %lu exists on %s %s\n",
  				(unsigned long)rwvolid,
+                                 noresolve ?
+                                 afs_inet_ntoa_r(entry.serverNumber[idx], hoststr) :
  				hostutil_GetNameByINet(entry.
  						       serverNumber[idx]),
  				pname);
***************
*** 5480,5485 ****
--- 5526,5533 ----
  				fprintf(STDERR,
  					"*** Warning: Orphaned BK volume %u exists on %s %s\n",
  					entry.volumeId[BACKVOL],
+                                         noresolve ?
+                                         afs_inet_ntoa_r(aserver, hoststr) :
  					hostutil_GetNameByINet(aserver),
  					pname);
  				fprintf(STDERR,
***************
*** 5492,5499 ****
  						  pname);
  				fprintf(STDERR,
  					"*** Warning: Orphaned BK volume %lu exists on %s %s\n",
! 					(unsigned long)volumeinfo->volid,
! 					hostutil_GetNameByINet(aserver),
  					pname);
  				fprintf(STDERR,
  					"    VLDB reports its BK volume ID is %u\n",
--- 5540,5549 ----
  						  pname);
  				fprintf(STDERR,
  					"*** Warning: Orphaned BK volume %lu exists on %s %s\n",
!                                         (unsigned long)volumeinfo->volid,
!                                         noresolve ?
!                                         afs_inet_ntoa_r(aserver, hoststr) :
!                                         hostutil_GetNameByINet(aserver),
  					pname);
  				fprintf(STDERR,
  					"    VLDB reports its BK volume ID is %u\n",
***************
*** 5513,5519 ****
  
  	    entry.serverNumber[idx] = aserver;
  	    entry.serverPartition[idx] = apart;
! 	    entry.serverFlags[idx] = ITSRWVOL;
  
  	    modified++;
  	}
--- 5563,5569 ----
  
  	    entry.serverNumber[idx] = aserver;
  	    entry.serverPartition[idx] = apart;
! 	    entry.serverFlags[idx] = ITSBACKVOL;
  
  	    modified++;
  	}
***************
*** 5563,5569 ****
  			    fprintf(STDERR,
  				    "*** Warning: Orphaned RO volume %u exists on %s %s\n",
  				    entry.volumeId[ROVOL],
! 				    hostutil_GetNameByINet(entry.
  							   serverNumber[j]),
  				    pname);
  			    fprintf(STDERR,
--- 5613,5621 ----
  			    fprintf(STDERR,
  				    "*** Warning: Orphaned RO volume %u exists on %s %s\n",
  				    entry.volumeId[ROVOL],
!                                     noresolve ?
!                                     afs_inet_ntoa_r(entry.serverNumber[j], hoststr) :
!                                     hostutil_GetNameByINet(entry.
  							   serverNumber[j]),
  				    pname);
  			    fprintf(STDERR,
***************
*** 5590,5597 ****
  		    MapPartIdIntoName(apart, pname);
  		    fprintf(STDERR,
  			    "*** Warning: Orphaned RO volume %lu exists on %s %s\n",
! 			    (unsigned long)volumeinfo->volid,
! 			    hostutil_GetNameByINet(aserver), pname);
  		    fprintf(STDERR,
  			    "    VLDB reports its RO volume ID is %u\n",
  			    entry.volumeId[ROVOL]);
--- 5642,5651 ----
  		    MapPartIdIntoName(apart, pname);
  		    fprintf(STDERR,
  			    "*** Warning: Orphaned RO volume %lu exists on %s %s\n",
!                             (unsigned long)volumeinfo->volid,
!                             noresolve ?
!                             afs_inet_ntoa_r(aserver, hoststr) :
!                             hostutil_GetNameByINet(aserver), pname);
  		    fprintf(STDERR,
  			    "    VLDB reports its RO volume ID is %u\n",
  			    entry.volumeId[ROVOL]);
***************
*** 5970,5975 ****
--- 6024,6030 ----
      afs_int32 failures = 0, modifications = 0, tentries = 0;
      afs_int32 modified;
      afs_uint32 maxvolid = 0;
+     char hoststr[16];
  
      volumeInfo.volEntries_val = (volintInfo *) 0;
      volumeInfo.volEntries_len = 0;
***************
*** 6021,6027 ****
  		fprintf(STDOUT,
  			"Processing volume entry %d: %s (%lu) on server %s %s...\n",
  			j + 1, vi->name, (unsigned long)vi->volid,
! 			hostutil_GetNameByINet(aserver), pname);
  		fflush(STDOUT);
  	    }
  
--- 6076,6084 ----
  		fprintf(STDOUT,
  			"Processing volume entry %d: %s (%lu) on server %s %s...\n",
  			j + 1, vi->name, (unsigned long)vi->volid,
!                         noresolve ?
!                         afs_inet_ntoa_r(aserver, hoststr) :
!                         hostutil_GetNameByINet(aserver), pname);
  		fflush(STDOUT);
  	    }
  
***************
*** 6050,6056 ****
  	if (pfail) {
  	    fprintf(STDERR,
  		    "Could not process entries on server %s partition %s\n",
! 		    hostutil_GetNameByINet(aserver), pname);
  	}
  	if (volumeInfo.volEntries_val) {
  	    free(volumeInfo.volEntries_val);
--- 6107,6115 ----
  	if (pfail) {
  	    fprintf(STDERR,
  		    "Could not process entries on server %s partition %s\n",
!                     noresolve ?
!                     afs_inet_ntoa_r(aserver, hoststr) :
!                     hostutil_GetNameByINet(aserver), pname);
  	}
  	if (volumeInfo.volEntries_val) {
  	    free(volumeInfo.volEntries_val);
***************
*** 6136,6141 ****
--- 6195,6201 ----
      int idx;
      afs_int32 code, error = 0;
      char pname[10];
+     char hoststr[16];
  
      if (modified)
  	*modified = 0;
***************
*** 6170,6176 ****
  		fprintf(STDERR,
  			"Transaction call failed for RW volume %u on server %s %s\n",
  			entry->volumeId[RWVOL],
! 			hostutil_GetNameByINet(entry->serverNumber[idx]),
  			pname);
  		ERROR_EXIT(code);
  	    }
--- 6230,6238 ----
  		fprintf(STDERR,
  			"Transaction call failed for RW volume %u on server %s %s\n",
  			entry->volumeId[RWVOL],
!                         noresolve ?
!                         afs_inet_ntoa_r(entry->serverNumber[idx], hoststr) :
!                         hostutil_GetNameByINet(entry->serverNumber[idx]),
  			pname);
  		ERROR_EXIT(code);
  	    }
***************
*** 6207,6213 ****
  		fprintf(STDERR,
  			"Transaction call failed for BK volume %u on server %s %s\n",
  			entry->volumeId[BACKVOL],
! 			hostutil_GetNameByINet(entry->serverNumber[idx]),
  			pname);
  		ERROR_EXIT(code);
  	    }
--- 6269,6277 ----
  		fprintf(STDERR,
  			"Transaction call failed for BK volume %u on server %s %s\n",
  			entry->volumeId[BACKVOL],
!                         noresolve ?
!                         afs_inet_ntoa_r(entry->serverNumber[idx], hoststr) :
!                         hostutil_GetNameByINet(entry->serverNumber[idx]),
  			pname);
  		ERROR_EXIT(code);
  	    }
***************
*** 6238,6243 ****
--- 6302,6308 ----
      int foundro = 0, modentry = 0;
      afs_int32 code, error = 0;
      char pname[10];
+     char hoststr[16];
  
      if (modified)
  	*modified = 0;
***************
*** 6266,6272 ****
  	    fprintf(STDERR,
  		    "Transaction call failed for RO %u on server %s %s\n",
  		    entry->volumeId[ROVOL],
! 		    hostutil_GetNameByINet(entry->serverNumber[idx]), pname);
  	    ERROR_EXIT(code);
  	}
      }
--- 6331,6339 ----
  	    fprintf(STDERR,
  		    "Transaction call failed for RO %u on server %s %s\n",
  		    entry->volumeId[ROVOL],
!                     noresolve ?
!                     afs_inet_ntoa_r(entry->serverNumber[idx], hoststr) :
!                     hostutil_GetNameByINet(entry->serverNumber[idx]), pname);
  	    ERROR_EXIT(code);
  	}
      }
***************
*** 6550,6555 ****
--- 6617,6623 ----
      afs_int32 tid;
      struct rx_connection *aconn;
      int islocked;
+     char hoststr[16];
  
      error = 0;
      aconn = (struct rx_connection *)0;
***************
*** 6714,6720 ****
  		    if (!code) {
  			VPRINT2("Renamed RO volume %s on host %s\n",
  				nameBuffer,
! 				hostutil_GetNameByINet(entry->
  						       serverNumber[i]));
  			code = AFSVolEndTrans(aconn, tid, &rcode);
  			tid = 0;
--- 6782,6790 ----
  		    if (!code) {
  			VPRINT2("Renamed RO volume %s on host %s\n",
  				nameBuffer,
!                                 noresolve ?
!                                 afs_inet_ntoa_r(entry->serverNumber[i], hoststr) :
!                                 hostutil_GetNameByINet(entry->
  						       serverNumber[i]));
  			code = AFSVolEndTrans(aconn, tid, &rcode);
  			tid = 0;
Index: openafs/src/volser/vsutils.c
diff -c openafs/src/volser/vsutils.c:1.16.2.4 openafs/src/volser/vsutils.c:1.16.2.5
*** openafs/src/volser/vsutils.c:1.16.2.4	Tue Oct 30 11:24:13 2007
--- openafs/src/volser/vsutils.c	Sat Aug 16 15:56:26 2008
***************
*** 11,17 ****
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsutils.c,v 1.16.2.4 2007/10/30 15:24:13 shadow Exp $");
  
  #include <afs/stds.h>
  #include <string.h>
--- 11,17 ----
  #include <afs/param.h>
  
  RCSID
!     ("$Header: /cvs/openafs/src/volser/vsutils.c,v 1.16.2.5 2008/08/16 19:56:26 shadow Exp $");
  
  #include <afs/stds.h>
  #include <string.h>
***************
*** 47,59 ****
  #include "volint.h"
  #include "lockdata.h"
  
  struct ubik_client *cstruct;
  static rxkad_level vsu_rxkad_level = rxkad_clear;
  
  static void
! ovlentry_to_nvlentry(oentryp, nentryp)
!      struct vldbentry *oentryp;
!      struct nvldbentry *nentryp;
  {
      register int i;
  
--- 47,60 ----
  #include "volint.h"
  #include "lockdata.h"
  
+ #include <vsutils_prototypes.h>
+ 
  struct ubik_client *cstruct;
  static rxkad_level vsu_rxkad_level = rxkad_clear;
  
  static void
! ovlentry_to_nvlentry(struct vldbentry *oentryp,
!                      struct nvldbentry *nentryp)
  {
      register int i;
  
***************
*** 71,80 ****
      nentryp->flags = oentryp->flags;
  }
  
! static
! nvlentry_to_ovlentry(nentryp, oentryp)
!      struct nvldbentry *nentryp;
!      struct vldbentry *oentryp;
  {
      register int i;
  
--- 72,80 ----
      nentryp->flags = oentryp->flags;
  }
  
! static int
! nvlentry_to_ovlentry(struct nvldbentry *nentryp,
!                      struct vldbentry *oentryp)
  {
      register int i;
  
***************
*** 102,109 ****
  
  static int newvlserver = 0;
  
! VLDB_CreateEntry(entryp)
!      struct nvldbentry *entryp;
  {
      struct vldbentry oentry;
      register int code;
--- 102,109 ----
  
  static int newvlserver = 0;
  
! int
! VLDB_CreateEntry(struct nvldbentry *entryp)
  {
      struct vldbentry oentry;
      register int code;
***************
*** 128,136 ****
      return code;
  }
  
! VLDB_GetEntryByID(volid, voltype, entryp)
!      afs_int32 volid, voltype;
!      struct nvldbentry *entryp;
  {
      struct vldbentry oentry;
      register int code;
--- 128,135 ----
      return code;
  }
  
! int
! VLDB_GetEntryByID(afs_int32 volid, afs_int32 voltype, struct nvldbentry *entryp)
  {
      struct vldbentry oentry;
      register int code;
***************
*** 155,163 ****
      return code;
  }
  
! VLDB_GetEntryByName(namep, entryp)
!      char *namep;
!      struct nvldbentry *entryp;
  {
      struct vldbentry oentry;
      register int code;
--- 154,161 ----
      return code;
  }
  
! int
! VLDB_GetEntryByName(char *namep, struct nvldbentry *entryp)
  {
      struct vldbentry oentry;
      register int code;
***************
*** 181,189 ****
      return code;
  }
  
! VLDB_ReplaceEntry(volid, voltype, entryp, releasetype)
!      afs_int32 volid, voltype, releasetype;
!      struct nvldbentry *entryp;
  {
      struct vldbentry oentry;
      register int code;
--- 179,186 ----
      return code;
  }
  
! int 
! VLDB_ReplaceEntry(afs_int32 volid, afs_int32 voltype, struct nvldbentry *entryp, afs_int32 releasetype)
  {
      struct vldbentry oentry;
      register int code;
***************
*** 213,223 ****
  }
  
  
! 
! VLDB_ListAttributes(attrp, entriesp, blkentriesp)
!      VldbListByAttributes *attrp;
!      afs_int32 *entriesp;
!      nbulkentries *blkentriesp;
  {
      bulkentries arrayEntries;
      register int code, i;
--- 210,219 ----
  }
  
  
! int
! VLDB_ListAttributes(VldbListByAttributes *attrp,
!                     afs_int32 *entriesp,
!                     nbulkentries *blkentriesp)
  {
      bulkentries arrayEntries;
      register int code, i;
***************
*** 254,267 ****
      return code;
  }
  
! VLDB_ListAttributesN2(attrp, name, thisindex, nentriesp, blkentriesp,
! 		      nextindexp)
!      VldbListByAttributes *attrp;
!      char *name;
!      afs_int32 thisindex;
!      afs_int32 *nentriesp;
!      nbulkentries *blkentriesp;
!      afs_int32 *nextindexp;
  {
      afs_int32 code;
  
--- 250,262 ----
      return code;
  }
  
! int
! VLDB_ListAttributesN2(VldbListByAttributes *attrp,
!                       char *name,
!                       afs_int32 thisindex,
!                       afs_int32 *nentriesp,
!                       nbulkentries *blkentriesp,
!                       afs_int32 *nextindexp)
  {
      afs_int32 code;
  
***************
*** 287,294 ****
  struct cacheips cacheips[GETADDRUCACHESIZE];
  int cacheip_index = 0;
  
! VLDB_IsSameAddrs(serv1, serv2, errorp)
!      afs_int32 serv1, serv2, *errorp;
  {
      register int code;
      ListAddrByAttributes attrs;
--- 282,289 ----
  struct cacheips cacheips[GETADDRUCACHESIZE];
  int cacheip_index = 0;
  
! int
! VLDB_IsSameAddrs(afs_int32 serv1, afs_int32 serv2, afs_int32 *errorp)
  {
      register int code;
      ListAddrByAttributes attrs;
***************
*** 377,384 ****
    to get a rxkad_clear connection, simply don't call this.
  */
  void
! vsu_SetCrypt(cryptflag)
!      int cryptflag;
  {
      if (cryptflag) {
  	vsu_rxkad_level = rxkad_crypt;
--- 372,378 ----
    to get a rxkad_clear connection, simply don't call this.
  */
  void
! vsu_SetCrypt(int cryptflag)
  {
      if (cryptflag) {
  	vsu_rxkad_level = rxkad_crypt;
***************
*** 392,404 ****
    Get the appropriate type of ubik client structure out from the system.
  */
  afs_int32
! vsu_ClientInit(noAuthFlag, confDir, cellName, sauth, uclientp, secproc)
!      int noAuthFlag;
!      int (*secproc) ();
!      char *cellName;
!      struct ubik_client **uclientp;
!      char *confDir;
!      afs_int32 sauth;
  {
      afs_int32 code, scIndex, i;
      struct afsconf_cell info;
--- 386,393 ----
    Get the appropriate type of ubik client structure out from the system.
  */
  afs_int32
! vsu_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth, 
! 	       struct ubik_client **uclientp, int (*secproc)())
  {
      afs_int32 code, scIndex, i;
      struct afsconf_cell info;
***************
*** 420,427 ****
   * and return the result as <rname>.
   */
  int
! vsu_ExtractName(rname, name)
!      char rname[], name[];
  {
      char sname[VOLSER_OLDMAXVOLNAME + 1];
      int total;
--- 409,415 ----
   * and return the result as <rname>.
   */
  int
! vsu_ExtractName(char rname[], char name[])
  {
      char sname[VOLSER_OLDMAXVOLNAME + 1];
      int total;
***************
*** 449,460 ****
  
  /* returns 0 if failed */
  afs_uint32
! vsu_GetVolumeID(astring, acstruct, errp)
!      struct ubik_client *acstruct;
!      afs_int32 *errp;
!      char *astring;
  {
-     afs_uint32 value;
      char volname[VOLSER_OLDMAXVOLNAME + 1];
      struct nvldbentry entry;
      afs_int32 vcode = 0;
--- 437,444 ----
  
  /* returns 0 if failed */
  afs_uint32
! vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp)
  {
      char volname[VOLSER_OLDMAXVOLNAME + 1];
      struct nvldbentry entry;
      afs_int32 vcode = 0;
Index: openafs/src/volser/vsutils_prototypes.h
diff -c /dev/null openafs/src/volser/vsutils_prototypes.h:1.1.4.2
*** /dev/null	Tue Oct  7 22:25:14 2008
--- openafs/src/volser/vsutils_prototypes.h	Mon Aug 18 13:23:40 2008
***************
*** 0 ****
--- 1,17 ----
+ #ifndef	_VSUTILS_PROTOTYPES_H
+ #define _VSUTILS_PROTOTYPES_H
+ /* vsutils.c */
+ extern int VLDB_CreateEntry(struct nvldbentry *entryp);
+ extern int VLDB_GetEntryByID(afs_int32 volid, afs_int32 voltype, struct nvldbentry *entryp);
+ extern int VLDB_GetEntryByName(char *namep, struct nvldbentry *entryp);
+ extern int VLDB_ReplaceEntry(afs_int32 volid, afs_int32 voltype, struct nvldbentry *entryp, afs_int32 releasetype);
+ extern int VLDB_ListAttributes(VldbListByAttributes *attrp, afs_int32 *entriesp, nbulkentries *blkentriesp);
+ extern int VLDB_ListAttributesN2(VldbListByAttributes *attrp, char *name, afs_int32 thisindex,
+            afs_int32 *nentriesp, nbulkentries *blkentriesp, afs_int32 *nextindexp);
+ extern int VLDB_IsSameAddrs(afs_int32 serv1, afs_int32 serv2, afs_int32 *errorp);
+ extern void vsu_SetCrypt(int cryptflag);
+ extern afs_int32 vsu_ClientInit(int noAuthFlag, char *confDir, char *cellName, afs_int32 sauth,
+                struct ubik_client **uclientp, int (*secproc)());
+ extern int vsu_ExtractName(char rname[], char name[]);
+ extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp);
+ #endif
