--- openafs/src/JAVA/libjafs/File.c:1.3.2.2	Tue Apr 10 14:43:28 2007
+++ openafs/src/JAVA/libjafs/File.c	Sun Nov 30 15:25:00 2008
@@ -20,6 +20,7 @@
  */
 
 #include <afs/param.h>
+#include <afs/com_err.h>
 #include <errno.h>
 
 #include "Internal.h"
--- openafs/src/WINNT/afsd/fs.c:1.16.2.22	Wed Oct 31 00:13:20 2007
+++ openafs/src/WINNT/afsd/fs.c	Sun Nov 30 15:25:02 2008
@@ -9,6 +9,7 @@
 
 #include <afs/param.h>
 #include <afs/stds.h>
+#include <afs/com_err.h>
 
 #include <windows.h>
 #include <stdlib.h>
--- openafs/src/WINNT/afsd/symlink.c:1.2.20.6	Wed Oct 31 00:13:21 2007
+++ openafs/src/WINNT/afsd/symlink.c	Sun Nov 30 15:25:02 2008
@@ -9,6 +9,7 @@
 
 #include <afs/param.h>
 #include <afs/stds.h>
+#include <afs/com_err.h>
 
 #include <windows.h>
 #include <stdlib.h>
--- openafs/src/WINNT/install/NSIS/CellServDB:1.2.2.7	Thu Jul  5 19:44:55 2007
+++ openafs/src/WINNT/install/NSIS/CellServDB	Sun Dec 21 00:46:42 2008
@@ -11,9 +11,9 @@
 193.170.243.12                  #baloo.oeaw.ac.at
 193.170.243.14                  #akela.oeaw.ac.at
 >cgv.tugraz.at          #CGV cell
-129.27.224.133                  #phobos.cgv.tugraz.at
-129.27.224.134                  #deimos.cgv.tugraz.at
-129.27.224.210                  #trinculo.cgv.tugraz.at
+129.27.218.30                   #phobos.cgv.tugraz.at
+129.27.218.31                   #deimos.cgv.tugraz.at
+129.27.218.32                   #trinculo.cgv.tugraz.at
 >itp.tugraz.at          #Institute of Theoretical and Computational Physics, TU Graz, Aus
 129.27.161.7                    #faepafs1.tu-graz.ac.at
 129.27.161.15                   #faepafs2.tu-graz.ac.at
@@ -44,6 +44,8 @@
 129.129.190.142                 #afs02.psi.ch
 >extundo.com            #Simon Josefsson's cell
 195.42.214.241                  #slipsten.extundo.com
+>freedaemon.com         #Free Daemon Consulting, Oklahoma City, OK, USA
+66.210.104.254                  #afs0.freedaemon.com
 >membrain.com           #membrain.com
 66.93.118.125                   #stormy
 130.85.24.11                    #weasel
@@ -206,20 +208,20 @@
 129.186.6.243                   #afsdb-2.iastate.edu
 129.186.142.243                 #afsdb-3.iastate.edu
 >athena.mit.edu         #MIT/Athena cell
-18.7.1.66                       #paris.mit.edu.
-18.7.1.74                       #chimera.mit.edu.
-18.158.0.37                     #prill.mit.edu.
+18.7.1.66                       #paris.mit.edu
+18.7.1.74                       #chimera.mit.edu
+18.158.0.37                     #prill.mit.edu
 >dev.mit.edu            #MIT/IS Development cell
-18.7.1.70                       #wham.mit.edu.
-18.92.1.219                     #click.mit.edu.
-18.92.1.220                     #whirr.mit.edu.
+18.7.1.70                       #wham.mit.edu
+18.92.1.219                     #click.mit.edu
+18.92.1.220                     #whirr.mit.edu
 >net.mit.edu            #MIT/Network Group cell
 18.7.7.73                       #gracie.mit.edu
 18.7.21.95                      #george.mit.edu
 >sipb.mit.edu           #MIT/SIPB cell
-18.181.0.19                     #reynelda.mit.edu.
-18.181.0.22                     #rosebud.mit.edu.
-18.181.0.23                     #ronald-ann.mit.edu.
+18.181.0.19                     #reynelda.mit.edu
+18.181.0.22                     #rosebud.mit.edu
+18.181.0.23                     #ronald-ann.mit.edu
 >soap.mit.edu           #MIT School Of Architecture & Planning
 18.89.1.204                     #crypt.mit.edu
 18.89.1.209                     #grotto.mit.edu
@@ -321,10 +323,6 @@
 141.211.43.104                  #linat04.grid.umich.edu
 >citi.umich.edu         #Center for Information Technology Integration
 141.211.133.5                   #babylon.citi.umich.edu
->lsa.umich.edu          #University of Michigan - College of LS&A
-141.211.211.53                  #gerow.lsa.umich.edu
-141.211.211.72                  #collines.lsa.umich.edu
-141.211.211.153                 #hodges.lsa.umich.edu
 >sph.umich.edu          #University of Michigan -- School of Public  Health
 141.211.51.137                  #afssph7.sph.umich.edu
 141.211.51.139                  #afssph0.sph.umich.edu
@@ -356,6 +354,8 @@
 144.92.13.16                    #moe.cae.wisc.edu
 >hep.wisc.edu           #University of Wisconsin -- High Energy Physics
 128.104.28.219                  #anise.hep.wisc.edu
+144.92.180.7                    #rosemary.hep.wisc.edu
+144.92.180.30                   #fennel.hep.wisc.edu
 >physics.wisc.edu       #Univ. of Wisconsin-Madison, Physics Department
 128.104.160.13                  #kendra.physics.wisc.edu
 128.104.160.14                  #fray.physics.wisc.edu
@@ -377,6 +377,8 @@
 >grif.fr                #GRIF cell
 192.54.208.18                   #node03.datagrid.cea.fr
 >in2p3.fr               #IN2P3 production cell
+134.158.104.11                  #ccafsdb01.in2p3.fr
+134.158.104.12                  #ccafsdb02.in2p3.fr
 134.158.232.11                  #ccafsdb1.in2p3.fr
 134.158.232.12                  #ccafsdb2.in2p3.fr
 134.158.232.13                  #ccafsdb3.in2p3.fr
@@ -406,6 +408,8 @@
 128.55.128.250                  #mars.nersc.gov
 128.55.128.252                  #alfred.nersc.gov
 128.55.128.254                  #lurch.nersc.gov
+>doe.atomki.hu          #Institute of Nuclear Research (MTA ATOMKI), Debrecen, Hungary
+193.6.179.31                    #afs.doe.atomki.hu
 >bme.hu                 #Budapest University of Technology and Economics
 152.66.241.6                    #afs.iit.bme.hu
 >kfki.hu                #Research Institute for Nuclear and Particle Physics - Budapest,H
@@ -449,6 +453,8 @@
 >pi.infn.it             #INFN, Sezione di Pisa
 131.114.134.26                  #unknownhost.pi.infn.it
 192.84.133.50                   #aix1.pi.infn.it
+>roma3.infn.it          #Istituto Nazionale di Fisica Nucleare (INFN), Italia
+193.205.159.17                  #afsrm3.roma3.infn.it
 >psm.it                 #Progetto San Marco, Universita' di Roma-1
 151.100.1.65                    #atlante.psm.uniroma1.it
 >tgrid.it               #CASPUR-CILEA-CINECA Grid Cell
@@ -587,3 +593,6 @@
 194.36.2.5                      #afs3.hep.man.ac.uk
 >rl.ac.uk               #Rutherford Appleton Lab, England
 130.246.183.164                 #wallace.cc.rl.ac.uk
+130.246.183.203                 #afs1.gridpp.rl.ac.uk
+130.246.183.204                 #afs2.gridpp.rl.ac.uk
+130.246.183.205                 #afs3.gridpp.rl.ac.uk
--- openafs/src/WINNT/install/wix/CellServDB:1.2.2.7	Thu Jul  5 19:44:59 2007
+++ openafs/src/WINNT/install/wix/CellServDB	Sun Dec 21 00:46:42 2008
@@ -11,9 +11,9 @@
 193.170.243.12                  #baloo.oeaw.ac.at
 193.170.243.14                  #akela.oeaw.ac.at
 >cgv.tugraz.at          #CGV cell
-129.27.224.133                  #phobos.cgv.tugraz.at
-129.27.224.134                  #deimos.cgv.tugraz.at
-129.27.224.210                  #trinculo.cgv.tugraz.at
+129.27.218.30                   #phobos.cgv.tugraz.at
+129.27.218.31                   #deimos.cgv.tugraz.at
+129.27.218.32                   #trinculo.cgv.tugraz.at
 >itp.tugraz.at          #Institute of Theoretical and Computational Physics, TU Graz, Aus
 129.27.161.7                    #faepafs1.tu-graz.ac.at
 129.27.161.15                   #faepafs2.tu-graz.ac.at
@@ -44,6 +44,8 @@
 129.129.190.142                 #afs02.psi.ch
 >extundo.com            #Simon Josefsson's cell
 195.42.214.241                  #slipsten.extundo.com
+>freedaemon.com         #Free Daemon Consulting, Oklahoma City, OK, USA
+66.210.104.254                  #afs0.freedaemon.com
 >membrain.com           #membrain.com
 66.93.118.125                   #stormy
 130.85.24.11                    #weasel
@@ -206,20 +208,20 @@
 129.186.6.243                   #afsdb-2.iastate.edu
 129.186.142.243                 #afsdb-3.iastate.edu
 >athena.mit.edu         #MIT/Athena cell
-18.7.1.66                       #paris.mit.edu.
-18.7.1.74                       #chimera.mit.edu.
-18.158.0.37                     #prill.mit.edu.
+18.7.1.66                       #paris.mit.edu
+18.7.1.74                       #chimera.mit.edu
+18.158.0.37                     #prill.mit.edu
 >dev.mit.edu            #MIT/IS Development cell
-18.7.1.70                       #wham.mit.edu.
-18.92.1.219                     #click.mit.edu.
-18.92.1.220                     #whirr.mit.edu.
+18.7.1.70                       #wham.mit.edu
+18.92.1.219                     #click.mit.edu
+18.92.1.220                     #whirr.mit.edu
 >net.mit.edu            #MIT/Network Group cell
 18.7.7.73                       #gracie.mit.edu
 18.7.21.95                      #george.mit.edu
 >sipb.mit.edu           #MIT/SIPB cell
-18.181.0.19                     #reynelda.mit.edu.
-18.181.0.22                     #rosebud.mit.edu.
-18.181.0.23                     #ronald-ann.mit.edu.
+18.181.0.19                     #reynelda.mit.edu
+18.181.0.22                     #rosebud.mit.edu
+18.181.0.23                     #ronald-ann.mit.edu
 >soap.mit.edu           #MIT School Of Architecture & Planning
 18.89.1.204                     #crypt.mit.edu
 18.89.1.209                     #grotto.mit.edu
@@ -321,10 +323,6 @@
 141.211.43.104                  #linat04.grid.umich.edu
 >citi.umich.edu         #Center for Information Technology Integration
 141.211.133.5                   #babylon.citi.umich.edu
->lsa.umich.edu          #University of Michigan - College of LS&A
-141.211.211.53                  #gerow.lsa.umich.edu
-141.211.211.72                  #collines.lsa.umich.edu
-141.211.211.153                 #hodges.lsa.umich.edu
 >sph.umich.edu          #University of Michigan -- School of Public  Health
 141.211.51.137                  #afssph7.sph.umich.edu
 141.211.51.139                  #afssph0.sph.umich.edu
@@ -356,6 +354,8 @@
 144.92.13.16                    #moe.cae.wisc.edu
 >hep.wisc.edu           #University of Wisconsin -- High Energy Physics
 128.104.28.219                  #anise.hep.wisc.edu
+144.92.180.7                    #rosemary.hep.wisc.edu
+144.92.180.30                   #fennel.hep.wisc.edu
 >physics.wisc.edu       #Univ. of Wisconsin-Madison, Physics Department
 128.104.160.13                  #kendra.physics.wisc.edu
 128.104.160.14                  #fray.physics.wisc.edu
@@ -377,6 +377,8 @@
 >grif.fr                #GRIF cell
 192.54.208.18                   #node03.datagrid.cea.fr
 >in2p3.fr               #IN2P3 production cell
+134.158.104.11                  #ccafsdb01.in2p3.fr
+134.158.104.12                  #ccafsdb02.in2p3.fr
 134.158.232.11                  #ccafsdb1.in2p3.fr
 134.158.232.12                  #ccafsdb2.in2p3.fr
 134.158.232.13                  #ccafsdb3.in2p3.fr
@@ -406,6 +408,8 @@
 128.55.128.250                  #mars.nersc.gov
 128.55.128.252                  #alfred.nersc.gov
 128.55.128.254                  #lurch.nersc.gov
+>doe.atomki.hu          #Institute of Nuclear Research (MTA ATOMKI), Debrecen, Hungary
+193.6.179.31                    #afs.doe.atomki.hu
 >bme.hu                 #Budapest University of Technology and Economics
 152.66.241.6                    #afs.iit.bme.hu
 >kfki.hu                #Research Institute for Nuclear and Particle Physics - Budapest,H
@@ -449,6 +453,8 @@
 >pi.infn.it             #INFN, Sezione di Pisa
 131.114.134.26                  #unknownhost.pi.infn.it
 192.84.133.50                   #aix1.pi.infn.it
+>roma3.infn.it          #Istituto Nazionale di Fisica Nucleare (INFN), Italia
+193.205.159.17                  #afsrm3.roma3.infn.it
 >psm.it                 #Progetto San Marco, Universita' di Roma-1
 151.100.1.65                    #atlante.psm.uniroma1.it
 >tgrid.it               #CASPUR-CILEA-CINECA Grid Cell
@@ -587,3 +593,6 @@
 194.36.2.5                      #afs3.hep.man.ac.uk
 >rl.ac.uk               #Rutherford Appleton Lab, England
 130.246.183.164                 #wallace.cc.rl.ac.uk
+130.246.183.203                 #afs1.gridpp.rl.ac.uk
+130.246.183.204                 #afs2.gridpp.rl.ac.uk
+130.246.183.205                 #afs3.gridpp.rl.ac.uk
--- openafs/src/afs/afs.h:1.48.2.35	Mon Oct 20 12:41:00 2008
+++ openafs/src/afs/afs.h	Mon Jan 19 14:27:19 2009
@@ -170,15 +170,44 @@
 /* The actual number of bytes in the SmallFid, not the sizeof struct. */
 #define SIZEOF_SMALLFID 10
 
+/* Queues 
+ * ------
+ *
+ *  Circular queues, implemented with pointers. Structures may contain as many
+ *  queues as required, which may be located at any point within the structure,
+ *  providing the QEntry macro is used to translate between a queue pointer, and
+ *  the address of its containing structure
+ */
 
-/*
-  * Queues implemented with both pointers and short offsets into a disk file.
-  */
 struct afs_q {
     struct afs_q *next;
     struct afs_q *prev;
 };
 
+#define	QInit(q)    ((q)->prev = (q)->next = (q))
+#define	QAdd(q,e)   ((e)->next = (q)->next, (e)->prev = (q), \
+			(q)->next->prev = (e), (q)->next = (e))
+#define	QRemove(e)  ((e)->next->prev = (e)->prev, (e)->prev->next = (e)->next, (e)->prev = NULL, (e)->next = NULL)
+#define	QNext(e)    ((e)->next)
+#define QPrev(e)    ((e)->prev)
+#define QEmpty(q)   ((q)->prev == (q))
+/* this one takes q1 and sticks it on the end of q2 - that is, the other end, not the end
+ * that things are added onto.  q1 shouldn't be empty, it's silly */
+#define QCat(q1,q2) ((q2)->prev->next = (q1)->next, (q1)->next->prev=(q2)->prev, (q1)->prev->next=(q2), (q2)->prev=(q1)->prev, (q1)->prev=(q1)->next=(q1))
+
+/* Given a pointer to an afs_q within a structure, go back to the address of
+ * the parent structure
+ */
+
+#define QEntry(queue, structure, member) \
+	((structure *)((char *)(queue)-(char *)(&((structure *)NULL)->member)))
+
+/* And implement operations for individual lists in terms of the above macro */
+
+#define QTOV(e)	    QEntry(e, struct vcache, vlruq)
+#define QTOC(e)	    QEntry(e, struct cell, lruq)
+#define QTOVH(e)    QEntry(e, struct vcache, vhashq)
+
 struct vrequest {
     afs_int32 uid;		/* user id making the request */
     afs_int32 busyCount;	/* how many busies we've seen so far */
@@ -318,29 +347,6 @@
 	 (!(afid)->Fid.Unique && ((tvc)->states & CUnique))))
 
 
-/*
-  * Operations on circular queues implemented with pointers.  Note: these queue
-  * objects are always located at the beginning of the structures they are linking.
-  */
-#define	QInit(q)    ((q)->prev = (q)->next = (q))
-#define	QAdd(q,e)   ((e)->next = (q)->next, (e)->prev = (q), \
-			(q)->next->prev = (e), (q)->next = (e))
-#define	QRemove(e)  ((e)->next->prev = (e)->prev, (e)->prev->next = (e)->next, (e)->prev = NULL, (e)->next = NULL)
-#define	QNext(e)    ((e)->next)
-#define QPrev(e)    ((e)->prev)
-#define QEmpty(q)   ((q)->prev == (q))
-/* this one takes q1 and sticks it on the end of q2 - that is, the other end, not the end
- * that things are added onto.  q1 shouldn't be empty, it's silly */
-#define QCat(q1,q2) ((q2)->prev->next = (q1)->next, (q1)->next->prev=(q2)->prev, (q1)->prev->next=(q2), (q2)->prev=(q1)->prev, (q1)->prev=(q1)->next=(q1))
-/*
- * Do lots of address arithmetic to go from vlruq to the base of the vcache
- * structure.  Don't move struct vnode, since we think of a struct vcache as
- * a specialization of a struct vnode
- */
-#define	QTOV(e)	    ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->vlruq))) - ((char *)(e)))))
-#define	QTOC(e)	    ((struct cell *)((char *) (e)))
-#define	QTOVH(e)   ((struct vcache *)(((char *) (e)) - (((char *)(&(((struct vcache *)(e))->vhashq))) - ((char *)(e)))))
-
 #define	SRVADDR_MH	1
 #define	SRVADDR_ISDOWN	0x20	/* same as SRVR_ISDOWN */
 #define  SRVADDR_NOUSE    0x40	/* Don't use this srvAddr */
--- openafs/src/afs/afs_call.c:1.74.2.32	Sat Jun 28 23:26:03 2008
+++ openafs/src/afs/afs_call.c	Thu Mar 19 22:32:59 2009
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/afs/afs_call.c,v 1.74.2.33 2009/03/20 02:32:59 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
@@ -825,7 +825,8 @@
 	    afs_CacheInit(cparms.cacheScaches, cparms.cacheFiles,
 			  cparms.cacheBlocks, cparms.cacheDcaches,
 			  cparms.cacheVolumes, cparms.chunkSize,
-			  cparms.memCacheFlag, cparms.inodes, cparms.users);
+			  cparms.memCacheFlag, cparms.inodes, cparms.users, 
+			  cparms.dynamic_vcaches);
 
     } else if (parm == AFSOP_CACHEINODE) {
 	ino_t ainode = parm2;
--- openafs/src/afs/afs_cbqueue.c:1.9.2.4	Thu Mar  2 01:44:05 2006
+++ openafs/src/afs/afs_cbqueue.c	Thu Mar 19 22:32:59 2009
@@ -75,7 +75,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/afs_cbqueue.c,v 1.9.2.4 2006/03/02 06:44:05 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/afs_cbqueue.c,v 1.9.2.5 2009/03/20 02:32:59 shadow Exp $");
 
 #include "afs/sysincludes.h"	/*Standard vendor system headers */
 #include "afsincludes.h"	/*AFS-based standard headers */
@@ -180,7 +180,7 @@
  */
 
 /* Sanity check on the callback queue. Allow for slop in the computation. */
-#ifdef AFS_OSF_ENV
+#if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
 #define CBQ_LIMIT (afs_maxvcount + 10)
 #else
 #define CBQ_LIMIT (afs_cacheStats + afs_stats_cmperf.vcacheXAllocs + 10)
--- openafs/src/afs/afs_daemons.c:1.28.2.14	Mon Oct 22 20:03:01 2007
+++ openafs/src/afs/afs_daemons.c	Thu Mar 19 22:32:59 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.28.2.14 2007/10/23 00:03:01 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/afs_daemons.c,v 1.28.2.15 2009/03/20 02:32:59 shadow Exp $");
 
 #ifdef AFS_AIX51_ENV
 #define __FULL_PROTO
@@ -40,6 +40,8 @@
 #define afs_CheckRXEpoch() {if (rxepoch_checked == 0 && rxkad_EpochWasSet) { \
 	rxepoch_checked = 1; afs_GCUserData(/* force flag */ 1);  } }
 
+extern int afsd_dynamic_vcaches;
+
 /* PAG garbage collection */
 /* We induce a compile error if param.h does not define AFS_GCPAGS */
 afs_int32 afs_gcpags = AFS_GCPAGS;
@@ -116,13 +118,13 @@
     struct afs_exporter *exporter;
     afs_int32 now;
     afs_int32 last3MinCheck, last10MinCheck, last60MinCheck, lastNMinCheck;
-    afs_int32 last1MinCheck;
+    afs_int32 last1MinCheck, last5MinCheck;
     afs_uint32 lastCBSlotBump;
     char cs_warned = 0;
 
     AFS_STATCNT(afs_Daemon);
     last1MinCheck = last3MinCheck = last60MinCheck = last10MinCheck =
-	lastNMinCheck = 0;
+    last5MinCheck = lastNMinCheck = 0;
 
     afs_rootFid.Fid.Volume = 0;
     while (afs_initState < 101)
@@ -150,6 +152,7 @@
     last3MinCheck = now - 90 + ((afs_random() & 0x7fffffff) % 180);
     last60MinCheck = now - 1800 + ((afs_random() & 0x7fffffff) % 3600);
     last10MinCheck = now - 300 + ((afs_random() & 0x7fffffff) % 600);
+    last5MinCheck = now - 150 + ((afs_random() & 0x7fffffff) % 300);
     lastNMinCheck = now - 90 + ((afs_random() & 0x7fffffff) % 180);
 
     /* start off with afs_initState >= 101 (basic init done) */
@@ -191,6 +194,19 @@
 					 * tickets */
 	    last3MinCheck = now;
 	}
+#ifdef AFS_MAXVCOUNT_ENV
+    if (afsd_dynamic_vcaches && (last5MinCheck + 300 < now)) {
+        /* start with trying to drop us back to our base usage */
+        int anumber;
+        if (afs_maxvcount <= afs_cacheStats) 
+        anumber = VCACHE_FREE;
+        else
+        anumber = VCACHE_FREE + (afs_maxvcount - afs_cacheStats);
+
+        afs_ShakeLooseVCaches(anumber);
+        last5MinCheck = now;
+    }
+#endif
 	if (!afs_CheckServerDaemonStarted) {
 	    /* Do the check here if the correct afsd is not installed. */
 	    if (!cs_warned) {
--- openafs/src/afs/afs_init.c:1.28.2.8	Thu Jun 12 13:25:03 2008
+++ openafs/src/afs/afs_init.c	Thu Mar 19 22:32:59 2009
@@ -17,7 +17,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/afs/afs_init.c,v 1.28.2.9 2009/03/20 02:32:59 shadow Exp $");
 
 #include "afs/stds.h"
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
@@ -45,6 +45,9 @@
 static struct vnode *volumeVnode;
 #endif
 
+/* This is the kernel side of the dynamic vcache setting */
+int afsd_dynamic_vcaches = 0;	/* Enable dynamic-vcache support */
+
 /*
  * Initialization order is important.  Must first call afs_CacheInit,
  * then cache file and volume file initialization routines.  Next, the
@@ -81,7 +84,7 @@
 int
 afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
 	      afs_int32 aDentries, afs_int32 aVolumes, afs_int32 achunk,
-	      afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers)
+	      afs_int32 aflags, afs_int32 ninodes, afs_int32 nusers, afs_int32 dynamic_vcaches)
 {
     register afs_int32 i;
     register struct volume *tv;
@@ -98,6 +101,13 @@
     afs_stats_cmperf.sysName_ID = SYS_NAME_ID_UNDEFINED;
 #endif /* SYS_NAME_ID */
 
+#ifdef AFS_MAXVCOUNT_ENV
+	afsd_dynamic_vcaches = dynamic_vcaches;
+    printf("%s dynamically allocated vcaches\n", ( afsd_dynamic_vcaches ? "enabling" : "disabling" ));
+#else
+	afsd_dynamic_vcaches = 0;
+#endif
+
     printf("Starting AFS cache scan...");
     if (afs_cacheinit_flag)
 	return 0;
--- openafs/src/afs/afs_nfsdisp.c:1.18.2.4	Wed Aug 13 19:49:37 2008
+++ openafs/src/afs/afs_nfsdisp.c	Thu Jan 15 08:27:43 2009
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/afs/afs_nfsdisp.c,v 1.18.2.5 2009/01/15 13:27:43 shadow Exp $");
 
 /* Ugly Ugly Ugly  but precludes conflicting XDR macros; We want kernel xdr */
 #define __XDR_INCLUDE__
@@ -378,8 +378,8 @@
 afs_nfs2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_GETATTR, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -393,8 +393,8 @@
 afs_nfs2_setattr(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_SETATTR, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -408,8 +408,8 @@
 afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_LOOKUP, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -426,8 +426,8 @@
 afs_nfs2_readlink(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_READLINK, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -441,8 +441,8 @@
 afs_nfs2_read(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_READ, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -456,8 +456,8 @@
 afs_nfs2_write(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_WRITE, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -471,8 +471,8 @@
 afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_CREATE, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -489,8 +489,8 @@
 afs_nfs2_remove(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_REMOVE, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -504,8 +504,8 @@
 afs_nfs2_rename(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_RENAME, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -519,8 +519,8 @@
 afs_nfs2_link(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_LINK, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -534,8 +534,8 @@
 afs_nfs2_symlink(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_SYMLINK, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -549,8 +549,8 @@
 afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_MKDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -567,8 +567,8 @@
 afs_nfs2_rmdir(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_RMDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -582,8 +582,8 @@
 afs_nfs2_readdir(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_READDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -597,8 +597,8 @@
 afs_nfs2_statfs(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs2_dispatcher(0, RFS_STATFS, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
@@ -633,8 +633,8 @@
 afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs2_dispatcher(1, ACLPROC2_GETACL, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -650,8 +650,8 @@
 afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs2_dispatcher(1, ACLPROC2_SETACL, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -667,8 +667,8 @@
 afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -684,8 +684,8 @@
 afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -702,8 +702,8 @@
 afs_acl2_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs2_dispatcher(1, ACLPROC2_GETXATTRDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1140,8 +1140,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1158,8 +1158,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1176,8 +1176,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1199,8 +1199,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1217,8 +1217,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_READLINK, (char *)args, &exp, rp,
 			    crp);
@@ -1236,8 +1236,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs3_dispatcher(0, NFSPROC3_READ, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
@@ -1253,8 +1253,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_WRITE, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1271,8 +1271,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_CREATE, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1294,8 +1294,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1317,8 +1317,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1340,8 +1340,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1363,8 +1363,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1381,8 +1381,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1399,8 +1399,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_RENAME, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1417,8 +1417,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, (char *)args, &exp, rp, crp);
     if (call > 1)
 	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
@@ -1434,8 +1434,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_READDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1452,8 +1452,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, (char *)args, &exp, rp,
 			    crp);
@@ -1473,8 +1473,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1491,8 +1491,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1509,8 +1509,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, (char *)args, &exp, rp,
 			    crp);
@@ -1528,8 +1528,8 @@
 {
     u_int call;
     afs_nfs3_resp dummy;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1570,8 +1570,8 @@
 afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(1, ACLPROC3_GETACL, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1587,8 +1587,8 @@
 afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(1, ACLPROC3_SETACL, (char *)args, &exp, rp, crp);
     if (call > 1)
@@ -1605,8 +1605,8 @@
 afs_acl3_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp)
 {
     u_int call;
-    struct cred *svcred = curthread->t_cred;
-    curthread->t_cred = (struct cred *)crp;
+    struct AFS_UCRED *svcred = curthread->t_cred;
+    curthread->t_cred = (struct AFS_UCRED *)crp;
     call =
 	afs_nfs3_dispatcher(1, ACLPROC3_GETXATTRDIR, (char *)args, &exp, rp, crp);
     if (call > 1)
--- openafs/src/afs/afs_osi.c:1.48.2.18	Sun Oct 12 14:44:46 2008
+++ openafs/src/afs/afs_osi.c	Fri Mar 27 11:55:43 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.18 2008/10/12 18:44:46 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/afs_osi.c,v 1.48.2.20 2009/03/27 15:55:43 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
@@ -435,6 +435,8 @@
     return osi_linux_alloc(x, 1);
 #elif defined(AFS_FBSD_ENV)
     return osi_fbsd_alloc(x, 1);
+#elif defined(AFS_OBSD_ENV)
+    return osi_obsd_Alloc(x, 1);
 #else
     size = x;
     tm = (struct osimem *)AFS_KALLOC(size);
@@ -1120,10 +1122,15 @@
 	|| (pr->state == TASK_UNINTERRUPTIBLE)
 	|| (pr->state == TASK_STOPPED)) {
 	cr.cr_ref = 1;
-	cr.cr_uid = pr->uid;
+	cr.cr_uid = task_uid(pr);
 #if defined(AFS_LINUX26_ENV)
+#if defined(STRUCT_TASK_HAS_CRED)
+	get_group_info(pr->cred->group_info);
+	cr.cr_group_info = pr->cred->group_info;
+#else
 	get_group_info(pr->group_info);
 	cr.cr_group_info = pr->group_info;
+#endif
 #else
 	cr.cr_ngroups = pr->ngroups;
 	memcpy(cr.cr_groups, pr->groups, NGROUPS * sizeof(gid_t));
--- openafs/src/afs/afs_pioctl.c:1.81.2.33	Fri Apr 18 16:13:32 2008
+++ openafs/src/afs/afs_pioctl.c	Mon Jan 19 13:09:34 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.33 2008/04/18 20:13:32 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/afs_pioctl.c,v 1.81.2.34 2009/01/19 18:09:34 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #ifdef AFS_OBSD_ENV
@@ -88,7 +88,7 @@
 DECL_PIOCTL(PRxStatProc);
 DECL_PIOCTL(PRxStatPeer);
 DECL_PIOCTL(PPrefetchFromTape);
-DECL_PIOCTL(PResidencyCmd);
+DECL_PIOCTL(PFsCmd);
 DECL_PIOCTL(PCallBackAddr);
 DECL_PIOCTL(PNewUuid);
 /*
@@ -182,7 +182,7 @@
 	PBogus,			/* 64 -- arla: force cache check */
 	PBogus,			/* 65 -- arla: break callback */
 	PPrefetchFromTape,	/* 66 -- MR-AFS: prefetch file from tape */
-	PResidencyCmd,		/* 67 -- MR-AFS: generic commnd interface */
+	PFsCmd,			/* 67 -- RXOSD: generic commnd interface */
 	PBogus,			/* 68 -- arla: fetch stats */
 	PGetVnodeXStatus2,	/* 69 - get caller access and some vcache status */
 };
@@ -3781,21 +3781,21 @@
     return code;
 }
 
-DECL_PIOCTL(PResidencyCmd)
+DECL_PIOCTL(PFsCmd)
 {
     register afs_int32 code;
     struct conn *tc;
     struct vcache *tvc;
-    struct ResidencyCmdInputs *Inputs;
-    struct ResidencyCmdOutputs *Outputs;
+    struct FsCmdInputs *Inputs;
+    struct FsCmdOutputs *Outputs;
     struct VenusFid tfid;
     struct AFSFid *Fid;
 
-    Inputs = (struct ResidencyCmdInputs *)ain;
-    Outputs = (struct ResidencyCmdOutputs *)aout;
+    Inputs = (struct FsCmdInputs *)ain;
+    Outputs = (struct FsCmdOutputs *)aout;
     if (!avc)
 	return EINVAL;
-    if (!ain || ainSize != sizeof(struct ResidencyCmdInputs))
+    if (!ain || ainSize != sizeof(struct FsCmdInputs))
 	return EINVAL;
 
     Fid = &Inputs->fid;
@@ -3819,8 +3819,8 @@
 	    if (tc) {
 		RX_AFS_GUNLOCK();
 		code =
-		    RXAFS_ResidencyCmd(tc->id, Fid, Inputs,
-				       (struct ResidencyCmdOutputs *)aout);
+		    RXAFS_FsCmd(tc->id, Fid, Inputs, 
+					(struct FsCmdOutputs *)aout);
 		RX_AFS_GLOCK();
 	    } else
 		code = -1;
@@ -3844,7 +3844,7 @@
     afs_PutVCache(tvc);
 
     if (!code) {
-	*aoutSize = sizeof(struct ResidencyCmdOutputs);
+	*aoutSize = sizeof(struct FsCmdOutputs);
     }
     return code;
 }
--- openafs/src/afs/afs_prototypes.h:1.53.2.25	Sat Jun 28 23:26:04 2008
+++ openafs/src/afs/afs_prototypes.h	Fri Mar 20 11:05:09 2009
@@ -376,7 +376,7 @@
 			 afs_int32 ablocks, afs_int32 aDentries,
 			 afs_int32 aVolumes, afs_int32 achunk,
 			 afs_int32 aflags, afs_int32 ninodes,
-			 afs_int32 nusers);
+			 afs_int32 nusers, afs_int32 dynamic_vcaches);
 extern void afs_ComputeCacheParms(void);
 extern int afs_InitCacheInfo(register char *afile);
 extern int afs_InitVolumeInfo(char *afile);
@@ -823,6 +823,7 @@
 
 
 /* afs_vcache.c */
+extern int afs_ShakeLooseVCaches(afs_int32 anumber);
 extern afs_int32 afs_maxvcount;
 extern afs_int32 afs_vcount;
 extern int afsvnumbers;
--- openafs/src/afs/afs_trace.et:1.17.2.2	Fri Nov 23 09:34:57 2007
+++ openafs/src/afs/afs_trace.et	Mon Jan 12 08:24:37 2009
@@ -132,8 +132,8 @@
 	ec	CM_TRACE_VMRDWR, "afs_vm_rdwr: vp = 0x%lx, xfrSize 0x%lx,  toffset 0x%x"
 	ec	CM_TRACE_READFAST, "ReadFast vp 0x%lx off (0x%x, 0x%x) resid 0x%x file length (0x%x, 0x%x)"
 	ec	CM_TRACE_FETCH64CODE, "StartRX_FetchData64 for vp 0x%lx returned %d"
-	ec	CM_TRACE_FETCH64LENG, "FetchData64 for vp 0xl%x code = %d, length = (0x%x, 0x%x)"
-	ec	CM_TRACE_FETCH64READ, "FetchData64 for vp 0xl%x code = %d, length = 0x%x"
+	ec      CM_TRACE_FETCH64LENG, "FetchData64 for vp 0x%lx code = %d, length = (0x%x, 0x%x)"
+	ec      CM_TRACE_FETCH64READ, "FetchData64 for vp 0x%lx code = %d, length = 0x%x"
 	ec	CM_TRACE_VMWRITE, "afs_vm_rdwr: vp 0x%lx offset (0x%x, 0x%x) length (0x%x, 0x%x)"
 	ec	CM_TRACE_VMWRITE2, "afs_vm_rdwr: vp 0x%lx first page 0x%x pages %d"
 	ec	CM_TRACE_VMSTOREALL, "osi_VM_StoreAllSegments for vp 0x%lx call %d"
--- openafs/src/afs/afs_vcache.c:1.65.2.50	Tue Aug 26 10:02:11 2008
+++ openafs/src/afs/afs_vcache.c	Tue Mar 31 08:41:47 2009
@@ -39,7 +39,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/afs/afs_vcache.c,v 1.65.2.55 2009/03/31 12:41:47 shadow Exp $");
 
 #include "afs/sysincludes.h"	/*Standard vendor system headers */
 #include "afsincludes.h"	/*AFS-based standard headers */
@@ -77,6 +77,7 @@
 static struct afs_cbr *afs_cbrHashT[CBRSIZE];
 afs_int32 afs_bulkStatsLost;
 int afs_norefpanic = 0;
+extern int afsd_dynamic_vcaches;
 
 /* Forward declarations */
 static afs_int32 afs_QueueVCB(struct vcache *avc);
@@ -253,6 +254,7 @@
 	VN_UNLOCK(AFSTOV(avc));
 #endif
 	AFS_RELE(AFSTOV(avc));
+	afs_stats_cmperf.vcacheXAllocs--;
     } else {
 	if (afs_norefpanic) {
 	    printf("flush vc refcnt < 1");
@@ -313,6 +315,8 @@
  * held, so we don't have to worry about blocking in osi_Alloc.
  */
 static struct afs_cbr *afs_cbrSpace = 0;
+/* if alloc limit below changes, fix me! */
+static struct afs_cbr *afs_cbrHeads[2];
 struct afs_cbr *
 afs_AllocCBR(void)
 {
@@ -334,6 +338,7 @@
 	    }
 	    tsp[AFS_NCBRS - 1].next = 0;
 	    afs_cbrSpace = tsp;
+	    afs_cbrHeads[afs_stats_cmperf.CallBackAlloced] = tsp;
 	    afs_stats_cmperf.CallBackAlloced++;
 	}
     }
@@ -621,54 +626,29 @@
 #endif
 }
 
-/*
- * afs_NewVCache
- *
- * Description:
- *	This routine is responsible for allocating a new cache entry
- *	from the free list.  It formats the cache entry and inserts it
- *	into the appropriate hash tables.  It must be called with
- *	afs_xvcache write-locked so as to prevent several processes from
- *	trying to create a new cache entry simultaneously.
- *
- * Parameters:
- *	afid  : The file id of the file whose cache entry is being
- *		created.
- */
-/* LOCK: afs_NewVCache  afs_xvcache W */
-struct vcache *
-afs_NewVCache(struct VenusFid *afid, struct server *serverp)
+int
+afs_ShakeLooseVCaches(afs_int32 anumber)
 {
-    struct vcache *tvc;
+#if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
     afs_int32 i, j;
-    afs_int32 anumber = VCACHE_FREE;
-#ifdef	AFS_AIX_ENV
-    struct gnode *gnodepnt;
-#endif
-#ifdef	AFS_OSF_ENV
-    struct vcache *nvc;
-#endif /* AFS_OSF_ENV */
+    struct vcache *tvc;
     struct afs_q *tq, *uq;
     int code, fv_slept;
+    afs_int32 target = anumber;
+    int haveGlock = 1;
 
-    AFS_STATCNT(afs_NewVCache);
-
-    afs_FlushReclaimedVcaches();
+    /* Should probably deal better */
+    if (!ISAFS_GLOCK()) {
+	haveGlock = 0;
+	AFS_GLOCK();
+    }
 
-#if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
-#if defined(AFS_OSF30_ENV) || defined(AFS_LINUX22_ENV)
-    if (afs_vcount >= afs_maxvcount)
-#else
-    /*
-     * If we are using > 33 % of the total system vnodes for AFS vcache
-     * entries or we are using the maximum number of vcache entries,
-     * then free some.  (if our usage is > 33% we should free some, if
-     * our usage is > afs_maxvcount, set elsewhere to 0.5*nvnode,
-     * we _must_ free some -- no choice).
-     */
-    if (((3 * afs_vcount) > nvnode) || (afs_vcount >= afs_maxvcount))
+    if (
+#ifdef AFS_MAXVCOUNT_ENV
+	afsd_dynamic_vcaches || /* Always run if dynamic vcaches are enabled. */
 #endif
-    {
+	afs_vcount >= afs_maxvcount
+	) {
 	int i;
 	char *panicstr;
 
@@ -678,7 +658,11 @@
 	    uq = QPrev(tq);
 	    if (tvc->states & CVFlushed) {
 		refpanic("CVFlushed on VLRU");
-	    } else if (i++ > afs_maxvcount) {
+	    } else if (
+#ifdef AFS_MAXVCOUNT_ENV
+	    ! afsd_dynamic_vcaches && 
+#endif
+	    i++ > afs_maxvcount) {
 		refpanic("Exceeded pool of AFS vnodes(VLRU cycle?)");
 	    } else if (QNext(uq) != tq) {
 		refpanic("VLRU inconsistent");
@@ -744,24 +728,48 @@
 	    if (tq == uq)
 		break;
 	}
-	if (anumber == VCACHE_FREE) {
-	    printf("afs_NewVCache: warning none freed, using %d of %d\n",
+	if (
+#ifdef AFS_MAXVCOUNT_ENV
+        !afsd_dynamic_vcaches &&
+#endif
+        anumber == target) {
+	    printf("afs_ShakeLooseVCaches: warning none freed, using %d of %d\n",
 		   afs_vcount, afs_maxvcount);
-	    if (afs_vcount >= afs_maxvcount) {
-	    	printf("afs_NewVCache - none freed\n");
-		return NULL;
-	    }
 	}
     }
+/*
+    printf("recycled %d entries\n", target-anumber);
+*/
+    if (!haveGlock)
+	AFS_GUNLOCK();
+#endif
+    return 0;
+}
 
-#if defined(AFS_LINUX22_ENV)
+
+static struct vcache *
+afs_AllocVCache(void) 
 {
+    struct vcache *tvc;
+#if defined(AFS_OSF30_ENV)
+    struct vcache *nvc;
+    AFS_GUNLOCK();
+    if (getnewvnode(MOUNT_AFS, &Afs_vnodeops, &nvc)) {
+	/* What should we do ???? */
+	osi_Panic("afs_AllocVCache: no more vnodes");
+    }
+    AFS_GLOCK();
+
+    tvc = nvc;
+    tvc->nextfree = NULL;
+    afs_vcount++;
+#elif defined(AFS_LINUX22_ENV)
     struct inode *ip;
 
     AFS_GUNLOCK();
     ip = new_inode(afs_globalVFS);
     if (!ip)
-	osi_Panic("afs_NewVCache: no more inodes");
+	osi_Panic("afs_AllocVCache: no more inodes");
     AFS_GLOCK();
 #if defined(STRUCT_SUPER_HAS_ALLOC_INODE)
     tvc = VTOAFS(ip);
@@ -770,19 +778,90 @@
     ip->u.generic_ip = tvc;
     tvc->v = ip;
 #endif
-}
-#else
-    AFS_GUNLOCK();
-    if (getnewvnode(MOUNT_AFS, &Afs_vnodeops, &nvc)) {
-	/* What should we do ???? */
-	osi_Panic("afs_NewVCache: no more vnodes");
+
+    afs_vcount++;
+#ifdef AFS_MAXVCOUNT_ENV
+    /* track the peak */
+    if (afsd_dynamic_vcaches && afs_maxvcount < afs_vcount) {
+	afs_maxvcount = afs_vcount;
+	/*printf("peak vnodes: %d\n", afs_maxvcount);*/
     }
-    AFS_GLOCK();
+#endif
+    afs_stats_cmperf.vcacheXAllocs++;	/* count in case we have a leak */
+#else
+    /* none free, making one is better than a panic */
+    afs_stats_cmperf.vcacheXAllocs++;	/* count in case we have a leak */
+    tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
+#if defined(AFS_DARWIN_ENV) && !defined(UKERNEL)
+    tvc->v = NULL; /* important to clean this, or use memset 0 */
+#endif
+#ifdef	KERNEL_HAVE_PIN
+    pin((char *)tvc, sizeof(struct vcache));	/* XXX */
+#endif
+#if defined(AFS_SGI_ENV)
+    {
+	char name[METER_NAMSZ];
+	memset(tvc, 0, sizeof(struct vcache));
+	tvc->v.v_number = ++afsvnumbers;
+	tvc->vc_rwlockid = OSI_NO_LOCKID;
+	initnsema(&tvc->vc_rwlock, 1,
+		  makesname(name, "vrw", tvc->v.v_number));
+#ifndef	AFS_SGI53_ENV
+	initnsema(&tvc->v.v_sync, 0,
+		  makesname(name, "vsy", tvc->v.v_number));
+#endif
+#ifndef AFS_SGI62_ENV
+	initnlock(&tvc->v.v_lock,
+		  makesname(name, "vlk", tvc->v.v_number));
+#endif
+    }
+#endif /* AFS_SGI_ENV */
+#endif
+    return tvc;
+}
 
-    tvc = nvc;
-    tvc->nextfree = NULL;
+/*!
+ *   This routine is responsible for allocating a new cache entry
+ * from the free list.  It formats the cache entry and inserts it
+ * into the appropriate hash tables.  It must be called with
+ * afs_xvcache write-locked so as to prevent several processes from
+ * trying to create a new cache entry simultaneously.
+ *
+ * LOCK: afs_NewVCache  afs_xvcache W
+ *
+ * \param afid The file id of the file whose cache entry is being created.
+ *
+ * \return The new vcache struct.
+ */
+struct vcache *
+afs_NewVCache(struct VenusFid *afid, struct server *serverp)
+{
+    struct vcache *tvc;
+    afs_int32 i, j;
+    afs_int32 anumber = VCACHE_FREE;
+#ifdef	AFS_AIX_ENV
+    struct gnode *gnodepnt;
 #endif
-    afs_vcount++;
+    struct afs_q *tq, *uq;
+    int code, fv_slept;
+
+    AFS_STATCNT(afs_NewVCache);
+
+    afs_FlushReclaimedVcaches();
+
+#if defined(AFS_OSF_ENV) || defined(AFS_LINUX22_ENV)
+#ifdef AFS_MAXVCOUNT_ENV
+    if(!afsd_dynamic_vcaches) {
+#endif
+    afs_ShakeLooseVCaches(anumber);
+    if (afs_vcount >= afs_maxvcount) {
+	printf("afs_NewVCache - none freed\n");
+	return NULL;
+    }
+#ifdef AFS_MAXVCOUNT_ENV
+    }
+#endif
+    tvc = afs_AllocVCache();
 #else /* AFS_OSF_ENV */
     /* pull out a free cache entry */
     if (!freeVCList) {
@@ -870,33 +949,7 @@
 	}
     }
     if (!freeVCList) {
-	/* none free, making one is better than a panic */
-	afs_stats_cmperf.vcacheXAllocs++;	/* count in case we have a leak */
-	tvc = (struct vcache *)afs_osi_Alloc(sizeof(struct vcache));
-#if defined(AFS_DARWIN_ENV) && !defined(UKERNEL)
-	tvc->v = NULL; /* important to clean this, or use memset 0 */
-#endif
-#ifdef	KERNEL_HAVE_PIN
-	pin((char *)tvc, sizeof(struct vcache));	/* XXX */
-#endif
-#if defined(AFS_SGI_ENV)
-	{
-	    char name[METER_NAMSZ];
-	    memset(tvc, 0, sizeof(struct vcache));
-	    tvc->v.v_number = ++afsvnumbers;
-	    tvc->vc_rwlockid = OSI_NO_LOCKID;
-	    initnsema(&tvc->vc_rwlock, 1,
-		      makesname(name, "vrw", tvc->v.v_number));
-#ifndef	AFS_SGI53_ENV
-	    initnsema(&tvc->v.v_sync, 0,
-		      makesname(name, "vsy", tvc->v.v_number));
-#endif
-#ifndef AFS_SGI62_ENV
-	    initnlock(&tvc->v.v_lock,
-		      makesname(name, "vlk", tvc->v.v_number));
-#endif
-	}
-#endif /* AFS_SGI_ENV */
+	tvc = afs_AllocVCache();
     } else {
 	tvc = freeVCList;	/* take from free list */
 	freeVCList = tvc->nextfree;
@@ -1769,7 +1822,7 @@
 	newvcache = 1;
 
 	ConvertWToSLock(&afs_xvcache);
-	if (!tvc)
+	if (tvc == NULL)
 	{
 		ReleaseSharedLock(&afs_xvcache);
 		return NULL;
@@ -3022,7 +3075,7 @@
      */
 
     {
-	register struct afs_q *tq, *uq;
+	register struct afs_q *tq, *uq = NULL;
 	register struct vcache *tvc;
 	for (tq = VLRU.prev; tq != &VLRU; tq = uq) {
 	    tvc = QTOV(tq);
@@ -3077,7 +3130,8 @@
 		    tvc->linkData = 0;
 		}
 
-		afs_FreeAllAxs(&(tvc->Access));
+		if (tvc->Access)
+		    afs_FreeAllAxs(&(tvc->Access));
 	    }
 	    afs_vhashT[i] = 0;
 	}
@@ -3085,8 +3139,9 @@
     /*
      * Free any leftover callback queue
      */
-    for (tsp = afs_cbrSpace; tsp; tsp = nsp) {
-	nsp = tsp->next;
+    for (i = 0; i < afs_stats_cmperf.CallBackAlloced; i++) {
+	tsp = afs_cbrHeads[i];
+	afs_cbrHeads[i] = 0;
 	afs_osi_Free((char *)tsp, AFS_NCBRS * sizeof(struct afs_cbr));
     }
     afs_cbrSpace = 0;
--- openafs/src/afs/FBSD/osi_vnodeops.c:1.18.2.5	Tue Aug 26 10:02:14 2008
+++ openafs/src/afs/FBSD/osi_vnodeops.c	Mon Jan 12 09:33:37 2009
@@ -48,7 +48,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/afs/FBSD/osi_vnodeops.c,v 1.18.2.6 2009/01/12 14:33:37 shadow Exp $");
 
 #include <afs/sysincludes.h>	/* Standard vendor system headers */
 #include <afsincludes.h>	/* Afs-based standard headers */
@@ -1044,8 +1044,7 @@
     if (((ap->a_command >> 8) & 0xff) == 'V') {
 	/* This is a VICEIOCTL call */
 	AFS_GLOCK();
-	error = HandleIoctl(tvc, NULL /*Not used */ ,
-			    ap->a_command, ap->a_data);
+	error = HandleIoctl(tvc, ap->a_command, ap->a_data);
 	AFS_GUNLOCK();
 	return (error);
     } else {
--- openafs/src/afs/LINUX/osi_cred.c:1.10.2.3	Mon Dec 18 21:29:56 2006
+++ openafs/src/afs/LINUX/osi_cred.c	Thu Jan 15 08:27:43 2009
@@ -15,7 +15,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_cred.c,v 1.10.2.3 2006/12/19 02:29:56 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_cred.c,v 1.10.2.4 2009/01/15 13:27:43 shadow Exp $");
 
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
@@ -79,15 +79,15 @@
 {
     cred_t *cr = crget();
 
-    cr->cr_uid = current->fsuid;
-    cr->cr_ruid = current->uid;
-    cr->cr_gid = current->fsgid;
-    cr->cr_rgid = current->gid;
+    cr->cr_uid = current_fsuid();
+    cr->cr_ruid = current_uid();
+    cr->cr_gid = current_fsgid();
+    cr->cr_rgid = current_gid();
 
 #if defined(AFS_LINUX26_ENV)
     task_lock(current);
-    get_group_info(current->group_info);
-    cr->cr_group_info = current->group_info;
+    get_group_info(current_group_info());
+    cr->cr_group_info = current_group_info();
     task_unlock(current);
 #else
     memcpy(cr->cr_groups, current->groups, NGROUPS * sizeof(gid_t));
@@ -101,10 +101,20 @@
 void
 crset(cred_t * cr)
 {
+#if defined(STRUCT_TASK_HAS_CRED)
+    struct cred *new_creds;
+
+    new_creds = prepare_creds();
+    new_creds->fsuid = cr->cr_uid;
+    new_creds->uid = cr->cr_ruid;
+    new_creds->fsgid = cr->cr_gid;
+    new_creds->gid = cr->cr_rgid;
+#else
     current->fsuid = cr->cr_uid;
     current->uid = cr->cr_ruid;
     current->fsgid = cr->cr_gid;
     current->gid = cr->cr_rgid;
+#endif
 #if defined(AFS_LINUX26_ENV)
 {
     struct group_info *old_info;
@@ -113,8 +123,14 @@
     get_group_info(cr->cr_group_info);
 
     task_lock(current);
+#if defined(STRUCT_TASK_HAS_CRED)
+    old_info = current->cred->group_info;
+    new_creds->group_info = cr->cr_group_info;
+    commit_creds(new_creds);
+#else
     old_info = current->group_info;
     current->group_info = cr->cr_group_info;
+#endif
     task_unlock(current);
 
     put_group_info(old_info);
--- openafs/src/afs/LINUX/osi_file.c:1.19.2.16	Wed Mar 26 00:10:52 2008
+++ openafs/src/afs/LINUX/osi_file.c	Thu Jan 15 08:27:43 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.19.2.16 2008/03/26 04:10:52 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_file.c,v 1.19.2.19 2009/01/15 13:27:43 shadow Exp $");
 
 #ifdef AFS_LINUX24_ENV
 #include "h/module.h" /* early to avoid printf->printk mapping */
@@ -78,11 +78,15 @@
 #endif
     tip->i_flags |= MS_NOATIME;	/* Disable updating access times. */
 
+#if defined(STRUCT_TASK_HAS_CRED)
+    filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR, current_cred());
+#else
     filp = dentry_open(dp, mntget(afs_cacheMnt), O_RDWR);
+#endif
     if (IS_ERR(filp))
 	osi_Panic("Can't open inode %d\n", ainode);
     afile->filp = filp;
-    afile->size = FILE_INODE(filp)->i_size;
+    afile->size = i_size_read(FILE_INODE(filp));
     AFS_GLOCK();
     afile->offset = 0;
     afile->proc = (int (*)())0;
@@ -133,7 +137,7 @@
 	code = filp->f_op->open(tip, filp);
     if (code)
 	osi_Panic("Can't open inode %d\n", ainode);
-    afile->size = tip->i_size;
+    afile->size = i_size_read(tip);
     AFS_GLOCK();
     afile->offset = 0;
     afile->proc = (int (*)())0;
@@ -148,7 +152,7 @@
     register afs_int32 code;
     AFS_STATCNT(osi_Stat);
     MObtainWriteLock(&afs_xosi, 320);
-    astat->size = OSIFILE_INODE(afile)->i_size;
+    astat->size = i_size_read(OSIFILE_INODE(afile));
 #if defined(AFS_LINUX26_ENV)
     astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
     astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
@@ -238,7 +242,7 @@
     if (!code)
 	truncate_inode_pages(&inode->i_data, asize);
 #else
-    inode->i_size = asize;
+    i_size_write(inode, asize);
     if (inode->i_sb->s_op && inode->i_sb->s_op->notify_change) {
 	code = inode->i_sb->s_op->notify_change(&afile->dentry, &newattrs);
     }
--- openafs/src/afs/LINUX/osi_groups.c:1.25.2.16	Sun Jun  8 23:39:44 2008
+++ openafs/src/afs/LINUX/osi_groups.c	Mon Mar 23 11:17:02 2009
@@ -20,7 +20,7 @@
 #endif
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.16 2008/06/09 03:39:44 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_groups.c,v 1.25.2.20 2009/03/23 15:17:02 shadow Exp $");
 
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
@@ -50,7 +50,7 @@
 
     crset(*cr);
 
-#ifdef STRUCT_TASK_STRUCT_HAS_PARENT
+#if defined(STRUCT_TASK_STRUCT_HAS_PARENT) && !defined(STRUCT_TASK_HAS_CRED)
     if (change_parent) {
 	old_info = current->parent->group_info;
 	get_group_info(group_info);
@@ -244,14 +244,19 @@
 	not_in_quota = KEY_ALLOC_IN_QUOTA;
 	sprintf(desc, "_ses.%u", task->tgid);
 
-#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK
+#if defined(KEY_ALLOC_NEEDS_STRUCT_TASK)
+	keyring = key_alloc(__key_type_keyring, desc,
+			    task_uid(task), task_gid(task), task,
+			    (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL,
+			    not_in_quota);
+#elif defined(KEY_ALLOC_NEEDS_CRED)
 	keyring = key_alloc(__key_type_keyring, desc,
-			    task->uid, task->gid, task,
+			    task_uid(task), task_gid(task), current_cred(),
 			    (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL,
 			    not_in_quota);
 #else
 	keyring = key_alloc(__key_type_keyring, desc,
-			    task->uid, task->gid,
+			    task_uid(task), task_gid(task),
 			    (KEY_POS_ALL & ~KEY_POS_SETATTR) | KEY_USR_ALL,
 			    not_in_quota);
 #endif
@@ -269,9 +274,9 @@
 
     /* install the keyring */
     spin_lock_irq(&task->sighand->siglock);
-    old = task->signal->session_keyring;
+    old = task_session_keyring(task);
     smp_wmb();
-    task->signal->session_keyring = keyring;
+    task_session_keyring(task) = keyring;
     spin_unlock_irq(&task->sighand->siglock);
 
     if (old)
@@ -337,22 +342,24 @@
 
 	(void) install_session_keyring(current, NULL);
 
-	if (current->signal->session_keyring) {
+	if (current_session_keyring()) {
 	    struct key *key;
 	    key_perm_t perm;
 
 	    perm = KEY_POS_VIEW | KEY_POS_SEARCH;
 	    perm |= KEY_USR_VIEW | KEY_USR_SEARCH;
 
-#ifdef KEY_ALLOC_NEEDS_STRUCT_TASK
+#if defined(KEY_ALLOC_NEEDS_STRUCT_TASK)
 	    key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, current, perm, 1);
+#elif defined(KEY_ALLOC_NEEDS_CRED)
+	    key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, current_cred(), perm, 1);
 #else
 	    key = key_alloc(&key_type_afs_pag, "_pag", 0, 0, perm, 1);
 #endif
 
 	    if (!IS_ERR(key)) {
 		key_instantiate_and_link(key, (void *) newpag, sizeof(afs_uint32),
-					 current->signal->session_keyring, NULL);
+					 current_session_keyring(), NULL);
 		key_put(key);
 	    }
 	}
@@ -549,26 +556,28 @@
 {
     int code;
     afs_uint32 *userpag, pag = NOPAG;
+#ifndef AFS_LINUX26_ONEGROUP_ENV
     int g0, g1;
+#endif
 
     if (key->uid != 0 || key->gid != 0)
 	return -EPERM;
 
     code = -EINVAL;
-    get_group_info(current->group_info);
+    get_group_info(current_group_info());
 
     if (datalen != sizeof(afs_uint32) || !data)
 	goto error;
 
-    if (current->group_info->ngroups < NUMPAGGROUPS)
+    if (current_group_info()->ngroups < NUMPAGGROUPS)
 	goto error;
 
     /* ensure key being set matches current pag */
 #ifdef AFS_LINUX26_ONEGROUP_ENV
-    pag = afs_get_pag_from_groups(current->group_info);
+    pag = afs_get_pag_from_groups(current_group_info());
 #else
-    g0 = GROUP_AT(current->group_info, 0);
-    g1 = GROUP_AT(current->group_info, 1);
+    g0 = GROUP_AT(current_group_info(), 0);
+    g1 = GROUP_AT(current_group_info(), 1);
 
     pag = afs_get_pag_from_groups(g0, g1);
 #endif
@@ -584,7 +593,7 @@
     code = 0;
 
 error:
-    put_group_info(current->group_info);
+    put_group_info(current_group_info());
     return code;
 }
 
@@ -651,8 +660,8 @@
 #else
 	p = find_task_by_vpid(1);
 #endif
-	if (p && p->user->session_keyring)
-	    __key_type_keyring = p->user->session_keyring->type;
+	if (p && task_user(p)->session_keyring)
+	    __key_type_keyring = task_user(p)->session_keyring->type;
 # ifdef EXPORTED_TASKLIST_LOCK
 	if (&tasklist_lock)
 	    read_unlock(&tasklist_lock);
--- openafs/src/afs/LINUX/osi_machdep.h:1.22.2.18	Fri Nov 23 08:45:04 2007
+++ openafs/src/afs/LINUX/osi_machdep.h	Thu Jan 15 08:27:43 2009
@@ -155,7 +155,7 @@
 #endif
 
 /* cred struct */
-typedef struct cred {		/* maps to task field: */
+typedef struct afs_cred {		/* maps to task field: */
     int cr_ref;
     uid_t cr_uid;		/* euid */
     uid_t cr_ruid;		/* uid */
@@ -167,10 +167,34 @@
     gid_t cr_groups[NGROUPS];	/* 32 groups - empty set to NOGROUP */
     int cr_ngroups;
 #endif
-    struct cred *cr_next;
+    struct afs_cred *cr_next;
 } cred_t;
-#define AFS_UCRED cred
+#define AFS_UCRED afs_cred
 #define AFS_PROC struct task_struct
+#if !defined(current_cred)
+#define current_gid() (current->gid)
+#define current_uid() (current->uid)
+#define current_fsgid() (current->fsgid)
+#define current_fsuid() (current->fsuid)
+#endif
+#if defined(STRUCT_TASK_HAS_CRED)
+#define current_group_info() (current->cred->group_info)
+#define task_gid(task) (task->cred->gid)
+#define task_user(task) (task->cred->user)
+#define task_session_keyring(task) (task->cred->tgcred->session_keyring)
+#define current_session_keyring() (current->cred->tgcred->session_keyring)
+#else
+#define current_group_info() (current->group_info)
+#if !defined(task_gid)
+#define task_gid(task) (task->gid)
+#endif
+#if !defined(task_uid)
+#define task_uid(task) (task->uid)
+#endif
+#define task_user(task) (task->user)
+#define task_session_keyring(task) (task->signal->session_keyring)
+#define current_session_keyring() (current->signal->session_keyring)
+#endif
 #define crhold(c) (c)->cr_ref++
 
 /* UIO manipulation */
--- openafs/src/afs/LINUX/osi_module.c:1.52.2.31	Fri Aug 22 15:17:02 2008
+++ openafs/src/afs/LINUX/osi_module.c	Tue Mar 31 08:16:50 2009
@@ -15,7 +15,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_module.c,v 1.52.2.33 2009/03/31 12:16:50 shadow Exp $");
 
 #include <linux/module.h> /* early to avoid printf->printk mapping */
 #include "afs/sysincludes.h"
@@ -83,6 +83,7 @@
 	struct afs_q *cq, *tq;
 	loff_t n = 0;
 
+	AFS_GLOCK();
 	ObtainReadLock(&afs_xcell);
 	for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
 		tq = QNext(cq);
@@ -91,8 +92,9 @@
 			break;
 	}
 	if (cq == &CellLRU)
-		return NULL;
+		cq = NULL;
 
+	AFS_GUNLOCK();
 	return cq;
 }
 
@@ -100,18 +102,23 @@
 {
 	struct afs_q *cq = p, *tq;
 
+
+	AFS_GLOCK();
 	(*pos)++;
 	tq = QNext(cq);
 
 	if (tq == &CellLRU)
-		return NULL;
+		tq = NULL;
 
+	AFS_GUNLOCK();
 	return tq;
 }
 
 static void c_stop(struct seq_file *m, void *p)
 {
+	AFS_GLOCK();
 	ReleaseReadLock(&afs_xcell);
+	AFS_GUNLOCK();
 }
 
 static int c_show(struct seq_file *m, void *p)
@@ -251,7 +258,9 @@
 
     entry1->proc_fops = &afs_syscall_fops;
 
+#if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
     entry1->owner = THIS_MODULE;
+#endif
 
 #ifdef HAVE_KERNEL_LINUX_SEQ_FILE_H
     entry2 = create_proc_entry(PROC_CELLSERVDB_NAME, 0, openafs_procfs);
--- openafs/src/afs/LINUX/osi_probe.c:1.1.2.26	Thu Jul  3 16:33:25 2008
+++ openafs/src/afs/LINUX/osi_probe.c	Thu Jan 15 08:13:21 2009
@@ -1210,14 +1210,14 @@
     if (probe_debug & 0x0001) {                                                              \
 	printk("<7>osi_probe: %s = 0x%016lx %s\n", P->symbol, (unsigned long)(x), (m)); \
     }                                                                                      \
-    if ((x)) {                                                                             \
+    if ((x) && ((int)(x)) != -ENOENT) {                                                    \
 	*method = (m);                                                                     \
         final_answer = (void *)(x);                                                        \
     }                                                                                      \
 } while (0)
 #else
 #define check_result(x,m) do {  \
-    if ((x)) {                  \
+    if ((x) && ((int)(x)) != -ENOENT) { \
         *method = (m);          \
         return (void *)(x);     \
     }                           \
--- openafs/src/afs/LINUX/osi_vfs.hin:1.6.2.2	Mon Jul 11 15:29:56 2005
+++ openafs/src/afs/LINUX/osi_vfs.hin	Fri Jan  9 09:58:03 2009
@@ -78,4 +78,9 @@
 
 #define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
 
+#ifndef HAVE_LINUX_I_SIZE_READ
+#define i_size_read(X) ((X)->i_size)
+#define i_size_write(X,Y) (X)->i_size = Y
+#endif
+
 #endif /* OSI_VFS_H_ */
--- openafs/src/afs/LINUX/osi_vfsops.c:1.29.2.28	Fri Nov 23 08:45:04 2007
+++ openafs/src/afs/LINUX/osi_vfsops.c	Wed Mar 18 08:57:17 2009
@@ -16,7 +16,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.28 2007/11/23 13:45:04 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vfsops.c,v 1.29.2.31 2009/03/18 12:57:17 shadow Exp $");
 
 #define __NO_VERSION__		/* don't define kernel_version in module.h */
 #include <linux/module.h> /* early to avoid printf->printk mapping */
@@ -143,6 +143,9 @@
     sb->s_blocksize_bits = 10;
     sb->s_magic = AFS_VFSMAGIC;
     sb->s_op = &afs_sops;	/* Super block (vfs) ops */
+#if defined(HAVE_BDI_INIT)
+    bdi_init(&afs_backing_dev_info);
+#endif
 #if defined(MAX_NON_LFS)
 #ifdef AFS_64BIT_CLIENT
 #if !defined(MAX_LFS_FILESIZE)
@@ -394,6 +397,9 @@
 #endif
 
     osi_linux_verify_alloced_memory();
+#if defined(HAVE_BDI_INIT)
+    bdi_destroy(&afs_backing_dev_info);
+#endif
     AFS_GUNLOCK();
 
     sbp->s_dev = 0;
@@ -532,7 +538,7 @@
     ip->i_mode = vp->va_mode;
     ip->i_uid = vp->va_uid;
     ip->i_gid = vp->va_gid;
-    ip->i_size = vp->va_size;
+    i_size_write(ip, vp->va_size);
 #if defined(AFS_LINUX26_ENV)
     ip->i_atime.tv_sec = vp->va_atime.tv_sec;
     ip->i_atime.tv_nsec = 0;
--- openafs/src/afs/LINUX/osi_vm.c:1.16.2.2	Mon Oct 20 08:10:00 2008
+++ openafs/src/afs/LINUX/osi_vm.c	Fri Mar 27 11:45:49 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vm.c,v 1.16.2.2 2008/10/20 12:10:00 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vm.c,v 1.16.2.5 2009/03/27 15:45:49 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
@@ -52,7 +52,7 @@
 	return EBUSY;
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-    truncate_inode_pages(&ip->i_data, 0);
+    return vmtruncate(ip, 0);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
     truncate_inode_pages(ip, 0);
 #else
@@ -132,7 +132,7 @@
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
     struct inode *ip = AFSTOV(avc);
-
+    
     truncate_inode_pages(&ip->i_data, 0);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
     struct inode *ip = AFSTOV(avc);
@@ -153,9 +153,7 @@
 osi_VM_Truncate(struct vcache *avc, int alen, struct AFS_UCRED *acred)
 {
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,4,0)
-    struct inode *ip = AFSTOV(avc);
-
-    truncate_inode_pages(&ip->i_data, alen);
+    vmtruncate(AFSTOV(avc), alen);
 #elif LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,15)
     struct inode *ip = AFSTOV(avc);
 
diff -u openafs/src/afs/LINUX/osi_vnodeops.c openafs/src/afs/LINUX/osi_vnodeops.c
--- openafs/src/afs/LINUX/osi_vnodeops.c	Thu Mar 19 00:54:50 2009
+++ openafs/src/afs/LINUX/osi_vnodeops.c	4 Apr 2009 12:33:39 -0000
@@ -22,7 +22,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.73 2008/11/08 16:49:59 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/LINUX/osi_vnodeops.c,v 1.81.2.77 2009/03/19 04:54:50 shadow Exp $");
 
 #include "afs/sysincludes.h"
 #include "afsincludes.h"
@@ -45,8 +45,13 @@
 #define pageoff(pp) pp->offset
 #endif
 
+#ifndef MAX_ERRNO
+#define MAX_ERRNO 1000L
+#endif
+
 #if defined(AFS_LINUX26_ENV)
 #define UnlockPage(pp) unlock_page(pp)
+extern struct backing_dev_info afs_backing_dev_info;
 #endif
 
 extern struct vcache *afs_globalVp;
@@ -1086,8 +1091,10 @@
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,2,10)
     if (code == ENOENT)
 	return ERR_PTR(0);
-    else
+    else if ((code >= 0) && (code <= MAX_ERRNO))
 	return ERR_PTR(-code);
+    else 
+	return ERR_PTR(-EIO);
 #else
     if (code == ENOENT)
 	code = 0;
@@ -1428,7 +1435,10 @@
 
     if (code < 0) {
 	dput(basep);
-	res = ERR_PTR(code);
+	if (code < -MAX_ERRNO)
+	    res = ERR_PTR(-EIO);
+	else
+	    res = ERR_PTR(code);
     } else {
 	name[code] = '\0';
 	res = lookup_dentry(name, basep, follow);
@@ -1581,7 +1591,7 @@
 
     code = afs_write(vcp, &tuio, f_flags, credp, 0);
 
-    ip->i_size = vcp->m.Length;
+    i_size_write(ip, vcp->m.Length);
     ip->i_blocks = ((vcp->m.Length + 1023) >> 10) << 1;
 
     if (!code) {
@@ -1635,13 +1645,13 @@
 #endif
 
     inode = (struct inode *)mapping->host;
-    end_index = inode->i_size >> PAGE_CACHE_SHIFT;
+    end_index = i_size_read(inode) >> PAGE_CACHE_SHIFT;
 
     /* easy case */
     if (pp->index < end_index)
 	goto do_it;
     /* things got complicated... */
-    offset = inode->i_size & (PAGE_CACHE_SIZE - 1);
+    offset = i_size_read(inode) & (PAGE_CACHE_SIZE - 1);
     /* OK, are we completely out? */
     if (pp->index >= end_index + 1 || !offset)
 	return -EIO;
@@ -1684,7 +1694,7 @@
 
     code = afs_write(vcp, &tuio, fp->f_flags, credp, 0);
 
-    ip->i_size = vcp->m.Length;
+    i_size_write(ip, vcp->m.Length);
     ip->i_blocks = ((vcp->m.Length + 1023) >> 10) << 1;
 
     if (!code) {
@@ -1791,7 +1801,11 @@
 {
     struct page *page;
     pgoff_t index = pos >> PAGE_CACHE_SHIFT;
+#if defined(HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN)
+    page = grab_cache_page_write_begin(mapping, index, flags);
+#else
     page = __grab_cache_page(mapping, index);
+#endif
     *pagep = page;
 
     return 0;
@@ -1925,6 +1939,9 @@
     if (vattr)
 	vattr2inode(ip, vattr);
 
+#if defined(AFS_LINUX26_ENV)
+    ip->i_mapping->backing_dev_info = &afs_backing_dev_info;
+#endif
 /* Reset ops if symlink or directory. */
     if (S_ISREG(ip->i_mode)) {
 	ip->i_op = &afs_file_iops;
--- openafs/src/afs/OBSD/osi_groups.c:1.5.2.1	Fri Jun 23 10:21:12 2006
+++ openafs/src/afs/OBSD/osi_groups.c	Fri Mar 27 11:55:45 2009
@@ -19,7 +19,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/OBSD/osi_groups.c,v 1.5.2.1 2006/06/23 14:21:12 rees Exp $");
+    ("$Header: /cvs/openafs/src/afs/OBSD/osi_groups.c,v 1.5.2.2 2009/03/27 15:55:45 shadow Exp $");
 
 #include "afs/sysincludes.h"
 #include "afs/afsincludes.h"
@@ -47,10 +47,12 @@
     struct vrequest treq;
 
     AFS_STATCNT(afs_xsetgroups);
-    AFS_GLOCKP(p);
+    AFS_GLOCK();
+
+    p = osi_curproc();
 
     code = afs_InitReq(&treq, p->p_rcred);
-    AFS_GUNLOCKP(p);
+    AFS_GUNLOCK();
     if (code)
 	return code;
 
@@ -61,10 +63,10 @@
      */
     if (PagInCred(p->p_rcred) == NOPAG) {
 	if (((treq.uid >> 24) & 0xff) == 'A') {
-	    AFS_GLOCKP(p);
+	    AFS_GLOCK();
 	    /* we've already done a setpag, so now we redo it */
 	    AddPag(p, treq.uid, &p->p_rcred);
-	    AFS_GUNLOCKP(p);
+	    AFS_GUNLOCK();
 	}
     }
     return code;
--- openafs/src/afs/OBSD/osi_machdep.h:1.16.2.9	Fri Jan  4 12:53:37 2008
+++ openafs/src/afs/OBSD/osi_machdep.h	Fri Mar 27 11:55:45 2009
@@ -16,7 +16,7 @@
  * afs_osi.h.
  */
 
-/* $Id: osi_machdep.h,v 1.16.2.9 2008/01/04 17:53:37 rees Exp $ */
+/* $Id: osi_machdep.h,v 1.16.2.10 2009/03/27 15:55:45 shadow Exp $ */
 
 #ifndef _OSI_MACHDEP_H_
 #define _OSI_MACHDEP_H_
@@ -54,8 +54,35 @@
 #define AFS_UIOUSER	UIO_USERSPACE
 
 /* malloc */
-#define AFS_KALLOC(s)	afs_nbsd_Alloc(s)
-#define AFS_KFREE(p, s)	afs_nbsd_Free((p), (s))
+extern void *osi_obsd_Alloc(size_t asize, int cansleep);
+extern void osi_obsd_Free(void *p, size_t asize);
+
+#ifdef afs_osi_Alloc_NoSleep
+#undef afs_osi_Alloc_NoSleep
+#define afs_osi_Alloc_NoSleep(asize) osi_obsd_Alloc((asize), 0)
+#endif
+
+#ifdef AFS_KALLOC
+#undef AFS_KALLOC
+#define AFS_KALLOC(s) osi_obsd_Alloc((s), 1 /* cansleep */)
+#endif
+
+#ifdef AFS_KFREE
+#undef AFS_KFREE
+#define AFS_KFREE(p, s) (osi_obsd_Free((p), (s)))
+#endif
+
+#ifdef AFS_OBSD42_ENV
+/* removed, live with it */
+#define BSD_KMALLOC(p, ptype, msize, mtype, mflags)     \
+  (p) = malloc((msize), (mtype), (mflags))
+
+#define BSD_KFREE(p, mflags) \
+  free((p), (mflags))
+#else
+#define BSD_KMALLOC MALLOC
+#define BSD_KFREE KFREE
+#endif /* AFS_OBSD42_ENV */
 
 /* proc, cred */
 #define	AFS_PROC	struct proc
@@ -92,11 +119,11 @@
 /* This is not always in scope yet */
 struct vcache;
 
-extern int afs_nbsd_lookupname(char *fnamep, enum uio_seg segflg,
+extern int afs_obsd_lookupname(char *fnamep, enum uio_seg segflg,
 			       int followlink, struct vnode **compvpp);
-extern void afs_nbsd_getnewvnode(struct vcache *tvc);
-extern void *afs_nbsd_Alloc(size_t asize);
-extern void afs_nbsd_Free(void *p, size_t asize);
+extern void afs_obsd_getnewvnode(struct vcache *tvc);
+extern void *afs_obsd_Alloc(size_t asize);
+extern void afs_obsd_Free(void *p, size_t asize);
 extern int afs_vget();
 
 #undef gop_lookupname
@@ -111,6 +138,49 @@
 
 #ifdef KERNEL
 
+#ifdef AFS_OBSD44_ENV
+/* Revert to classical, BSD locks */
+
+extern struct lock afs_global_lock;
+extern struct proc *afs_global_owner;
+
+#ifdef AFS_GLOBAL_SUNLOCK
+
+#if defined(LOCKDEBUG)
+
+#define AFS_GLOCK() \
+  do { \
+  _lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL, __FILE__, __LINE__); \
+  } while(0);
+#define AFS_GUNLOCK() \
+  do { \
+  _lockmgr(&afs_global_lock, LK_RELEASE, NULL, __FILE__, __LINE__); \
+  } while(0);
+
+#else
+
+#define AFS_GLOCK() \
+  do { \
+  lockmgr(&afs_global_lock, LK_EXCLUSIVE, NULL); \
+  } while(0);
+#define AFS_GUNLOCK() \
+  do { \
+  lockmgr(&afs_global_lock, LK_RELEASE, NULL); \
+  } while(0);
+#endif /* LOCKDEBUG */
+#define ISAFS_GLOCK() (lockstatus(&afs_global_lock) == LK_EXCLUSIVE)
+#else
+extern struct lock afs_global_lock;
+#define AFS_GLOCKP(p)
+#define AFS_GUNLOCKP(p)
+#define AFS_ASSERT_GLOCK()
+#define ISAFS_GLOCK() 1
+#endif
+
+#else
+/* I don't see doing locks this way for older kernels, either,
+ * but, smart folks wrote this
+ */
 #define AFS_GLOCK() AFS_GLOCKP(curproc)
 #define AFS_GUNLOCK() AFS_GUNLOCKP(curproc)
 #ifdef AFS_GLOBAL_SUNLOCK
@@ -139,6 +209,8 @@
 #define ISAFS_GLOCK() 1
 #endif
 
+#endif /* AFS_OBSD44_ENV */
+
 #undef SPLVAR
 #define SPLVAR int splvar
 #undef NETPRI
--- openafs/src/afs/OBSD/osi_misc.c:1.4	Thu Oct  9 12:13:16 2003
+++ openafs/src/afs/OBSD/osi_misc.c	Fri Mar 27 11:55:45 2009
@@ -1,7 +1,7 @@
 /* 
  * osi_misc.c
  *
- * $Id: osi_misc.c,v 1.4 2003/10/09 16:13:16 rees Exp $
+ * $Id: osi_misc.c,v 1.4.2.1 2009/03/27 15:55:45 shadow Exp $
  */
 
 /*
@@ -47,10 +47,12 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/OBSD/osi_misc.c,v 1.4 2003/10/09 16:13:16 rees Exp $");
+    ("$Header: /cvs/openafs/src/afs/OBSD/osi_misc.c,v 1.4.2.1 2009/03/27 15:55:45 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afs/afsincludes.h"	/* Afs-based standard headers */
+#include <sys/types.h>
+#include <sys/malloc.h>
 
 /*
  * afs_suser() returns true if the caller is superuser, false otherwise.
@@ -74,20 +76,94 @@
 #endif
 }
 
+/*
+ * reworked for netbsd and openbsd at 4.0/4.4
+ */
+
+#if defined(AFS_OBSD42_ENV)
+/* ripped out MALLOC/FREE */
+
+void *
+osi_obsd_Alloc(size_t asize, int cansleep)
+{
+  void *p;
+  int glocked;
+
+  if (cansleep) {
+    glocked = ISAFS_GLOCK();
+    if (glocked)
+      AFS_GUNLOCK();
+    p = malloc(asize, M_AFSGENERIC, M_WAITOK);
+    if (glocked)
+      AFS_GLOCK();
+  } else {
+    p = malloc(asize, M_AFSGENERIC, M_NOWAIT);
+  }
+
+  return (p);
+}
+
+void
+osi_obsd_Free(void *p, size_t asize)
+{
+  free(p, M_AFSGENERIC);
+}
+
+#else
 void *
-afs_nbsd_Alloc(size_t asize)
+osi_obsd_Alloc(size_t asize, int cansleep)
 {
-    void *p;
+  void *p;
+  int glocked;
 
+  if (cansleep) {
+    glocked = ISAFS_GLOCK();
+    if (glocked)
+      AFS_GUNLOCK();
     MALLOC(p, void *, asize, M_AFSGENERIC, M_WAITOK);
-    return p;
+    if (glocked)
+      AFS_GLOCK();
+  } else {
+    MALLOC(p, void *, asize, M_AFSGENERIC, M_NOWAIT);
+  }
+
+  return (p);
 }
 
 void
-afs_nbsd_Free(void *p, size_t asize)
+osi_obsd_Free(void *p, size_t asize)
 {
-    FREE(p, M_AFSGENERIC);
+  FREE(p, M_AFSGENERIC);
 }
+#endif
+
+#if 0 /* XXX */
+/* I speculate this usage may be more correct than definitions
+ * in afs_osi_alloc.c, which I discarded successfully for FreeBSD 7+,
+ * and am trying to discard for NetBSD 4.x, but until tested, I'm
+ * not rocking the boat.  Matt.
+ */
+   
+void
+osi_FreeLargeSpace(void *p)
+{
+  osi_obsd_Free(p, 0);
+}
+
+void
+osi_FreeSmallSpace(void *p)
+{
+  osi_obsd_Free(p, 0);
+}
+
+void *
+osi_AllocLargeSpace(size_t size)
+{
+  AFS_ASSERT_GLOCK();
+  AFS_STATCNT(osi_AllocLargeSpace);
+  return (osi_obsd_Alloc(size, 1));
+}
+#endif
 
 int
 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
--- openafs/src/afs/OBSD/osi_vnodeops.c:1.18.2.5	Tue Jan  8 12:06:59 2008
+++ openafs/src/afs/OBSD/osi_vnodeops.c	Fri Mar 27 11:55:45 2009
@@ -3,7 +3,7 @@
  * Original NetBSD version for Transarc afs by John Kohl <jtk@MIT.EDU>
  * OpenBSD version by Jim Rees <rees@umich.edu>
  *
- * $Id: osi_vnodeops.c,v 1.18.2.5 2008/01/08 17:06:59 rees Exp $
+ * $Id: osi_vnodeops.c,v 1.18.2.6 2009/03/27 15:55:45 shadow Exp $
  */
 
 /*
@@ -99,7 +99,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/OBSD/osi_vnodeops.c,v 1.18.2.5 2008/01/08 17:06:59 rees Exp $");
+    ("$Header: /cvs/openafs/src/afs/OBSD/osi_vnodeops.c,v 1.18.2.6 2009/03/27 15:55:45 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afs/afsincludes.h"	/* Afs-based standard headers */
@@ -160,7 +160,11 @@
 /* Global vfs data structures for AFS. */
 int (**afs_vnodeop_p) __P((void *));
 struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
+#ifdef AFS_OBSD44_ENV /* feel free to zero in on this */
+  {&vop_default_desc, eopnotsupp},
+#else
     {&vop_default_desc, vn_default_error},
+#endif
     {&vop_lookup_desc, afs_nbsd_lookup},	/* lookup */
     {&vop_create_desc, afs_nbsd_create},	/* create */
     {&vop_mknod_desc, afs_nbsd_mknod},		/* mknod */
@@ -207,11 +211,11 @@
 #define GETNAME()	\
     struct componentname *cnp = ap->a_cnp; \
     char *name; \
-    MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
+    BSD_KMALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
     bcopy(cnp->cn_nameptr, name, cnp->cn_namelen); \
     name[cnp->cn_namelen] = '\0'
 
-#define DROPNAME() FREE(name, M_TEMP)
+#define DROPNAME() BSD_KFREE(name, M_TEMP)
 
 #ifdef AFS_OBSD36_ENV
 #define DROPCNP(cnp) pool_put(&namei_pool, (cnp)->cn_pnbuf)
@@ -687,10 +691,10 @@
     if ((code = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curproc)))
 	goto abortit;
 
-    MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
+    BSD_KMALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
     bcopy(fcnp->cn_nameptr, fname, fcnp->cn_namelen);
     fname[fcnp->cn_namelen] = '\0';
-    MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
+    BSD_KMALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
     bcopy(tcnp->cn_nameptr, tname, tcnp->cn_namelen);
     tname[tcnp->cn_namelen] = '\0';
 
@@ -702,8 +706,8 @@
     AFS_GUNLOCK();
 
     VOP_UNLOCK(fvp, 0, curproc);
-    FREE(fname, M_TEMP);
-    FREE(tname, M_TEMP);
+    BSD_KFREE(fname, M_TEMP);
+    BSD_KFREE(tname, M_TEMP);
     if (code)
 	goto abortit;		/* XXX */
     if (tdvp == tvp)
--- openafs/src/afs/SOLARIS/osi_file.c:1.13.2.3	Mon Mar 17 11:28:55 2008
+++ openafs/src/afs/SOLARIS/osi_file.c	Thu Mar 19 15:30:28 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_file.c,v 1.13.2.3 2008/03/17 15:28:55 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_file.c,v 1.13.2.5 2009/03/19 19:30:28 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
@@ -175,22 +175,85 @@
 osi_UfsOpen(afs_int32 ainode)
 #endif
 {
+#ifdef AFS_CACHE_VNODE_PATH
+    struct vnode *vp;
+#else
     struct inode *ip;
+#endif
     register struct osi_file *afile = NULL;
     afs_int32 code = 0;
     int dummy;
+    char fname[1024];
+#ifdef AFS_CACHE_VNODE_PATH
+    char namebuf[1024];
+    struct pathname lookpn;
+#endif
+    struct osi_stat tstat;
     afile = (struct osi_file *)osi_AllocSmallSpace(sizeof(struct osi_file));
     AFS_GUNLOCK();
+
+/*
+ * AFS_CACHE_VNODE_PATH can be used with any file system, including ZFS or tmpfs.
+ * The ainode is not an inode number but a signed index used to generate file names. 
+ */
+#ifdef AFS_CACHE_VNODE_PATH
+	switch (ainode) {
+	case AFS_CACHE_CELLS_INODE:
+	    snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "CellItems");
+	    break;
+	case AFS_CACHE_ITEMS_INODE:
+	    snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "CacheItems");
+	    break;
+	case AFS_CACHE_VOLUME_INODE:
+	    snprintf(fname, 1024, "%s/%s", afs_cachebasedir, "VolumeItems");
+	    break;
+	default:
+		dummy = ainode / afs_numfilesperdir;
+		snprintf(fname, 1024, "%s/D%d/V%d", afs_cachebasedir, dummy, ainode);
+    }
+		
+	/* Can not use vn_open or lookupname, they use user's CRED() 
+     * We need to run as root So must use low level lookuppnvp 
+     * assume fname starts with /
+	 */
+
+	code = pn_get_buf(fname, AFS_UIOSYS, &lookpn, namebuf, sizeof(namebuf));
+    if (code != 0) 
+        osi_Panic("UfsOpen: pn_get_buf failed %ld %s %ld", code, fname, ainode);
+ 
+	VN_HOLD(rootdir); /* released in loopuppnvp */
+	code = lookuppnvp(&lookpn, NULL, FOLLOW, NULL, &vp, 
+           rootdir, rootdir, &afs_osi_cred); 
+    if (code != 0)  
+        osi_Panic("UfsOpen: lookuppnvp failed %ld %s %ld", code, fname, ainode);
+	
+#ifdef AFS_SUN511_ENV
+    code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred, NULL);
+#else
+    code = VOP_OPEN(&vp, FREAD|FWRITE, &afs_osi_cred);
+#endif
+
+    if (code != 0)
+        osi_Panic("UfsOpen: VOP_OPEN failed %ld %s %ld", code, fname, ainode);
+
+#else
     code =
 	igetinode(afs_cacheVfsp, (dev_t) cacheDev.dev, (ino_t) ainode, &ip,
 		  CRED(), &dummy);
+#endif
     AFS_GLOCK();
     if (code) {
 	osi_FreeSmallSpace(afile);
-	osi_Panic("UfsOpen: igetinode failed");
+	osi_Panic("UfsOpen: igetinode failed %ld %s %ld", code, fname, ainode);
     }
+#ifdef AFS_CACHE_VNODE_PATH
+	afile->vnode = vp;
+	code = afs_osi_Stat(afile, &tstat);
+	afile->size = tstat.size;
+#else
     afile->vnode = ITOV(ip);
     afile->size = VTOI(afile->vnode)->i_size;
+#endif
     afile->offset = 0;
     afile->proc = (int (*)())0;
     afile->inum = ainode;	/* for hint validity checking */
@@ -304,12 +367,14 @@
 osi_DisableAtimes(struct vnode *avp)
 {
     if (afs_CacheFSType == AFS_SUN_UFS_CACHE) {
+#ifndef AFS_CACHE_VNODE_PATH 
 	struct inode *ip = VTOI(avp);
 	rw_enter(&ip->i_contents, RW_READER);
 	mutex_enter(&ip->i_tlock);
 	ip->i_flag &= ~IACC;
 	mutex_exit(&ip->i_tlock);
 	rw_exit(&ip->i_contents);
+#endif
     }
 }
 
--- openafs/src/afs/SOLARIS/osi_vnodeops.c:1.20.2.12	Mon Mar 17 11:28:55 2008
+++ openafs/src/afs/SOLARIS/osi_vnodeops.c	Sun Mar 15 14:13:55 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vnodeops.c,v 1.20.2.12 2008/03/17 15:28:55 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/SOLARIS/osi_vnodeops.c,v 1.20.2.13 2009/03/15 18:13:55 shadow Exp $");
 
 /*
  * SOLARIS/osi_vnodeops.c
@@ -363,7 +363,7 @@
     else
 	tdc = afs_GetDCache(avc, (afs_offs_t) off, &treq, &offset, &nlen, 1);
     if (!tdc)
-	return EINVAL;
+	return afs_CheckCode(EINVAL, &treq, 62);
     code = afs_VerifyVCache(avc, &treq);
     if (code) {
 	afs_PutDCache(tdc);
--- openafs/src/afs/UKERNEL/afs_usrops.c:1.27.2.9	Mon Oct 27 19:54:09 2008
+++ openafs/src/afs/UKERNEL/afs_usrops.c	Mon Dec 29 16:26:24 2008
@@ -15,7 +15,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/UKERNEL/afs_usrops.c,v 1.27.2.9 2008/10/27 23:54:09 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/UKERNEL/afs_usrops.c,v 1.27.2.10 2008/12/29 21:26:24 shadow Exp $");
 
 
 #ifdef	UKERNEL
@@ -56,7 +56,7 @@
 
 struct usr_vnode *afs_FileTable[MAX_OSI_FILES];
 int afs_FileFlags[MAX_OSI_FILES];
-int afs_FileOffsets[MAX_OSI_FILES];
+off_t afs_FileOffsets[MAX_OSI_FILES];
 
 #define MAX_CACHE_LOOPS 4
 
@@ -107,8 +107,8 @@
 
 usr_key_t afs_global_u_key;
 
-struct usr_proc *afs_global_procp;
-struct usr_ucred *afs_global_ucredp;
+struct usr_proc *afs_global_procp = NULL;
+struct usr_ucred *afs_global_ucredp = NULL;
 struct usr_sysent usr_sysent[200];
 
 #ifdef AFS_USR_OSF_ENV
@@ -1562,7 +1562,7 @@
 	cacheStatEntries = cacheStatEntriesParam;
     }
     strcpy(cacheBaseDir, cacheBaseDirParam);
-    if (nDaemons != 0) {
+    if (nDaemonsParam != 0) {
 	nDaemons = nDaemonsParam;
     } else {
 	nDaemons = 3;
@@ -1847,7 +1847,11 @@
 			 (long)pathname_for_V[currVFile], 0, 0, 0);
 	}
     /*end for */
-#ifndef NETSCAPE_NSAPI
+/*#ifndef NETSCAPE_NSAPI*/
+#if 0
+/* this breaks solaris if the kernel-mode client has never been installed,
+ * and it doesn't seem to work now anyway, so just disable it */
+
     /*
      * Copy our tokens from the kernel to the user space client
      */
@@ -2692,6 +2696,7 @@
 		errno = code;
 		return -1;
 	    }
+	    fileP = AFSTOV(vc);
 	} else {
 	    fileP = NULL;
 	    code = uafs_LookupName(nameP, dirP, &fileP, 1, 0);
@@ -2764,6 +2769,7 @@
      */
     if ((flags & O_TRUNC) && (attrs.va_size != 0)) {
 	usr_vattr_null(&attrs);
+	attrs.va_mask = ATTR_SIZE;
 	attrs.va_size = 0;
 	code = afs_setattr(VTOAFS(fileP), &attrs, u.u_cred);
 	if (code != 0) {
@@ -2835,13 +2841,23 @@
 {
     int retval;
     AFS_GLOCK();
-    retval = uafs_write_r(fd, buf, len);
+    retval = uafs_pwrite_r(fd, buf, len, afs_FileOffsets[fd]);
+    AFS_GUNLOCK();
+    return retval;
+}
+
+int
+uafs_pwrite(int fd, char *buf, int len, off_t offset)
+{
+    int retval;
+    AFS_GLOCK();
+    retval = uafs_pwrite_r(fd, buf, len, offset);
     AFS_GUNLOCK();
     return retval;
 }
 
 int
-uafs_write_r(int fd, char *buf, int len)
+uafs_pwrite_r(int fd, char *buf, int len, off_t offset)
 {
     int code;
     struct usr_uio uio;
@@ -2864,7 +2880,7 @@
     iov[0].iov_len = len;
     uio.uio_iov = &iov[0];
     uio.uio_iovcnt = 1;
-    uio.uio_offset = afs_FileOffsets[fd];
+    uio.uio_offset = offset;
     uio.uio_segflg = 0;
     uio.uio_fmode = FWRITE;
     uio.uio_resid = len;
@@ -2891,13 +2907,23 @@
 {
     int retval;
     AFS_GLOCK();
-    retval = uafs_read_r(fd, buf, len);
+    retval = uafs_pread_r(fd, buf, len, afs_FileOffsets[fd]);
+    AFS_GUNLOCK();
+    return retval;
+}
+
+int
+uafs_pread(int fd, char *buf, int len, off_t offset)
+{
+    int retval;
+    AFS_GLOCK();
+    retval = uafs_pread_r(fd, buf, len, offset);
     AFS_GUNLOCK();
     return retval;
 }
 
 int
-uafs_read_r(int fd, char *buf, int len)
+uafs_pread_r(int fd, char *buf, int len, off_t offset)
 {
     int code;
     struct usr_uio uio;
@@ -2921,7 +2947,7 @@
     iov[0].iov_len = len;
     uio.uio_iov = &iov[0];
     uio.uio_iovcnt = 1;
-    uio.uio_offset = afs_FileOffsets[fd];
+    uio.uio_offset = offset;
     uio.uio_segflg = 0;
     uio.uio_fmode = FREAD;
     uio.uio_resid = len;
@@ -3105,6 +3131,7 @@
 	return -1;
     }
     usr_vattr_null(&attrs);
+    attrs.va_mask = ATTR_MODE;
     attrs.va_mode = mode;
     code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
     VN_RELE(vp);
@@ -3141,6 +3168,7 @@
 	return -1;
     }
     usr_vattr_null(&attrs);
+    attrs.va_mask = ATTR_MODE;
     attrs.va_mode = mode;
     code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
     if (code != 0) {
@@ -3176,6 +3204,7 @@
 	return -1;
     }
     usr_vattr_null(&attrs);
+    attrs.va_mask = ATTR_SIZE;
     attrs.va_size = length;
     code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
     VN_RELE(vp);
@@ -3212,6 +3241,7 @@
 	return -1;
     }
     usr_vattr_null(&attrs);
+    attrs.va_mask = ATTR_SIZE;
     attrs.va_size = length;
     code = afs_setattr(VTOAFS(vp), &attrs, u.u_cred);
     if (code != 0) {
--- openafs/src/afs/UKERNEL/afs_usrops.h:1.5	Tue May  4 05:31:11 2004
+++ openafs/src/afs/UKERNEL/afs_usrops.h	Mon Dec 29 16:26:24 2008
@@ -61,7 +61,7 @@
 extern struct usr_vnode *afs_CurrentDir;
 extern struct usr_vnode *afs_FileTable[];
 extern int afs_FileFlags[];
-extern int afs_FileOffsets[];
+extern off_t afs_FileOffsets[];
 
 extern char afs_mountDir[];
 extern int afs_mountDirLen;
@@ -90,9 +90,11 @@
 extern int uafs_creat(char *path, int mode);
 extern int uafs_creat_r(char *path, int mode);
 extern int uafs_write(int fd, char *buf, int len);
-extern int uafs_write_r(int fd, char *buf, int len);
+extern int uafs_pwrite(int fd, char *buf, int len, off_t offset);
+extern int uafs_pwrite_r(int fd, char *buf, int len, off_t offset);
 extern int uafs_read(int fd, char *buf, int len);
-extern int uafs_read_r(int fd, char *buf, int len);
+extern int uafs_pread(int fd, char *buf, int leni, off_t offset);
+extern int uafs_pread_r(int fd, char *buf, int len, off_t offset);
 extern int uafs_fsync(int fd);
 extern int uafs_fsync_r(int fd);
 extern int uafs_close(int fd);
--- openafs/src/afs/UKERNEL/sysincludes.h:1.15.2.2	Thu Nov  9 19:08:56 2006
+++ openafs/src/afs/UKERNEL/sysincludes.h	Mon Dec 29 16:26:24 2008
@@ -1017,22 +1017,28 @@
     unsigned long f_files;
 };
 
+#define ATTR_MODE	(1 << 0)
+#define ATTR_UID	(1 << 1)
+#define ATTR_GID	(1 << 2)
+#define ATTR_MTIME	(1 << 3)
+#define ATTR_SIZE	(1 << 4)
+
 struct usr_vattr {
-    long va_mask;
+    int va_mask;	/* bitmask of ATTR_* values above */
     usr_vtype_t va_type;
-    unsigned short va_mode;
-    long va_uid;
-    long va_gid;
-    unsigned long va_fsid;
-    unsigned long va_nodeid;
-    unsigned long va_nlink;
-    unsigned long va_size;
+    mode_t va_mode;
+    uid_t va_uid;
+    gid_t va_gid;
+    int va_fsid;
+    ino_t va_nodeid;
+    nlink_t va_nlink;
+    afs_size_t va_size;
     struct timeval va_atime;
     struct timeval va_mtime;
     struct timeval va_ctime;
-    unsigned long va_rdev;
+    dev_t va_rdev;
     unsigned long va_blocksize;
-    unsigned long va_blocks;
+    blkcnt_t va_blocks;
     unsigned long va_vcode;
 };
 
--- openafs/src/afs/VNOPS/afs_vnop_attrs.c:1.27.2.11	Thu Nov  9 19:08:57 2006
+++ openafs/src/afs/VNOPS/afs_vnop_attrs.c	Tue Jan 13 14:37:28 2009
@@ -24,7 +24,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.11 2006/11/10 00:08:57 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_attrs.c,v 1.27.2.14 2009/01/13 19:37:28 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
@@ -344,7 +344,7 @@
 #elif	defined(AFS_AIX_ENV)
 /* Boy, was this machine dependent bogosity hard to swallow????.... */
     if (av->va_mode != -1) {
-#elif	defined(AFS_LINUX22_ENV)
+#elif	defined(AFS_LINUX22_ENV) || defined(UKERNEL)
     if (av->va_mask & ATTR_MODE) {
 #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
     if (av->va_mask & AT_MODE) {
@@ -363,7 +363,7 @@
     }
 #if     defined(AFS_DARWIN80_ENV)
     if (VATTR_IS_ACTIVE(av, va_gid)) {
-#elif defined(AFS_LINUX22_ENV)
+#elif defined(AFS_LINUX22_ENV) || defined(UKERNEL)
     if (av->va_mask & ATTR_GID) {
 #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
     if (av->va_mask & AT_GID) {
@@ -383,7 +383,7 @@
     }
 #if     defined(AFS_DARWIN80_ENV)
     if (VATTR_IS_ACTIVE(av, va_uid)) {
-#elif defined(AFS_LINUX22_ENV)
+#elif defined(AFS_LINUX22_ENV) || defined(UKERNEL)
     if (av->va_mask & ATTR_UID) {
 #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
     if (av->va_mask & AT_UID) {
@@ -403,7 +403,7 @@
     }
 #if     defined(AFS_DARWIN80_ENV)
     if (VATTR_IS_ACTIVE(av, va_modify_time)) {
-#elif	defined(AFS_LINUX22_ENV)
+#elif	defined(AFS_LINUX22_ENV) || defined(UKERNEL)
     if (av->va_mask & ATTR_MTIME) {
 #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
     if (av->va_mask & AT_MTIME) {
@@ -482,7 +482,7 @@
      */
 #if	defined(AFS_DARWIN80_ENV)
     if (VATTR_IS_ACTIVE(attrs, va_data_size)) {
-#elif	defined(AFS_LINUX22_ENV)
+#elif	defined(AFS_LINUX22_ENV) || defined(UKERNEL)
     if (attrs->va_mask & ATTR_SIZE) {
 #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
     if (attrs->va_mask & AT_SIZE) {
@@ -515,19 +515,28 @@
 #endif
 #if	defined(AFS_DARWIN80_ENV)
     if (VATTR_IS_ACTIVE(attrs, va_data_size)) {
-#elif	defined(AFS_LINUX22_ENV)
+#elif	defined(AFS_LINUX22_ENV) || defined(UKERNEL)
     if (attrs->va_mask & ATTR_SIZE) {
 #elif	defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
     if (attrs->va_mask & AT_SIZE) {
 #elif	defined(AFS_OSF_ENV) || defined(AFS_XBSD_ENV)
     if (attrs->va_size != VNOVAL) {
-#else
+#elif	defined(AFS_AIX41_ENV)
     if (attrs->va_size != -1) {
+#else
+    if (attrs->va_size != ~0) {
 #endif
 	afs_size_t tsize = attrs->va_size;
 	ObtainWriteLock(&avc->lock, 128);
 	avc->states |= CDirty;
 	code = afs_TruncateAllSegments(avc, tsize, &treq, acred);
+#ifdef AFS_LINUX26_ENV
+	/* We must update the Linux kernel's idea of file size as soon as
+	 * possible, to avoid racing with delayed writepages delivered by
+	 * pdflush */
+	if (code == 0) 
+	    i_size_write(AFSTOV(avc), tsize);
+#endif
 	/* if date not explicitly set by this call, set it ourselves, since we
 	 * changed the data */
 	if (!(astat.Mask & AFS_SETMODTIME)) {
--- openafs/src/afs/VNOPS/afs_vnop_create.c:1.16.2.10	Sat Dec  8 13:00:45 2007
+++ openafs/src/afs/VNOPS/afs_vnop_create.c	Mon Dec 29 16:26:25 2008
@@ -17,7 +17,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.10 2007/12/08 18:00:45 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afs/VNOPS/afs_vnop_create.c,v 1.16.2.11 2008/12/29 21:26:25 shadow Exp $");
 
 #include "afs/sysincludes.h"	/* Standard vendor system headers */
 #include "afsincludes.h"	/* Afs-based standard headers */
@@ -217,6 +217,8 @@
 		    VATTR_INIT(attrs);
 		    VATTR_SET_SUPPORTED(attrs, va_data_size);
 		    VATTR_SET_ACTIVE(attrs, va_data_size);
+#elif defined(UKERNEL)
+		    attrs->va_mask = ATTR_SIZE;
 #elif defined(AFS_SUN5_ENV) || defined(AFS_SGI_ENV)
 		    attrs->va_mask = AT_SIZE;
 #else
--- openafs/src/afsd/afs.rc.linux:1.9.2.4	Mon Jan 21 16:05:15 2008
+++ openafs/src/afsd/afs.rc.linux	Mon Jan 19 15:54:01 2009
@@ -1,4 +1,4 @@
-#! /bin/sh
+#! /bin/bash
 # Copyright 2000, International Business Machines Corporation and others.
 # All Rights Reserved.
 # 
--- openafs/src/afsd/afsd.c:1.43.2.25	Wed Oct 31 18:32:17 2007
+++ openafs/src/afsd/afsd.c	Thu Mar 19 22:32:59 2009
@@ -32,6 +32,9 @@
   *	-nosettime  Don't keep checking the time to avoid drift (default).
   *     -settime    Keep checking the time to avoid drift.
   *	-verbose     Be chatty.
+  *	-disable-dynamic-vcaches     Disable the use of -stat value as the starting size of
+  *                          the size of the vcache/stat cache pool, 
+  *                          but increase that pool dynamically as needed.
   *	-debug	   Print out additional debugging info.
   *	-kerndev    [OBSOLETE] The kernel device for AFS.
   *	-dontfork   [OBSOLETE] Don't fork off as a new process.
@@ -58,7 +61,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.25 2007/10/31 22:32:17 shadow Exp $");
+    ("$Header: /cvs/openafs/src/afsd/afsd.c,v 1.43.2.26 2009/03/20 02:32:59 shadow Exp $");
 
 #define VFS 1
 
@@ -312,6 +315,7 @@
 #ifdef notdef
 static int inodes = 60;		/* VERY conservative, but has to be */
 #endif
+int afsd_dynamic_vcaches = 0;	/* Enable dynamic-vcache support */
 int afsd_verbose = 0;		/*Are we being chatty? */
 int afsd_debug = 0;		/*Are we printing debugging info? */
 int afsd_CloseSynch = 0;	/*Are closes synchronous or not? */
@@ -1736,6 +1740,25 @@
 	}
     }
     
+    if (as->parms[34].items) {
+#ifdef AFS_MAXVCOUNT_ENV
+       /* -disable-dynamic-vcaches */
+       afsd_dynamic_vcaches = FALSE;
+#else
+       printf("afsd: Error toggling flag, dynamically allocated vcaches not supported on your platform\n");
+       exit(1);
+#endif
+    }
+#ifdef AFS_MAXVCOUNT_ENV
+    else {
+       /* -dynamic-vcaches */
+       afsd_dynamic_vcaches = TRUE;
+    }
+
+    if (afsd_verbose)
+    printf("afsd: %s dynamically allocated vcaches\n", ( afsd_dynamic_vcaches ? "enabling" : "disabling" ));
+#endif
+
     /*
      * Pull out all the configuration info for the workstation's AFS cache and
      * the cellular community we're willing to let our users see.
@@ -2073,6 +2096,7 @@
     cparams.chunkSize = chunkSize;
     cparams.setTimeFlag = cacheSetTime;
     cparams.memCacheFlag = cacheFlags;
+    cparams.dynamic_vcaches = afsd_dynamic_vcaches;
 #ifdef notdef
     cparams.inodes = inodes;
 #endif
@@ -2445,6 +2469,7 @@
     cmd_AddParm(ts, "-settime", CMD_FLAG, CMD_OPTIONAL,
                "set the time");
     cmd_AddParm(ts, "-rxpck", CMD_SINGLE, CMD_OPTIONAL, "set rx_extraPackets to this value");
+    cmd_AddParm(ts, "-disable-dynamic-vcaches", CMD_FLAG, CMD_OPTIONAL, "disable stat/vcache cache growing as needed");
     return (cmd_Dispatch(argc, argv));
 }
 
--- openafs/src/aklog/Makefile.in:1.1.2.12	Sat Jun 28 03:19:05 2008
+++ openafs/src/aklog/Makefile.in	Tue Feb 17 17:06:11 2009
@@ -9,9 +9,10 @@
 AKLIBS = ${LIBS} @KRB5LIBS@
 AFSLIBS = ${TOP_LIBDIR}/libprot.a ${TOP_LIBDIR}/libubik.a \
 	  ${TOP_LIBDIR}/libauth.a ${TOP_LIBDIR}/librxkad.a \
-	  ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a \
-	  ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libdes.a \
-	  ${TOP_LIBDIR}/libcom_err.a ${TOP_LIBDIR}/libafsutil.a
+	  ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librx.a \
+	  ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libsys.a \
+	  ${TOP_LIBDIR}/libdes.a ${TOP_LIBDIR}/libcom_err.a \
+	  ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libafsutil.a 
 
 SRCS=	aklog.c aklog_main.c  krb_util.c linked_list.c
 OBJS=   aklog.o aklog_main.o krb_util.o linked_list.o
@@ -26,7 +27,7 @@
 
 klog: klog.o skipwrap.o ${AFSLIBS}
 	${CC} -o $@ ${CFLAGS} skipwrap.o klog.o ${AKLIBS} ${AFSLIBS} \
-		${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/librx.a ${XLIBS}
+		${XLIBS}
 
 #
 # Installation targets
--- openafs/src/aklog/aklog_main.c:1.1.2.28	Wed Oct 29 15:44:10 2008
+++ openafs/src/aklog/aklog_main.c	Sun Mar 15 14:02:52 2009
@@ -1,5 +1,5 @@
 /* 
- * $Id: aklog_main.c,v 1.1.2.28 2008/10/29 19:44:10 shadow Exp $
+ * $Id: aklog_main.c,v 1.1.2.31 2009/03/15 18:02:52 shadow Exp $
  *
  * Copyright 1990,1991 by the Massachusetts Institute of Technology
  * For distribution and copying rights, see the file "mit-copyright.h"
@@ -36,7 +36,7 @@
 
 #include <afsconfig.h>
 RCSID
-     ("$Header: /cvs/openafs/src/aklog/aklog_main.c,v 1.1.2.28 2008/10/29 19:44:10 shadow Exp $");
+     ("$Header: /cvs/openafs/src/aklog/aklog_main.c,v 1.1.2.31 2009/03/15 18:02:52 shadow Exp $");
 #include <stdio.h>
 #include <string.h>
 #include <ctype.h>
@@ -637,25 +637,40 @@
 
 	if (! do524) {
 	    char *p;
+	    char k4name[ANAME_SZ], k4inst[INST_SZ], k4realm[REALM_SZ];
 	    int len;
 
 	    if (dflag)
 	    	printf("Using Kerberos V5 ticket natively\n");
 
+#ifndef HAVE_NO_KRB5_524
+	    status = krb5_524_conv_principal (context, v5cred->client, &k4name, &k4inst, &k4realm);
+	    if (status) {
+		afs_com_err(progname, status, "while converting principal "
+			"to Kerberos V4 format");
+		return(AKLOG_KERBEROS);
+	    }
+	    strcpy (username, k4name);
+	    if (k4inst[0]) {
+		strcat (username, ".");
+		strcat (username, k4inst);
+	    }
+#else
 	    len = min(get_princ_len(context, v5cred->client, 0),
-	    	      second_comp(context, v5cred->client) ?
-					MAXKTCNAMELEN - 2 : MAXKTCNAMELEN - 1);
+		      second_comp(context, v5cred->client) ?
+		      MAXKTCNAMELEN - 2 : MAXKTCNAMELEN - 1);
 	    strncpy(username, get_princ_str(context, v5cred->client, 0), len);
 	    username[len] = '\0';
-
+	    
 	    if (second_comp(context, v5cred->client)) {
-	    	strcat(username, ".");
+		strcat(username, ".");
 		p = username + strlen(username);
 		len = min(get_princ_len(context, v5cred->client, 1),
 			  MAXKTCNAMELEN - strlen(username) - 1);
 		strncpy(p, get_princ_str(context, v5cred->client, 1), len);
 		p[len] = '\0';
 	    }
+#endif
 
 	    memset(&atoken, 0, sizeof(atoken));
 	    atoken.kvno = RXKAD_TKT_TYPE_KERBEROS_V5;
--- openafs/src/audit/audit.c:1.8.2.12	Fri Oct 13 15:42:19 2006
+++ openafs/src/audit/audit.c	Wed Mar 18 23:45:01 2009
@@ -11,11 +11,18 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/audit/audit.c,v 1.8.2.12 2006/10/13 19:42:19 shadow Exp $");
+    ("$Header: /cvs/openafs/src/audit/audit.c,v 1.8.2.16 2009/03/19 03:45:01 shadow Exp $");
 
 #include <fcntl.h>
 #include <stdarg.h>
 #include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifndef AFS_NT40_ENV
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
 #ifdef AFS_AIX32_ENV
 #include <sys/audit.h>
 #else
@@ -233,24 +240,21 @@
 	    break;
 	case AUD_FIDS:		/* array of Fids */
 	    vaFids = va_arg(vaList, struct AFSCBFids *);
-	    vaFid = NULL;
 
 	    if (vaFids) {
                 int i;
-                if (vaFid)
+                
+                vaFid = vaFids->AFSCBFids_val;
+                
+                if (vaFid) {
                     fprintf(out, "FIDS %u FID %u:%u:%u ", vaFids->AFSCBFids_len, vaFid->Volume,
                              vaFid->Vnode, vaFid->Unique);
-                else
+                    for ( i = 1; i < vaFids->AFSCBFids_len; i++, vaFid++ ) 
+                        fprintf(out, "FID %u:%u:%u ", vaFid->Volume,
+                                vaFid->Vnode, vaFid->Unique);
+                } else
                     fprintf(out, "FIDS 0 FID 0:0:0 ");
 
-                for ( i = 1; i < vaFids->AFSCBFids_len; i++ ) {
-                    vaFid = vaFids->AFSCBFids_val;
-                    if (vaFid)
-                        fprintf(out, "FID %u:%u:%u ", vaFid->Volume,
-                                 vaFid->Vnode, vaFid->Unique);
-                    else
-                        fprintf(out, "FID 0:0:0 ");
-                }
             }
 	    break;
 	default:
@@ -447,12 +451,43 @@
                     }
                     if ((clen = strlen(tcell))) {
 #if defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
-                        static char local_realm[AFS_REALM_SZ] = "";
-                        if (!local_realm[0]) {
-                            if (afs_krb_get_lrealm(local_realm, 0) != 0 /*KSUCCESS*/)
-                                strncpy(local_realm, "UNKNOWN.LOCAL.REALM", AFS_REALM_SZ);
+                        static char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
+			static int  num_lrealms = -1;
+			int i, lrealm_match;
+
+			if (num_lrealms == -1) {
+			    for (i=0; i<AFS_NUM_LREALMS; i++) {
+				if (afs_krb_get_lrealm(local_realms[i], i) != 0 /*KSUCCESS*/)
+				    break;
+			    }
+
+			    if (i == 0)
+				strncpy(local_realms[0], "UNKNOWN.LOCAL.REALM", AFS_REALM_SZ);
+			    num_lrealms = i;
                         }
-                        if (strcasecmp(local_realm, tcell)) {
+
+			/* Check to see if the ticket cell matches one of the local realms */
+			lrealm_match = 0;
+			for ( i=0;i<num_lrealms;i++ ) {
+			    if (!strcasecmp(local_realms[i], tcell)) {
+				lrealm_match = 1;
+				break;
+			    }
+			}
+			/* If yes, then make sure that the name is not present in 
+  			 * an exclusion list */
+			if (lrealm_match) {
+			    char uname[256];
+			    if (inst[0])
+				snprintf(uname,sizeof(uname),"%s.%s@%s",name,inst,tcell);
+			    else
+				snprintf(uname,sizeof(uname),"%s@%s",name,tcell);
+
+			    if (afs_krb_exclusion(uname))
+				lrealm_match = 0;
+			}
+
+			if (!lrealm_match) {	
                             if (strlen(vname) + 1 + clen >= sizeof(vname))
                                 goto done;
                             strcat(vname, "@");
@@ -527,8 +562,35 @@
 }
 
 int
-osi_audit_file(FILE *out)
+osi_audit_file(char *fileName)
 {
-    auditout = out;
+    int tempfd, flags;
+    char oldName[MAXPATHLEN];
+    
+#ifndef AFS_NT40_ENV
+    struct stat statbuf;
+    
+    if ((lstat(fileName, &statbuf) == 0)
+        && (S_ISFIFO(statbuf.st_mode))) {
+        flags = O_WRONLY | O_NONBLOCK;
+    } else 
+#endif
+    {
+        strcpy(oldName, fileName);
+        strcat(oldName, ".old");
+        renamefile(fileName, oldName);
+        flags = O_WRONLY | O_TRUNC | O_CREAT;
+    }
+    tempfd = open(fileName, flags, 0666);
+    if (tempfd > -1) {
+        auditout = fdopen(tempfd, "a");
+        if (!auditout) {
+            printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+            return 1;
+        }
+    } else { 
+        printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+        return 1;
+    }
     return 0;
 }
--- openafs/src/audit/audit.h:1.5.2.5	Mon Feb 13 12:56:49 2006
+++ openafs/src/audit/audit.h	Wed Dec 17 13:16:25 2008
@@ -291,6 +291,6 @@
 /* prototypes for audit functions */
 int osi_audit(char *audEvent, afs_int32 errCode, ...);
 int osi_auditU(struct rx_call *call, char *audEvent, int errCode, ...);
-int osi_audit_file(FILE *out);
+int osi_audit_file(char *filename);
 void osi_audit_init(void);
 
--- openafs/src/auth/ktc.c:1.15.2.10	Thu Dec 13 13:54:09 2007
+++ openafs/src/auth/ktc.c	Fri Mar 20 18:45:37 2009
@@ -17,7 +17,7 @@
 #endif
 
 RCSID
-    ("$Header: /cvs/openafs/src/auth/ktc.c,v 1.15.2.10 2007/12/13 18:54:09 shadow Exp $");
+    ("$Header: /cvs/openafs/src/auth/ktc.c,v 1.15.2.11 2009/03/20 22:45:37 shadow Exp $");
 
 #if defined(UKERNEL)
 #include "afs/sysincludes.h"
@@ -56,9 +56,11 @@
 #include <sys/lockf.h>
 #ifdef AFS_AIX51_ENV
 #include <sys/cred.h>
+#ifdef HAVE_SYS_PAG_H
 #include <sys/pag.h>
 #endif
 #endif
+#endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
--- openafs/src/auth/userok.c:1.12.2.3	Thu Feb 28 23:46:20 2008
+++ openafs/src/auth/userok.c	Wed Mar 18 23:44:59 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/auth/userok.c,v 1.12.2.3 2008/02/29 04:46:20 shadow Exp $");
+    ("$Header: /cvs/openafs/src/auth/userok.c,v 1.12.2.4 2009/03/19 03:44:59 shadow Exp $");
 
 #include <afs/stds.h>
 #include <afs/pthread_glock.h>
@@ -382,7 +382,9 @@
 
 	afs_uint32 exp;
 	static char lcell[MAXCELLCHARS] = "";
-	static char lrealm[AFS_REALM_SZ] = "";
+	static char lrealms[AFS_NUM_LREALMS][AFS_REALM_SZ];
+	static int  num_lrealms = -1;
+	int lrealm_match = 0, i;
 
 	/* get auth details from server connection */
 	code =
@@ -419,11 +421,40 @@
 	/* if running a krb environment, also get the local realm */
 	/* note - this assumes AFS_REALM_SZ <= MAXCELLCHARS */
 	/* just set it to lcell if it fails */
-	if (!lrealm[0]) {
-	    if (afs_krb_get_lrealm(lrealm, 0) != 0)	/* KSUCCESS */
-		strncpy(lrealm, lcell, AFS_REALM_SZ);
+	if (num_lrealms == -1) {
+	    for (i=0; i<AFS_NUM_LREALMS; i++) {
+		if (afs_krb_get_lrealm(lrealms[i], i) != 0 /*KSUCCESS*/)
+		    break;
+	    }
+
+	    if (i == 0) {
+		strncpy(lrealms[0], lcell, AFS_REALM_SZ);
+		num_lrealms = 1;
+	    } else {
+		num_lrealms = i;
+	    }
 	}
 
+	/* See if the ticket cell matches one of the local realms */
+	lrealm_match = 0;
+	for ( i=0;i<num_lrealms;i++ ) {
+	    if (!strcasecmp(lrealms[i], tcell)) {
+		lrealm_match = 1;
+		break;
+	    }
+	}
+
+	/* If yes, then make sure that the name is not present in 
+	 * an exclusion list */
+	if (lrealm_match) {
+	    if (tinst[0])
+		snprintf(uname,sizeof(uname),"%s.%s@%s",tname,tinst,tcell);
+	    else
+		snprintf(uname,sizeof(uname),"%s@%s",tname,tcell);
+
+	    if (afs_krb_exclusion(uname))
+		lrealm_match = 0;
+	}
 
 	/* start with no uname and no authorization */
 	strcpy(uname, "");
@@ -435,8 +466,8 @@
 	    strcpy(uname, "<LocalAuth>");
 	    flag = 1;
 
-	    /* cell of connection matches local cell or krb4 realm */
-	} else if (!strcasecmp(tcell, lcell) || !strcasecmp(tcell, lrealm)) {
+	    /* cell of connection matches local cell or one of the realms */
+	} else if (!strcasecmp(tcell, lcell) || lrealm_match) {
 	    if ((tmp = CompFindUser(adir, tname, ".", tinst, NULL))) {
 		strcpy(uname, tmp);
 		flag = 1;
@@ -446,7 +477,6 @@
 		flag = 1;
 #endif
 	    }
-
 	    /* cell of conn doesn't match local cell or realm */
 	} else {
 	    if ((tmp = CompFindUser(adir, tname, ".", tinst, tcell))) {
--- openafs/src/bozo/bnode.c:1.17.2.9	Mon Jun 30 16:31:41 2008
+++ openafs/src/bozo/bnode.c	Thu Mar 26 10:30:46 2009
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/bozo/bnode.c,v 1.17.2.11 2009/03/26 14:30:46 shadow Exp $");
 
 #include <stddef.h>
 #include <stdlib.h>
@@ -147,7 +147,7 @@
     TM_GetTimeOfDay(&Start, 0);
     TimeFields = localtime(&Start.tv_sec);
     sprintf(FileName, "%s.%d%02d%02d%02d%02d%02d", tbuffer,
-	    TimeFields->tm_year, TimeFields->tm_mon + 1, TimeFields->tm_mday,
+	    TimeFields->tm_year + 1900, TimeFields->tm_mon + 1, TimeFields->tm_mday,
 	    TimeFields->tm_hour, TimeFields->tm_min, TimeFields->tm_sec);
     strcpy(tbuffer, FileName);
 #endif
@@ -753,6 +753,7 @@
     if (write(fd, buffer, len) < 0) {
 	return -1;
     }
+    return 0;
 }
 
 int
--- openafs/src/bozo/bosserver.c:1.23.2.17	Sat Oct 18 11:10:57 2008
+++ openafs/src/bozo/bosserver.c	Wed Dec 17 13:16:27 2008
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/bozo/bosserver.c,v 1.23.2.17 2008/10/18 15:10:57 jaltman Exp $");
+    ("$Header: /cvs/openafs/src/bozo/bosserver.c,v 1.23.2.18 2008/12/17 18:16:27 shadow Exp $");
 
 #include <afs/stds.h>
 #include <sys/types.h>
@@ -841,34 +841,9 @@
 	    }
 	}
 	else if (strcmp(argv[code], "-auditlog") == 0) {
-	    int tempfd, flags;
-	    FILE *auditout;
-	    char oldName[MAXPATHLEN];
 	    char *fileName = argv[++code];
 
-#ifndef AFS_NT40_ENV
-	    struct stat statbuf;
-	    
-	    if ((lstat(fileName, &statbuf) == 0) 
-		&& (S_ISFIFO(statbuf.st_mode))) {
-		flags = O_WRONLY | O_NONBLOCK;
-	    } else 
-#endif
-	    {
-		strcpy(oldName, fileName);
-		strcat(oldName, ".old");
-		renamefile(fileName, oldName);
-		flags = O_WRONLY | O_TRUNC | O_CREAT;
-	    }
-	    tempfd = open(fileName, flags, 0666);
-	    if (tempfd > -1) {
-		auditout = fdopen(tempfd, "a");
-		if (auditout) {
-		    osi_audit_file(auditout);
-		} else
-		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-	    } else
-		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+            osi_audit_file(fileName);
 	}
 	else {
 
--- openafs/src/bucoord/ubik_db_if.c:1.10.2.2	Tue Apr 10 14:43:41 2007
+++ openafs/src/bucoord/ubik_db_if.c	Fri Mar 27 09:46:13 2009
@@ -13,7 +13,7 @@
 #include <afs/stds.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/bucoord/ubik_db_if.c,v 1.10.2.2 2007/04/10 18:43:41 shadow Exp $");
+    ("$Header: /cvs/openafs/src/bucoord/ubik_db_if.c,v 1.10.2.5 2009/03/27 13:46:13 shadow Exp $");
 
 #include <sys/types.h>
 #include <fcntl.h>
@@ -44,7 +44,7 @@
 afs_int32 bcdb_CreateDump(register struct budb_dumpEntry *) ;
 afs_int32 bcdb_deleteDump(afs_int32, afs_int32, afs_int32, budb_dumpsList *);
 /*note the pinter to the function comes from ubik/ubikclient ubik_Call function.*/
-afs_int32 bcdb_listDumps (int (), afs_int32,afs_int32,afs_int32, budb_dumpsList *,
+afs_int32 bcdb_listDumps (afs_int32, afs_int32,afs_int32,afs_int32, budb_dumpsList *,
  budb_dumpsList *);
 afs_int32 bcdb_DeleteVDP(char *, char *, afs_int32 );
 afs_int32 bcdb_FindClone(afs_int32, char *, afs_int32 *);
@@ -109,7 +109,7 @@
     return (code);
 }
 
-afs_int32 bcdb_listDumps (int (*sflags) (), afs_int32 groupId,afs_int32 fromTime, afs_int32 toTime,budb_dumpsList *dumps, budb_dumpsList *flags)
+afs_int32 bcdb_listDumps (afs_int32 sflags, afs_int32 groupId,afs_int32 fromTime, afs_int32 toTime,budb_dumpsList *dumps, budb_dumpsList *flags)
 {
     afs_int32 code, sflag = 0;
     budb_dumpsList dumpsList, *dumpsPtr;
@@ -883,7 +883,7 @@
 		afs_com_err(whoami, code, 0,
 			"; Can't get AFS tokens - running unauthenticated");
 	    } else {
-		if ((ttoken->kvno < 0) || (ttoken->kvno > 255))
+		if ((ttoken->kvno < 0) || (ttoken->kvno > 256))
 		    afs_com_err(whoami, 0,
 			    "Funny kvno (%d) in ticket, proceeding",
 			    ttoken->kvno);
@@ -1026,7 +1026,7 @@
 		afs_com_err(whoami, code,
 			"; Can't get tokens - running unauthenticated");
 	    } else {
-		if ((token.kvno < 0) || (token.kvno > 255))
+		if ((token.kvno < 0) || (token.kvno > 256))
 		    afs_com_err(whoami, 0,
 			    "Unexpected kvno (%d) in ticket - proceeding",
 			    token.kvno);
--- openafs/src/budb/ol_verify.c:1.13.2.2	Tue Oct 30 11:23:50 2007
+++ openafs/src/budb/ol_verify.c	Thu Mar 26 10:30:44 2009
@@ -13,7 +13,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/budb/ol_verify.c,v 1.13.2.2 2007/10/30 15:23:50 shadow Exp $");
+    ("$Header: /cvs/openafs/src/budb/ol_verify.c,v 1.13.2.3 2009/03/26 14:30:44 shadow Exp $");
 
 #include <stdio.h>
 #ifdef AFS_NT40_ENV
@@ -1495,8 +1495,8 @@
  *	do a simple sanity check on the database header
  */
 
-check_header(callerst)
-     char *callerst;
+void
+check_header(char *callerst)
 {
     static int iteration_count = 0;
     afs_int32 eof;
--- openafs/src/budb/server.c:1.14.2.9	Mon Mar 10 18:35:34 2008
+++ openafs/src/budb/server.c	Mon Dec 22 14:23:31 2008
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/budb/server.c,v 1.14.2.9 2008/03/10 22:35:34 shadow Exp $");
+    ("$Header: /cvs/openafs/src/budb/server.c,v 1.14.2.11 2008/12/22 19:23:31 shadow Exp $");
 
 #include <fcntl.h>
 #include <sys/stat.h>
@@ -220,33 +220,9 @@
 	ubik_nBuffers = 0;
 
     if (as->parms[7].items != 0) {
-	int tempfd, flags;
-	FILE *auditout;
-	char oldName[MAXPATHLEN];
 	char *fileName = as->parms[7].items->data;
-#ifndef AFS_NT40_ENV
-	struct stat statbuf;
 
-	if ((lstat(fileName, &statbuf) == 0) 
-	    && (S_ISFIFO(statbuf.st_mode))) {
-	    flags = O_WRONLY | O_NONBLOCK;
-	} else 
-#endif
-	{
-	    strcpy(oldName, fileName);
-	    strcat(oldName, ".old");
-	    renamefile(fileName, oldName);
-	    flags = O_WRONLY | O_TRUNC | O_CREAT;
-	}
-	tempfd = open(fileName, flags, 0666);
-	if (tempfd > -1) {
-	    auditout = fdopen(tempfd, "a");
-	    if (auditout) {
-		osi_audit_file(auditout);
-	    } else
-		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-	} else
-	    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+        osi_audit_file(fileName);
     }
 
     return 0;
@@ -535,7 +511,7 @@
     code = ubik_ServerInitByInfo (globalConfPtr->myHost,
 				  htons(AFSCONF_BUDBPORT), 
 				  &cellinfo,
-				  &clones,              
+				  clones,              
 				  dbNamePtr,           /* name prefix */
 				  &BU_dbase);
 
--- openafs/src/butc/afsxbsa.c:1.1.6.2	Tue Jul 15 06:33:57 2008
+++ openafs/src/butc/afsxbsa.c	Mon Dec 15 17:21:37 2008
@@ -648,6 +648,8 @@
 #endif
 #if defined(AFS_AIX_ENV)
         dynlib = dlopen("/usr/lib/libApiDS.a(dsmapish.o)", RTLD_NOW | RTLD_LOCAL | RTLD_MEMBER);
+#elif defined (AFS_AMD64_LINUX26_ENV)
+	dynlib = dlopen("/usr/lib64/libApiTSM64.so", RTLD_NOW | RTLD_LOCAL);
 #elif defined(AFS_SUN5_ENV) || defined(AFS_LINUX26_ENV)
         dynlib = dlopen("/usr/lib/libApiDS.so", RTLD_NOW | RTLD_LOCAL);
 #else
--- openafs/src/butc/dump.c:1.17.2.4	Thu May  1 20:59:48 2008
+++ openafs/src/butc/dump.c	Sun Mar 15 14:19:37 2009
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/butc/dump.c,v 1.17.2.5 2009/03/15 18:19:37 shadow Exp $");
 
 #include <sys/types.h>
 #ifdef AFS_NT40_ENV
@@ -358,6 +358,13 @@
 		}
 	    }
 
+#ifdef xbsa
+	    /* Set aside space for the trailing volume header when using large buffers. */
+	    if (XBSAMAXBUFFER < toread + sizeof(hostVolumeHeader)) {
+		toread = XBSAMAXBUFFER - sizeof(hostVolumeHeader);
+	    }
+#endif
+
 	    /* Read some volume data. */
 	    if (fragmentvolume) {
 		bytesread = 0;
--- openafs/src/cf/kerberos.m4:1.1.2.16	Fri Apr 18 16:50:28 2008
+++ openafs/src/cf/kerberos.m4	Sat Mar 21 12:30:15 2009
@@ -1,5 +1,5 @@
 dnl
-dnl $Id: kerberos.m4,v 1.1.2.16 2008/04/18 20:50:28 shadow Exp $
+dnl $Id: kerberos.m4,v 1.1.2.18 2009/03/21 16:30:15 shadow Exp $
 dnl
 dnl Kerberos autoconf glue
 dnl
@@ -37,7 +37,7 @@
 
 AC_ARG_WITH([krb5], [--with-krb5 Support for Kerberos 5 (manual configuration)])
 
-if test X$with_krb5 = Xyes; then
+if test X$with_krb5 != X; then
         if test X$conf_krb5 = XYES; then
 		AC_MSG_ERROR([--with-krb5-config and --with-krb5 are mutually exclusive, choose only one])
 	fi
@@ -51,9 +51,11 @@
 fi
 
 BUILD_KRB5=no
+MAKE_KRB5=#
 if test X$conf_krb5 = XYES; then
 	AC_MSG_RESULT([Configuring support for Kerberos 5 utilities])
 	BUILD_KRB5=yes
+	MAKE_KRB5=
 	save_CPPFLAGS="$CPPFLAGS"
 	CPPFLAGS="$CPPFLAGS $KRB5CFLAGS"
 	save_LIBS="$LIBS"
@@ -122,6 +124,7 @@
 fi
 
 AC_SUBST(BUILD_KRB5)
+AC_SUBST(MAKE_KRB5)
 AC_SUBST(KRB5CFLAGS)
 AC_SUBST(KRB5LIBS)
 
--- openafs/src/cf/linux-test1.m4:1.3.2.13	Sun Oct 12 14:02:37 2008
+++ openafs/src/cf/linux-test1.m4	Sat Feb 21 10:37:01 2009
@@ -29,7 +29,7 @@
 _ACEOF
     echo make -C $LINUX_KERNEL_BUILD M=$SRCDIR_PARENT/conftest.dir modules KBUILD_VERBOSE=1 >&AS_MESSAGE_LOG_FD &&
     make -C $LINUX_KERNEL_BUILD M=$SRCDIR_PARENT/conftest.dir modules KBUILD_VERBOSE=1 >&AS_MESSAGE_LOG_FD 2>conftest.err &&
-    ! grep -i "^WARNING: .* undefined!$" conftest.err >/dev/null 2>&1
+    ! grep -i "WARNING: .* undefined!$" conftest.err >/dev/null 2>&1
     then [$3]
     else
       sed '/^ *+/d' conftest.err >&AS_MESSAGE_LOG_FD
--- openafs/src/cf/linux-test4.m4:1.20.2.51	Sat Nov  8 11:49:58 2008
+++ openafs/src/cf/linux-test4.m4	Sat Apr  4 12:44:15 2009
@@ -772,18 +772,41 @@
 AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_STRUCT_TASK], [
   AC_MSG_CHECKING([if key_alloc() takes a struct task *])
   AC_CACHE_VAL([ac_cv_key_alloc_needs_struct_task], [
+    save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -Werror -Wno-pointer-arith"
     AC_TRY_KBUILD(
 [#include <linux/rwsem.h>
 #include <linux/key.h>
 ],
-[(void) key_alloc(NULL, NULL, 0, 0, NULL, 0, 0);],
+[struct task_struct *t=NULL;
+(void) key_alloc(NULL, NULL, 0, 0, t, 0, 0);],
       ac_cv_key_alloc_needs_struct_task=yes,
-      ac_cv_key_alloc_needs_struct_task=no)])
+      ac_cv_key_alloc_needs_struct_task=no)
+    CPPFLAGS="$save_CPPFLAGS"])
   AC_MSG_RESULT($ac_cv_key_alloc_needs_struct_task)
   if test "x$ac_cv_key_alloc_needs_struct_task" = "xyes"; then
     AC_DEFINE([KEY_ALLOC_NEEDS_STRUCT_TASK], 1, [define if key_alloc takes a struct task *])
   fi])
 
+AC_DEFUN([LINUX_KEY_ALLOC_NEEDS_CRED], [
+  AC_MSG_CHECKING([if key_alloc() takes credentials])
+  AC_CACHE_VAL([ac_cv_key_alloc_needs_cred], [
+    save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -Werror -Wno-pointer-arith"
+    AC_TRY_KBUILD(
+[#include <linux/rwsem.h>
+#include <linux/key.h>
+],
+[struct cred *c = NULL;
+(void) key_alloc(NULL, NULL, 0, 0, c, 0, 0);],
+      ac_cv_key_alloc_needs_cred=yes,
+      ac_cv_key_alloc_needs_cred=no)
+    CPPFLAGS="$save_CPPFLAGS"])
+  AC_MSG_RESULT($ac_cv_key_alloc_needs_cred)
+  if test "x$ac_cv_key_alloc_needs_cred" = "xyes"; then
+    AC_DEFINE([KEY_ALLOC_NEEDS_CRED], 1, [define if key_alloc takes credentials])
+  fi])
+
 AC_DEFUN([LINUX_DO_SYNC_READ], [
   AC_MSG_CHECKING([for linux do_sync_read()])
   AC_CACHE_VAL([ac_cv_linux_do_sync_read], [
@@ -816,6 +839,22 @@
     AC_DEFINE([GENERIC_FILE_AIO_READ], 1, [define if your kernel has generic_file_aio_read()])
   fi])
 
+AC_DEFUN([LINUX_HAVE_I_SIZE_READ], [
+  AC_MSG_CHECKING([for linux i_size_read()])
+  AC_CACHE_VAL([ac_cv_linux_i_size_read], [
+    save_CPPFLAGS="$CPPFLAGS"
+    CPPFLAGS="$CPPFLAGS -Werror-implicit-function-declaration"
+    AC_TRY_KBUILD(
+[#include <linux/fs.h>],
+[i_size_read(NULL);],
+      ac_cv_linux_i_size_read=yes,
+      ac_cv_linux_i_size_read=no)
+    CPPFLAGS="$save_CPPFLAGS"])
+  AC_MSG_RESULT($ac_cv_linux_i_size_read)
+  if test "x$ac_cv_linux_i_size_read" = "xyes"; then
+    AC_DEFINE([HAVE_LINUX_I_SIZE_READ], 1, [define if your kernel has i_size_read()])
+  fi])
+
 AC_DEFUN([LINUX_FREEZER_H_EXISTS], [
   AC_MSG_CHECKING([for linux/freezer.h existance])
   AC_CACHE_VAL([ac_cv_linux_freezer_h_exists], [
@@ -1045,6 +1084,19 @@
     AC_DEFINE([LINUX_SEMAPHORE_H], 1, [define if linux/semaphore.h exists])
   fi])
 
+AC_DEFUN([LINUX_HAVE_BDI_INIT], [
+  AC_MSG_CHECKING([for linux bdi_init()])
+  AC_CACHE_VAL([ac_cv_linux_bdi_init], [
+    AC_TRY_KBUILD(
+[#include <linux/backing-dev.h>],
+[bdi_init(NULL);],
+      ac_cv_linux_bdi_init=yes,
+      ac_cv_linux_bdi_init=no)])
+  AC_MSG_RESULT($ac_cv_linux_bdi_init)
+  if test "x$ac_cv_linux_bdi_init" = "xyes"; then
+    AC_DEFINE([HAVE_BDI_INIT], 1, [define if your kernel has a bdi_init()])
+  fi])
+
 AC_DEFUN([LINUX_HAVE_WRITE_BEGIN_AOP], [
   AC_MSG_CHECKING([for linux write_begin() address space op])
   AC_CACHE_VAL([ac_cv_linux_write_begin], [
@@ -1057,3 +1109,46 @@
   if test "x$ac_cv_linux_write_begin" = "xyes"; then
     AC_DEFINE([HAVE_WRITE_BEGIN], 1, [define if your kernel has a write_begin() address space op])
   fi])
+
+AC_DEFUN([LINUX_HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN], [
+  AC_MSG_CHECKING([for linux grab_cache_page_write_begin()])
+  AC_CACHE_VAL([ac_cv_linux_grab_cache_page_write_begin], [
+    AC_TRY_KBUILD(
+[#include <linux/pagemap.h>],
+[grab_cache_page_write_begin(NULL, 0, 0);],
+      ac_cv_linux_grab_cache_page_write_begin=yes,
+      ac_cv_linux_grab_cache_page_write_begin=no)])
+  AC_MSG_RESULT($ac_cv_linux_grab_cache_page_write_begin)
+  if test "x$ac_cv_linux_grab_cache_page_write_begin" = "xyes"; then
+    AC_DEFINE([HAVE_GRAB_CACHE_PAGE_WRITE_BEGIN], 1, [define if your kernel has grab_cache_page_write_begin()])
+  fi])
+
+AC_DEFUN([LINUX_STRUCT_TASK_HAS_CRED], [
+  AC_MSG_CHECKING([if struct task has cred])
+  AC_CACHE_VAL([ac_cv_linux_struct_task_has_cred], [
+    AC_TRY_KBUILD(
+[#include <linux/sched.h>
+#include <linux/cred.h>],
+[struct task_struct _t;
+uid_t _u;
+_u =_t.cred->uid ;],
+      ac_cv_linux_struct_task_has_cred=yes,
+      ac_cv_linux_struct_task_has_cred=no)])
+  AC_MSG_RESULT($ac_cv_linux_struct_task_has_cred)
+  if test "x$ac_cv_linux_struct_task_has_cred" = "xyes"; then
+    AC_DEFINE([STRUCT_TASK_HAS_CRED], 1, [define if struct task has a cred pointer])
+  fi])
+
+AC_DEFUN([LINUX_STRUCT_PROC_DIR_ENTRY_HAS_OWNER], [
+  AC_MSG_CHECKING([if struct proc_dir_entry_has_owner])
+  AC_CACHE_VAL([ac_cv_linux_struct_proc_dir_entry_has_owner], [
+    AC_TRY_KBUILD(
+[#include <linux/proc_fs.h>],
+[struct proc_dir_entry _p;
+_p.owner= "";],
+      ac_cv_linux_struct_proc_dir_entry_has_owner=yes,
+      ac_cv_linux_struct_proc_dir_entry_has_owner=no)])
+  AC_MSG_RESULT($ac_cv_linux_struct_proc_dir_entry_has_owner)
+  if test "x$ac_cv_linux_struct_proc_dir_entry_has_owner" = "xyes"; then
+    AC_DEFINE([STRUCT_PROC_DIR_ENTRY_HAS_OWNER], 1, [define if struct proc_dir_entry has an owner member])
+  fi])
--- openafs/src/cf/osconf.m4:1.51.2.38	Wed Sep  3 14:27:39 2008
+++ openafs/src/cf/osconf.m4	Mon Dec 29 12:29:30 2008
@@ -234,7 +234,7 @@
 		SHLIB_LINKER="ld -b"
 		;;
 
-	*fbsd_*)
+	i386_fbsd_*)
 		LEX="flex -l"
 		MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}'
 		MT_LIBS="-pthread"
@@ -246,6 +246,18 @@
 		YACC="byacc"
 		;;
 
+	amd64_fbsd_*)
+		LEX="flex -l"
+		MT_CFLAGS='-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}'
+		MT_LIBS="-pthread"
+		PAM_CFLAGS="-O2 -pipe -fPIC"
+		SHLIB_LDFLAGS="-shared -Xlinker -x"
+		SHLIB_LINKER="${MT_CC} -shared"
+		TXLIBS="-lncurses"
+		XCFLAGS="-O2 -pipe -fPIC"
+		YACC="byacc"
+		;;
+
 	*nbsd2*|*nbsd3*|*nbsd4*)
 		LEX="flex -l"
 		MT_CFLAGS='${XCFLAGS} -DAFS_PTHREAD_ENV -D_REENTRANT '
@@ -474,7 +486,7 @@
 		;;
 
 	ppc_darwin_70)
-		AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration"
+		AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration -framework SystemConfiguration -framework IOKit -framework CoreFoundation"
 		LEX="lex -l"
 		MT_CFLAGS='-DAFS_PTHREAD_ENV -D_REENTRANT ${XCFLAGS}'
 		KROOT=
--- /dev/null	Sat Apr  4 14:44:30 2009
+++ openafs/src/cf/socklen.m4	Fri Mar 20 09:53:09 2009
@@ -0,0 +1,18 @@
+AC_DEFUN([AC_TYPE_SOCKLEN_T],
+[
+AC_CACHE_CHECK([for socklen_t], 
+ac_cv_type_socklen_t, [
+        AC_TRY_COMPILE([
+                      #include <sys/types.h>
+                      #include <sys/socket.h>
+              ],
+              [
+                      socklen_t len = 42; return 0;
+              ],
+              ac_cv_type_socklen_t="yes", ac_cv_type_socklen_t="no")
+        ])
+
+        if test "x$ac_cv_type_socklen_t" = "xno"; then
+              AC_DEFINE(socklen_t, int, [the type of the last argument to getsockopt etc])
+        fi
+])
--- openafs/src/config/afs_args.h:1.13.2.9	Wed Jan 30 16:37:35 2008
+++ openafs/src/config/afs_args.h	Thu Mar 19 22:32:59 2009
@@ -141,6 +141,7 @@
     afs_int32 memCacheFlag;
     afs_int32 inodes;
     afs_int32 users;
+    afs_int32 dynamic_vcaches;
 };
 
 /*
--- openafs/src/config/afs_sysnames.h:1.50.2.31	Wed Sep  3 14:27:39 2008
+++ openafs/src/config/afs_sysnames.h	Fri Mar 27 11:55:45 2009
@@ -187,7 +187,8 @@
 #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_i386_fbsd_71        2116
+#define SYS_NAME_ID_i386_fbsd_80        2117
 
 #define SYS_NAME_ID_ia64_linux2		2200
 #define SYS_NAME_ID_ia64_linux22	2201
@@ -245,6 +246,9 @@
 #define SYS_NAME_ID_i386_obsd39		2608
 #define SYS_NAME_ID_i386_obsd40         2609
 #define SYS_NAME_ID_i386_obsd41         2610
+#define SYS_NAME_ID_i386_obsd42         2611
+#define SYS_NAME_ID_i386_obsd43         2612
+#define SYS_NAME_ID_i386_obsd44         2613
 
 #define SYS_NAME_ID_amd64_linux2        2700
 #define SYS_NAME_ID_amd64_linux22       2701
@@ -262,6 +266,9 @@
 #define SYS_NAME_ID_ppc64_linux26	2903
 
 #define SYS_NAME_ID_amd64_fbsd_53        3008
+#define SYS_NAME_ID_amd64_fbsd_70        3009
+#define SYS_NAME_ID_amd64_fbsd_71        3010
+#define SYS_NAME_ID_amd64_fbsd_80        3011
 
 #define SYS_NAME_ID_amd64_w2k           3400
 
@@ -295,4 +302,6 @@
 #ifdef	AFS_KERBREALM_ENV
 #define	AFS_REALM_SZ		64
 #endif
+/* Specifies the number of equivalent local realm names */
+#define AFS_NUM_LREALMS         4
 #endif /* __AFS_SYSNAMES_INCL_ENV_ */
--- openafs/src/config/param.alpha_linux_22.h:1.5.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.alpha_linux_22.h	Thu Mar 19 22:32:59 2009
@@ -28,6 +28,7 @@
 
 #define AFS_64BIT_ENV          1	/* Defines afs_int32 as int, not long. */
 #define AFS_64BITPOINTER_ENV   1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.alpha_linux_24.h:1.5.2.4	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.alpha_linux_24.h	Thu Mar 19 22:32:59 2009
@@ -30,6 +30,7 @@
 
 #define AFS_64BIT_ENV          1	/* Defines afs_int32 as int, not long. */
 #define AFS_64BITPOINTER_ENV   1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.alpha_linux_26.h:1.1.2.6	Mon Jun 30 16:52:22 2008
+++ openafs/src/config/param.alpha_linux_26.h	Thu Mar 19 23:12:39 2009
@@ -33,7 +33,7 @@
 #define AFS_64BIT_ENV          1
 #define AFS_64BIT_CLIENT       1
 #define AFS_64BITPOINTER_ENV   1       /* pointers are 64 bits */
-
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -104,6 +104,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 338
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- /dev/null	Sat Apr  4 14:44:30 2009
+++ openafs/src/config/param.amd64_fbsd_70.h	Mon Dec 15 15:38:21 2008
@@ -0,0 +1,213 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"amd64_fbsd_70"
+#define SYS_NAME_ID	SYS_NAME_ID_amd64_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_64BITPOINTER_ENV 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_64BITPOINTER_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 */
--- /dev/null	Sat Apr  4 14:44:30 2009
+++ openafs/src/config/param.amd64_fbsd_71.h	Mon Dec 15 15:38:21 2008
@@ -0,0 +1,216 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"amd64_fbsd_71"
+#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_71
+
+#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_64BITPOINTER_ENV 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_FBSD71_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_FBSD71_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_FBSD71_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_64BITPOINTER_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 */
--- /dev/null	Sat Apr  4 14:44:30 2009
+++ openafs/src/config/param.amd64_fbsd_80.h	Mon Dec 15 15:38:22 2008
@@ -0,0 +1,219 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"amd64_fbsd_80"
+#define SYS_NAME_ID	SYS_NAME_ID_amd64_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_64BITPOINTER_ENV 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_FBSD71_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_FBSD71_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_FBSD71_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_64BITPOINTER_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 */
--- openafs/src/config/param.amd64_linux24.h:1.3.2.5	Tue Feb 13 14:12:46 2007
+++ openafs/src/config/param.amd64_linux24.h	Thu Mar 19 23:12:39 2009
@@ -39,6 +39,7 @@
 #define AFS_64BIT_CLIENT	1
 
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -125,6 +126,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 183
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.amd64_linux26.h:1.1.2.6	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.amd64_linux26.h	Thu Mar 19 23:12:39 2009
@@ -29,6 +29,7 @@
 #define AFS_64BIT_ENV		1
 #define AFS_64BIT_CLIENT	1
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -107,6 +108,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 183
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.arm_linux24.h:1.1.4.2	Tue Jan 15 00:14:02 2008
+++ openafs/src/config/param.arm_linux24.h	Thu Mar 19 23:12:39 2009
@@ -108,6 +108,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.arm_linux26.h:1.1.4.4	Wed Feb 27 17:31:39 2008
+++ openafs/src/config/param.arm_linux26.h	Thu Mar 19 23:12:39 2009
@@ -113,6 +113,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.hp_ux110.h:1.9.2.1	Mon Mar 10 12:25:26 2008
+++ openafs/src/config/param.hp_ux110.h	Thu Mar 19 23:12:39 2009
@@ -123,6 +123,7 @@
 #define AFS_GREEDY43_ENV	1	/* Used only in rx/rx_user.c */
 #define AFS_ENV			1
 #define AFS_USR_HPUX_ENV    	1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.hp_ux11i.h:1.4.2.2	Mon Mar 10 12:25:26 2008
+++ openafs/src/config/param.hp_ux11i.h	Thu Mar 19 23:12:39 2009
@@ -126,6 +126,7 @@
 #define AFS_GREEDY43_ENV	1	/* Used only in rx/rx_user.c */
 #define AFS_ENV			1
 #define AFS_USR_HPUX_ENV    	1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 
 #include <afs/afs_sysnames.h>
 
--- /dev/null	Sat Apr  4 14:44:31 2009
+++ openafs/src/config/param.i386_fbsd_71.h	Mon Dec 15 15:38:22 2008
@@ -0,0 +1,214 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"i386_fbsd_71"
+#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_71
+
+#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_FBSD71_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_FBSD71_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_FBSD71_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 */
--- openafs/src/config/param.i386_fbsd_80.h:1.1.2.2	Tue Aug 26 10:02:15 2008
+++ openafs/src/config/param.i386_fbsd_80.h	Mon Dec 15 15:38:22 2008
@@ -41,6 +41,7 @@
 #define AFS_FBSD61_ENV 1
 #define AFS_FBSD62_ENV 1
 #define AFS_FBSD70_ENV 1
+#define AFS_FBSD71_ENV 1
 #define AFS_FBSD80_ENV 1
 #define AFS_X86_FBSD_ENV 1
 #define AFS_X86_FBSD40_ENV 1
@@ -52,6 +53,7 @@
 #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_FBSD71_ENV 1
 #define AFS_X86_FBSD80_ENV 1
 #define AFS_X86_ENV 1
 #define AFS_NONFSTRANS 1
@@ -162,6 +164,7 @@
 #define AFS_USR_FBSD60_ENV	1
 #define AFS_USR_FBSD61_ENV	1
 #define AFS_USR_FBSD70_ENV	1
+#define AFS_USR_FBSD71_ENV	1
 #define AFS_USR_FBSD80_ENV	1
 #define AFS_USR_FBSD_ENV	1
 #define AFS_NONFSTRANS 1
--- openafs/src/config/param.i386_linux22.h:1.15.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.i386_linux22.h	Thu Mar 19 22:32:59 2009
@@ -30,6 +30,7 @@
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.i386_linux24.h:1.19.2.4	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.i386_linux24.h	Thu Mar 19 23:12:39 2009
@@ -25,6 +25,7 @@
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #define AFS_64BIT_ENV		1
 #define AFS_64BIT_CLIENT	1
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -111,6 +112,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.i386_linux26.h:1.3.2.7	Sat Mar 22 20:54:03 2008
+++ openafs/src/config/param.i386_linux26.h	Thu Mar 19 23:12:39 2009
@@ -27,6 +27,7 @@
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #define AFS_64BIT_ENV		1
 #define AFS_64BIT_CLIENT	1
+#define AFS_MAXVCOUNT_ENV       1
 
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
@@ -119,6 +120,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.i386_umlinux22.h:1.2.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.i386_umlinux22.h	Thu Mar 19 22:32:59 2009
@@ -32,6 +32,7 @@
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.i386_umlinux24.h:1.2.2.4	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.i386_umlinux24.h	Thu Mar 19 23:12:39 2009
@@ -28,6 +28,7 @@
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #define AFS_64BIT_ENV		1
 #define AFS_64BIT_CLIENT	1
+#define AFS_MAXVCOUNT_ENV       1
 
 #ifdef AFS_LARGEFILE_ENV
 #define _FILE_OFFSET_BITS	64
@@ -112,6 +113,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.i386_umlinux26.h:1.1.2.5	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.i386_umlinux26.h	Thu Mar 19 23:12:39 2009
@@ -27,6 +27,7 @@
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #define AFS_64BIT_ENV		1
 #define AFS_64BIT_CLIENT	1
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -113,6 +114,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.ia64_linux24.h:1.9.2.5	Tue Apr  3 15:31:27 2007
+++ openafs/src/config/param.ia64_linux24.h	Thu Mar 19 23:12:39 2009
@@ -39,6 +39,7 @@
 #define AFS_64BIT_CLIENT	1	
 
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -125,6 +126,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 1141
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.ia64_linux26.h:1.1.2.7	Tue Apr  3 15:31:27 2007
+++ openafs/src/config/param.ia64_linux26.h	Thu Mar 19 23:12:39 2009
@@ -41,6 +41,7 @@
 #define AFS_64BIT_CLIENT	1	
 
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #include <linux/init.h>
@@ -135,6 +136,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 1141
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.parisc_linux24.h:1.7.2.4	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.parisc_linux24.h	Thu Mar 19 23:12:39 2009
@@ -23,6 +23,7 @@
 #define AFS_64BIT_CLIENT  1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -96,6 +97,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.ppc64_linux24.h:1.2.2.5	Wed Jun  6 13:33:50 2007
+++ openafs/src/config/param.ppc64_linux24.h	Thu Mar 19 23:12:39 2009
@@ -27,6 +27,7 @@
 #define AFS_64BIT_CLIENT	1
 
 #define AFS_64BITPOINTER_ENV   1     /* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -117,6 +118,7 @@
 #define AFS_MOUNT_AFS "afs"    /* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1   /* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.ppc64_linux26.h:1.1.2.6	Wed Jun  6 13:33:50 2007
+++ openafs/src/config/param.ppc64_linux26.h	Thu Mar 19 23:12:39 2009
@@ -29,6 +29,7 @@
 #define AFS_64BIT_CLIENT	1
 
 #define AFS_64BITPOINTER_ENV   1     /* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -119,6 +120,7 @@
 #define AFS_MOUNT_AFS "afs"    /* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1   /* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.ppc_darwin_70.h:1.4.2.2	Tue Nov 29 00:02:24 2005
+++ openafs/src/config/param.ppc_darwin_70.h	Mon Dec 29 12:29:31 2008
@@ -6,7 +6,6 @@
 
 #define AFS_ENV                 1
 #define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
-#define AFS_64BIT_CLIENT        1
 #define AFS_64BIT_IOPS_ENV 1
 #define AFS_PPC_ENV 1
 #define AFS_VFSINCL_ENV 1
--- openafs/src/config/param.ppc_linux22.h:1.8.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.ppc_linux22.h	Thu Mar 19 22:32:59 2009
@@ -21,6 +21,7 @@
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.ppc_linux24.h:1.10.2.5	Wed Jun  6 13:33:50 2007
+++ openafs/src/config/param.ppc_linux24.h	Thu Mar 19 23:12:39 2009
@@ -25,6 +25,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -104,6 +105,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.ppc_linux26.h:1.1.2.6	Wed Jun  6 13:33:50 2007
+++ openafs/src/config/param.ppc_linux26.h	Thu Mar 19 23:12:39 2009
@@ -27,6 +27,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -107,6 +108,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.s390_linux22.h:1.10.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.s390_linux22.h	Thu Mar 19 22:32:59 2009
@@ -31,6 +31,7 @@
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.s390_linux24.h:1.12.2.4	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.s390_linux24.h	Thu Mar 19 23:12:39 2009
@@ -35,6 +35,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -119,6 +120,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.s390_linux26.h:1.1.2.5	Mon Jun 30 16:52:22 2008
+++ openafs/src/config/param.s390_linux26.h	Thu Mar 19 23:12:39 2009
@@ -37,6 +37,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -127,6 +128,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 137
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.s390x_linux24.h:1.1.2.5	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.s390x_linux24.h	Thu Mar 19 22:32:59 2009
@@ -40,6 +40,7 @@
 #define AFS_64BIT_KERNEL  1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
--- openafs/src/config/param.s390x_linux26.h:1.1.2.7	Mon Jun 30 16:52:22 2008
+++ openafs/src/config/param.s390x_linux26.h	Thu Mar 19 22:32:59 2009
@@ -43,6 +43,7 @@
 #define AFS_LINUX_64BIT_KERNEL  1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
--- openafs/src/config/param.sparc64_linux22.h:1.8.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.sparc64_linux22.h	Thu Mar 19 22:32:59 2009
@@ -36,6 +36,7 @@
 #define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_32BIT_USR_ENV	1	/* user level processes are 32bit */
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.sparc64_linux24.h:1.7.2.5	Wed Jun  6 13:33:50 2007
+++ openafs/src/config/param.sparc64_linux24.h	Thu Mar 19 23:12:39 2009
@@ -39,6 +39,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_32BIT_USR_ENV       1
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -135,6 +136,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 227
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.sparc64_linux26.h:1.1.4.6	Wed Jun  6 13:33:50 2007
+++ openafs/src/config/param.sparc64_linux26.h	Thu Mar 19 23:12:39 2009
@@ -41,6 +41,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_32BIT_USR_ENV       1
 #define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits. */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -137,6 +138,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 227
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.sparc_linux22.h:1.9.2.3	Thu Nov  9 18:18:31 2006
+++ openafs/src/config/param.sparc_linux22.h	Thu Mar 19 22:33:00 2009
@@ -31,6 +31,7 @@
 #define AFS_SYSCALL 227
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 #ifdef CONFIG_SMP
--- openafs/src/config/param.sparc_linux24.h:1.8.2.6	Tue Jul 17 00:06:41 2007
+++ openafs/src/config/param.sparc_linux24.h	Thu Mar 19 23:12:39 2009
@@ -34,6 +34,7 @@
 #define AFS_64BIT_CLIENT	1
 #define AFS_64BIT_IOPS_ENV  1
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
+#define AFS_MAXVCOUNT_ENV       1
 
 #if defined(__KERNEL__) && !defined(KDUMP_KERNEL)
 
@@ -136,6 +137,7 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 227
 #define AFS_64BIT_IOPS_ENV  1
+#define AFS_64BIT_ENV		1	/* Defines afs_int32 as int, not long. */
 #define AFS_NAMEI_ENV     1	/* User space interface to file system */
 #include <afs/afs_sysnames.h>
 
--- openafs/src/config/param.sun4x_510.h:1.2.2.6	Fri Dec 23 20:09:53 2005
+++ openafs/src/config/param.sun4x_510.h	Mon Dec 22 15:34:33 2008
@@ -34,6 +34,8 @@
 #define AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #endif /* AFS_NAMEI_ENV */
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
@@ -53,6 +55,7 @@
 #define AFS_HAVE_FFS		1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS		1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS	1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV		1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY	1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sun4x_511.h:1.1.2.2	Thu Dec 28 16:59:45 2006
+++ openafs/src/config/param.sun4x_511.h	Mon Dec 22 15:34:33 2008
@@ -35,6 +35,8 @@
 #define AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #endif /* AFS_NAMEI_ENV */
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
@@ -54,6 +56,7 @@
 #define AFS_HAVE_FFS		1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS		1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS	1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV		1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY	1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sun4x_58.h:1.11.2.5	Fri Dec 23 20:09:53 2005
+++ openafs/src/config/param.sun4x_58.h	Mon Dec 22 15:34:33 2008
@@ -51,6 +51,7 @@
 #define AFS_HAVE_FFS    1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS	1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS 1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV	1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY 1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sun4x_59.h:1.5.2.5	Fri Dec 23 20:09:53 2005
+++ openafs/src/config/param.sun4x_59.h	Mon Dec 22 15:34:33 2008
@@ -52,6 +52,7 @@
 #define AFS_HAVE_FFS    1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS	1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS 1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV	1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY 1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sunx86_510.h:1.2.2.8	Fri Dec 23 20:09:53 2005
+++ openafs/src/config/param.sunx86_510.h	Mon Dec 22 15:34:33 2008
@@ -38,6 +38,8 @@
 
 #define AFS_HAVE_FLOCK_SYSID    1
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
@@ -63,6 +65,7 @@
 #define AFS_HAVE_FFS		1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS		1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS	1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV		1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY	1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sunx86_511.h:1.1.2.2	Thu Dec 28 16:59:45 2006
+++ openafs/src/config/param.sunx86_511.h	Mon Dec 22 15:34:33 2008
@@ -39,6 +39,8 @@
 
 #define AFS_HAVE_FLOCK_SYSID    1
 
+#define AFS_CACHE_VNODE_PATH 1
+
 #include <afs/afs_sysnames.h>
 
 #define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
@@ -64,6 +66,7 @@
 #define AFS_HAVE_FFS		1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS		1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS	1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV		1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY	1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sunx86_58.h:1.6.2.5	Fri Dec 23 20:09:53 2005
+++ openafs/src/config/param.sunx86_58.h	Mon Dec 22 15:34:33 2008
@@ -62,6 +62,7 @@
 #define AFS_HAVE_FFS    1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS	1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS 1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV	1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY 1	/* use gettimeofday to implement rx clock */
 
--- openafs/src/config/param.sunx86_59.h:1.2.2.5	Fri Dec 23 20:09:53 2005
+++ openafs/src/config/param.sunx86_59.h	Mon Dec 22 15:34:33 2008
@@ -63,6 +63,7 @@
 #define AFS_HAVE_FFS    1	/* Use system's ffs. */
 #define AFS_HAVE_VXFS	1	/* Support cache on Veritas vxfs file system */
 #define AFS_HAVE_STATVFS 1	/* System supports statvfs */
+#define AFS_HAVE_STATVFS64	1	/* System supports statvfs64 */
 #define AFS_VM_RDWR_ENV	1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY 1	/* use gettimeofday to implement rx clock */
 
--- /dev/null	Sat Apr  4 14:44:31 2009
+++ openafs/src/config/param.x86_darwin_100.h	Mon Feb 16 23:25:40 2009
@@ -0,0 +1,190 @@
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#ifndef AFS_PARAM_H
+#define AFS_PARAM_H
+
+#define AFS_ENV                 1
+#define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
+#define AFS_64BIT_CLIENT        1
+#define AFS_64BIT_IOPS_ENV	1
+#if defined(__ppc__)
+#define AFS_PPC_ENV		1
+#elif defined(__i386__)
+#define AFS_X86_ENV		1
+#else
+#error Unsupported architecture
+#endif
+#define AFS_VFSINCL_ENV		1
+
+#include <afs/afs_sysnames.h>
+
+#define AFS_DARWIN_ENV
+#define AFS_DARWIN13_ENV
+#define AFS_DARWIN14_ENV
+#define AFS_DARWIN60_ENV
+#define AFS_DARWIN70_ENV
+#define AFS_DARWIN80_ENV
+#define AFS_DARWIN90_ENV
+#define AFS_DARWIN100_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define AFS_NAMEI_ENV 1
+#define DARWIN_REFBASE 3
+#define AFS_CACHE_VNODE_PATH
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS    "afs"
+
+/* Machine / Operating system information */
+#if defined(__ppc__)
+#define sys_ppc_darwin_12	1
+#define sys_ppc_darwin_13	1
+#define sys_ppc_darwin_14	1
+#define sys_ppc_darwin_60	1
+#define sys_ppc_darwin_70	1
+#define sys_ppc_darwin_80	1
+#define sys_ppc_darwin_90	1
+#define sys_ppc_darwin_100	1
+#define SYS_NAME		"ppc_darwin_100"
+#define SYS_NAME_ID		SYS_NAME_ID_ppc_darwin_100
+#define AFSBIG_ENDIAN		1
+#elif defined(__i386__)
+#define sys_x86_darwin_12	1
+#define sys_x86_darwin_13	1
+#define sys_x86_darwin_14	1
+#define sys_x86_darwin_60	1
+#define sys_x86_darwin_70	1
+#define sys_x86_darwin_80	1
+#define sys_x86_darwin_90	1
+#define sys_x86_darwin_100	1
+#define SYS_NAME		"x86_darwin_100"
+#define SYS_NAME_ID		SYS_NAME_ID_x86_darwin_100
+#define AFSLITTLE_ENDIAN	1
+#else
+#error Unsupported architecture
+#endif
+#define AFS_HAVE_FFS    1	/* Use system's ffs. */
+
+#define AFS_GCPAGS               0
+#define RXK_LISTENER_ENV         1
+
+#ifdef KERNEL
+#undef MACRO_BEGIN
+#undef MACRO_END
+#include <kern/macro_help.h>
+#define AFS_GLOBAL_SUNLOCK        1
+#define AFS_VFS34       1	/* What is VFS34??? */
+#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)   _MALLOC(x, M_TEMP, M_WAITOK)
+#define AFS_KFREE(x,y)  _FREE(x,M_TEMP)
+#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 BIND_8_COMPAT
+
+#endif
+#endif /* AFS_PARAM_H */
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#ifndef AFS_PARAM_H
+#define AFS_PARAM_H
+
+#define AFS_VFSINCL_ENV 1	/* NOBODY uses this.... */
+#define AFS_ENV                 1
+#define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
+#if defined(__ppc__)
+#define AFS_PPC_ENV		1
+#elif defined(__i386__)
+#define AFS_X86_ENV		1
+#else
+#error Unsupported architecture
+#endif
+
+#include <afs/afs_sysnames.h>
+#define AFS_USERSPACE_ENV
+#define AFS_USR_DARWIN_ENV
+#define AFS_USR_DARWIN13_ENV
+#define AFS_USR_DARWIN14_ENV
+#define AFS_USR_DARWIN60_ENV
+#define AFS_USR_DARWIN70_ENV
+#define AFS_USR_DARWIN80_ENV
+#define AFS_USR_DARWIN90_ENV
+#define AFS_USR_DARWIN100_ENV
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define DARWIN_REFBASE 0
+
+/* File system entry (used if mount.h doesn't define MOUNT_AFS */
+#define AFS_MOUNT_AFS    "afs"
+
+/* Machine / Operating system information */
+#if defined(__ppc__)
+#define sys_ppc_darwin_12	1
+#define sys_ppc_darwin_13	1
+#define sys_ppc_darwin_14	1
+#define sys_ppc_darwin_60	1
+#define sys_ppc_darwin_70	1
+#define sys_ppc_darwin_80	1
+#define sys_ppc_darwin_90	1
+#define sys_ppc_darwin_100	1
+#define SYS_NAME		"ppc_darwin_100"
+#define SYS_NAME_ID		SYS_NAME_ID_ppc_darwin_100
+#define AFSBIG_ENDIAN		1
+#elif defined(__i386__)
+#define sys_x86_darwin_12	1
+#define sys_x86_darwin_13	1
+#define sys_x86_darwin_14	1
+#define sys_x86_darwin_60	1
+#define sys_x86_darwin_70	1
+#define sys_x86_darwin_80	1
+#define sys_x86_darwin_100	1
+#define SYS_NAME		"x86_darwin_100"
+#define SYS_NAME_ID		SYS_NAME_ID_x86_darwin_100
+#define AFSLITTLE_ENDIAN	1
+#else
+#error Unsupported architecture
+#endif
+#define AFS_HAVE_FFS    1	/* Use system's ffs. */
+
+#define AFS_UIOSYS      UIO_SYSSPACE
+#define AFS_UIOUSER     UIO_USERSPACE
+
+#define AFS_GCPAGS                0	/* if nonzero, garbage collect PAGs */
+#define RXK_LISTENER_ENV          1
+
+#define AFS_VFS34       1	/* What is VFS34??? */
+#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        VATTR_NULL      usr_vattr_null
+
+#define AFS_DIRENT
+#ifndef CMSERVERPREF
+#define CMSERVERPREF
+#endif
+
+#define BIND_8_COMPAT
+#endif /* AFS_PARAM_H */
+
+#endif /* !defined(UKERNEL) */
--- openafs/src/config/stds.h:1.21.2.4	Sat Aug 16 15:15:50 2008
+++ openafs/src/config/stds.h	Mon Mar 23 14:19:55 2009
@@ -255,4 +255,41 @@
 };
 typedef struct afsUUID afsUUID;
 
+/* A macro that can be used when printf'ing 64 bit integers, as Unix and 
+ * windows use a different format string
+ */
+#ifdef AFS_NT40_ENV
+#define AFS_INT64_FMT "l64d"
+#else
+#define AFS_INT64_FMT "lld"
+#endif
+
+/* Functions to safely cast afs_int32 and afs_uint32 so they can be used in 
+ * printf statemements with %ld and %lu
+ */
+#ifdef AFS_NT40_ENV
+#define static_inline __inline static
+#define hdr_static_inline(x) __inline static x
+#elif defined(AFS_HPUX_ENV) || defined(AFS_USR_HPUX_ENV)
+#define static_inline static __inline
+#define hdr_static_inline(x) static __inline x
+#elif defined(AFS_AIX_ENV) || defined(AFS_USR_AIX_ENV)
+#define static_inline static
+#define hdr_static_inline(x) static x
+#elif defined(AFS_SGI_ENV) || defined(AFS_USR_SGI_ENV)
+#define static_inline static
+#define hdr_static_inline(x) x
+#else
+#define static_inline static inline
+#define hdr_static_inline(x) static inline x
+#endif
+
+#ifdef  AFS_64BIT_ENV
+hdr_static_inline(afs_int32) afs_cast_int32(afs_int32 d) { return (afs_int32) d; }
+hdr_static_inline(afs_uint32) afs_cast_uint32(afs_uint32 d) { return (afs_uint32) d; }
+#else
+hdr_static_inline(long) afs_cast_int32(afs_int32 d) { return (long) d; }
+hdr_static_inline(unsigned long) afs_cast_uint32(afs_uint32 d) { return (unsigned long) d; }
+#endif
+
 #endif /* OPENAFS_CONFIG_AFS_STDS_H */
--- openafs/src/config/venus.h:1.10.2.2	Tue Jun 12 15:20:13 2007
+++ openafs/src/config/venus.h	Mon Jan 19 13:09:32 2009
@@ -172,8 +172,8 @@
 #define VIOC_RXSTAT_PEER	_VICEIOCTL(54)	/* Control peer RX stats */
 #define VIOC_GETRXKCRYPT        _VICEIOCTL(55)	/* Set rxkad enc flag */
 #define VIOC_SETRXKCRYPT        _VICEIOCTL(56)	/* Set rxkad enc flag */
-#define VIOC_PREFETCHTAPE       _VICEIOCTL(66)	/* MR-AFS prefetch from tape */
-#define VIOC_RESIDENCY_CMD      _VICEIOCTL(67)	/* generic MR-AFS cmds */
+#define VIOC_PREFETCHTAPE       _VICEIOCTL(66)	/* osd prefetch from tape */
+#define VIOC_FS_CMD      	_VICEIOCTL(67)	/* fs extensions for osd etc. */
 #define VIOC_STATISTICS         _VICEIOCTL(68)	/* arla: fetch statistics */
 #define VIOC_GETVCXSTATUS2      _VICEIOCTL(69)  /* vcache statistics */
 
--- openafs/src/fsint/afsint.xg:1.13.2.2	Sat Aug 16 15:15:45 2008
+++ openafs/src/fsint/afsint.xg	Mon Jan 19 13:09:33 2009
@@ -393,7 +393,7 @@
     afs_uint32 Residency4;
 };
 
-struct ResidencyCmdInputs {
+struct FsCmdInputs {
     afs_int32  command;
     struct AFSFid fid;
     afs_int64  int64s[MAXCMDINT64S];
@@ -401,7 +401,7 @@
     char       chars[MAXCMDCHARS];
 };
 
-struct ResidencyCmdOutputs {
+struct FsCmdOutputs {
     afs_int32  code;
     struct AFSFetchStatus status;
     afs_int64  int64s[MAXCMDINT64S];
@@ -660,10 +660,10 @@
   AFSVolSync *Sync
 ) = 163;
 
-ResidencyCmd(
+FsCmd(
   IN AFSFid *Fid,
-  IN struct ResidencyCmdInputs *Inputs,
-  OUT struct ResidencyCmdOutputs *Outputs
+  IN struct FsCmdInputs *Inputs,
+  OUT struct FsCmdOutputs *Outputs
 ) = 220;
 
 InlineBulkStatus(
--- openafs/src/gtx/windows.c:1.6	Tue Jul 15 19:15:13 2003
+++ openafs/src/gtx/windows.c	Mon Mar 16 22:39:43 2009
@@ -19,7 +19,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/gtx/windows.c,v 1.6 2003/07/15 23:15:13 shadow Exp $");
+    ("$Header: /cvs/openafs/src/gtx/windows.c,v 1.6.2.1 2009/03/17 02:39:43 shadow Exp $");
 
 /* On DUX "IN" is a variable in curses.h, so this can be a bit of a problem */
 #ifdef IN
@@ -114,7 +114,7 @@
 	    fprintf(stderr, "[%s:%s] Initializing for the X11 package\n", mn,
 		    rn);
 	gwinbops = gator_X11_gwinbops;
-	code = gator_X11gwin_init(params);
+	code = gator_X11gwin_init(gwin_debug);
 	if (code) {
 	    fprintf(stderr,
 		    "[%s:%s] Error in X11 initialization routine, gator_X11gwin_init(): %d\n",
--- openafs/src/kauth/kaserver.c:1.17.2.8	Mon Mar 10 18:35:35 2008
+++ openafs/src/kauth/kaserver.c	Mon Dec 22 14:23:32 2008
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/kauth/kaserver.c,v 1.17.2.8 2008/03/10 22:35:35 shadow Exp $");
+    ("$Header: /cvs/openafs/src/kauth/kaserver.c,v 1.17.2.10 2008/12/22 19:23:32 shadow Exp $");
 
 #include <afs/stds.h>
 #include <sys/types.h>
@@ -249,34 +249,9 @@
 		lclpath = dbpath;
 	}
 	else if (strncmp(arg, "-auditlog", arglen) == 0) {
-	    int tempfd, flags;
-	    FILE *auditout;
-	    char oldName[MAXPATHLEN];
 	    char *fileName = argv[++a];
 	    
-#ifndef AFS_NT40_ENV
-	    struct stat statbuf;
-	    
-	    if ((lstat(fileName, &statbuf) == 0) 
-		&& (S_ISFIFO(statbuf.st_mode))) {
-		flags = O_WRONLY | O_NONBLOCK;
-	    } else 
-#endif
-	    {
-		strcpy(oldName, fileName);
-		strcat(oldName, ".old");
-		renamefile(fileName, oldName);
-		flags = O_WRONLY | O_TRUNC | O_CREAT;
-	    }
-	    tempfd = open(fileName, flags, 0666);
-	    if (tempfd > -1) {
-		auditout = fdopen(tempfd, "a");
-		if (auditout) {
-		    osi_audit_file(auditout);
-		} else
-		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-	    } else
-		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+	    osi_audit_file(fileName);
 	} else if (strcmp(arg, "-localfiles") == 0)
 	    lclpath = argv[++a];
 	else if (strcmp(arg, "-servers") == 0)
@@ -416,7 +391,7 @@
     else
 	code =
 	    ubik_ServerInitByInfo(myHost, htons(AFSCONF_KAUTHPORT), &cellinfo,
-				  &clones, dbpath, &KA_dbase);
+				  clones, dbpath, &KA_dbase);
 
     if (code) {
 	afs_com_err(whoami, code, "Ubik init failed");
--- openafs/src/libafs/MakefileProto.FBSD.in:1.24.2.1	Tue Aug 26 10:02:16 2008
+++ openafs/src/libafs/MakefileProto.FBSD.in	Mon Jan 12 09:33:38 2009
@@ -26,15 +26,20 @@
 AFS_OS_NONFSOBJS = \
 	osi_vfsops.o
 
-
 # System specific build commands and flags
 KSRC = @BSD_KERNEL_PATH@
 KBLD = @BSD_KERNEL_BUILD@
+<amd64_fbsd_70 amd64_fbsd_71 amd64_fbsd_80>
+KOPTS = -fPIC
+<all>
+
 KDEFS=-Wall -nostdinc -I/usr/include -D_KERNEL -DKLD_MODULE \
-	    -elf -mpreferred-stack-boundary=2 \
+	    -elf \
 <i386_fbsd_42 i386_fbsd_43 i386_fbsd_44 i386_fbsd_45 i386_fbsd_46 i386_fbsd_47>
+	     -mpreferred-stack-boundary=2 \
 	     -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
+<i386_fbsd_42 i386_fbsd_43 i386_fbsd_44 i386_fbsd_45 i386_fbsd_46 i386_fbsd_47>
+	-include ${KBLD}/opt_global.h -mpreferred-stack-boundary=2
 <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
@@ -43,11 +48,8 @@
 DBUG = -O2
 #DBUG = -O -g
 DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
-OPTF=${OPT} 
-OPTF2=${OPT2} 
 CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KDEFS) $(KOPTS) ${DBUG}
 
-
 # Name of directory to hold object files and libraries.
 KOBJ = MODLOAD
 
@@ -65,12 +67,12 @@
 	ln -fs ../Makefile.common $(KOBJ)/Makefile.common
 	-$(RM) -f  h net netinet rpc ufs nfs  machine sys vm
 	-ln -fs ${KSRC}/net net
-	-ln -fs ${KSRC}/i386/include machine
+	-ln -fs ${KSRC}/${CPUARCH}/include machine
 	-ln -fs ${KSRC}/netinet netinet
 	-ln -fs ${KSRC}/nfs nfs
-<all -i386_fbsd_80>
+<all -fbsd_71 -fbsd_80>
 	-ln -fs /usr/include/rpc rpc
-<i386_fbsd_80>
+<fbsd_71 fbsd_80>
 	-ln -fs ${KSRC}/rpc rpc
 <all>
 	-ln -fs ${KSRC}/sys sys
--- /dev/null	Sat Apr  4 14:44:31 2009
+++ openafs/src/libafs/afs.x86_darwin_100.plist.in	Mon Feb 16 23:25:41 2009
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
+<plist version="0.9">
+<dict>
+	<key>CFBundleDevelopmentRegion</key>
+	<string>English</string>
+	<key>CFBundleExecutable</key>
+	<string>afs</string>
+	<key>CFBundleIdentifier</key>
+	<string>org.openafs.filesystems.afs</string>
+	<key>CFBundleInfoDictionaryVersion</key>
+	<string>8.0</string>
+	<key>CFBundleName</key>
+	<string>afs</string>
+	<key>CFBundlePackageType</key>
+	<string>KEXT</string>
+	<key>CFBundleShortVersionString</key>
+	<string>@MACOS_VERSION@</string>
+	<key>CFBundleSignature</key>
+	<string>????</string>
+	<key>CFBundleVersion</key>
+	<string>@MACOS_VERSION@</string>
+	<key>OSBundleLibraries</key>
+	<dict>
+		<key>com.apple.kpi.bsd</key>
+		<string>8.0.0</string>
+		<key>com.apple.kpi.mach</key>
+		<string>8.0.0</string>
+		<key>com.apple.kpi.libkern</key>
+		<string>8.0</string>
+	</dict>
+</dict>
+</plist>
--- openafs/src/libuafs/MakefileProto.FBSD.in:1.11.2.1	Tue Aug 26 10:02:15 2008
+++ openafs/src/libuafs/MakefileProto.FBSD.in	Mon Dec 15 15:38:22 2008
@@ -19,9 +19,9 @@
 
 TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_FBSD40_ENV
 TEST_LDFLAGS=
-<all -i386_fbsd_62 -i386_fbsd_70 -i386_fbsd_80>
+<all -i386_fbsd_62 -i386_fbsd_70 -i386_fbsd_71 -i386_fbsd_80 -amd64_fbsd_62 -amd64_fbsd_70 -amd64_fbsd_71 -amd64_fbsd_80>
 TEST_LIBS=-lc_r
-<i386_fbsd_62 i386_fbsd_70 i386_fbsd_80>
+<i386_fbsd_62 i386_fbsd_70 i386_fbsd_71 i386_fbsd_80 amd64_fbsd_62 amd64_fbsd_70 amd64_fbsd_71 amd64_fbsd_80>
 TEST_LIBS=-lpthread
 <all>
 
--- openafs/src/lwp/process.amd64.s:1.1.2.1	Sun Feb 20 20:12:10 2005
+++ openafs/src/lwp/process.amd64.s	Mon Dec 15 15:38:22 2008
@@ -1,4 +1,4 @@
-/* $Id: process.amd64.s,v 1.1.2.1 2005/02/21 01:12:10 shadow Exp $ */
+/* $Id: process.amd64.s,v 1.1.2.2 2008/12/15 20:38:22 shadow Exp $ */
 
 /*
  * Copyright (c) 2003,2005 Kungliga Tekniska Högskolan
@@ -85,7 +85,8 @@
 	movq	%rsi, area1(%rbp)	/* i multiples of 24, so 32 it is) */
 	movq	%rdx, newsp(%rbp)	/* and copy them there. */
 
-	movl    $1,_C_LABEL(PRE_Block)  /* Do not allow any interrupts */
+	movq	PRE_Block@GOTPCREL(%rip), %rax
+	movl	$1,(%rax)		/* Do not allow any interrupts */
 
 	pushq	%rsp			/* Push all registers onto the stack */
 	pushq	%rax			/* Probably not _all_ are necessary */
@@ -149,8 +150,9 @@
 	popq	%rcx
 	popq	%rax
 	popq	%rsp			/* See savecontext */
-	
-	movl    $0,_C_LABEL(PRE_Block)  /* clear it up... */
+
+	movq    PRE_Block@GOTPCREL(%rip), %rax
+	movl    $0,(%rax)	
 	addq	$32, %rsp		/* We did rsp-32 above, correct that */
 	popq    %rbp
 	ret
--- /dev/null	Sat Apr  4 14:44:31 2009
+++ openafs/src/packaging/MacOS/InstallationCheck.10	Mon Feb 16 23:25:41 2009
@@ -0,0 +1,10 @@
+#!/bin/sh
+majorvers=`uname -r | sed 's/\..*//'`
+echo "InstallationCheck: os release is $majorvers"
+if [ $majorvers -ne 10 ]; then
+echo "InstallationCheck: not ok"
+	exit 112
+fi
+
+echo "InstallationCheck: ok"
+exit 0
--- /dev/null	Sat Apr  4 14:44:31 2009
+++ openafs/src/packaging/MacOS/ReadMe.rtf.10	Mon Feb 16 23:25:41 2009
@@ -0,0 +1,13 @@
+{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf100
+{\fonttbl\f0\fswiss\fcharset77 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\margl1440\margr1440\vieww9000\viewh9000\viewkind0
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f0\fs20 \cf0 This release of OpenAFS is targeted at MacOS 10.6. (Snow Leopard)
+\
+Select a client cell name by editing /var/db/openafs/etc/ThisCell\
+\
+The included afssettings program is distributed under the Apple Public Source License, version 2.0. See http://www.opensource.apple.com/apsl/2.0.txt or the included file 2.0.txt.\
+\
+Reboot when all of this is done.}
--- openafs/src/packaging/RedHat/mockbuild.pl:1.1.2.5	Fri Sep 12 09:07:52 2008
+++ openafs/src/packaging/RedHat/mockbuild.pl	Tue Feb  3 14:34:31 2009
@@ -16,6 +16,7 @@
 my $resultbase="/tmp/result/";
 my $stashbase="/disk/scratch/repository/";
 my $mockcommand = "/usr/bin/mock";
+my $resultfile;
 my $buildall = 0;
 my $ignorerelease = 1;
 my @newrpms;
@@ -134,6 +135,26 @@
 					basearch => "x86_64",
 					updaterepo => "updates-released",
 					results => "fedora-9/x86_64" },
+		 "fedora-10-i386" => { osver => "fc10",
+				      kmod => '1',
+				      basearch => 'i386',
+				      updaterepo => "updates-released",
+				      results => 'fedora-10/i386' },
+		 "fedora-10-x86_64" => { osver => "fc10",
+					kmod => "1",
+					basearch => "x86_64",
+					updaterepo => "updates-released",
+					results => "fedora-10/x86_64" },
+		 "fedora-11-i386" => { osver => "fc11",
+				      kmod => '1',
+				      basearch => 'i386',
+#				      updaterepo => "updates-released",
+				      results => 'fedora-11/i386' },
+		 "fedora-11-x86_64" => { osver => "fc11",
+					kmod => "1",
+					basearch => "x86_64",
+#					updaterepo => "updates-released",
+					results => "fedora-11/x86_64" },
 		 "fedora-development-i386" => { osver => "fcd",
 					  kmod => '1',
 					  basearch => 'i386',
@@ -153,6 +174,7 @@
 
 my $help;
 my $ok = GetOptions("resultdir=s" => \$resultbase,
+		    "resultlist=s" => \$resultfile,
 		    "help" => \$help);
 
 my @platforms = @ARGV;
@@ -234,7 +256,7 @@
 	  next if ($variant eq "xen0"); # Fedora 5 has some bad xen0 kernel-devels
 	  next if ($variant eq "smp");
       }
-      if ($platform=~/fedora-8/ || $platform=~/fedora-9/ || $platform=~/fedora-development/) {
+      if ($platform=~/fedora-8/ || $platform=~/fedora-9/ || $platform=~/fedora-10/ || $platform=~/fedora-development/) {
 	  next if ($variant =~/debug$/); # Fedora 8 debug kernels are bad
       }
       print "$arch : $variant : $version\n";
@@ -282,7 +304,7 @@
 		   $osver.".".$oafsrelease.".".$basearch.".rpm ".
 		   $resultdir) == 0
           or die "Copy failed with : $!\n";
-      push @newrpms, $mockresults."/".$rpm."-".$oafsversion."-".
+      push @newrpms, $resultdir."/".$rpm."-".$oafsversion."-".
 		     $osver.".".$oafsrelease.".".$basearch.".rpm";
     }
   } else {
@@ -342,7 +364,7 @@
           }
           system("cp ".$mockresults."/kmod-openafs-".$variant.$oafsversion."-".$oafsrelease.".".$kversion.".".$arch.".rpm $resultdir") == 0
             or die "Copy failed with : $!\n";
-	  push @newrpms, $mockresults."/kmod-openafs-".$variant.$oafsversion."-".$oafsrelease.".".$kversion.".".$arch.".rpm";
+	  push @newrpms, $resultdir."/kmod-openafs-".$variant.$oafsversion."-".$oafsrelease.".".$kversion.".".$arch.".rpm";
         }
       } else {
          print "All kernel modules already built for $version on $arch\n";
@@ -384,4 +406,8 @@
 print "=====================================================================\n";
 print "All builds complete\nBuilt:\n";
 print join("\n",@newrpms);
+if (defined($resultfile)) {
+  my $resultfh=new IO::File $resultfile, 'w';
+  print $resultfh join("\n",@newrpms);
+}
 
--- openafs/src/packaging/RedHat/openafs-kmodtool:1.1.4.3	Tue Apr 22 08:50:56 2008
+++ openafs/src/packaging/RedHat/openafs-kmodtool	Tue Feb  3 14:34:31 2009
@@ -39,6 +39,10 @@
 {
   verrel=${1:-$(uname -r)}
   verrel=${verrel%%$knownvariants}
+  case "$verrel" in
+    *.fc9*)  verrel="`echo ${verrel} | sed -e 's/^\(.*.fc9[^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
+    *.fc1?*) verrel="`echo ${verrel} | sed -e 's/^\(.*.fc1[0-9][^\.]*\)\.[^\.]\+.\?$/\1/'`" ;;
+  esac
 }
 
 print_verrel ()
@@ -72,6 +76,7 @@
     esac
     case "$verrel" in
         *.fc9*) kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
+        *.fc1?*)  kname="${verrel}.%{_target_cpu}${variant:+.${variant}}" ;;
         *)      kname="${verrel}${variant}"                             ;;
     esac
 
--- openafs/src/packaging/RedHat/openafs.spec.in:1.1.2.27	Wed Nov  5 16:29:57 2008
+++ openafs/src/packaging/RedHat/openafs.spec.in	Wed Mar 25 14:42:48 2009
@@ -1,4 +1,7 @@
-# Openafs Spec $Revision: 1.1.2.27 $
+# Openafs Spec $Revision: 1.1.2.29 $
+
+# TEMPORARY fix for patch fuzz so we can build on Fedora 10
+%define _default_patch_fuzz 2
 
 %define afsvers @VERSION@
 %define pkgvers @LINUX_PKGVER@
@@ -266,7 +269,7 @@
 Source10: http://www.openafs.org/dl/openafs/%{afsvers}/RELNOTES-%{afsvers}
 Source11: http://www.openafs.org/dl/openafs/%{afsvers}/ChangeLog
 
-Source20: http://dl.central.org/dl/cellservdb/CellServDB.2008-04-23
+Source20: http://dl.central.org/dl/cellservdb/CellServDB.2008-11-07
 
 Source30: openafs-kernel-version.sh
 Source996: openafs-kvers-is.sh
@@ -1014,7 +1017,7 @@
 tar cf - -C ${sysname}/dest/lib . | tar xf - -C $RPM_BUILD_ROOT%{_libdir}
 tar cf - -C ${sysname}/dest/etc . | tar xf - -C $RPM_BUILD_ROOT%{_sbindir}
 tar cf - -C ${sysname}/dest/root.server%{_prefix}/afs bin | tar xf - -C $RPM_BUILD_ROOT%{_prefix}/afs
-tar cf - -C ${sysname}/dest/root.client%{_prefix}/vice/etc afsd | tar xf - -C $RPM_BUILD_ROOT%{_prefix}/vice/etc
+tar cf - -C ${sysname}/dest/root.client%{_prefix}/vice/etc afsd C | tar xf - -C $RPM_BUILD_ROOT%{_prefix}/vice/etc
 
 # Link kpasswd to kapasswd
 ln -f $RPM_BUILD_ROOT%{_bindir}/kpasswd $RPM_BUILD_ROOT%{_bindir}/kapasswd
@@ -1049,7 +1052,7 @@
 
 # Items below here should not have to change with each driver version
 PACKAGE_NAME="%{name}"
-MAKE[0]="SMP=SP; eval \\\`grep CONFIG_SMP /boot/config-\${kernelver_array[0]}\\\`; [ -n \"\\\$CONFIG_SMP\" ] && SMP=MP; ./configure --with-linux-kernel-headers=\${kernel_source_dir}; make MPS=\\\$SMP; mv src/libafs/MODLOAD-*/openafs.ko ."
+MAKE[0]="SMP=SP; eval \\\`grep CONFIG_SMP /boot/config-\${kernelver_array[0]}\\\`; [ -n \"\\\$CONFIG_SMP\" ] && SMP=MP; KMODNAME=openafs.ko; DSTKMOD=\\".\\"; [ \\"\\\`echo \\"\${kernelver_array[0]}\\" | sed -e 's/^\\([0-9]*\\.[0-9]*\\)\\..*/\\1/'\\\`\\" = \\"2.4\\" ] && KMODNAME=\\"libafs-*\\" && DSTKMOD=openafs.o; ./configure --with-linux-kernel-headers=\${kernel_source_dir}; make MPS=\\\$SMP; mv src/libafs/MODLOAD-*/\\\$KMODNAME \\\$DSTKMOD"
 CLEAN="make -C src/libafs clean"
 
 BUILT_MODULE_NAME[0]="\$PACKAGE_NAME"
@@ -1432,12 +1435,14 @@
 %dir %{_prefix}/vice
 %dir %{_prefix}/vice/cache
 %dir %{_prefix}/vice/etc
+%dir %{_prefix}/vice/etc/C
 %{_prefix}/vice/etc/CellServDB.dist
 %config %{_prefix}/vice/etc/ThisCell
 %config %{_prefix}/vice/etc/cacheinfo
 %{_bindir}/cmdebug
 %{_bindir}/up
 %{_prefix}/vice/etc/afsd
+%{_prefix}/vice/etc/C/afszcm.cat
 %{pamdir}/pam_afs.krb.so.1
 %{pamdir}/pam_afs.krb.so
 %{pamdir}/pam_afs.so.1
@@ -1449,6 +1454,7 @@
 %{_mandir}/man5/cacheinfo.*
 %{_mandir}/man8/afsd.*
 %{_mandir}/man5/CellAlias.*
+%{_mandir}/man5/afszcm.cat.*
 
 %files server
 %defattr(-,root,root)
--- openafs/src/pam/afs_util.c:1.12.2.6	Thu Dec 13 13:54:08 2007
+++ openafs/src/pam/afs_util.c	Fri Mar 20 18:45:38 2009
@@ -21,11 +21,13 @@
 #include <stdlib.h>
 #ifdef AFS_AIX51_ENV
 #include <sys/cred.h>
+#ifdef HAVE_SYS_PAG_H
 #include <sys/pag.h>
 #endif
+#endif
 
 RCSID
-    ("$Header: /cvs/openafs/src/pam/afs_util.c,v 1.12.2.6 2007/12/13 18:54:08 shadow Exp $");
+    ("$Header: /cvs/openafs/src/pam/afs_util.c,v 1.12.2.7 2009/03/20 22:45:38 shadow Exp $");
 
 #include "afs_util.h"
 
--- openafs/src/ptserver/pt_util.c:1.9.2.9	Mon Oct 27 19:54:10 2008
+++ openafs/src/ptserver/pt_util.c	Sun Nov 30 15:25:02 2008
@@ -1,4 +1,4 @@
-/* $Id: pt_util.c,v 1.9.2.9 2008/10/27 23:54:10 shadow Exp $ */
+/* $Id: pt_util.c,v 1.9.2.10 2008/11/30 20:25:02 shadow Exp $ */
 
 /*
  *
@@ -21,9 +21,10 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/com_err.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/ptserver/pt_util.c,v 1.9.2.9 2008/10/27 23:54:10 shadow Exp $");
+    ("$Header: /cvs/openafs/src/ptserver/pt_util.c,v 1.9.2.10 2008/11/30 20:25:02 shadow Exp $");
 
 #include <afs/cmd.h>		/*Command line parsing */
 #include <afs/afsutil.h>
--- openafs/src/ptserver/ptprocs.c:1.21.2.9	Tue Oct 30 11:24:02 2007
+++ openafs/src/ptserver/ptprocs.c	Wed Mar 18 23:45:02 2009
@@ -51,7 +51,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/ptserver/ptprocs.c,v 1.21.2.9 2007/10/30 15:24:02 shadow Exp $");
+    ("$Header: /cvs/openafs/src/ptserver/ptprocs.c,v 1.21.2.10 2009/03/19 03:45:02 shadow Exp $");
 
 #include <afs/stds.h>
 #include <ctype.h>
@@ -87,6 +87,7 @@
 extern afs_int32 Initdb();
 extern int pr_noAuth;
 extern afs_int32 initd;
+extern char *pr_realmName;
 afs_int32 iNewEntry(), newEntry(), whereIsIt(), dumpEntry(), addToGroup(),
 nameToID(), Delete(), removeFromGroup();
 afs_int32 getCPS(), getCPS2(), getHostCPS(), listMax(), setMax(), listEntry();
@@ -172,22 +173,9 @@
 	if (exp < FT_ApproxTime())
 	    goto done;
 #endif
-	if (strlen(tcell)) {
-	    extern char *pr_realmName;
-#if	defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
-	    static char local_realm[AFS_REALM_SZ] = "";
-	    if (!local_realm[0]) {
-		if (afs_krb_get_lrealm(local_realm, 0) != 0 /*KSUCCESS*/)
-		    strncpy(local_realm, pr_realmName, AFS_REALM_SZ);
-	    }
-#endif
-	    if (
-#if	defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
-		   strcasecmp(local_realm, tcell) &&
-#endif
-		   strcasecmp(pr_realmName, tcell))
-		foreign = 1;
-	}
+	if (tcell[0])
+	    foreign = afs_is_foreign_ticket_name(name,inst,tcell,pr_realmName);
+
 	strncpy(vname, name, sizeof(vname));
 	if (ilen = strlen(inst)) {
 	    if (strlen(vname) + 1 + ilen >= sizeof(vname))
@@ -634,7 +622,24 @@
 	ABORT_WITH(tt, code);
 
     for (i = 0; i < aname->namelist_len; i++) {
-	code = NameToID(tt, aname->namelist_val[i], &aid->idlist_val[i]);
+	char vname[256];
+	char *nameinst, *cell;
+
+	strncpy(vname, aname->namelist_val[i], sizeof(vname));
+	vname[sizeof(vname)-1] ='\0';
+
+	nameinst = vname;
+	cell = strchr(vname, '@');
+	if (cell) {
+	    *cell = '\0';
+	    cell++;
+	}
+
+	if (cell && afs_is_foreign_ticket_name(nameinst,NULL,cell,pr_realmName))
+	    code = NameToID(tt, aname->namelist_val[i], &aid->idlist_val[i]);
+	else 
+	    code = NameToID(tt, nameinst, &aid->idlist_val[i]);
+
 	if (code != PRSUCCESS)
 	    aid->idlist_val[i] = ANONYMOUSID;
         osi_audit(PTS_NmToIdEvent, code, AUD_STR,
@@ -2275,7 +2280,6 @@
 }
 #endif /* IP_WILDCARDS */
 
-
 afs_int32
 WhoIsThisWithName(acall, at, aid, aname)
      struct rx_call *acall;
@@ -2303,11 +2307,12 @@
     } else if (code == 2) {	/* kad class */
 
 	int clen;
-	extern char *pr_realmName;
 
 	if ((code = rxkad_GetServerInfo(acall->conn, NULL, 0 /*was &exp */ ,
 					name, inst, tcell, NULL)))
 	    goto done;
+
+
 	strncpy(vname, name, sizeof(vname));
 	if ((ilen = strlen(inst))) {
 	    if (strlen(vname) + 1 + ilen >= sizeof(vname))
@@ -2316,19 +2321,9 @@
 	    strcat(vname, inst);
 	}
 	if ((clen = strlen(tcell))) {
+	    int foreign = afs_is_foreign_ticket_name(name,inst,tcell,pr_realmName);
 
-#if	defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
-	    static char local_realm[AFS_REALM_SZ] = "";
-	    if (!local_realm[0]) {
-		if (afs_krb_get_lrealm(local_realm, 0) != 0 /*KSUCCESS*/)
-		    strncpy(local_realm, pr_realmName, AFS_REALM_SZ);
-	    }
-#endif
-	    if (
-#if	defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
-		   strcasecmp(local_realm, tcell) &&
-#endif
-		   strcasecmp(pr_realmName, tcell)) {
+	    if (foreign) {
 		if (strlen(vname) + 1 + clen >= sizeof(vname))
 		    goto done;
 		strcat(vname, "@");
--- openafs/src/ptserver/ptserver.c:1.21.2.12	Sun Aug 24 21:15:20 2008
+++ openafs/src/ptserver/ptserver.c	Mon Dec 22 14:23:32 2008
@@ -113,7 +113,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/ptserver/ptserver.c,v 1.21.2.14 2008/12/22 19:23:32 shadow Exp $");
 
 #include <afs/stds.h>
 #ifdef	AFS_AIX32_ENV
@@ -336,35 +336,10 @@
 	}
 #endif
 	else if (strncmp(arg, "-auditlog", alen) == 0) {
-	    int tempfd, flags;
-	    FILE *auditout;
-	    char oldName[MAXPATHLEN];
 	    char *fileName = argv[++a];
 
-#ifndef AFS_NT40_ENV
-	    struct stat statbuf;
-
-	    if ((lstat(fileName, &statbuf) == 0) 
-		&& (S_ISFIFO(statbuf.st_mode))) {
-		flags = O_WRONLY | O_NONBLOCK;
-	    } else 
-#endif
-	    {
-		strcpy(oldName, fileName);
-		strcat(oldName, ".old");
-		renamefile(fileName, oldName);
-		flags = O_WRONLY | O_TRUNC | O_CREAT;
-	    }
-	    tempfd = open(fileName, flags, 0666);
-	    if (tempfd > -1) {
-		auditout = fdopen(tempfd, "a");
-		if (auditout) {
-		    osi_audit_file(auditout);
-		    osi_audit(PTS_StartEvent, 0, AUD_END);
-		} else
-		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-	    } else
-		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+            osi_audit_file(fileName);
+            osi_audit(PTS_StartEvent, 0, AUD_END);
 	}
 	else if (!strncmp(arg, "-rxmaxmtu", alen)) {
 	    if ((a + 1) >= argc) {
@@ -536,7 +511,7 @@
     }
 
     code =
-	ubik_ServerInitByInfo(myHost, htons(AFSCONF_PROTPORT), &info, &clones,
+	ubik_ServerInitByInfo(myHost, htons(AFSCONF_PROTPORT), &info, clones,
 			      pr_dbaseName, &dbase);
     if (code) {
 	afs_com_err(whoami, code, "Ubik init failed");
--- openafs/src/rx/rx.c:1.58.2.53	Thu Sep 25 13:26:47 2008
+++ openafs/src/rx/rx.c	Sat Mar  7 09:11:01 2009
@@ -17,7 +17,7 @@
 #endif
 
 RCSID
-    ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.53 2008/09/25 17:26:47 shadow Exp $");
+    ("$Header: /cvs/openafs/src/rx/rx.c,v 1.58.2.55 2009/03/07 14:11:01 shadow Exp $");
 
 #ifdef KERNEL
 #include "afs/sysincludes.h"
@@ -5380,7 +5380,7 @@
      * 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)
+    if ((p->header.type != RX_PACKET_TYPE_ACK) || (((struct rx_ackPacket *)rx_DataOf(p))->reason != RX_ACK_PING))
 	call->lastSendData = call->lastSendTime;
 }
 
@@ -5789,8 +5789,11 @@
 		for (i = 0; i < RX_MAXCALLS; i++) {
 		    call = conn->call[i];
 		    if (call) {
+			int code;
 			havecalls = 1;
-			MUTEX_ENTER(&call->lock);
+			code = MUTEX_TRYENTER(&call->lock);
+			if (!code)
+			    continue;
 #ifdef RX_ENABLE_LOCKS
 			result = rxi_CheckCall(call, 1);
 #else /* RX_ENABLE_LOCKS */
--- openafs/src/rx/rx_kcommon.c:1.44.2.20	Fri Aug 22 00:32:01 2008
+++ openafs/src/rx/rx_kcommon.c	Fri Mar 27 11:55:45 2009
@@ -15,7 +15,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/rx/rx_kcommon.c,v 1.44.2.21 2009/03/27 15:55:45 shadow Exp $");
 
 #include "rx/rx_kcommon.h"
 
@@ -996,10 +996,12 @@
     }
     nam->m_len = sizeof(myaddr);
     memcpy(mtod(nam, caddr_t), &myaddr, sizeof(myaddr));
-#ifdef AFS_SGI65_ENV
+#if defined(AFS_SGI65_ENV)
     BHV_PDATA(&bhv) = (void *)newSocket;
     code = sobind(&bhv, nam);
     m_freem(nam);
+#elif defined(AFS_OBSD44_ENV)
+    code = sobind(newSocket, nam, osi_curproc());
 #else
     code = sobind(newSocket, nam);
 #endif
--- openafs/src/rx/rx_prototypes.h:1.14.2.23	Thu Sep 25 13:16:14 2008
+++ openafs/src/rx/rx_prototypes.h	Sat Mar 21 11:46:07 2009
@@ -583,8 +583,12 @@
 extern void rxi_InitPeerParams(struct rx_peer *pp);
 
 #if defined(AFS_AIX32_ENV) && !defined(KERNEL)
+#ifndef osi_Alloc
 extern void *osi_Alloc(afs_int32 x);
+#endif
+#ifndef osi_Free
 extern void osi_Free(void *x, afs_int32 size);
+#endif
 #endif /* defined(AFS_AIX32_ENV) && !defined(KERNEL) */
 
 extern void rx_GetIFInfo(void);
--- openafs/src/rx/rx_rdwr.c:1.21.2.11	Thu Oct  2 07:55:03 2008
+++ openafs/src/rx/rx_rdwr.c	Mon Jan  5 18:17:48 2009
@@ -15,7 +15,7 @@
 #endif
 
 RCSID
-    ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.21.2.11 2008/10/02 11:55:03 jaltman Exp $");
+    ("$Header: /cvs/openafs/src/rx/rx_rdwr.c,v 1.21.2.13 2009/01/05 23:17:48 jaltman Exp $");
 
 #ifdef KERNEL
 #ifndef UKERNEL
@@ -231,6 +231,8 @@
 		    osi_rxSleep(&call->rq);
 #endif
 		}
+                /* cp is no longer valid since we may have given up the lock */
+                cp = call->currentPacket;
 
 		call->startWait = 0;
 #ifdef RX_ENABLE_LOCKS
@@ -690,6 +692,12 @@
     do {
 	if (call->nFree == 0) {
 	    if (!call->error && cp) {
+                /* Clear the current packet now so that if
+                 * we are forced to wait and drop the lock 
+                 * the packet we are planning on using 
+                 * cannot be freed.
+                 */
+		call->currentPacket = (struct rx_packet *)0;
 #ifdef AFS_GLOBAL_RXLOCK_KERNEL
 		/* Wait until TQ_BUSY is reset before adding any
 		 * packets to the transmit queue
@@ -711,7 +719,7 @@
 		hadd32(call->bytesSent, cp->length);
 		rxi_PrepareSendPacket(call, cp, 0);
 		queue_Append(&call->tq, cp);
-		cp = call->currentPacket = NULL;
+		cp = NULL;
 		if (!
 		    (call->
 		     flags & (RX_CALL_FAST_RECOVER |
@@ -1050,7 +1058,7 @@
 int
 rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
 {
-    struct rx_packet *cp = call->currentPacket;
+    struct rx_packet *cp = NULL;
     int nextio;
     int requestCount;
     struct rx_queue tmpq;
@@ -1073,6 +1081,8 @@
 #endif /* RX_ENABLE_LOCKS */
     }
 #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
+    /* cp is no longer valid since we may have given up the lock */
+    cp = call->currentPacket;
 
     if (call->error) {
 	if (cp) {
@@ -1171,6 +1181,8 @@
 #endif
 	call->startWait = 0;
     }
+    /* cp is no longer valid since we may have given up the lock */
+    cp = call->currentPacket;
 
     if (call->error) {
 	if (cp) {
@@ -1202,7 +1214,7 @@
 void
 rxi_FlushWrite(register struct rx_call *call)
 {
-    register struct rx_packet *cp = call->currentPacket;
+    register struct rx_packet *cp = NULL;
 
     /* Free any packets from the last call to ReadvProc/WritevProc */
     if (queue_IsNotEmpty(&call->iovq)) {
@@ -1242,6 +1254,9 @@
 	}
 #endif /* AFS_GLOBAL_RXLOCK_KERNEL */
 
+        /* cp is no longer valid since we may have given up the lock */
+        cp = call->currentPacket;
+
 	if (cp) {
 	    /* cp->length is only supposed to be the user's data */
 	    /* cp->length was already set to (then-current) 
--- openafs/src/rx/xdr.h:1.12.2.1	Thu Mar  9 01:41:55 2006
+++ openafs/src/rx/xdr.h	Fri Mar 27 11:55:46 2009
@@ -96,11 +96,13 @@
 #define	osi_free		afs_osi_Free
 
 /* keep here for now, 64 bit issues */
+#ifndef AFS_OBSD44_ENV
 extern void *afs_osi_Alloc(size_t x);
 #ifndef afs_osi_Alloc_NoSleep
 extern void *afs_osi_Alloc_NoSleep(size_t x);
 #endif
 extern void afs_osi_Free(void *x, size_t asize);
+#endif
 
 #endif
 #ifndef major			/* ouch! */
--- openafs/src/rx/xdr_arrayn.c:1.8.2.2	Sun Apr  3 14:15:51 2005
+++ openafs/src/rx/xdr_arrayn.c	Fri Mar 27 11:55:46 2009
@@ -26,11 +26,17 @@
  * 2550 Garcia Avenue
  * Mountain View, California  94043
  */
+
 #include <afsconfig.h>
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/rx/xdr_arrayn.c,v 1.8.2.2 2005/04/03 18:15:51 shadow Exp $");
+    ("$Header: /cvs/openafs/src/rx/xdr_arrayn.c,v 1.8.2.3 2009/03/27 15:55:46 shadow Exp $");
+
+#if defined(AFS_OBSD44_ENV) && defined(KERNEL) && !defined(UKERNEL)
+/* XXX osi_alloc, please find and fix */
+#include "osi_machdep.h"
+#endif
 
 #if !defined(NeXT)
 
@@ -44,6 +50,7 @@
  */
 
 #if defined(KERNEL) && !defined(UKERNEL)
+
 #include <sys/param.h>
 #ifdef AFS_LINUX20_ENV
 #include "h/string.h"
--- openafs/src/rx/UKERNEL/rx_knet.c:1.10.2.4	Mon Mar 10 18:35:36 2008
+++ openafs/src/rx/UKERNEL/rx_knet.c	Thu Mar 26 10:30:42 2009
@@ -11,7 +11,7 @@
 #include "afs/param.h"
 
 RCSID
-    ("$Header: /cvs/openafs/src/rx/UKERNEL/rx_knet.c,v 1.10.2.4 2008/03/10 22:35:36 shadow Exp $");
+    ("$Header: /cvs/openafs/src/rx/UKERNEL/rx_knet.c,v 1.10.2.5 2009/03/26 14:30:42 shadow Exp $");
 
 #include "rx/rx_kcommon.h"
 
@@ -161,6 +161,7 @@
 	/* assert(newcall != NULL); */
     }
     AFS_GLOCK();
+    return NULL;
 }
 
 /*
--- /dev/null	Sat Apr  4 14:44:31 2009
+++ openafs/src/rxdebug/rxdumptrace.c	Mon Feb 16 23:25:42 2009
@@ -0,0 +1,103 @@
+/*
+ * 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
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+
+RCSID
+    ("$Header: /cvs/openafs/src/rxdebug/rxdumptrace.c,v 1.1.4.2 2009/02/17 04:25:42 shadow Exp $");
+
+#ifdef RXDEBUG
+#include <string.h>
+#ifdef AFS_NT40_ENV
+#include <fcntl.h>
+#include <io.h>
+#else
+#include <sys/file.h>
+#include <unistd.h>
+#endif
+#include "rx.h"
+#include "rx_globals.h"
+#include "rx_trace.h"
+
+extern char *rxi_tracename;
+extern int rxi_logfd;
+
+struct rx_trace {
+    afs_uint32 cid;
+    unsigned short call;
+    unsigned short qlen;
+    afs_uint32 now;
+    afs_uint32 waittime;
+    afs_uint32 servicetime;
+    afs_uint32 event;
+};
+
+#include <errno.h>
+#ifdef AFS_NT40_ENV
+#include <afs/afsutil.h>
+#endif
+
+int
+main(argc, argv)
+     char **argv;
+{
+    struct rx_trace ip;
+    int err = 0;
+
+    setlinebuf(stdout);
+    argv++;
+    argc--;
+    while (argc && **argv == '-') {
+	if (strcmp(*argv, "-trace") == 0) {
+	    strcpy(rxi_tracename, *(++argv));
+	    argc--;
+	} else {
+	    err++;
+	    break;
+	}
+	argv++, argc--;
+    }
+    if (err || argc != 0) {
+	printf("usage: dumptrace [-trace pathname]");
+	exit(1);
+    }
+
+    rxi_logfd = open(rxi_tracename, O_RDONLY);
+    if (rxi_logfd < 0) {
+	perror("");
+	exit(errno);
+    }
+
+    while (read(rxi_logfd, &ip, sizeof(struct rx_trace))) {
+	printf("%9u ", ip.now);
+	switch (ip.event) {
+	case RX_CALL_END:
+	    putchar('E');
+	    break;
+	case RX_CALL_START:
+	    putchar('S');
+	    break;
+	case RX_CALL_ARRIVAL:
+	    putchar('A');
+	    break;
+	case RX_TRACE_DROP:
+	    putchar('D');
+	    break;
+	default:
+	    putchar('U');
+	    break;
+	}
+	printf(" %3u %7u %7u      %x.%x\n", ip.qlen, ip.servicetime,
+	       ip.waittime, ip.cid, ip.call);
+    }
+    return 0;
+}
+
+#endif
--- openafs/src/rxgen/rpc_main.c:1.21.2.7	Mon Jun 30 19:57:46 2008
+++ openafs/src/rxgen/rpc_main.c	Sun Dec 21 01:05:22 2008
@@ -37,7 +37,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/rxgen/rpc_main.c,v 1.21.2.8 2008/12/21 06:05:22 jaltman Exp $");
 
 #include <limits.h>
 #include <stdio.h>
@@ -94,11 +94,15 @@
 char yflag = 0;			/* if set, only emit function name arrays to xdr file */
 int debug = 0;
 static char *cmdname;
+#ifdef AFS_NT40_ENV
+static char *CPP = NULL;
+#else /* AFS_NT40_ENV */
 #ifdef PATH_CPP
 static char CPP[] = PATH_CPP;
 #else
 static char CPP[] = "/lib/cpp";
 #endif
+#endif /* AFS_NT40_ENV */
 static char CPPFLAGS[] = "-C";
 
 #ifdef	AFS_ALPHA_ENV
@@ -144,16 +148,14 @@
 main(int argc, char *argv[])
 {
     struct commandline cmd;
-#ifdef AFS_NT40_ENV
-    char *ep;
 
-    /* initialize CPP with the correct pre-processor on NT */
-    ep = getenv("RXGEN_CPPCMD");
-    if (ep)
-	strcpy(CPP, ep);
-    else
-	strcpy(CPP, "cl /EP /C /nologo");
-#endif
+#ifdef AFS_NT40_ENV
+    /* initialize CPP with the correct pre-processor for Windows */
+    CPP = getenv("RXGEN_CPPCMD");
+    if (!CPP)
+	CPP = "cl /EP /C /nologo";
+#endif /* AFS_NT40_ENV */
+    
 #ifdef	AFS_AIX32_ENV
     /*
      * The following signal action for AIX is necessary so that in case of a 
--- openafs/src/sys/pagsh.c:1.9.2.8	Thu Dec 13 16:23:42 2007
+++ openafs/src/sys/pagsh.c	Fri Mar 20 18:45:37 2009
@@ -11,13 +11,15 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/sys/pagsh.c,v 1.9.2.8 2007/12/13 21:23:42 shadow Exp $");
+    ("$Header: /cvs/openafs/src/sys/pagsh.c,v 1.9.2.9 2009/03/20 22:45:37 shadow Exp $");
 
 #ifdef	AFS_AIX32_ENV
 #include <signal.h>
 #ifdef AFS_AIX51_ENV
 #include <sys/cred.h>
+#ifdef HAVE_SYS_PAG_H
 #include <sys/pag.h>
+#endif
 #include <errno.h>
 #endif
 #endif
--- openafs/src/tests/afs-newcell.pl:1.1.10.2	Mon Mar 31 11:53:48 2008
+++ openafs/src/tests/afs-newcell.pl	Mon Mar 16 23:07:21 2009
@@ -584,6 +584,7 @@
     unwind($os->command('remove', "$path->{'afsconfdir'}/ThisCell"));
     unwind($os->command('remove', "$path->{'afsconfdir'}/CellServDB"));
     unwind($os->command('remove', "$path->{'afsconfdir'}/UserList"));
+    unwind($os->command('remove', "$path->{'afsconfdir'}/KeyFile"));
     unwind($os->command('remove', "$path->{'afsbosconfigdir'}/BosConfig"));
     unwind($os->command('fileserver-stop'));
 }
@@ -680,7 +681,7 @@
 if ($with_dafs) {
   run( "$bos create $server dafs dafs ".
        "-cmd \"$path->{'afssrvlibexecdir'}/fileserver $options_fileserver\" ".
-       "-cmd \"$path->{'afssrvlibexecdir'}/volserver $options_volserver\"".
+       "-cmd \"$path->{'afssrvlibexecdir'}/volserver $options_volserver\" ".
        "-cmd \"$path->{'afssrvlibexecdir'}/salvageserver $options_salvageserver\" ".
        "-cmd \"$path->{'afssrvlibexecdir'}/salvager $options_salvager\" ".
        "-noauth");
--- openafs/src/tests/OpenAFS/Auth.pm:1.1.4.3	Mon Mar 31 11:53:50 2008
+++ openafs/src/tests/OpenAFS/Auth.pm	Mon Mar 16 23:07:23 2009
@@ -380,7 +380,7 @@
   my $self = shift;
   my $principal = shift || 'admin';
   #run("echo \"Proceeding w/o authentication\"|klog -pipe ${principal}\@$self->{'realm'}");
-  run("klog $principal\@$self->{'realm'}");
+  run("klog $principal");
 }
 
 1;
--- openafs/src/tests/OpenAFS/vos.pm:1.1	Tue Jan 15 14:22:11 2002
+++ openafs/src/tests/OpenAFS/vos.pm	Mon Mar 16 23:07:23 2009
@@ -144,6 +144,7 @@
 #: - id           ID of this volume
 #: - kind         Kind of volume (RW, RO, or BK)
 #: - inuse        Disk space in use
+#: - state        On-line or Off-line
 #: - maxquota     Maximum disk usage quota
 #: - minquota     Minimum disk usage quota (optional)
 #: - stamp_create Time when volume was originally created
@@ -172,7 +173,7 @@
   push(@args, '-cell', $cell ? $cell : $AFS_Parms{'cell'});
   %result = &wrapper('vos', \@args,
 		     [$vos_err_parse,
-		      ['^(\S+)\s*(\d+)\s*(RW|RO|BK)\s*(\d+)\s*K',          'name', 'id', 'kind', 'inuse'],
+		      ['^(\S+)\s*(\d+)\s*(RW|RO|BK)\s*(\d+)\s*K\s*([-\w]+)',          'name', 'id', 'kind', 'inuse', 'state'],
 		      ['MaxQuota\s*(\d+)\s*K',                             'maxquota'     ],
 		      ['MinQuota\s*(\d+)\s*K',                             'minquota'     ],
 		      ['Creation\s*(.*\S+)',                               'stamp_create' ],
--- openafs/src/tests/OpenAFS/wrapper.pm:1.1	Tue Jan 15 14:22:11 2002
+++ openafs/src/tests/OpenAFS/wrapper.pm	Mon Mar 16 23:07:23 2009
@@ -77,7 +77,7 @@
 
 If specified, the path to be used for the program to execute, instead of
 deriving it from the command name.  This is useful when we want the
-command's argv[0] (which is always I<$cmd}) to be different from the
+command's argv[0] (which is always I<$cmd>) to be different from the
 path to the program.
 
 =item errors_last
--- openafs/src/tsm41/Makefile.in:1.7.6.3	Fri Jul 13 15:55:21 2007
+++ openafs/src/tsm41/Makefile.in	Fri Mar 20 18:59:17 2009
@@ -58,9 +58,7 @@
 		aix_ktc_krb.o \
 
 AUTHLIBS= \
-		afs_dynamic_auth \
-		aklog_dynamic_auth \
-		afs_dynamic_kerbauth
+		afs_dynamic_auth afs_dynamic_kerbauth @MAKE_KRB5@ aklog_dynamic_auth
 
 IMPORTS = -bI:/lib/aio.exp -bI:/lib/netinet.exp -bI:/lib/sockets.exp -bI:/lib/statcmd.exp 
 LDFLAGS = -eafs_initialize ${IMPORTS} -lsys -lcsys -lc
@@ -71,7 +69,7 @@
 install install.noversion:
 
 clean:
-	$(RM) -f $(AUTHLIBS) $(AUTHFILES) so_locations
+	$(RM) -f *.o $(AUTHLIBS) $(AUTHFILES) so_locations
 
 afs_dynamic_auth: ${AUTH_OBJS} ${AFSLIBS} ${AUTHFILES}
 	$(LD) -o $@ ${AUTH_OBJS} $(AFSLIBS) ${AUTHFILES} ${XLIBS} ${LDFLAGS}
@@ -100,6 +98,8 @@
 		${CC} ${CFLAGS} -c ${srcdir}/aix41_auth.c -o $@ ;; \
 	rs_aix5*) \
 		${CC} ${CFLAGS} -c ${srcdir}/aix5_auth.c -o $@ ;; \
+	rs_aix6*) \
+		${CC} ${CFLAGS} -c ${srcdir}/aix5_auth.c -o $@ ;; \
 	*) \
 		echo "not building aix lam binary for ${SYS_NAME}" ;; \
 	esac
@@ -114,7 +114,9 @@
 ${DEST}/root.client/usr/vice/etc/afs_dynamic_kerbauth: afs_dynamic_kerbauth
 	${INSTALL} $? $@
 
+${DEST}/root.client/usr/vice/etc/aklog_dynamic_auth: aklog_dynamic_auth
+	${INSTALL} $? $@
+
 dest: \
-	${DEST}/root.client/usr/vice/etc/afs_dynamic_auth \
-	${DEST}/root.client/usr/vice/etc/afs_dynamic_kerbauth
+	${DEST}/root.client/usr/vice/etc/afs_dynamic_auth ${DEST}/root.client/usr/vice/etc/afs_dynamic_kerbauth @MAKE_KRB5@ ${DEST}/root.client/usr/vice/etc/aklog_dynamic_auth
 
--- openafs/src/tsm41/aix_aklog.c:1.1.4.6	Thu Jan  3 13:05:26 2008
+++ openafs/src/tsm41/aix_aklog.c	Fri Mar 20 18:45:38 2009
@@ -9,9 +9,10 @@
 
 #include <afsconfig.h>
 #include <afs/param.h>
+#include <afs/com_err.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/tsm41/aix_aklog.c,v 1.1.4.6 2008/01/03 18:05:26 shadow Exp $");
+    ("$Header: /cvs/openafs/src/tsm41/aix_aklog.c,v 1.1.4.8 2009/03/20 22:45:38 shadow Exp $");
 
 #if defined(AFS_AIX51_ENV)
 #include <sys/types.h>
@@ -23,7 +24,9 @@
 #include <netdb.h>
 #include <sys/socket.h>
 #include <sys/file.h>
+#ifdef HAVE_SYS_PAG_H
 #include <sys/pag.h>
+#endif
 #include <errno.h>
 #include <usersec.h>
 #include <syslog.h>
--- openafs/src/ubik/recovery.c:1.13.2.7	Sat Oct 18 11:24:57 2008
+++ openafs/src/ubik/recovery.c	Thu Mar 19 23:49:16 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/ubik/recovery.c,v 1.13.2.7 2008/10/18 15:24:57 jaltman Exp $");
+    ("$Header: /cvs/openafs/src/ubik/recovery.c,v 1.13.2.9 2009/03/20 03:49:16 shadow Exp $");
 
 #include <sys/types.h>
 #ifdef AFS_NT40_ENV
@@ -578,7 +578,7 @@
 	    }
 #ifndef OLD_URECOVERY
 	    flen = length;
-	    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+	    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 	    fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
 	    if (fd < 0) {
 		code = errno;
@@ -639,27 +639,27 @@
 #ifdef OLD_URECOVERY
 		(*ubik_dbase->sync) (ubik_dbase, 0);	/* get data out first */
 #else
-		afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB0", ubik_dbase->pathName);
+		afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #ifdef AFS_NT40_ENV
-		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 		code = unlink(pbuffer);
 		if (!code)
 		    code = rename(tbuffer, pbuffer);
-		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #endif
 		if (!code) 
 		    code = rename(pbuffer, tbuffer);
-		if (!code) 
-		    code = (*ubik_dbase->open) (ubik_dbase, 0);
-		if (!code)
+		if (!code) {
+		    (*ubik_dbase->open) (ubik_dbase, 0);
 #endif
-		/* after data is good, sync disk with correct label */
-		code =
-		    (*ubik_dbase->setlabel) (ubik_dbase, 0,
-					     &ubik_dbase->version);
+		    /* after data is good, sync disk with correct label */
+		    code =
+			(*ubik_dbase->setlabel) (ubik_dbase, 0,
+						 &ubik_dbase->version);
 #ifndef OLD_URECOVERY
+		}
 #ifdef AFS_NT40_ENV
-		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+		afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 		unlink(pbuffer);
 #endif
 #endif
--- openafs/src/ubik/remote.c:1.12.2.9	Mon Oct 27 19:54:10 2008
+++ openafs/src/ubik/remote.c	Thu Mar 19 23:49:16 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/ubik/remote.c,v 1.12.2.9 2008/10/27 23:54:10 shadow Exp $");
+    ("$Header: /cvs/openafs/src/ubik/remote.c,v 1.12.2.11 2009/03/20 03:49:16 shadow Exp $");
 
 #include <sys/types.h>
 #ifdef AFS_NT40_ENV
@@ -550,7 +550,7 @@
     (*dbase->setlabel) (dbase, file, &tversion);	/* setlabel does sync */
 #ifndef OLD_URECOVERY
     flen = length;
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
     if (fd < 0) {
 	code = errno;
@@ -605,24 +605,24 @@
 #ifdef OLD_URECOVERY
     (*ubik_dbase->sync) (dbase, file);
 #else
-    afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB0", ubik_dbase->pathName);
+    afs_snprintf(tbuffer, sizeof(tbuffer), "%s.DB%s%d", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #ifdef AFS_NT40_ENV
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     code = unlink(pbuffer);
     if (!code)
 	code = rename(tbuffer, pbuffer);
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.TMP", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
 #endif
     if (!code) 
 	code = rename(pbuffer, tbuffer);
-    if (!code) 
-	code = (*ubik_dbase->open) (ubik_dbase, 0);
-    if (!code)
+    if (!code) {
+	(*ubik_dbase->open) (ubik_dbase, 0);
 #endif
-    code = (*ubik_dbase->setlabel) (dbase, file, avers);
+	code = (*ubik_dbase->setlabel) (dbase, file, avers);
 #ifndef OLD_URECOVERY
+    }
 #ifdef AFS_NT40_ENV
-    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB0.OLD", ubik_dbase->pathName);
+    afs_snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.OLD", ubik_dbase->pathName, (file<0)?"SYS":"", (file<0)?-file:file);
     unlink(pbuffer);
 #endif
 #endif
--- openafs/src/ubik/ubik.p.h:1.11.2.7	Mon Apr 28 17:48:25 2008
+++ openafs/src/ubik/ubik.p.h	Mon Mar 16 09:46:22 2009
@@ -164,7 +164,7 @@
     int (*sync) (struct ubik_dbase * adbase, afs_int32 afile);
     int (*stat) (struct ubik_dbase * adbase, afs_int32 afid,
 		 struct ubik_stat * astat);
-    int (*open) (struct ubik_dbase * adbase, afs_int32 afid);
+    void (*open) (struct ubik_dbase * adbase, afs_int32 afid);
     int (*setlabel) (struct ubik_dbase * adbase, afs_int32 afile, struct ubik_version * aversion);	/* set the version label */
     int (*getlabel) (struct ubik_dbase * adbase, afs_int32 afile, struct ubik_version * aversion);	/* retrieve the version label */
     int (*getnfiles) (struct ubik_dbase * adbase);	/* find out number of files */
--- openafs/src/update/client.c:1.12.2.2	Tue Oct 30 11:24:08 2007
+++ openafs/src/update/client.c	Tue Feb  3 14:44:51 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/update/client.c,v 1.12.2.2 2007/10/30 15:24:08 shadow Exp $");
+    ("$Header: /cvs/openafs/src/update/client.c,v 1.12.2.3 2009/02/03 19:44:51 shadow Exp $");
 
 #include <afs/stds.h>
 #ifdef	AFS_AIX32_ENV
@@ -449,7 +449,7 @@
     if (fstat(fd, &status) < 0) {
 	afs_com_err(whoami, errno, "Could not stat %s", localFile);
 	close(fd);
-	printf("could not stast %s\n", localFile);
+	printf("could not stat %s\n", localFile);
 	return UPDATE_ERROR;
     }
     if (update_ReceiveFile(fd, call, &status))
@@ -676,6 +676,7 @@
     if (errcode) {
 	printf("failed to fetch file %s \n", filename);
 	afs_com_err(whoami, errcode, "fetching file");
+        unlink(newfile);
 	return 1;
     }
 
@@ -686,6 +687,7 @@
 	       (unsigned int)mode);
 	afs_com_err(whoami, errno, "could not change protection on %s to %u",
 		newfile, mode);
+        unlink(newfile);
 	return 1;
     }
 #ifdef AFS_NT40_ENV
@@ -713,6 +715,7 @@
 	afs_com_err(whoami, errno,
 		"could not change access and modify times on %s to %u %u",
 		newfile, atime, mtime);
+        unlink(newfile);
 	return 1;
     }
 
--- openafs/src/uss/uss_vol.c:1.10.2.2	Tue Oct 30 11:24:09 2007
+++ openafs/src/uss/uss_vol.c	Fri Mar 27 11:47:43 2009
@@ -19,7 +19,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/uss/uss_vol.c,v 1.10.2.2 2007/10/30 15:24:09 shadow Exp $");
+    ("$Header: /cvs/openafs/src/uss/uss_vol.c,v 1.10.2.3 2009/03/27 15:47:43 shadow Exp $");
 
 #include "uss_vol.h"		/*Interface to this module */
 #include "uss_common.h"		/*Common definitions */
@@ -180,7 +180,7 @@
 	    /*
 	     * We got a ticket, go for an authenticated connection.
 	     */
-	    if (ttoken.kvno >= 0 && ttoken.kvno <= 255)
+	    if (ttoken.kvno >= 0 && ttoken.kvno <= 256)
 		scIndex = 2;	/*Kerberos */
 	    else {
 		fprintf(stderr, "%s: Funny kvno (%d) in ticket, proceeding\n",
--- openafs/src/util/afsutil.h:1.17.2.7	Tue Aug 26 10:12:24 2008
+++ openafs/src/util/afsutil.h	Sun Dec 21 00:59:57 2008
@@ -43,8 +43,8 @@
 extern void SetLogThreadNumProgram(int (*func) (void) );
 
 /*@printflike@*/ extern void FSLog(const char *format, ...);
-#define ViceLog(level, str)  if ((level) <= LogLevel) (FSLog str)
-#define vViceLog(level, str) if ((level) <= LogLevel) (vFSLog str)
+#define ViceLog(level, str)  do { if ((level) <= LogLevel) (FSLog str); } while (0)
+#define vViceLog(level, str) do { if ((level) <= LogLevel) (vFSLog str); } while (0)
 
 extern int OpenLog(const char *filename);
 extern int ReOpenLog(const char *fileName);
--- openafs/src/util/afsutil_prototypes.h:1.7.2.5	Wed Oct 31 00:26:29 2007
+++ openafs/src/util/afsutil_prototypes.h	Wed Mar 18 23:45:03 2009
@@ -74,7 +74,8 @@
 
 /* get_krbrlm.c */
 extern int afs_krb_get_lrealm(char *r, int n);
-
+extern int afs_krb_exclusion(char *name);
+extern int afs_is_foreign_ticket_name(char *tname, char *tinst, char * tcell, char *localrealm);
 /* hostparse.c */
 extern struct hostent *hostutil_GetHostByName(register char *ahost);
 extern char *hostutil_GetNameByINet(afs_uint32 addr);
--- openafs/src/util/dirpath.c:1.15.2.1	Mon Nov 20 18:47:24 2006
+++ openafs/src/util/dirpath.c	Wed Mar 18 23:45:03 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/util/dirpath.c,v 1.15.2.1 2006/11/20 23:47:24 rra Exp $");
+    ("$Header: /cvs/openafs/src/util/dirpath.c,v 1.15.2.2 2009/03/19 03:45:03 shadow Exp $");
 
 #include <stddef.h>
 #include <stdlib.h>
@@ -365,6 +365,8 @@
     pathp = dirPathArray[AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID];
     AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_MIGR_DIR, AFSDIR_MIGRATE_LOGNAME);
 
+    pathp = dirPathArray[AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID];
+    AFSDIR_SERVER_FILEPATH(pathp, AFSDIR_SERVER_ETC_DIR, AFSDIR_KRB_EXCL_FILE);
 
     /* client file paths */
 #ifdef AFS_NT40_ENV
--- openafs/src/util/dirpath.hin:1.4	Thu Nov  1 00:24:38 2001
+++ openafs/src/util/dirpath.hin	Wed Mar 18 23:45:03 2009
@@ -144,6 +144,7 @@
 #define AFSDIR_BOSVR_FILE       "bosserver"
 #define AFSDIR_VOLSERLOG_FILE   "VolserLog"
 #define AFSDIR_AUDIT_FILE       "Audit"
+#define AFSDIR_KRB_EXCL_FILE    "krb.excl"
 
 #define AFSDIR_ROOTVOL_FILE     "RootVolume"
 #define AFSDIR_HOSTDUMP_FILE    "hosts.dump"
@@ -262,6 +263,7 @@
       AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID,
       AFSDIR_SERVER_BIN_FILE_DIRPATH_ID,
       AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID,
+      AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID,
       AFSDIR_PATHSTRING_MAX } afsdir_id_t;
 
 /* getDirPath() returns a pointer to a string from an internal array of path strings 
@@ -329,6 +331,7 @@
 #define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID)
 #define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID)
 #define AFSDIR_SERVER_MIGRATELOG_FILEPATH getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KRB_EXCL_FILEPATH getDirPath(AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID)
 
 /* client file paths */
 #define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
--- openafs/src/util/dirpath_nt.h:1.6	Tue Jul 13 23:28:45 2004
+++ openafs/src/util/dirpath_nt.h	Wed Mar 18 23:45:03 2009
@@ -135,6 +135,7 @@
 #define AFSDIR_BOSVR_FILE       "bosserver"
 #define AFSDIR_VOLSERLOG_FILE   "VolserLog"
 #define AFSDIR_AUDIT_FILE       "Audit"
+#define AFSDIR_KRB_EXCL_FILE    "krb.excl"
 
 #define AFSDIR_ROOTVOL_FILE     "RootVolume"
 #define AFSDIR_HOSTDUMP_FILE    "hosts.dump"
@@ -257,6 +258,7 @@
     AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID,
     AFSDIR_SERVER_BIN_FILE_DIRPATH_ID,
     AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID,
+    AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID,
     AFSDIR_PATHSTRING_MAX
 } afsdir_id_t;
 
@@ -325,6 +327,7 @@
 #define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID)
 #define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID)
 #define AFSDIR_SERVER_MIGRATELOG_FILEPATH getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KRB_EXCL_FILEPATH getDirPath(AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID)
 
 /* client file paths */
 #define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
--- openafs/src/util/get_krbrlm.c:1.6.2.1	Tue Oct 30 11:24:09 2007
+++ openafs/src/util/get_krbrlm.c	Wed Mar 18 23:45:03 2009
@@ -7,7 +7,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/util/get_krbrlm.c,v 1.6.2.1 2007/10/30 15:24:09 shadow Exp $");
+    ("$Header: /cvs/openafs/src/util/get_krbrlm.c,v 1.6.2.2 2009/03/19 03:45:03 shadow Exp $");
 
 #include <stdio.h>
 #include <string.h>
@@ -28,21 +28,148 @@
 #define	KSUCCESS	0
 #define	KFAILURE	(-1)
 
+static char *
+parse_str(char *buffer, char *result, int size)
+{
+    int n=0;
+
+    if (!buffer)
+        goto cleanup;
+
+    while (*buffer && isspace(*buffer))
+        buffer++;
+    while (*buffer && !isspace(*buffer)) {
+	if (n < size - 1) {
+	    *result++=*buffer++;
+	    n++;
+	} else {
+	    buffer++;
+	}
+    }
+
+  cleanup:
+    *result='\0';
+    return buffer;
+}
+
+
 int
 afs_krb_get_lrealm(char *r, int n)
 {
+    char linebuf[2048];
+    char tr[AFS_REALM_SZ] = "";
+    char *p;
     FILE *cnffile/*, *fopen()*/;
+    int i;
+    int rv = KFAILURE;
 
-    if (n > 1)
-	return (KFAILURE);	/* Temporary restriction */
+    *r = '\0';
 
     if ((cnffile = fopen(AFSDIR_SERVER_KCONF_FILEPATH, "r")) == NULL) {
 	return (KFAILURE);
     }
-    if (fscanf(cnffile, "%s", r) != 1) {
-	(void)fclose(cnffile);
-	return (KFAILURE);
+    if (fgets(linebuf, sizeof(linebuf)-1, cnffile) == NULL) {
+	goto cleanup;
+    }
+    linebuf[sizeof(linebuf)-1] = '\0';
+    for (i=0, p=linebuf; i<=n && *p; i++) {
+        p = parse_str(p, tr, AFS_REALM_SZ);
     }
+
+    if (*tr) {
+	strcpy(r,tr);
+	rv = KSUCCESS;
+    }
+
+  cleanup:
     (void)fclose(cnffile);
-    return (KSUCCESS);
+    return rv;
 }
+
+int
+afs_krb_exclusion(char * name)
+{
+    char linebuf[2048];
+    char excl_name[256] = "";
+    FILE *cnffile/*, *fopen()*/;
+    int exclude = 0;
+
+    if ((cnffile = fopen(AFSDIR_SERVER_KRB_EXCL_FILEPATH, "r")) == NULL)
+	return exclude;
+
+    for (;;) {
+	if (fgets(linebuf, sizeof(linebuf)-1, cnffile) == NULL) {
+	    goto cleanup;
+	}
+	linebuf[sizeof(linebuf)-1] = '\0';
+        parse_str(linebuf, excl_name, sizeof(excl_name));
+
+	if (!strcmp(name,excl_name)) {
+	    exclude = 1;
+	    break;
+	}
+    }
+
+  cleanup:
+    (void)fclose(cnffile);
+    return exclude;
+}
+
+int 
+afs_is_foreign_ticket_name(char *tname, char *tinst, char * tcell, char *localrealm)
+{
+    int foreign = 0;
+
+    if (localrealm && strcasecmp(localrealm, tcell))
+	foreign = 1;
+
+#if	defined(AFS_ATHENA_STDENV) || defined(AFS_KERBREALM_ENV)
+    if (foreign) {
+	static char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
+	static int  num_lrealms = -1;
+	int lrealm_match, i;
+	char uname[256];
+
+	if (num_lrealms == -1) {
+	    for (i=0; i<AFS_NUM_LREALMS; i++) {
+		if (afs_krb_get_lrealm(local_realms[i], i) != 0 /*KSUCCESS*/)
+		    break;
+	    }
+
+	    if (i==0 && localrealm) {
+		strncpy(local_realms[0], localrealm, AFS_REALM_SZ);
+		num_lrealms = 1;
+	    } else {
+		num_lrealms = i;
+	    }
+	}
+
+	/* See if the ticket cell matches one of the local realms */
+	lrealm_match = 0;
+	for ( i=0;i<num_lrealms;i++ ) {
+	    if (!strcasecmp(local_realms[i], tcell)) {
+		lrealm_match = 1;
+		break;
+	    }
+	}
+
+	/* If yes, then make sure that the name is not present in 
+	 * an exclusion list */
+	if (lrealm_match) {
+	    if (tinst && tinst[0])
+		snprintf(uname,sizeof(uname),"%s.%s@%s",tname,tinst,tcell);
+	    else
+		snprintf(uname,sizeof(uname),"%s@%s",tname,tcell);
+
+	    if (afs_krb_exclusion(uname))
+		lrealm_match = 0;
+	}
+
+	foreign = !lrealm_match;
+    }
+#endif
+    return foreign;
+}
+
+
+
--- openafs/src/util/test/dirpath_test.c:1.5	Tue Jul 15 19:17:18 2003
+++ openafs/src/util/test/dirpath_test.c	Wed Mar 18 23:45:03 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/util/test/dirpath_test.c,v 1.5 2003/07/15 23:17:18 shadow Exp $");
+    ("$Header: /cvs/openafs/src/util/test/dirpath_test.c,v 1.5.2.1 2009/03/19 03:45:03 shadow Exp $");
 
 #include <stdio.h>
 #include <afs/afsutil.h>
@@ -124,6 +124,8 @@
 	   AFSDIR_SERVER_FILELOG_FILEPATH);
     printf("AFSDIR_SERVER_AUDIT_FILEPATH = %s\n",
 	   AFSDIR_SERVER_AUDIT_FILEPATH);
+    printf("AFSDIR_SERVER_KRB_EXCL_FILEPATH  = %s\n",
+	   AFSDIR_SERVER_KRB_EXCL_FILEPATH);
     printf("\n");
     printf("\n");
     printf("AFSDIR_CLIENT_THISCELL_FILEPATH = %s\n",
--- openafs/src/venus/fs.c:1.24.2.12	Fri Mar  7 20:15:36 2008
+++ openafs/src/venus/fs.c	Mon Feb 16 22:59:53 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/venus/fs.c,v 1.24.2.12 2008/03/08 01:15:36 shadow Exp $");
+    ("$Header: /cvs/openafs/src/venus/fs.c,v 1.24.2.14 2009/02/17 03:59:53 shadow Exp $");
 
 #include <afs/afs_args.h>
 #include <rx/xdr.h>
@@ -46,6 +46,7 @@
 #include <afs/vlserver.h>
 #include <afs/cmd.h>
 #include <afs/afsutil.h>
+#include <afs/com_err.h>
 #include <stdlib.h>
 #include <assert.h>
 #include <afs/ptclient.h>
@@ -307,12 +308,15 @@
 Parent(char *apath)
 {
     char *tp;
-    strcpy(tspace, apath);
+    strlcpy(tspace, apath, sizeof(tspace));
     tp = strrchr(tspace, '/');
-    if (tp) {
-	*tp = 0;
-    } else
-	strcpy(tspace, ".");
+    if (tp == (char *)tspace)
+	tp++;
+    else if (tp == (char *)NULL) {
+	tp      = (char *)tspace;
+	*(tp++) = '.';
+    }
+    *tp = '\0';
     return tspace;
 }
 
@@ -1621,7 +1625,11 @@
 	 * Find rightmost slash, if any.
 	 */
 	last_component = (char *)strrchr(true_name, '/');
-	if (last_component) {
+	if (last_component == (char *)true_name) {
+	    strcpy(parent_dir, "/");
+	    last_component++;
+	}
+	else if (last_component != (char *)NULL) {
 	    /*
 	     * Found it.  Designate everything before it as the parent directory,
 	     * everything after it as the final component.
@@ -3717,7 +3725,11 @@
 	 * Find rightmost slash, if any.
 	 */
 	last_component = (char *)strrchr(true_name, '/');
-	if (last_component) {
+	if (last_component == (char *)true_name) {
+	    strcpy(parent_dir, "/");
+	    last_component++;
+	}
+	else if (last_component != (char *)NULL) {
 	    /*
 	     * Found it.  Designate everything before it as the parent directory,
 	     * everything after it as the final component.
--- openafs/src/venus/livesys.c:1.4.2.3	Fri Mar  7 20:15:37 2008
+++ openafs/src/venus/livesys.c	Sun Nov 30 15:25:03 2008
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/venus/livesys.c,v 1.4.2.3 2008/03/08 01:15:37 shadow Exp $");
+    ("$Header: /cvs/openafs/src/venus/livesys.c,v 1.4.2.4 2008/11/30 20:25:03 shadow Exp $");
 
 #include <afs/afs_args.h>
 #include <rx/xdr.h>
@@ -24,6 +24,7 @@
 #include <sys/stat.h>
 #include <string.h>
 #include <afs/stds.h>
+#include <afs/com_err.h>
 #include <afs/vice.h>
 #include <afs/venus.h>
 #include <afs/com_err.h>
--- openafs/src/venus/twiddle.c:1.7.2.3	Fri Mar  7 20:15:37 2008
+++ openafs/src/venus/twiddle.c	Sun Nov 30 15:25:03 2008
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/venus/twiddle.c,v 1.7.2.3 2008/03/08 01:15:37 shadow Exp $");
+    ("$Header: /cvs/openafs/src/venus/twiddle.c,v 1.7.2.4 2008/11/30 20:25:03 shadow Exp $");
 
 #include <rx/xdr.h>
 #include <sys/ioctl.h>
@@ -22,6 +22,7 @@
 #include <netinet/in.h>
 #include <sys/stat.h>
 #include <afs/stds.h>
+#include <afs/com_err.h>
 #include <afs/vice.h>
 #include <afs/venus.h>
 #ifdef	AFS_AIX32_ENV
--- openafs/src/venus/whatfid.c:1.5.2.2	Wed Oct 31 00:13:50 2007
+++ openafs/src/venus/whatfid.c	Sun Nov 30 15:25:03 2008
@@ -14,7 +14,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/venus/whatfid.c,v 1.5.2.2 2007/10/31 04:13:50 shadow Exp $");
+    ("$Header: /cvs/openafs/src/venus/whatfid.c,v 1.5.2.3 2008/11/30 20:25:03 shadow Exp $");
 
 #include <stdio.h>
 #include <errno.h>
@@ -26,6 +26,7 @@
 #include <netdb.h>
 #include <netinet/in.h>
 #include <afs/stds.h>
+#include <afs/com_err.h>
 #include <afs/vice.h>
 #include <afs/venus.h>
 #include "afs/prs_fs.h"
--- openafs/src/viced/afsfileprocs.c:1.81.2.50	Fri Sep  5 12:58:05 2008
+++ openafs/src/viced/afsfileprocs.c	Wed Mar 25 09:07:27 2009
@@ -29,7 +29,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/viced/afsfileprocs.c,v 1.81.2.53 2009/03/25 13:07:27 shadow Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -2051,11 +2051,21 @@
 }
 
 afs_int32
-SRXAFS_ResidencyCmd(struct rx_call * acall, struct AFSFid * Fid,
-		    struct ResidencyCmdInputs * Inputs,
-		    struct ResidencyCmdOutputs * Outputs)
+SRXAFS_FsCmd(struct rx_call * acall, struct AFSFid * Fid,
+		    struct FsCmdInputs * Inputs,
+		    struct FsCmdOutputs * Outputs)
 {
-    return EINVAL;
+    afs_int32 code = 0;
+    struct AFSCallBack callback;
+    struct AFSVolSync sync;
+
+    switch (Inputs->command) {
+    default:
+        code = EINVAL;
+    }
+    ViceLog(1,("FsCmd: cmd = %d, code=%d\n", 
+			Inputs->command, Outputs->code));
+    return code;
 }
 
 static struct afs_buffer {
--- openafs/src/viced/callback.c:1.55.2.27	Tue Mar 11 13:40:55 2008
+++ openafs/src/viced/callback.c	Thu Mar 19 16:13:23 2009
@@ -83,7 +83,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/viced/callback.c,v 1.55.2.27 2008/03/11 17:40:55 shadow Exp $");
+    ("$Header: /cvs/openafs/src/viced/callback.c,v 1.55.2.30 2009/03/19 20:13:23 shadow Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>		/* for malloc() */
@@ -532,19 +532,21 @@
     tfirst = CBtime(FT_ApproxTime());
     /* N.B. The "-1", below, is because
      * FE[0] and CB[0] are not used--and not allocated */
-    FE = ((struct FileEntry *)(calloc(nblks, sizeof(struct FileEntry)))) - 1;
+    FE = ((struct FileEntry *)(calloc(nblks, sizeof(struct FileEntry))));
     if (!FE) {
 	ViceLog(0, ("Failed malloc in InitCallBack\n"));
 	assert(0);
     }
+    FE--;  /* FE[0] is supposed to point to junk */
     cbstuff.nFEs = nblks;
     while (cbstuff.nFEs)
 	FreeFE(&FE[cbstuff.nFEs]);	/* This is correct */
-    CB = ((struct CallBack *)(calloc(nblks, sizeof(struct CallBack)))) - 1;
+    CB = ((struct CallBack *)(calloc(nblks, sizeof(struct CallBack))));
     if (!CB) {
 	ViceLog(0, ("Failed malloc in InitCallBack\n"));
 	assert(0);
     }
+    CB--;  /* CB[0] is supposed to point to junk */
     cbstuff.nCBs = nblks;
     while (cbstuff.nCBs)
 	FreeCB(&CB[cbstuff.nCBs]);	/* This is correct */
@@ -1797,6 +1799,8 @@
 }
 
 #define MAGIC 0x12345678	/* To check byte ordering of dump when it is read in */
+#define MAGICV2 0x12345679      /* To check byte ordering & version of dump when it is read in */
+
 
 #ifndef INTERPRET_DUMP
 
@@ -1804,7 +1808,7 @@
 DumpCallBackState(void)
 {
     int fd, oflag;
-    afs_uint32 magic = MAGIC, now = FT_ApproxTime(), freelisthead;
+    afs_uint32 magic = MAGICV2, now = (afs_int32) FT_ApproxTime(), freelisthead;
 
     oflag = O_WRONLY | O_CREAT | O_TRUNC;
 #ifdef AFS_NT40_ENV
@@ -1842,11 +1846,14 @@
 /* This is only compiled in for the callback analyzer program */
 /* Returns the time of the dump */
 time_t
-ReadDump(char *file)
+ReadDump(char *file, int timebits)
 {
     int fd, oflag;
     afs_uint32 magic, freelisthead;
     afs_uint32 now;
+#ifdef AFS_64BIT_ENV
+    afs_int64 now64;
+#endif
 
     oflag = O_RDONLY;
 #ifdef AFS_NT40_ENV
@@ -1858,15 +1865,25 @@
 	exit(1);
     }
     read(fd, &magic, sizeof(magic));
-    if (magic != MAGIC) {
-	fprintf(stderr,
-		"Magic number of %s is invalid.  You might be trying to\n",
-		file);
-	fprintf(stderr,
-		"run this program on a machine type with a different byte ordering.\n");
-	exit(1);
+    if (magic == MAGICV2) {
+	timebits = 32;
+    } else {
+	if (magic != MAGIC) {
+	    fprintf(stderr,
+		    "Magic number of %s is invalid.  You might be trying to\n",
+		    file);
+	    fprintf(stderr,
+		    "run this program on a machine type with a different byte ordering.\n");
+	    exit(1);
+	}
     }
-    read(fd, &now, sizeof(now));
+#ifdef AFS_64BIT_ENV
+    if (timebits == 64) {
+	read(fd, &now64, sizeof(afs_int64));
+	now = (afs_int32) now64;
+    } else
+#endif
+	read(fd, &now, sizeof(afs_int32));
     read(fd, &cbstuff, sizeof(cbstuff));
     read(fd, TimeOuts, sizeof(TimeOuts));
     read(fd, timeout, sizeof(timeout));
@@ -1898,8 +1915,9 @@
     static AFSFid fid;
     register struct FileEntry *fe;
     register struct CallBack *cb;
-    time_t now;
-
+    afs_int32 now;
+    int timebits = 32;
+    
     memset(&fid, 0, sizeof(fid));
     argc--;
     argv++;
@@ -1931,6 +1949,19 @@
 	    all = 1;
 	} else if (!strcmp(*argv, "-raw")) {
 	    raw = 1;
+	} else if (!strcmp(*argv, "-timebits")) {
+	    if (argc < 1) {
+		err++;
+		break;
+	    }
+	    argc--;
+	    timebits = atoi(*++argv);
+	    if ((timebits != 32)
+#ifdef AFS_64BIT_ENV
+		&& (timebits != 64)
+#endif
+		) 
+		err++;
 	} else if (!strcmp(*argv, "-volume")) {
 	    if (argc < 1) {
 		err++;
@@ -1944,12 +1975,16 @@
     }
     if (err || argc != 1) {
 	fprintf(stderr,
-		"Usage: cbd [-host cbid] [-fid volume vnode] [-stats] [-all] callbackdumpfile\n");
+		"Usage: cbd [-host cbid] [-fid volume vnode] [-stats] [-all] [-timebits 32"
+#ifdef AFS_64BIT_ENV
+		"|64"
+#endif
+		"] callbackdumpfile\n");
 	fprintf(stderr,
 		"[cbid is shown for each host in the hosts.dump file]\n");
 	exit(1);
     }
-    now = ReadDump(*argv);
+    now = ReadDump(*argv, timebits);
     if (stats || noptions == 0) {
 	time_t uxtfirst = UXtime(tfirst);
 	printf("The time of the dump was %u %s", now, ctime(&now));
--- openafs/src/viced/host.c:1.57.2.60	Mon Oct 27 19:54:10 2008
+++ openafs/src/viced/host.c	Wed Mar 18 23:45:02 2009
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.60 2008/10/27 23:54:10 shadow Exp $");
+    ("$Header: /cvs/openafs/src/viced/host.c,v 1.57.2.64 2009/03/19 03:45:02 shadow Exp $");
 
 #include <stdio.h>
 #include <errno.h>
@@ -180,7 +180,7 @@
  */
 static struct h_AddrHashChain *hostAddrHashTable[h_HASHENTRIES];
 static struct h_UuidHashChain *hostUuidHashTable[h_HASHENTRIES];
-#define h_HashIndex(hostip) ((hostip) & (h_HASHENTRIES-1))
+#define h_HashIndex(hostip) (ntohl(hostip) & (h_HASHENTRIES-1))
 #define h_UuidHashIndex(uuidp) (((int)(afs_uuid_hash(uuidp))) & (h_HASHENTRIES-1))
 
 struct HTBlock {		/* block of HTSPERBLOCK file entries */
@@ -1420,12 +1420,17 @@
     char hoststr[16], hoststr2[16];
     Capabilities caps;
     struct rx_connection *cb_conn = NULL;
+    struct rx_connection *cb_in = NULL;
 
     caps.Capabilities_val = NULL;
 
     haddr = rxr_HostOf(tcon);
     hport = rxr_PortOf(tcon);
   retry:
+    if (cb_in) {
+        rx_DestroyConnection(cb_in);
+        cb_in = NULL;
+    }
     if (caps.Capabilities_val)
 	free(caps.Capabilities_val);
     caps.Capabilities_val = NULL;
@@ -1460,13 +1465,45 @@
 	}
 	host->hostFlags |= HWHO_INPROGRESS;
 	host->hostFlags &= ~ALTADDR;
+
+        /* We received a new connection from an IP address/port
+         * that is associated with 'host' but the address/port of
+         * the callback connection does not have to match it.
+         * If there is a match, we can use the existing callback
+         * connection to verify the UUID.  If they do not match
+         * we need to use a new callback connection to verify the
+         * UUID of the incoming caller and perhaps use the old 
+         * callback connection to verify that the old address/port
+         * is still valid.
+         */
+       
 	cb_conn = host->callback_rxcon;
 	rx_GetConnection(cb_conn);
 	H_UNLOCK;
-	code =
-	    RXAFSCB_TellMeAboutYourself(cb_conn, &interf, &caps);
-	if (code == RXGEN_OPCODE)
-	    code = RXAFSCB_WhoAreYou(cb_conn, &interf);
+        if (haddr == host->host && hport == host->port) {
+            /* The existing callback connection matches the 
+             * incoming connection so just use it.
+             */
+	    code =
+		RXAFSCB_TellMeAboutYourself(cb_conn, &interf, &caps);
+	    if (code == RXGEN_OPCODE)
+		code = RXAFSCB_WhoAreYou(cb_conn, &interf);
+	} else {
+            /* We do not have a match.  Create a new connection
+             * for the new addr/port and use multi_Rx to probe
+             * both of them simultaneously.
+             */
+	    if (!sc)
+                sc = rxnull_NewClientSecurityObject();
+            cb_in = rx_NewConnection(haddr, hport, 1, sc, 0);
+            rx_SetConnDeadTime(cb_in, 50);
+            rx_SetConnHardDeadTime(cb_in, AFS_HARDDEADTIME);
+	    
+            code =
+                RXAFSCB_TellMeAboutYourself(cb_in, &interf, &caps);
+	    if (code == RXGEN_OPCODE)
+                code = RXAFSCB_WhoAreYou(cb_in, &interf);
+	}
 	rx_PutConnection(cb_conn);
 	cb_conn=NULL;
 	H_LOCK;
@@ -1479,18 +1516,37 @@
 	    }
 	    identP->valid = 0;
 	    rx_SetSpecific(tcon, rxcon_ident_key, identP);
-	    /* The host on this connection was unable to respond to 
-	     * the WhoAreYou. We will treat this as a new connection
-	     * from the existing host. The worst that can happen is
-	     * that we maintain some extra callback state information */
-	    if (host->interface) {
-		ViceLog(0,
-			("Host %s:%d used to support WhoAreYou, deleting.\n",
-			 afs_inet_ntoa_r(host->host, hoststr),
-			 ntohs(host->port)));
-		host->hostFlags |= HOSTDELETED;
-		host->hostFlags &= ~HWHO_INPROGRESS;
-		h_Unlock_r(host);
+	    if (cb_in == NULL) {
+		/* The host on this connection was unable to respond to 
+		 * the WhoAreYou. We will treat this as a new connection
+		 * from the existing host. The worst that can happen is
+		 * that we maintain some extra callback state information */
+		if (host->interface) {
+		    ViceLog(0,
+			    ("Host %x (%s:%d) used to support WhoAreYou, deleting.\n",
+			     host, 
+			     afs_inet_ntoa_r(host->host, hoststr),
+			     ntohs(host->port)));
+		    host->hostFlags |= HOSTDELETED;
+		    host->hostFlags &= ~HWHO_INPROGRESS;
+		    host->hostFlags |= ALTADDR;
+		    h_Unlock_r(host);
+		    if (!held)
+			h_Release_r(host);
+		    host = NULL;
+		    goto retry;
+		}
+	    } else {
+		/* The incoming connection does not support WhoAreYou but
+                * the original one might have.  Use removeAddress_r() to
+                 * remove this addr/port from the host that was found.
+                 * If there are no more addresses left for the host it 
+                 * will be deleted.  Then we retry.
+                 */
+                removeAddress_r(host, haddr, hport);
+                host->hostFlags &= ~HWHO_INPROGRESS;
+		host->hostFlags |= ALTADDR;
+                h_Unlock_r(host);
 		if (!held)
 		    h_Release_r(host);
 		host = NULL;
@@ -1511,23 +1567,104 @@
 	     * then this is not the same host as before. */
 	    if (!host->interface
 		|| !afs_uuid_equal(&interf.uuid, &host->interface->uuid)) {
-                ViceLog(25,
-                         ("Uuid doesn't match host %x (%s:%d). Host deleted.\n",
-                           host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port)));
-		host->hostFlags |= HOSTDELETED;
+		if (cb_in) {
+                    ViceLog(25,
+			    ("Uuid doesn't match connection (%s:%d).\n",
+			     afs_inet_ntoa_r(haddr, hoststr), ntohs(hport)));
+		    
+                    removeAddress_r(host, haddr, hport);
+		} else {
+		    ViceLog(25,
+			    ("Uuid doesn't match host %x (%s:%d).\n",
+			     host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port)));
+		    
+		    removeAddress_r(host, host->host, host->port);
+		}
 		host->hostFlags &= ~HWHO_INPROGRESS;
+		host->hostFlags |= ALTADDR;
 		h_Unlock_r(host);
 		if (!held)
 		    h_Release_r(host);
 		host = NULL;
 		goto retry;
+	    } else if (cb_in) {
+		/* the UUID matched the client at the incoming addr/port 
+                 * but this is not the address of the active callback 
+                 * connection.  Try that connection and see if the client
+                 * is still there and if the reported UUID is the same.
+                 */
+                int code2;
+                afsUUID uuid = host->interface->uuid;
+                cb_conn = host->callback_rxcon;
+                rx_GetConnection(cb_conn);
+                rx_SetConnDeadTime(cb_conn, 2);
+                rx_SetConnHardDeadTime(cb_conn, AFS_HARDDEADTIME);
+                H_UNLOCK;
+                code2 = RXAFSCB_ProbeUuid(cb_conn, &uuid);
+                H_LOCK;
+                rx_SetConnDeadTime(cb_conn, 50);
+                rx_SetConnHardDeadTime(cb_conn, AFS_HARDDEADTIME);
+                rx_PutConnection(cb_conn);
+                cb_conn=NULL;
+                if (code2) {
+                    /* The primary address is either not responding or
+                     * is not the client we are looking for.  Need to
+                     * remove the primary address and add swap in the new 
+                     * callback connection, and destroy the old one.
+                     */
+                    struct rx_connection *rxconn;
+                    ViceLog(0,("CB: ProbeUuid for host %x (%s:%d) failed %d\n",
+			       host, 
+			       afs_inet_ntoa_r(host->host, hoststr),
+			       ntohs(host->port),code2));
+		    
+                    removeInterfaceAddr_r(host, host->host, host->port);
+                    addInterfaceAddr_r(host, haddr, hport);
+                    host->host = haddr;
+                    host->port = hport;
+                    rxconn = host->callback_rxcon;
+                    host->callback_rxcon = cb_in;
+                    cb_in = NULL;
+		    
+                    if (rxconn) {
+                        struct client *client;
+                        /*
+                         * If rx_DestroyConnection calls h_FreeConnection we will
+			 * deadlock on the host_glock_mutex. Work around the problem
+                         * by unhooking the client from the connection before
+                         * destroying the connection.
+                         */
+                        client = rx_GetSpecific(rxconn, rxcon_client_key);
+                        rx_SetSpecific(rxconn, rxcon_client_key, (void *)0);
+                        rx_DestroyConnection(rxconn);
+                   }
+               }
 	    }
 	} else {
-	    ViceLog(0,
-		    ("CB: WhoAreYou failed for host %x (%s:%d), error %d\n", 
-                     host, afs_inet_ntoa_r(host->host, hoststr),
-		     ntohs(host->port), code));
-	    host->hostFlags |= VENUSDOWN;
+	    if (cb_in) {
+                /* A callback to the incoming connection address is failing.  
+                 * Assume that the addr/port is no longer associated with the host
+                 * returned by h_Lookup_r.
+                 */
+                ViceLog(0,
+			("CB: WhoAreYou failed for connection (%s:%d) , error %d\n",
+			 afs_inet_ntoa_r(haddr, hoststr), ntohs(hport), code));
+		removeAddress_r(host, haddr, hport);
+		host->hostFlags &= ~HWHO_INPROGRESS;
+		host->hostFlags |= ALTADDR;
+		h_Unlock_r(host);
+		if (!held)
+		    h_Release_r(host);
+		host = NULL;
+		rx_DestroyConnection(cb_in);
+		return 0;
+	    } else {
+		ViceLog(0,
+			("CB: WhoAreYou failed for host %x (%s:%d), error %d\n",
+			 host, afs_inet_ntoa_r(host->host, hoststr),
+			 ntohs(host->port), code));
+		host->hostFlags |= VENUSDOWN;
+	    }
 	}
 	if (caps.Capabilities_val
 	    && (caps.Capabilities_val[0] & CAPABILITY_ERRORTRANS))
@@ -1811,7 +1948,8 @@
 
 
 static char localcellname[PR_MAXNAMELEN + 1];
-char local_realm[AFS_REALM_SZ] = "";
+char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
+int  num_lrealms = -1;
 
 /* not reentrant */
 void
@@ -1819,13 +1957,26 @@
 {
     memset(&nulluuid, 0, sizeof(afsUUID));
     afsconf_GetLocalCell(confDir, localcellname, PR_MAXNAMELEN);
-    if (!local_realm[0]) {
-	if (afs_krb_get_lrealm(local_realm, 0) != 0 /*KSUCCESS*/) {
+    if (num_lrealms == -1) {
+	int i;
+	for (i=0; i<AFS_NUM_LREALMS; i++) {
+	    if (afs_krb_get_lrealm(local_realms[i], i) != 0 /*KSUCCESS*/)
+		break;
+	}
+	
+	if (i == 0) {
 	    ViceLog(0,
 		    ("afs_krb_get_lrealm failed, using %s.\n",
 		     localcellname));
-	    strcpy(local_realm, localcellname);
+	    strncpy(local_realms[0], localcellname, AFS_REALM_SZ);
+	    num_lrealms = i =1;
+	} else {
+	    num_lrealms = i;
 	}
+ 
+	/* initialize the rest of the local realms to nullstring for debugging */
+	for (; i<AFS_NUM_LREALMS; i++)
+	    local_realms[i][0] = '\0';
     }
     rxcon_ident_key = rx_KeyCreate((rx_destructor_t) free);
     rxcon_client_key = rx_KeyCreate((rx_destructor_t) 0);
@@ -1855,11 +2006,10 @@
 
     cnamelen = strlen(acell);
     if (cnamelen) {
-	if (strcasecmp(local_realm, acell)
-	    && strcasecmp(localcellname, acell)) {
+	if (afs_is_foreign_ticket_name(aname, NULL, acell, localcellname)) {
 	    ViceLog(2,
-		    ("MapName: cell is foreign.  cell=%s, localcell=%s, localrealm=%s\n",
-		     acell, localcellname, local_realm));
+		    ("MapName: cell is foreign.  cell=%s, localcell=%s, localrealms={%s,%s,%s,%s}\n",
+		    acell, localcellname, local_realms[0],local_realms[1],local_realms[2],local_realms[3]));
 	    if ((anamelen + cnamelen + 1) >= PR_MAXNAMELEN) {
 		ViceLog(2,
 			("MapName: Name too long, using AnonymousID for %s@%s\n",
--- openafs/src/viced/viced.c:1.58.2.30	Sun Aug 24 21:15:21 2008
+++ openafs/src/viced/viced.c	Wed Mar 25 09:07:27 2009
@@ -20,7 +20,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/viced/viced.c,v 1.58.2.36 2009/03/25 13:07:27 shadow Exp $");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -315,16 +315,16 @@
 }
 
 #if defined(AFS_PTHREAD_ENV)
-char *
+int
 threadNum(void)
 {
-    return pthread_getspecific(rx_thread_id_key);
+    return (int)pthread_getspecific(rx_thread_id_key);
 }
 #endif
 
 /* proc called by rxkad module to get a key */
 static int
-get_key(char *arock, register afs_int32 akvno, char *akey)
+get_key(void *arock, register afs_int32 akvno, char *akey)
 {
     /* find the key */
     static struct afsconf_key tkey;
@@ -1078,7 +1078,8 @@
 		return -1;
 	    }
 	} else if (!strcmp(argv[i], "-realm")) {
-	    extern char local_realm[AFS_REALM_SZ];
+	    extern char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
+	    extern int  num_lrealms;
 	    if ((i + 1) >= argc) {
 		fprintf(stderr, "missing argument for -realm\n"); 
 		return -1; 
@@ -1089,7 +1090,15 @@
 		     AFS_REALM_SZ);
 		return -1;
 	    }
-	    strncpy(local_realm, argv[i], AFS_REALM_SZ);
+	    if (num_lrealms == -1) 
+		num_lrealms = 0;
+	    if (num_lrealms >= AFS_NUM_LREALMS) {
+		printf
+		    ("a maximum of %d -realm arguments can be specified.\n",
+		     AFS_NUM_LREALMS);
+		return -1;
+	    }
+	    strncpy(local_realms[num_lrealms++], argv[i], AFS_REALM_SZ);
 	} else if (!strcmp(argv[i], "-udpsize")) {
 	    if ((i + 1) >= argc) {
 		printf("You have to specify -udpsize <integer value>\n");
@@ -1120,34 +1129,9 @@
 	    rx_enableProcessRPCStats();
 	}
 	else if (strcmp(argv[i], "-auditlog") == 0) {
-	    int tempfd, flags;
-	    FILE *auditout;
-	    char oldName[MAXPATHLEN];
 	    char *fileName = argv[++i];
-	    
-#ifndef AFS_NT40_ENV
-	    struct stat statbuf;
-	    
-	    if ((lstat(fileName, &statbuf) == 0) 
-		&& (S_ISFIFO(statbuf.st_mode))) {
-		flags = O_WRONLY | O_NONBLOCK;
-	    } else 
-#endif
-	    {
-		strcpy(oldName, fileName);
-		strcat(oldName, ".old");
-		renamefile(fileName, oldName);
-		flags = O_WRONLY | O_TRUNC | O_CREAT;
-	    }
-	    tempfd = open(fileName, flags, 0666);
-	    if (tempfd > -1) {
-		auditout = fdopen(tempfd, "a");
-		if (auditout) {
-		    osi_audit_file(auditout);
-		} else
-		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-	    } else
-		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+
+            osi_audit_file(fileName);
 	}
 #ifndef AFS_NT40_ENV
 	else if (strcmp(argv[i], "-syslog") == 0) {
--- openafs/src/viced/viced.h:1.6.2.2	Wed Apr 23 14:58:09 2008
+++ openafs/src/viced/viced.h	Tue Nov 11 15:31:40 2008
@@ -198,7 +198,7 @@
 
 #define MAX_FILESERVER_THREAD	128	/* max number of threads in fileserver, subject to system limits. match to FD_HANDLE_SETASIDE */
 
-#define FILESERVER_HELPER_THREADS 7	/* Listner, IOMGR, FiveMinute, 
+#define FILESERVER_HELPER_THREADS 8	/* Listner, IOMGR, FiveMinute, FsyncCk 
 					 * HostCheck, Signal, min 2 for RXSTATS */
 #ifdef AFS_PTHREAD_ENV
 #include <pthread.h>
--- openafs/src/vlserver/vldb_check.c:1.11.2.7	Mon Oct 27 19:54:11 2008
+++ openafs/src/vlserver/vldb_check.c	Tue Feb 17 09:34:41 2009
@@ -36,6 +36,10 @@
 #define MISBKH 0x400000          /* mischained (BK) */
 #define MISNH  0x800000          /* mischained (name) */
 
+#define VLDB_CHECK_NO_VLDB_CHECK_ERROR 0
+#define VLDB_CHECK_WARNING  1
+#define VLDB_CHECK_ERROR    2
+#define VLDB_CHECK_FATAL    4
 #define vldbread(x,y,z) vldbio(x,y,z,0)
 #define vldbwrite(x,y,z) vldbio(x,y,z,1)
 
@@ -43,8 +47,9 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vlserver/vldb_check.c,v 1.11.2.7 2008/10/27 23:54:11 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vlserver/vldb_check.c,v 1.11.2.9 2009/02/17 14:34:41 shadow Exp $");
 
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
@@ -69,11 +74,15 @@
 #define ADDR(x) (x/sizeof(struct nvlentry))
 
 int fd;
-int listentries, listservers, listheader, listuheader, verbose;
+int listentries, listservers, listheader, listuheader, verbose, quiet;
 
 int fix = 0;
 int fixed = 0;
 int passes = 0;
+/* if quiet, don't send anything to stdout */
+int quiet = 0; 
+/*  error level. 0 = no error, 1 = warning, 2 = error, 4 = fatal */
+int error_level  = 0; 
 
 struct er {
     long addr;
@@ -81,6 +90,31 @@
 } *record;
 int serveraddrs[MAXSERVERID + 2];
 
+/*  Used to control what goes to stdout based on quiet flag */
+void 
+quiet_println(const char *fmt,...) {
+    va_list args;                                             
+    if (!quiet) {
+        va_start(args, fmt);                                      
+        vfprintf(stdout, fmt, args);                              
+        va_end(args);                                             
+    }
+}
+
+/*  Used to set the error level and ship messages to stderr */
+void                                                   
+log_error(int eval, const char *fmt, ...)                          
+{                                                             
+    va_list args;                                             
+    if (error_level < eval) error_level  = eval ;  /*  bump up the severity */
+    va_start(args, fmt);                                      
+    vfprintf(stderr, fmt, args);                              
+    va_end(args);                                             
+
+    if (error_level  == VLDB_CHECK_FATAL) exit(VLDB_CHECK_FATAL);
+}  
+
+
 #if 0
 int
 writeUbikHeader()
@@ -98,16 +132,16 @@
 
     offset = lseek(fd, 0, 0);
     if (offset != 0) {
-	printf("error: lseek to 0 failed: %d %d\n", offset, errno);
-	return (-1);
+	log_error(VLDB_CHECK_FATAL,"error: lseek to 0 failed: %d %d\n", offset, errno);
+	return (VLDB_CHECK_FATAL);
     }
 
     /* now read the info */
     r = read(fd, &uheader, sizeof(uheader));
     if (r != sizeof(uheader)) {
-	printf("error: read of %d bytes failed: %d %d\n", sizeof(uheader), r,
+	log_error(VLDB_CHECK_FATAL,"error: read of %d bytes failed: %d %d\n", sizeof(uheader), r,
 	       errno);
-	return (-1);
+	return (VLDB_CHECK_FATAL);
     }
 
     uheader.magic = ntohl(uheader.magic);
@@ -116,18 +150,18 @@
     uheader.version.counter = ntohl(uheader.version.counter);
 
     if (listuheader) {
-	printf("Ubik Header\n");
-	printf("   Magic           = 0x%x\n", uheader.magic);
-	printf("   Size            = %u\n", uheader.size);
-	printf("   Version.epoch   = %u\n", uheader.version.epoch);
-	printf("   Version.counter = %u\n", uheader.version.counter);
+	quiet_println("Ubik Header\n");
+	quiet_println("   Magic           = 0x%x\n", uheader.magic);
+	quiet_println("   Size            = %u\n", uheader.size);
+	quiet_println("   Version.epoch   = %u\n", uheader.version.epoch);
+	quiet_println("   Version.counter = %u\n", uheader.version.counter);
     }
 
     if (uheader.size != HDRSIZE)
-	printf("Ubik header size is %u (should be %u)\n", uheader.size,
+	log_error(VLDB_CHECK_WARNING,"VLDB_CHECK_WARNING: Ubik header size is %u (should be %u)\n", uheader.size,
 	       HDRSIZE);
     if (uheader.magic != UBIK_MAGIC)
-	printf("Ubik header magic is 0x%x (should be 0x%x)\n", uheader.magic,
+	log_error(VLDB_CHECK_ERROR,"Ubik header magic is 0x%x (should be 0x%x)\n", uheader.magic,
 	       UBIK_MAGIC);
 
     return (0);
@@ -142,7 +176,7 @@
     p = position + HDRSIZE;
     offset = lseek(fd, p, 0);
     if (offset != p) {
-	printf("error: lseek to %d failed: %d %d\n", p, offset, errno);
+	log_error(VLDB_CHECK_FATAL,"error: lseek to %d failed: %d %d\n", p, offset, errno);
 	return (-1);
     }
 
@@ -152,7 +186,7 @@
 	r = read(fd, buffer, size);
 
     if (r != size) {
-	printf("error: %s of %d bytes failed: %d %d\n", rdwr==1?"write":"read",
+	log_error(VLDB_CHECK_FATAL,"error: %s of %d bytes failed: %d %d\n", rdwr==1?"write":"read",
 	       size, r, errno);
 	return (-1);
     }
@@ -212,7 +246,7 @@
 {
     int i, j;
 
-    vldbread(0, headerp, sizeof(*headerp));
+    vldbread(0, (char *)headerp, sizeof(*headerp));
 
     headerp->vital_header.vldbversion =
 	ntohl(headerp->vital_header.vldbversion);
@@ -240,35 +274,35 @@
 	    headerp->VolidHash[i][j] = ntohl(headerp->VolidHash[i][j]);
 
     if (listheader) {
-	printf("vldb header\n");
-	printf("   vldbversion      = %u\n",
+	quiet_println("vldb header\n");
+	quiet_println("   vldbversion      = %u\n",
 	       headerp->vital_header.vldbversion);
-	printf("   headersize       = %u [actual=%u]\n",
+	quiet_println("   headersize       = %u [actual=%u]\n",
 	       headerp->vital_header.headersize, sizeof(*headerp));
-	printf("   freePtr          = 0x%x\n", headerp->vital_header.freePtr);
-	printf("   eofPtr           = %u\n", headerp->vital_header.eofPtr);
-	printf("   allocblock calls = %10u\n", headerp->vital_header.allocs);
-	printf("   freeblock  calls = %10u\n", headerp->vital_header.frees);
-	printf("   MaxVolumeId      = %u\n",
+	quiet_println("   freePtr          = 0x%x\n", headerp->vital_header.freePtr);
+	quiet_println("   eofPtr           = %u\n", headerp->vital_header.eofPtr);
+	quiet_println("   allocblock calls = %10u\n", headerp->vital_header.allocs);
+	quiet_println("   freeblock  calls = %10u\n", headerp->vital_header.frees);
+	quiet_println("   MaxVolumeId      = %u\n",
 	       headerp->vital_header.MaxVolumeId);
-	printf("   rw vol entries   = %u\n",
+	quiet_println("   rw vol entries   = %u\n",
 	       headerp->vital_header.totalEntries[0]);
-	printf("   ro vol entries   = %u\n",
+	quiet_println("   ro vol entries   = %u\n",
 	       headerp->vital_header.totalEntries[1]);
-	printf("   bk vol entries   = %u\n",
+	quiet_println("   bk vol entries   = %u\n",
 	       headerp->vital_header.totalEntries[2]);
-	printf("   multihome info   = 0x%x (%u)\n", headerp->SIT,
+	quiet_println("   multihome info   = 0x%x (%u)\n", headerp->SIT,
 	       headerp->SIT);
-	printf("   server ip addr   table: size = %d entries\n",
+	quiet_println("   server ip addr   table: size = %d entries\n",
 	       MAXSERVERID + 1);
-	printf("   volume name hash table: size = %d buckets\n", HASHSIZE);
-	printf("   volume id   hash table: %d tables with %d buckets each\n",
+	quiet_println("   volume name hash table: size = %d buckets\n", HASHSIZE);
+	quiet_println("   volume id   hash table: %d tables with %d buckets each\n",
 	       MAXTYPES, HASHSIZE);
     }
 
     /* Check the header size */
     if (headerp->vital_header.headersize != sizeof(*headerp))
-	printf("Header reports its size as %d (should be %d)\n",
+	log_error(VLDB_CHECK_WARNING,"Header reports its size as %d (should be %d)\n",
 	       headerp->vital_header.headersize, sizeof(*headerp));
     return;
 }
@@ -303,7 +337,7 @@
 	for (j = 0; j < HASHSIZE; j++)
 	    headerp->VolidHash[i][j] = htonl(headerp->VolidHash[i][j]);
 
-    vldbwrite(0, headerp, sizeof(*headerp));
+    vldbwrite(0, (char *)headerp, sizeof(*headerp));
 }
 
 void
@@ -312,7 +346,7 @@
     int i, j;
     struct extentaddr *e;
 
-    vldbread(addr, mhblockP, VL_ADDREXTBLK_SIZE);
+    vldbread(addr, (char *)mhblockP, VL_ADDREXTBLK_SIZE);
 
     mhblockP->ex_count = ntohl(mhblockP->ex_count);
     mhblockP->ex_flags = ntohl(mhblockP->ex_flags);
@@ -335,7 +369,7 @@
 {
     int i;
 
-    vldbread(addr, vlentryp, sizeof(*vlentryp));
+    vldbread(addr, (char *)vlentryp, sizeof(*vlentryp));
 
     for (i = 0; i < MAXTYPES; i++)
 	vlentryp->volumeId[i] = ntohl(vlentryp->volumeId[i]);
@@ -361,47 +395,47 @@
     }
 
     if (listentries) {
-	printf("address %u: ", addr);
+	quiet_println("address %u: ", addr);
 	if (vlentryp->flags == VLCONTBLOCK) {
-	    printf("mh extension block\n");
+	    quiet_println("mh extension block\n");
 	} else if (vlentryp->flags == VLFREE) {
-	    printf("free vlentry\n");
+	    quiet_println("free vlentry\n");
 	} else {
-	    printf("vlentry %s\n", vlentryp->name);
-	    printf("   rw id = %u ; ro id = %u ; bk id = %u\n",
+	    quiet_println("vlentry %s\n", vlentryp->name);
+	    quiet_println("   rw id = %u ; ro id = %u ; bk id = %u\n",
 		   vlentryp->volumeId[0], vlentryp->volumeId[1],
 		   vlentryp->volumeId[2]);
-	    printf("   flags         =");
+	    quiet_println("   flags         =");
 	    if (vlentryp->flags & VLF_RWEXISTS)
-		printf(" rw");
+		quiet_println(" rw");
 	    if (vlentryp->flags & VLF_ROEXISTS)
-		printf(" ro");
+		quiet_println(" ro");
 	    if (vlentryp->flags & VLF_BACKEXISTS)
-		printf(" bk");
+		quiet_println(" bk");
 	    if (vlentryp->flags & 0xffff8fff)
-		printf(" errorflag(0x%x)", vlentryp->flags);
-	    printf("\n");
-	    printf("   LockAfsId     = %d\n", vlentryp->LockAfsId);
-	    printf("   LockTimestamp = %d\n", vlentryp->LockTimestamp);
-	    printf("   cloneId       = %u\n", vlentryp->cloneId);
-	    printf
+		quiet_println(" errorflag(0x%x)", vlentryp->flags);
+	    quiet_println("\n");
+	    quiet_println("   LockAfsId     = %d\n", vlentryp->LockAfsId);
+	    quiet_println("   LockTimestamp = %d\n", vlentryp->LockTimestamp);
+	    quiet_println("   cloneId       = %u\n", vlentryp->cloneId);
+	    quiet_println
 		("   next hash for rw = %u ; ro = %u ; bk = %u ; name = %u\n",
 		 vlentryp->nextIdHash[0], vlentryp->nextIdHash[1],
 		 vlentryp->nextIdHash[2], vlentryp->nextNameHash);
 	    for (i = 0; i < NMAXNSERVERS; i++) {
 		if (vlentryp->serverNumber[i] != 255) {
-		    printf("   server %d ; partition %d ; flags =",
+		    quiet_println("   server %d ; partition %d ; flags =",
 			   vlentryp->serverNumber[i],
 			   vlentryp->serverPartition[i]);
 		    if (vlentryp->serverFlags[i] & VLSF_RWVOL)
-			printf(" rw");
+			quiet_println(" rw");
 		    if (vlentryp->serverFlags[i] & VLSF_ROVOL)
-			printf(" ro");
+			quiet_println(" ro");
 		    if (vlentryp->serverFlags[i] & VLSF_BACKVOL)
-			printf(" bk");
+			quiet_println(" bk");
 		    if (vlentryp->serverFlags[i] & VLSF_NEWREPSITE)
-			printf(" newro");
-		    printf("\n");
+			quiet_println(" newro");
+		    quiet_println("\n");
 		}
 	    }
 	}
@@ -414,8 +448,7 @@
 {
     int i;
 
-    if (verbose)
-	printf("Writing back entry at addr %u\n", addr);
+    if (verbose) quiet_println("Writing back entry at addr %u\n", addr);
     fixed++;
     for (i = 0; i < MAXTYPES; i++)
 	vlentryp->volumeId[i] = htonl(vlentryp->volumeId[i]);
@@ -431,7 +464,7 @@
 	vlentryp->serverPartition[i] = htonl(vlentryp->serverPartition[i]);
 	vlentryp->serverFlags[i] = htonl(vlentryp->serverFlags[i]);
     }
-    vldbwrite(addr, vlentryp, sizeof(*vlentryp));
+    vldbwrite(addr, (char *)vlentryp, sizeof(*vlentryp));
 }
 
 void
@@ -446,12 +479,12 @@
     vldbread(addr, sitbuf, VL_ADDREXTBLK_SIZE);
     extent = (struct extentaddr *)sitbuf;
 
-    printf("multihome info block: base %d\n", base);
+    quiet_println("multihome info block: base %d\n", base);
     if (base == 0) {
-	printf("   count = %u\n", ntohl(extent->ex_count));
-	printf("   flags = %u\n", ntohl(extent->ex_flags));
+	quiet_println("   count = %u\n", ntohl(extent->ex_count));
+	quiet_println("   flags = %u\n", ntohl(extent->ex_flags));
 	for (i = 0; i < VL_MAX_ADDREXTBLKS; i++) {
-	    printf("   contaddrs[%d] = %u\n", i,
+	    quiet_println("   contaddrs[%d] = %u\n", i,
 		   ntohl(extent->ex_contaddrs[i]));
 	}
     }
@@ -464,9 +497,9 @@
 	if (j >= VL_MAX_ADDREXTBLKS)
 	    continue;
 
-	printf("   base %d index %d:\n", base, i);
+	quiet_println("   base %d index %d:\n", base, i);
 
-	printf("       afsuuid    = (%x %x %x /%d/%d/ /%x/%x/%x/%x/%x/%x/)\n",
+	quiet_println("       afsuuid    = (%x %x %x /%d/%d/ /%x/%x/%x/%x/%x/%x/)\n",
 	       ntohl(extent[i].ex_hostuuid.time_low),
 	       ntohl(extent[i].ex_hostuuid.time_mid),
 	       ntohl(extent[i].ex_hostuuid.time_hi_and_version),
@@ -478,11 +511,11 @@
 	       ntohl(extent[i].ex_hostuuid.node[3]),
 	       ntohl(extent[i].ex_hostuuid.node[4]),
 	       ntohl(extent[i].ex_hostuuid.node[5]));
-	printf("       uniquifier = %u\n", ntohl(extent[i].ex_uniquifier));
+	quiet_println("       uniquifier = %u\n", ntohl(extent[i].ex_uniquifier));
 	for (j = 0; j < VL_MAXIPADDRS_PERMH; j++) {
 	    a = ntohl(extent[i].ex_addrs[j]);
 	    if (a) {
-		printf("       %d.%d.%d.%d\n", (a >> 24) & 0xff,
+		quiet_println("       %d.%d.%d.%d\n", (a >> 24) & 0xff,
 		       (a >> 16) & 0xff, (a >> 8) & 0xff, (a) & 0xff);
 	    }
 	}
@@ -505,8 +538,7 @@
     afs_uint32 entrysize = 0;
     afs_uint32 maxvolid = 0;
 
-    if (verbose)
-	printf("Read each entry in the database\n");
+    if (verbose) quiet_println("Read each entry in the database\n");
     for (addr = header->vital_header.headersize;
 	 addr < header->vital_header.eofPtr; addr += entrysize) {
 
@@ -514,7 +546,7 @@
 	readentry(addr, &vlentry, &type);
 	if (type == VL) {
 	    if (!(vlentry.flags & VLF_RWEXISTS))
-		printf("WARNING: VLDB entry '%s' has no RW volume\n",
+		log_error(VLDB_CHECK_WARNING,"VLDB_CHECK_WARNING: VLDB entry '%s' has no RW volume\n",
 		       vlentry.name);
 
 	    for (i = 0; i < MAXTYPES; i++)
@@ -540,12 +572,12 @@
 		    continue;
  		}
 		if (e) {
-		    printf
-			("VLDB entry '%s' contains an unknown RW/RO index serverFlag\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"VLDB entry '%s' contains an unknown RW/RO index serverFlag\n",
 			 vlentry.name);
 		    e = 0;
 		}
-		printf
+		quiet_println
 		    ("   index %d : serverNumber %d : serverPartition %d : serverFlag %d\n",
 		     j, vlentry.serverNumber[j], vlentry.serverPartition[j],
 		     vlentry.serverFlags[j]);
@@ -554,7 +586,7 @@
 
 	rindex = addr / sizeof(vlentry);
 	if (record[rindex].type) {
-	    printf("INTERNAL ERROR: record holder %d already in use\n",
+	    log_error(VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: record holder %d already in use\n",
 		   rindex);
 	    return;
 	}
@@ -572,20 +604,20 @@
 	    entrysize = VL_ADDREXTBLK_SIZE;
 	    mhcount++;
 	} else {
-	    printf("Unknown entry at %u. Aborting\n", addr);
+	    log_error(VLDB_CHECK_ERROR, "Unknown entry at %u. Aborting\n", addr);
 	    break;
 	}
     }
     if (verbose) {
-	printf("Found %d entries, %d free entries, %d multihomed blocks\n",
+	quiet_println("Found %d entries, %d free entries, %d multihomed blocks\n",
 	       vlcount, freecount, mhcount);
-	printf("Found %d RW volumes, %d BK volumes, %d RO volumes\n", rwcount,
+	quiet_println("Found %d RW volumes, %d BK volumes, %d RO volumes\n", rwcount,
 	       bkcount, rocount);
     }
 
     /* Check the maxmimum volume id in the header */
     if (maxvolid != header->vital_header.MaxVolumeId - 1)
-	printf
+	quiet_println
 	    ("Header's maximum volume id is %u and largest id found in VLDB is %u\n",
 	     header->vital_header.MaxVolumeId, maxvolid);
 }
@@ -619,19 +651,19 @@
 	if (next < 1) {
 	    switch(type & 0xf0) {
 	    case RWH:
-	      if (vlentry.nextIdHash[0] != 0) {printf("bwoop\n");}
+	      if (vlentry.nextIdHash[0] != 0) {quiet_println("bwoop\n");}
 		vlentry.nextIdHash[0] = new;
 		break;
 	    case ROH:
-	      if (vlentry.nextIdHash[1] != 0) {printf("bwoop\n");}
+	      if (vlentry.nextIdHash[1] != 0) {quiet_println("bwoop\n");}
 		vlentry.nextIdHash[1] = new;
 		break;
 	    case BKH:
-	      if (vlentry.nextIdHash[2] != 0) {printf("bwoop\n");}
+	      if (vlentry.nextIdHash[2] != 0) {quiet_println("bwoop\n");}
 		vlentry.nextIdHash[2] = new;
 		break;
 	    case NH:
-	      if (vlentry.nextNameHash != 0) {printf("bwoop\n");}
+	      if (vlentry.nextNameHash != 0) {quiet_println("bwoop\n");}
 		vlentry.nextNameHash = new;
 		break;
 	    }
@@ -655,14 +687,13 @@
     afs_int32 i, type, rindex;
 
     /* Now follow the Name Hash Table */
-    if (verbose)
-	printf("Check Volume Name Hash\n");
+    if (verbose) quiet_println("Check Volume Name Hash\n");
     for (i = 0; i < HASHSIZE; i++) {
 	chainlength = 0;
 	for (addr = header->VolnameHash[i]; addr; addr = vlentry.nextNameHash) {
 	    readentry(addr, &vlentry, &type);
 	    if (type != VL) {
-		printf("Name Hash %d: Bad entry at %u: Not a valid vlentry\n",
+		log_error(VLDB_CHECK_ERROR,"Name Hash %d: Bad entry at %u: Not a valid vlentry\n",
 		       i, addr);
 		continue;
 	    }
@@ -670,13 +701,13 @@
 	    rindex = addr / sizeof(vlentry);
 
 	    if (record[rindex].addr != addr && record[rindex].addr) {
-		printf
-		    ("INTERNAL ERROR: addresses %u and %u use same record slot %d\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n",
 		     record[rindex].addr, addr, rindex);
 	    }
 	    if (record[rindex].type & NH) {
-		printf
-		    ("Name Hash %d: Bad entry '%s': Already in the name hash\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"Name Hash %d: Bad entry '%s': Already in the name hash\n",
 		     i, vlentry.name);
 		record[rindex].type |= MULTN;
 		break;
@@ -689,8 +720,8 @@
 
 	    /* Hash the name and check if in correct hash table */
 	    if (NameHash(vlentry.name) != i) {
-		printf
-		    ("Name Hash %d: Bad entry '%s': Incorrect name hash chain (should be in %d)\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"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;
 	    }
@@ -701,7 +732,7 @@
 	    shortest = chainlength;
     }
     if (verbose) {
-	printf
+	quiet_println
 	    ("%d entries in name hash, longest is %d, shortest is %d, average length is %f\n",
 	     count, longest, shortest, ((float)count / (float)HASHSIZE));
     }
@@ -722,8 +753,7 @@
     afs_int32 i, j, hash, type, rindex, ref, badref, badhash;
 
     /* Now follow the RW, RO, and BK Hash Tables */
-    if (verbose)
-	printf("Check RW, RO, and BK id Hashes\n");
+    if (verbose) quiet_println("Check RW, RO, and BK id Hashes\n");
     for (i = 0; i < MAXTYPES; i++) {
 	hash = ((i == 0) ? RWH : ((i == 1) ? ROH : BKH));
 	ref = ((i == 0) ? REFRW : ((i == 1) ? REFRO : REFBK));
@@ -738,21 +768,21 @@
 		 addr = vlentry.nextIdHash[i]) {
 		readentry(addr, &vlentry, &type);
 		if (type != VL) {
-		    printf
-			("%s Id Hash %d: Bad entry at %u: Not a valid vlentry\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"%s Id Hash %d: Bad entry at %u: Not a valid vlentry\n",
 			 vtype(i), j, addr);
 		    continue;
 		}
 
 		rindex = addr / sizeof(vlentry);
 		if (record[rindex].addr != addr && record[rindex].addr) {
-		    printf
-			("INTERNAL ERROR: addresses %u and %u use same record slot %d\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n",
 			 record[rindex].addr, addr, rindex);
 		}
 		if (record[rindex].type & hash) {
-		    printf
-			("%s Id Hash %d: Bad entry '%s': Already in the hash table\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"%s Id Hash %d: Bad entry '%s': Already in the hash table\n",
 			 vtype(i), j, vlentry.name);
 		    record[rindex].type |= badref;
 		    break;
@@ -765,8 +795,8 @@
 
 		/* Hash the id and check if in correct hash table */
 		if (IdHash(vlentry.volumeId[i]) != j) {
-		    printf
-			("%s Id Hash %d: Bad entry '%s': Incorrect Id hash chain (should be in %d)\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"%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;
@@ -780,10 +810,9 @@
 		shortest = chainlength;
 	}
 	if (verbose) {
-	    printf
+	    quiet_println
 		("%d entries in %s hash, longest is %d, shortest is %d, average length is %f\n",
-		 count, vtype(i), longest, shortest,
-		 ((float)count / (float)HASHSIZE));
+		 count, vtype(i), longest, shortest,((float)count / (float)HASHSIZE));
 	}
     }
     return;
@@ -802,26 +831,25 @@
     afs_int32 type, rindex;
 
     /* Now follow the Free Chain */
-    if (verbose)
-	printf("Check Volume Free Chain\n");
+    if (verbose) quiet_println("Check Volume Free Chain\n");
     for (addr = header->vital_header.freePtr; addr;
 	 addr = vlentry.nextIdHash[0]) {
 	readentry(addr, &vlentry, &type);
 	if (type != FR) {
-	    printf
-		("Free Chain %d: Bad entry at %u: Not a valid free vlentry (0x%x)\n",
+	   log_error 
+		(VLDB_CHECK_ERROR,"Free Chain %d: Bad entry at %u: Not a valid free vlentry (0x%x)\n",
 		 count, addr, type);
 	    continue;
 	}
 
 	rindex = addr / sizeof(vlentry);
 	if (record[rindex].addr != addr && record[rindex].addr) {
-	    printf
-		("INTERNAL ERROR: addresses %u and %u use same record slot %d\n",
+	   log_error 
+		(VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n",
 		 record[rindex].addr, addr, rindex);
 	}
 	if (record[rindex].type & FRC) {
-	    printf("Free Chain: Bad entry at %u: Already in the free chain\n",
+	    log_error(VLDB_CHECK_ERROR,"Free Chain: Bad entry at %u: Already in the free chain\n",
 		   addr);
 	    break;
 	}
@@ -830,7 +858,7 @@
 	count++;
     }
     if (verbose)
-	printf("%d entries on free chain\n", count);
+     quiet_println("%d entries on free chain\n", count);
     return;
 }
 
@@ -866,7 +894,7 @@
     memset(&nulluuid, 0, sizeof(nulluuid));
 
     if (verbose)
-	printf("Check Multihomed blocks\n");
+	quiet_println("Check Multihomed blocks\n");
 
     if (header->SIT) {
 	/* Read the first MH block and from it, gather the 
@@ -874,8 +902,8 @@
 	 */
 	readMH(header->SIT, MHblock);
 	if (MHblock->ex_flags != VLCONTBLOCK) {
-	    printf
-		("Multihomed Block 0: Bad entry at %u: Not a valid multihomed block\n",
+	   log_error 
+		(VLDB_CHECK_ERROR,"Multihomed Block 0: Bad entry at %u: Not a valid multihomed block\n",
 		 header->SIT);
 	}
 
@@ -884,8 +912,8 @@
 	}
 
 	if (header->SIT != caddrs[0]) {
-	    printf
-		("MH block does not point to self %u in header, %u in block\n",
+	   log_error 
+		(VLDB_CHECK_ERROR,"MH block does not point to self %u in header, %u in block\n",
 		 header->SIT, caddrs[0]);
 	}
 
@@ -896,20 +924,20 @@
 
 	    readMH(caddrs[i], MHblock);
 	    if (MHblock->ex_flags != VLCONTBLOCK) {
-		printf
-		    ("Multihomed Block 0: Bad entry at %u: Not a valid multihomed block\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"Multihomed Block 0: Bad entry at %u: Not a valid multihomed block\n",
 		     header->SIT);
 	    }
 
 	    rindex = caddrs[i] / sizeof(vlentry);
 	    if (record[rindex].addr != caddrs[i] && record[rindex].addr) {
-		printf
-		    ("INTERNAL ERROR: addresses %u and %u use same record slot %d\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"INTERNAL VLDB_CHECK_ERROR: addresses %u and %u use same record slot %d\n",
 		     record[rindex].addr, caddrs[i], rindex);
 	    }
 	    if (record[rindex].type & FRC) {
-		printf
-		    ("MH Blocks Chain %d: Bad entry at %u: Already a MH block\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"MH Blocks Chain %d: Bad entry at %u: Already a MH block\n",
 		     i, record[rindex].addr);
 		break;
 	    }
@@ -944,8 +972,8 @@
 
 		if (memcmp(&e->ex_hostuuid, &nulluuid, sizeof(afsUUID)) == 0) {
 		    if (ipindex != -1) {
-			printf
-			    ("Server Addrs index %d references null MH block %d, index %d\n",
+		        log_error	
+			    (VLDB_CHECK_ERROR,"Server Addrs index %d references null MH block %d, index %d\n",
 			     ipindex, i, j);
 			serveraddrs[ipindex] = 0;	/* avoids printing 2nd error below */
 		    }
@@ -963,8 +991,8 @@
 		if (ipaddrs) {
 		    mhentries++;
 		    if (ipindex == -1) {
-			printf
-			    ("MH block %d, index %d: Not referenced by server addrs\n",
+		        log_error    	
+			    (VLDB_CHECK_ERROR,"MH block %d, index %d: Not referenced by server addrs\n",
 			     i, j);
 		    } else {
 			serveraddrs[ipindex] = ipaddrs;	/* It is good */
@@ -972,33 +1000,33 @@
 		}
 
 		if (listservers && ipaddrs) {
-		    printf("MH block %d, index %d:", i, j);
+		    quiet_println("MH block %d, index %d:", i, j);
 		    for (m = 0; m < VL_MAXIPADDRS_PERMH; m++) {
 			if (!e->ex_addrs[m])
 			    continue;
-			printf(" %d.%d.%d.%d",
+			quiet_println(" %d.%d.%d.%d",
 			       (e->ex_addrs[m] & 0xff000000) >> 24,
 			       (e->ex_addrs[m] & 0x00ff0000) >> 16,
 			       (e->ex_addrs[m] & 0x0000ff00) >> 8,
 			       (e->ex_addrs[m] & 0x000000ff));
 		    }
-		    printf("\n");
+		    quiet_println("\n");
 		}
 	    }
 /*
  *      if (mhentries != MHblock->ex_count) {
- *	   printf("MH blocks says it has %d entries (found %d)\n",
+ *	   quiet_println("MH blocks says it has %d entries (found %d)\n",
  *		  MHblock->ex_count, mhentries);
  *	}
  */
 	}
     }
     if (verbose)
-	printf("%d multihomed blocks\n", mhblocks);
+	quiet_println("%d multihomed blocks\n", mhblocks);
 
     /* Check the server addresses */
     if (verbose)
-	printf("Check server addresses\n");
+	quiet_println("Check server addresses\n");
     mhentries = regentries = 0;
     for (i = 0; i <= MAXSERVERID; i++) {
 	if (header->IpMappedAddr[i]) {
@@ -1006,22 +1034,22 @@
 		mhentries++;
 		if (((header->IpMappedAddr[i] & 0x00ff0000) >> 16) >
 		    VL_MAX_ADDREXTBLKS)
-		    printf
-			("IP Addr for entry %d: Multihome block is bad (%d)\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"IP Addr for entry %d: Multihome block is bad (%d)\n",
 			 i, ((header->IpMappedAddr[i] & 0x00ff0000) >> 16));
 		if (((header->IpMappedAddr[i] & 0x0000ffff) > VL_MHSRV_PERBLK)
 		    || ((header->IpMappedAddr[i] & 0x0000ffff) < 1))
-		    printf
-			("IP Addr for entry %d: Multihome index is bad (%d)\n",
+		    log_error 
+			(VLDB_CHECK_ERROR,"IP Addr for entry %d: Multihome index is bad (%d)\n",
 			 i, (header->IpMappedAddr[i] & 0x0000ffff));
 		if (serveraddrs[i] == -1) {
-		    printf
-			("warning: IP Addr for entry %d: Multihome entry has no ip addresses\n",
+		    log_error 
+			(VLDB_CHECK_WARNING,"warning: IP Addr for entry %d: Multihome entry has no ip addresses\n",
 			 i);
 		    serveraddrs[i] = 0;
 		}
 		if (listservers) {
-		    printf("   Server ip addr %d = MH block %d, index %d\n",
+		    quiet_println("   Server ip addr %d = MH block %d, index %d\n",
 			   i, (header->IpMappedAddr[i] & 0x00ff0000) >> 16,
 			   (header->IpMappedAddr[i] & 0x0000ffff));
 		}
@@ -1029,7 +1057,7 @@
 		regentries++;
 		serveraddrs[i] = 1;	/* It is good */
 		if (listservers) {
-		    printf("   Server ip addr %d = %d.%d.%d.%d\n", i,
+		    quiet_println("   Server ip addr %d = %d.%d.%d.%d\n", i,
 			   (header->IpMappedAddr[i] & 0xff000000) >> 24,
 			   (header->IpMappedAddr[i] & 0x00ff0000) >> 16,
 			   (header->IpMappedAddr[i] & 0x0000ff00) >> 8,
@@ -1039,7 +1067,7 @@
 	}
     }
     if (verbose) {
-	printf("%d simple entries, %d multihomed entries, Total = %d\n",
+	quiet_println("%d simple entries, %d multihomed entries, Total = %d\n",
 	       regentries, mhentries, mhentries + regentries);
     }
     return;
@@ -1049,7 +1077,7 @@
 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", 
+    quiet_println("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")));
 }
 
@@ -1062,19 +1090,28 @@
     struct nvlentry vlentry, vlentry2;
     int i, j, help = 0;
 
+    error_level = 0;  /*  start clean with no error status */
     dbfile = as->parms[0].items->data;	/* -database */
     listuheader = (as->parms[1].items ? 1 : 0);	/* -uheader  */
     listheader = (as->parms[2].items ? 1 : 0);	/* -vheader  */
     listservers = (as->parms[3].items ? 1 : 0);	/* -servers  */
     listentries = (as->parms[4].items ? 1 : 0);	/* -entries  */
     verbose = (as->parms[5].items ? 1 : 0);	/* -verbose  */
-    fix = (as->parms[6].items ? 1 : 0);	/* -fix  */
+    quiet = (as->parms[6].items ? 1 : 0);  /* -quiet */
+    fix = (as->parms[7].items ? 1 : 0);    /* -fix  */
+
+    /* sanity check */
+    if (quiet && (verbose || listuheader || listheader ||listservers \
+                || listentries)) {
+        log_error(VLDB_CHECK_FATAL," -quiet cannot be used other display flags\n");
+        return VLDB_CHECK_FATAL;
+    }
 
  restart:
     /* open the vldb database file */
     fd = open(dbfile, (fix > 0)?O_RDWR:O_RDONLY, 0);
     if (fd < 0) {
-	printf("can't open file '%s'. error = %d\n", dbfile, errno);
+	log_error(VLDB_CHECK_FATAL,"can't open file '%s'. error = %d\n", dbfile, errno);
 	return 0;
     }
 
@@ -1082,8 +1119,8 @@
     readUbikHeader();
     readheader(&header);
     if (header.vital_header.vldbversion < 3) {
-	printf("does not support vldb with version less than 3\n");
-	return 0;
+	log_error(VLDB_CHECK_FATAL,"does not support vldb with version less than 3\n");
+	return VLDB_CHECK_FATAL;
     }
 
     maxentries = (header.vital_header.eofPtr / sizeof(vlentry)) + 1;
@@ -1112,7 +1149,7 @@
      * valid (the serveraddrs array).
      */
     if (verbose)
-	printf("Verify each volume entry\n");
+	quiet_println("Verify each volume entry\n");
     for (i = 0; i < maxentries; i++) {
 	int nextp = 0;
 	int reft = 0;
@@ -1134,7 +1171,7 @@
 	    readentry(record[i].addr, &vlentry, &type);
 
 	    if (InvalidVolname(vlentry.name))
-		printf("Volume '%s' at addr %u has an invalid name\n",
+		log_error(VLDB_CHECK_ERROR,"Volume '%s' at addr %u has an invalid name\n",
 		       vlentry.name, record[i].addr);
 
 	    if (!(record[i].type & NH)) {
@@ -1230,71 +1267,69 @@
 	    }
 
 	    if (foundbad) {
-		printf("%d: Volume '%s' %snot found in %s hash %d", i, 
+		log_error(VLDB_CHECK_ERROR,"%d: Volume '%s' %snot found in %s hash %d", i, 
 		       vlentry.name, volidbuf, which, hash);
 		if (nextp) {
-		    printf(" (next %d", nextp);
+		    log_error(VLDB_CHECK_ERROR," (next %d", nextp);
 		    if (!(record[nextp].type & reft)) {
-			printf(" not in chain ");
+			log_error(VLDB_CHECK_ERROR," not in chain ");
 			record[nextp].type |= reft;
 		    } else if (nextp != 0) {
-			printf(" next in chain");
+			log_error(VLDB_CHECK_ERROR," next in chain");
 			if (fix) {
-			    printf(", unchaining");
+			    log_error(VLDB_CHECK_ERROR,", unchaining");
 			    *nextpp = 0;
 			    writeentry(record[i].addr, &vlentry);
 			}
 		    }
-		    printf(")");
+		    log_error(VLDB_CHECK_ERROR,")");
 		}
-		printf("\n");
+		log_error(VLDB_CHECK_ERROR,"\n");
 	    }
 	
 	    for (j = 0; j < NMAXNSERVERS; j++) {
 		if ((vlentry.serverNumber[j] != 255)
 		    && (serveraddrs[vlentry.serverNumber[j]] == 0)) {
-		    printf
-			("Volume '%s', index %d points to empty server entry %d\n",
+		   log_error 
+			(VLDB_CHECK_ERROR,"Volume '%s', index %d points to empty server entry %d\n",
 			 vlentry.name, j, vlentry.serverNumber[j]);
 		}
 	    }
 	
 	    if (record[i].type & 0xffff0f00)
-		printf
-		    ("Volume '%s' id %u also found on other chains (0x%x)\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"Volume '%s' id %u also found on other chains (0x%x)\n",
 		     vlentry.name, vlentry.volumeId[0], record[i].type);
 	    
 	    /* A free entry */
 	} else if (record[i].type & FR) {
 	    if (!(record[i].type & FRC))
-		printf("Free vlentry at %u not on free chain\n",
+		log_error(VLDB_CHECK_ERROR,"Free vlentry at %u not on free chain\n",
 		       record[i].addr);
 	    
 	    if (record[i].type & 0xfffffdf0)
-		printf
-		    ("Free vlentry at %u also found on other chains (0x%x)\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"Free vlentry at %u also found on other chains (0x%x)\n",
 		     record[i].addr, record[i].type);
 	    
 	    /* A multihomed entry */
 	} else if (record[i].type & MH) {
 	    if (!(record[i].type & MHC))
-		printf("Multihomed block at %u is orphaned\n",
+		log_error(VLDB_CHECK_ERROR,"Multihomed block at %u is orphaned\n",
 		       record[i].addr);
 	    
 	    if (record[i].type & 0xfffffef0)
-		printf
-		    ("Multihomed block at %u also found on other chains (0x%x)\n",
+	        log_error	
+		    (VLDB_CHECK_ERROR,"Multihomed block at %u also found on other chains (0x%x)\n",
 		     record[i].addr, record[i].type);
 	    
 	} else {
-	    printf("Unknown entry type at %u (0x%x)\n", record[i].addr,
+	    log_error(VLDB_CHECK_ERROR,"Unknown entry type at %u (0x%x)\n", record[i].addr,
 		   record[i].type);
 	}
     }
 
-    if (verbose)
-	printf("Verify each chain head\n");
-
+    if (verbose)  quiet_println("Verify each chain head\n");
     {
 	afs_uint32 addr;
 	int hash;
@@ -1313,48 +1348,54 @@
 	    }
 	}
 	for (i = 0; i <= 2; i++) {
-	    for (j = 0; j < HASHSIZE; j++) {
-		addr = header.VolidHash[i][j]; 
+         for (j = 0, addr = header.VolidHash[i][j]; j < HASHSIZE; j++) {
+        if (verbose) quiet_println("got %d %d %d\n", i, j, ADDR(addr));
 		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)
+			if (fix) {
+                         quiet_println("fix %d %d %d\n", i, j, ADDR(addr));
 			    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)
+			if (fix) {
+                         quiet_println("fix %d %d %d\n", i, j, addr);
 			    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)
+			if (fix) {
+                         quiet_println("fix %d %d %d\n", i, j, addr);
 			    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);
+    quiet_println("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, 
+		log_error(VLDB_CHECK_ERROR,"%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) {
@@ -1373,7 +1414,7 @@
 		}
 	    }
 	    if (vlentry.volumeId[0] && !(record[i].type & REFRW)) {
-		printf("%d: Record %u (type 0x%x) not in a RW chain\n", i,
+		log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a RW chain\n", i,
 		       record[i].addr, record[i].type);
 		if (fix) {
 		    if (header.VolidHash[0][IdHash(vlentry.volumeId[0])] == 0)
@@ -1383,7 +1424,7 @@
 		}
 	    }
 	    if (vlentry.volumeId[1] && !(record[i].type & REFRO)) {
-		printf("%d: Record %u (type 0x%x) not in a RO chain\n", i, 
+		log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a RO chain\n", i, 
 		       record[i].addr, record[i].type);
 		if (fix) {
 		    if (header.VolidHash[1][IdHash(vlentry.volumeId[1])] == 0)
@@ -1393,7 +1434,7 @@
 		}
 	    }
 	    if (vlentry.volumeId[2] && !(record[i].type & REFBK)) {
-		printf("%d: Record %u (type 0x%x) not in a BK chain\n", i, 
+		log_error(VLDB_CHECK_ERROR,"%d: Record %u (type 0x%x) not in a BK chain\n", i, 
 		       record[i].addr, record[i].type);
 		if (fix) {
 		    if (header.VolidHash[2][IdHash(vlentry.volumeId[2])] == 0)
@@ -1418,7 +1459,7 @@
       else
 	return 1;
     }
-    return 0;
+    return error_level;
 }
 
 int
@@ -1438,6 +1479,7 @@
 		"Display server list");
     cmd_AddParm(ts, "-entries", CMD_FLAG, CMD_OPTIONAL, "Display entries");
     cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "verbose");
+    cmd_AddParm(ts, "-quiet", CMD_FLAG, CMD_OPTIONAL, "quiet");
     cmd_AddParm(ts, "-fix", CMD_FLAG, CMD_OPTIONAL, "attempt to patch the database (potentially dangerous)");
 
     return cmd_Dispatch(argc, argv);
--- openafs/src/vlserver/vlserver.c:1.18.2.14	Sat Oct 18 11:10:57 2008
+++ openafs/src/vlserver/vlserver.c	Mon Dec 22 14:23:32 2008
@@ -11,7 +11,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vlserver/vlserver.c,v 1.18.2.14 2008/10/18 15:10:57 jaltman Exp $");
+    ("$Header: /cvs/openafs/src/vlserver/vlserver.c,v 1.18.2.16 2008/12/22 19:23:32 shadow Exp $");
 
 #include <afs/stds.h>
 #include <sys/types.h>
@@ -211,34 +211,9 @@
 	    strcpy(rxi_tracename, argv[++index]);
 
        } else if (strcmp(argv[index], "-auditlog") == 0) {
-	   int tempfd, flags;
-           FILE *auditout;
-           char oldName[MAXPATHLEN];
            char *fileName = argv[++index];
 
-#ifndef AFS_NT40_ENV
-           struct stat statbuf;
-
-           if ((lstat(fileName, &statbuf) == 0) 
-               && (S_ISFIFO(statbuf.st_mode))) {
-               flags = O_WRONLY | O_NONBLOCK;
-           } else 
-#endif
-           {
-               strcpy(oldName, fileName);
-               strcat(oldName, ".old");
-               renamefile(fileName, oldName);
-               flags = O_WRONLY | O_TRUNC | O_CREAT;
-           }
-           tempfd = open(fileName, flags, 0666);
-           if (tempfd > -1) {
-               auditout = fdopen(tempfd, "a");
-               if (auditout) {
-                   osi_audit_file(auditout);
-               } else
-                   printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-           } else
-               printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+           osi_audit_file(fileName);
 	} else if (strcmp(argv[index], "-enable_peer_stats") == 0) {
 	    rx_enablePeerRPCStats();
 	} else if (strcmp(argv[index], "-enable_process_stats") == 0) {
@@ -362,7 +337,7 @@
     ubik_CheckRXSecurityProc = afsconf_CheckAuth;
     ubik_CheckRXSecurityRock = (char *)tdir;
     code =
-	ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, &clones,
+	ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info, clones,
 			      vl_dbaseName, &VL_dbase);
     if (code) {
 	printf("vlserver: Ubik init failed with code %d\n", code);
--- openafs/src/vol/fssync.c:1.26.2.10	Tue Apr  1 16:05:47 2008
+++ openafs/src/vol/fssync.c	Mon Mar 23 14:19:57 2009
@@ -51,15 +51,15 @@
 #include <afs/afsutil.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vol/Attic/fssync.c,v 1.26.2.10 2008/04/01 20:05:47 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vol/Attic/fssync.c,v 1.26.2.12 2009/03/23 18:19:57 shadow Exp $");
 
 #include <sys/types.h>
 #include <stdio.h>
-#include <unistd.h>
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
 #include <time.h>
 #else
+#include <unistd.h>
 #include <sys/param.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
@@ -527,7 +527,7 @@
 	if (v)
 	    v->volumeID = 0;
 	tvolName[0] = '/';
-	sprintf(&tvolName[1], VFORMAT, command.volume);
+	sprintf(&tvolName[1], VFORMAT, afs_cast_uint32(command.volume));
 
 	vp = VAttachVolumeByName_r(&error, command.partName, tvolName,
 				   V_VOLUPD);
@@ -667,7 +667,7 @@
 	    Volume *vp;
 
 	    tvolName[0] = '/';
-	    sprintf(&tvolName[1], VFORMAT, p[i].volumeID);
+	    sprintf(&tvolName[1], VFORMAT, afs_cast_uint32(p[i].volumeID));
 	    vp = VAttachVolumeByName_r(&error, p[i].partName, tvolName,
 				       V_VOLUPD);
 	    if (vp)
--- openafs/src/vol/listinodes.c:1.13.2.7	Sat Aug 16 15:15:48 2008
+++ openafs/src/vol/listinodes.c	Mon Mar 23 14:19:57 2009
@@ -23,7 +23,7 @@
 #include <string.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.13.2.7 2008/08/16 19:15:48 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vol/listinodes.c,v 1.13.2.8 2009/03/23 18:19:57 shadow Exp $");
 
 #ifndef AFS_NAMEI_ENV
 #if defined(AFS_LINUX20_ENV) || defined(AFS_SUN4_ENV)
@@ -1664,7 +1664,7 @@
 
     memset(&specinos, 0, sizeof(specinos));
 	   
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, volumeId);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(volumeId));
     (void)afs_snprintf(oldpath, sizeof oldpath, "%s/%s", pname, headername);
     fd = open(oldpath, O_RDONLY);
     if (fd < 0) {
@@ -1767,7 +1767,7 @@
     }
 #endif
 
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, h.id);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(h.id));
     (void)afs_snprintf(newpath, sizeof newpath, "%s/%s", pname, headername);
     fd = open(newpath, O_CREAT | O_EXCL | O_RDWR, 0644);
     if (fd < 0) {
--- openafs/src/vol/namei_ops.c:1.21.2.18	Fri Oct 10 10:43:02 2008
+++ openafs/src/vol/namei_ops.c	Mon Mar 23 14:19:57 2009
@@ -13,7 +13,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.18 2008/10/10 14:43:02 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vol/namei_ops.c,v 1.21.2.19 2009/03/23 18:19:57 shadow Exp $");
 
 #ifdef AFS_NAMEI_ENV
 #include <stdio.h>
@@ -1572,7 +1572,7 @@
     char headername[16];
     afs_int32 error = 0;
 
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, volumeId);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(volumeId));
     (void)afs_snprintf(oldpath, sizeof oldpath, "%s/%s", pname, headername);
     fd = open(oldpath, O_RDONLY);
     if (fd < 0) {
@@ -1722,7 +1722,7 @@
     h.smallVnodeIndex_hi = h.id;
     h.largeVnodeIndex_hi = h.id;
     h.linkTable_hi = h.id;
-    (void)afs_snprintf(headername, sizeof headername, VFORMAT, h.id);
+    (void)afs_snprintf(headername, sizeof headername, VFORMAT, afs_cast_uint32(h.id));
     (void)afs_snprintf(newpath, sizeof newpath, "%s/%s", pname, headername);
     fd = open(newpath, O_CREAT | O_EXCL | O_RDWR, 0644);
     if (fd < 0) {
--- openafs/src/vol/vnode.c:1.19.2.6	Fri Dec 28 17:16:51 2007
+++ openafs/src/vol/vnode.c	Mon Feb 16 23:37:59 2009
@@ -17,7 +17,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vol/vnode.c,v 1.19.2.6 2007/12/28 22:16:51 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vol/vnode.c,v 1.19.2.7 2009/02/17 04:37:59 shadow Exp $");
 
 #include <errno.h>
 #include <stdio.h>
@@ -959,6 +959,7 @@
 	for (vnp = VnodeHashTable[i]; vnp; vnp = vnp->hashNext) {
 	    if (vnp->volumePtr == vp) {
 		IH_REALLYCLOSE(vnp->handle);
+		IH_RELEASE(vnp->handle);
 	    }
 	}
     }
--- openafs/src/vol/vol-info.c:1.18.2.5	Sat Aug 16 15:15:49 2008
+++ openafs/src/vol/vol-info.c	Mon Mar 23 14:19:57 2009
@@ -18,7 +18,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/vol/vol-info.c,v 1.18.2.6 2009/03/23 18:19:57 shadow Exp $");
 
 #include <ctype.h>
 #include <errno.h>
@@ -322,7 +322,7 @@
 	    }
 	}
 	(void)afs_snprintf(name1, sizeof name1, VFORMAT,
-			   (unsigned long)volumeId);
+			   afs_cast_uint32(volumeId));
 	if (dsizeOnly && !saveinodes)
 	    printf
 		("Volume-Id\t  Volsize  Auxsize Inodesize  AVolsize SizeDiff                (VolName)\n");
--- openafs/src/vol/vol-salvage.c:1.41.2.19	Mon Oct 27 19:54:12 2008
+++ openafs/src/vol/vol-salvage.c	Mon Mar 23 14:19:57 2009
@@ -92,7 +92,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.19 2008/10/27 23:54:12 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vol/vol-salvage.c,v 1.41.2.20 2009/03/23 18:19:57 shadow Exp $");
 
 #include <stdlib.h>
 #include <stdio.h>
@@ -1787,7 +1787,7 @@
 		    || (vsp->header.id == singleVolumeNumber
 			|| vsp->header.parent == singleVolumeNumber)) {
 		    (void)afs_snprintf(nameShouldBe, sizeof nameShouldBe,
-				       VFORMAT, vsp->header.id);
+				       VFORMAT, afs_cast_uint32(vsp->header.id));
 		    if (singleVolumeNumber
 			&& vsp->header.id != singleVolumeNumber)
 			AskOffline(vsp->header.id);
@@ -2237,7 +2237,7 @@
 
     if (isp->volSummary == NULL) {
 	char name[64];
-	(void)afs_snprintf(name, sizeof name, VFORMAT, isp->volumeId);
+	(void)afs_snprintf(name, sizeof name, VFORMAT, afs_cast_uint32(isp->volumeId));
 	if (check) {
 	    Log("No header file for volume %u\n", isp->volumeId);
 	    return -1;
@@ -2264,7 +2264,7 @@
 	    if (isp->volSummary->fileName) {
 		strcpy(name, isp->volSummary->fileName);
 	    } else {
-		(void)afs_snprintf(name, sizeof name, VFORMAT, isp->volumeId);
+	      (void)afs_snprintf(name, sizeof name, VFORMAT, afs_cast_uint32(isp->volumeId));
 		isp->volSummary->fileName = ToString(name);
 	    }
 
--- openafs/src/vol/volume.c:1.35.2.15	Mon Oct 27 20:54:49 2008
+++ openafs/src/vol/volume.c	Mon Mar 23 14:19:57 2009
@@ -20,7 +20,7 @@
 #include <afs/param.h>
 
 RCSID
-    ("$Header: /cvs/openafs/src/vol/volume.c,v 1.35.2.15 2008/10/28 00:54:49 shadow Exp $");
+    ("$Header: /cvs/openafs/src/vol/volume.c,v 1.35.2.16 2009/03/23 18:19:57 shadow Exp $");
 
 #include <rx/xdr.h>
 #include <afs/afsint.h>
@@ -1680,7 +1680,7 @@
 
     *ec = 0;
     name[0] = '/';
-    (void)afs_snprintf(&name[1], (sizeof name) - 1, VFORMAT, volumeId);
+    (void)afs_snprintf(&name[1], (sizeof name) - 1, VFORMAT, afs_cast_uint32(volumeId));
     for (dp = DiskPartitionList; dp; dp = dp->next) {
 	struct afs_stat status;
 	strcpy(path, VPartitionPath(dp));
@@ -1712,7 +1712,7 @@
 VolumeExternalName(VolumeId volumeId)
 {
     static char name[VMAXPATHLEN];
-    (void)afs_snprintf(name, sizeof name, VFORMAT, volumeId);
+    (void)afs_snprintf(name, sizeof name, VFORMAT, afs_cast_uint32(volumeId));
     return name;
 }
 
--- openafs/src/vol/vutil.c:1.15.2.3	Thu Sep  4 14:17:23 2008
+++ openafs/src/vol/vutil.c	Mon Mar 23 14:19:57 2009
@@ -18,7 +18,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/vol/vutil.c,v 1.15.2.4 2009/03/23 18:19:57 shadow Exp $");
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -171,7 +171,7 @@
     vol.stamp.magic = VOLUMEINFOMAGIC;
     vol.stamp.version = VOLUMEINFOVERSION;
     vol.destroyMe = DESTROY_ME;
-    (void)afs_snprintf(headerName, sizeof headerName, VFORMAT, vol.id);
+    (void)afs_snprintf(headerName, sizeof headerName, VFORMAT, afs_cast_uint32(vol.id));
     (void)afs_snprintf(volumePath, sizeof volumePath, "%s/%s",
 		       VPartitionPath(partition), headerName);
     fd = afs_open(volumePath, O_CREAT | O_EXCL | O_WRONLY, 0600);
--- openafs/src/volser/vol-dump.c:1.1.2.2	Sat Aug 16 15:15:49 2008
+++ openafs/src/volser/vol-dump.c	Mon Mar 23 14:19:57 2009
@@ -18,7 +18,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/volser/vol-dump.c,v 1.1.2.4 2009/03/23 18:19:57 shadow Exp $");
 
 #include <ctype.h>
 #include <errno.h>
@@ -90,11 +90,11 @@
 int verbose = 0;
 
 /* Forward Declarations */
-void HandleVolume(struct DiskPartition64 *partP, char *name, char *filename);
+void HandleVolume(struct DiskPartition64 *partP, char *name, char *filename, int fromtime);
 Volume *AttachVolume(struct DiskPartition64 *dp, char *volname,
 		     register struct VolumeHeader *header);
 static void DoMyVolDump(Volume * vp, struct DiskPartition64 *dp,
-			char *dumpfile);
+			char *dumpfile, int fromtime);
 
 #ifndef AFS_NT40_ENV
 #include "AFS_component_version_number.c"
@@ -176,6 +176,8 @@
     struct DiskPartition64 *partP = NULL;
     char name1[128];
     char tmpPartName[20];
+    int fromtime = 0;
+    afs_int32 code;
 
 
 #ifndef AFS_NT40_ENV
@@ -195,6 +197,14 @@
 	fileName = ti->data;
     if ((ti = as->parms[3].items))
 	verbose = 1;
+    if (as->parms[4].items && strcmp(as->parms[4].items->data, "0")) {
+	code = ktime_DateToInt32(as->parms[4].items->data, &fromtime);
+	if (code) {
+	    fprintf(STDERR, "failed to parse date '%s' (error=%d))\n",
+		as->parms[4].items->data, code);
+		return code;
+	}
+    }
 
     DInit(10);
 
@@ -231,13 +241,13 @@
 	exit(1);
     }
 
-    (void)afs_snprintf(name1, sizeof name1, VFORMAT, (unsigned long)volumeId);
-    HandleVolume(partP, name1, fileName);
+    (void)afs_snprintf(name1, sizeof name1, VFORMAT, afs_cast_uint32(volumeId));
+    HandleVolume(partP, name1, fileName, fromtime);
     return 0;
 }
 
 void
-HandleVolume(struct DiskPartition64 *dp, char *name, char *filename)
+HandleVolume(struct DiskPartition64 *dp, char *name, char *filename, int fromtime)
 {
     struct VolumeHeader header;
     struct VolumeDiskHeader diskHeader;
@@ -279,7 +289,7 @@
 	exit(1);
     }
 
-    DoMyVolDump(vp, dp, filename);
+    DoMyVolDump(vp, dp, filename, fromtime);
 }
 
 
@@ -298,6 +308,7 @@
     cmd_AddParm(ts, "-file", CMD_LIST, CMD_OPTIONAL, "Dump filename");
     cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL,
 		"Trace dump progress (very verbose)");
+    cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
     code = cmd_Dispatch(argc, argv);
     return code;
 }
@@ -831,17 +842,16 @@
 
 
 static void
-DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, char *dumpfile)
+DoMyVolDump(Volume * vp, struct DiskPartition64 *dp, char *dumpfile, int fromtime)
 {
     int code = 0;
-    int fromtime = 0;
     int dumpAllDirs = 0;
     int dumpfd = 0;
 
     if (dumpfile) {
 	unlink(dumpfile);
 	dumpfd =
-	    open(dumpfile, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
+	    afs_open(dumpfile, O_CREAT | O_WRONLY | O_TRUNC, S_IRUSR | S_IWUSR);
 	if (dumpfd < 0) {
 	    fprintf(stderr, "Failed to open dump file! Exiting.\n");
 	    exit(1);
--- openafs/src/volser/volmain.c:1.18.2.15	Sun Aug 24 21:15:18 2008
+++ openafs/src/volser/volmain.c	Wed Dec 17 13:16:28 2008
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/volser/volmain.c,v 1.18.2.16 2008/12/17 18:16:28 shadow Exp $");
 
 #include <sys/types.h>
 #include <string.h>
@@ -311,35 +311,10 @@
 		lwps = MAXLWP;
 	    }
 	} else if (strcmp(argv[code], "-auditlog") == 0) {
-	    int tempfd, flags;
-	    FILE *auditout;
-	    char oldName[MAXPATHLEN];
 	    char *fileName = argv[++code];
 
-#ifndef AFS_NT40_ENV
-	    struct stat statbuf;
-	    
-	    if ((lstat(fileName, &statbuf) == 0) 
-		&& (S_ISFIFO(statbuf.st_mode))) {
-		flags = O_WRONLY | O_NONBLOCK;
-	    } else 
-#endif
-	    {
-		strcpy(oldName, fileName);
-		strcat(oldName, ".old");
-		renamefile(fileName, oldName);
-		flags = O_WRONLY | O_TRUNC | O_CREAT;
-	    }
-	    tempfd = open(fileName, flags, 0666);
-	    if (tempfd > -1) {
-		auditout = fdopen(tempfd, "a");
-		if (auditout) {
-		    osi_audit_file(auditout);
-		    osi_audit(VS_StartEvent, 0, AUD_END);
-		} else
-		    printf("Warning: auditlog %s not writable, ignored.\n", fileName);
-	    } else
-		printf("Warning: auditlog %s not writable, ignored.\n", fileName);
+            osi_audit_file(fileName);
+            osi_audit(VS_StartEvent, 0, AUD_END);
 	} else if (strcmp(argv[code], "-nojumbo") == 0) {
 	    rxJumbograms = 0;
 	} else if (strcmp(argv[code], "-jumbo") == 0) {
--- openafs/src/volser/volprocs.c:1.34.2.17	Sat Aug 16 16:07:57 2008
+++ openafs/src/volser/volprocs.c	Mon Mar 23 14:19:57 2009
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/volser/volprocs.c,v 1.34.2.18 2009/03/23 18:19:57 shadow Exp $");
 
 #include <stdio.h>
 #include <sys/types.h>
@@ -152,7 +152,7 @@
     if (asize < 18)
 	return -1;
     /* It's better using the Generic VFORMAT since otherwise we have to make changes to too many places... The 14 char limitation in names hits us again in AIX; print in field of 9 digits (still 10 for the rest), right justified with 0 padding */
-    (void)afs_snprintf(aname, asize, VFORMAT, (unsigned long)avol);
+    (void)afs_snprintf(aname, asize, VFORMAT, afs_cast_uint32(avol));
     return 0;
 }
 
--- openafs/src/volser/vos.c:1.40.2.27	Sat Aug 16 15:56:25 2008
+++ openafs/src/volser/vos.c	Mon Mar 23 14:19:57 2009
@@ -11,7 +11,7 @@
 #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 $");
+    ("$Header: /cvs/openafs/src/volser/vos.c,v 1.40.2.29 2009/03/23 18:19:57 shadow Exp $");
 
 #include <sys/types.h>
 #include <string.h>
@@ -505,7 +505,7 @@
 		*totalOK += 1;
 	    } else {
 		fprintf(STDOUT, "Off-line");
-		*totalNotOK++;
+		*totalNotOK += 1;
 	    }
 	    if (pntr->needsSalvaged == 1)
 		fprintf(STDOUT, "**needs salvage**");
@@ -546,13 +546,13 @@
 	    qPut(&busyHead, pntr->volid);
 	    if (disp)
 		fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-			(unsigned long)pntr->volid);
+			afs_cast_uint32(pntr->volid));
 	} else {
 	    *totalNotOK += 1;
 	    qPut(&notokHead, pntr->volid);
 	    if (disp)
 		fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-			(unsigned long)pntr->volid);
+			afs_cast_uint32(pntr->volid));
 	}
 	fprintf(STDOUT, "\n");
     } else {			/* default listing */
@@ -581,13 +581,13 @@
 	    qPut(&busyHead, pntr->volid);
 	    if (disp)
 		fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-			(unsigned long)pntr->volid);
+			afs_cast_uint32(pntr->volid));
 	} else {
 	    *totalNotOK += 1;
 	    qPut(&notokHead, pntr->volid);
 	    if (disp)
 		fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-			(unsigned long)pntr->volid);
+			afs_cast_uint32(pntr->volid));
 	}
     }
 }
@@ -776,14 +776,14 @@
 	    qPut(&busyHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	} /*Busy volume */
 	else {
 	    (*a_totalNotOKP)++;
 	    qPut(&notokHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	}			/*Screwed volume */
 	fprintf(STDOUT, "\n");
     } /*Long listing */
@@ -815,14 +815,14 @@
 	    qPut(&busyHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	} /*Busy volume */
 	else {
 	    (*a_totalNotOKP)++;
 	    qPut(&notokHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	}			/*Screwed volume */
     }				/*Default listing */
 }				/*XDisplayFormat */
@@ -977,14 +977,14 @@
 	    qPut(&busyHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "BUSY_VOL\t%lu\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	} /*Busy volume */
 	else {
 	    (*a_totalNotOKP)++;
 	    qPut(&notokHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	}			/*Screwed volume */
     } /*Long listing */
     else {
@@ -1014,14 +1014,14 @@
 	    qPut(&busyHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "VOLUME_BUSY\t%lu\n",
-			(unsigned long)a_xInfoP->volid);
+			afs_cast_uint32(a_xInfoP->volid));
 	} /*Busy volume */
 	else {
 	    (*a_totalNotOKP)++;
 	    qPut(&notokHead, a_xInfoP->volid);
 	    if (a_showProblems)
 		fprintf(STDOUT, "COULD_NOT_ATTACH_VOLUME\t%lu\n",
-			(unsigned long)a_xInfoP->volid);
+		        afs_cast_uint32(a_xInfoP->volid));
 	}			/*Screwed volume */
     }				/*Default listing */
 }				/*XDisplayFormat */
@@ -1147,14 +1147,14 @@
 	while (busyHead.count) {
 	    qGet(&busyHead, &volid);
 	    fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	}
     }
     if (totalNotOK) {
 	while (notokHead.count) {
 	    qGet(&notokHead, &volid);
 	    fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	}
     }
     if (!quiet) {
@@ -1235,14 +1235,14 @@
 	while (busyHead.count) {
 	    qGet(&busyHead, &volid);
 	    fprintf(STDOUT, "**** Volume %lu is busy ****\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	}
     }
     if (totalNotOK) {
 	while (notokHead.count) {
 	    qGet(&notokHead, &volid);
 	    fprintf(STDOUT, "**** Could not attach volume %lu ****\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	}
     }
 
@@ -1328,14 +1328,14 @@
 	while (busyHead.count) {
 	    qGet(&busyHead, &volid);
 	    fprintf(STDOUT, "BUSY_VOL\t%lu\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	}
     }
     if (totalNotOK) {
 	while (notokHead.count) {
 	    qGet(&notokHead, &volid);
 	    fprintf(STDOUT, "COULD_NOT_ATTACH\t%lu\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	}
     }
 
@@ -1556,14 +1556,14 @@
 
     if (verbose) {
 	fprintf(STDOUT, "Fetching VLDB entry for %lu .. ",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	fflush(STDOUT);
     }
     vcode = VLDB_GetEntryByID(volid, -1, &entry);
     if (vcode) {
 	fprintf(STDERR,
 		"Could not fetch the entry for volume number %lu from VLDB \n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	return (vcode);
     }
     if (verbose)
@@ -1705,7 +1705,7 @@
     if (code) {
 	fprintf(STDERR,
 		"Could not fetch the entry for volume number %lu from VLDB \n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	return (code);
     }
     MapHostToNetwork(&entry);
@@ -1737,7 +1737,7 @@
     if (code)
 	fprintf(STDERR,
 		"Could not update volume info fields for volume number %lu\n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
     return (code);
 }
 
@@ -1949,7 +1949,7 @@
     }
     MapPartIdIntoName(pnum, part);
     fprintf(STDOUT, "Volume %lu created on partition %s of %s\n",
-	    (unsigned long)volid, part, as->parms[0].items->data);
+	    afs_cast_uint32(volid), part, as->parms[0].items->data);
 
     return 0;
 }
@@ -2035,7 +2035,7 @@
 	if (code) {
 	    fprintf(STDERR,
 		    "Could not fetch the entry for volume %lu from VLDB\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	    PrintError("", code);
 	    return (code);
 	}
@@ -2093,7 +2093,7 @@
 
     MapPartIdIntoName(partition, pname);
     fprintf(STDOUT, "Volume %lu on partition %s server %s deleted\n",
-	    (unsigned long)volid, pname, hostutil_GetNameByINet(server));
+	    afs_cast_uint32(volid), pname, hostutil_GetNameByINet(server));
     return 0;
 }
 
@@ -2188,16 +2188,16 @@
     code = UV_ListOneVolume(fromserver, frompart, volid, &p);
     if (code) {
 	fprintf(STDERR, "vos:cannot access volume %lu\n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	exit(1);
     }
     if (TESTM)
-	fprintf(STDOUT, "volume %lu size %d\n", (unsigned long)volid,
+	fprintf(STDOUT, "volume %lu size %d\n", afs_cast_uint32(volid),
 		p->size);
     if (partition.free <= p->size) {
 	fprintf(STDERR,
 		"vos: no space on target partition %s to move volume %lu\n",
-		toPartName, (unsigned long)volid);
+		toPartName, afs_cast_uint32(volid));
 	free(p);
 	exit(1);
     }
@@ -2219,7 +2219,7 @@
     MapPartIdIntoName(topart, toPartName);
     MapPartIdIntoName(frompart, fromPartName);
     fprintf(STDOUT, "Volume %lu moved from %s %s to %s %s \n",
-	    (unsigned long)volid, as->parms[1].items->data, fromPartName,
+	    afs_cast_uint32(volid), as->parms[1].items->data, fromPartName,
 	    as->parms[3].items->data, toPartName);
 
     return 0;
@@ -2339,14 +2339,14 @@
     code = UV_ListOneVolume(fromserver, frompart, volid, &p);
     if (code) {
 	fprintf(STDERR, "vos:cannot access volume %lu\n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	exit(1);
     }
 
     if (partition.free <= p->size) {
 	fprintf(STDERR,
 		"vos: no space on target partition %s to copy volume %lu\n",
-		toPartName, (unsigned long)volid);
+		toPartName, afs_cast_uint32(volid));
 	free(p);
 	exit(1);
     }
@@ -2364,7 +2364,7 @@
     MapPartIdIntoName(topart, toPartName);
     MapPartIdIntoName(frompart, fromPartName);
     fprintf(STDOUT, "Volume %lu copied from %s %s to %s on %s %s \n",
-	    (unsigned long)volid, as->parms[1].items->data, fromPartName,
+	    afs_cast_uint32(volid), as->parms[1].items->data, fromPartName,
 	    tovolume, as->parms[4].items->data, toPartName);
 
     return 0;
@@ -2464,7 +2464,7 @@
 	code = UV_ListOneVolume(fromserver, frompart, volid, &p);
 	if (code) {
 	    fprintf(STDERR, "vos:cannot access volume %lu\n",
-		(unsigned long)volid);
+		    afs_cast_uint32(volid));
 	    exit(1);
 	}
 	strcpy(toVolName, p->name);
@@ -2525,7 +2525,7 @@
 	code = UV_ListOneVolume(fromserver, frompart, volid, &p);
 	if (code) {
 	    fprintf(STDERR, "vos:cannot access volume %lu\n",
-		(unsigned long)volid);
+		    afs_cast_uint32(volid));
 	    exit(1);
 	}
     }
@@ -2540,7 +2540,7 @@
     if (partition.free <= p->size) {
 	fprintf(STDERR,
 		"vos: no space on target partition %s to copy volume %lu\n",
-		toPartName, (unsigned long)volid);
+		toPartName, afs_cast_uint32(volid));
 	free(p);
 	if (q) free(q);
 	exit(1);
@@ -2560,7 +2560,7 @@
     MapPartIdIntoName(topart, toPartName);
     MapPartIdIntoName(frompart, fromPartName);
     fprintf(STDOUT, "Volume %lu shadowed from %s %s to %s %s \n",
-	    (unsigned long)volid, as->parms[1].items->data, fromPartName,
+	    afs_cast_uint32(volid), as->parms[1].items->data, fromPartName,
 	    as->parms[3].items->data, toPartName);
 
     return 0;
@@ -2730,7 +2730,7 @@
 	if (!code) {
 	    fprintf(STDERR,
 		    "FATAL ERROR: backup volume %lu exists on server %lu\n",
-		    (unsigned long)buvolid, (unsigned long)buserver);
+		    afs_cast_uint32(buvolid), (unsigned long)buserver);
 	    exit(1);
 	}
     }
@@ -3124,7 +3124,7 @@
 	    if (vol_elsewhere) {
 		fprintf(STDERR,
 			"%s volume %lu already exists on a different server/part; not allowed\n",
-			readonly ? "RO" : "RW", (unsigned long)avolid);
+			readonly ? "RO" : "RW", afs_cast_uint32(avolid));
 		exit(1);
 	    }
 	}
@@ -3896,7 +3896,7 @@
 	    backupid = entry.volumeId[BACKVOL];
 	fprintf(STDERR,
 		"Warning: Entry for volume number %lu exists in VLDB (but we're zapping it anyway!)\n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
     }
     if (zapbackupid) {
 	volintInfo *pntr = (volintInfo *) 0;
@@ -3917,7 +3917,7 @@
 		exit(1);
 	    }
 	    fprintf(STDOUT, "Backup Volume %lu deleted\n",
-		    (unsigned long)backupid);
+		    afs_cast_uint32(backupid));
 	}
     }
     code = UV_VolumeZap(server, part, volid);
@@ -3925,7 +3925,7 @@
 	PrintDiagnostics("zap", code);
 	exit(1);
     }
-    fprintf(STDOUT, "Volume %lu deleted\n", (unsigned long)volid);
+    fprintf(STDOUT, "Volume %lu deleted\n", afs_cast_uint32(volid));
 
     return 0;
 }
@@ -4092,7 +4092,7 @@
     if (vcode) {
 	fprintf(STDERR,
 		"Could not fetch the entry for volume %lu from VLDB \n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	PrintError("", vcode);
 	return (vcode);
     }
@@ -4107,7 +4107,7 @@
 	if (index == -1) {
 	    fprintf(STDERR,
 		    "RO volume is not found in VLDB entry for volume %lu\n",
-		    (unsigned long)volid);
+		    afs_cast_uint32(volid));
 	    return -1;
 	}
 
@@ -4120,7 +4120,7 @@
     if (index == -1) {
 	fprintf(STDERR,
 		"RW Volume is not found in VLDB entry for volume %lu\n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	return -1;
     }
     if (volid == rentry->volumeId[RWVOL]) {
@@ -4137,7 +4137,7 @@
     }
     fprintf(STDERR,
             "unexpected volume type for volume %lu\n",
-            (unsigned long)volid);
+            afs_cast_uint32(volid));
     return -1;
 }
 
@@ -4939,7 +4939,7 @@
     if (totalE)
 	fprintf(STDOUT,
 		"Could not lock %lu VLDB entries of %lu locked entries\n",
-		(unsigned long)totalE, (unsigned long)nentries);
+		afs_cast_uint32(totalE), (unsigned long)nentries);
     else {
 	if (as->parms[0].items) {
 	    fprintf(STDOUT,
@@ -5406,7 +5406,7 @@
     if (vcode) {
 	fprintf(STDERR,
 		"Could not fetch the entry for volume %lu from VLDB\n",
-		(unsigned long)volid);
+		afs_cast_uint32(volid));
 	PrintError("convertROtoRW", code);
 	return vcode;
     }
@@ -5473,7 +5473,7 @@
     if (code) {
 	fprintf(STDERR,
 		"Converting RO volume %lu to RW volume failed with code %d\n",
-		(unsigned long)volid, code);
+		afs_cast_uint32(volid), code);
 	PrintError("convertROtoRW ", code);
 	return -1;
     }
only in patch2:
--- openafs/src/afs/VNOPS/afs_vnop_lookup.c	26 Aug 2008 14:02:14 -0000	1.50.2.22
+++ openafs/src/afs/VNOPS/afs_vnop_lookup.c	4 Apr 2009 12:32:41 -0000
@@ -538,8 +538,6 @@
     int nskip;			/* # of slots in the LRU queue to skip */
     struct vcache *lruvcp;	/* vcache ptr of our goal pos in LRU queue */
     struct dcache *dcp;		/* chunk containing the dir block */
-    char *statMemp;		/* status memory block */
-    char *cbfMemp;		/* callback and fid memory block */
     afs_size_t temp;		/* temp for holding chunk length, &c. */
     struct AFSFid *fidsp;	/* file IDs were collecting */
     struct AFSCallBack *cbsp;	/* call back pointers */
@@ -597,13 +595,11 @@
      * one for fids and callbacks, and one for stat info.  Well set
      * up our pointers to the memory from there, too.
      */
-    statMemp = osi_AllocLargeSpace(nentries * sizeof(AFSFetchStatus));
-    statsp = (struct AFSFetchStatus *)statMemp;
-    cbfMemp =
-	osi_AllocLargeSpace(nentries *
-			    (sizeof(AFSCallBack) + sizeof(AFSFid)));
-    fidsp = (AFSFid *) cbfMemp;
-    cbsp = (AFSCallBack *) (cbfMemp + nentries * sizeof(AFSFid));
+    statsp = (AFSFetchStatus *) 
+	    osi_Alloc(AFSCBMAX * sizeof(AFSFetchStatus));
+    fidsp = (AFSFid *) osi_AllocLargeSpace(nentries * sizeof(AFSFid));
+    cbsp = (AFSCallBack *) 
+	    osi_Alloc(AFSCBMAX * sizeof(AFSCallBack));
 
     /* next, we must iterate over the directory, starting from the specified
      * cookie offset (dirCookie), and counting out nentries file entries.
@@ -1081,7 +1077,7 @@
 	afs_PutVolume(volp, READ_LOCK);
 
     /* If we did the InlineBulk RPC pull out the return code */
-    if (inlinebulk) {
+    if (inlinebulk && code == 0) {
 	if ((&statsp[0])->errorCode) {
 	    afs_Analyze(tcp, (&statsp[0])->errorCode, &adp->fid, areqp,
 			AFS_STATS_FS_RPCIDX_BULKSTATUS, SHARED_LOCK, NULL);
@@ -1091,8 +1087,9 @@
 	code = 0;
     }
   done2:
-    osi_FreeLargeSpace(statMemp);
-    osi_FreeLargeSpace(cbfMemp);
+    osi_FreeLargeSpace((char *)fidsp);
+    osi_Free((char *)statsp, AFSCBMAX * sizeof(AFSFetchStatus));
+    osi_Free((char *)cbsp, AFSCBMAX * sizeof(AFSCallBack));
     return code;
 }
 
only in patch2:
--- openafs/src/sys/rmtsysc.c	28 Nov 2007 05:08:11 -0000	1.11.2.5
+++ openafs/src/sys/rmtsysc.c	4 Apr 2009 12:32:41 -0000
@@ -241,8 +241,14 @@
     InData.rmtbulk_len = data->in_size;
     InData.rmtbulk_val = inbuffer;
     inparam_conversion(cmd, InData.rmtbulk_val, 0);
-    OutData.rmtbulk_len = data->out_size;
-    OutData.rmtbulk_val = data->out;
+
+    OutData.rmtbulk_len = MAXBUFFERLEN * sizeof(*OutData.rmtbulk_val);
+    OutData.rmtbulk_val = malloc(OutData.rmtbulk_len); 
+    if (!OutData.rmtbulk_val) {
+	free(inbuffer);
+	return -1;
+    }
+
     /* We always need to pass absolute pathnames to the remote pioctl since we
      * lose the current directory value when doing an rpc call. Below we
      * prepend the current absolute path directory, if the name is relative */
@@ -279,8 +285,15 @@
     if (!errorcode) {
 	/* Do the conversions back to the host order; store the results back
 	 * on the same buffer */
-	outparam_conversion(cmd, OutData.rmtbulk_val, 1);
+	if (data->out_size < OutData.rmtbulk_len) {
+	    errno = EINVAL;
+	    errorcode = -1;
+	} else {
+	    memcpy(data->out, OutData.rmtbulk_val, data->out_size);
+	    outparam_conversion(cmd, data->out, 1);
+	}
     }
+    free(OutData.rmtbulk_val);
     free(inbuffer);
     return errorcode;
 }
