diff --git a/.gitignore b/.gitignore
index cfafcedab..0432c0083 100644
--- a/.gitignore
+++ b/.gitignore
@@ -63,7 +63,6 @@ config.log
 
 # Destination build directories
 /alpha_nbsd*
-/alpha_dux*
 /amd64_linux*
 /amd64_fsbd*
 /amd64_nbsd*
diff --git a/CODING b/CODING
index fe6443157..bff3c927c 100644
--- a/CODING
+++ b/CODING
@@ -115,6 +115,47 @@ Instead of:
 	    do_something();
 	}
 
+In switch statements, to fall through from one case statement to another, use
+AFS_FALLTHROUGH to mark the intentional fall through.  Do not use fall through
+comments (e.g. /* fallthrough */), as some compilers do not recognize them and
+will flag the case statement with an implied fallthrough warning.
+
+Use:
+
+    switch (x) {
+    case 1:
+        do_something();
+        AFS_FALLTHROUGH;
+    case 2:
+        do_something_else();
+        AFS_FALLTHROUGH;
+    default:
+        do_some_action();
+    }
+
+Instead of using fallthrough comments:
+
+    switch (x) {
+    case 1:
+        do_something();
+        /* fallthrough */
+    case 2:
+        do_something_else();
+        /* fallthrough */
+    default:
+        do_some_action();
+    }
+
+Or not marking the fall through:
+
+   switch (x) {
+    case 1:
+        do_something();
+    case 2:
+        do_something_else();
+    default:
+        do_some_action();
+    }
 
 Dependencies required to build OpenAFS from source
 --------------------------------------------------
@@ -276,7 +317,10 @@ If you add a new warning inhibition, please also add it to the list below.
 
 Inhibited warnings
 ------------------
-
+uss/lex.i            : fallthrough   : clang fallthrough, flex generated code
+comerr/et_lex.lex.l  : fallthrough   : clang fallthrough, flex generated code
+                                       pragma set to ignored where included in
+                                       error_table.y
 afs/afs_syscall.c    : old-style
 		     : strict-proto
 		     : all (ukernel) : syscall pointer issues
@@ -296,4 +340,8 @@ libadmin/samples/rxstat_query_process.c : all : util_RPCStatsStateGet types
 libadmin/test/client.c : all         : util_RPCStatsStateGet types
 ubik/ubikclient.c    : strict-protos : ubik_Call
 volser/vol-dump.c    : format        : afs_sfsize_t
-
+rxkad/ticket5.c      : format-truncation : inside included file v5der.c in the
+                                       function _heim_time2generalizedtime, the
+                                       two snprintf calls raise
+                                       format-truncation warnings due to the
+                                       arithmetic on tm_year and tm_mon fields
\ No newline at end of file
diff --git a/CONTRIBUTING b/CONTRIBUTING
index ec28eb117..c07a32ede 100644
--- a/CONTRIBUTING
+++ b/CONTRIBUTING
@@ -3,12 +3,13 @@ OPENAFS CONTRIBUTOR CODE OF CONDUCT
 
 As contributors and maintainers of this project, and in the interest of fostering an open and welcoming community, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
 
-We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, religion, or nationality.
+We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, ethnicity, age, religion, or nationality.
 
 Examples of unacceptable behavior by participants include:
 
     The use of sexualized language or imagery
     Personal attacks
+    Racism
     Trolling or insulting/derogatory comments
     Public or private harassment
     Publishing other's private information, such as physical or electronic addresses, without explicit permission
diff --git a/INSTALL b/INSTALL
index 3d802a72d..f9b316632 100644
--- a/INSTALL
+++ b/INSTALL
@@ -30,7 +30,6 @@ A  Configuring
       A directory will be automatically created for binaries to be written
       into with this name when you build.
 
-      alpha_dux40, alpha_dux50, alpha_dux51 (client does not work)
       alpha_linux26
       alpha_nbsd15, alpha_nbsd16
       amd64_fbsd_80, amd64_fbsd_81, amd64_fbsd_82, amd64_fbsd_83,
@@ -38,7 +37,7 @@ A  Configuring
          amd64_fbsd_93, amd64_fbsd_100, amd64_fbsd_101
       amd64_linux26
       amd64_nbsd20, amd64_nbsd30, amd64_nbsd40
-      arm_linux26
+      arm_linux26, arm64_linux26
       hp_ux11i, hp_ux110, hp_ux1123 (See notes below for information on
          getting missing header)
       hp_ux102 (Client port possible, but db servers and utilities work)
@@ -203,9 +202,7 @@ D  Linux Notes
    last kernel you built for, the previous kernel module will be
    overwritten.
 
-   The Linux 2.4 series (and older) are no longer supported. The OpenAFS 1.6
-   series of releases are the last ones supporting those old kernels and in
-   particular their LinuxThreads.
+   The minimum supported Linux kernel is 2.6.18.
 
 E  HP-UX 11.0 Notes
 
@@ -218,7 +215,8 @@ E  HP-UX 11.0 Notes
 F  OpenBSD Notes
 
    If you need to run regen.sh to make the configure script, you should
-   first install autoconf-2.59, then setenv AUTOCONF_VERSION 2.59.
+   set the environment variable AUTOCONF_VERSION to the installed autoconf
+   version, e.g. 'setenv AUTOCONF_VERSION 2.64' (see 'J' below).
 
    You need kernel source installed to build OpenAFS.  Use the
    --with-bsd-kernel-headers= configure option if your kernel source is
@@ -236,11 +234,10 @@ F  OpenBSD Notes
 
 G  FreeBSD Notes
 
-   The FreeBSD client supports FreeBSD 8.x and later, but does not receive
-   regular testing on versions older than FreeBSD 9.x at this time.  Only
-   the amd64 and i386 architectures are supported, but it should not be
-   hard to port to other processors if they are already supported under
-   another operating system.
+   The FreeBSD client supports FreeBSD 10.x and later.  Only the amd64
+   and i386 architectures are supported, but it should not be hard to
+   port to other processors if they are already supported under another
+   operating system.
 
    You need kernel source installed to build OpenAFS.  Use the
    --with-bsd-kernel-headers= configure option if your kernel source is
@@ -563,3 +560,22 @@ I  Other configure options
 
    YFLAGS
        Additional flags to pass to yacc.
+
+J  Creating 'configure'
+
+   Normally you can use the configure script provided with the OpenAFS release
+   tar file, but if you are patching the autoconf logic or building directly
+   from source pulled from the git repository you may need to (re-)generate
+   the configure script.
+
+   To create the configure script autoconf-2.64 or later and libtool-1.9b or
+   later are needed.
+
+   Running the script 'regen.sh' creates the configure script.  In addition
+   to creating the configure script, regen.sh will also, by default, build
+   the man pages, which requires the pod2man utility. Use 'regen.sh -q' to
+   skip building the man pages.
+
+   It is possible to create the configure script on one system to be used on
+   another. Ensure that the files created by 'regen.sh' are copied to the
+   target system.
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
index 92528897a..b15979444 100644
--- a/LICENSE
+++ b/LICENSE
@@ -415,3 +415,18 @@ src/cf/lib-pathname.m4 are covered by the following license:
   THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
   WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
   MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+====================================================
+
+The file src/cf/ax_gcc_func_attribute.m4 and the files under
+src/external/autoconf-archive/m4/ are covered by the following license:
+
+  Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+  Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+  Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
+  Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+
+  Copying and distribution of this file, with or without modification, are
+  permitted in any medium without royalty provided the copyright notice
+  and this notice are preserved.  This file is offered as-is, without any
+  warranty.
diff --git a/Makefile.in b/Makefile.in
index 064d316aa..0c73bec18 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -57,6 +57,7 @@ generated: force buildtools
 	+${COMPILE_PART1} fsint ${COMPILE_GENERATED}
 	+${COMPILE_PART1} kauth ${COMPILE_GENERATED}
 	+${COMPILE_PART1} ptserver ${COMPILE_GENERATED}
+	+${COMPILE_PART1} rxgk ${COMPILE_GENERATED}
 	+${COMPILE_PART1} rxkad ${COMPILE_GENERATED}
 	+${COMPILE_PART1} rxstat ${COMPILE_GENERATED}
 	+${COMPILE_PART1} sys ${COMPILE_GENERATED}
@@ -157,7 +158,7 @@ util: opr $(DIR_roken) procmgmt hcrypto lwp
 libafscp: util afs volser vlserver rx auth fsint
 	+${COMPILE_PART1} libafscp ${COMPILE_PART2}
 
-audit: util rx rxkad fsint
+audit: util rx rxkad fsint bubasics
 	+${COMPILE_PART1} audit ${COMPILE_PART2} #TODO
 
 comerr: util $(DIR_roken)
@@ -186,14 +187,14 @@ roken: config
 rxgen: $(DIR_roken) config
 	+${COMPILE_PART1} rxgen ${COMPILE_PART2}
 
-rx: config lwp rxgen rx_depinstall util
+rx: config lwp rxgen rx_depinstall util rxgk_depinstall
 	+${COMPILE_PART1} rx ${COMPILE_PART2}
 
 rxstat: rx rxstat_depinstall
 	+${COMPILE_PART1} rxstat ${COMPILE_PART2}
 
 rxtests: rxdebug
-rxdebug: rx sys
+rxdebug: rx sys rxgk
 	+${COMPILE_PART1} rxdebug ${COMPILE_PART2}
 
 fsint: cmd comerr rxgen rx lwp fsint_depinstall
@@ -216,10 +217,18 @@ afs: config export comerr afs_depinstall
 sys: cmd comerr afs hcrypto rx rxstat fsint sys_depinstall
 	+${COMPILE_PART1} sys ${COMPILE_PART2}
 
+rxgk: cmd comerr hcrypto rfc3961 rx rxgk_depinstall
+	+set -x; \
+	if test "@BUILD_RXGK@" = "yes"; then \
+		${COMPILE_PART1} rxgk ${COMPILE_PART2} ; \
+	else \
+		echo Skipping rxgk for ${SYS_NAME} ; \
+	fi
+
 rxkad: cmd comerr hcrypto rfc3961 rx rxkad_depinstall
 	+${COMPILE_PART1} rxkad ${COMPILE_PART2}
 
-auth: cmd comerr hcrypto lwp rx rxkad audit sys auth_depinstall
+auth: cmd comerr hcrypto lwp rx rxkad audit sys auth_depinstall rxgk
 	+${COMPILE_PART1} auth ${COMPILE_PART2}
 
 ubik: cmd comerr auth ubik_depinstall sys
@@ -227,7 +236,7 @@ ubik: cmd comerr auth ubik_depinstall sys
 
 tubik: ubik libafsrpc libafsauthent
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
+	sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
 		${COMPILE_PART1} tubik ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building MT ubik for ${SYS_NAME} ;; \
@@ -240,7 +249,7 @@ ptserver: cmd comerr ubik cmd comerr auth audit ptserver_depinstall
 
 tptserver: cmd comerr ptserver tubik libafsrpc libafsauthent
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
+	sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
 		${COMPILE_PART1} tptserver ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building MT ptserver for ${SYS_NAME} ;; \
@@ -261,7 +270,7 @@ vol: cmd comerr dir afs $(DIR_roken)
 
 tsalvaged: vol libafsrpc libafsauthent cmd util
 	+case ${SYS_NAME} in \
-		alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[fn]bsd*|*_darwin_*) \
+		sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[fn]bsd*|*_darwin_*) \
 			${COMPILE_PART1} tsalvaged ${COMPILE_PART2} ;; \
 		*_darwin_*) \
 			${COMPILE_PART1} tsalvaged  ${COMPILE_PART2} ;; \
@@ -276,7 +285,7 @@ vlserver: cmd comerr vol audit vlserver_depinstall
 tvlserver: cmd comerr vol audit tubik libafsrpc libafsauthent \
 	tvlserver_depinstall
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
+	sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
 		${COMPILE_PART1} tvlserver ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building MT tvlserver for ${SYS_NAME} ;; \
@@ -288,7 +297,7 @@ viced: cmd comerr vlserver tvlserver libafsrpc libafsauthent audit
 
 dviced: cmd comerr viced vlserver tvlserver libafsrpc libafsauthent
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
+	sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
 		${COMPILE_PART1} dviced ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building DAFS viced for ${SYS_NAME} ;; \
@@ -299,7 +308,7 @@ volser: cmd comerr usd kauth vlserver audit
 
 tvolser: project viced usd libafsrpc libafsauthent volser
 	+@case ${SYS_NAME} in						\
-	*_darwin_*|alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*)   \
+	*_darwin_*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*)   \
 		${COMPILE_PART1} tvolser ${COMPILE_PART2} ;;            \
 	*)                                                              \
 		echo Not building MT volser for ${SYS_NAME} ;;          \
@@ -307,7 +316,7 @@ tvolser: project viced usd libafsrpc libafsauthent volser
 
 dvolser: project viced usd libafsrpc libafsauthent volser
 	+@case ${SYS_NAME} in						\
-	*_darwin_*|alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*)   \
+	*_darwin_*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*)   \
 		${COMPILE_PART1} dvolser ${COMPILE_PART2} ;;            \
 	*)                                                              \
 		echo Not building DAFS volser for ${SYS_NAME} ;;          \
@@ -407,6 +416,9 @@ lwp_depinstall: config
 rx_depinstall: config
 	+${COMPILE_PART1} rx ${COMPILE_DEPINSTALL}
 
+rxgk_depinstall: config comerr
+	+${COMPILE_PART1} rxgk ${COMPILE_DEPINSTALL}
+
 rxkad_depinstall: config comerr
 	+${COMPILE_PART1} rxkad ${COMPILE_DEPINSTALL}
 
@@ -519,7 +531,7 @@ butc: cmd comerr bubasics butm budb bucoord cmd rxgen rx
 
 tbutc: cmd comerr bubasics butm budb bucoord cmd butc libadmin
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*_darwin_*) \
+	sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*_darwin_*) \
 		${COMPILE_PART1} tbutc ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building MT butc for ${SYS_NAME} ;; \
@@ -530,7 +542,7 @@ budb: cmd comerr bubasics uss
 
 tbudb: budb tubik
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
+	sgi_*|sun*_5*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*|*_darwin_*) \
 		${COMPILE_PART1} tbudb ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building MT budb for ${SYS_NAME} ;; \
@@ -553,9 +565,9 @@ afsmonitor: cmd comerr gtx xstat
 tests: rxtests ubiktests rpctestlib viced
 
 # pthread based user space RX library
-libafsrpc: comerr fsint hcrypto lwp rx rxkad rxstat sys util
+libafsrpc: comerr fsint hcrypto lwp rx rxkad rxstat sys util rxgk
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*) \
+	sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*) \
 	${COMPILE_PART1} libafsrpc ${COMPILE_PART2} ;; \
 	*_darwin_[1-6][0-9]) \
 		echo Not building MT libafsrpc for ${SYS_NAME} ;; \
@@ -567,7 +579,7 @@ libafsrpc: comerr fsint hcrypto lwp rx rxkad rxstat sys util
 
 libafsauthent: audit auth kauth ubik util sys ptserver volser vlserver libafsrpc
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*) \
+	sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*|*[nof]bsd*) \
 	${COMPILE_PART1} libafsauthent ${COMPILE_PART2} ;; \
 	*_darwin_[1-6][0-9]) \
 		echo Not building MT libafsauthent for ${SYS_NAME} ;; \
@@ -594,7 +606,7 @@ libadmin_real:
 
 libadmin: libafsauthent bozo bubasics
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \
+	sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux11*|ia64_hpux*) \
 			$(MAKE) libadmin_real ;; \
 	*_darwin_[1-6][0-9]) \
 		echo Not building MT libadmin for ${SYS_NAME} ;; \
@@ -606,7 +618,7 @@ libadmin: libafsauthent bozo bubasics
 
 libjafs: libadmin
 	+case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110) \
+	sgi_*|sun4x_*|rs_aix*|*linux*|hp_ux110) \
 	${COMPILE_PART1} JAVA/libjafs  ${COMPILE_PART2} ;; \
 	*) \
 		echo Not building MT libjafs for ${SYS_NAME} ;; \
@@ -621,26 +633,36 @@ jafsadm: libjafsadm
 build_tools: config comerr rxgen
 	+${COMPILE_PART1} util ${COMPILE_PART2A} buildtools_clean
 
-finale: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ \
+finale_notest: project cmd comerr afsd butc tbutc tbudb @ENABLE_KERNEL_MODULE@ \
 	libuafs audit kauth log ptserver tptserver scout bu_utils ubik uss \
 	bozo @VFSCK@ volser tvolser tsalvaged dviced dvolser libafscp \
 	venus venustests update xstat afsmonitor rxdebug libafsrpc rfc3961 \
 	hcrypto libafsauthent libadmin man-pages tools platform kopenafs \
-	authtools $(DIR_roken)
+	authtools $(DIR_roken) rxgk
 	+${COMPILE_PART1} finale ${COMPILE_PART2}
 
-finale_nolibafs: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth \
+finale_nolibafs_notest: project cmd comerr afsd butc tbutc tbudb libuafs audit kauth \
 	log ptserver tptserver scout bu_utils ubik tubik uss bozo @VFSCK@ \
 	volser tvolser tsalvaged dviced dvolser libafscp venus venustests \
 	update xstat afsmonitor rxdebug libafsrpc rfc3961 hcrypto \
 	libafsauthent libadmin man-pages tools platform kopenafs \
-	authtools $(DIR_roken)
+	authtools $(DIR_roken) rxgk
 	+${COMPILE_PART1} finale ${COMPILE_PART2}
 
 rpctestlib: util fsint rx opr libafsrpc libafsauthent
 	+${TEST_PART1} rpctestlib  ${COMPILE_PART2}
 
-check test: finale
+finale: finale_notest test_build
+
+finale_nolibafs: finale_nolibafs_notest test_build_nolibafs
+
+test_build: finale_notest
+	cd tests && $(MAKE) all
+
+test_build_nolibafs: finale_nolibafs_notest
+	cd tests && $(MAKE) all
+
+check test: finale_notest
 	cd tests && $(MAKE) check
 
 force:
@@ -680,6 +702,7 @@ clean2:
 	-${COMPILE_PART1} export ${COMPILE_CLEAN}
 	-${COMPILE_PART1} afs ${COMPILE_CLEAN}
 	-${COMPILE_PART1} sys ${COMPILE_CLEAN}
+	-${COMPILE_PART1} rxgk ${COMPILE_CLEAN}
 	-${COMPILE_PART1} rxkad ${COMPILE_CLEAN}
 	-${COMPILE_PART1} auth ${COMPILE_CLEAN}
 	-${COMPILE_PART1} ubik ${COMPILE_CLEAN}
@@ -758,11 +781,16 @@ clean2:
 	-/bin/rm -rf libafs_tree ${SYS_NAME}
 
 dist:
-	mkdir -p packages
 	./build-tools/make-release --dir=packages HEAD
 
-srpm:
-	(cd packages && ../src/packaging/RedHat/makesrpm.pl *-src.tar.bz2 *-doc.tar.bz2)
+srpm: dist
+	./src/packaging/RedHat/makesrpm.pl --dir=packages \
+	  packages/openafs-*-src.tar.bz2 \
+	  packages/openafs-*-doc.tar.bz2
+
+rpm: srpm
+	rpmbuild --rebuild --define "_topdir @TOP_OBJDIR@/packages/rpmbuild" \
+	  packages/openafs-*.src.rpm
 
 dox:
 	if test "x$(DOXYGEN)" != "x"; then \
@@ -872,6 +900,7 @@ distclean: clean
 	src/rx/test/Makefile \
 	src/rxdebug/Makefile \
 	src/rxgen/Makefile \
+	src/rxgk/Makefile \
 	src/rxkad/Makefile \
 	src/rxkad/test/Makefile \
 	src/rxosd/Makefile \
diff --git a/NEWS b/NEWS
index 1c64059fc..8dd215374 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,602 @@
                        User-Visible OpenAFS Changes
 
+OpenAFS 1.9.0
+
+  All platforms
+
+    Introduce the rxgk Rx security class, initially limited to server-to-server
+    traffic and local keys (gerrit topic: rxgk-phase1).
+
+    Add options to the vos and pts commands for server-to-server rxgk support.
+
+    Add support to add and delete rxgk keys with asetkey.  Add support to
+    generate random keys with asetkey, which can be useful to create certain
+    types of rxgk keys.
+
+    Raise implementation-defined anti-DoS length limits for prdb-related XDR
+    array types, which were being reached at some sites (13838).
+
+    Bring "-setpag" functionality in klog to parity with aklog (14146).
+
+    Fix potential Rx hang when an incoming call must wait (14158).
+
+    Fix latent bug preventing RX_CONN_NAT_PING from working (13041).
+
+    Fix potential rx_connection leak in pthreaded programs (13042).
+
+    Avoid NatPing storm with many connections to the same server (14312).
+
+    Do not leave empty directories behind in the file server vice partition
+    when running the "vos zap -force" command (12879, 12839).
+
+    Make non-verbose "vos remsite" output output more readable (14127).
+
+    Display the usage of simple commands (commands without subcommands) when run
+    only with the -help option (10983).
+
+    Replace SOURCE-MAP with a README.md (14003).
+
+    Improve documentation of minimum required dependency versions (14305).
+
+    Remove unused definition of LINUX_PKGREL from configure.ac (14117).
+
+    Improve logging and diagnostic messages:
+      * Add a warning message to vos when performing an incremental volume
+        restore over an existing volume which is newer than the dump
+        volume (13251)
+      * Log the binding address and port during startup in the cache manager and
+        all of the server processes (13272)
+      * Improve volume server logging to provide better information during
+        volume restore failures (13252)
+      * Improved cache manager syslog tracing (11858)
+      * Improved database server logging to log important messages at the
+        default logging level, log information during database synchronizations,
+        and log diagnostic messages during recovery aborts (12617, 13079, 12618)
+      * Set a thread name for rx listener threads (13600)
+      * Avoid truncating authentication information in vlserver log
+        messages (13466)
+      * Log when ubik recovery aborts a running remote transaction (13862).
+
+    Fix warnings issued by static code analyzers:
+      * Fix possible undefined variable in disconnected mode (13207)
+      * Remove redundant conditionals (13158, 13157)
+      * Exit if out of memory while attempting to format command help
+        messages (13335)
+      * Fix possible undefined variable when reading old vldb formats (13755)
+
+    Assorted memory-handling fixes (13461, 12293, 13355, 13395, 13396, 13161,
+    13659, 13714, 13715, 13760, 13716, 13761).
+
+    Fix many (but not all) of the new warnings issued by recent versions of
+    gcc and clang (12987..12989, 13010, 13287, 13462..13464, 13467..13468,
+    13470..13476, 13494, 13660..13664, 13684, 13726, 13754, 14049, 14092,
+    14106, 14207, 14273, 14277, 14274, 14275, 14279, 14292, 14125).
+
+    Added unit tests for functions mapping vice partition to id (13176).
+
+    Fix issues resulting in parallel "make install" to fail (13786, 14137).
+
+    Updated libauth test program (13394).
+
+    General code cleanup; remove unused code or obsolete code, old comments,
+    or refactor for clarity
+    (12988, 13204, 13209, 13210, 13213, 13226, 13227, 13260, 13271, 13277,
+    13309, 13310, 13324, 13325, 13339, 13345, 13346, 13351, 13361, 13362, 13363,
+    13390, 13397, 13408, 13414, 13458, 13490, 13500, 13509, 13514, 13557, 13640,
+    13655, 13282, 13683, 13995, 14218, 14219, 14236, 14246, 14322, 14338).
+
+    Build system clean up and fixes
+    (12956, 12961, 12962, 12963, 12992, 12993, 12994, 13237, 13275, 13338,
+    13357, 13360, 13387, 13419, 13594, 13652, 14115, 14148..14150, 14132,
+    14133, 14135, 14153).
+
+  All server platforms
+
+    Improve database server logging by logging messages when and why a server
+    is marked as down (12616).
+
+    Log a warning message when starting server processes with no encryption
+    keys available (13911).
+
+    Fix use of triple-DES cell-wide keys for rxkad.krb5 (14203).
+
+    Remove redundant lseek system calls and use positional I/O in the database
+    servers to improve performance (12271, 12272).
+
+    Fix option parsing to enable parallel salvageserver operation (14201).
+
+    Fix an edge case where writes were errneously allowed on readonly
+    fileservers (13934).
+
+    Add an option to allow members of system:administrators to perform
+    write operations on otherwise readonly fileservers (13707).
+
+    Allow "vos rename" to be re-run to finish a previously interrupted
+    volume rename operation (13720).
+
+    Return errors for short reads during volume dumps instead of silently
+    padding with NUL bytes (14255).
+
+    Work around potential deadlocks when the salvageserver spawns a child
+    at the same time another thread is writing to the log (14239).
+
+    Do not overwrite the errno variable when logging certain database sendfile
+    errors (13263).
+
+    Avoid confusing log message ("Unable to create the volume") when
+    restoring over an existing volume (14208).
+
+    Fix vldb listing of created-but-not-released RO replicas (14154).
+
+    Avoid confusing "half-locked" state for interrupted volume renames (14157).
+
+    Prevent attempts to grow the VLDB past the maximum 2GB size (14180).
+
+    Fix a bug that prevented logging of discarded callbacks (14256).
+
+    Code migration to POSIX Threads (pthreads) from LWP.
+      * Convert upserver and upclient to pthreads (12754)
+      * Convert xstat libraries and related utilities to pthreads (12745, 12746,
+        12747, 12753, 13454, 13455)
+
+  All client platforms
+
+    Attempt to detect and report some common types of cache corruption
+    (13436, 13747, 13969, 14002).
+
+    Log a warning when the cache is "stressed" (almost full) to suggest
+    possible re-tuning (13255).
+
+    Require opt-in to use the historical/deprecated single-DES krb5
+    encryption types, which are being removed from krb5 distributions (13689).
+
+    Fix incorrect informational messages when the AFSCELL environment
+    variable is set (13371).
+
+    Assorted cleanup and microoptimizations (12655, 13254, 12656, 13253, 14241,
+    13256, 14254).
+
+    Tidy up the shutdown sequence, closing some memory leaks and not
+    generatin Rx traffic while Rx datastructures are being deconstructed
+    (13718, 13719).
+
+    Fix reading entries of historic vldb formats (13465).
+
+    Suppress warning about running unauthenticated for `bos -noauth` (14306).
+
+  Linux
+
+    Support upstream kernels through Linux 5.9.
+
+    Be more careful about overriding the current credentials for operations
+    on cache files, preventing spurious permission errors when systems like
+    AppArmor and SELinux are in use (13751, 14098).
+
+    Avoid panics from procfs when the kernel module is loaded but afsd is
+    not running (14093).
+
+    Improve ppc64le support (13980, 14046).
+
+    Improve RPM packaging (14114, 14116, 14266)
+
+  MacOS
+
+    Simplify background-move return-code processing (13280).
+
+    Support macOS Catalina (13935, 13936, 13668..13671, 13928, 14062, 14222).
+
+    Add OpenAFS.pkg to the list of files to be codesigned (14221).
+
+  Solaris
+
+    Remove references to (unspported) SunOS 4 (13506).
+
+    Build system fixes for parallel make on Solaris.
+
+    Support function attributes when building with recent versions of Solaris
+    compilers.
+
+    Fix many (but not all) of the compiler warnings when building on the Solaris
+    platform.
+
+    Add autoconf support for Studio 12.6 tools (13867).
+
+  FreeBSD
+
+    General improvements to VFS compliance.
+
+    Create destination kernel module directory when installing on
+    FreeBSD (13653, 13690)).
+
+    Add param.h files and sysnames for FreeBSD 11.2 (13534), 11.3 (13792),
+    and 12.1 (13982).
+
+    Fix fcntl-style locks by adapting to quirky historical behavior (12579).
+
+    Support kernels that use VIMAGE support at runtime, not just at
+    build-time (12580).
+
+    Change LWP stack strategy to avoid SIGBUS errors (13691).
+
+    Skip SIGBUS test (for reasons unrelated to the previous) (14145).
+
+
+OpenAFS 1.8.6
+
+  All platforms
+
+    * Address warnings and errors encountered when building OpenAFS with
+      modern compilers like gcc9 or recent clang (13727..45 13749..50 13756
+      13846 13879)
+
+    * Avoid some rare cases of Rx calls getting stuck in the incoming queue
+      (13892)
+
+    * Display the usage of simple commands (commands without subcommands) when
+      run only with the -help option (13894)
+
+    * Fix a memory leak in the cache manager and the fileserver while
+      processing "fs uuid" or "fs setcbaddr" (13899)
+
+    * Fix a memory leak when reopening krb local realms configuration (13900)
+
+    * Avoid possible crashes when freeing kerberos contexts (13902)
+
+  All server platforms
+
+    * Do not leave empty directories behind in the file server vice partition
+      when running the "vos zap -force" command (13897)
+
+    * Fix "vos zap -force" failures when the volume being zapped does not have
+      an entry in the fileserver's volume group cache (e.g., during fileserver
+      startup) (13896)
+
+    * Relax the length limits on some membership lists used in ptserver RPCs,
+      introduced in release 1.8.0 to prevent denial of service attacks, to
+      accommodate use cases of some larger existing sites (13844)
+
+    * Improved diagnostics and error messages (13898 13906..8 13938)
+
+    * Ensure that fileservers running in readonly mode actually reject all
+      write requests, but introduce a -admin-write switch allowing writes
+      by members of the system:administrators group (14018 14019)
+
+  All client platforms
+
+    * Require the -insecure_des switch to be passed to aklog and klog.krb5
+      to make them work with single-DES encryption types (13791)
+
+    * Avoid a panic due to a retryable error - retry in a background request
+      instead (13847)
+
+    * Avoid blocking other functions on the completion of some potentially
+      long-running RPCs issued by the server (13893)
+
+    * Fix a potential memory leak in "fs getserverprefs" when the pioctl fails
+      with E2BIG (13895)
+
+    * Avoid the local cache incorrectly reflecting the state of a file on the
+      fileserver after flushing large chunks of data to the server. This
+      issue was present on FreeBSD clients, but probably not Linux/Solaris
+      ones (13951) (RT #135041)
+
+    * After a VLDB lookup of a read-write volume already failed, don't bother
+      looking up corresponding read-only or backup volumes since those lookups
+      are bound to fail, in order to make the client more responsive and
+      avoid unnecessary load on the vlserver (13968)
+
+    * Allow a "vos rename" to succeed if the new volume name is the same as
+      that in the current VLDB, to make it possible to complete a previously
+      interrupted volume rename (14055)
+
+    * Allow processes which are sleeping due to PAG throttling to be killable
+      (13974).
+
+    * Fix set PAG failures due to signals (13975).
+
+  Linux clients
+
+    * Support mainline kernels up to and including 5.7 (14069 14094 14095
+      14209 14210)
+
+    * Make builds succeed with --enable-checking for mainline kernels
+      5.3-rc2 and later (13910)
+
+    * Avoid possible deadlocks (13748 13765)
+
+    * Fix build of libuafs on ppc64le (14104)
+
+    * Fix build on certain recent 32-bit distributions (14234) (RT #135084)
+
+  macOS
+
+    * Support building, packaging and notarization on macOS 10.15 "Catalina"
+      (14031..7 14068)
+
+  Microsoft Windows
+
+    * Build fixes (13848..52)
+
+OpenAFS 1.8.5
+
+All platforms
+
+    * Fix OPENAFS-SA-2019-001: information leakage in failed RPC output
+      Generated RPC handler routines ran output variables through XDR encoding
+      even when the call had failed and would shortly be aborted (and for
+      which uninitialized output variables is common); any complete packets
+      assembled in the process would be sent to the peer, leaking the contents
+      of the uninitialized memory in question.
+
+    * Fix OPENAFS-SA-2019-002: information leakage from uninitialized scalars
+      Generated RPC handler routines did not initialize output variables of
+      scalar (fixed-length) type, since they did not require dedicated logic to
+      free.  Such variables allocated on the stack could remain uninitialized
+      in some cases (including those affected by OPENAFS-SA-2019-001), and the
+      contents of uninitialized memory would be returned to the peer.
+
+All server platforms
+
+    * Fix OPENAFS-SA-2019-003: fix crash in database servers
+      The ubik debugging RPCs prioritize being fast and non-disruptive to
+      database operations over strict correctness, and do not adhere to the
+      usual locking protocol for data access.  A data race could cause a NULL
+      dereference if the second memory load was not optimized out by the
+      compiler.
+
+OpenAFS 1.8.4
+
+  All platforms
+
+    Build system updates to remove obsolete autoconf macros and remove missing
+    script warning during builds (13480, 13481, 13482, 13483, 13484, 13486,
+    13789, 13790).
+
+    Build system update to fix a conditional check in the pthread.m4 autoconf
+    file (13595)
+
+    Build system update to create the man3 subdirectory, fixing a
+    reported build failure (13535).
+
+    Remove the last reference to src/mcas in the documentation (13558).
+
+  All server platforms
+
+    Fix fileserver's parsing of the options -vlruthresh, -vlruinterval,
+    -vlrumax and -novbc (13680).
+
+    Fixes to make ptserver's behaviour when run in restricted mode consistent
+    with the documentation: Non-members of the system:administrators group
+    are no longer allowed to issue the adduser, setfields and delete pts
+    commands, and all members of system:administrators are now allowed to
+    issue pts commands in this mode, not just the admin principal (13686..88).
+
+  All client platforms
+
+    Fix missing Rx call clean-up after failing to read dcaches from a file
+    server (13511).
+
+    Fix an Rx call leak for calls aborted by a connection abort after the call
+    was initialized but before use (13517).
+
+    Remove the obsolete afs_xosi lock to remove unnecessary serialization of
+    VOP_GETATTR calls. This can lead to improved performance under heavy
+    workloads (13529).
+
+    Increase the size of the Directory Name Lookup Cache (DNLC) to improve
+    cache performance (13559).
+
+    Fix getting tokens for cells with a three character name (13679).
+
+    Avoid a misleading message about the cell being used when aklog is run
+    with the -cell parameter but the AFSCELL environment variable is set to
+    a different cell (13676).
+
+    Build system update to honor the CFLAGS environment variable when building
+    libuafs (13544).
+
+  Linux
+
+    Support for mainline kernels up to 5.3 (13787, 13789).
+
+    More fixes for improper use of ENOENT fixes to avoid incorrect use of linux
+    negative dentry cache, which can lead to false ENOENT errors (13542, 13543,
+    13590, 13692) (RT #134904).
+
+    Return errors instead of returning incomplete directory listings when the
+    directory objects are incomplete in the cache (13591).
+
+    Add ppc64le_linux26 sysname for the ppc64le architecture (13636, 13637,
+    13589).
+
+    Fix configure check for a kernel time function in order to build on
+    Linux 5.0 (13523).
+
+    RPM packaging update for RHEL8 adding a build requirement to ensure the
+    kernel module can be built from the SRPM (13563) (RT #134900).
+
+    On systemd based RHEL/Fedora systems, start the client after dkms startup
+    is finished if the latter is installed and enabled, to avoid attempting
+    starts without the kernel module being available yet (13674) (RT #134974).
+
+  MacOS
+
+    Build system updates for MacOS (13584).
+
+  Solaris
+
+    Add CTF debugging records to userspace objects to improve debugging
+    of servers (13487).
+
+    Convert the cache manager vnodes to be non-embebbed on Solaris 11 in order
+    to make the cache manager more resilient across Solaris 11 changes (13524,
+    13525, 13526, 13527, 13528).
+
+
+OpenAFS 1.8.3
+
+  All platforms
+
+    * Improved diagnostics and error messages (13186 13411 13417)
+
+    * Avoid sending RX packets with random garbage in the userStatus field
+      (13332)
+
+    * Fixed detection of the RX initialization status (13416)
+
+    * Assorted fixes to avoid segmentation faults and other potential problems
+      by detecting internal errors rather than letting them go unnoticed
+      (13329 13372)
+
+  All server platforms
+
+    * Fixed a build problem accidentally introduced in release 1.8.2 (13328)
+
+    * Assorted efficiency improvements in the ubik implementation (13153 13218
+      13188 13353)
+
+    * Fixed locking around transaction list processing in volserver to avoid
+      segmentation faults and other potential problems (13336 13337)
+
+    * When the volserver attempts to remove a temporary volume after a
+      transaction, but the volume was already removed, e.g., by the salvager,
+      this is no longer treated as an error (13235)
+
+  All client platforms
+
+    * Update the CellServDB to the latest version from grand.central.org from
+      May 14th 2018 (13409)
+
+    * Avoid a panic during cache initialization when allocating the required
+      memory fails (13307)
+
+    * Add back the packet counters and timestamps to "vos status" output
+      which had been missing since release 1.8.0 (13421)
+
+    * Correctly handle errors encountered while reading data from the server
+      and writing it to the cache, e.g., due to a full cache partition (13443)
+
+    * Avoid a panic due to a recoverable error while flushing cache items
+      (13503)
+
+  Linux clients
+
+    * Support mainline kernels 4.20 and 5.0 and distribution kernels with
+      backports from those (13405 13406 13440 13441 13442)
+
+    * DKMS-related fixes in Red Hat packaging (13438 13479)
+
+  macOS
+
+    * Support building and packaging on macOS 10.14 "Mojave" (13412 13413)
+
+
+OpenAFS 1.8.2
+
+  All platforms
+
+    * Fix OPENAFS-SA-2018-002: information leakage in RPC output variables
+      Various RPC routines did not always initialize all output fields,
+      exposing memory contents to network attackers.  The relevant RPCs include
+      an AFSCB_ RPC, so cache managers are affected as well as servers.
+
+  All server platforms
+
+    * Fix OPENAFS-SA-2018-003: denial of service due to excess resource consumption
+      Various RPCs were defined as allowing unbounded arrays as input, allowing
+      an unauthenticated attacker to cause excess memory allocation and tie up
+      network bandwidth by sending (or claiming to send) large input arrays.
+
+    * Fix OPENAFS-SA-2018-001: unauthenticated volume operations via butc
+      On systems using the in-tree backup system, the butc process was running
+      with administrative credentials, but accepted incoming RPCs over
+      unauthenticated connections; these incoming RPCs in turn triggered
+      outgoing RPCs using the administrative credentials.  Unauthenticated
+      attackers could construct volue dumps containing arbitrary contents
+      and cause these dumps to be restored and overwrite arbitrary volume
+      contents; afterward, the backup database could be restored to its
+      initial state, hiding evidence of the unauthorized changes.
+
+      Running butc with -localauth now requires authenticated incoming
+      connections, and the backup utility makes authenticated connections to
+      the butc.  Audit capabilities have been added to the butc RPC handlers.
+      Command-line arguments are provided to retain the (insecure) historical
+      behavior until all systems have been upgraded.
+
+OpenAFS 1.8.1.1
+
+  Linux Clients
+
+    * Support for mainline kernel 4.18 and distribution kernels with backports
+      from it (13268)
+
+OpenAFS 1.8.1
+
+  All Platforms
+
+    * Improve the usability and consistency of the public API: install missing
+      headers, and add additional symbols to the export list for shared libraries.
+
+    * Improved Rx abort generation: use the proper serial number for an existing
+      connection if possible, and 0 otherwise (to improve debugging).
+
+    * Assorted minor fixes in response to static analysis of the codebase.
+
+    * Fix memory-safety error in XDR decoding of enumerated types.
+
+  All Server Platforms
+
+    * Fix reference counting error that could cause an assertion failure
+      in some workloads.
+
+    * vldb_check -fix will no longer corrupt the vldb when multiple MH blocks are present.
+
+    * Assorted cleanups and efficiency improvements in the ubik implementation.
+
+    * Return a valid InlineBulkStatus response in error cases.
+
+    * The fileserver now rejects invalid partition names when attaching partitions.
+
+  All Client Platforms
+
+    * Fix volume callbacks (e.g., when running 'vos release').
+
+    * Treat failure to obtain a DSlot as a hard error for that cache partition,
+      avoiding a flood of "disk cache read error in CacheItems" log messages,
+      and reducing the chance of subsequent panic.
+
+    * Improve error messages for invalid values with -volume-ttl.
+
+    * Remove useless error message:
+      "find_preferred_connection: no connection and !create".
+
+    * Avoid passing NULL to a kernel memory deallocator, which is not guaranteed
+      to be safe on all systems.
+
+  Linux
+
+    * Add support for 64-bit ARM clients ("arm64").
+
+    * Fix panic when cache bypass is enabled.
+
+    * Improve cache manager behavior when unable to open cache files.
+
+    * Improvements to the RPM packaging.
+
+    * Detect out-of-memory when using kernel pages for writing.
+
+  Solaris
+
+    * Fix various issues in the build process for recent Solaris versions.
+
+  MacOS
+
+    * Fix clients on OS X 10.13.
+
+  FreeBSD / NetBSD / OpenBSD
+
+    * Fix panic triggered during periodic cleanup operations and shutdown.
+
 OpenAFS 1.8.0
 
   All Platforms
@@ -468,6 +1065,7 @@ OpenAFS 1.8.0
       (These runtime options override the use of UID-based PAGs, which were
       introduced to appease the CDE screensaver.)
 
+
 OpenAFS 1.6.21
 
   All platforms
diff --git a/NTMakefile b/NTMakefile
index 4b28fda3f..e3be8f99a 100644
--- a/NTMakefile
+++ b/NTMakefile
@@ -257,7 +257,14 @@ fsint: procmgmt
 	$(NTMAKE)
 	$(CD) ..\..
 
-audit: fsint
+bubasics: fsint
+     @echo ***** $@
+	$(DOCD) $(SRC)\$@
+	$(CD) $(SRC)\$@
+	$(NTMAKE)
+	$(CD) ..\..
+
+audit: bubasics
      @echo ***** $@
 	$(DOCD) $(SRC)\$@
 	$(CD) $(SRC)\$@
@@ -285,7 +292,14 @@ cm_headers: libacl_headers
 	$(NTMAKE_HEADERS)
 	$(CD) ..\..\..
 
-auth_headers: cm_headers
+rxgk_headers: cm_headers
+     @echo ***** $@
+	$(DOCD) $(SRC)\rxgk
+	$(CD) $(SRC)\rxgk
+	$(NTMAKE_HEADERS)
+	$(CD) ..\..
+
+auth_headers: rxgk_headers
      @echo ***** $@
 	$(DOCD) $(SRC)\auth
 	$(CD) $(SRC)\auth
@@ -362,14 +376,7 @@ usd: vlserver
 	$(NTMAKE)
 	$(CD) ..\..
 
-bubasics: usd
-     @echo ***** $@
-	$(DOCD) $(SRC)\$@
-	$(CD) $(SRC)\$@
-	$(NTMAKE)
-	$(CD) ..\..
-
-budb:	bubasics
+budb: usd
      @echo ***** $@
 	$(DOCD) $(SRC)\$@
 	$(CD) $(SRC)\$@
diff --git a/acinclude.m4 b/acinclude.m4
index 7b35bb122..9fa6340d7 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -14,7 +14,7 @@ OPENAFS_OPTIONS
 OPENAFS_DOC
 
 dnl Checks for UNIX variants.
-AC_ISC_POSIX
+AC_SEARCH_LIBS([strerror],[cposix])
 
 dnl Various compiler setup.
 AC_TYPE_PID_T
@@ -60,7 +60,7 @@ OPENAFS_NETDB_CHECKS
 AC_HEADER_TIME
 OPENAFS_ROKEN_HEADERS
 OPENAFS_BSWAP_CHECKS
-OPENAFS_HPUX_CHECKS
+OPENAFS_PIO_CHECKS
 OPENAFS_REGEX_CHECKS
 OPENAFS_MORE_PTHREAD_CHECKS
 OPENAFS_TYPE_CHECKS
@@ -73,7 +73,6 @@ OPENAFS_SWIG
 OPENAFS_TOPDIRS
 OPENAFS_CROSSTOOLS
 OPENAFS_LINT
-OPENAFS_JAVA
 OPENAFS_CRYPT_CHECKS
 OPENAFS_C_STRUCT_LABEL_CHECK
 OPENAFS_DIRENT_CHECKS
diff --git a/build-tools/make-release b/build-tools/make-release
index a8ba7baeb..7ef82e79a 100755
--- a/build-tools/make-release
+++ b/build-tools/make-release
@@ -13,19 +13,24 @@ my $tagPoint;
 my $last;
 my $outDir = ".";
 
-GetOptions("help|?" => \$help,
-	   "man" => \$man,
-	   "tagpoint=s" => \$tagPoint,
- 	   "last=s" => \$last,
-	   "dir=s" => \$outDir) or pod2usage(2);
+GetOptions(
+    "help|?" => \$help,
+    "man" => \$man,
+    "tagpoint=s" => \$tagPoint,
+    "last=s" => \$last,
+    "dir=s" => \$outDir,
+) or pod2usage(2);
 
 pod2usage(1) if $help;
 pod2usage(-exitstatus => 0, -verbose => 2) if $man;
 
 my $tagName = shift;
-my $version = shift;
+my $notused = shift;  # Used to be "version".
 
 pod2usage(2) if !defined($tagName);
+if (defined $notused) {
+    warn "Warning: argument '$notused' is ignored.\n";
+}
 
 # Tag the repository
 
@@ -35,23 +40,29 @@ if ($tagPoint) {
 
     # Push the tag upstream
     system ("git push ssh://gerrit.openafs.org:29418/openafs tag $tagName") == 0
-    	or die "git push failed with : $!";
+        or die "git push failed with : $!";
 }
 
-$version = `git describe --abbrev=4 $tagName`;
+my $version = `git describe --abbrev=4 $tagName`;
 chomp $version;
-$version=~s/openafs-[^-]*-//;
-$version=~s/_/./g;
+if (!$version) {
+    die "Failed to describe $tagName.\n";
+}
+my $suffix = $version;
+$suffix =~ s/openafs-[^-]*-//;
+$suffix =~ s/_/./g;
+my $name = "openafs-$suffix";
 
 # Grab the tagged code into a temporary directory
 
-my $name = "openafs-".$version;
-
 my $tempDir = File::Temp::tempdir();
 system ("git archive --format=tar --prefix=$name/ $tagName ".
-	" | tar -C $tempDir -x") == 0
+        " | tar -C $tempDir -x") == 0
     or die "Git archive failed with: $?";
 
+# Make the output path, if not already present.
+File::Path::mkpath($outDir);
+
 # Construct the ChangeLog
 if ($last) {
     system("git log $last..$tagName > $outDir/ChangeLog");
@@ -60,7 +71,10 @@ if ($last) {
 }
 
 # Describe the tree
-system("git describe --abbrev=4 $tagName > $tempDir/$name/.version");
+open(my $fh, ">", "$tempDir/$name/.version") or
+    die "Failed to open $tempDir/$name/.version: $!\n";
+print $fh "$version\n";
+close($fh);
 
 # Run regen.sh to create the rest of the tree
 system ("cd $tempDir/$name && ./regen.sh") == 0
@@ -95,11 +109,11 @@ my @toMD5;
 # and also set up a list for md5 checksumming.
 foreach my $file (@toCompress) {
     system("gzip < $file > $file.gz") == 0
-	or die "Unable to create gzip file of '$file' : $!";
+        or die "Unable to create gzip file of '$file' : $!";
     push @toMD5, "$file.gz";
 
     system("bzip2 < $file > $file.bz2") == 0
-	or die "Unable to create bzip file of '$file' : $!";
+        or die "Unable to create bzip file of '$file' : $!";
     push @toMD5, "$file.bz2";
 
     # Delete the uncompressed tar files.
@@ -113,38 +127,38 @@ foreach my $file (@toCompress) {
 
 foreach my $file (@toMD5) {
     if (-x "/sbin/md5") {
-	system("/sbin/md5 -q $file > $file.md5");
+        system("/sbin/md5 -q $file > $file.md5");
     } elsif (-x "/usr/bin/md5sum") {
-	system("/usr/bin/md5sum $file > $file.md5");
+        system("/usr/bin/md5sum $file > $file.md5");
     } else {
-	print STDERR "No md5 utiltiy found. Not producing checksums\n";
+        print STDERR "No md5 utility found. Not producing checksums\n";
     }
 }
- 
+
 
 __END__
 
 =head1 NAME
 
-make_release - Make an OpenAFS release from git
+make-release - Make an OpenAFS release from git
 
 =head1 SYNOPSIS
 
-make_release [options] <tag> [<version>]
+make-release [options] <tag>
 
  Options:
-    --help	         brief help message
-    --man	         full documentation
+    --help               brief help message
+    --man                full documentation
     --tagpoint <object>  create new tag
     --last <object>      generate changelog and diffs from this point
     --dir <dir>          output results into this directory
 
 =head1 DESCRIPTION
 
-make_release constructs an OpenAFS release from a local git clone. If run
+make-release constructs an OpenAFS release from a local git clone. If run
 with just the standard arguments, it will extract the contents of the
 specified tag into the current directory, creating src and doc tarballs,
-gziping and bziping them, and generating md5 hashes. It will also create a
+gzipping and bzipping them, and generating md5 hashes. It will also create a
 ChangeLog file, listing all of the changes in that release.
 
 This standard behaviour may be modified by the following options
@@ -155,14 +169,14 @@ This standard behaviour may be modified by the following options
 
 =item B<--last> I<object>
 
-Generate the ChangeLog starting from I<object>. Also generate a 
+Generate the ChangeLog starting from I<object>. Also generate a
 openafs-$version.diff file in the output directory containing all of the
 changes between I<object> and the current tag
 
 =item B<--dir> I<directory>
 
 Instead of generating all of the output in the current directory, place it
-in <directory>, which must already exist.
+in <directory>, which is created if it does not already exist.
 
 =item B<--tagpoint> I<commit|branch>
 
@@ -170,4 +184,6 @@ Rather than using an existing tag, create a new one on the specified commit,
 or on the tip of the specified branch. This will GPG sign the new tag, and
 push it into gerrit.
 
+=back
+
 =cut
diff --git a/configure-libafs.ac b/configure-libafs.ac
index 5c22ec649..227adaadd 100644
--- a/configure-libafs.ac
+++ b/configure-libafs.ac
@@ -1,14 +1,10 @@
 AC_PRERQ([2.60])
-AC_INIT([OpenAFS],
-	m4_esyscmd([build-tools/git-version .]),
-	[openafs-bugs@openafs.org], [],
-	[http://www.openafs.org/])
+AC_INIT([OpenAFS],[m4_esyscmd(build-tools/git-version .)],[openafs-bugs@openafs.org],[],[http://www.openafs.org/])
 AC_CONFIG_AUX_DIR([build-tools])
 AC_CONFIG_SRCDIR([src/libafs/Makefile.common.in])
-AM_INIT_AUTOMAKE([foreign])
 
 AC_CONFIG_HEADER([src/config/afsconfig.h])
-MACOS_VERSION=1.8.0fc5
+MACOS_VERSION=1.9.0
 
 AC_SUBST([MACOS_VERSION])
 
@@ -18,7 +14,7 @@ AC_PROG_CC
 
 OPENAFS_CONFIGURE_COMMON
 
-AC_OUTPUT([
+AC_CONFIG_FILES([
 	Makefile
 	src/config/Makefile
 	src/config/Makefile.config
@@ -28,3 +24,4 @@ AC_OUTPUT([
 	src/libafs/Makefile.common
 	src/libafs/MakefileProto
 ])
+AC_OUTPUT
diff --git a/configure.ac b/configure.ac
index e3f38301a..5ee2dd3c7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,16 +1,11 @@
-AC_PREREQ([2.60])
-AC_INIT([OpenAFS],
-    m4_esyscmd([build-tools/git-version .]),
-    [openafs-bugs@openafs.org], [],
-    [http://www.openafs.org/])
+AC_PREREQ([2.64])
+AC_INIT([OpenAFS],[m4_esyscmd(build-tools/git-version .)],[openafs-bugs@openafs.org],[],[http://www.openafs.org/])
 AC_CONFIG_AUX_DIR([build-tools])
 AC_CONFIG_MACRO_DIR([src/cf])
 AC_CONFIG_SRCDIR([src/config/stds.h])
-AM_INIT_AUTOMAKE([foreign])
 
 AC_CONFIG_HEADER([src/config/afsconfig.h])
-MACOS_VERSION=1.8.0fc5
-LINUX_PKGREL=1.8.0pre5
+MACOS_VERSION=1.9.0
 
 AC_SUBST([MACOS_VERSION])
 
@@ -19,99 +14,15 @@ AS_IF([test -z "$CFLAGS"], [CFLAGS=" "])
 
 AC_USE_SYSTEM_EXTENSIONS
 
-LT_INIT
+AFS_LT_INIT
 
 AC_PROG_CC
-AC_PROG_LIBTOOL
 
 AC_PATH_PROGS([PATH_CPP], [cpp], [${CC-cc} -E], [$PATH:/lib:/usr/ccs/lib])
 AC_SUBST([PATH_CPP])
 OPENAFS_CONFIGURE_COMMON
-
-dnl Probe for Kerberos.  We have a few platform-specific overrides due to
-dnl weird Kerberos implementations and installation locations.
-AS_CASE([$AFS_SYSNAME],
-    [*_obsd*],
-    [KRB5_CPPFLAGS="-I/usr/include/kerberosV"],
-
-    [ppc_darwin_70],
-    [KRB5_CPPFLAGS="-I/usr/include"
-     KRB5_LDFLAGS="-L/usr/lib -Wl,-search_paths_first"])
-RRA_LIB_KRB5_OPTIONAL
-AS_CASE([$AFS_SYSNAME],
-    [hp_ux*|*_hpux*],
-    [KRB5_LIBS="-l:libkrb5.sl -l:libcom_err.sl"])
-
-dnl Check for the characteristics of whatever Kerberos we found, if we found
-dnl one.
-BUILD_KRB5=no
-MAKE_KRB5="#"
-AS_IF([test x"$KRB5_LIBS" != x],
-    [BUILD_KRB5=yes
-     MAKE_KRB5=
-     RRA_LIB_KRB5_SWITCH
-     AC_CHECK_FUNCS([add_error_table \
-	add_to_error_table \
-	encode_krb5_enc_tkt_part \
-	encode_krb5_ticket \
-	krb5_524_conv_principal \
-	krb5_allow_weak_crypto \
-	krb5_c_encrypt \
-	krb5_decode_ticket \
-	krb5_enctype_enable \
-	krb5_free_keytab_entry_contents \
-	krb5_free_unparsed_name \
-	krb5_get_init_creds_opt_alloc \
-	krb5_get_prompt_types \
-	krb5_princ_size \
-	krb5_principal_get_comp_string])
-     AC_CHECK_FUNCS([krb5_524_convert_creds], [],
-	[AC_CHECK_FUNCS([krb524_convert_creds_kdc], [],
-	    [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
-		[LIBS="-lkrb524 $LIBS"
-		 KRB5_LIBS="-lkrb524 $KRB5_LIBS"
-		 AC_CHECK_LIB([krb524], [krb5_524_conv_principal],
-		     [AC_DEFINE([HAVE_KRB5_524_CONV_PRINCIPAL], [1],
-			 [Define to 1 if you have the `krb5_524_conv_principal' function.])
-		 ])
-		 AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], [1],
-		     [Define to 1 if you have the `krb524_convert_creds_kdc' function.])
-	    ])
-	])
-     ])
-     AC_CHECK_HEADERS([kerberosIV/krb.h])
-     AC_CHECK_HEADERS([kerberosV/heim_err.h])
-     AC_CHECK_HEADERS([com_err.h et/com_err.h krb5/com_err.h])
-     AS_IF([test x"$ac_cv_header_com_err_h" != xyes \
-             && test x"$ac_cv_header_et_com_err_h" != xyes \
-             && test x"$ac_cv_header_krb5_com_err_h" != xyes],
-       [AC_MSG_ERROR([Cannot find a usable com_err.h])])
-     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.keyblock.enctype, krb5_creds.session,
-		       krb5_prompt.type], [], [], [#include <krb5.h>])
-     AC_CHECK_MEMBERS([krb5_keytab_entry.key, krb5_keytab_entry.keyblock],
-		      [], [], [#include <krb5.h>])
-dnl If we have krb5_creds.session, we are using heimdal
-dnl If we're using heimdal, aklog needs libasn1 for encode_EncTicketPart and a
-dnl few other functions. But just aklog; not any of the other stuff that uses
-dnl krb5.
-     AS_IF([test x"$ac_cv_member_krb5_creds_session" = xyes],
-	   [AC_CHECK_LIB([asn1], [encode_EncTicketPart],
-	       [AKLOG_KRB5_LIBS="-lasn1"])
-     ])
-     RRA_LIB_KRB5_RESTORE
-])
-AC_SUBST([BUILD_KRB5])
-AC_SUBST([MAKE_KRB5])
-AC_SUBST([AKLOG_KRB5_LIBS])
-
-dnl Probe for GSSAPI
-RRA_LIB_GSSAPI
-dnl Check for the characteristics of whatever GSSAPI we found, if we found one
-BUILD_GSSAPI=no
-AS_IF([test x"$GSSAPI_LIBS" != x],
-    [BUILD_GSSAPI=yes
-])
-AC_SUBST([BUILD_GSSAPI])
+OPENAFS_KRB5
+OPENAFS_GSS
 
 dnl Checks for summary
 OPENAFS_SUMMARY_CHECK_NAMEI
@@ -138,7 +49,7 @@ AS_IF([test -f 'doc/doxygen/Doxyfile.in'],
     [DOXYFILE="doc/doxygen/Doxyfile"],
     [DOXYFILE=])
 
-AC_OUTPUT([
+AC_CONFIG_FILES([
     Makefile
     ${MAN_MAKEFILE}
     ${ADMINGUIDE_MAKEFILE}
@@ -176,6 +87,7 @@ AC_OUTPUT([
     src/config/Makefile.pthread
     src/config/Makefile.version-CML
     src/config/Makefile.version-NOCML
+    src/config/cc-wrapper
     src/config/shlib-build
     src/config/shlib-install
     src/crypto/hcrypto/Makefile
@@ -242,6 +154,7 @@ AC_OUTPUT([
     src/rx/test/Makefile
     src/rxdebug/Makefile
     src/rxgen/Makefile
+    src/rxgk/Makefile
     src/rxkad/Makefile
     src/rxkad/test/Makefile
     src/rxosd/Makefile
@@ -286,9 +199,11 @@ AC_OUTPUT([
     tests/rx/Makefile
     tests/tap/Makefile
     tests/util/Makefile
-    tests/volser/Makefile],
-[chmod a+x src/config/shlib-build
- chmod a+x src/config/shlib-install])
+    tests/volser/Makefile])
+AC_CONFIG_COMMANDS([default],[chmod a+x src/config/shlib-build
+ chmod a+x src/config/shlib-install
+ chmod a+x src/config/cc-wrapper],[])
+AC_OUTPUT
 
 # print a final summary
 OPENAFS_SUMMARY
diff --git a/doc/doxygen/Doxyfile.in b/doc/doxygen/Doxyfile.in
index 30e3d558b..40c4d3d89 100644
--- a/doc/doxygen/Doxyfile.in
+++ b/doc/doxygen/Doxyfile.in
@@ -44,10 +44,8 @@ EXCLUDE                = \
     src/JAVA \
     src/kauth \
     src/libafs \
-    src/mcas \
     src/NTObjdir \
     src/packaging \
-    src/shlibafsrpc \
     src/tbudb \
     src/tbutc \
     src/tests \
diff --git a/doc/man-pages/Makefile.in b/doc/man-pages/Makefile.in
index 587bed2d7..882dd48c5 100644
--- a/doc/man-pages/Makefile.in
+++ b/doc/man-pages/Makefile.in
@@ -33,7 +33,7 @@ INSTALL_KAUTH = @INSTALL_KAUTH@
 prep-noinstall: Makefile
 	rm -f man*/*.noinstall
 	if [ "$(INSTALL_KAUTH)" = "no" ] ; then \
-		mkdir -p man1 man5 man8; \
+		mkdir -p man1 man3 man5 man8; \
 		for M in $(KAUTH_MAN); do \
 			touch $$M.noinstall; \
 		done; \
diff --git a/doc/man-pages/pod1/afs.pod b/doc/man-pages/pod1/afs.pod
index a65cb1c2b..9f97d7abb 100644
--- a/doc/man-pages/pod1/afs.pod
+++ b/doc/man-pages/pod1/afs.pod
@@ -410,10 +410,9 @@ After /vicepz (for which the index is 25) comes
 
 and so on through
 
-   /vicepiv    =     vicepiv     =      iv     =      255
+   /vicepiu    =     vicepiu     =      iu     =      254
 
-F</vicepiv> is the last permissible AFS partition name. In practice it
-will not work well; stopping with F</vicepiu> is highly recommended.
+F</vicepiu> is the last permissible OpenAFS partition name.
 
 =head4 Abbreviating Cell Names
 
diff --git a/doc/man-pages/pod1/aklog.pod b/doc/man-pages/pod1/aklog.pod
index eb1727b42..0d67ea1b1 100644
--- a/doc/man-pages/pod1/aklog.pod
+++ b/doc/man-pages/pod1/aklog.pod
@@ -8,11 +8,11 @@ aklog - Obtain tokens for authentication to AFS
 <div class="synopsis">
 
 B<aklog> [B<-d>] [B<-hosts>] [B<-zsubs>] [B<-noprdb>] [B<-noauth>] [B<-linked>]
-    [B<-force>] [B<-524>] [B<-setpag>]
+    [B<-force>] [B<-524>] [B<-setpag>] [B<-insecure_des>]
     S<<< [[B<-cell> | B<-c>] <I<cell>> [B<-k> <I<Kerberos realm>>]]+ >>>
 
 B<aklog> [B<-d>] [B<-hosts>] [B<-zsubs>] [B<-noprdb>] [B<-noauth>] [B<-linked>]
-    [B<-force>] [B<-524>] [B<-setpag>] [B<-path> | B<-p>] <I<path>>+
+    [B<-force>] [B<-524>] [B<-setpag>] [B<-insecure_des>] [B<-path> | B<-p>] <I<path>>+
 
 =for html
 </div>
@@ -119,6 +119,11 @@ normally won't be necessary.
 
 If the AFS cell is linked to another AFS cell, get tokens for both.
 
+-item B<-insecure_des>
+
+Configure libkrb5 to allow the use of the (insecure) single-DES encryption
+types.  When rxkad-k5 is in use, this is not needed.
+
 =item B<-noauth>
 
 Don't actually authenticate, just do everything else B<aklog> does up to
diff --git a/doc/man-pages/pod1/klog.krb5.pod b/doc/man-pages/pod1/klog.krb5.pod
index 023deeef6..6b98c7a23 100644
--- a/doc/man-pages/pod1/klog.krb5.pod
+++ b/doc/man-pages/pod1/klog.krb5.pod
@@ -11,14 +11,15 @@ B<klog.krb5> [B<-x>] S<<< [B<-principal> <I<user name>>] >>>
     [-password <I<user's password>>] S<<< [B<-cell> <I<cell name>>] >>>
     S<<< [B<-k> <I<realm>>] >>> [B<-pipe>] [B<-silent>]
     S<<< [B<-lifetime> <I<ticket lifetime in hh[:mm[:ss]]>>] >>>
-    [B<-setpag>] [B<-tmp>] [B<-noprdb>] [B<-unwrap>] [B<-help>]
+    [B<-setpag>] [B<-tmp>] [B<-noprdb>] [B<-unwrap>] [B<-insecure_des>]
+    [B<-help>]
 
 B<klog.krb5> [B<-x>] S<<< [B<-pr> <I<user name>>] >>>
     S<<< [B<-pa> <I<user's password>>] >>>
     S<<< [B<-c> <I<cell name>>] >>>
     B<<< [B<-k> <I<realm>>] >>> [B<-pi>] [B<-si>]
     S<<< [B<-l> <I<ticket lifetime in hh[:mm[:ss]]>>] >>>
-    [B<-se>] [B<-t>] [B<-n>] [B<-u>] [B<-h>]
+    [B<-se>] [B<-t>] [B<-n>] [B<-u>] [B<-i>] [B<-h>]
 
 =for html
 </div>
@@ -60,11 +61,6 @@ the following:
 
 =item *
 
-The lifetime specified by the issuer with the B<-lifetime> argument if
-that argument was given.
-
-=item *
-
 The maximum ticket lifetime recorded for the C<afs/I<cell>> principal in
 thet Kerberos database.
 
@@ -191,8 +187,7 @@ major problems encountered.
 
 =item B<-lifetime> <I<ticket lifetime>
 
-Requests a specific lifetime for the token.  Provide a number of hours and
-optionally minutes and seconds in the format I<hh>[B<:>I<mm>[B<:>I<ss>]].
+This option is not implemented by B<klog.krb5> and has no effect.
 
 =item B<-setpag>
 
@@ -227,6 +222,11 @@ sizes in conjunction with Active Directory as the Kerberos server, using
 B<-unwrap> can shrink the AFS token size so that older software can handle
 it more easily.
 
+=item B<-insecure_des>
+
+Configures libkrb5 to allow the use of the (insecure) single-DES encryption
+types.  When rxkad-k5 is in use, this is not needed.
+
 =item B<-help>
 
 Prints the online help for this command. All other valid options are
@@ -258,12 +258,6 @@ Corporation's test cell:
    % klog.krb5 -principal admin -cell test.example.com
    Password for admin@EXAMPLE.COM:
 
-In the following, the issuer requests a ticket lifetime of 104 hours 30
-minutes (4 days 8 hours 30 minutes).
-
-   % klog.krb5 -lifetime 104:30
-   Password for user@EXAMPLE.ORG:
-
 =head1 PRIVILEGE REQUIRED
 
 None
diff --git a/doc/man-pages/pod1/pts.pod b/doc/man-pages/pod1/pts.pod
index d3a890b05..1a3a009c8 100644
--- a/doc/man-pages/pod1/pts.pod
+++ b/doc/man-pages/pod1/pts.pod
@@ -195,6 +195,16 @@ L<pts_interactive(1)>, since otherwise it would be impossible to switch from,
 for example, B<-localauth> back to using regular tokens during a bulk
 operation. See L<pts_interactive(1)> for more details.
 
+=item B<-rxgk> (crypt | auth | clear)
+
+Specify B<-rxgk> to use rxgk credentials when contacting the ptserver. The
+C<crypt> argument causes B<pts> to use rxgk with per-packet encryption, C<auth>
+causes B<pts> to use rxgk with per-packet integrity protection, and C<clear>
+causes B<pts> to use rxgk without any per-packet cryptography.
+
+By default, B<pts> uses rxkad credentials.  B<pts> falls back to unauthenticated
+connections if credentials are not available.
+
 =back
 
 =head1 PRIVILEGE REQUIRED
diff --git a/doc/man-pages/pod1/vos.pod.in b/doc/man-pages/pod1/vos.pod.in
index f0ec34acd..3dab98b74 100644
--- a/doc/man-pages/pod1/vos.pod.in
+++ b/doc/man-pages/pod1/vos.pod.in
@@ -231,7 +231,7 @@ After /vicepz (for which the index is 25) comes
 
 and so on through
 
-   /vicepiv    =     vicepiv     =      iv     =      255
+   /vicepiu    =     vicepiu     =      iu     =      254
 
 The B<-frompartition> and B<-topartition> arguments to the
 L<B<vos move>|vos_move(1)> command also accept this notation.
@@ -263,6 +263,16 @@ Produces on the standard output stream a detailed trace of the command's
 execution. If this argument is omitted, only warnings and error messages
 appear.
 
+=item B<-rxgk> (crypt | auth | clear)
+
+Specify B<-rxgk> to use rxgk credentials when contacting the vlserver or volserver. The
+C<crypt> argument causes B<vos> to use rxgk with per-packet encryption, C<auth>
+causes B<vos> to use rxgk with per-packet integrity protection, and C<clear>
+causes B<vos> to use rxgk without any per-packet cryptography.
+
+By default, B<vos> uses rxkad credentials.  B<vos> falls back to unauthenticated
+connections if credentials are not available.
+
 =back
 
 =head1 PRIVILEGE REQUIRED
diff --git a/doc/man-pages/pod1/vos_rename.pod.in b/doc/man-pages/pod1/vos_rename.pod.in
index f2b05fd17..e798e5657 100644
--- a/doc/man-pages/pod1/vos_rename.pod.in
+++ b/doc/man-pages/pod1/vos_rename.pod.in
@@ -40,14 +40,17 @@ command.
 
 =over 4
 
-=item B<-oldname> <I<old volume name>>
+=item B<-oldname> <I<old volume name or id>>
 
-Is the current name of the read/write volume.
+Is the current name or numeric id of the read/write volume to be renamed.
 
 =item B<-newname> <I<new volume name>>
 
 Is the desired new name for the volume.
 
+The new name may be the same as the current volume name in the VLDB
+in order to complete a previously interrupted volume rename.
+
 =include fragments/vos-common.pod
 
 =back
diff --git a/doc/man-pages/pod5/uss.pod b/doc/man-pages/pod5/uss.pod
index cb277c1fb..d09cacba1 100644
--- a/doc/man-pages/pod5/uss.pod
+++ b/doc/man-pages/pod5/uss.pod
@@ -618,7 +618,7 @@ After F</vicepz> (for which the index is 25) comes
 
 and so on through
 
-   /vicepiv    =     vicepiv     =      iv     =      255
+   /vicepiu    =     vicepiu     =      iu     =      254
 
 To read in the value from the B<uss add> command's B<-partition> argument,
 specify the value $PART.
diff --git a/doc/man-pages/pod5/uss_bulk.pod b/doc/man-pages/pod5/uss_bulk.pod
index 8e80249d1..e635607c7 100644
--- a/doc/man-pages/pod5/uss_bulk.pod
+++ b/doc/man-pages/pod5/uss_bulk.pod
@@ -159,7 +159,7 @@ After F</vicepz> (for which the index is 25) comes
 
 and so on through
 
-   /vicepiv    =     vicepiv     =      iv     =      255
+   /vicepiu    =     vicepiu     =      iu     =      254
 
 Corresponding argument to the B<uss add> command: B<-partition>.
 Corresponding variable in template: $PART.
diff --git a/doc/man-pages/pod8/asetkey.pod b/doc/man-pages/pod8/asetkey.pod
index 3ec30a30d..94fb5223b 100644
--- a/doc/man-pages/pod8/asetkey.pod
+++ b/doc/man-pages/pod8/asetkey.pod
@@ -15,8 +15,16 @@ B<asetkey> add <I<type>> <I<kvno>> <I<subtype>> <I<key>>
 
 B<asetkey> add <I<type>> <I<kvno>> <I<subtype>> <I<keyfile>> <I<princ>>
 
+B<asetkey> add-random <I<type>> <I<kvno>>
+
+B<asetkey> add-random <I<type>> <I<kvno>> <I<subtype>>
+
 B<asetkey> delete <I<kvno>>
 
+B<asetkey> delete <I<type>> <I<kvno>>
+
+B<asetkey> delete <I<type>> <I<kvno>> <I<subtype>>
+
 B<asetkey> list
 
 =for html
@@ -50,6 +58,10 @@ C<getprinc> function of B<kadmin>).  I<principal> should be the name of
 the AFS principal in the keytab, which must be either C<afs> or
 C<afs/I<cell name>>.
 
+The B<asetkey add-random> command can be used to create randomized keys,
+instead of using keys derived from an existing krb5 principal. This is useful
+primarily for some rxgk keys.
+
 =head1 CAUTIONS
 
 Historically, AFS only supported des-cbc-crc:v4 Kerberos keys.  In environments
diff --git a/doc/man-pages/pod8/backup.pod b/doc/man-pages/pod8/backup.pod
index f8e2ebcc3..0900fe6ed 100644
--- a/doc/man-pages/pod8/backup.pod
+++ b/doc/man-pages/pod8/backup.pod
@@ -194,6 +194,18 @@ interactive mode. The local identity and AFS tokens with which the
 B<backup> command interpreter enters interactive mode apply to all
 commands issued during the interactive session.
 
+=item B<-nobutcauth>
+
+Prior to the fix for OPENAFS-SA-2018-001, B<butc> did not allow incoming
+connections to be authenticated.  As part of that fix, B<backup> was modified
+to authenticate to the B<butc> services when possible, but a B<backup> utility
+with the security fix will not interoperate with a B<butc> that lacks the fix
+unless this option is passed, which forces the use of unauthenticated
+connections to the B<butc>.  Use of this option is strongly disrecommended,
+and it is provided only for backwards compatibility in environments where
+B<backup> and B<butc> communicate over a secure network environment that denies
+access to untrusted parties.
+
 =item B<-portoffset> <I<TC port offset>>
 
 Specifies the port offset number of the Tape Coordinator that is to
diff --git a/doc/man-pages/pod8/bos_salvage.pod b/doc/man-pages/pod8/bos_salvage.pod
index 6e7fe18f6..67c08fc3a 100644
--- a/doc/man-pages/pod8/bos_salvage.pod
+++ b/doc/man-pages/pod8/bos_salvage.pod
@@ -168,7 +168,7 @@ After F</vicepz> (for which the index is 25) comes
 
 and so on through
 
-   /vicepiv    =     vicepiv     =      iv     =      255
+   /vicepiu    =     vicepiu     =      iu     =      254
 
 =item B<-volume> <I<salvage volume id or name>>
 
diff --git a/doc/man-pages/pod8/butc.pod b/doc/man-pages/pod8/butc.pod
index 730ce8397..42c72daf2 100644
--- a/doc/man-pages/pod8/butc.pod
+++ b/doc/man-pages/pod8/butc.pod
@@ -8,10 +8,14 @@ butc - Initializes the Tape Coordinator process
 <div class="synopsis">
 
 B<butc> S<<< [B<-port> <I<port offset>>] >>> S<<< [B<-debuglevel> (0 | 1 | 2)] >>>
-    S<<< [B<-cell> <I<cell name>>] >>> [B<-noautoquery>] [B<-rxbind>] [B<-localauth>] [B<-help>]
+    S<<< [B<-cell> <I<cell name>>] >>> [B<-noautoquery>] [B<-rxbind>] [B<-localauth>]
+    [B<-auditlog> <I<file | sysvmq>> [B<-audit-interface> <I<interface>>]]
+    [B<-allow_unauthenticated>] [B<-help>]
 
 B<butc> S<<< [B<-p> <I<port offset>>] >>> S<<< [B<-d> (0 | 1 | 2)] >>>
-    S<<< [B<-c> <I<cell name>>] >>> [B<-n>] [B<-r>] [B<-l>] [B<-h>]
+    S<<< [B<-c> <I<cell name>>] >>> [B<-n>] [B<-r>] [B<-l>]
+    [B<-auditl> <I<file | sysvmq>> [-B<-audit-i> <I<interface>>]]
+    [B<-al>] [B<-h>]
 
 =for html
 </div>
@@ -186,6 +190,29 @@ logged on to a server machine as the local superuser C<root>; client
 machines do not have F</usr/afs/etc/KeyFile> or F</usr/afs/etc/KeyFileExt>
 files.
 
+=item B<-auditlog> <I<log path>>
+
+Turns on audit logging, and sets the path for the audit log.  The audit
+log records information about RPC calls, including the name of the RPC
+call, the host that submitted the call, the authenticated entity (user)
+that issued the call, the parameters for the call, and if the call
+succeeded or failed.
+
+=item B<-audit-interface> <(file | sysvmq)>
+
+Specifies what audit interface to use. Defaults to C<file>. See
+L<fileserver(8)> for an explanation of each interface.
+
+=item B<-allow_unauthenticated>
+
+By default the B<butc> requires clients performing TC_ RPCs to authenticate
+themselves, behavior introduced in the fix for OPENAFS-SA-2018-001.
+This option reverts to the historical behavior of only using the rxnull
+security class for incoming connections.  Use of this option is strongly
+disrecommended; it is provided only for backwards compatibility with older
+clients in environments where B<backup> and B<butc> communicate over a secure
+network that denies access to untrusted parties.
+
 =item B<-help>
 
 Prints the online help for this command. All other valid options are
diff --git a/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod b/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod
index 91a1550f1..1e74123c9 100644
--- a/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod
+++ b/doc/man-pages/pod8/fragments/dafileserver-synopsis.pod
@@ -15,6 +15,7 @@ B<dafileserver>
     S<<< [B<-novbc>] >>>
     S<<< [B<-implicit> <I<admin mode bits: rlidwka>>] >>>
     S<<< [B<-readonly>] >>>
+    S<<< [B<-admin-write>] >>>
     S<<< [B<-hr> <I<number of hours between refreshing the host cps>>] >>>
     S<<< [B<-busyat> <I<< redirect clients when queue > n >>>] >>>
     S<<< [B<-nobusy>] >>>
diff --git a/doc/man-pages/pod8/fragments/fileserver-options.pod b/doc/man-pages/pod8/fragments/fileserver-options.pod
index 378f6301c..165230360 100644
--- a/doc/man-pages/pod8/fragments/fileserver-options.pod
+++ b/doc/man-pages/pod8/fragments/fileserver-options.pod
@@ -127,6 +127,12 @@ permissions, see the B<fs setacl> reference page.
 
 Don't allow writes to this fileserver.
 
+=item B<-admin-write>
+
+Allows write requests for members of system:administrators on the read-only
+fileserver in question. The C<-admin-write> option has no effect when the
+C<-readonly> is not specified.
+
 =item B<-hr> <I<number of hours between refreshing the host cps>>
 
 Specifies how often the File Server refreshes its knowledge of the
diff --git a/doc/man-pages/pod8/fragments/fileserver-synopsis.pod b/doc/man-pages/pod8/fragments/fileserver-synopsis.pod
index c949d6ec5..203d7a36b 100644
--- a/doc/man-pages/pod8/fragments/fileserver-synopsis.pod
+++ b/doc/man-pages/pod8/fragments/fileserver-synopsis.pod
@@ -15,6 +15,7 @@ B<fileserver>
     S<<< [B<-novbc>] >>>
     S<<< [B<-implicit> <I<admin mode bits: rlidwka>>] >>>
     S<<< [B<-readonly>] >>>
+    S<<< [B<-admin-write>] >>>
     S<<< [B<-hr> <I<number of hours between refreshing the host cps>>] >>>
     S<<< [B<-busyat> <I<< redirect clients when queue > n >>>] >>>
     S<<< [B<-nobusy>] >>>
diff --git a/doc/man-pages/pod8/ptserver.pod b/doc/man-pages/pod8/ptserver.pod
index 11e677050..31c5086da 100644
--- a/doc/man-pages/pod8/ptserver.pod
+++ b/doc/man-pages/pod8/ptserver.pod
@@ -21,6 +21,7 @@ ptserver S<<< [B<-database> | B<-db> <I<db path>>] >>>
     [B<-transarc-logs>]
     S<<< [B<-config> <I<configuration path>>] >>>
     S<<< [B<-rxmaxmtu> <I<bytes>>] >>>
+    S<< [B<-s2scrypt> (rxgk-crypt | never)] >>
     [B<-help>]
 
 =for html
@@ -194,6 +195,14 @@ L<fileserver(8)> for an explanation of each interface.
 
 Sets the maximum transmission unit for the RX protocol.
 
+=item B<-s2scrypt> (rxgk-crypt | never)
+
+Specify C<rxgk-crypt> to use rxgk connections with per-packet encryption for
+server-to-server (s2s) communication. Specify C<never> to use rxkad connections
+instead, without per-packet encryption ("rxkad_clear").
+
+The default is currently C<never>.
+
 =item B<-help>
 
 Prints the online help for this command. All other valid options are
diff --git a/doc/man-pages/pod8/uss_add.pod b/doc/man-pages/pod8/uss_add.pod
index 7a365d0de..829cefbc4 100644
--- a/doc/man-pages/pod8/uss_add.pod
+++ b/doc/man-pages/pod8/uss_add.pod
@@ -145,7 +145,7 @@ After F</vicepz> (for which the index is 25) comes
 
 and so on through
 
-   /vicepiv    =     vicepiv     =      iv     =      255
+   /vicepiu    =     vicepiu     =      iu     =      254
 
 Corresponding variable in the template file: $PART.
 
diff --git a/doc/man-pages/pod8/vlserver.pod b/doc/man-pages/pod8/vlserver.pod
index c74b8bd83..485d772e7 100644
--- a/doc/man-pages/pod8/vlserver.pod
+++ b/doc/man-pages/pod8/vlserver.pod
@@ -23,6 +23,7 @@ vlserver [B<-noauth>] [B<-smallmem>]
     S<<< [B<-auditlog> <I<log path>>] >>>
     S<<< [B<-audit-interface> (file | sysvmq)] >>>
     S<<< [B<-restricted_query> (anyuser | admin)] >>>
+    S<< [B<-s2scrypt> (rxgk-crypt | never)] >>
     [B<-help>]
 
 =for html
@@ -206,6 +207,14 @@ administrators.  The C<anyuser> option doesn't restrict the RPCs and
 leaves it open for all users including unauthenticated users, this is
 the default.
 
+=item B<-s2scrypt> (rxgk-crypt | never)
+
+Specify C<rxgk-crypt> to use rxgk connections with per-packet encryption for
+server-to-server (s2s) communication. Specify C<never> to use rxkad connections
+instead, without per-packet encryption ("rxkad_clear").
+
+The default is currently C<never>.
+
 =item B<-help>
 
 Prints the online help for this command. All other valid options are
diff --git a/doc/man-pages/pod8/voldump.pod b/doc/man-pages/pod8/voldump.pod
index cbe07767f..bd2e66c3b 100644
--- a/doc/man-pages/pod8/voldump.pod
+++ b/doc/man-pages/pod8/voldump.pod
@@ -9,7 +9,7 @@ voldump - Dump an AFS volume without using the Volume Server
 
 B<voldump> S<<< B<-part> <I<partition>> >>> S<<< B<-volumeid> <I<volume id>> >>>
     S<<< [B<-file> <I<dump file>>] >>> [B<-time> <I<dump from time>>]
-    [B<-verbose>] [B<-help>]
+    [B<-pad-errors>] [B<-verbose>] [B<-help>]
 
 B<voldump> S<<< B<-p> <I<partition>> >>> S<<< B<-vo> <I<volume id>> >>>
     S<<< [B<-f> <I<dump file>>] >>> [B<-time> <I<dump from time>>]
@@ -70,6 +70,18 @@ volume will be dumped to standard output.
 Specifies whether the dump is full or incremental. Omit this argument to create
 a full dump, or provide one of the valid values listed in L<vos_dump(1)>.
 
+=item B<-pad-errors>
+
+When reading vnode data from disk, if B<voldump> encounters an I/O error or
+unexpected EOF, by default B<voldump> will print an error and exit. If
+B<-pad-errors> is given, instead B<voldump> will pad the unreadable region with
+NUL bytes, and continue with the dump.
+
+This option may be useful when trying to extract data from volumes where the
+underlying disk is failing, or the volume data is corrupted. Data may be
+missing from files in the volume in such cases (replaced by NUL bytes), but at
+least some data may be extracted.
+
 =item B<-verbose>
 
 Asks for a verbose trace of the dump process.  This trace information will
diff --git a/doc/txt/file-reorg b/doc/txt/file-reorg
index 1a83fa857..ebb3ba7dc 100644
--- a/doc/txt/file-reorg
+++ b/doc/txt/file-reorg
@@ -72,8 +72,6 @@ AIX:  afs_aixops.c -> osi_vnodeops.c
       aix_vfs.h    -> osi_vfs.h
       misc.s       -> osi_assem.s
 
-DUX:  afs_vnodeops.c -> osi_vnodeops.c (DUX specific code)
-
 HPUX: afs_vnodeops.c -> osi_vnodeops.c (HPUX specific code)
       afs_hp_debug.c -> osi_debug.c
       hpux_proc_private.h -> osi_proc_private.h
diff --git a/doc/txt/rx-debug.txt b/doc/txt/rx-debug.txt
index d3f8aff24..51d555a2e 100644
--- a/doc/txt/rx-debug.txt
+++ b/doc/txt/rx-debug.txt
@@ -194,6 +194,8 @@ as follows:
         afs_int32 sparel[9];
     };
 
+Note: the char 'flags' member is no longer able to represent all possible values in the
+rx_connection 'flags' member, after the latter was enlarged from u_char to afs_uint32.
 
 An obsolete layout, which exhibited a problem with data alignment, was used in
 Version 'L'. This is defined as:
diff --git a/doc/txt/ubik.txt b/doc/txt/ubik.txt
index 547654fe8..8a649f316 100644
--- a/doc/txt/ubik.txt
+++ b/doc/txt/ubik.txt
@@ -90,14 +90,6 @@ MAJOR DATA STRUCTURES
       thread to examine them without holding the database lock; see the
       section on the BEACON package for details.
 
-      The condition variable 'version_cond' is used to signal to that the
-      database version may have changed; it is broadcast in udisk_commit(),
-      in SDISK_SendFile(), and from the recovery thread; it is monitored by
-      ubik_WaitVersion(), which can be called by an application to wait for
-      a database version change (this is not currently used in OpenAFS).
-      This CV is associated with the database lock.  When LWP is used, this
-      condition is signalled on &ubik_dbase->version.
-
       The condition variable 'flags_cond' is used by udisk_end() to signal
       that DBWRITING flag has been cleared.  This wakes threads waiting in
       ubik.c:BeginTrans() to begin a new transaction.  This CV is
@@ -1165,12 +1157,6 @@ MAJOR SUBSYSTEMS
 
       Utilities
 
-         The functions ubik_GetVersion() and ubik_WaitVersion() provide the
-         application with a way to discover the current database version
-         and to wait for it to change.  These interfaces are not currently
-         used in OpenAFS.  ubik_GetVersion() needs to acquire the database
-         lock while copying the database version.
-
          The internal function ubikGetPrimaryInterfaceAddr() is used by
          Ubik RPCs to determine a peer server's primary address, given the
          IP address from which a call arrived.  This needs to hold the
diff --git a/doc/xml/AdminGuide/auagd008.xml b/doc/xml/AdminGuide/auagd008.xml
index 9e4f11936..fe6105ebe 100644
--- a/doc/xml/AdminGuide/auagd008.xml
+++ b/doc/xml/AdminGuide/auagd008.xml
@@ -4671,7 +4671,7 @@
     convention, the first partition on a machine is mounted at <emphasis role="bold">/vicepa</emphasis>, the second at <emphasis
     role="bold">/vicepb</emphasis>, and so on to the twenty-sixth at <emphasis role="bold">/vicepz</emphasis>. Additional partitions
     are mounted at <emphasis role="bold">/vicepaa</emphasis> through <emphasis role="bold">/vicepaz</emphasis> and so on up to
-    <emphasis role="bold">/vicepiv</emphasis>. Using the letters consecutively is not required, but is simpler.</para>
+    <emphasis role="bold">/vicepiu</emphasis>. Using the letters consecutively is not required, but is simpler.</para>
 
     <para>Mount each <emphasis role="bold">/vicep</emphasis> directory directly under the local file system's root directory (
     <emphasis role="bold">/</emphasis> ), not as a subdirectory of any other directory; for example, <emphasis
diff --git a/doc/xml/AdminGuide/auagd023.xml b/doc/xml/AdminGuide/auagd023.xml
index 2de38732b..54039d2ce 100644
--- a/doc/xml/AdminGuide/auagd023.xml
+++ b/doc/xml/AdminGuide/auagd023.xml
@@ -349,8 +349,8 @@
         <para>and so on through</para>
 
         <programlisting>
-<emphasis role="bold">/vicepiv</emphasis>    =     <emphasis role="bold">vicepiv</emphasis>     =      <emphasis role="bold">iv</emphasis>     =      <emphasis
-            role="bold">255</emphasis>
+<emphasis role="bold">/vicepiu</emphasis>    =     <emphasis role="bold">vicepiu</emphasis>     =      <emphasis role="bold">iu</emphasis>     =      <emphasis
+            role="bold">254</emphasis>
 </programlisting>
       </sect3>
 
diff --git a/regen.sh b/regen.sh
index 3ada36c6b..3ae1987f0 100755
--- a/regen.sh
+++ b/regen.sh
@@ -26,11 +26,15 @@ else
   exit 1
 fi
 
+M4_INCS="-I src/cf"
+M4_INCS="$M4_INCS -I src/external/rra-c-util/m4"
+M4_INCS="$M4_INCS -I src/external/autoconf-archive/m4"
+
 echo "Running aclocal"
 if which aclocal > /dev/null 2>&1; then
-  aclocal -I src/cf -I src/external/rra-c-util/m4
+  aclocal $M4_INCS
 elif which aclocal-1.10 > /dev/null 2>&1; then
-  aclocal-1.10 -I src/cf -I src/external/rra-c-util/m4
+  aclocal-1.10 $M4_INCS
 else
   echo "No aclocal found on your system (looked for aclocal & aclocal-1.10)"
   exit 1
diff --git a/src/JAVA/libjafs/File.c b/src/JAVA/libjafs/File.c
index 080474219..78a6029f9 100644
--- a/src/JAVA/libjafs/File.c
+++ b/src/JAVA/libjafs/File.c
@@ -394,62 +394,6 @@ JNIEXPORT jlong JNICALL Java_org_openafs_jafs_File_listNative
   (JNIEnv *env, jobject obj, jobject buffer)
 {
   return 0;
-#if 0
-    char dirName[FILENAME_MAX];
-    jclass arrayListClass;
-    jmethodID addID;
-    jstring entryJString;
-    usr_DIR *dirp;
-    struct usr_dirent *enp;
-    int i, dirSize;
-
-    *dirName='\0';
-    getAbsolutePath(env, &obj, dirName);
-    if(*dirName == '\0') {
-      fprintf(stderr, "File::listNative(): failed to get dirName\n");
-      setError(env, &obj, -1);
-      return 0;
-    }
-    arrayListClass = (*env)->GetObjectClass(env, buffer);
-    if(arrayListClass == NULL) {
-      fprintf(stderr, "File::listNative(): GetObjectClass failed\n");
-      setError(env, &obj, -1);
-      return 0;
-    }
-    addID = (*env) -> GetMethodID(env, arrayListClass, "add", 
-                                  "(Ljava/lang/Object;)Z");
-    if(addID == 0) {
-      fprintf(stderr, 
-            "File::listNative(): failed to get addID\n");
-      setError(env, &obj, -1);
-      return 0;
-    }
-    dirp = uafs_opendir(dirName);
-    if(dirp == NULL) {
-      fprintf(stderr, "File::listNative(): uafs_opendir(%s) failed(%s)\n",
-                       dirName, afs_error_message(errno));
-      setError(env, &obj, errno);
-      //throwAFSSecurityException( env, errno );
-      return 0;
-    }
-    while((enp = uafs_readdir(dirp)) != NULL) {
-	if(strcmp(enp->d_name, ".") == 0 || strcmp(enp->d_name, "..") == 0) {
-        continue;
-	}
-      entryJString = (*env) -> NewStringUTF(env, enp->d_name);
-      if(entryJString == NULL) {
-        fprintf(stderr, "File::listNative(): NewStringUTF failed\n");
-        setError(env, &obj, -1);
-        return 0;
-      }
-      (*env) -> CallBooleanMethod(env, buffer, addID, entryJString);
-    }
-    /*uafs_closedir(dirp);*/
-
-    setError(env, &obj, 0);
-
-    return (jlong) dirp;
-#endif
 }
 
 /**
@@ -465,19 +409,6 @@ JNIEXPORT jboolean JNICALL Java_org_openafs_jafs_File_closeDir
 {
 
   return JNI_TRUE;
-
-#if 0
-  usr_DIR *dirp = (usr_DIR *) dp;
-  int rc;
-  
-  rc = uafs_closedir(dirp);
-  if (rc < 0) {
-    setError(env, &obj, errno);
-    return JNI_FALSE;
-  }
-  else return JNI_TRUE;
-#endif
-
 }
 
 
diff --git a/src/README.md b/src/README.md
new file mode 100644
index 000000000..61b8b1f36
--- /dev/null
+++ b/src/README.md
@@ -0,0 +1,178 @@
+Guide to the OpenAFS source tree
+================================
+
+This is a guide to the various directories in the OpenAFS source code tree.
+Some directories contain source code for components of the OpenAFS system,
+while other directories are used by the build system to build libraries, kernel
+modules, and program variations. See the `Makefile` at the top of the project
+tree for build order and inter-dependencies.
+
+RPC interface definitions (IDL)
+-------------------------------
+
+The following directory contains interface definitions (IDL) files for the
+OpenAFS file server and cache manager.
+
+| directory | description |
+| --------- | ----------- |
+| fsint     | File server and cache manager RPC interface definitions |
+
+Cache Managers
+--------------
+
+The following directories contain the source code of OpenAFS cache manager and
+related programs.
+
+| directory | description |
+| --------- | ----------- |
+| afs       | The OpenAFS cache manager as a kernel-module for unix-like systems |
+| afsd      | The `afsd` user-space program to start the cache manager on unix-like systems |
+| aklog     | The Kerberos 5 login programs: `aklog`, `asetkey`, `akeyconvert` |
+| sys       | NFS translator local and remote system call interfaces |
+| venus     | The `fs` program and other cache manager related utilities |
+| WINNT     | The OpenAFS cache manager and installer for MS Windows |
+| export    | Symbol exports for AIX kernel module |
+
+Servers
+-------
+
+The following directories contain the source code of the OpenAFS servers and
+administrative command suites.
+
+| directory | description |
+| --------- | ----------- |
+| bozo      | The basic overseer server and `bos` command suite |
+| ptserver  | The protection server and `pts` command suite |
+| update    | The update server and client for maintaining server software and configuration (deprecated) |
+| viced     | The file server |
+| vlserver  | The volume location server |
+| volser    | The volume server and `vos` command suite |
+
+Backup system
+-------------
+
+The following directories contain the source code of the OpenAFS backup system.
+
+| directory | description |
+| --------- | ----------- |
+| bubasics  | Backup related RPC interface definitions |
+| bucoord   | Backup coordinator and support library |
+| budb      | Backup database server `buserver` |
+| butc      | Backup tape coordinator, and `read_tape` restoration client |
+| butm      | Backup tape manager library |
+| `bu_utils` | Backup utilities to estimate tape capacity and file mark sizes |
+| tsm41     | Tivoli storage manager support |
+
+
+Rx subsystem
+------------
+
+The following directories contain the source code of the Rx subsystem. Rx
+provides Remote Procedure Calls (RPC) over UDP/IP in user-space and kernel-mode,
+and includes an XDR implementation to encode and decode binary data.
+
+| directory | description |
+| --------- | ----------- |
+| rx        | The Rx library for kernel and user-space |
+| rxdebug   | Debugging tool for rx |
+| rxgen     | The `rxgen` program to generate AFS RPC stubs from IDL (i.e., `*.xg`) |
+| rxgk      | Rxgk security class for rx |
+| rxkad     | Kerberos security module for rx |
+| rxosd     | Rx object storage device extensions IDL files |
+| rxstat    | Rx statistics package |
+
+Libraries
+---------
+
+The following directories contain the source code for the various libraries
+used by OpenAFS.
+
+| directory | description |
+| --------- | ----------- |
+| opr       | General purpose library for user-space and headers for kernel mode |
+| audit     | The `libaudit` event auditing support library |
+| auth      | The `libauth` library to manage key and cell configuration files |
+| cmd       | The `libcmd` library to parse command line arguments |
+| comerr    | The `com_err` library to provide error table lookup |
+| dir       | Modules to lookup, add, and remove entries in directory objects |
+| gtx       | A curses-based graphics library for terminal-based programs |
+| kopenafs  | The `libkopenafs` library for setting up stand-alone setpag() function for Heimdal/KTH libkafs |
+| libacl    | The `libacl` library for access control lists |
+| libadmin  | The `libadmin` administration API |
+| libafscp  | The `libafscp` library; client operations without a cache manager |
+| libafsrpc | The `libafsrpc` library; basic rx functionality for programs which do not require authentication |
+| libafsauthent | The `libafsauthent` library; for AFS-aware utilities |
+| procmgmt  | Process management library |
+| ubik      | Ubik replicated database library |
+| usd       | User-space device input/output library |
+| util      | Utility library (deprecated in favor of opr) |
+| vol       | Volume library for managing volumes on-disk |
+
+Utilities
+---------
+
+The following directories contain source code for utilities and libraries for
+OpenAFS administrators.
+
+| directory | description |
+| --------- | ----------- |
+| afsmonitor | Terminal-based file server and cache manager monitoring tool |
+| fsprobe   | File Server probe library and program |
+| scout     | Terminal-based file server monitoring tool |
+| tools     | Contributed configuration and maintenance tools |
+| xstat     | Command line tools and libraries for gathering file server and cache manager statistics |
+
+Other
+-----
+
+| directory | description |
+| --------- | ----------- |
+| external  | Contains imported code which is maintained in other open source projects |
+| platform  | Code for platform-specific programs and build specs. |
+
+
+Build system
+------------
+
+The following directories are build directories or contain components
+for the build system.
+
+| directory | description |
+| --------- | ----------- |
+| cf        | OpenAFS specific M4 macros for `autoconf`  |
+| config    | Build system OS-specific configuration |
+| crypto    | `libhcrypto` library build directory |
+| dviced    | Demand Attach File Server (DAFS) build directory |
+| dvolser   | Demand Attach Volume Server build directory  |
+| finale    | Final stage build directory; includes `translate_et` which translates error codes to descriptive messages |
+| libafs    | OpenAFS kernel modules build directory |
+| libuafs   | OpenAFS user-space cache manager build directory |
+| packaging | Contributed packaging files for various platforms |
+| roken     | Build directory for `libroken`, a set of os-independent functions|
+| tbudb     | Pthreaded Backup Server (`budb`) build directory |
+| tbutc     | Pthreaded Backup Tape Coordinator (`butc`) build directory |
+| tptserver | Pthreaded Protection Server (`ptserver`) build directory |
+| tsalvaged | Pthreaded Salvage Server build directory; Used by Demand Attach File Server |
+| tubik     | Pthreaded ubik build directory |
+| tvlserver | Pthreaded Volume Location `vlserver` build directory |
+| tvolser   | Pthreaded Volume Server build directory |
+
+
+Not Maintained
+--------------
+
+The following directories contain code of obsolete components which are no
+longer actively maintained.
+
+| directory | description |
+| --------- | ----------- |
+| afsinstall | Installation scripts and notes from IBM AFS |
+| afsweb    | Authenticated AFS access for older versions of Apache |
+| JAVA      | Java API library for OpenAFS development |
+| kauth     | Obsolete Kerberos-4 server (`kaserver`) and related programs |
+| log       | Obsolete programs to show and forget Kerberos-4 tokens |
+| lwp       | Lightweight user-level non-preemptive cooperative threading library |
+| pam       | Pluggable authentication modules (PAM) for kauth authentication |
+| tests     | Legacy test scripts; new unit tests should be added to the top level `tests` directory |
+| uss       | Tool for managing users; limited to kauth |
+| vfsck     | OpenAFS specific `fsck` for obsolete inode-based file server partitions |
diff --git a/src/SOURCE-MAP b/src/SOURCE-MAP
deleted file mode 100644
index ddcc4b0cb..000000000
--- a/src/SOURCE-MAP
+++ /dev/null
@@ -1,322 +0,0 @@
-Guide to the AFS source tree
-
-
- -- afs
-
-Routines which make up the kernel- and userlevel- cachemanager.
-
- -- afsd
-
-The afsd process which parses config files, sets up the cache,
-and forks off subprocess to start each of the libafs
-"kernel threads".
-
- -- afsinstall
-
-Leftovers from IBM AFS including installation notes and helper
-scripts.
-
- -- afsmonitor
-
-Afs monitoring tool.
-
- -- afsweb
-
-Authenticated AFS access via Apache. requires minor porting for
-newer Apache versions.
-
- -- aklog
-
-Kerberos v5 AFS login and related error routines as well as a linked list
-struct definition.
-
- -- audit
-
-Afs event auditing support library.
-
- -- auth
-
-Afsconf suite (CellServDB/UserList/ThisCell) and token interface,
-outdated copyauth program, setkey utility for adding a key
-to a server KeyFile (as a key).
-
- -- bozo
-
-Bos suite, includes bos client and bosserver.
-
- -- bubasics
-
-Backup related rpc interface definitions.
-
- -- bucoord
-
-Backup coordinator and support library.
-
- -- budb
-
-Backup database server (buserver).
-
- -- butc
-
-Backup tape coordinator, and read_tape restoral client.
-
- -- butm
-
-Backup tape manager library.
-
- -- bu_utils
-
-Backup utilities Fms (estimate tape capacity and file mark sizes)
-(not useful for tape drives with compression).
-
- -- cf
-
-Autoconf config files.
-
- -- cmd
-
-Cmd library, routines to parse cmd line arguments
-used by all command line utilities.
-
- -- comerr
-
-Com_err library, error table routines.
-
- -- config
-
-Build system OS-specific configuration.
-
- -- des
-
-Des library.
-
- -- dir
-
-Afs directory handling library (client and server, internal format).
-
- -- export
-
-EXPORT is an aix3.1 kernel extension whose sole purpose in
-life is to provide access to kernel symbols that were mistakenly
-(or purposefully) omitted from the kernel exports list.
-
- -- external
-
-Contains all source maintained upstream as external projects.
-
- -- finale
-
-Last part of the source to build:
-translate_et translates error codes to descriptive messages.
-
- -- fsint
-
-Fileserver and Cache manager RPC interface definitions.
-
- -- fsprobe
-
-Fileserver probe facility for information collection.
-
- -- gtx
-
-Graphics library for monitoring clients.
-
- -- JAVA
-
-Java API library for OpenAFS development.
-
- -- kauth
-
-Deprecated Kaserver suite including server, admin client, password
-changing and validating clients, token-getting and
-token-and-ticket-getting authentication clients, nfs
-authentication exporter and server database reconstructor.
-
- -- kopenafs
-
-Library and interface for setting up standalone setpag() function
-for Heimdal/KTH libkafs.
-
- -- libacl
-
-Acl library, routines for manipulation of ACLs.
-
- -- libadmin
-
-AFS administration API.
-
- -- libafs
-
-Directory where build system actually builds kernel modules.
-
- -- libafsauthent
-
-Pthreaded set of libraries for AFS-aware utilties.
-This and libafsrpc provide complete functionality.
-
- -- libafsrpc
-
-Pthreaded Afsrpc library. Provides basic Rx functionality for AFS-aware
-programs which don't need to do authentication.
-
- -- libuafs
-
-Userlevel cache manager build directory
-
- -- log
-
-Programs to show and forget tokens (and optionally forget tokens
-and tickets) and test program to create an AFS token.
-
- -- lwp
-
-Lightweight user-level non-preemptive cooperative threading library.
-
- -- pam
-
-Pluggable authentication modules for afs authentication.
-
- -- platform
-
-Platform-specific binaries and build specs for which
-the source tree provides no alternative location.
-
- -- procmgmt
-
-"Portable" process management library.
-
- -- ptserver
-
-The protection database server and clients.
-
- -- rx
-
-Rx rpc library for kernel and userspace.
-
- -- rxdebug
-
-Debugging tool for rx.
-
- -- rxgen
-
-Rxgen program. generates AFS RPC stubs from .xg files.
-
- -- rxkad
-
-Kerberos security module for rx.
-
- -- rxstat
-
-Rx statistics package.
-
- -- scout
-
-Monitoring tool for afs fileservers.
-
- -- sgistuff
-
-SGI authentication plugin for graphical login.
-
- -- shlibafsauthent
-
-Shared library version of libauthent.
-
- -- shlibafsrpc
-
-Shared library verion of libafsrpc.
-
- -- sys
-
-Local and remote system call interfaces. basic PAG-creation
-and remote system call handling for NFS translator.
-
- -- tbudb
-
-Pthreaded budb build dir.
-
- -- tbutc
-
-Pthreaded butc build dir.
-
- -- tests
-
-Legacy test scripts.
-
- -- tools
-
-Contributed configuration/maintenance tools.
-
- -- tptserver
-
-Pthreaded ptserver build dir.
-
- -- tsalvaged
-
-Pthreaded Salvageserver and salvync-debug build dir
-(used by demand-attach fileserver)
-
- -- tsm41
-
-Tivoli storage manager support for the backup system.
-
- -- tubik
-
-Pthreaded ubik build dir.
-
- -- tvlsever
-
-Pthreaded vlserver build dir.
-
- -- tvolser
-
-Pthreaded volser build dir
-
- -- ubik
-
-Ubik replicated database library.
-
- -- update
-
-Upserver/upclient for maintaining server software from a system
-control machine.
-
- -- usd
-
-Userspace device input/output library.
-
- -- uss
-
-Uss tool for managing users.
-
- -- util
-
-Swiss army knife library.
-
- -- venus
-
-Various cachemanager related utilities.
-
- -- vfsck
-
-Fsck for vice partitions on non-namei fileservers.
-
- -- viced
-
-Fileserver.
-
- -- vlserver
-
-Volume location server.
-
- -- vol
-
-Volume library for managing volumes on-disk.
-
- -- volser
-
-Volume server package. includes volserver and vos client.
-
- -- xstat
-
-Extended statistics clients for cachemanagers and fileservers,
-includes xstat library and xstatcommand line clients.
diff --git a/src/WINNT/afsadmsvr/TaAfsAdmSvrClientBind.cpp b/src/WINNT/afsadmsvr/TaAfsAdmSvrClientBind.cpp
index b986e5468..3dd62d06f 100644
--- a/src/WINNT/afsadmsvr/TaAfsAdmSvrClientBind.cpp
+++ b/src/WINNT/afsadmsvr/TaAfsAdmSvrClientBind.cpp
@@ -57,26 +57,7 @@ BOOL ADMINAPI BindToAdminServer (LPCTSTR pszAddress, BOOL fWait, UINT_PTR *pidCl
 
    for (DWORD dwTickStart = GetTickCount(); ; )
       {
-#ifdef notdef
-      // First we'll enumerate the name services around here to see if
-      // an admin server is already running.
-      //
-      RPC_NS_HANDLE hEnum;
-      if ((status = RpcNsBindingImportBegin (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_c_ifspec, NULL, &hEnum)) == 0)
-         {
-         RPC_BINDING_HANDLE hBind;
-         status = RpcNsBindingImportNext (hEnum, &hBind);
-         RpcNsBindingImportDone (&hEnum);
-
-         if (status)
-            RpcBindingFree (&hBind);
-         else if (ValidateBinding (hBind, pidClient, (ULONG*)&status))
-            return TRUE;
-         else if (status != RPC_S_CALL_FAILED_DNE) // server rejected us!
-            break;
-         }
-#endif
-      // Failing that, we'll try to bind to the well-known endpoint that the
+      // Try to bind to the well-known endpoint that the
       // admin server may have had to use. (if RpcNsBindingExport failed.)
       //
       unsigned char *pszStringBinding = NULL;
diff --git a/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp b/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp
index 8e513310d..bf758e530 100644
--- a/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp
+++ b/src/WINNT/afsadmsvr/TaAfsAdmSvrGeneral.cpp
@@ -653,7 +653,7 @@ void AfsAdmSvr_Action_StartRefresh (ASID idScope)
       {
       case itCELL:
          AfsAdmSvr_MarkRefreshThread (idScope);
-         // fall through
+         AFS_FALLTHROUGH;
 
       case itSERVER:
          ASACTION Action;
diff --git a/src/WINNT/afsadmsvr/TaAfsAdmSvrMain.cpp b/src/WINNT/afsadmsvr/TaAfsAdmSvrMain.cpp
index e62973855..ef8e8fd38 100644
--- a/src/WINNT/afsadmsvr/TaAfsAdmSvrMain.cpp
+++ b/src/WINNT/afsadmsvr/TaAfsAdmSvrMain.cpp
@@ -85,9 +85,6 @@ int cdecl main (int argc, char **argv)
    // Clean up any broken interface registration
    //
    RpcServerUnregisterIf (ITaAfsAdminSvr_v1_0_s_ifspec, 0, FALSE);
-#ifdef notdef
-   RpcNsBindingUnexport (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_s_ifspec, NULL);
-#endif
 
    // Register our interface
    //
@@ -125,13 +122,6 @@ int cdecl main (int argc, char **argv)
          {
          BOOL fExportedBinding = FALSE;
 
-#ifdef notdef
-         if ((status = RpcNsBindingExport (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_s_ifspec, pBindingVector, NULL)) == 0)
-            fExportedBinding = TRUE;
-         else
-            Print (dlWARNING, TEXT("RpcNsBindingExport failed (benign); error 0x%08lX"), status);
-#endif
-
          if (!fExportedBinding && !fGotPort)
             {
             Print (dlERROR, TEXT("RpcNsBindingExport failed; error 0x%08lX"), status);
@@ -166,15 +156,6 @@ int cdecl main (int argc, char **argv)
             AfsAdmSvr_Shutdown();
             }
 
-#ifdef notdef
-         if (fExportedBinding)
-            {
-            if ((status = RpcNsBindingUnexport (RPC_C_NS_SYNTAX_DEFAULT, pszENTRYNAME, ITaAfsAdminSvr_v1_0_s_ifspec, NULL)) != 0)
-               {
-               Print (dlWARNING, TEXT("RpcNsBindingExport failed; error 0x%08lX"), status);
-               }
-            }
-#endif
          if ((status = RpcEpUnregister (ITaAfsAdminSvr_v1_0_s_ifspec, pBindingVector, NULL)) != 0)
             {
             Print (dlWARNING, TEXT("RpcEpUnregister failed; error 0x%08lX"), status);
diff --git a/src/WINNT/afsapplib/al_browseset.cpp b/src/WINNT/afsapplib/al_browseset.cpp
index 672c45f45..fbb812594 100644
--- a/src/WINNT/afsapplib/al_browseset.cpp
+++ b/src/WINNT/afsapplib/al_browseset.cpp
@@ -301,46 +301,6 @@ DWORD WINAPI BrowseSet_Init_ThreadProc (LPARAM lp)
    // Fill in hList with the names of all filesets in the cell.
    //
    ULONG status = 0;
-#if 0
-   // TODO
-   if (OpenFTS (&status))
-      {
-      PVOID hCell;
-      if ((status = FtsOpenCell (szCellA, &hCell)) == 0)
-         {
-         fldb_short_ft_info_t *fti;
-         if ((status = FtsAllocateShortFtInfoBuffer (&fti)) == 0)
-            {
-            PVOID cookie = 0;
-            ULONG nEntries;
-
-            while ( (FtsListFilesetsFromFldb (hCell, fti, &nEntries, &cookie) == 0) && (nEntries > 0) )
-               {
-               if (!IsWindow ((HWND)(lpp->pInternal)))
-                  break;
-
-               for (ULONG ii = 0; ii < nEntries; ++ii)
-                  {
-#define DECODE_SHINFO_TYPE_FLAGS(_fl) ((_fl) >> 12)
-                  if (DECODE_SHINFO_TYPE_FLAGS(fti[ ii ].flags) & FTS_FT_SHINFO_TYPE_RW)
-                     {
-                     LPTSTR pszFileset;
-                     if ((pszFileset = CloneString (fti[ii].name)) != NULL)
-                        {
-                        PostMessage ((HWND)(lpp->pInternal), WM_FOUNDNAME, (WPARAM)pszFileset, 0);
-                        // string memory is freed by recipient of message
-                        }
-                     }
-                  }
-               }
-            FtsFreeShortFtInfoBuffer (fti);
-            }
-         FtsCloseCell (hCell);
-         }
-      CloseFTS();
-      }
-#endif
-
    if (IsWindow ((HWND)(lpp->pInternal)))
       PostMessage ((HWND)(lpp->pInternal), WM_THREADDONE, status, 0);
 
diff --git a/src/WINNT/afsapplib/resize.cpp b/src/WINNT/afsapplib/resize.cpp
index 0c1c5014b..98fd8e111 100644
--- a/src/WINNT/afsapplib/resize.cpp
+++ b/src/WINNT/afsapplib/resize.cpp
@@ -636,18 +636,6 @@ LONG APIENTRY SplitterWndProc (HWND hWnd, UINT msg, WPARAM wp, LPARAM lp)
                   SetWindowLong (hWnd, GWL_USER, 0);
                   }
                break;
-
-#if 0 // Enable me to make the splitters draw in black
-         case WM_PAINT:
-               {
-               PAINTSTRUCT ps;
-               HDC hdc = BeginPaint (hWnd, &ps);
-               FillRect (hdc, &ps.rcPaint, GetStockObject(BLACK_BRUSH));
-               EndPaint (hWnd, &ps);
-               return 0;
-               }
-               break;
-#endif
          }
       }
 
diff --git a/src/WINNT/afsclass/worker.cpp b/src/WINNT/afsclass/worker.cpp
index 5960fd6f7..2a65f6d85 100644
--- a/src/WINNT/afsclass/worker.cpp
+++ b/src/WINNT/afsclass/worker.cpp
@@ -30,21 +30,12 @@ extern "C" {
  *
  */
 
-#if 0
-static LPCTSTR cszAFSVOSDLL = TCHAR("AfsVosAdmin.dll");
-static LPCTSTR cszAFSBOSDLL = TCHAR("AfsBosAdmin.dll");
-static LPCTSTR cszAFSKASDLL = TCHAR("AfsKasAdmin.dll");
-static LPCTSTR cszAFSPTSDLL = TCHAR("AfsPtsAdmin.dll");
-static LPCTSTR cszAFSUTILDLL = TCHAR("AfsAdminUtil.dll");
-static LPCTSTR cszAFSCLIENTDLL = TCHAR("AfsClientAdmin.dll");
-#else
 static LPCTSTR cszAFSVOSDLL = __T("AfsVosAdmin.dll");
 static LPCTSTR cszAFSBOSDLL = __T("AfsBosAdmin.dll");
 static LPCTSTR cszAFSKASDLL = __T("AfsKasAdmin.dll");
 static LPCTSTR cszAFSPTSDLL = __T("AfsPtsAdmin.dll");
 static LPCTSTR cszAFSUTILDLL = __T("AfsAdminUtil.dll");
 static LPCTSTR cszAFSCLIENTDLL = __T("AfsClientAdmin.dll");
-#endif
 
 /*
  * VARIABLES __________________________________________________________________
diff --git a/src/WINNT/afsd/afskfw.c b/src/WINNT/afsd/afskfw.c
index 636b58b59..a45896fcf 100644
--- a/src/WINNT/afsd/afskfw.c
+++ b/src/WINNT/afsd/afskfw.c
@@ -1995,7 +1995,7 @@ MultiInputDialogProc( HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam)
                 if ( !GetDlgItemText(hDialog, ID_MID_TEXT+i, mid_tb[i].buf, mid_tb[i].len) )
                     *mid_tb[i].buf = '\0';
             }
-            /* fallthrough */
+            AFS_FALLTHROUGH;
         case IDCANCEL:
             EndDialog(hDialog, LOWORD(wParam));
             return TRUE;
diff --git a/src/WINNT/afsd/cm_btree.c b/src/WINNT/afsd/cm_btree.c
index 82cd9d378..615c4054e 100644
--- a/src/WINNT/afsd/cm_btree.c
+++ b/src/WINNT/afsd/cm_btree.c
@@ -2147,9 +2147,6 @@ long cm_BPlusDirBuildTree(cm_scache_t *scp, cm_user_t *userp, cm_req_t* reqp)
 
     bplus_build_time += (end.QuadPart - start.QuadPart);
 
-#if 0
-    cm_BPlusDirEnumTest(scp, 1);
-#endif
     return rc;
 }
 
diff --git a/src/WINNT/afsd/cm_buf.c b/src/WINNT/afsd/cm_buf.c
index 37c8e803a..57bd614c3 100644
--- a/src/WINNT/afsd/cm_buf.c
+++ b/src/WINNT/afsd/cm_buf.c
@@ -2603,37 +2603,6 @@ long buf_ClearRDRFlag(cm_scache_t *scp, char *reason)
     return 0;
 }
 
-#if 0
-long buf_CleanDirtyBuffers(cm_scache_t *scp)
-{
-    cm_buf_t *bp;
-    afs_uint32 bcount = 0;
-    cm_fid_t * fidp = &scp->fid;
-
-    for (bp = cm_data.buf_allp; bp; bp=bp->allp, bcount++) {
-	if (!cm_FidCmp(fidp, &bp->fid) && (bp->flags & CM_BUF_DIRTY)) {
-            buf_Hold(bp);
-	    lock_ObtainMutex(&bp->mx);
-	    _InterlockedAnd(&bp->cmFlags, ~CM_BUF_CMSTORING);
-	    _InterlockedAnd(&bp->flags, ~CM_BUF_DIRTY);
-            bp->dirty_length = 0;
-	    _InterlockedOr(&bp->flags, CM_BUF_ERROR);
-	    bp->error = VNOVNODE;
-	    bp->dataVersion = CM_BUF_VERSION_BAD; /* bad */
-	    bp->dirtyCounter++;
-	    if (bp->flags & CM_BUF_WAITING) {
-		osi_Log2(buf_logp, "BUF CleanDirtyBuffers Waking [scp 0x%x] bp 0x%x", scp, bp);
-		osi_Wakeup((long) &bp);
-	    }
-	    lock_ReleaseMutex(&bp->mx);
-	    buf_Release(bp);
-            buf_DecrementUsedCount();
-	}
-    }
-    return 0;
-}
-#endif
-
 /*
  * The following routines will not be used on a
  * regular basis but are very useful in a variety
diff --git a/src/WINNT/afsd/cm_callback.c b/src/WINNT/afsd/cm_callback.c
index 5816bbe3c..a5db1403e 100644
--- a/src/WINNT/afsd/cm_callback.c
+++ b/src/WINNT/afsd/cm_callback.c
@@ -1256,6 +1256,7 @@ SRXAFSCB_TellMeAboutYourself( struct rx_call *callp,
     }
 
     /* return all network interface addresses */
+    memset(addr, 0, sizeof(*addr));
     addr->numberOfInterfaces = cm_noIPAddr;
     addr->uuid = cm_data.Uuid;
     for ( i=0; i < cm_noIPAddr; i++ ) {
diff --git a/src/WINNT/afsd/cm_daemon.c b/src/WINNT/afsd/cm_daemon.c
index d6bfdfcbd..c3f41c852 100644
--- a/src/WINNT/afsd/cm_daemon.c
+++ b/src/WINNT/afsd/cm_daemon.c
@@ -252,7 +252,8 @@ void * cm_BkgDaemon(void * vparm)
                 cm_daemons[daemonID].retryCount++;
                 osi_QAddT((osi_queue_t **) &cm_daemons[daemonID].head, (osi_queue_t **)&cm_daemons[daemonID].tail, &rp->q);
                 break;
-            } /* otherwise fall through */
+            }
+            AFS_FALLTHROUGH;
         case 0:  /* success */
         default: /* other error */
             if (code == 0) {
@@ -881,17 +882,6 @@ void cm_DaemonShutdown(void)
 
     if (cm_LockDaemon_ShutdownEvent)
         code = thrd_WaitForSingleObject_Event(cm_LockDaemon_ShutdownEvent, INFINITE);
-
-#if 0
-    /*
-     * Do not waste precious time waiting for the ipaddr daemon to shutdown.
-     * When it does it means we have lost our network connection and we need
-     * it during cache shutdown in order to notify the file servers that this
-     * client is giving up all callbacks.
-     */
-    if (cm_IPAddrDaemon_ShutdownEvent)
-        code = thrd_WaitForSingleObject_Event(cm_IPAddrDaemon_ShutdownEvent, INFINITE);
-#endif
 }
 
 void cm_InitDaemon(int nDaemons)
diff --git a/src/WINNT/afsd/cm_getaddrs.c b/src/WINNT/afsd/cm_getaddrs.c
index 29e9d1a6c..73752bc3e 100644
--- a/src/WINNT/afsd/cm_getaddrs.c
+++ b/src/WINNT/afsd/cm_getaddrs.c
@@ -244,17 +244,17 @@ cm_GetAddrsU(cm_cell_t *cellp, cm_user_t *userp, cm_req_t *reqp,
 	code = cm_MapVLRPCError(code, reqp);
 
 	if (afsd_logp->enabled) {
-	    char uuidstr[128];
-	    afsUUID_to_string(Uuid, uuidstr, sizeof(uuidstr));
+	    struct uuid_fmtbuf uuidstr;
+	    afsUUID_to_string(Uuid, &uuidstr);
 
 	    if (code)
 		osi_Log2(afsd_logp,
 			  "CALL VL_GetAddrsU serverNumber %s FAILURE, code 0x%x",
-			  osi_LogSaveString(afsd_logp, uuidstr),
+			  osi_LogSaveString(afsd_logp, uuidstr.buffer),
 			  code);
 	    else
 		osi_Log1(afsd_logp, "CALL VL_GetAddrsU serverNumber %s SUCCESS",
-			  osi_LogSaveString(afsd_logp, uuidstr));
+			  osi_LogSaveString(afsd_logp, uuidstr.buffer));
 	}
 
 	if (code)
diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c
index 5322479d8..ba4530fc8 100644
--- a/src/WINNT/afsd/cm_ioctl.c
+++ b/src/WINNT/afsd/cm_ioctl.c
@@ -2526,151 +2526,6 @@ cm_UsernameToId(char *uname, cm_ucell_t * ucellp, afs_uint32* uid)
 }
 #endif /* QUERY_AFSID */
 
-#if 0
-/* This has been copied to smb_IoctlSetToken in its entirety.
- * An equivalent version will need to be produced for the
- * redirector and some extensive refactoring might be required.
- */
-afs_int32
-cm_IoctlSetToken(struct cm_ioctl *ioctlp, struct cm_user *userp)
-{
-    char *saveDataPtr;
-    char *tp;
-    int ticketLen;
-    char *ticket;
-    int ctSize;
-    struct ClearToken ct;
-    cm_cell_t *cellp;
-    cm_ucell_t *ucellp;
-    char *uname = NULL;
-    afs_uuid_t uuid;
-    int flags;
-    char sessionKey[8];
-    char *smbname;
-    int release_userp = 0;
-    char * wdir = NULL;
-
-    saveDataPtr = ioctlp->inDatap;
-
-    cm_SkipIoctlPath(ioctlp);
-
-    tp = ioctlp->inDatap;
-
-    /* ticket length */
-    memcpy(&ticketLen, tp, sizeof(ticketLen));
-    tp += sizeof(ticketLen);
-    if (ticketLen < MINKTCTICKETLEN || ticketLen > MAXKTCTICKETLEN)
-        return CM_ERROR_INVAL;
-
-    /* remember ticket and skip over it for now */
-    ticket = tp;
-    tp += ticketLen;
-
-    /* clear token size */
-    memcpy(&ctSize, tp, sizeof(ctSize));
-    tp += sizeof(ctSize);
-    if (ctSize != sizeof(struct ClearToken))
-        return CM_ERROR_INVAL;
-
-    /* clear token */
-    memcpy(&ct, tp, ctSize);
-    tp += ctSize;
-    if (ct.AuthHandle == -1)
-        ct.AuthHandle = 999;	/* more rxvab compat stuff */
-
-    /* more stuff, if any */
-    if (ioctlp->inCopied > tp - saveDataPtr) {
-        /* flags:  logon flag */
-        memcpy(&flags, tp, sizeof(int));
-        tp += sizeof(int);
-
-        /* cell name */
-        cellp = cm_GetCell(tp, CM_FLAG_CREATE | CM_FLAG_NOPROBE);
-        if (!cellp)
-            return CM_ERROR_NOSUCHCELL;
-        tp += strlen(tp) + 1;
-
-        /* user name */
-        uname = tp;
-        tp += strlen(tp) + 1;
-
-        if (flags & PIOCTL_LOGON) {
-            /* SMB user name with which to associate tokens */
-            smbname = tp;
-            osi_Log2(smb_logp,"cm_IoctlSetToken for user [%s] smbname [%s]",
-                     osi_LogSaveString(smb_logp,uname), osi_LogSaveString(smb_logp,smbname));
-            fprintf(stderr, "SMB name = %s\n", smbname);
-            tp += strlen(tp) + 1;
-        } else {
-            osi_Log1(smb_logp,"cm_IoctlSetToken for user [%s]",
-                     osi_LogSaveString(smb_logp, uname));
-        }
-
-		/* uuid */
-        memcpy(&uuid, tp, sizeof(uuid));
-        if (!cm_FindTokenEvent(uuid, sessionKey))
-            return CM_ERROR_INVAL;
-    } else {
-        cellp = cm_data.rootCellp;
-        osi_Log0(smb_logp,"cm_IoctlSetToken - no name specified");
-    }
-
-    if (flags & PIOCTL_LOGON) {
-        clientchar_t *cname;
-
-        cname = cm_FsStringToClientStringAlloc(smbname, -1, NULL);
-
-        userp = smb_FindCMUserByName(cname, ioctlp->fidp->vcp->rname,
-				     SMB_FLAG_CREATE|SMB_FLAG_AFSLOGON);
-        if (cname)
-            free(cname);
-	release_userp = 1;
-    }
-
-    /* store the token */
-    lock_ObtainMutex(&userp->mx);
-    ucellp = cm_GetUCell(userp, cellp);
-    osi_Log1(smb_logp,"cm_IoctlSetToken ucellp %lx", ucellp);
-    ucellp->ticketLen = ticketLen;
-    if (ucellp->ticketp)
-        free(ucellp->ticketp);	/* Discard old token if any */
-    ucellp->ticketp = malloc(ticketLen);
-    memcpy(ucellp->ticketp, ticket, ticketLen);
-    /*
-     * Get the session key from the RPC, rather than from the pioctl.
-     */
-    /*
-    memcpy(&ucellp->sessionKey, ct.HandShakeKey, sizeof(ct.HandShakeKey));
-    */
-    memcpy(ucellp->sessionKey.data, sessionKey, sizeof(sessionKey));
-    ucellp->kvno = ct.AuthHandle;
-    ucellp->expirationTime = ct.EndTimestamp;
-    ucellp->gen++;
-#ifdef QUERY_AFSID
-    ucellp->uid = ANONYMOUSID;
-#endif
-    if (uname) {
-        StringCbCopyA(ucellp->userName, MAXKTCNAMELEN, uname);
-#ifdef QUERY_AFSID
-	cm_UsernameToId(uname, ucellp, &ucellp->uid);
-#endif
-    }
-    _InterlockedOr(&ucellp->flags, CM_UCELLFLAG_RXKAD);
-    lock_ReleaseMutex(&userp->mx);
-
-    if (flags & PIOCTL_LOGON) {
-        ioctlp->flags |= CM_IOCTLFLAG_LOGON;
-    }
-
-    cm_ResetACLCache(cellp, userp);
-
-    if (release_userp)
-	cm_ReleaseUser(userp);
-
-    return 0;
-}
-#endif
-
 /*
  * VIOC_GETTOK internals.
  *
diff --git a/src/WINNT/afsd/cm_nls.c b/src/WINNT/afsd/cm_nls.c
index 9b70b727b..06b81f780 100644
--- a/src/WINNT/afsd/cm_nls.c
+++ b/src/WINNT/afsd/cm_nls.c
@@ -1309,23 +1309,6 @@ int cm_stricmp_utf8(const char * str1, const char * str2)
     }
 }
 
-#if 0
-wchar_t * strupr_utf16(wchar_t * wstr, size_t cbstr)
-{
-    wchar_t wstrd[NLSMAXCCH];
-    int len;
-
-    if (!nls_init)
-        cm_InitNormalization();
-
-    len = cbstr / sizeof(wchar_t);
-    len = LCMapStringW(nls_lcid, LCMAP_UPPERCASE, wstr, len, wstrd, NLSMAXCCH);
-    StringCbCopyW(wstr, cbstr, wstrd);
-
-    return wstr;
-}
-#endif
-
 char * strupr_utf8(char * str, size_t cbstr)
 {
     wchar_t wstr[NLSMAXCCH];
diff --git a/src/WINNT/afsd/cm_nls.h b/src/WINNT/afsd/cm_nls.h
index 403047abc..4d6591400 100644
--- a/src/WINNT/afsd/cm_nls.h
+++ b/src/WINNT/afsd/cm_nls.h
@@ -274,18 +274,5 @@ cm_is_valid_utf16(__in_z const wchar_t * c, int cch);
 wchar_t * cm_GetRawCharsAlloc(const wchar_t * c, int len);
 #endif
 
-#if 0
-
-extern long cm_NormalizeUtf16StringToUtf8(const wchar_t * src, int cch_src,
-                                          char * adest, int cch_adest);
-
-extern char * char_next_utf8(const char * c);
-
-extern char * char_prev_utf8(const char * c);
-
-extern char * strupr_utf8(char * str, size_t cbstr);
-
-#endif
-
 #define lengthof(a) (sizeof(a)/sizeof(a[0]))
 #endif
diff --git a/src/WINNT/afsd/cm_performance.c b/src/WINNT/afsd/cm_performance.c
index 41343e534..4a25c4ade 100644
--- a/src/WINNT/afsd/cm_performance.c
+++ b/src/WINNT/afsd/cm_performance.c
@@ -118,24 +118,6 @@ void cm_PerformanceAddSCache(cm_scache_t *scp)
     }
     lock_ReleaseRead(&scp->rw);
 
-#if 0
-    if (statp->fid.vnode == 1) {
-        cm_volume_t *volp = NULL;
-        cm_cell_t *cellp = NULL;
-        cm_req_t req;
-
-        cm_InitReq(&req);
-
-        cellp = cm_FindCellByID(statp->fid.cell, 0);
-        if (cellp) {
-            if (!cm_FindVolumeByID(cellp, statp->fid.volume, cm_rootUserp, &req, 0, &volp)) {
-                statp->flags |= CM_FIDSTATS_HAVE_VOLUME;
-                cm_PutVolume(volp);
-            }
-        }
-    }
-#endif
-
     cm_PerformanceInsertToHashTable(statp);
 }
 
diff --git a/src/WINNT/afsd/cm_server.c b/src/WINNT/afsd/cm_server.c
index fa3a7e9c6..155f1b4ac 100644
--- a/src/WINNT/afsd/cm_server.c
+++ b/src/WINNT/afsd/cm_server.c
@@ -1606,7 +1606,7 @@ int cm_DumpServers(FILE *outputFile, char *cookie, int lock)
     int zilch;
     cm_server_t *tsp;
     char output[1024];
-    char uuidstr[128];
+    struct uuid_fmtbuf uuidstr;
     char hoststr[16];
 
     if (lock)
@@ -1634,8 +1634,7 @@ int cm_DumpServers(FILE *outputFile, char *cookie, int lock)
         default:
             type = "unknown";
         }
-
-        afsUUID_to_string(&tsp->uuid, uuidstr, sizeof(uuidstr));
+        afsUUID_to_string(&tsp->uuid, &uuidstr);
         afs_inet_ntoa_r(tsp->addr.sin_addr.s_addr, hoststr);
         down = ctime(&tsp->downTime);
         down[strlen(down)-1] = '\0';
@@ -1645,7 +1644,7 @@ int cm_DumpServers(FILE *outputFile, char *cookie, int lock)
 		 "flags=0x%x waitCount=%u pingCount=%d rank=%u downTime=\"%s\" "
 		 "refCount=%u\r\n",
                  cookie, tsp, tsp->cellp ? tsp->cellp->name : "", hoststr,
-                 ntohs(tsp->addr.sin_port), uuidstr, type,
+                 ntohs(tsp->addr.sin_port), uuidstr.buffer, type,
 		 tsp->capabilities, tsp->flags, tsp->waitCount, tsp->pingCount,
 		 tsp->activeRank,
                  (tsp->flags & CM_SERVERFLAG_DOWN) ?  "down" : "up",
diff --git a/src/WINNT/afsd/cm_utils.c b/src/WINNT/afsd/cm_utils.c
index f89b84bc3..c335a4098 100644
--- a/src/WINNT/afsd/cm_utils.c
+++ b/src/WINNT/afsd/cm_utils.c
@@ -768,7 +768,7 @@ int cm_MatchMask(clientchar_t *namep, clientchar_t *maskp, int flags)
             break;
         case '.':
             dot++;
-            /* fallthrough */
+            AFS_FALLTHROUGH;
         default:
             if ( star ) {
                 newmask[j++] = '*';
diff --git a/src/WINNT/afsd/cm_vnodeops.c b/src/WINNT/afsd/cm_vnodeops.c
index 1c3edd6df..074a97045 100644
--- a/src/WINNT/afsd/cm_vnodeops.c
+++ b/src/WINNT/afsd/cm_vnodeops.c
@@ -1913,21 +1913,12 @@ long cm_AssembleLink(cm_scache_t *linkScp, fschar_t *pathSuffixp,
         StringCchCopyA(tsp->data,lengthof(tsp->data), linkp);
         code = CM_ERROR_PATH_NOT_COVERED;
     } else if (*linkp == '\\' || *linkp == '/') {
-#if 0
-        /* formerly, this was considered to be from the AFS root,
-         * but this seems to create problems.  instead, we will just
-         * reject the link */
-        StringCchCopyA(tsp->data,lengthof(tsp->data), linkp+1);
-        *newRootScpp = cm_RootSCachep(userp, reqp);
-        cm_HoldSCache(*newRootScpp);
-#else
         /* we still copy the link data into the response so that
          * the user can see what the link points to
          */
         linkScp->fileType = CM_SCACHETYPE_INVALID;
         StringCchCopyA(tsp->data,lengthof(tsp->data), linkp);
         code = CM_ERROR_NOSUCHPATH;
-#endif
     } else {
         /* a relative link */
         StringCchCopyA(tsp->data,lengthof(tsp->data), linkp);
@@ -4740,20 +4731,6 @@ long cm_IntSetLock(cm_scache_t * scp, cm_user_t * userp, int lockType,
 
     osi_Log2(afsd_logp, "CALL SetLock scp 0x%p for lock %d", scp, lockType);
 
-#if 0
-    /*
-     * The file server prior to 1.6.2 does not report an accurate value
-     * and callbacks are not issued if the lock is dropped due to expiration.
-     */
-    if ((lockType != LOCKING_ANDX_SHARED_LOCK && scp->fsLockCount != 0) ||
-         (lockType == LOCKING_ANDX_SHARED_LOCK && scp->fsLockCount < 0))
-    {
-        code = CM_ERROR_LOCK_NOT_GRANTED;
-        osi_Log2(afsd_logp, "CALL SetLock FAILURE, fsLockCount %d code 0x%x", scp->fsLockCount, code);
-        return code;
-    }
-#endif
-
     memset(&volSync, 0, sizeof(volSync));
 
     tfid.Volume = scp->fid.volume;
diff --git a/src/WINNT/afsd/cm_volume.c b/src/WINNT/afsd/cm_volume.c
index c85107ba7..1fdbf4168 100644
--- a/src/WINNT/afsd/cm_volume.c
+++ b/src/WINNT/afsd/cm_volume.c
@@ -581,16 +581,15 @@ long cm_UpdateVolumeLocation(struct cm_cell *cellp, cm_user_t *userp, cm_req_t *
                  * vlserver.  If not, ...?
                  */
                 if (!afs_uuid_equal(&serverUUID[i], &tsp->uuid)) {
-                    char uuid1[128], uuid2[128];
+                    struct uuid_fmtbuf uuid1, uuid2;
                     char hoststr[16];
-
-                    afsUUID_to_string(&serverUUID[i], uuid1, sizeof(uuid1));
-                    afsUUID_to_string(&tsp->uuid, uuid2, sizeof(uuid2));
+                    afsUUID_to_string(&serverUUID[i], &uuid1);
+                    afsUUID_to_string(&tsp->uuid, &uuid2);
                     afs_inet_ntoa_r(serverNumber[i], hoststr);
 
                     osi_Log3(afsd_logp, "cm_UpdateVolumeLocation UUIDs do not match! %s != %s (%s)",
-                              osi_LogSaveString(afsd_logp, uuid1),
-                              osi_LogSaveString(afsd_logp, uuid2),
+                              osi_LogSaveString(afsd_logp, uuid1.buffer),
+                              osi_LogSaveString(afsd_logp, uuid2.buffer),
                               osi_LogSaveString(afsd_logp, hoststr));
                 }
             }
diff --git a/src/WINNT/afsd/fs.c b/src/WINNT/afsd/fs.c
index f77033d02..a7f0722cc 100644
--- a/src/WINNT/afsd/fs.c
+++ b/src/WINNT/afsd/fs.c
@@ -3049,10 +3049,6 @@ GetCellCmd(struct cmd_syndesc *as, void *arock)
             continue;
 	}
 	printf("Cell %s status: ", info.name);
-#ifdef notdef
-	if (args.stat & 1)
-            printf("primary ");
-#endif
 	if (args.stat & 2)
             printf("no setuid allowed");
 	else
@@ -5251,9 +5247,6 @@ int wmain(int argc, wchar_t **wargv)
     ts = cmd_CreateSyntax("setvol", SetVolCmd, NULL, 0, "set volume status");
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL, "disk space quota in 1K units");
-#ifdef notdef
-    cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "disk space guaranteed");
-#endif
     cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
     cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL, "offline message");
     cmd_CreateAlias(ts, "sv");
@@ -5323,9 +5316,6 @@ int wmain(int argc, wchar_t **wargv)
     ts = cmd_CreateSyntax("setquota", SetQuotaCmd, NULL, 0, "set volume quota");
     cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
-#ifdef notdef
-    cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
-#endif
     cmd_CreateAlias(ts, "sq");
 
     ts = cmd_CreateSyntax("newcell", NewCellCmd, NULL, 0, "configure new cell");
diff --git a/src/WINNT/afsd/krb.h b/src/WINNT/afsd/krb.h
index 0065a9421..9ac508f9b 100644
--- a/src/WINNT/afsd/krb.h
+++ b/src/WINNT/afsd/krb.h
@@ -157,69 +157,6 @@ typedef struct ktext KTEXT_ST;
 /* Error code returned by krb_mk_safe */
 #define		SAFE_PRIV_ERROR	-1	/* syscall error */
 
-#if 0
-/*
- * macros for byte swapping; also scratch space
- * u_quad  0-->7, 1-->6, 2-->5, 3-->4, 4-->3, 5-->2, 6-->1, 7-->0
- * u_long  0-->3, 1-->2, 2-->1, 3-->0
- * u_short 0-->1, 1-->0
- */
-
-#define     swap_u_16(x) {\
- unsigned long   _krb_swap_tmp[4];\
- swab(((char *) x) +0, ((char *)  _krb_swap_tmp) +14 ,2); \
- swab(((char *) x) +2, ((char *)  _krb_swap_tmp) +12 ,2); \
- swab(((char *) x) +4, ((char *)  _krb_swap_tmp) +10 ,2); \
- swab(((char *) x) +6, ((char *)  _krb_swap_tmp) +8  ,2); \
- swab(((char *) x) +8, ((char *)  _krb_swap_tmp) +6 ,2); \
- swab(((char *) x) +10,((char *)  _krb_swap_tmp) +4 ,2); \
- swab(((char *) x) +12,((char *)  _krb_swap_tmp) +2 ,2); \
- swab(((char *) x) +14,((char *)  _krb_swap_tmp) +0 ,2); \
- memcpy((char *)x, (char *)_krb_swap_tmp, 16);\
-                            }
-
-#define     swap_u_12(x) {\
- unsigned long   _krb_swap_tmp[4];\
- swab(( char *) x,     ((char *)  _krb_swap_tmp) +10 ,2); \
- swab(((char *) x) +2, ((char *)  _krb_swap_tmp) +8 ,2); \
- swab(((char *) x) +4, ((char *)  _krb_swap_tmp) +6 ,2); \
- swab(((char *) x) +6, ((char *)  _krb_swap_tmp) +4 ,2); \
- swab(((char *) x) +8, ((char *)  _krb_swap_tmp) +2 ,2); \
- swab(((char *) x) +10,((char *)  _krb_swap_tmp) +0 ,2); \
- memcpy((char *)x, (char *)_krb_swap_tmp, 12);\
-                            }
-
-#define     swap_C_Block(x) {\
- unsigned long   _krb_swap_tmp[4];\
- swab(( char *) x,    ((char *)  _krb_swap_tmp) +6 ,2); \
- swab(((char *) x) +2,((char *)  _krb_swap_tmp) +4 ,2); \
- swab(((char *) x) +4,((char *)  _krb_swap_tmp) +2 ,2); \
- swab(((char *) x) +6,((char *)  _krb_swap_tmp)    ,2); \
- memcpy((char *)x, (char *)_krb_swap_tmp, 8);\
-                            }
-#define     swap_u_quad(x) {\
- unsigned long   _krb_swap_tmp[4];\
- swab(( char *) &x,    ((char *)  _krb_swap_tmp) +6 ,2); \
- swab(((char *) &x) +2,((char *)  _krb_swap_tmp) +4 ,2); \
- swab(((char *) &x) +4,((char *)  _krb_swap_tmp) +2 ,2); \
- swab(((char *) &x) +6,((char *)  _krb_swap_tmp)    ,2); \
- memcpy((char *)&x, (char *)_krb_swap_tmp, 8);\
-                            }
-
-#define     swap_u_long(x) {\
- unsigned long   _krb_swap_tmp[4];\
- swab((char *)  &x,    ((char *)  _krb_swap_tmp) +2 ,2); \
- swab(((char *) &x) +2,((char *)  _krb_swap_tmp),2); \
- x = _krb_swap_tmp[0];   \
-                           }
-
-#define     swap_u_short(x) {\
- unsigned short	_krb_swap_sh_tmp; \
- swab((char *)  &x,    ( &_krb_swap_sh_tmp) ,2); \
- x = (unsigned short) _krb_swap_sh_tmp; \
-                            }
-#endif /* 0 */
-
 #include "krb_prot.h"
 
 static send_to_kdc(
diff --git a/src/WINNT/afsd/rpc_srvsvc.c b/src/WINNT/afsd/rpc_srvsvc.c
index 2c8f462e4..899e2ad6c 100644
--- a/src/WINNT/afsd/rpc_srvsvc.c
+++ b/src/WINNT/afsd/rpc_srvsvc.c
@@ -877,12 +877,12 @@ NET_API_STATUS NetrShareGetInfo(
                 NetrIntGenerateSharePath(ServerName, &scp->fid);
             /* must be the empty string */
             InfoStruct->ShareInfo2->shi2_passwd = wcsdup(L"");
-            /* fall-through */
+            AFS_FALLTHROUGH;
         case 1:
             InfoStruct->ShareInfo1->shi1_type = STYPE_DISKTREE;
             InfoStruct->ShareInfo1->shi1_remark =
                 NetrIntGenerateShareRemark(scp, &scp->fid);
-            /* fall-through */
+            AFS_FALLTHROUGH;
         case 0:
             /* Canonicalized version of NetName parameter */
             InfoStruct->ShareInfo0->shi0_netname = wcsdup(NetName);
@@ -995,7 +995,7 @@ NET_API_STATUS NetrServerGetInfo(
     switch (Level) {
     case 103:
         InfoStruct->ServerInfo103->sv103_capabilities = 0;
-        /* fall-through */
+        AFS_FALLTHROUGH;
     case 102:
         InfoStruct->ServerInfo102->sv102_users = 0xFFFFFFFF;
         InfoStruct->ServerInfo102->sv102_disc = SV_NODISC;
@@ -1004,13 +1004,13 @@ NET_API_STATUS NetrServerGetInfo(
         InfoStruct->ServerInfo102->sv102_anndelta = 0;
         InfoStruct->ServerInfo102->sv102_licenses = 0;
         InfoStruct->ServerInfo102->sv102_userpath = wcsdup(L"C:\\");
-        /* fall-through */
+        AFS_FALLTHROUGH;
     case 101:
         InfoStruct->ServerInfo101->sv101_version_major = AFSPRODUCT_VERSION_MAJOR;
         InfoStruct->ServerInfo101->sv101_version_minor = AFSPRODUCT_VERSION_MINOR;
         InfoStruct->ServerInfo101->sv101_type = SV_TYPE_WORKSTATION | SV_TYPE_SERVER | SV_TYPE_SERVER_UNIX;
         InfoStruct->ServerInfo101->sv101_comment = wcsdup(wAFSVersion);
-        /* fall-through */
+        AFS_FALLTHROUGH;
     case 100:
         InfoStruct->ServerInfo100->sv100_platform_id = SV_PLATFORM_ID_AFS;
         /* The Netbios Name */
@@ -1426,18 +1426,6 @@ void __RPC_USER SHARE_DEL_HANDLE_rundown( SHARE_DEL_HANDLE h)
 {
 }
 
-#if 0
-/* [nocode] */ void Opnum3NotUsedOnWire(
-    /* [in] */ handle_t IDL_handle)
-{
-}
-
-/* [nocode] */ void Opnum4NotUsedOnWire(
-    /* [in] */ handle_t IDL_handle)
-{
-}
-#endif
-
 /* [nocode] */ void Opnum5NotUsedOnWire(
     /* [in] */ handle_t IDL_handle)
 {
diff --git a/src/WINNT/afsd/smb.c b/src/WINNT/afsd/smb.c
index c1adc591c..4bfb1bee2 100644
--- a/src/WINNT/afsd/smb.c
+++ b/src/WINNT/afsd/smb.c
@@ -3908,13 +3908,7 @@ long smb_ReceiveNegotiate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
     }
 
     lock_ObtainMutex(&vcp->mx);
-#if 0
-    if (VistaProtoIndex != -1) {
-        protoIndex = VistaProtoIndex;
-        vcp->flags |= (SMB_VCFLAG_USENT | SMB_VCFLAG_USEV3);
-    } else
-#endif
-	if (NTProtoIndex != -1) {
+    if (NTProtoIndex != -1) {
         protoIndex = NTProtoIndex;
         vcp->flags |= (SMB_VCFLAG_USENT | SMB_VCFLAG_USEV3);
     }
@@ -9477,7 +9471,7 @@ void smb_Server(VOID *parmp)
         case NRC_SNUMOUT:
 	case NRC_SABORT:
 	    LogEvent(EVENTLOG_WARNING_TYPE, MSG_UNEXPECTED_SMB_SESSION_CLOSE, ncb_error_string(rc));
-	    /* fallthrough */
+	    AFS_FALLTHROUGH;
 	case NRC_SCLOSED:
             /* Client closed session */
             vcp = smb_FindVC(ncbp->ncb_lsn, 0, lanas[idx_session]);
@@ -9846,36 +9840,6 @@ void smb_Listener(void *parmp)
             lock_ReleaseMutex(&smb_StartedLock);
 	    break;
 	}
-#if 0
-        else if (code != 0) {
-            char tbuffer[AFSPATHMAX];
-
-            /* terminate silently if shutdown flag is set */
-            while (!lock_TryMutex(&smb_StartedLock)) {
-                if (smb_ListenerState == SMB_LISTENER_STOPPED || smbShutdownFlag == 1)
-                    goto exit_thread;
-                Sleep(50);
-            }
-
-            osi_Log3(smb_logp,
-                     "NCBLISTEN lana=%d failed with code %d [%s]",
-                     ncbp->ncb_lana_num, code, ncb_error_string(code));
-            osi_Log0(smb_logp,
-                     "Client exiting due to network failure. Please restart client.\n");
-
-            sprintf(tbuffer,
-                     "Client exiting due to network failure.  Please restart client.\n"
-                     "NCBLISTEN lana=%d failed with code %d [%s]",
-                     ncbp->ncb_lana_num, code, ncb_error_string(code));
-            if (showErrors)
-                code = (*smb_MBfunc)(NULL, tbuffer, "AFS Client Service: Fatal Error",
-                                      MB_OK|MB_SERVICE_NOTIFICATION);
-            osi_panic(tbuffer, __FILE__, __LINE__);
-
-            lock_ReleaseMutex(&smb_StartedLock);
-            break;
-        }
-#endif /* 0 */
 
         /* a successful packet received.  clear bridge error count */
         bridgeCount = 0;
diff --git a/src/WINNT/afsd/smb3.c b/src/WINNT/afsd/smb3.c
index 290b1e715..006e2fa86 100644
--- a/src/WINNT/afsd/smb3.c
+++ b/src/WINNT/afsd/smb3.c
@@ -3766,10 +3766,6 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
 /* TRANS2_SET_PATH_INFORMATION */
 long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *opx)
 {
-#if 0
-    osi_Log0(smb_logp,"ReceiveTran2SetPathInfo - NOT_SUPPORTED");
-    return CM_ERROR_BADOP;
-#else
     long code = 0;
     unsigned short infoLevel;
     clientchar_t * pathp;
@@ -3968,7 +3964,6 @@ long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet
     smb_FreeTran2Packet(outp);
 
     return 0;
-#endif
 }
 
 /* TRANS2_QUERY_FILE_INFORMATION */
@@ -5397,12 +5392,12 @@ long smb_T2SearchDirSingle(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op
                    shortName);
             fp->u.FfileBothDirectoryInfo.shortNameLength = cm_ClientStrLen(shortName);
 #endif
-    }
-        /* Fallthrough */
+        }
+        AFS_FALLTHROUGH;
 
     case SMB_FIND_FILE_FULL_DIRECTORY_INFO:
         fp->u.FfileFullDirectoryInfo.eaSize = 0;
-        /* Fallthrough */
+        AFS_FALLTHROUGH;
 
     case SMB_FIND_FILE_DIRECTORY_INFO:
         fp->u.FfileDirectoryInfo.nextEntryOffset = 0;
@@ -6113,11 +6108,11 @@ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
                     fp->u.FfileBothDirectoryInfo.shortNameLength = cm_ClientStrLen(shortName);
 #endif
                 }
-                /* Fallthrough */
+                AFS_FALLTHROUGH;
 
             case SMB_FIND_FILE_FULL_DIRECTORY_INFO:
                 fp->u.FfileFullDirectoryInfo.eaSize = 0;
-                /* Fallthrough */
+                AFS_FALLTHROUGH;
 
             case SMB_FIND_FILE_DIRECTORY_INFO:
                 fp->u.FfileDirectoryInfo.nextEntryOffset = orbytes + align;
diff --git a/src/WINNT/afsrdr/kernel/lib/AFSInit.cpp b/src/WINNT/afsrdr/kernel/lib/AFSInit.cpp
index f25f5d556..3eb45b812 100644
--- a/src/WINNT/afsrdr/kernel/lib/AFSInit.cpp
+++ b/src/WINNT/afsrdr/kernel/lib/AFSInit.cpp
@@ -122,32 +122,6 @@ DriverEntry( PDRIVER_OBJECT DriverObject,
 
 	RtlGetVersion( &AFSRtlSysVersion);
 
-#if 0
-        //
-        // By not fetching the RtlSetSaclSecurityDescriptor function
-        // pointer it disables the additional of a mandatory label
-        // to the default acl which is returned by AFSRedir for all
-        // security information queries.   The addition of the
-        // mandatory label appears to have a negative consequence
-        // for roaming profiles and redirected folders.  All links
-        // become untrusted and IE9 is unable to open a new instance
-        // to a non-default home page.
-        //
-        //
-        // Only retrieve this function for Vista and above since
-        // Mandatory Labels only exist on those operating systems.
-        //
-
-	if( AFSRtlSysVersion.dwMajorVersion >= 6)
-        {
-            RtlInitUnicodeString( &uniRoutine,
-                                  L"RtlSetSaclSecurityDescriptor");
-
-            AFSRtlSetSaclSecurityDescriptor = (PAFSRtlSetSaclSecurityDescriptor)MmGetSystemRoutineAddress( &uniRoutine);
-        }
-
-#endif
-
         RtlInitUnicodeString( &uniRoutine,
                               L"RtlSetGroupSecurityDescriptor");
 
diff --git a/src/WINNT/afsrdr/user/RDRFunction.c b/src/WINNT/afsrdr/user/RDRFunction.c
index 940deda7e..cffb9b58c 100644
--- a/src/WINNT/afsrdr/user/RDRFunction.c
+++ b/src/WINNT/afsrdr/user/RDRFunction.c
@@ -4091,24 +4091,6 @@ RDR_RequestFileExtentsAsync( IN cm_user_t *userp,
                 bHaveBuffer = TRUE;
             } else if (bufp->flags & CM_BUF_DIRTY) {
                 bHaveBuffer = FALSE;
-#if 0
-                code = buf_CleanAsyncLocked(scp, bufp, &req, 0, NULL);
-                switch (code) {
-                case 0:
-                    bHaveBuffer = TRUE;
-                    break;
-                case CM_ERROR_RETRY:
-                    /* Couldn't flush it, obtain it asynchronously so we don't block the thread. */
-                    bHaveBuffer = FALSE;
-                    code = 0;
-                    break;
-                default:
-                    smb_MapNTError(cm_MapRPCError(code, &req), &status, TRUE);
-                    RDR_SetFileStatus(&FileId, &userp->authgroup, status);
-                    bHaveBuffer = FALSE;
-                    code = 0;
-                }
-#endif
             } else {
                 osi_hyper_t minLength;  /* effective end of file */
 
diff --git a/src/WINNT/afssvrmgr/svr_getdates.cpp b/src/WINNT/afssvrmgr/svr_getdates.cpp
index 07096e8fe..b8ba3409b 100644
--- a/src/WINNT/afssvrmgr/svr_getdates.cpp
+++ b/src/WINNT/afssvrmgr/svr_getdates.cpp
@@ -97,7 +97,7 @@ BOOL WINAPI Server_GetDates_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
                {
                case IDOK:
                   Server_GetDates_OnOK (hDlg);
-                  // fall through
+                  AFS_FALLTHROUGH;
 
                case IDCANCEL:
                   DestroyWindow (hDlg);
diff --git a/src/WINNT/afssvrmgr/svr_install.cpp b/src/WINNT/afssvrmgr/svr_install.cpp
index 2dfca8bff..f77b54dcb 100644
--- a/src/WINNT/afssvrmgr/svr_install.cpp
+++ b/src/WINNT/afssvrmgr/svr_install.cpp
@@ -94,7 +94,7 @@ BOOL WINAPI Server_Install_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
                {
                case IDOK:
                   Server_Install_OnOK (hDlg);
-                  // fall through
+                  AFS_FALLTHROUGH;
 
                case IDCANCEL:
                   DestroyWindow (hDlg);
diff --git a/src/WINNT/afssvrmgr/svr_prune.cpp b/src/WINNT/afssvrmgr/svr_prune.cpp
index ac39fc337..d645b1656 100644
--- a/src/WINNT/afssvrmgr/svr_prune.cpp
+++ b/src/WINNT/afssvrmgr/svr_prune.cpp
@@ -94,7 +94,7 @@ BOOL WINAPI Server_Prune_DlgProc (HWND hDlg, UINT msg, WPARAM wp, LPARAM lp)
                {
                case IDOK:
                   Server_Prune_OnOK (hDlg);
-                  // fall through
+                  AFS_FALLTHROUGH;
 
                case IDCANCEL:
                   DestroyWindow (hDlg);
diff --git a/src/WINNT/client_config/config.cpp b/src/WINNT/client_config/config.cpp
index c6d1938a2..8d064a99d 100644
--- a/src/WINNT/client_config/config.cpp
+++ b/src/WINNT/client_config/config.cpp
@@ -217,134 +217,6 @@ BOOL Config_SetCellName (LPCTSTR pszName, ULONG *pStatus)
    return TRUE;
 }
 
-#if 0
-/* 	These two functions are not needed as of the 1.2.2a updates.
-	The old implementation used to 'bind' afslogon.dll to the credentials manager
-	when the Integrated Logon was selected.
-
-	With version 1.2.2a afslogon.dll is always 'bound' to the credentials manager; therefore,
-	the binding operation is done during installation.  Note: the Integrated Logon is
-	selected by an entry in the registry (LogonOptions).
-*/
-void Config_GetAuthentFlag (BOOL *pfFlag)
-{
-   *pfFlag = FALSE;
-
-   HKEY hk;
-   if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Control\\NetworkProvider\\Order"), 0, KEY_QUERY_VALUE, &hk) == ERROR_SUCCESS)
-      {
-      if (g.fIsWinNT)
-         {
-         TCHAR szProviders[ MAX_PATH ] = TEXT("");
-         DWORD dwSize = sizeof(szProviders);
-
-         if (RegQueryValueEx (hk, TEXT("ProviderOrder"), NULL, NULL, (PBYTE)szProviders, &dwSize) == ERROR_SUCCESS)
-            {
-            for (LPTSTR pch = szProviders; *pch; )
-               {
-               if (!lstrncmpi (pch, TEXT("TransarcAFSDaemon"), lstrlen(TEXT("TransarcAFSDaemon"))))
-                  *pfFlag = TRUE;
-
-               for ( ; *pch && (*pch != TEXT(',')); ++pch)
-                  ;
-               for ( ; *pch == TEXT(','); ++pch)
-                  ;
-               }
-            }
-
-         RegCloseKey (hk);
-         }
-      else // (!g.fIsWinNT)
-         {
-         TCHAR szLHS[ MAX_PATH ] = TEXT("");
-         DWORD dwSize = sizeof(szLHS);
-
-         if (RegQueryValueEx (hk, TEXT("TransarcAFSDaemon"), NULL, NULL, (PBYTE)szLHS, &dwSize) == ERROR_SUCCESS)
-            *pfFlag = TRUE;
-         }
-      }
-}
-
-
-BOOL Config_SetAuthentFlag (BOOL fFlag, ULONG *pStatus)
-{
-   ULONG status = 0;
-   BOOL rc = FALSE;
-
-   HKEY hk;
-   DWORD dwDisp;
-   if ((status = RegCreateKeyEx (HKEY_LOCAL_MACHINE, TEXT("System\\CurrentControlSet\\Control\\NetworkProvider\\Order"), 0, TEXT("container"), 0, KEY_QUERY_VALUE | KEY_SET_VALUE, NULL, &hk, &dwDisp)) == ERROR_SUCCESS)
-      {
-      if (g.fIsWinNT)
-         {
-         TCHAR szOldProviders[ MAX_PATH ] = TEXT("");
-         TCHAR szNewProviders[ MAX_PATH ] = TEXT("");
-         DWORD dwSize = sizeof(szOldProviders);
-         RegQueryValueEx (hk, TEXT("ProviderOrder"), NULL, NULL, (PBYTE)szOldProviders, &dwSize);
-
-         for (LPTSTR pch = szOldProviders; *pch; )
-            {
-            BOOL fCopy = TRUE;
-            if (!lstrncmpi (pch, TEXT("TransarcAFSDaemon"), lstrlen(TEXT("TransarcAFSDaemon"))))
-               {
-               fCopy = fFlag;
-               fFlag = FALSE;
-               }
-
-            if (fCopy)
-               {
-               LPTSTR pchOut = &szNewProviders[ lstrlen(szNewProviders) ];
-               if (szNewProviders[0])
-                  *pchOut++ = TEXT(',');
-               for ( ; *pch && (*pch != TEXT(',')); )
-                  *pchOut++ = *pch++;
-               *pchOut = TEXT('\0');
-               }
-
-            for ( ; *pch && (*pch != TEXT(',')); ++pch)
-               ;
-            for ( ; *pch == TEXT(','); ++pch)
-               ;
-            }
-
-         if (fFlag)
-            {
-            if (szNewProviders[0])
-               lstrcat (szNewProviders, TEXT(","));
-            lstrcat (szNewProviders, TEXT("TransarcAFSDaemon"));
-            }
-
-         if ((status = RegSetValueEx (hk, TEXT("ProviderOrder"), NULL, REG_SZ, (PBYTE)szNewProviders, sizeof(TCHAR)*(1+lstrlen(szNewProviders)))) == ERROR_SUCCESS)
-            rc = TRUE;
-         }
-      else // (!g.fIsWinNT)
-         {
-         TCHAR szLHS[ cchRESOURCE ] = TEXT("TransarcAFSDaemon");
-         TCHAR szRHS[ cchRESOURCE ] = TEXT("");
-
-         if (fFlag)
-            {
-            if ((status = RegSetValueEx (hk, szLHS, NULL, REG_SZ, (PBYTE)szRHS, sizeof(TCHAR)*(lstrlen(szRHS)+1))) == 0)
-               rc = TRUE;
-            }
-         else
-            {
-            RegDeleteValue (hk, szLHS);
-            rc = TRUE;
-            }
-         }
-
-      RegCloseKey (hk);
-      }
-
-   if (pStatus && !rc)
-      *pStatus = status;
-   if (!rc)
-      Message (MB_ICONHAND, GetErrorTitle(), IDS_FAILCONFIG_AUTHENT, TEXT("%ld"), status);
-   return rc;
-}
-#endif
-
 void Config_GetTrayIconFlag (BOOL *pfFlag)
 {
    if (!Config_ReadUserNum (TEXT("ShowTrayIcon"), (DWORD*)pfFlag))
diff --git a/src/WINNT/client_config/drivemap.cpp b/src/WINNT/client_config/drivemap.cpp
index cb9a9a21a..30f86a3cf 100644
--- a/src/WINNT/client_config/drivemap.cpp
+++ b/src/WINNT/client_config/drivemap.cpp
@@ -198,30 +198,6 @@ static void FreeStringMemory (LPTSTR pszString)
    Free (pszString);
 }
 
-#if 0
-static int lstrncmpi (LPCTSTR pszA, LPCTSTR pszB, size_t cch)
-{
-   if (!pszA || !pszB)
-      {
-      return (!pszB) - (!pszA);   // A,!B:1, !A,B:-1, !A,!B:0
-      }
-
-   for ( ; cch > 0; cch--, pszA = CharNext(pszA), pszB = CharNext(pszB))
-      {
-      TCHAR chA = toupper( *pszA );
-      TCHAR chB = toupper( *pszB );
-
-      if (!chA || !chB)
-         return (!chB) - (!chA);    // A,!B:1, !A,B:-1, !A,!B:0
-
-      if (chA != chB)
-         return (int)(chA) - (int)(chB);   // -1:A<B, 0:A==B, 1:A>B
-      }
-
-   return 0;  // no differences before told to stop comparing, so A==B
-}
-#endif
-
 /*
  * REALLOC ____________________________________________________________________
  *
diff --git a/src/WINNT/client_config/tab_hosts.cpp b/src/WINNT/client_config/tab_hosts.cpp
index a6c6a98f3..40cb578da 100644
--- a/src/WINNT/client_config/tab_hosts.cpp
+++ b/src/WINNT/client_config/tab_hosts.cpp
@@ -321,11 +321,6 @@ void HostsTab_FillList (HWND hDlg)
       TCHAR szText[ MAX_PATH ];
       lstrcpy (szText, Info.szCell);
 
-#if 0 // Add this if you like a more verbose Cell Hosts tab
-      if (Info.szComment)
-         wsprintf (&szText[ lstrlen(szText) ], TEXT(" (%s)"), Info.szComment);
-#endif
-
       FASTLISTADDITEM ai;
       memset (&ai, 0x00, sizeof(ai));
       ai.iFirstImage = IMAGE_NOIMAGE;
diff --git a/src/WINNT/client_creds/ipaddrchg.c b/src/WINNT/client_creds/ipaddrchg.c
index 5bfb3c15e..f2aec04f4 100644
--- a/src/WINNT/client_creds/ipaddrchg.c
+++ b/src/WINNT/client_creds/ipaddrchg.c
@@ -146,13 +146,7 @@ pingFS(void *ping_params, struct sockaddr_in *addrp, char *namep)
         return 0;
     }
 
-    for (;;)
-    {
-        tv.tv_sec = pp->host.wait;
-        tv.tv_usec = 0;
-        if (IOMGR_Select(0, 0, 0, 0, &tv))
-            break;
-    }
+    fsprobe_Wait(0);
     probeComplete();
     return(0);
 }
diff --git a/src/WINNT/client_osi/osidb.c b/src/WINNT/client_osi/osidb.c
index 98adc044d..ec349e74c 100644
--- a/src/WINNT/client_osi/osidb.c
+++ b/src/WINNT/client_osi/osidb.c
@@ -107,36 +107,6 @@ void dbrpc_Close(handle_t handle, osi_remHyper_t *fnp, long *codep)
 		*codep = OSI_DBRPC_NOFD;
 }
 
-#ifdef notdef
-long osi_CleanupRPCEntry(char *exportName)
-{
-	UUID_VECTOR uuidvp;
-	RPC_NS_HANDLE thandle;
-	UUID tuuid;
-	long code;
-
-	code = RpcNsEntryObjectInqBegin(RPC_C_NS_SYNTAX_DCE, exportName, &thandle);
-	if (code != RPC_S_OK && code != RPC_S_ENTRY_NOT_FOUND) return code;
-	while(1) {
-		code = RpcNsEntryObjectInqNext(thandle, &tuuid);
-		if (code == RPC_S_NO_MORE_MEMBERS) {
-			code = 0;
-			break;
-		}
-		else if (code != RPC_S_OK) {
-			break;
-		}
-		uuidvp.Count = 1;
-		uuidvp.Uuid[0] = &tuuid;
-		code = RpcNsBindingUnexport(RPC_C_NS_SYNTAX_DCE, exportName, dbrpc_v1_0_s_ifspec,
-			&uuidvp);
-		if (code != RPC_S_OK && code != RPC_S_INTERFACE_NOT_FOUND) break;
-	}
-	RpcNsEntryObjectInqDone(&thandle);
-	return code;
-}
-#endif /* notdef */
-
 long osi_InitDebug(osi_uid_t *exportIDp)
 {
 	RPC_STATUS rpcStatus;
@@ -174,22 +144,10 @@ long osi_InitDebug(osi_uid_t *exportIDp)
 	uuidVector.Count = 1;
 	uuidVector.Uuid[0] = exportIDp;
 
-#ifdef notdef
-	/* don't use CDS any longer; too big and slow */
-	rpcStatus = osi_CleanupRPCEntry(exportName);
-	if (rpcStatus) goto done;
-#endif /* notdef */
-
 	rpcStatus = RpcEpRegister(dbrpc_v1_0_s_ifspec, bindingVector,
 		&uuidVector, (unsigned char *) 0);
 	if (rpcStatus != RPC_S_OK) goto done;
 
-#ifdef notdef
-	/* don't use CDS */
-	rpcStatus = RpcNsBindingExport(RPC_C_NS_SYNTAX_DCE, exportName,
-		dbrpc_v1_0_s_ifspec, bindingVector, &uuidVector);
-#endif /* notdef */
-
 	rpcStatus = RpcBindingVectorFree(&bindingVector);
 	if (rpcStatus != RPC_S_OK) goto done;
 
diff --git a/src/WINNT/client_osi/osidebug.c b/src/WINNT/client_osi/osidebug.c
index 244ed2e91..2cb72b290 100644
--- a/src/WINNT/client_osi/osidebug.c
+++ b/src/WINNT/client_osi/osidebug.c
@@ -321,63 +321,6 @@ main_formatCache_t *main_GetFormatCache(RPC_BINDING_HANDLE handle, char *typep,
 	else return NULL;
 }
 
-#ifdef notdef
-/* take a name and return a working binding to the server.  Server must be
- * exporting a dbrpc interface.
- */
-main_GetBinding(char *name, RPC_BINDING_HANDLE *handlep)
-{
-	RPC_NS_HANDLE tempContext;	/* context used for iteration */
-	RPC_BINDING_HANDLE thp;		/* temp handle we're using now */
-	long code;
-	int count=0;
-	int valid;
-
-	code = RpcNsBindingImportBegin(RPC_C_NS_SYNTAX_DCE, name, *dbrpc_v1_0_c_ifspecp,
-		(UUID *) 0, &tempContext);
-	if (code != RPC_S_OK) return code;
-
-	/* this next line is useful when trying to debug things */
-	// RpcNsMgmtHandleSetExpAge(tempContext, 0);
-
-	valid = 0;	/* is thp valid? */
-	while (1) {
-		code = RpcNsBindingImportNext(tempContext, &thp);
-		if (code == RPC_S_NO_MORE_BINDINGS) break;	/* we're done */
-
-		if (code != RPC_S_OK) {
-			RpcNsBindingImportDone(&tempContext);
-			return code;
-		}
-
-		/* otherwise we have a putatively good binding; try it out
-		 * with the probe interface and see if it really works
-		 */
-                code = RpcMgmtSetComTimeout(thp, 2);
-
-		code = 0;
-		RpcTryExcept {
-			dbrpc_Ping(thp);
-		}
-		RpcExcept(1) {
-			code = RpcExceptionCode();
-		}
-		RpcEndExcept;
-
-		/* now, if call worked, we're done */
-		if (code == 0) break;
-
-		/* else cleanup the binding and try again */
-		RpcBindingFree(&thp);
-	}
-
-	/* cleanup and return */
-	RpcNsBindingImportDone(&tempContext);
-	*handlep = thp;
-	return code;
-}
-#endif /* notdef */
-
 main_GetBinding(char *hostNamep, UUID *exportIDp, RPC_BINDING_HANDLE *handlep)
 {
 	char *stringBindingp;
diff --git a/src/WINNT/doc/install/Documentation/ko_KR/html/SysAdminGd/auagd007.htm b/src/WINNT/doc/install/Documentation/ko_KR/html/SysAdminGd/auagd007.htm
index 6d8b70901..066391275 100755
--- a/src/WINNT/doc/install/Documentation/ko_KR/html/SysAdminGd/auagd007.htm
+++ b/src/WINNT/doc/install/Documentation/ko_KR/html/SysAdminGd/auagd007.htm
@@ -1754,7 +1754,7 @@ ACL
 <PRE>   % <B>tokens.krb</B>
    Tokens held by the Cache Manager:
    User's (AFS ID 1000) tokens for afs@example.com [Expires Jun  2 10:00]
-   User smith's tokens for krbtgt.Example.COM@example.com [Expires Jun  2 10:00]
+   User smith's tokens for krbtgt.EXAMPLE.COM@example.com [Expires Jun  2 10:00]
      --End of list--
 </PRE>
 <P><H3><A NAME="Header_82" HREF="auagd002.htm#ToC_82">»ç¿ëÀÚ¿¡ ´ëÇÑ ÅäÅ« ±âº» ¼ö¸í ¼³Á¤</A></H3>
diff --git a/src/WINNT/install/NSIS/CellServDB b/src/WINNT/install/NSIS/CellServDB
index eaca48763..a6bd8fc38 100644
--- a/src/WINNT/install/NSIS/CellServDB
+++ b/src/WINNT/install/NSIS/CellServDB
@@ -1,4 +1,4 @@
->grand.central.org      #GCO Public CellServDB 14 Mar 2017
+>grand.central.org      #GCO Public CellServDB 14 May 2018
 18.9.48.14                      #grand.mit.edu
 128.2.13.219                    #grand-old-opry.central.org
 >wu-wien.ac.at          #University of Economics, Vienna, Austria
@@ -270,10 +270,10 @@
 >acm.jhu.edu            #Johns Hopkins ACM chapter
 128.220.35.191                  #chicago.acm.jhu.edu
 128.220.70.76                   #typhon.acm.jhu.edu
->athena.mit.edu         #Cell Name
+>athena.mit.edu         #MIT/Athena cell
+18.7.45.11                      #leda.mit.edu
 18.9.48.11                      #castor.mit.edu
 18.9.48.12                      #pollux.mit.edu
-18.27.2.14                      #prill.mit.edu
 >csail.mit.edu          #MIT Computer Science & Artificial Intelligence Lab
 128.30.2.13                     #titanic.csail.mit.edu
 128.30.2.31                     #vasa.csail.mit.edu
@@ -286,12 +286,10 @@
 18.7.62.60                      #willy.mit.edu
 18.9.48.15                      #moby.mit.edu
 18.9.48.16                      #springer.mit.edu
->numenor.mit.edu        #Project Numenor
-18.243.2.49                     #numenor.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.4.60.19                      #reynelda.mit.edu
+18.4.60.22                      #rosebud.mit.edu
+18.4.60.23                      #ronald-ann.mit.edu
 >msu.edu                #Michigan State University Main Cell
 35.9.7.10                       #afsdb0.cl.msu.edu
 35.9.7.11                       #afsdb1.cl.msu.edu
@@ -535,11 +533,11 @@
 >laroia.net             #Laroia Networks
 66.66.102.254                   #supercore.laroia.net
 >pallissard.net         #pallissard.net
-198.98.51.77                    #a001.pallissard.net
+35.184.35.247                   #files.pallissard.net
 >sinenomine.net         #Sine Nomine Associates
-199.167.73.142                  #afsdb1.sinenomine.net
-199.167.73.152                  #afsdb4.sinenomine.net
-199.167.73.153                  #afsdb5.sinenomine.net
+207.89.43.108                   #afsdb3.sinenomine.net
+207.89.43.109                   #afsdb4.sinenomine.net
+207.89.43.110                   #afsdb5.sinenomine.net
 >slackers.net           #The Slackers' Network
 199.4.150.159                   #alexandria.slackers.net
 >tproa.net              #The People's Republic of Ames
@@ -610,11 +608,9 @@
 130.237.233.143                 #castor.mech.kth.se
 130.237.233.144                 #pollux.mech.kth.se
 >nada.kth.se            #Royal Institute of Technology, NADA
-130.237.222.20                  #afsdb-1.csc.kth.se
 130.237.223.12                  #afsdb-2.csc.kth.se
 130.237.224.78                  #afsdb-3.csc.kth.se
 130.237.227.23                  #afsdb-4.csc.kth.se
-130.237.228.28                  #afsdb-5.csc.kth.se
 >pdc.kth.se             #Royal Institute of Technology, PDC
 130.237.232.29                  #crab.pdc.kth.se
 130.237.232.112                 #anna.pdc.kth.se
@@ -644,7 +640,6 @@
 194.190.165.201                 #fs0001.ihep.su
 194.190.165.202                 #fs0002.ihep.su
 >motherfsck.tech        #motherfsck.tech
-198.98.52.149                   #a001.motherfsck.tech
 >hep-ex.physics.metu.edu.tr #METU Department of Physics, Experimental HEP group, Ankara/Turke
 144.122.31.131                  #neutrino.physics.metu.edu.tr
 >phy.bris.ac.uk         #Bristol University - physics
diff --git a/src/WINNT/install/loopback/wmi.cpp b/src/WINNT/install/loopback/wmi.cpp
index baf00998f..79793fe9b 100644
--- a/src/WINNT/install/loopback/wmi.cpp
+++ b/src/WINNT/install/loopback/wmi.cpp
@@ -361,20 +361,6 @@ WMIEnableStatic(
 
     ReportMessage(0,"Found Adapter Instance",NULL, InstancePath,0);
 
-#if 0
-    // Use the adapter instance index to set MAXLANA in the registry.
-    {
-        DWORD dwIndex;
-        if (swscanf(InstancePath, L"Win32_NetworkAdapterConfiguration.Index=%u", &dwIndex)==1)
-        {
-            DWORD ret = 0;
-            ReportMessage(1,"Setting MAXLANA",NULL,NULL,dwIndex+1);
-            ret = AdjustMaxLana(dwIndex+1);
-            if (ret) ReportMessage(0,"AdjustMaxLana returned the error code ",NULL,NULL,ret);
-        }
-    }
-#endif
-
     MethodName = SysAllocString(L"EnableStatic");
     CLEANUP_ON_AND_SET(!MethodName, hr, E_OUTOFMEMORY);
 
@@ -955,25 +941,6 @@ BOOL UpdateHostsFile( LPCWSTR swName, LPCWSTR swIp, LPCSTR szFilename, BOOL bPre
 }
 
 #ifdef TEST
-#if 0
-int
-wmain(
-    int argc,
-    wchar_t* argv[]
-    )
-{
-    if (argc < 3)
-    {
-        printf("usage: %S ip mask\n"
-               "  example: %S 10.0.0.1 255.0.0.0", argv[0], argv[0]);
-        return 0;
-    }
-
-    return WMIEnableStatic(FindNetworkAdapterConfigurationInstanceByGUID,
-                           L"{B4981E32-551C-4164-96B6-B8874BD2E555}",
-                           argv[1], argv[2]);
-}
-#else
 int
 wmain(
     int argc,
@@ -992,5 +959,4 @@ wmain(
                            argv[1], argv[2], argv[3]);
 }
 #endif
-#endif
 
diff --git a/src/WINNT/install/wix/CellServDB b/src/WINNT/install/wix/CellServDB
index eaca48763..a6bd8fc38 100644
--- a/src/WINNT/install/wix/CellServDB
+++ b/src/WINNT/install/wix/CellServDB
@@ -1,4 +1,4 @@
->grand.central.org      #GCO Public CellServDB 14 Mar 2017
+>grand.central.org      #GCO Public CellServDB 14 May 2018
 18.9.48.14                      #grand.mit.edu
 128.2.13.219                    #grand-old-opry.central.org
 >wu-wien.ac.at          #University of Economics, Vienna, Austria
@@ -270,10 +270,10 @@
 >acm.jhu.edu            #Johns Hopkins ACM chapter
 128.220.35.191                  #chicago.acm.jhu.edu
 128.220.70.76                   #typhon.acm.jhu.edu
->athena.mit.edu         #Cell Name
+>athena.mit.edu         #MIT/Athena cell
+18.7.45.11                      #leda.mit.edu
 18.9.48.11                      #castor.mit.edu
 18.9.48.12                      #pollux.mit.edu
-18.27.2.14                      #prill.mit.edu
 >csail.mit.edu          #MIT Computer Science & Artificial Intelligence Lab
 128.30.2.13                     #titanic.csail.mit.edu
 128.30.2.31                     #vasa.csail.mit.edu
@@ -286,12 +286,10 @@
 18.7.62.60                      #willy.mit.edu
 18.9.48.15                      #moby.mit.edu
 18.9.48.16                      #springer.mit.edu
->numenor.mit.edu        #Project Numenor
-18.243.2.49                     #numenor.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.4.60.19                      #reynelda.mit.edu
+18.4.60.22                      #rosebud.mit.edu
+18.4.60.23                      #ronald-ann.mit.edu
 >msu.edu                #Michigan State University Main Cell
 35.9.7.10                       #afsdb0.cl.msu.edu
 35.9.7.11                       #afsdb1.cl.msu.edu
@@ -535,11 +533,11 @@
 >laroia.net             #Laroia Networks
 66.66.102.254                   #supercore.laroia.net
 >pallissard.net         #pallissard.net
-198.98.51.77                    #a001.pallissard.net
+35.184.35.247                   #files.pallissard.net
 >sinenomine.net         #Sine Nomine Associates
-199.167.73.142                  #afsdb1.sinenomine.net
-199.167.73.152                  #afsdb4.sinenomine.net
-199.167.73.153                  #afsdb5.sinenomine.net
+207.89.43.108                   #afsdb3.sinenomine.net
+207.89.43.109                   #afsdb4.sinenomine.net
+207.89.43.110                   #afsdb5.sinenomine.net
 >slackers.net           #The Slackers' Network
 199.4.150.159                   #alexandria.slackers.net
 >tproa.net              #The People's Republic of Ames
@@ -610,11 +608,9 @@
 130.237.233.143                 #castor.mech.kth.se
 130.237.233.144                 #pollux.mech.kth.se
 >nada.kth.se            #Royal Institute of Technology, NADA
-130.237.222.20                  #afsdb-1.csc.kth.se
 130.237.223.12                  #afsdb-2.csc.kth.se
 130.237.224.78                  #afsdb-3.csc.kth.se
 130.237.227.23                  #afsdb-4.csc.kth.se
-130.237.228.28                  #afsdb-5.csc.kth.se
 >pdc.kth.se             #Royal Institute of Technology, PDC
 130.237.232.29                  #crab.pdc.kth.se
 130.237.232.112                 #anna.pdc.kth.se
@@ -644,7 +640,6 @@
 194.190.165.201                 #fs0001.ihep.su
 194.190.165.202                 #fs0002.ihep.su
 >motherfsck.tech        #motherfsck.tech
-198.98.52.149                   #a001.motherfsck.tech
 >hep-ex.physics.metu.edu.tr #METU Department of Physics, Experimental HEP group, Ankara/Turke
 144.122.31.131                  #neutrino.physics.metu.edu.tr
 >phy.bris.ac.uk         #Bristol University - physics
diff --git a/src/WINNT/kfw/inc/krb4/conf.h b/src/WINNT/kfw/inc/krb4/conf.h
index 2e2a84cd6..fca3ee0e8 100644
--- a/src/WINNT/kfw/inc/krb4/conf.h
+++ b/src/WINNT/kfw/inc/krb4/conf.h
@@ -47,11 +47,6 @@ typedef void *pointer;
 #endif
 #endif
 
-/* Does your compiler understand "void"? */
-#ifdef notdef
-#define void int
-#endif
-
 /*
  * A few checks to see that necessary definitions are included.
  */
diff --git a/src/WINNT/kfw/inc/krb4/krb.h b/src/WINNT/kfw/inc/krb4/krb.h
index 37431fbdb..59134da14 100644
--- a/src/WINNT/kfw/inc/krb4/krb.h
+++ b/src/WINNT/kfw/inc/krb4/krb.h
@@ -43,15 +43,6 @@ typedef unsigned short gid_t;
  * the realm.
  */
 
-#ifdef notdef
-/* this is server - only, does not belong here; */
-#define         KRBLOG          "/kerberos/kerberos.log"
-/* are these used anyplace? */
-#define         VX_KRB_HSTFILE  "/etc/krbhst"
-#define         PC_KRB_HSTFILE  "\\kerberos\\krbhst"
-#endif
-
-#ifdef PC
 
 #define         KRB_CONF        "krb.con"
 #define         KRB_RLM_TRANS   "krbrealm.con"
diff --git a/src/WINNT/kfw/inc/krb5/krb5/krb5.h b/src/WINNT/kfw/inc/krb5/krb5/krb5.h
index 29dc7643e..23b80b8c9 100644
--- a/src/WINNT/kfw/inc/krb5/krb5/krb5.h
+++ b/src/WINNT/kfw/inc/krb5/krb5/krb5.h
@@ -859,9 +859,6 @@ krb5_error_code krb5_decrypt_data
 #define	KRB5_PADATA_TGS_REQ		KRB5_PADATA_AP_REQ
 #define KRB5_PADATA_ENC_TIMESTAMP	2
 #define	KRB5_PADATA_PW_SALT		3
-#if 0				/* Not used */
-#define KRB5_PADATA_ENC_ENCKEY		4  /* Key encrypted within itself */
-#endif
 #define KRB5_PADATA_ENC_UNIX_TIME	5  /* timestamp encrypted in key */
 #define KRB5_PADATA_ENC_SANDIA_SECURID	6  /* SecurId passcode */
 #define KRB5_PADATA_SESAME		7  /* Sesame project */
diff --git a/src/WINNT/kfw/inc/krbcc/cacheapi.h b/src/WINNT/kfw/inc/krbcc/cacheapi.h
index d274ecf7d..1e706a209 100644
--- a/src/WINNT/kfw/inc/krbcc/cacheapi.h
+++ b/src/WINNT/kfw/inc/krbcc/cacheapi.h
@@ -104,21 +104,6 @@ typedef struct opaque_dll_control_block_type* apiCB;
 typedef struct opaque_ccache_pointer_type* ccache_p;
 typedef struct opaque_credential_iterator_type* ccache_cit;
 
-#if 0
-enum _cc_data_type {
-    type_ticket = 0,                /* 0 for ticket, second_ticket */
-    /* Ted's draft spec says these are to be
-       "as defined in the Kerberos V5 protocol"
-       all I can find are typdefs,
-       can't find an enumerated type or #define
-    */
-    type_address,           /* =  <"as defined in the Kerberos V5 protocol"> */
-    type_authdata,          /* = <"as defined in the Kerberos V5 protocol"> */
-    type_encryption,        /* = <"as defined in the Kerberos V5 protocol"> */
-    cc_data_type_max        /* for validation */
-};
-#endif
-
 typedef struct _cc_data
 {
     cc_uint32       type;		// should be one of _cc_data_type
diff --git a/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h b/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h
index 4c9c3f25e..5944585ce 100644
--- a/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h
+++ b/src/WINNT/kfw/inc/loadfuncs/loadfuncs-krb5.h
@@ -107,28 +107,6 @@ TYPEDEF_FUNC(
     (krb5_context, krb5_ap_rep * )
     );
 
-/* Removed around the time of krb5_rc_* change... */
-#if 0
-TYPEDEF_FUNC(
-    void,
-    KRB5_CALLCONV,
-    krb5_free_safe,
-    (krb5_context, krb5_safe * )
-    );
-TYPEDEF_FUNC(
-    void,
-    KRB5_CALLCONV,
-    krb5_free_priv,
-    (krb5_context, krb5_priv * )
-    );
-TYPEDEF_FUNC(
-    void,
-    KRB5_CALLCONV,
-    krb5_free_priv_enc_part,
-    (krb5_context, krb5_priv_enc_part * )
-    );
-#endif
-
 TYPEDEF_FUNC(
     void,
     KRB5_CALLCONV,
diff --git a/src/WINNT/kfw/inc/netidmgr/khmsgtypes.h b/src/WINNT/kfw/inc/netidmgr/khmsgtypes.h
index 5f99ab98d..e5922e8c7 100644
--- a/src/WINNT/kfw/inc/netidmgr/khmsgtypes.h
+++ b/src/WINNT/kfw/inc/netidmgr/khmsgtypes.h
@@ -462,14 +462,6 @@
  */
 #define KMSG_CRED_DESTROY_CREDS     32
 
-#if 0
-/*! \brief Parse an identity
-
-    \note May be sent to individual credential subscriptions.
- */
-#define KMSG_CRED_IDENT_PARSE       65
-#endif
-
 /*! \brief A property page is being launced
 
     Message parameters:
diff --git a/src/WINNT/netidmgr_plugin/afsfuncs.c b/src/WINNT/netidmgr_plugin/afsfuncs.c
index db9b72550..3439a6756 100644
--- a/src/WINNT/netidmgr_plugin/afsfuncs.c
+++ b/src/WINNT/netidmgr_plugin/afsfuncs.c
@@ -369,36 +369,6 @@ afs_list_tokens_internal(void)
             continue;
         }
 
-#if 0
-        /* failed attempt at trying to figure out the principal name from
-           the token.  The ticket that is attached to the token is not
-           in a form that is useful at this point */
-        idname[0] = L'\0';
-        if(atoken.kvno == RXKAD_TKT_TYPE_KERBEROS_V5) {
-            krb5_context ctx = 0;
-            krb5_ccache cc = 0;
-            krb5_creds * k5c;
-            krb5_error_code code;
-            char * princ;
-
-            code = khm_krb5_initialize(&ctx, &cc);
-            if(code)
-                goto _no_krb5;
-
-            k5c = (krb5_creds *) atoken.ticket;
-
-            code = krb5_unparse_name(ctx, k5c->client, &princ);
-            if(code)
-                goto _no_krb5;
-
-            MultiByteToWideChar(CP_ACP, 0, princ, strlen(princ), idname, sizeof(idname)/sizeof(idname[0]));
-
-            krb5_free_unparsed_name(ctx, princ);
-_no_krb5:
-            ;
-        }
-#endif
-
         method = AFS_TOKEN_AUTO;
 
         afs_princ_to_string(&aclient, idname, sizeof(idname));
diff --git a/src/WINNT/netidmgr_plugin/afsplugin.c b/src/WINNT/netidmgr_plugin/afsplugin.c
index 87cd429a6..9ddb4df13 100644
--- a/src/WINNT/netidmgr_plugin/afsplugin.c
+++ b/src/WINNT/netidmgr_plugin/afsplugin.c
@@ -713,11 +713,6 @@ afs_msg_system(khm_int32 msg_subtype,
         if(afs_credtype_id >= 0) {
             kcdb_credtype_unregister(afs_credtype_id);
         }
-#if 0
-        if(afs_attr_client >= 0) {
-            kcdb_attrib_unregister(afs_attr_client);
-        }
-#endif
         if(afs_attr_cell >= 0) {
             kcdb_attrib_unregister(afs_attr_cell);
         }
@@ -772,12 +767,6 @@ afs_msg_kcdb(khm_int32 msg_subtype,
 {
     khm_int32 rv = KHM_ERROR_SUCCESS;
 
-    /* we don't really do anything with this yet */
-#if 0
-    switch(msg_subtype) {
-    }
-#endif
-
     return rv;
 }
 
diff --git a/src/WINNT/tests/largefiles/lftest.c b/src/WINNT/tests/largefiles/lftest.c
index 4f63c8dc8..0ffcd0aa9 100644
--- a/src/WINNT/tests/largefiles/lftest.c
+++ b/src/WINNT/tests/largefiles/lftest.c
@@ -48,12 +48,6 @@ int test_write(HANDLE hf, LARGE_INTEGER offset) {
 	ret = -1;
     }
 
-#if 0
-    if (!FlushFileBuffers(hf)) {
-	fprintf(stderr, "Flush buffers fails at offset 0x%08x:%08x gle = 0x%08x\n",
-		 offset.u.HighPart, offset.u.LowPart, GetLastError());
-    }
-#endif
     return ret;
 }
 
diff --git a/src/WINNT/tests/torture/Source/WinTorture.c b/src/WINNT/tests/torture/Source/WinTorture.c
index a8b27e194..3493ad8da 100644
--- a/src/WINNT/tests/torture/Source/WinTorture.c
+++ b/src/WINNT/tests/torture/Source/WinTorture.c
@@ -534,15 +534,7 @@ int main(int argc, char *argv[])
     {
 #endif /* HAVE_HESOID */
         strcpy(AfsLocker, Locker);
-#if 0
-        /* jaltman - this makes no sense.  why strip off the server name and leave
-         * an absolute path on the local disk?
-         */
-        if (!strnicmp(Locker, "\\\\afs\\", strlen("\\\\afs\\")))
-            strcpy(TargetDirectory, &Locker[strlen("\\\\afs\\")]);
-        else
-#endif
-            strcpy(TargetDirectory, Locker);
+        strcpy(TargetDirectory, Locker);
 #ifdef HAVE_HESOID
     }
 #endif /* HAVE_HESOID */
diff --git a/src/afs/AIX/osi_config.c b/src/afs/AIX/osi_config.c
index 6cd306d1d..82fe53333 100644
--- a/src/afs/AIX/osi_config.c
+++ b/src/afs/AIX/osi_config.c
@@ -56,7 +56,7 @@
 #include <sys/timer.h>		/* For the timer related defines                */
 #include <sys/intr.h>		/* for the serialization defines                */
 #include <sys/malloc.h>		/* for the parameters to xmalloc()              */
-#include "afs/afs_osi.h"	/* pick up osi_timeval_t for afs_stats.h */
+#include "afs/afs_osi.h"	/* pick up osi_timeval32_t for afs_stats.h */
 #include "afs/afs_stats.h"
 #include "../export.h"
 
diff --git a/src/afs/AIX/osi_file.c b/src/afs/AIX/osi_file.c
index 4bd33711e..086a7d981 100644
--- a/src/afs/AIX/osi_file.c
+++ b/src/afs/AIX/osi_file.c
@@ -18,7 +18,6 @@
 
 int afs_osicred_initialized = 0;
 afs_ucred_t afs_osi_cred;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
 
@@ -37,7 +36,6 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 	osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
-	/* valid for alpha_osf, SunOS, Ultrix */
 	memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
 	crhold(&afs_osi_cred);	/* don't let it evaporate, since it is static */
 	afs_osicred_initialized = 1;
@@ -65,7 +63,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
     code = VNOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred);
     AFS_GLOCK();
@@ -74,7 +71,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -121,7 +117,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
 	return code;
-    ObtainWriteLock(&afs_xosi, 321);
     /* 
      * If we're truncating an unopened file to a non-zero length,
      * we need to bind it to a vm segment    
@@ -133,7 +128,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     AFS_GUNLOCK();
     code = VNOP_FTRUNC(afile->vnode, mode, asize, (caddr_t) 0, &afs_osi_cred);
     AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -240,8 +234,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
 	afs_Trace3(afs_iclSetp, CM_TRACE_WRITEFAILED, ICL_TYPE_INT32, asize,
 		   ICL_TYPE_INT32, resid, ICL_TYPE_INT32, code);
 	if (code == ENOSPC)
-	    afs_warnuser
-		("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
+            afs_WarnENOSPC();
 	setuerror(code);
 	if (code > 0) {
 	    code = -code;
diff --git a/src/afs/AIX/osi_machdep.h b/src/afs/AIX/osi_machdep.h
index 1cc3a2bcd..0c79c03c5 100644
--- a/src/afs/AIX/osi_machdep.h
+++ b/src/afs/AIX/osi_machdep.h
@@ -31,8 +31,6 @@ typedef struct proc afs_proc_t;
 
 #define afs_bufferpages v.v_bufhw
 
-#define osi_vnhold(avc, r) do { VN_HOLD(AFSTOV(avc)); } while (0)
-
 #undef gop_lookupname
 #define	gop_lookupname(fnamep,segflg,followlink,compvpp) \
 	lookupvp((fnamep), (followlink), (compvpp), &afs_osi_cred)
@@ -86,4 +84,13 @@ extern simple_lock_data afs_global_lock;
  * src/afs/AIX/osi_gcpags.c for how to look at the process list */
 #define osi_procname(procname, size) strncpy(procname, "", size)
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timestruc_t now;
+    curtime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_nsec / 1000;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/AIX/osi_misc.c b/src/afs/AIX/osi_misc.c
index 77609a92f..be4336a29 100644
--- a/src/afs/AIX/osi_misc.c
+++ b/src/afs/AIX/osi_misc.c
@@ -167,7 +167,7 @@ aix_gnode_rele(vp)
  * Note that it must NOT set errno.
  */
 
-afs_suser(void *credp)
+afs_suser(afs_ucred_t *credp)
 {
     int rc;
     char err;
diff --git a/src/afs/AIX/osi_prototypes.h b/src/afs/AIX/osi_prototypes.h
index e6ebac32b..84d31b3ba 100644
--- a/src/afs/AIX/osi_prototypes.h
+++ b/src/afs/AIX/osi_prototypes.h
@@ -10,9 +10,6 @@
 #ifndef _OSI_PROTOTYPES_H_
 #define _OSI_PROTOTYPES_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 /* osi_groups.c */
 extern void afs_aix_SetupPagRefCount(void);
 
diff --git a/src/afs/AIX/osi_sleep.c b/src/afs/AIX/osi_sleep.c
index ba9557912..37235468f 100644
--- a/src/afs/AIX/osi_sleep.c
+++ b/src/afs/AIX/osi_sleep.c
@@ -20,11 +20,6 @@ static char waitV;
 static void
 AfsWaitHack(struct trb *trb)
 {
-#if 0
-/* this gets called at interrupt context; let's not tempt fate... */
-    AFS_STATCNT(WaitHack);
-#endif
-
     e_clear_wait(trb->func_data, THREAD_TIMED_OUT);
 }
 
diff --git a/src/afs/AIX/osi_vcache.c b/src/afs/AIX/osi_vcache.c
index b61d466c0..eec57c9d2 100644
--- a/src/afs/AIX/osi_vcache.c
+++ b/src/afs/AIX/osi_vcache.c
@@ -16,19 +16,21 @@
 extern struct vnodeops *afs_ops;
 
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
-     int code;
-     if (!VREFCOUNT_GT(avc,0)
-         && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0) {
-        code = afs_FlushVCache(avc, slept);
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
+    int code;
+    if (!VREFCOUNT_GT(avc,0)
+	&& avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0) {
+	code = afs_FlushVCache(avc, slept);
 	if (code == 0)
 	    return 1;
-     }
-     return 0;
+    }
+    return 0;
 }
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *tvc;
 
     tvc = afs_osi_Alloc(sizeof(struct vcache));
@@ -42,7 +44,8 @@ osi_NewVnode(void) {
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 
 #ifdef	AFS_AIX32_ENV
@@ -57,10 +60,13 @@ osi_PrePopulateVCache(struct vcache *avc) {
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) { }
+osi_AttachVnode(struct vcache *avc, int seq)
+{
+}
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     avc->v.v_op = afs_ops;
 
     avc->v.v_vfsp = afs_globalVFS;
@@ -75,3 +81,9 @@ osi_PostPopulateVCache(struct vcache *avc) {
     avc->v.v_gnode->gn_vnode = &avc->v;
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/AIX/osi_vfsops.c b/src/afs/AIX/osi_vfsops.c
index 526594442..3c895d8b1 100644
--- a/src/afs/AIX/osi_vfsops.c
+++ b/src/afs/AIX/osi_vfsops.c
@@ -125,7 +125,7 @@ afs_root_nolock(struct vfs *afsp, struct vnode **avpp)
 	}
 	credp = crref();
 	if (!(code = afs_InitReq(&treq, credp)) && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 	    /* we really want this to stay around */
 	    if (tvp) {
 		afs_globalVp = tvp;
diff --git a/src/afs/AIX/osi_vnodeops.c b/src/afs/AIX/osi_vnodeops.c
index d0cabe9c8..1722d355e 100644
--- a/src/afs/AIX/osi_vnodeops.c
+++ b/src/afs/AIX/osi_vnodeops.c
@@ -1239,14 +1239,6 @@ afs_direct_rdwr(struct vnode *vp,
 	goto fail;
     }
 
-    /* check for "file too big" error, which should really be done above us */
-#ifdef notdef
-    if (rw == UIO_WRITE && xfrSize + fileSize > get_ulimit()) {
-	code = EFBIG;
-	ReleaseReadLock(&vcp->lock);
-	goto fail;
-    }
-#endif
     ReleaseReadLock(&vcp->lock);
     if (rw == UIO_WRITE) {
 	ObtainWriteLock(&vcp->lock, 400);
diff --git a/src/afs/DARWIN/osi_file.c b/src/afs/DARWIN/osi_file.c
index 19bfdf9b7..7c1539eca 100644
--- a/src/afs/DARWIN/osi_file.c
+++ b/src/afs/DARWIN/osi_file.c
@@ -19,7 +19,6 @@
 
 int afs_osicred_initialized = 0;
 afs_ucred_t afs_osi_cred;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct mount *afs_cacheVfsp;
 int afs_CacheFSType = -1;
@@ -151,7 +150,6 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 	osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
-	/* valid for alpha_osf, SunOS, Ultrix */
 	memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
 	afs_osi_cred.cr_ref++;
 #ifndef AFS_DARWIN110_ENV
@@ -204,7 +202,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
 #ifdef AFS_DARWIN80_ENV
     VATTR_INIT(&tvattr);
@@ -224,7 +221,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -260,7 +256,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
 	return code;
-    ObtainWriteLock(&afs_xosi, 321);
     AFS_GUNLOCK();
 #ifdef AFS_DARWIN80_ENV
     VATTR_INIT(&tvattr);
@@ -272,7 +267,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, current_proc());
 #endif
     AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
diff --git a/src/afs/DARWIN/osi_inode.c b/src/afs/DARWIN/osi_inode.c
index e854a418a..1ee2ef213 100644
--- a/src/afs/DARWIN/osi_inode.c
+++ b/src/afs/DARWIN/osi_inode.c
@@ -139,10 +139,6 @@ getinode(fs, dev, inode, vpp, perror)
 #ifdef VFSTOHFS
 		if (!strcmp(mp->mnt_vfc->vfc_name, "hfs")) {
 		    hmp = VFSTOHFS(mp);
-#if 0
-		    if (hmp->hfs_mp == NULL)
-			break;
-#endif
 		    if (hmp->hfs_raw_dev == dev) {
 			fs = hmp->hfs_mp;
 		    }
@@ -217,14 +213,7 @@ iforget(vp)
     if (vp->v_usecount == 1) {
 	vp->v_usecount = 0;
 	VOP_UNLOCK(vp, 0, current_proc());
-#if 0
-	simple_lock(&vnode_free_list_slock);
-	TAILQ_INSERT_TAIL(&vnode_free_list, vp, v_freelist);
-	freevnodes++;
-	simple_unlock(&vnode_free_list_slock);
-#else
 	printf("iforget: leaking vnode\n");
-#endif
     } else {
 	vput(vp);
     }
diff --git a/src/afs/DARWIN/osi_machdep.h b/src/afs/DARWIN/osi_machdep.h
index a4f01b3e1..b3609702f 100644
--- a/src/afs/DARWIN/osi_machdep.h
+++ b/src/afs/DARWIN/osi_machdep.h
@@ -18,12 +18,6 @@
 #ifndef _OSI_MACHDEP_H_
 #define _OSI_MACHDEP_H_
 
-#ifdef XAFS_DARWIN_ENV
-#ifndef _MACH_ETAP_H_
-#define _MACH_ETAP_H_
-typedef unsigned short etap_event_t;
-#endif
-#endif
 
 #ifdef AFS_DARWIN80_ENV
 #include <kern/locks.h>
@@ -88,11 +82,6 @@ enum vcexcl { EXCL, NONEXCL };
 #define vput vnode_rele
 #define vref vnode_ref
 #define vattr vnode_attr
-#if 0
-#define vn_lock(v, unused1, unused2) vnode_get((v))
-#define VOP_LOCK(v, unused1, unused2) vnode_get((v))
-#define VOP_UNLOCK(v, unused1, unused2) vnode_put((v))
-#endif
 
 #define va_size va_data_size
 #define va_atime va_access_time
@@ -141,7 +130,6 @@ extern int hz;
 typedef struct ucred afs_ucred_t;
 typedef struct proc afs_proc_t;
 
-#define osi_vnhold(avc,r)       VN_HOLD(AFSTOV(avc))
 #define VN_HOLD(vp) darwin_vn_hold(vp)
 #define VN_RELE(vp) vrele(vp)
 
@@ -203,15 +191,6 @@ extern struct lock__bsd__ afs_global_lock;
 #define SPLVAR
 #define NETPRI
 #define USERPRI
-#if 0
-#undef SPLVAR
-#define SPLVAR int x
-#undef NETPRI
-#define NETPRI x=splnet()
-#undef USERPRI
-#define USERPRI splx(x)
-#endif
-
 #define AFS_APPL_UFS_CACHE 1
 #define AFS_APPL_HFS_CACHE 2
 #define AFS_APPL_APFS_CACHE 3
@@ -256,4 +235,13 @@ extern int (**afs_vnodeop_p) ();
 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
 #endif
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    microtime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/DARWIN/osi_misc.c b/src/afs/DARWIN/osi_misc.c
index 22dcfb047..b0e006f82 100644
--- a/src/afs/DARWIN/osi_misc.c
+++ b/src/afs/DARWIN/osi_misc.c
@@ -170,7 +170,7 @@ osi_lookupname(char *aname, enum uio_seg seg, int followlink,
  * Note that it must NOT set errno.
  */
 int
-afs_suser(void *credp)
+afs_suser(afs_ucred_t *credp)
 {
     int error;
     struct proc *p = current_proc();
diff --git a/src/afs/DARWIN/osi_module.c b/src/afs/DARWIN/osi_module.c
index 046870a7f..41ff02131 100644
--- a/src/afs/DARWIN/osi_module.c
+++ b/src/afs/DARWIN/osi_module.c
@@ -50,9 +50,9 @@ kern_return_t
 afs_modload(struct kmod_info *kmod_info, void *data)
 {
     int ret;
-    osi_Init();
 #ifdef AFS_DARWIN80_ENV
     MUTEX_SETUP();
+    osi_Init();
     afs_global_lock = lck_mtx_alloc_init(openafs_lck_grp, 0);
 
     if (ret = vfs_fsadd(&afs_vfsentry, &afs_vfstable)) {
@@ -82,6 +82,7 @@ afs_modload(struct kmod_info *kmod_info, void *data)
 	return KERN_FAILURE;
     }
 #else
+    osi_Init();
     memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
     strcpy(afs_vfsconf.vfc_name, "afs");
     afs_vfsconf.vfc_vfsops = &afs_vfsops;
@@ -140,5 +141,5 @@ afs_modunload(struct kmod_info * kmod_info, void *data)
     return KERN_SUCCESS;
 }
 
-KMOD_EXPLICIT_DECL(MYBUNDLEID, VERSION, afs_modload,
+KMOD_EXPLICIT_DECL(MYBUNDLEID, PACKAGE_VERSION, afs_modload,
 		   afs_modunload)
diff --git a/src/afs/DARWIN/osi_prototypes.h b/src/afs/DARWIN/osi_prototypes.h
index 0380461d7..956211232 100644
--- a/src/afs/DARWIN/osi_prototypes.h
+++ b/src/afs/DARWIN/osi_prototypes.h
@@ -14,16 +14,13 @@
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 /* osi_misc.c */
 extern void darwin_notify_perms(struct unixuser *auser, int event);
 extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
 			  struct vnode **vpp);
 extern int osi_lookupname_user(user_addr_t aname, enum uio_seg seg,
 			       int followlink, struct vnode **vpp);
-extern int afs_suser(void *credp);
+extern int afs_suser(afs_ucred_t *credp);
 extern void get_vfs_context(void);
 extern void put_vfs_context(void);
 
diff --git a/src/afs/DARWIN/osi_vcache.c b/src/afs/DARWIN/osi_vcache.c
index 54c6e77c5..1d7922418 100644
--- a/src/afs/DARWIN/osi_vcache.c
+++ b/src/afs/DARWIN/osi_vcache.c
@@ -14,7 +14,8 @@
 #include "afsincludes.h"        /*AFS-based standard headers */
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *tvc;
 
     tvc = afs_osi_Alloc(sizeof(struct vcache));
@@ -27,7 +28,8 @@ osi_NewVnode(void) {
 
 #if defined(AFS_DARWIN80_ENV)
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     *slept = 0;
 
     /* we ignore defersleep, as we *always* need to sleep */
@@ -62,7 +64,8 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 }
 #else
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     if (!VREFCOUNT_GT(avc,0)
         || ((VREFCOUNT(avc) == 1) && (UBCINFOEXISTS(AFSTOV(avc))))
         && avc->opens == 0 && (avc->f.states & CUnlinkedDel) == 0)
@@ -83,12 +86,14 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 #endif /* AFS_DARWIN80_ENV */
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) {
+osi_AttachVnode(struct vcache *avc, int seq)
+{
     ReleaseWriteLock(&afs_xvcache);
     AFS_GUNLOCK();
     afs_darwin_getnewvnode(avc);  /* includes one refcount */
@@ -102,7 +107,8 @@ osi_AttachVnode(struct vcache *avc, int seq) {
 }
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
 #if !defined(AFS_DARWIN80_ENV)
    avc->v->v_mount = afs_globalVFS;
    vSetType(avc, VREG);
@@ -110,3 +116,10 @@ osi_PostPopulateVCache(struct vcache *avc) {
    vSetType(avc, VNON);
 #endif
 }
+
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/DARWIN/osi_vfsops.c b/src/afs/DARWIN/osi_vfsops.c
index 064410dec..60b3a1856 100644
--- a/src/afs/DARWIN/osi_vfsops.c
+++ b/src/afs/DARWIN/osi_vfsops.c
@@ -251,7 +251,7 @@ again:
 	    ? &afs_rootFid : (struct VenusFid *)mdata;
 
 	if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
-	    tvp = afs_GetVCache(rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(rootFid, &treq);
 #ifdef AFS_DARWIN80_ENV
             if (tvp) {
 	        AFS_GUNLOCK();
@@ -286,7 +286,7 @@ again:
     }
     if (tvp) {
 #ifndef AFS_DARWIN80_ENV /* KPI callers don't need a usecount reference */
-	osi_vnhold(tvp, 0);
+	osi_Assert(osi_vnhold(tvp) == 0);
 	AFS_GUNLOCK();
 	vn_lock(AFSTOV(tvp), LK_EXCLUSIVE | LK_RETRY, p);
 	AFS_GLOCK();
@@ -357,9 +357,6 @@ afs_statfs(struct mount *mp, STATFS_TYPE *abp, CTX_TYPE ctx)
     abp->f_bsize = mp->vfs_bsize;
     abp->f_iosize = mp->vfs_bsize;
 #endif
-#if 0
-    abp->f_type = MOUNT_AFS;
-#endif
 
     abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
       abp->f_ffree = AFS_VFS_FAKEFREE;
diff --git a/src/afs/DARWIN/osi_vm.c b/src/afs/DARWIN/osi_vm.c
index f84703752..7d7b0b08c 100644
--- a/src/afs/DARWIN/osi_vm.c
+++ b/src/afs/DARWIN/osi_vm.c
@@ -37,12 +37,6 @@ osi_VM_FlushVCache(struct vcache *avc)
     if (!vp)
 	return 0;
     AFS_GUNLOCK();
-#if 0
-    if (!(UBCINFOMISSING(vp) || UBCINFORECLAIMED(vp))) {
-      size=ubc_getsize(vp);
-      kret=ubc_invalidate(vp,0,size); 
-    }
-#endif
     cache_purge(vp);
     AFS_GLOCK();
 
@@ -161,19 +155,6 @@ osi_VM_Truncate(struct vcache *avc, int alen, afs_ucred_t *acred)
 void
 osi_VM_NukePages(struct vnode *vp, off_t offset, off_t size)
 {
-#if 0
-    void *object;
-    struct vcache *avc = VTOAFS(vp);
-
-    offset = trunc_page(offset);
-    size = round_page(size + 1);
-    while (size) {
-	ubc_page_op(vp, (vm_offset_t) offset,
-		    UPL_POP_SET | UPL_POP_BUSY | UPL_POP_DUMP, 0, 0);
-	size -= PAGE_SIZE;
-	offset += PAGE_SIZE;
-    }
-#endif
 }
 
 int
@@ -185,7 +166,7 @@ osi_VM_Setup(struct vcache *avc, int force)
 #ifndef AFS_DARWIN80_ENV
     if (UBCISVALID(vp) && ((avc->f.states & CStatd) || force)) {
 	if (!UBCINFOEXISTS(vp)) {
-	    osi_vnhold(avc, 0);
+	    osi_Assert(osi_vnhold(avc) == 0);
 	    avc->f.states |= CUBCinit;
 	    AFS_GUNLOCK();
 	    if ((error = ubc_info_init(vp))) {
diff --git a/src/afs/DARWIN/osi_vnodeops.c b/src/afs/DARWIN/osi_vnodeops.c
index 28c0e0a7f..a3c222aec 100644
--- a/src/afs/DARWIN/osi_vnodeops.c
+++ b/src/afs/DARWIN/osi_vnodeops.c
@@ -596,12 +596,6 @@ afs_vop_access(ap)
           bits |= PRSFS_INSERT;
        if (ap->a_action & KAUTH_VNODE_DELETE_CHILD)
           bits |= PRSFS_DELETE;
-#if 0 /* I'd argue this should be enforced on the parent. But that's ugly */
-       if (ap->a_action & KAUTH_VNODE_READ_ATTRIBUTES)
-          bits |= PRSFS_LOOKUP;
-       if (ap->a_action & KAUTH_VNODE_READ_SECURITY) /* mode bits/gid, not afs acl */
-          bits |= PRSFS_LOOKUP;
-#endif
     } else {
        if (ap->a_action & KAUTH_VNODE_READ_DATA)
           bits |= PRSFS_READ;
@@ -622,12 +616,6 @@ afs_vop_access(ap)
     }
     if (ap->a_action & KAUTH_VNODE_WRITE_ATTRIBUTES)
        bits |= PRSFS_WRITE;
-#if 0 /* no extended attributes */
-    if (ap->a_action & KAUTH_VNODE_READ_EXTATTRIBUTES)
-       bits |= PRSFS_READ;
-    if (ap->a_action & KAUTH_VNODE_WRITE_EXTATTRIBUTES)
-       bits |= PRSFS_WRITE;
-#endif
     if (ap->a_action & KAUTH_VNODE_WRITE_SECURITY)
        bits |= PRSFS_WRITE;
     /* we can't check for KAUTH_VNODE_TAKE_OWNERSHIP, so we always permit it */
@@ -1535,7 +1523,7 @@ afs_vop_rename(ap)
                 afs_osi_Sleep(tb);
             }
             /* if we succeeded, clear the error. otherwise, EXDEV */
-            if (mvReq.retval == 0)
+            if (tb->code_raw == 0)
                 error = 0;
 
             afs_BRelease(tb);
@@ -2046,10 +2034,6 @@ afs_vop_bmap(ap)
     }
     if (ap->a_runp != NULL)
 	*ap->a_runp = 0;
-#ifdef notyet
-    if (ap->a_runb != NULL)
-	*ap->a_runb = 0;
-#endif
 
     return 0;
 }
@@ -2177,12 +2161,6 @@ afs_darwin_finalizevnode(struct vcache *avc, struct vnode *dvp,
 
     if (!(avc->f.states & CDeadVnode) && vnode_vtype(ovp) != VNON) {
 	AFS_GUNLOCK();
-#if 0 /* unsupported */
-        if (dvp && cnp)
-	    vnode_update_identity(ovp, dvp, cnp->cn_nameptr, cnp->cn_namelen,
-				  cnp->cn_hash,
-				  VNODE_UPDATE_PARENT|VNODE_UPDATE_NAME);
-#endif
 	/* Can end up in reclaim... drop GLOCK */
 	vnode_rele(ovp);
 	AFS_GLOCK();
diff --git a/src/afs/DFBSD/osi_machdep.h b/src/afs/DFBSD/osi_machdep.h
new file mode 100644
index 000000000..4c6a80d4d
--- /dev/null
+++ b/src/afs/DFBSD/osi_machdep.h
@@ -0,0 +1,31 @@
+/*
+ * 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
+ */
+
+/*
+ *
+ * DFBSD OSI header file. Extends afs_osi.h.
+ *
+ * afs_osi.h includes this file, which is the only way this file should
+ * be included in a source file. This file can redefine macros declared in
+ * afs_osi.h.
+ */
+
+#ifndef _OSI_MACHDEP_H_
+#define _OSI_MACHDEP_H_
+
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    microtime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
+#endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/DFBSD/osi_prototypes.h b/src/afs/DFBSD/osi_prototypes.h
index e65ae5bcb..1f0392e27 100644
--- a/src/afs/DFBSD/osi_prototypes.h
+++ b/src/afs/DFBSD/osi_prototypes.h
@@ -14,9 +14,4 @@
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
-
-
 #endif /* _OSI_PROTO_H_ */
diff --git a/src/afs/FBSD/osi_file.c b/src/afs/FBSD/osi_file.c
index 1cfc5c83c..00bbc8b61 100644
--- a/src/afs/FBSD/osi_file.c
+++ b/src/afs/FBSD/osi_file.c
@@ -17,10 +17,6 @@
 
 
 int afs_osicred_initialized = 0;
-#ifndef AFS_FBSD80_ENV	/* cr_groups is now malloc()'d */
-afs_ucred_t afs_osi_cred;
-#endif
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct mount *afs_cacheVfsp;
 
@@ -46,11 +42,7 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 	osi_FreeSmallSpace(afile);
 	osi_Panic("UFSOpen: igetinode failed");
     }
-#if defined(AFS_FBSD80_ENV)
     VOP_UNLOCK(vp, 0);
-#else
-    VOP_UNLOCK(vp, 0, curthread);
-#endif
     afile->vnode = vp;
     afile->size = VTOI(vp)->i_size;
     afile->offset = 0;
@@ -64,24 +56,16 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
-#if defined(AFS_FBSD80_ENV)
     vn_lock(afile->vnode, LK_EXCLUSIVE | LK_RETRY);
     code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp);
     VOP_UNLOCK(afile->vnode, 0);
-#else
-    vn_lock(afile->vnode, LK_EXCLUSIVE | LK_RETRY, curthread);
-    code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
-    VOP_UNLOCK(afile->vnode, LK_EXCLUSIVE, curthread);
-#endif
     AFS_GLOCK();
     if (code == 0) {
 	astat->size = tvattr.va_size;
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -105,7 +89,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     afs_int32 code, glocked;
     AFS_STATCNT(osi_Truncate);
 
-    ObtainWriteLock(&afs_xosi, 321);
     vp = afile->vnode;
     /*
      * This routine only shrinks files, and most systems
@@ -115,33 +98,19 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     glocked = ISAFS_GLOCK();
     if (glocked)
       AFS_GUNLOCK();
-#if defined(AFS_FBSD80_ENV)
     vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
     code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp);
-#else
-    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
-    code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curthread);
-#endif
     if (code != 0 || tvattr.va_size <= asize)
 	goto out;
 
     VATTR_NULL(&tvattr);
     tvattr.va_size = asize;
-#if defined(AFS_FBSD80_ENV)
     code = VOP_SETATTR(vp, &tvattr, afs_osi_credp);
-#else
-    code = VOP_SETATTR(vp, &tvattr, afs_osi_credp, curthread);
-#endif
 
 out:
-#if defined(AFS_FBSD80_ENV)
     VOP_UNLOCK(vp, 0);
-#else
-    VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
-#endif
     if (glocked)
       AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -158,7 +127,7 @@ int
 afs_osi_Read(struct osi_file *afile, int offset, void *aptr,
 	     afs_int32 asize)
 {
-#if (__FreeBSD_version >= 900505 && __FreeBSD_Version < 1000000) ||__FreeBSD_version >= 1000009
+#if __FreeBSD_version >= 1000009
     ssize_t resid;
 #else
     int resid;
@@ -203,7 +172,7 @@ int
 afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
 	      afs_int32 asize)
 {
-#if (__FreeBSD_version >= 900505 && __FreeBSD_Version < 1000000) ||__FreeBSD_version >= 1000009
+#if __FreeBSD_version >= 1000009
     ssize_t resid;
 #else
     int resid;
diff --git a/src/afs/FBSD/osi_groups.c b/src/afs/FBSD/osi_groups.c
index e897f4610..6326f6c90 100644
--- a/src/afs/FBSD/osi_groups.c
+++ b/src/afs/FBSD/osi_groups.c
@@ -48,17 +48,9 @@ Afs_xsetgroups(struct thread *td, struct setgroups_args *uap)
     AFS_GUNLOCK();
     crfree(cr);
     if (code)
-#if (__FreeBSD_version >= 900044)
 	return sys_setgroups(td, uap);	/* afs has shut down */
-#else
-	return setgroups(td, uap);	/* afs has shut down */
-#endif
 
-#if (__FreeBSD_version >= 900044)
     code = sys_setgroups(td, uap);
-#else
-    code = setgroups(td, uap);
-#endif
     /* Note that if there is a pag already in the new groups we don't
      * overwrite it with the old pag.
      */
@@ -81,23 +73,13 @@ int
 setpag(struct thread *td, struct ucred **cred, afs_uint32 pagvalue,
        afs_uint32 * newpag, int change_parent)
 {
-#if defined(AFS_FBSD81_ENV)
     gid_t *gidset;
     int gidset_len = ngroups_max + 1;
-#elif defined(AFS_FBSD80_ENV)
-    gid_t *gidset;
-    int gidset_len = NGROUPS;	/* 1024 */
-#else
-    gid_t gidset[NGROUPS];
-    int gidset_len = NGROUPS;	/* 16 */
-#endif
     int ngroups, code;
     int j;
 
     AFS_STATCNT(setpag);
-#ifdef AFS_FBSD80_ENV
     gidset = osi_Alloc(gidset_len * sizeof(gid_t));
-#endif
     ngroups = afs_getgroups(*cred, gidset_len, gidset);
     if (afs_get_pag_from_groups(gidset[1], gidset[2]) == NOPAG) {
 	/* We will have to shift grouplist to make room for pag */
@@ -112,9 +94,7 @@ setpag(struct thread *td, struct ucred **cred, afs_uint32 pagvalue,
     *newpag = (pagvalue == -1 ? genpag() : pagvalue);
     afs_get_groups_from_pag(*newpag, &gidset[1], &gidset[2]);
     code = afs_setgroups(td, cred, ngroups, gidset, change_parent);
-#ifdef AFS_FBSD80_ENV
     osi_Free(gidset, gidset_len * sizeof(gid_t));
-#endif
     return code;
 }
 
diff --git a/src/afs/FBSD/osi_inode.c b/src/afs/FBSD/osi_inode.c
index 7588c81ac..f22efca17 100644
--- a/src/afs/FBSD/osi_inode.c
+++ b/src/afs/FBSD/osi_inode.c
@@ -31,11 +31,7 @@ int
 getinode(fs, dev, inode, ipp, perror)
      struct mount *fs;
      struct inode **ipp;
-#ifdef AFS_FBSD53_ENV
      struct cdev *dev;
-#else
-     dev_t dev;
-#endif
      ino_t inode;
      int *perror;
 {
@@ -84,11 +80,7 @@ int
 igetinode(vfsp, dev, inode, ipp, perror)
      struct inode **ipp;
      struct mount *vfsp;
-#ifdef AFS_FBSD53_ENV
      struct cdev *dev;
-#else
-     dev_t dev;
-#endif
      ino_t inode;
      int *perror;
 {
@@ -118,159 +110,6 @@ igetinode(vfsp, dev, inode, ipp, perror)
     return (0);
 }
 
-#if 0
-/*
- * icreate system call -- create an inode
- */
-afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
-     long *retval;
-     long dev, near_inode, param1, param2, param3, param4;
-{
-    int dummy, err = 0;
-    struct inode *ip, *newip;
-    int code;
-    struct vnode *vp;
-
-    AFS_STATCNT(afs_syscall_icreate);
-
-    if (!afs_suser(NULL))
-	return (EPERM);
-
-    code = getinode(0, (dev_t) dev, 2, &ip, &dummy);
-    if (code) {
-	return (ENOENT);
-    }
-    code = ialloc(ip, (ino_t) near_inode, 0, &newip);
-    iput(ip);
-    if (code) {
-	return (code);
-    }
-    IN_LOCK(newip);
-    newip->i_flag |= IACC | IUPD | ICHG;
-
-    newip->i_nlink = 1;
-
-    newip->i_mode = IFREG;
-
-    IN_UNLOCK(newip);
-    vp = ITOV(newip);
-    VN_LOCK(vp);
-    vp->v_type = VREG;
-    VN_UNLOCK(vp);
-
-    /*
-     * if ( !vp->v_object)
-     * {
-     * extern struct vfs_ubcops ufs_ubcops;
-     * extern struct vm_ubc_object* ubc_object_allocate();
-     * struct vm_ubc_object* vop;
-     * vop = ubc_object_allocate(&vp, &ufs_ubcops,
-     * vp->v_mount->m_funnel);
-     * VN_LOCK(vp);
-     * vp->v_object = vop;
-     * VN_UNLOCK(vp);
-     * }
-     */
-
-    IN_LOCK(newip);
-    /*    newip->i_flags |= IC_XUID|IC_XGID; */
-    /*    newip->i_flags &= ~IC_PROPLIST; */
-    newip->i_vicep1 = param1;
-    if (param2 == 0x1fffffff /*INODESPECIAL*/) {
-	newip->i_vicep2 = ((0x1fffffff << 3) + (param4 & 0x3));
-	newip->i_vicep3a = (u_short) (param3 >> 16);
-	newip->i_vicep3b = (u_short) param3;
-    } else {
-	newip->i_vicep2 =
-	    (((param2 >> 16) & 0x1f) << 27) +
-	    (((param4 >> 16) & 0x1f) << 22) + (param3 & 0x3fffff);
-	newip->i_vicep3a = (u_short) param4;
-	newip->i_vicep3b = (u_short) param2;
-    }
-    newip->i_vicemagic = VICEMAGIC;
-
-    *retval = newip->i_number;
-    IN_UNLOCK(newip);
-    iput(newip);
-    return (code);
-}
-
-
-int
-afs_syscall_iopen(dev, inode, usrmod, retval)
-     long *retval;
-     int dev, inode, usrmod;
-{
-    struct file *fp;
-    struct inode *ip;
-    struct vnode *vp = NULL;
-    int dummy;
-    int fd;
-    extern struct fileops vnops;
-    int code;
-
-    AFS_STATCNT(afs_syscall_iopen);
-
-    if (!afs_suser(NULL))
-	return (EPERM);
-
-    code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
-    if (code) {
-	return (code);
-    }
-    if ((code = falloc(curproc, &fp, &fd)) != 0) {
-	iput(ip);
-	return (code);
-    }
-    IN_UNLOCK(ip);
-
-    /* FreeBSD doesn't do much mp stuff yet :( */
-    /* FP_LOCK(fp); */
-    fp->f_flag = (usrmod) & FMASK;
-    fp->f_type = DTYPE_VNODE;
-    fp->f_ops = &vnops;
-    fp->f_data = (caddr_t) ITOV(ip);
-
-    /* FP_UNLOCK(fp); */
-    return (0);
-}
-
-
-/*
- * Support for iinc() and idec() system calls--increment or decrement
- * count on inode.
- * Restricted to super user.
- * Only VICEMAGIC type inodes.
- */
-int
-afs_syscall_iincdec(dev, inode, inode_p1, amount)
-     int dev, inode, inode_p1, amount;
-{
-    int dummy;
-    struct inode *ip;
-    int code;
-
-    if (!afs_suser(NULL))
-	return (EPERM);
-
-    code = igetinode(0, (dev_t) dev, (ino_t) inode, &ip, &dummy);
-    if (code) {
-	return (code);
-    }
-    if (!IS_VICEMAGIC(ip)) {
-	return (EPERM);
-    } else if (ip->i_vicep1 != inode_p1) {
-	return (ENXIO);
-    }
-    ip->i_nlink += amount;
-    if (ip->i_nlink == 0) {
-	CLEAR_VICEMAGIC(ip);
-    }
-    ip->i_flag |= ICHG;
-    iput(ip);
-    return (0);
-}
-#else
 int
 afs_syscall_icreate(dev, near_inode, param1, param2, param3, param4, retval)
      long *retval;
@@ -293,4 +132,3 @@ afs_syscall_iincdec(dev, inode, inode_p1, amount)
 {
     return EOPNOTSUPP;
 }
-#endif
diff --git a/src/afs/FBSD/osi_machdep.h b/src/afs/FBSD/osi_machdep.h
index 2865120f3..d9d39f096 100644
--- a/src/afs/FBSD/osi_machdep.h
+++ b/src/afs/FBSD/osi_machdep.h
@@ -23,9 +23,7 @@
 #include <sys/time.h>
 #include <sys/mutex.h>
 #include <sys/vnode.h>
-#if defined(AFS_FBSD80_ENV)
 #include <sys/priv.h>
-#endif
 
 /*
  * Time related macros
@@ -41,17 +39,13 @@ typedef struct proc afs_proc_t;
 #define iodone biodone
 #endif
 
-#ifdef AFS_FBSD80_ENV
 #define VSUID           S_ISUID
 #define VSGID           S_ISGID
-#endif
-
-#define osi_vnhold(avc,r)	vref(AFSTOV(avc))
 
 #define vType(vc)               AFSTOV(vc)->v_type
 #define vSetVfsp(vc, vfsp) 	AFSTOV(vc)->v_mount = (vfsp)
 #define vSetType(vc, type)      AFSTOV(vc)->v_type = (type)
-#if defined(AFS_FBSD60_ENV) && defined(KERNEL)
+#ifdef KERNEL
 extern struct vop_vector afs_vnodeops;
 # define IsAfsVnode(v) ((v)->v_op == &afs_vnodeops)
 #else
@@ -60,14 +54,8 @@ extern int (**afs_vnodeop_p) ();
 #endif
 #define SetAfsVnode(v)          /* nothing; done in getnewvnode() */
 
-#if defined(AFS_FBSD80_ENV)
 #define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \
   vinvalbuf((vp), (flags), (slpflag), (slptimeo))
-#else
-#define osi_vinvalbuf(vp, flags, slpflag, slptimeo) \
-  vinvalbuf((vp), (flags), (curthread), (slpflag), (slptimeo))
-#define osi_curproc() (curthread)
-#endif
 
 #undef gop_lookupname
 #define gop_lookupname osi_lookupname
@@ -83,26 +71,18 @@ extern void osi_fbsd_free(void *p);
 
 #define afs_osi_Alloc_NoSleep(size) osi_fbsd_alloc((size), 0)
 
-#ifdef AFS_FBSD80_ENV
 #define VN_RELE(vp)				\
   do {						\
     vrele(vp);					\
   } while(0);
-#else
-#define VN_RELE(vp)             vrele(vp)
-#endif
 #define VN_HOLD(vp)		VREF(vp)
 
 #undef afs_suser
-#if defined(AFS_FBSD80_ENV)
 /* OpenAFS-specific privileges negotiated for FreeBSD, thanks due to
  * Ben Kaduk */
 #define osi_suser_client_settings(x)   (!priv_check(curthread, PRIV_AFS_ADMIN))
 #define osi_suser_afs_daemon(x)   (!priv_check(curthread, PRIV_AFS_DAEMON))
 #define afs_suser(x) (osi_suser_client_settings((x)) && osi_suser_afs_daemon((x)))
-#else
-#define afs_suser(x)	(!suser(curthread))
-#endif
 
 #undef osi_getpid
 #define VT_AFS		"afs"
@@ -129,7 +109,7 @@ extern struct thread *afs_global_owner;
 	mtx_unlock(&afs_global_mtx); \
     } while (0)
 #define ISAFS_GLOCK() (mtx_owned(&afs_global_mtx))
-# if defined(AFS_FBSD80_ENV) && defined(WITNESS)
+# ifdef WITNESS
 #  define osi_InitGlock() \
 	do { \
 	    memset(&afs_global_mtx, 0, sizeof(struct mtx)); \
@@ -153,4 +133,13 @@ extern struct thread *afs_global_owner;
 
 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    microtime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/FBSD/osi_misc.c b/src/afs/FBSD/osi_misc.c
index 9ca97e249..8d3c99854 100644
--- a/src/afs/FBSD/osi_misc.c
+++ b/src/afs/FBSD/osi_misc.c
@@ -48,26 +48,13 @@ osi_lookupname(char *aname, enum uio_seg seg, int followlink,
     }
     *vpp = n.ni_vp;
     /* XXX should we do this?  Usually NOT (matt) */
-#if defined(AFS_FBSD80_ENV)
     /*VOP_UNLOCK(n.ni_vp, 0);*/
-#else
-    VOP_UNLOCK(n.ni_vp, 0, curthread);
-#endif
     NDFREE(&n, NDF_ONLY_PNBUF);
     if (glocked)
 	AFS_GLOCK();
     return 0;
 }
 
-/*
- * does not implement security features of kern_time.c:settime()
- */
-void
-afs_osi_SetTime(osi_timeval_t * atv)
-{
-    printf("afs attempted to set clock; use \"afsd -nosettime\"\n");
-}
-
 /*
  * Replace all of the bogus special-purpose memory allocators...
  */
diff --git a/src/afs/FBSD/osi_module.c b/src/afs/FBSD/osi_module.c
index 098a0a9d2..0ce956c65 100644
--- a/src/afs/FBSD/osi_module.c
+++ b/src/afs/FBSD/osi_module.c
@@ -24,65 +24,4 @@ extern struct mount *afs_globalVFS;
 
 MALLOC_DEFINE(M_AFS, "afsmisc", "memory used by the AFS filesystem");
 
-#ifdef AFS_FBSD60_ENV
 VFS_SET(afs_vfsops, afs, VFCF_NETWORK);
-#else
-int afs_module_handler(module_t mod, int what, void *arg);
-
-static struct vfsconf afs_vfsconf;
-static moduledata_t afs_mod = {
-    "afs",
-    afs_module_handler,
-    &afs_mod
-};
-
-DECLARE_MODULE(afs, afs_mod, SI_SUB_VFS, SI_ORDER_MIDDLE);
-#endif
-
-#ifndef AFS_FBSD60_ENV
-int
-afs_module_handler(module_t mod, int what, void *arg)
-{
-    static int inited = 0;
-    int error = 0;
-
-    switch (what) {
-    case MOD_LOAD:
-	if (inited) {
-	    printf("afs cannot be MOD_LOAD'd more than once\n");
-	    error = EBUSY;
-	    break;
-	}
-	memset(&afs_vfsconf, 0, sizeof(struct vfsconf));
-#ifdef AFS_FBSD53_ENV
-	afs_vfsconf.vfc_version = VFS_VERSION;
-#endif
-	strcpy(afs_vfsconf.vfc_name, "AFS");
-	afs_vfsconf.vfc_vfsops = &afs_vfsops;
-	afs_vfsconf.vfc_typenum = -1;	/* set by vfs_register */
-	afs_vfsconf.vfc_flags = VFCF_NETWORK;
-	if ((error = vfs_register(&afs_vfsconf)) != 0)
-	    break;
-	vfs_add_vnodeops(&afs_vnodeop_opv_desc);
-	inited = 1;
-	break;
-    case MOD_UNLOAD:
-#ifndef RXK_LISTENER_ENV
-	/* shutdown is incomplete unless RXK_LISTENER_ENV */
-	printf("afs: I can't be unloaded yet\n");
-	return -1;
-#endif
-	if (!inited) {
-	    error = 0;
-	    break;
-	}
-	if ((error = vfs_unregister(&afs_vfsconf)) != 0) {
-	    break;
-	}
-	vfs_rm_vnodeops(&afs_vnodeop_opv_desc);
-	break;
-    }
-
-    return (error);
-}
-#endif
diff --git a/src/afs/FBSD/osi_prototypes.h b/src/afs/FBSD/osi_prototypes.h
index c3c3b6042..b28005e79 100644
--- a/src/afs/FBSD/osi_prototypes.h
+++ b/src/afs/FBSD/osi_prototypes.h
@@ -14,24 +14,11 @@
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 /* osi_misc.c */
 extern int osi_lookupname(char *aname, enum uio_seg seg, int followlink,
 			  struct vnode **vpp);
 extern void *osi_fbsd_alloc(size_t size, int dropglobal);
 extern void osi_fbsd_free(void *p);
-
-/* osi_vfsops.c */
-int afs_init(struct vfsconf *vfc);
-int afs_uninit(struct vfsconf *vfc);
-#if defined(AFS_FBSD80_ENV)
-extern int afs_statfs(struct mount *mp, struct statfs *abp);
-#else
-extern int afs_statfs(struct mount *mp, struct statfs *abp, struct thread *td);
-#endif
-
 extern int osi_fbsd_checkinuse(struct vcache *avc);
 
 #endif /* _OSI_PROTO_H_ */
diff --git a/src/afs/FBSD/osi_vcache.c b/src/afs/FBSD/osi_vcache.c
index 69ac7f8f3..922d8c146 100644
--- a/src/afs/FBSD/osi_vcache.c
+++ b/src/afs/FBSD/osi_vcache.c
@@ -18,43 +18,55 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
 {
     struct vnode *vp;
     int code;
+    int evicted = 0;
 
     vp = AFSTOV(avc);
 
     if (!VI_TRYLOCK(vp))
-	return 0;
+	return evicted;
     code = osi_fbsd_checkinuse(avc);
     if (code != 0) {
 	VI_UNLOCK(vp);
-	return 0;
+	return evicted;
     }
 
     if ((vp->v_iflag & VI_DOOMED) != 0) {
 	VI_UNLOCK(vp);
-	return 1;
+	evicted = 1;
+	return evicted;
     }
 
-    /* must hold the vnode before calling vgone()
-     * This code largely copied from vfs_subr.c:vlrureclaim() */
     vholdl(vp);
 
     ReleaseWriteLock(&afs_xvcache);
     AFS_GUNLOCK();
 
     *slept = 1;
-    /* use the interlock while locking, so no one else can DOOM this */
-    vn_lock(vp, LK_INTERLOCK|LK_EXCLUSIVE|LK_RETRY);
-    vgone(vp);
-    VOP_UNLOCK(vp, 0);
+
+    if (vn_lock(vp, LK_INTERLOCK|LK_EXCLUSIVE|LK_NOWAIT) == 0) {
+	/*
+	 * vrecycle() will vgone() only if its usecount is 0. If someone grabbed a
+	 * new usecount ref just now, the vgone() will be skipped, and vrecycle
+	 * will return 0.
+	 */
+	if (vrecycle(vp) != 0) {
+	    evicted = 1;
+	}
+
+	VOP_UNLOCK(vp, 0);
+    }
+
     vdrop(vp);
 
     AFS_GLOCK();
     ObtainWriteLock(&afs_xvcache, 340);
-    return 1;
+
+    return evicted;
 }
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *tvc;
 
     tvc = afs_osi_Alloc(sizeof(struct vcache));
@@ -64,12 +76,14 @@ osi_NewVnode(void) {
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) {
+osi_AttachVnode(struct vcache *avc, int seq)
+{
     struct vnode *vp;
 
     ReleaseWriteLock(&afs_xvcache);
@@ -103,8 +117,24 @@ osi_AttachVnode(struct vcache *avc, int seq) {
 }
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     avc->v->v_mount = afs_globalVFS;
     vSetType(avc, VREG);
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    struct vnode *vp = AFSTOV(avc);
+
+    VI_LOCK(vp);
+    if ((vp->v_iflag & VI_DOOMED) != 0) {
+	VI_UNLOCK(vp);
+	return ENOENT;
+    }
+
+    vrefl(AFSTOV(avc));
+    VI_UNLOCK(vp);
+    return 0;
+}
diff --git a/src/afs/FBSD/osi_vfsops.c b/src/afs/FBSD/osi_vfsops.c
index 8ca88c3b0..b40cc73a4 100644
--- a/src/afs/FBSD/osi_vfsops.c
+++ b/src/afs/FBSD/osi_vfsops.c
@@ -20,94 +20,77 @@ int afs_pbuf_freecnt = -1;
 extern int Afs_xsetgroups();
 extern int afs_xioctl();
 
-#if !defined(AFS_FBSD90_ENV) && !defined(AFS_FBSD82_ENV)
-static sy_call_t *old_handler;
-#else
 static struct sysent old_sysent;
 
 static struct sysent afs_sysent = {
     5,			/* int sy_narg */
     (sy_call_t *) afs3_syscall,	/* sy_call_t *sy_call */
-#ifdef AFS_FBSD60_ENV
     AUE_NULL,		/* au_event_t sy_auevent */
-#ifdef AFS_FBSD70_ENV
     NULL,		/* systrace_args_funt_t sy_systrace_args_func */
     0,			/* u_int32_t sy_entry */
     0,			/* u_int32_t sy_return */
-#ifdef AFS_FBSD90_ENV
     0,			/* u_int32_t sy_flags */
     0			/* u_int32_t sy_thrcnt */
-#endif
-#endif
-#endif /* FBSD60 */
 };
-#endif /* FBSD90 */
 
-int
+static int
 afs_init(struct vfsconf *vfc)
 {
     int code;
     int offset = AFS_SYSCALL;
-#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
-# if defined(FBSD_SYSCALL_REGISTER_FOUR_ARGS)
+#if defined(FBSD_SYSCALL_REGISTER_FOUR_ARGS)
     code = syscall_register(&offset, &afs_sysent, &old_sysent, 0);
-# else
+#else
     code = syscall_register(&offset, &afs_sysent, &old_sysent);
-# endif
+#endif
     if (code) {
 	printf("AFS_SYSCALL in use, error %i. aborting\n", code);
 	return code;
     }
-#else
-    if (sysent[AFS_SYSCALL].sy_call != (sy_call_t *)nosys
-        && sysent[AFS_SYSCALL].sy_call != (sy_call_t *)lkmnosys) {
-        printf("AFS_SYSCALL in use. aborting\n");
-        return EBUSY;
-    }
-#endif
     osi_Init();
     afs_pbuf_freecnt = nswbuf / 2 + 1;
-#if !defined(AFS_FBSD90_ENV) && !defined(AFS_FBSD82_ENV)
-    old_handler = sysent[AFS_SYSCALL].sy_call;
-    sysent[AFS_SYSCALL].sy_call = afs3_syscall;
-    sysent[AFS_SYSCALL].sy_narg = 5;
-#endif
     return 0;
 }
 
-int
+static int
 afs_uninit(struct vfsconf *vfc)
 {
-#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
     int offset = AFS_SYSCALL;
-#endif
 
     if (afs_globalVFS)
 	return EBUSY;
-#if defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)
     syscall_deregister(&offset, &old_sysent);
-#else
-    sysent[AFS_SYSCALL].sy_narg = 0;
-    sysent[AFS_SYSCALL].sy_call = old_handler;
-#endif
     return 0;
 }
 
-int
-afs_start(struct mount *mp, int flags, struct thread *p)
+static int
+afs_statfs(struct mount *mp, struct statfs *abp)
 {
-    return (0);			/* nothing to do. ? */
+    AFS_GLOCK();
+    AFS_STATCNT(afs_statfs);
+
+    abp->f_bsize = mp->vfs_bsize;
+    abp->f_iosize = mp->vfs_bsize;
+
+    abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
+	abp->f_ffree = AFS_VFS_FAKEFREE;
+
+    abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
+    abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
+    if (abp != &mp->mnt_stat) {
+	abp->f_type = mp->mnt_vfc->vfc_typenum;
+	memcpy((caddr_t) & abp->f_mntonname[0],
+	       (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
+	memcpy((caddr_t) & abp->f_mntfromname[0],
+	       (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
+    }
+
+    AFS_GUNLOCK();
+    return 0;
 }
 
-int
-#if defined(AFS_FBSD80_ENV)
+static int
 afs_omount(struct mount *mp, char *path, caddr_t data)
-#elif defined(AFS_FBSD53_ENV)
-afs_omount(struct mount *mp, char *path, caddr_t data, struct thread *p)
-#else
-afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
-	struct thread *p)
-#endif
 {
     /* ndp contains the mounted-from device.  Just ignore it.
      * we also don't care about our thread struct. */
@@ -132,18 +115,10 @@ afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
      * more fields over time and there's not a good way to group the
      * code without duplication.
      */
-#ifdef AFS_FBSD62_ENV
     MNT_ILOCK(mp);
-#endif
     mp->mnt_flag &= ~MNT_LOCAL;
-#if defined(AFS_FBSD61_ENV) && !defined(AFS_FBSD62_ENV)
-    MNT_ILOCK(mp);
-#endif
 #if __FreeBSD_version < 1000021
     mp->mnt_kern_flag |= MNTK_MPSAFE; /* solid steel */
-#endif
-#ifndef AFS_FBSD61_ENV
-    MNT_ILOCK(mp);
 #endif
     /*
      * XXX mnt_stat "is considered stable as long as a ref is held".
@@ -162,51 +137,29 @@ afs_omount(struct mount *mp, char *path, caddr_t data, struct nameidata *ndp,
     strcpy(mp->mnt_stat.f_fstypename, "afs");
     MNT_IUNLOCK(mp);
     AFS_GUNLOCK();
-#ifdef AFS_FBSD80_ENV
     afs_statfs(mp, &mp->mnt_stat);
-#else
-    afs_statfs(mp, &mp->mnt_stat, p);
-#endif
 
     return 0;
 }
 
-#ifdef AFS_FBSD53_ENV
-int
-#ifdef AFS_FBSD80_ENV
+static int
 afs_mount(struct mount *mp)
-#else
-afs_mount(struct mount *mp, struct thread *td)
-#endif
 {
-#ifdef AFS_FBSD80_ENV
     return afs_omount(mp, NULL, NULL);
-#else
-    return afs_omount(mp, NULL, NULL, td);
-#endif
 }
-#endif
 
-#ifdef AFS_FBSD60_ENV
 static int
-#if (__FreeBSD_version >= 900503 && __FreeBSD_version < 1000000) || __FreeBSD_version >= 1000004
+#if __FreeBSD_version >= 1000004
 afs_cmount(struct mntarg *ma, void *data, uint64_t flags)
-#elif defined(AFS_FBSD80_ENV)
-afs_cmount(struct mntarg *ma, void *data, int flags)
 #else
-afs_cmount(struct mntarg *ma, void *data, int flags, struct thread *td)
+afs_cmount(struct mntarg *ma, void *data, int flags)
 #endif
 {
     return kernel_mount(ma, flags);
 }
-#endif
 
-int
-#ifdef AFS_FBSD80_ENV
+static int
 afs_unmount(struct mount *mp, int flags)
-#else
-afs_unmount(struct mount *mp, int flags, struct thread *p)
-#endif
 {
     int error = 0;
 
@@ -222,20 +175,13 @@ afs_unmount(struct mount *mp, int flags, struct thread *p)
 	error = EBUSY;
     AFS_GUNLOCK();
 
-    /*
-     * Release any remaining vnodes on this mount point.
-     * The `1' means that we hold one extra reference on
-     * the root vnode (this is just a guess right now).
-     * This has to be done outside the global lock.
-     */
     if (!error) {
-#if defined(AFS_FBSD80_ENV)
-	error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread);
-#elif defined(AFS_FBSD53_ENV)
-	error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0, p);
-#else
-	error = vflush(mp, 1, (flags & MNT_FORCE) ? FORCECLOSE : 0);
-#endif
+	/*
+	 * Release any remaining vnodes on this mount point. The second
+	 * argument is how many refs we hold on the root vnode. Since we
+	 * released our reference to the root vnode up above, give 0.
+	 */
+	error = vflush(mp, 0, (flags & MNT_FORCE) ? FORCECLOSE : 0, curthread);
     }
     if (error)
 	goto out;
@@ -249,24 +195,14 @@ out:
     return error;
 }
 
-int
-#if defined(AFS_FBSD80_ENV)
+static int
 afs_root(struct mount *mp, int flags, struct vnode **vpp)
-#elif defined(AFS_FBSD60_ENV)
-afs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td)
-#elif defined(AFS_FBSD53_ENV)
-afs_root(struct mount *mp, struct vnode **vpp, struct thread *td)
-#else
-afs_root(struct mount *mp, struct vnode **vpp)
-#endif
 {
     int error;
     struct vrequest treq;
     struct vcache *tvp = 0;
     struct vcache *gvp;
-#if !defined(AFS_FBSD53_ENV) || defined(AFS_FBSD80_ENV)
     struct thread *td = curthread;
-#endif
     struct ucred *cr = osi_curcred();
 
     AFS_GLOCK();
@@ -278,7 +214,7 @@ tryagain:
 	error = 0;
     } else {
 	if (!(error = afs_InitReq(&treq, cr)) && !(error = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 	    /* we really want this to stay around */
 	    if (tvp) {
 		gvp = afs_globalVp;
@@ -329,49 +265,12 @@ tryagain:
     return error;
 }
 
-int
-#ifdef AFS_FBSD80_ENV
-afs_statfs(struct mount *mp, struct statfs *abp)
-#else
-afs_statfs(struct mount *mp, struct statfs *abp, struct thread *p)
-#endif
-{
-    AFS_GLOCK();
-    AFS_STATCNT(afs_statfs);
-
-    abp->f_bsize = mp->vfs_bsize;
-    abp->f_iosize = mp->vfs_bsize;
-
-    abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
-	abp->f_ffree = AFS_VFS_FAKEFREE;
-
-    abp->f_fsid.val[0] = mp->mnt_stat.f_fsid.val[0];
-    abp->f_fsid.val[1] = mp->mnt_stat.f_fsid.val[1];
-    if (abp != &mp->mnt_stat) {
-	abp->f_type = mp->mnt_vfc->vfc_typenum;
-	memcpy((caddr_t) & abp->f_mntonname[0],
-	       (caddr_t) mp->mnt_stat.f_mntonname, MNAMELEN);
-	memcpy((caddr_t) & abp->f_mntfromname[0],
-	       (caddr_t) mp->mnt_stat.f_mntfromname, MNAMELEN);
-    }
-
-    AFS_GUNLOCK();
-    return 0;
-}
-
-int
-#if defined(AFS_FBSD80_ENV)
+static int
 afs_sync(struct mount *mp, int waitfor)
-#elif defined(AFS_FBSD60_ENV)
-afs_sync(struct mount *mp, int waitfor, struct thread *td)
-#else
-afs_sync(struct mount *mp, int waitfor, struct ucred *cred, struct thread *p)
-#endif
 {
     return 0;
 }
 
-#ifdef AFS_FBSD60_ENV
 struct vfsops afs_vfsops = {
 	.vfs_init =		afs_init,
 	.vfs_mount =		afs_mount,
@@ -383,25 +282,3 @@ struct vfsops afs_vfsops = {
 	.vfs_unmount =		afs_unmount,
 	.vfs_sysctl =		vfs_stdsysctl,
 };
-#else
-struct vfsops afs_vfsops = {
-#ifdef AFS_FBSD53_ENV
-    afs_mount,
-#endif
-    afs_omount,
-    afs_start,
-    afs_unmount,
-    afs_root,
-    vfs_stdquotactl,
-    afs_statfs,
-    afs_sync,
-    vfs_stdvget,
-    vfs_stdfhtovp,
-    vfs_stdcheckexp,
-    vfs_stdvptofh,
-    afs_init,
-    afs_uninit,
-    vfs_stdextattrctl,
-    vfs_stdsysctl,
-};
-#endif
diff --git a/src/afs/FBSD/osi_vm.c b/src/afs/FBSD/osi_vm.c
index d475d914e..780ae1280 100644
--- a/src/afs/FBSD/osi_vm.c
+++ b/src/afs/FBSD/osi_vm.c
@@ -48,17 +48,10 @@
  * check the VCS history of those files.
  */
 
-#if defined(AFS_FBSD80_ENV)
 #define	lock_vnode(v, f)	vn_lock((v), (f))
 #define ilock_vnode(v)	vn_lock((v), LK_INTERLOCK|LK_EXCLUSIVE|LK_RETRY)
 #define unlock_vnode(v)	VOP_UNLOCK((v), 0)
 #define islocked_vnode(v)	VOP_ISLOCKED((v))
-#else
-#define	lock_vnode(v, f)	vn_lock((v), (f), curthread)
-#define ilock_vnode(v)	vn_lock((v), LK_INTERLOCK|LK_EXCLUSIVE|LK_RETRY, curthread)
-#define unlock_vnode(v)	VOP_UNLOCK((v), 0, curthread)
-#define islocked_vnode(v)	VOP_ISLOCKED((v), curthread)
-#endif
 
 #if __FreeBSD_version >= 1000030
 #define AFS_VM_OBJECT_WLOCK(o)	VM_OBJECT_WLOCK(o)
@@ -86,8 +79,7 @@ osi_VM_FlushVCache(struct vcache *avc)
 
     vp = AFSTOV(avc);
 
-    if (!VI_TRYLOCK(vp))
-	return EBUSY;
+    VI_LOCK(vp);
     code = osi_fbsd_checkinuse(avc);
     if (code) {
 	VI_UNLOCK(vp);
@@ -180,6 +172,8 @@ osi_VM_TryToSmush(struct vcache *avc, afs_ucred_t *acred, int sync)
     }
     VI_UNLOCK(vp);
 
+    AFS_GUNLOCK();
+
     islocked = islocked_vnode(vp);
     if (islocked == LK_EXCLOTHER)
 	panic("Trying to Smush over someone else's lock");
@@ -220,6 +214,8 @@ osi_VM_TryToSmush(struct vcache *avc, afs_ucred_t *acred, int sync)
 	lock_vnode(vp, LK_DOWNGRADE);
     else if (!islocked)
 	unlock_vnode(vp);
+
+    AFS_GLOCK();
 }
 
 /* Purge VM for a file when its callback is revoked.
diff --git a/src/afs/FBSD/osi_vnodeops.c b/src/afs/FBSD/osi_vnodeops.c
index df97f349d..828a0a485 100644
--- a/src/afs/FBSD/osi_vnodeops.c
+++ b/src/afs/FBSD/osi_vnodeops.c
@@ -63,166 +63,6 @@
 #include <vm/vnode_pager.h>
 extern int afs_pbuf_freecnt;
 
-#ifdef AFS_FBSD60_ENV
-static vop_access_t	afs_vop_access;
-static vop_advlock_t	afs_vop_advlock;
-static vop_close_t	afs_vop_close;
-static vop_create_t	afs_vop_create;
-static vop_fsync_t	afs_vop_fsync;
-static vop_getattr_t	afs_vop_getattr;
-static vop_getpages_t	afs_vop_getpages;
-static vop_inactive_t	afs_vop_inactive;
-static vop_ioctl_t	afs_vop_ioctl;
-static vop_link_t	afs_vop_link;
-static vop_lookup_t	afs_vop_lookup;
-static vop_mkdir_t	afs_vop_mkdir;
-static vop_mknod_t	afs_vop_mknod;
-static vop_open_t	afs_vop_open;
-static vop_pathconf_t	afs_vop_pathconf;
-static vop_print_t	afs_vop_print;
-static vop_putpages_t	afs_vop_putpages;
-static vop_read_t	afs_vop_read;
-static vop_readdir_t	afs_vop_readdir;
-static vop_readlink_t	afs_vop_readlink;
-static vop_reclaim_t	afs_vop_reclaim;
-static vop_remove_t	afs_vop_remove;
-static vop_rename_t	afs_vop_rename;
-static vop_rmdir_t	afs_vop_rmdir;
-static vop_setattr_t	afs_vop_setattr;
-static vop_strategy_t	afs_vop_strategy;
-static vop_symlink_t	afs_vop_symlink;
-static vop_write_t	afs_vop_write;
-#if defined(AFS_FBSD70_ENV) && !defined(AFS_FBSD80_ENV)
-static vop_lock1_t      afs_vop_lock;
-static vop_unlock_t     afs_vop_unlock;
-static vop_islocked_t   afs_vop_islocked;
-#endif
-
-struct vop_vector afs_vnodeops = {
-	.vop_default =		&default_vnodeops,
-	.vop_access =		afs_vop_access,
-	.vop_advlock =		afs_vop_advlock,
-	.vop_close =		afs_vop_close,
-	.vop_create =		afs_vop_create,
-	.vop_fsync =		afs_vop_fsync,
-	.vop_getattr =		afs_vop_getattr,
-	.vop_getpages =		afs_vop_getpages,
-	.vop_inactive =		afs_vop_inactive,
-	.vop_ioctl =		afs_vop_ioctl,
-#if !defined(AFS_FBSD80_ENV)
-	/* removed at least temporarily (NFSv4 flux) */
-	.vop_lease =		VOP_NULL,
-#endif
-	.vop_link =		afs_vop_link,
-	.vop_lookup =		afs_vop_lookup,
-	.vop_mkdir =		afs_vop_mkdir,
-	.vop_mknod =		afs_vop_mknod,
-	.vop_open =		afs_vop_open,
-	.vop_pathconf =		afs_vop_pathconf,
-	.vop_print =		afs_vop_print,
-	.vop_putpages =		afs_vop_putpages,
-	.vop_read =		afs_vop_read,
-	.vop_readdir =		afs_vop_readdir,
-	.vop_readlink =		afs_vop_readlink,
-	.vop_reclaim =		afs_vop_reclaim,
-	.vop_remove =		afs_vop_remove,
-	.vop_rename =		afs_vop_rename,
-	.vop_rmdir =		afs_vop_rmdir,
-	.vop_setattr =		afs_vop_setattr,
-	.vop_strategy =		afs_vop_strategy,
-	.vop_symlink =		afs_vop_symlink,
-	.vop_write =		afs_vop_write,
-#if defined(AFS_FBSD70_ENV) && !defined(AFS_FBSD80_ENV)
-	.vop_lock1 =            afs_vop_lock,
-	.vop_unlock =           afs_vop_unlock,
-	.vop_islocked =         afs_vop_islocked,
-#endif
-};
-
-#else /* AFS_FBSD60_ENV */
-
-int afs_vop_lookup(struct vop_lookup_args *);
-int afs_vop_create(struct vop_create_args *);
-int afs_vop_mknod(struct vop_mknod_args *);
-int afs_vop_open(struct vop_open_args *);
-int afs_vop_close(struct vop_close_args *);
-int afs_vop_access(struct vop_access_args *);
-int afs_vop_getattr(struct vop_getattr_args *);
-int afs_vop_setattr(struct vop_setattr_args *);
-int afs_vop_read(struct vop_read_args *);
-int afs_vop_write(struct vop_write_args *);
-int afs_vop_getpages(struct vop_getpages_args *);
-int afs_vop_putpages(struct vop_putpages_args *);
-int afs_vop_ioctl(struct vop_ioctl_args *);
-static int afs_vop_pathconf(struct vop_pathconf_args *);
-int afs_vop_fsync(struct vop_fsync_args *);
-int afs_vop_remove(struct vop_remove_args *);
-int afs_vop_link(struct vop_link_args *);
-int afs_vop_rename(struct vop_rename_args *);
-int afs_vop_mkdir(struct vop_mkdir_args *);
-int afs_vop_rmdir(struct vop_rmdir_args *);
-int afs_vop_symlink(struct vop_symlink_args *);
-int afs_vop_readdir(struct vop_readdir_args *);
-int afs_vop_readlink(struct vop_readlink_args *);
-int afs_vop_inactive(struct vop_inactive_args *);
-int afs_vop_reclaim(struct vop_reclaim_args *);
-int afs_vop_bmap(struct vop_bmap_args *);
-int afs_vop_strategy(struct vop_strategy_args *);
-int afs_vop_print(struct vop_print_args *);
-int afs_vop_advlock(struct vop_advlock_args *);
-
-
-
-/* Global vfs data structures for AFS. */
-vop_t **afs_vnodeop_p;
-struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
-    {&vop_default_desc, (vop_t *) vop_defaultop},
-    {&vop_access_desc, (vop_t *) afs_vop_access},	/* access */
-    {&vop_advlock_desc, (vop_t *) afs_vop_advlock},	/* advlock */
-    {&vop_bmap_desc, (vop_t *) afs_vop_bmap},	/* bmap */
-    {&vop_close_desc, (vop_t *) afs_vop_close},	/* close */
-    {&vop_createvobject_desc, (vop_t *) vop_stdcreatevobject},
-    {&vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject},
-    {&vop_create_desc, (vop_t *) afs_vop_create},	/* create */
-    {&vop_fsync_desc, (vop_t *) afs_vop_fsync},	/* fsync */
-    {&vop_getattr_desc, (vop_t *) afs_vop_getattr},	/* getattr */
-    {&vop_getpages_desc, (vop_t *) afs_vop_getpages},	/* read */
-    {&vop_getvobject_desc, (vop_t *) vop_stdgetvobject},
-    {&vop_putpages_desc, (vop_t *) afs_vop_putpages},	/* write */
-    {&vop_inactive_desc, (vop_t *) afs_vop_inactive},	/* inactive */
-    {&vop_lease_desc, (vop_t *) vop_null},
-    {&vop_link_desc, (vop_t *) afs_vop_link},	/* link */
-    {&vop_lookup_desc, (vop_t *) afs_vop_lookup},	/* lookup */
-    {&vop_mkdir_desc, (vop_t *) afs_vop_mkdir},	/* mkdir */
-    {&vop_mknod_desc, (vop_t *) afs_vop_mknod},	/* mknod */
-    {&vop_open_desc, (vop_t *) afs_vop_open},	/* open */
-    {&vop_pathconf_desc, (vop_t *) afs_vop_pathconf},	/* pathconf */
-    {&vop_poll_desc, (vop_t *) vop_nopoll},	/* select */
-    {&vop_print_desc, (vop_t *) afs_vop_print},	/* print */
-    {&vop_read_desc, (vop_t *) afs_vop_read},	/* read */
-    {&vop_readdir_desc, (vop_t *) afs_vop_readdir},	/* readdir */
-    {&vop_readlink_desc, (vop_t *) afs_vop_readlink},	/* readlink */
-    {&vop_reclaim_desc, (vop_t *) afs_vop_reclaim},	/* reclaim */
-    {&vop_remove_desc, (vop_t *) afs_vop_remove},	/* remove */
-    {&vop_rename_desc, (vop_t *) afs_vop_rename},	/* rename */
-    {&vop_rmdir_desc, (vop_t *) afs_vop_rmdir},	/* rmdir */
-    {&vop_setattr_desc, (vop_t *) afs_vop_setattr},	/* setattr */
-    {&vop_strategy_desc, (vop_t *) afs_vop_strategy},	/* strategy */
-    {&vop_symlink_desc, (vop_t *) afs_vop_symlink},	/* symlink */
-    {&vop_write_desc, (vop_t *) afs_vop_write},	/* write */
-    {&vop_ioctl_desc, (vop_t *) afs_vop_ioctl},	/* XXX ioctl */
-    /*{ &vop_seek_desc, afs_vop_seek }, *//* seek */
-#if defined(AFS_FBSD70_ENV) && !defined(AFS_FBSD90_ENV)
-    {&vop_lock1_desc, (vop_t *) afs_vop_lock}, /* lock */
-    {&vop_unlock_desc, (vop_t *) afs_vop_unlock}, /* unlock */
-    {&vop_islocked_desc, (vop_t *) afs_vop_islocked}, /* islocked */
-#endif
-    {NULL, NULL}
-};
-struct vnodeopv_desc afs_vnodeop_opv_desc =
-    { &afs_vnodeop_p, afs_vnodeop_entries };
-#endif /* AFS_FBSD60_ENV */
-
 #define GETNAME()       \
     struct componentname *cnp = ap->a_cnp; \
     char *name; \
@@ -236,35 +76,10 @@ struct vnodeopv_desc afs_vnodeop_opv_desc =
  * Here we define compatibility functions/macros for interfaces that
  * have changed between different FreeBSD versions.
  */
-#if defined(AFS_FBSD90_ENV)
 static __inline void ma_vm_page_lock_queues(void) {};
 static __inline void ma_vm_page_unlock_queues(void) {};
 static __inline void ma_vm_page_lock(vm_page_t m) { vm_page_lock(m); };
 static __inline void ma_vm_page_unlock(vm_page_t m) { vm_page_unlock(m); };
-#else
-static __inline void ma_vm_page_lock_queues(void) { vm_page_lock_queues(); };
-static __inline void ma_vm_page_unlock_queues(void) { vm_page_unlock_queues(); };
-static __inline void ma_vm_page_lock(vm_page_t m) {};
-static __inline void ma_vm_page_unlock(vm_page_t m) {};
-#endif
-
-#if defined(AFS_FBSD80_ENV)
-#define ma_vn_lock(vp, flags, p) (vn_lock(vp, flags))
-#define MA_VOP_LOCK(vp, flags, p) (VOP_LOCK(vp, flags))
-#define MA_VOP_UNLOCK(vp, flags, p) (VOP_UNLOCK(vp, flags))
-#else
-#define ma_vn_lock(vp, flags, p) (vn_lock(vp, flags, p))
-#define MA_VOP_LOCK(vp, flags, p) (VOP_LOCK(vp, flags, p))
-#define MA_VOP_UNLOCK(vp, flags, p) (VOP_UNLOCK(vp, flags, p))
-#endif
-
-#if defined(AFS_FBSD70_ENV)
-#define MA_PCPU_INC(c) PCPU_INC(c)
-#define	MA_PCPU_ADD(c, n) PCPU_ADD(c, n)
-#else
-#define MA_PCPU_INC(c) PCPU_LAZY_INC(c)
-#define	MA_PCPU_ADD(c, n) (c) += (n)
-#endif
 
 #if __FreeBSD_version >= 1000030
 #define AFS_VM_OBJECT_WLOCK(o)	VM_OBJECT_WLOCK(o)
@@ -274,113 +89,6 @@ static __inline void ma_vm_page_unlock(vm_page_t m) {};
 #define AFS_VM_OBJECT_WUNLOCK(o)	VM_OBJECT_UNLOCK(o)
 #endif
 
-#ifdef AFS_FBSD70_ENV
-#ifndef AFS_FBSD80_ENV
-/* From kern_lock.c */
-#define	COUNT(td, x)	if ((td)) (td)->td_locks += (x)
-#define LK_ALL (LK_HAVE_EXCL | LK_WANT_EXCL | LK_WANT_UPGRADE | \
-	LK_SHARE_NONZERO | LK_WAIT_NONZERO)
-
-static __inline void
-sharelock(struct thread *td, struct lock *lkp, int incr) {
-	lkp->lk_flags |= LK_SHARE_NONZERO;
-	lkp->lk_sharecount += incr;
-	COUNT(td, incr);
-}
-#endif
-
-/*
- * Standard lock, unlock and islocked functions.
- */
-int
-afs_vop_lock(ap)
-    struct vop_lock1_args /* {
-			     struct vnode *a_vp;
-			     int a_flags;
-			     struct thread *a_td;
-			     char *file;
-			     int line;
-			     } */ *ap;
-{
-    struct vnode *vp = ap->a_vp;
-    struct lock *lkp = vp->v_vnlock;
-
-#if 0 && defined(AFS_FBSD80_ENV) && !defined(UKERNEL)
-    afs_warn("afs_vop_lock: tid %d pid %d \"%s\"\n", curthread->td_tid,
-	     curthread->td_proc->p_pid, curthread->td_name);
-    kdb_backtrace();
-#endif
-
-#ifdef AFS_FBSD80_ENV
-    return (_lockmgr_args(lkp, ap->a_flags, VI_MTX(vp),
-			  LK_WMESG_DEFAULT, LK_PRIO_DEFAULT, LK_TIMO_DEFAULT,
-			  ap->a_file, ap->a_line));
-#else
-    return (_lockmgr(lkp, ap->a_flags, VI_MTX(vp), ap->a_td, ap->a_file, ap->a_line));
-#endif
-}
-
-/* See above. */
-int
-afs_vop_unlock(ap)
-    struct vop_unlock_args /* {
-			      struct vnode *a_vp;
-			      int a_flags;
-			      struct thread *a_td;
-			      } */ *ap;
-{
-    struct vnode *vp = ap->a_vp;
-    struct lock *lkp = vp->v_vnlock;
-
-#ifdef AFS_FBSD80_ENV
-    int code = 0;
-    u_int op;
-    op = ((ap->a_flags) | LK_RELEASE) & LK_TYPE_MASK;
-    int glocked = ISAFS_GLOCK();
-    if (glocked)
-	AFS_GUNLOCK();
-    if ((op & (op - 1)) != 0) {
-      afs_warn("afs_vop_unlock: Shit.\n");
-      goto done;
-    }
-    code = lockmgr(lkp, ap->a_flags | LK_RELEASE, VI_MTX(vp));
- done:
-    if (glocked)
-	AFS_GLOCK();
-    return(code);
-#else
-    /* possibly in current code path where this
-     * forces trace, we should have had a (shared? not
-     * necessarily, see _lockmgr in kern_lock.c) lock
-     * and that's the real bug.  but. 
-     */
-    critical_enter();
-    if ((lkp->lk_exclusivecount == 0) &&
-	(!(lkp->lk_flags & LK_SHARE_NONZERO))) {
-	sharelock(ap->a_td, lkp, 1);
-    }
-    critical_exit();
-    return (lockmgr(lkp, ap->a_flags | LK_RELEASE, VI_MTX(vp),
-		    ap->a_td));
-#endif
-}
-
-/* See above. */
-int
-afs_vop_islocked(ap)
-    struct vop_islocked_args /* {
-				struct vnode *a_vp;
-				struct thread *a_td; (not in 80)
-				} */ *ap;
-{
-#ifdef AFS_FBSD80_ENV
-    return (lockstatus(ap->a_vp->v_vnlock));
-#else
-    return (lockstatus(ap->a_vp->v_vnlock, ap->a_td));
-#endif
-}
-#endif /* 70 */
-
 /*
  * Mosty copied from sys/ufs/ufs/ufs_vnops.c:ufs_pathconf().
  * We should know the correct answers to these questions with
@@ -474,7 +182,7 @@ afs_vop_pathconf(struct vop_pathconf_args *ap)
 	return (error);
 }
 
-int
+static int
 afs_vop_lookup(ap)
      struct vop_lookup_args	/* {
 				 * struct vnodeop_desc * a_desc;
@@ -487,17 +195,9 @@ afs_vop_lookup(ap)
     struct vcache *vcp;
     struct vnode *vp, *dvp;
     int flags = ap->a_cnp->cn_flags;
-    int lockparent;		/* 1 => lockparent flag is set */
-    int wantparent;		/* 1 => wantparent or lockparent flag */
-#ifndef AFS_FBSD80_ENV
-    struct thread *p = ap->a_cnp->cn_thread;
-#endif
 
     dvp = ap->a_dvp;
     if (dvp->v_type != VDIR) {
-#ifndef AFS_FBSD70_ENV
-	*ap->a_vpp = 0;
-#endif
 	return ENOTDIR;
     }
 
@@ -506,15 +206,30 @@ afs_vop_lookup(ap)
 
     GETNAME();
 
-    lockparent = flags & LOCKPARENT;
-    wantparent = flags & (LOCKPARENT | WANTPARENT);
-
 #if __FreeBSD_version < 1000021
     cnp->cn_flags |= MPSAFE; /* steel */
 #endif
 
+    /*
+     * Locking rules:
+     *
+     * - 'dvp' is locked by our caller. We must return it locked, whether we
+     * return success or error.
+     *
+     * - If the lookup succeeds, 'vp' must be locked before we return.
+     *
+     * - If we lock multiple vnodes, parent vnodes must be locked before
+     * children vnodes.
+     *
+     * As a result, looking up the parent directory (if 'flags' has ISDOTDOT
+     * set) is a bit of a special case. In that case, we must unlock 'dvp'
+     * before performing the lookup, since the lookup operation may lock the
+     * target vnode, and the target vnode is the parent of 'dvp' (so we must
+     * lock 'dvp' after locking the target vnode).
+     */
+
     if (flags & ISDOTDOT)
-	MA_VOP_UNLOCK(dvp, 0, p);
+	VOP_UNLOCK(dvp, 0);
 
     AFS_GLOCK();
     error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
@@ -522,7 +237,7 @@ afs_vop_lookup(ap)
 
     if (error) {
 	if (flags & ISDOTDOT)
-	    MA_VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
+	    vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
 	if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
 	    && (flags & ISLASTCN) && error == ENOENT)
 	    error = EJUSTRETURN;
@@ -534,44 +249,26 @@ afs_vop_lookup(ap)
     }
     vp = AFSTOV(vcp);		/* always get a node if no error */
 
-    /* The parent directory comes in locked.  We unlock it on return
-     * unless the caller wants it left locked.
-     * we also always return the vnode locked. */
-
     if (flags & ISDOTDOT) {
-	/* vp before dvp since we go root to leaf, and .. comes first */
-	ma_vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
-	ma_vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY, p);
-	/* always return the child locked */
-	if (lockparent && (flags & ISLASTCN)
-	    && (error = ma_vn_lock(dvp, LK_EXCLUSIVE, p))) {
-	    vput(vp);
-	    DROPNAME();
-	    return (error);
-	}
+	/* Must lock 'vp' before 'dvp', since 'vp' is the parent vnode. */
+	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
+	vn_lock(dvp, LK_EXCLUSIVE | LK_RETRY);
     } else if (vp == dvp) {
 	/* they're the same; afs_lookup() already ref'ed the leaf.
 	 * It came in locked, so we don't need to ref OR lock it */
     } else {
-	if (!lockparent || !(flags & ISLASTCN)) {
-#ifndef AFS_FBSD70_ENV /* 6 too? */
-	    MA_VOP_UNLOCK(dvp, 0, p);	/* done with parent. */
-#endif
-	}
-	ma_vn_lock(vp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY, p);
-	/* always return the child locked */
+	vn_lock(vp, LK_EXCLUSIVE | LK_CANRECURSE | LK_RETRY);
     }
     *ap->a_vpp = vp;
 
-    if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN))
-	|| (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)))
+    if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
 	cnp->cn_flags |= SAVENAME;
 
     DROPNAME();
     return error;
 }
 
-int
+static int
 afs_vop_create(ap)
      struct vop_create_args	/* {
 				 * struct vnode *a_dvp;
@@ -583,9 +280,6 @@ afs_vop_create(ap)
     int error = 0;
     struct vcache *vcp;
     struct vnode *dvp = ap->a_dvp;
-#ifndef AFS_FBSD80_ENV
-    struct thread *p = ap->a_cnp->cn_thread;
-#endif
     GETNAME();
 
     AFS_GLOCK();
@@ -601,7 +295,7 @@ afs_vop_create(ap)
 
     if (vcp) {
 	*ap->a_vpp = AFSTOV(vcp);
-	ma_vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p);
+	vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY);
     } else
 	*ap->a_vpp = 0;
 
@@ -609,7 +303,7 @@ afs_vop_create(ap)
     return error;
 }
 
-int
+static int
 afs_vop_mknod(ap)
      struct vop_mknod_args	/* {
 				 * struct vnode *a_dvp;
@@ -621,28 +315,7 @@ afs_vop_mknod(ap)
     return (ENODEV);
 }
 
-#if 0
 static int
-validate_vops(struct vnode *vp, int after)
-{
-    int ret = 0;
-    struct vnodeopv_entry_desc *this;
-    for (this = afs_vnodeop_entries; this->opve_op; this++) {
-	if (vp->v_op[this->opve_op->vdesc_offset] != this->opve_impl) {
-	    if (!ret) {
-		printf("v_op %d ", after);
-		vprint("check", vp);
-	    }
-	    ret = 1;
-	    printf("For oper %d (%s), func is %p, not %p",
-		   this->opve_op->vdesc_offset, this->opve_op->vdesc_name,
-		   vp->v_op[this->opve_op->vdesc_offset], this->opve_impl);
-	}
-    }
-    return ret;
-}
-#endif
-int
 afs_vop_open(ap)
      struct vop_open_args	/* {
 				 * struct vnode *a_vp;
@@ -662,14 +335,12 @@ afs_vop_open(ap)
 	panic("AFS open changed vnode!");
 #endif
     AFS_GUNLOCK();
-#ifdef AFS_FBSD60_ENV
     vnode_create_vobject(ap->a_vp, vc->f.m.Length, ap->a_td);
-#endif
     osi_FlushPages(vc, ap->a_cred);
     return error;
 }
 
-int
+static int
 afs_vop_close(ap)
      struct vop_close_args	/* {
 				 * struct vnode *a_vp;
@@ -682,7 +353,6 @@ afs_vop_close(ap)
     struct vnode *vp = ap->a_vp;
     struct vcache *avc = VTOAFS(vp);
 
-#if defined(AFS_FBSD80_ENV)
     VI_LOCK(vp);
     iflag = vp->v_iflag & VI_DOOMED;
     VI_UNLOCK(vp);
@@ -694,7 +364,6 @@ afs_vop_close(ap)
                   vp, avc, avc->opens);
         return 0;
     }
-#endif
 
     AFS_GLOCK();
     if (ap->a_cred)
@@ -706,7 +375,7 @@ afs_vop_close(ap)
     return code;
 }
 
-int
+static int
 afs_vop_access(ap)
      struct vop_access_args	/* {
 				 * struct vnode *a_vp;
@@ -717,16 +386,12 @@ afs_vop_access(ap)
 {
     int code;
     AFS_GLOCK();
-#if defined(AFS_FBSD80_ENV)
     code = afs_access(VTOAFS(ap->a_vp), ap->a_accmode, ap->a_cred);
-#else
-    code = afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
-#endif
     AFS_GUNLOCK();
     return code;
 }
 
-int
+static int
 afs_vop_getattr(ap)
      struct vop_getattr_args	/* {
 				 * struct vnode *a_vp;
@@ -743,7 +408,7 @@ afs_vop_getattr(ap)
     return code;
 }
 
-int
+static int
 afs_vop_setattr(ap)
      struct vop_setattr_args	/* {
 				 * struct vnode *a_vp;
@@ -758,7 +423,7 @@ afs_vop_setattr(ap)
     return code;
 }
 
-int
+static int
 afs_vop_read(ap)
      struct vop_read_args	/* {
 				 * struct vnode *a_vp;
@@ -785,7 +450,7 @@ afs_vop_read(ap)
  *	int *a_rahead;
  * };
  */
-int
+static int
 afs_vop_getpages(struct vop_getpages_args *ap)
 {
     int code;
@@ -862,8 +527,8 @@ afs_vop_getpages(struct vop_getpages_args *ap)
 
     kva = (vm_offset_t) bp->b_data;
     pmap_qenter(kva, pages, npages);
-    MA_PCPU_INC(cnt.v_vnodein);
-    MA_PCPU_ADD(cnt.v_vnodepgsin, npages);
+    PCPU_INC(cnt.v_vnodein);
+    PCPU_ADD(cnt.v_vnodepgsin, npages);
 
 #ifdef FBSD_VOP_GETPAGES_BUSIED
     count = ctob(npages);
@@ -918,11 +583,7 @@ afs_vop_getpages(struct vop_getpages_args *ap)
 	     * Read operation filled an entire page
 	     */
 	    m->valid = VM_PAGE_BITS_ALL;
-#ifndef AFS_FBSD80_ENV
-	    vm_page_undirty(m);
-#else
 	    KASSERT(m->dirty == 0, ("afs_getpages: page %p is dirty", m));
-#endif
 	} else if (size > toff) {
 	    /*
 	     * Read operation filled a partial page.
@@ -950,11 +611,7 @@ afs_vop_getpages(struct vop_getpages_args *ap)
 	     * now tell them that it is ok to use.
 	     */
 	    if (!code) {
-#if defined(AFS_FBSD70_ENV)
 		if (m->oflags & VPO_WANTED) {
-#else
-		if (m->flags & PG_WANTED) {
-#endif
 		    ma_vm_page_lock(m);
 		    vm_page_activate(m);
 		    ma_vm_page_unlock(m);
@@ -979,7 +636,7 @@ afs_vop_getpages(struct vop_getpages_args *ap)
     return VM_PAGER_OK;
 }
 
-int
+static int
 afs_vop_write(ap)
      struct vop_write_args	/* {
 				 * struct vnode *a_vp;
@@ -1012,7 +669,7 @@ afs_vop_write(ap)
  * All of the pages passed to us in ap->a_m[] are already marked as busy,
  * so there is no additional locking required to set their flags.  -GAW
  */
-int
+static int
 afs_vop_putpages(struct vop_putpages_args *ap)
 {
     int code;
@@ -1045,8 +702,8 @@ afs_vop_putpages(struct vop_putpages_args *ap)
 
     kva = (vm_offset_t) bp->b_data;
     pmap_qenter(kva, ap->a_m, npages);
-    MA_PCPU_INC(cnt.v_vnodeout);
-    MA_PCPU_ADD(cnt.v_vnodepgsout, ap->a_count);
+    PCPU_INC(cnt.v_vnodeout);
+    PCPU_ADD(cnt.v_vnodepgsout, ap->a_count);
 
     iov.iov_base = (caddr_t) kva;
     iov.iov_len = ap->a_count;
@@ -1080,7 +737,7 @@ afs_vop_putpages(struct vop_putpages_args *ap)
     return ap->a_rtvals[0];
 }
 
-int
+static int
 afs_vop_ioctl(ap)
      struct vop_ioctl_args	/* {
 				 * struct vnode *a_vp;
@@ -1109,7 +766,7 @@ afs_vop_ioctl(ap)
     }
 }
 
-int
+static int
 afs_vop_fsync(ap)
      struct vop_fsync_args	/* {
 				 * struct vnode *a_vp;
@@ -1122,19 +779,12 @@ afs_vop_fsync(ap)
 
     AFS_GLOCK();
     /*vflushbuf(vp, wait); */
-#ifdef AFS_FBSD60_ENV
     error = afs_fsync(VTOAFS(vp), ap->a_td->td_ucred);
-#else
-    if (ap->a_cred)
-	error = afs_fsync(VTOAFS(vp), ap->a_cred);
-    else
-	error = afs_fsync(VTOAFS(vp), afs_osi_credp);
-#endif
     AFS_GUNLOCK();
     return error;
 }
 
-int
+static int
 afs_vop_remove(ap)
      struct vop_remove_args	/* {
 				 * struct vnode *a_dvp;
@@ -1155,7 +805,7 @@ afs_vop_remove(ap)
     return error;
 }
 
-int
+static int
 afs_vop_link(ap)
      struct vop_link_args	/* {
 				 * struct vnode *a_vp;
@@ -1166,9 +816,6 @@ afs_vop_link(ap)
     int error = 0;
     struct vnode *dvp = ap->a_tdvp;
     struct vnode *vp = ap->a_vp;
-#ifndef AFS_FBSD80_ENV
-    struct thread *p = ap->a_cnp->cn_thread;
-#endif
 
     GETNAME();
     if (dvp->v_mount != vp->v_mount) {
@@ -1179,20 +826,20 @@ afs_vop_link(ap)
 	error = EISDIR;
 	goto out;
     }
-    if ((error = ma_vn_lock(vp, LK_CANRECURSE | LK_EXCLUSIVE, p)) != 0) {
+    if ((error = vn_lock(vp, LK_CANRECURSE | LK_EXCLUSIVE)) != 0) {
 	goto out;
     }
     AFS_GLOCK();
     error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
     AFS_GUNLOCK();
     if (dvp != vp)
-	MA_VOP_UNLOCK(vp, 0, p);
+	VOP_UNLOCK(vp, 0);
   out:
     DROPNAME();
     return error;
 }
 
-int
+static int
 afs_vop_rename(ap)
      struct vop_rename_args	/* {
 				 * struct vnode *a_fdvp;
@@ -1212,9 +859,6 @@ afs_vop_rename(ap)
     struct vnode *tdvp = ap->a_tdvp;
     struct vnode *fvp = ap->a_fvp;
     struct vnode *fdvp = ap->a_fdvp;
-#ifndef AFS_FBSD80_ENV
-    struct thread *p = fcnp->cn_thread;
-#endif
 
     /*
      * Check for cross-device rename.
@@ -1273,7 +917,7 @@ afs_vop_rename(ap)
 	vput(fvp);
 	return (error);
     }
-    if ((error = ma_vn_lock(fvp, LK_EXCLUSIVE, p)) != 0)
+    if ((error = vn_lock(fvp, LK_EXCLUSIVE)) != 0)
 	goto abortit;
 
     MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
@@ -1303,7 +947,7 @@ afs_vop_rename(ap)
     return error;
 }
 
-int
+static int
 afs_vop_mkdir(ap)
      struct vop_mkdir_args	/* {
 				 * struct vnode *a_dvp;
@@ -1316,9 +960,6 @@ afs_vop_mkdir(ap)
     struct vattr *vap = ap->a_vap;
     int error = 0;
     struct vcache *vcp;
-#ifndef AFS_FBSD80_ENV
-    struct thread *p = ap->a_cnp->cn_thread;
-#endif
 
     GETNAME();
 #ifdef DIAGNOSTIC
@@ -1334,14 +975,14 @@ afs_vop_mkdir(ap)
     }
     if (vcp) {
 	*ap->a_vpp = AFSTOV(vcp);
-	ma_vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, p);
+	vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY);
     } else
 	*ap->a_vpp = 0;
     DROPNAME();
     return error;
 }
 
-int
+static int
 afs_vop_rmdir(ap)
      struct vop_rmdir_args	/* {
 				 * struct vnode *a_dvp;
@@ -1368,7 +1009,7 @@ afs_vop_rmdir(ap)
  *	char *a_target;
  * };
  */
-int
+static int
 afs_vop_symlink(struct vop_symlink_args *ap)
 {
     struct vnode *dvp;
@@ -1389,7 +1030,7 @@ afs_vop_symlink(struct vop_symlink_args *ap)
 	error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
 	if (error == 0) {
 	    newvp = AFSTOV(vcp);
-	    ma_vn_lock(newvp, LK_EXCLUSIVE | LK_RETRY, cnp->cn_thread);
+	    vn_lock(newvp, LK_EXCLUSIVE | LK_RETRY);
 	}
     }
     AFS_GUNLOCK();
@@ -1398,7 +1039,7 @@ afs_vop_symlink(struct vop_symlink_args *ap)
     return error;
 }
 
-int
+static int
 afs_vop_readdir(ap)
      struct vop_readdir_args	/* {
 				 * struct vnode *a_vp;
@@ -1448,7 +1089,7 @@ afs_vop_readdir(ap)
     return error;
 }
 
-int
+static int
 afs_vop_readlink(ap)
      struct vop_readlink_args	/* {
 				 * struct vnode *a_vp;
@@ -1464,7 +1105,7 @@ afs_vop_readlink(ap)
     return error;
 }
 
-int
+static int
 afs_vop_inactive(ap)
      struct vop_inactive_args	/* {
 				 * struct vnode *a_vp;
@@ -1476,9 +1117,6 @@ afs_vop_inactive(ap)
     AFS_GLOCK();
     afs_InactiveVCache(VTOAFS(vp), 0);	/* decrs ref counts */
     AFS_GUNLOCK();
-#ifndef AFS_FBSD60_ENV
-    MA_VOP_UNLOCK(vp, 0, ap->a_td);
-#endif
     return 0;
 }
 
@@ -1487,21 +1125,34 @@ afs_vop_inactive(ap)
  *	struct vnode *a_vp;
  * };
  */
-int
+static int
 afs_vop_reclaim(struct vop_reclaim_args *ap)
 {
-    /* copied from ../OBSD/osi_vnodeops.c:afs_nbsd_reclaim() */
     int code, slept;
     struct vnode *vp = ap->a_vp;
     struct vcache *avc = VTOAFS(vp);
     int haveGlock = ISAFS_GLOCK();
-    int haveVlock = CheckLock(&afs_xvcache);
+
+    /*
+     * In other code paths, we acquire the vnode lock while afs_xvcache is
+     * already held (e.g. afs_PutVCache() -> vrele()). Here, we already have
+     * the vnode lock, and we need afs_xvcache. So drop the vnode lock in order
+     * to hold afs_xvcache.
+     */
+    VOP_UNLOCK(vp, 0);
 
     if (!haveGlock)
 	AFS_GLOCK();
-    if (!haveVlock)
-	ObtainWriteLock(&afs_xvcache, 901);
-    /* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */
+    ObtainWriteLock(&afs_xvcache, 901);
+
+    /*
+     * Note that we deliberately call VOP_LOCK() instead of vn_lock() here.
+     * vn_lock() will return an error for VI_DOOMED vnodes, but we know this
+     * vnode is already VI_DOOMED. We just want to lock it again, and skip the
+     * VI_DOOMED check.
+     */
+    VOP_LOCK(vp, LK_EXCLUSIVE);
+
     code = afs_FlushVCache(avc, &slept);
 
     if (avc->f.states & CVInit) {
@@ -1509,51 +1160,23 @@ afs_vop_reclaim(struct vop_reclaim_args *ap)
 	afs_osi_Wakeup(&avc->f.states);
     }
 
-    if (!haveVlock)
-	ReleaseWriteLock(&afs_xvcache);
+    ReleaseWriteLock(&afs_xvcache);
     if (!haveGlock)
 	AFS_GUNLOCK();
 
     if (code) {
 	afs_warn("afs_vop_reclaim: afs_FlushVCache failed code %d vnode\n", code);
 	VOP_PRINT(vp);
+	panic("afs: afs_FlushVCache failed during reclaim");
     }
 
-    /* basically, it must not fail */
     vnode_destroy_vobject(vp);
     vp->v_data = 0;
 
     return 0;
 }
 
-#ifndef AFS_FBSD60_ENV
-int
-afs_vop_bmap(ap)
-     struct vop_bmap_args	/* {
-				 * struct vnode *a_vp;
-				 * daddr_t  a_bn;
-				 * struct vnode **a_vpp;
-				 * daddr_t *a_bnp;
-				 * int *a_runp;
-				 * int *a_runb;
-				 * } */ *ap;
-{
-    if (ap->a_bnp) {
-	*ap->a_bnp = ap->a_bn * (PAGE_SIZE / DEV_BSIZE);
-    }
-    if (ap->a_vpp) {
-	*ap->a_vpp = ap->a_vp;
-    }
-    if (ap->a_runp != NULL)
-	*ap->a_runp = 0;
-    if (ap->a_runb != NULL)
-	*ap->a_runb = 0;
-
-    return 0;
-}
-#endif
-
-int
+static int
 afs_vop_strategy(ap)
      struct vop_strategy_args	/* {
 				 * struct buf *a_bp;
@@ -1566,7 +1189,7 @@ afs_vop_strategy(ap)
     return error;
 }
 
-int
+static int
 afs_vop_print(ap)
      struct vop_print_args	/* {
 				 * struct vnode *a_vp;
@@ -1591,7 +1214,7 @@ afs_vop_print(ap)
 /*
  * Advisory record locking support (fcntl() POSIX style)
  */
-int
+static int
 afs_vop_advlock(ap)
      struct vop_advlock_args	/* {
 				 * struct vnode *a_vp;
@@ -1601,15 +1224,59 @@ afs_vop_advlock(ap)
 				 * int  a_flags;
 				 * } */ *ap;
 {
-    int error;
+    int error, a_op;
     struct ucred cr = *osi_curcred();
 
+    a_op = ap->a_op;
+    if (a_op == F_UNLCK) {
+	/*
+	 * When a_fl->type is F_UNLCK, FreeBSD passes in an a_op of F_UNLCK.
+	 * This is (confusingly) different than how you actually release a lock
+	 * with fcntl(), which is done with an a_op of F_SETLK and an l_type of
+	 * F_UNLCK. Pretend we were given an a_op of F_SETLK in this case,
+	 * since this is what afs_lockctl expects.
+	 */
+	a_op = F_SETLK;
+    }
+
     AFS_GLOCK();
     error =
 	afs_lockctl(VTOAFS(ap->a_vp),
 		ap->a_fl,
-		ap->a_op, &cr,
+		a_op, &cr,
 		(int)(intptr_t)ap->a_id);	/* XXX: no longer unique! */
     AFS_GUNLOCK();
     return error;
 }
+
+struct vop_vector afs_vnodeops = {
+	.vop_default =		&default_vnodeops,
+	.vop_access =		afs_vop_access,
+	.vop_advlock =		afs_vop_advlock,
+	.vop_close =		afs_vop_close,
+	.vop_create =		afs_vop_create,
+	.vop_fsync =		afs_vop_fsync,
+	.vop_getattr =		afs_vop_getattr,
+	.vop_getpages =		afs_vop_getpages,
+	.vop_inactive =		afs_vop_inactive,
+	.vop_ioctl =		afs_vop_ioctl,
+	.vop_link =		afs_vop_link,
+	.vop_lookup =		afs_vop_lookup,
+	.vop_mkdir =		afs_vop_mkdir,
+	.vop_mknod =		afs_vop_mknod,
+	.vop_open =		afs_vop_open,
+	.vop_pathconf =		afs_vop_pathconf,
+	.vop_print =		afs_vop_print,
+	.vop_putpages =		afs_vop_putpages,
+	.vop_read =		afs_vop_read,
+	.vop_readdir =		afs_vop_readdir,
+	.vop_readlink =		afs_vop_readlink,
+	.vop_reclaim =		afs_vop_reclaim,
+	.vop_remove =		afs_vop_remove,
+	.vop_rename =		afs_vop_rename,
+	.vop_rmdir =		afs_vop_rmdir,
+	.vop_setattr =		afs_vop_setattr,
+	.vop_strategy =		afs_vop_strategy,
+	.vop_symlink =		afs_vop_symlink,
+	.vop_write =		afs_vop_write,
+};
diff --git a/src/afs/HPUX/osi_file.c b/src/afs/HPUX/osi_file.c
index a562fd46d..e1e62eab0 100644
--- a/src/afs/HPUX/osi_file.c
+++ b/src/afs/HPUX/osi_file.c
@@ -19,7 +19,6 @@
 
 int afs_osicred_initialized = 0;
 afs_ucred_t afs_osi_cred;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
 
@@ -37,7 +36,6 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 	osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
-	/* valid for alpha_osf, SunOS, Ultrix */
 	memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
 	crhold(&afs_osi_cred);	/* don't let it evaporate, since it is static */
 	afs_osicred_initialized = 1;
@@ -66,7 +64,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
     code = VOP_GETATTR(afile->vnode, &tvattr, &afs_osi_cred, VSYNC);
     AFS_GLOCK();
@@ -75,7 +72,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -107,7 +103,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
 	return code;
-    ObtainWriteLock(&afs_xosi, 321);
     VATTR_NULL(&tvattr);
     /* note that this credential swapping stuff is only necessary because
      * of ufs's references directly to u.u_cred instead of to
@@ -119,7 +114,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = VOP_SETATTR(afile->vnode, &tvattr, &afs_osi_cred, 0);
     AFS_GLOCK();
     set_p_cred(u.u_procp, oldCred);	/* restore */
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -207,8 +201,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
 	afile->offset += code;
     } else {
 	if (code == ENOSPC)
-	    afs_warnuser
-		("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
+            afs_WarnENOSPC();
 	setuerror(code);
 	if (code > 0) {
 	    code = -code;
diff --git a/src/afs/HPUX/osi_machdep.h b/src/afs/HPUX/osi_machdep.h
index d8f16c611..f2afe21ce 100644
--- a/src/afs/HPUX/osi_machdep.h
+++ b/src/afs/HPUX/osi_machdep.h
@@ -29,7 +29,6 @@ extern struct timeval time;
 typedef struct ucred afs_ucred_t;
 typedef proc_t afs_proc_t;
 
-#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
 #define gop_rdwr(rw,gp,base,len,offset,segflg,unit,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(unit),(aresid),0)
 #define gop_lookupname(fnamep,segflg,followlink,compvpp) \
@@ -122,4 +121,13 @@ extern caddr_t kmem_alloc();
 
 #define osi_procname(procname, size) strncpy(procname, "", size)
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    uniqtime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/HPUX/osi_misc.c b/src/afs/HPUX/osi_misc.c
index c80bf6a78..ab2eec7c8 100644
--- a/src/afs/HPUX/osi_misc.c
+++ b/src/afs/HPUX/osi_misc.c
@@ -27,7 +27,7 @@
  * Here we have to save and restore errno since the HP-UX suser() sets errno.
  */
 
-afs_suser(void *credp)
+afs_suser(afs_ucred_t *credp)
 {
     int save_errno;
     int code;
diff --git a/src/afs/HPUX/osi_prototypes.h b/src/afs/HPUX/osi_prototypes.h
index 4bc45e9e8..6867e1549 100644
--- a/src/afs/HPUX/osi_prototypes.h
+++ b/src/afs/HPUX/osi_prototypes.h
@@ -6,7 +6,4 @@
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 #endif /* _OSI_PROTO_H_ */
diff --git a/src/afs/HPUX/osi_vcache.c b/src/afs/HPUX/osi_vcache.c
index cf669a29d..80c7db62e 100644
--- a/src/afs/HPUX/osi_vcache.c
+++ b/src/afs/HPUX/osi_vcache.c
@@ -14,7 +14,8 @@
 #include "afsincludes.h"        /*AFS-based standard headers */
 
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     int code;
 
     /* we can't control whether we sleep */
@@ -28,25 +29,35 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 }
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     return afs_osi_Alloc(sizeof(struct vcache));
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 
     avc->flushDV.low = avc->flushDV.high = AFS_MAXDV;
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) {
+osi_AttachVnode(struct vcache *avc, int seq)
+{
 }
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     AFSTOV(avc)->v_op = afs_ops;
     avc->v.v_vfsp = afs_globalVFS;
     vSetType(avc, VREG);
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/HPUX/osi_vfsops.c b/src/afs/HPUX/osi_vfsops.c
index ee3741c62..6383d5345 100644
--- a/src/afs/HPUX/osi_vfsops.c
+++ b/src/afs/HPUX/osi_vfsops.c
@@ -128,7 +128,7 @@ afs_root(struct vfs *afsp, struct vnode **avpp, char *unused1)
 
 	if (!(code = afs_InitReq(&treq, p_cred(u.u_procp)))
 	    && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 	    /* we really want this to stay around */
 	    if (tvp) {
 		afs_globalVp = tvp;
@@ -166,7 +166,7 @@ afs_statfs(struct vfs *afsp, struct k_statvfs *abp)
      */
     abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
 	abp->f_ffree = abp->f_favail = AFS_VFS_FAKEFREE;
-    abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
+    abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID;
 
     AFS_GUNLOCK();
     return 0;
diff --git a/src/afs/HPUX/osi_vnodeops.c b/src/afs/HPUX/osi_vnodeops.c
index bce2441da..b54bf1a25 100644
--- a/src/afs/HPUX/osi_vnodeops.c
+++ b/src/afs/HPUX/osi_vnodeops.c
@@ -882,60 +882,6 @@ afspgin_io(vfspage_t * vm_info, struct vnode *devvp, pgcnt_t bpages,
     space_t space = VM_SPACE(vm_info);
     int num_io = VM_GET_NUM_IO(vm_info);
 
-#ifdef notdef			/* Not used in AFS */
-    /*
-     * With VM_READ_AHEAD_ALLOWED() macro, check if read-ahead should
-     * be used in this case.
-     *
-     * Unlike UFS, NFS does not start the faulting page I/O
-     * asynchronously. Why?  Asynchronous requests are handled by the
-     * biod's.  It doesn't make sense to queue up the faulting request
-     * behind other asynchrnous requests.  This is not true for UFS
-     * where the asynchrnous request is immediately handled.
-     */
-
-    if ((VM_READ_AHEAD_ALLOWED(vm_info)) && (nfs_read_ahead_on)
-	&& (NFS_DO_READ_AHEAD) && (should_do_read_ahead(prp, vaddr))) {
-
-	pgcnt_t max_rhead_io;
-	caddr_t rhead_vaddr;
-	pgcnt_t total_rheads_allowed;
-
-	/*
-	 * Determine the maximum amount of read-ahead I/O.
-	 */
-	total_rheads_allowed = maxpagein - count;
-
-	/*
-	 * If the count is less than a block, raise it to one.
-	 */
-	if (total_rheads_allowed < bpages)
-	    total_rheads_allowed = bpages;
-
-	max_rhead_io = total_rheads_allowed;
-	rhead_vaddr = VM_MAPPED_ADDR(vm_info) + (count * NBPG);
-	error =
-	    nfs_read_ahead(vm_info->vp, prp, wrt, space, rhead_vaddr,
-			   &max_rhead_io);
-
-	/*
-	 * Set the next fault location.  If read_ahead launches any
-	 * I/O it will adjust it accordingly.
-	 */
-	vm_info->prp->p_nextfault = vm_info->startindex + count;
-
-	/*
-	 * Now perform the faulting I/O synchronously.
-	 */
-	vm_unlock(vm_info);
-
-	error =
-	    syncpageio((swblk_t) VM_GET_IO_STARTBLK(vm_info, 0),
-		       VM_MAPPED_SPACE(vm_info), VM_MAPPED_ADDR(vm_info),
-		       (int)ptob(count), B_READ, devvp,
-		       B_vfs_pagein | B_pagebf, VM_REGION(vm_info));
-    } else
-#endif
     {
 	virt_addr = VM_MAPPED_ADDR(vm_info);
 	vm_unlock(vm_info);
@@ -1199,22 +1145,6 @@ afs_pagein(vp, prp, wrt, space, vaddr, ret_startindex)
     if (retval == VM_PAGE_PRESENT)
 	return (count);
 
-#if 0
-    /*
-     * The definition of krusage_cntr_t is in h/kmetric.h, which
-     * is not shipped.  Since it's just statistics, we punt and do
-     * not update it.  If it's a problem we'll need to get HP to export
-     * an interface that we can use to increment the counter.
-     */
-
-    /* It's a real fault, not a reclaim */
-    {
-	krusage_cntr_t *temp;
-	temp = kt_cntrp(u.u_kthreadp);
-	temp->krc_majflt++;
-    }
-#endif
-
     /*
      * Tell VM where the I/O intends to start.  This may be different
      * from the faulting point.
@@ -1895,32 +1825,6 @@ afs_vm_checkpage(vp, args, pgindx, cur_data)
 	VM_SETFS_FLAGS(args, PAGEOUT_TRUNCATE);
 	return (1);
     }
-#ifdef notdef
-    if ((args->vm_flags & PAGEOUT_VHAND)
-	&& (!(args->vm_flags & PAGEOUT_RESERVED))
-	&& (!(VM_IS_ZOMBIE(args)))) {
-	VASSERT(args->run == 0);
-	if (vm_reserve_malloc_memory(NFS_PAGEOUT_MEM)) {
-	    /*
-	     * Got enough memory to pageout.  Mark the fact that we did
-	     * a sysprocmemreserve(), so that we can sysprocmemunreserve() it
-	     * later (in remote_pageout()).
-	     */
-	    args->vm_flags |= PAGEOUT_RESERVED;
-	} else {
-	    /*
-	     * We do not have enough memory to do this pageout.  By
-	     * definition, we do not yet have a run, so we just unlock
-	     * this page and tell foreach_valid() to continue scanning.
-	     * If we come across another dirty page, we will try to
-	     * reserve memory again.  That is okay, in fact some memory
-	     * may have freed up (as earlier pageouts complete under
-	     * interrupt).
-	     */
-	    return 1;
-	}
-    }
-#endif
     return (0);
 }
 
@@ -2042,12 +1946,6 @@ afs_ioctl(vp, com, data, flag, cred)
 
     /* The call must be a VICEIOCTL call */
     if (((com >> 8) & 0xff) == 'V') {
-#ifdef notdef
-	/* AFS_COPYIN returns error 14. Copy data in instead */
-	AFS_COPYIN(data, (caddr_t) & afsioctl, sizeof(afsioctl), error);
-	if (error)
-	    return (error);
-#endif
 	ai = (struct afs_ioctl *)data;
 	afsioctl.in = ai->in;
 	afsioctl.out = ai->out;
@@ -2512,10 +2410,6 @@ afsHashGarbageCollect()
 	}
 	hashUnlock(hashTable[index].lock);
     }
-#if 0
-    if (!foundFlag)
-	osi_Panic("afs: SEMA HashTable full\n");
-#endif
 }
 
 #endif /* AFS_SV_SEMA_HASH */
diff --git a/src/afs/IRIX/osi_file.c b/src/afs/IRIX/osi_file.c
index 92a366cc8..d2af37aff 100644
--- a/src/afs/IRIX/osi_file.c
+++ b/src/afs/IRIX/osi_file.c
@@ -17,7 +17,6 @@
 
 afs_ucred_t afs_osi_cred;
 int afs_osicred_initialized = 0;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
 
@@ -50,7 +49,6 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 	osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
-	/* valid for alpha_osf, SunOS, Ultrix */
 	memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
 	crhold(&afs_osi_cred);	/* don't let it evaporate, since it is static */
 	afs_osicred_initialized = 1;
@@ -71,7 +69,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
     tvattr.va_mask = AT_SIZE | AT_BLKSIZE | AT_MTIME | AT_ATIME;
     AFS_VOP_GETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred, code);
@@ -81,7 +78,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -114,13 +110,11 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
 	return code;
-    ObtainWriteLock(&afs_xosi, 321);
     AFS_GUNLOCK();
     tvattr.va_mask = AT_SIZE;
     tvattr.va_size = asize;
     AFS_VOP_SETATTR(afile->vnode, &tvattr, 0, &afs_osi_cred, code);
     AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -191,8 +185,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
 	afile->offset += code;
     } else {
 	if (code == ENOSPC)
-	    afs_warnuser
-		("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
+            afs_WarnENOSPC();
 	if (code > 0) {
 	    code = -code;
 	}
diff --git a/src/afs/IRIX/osi_machdep.h b/src/afs/IRIX/osi_machdep.h
index 0ee293759..56defecf9 100644
--- a/src/afs/IRIX/osi_machdep.h
+++ b/src/afs/IRIX/osi_machdep.h
@@ -36,8 +36,6 @@ typedef struct proc afs_proc_t;
 #undef gop_lookupname_user
 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),NULL,(compvpp), NULL)
 
-#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
-
 #ifdef AFS_SGI64_ENV
 #include <sys/flock.h>
 extern flid_t osi_flid;
@@ -389,5 +387,18 @@ extern long afs_global_owner;
 
 #define osi_procname(procname, size) strncpy(procname, proc_name(curproc()), size)
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+#ifdef _K64U64
+    struct __irix5_timeval now;
+    irix5_microtime(&now);
+#else
+    struct timeval now;
+    microtime(&now);
+#endif
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
 
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/IRIX/osi_prototypes.h b/src/afs/IRIX/osi_prototypes.h
index 53eed5049..c7a87969a 100644
--- a/src/afs/IRIX/osi_prototypes.h
+++ b/src/afs/IRIX/osi_prototypes.h
@@ -10,7 +10,4 @@
 #ifndef _OSI_PROTOTYPES_H_
 #define _OSI_PROTOTYPES_H_
 
-/* osi_file.c */
-extern afs_lock_t afs_xosi;
-
 #endif /* _OSI_PROTOTYPES_H_ */
diff --git a/src/afs/IRIX/osi_vcache.c b/src/afs/IRIX/osi_vcache.c
index e273aa517..522e8b5c7 100644
--- a/src/afs/IRIX/osi_vcache.c
+++ b/src/afs/IRIX/osi_vcache.c
@@ -14,7 +14,8 @@
 #include "afsincludes.h"        /*AFS-based standard headers */
 
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
      int code;
      /* we can't control whether we sleep */
      if (!VREFCOUNT_GT(avc,0)
@@ -29,7 +30,8 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 extern char *makesname();
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *avc;
     char name[METER_NAMSZ];
 
@@ -52,16 +54,20 @@ osi_NewVnode(void) {
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     avc->uncred = 0;
     memset(&(avc->f), 0, sizeof(struct fvcache));
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) { }
+osi_AttachVnode(struct vcache *avc, int seq)
+{
+}
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     memset(&(avc->vc_bhv_desc), 0, sizeof(avc->vc_bhv_desc));
     bhv_desc_init(&(avc->vc_bhv_desc), avc, avc, &Afs_vnodeops);
 
@@ -114,3 +120,9 @@ osi_PostPopulateVCache(struct vcache *avc) {
     avc->lastr = 0;
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/IRIX/osi_vfs.h b/src/afs/IRIX/osi_vfs.h
index d257b1a94..cd5cfbf8b 100644
--- a/src/afs/IRIX/osi_vfs.h
+++ b/src/afs/IRIX/osi_vfs.h
@@ -176,10 +176,6 @@ extern int afs_is_numa_arch;
 extern int afs_is_numa_arch;
 typedef struct bhv_head1 {
     struct bhv_desc *bh_first;	/* first behavior in chain */
-#ifdef notdef
-    /* This is not present in the non NUMA machines. */
-    mrlock_t bh_mrlock;		/* lock for ops-in-progress synch. */
-#endif
 } bhv_head1_t;
 
 typedef struct vnode1 {
diff --git a/src/afs/IRIX/osi_vfsops.c b/src/afs/IRIX/osi_vfsops.c
index a7e838745..ef800a3d3 100644
--- a/src/afs/IRIX/osi_vfsops.c
+++ b/src/afs/IRIX/osi_vfsops.c
@@ -274,7 +274,7 @@ afs_root(OSI_VFS_ARG(afsp), avpp)
 
 	if (!(code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED()))
 	    && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 	    /* we really want this to stay around */
 	    if (tvp) {
 		afs_globalVp = tvp;
@@ -541,7 +541,7 @@ afs_vget(OSI_VFS_DECL(afsp), vnode_t ** avcp, struct fid * fidp)
 	if (code = afs_InitReq(&treq, OSI_GET_CURRENT_CRED()))
 	    goto out;
 	*avcp =
-	    (vnode_t *) afs_GetVCache(&vfid, &treq, NULL, (struct vcache *)0);
+	    (vnode_t *) afs_GetVCache(&vfid, &treq);
 	if (!*avcp) {
 	    code = EIO;
 	}
diff --git a/src/afs/IRIX/osi_vnodeops.c b/src/afs/IRIX/osi_vnodeops.c
index 5efd81cc3..29aab4a27 100644
--- a/src/afs/IRIX/osi_vnodeops.c
+++ b/src/afs/IRIX/osi_vnodeops.c
@@ -1902,15 +1902,12 @@ struct vnodeops *afs_ops = &Afs_vnodeops;
 /* Initialized in osi_InitCacheFSType(). Used to determine inode type. */
 vnodeops_t *afs_xfs_vnodeopsp;
 
-extern afs_lock_t afs_xosi;	/* lock is for tvattr */
-
 ino_t
 VnodeToIno(vnode_t * vp)
 {
     int code;
     struct vattr vattr;
 
-    ObtainWriteLock(&afs_xosi, 579);
     vattr.va_mask = AT_FSID | AT_NODEID;	/* quick return using this mask. */
     AFS_GUNLOCK();
     AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
@@ -1918,7 +1915,6 @@ VnodeToIno(vnode_t * vp)
     if (code) {
 	osi_Panic("VnodeToIno");
     }
-    ReleaseWriteLock(&afs_xosi);
     return vattr.va_nodeid;
 }
 
@@ -1928,7 +1924,6 @@ VnodeToDev(vnode_t * vp)
     int code;
     struct vattr vattr;
 
-    ObtainWriteLock(&afs_xosi, 580);
     vattr.va_mask = AT_FSID | AT_NODEID;	/* quick return using this mask. */
     AFS_GUNLOCK();
     AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
@@ -1936,7 +1931,6 @@ VnodeToDev(vnode_t * vp)
     if (code) {
 	osi_Panic("VnodeToDev");
     }
-    ReleaseWriteLock(&afs_xosi);
     return (dev_t) vattr.va_fsid;
 }
 
@@ -1946,7 +1940,6 @@ VnodeToSize(vnode_t * vp)
     int code;
     struct vattr vattr;
 
-    ObtainWriteLock(&afs_xosi, 581);
     vattr.va_mask = AT_SIZE;
     AFS_GUNLOCK();
     AFS_VOP_GETATTR(vp, &vattr, 0, OSI_GET_CURRENT_CRED(), code);
@@ -1954,7 +1947,6 @@ VnodeToSize(vnode_t * vp)
     if (code) {
 	osi_Panic("VnodeToSize");
     }
-    ReleaseWriteLock(&afs_xosi);
     return vattr.va_size;
 }
 #endif /* AFS_SGI62_ENV */
diff --git a/src/afs/LINUX/osi_alloc.c b/src/afs/LINUX/osi_alloc.c
index 78cc6ab7c..f66fe02c4 100644
--- a/src/afs/LINUX/osi_alloc.c
+++ b/src/afs/LINUX/osi_alloc.c
@@ -305,8 +305,7 @@ osi_linux_free(void *addr)
 	afs_atomlist_put(al_mem_pool, lmp);	/* return osi_linux_mem struct to pool */
 	afs_linux_cur_allocs--;
     } else {
-	printf("osi_linux_free: failed to remove chunk from hashtable\n");
-	BUG();
+	osi_Panic("osi_linux_free: failed to remove chunk from hashtable\n");
     }
 
     mutex_unlock(&afs_linux_alloc_sem);
diff --git a/src/afs/LINUX/osi_compat.h b/src/afs/LINUX/osi_compat.h
index abe6b711b..a1e7f21fb 100644
--- a/src/afs/LINUX/osi_compat.h
+++ b/src/afs/LINUX/osi_compat.h
@@ -222,9 +222,15 @@ afs_linux_search_keyring(afs_ucred_t *cred, struct key_type *type)
     key_ref_t key_ref;
 
     if (afs_session_keyring(cred)) {
+#  if defined(KEYRING_SEARCH_TAKES_RECURSE)
+	key_ref = keyring_search(
+		      make_key_ref(afs_session_keyring(cred), 1),
+		      type, "_pag", 1);
+#  else
 	key_ref = keyring_search(
 		      make_key_ref(afs_session_keyring(cred), 1),
 		      type, "_pag");
+#  endif
 	if (IS_ERR(key_ref))
 	    return ERR_CAST(key_ref);
 
@@ -308,9 +314,22 @@ zero_user_segment(struct page *pp, unsigned int from1, unsigned int to1)
 }
 #endif
 
-#ifndef HAVE_LINUX_KERNEL_SETSOCKOPT
+#if defined(HAVE_LINUX_IP_SOCK_SET)
+# include <net/ip.h>
+/* ip_sock_set_* introduced in linux 5.8 */
+static inline void
+afs_linux_sock_set_mtu_discover(struct socket *sockp, int pmtu)
+{
+    ip_sock_set_mtu_discover(sockp->sk, pmtu);
+}
+static inline void
+afs_linux_sock_set_recverr(struct socket *sockp)
+{
+    ip_sock_set_recverr(sockp->sk);
+}
+#else
+# if !defined(HAVE_LINUX_KERNEL_SETSOCKOPT)
 /* Available from 2.6.19 */
-
 static inline int
 kernel_setsockopt(struct socket *sockp, int level, int name, char *val,
 		  unsigned int len) {
@@ -323,20 +342,22 @@ kernel_setsockopt(struct socket *sockp, int level, int name, char *val,
 
     return ret;
 }
+# endif /* !HAVE_LINUX_KERNEL_SETSOCKOPT */
 
-static inline int
-kernel_getsockopt(struct socket *sockp, int level, int name, char *val,
-		  int *len) {
-    mm_segment_t old_fs = get_fs();
-    int ret;
-
-    set_fs(get_ds());
-    ret = sockp->ops->getsockopt(sockp, level, name, val, len);
-    set_fs(old_fs);
-
-    return ret;
+static inline void
+afs_linux_sock_set_mtu_discover(struct socket *sockp, int pmtu)
+{
+    kernel_setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu,
+		      sizeof(pmtu));
 }
-#endif
+static inline void
+afs_linux_sock_set_recverr(struct socket *sockp)
+{
+    int recverr = 1;
+    kernel_setsockopt(sockp, SOL_IP, IP_RECVERR, (char *)&recverr,
+		      sizeof(recverr));
+}
+#endif /* !HAVE_LINUX_IP_SOCK_SET */
 
 #ifdef HAVE_TRY_TO_FREEZE
 static inline int
@@ -621,14 +642,18 @@ afs_truncate(struct inode *inode, int len)
 }
 
 static inline struct proc_dir_entry *
-afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct file_operations *fops) {
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct proc_ops *ops) {
+#else
+afs_proc_create(char *name, umode_t mode, struct proc_dir_entry *parent, struct file_operations *ops) {
+#endif
 #if defined(HAVE_LINUX_PROC_CREATE)
-    return proc_create(name, mode, parent, fops);
+    return proc_create(name, mode, parent, ops);
 #else
     struct proc_dir_entry *entry;
     entry = create_proc_entry(name, mode, parent);
     if (entry)
-	entry->proc_fops = fops;
+	entry->proc_fops = ops;
     return entry;
 #endif
 }
@@ -712,4 +737,15 @@ afs_file_write(struct file *filp, char __user *buf, size_t len, loff_t *pos)
 #endif
 }
 
+static inline char*
+afs_d_path(struct dentry *dp, struct vfsmount *mnt, char *buf, int buflen)
+{
+#ifdef D_PATH_TAKES_STRUCT_PATH
+    afs_linux_path_t p = { .mnt = mnt, .dentry = dp };
+    return d_path(&p, buf, buflen);
+#else
+    return d_path(dp, mnt, buf, buflen);
+#endif
+}
+
 #endif /* AFS_LINUX_OSI_COMPAT_H */
diff --git a/src/afs/LINUX/osi_export.c b/src/afs/LINUX/osi_export.c
index a3175b5d5..3a40eaec1 100644
--- a/src/afs/LINUX/osi_export.c
+++ b/src/afs/LINUX/osi_export.c
@@ -93,7 +93,7 @@ static int afs_encode_fh(struct dentry *de, __u32 *fh, int *max_len,
 		if (*max_len < 5) {
 		    return 255;
 		}
-		/* fall through */
+		AFS_FALLTHROUGH;
 
 	    case VN_TYPE_CELL:
 	    case VN_TYPE_ALIAS:
@@ -349,7 +349,7 @@ redo:
      */
     while ((adp->f.states & CStatd)
 	   && (tdc->dflags & DFFetching)
-	   && hsame(adp->f.m.DataVersion, tdc->f.versionNo)) {
+	   && afs_IsDCacheFresh(tdc, adp)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseSharedLock(&adp->lock);
 	afs_osi_Sleep(&tdc->validPos);
@@ -357,7 +357,7 @@ redo:
 	ObtainReadLock(&tdc->lock);
     }
     if (!(adp->f.states & CStatd)
-	|| !hsame(adp->f.m.DataVersion, tdc->f.versionNo)) {
+	|| !afs_IsDCacheFresh(tdc, adp)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseSharedLock(&adp->lock);
 	afs_PutDCache(tdc);
@@ -424,7 +424,7 @@ static int UnEvalFakeStat(struct vrequest *areq, struct vcache **vcpp)
     tfid = tvp->mtpoint;
     afs_PutVolume(tvp, READ_LOCK);
 
-    tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+    tvc = afs_GetVCache(&tfid, areq);
     if (!tvc) {
 #ifdef OSI_EXPORT_DEBUG
 	printk("afs: UnEvalFakeStat(0x%08x/%d/%d.%d): GetVCache(0x%08x/%d/%d.%d) failed\n",
@@ -486,7 +486,7 @@ static struct dentry *get_dentry_from_fid(cred_t *credp, struct VenusFid *afid)
 	afs_DestroyAttr(vattr);
 	return ERR_PTR(-afs_CheckCode(code, NULL, 101));
     }
-    vcp = afs_GetVCache(afid, treq, NULL, NULL);
+    vcp = afs_GetVCache(afid, treq);
     if (vcp == NULL) {
 #ifdef OSI_EXPORT_DEBUG
 	printk("afs: get_dentry_from_fid(0x%08x/%d/%d.%d): no vcache\n",
@@ -689,7 +689,7 @@ static int afs_export_get_name(struct dentry *parent, char *name,
 	       data.fid.Cell,      data.fid.Fid.Volume,
 	       data.fid.Fid.Vnode, data.fid.Fid.Unique);
 #endif
-	vcp = afs_GetVCache(&data.fid, treq, NULL, NULL);
+	vcp = afs_GetVCache(&data.fid, treq);
 	if (vcp) {
 	    ObtainReadLock(&vcp->lock);
 	    if (strlen(vcp->linkData + 1) <= NAME_MAX)
@@ -770,7 +770,7 @@ redo:
      */
     while ((vcp->f.states & CStatd)
 	   && (tdc->dflags & DFFetching)
-	   && hsame(vcp->f.m.DataVersion, tdc->f.versionNo)) {
+	   && afs_IsDCacheFresh(tdc, vcp)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseReadLock(&vcp->lock);
 	afs_osi_Sleep(&tdc->validPos);
@@ -778,7 +778,7 @@ redo:
 	ObtainReadLock(&tdc->lock);
     }
     if (!(vcp->f.states & CStatd)
-	|| !hsame(vcp->f.m.DataVersion, tdc->f.versionNo)) {
+	|| !afs_IsDCacheFresh(tdc, vcp)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseReadLock(&vcp->lock);
 	afs_PutDCache(tdc);
diff --git a/src/afs/LINUX/osi_fetchstore.c b/src/afs/LINUX/osi_fetchstore.c
deleted file mode 100644
index 997c1aa2e..000000000
--- a/src/afs/LINUX/osi_fetchstore.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2009 Simon Wilkinson. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/* Linux specific store operations
- *
- * The idea of these operations is to reduce the number of copies
- * that data incurs when passing from the disk cache through to the
- * RX layer, and vice versa.
- *
- * In kernels which support it, we use the splice() operation - in
- * older kernels, the filesystem's sendpage() operation is used directly.
- * Either way, this means that we can get direct access to the page contents,
- * rather than getting a copy.
- */
-
-#include <afsconfig.h>
-#include "afs/param.h"
-
-#include <linux/fs.h>
-#if 0 && defined(HAVE_LINUX_SPLICE_DIRECT_TO_ACTOR)
-# include <linux/splice.h>
-#else
-# include <linux/pipe_fs_i.h>
-#endif
-
-#include "afs/sysincludes.h"
-#include "afsincludes.h"
-
-#if 0 && defined(HAVE_LINUX_SPLICE_DIRECT_TO_ACTOR)
-static int
-afs_linux_splice_actor(struct pipe_inode_info *pipe,
-		       struct pipe_buffer *buf,
-		       struct splice_desc *sd)
-{
-    struct rxfs_storeVariables *svar = sd->u.data;
-    size_t size;
-    int code;
-
-    code = buf->ops->confirm(pipe, buf);
-    if (code)
-	return code;
-
-    size = sd->len;
-
-    /* Eventually, this could be rx_WritePage */
-    code = rx_Write(svar->call, kmap(buf->page), size);
-
-    if (code != size)
-	size = -33; /* Can't get a proper rx error out from here */
-
-    kunmap(buf->page);
-
-    return size;
-}
-
-static int
-afs_linux_ds_actor(struct pipe_inode_info *pipe, struct splice_desc *sd)
-{
-    return __splice_from_pipe(pipe, sd, afs_linux_splice_actor);
-}
-
-/* This is a store proc which uses splice to reduce the number
- * of page copies. */
-afs_int32
-afs_linux_storeproc(struct storeOps *ops, void *rock, struct dcache *tdc,
-		    int *shouldwake, afs_size_t *bytesXferred)
-{
-    struct rxfs_storeVariables *svar = rock;
-    struct file *cacheFp;
-    struct splice_desc sd = {
-	.len	= 0,
-	.total_len = tdc->f.chunkBytes,
-	.pos	= 0,
-	.u.data = rock
-    };
-    int code;
-
-    /* Open the file, splice its contents */
-    AFS_GUNLOCK();
-    cacheFp = afs_linux_raw_open(&tdc->f.inode);
-    code = splice_direct_to_actor(cacheFp, &sd, afs_linux_ds_actor);
-    filp_close(cacheFp, NULL);
-    AFS_GLOCK();
-
-    /* If we're being called from a backing request, then wake up that
-     * request once the file server says its happy. Potentially, we should
-     * do this each time we rx_Write, but that would mean acquiring the
-     * GLOCK in the middle of our actor */
-    if (shouldwake && *shouldwake && ((*ops->status)(rock) == 0)) {
-	*shouldwake = 0;
-	afs_wakeup(svar->vcache);
-    }
-
-    if (code > 0) {
-	*bytesXferred+=code;
-        return 0;
-    }
-
-    return code;
-}
-
-# else
-
-static int
-afs_linux_read_actor(read_descriptor_t *desc, struct page *page,
-		     unsigned long offset, unsigned long size)
-{
-#ifdef READ_DESCRIPTOR_T_HAS_BUF
-    struct rxfs_storeVariables *svar = (void *) desc->buf;
-#else
-    struct rxfs_storeVariables *svar = desc->arg.data;
-#endif
-    unsigned long count = desc->count;
-    int code;
-
-    if (size > count)
-	size = count;
-
-    /* Eventually, this could be rx_WritePage */
-    code = rx_Write(svar->call, kmap(page) + offset, size);
-    kunmap(page);
-
-    if (code != size) {
-        return -33; /* Can't get a proper rx error out from here */
-    }
-
-    desc->count = count - size;
-    desc->written += size;
-
-    return size;
-}
-
-#if 0
-afs_int32
-afs_linux_storeproc(struct storeOps *ops, void *rock, struct dcache *tdc,
-                    int *shouldwake, afs_size_t *bytesXferred)
-{
-    struct rxfs_storeVariables *svar = rock;
-    struct file *cacheFp;
-    int code;
-    loff_t offset = 0;
-
-    /* Open the file, splice its contents */
-    AFS_GUNLOCK();
-    cacheFp = afs_linux_raw_open(&tdc->f.inode);
-    code = cacheFp->f_op->sendfile(cacheFp, &offset, tdc->f.chunkBytes,
-				   afs_linux_read_actor, rock);
-    filp_close(cacheFp, NULL);
-    AFS_GLOCK();
-
-    /* If we're being called from a backing request, then wake up that
-     * request once the file server says its happy. Potentially, we should
-     * do this each time we rx_Write, but that would mean acquiring the
-     * GLOCK in the middle of our actor */
-    if (shouldwake && *shouldwake && ((*ops->status)(rock) == 0)) {
-	*shouldwake = 0;
-	afs_wakeup(svar->vcache);
-    }
-
-    if (code > 0) {
-	*bytesXferred+=code;
-        return 0;
-    }
-
-    return code;
-}
-#endif
-
-#endif
diff --git a/src/afs/LINUX/osi_file.c b/src/afs/LINUX/osi_file.c
index 0374c1cce..42d49ef37 100644
--- a/src/afs/LINUX/osi_file.c
+++ b/src/afs/LINUX/osi_file.c
@@ -23,13 +23,22 @@
 #include "osi_compat.h"
 
 #ifndef CURRENT_TIME
-#define CURRENT_TIME		(current_kernel_time())
+# if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
+#   define AFS_CURRENT_TIME(x) (ktime_get_coarse_real_ts64((x)))
+# else
+#  ifdef IATTR_TAKES_64BIT_TIME
+#    define AFS_CURRENT_TIME(x) do {*(x) = current_kernel_time64();} while (0)
+#  else
+#    define AFS_CURRENT_TIME(x) do {*(x) = current_kernel_time();} while (0)
+#  endif
+# endif
+#else
+# define AFS_CURRENT_TIME(x) do {*(x) = CURRENT_TIME;} while(0)
 #endif
 
 int cache_fh_type = -1;
 int cache_fh_len = -1;
 
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfsmount *afs_cacheMnt;
 extern struct super_block *afs_cacheSBp;
@@ -50,14 +59,24 @@ afs_linux_raw_open(afs_dcache_id_t *ainode)
     struct inode *tip = NULL;
     struct dentry *dp = NULL;
     struct file* filp;
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    const struct cred *cur_cred;
+#endif
 
     dp = afs_get_dentry_from_fh(afs_cacheSBp, ainode, cache_fh_len, cache_fh_type,
 		afs_fh_acceptable);
-    if ((!dp) || IS_ERR(dp))
-           osi_Panic("Can't get dentry\n");
+    if ((!dp) || IS_ERR(dp)) {
+	   afs_warn("afs: Cannot get dentry for cache file (code %d). Trying to continue, "
+		    "but AFS accesses may return errors or panic the system\n",
+		    (int) PTR_ERR(dp));
+	   return NULL;
+    }
     tip = dp->d_inode;
     tip->i_flags |= S_NOATIME;	/* Disable updating access times. */
 
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    cur_cred = override_creds(cache_creds);
+#endif
 #if defined(STRUCT_TASK_STRUCT_HAS_CRED)
     /* Use stashed credentials - prevent selinux/apparmor problems  */
     filp = afs_dentry_open(dp, afs_cacheMnt, O_RDWR, cache_creds);
@@ -66,8 +85,15 @@ afs_linux_raw_open(afs_dcache_id_t *ainode)
 #else
     filp = dentry_open(dget(dp), mntget(afs_cacheMnt), O_RDWR);
 #endif
-    if (IS_ERR(filp))
-	osi_Panic("Can't open file: %d\n", (int) PTR_ERR(filp));
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    revert_creds(cur_cred);
+#endif
+    if (IS_ERR(filp)) {
+	afs_warn("afs: Cannot open cache file (code %d). Trying to continue, "
+                 "but AFS accesses may return errors or panic the system\n",
+                 (int) PTR_ERR(filp));
+        filp = NULL;
+    }
 
     dput(dp);
 
@@ -85,7 +111,6 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
 	osi_Panic("UFSOpen called for non-UFS cache\n");
     }
     if (!afs_osicred_initialized) {
-	/* valid for alpha_osf, SunOS, Ultrix */
 	memset(&afs_osi_cred, 0, sizeof(afs_ucred_t));
 	crhold(&afs_osi_cred);	/* don't let it evaporate, since it is static */
 	afs_osicred_initialized = 1;
@@ -93,14 +118,25 @@ osi_UFSOpen(afs_dcache_id_t *ainode)
     AFS_GUNLOCK();
     afile = kmalloc(sizeof(struct osi_file), GFP_NOFS);
     if (!afile) {
-	osi_Panic("osi_UFSOpen: Failed to allocate %d bytes for osi_file.\n",
-		  (int)sizeof(struct osi_file));
+	afs_warn("afs: Failed to allocate memory for opening a cache file. "
+		 "Trying to continue, but AFS access may return errors or panic "
+		 "the system\n");
+	AFS_GLOCK();
+	return NULL;
     }
     memset(afile, 0, sizeof(struct osi_file));
 
     afile->filp = afs_linux_raw_open(ainode);
-    afile->size = i_size_read(FILE_INODE(afile->filp));
+    if (afile->filp) {
+        afile->size = i_size_read(FILE_INODE(afile->filp));
+    }
     AFS_GLOCK();
+
+    if (!afile->filp) {
+        osi_FreeLargeSpace(afile);
+        return NULL;
+    }
+
     afile->offset = 0;
     afile->proc = (int (*)())0;
     return (void *)afile;
@@ -138,22 +174,30 @@ int
 afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 {
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     astat->size = i_size_read(OSIFILE_INODE(afile));
     astat->mtime = OSIFILE_INODE(afile)->i_mtime.tv_sec;
     astat->atime = OSIFILE_INODE(afile)->i_atime.tv_sec;
 
-    ReleaseWriteLock(&afs_xosi);
     return 0;
 }
 
 int
 osi_UFSClose(struct osi_file *afile)
 {
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    const struct cred *cur_cred;
+#endif
+
     AFS_STATCNT(osi_Close);
     if (afile) {
 	if (OSIFILE_INODE(afile)) {
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+	    cur_cred = override_creds(cache_creds);
+#endif
 	    filp_close(afile->filp, NULL);
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+	    revert_creds(cur_cred);
+#endif
 	}
     }
     kfree(afile);
@@ -167,16 +211,21 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     struct osi_stat tstat;
     struct iattr newattrs;
     struct inode *inode = OSIFILE_INODE(afile);
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    const struct cred *cur_cred;
+#endif
     AFS_STATCNT(osi_Truncate);
 
     /* This routine only shrinks files, and most systems
      * have very slow truncates, even when the file is already
      * small enough.  Check now and save some time.
      */
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    cur_cred = override_creds(cache_creds);
+#endif
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
-	return code;
-    ObtainWriteLock(&afs_xosi, 321);
+	goto done;
     AFS_GUNLOCK();
     afs_linux_lock_inode(inode);
 #ifdef STRUCT_INODE_HAS_I_ALLOC_SEM
@@ -184,7 +233,7 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
 #endif
     newattrs.ia_size = asize;
     newattrs.ia_valid = ATTR_SIZE | ATTR_CTIME;
-    newattrs.ia_ctime = CURRENT_TIME;
+    AFS_CURRENT_TIME(&newattrs.ia_ctime);
 
     /* avoid notify_change() since it wants to update dentry->d_parent */
 #ifdef HAVE_LINUX_SETATTR_PREPARE
@@ -202,7 +251,10 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
 #endif
     afs_linux_unlock_inode(inode);
     AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
+ done:
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    revert_creds(cur_cred);
+#endif
     return code;
 }
 
@@ -283,8 +335,7 @@ afs_osi_Write(struct osi_file *afile, afs_int32 offset, void *aptr,
 	afile->offset += code;
     } else {
 	if (code == ENOSPC)
-	    afs_warnuser
-		("\n\n\n*** Cache partition is FULL - Decrease cachesize!!! ***\n\n");
+            afs_WarnENOSPC();
 	if (code > 0) {
 	    code = -code;
 	}
@@ -364,6 +415,9 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw)
     size_t count;
     unsigned long savelim;
     loff_t pos;
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    const struct cred *cur_cred = override_creds(cache_creds);
+#endif
 
     savelim = current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur;
     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
@@ -419,6 +473,9 @@ osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw)
 #endif /* AFS_FILE_NEEDS_SET_FS */
 
     current->TASK_STRUCT_RLIM[RLIMIT_FSIZE].rlim_cur = savelim;
+#if defined(HAVE_LINUX_OVERRIDE_CREDS)
+    revert_creds(cur_cred);
+#endif
 
     return code;
 }
diff --git a/src/afs/LINUX/osi_ioctl.c b/src/afs/LINUX/osi_ioctl.c
index 82e907bf6..9ba076a1b 100644
--- a/src/afs/LINUX/osi_ioctl.c
+++ b/src/afs/LINUX/osi_ioctl.c
@@ -25,10 +25,6 @@
 #include <asm/ia32_unistd.h>
 #endif
 
-#if defined(AFS_SPARC64_LINUX26_ENV) && defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
-#include <linux/ioctl32.h>
-#endif
-
 #include <linux/slab.h>
 #include <linux/init.h>
 #include <linux/sched.h>
@@ -37,9 +33,6 @@
 #include "osi_compat.h"
 
 extern struct proc_dir_entry *openafs_procfs;
-#if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
-static int ioctl32_done;
-#endif
 
 extern asmlinkage long
 afs_syscall(long syscall, long parm1, long parm2, long parm3, long parm4);
@@ -85,47 +78,40 @@ afs_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
     }
 }
 
-#if defined(HAVE_UNLOCKED_IOCTL) || defined(HAVE_COMPAT_IOCTL)
 static long afs_unlocked_ioctl(struct file *file, unsigned int cmd,
                                unsigned long arg) {
     return afs_ioctl(FILE_INODE(file), file, cmd, arg);
 }
-#endif
 
-static struct file_operations afs_syscall_fops = {
-#ifdef HAVE_UNLOCKED_IOCTL
-    .unlocked_ioctl = afs_unlocked_ioctl,
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+static struct proc_ops afs_syscall_ops = {
+    .proc_ioctl = afs_unlocked_ioctl,
+# ifdef STRUCT_PROC_OPS_HAS_PROC_COMPAT_IOCTL
+    .proc_compat_ioctl = afs_unlocked_ioctl,
+# endif
+};
 #else
-    .ioctl = afs_ioctl,
-#endif
-#ifdef HAVE_COMPAT_IOCTL
+static struct file_operations afs_syscall_ops = {
+    .unlocked_ioctl = afs_unlocked_ioctl,
     .compat_ioctl = afs_unlocked_ioctl,
-#endif
 };
+#endif /* HAVE_LINUX_STRUCT_PROC_OPS */
 
 void
 osi_ioctl_init(void)
 {
     struct proc_dir_entry *entry;
 
-    entry = afs_proc_create(PROC_SYSCALL_NAME, 0666, openafs_procfs, &afs_syscall_fops);
+    entry = afs_proc_create(PROC_SYSCALL_NAME, 0666, openafs_procfs, &afs_syscall_ops);
 #if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
     if (entry)
 	entry->owner = THIS_MODULE;
 #endif
 
-#if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
-    if (register_ioctl32_conversion(VIOC_SYSCALL32, NULL) == 0) 
-	ioctl32_done = 1;
-#endif
 }
 
 void
 osi_ioctl_clean(void)
 {
     remove_proc_entry(PROC_SYSCALL_NAME, openafs_procfs);
-#if defined(NEED_IOCTL32) && !defined(HAVE_COMPAT_IOCTL)
-    if (ioctl32_done)
-	    unregister_ioctl32_conversion(VIOC_SYSCALL32);
-#endif
 }
diff --git a/src/afs/LINUX/osi_machdep.h b/src/afs/LINUX/osi_machdep.h
index ce8cabf6e..4053ac751 100644
--- a/src/afs/LINUX/osi_machdep.h
+++ b/src/afs/LINUX/osi_machdep.h
@@ -75,7 +75,18 @@
 #if defined(HAVE_LINUX_CRED_H)
 #include "h/cred.h"
 #endif
-#if defined(HAVE_LINUX_CURRENT_KERNEL_TIME)
+
+#if !defined(HAVE_LINUX_TIME_T)
+typedef time64_t time_t;
+#endif
+
+#if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
+static inline time_t osi_Time(void) {
+    struct timespec64 xtime;
+    ktime_get_coarse_real_ts64(&xtime);
+    return xtime.tv_sec;
+}
+#elif defined(HAVE_LINUX_CURRENT_KERNEL_TIME)
 static inline time_t osi_Time(void) {
     struct timespec xtime;
     xtime = current_kernel_time();
@@ -85,18 +96,24 @@ static inline time_t osi_Time(void) {
 # define osi_Time() (xtime.tv_sec)
 #endif
 
-
-
-#ifdef AFS_LINUX_64BIT_KERNEL
-# define osi_GetTime(V)                                 \
-    do {                                               \
-       struct timeval __afs_tv;                              \
-       do_gettimeofday(&__afs_tv);                           \
-       (V)->tv_sec = (afs_int32)__afs_tv.tv_sec;             \
-       (V)->tv_usec = (afs_int32)__afs_tv.tv_usec;           \
-    } while (0)
+#if defined(HAVE_LINUX_KTIME_GET_REAL_TS64)
+static inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timespec64 now;
+    ktime_get_real_ts64(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_nsec / 1000;
+}
 #else
-# define osi_GetTime(V) do_gettimeofday((V))
+static inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    do_gettimeofday(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
 #endif
 
 #undef gop_lookupname
@@ -105,7 +122,6 @@ static inline time_t osi_Time(void) {
 #undef gop_lookupname_user
 #define gop_lookupname_user osi_lookupname
 
-#define osi_vnhold(V, N) do { VN_HOLD(AFSTOV(V)); } while (0)
 #define VN_HOLD(V) osi_Assert(igrab((V)) == (V))
 #define VN_RELE(V) iput((V))
 
diff --git a/src/afs/LINUX/osi_misc.c b/src/afs/LINUX/osi_misc.c
index 077d4edfb..aa5d5fc93 100644
--- a/src/afs/LINUX/osi_misc.c
+++ b/src/afs/LINUX/osi_misc.c
@@ -28,18 +28,6 @@
 int afs_osicred_initialized = 0;
 afs_ucred_t afs_osi_cred;
 
-void
-afs_osi_SetTime(osi_timeval_t * tvp)
-{
-    struct timespec tv;
-    tv.tv_sec = tvp->tv_sec;
-    tv.tv_nsec = tvp->tv_usec * NSEC_PER_USEC;
-
-    AFS_STATCNT(osi_SetTime);
-
-    do_settimeofday(&tv);
-}
-
 void
 osi_linux_mask(void)
 {
@@ -49,6 +37,17 @@ osi_linux_mask(void)
     SIG_UNLOCK(current);
 }
 
+void
+osi_linux_unmaskrxk(void)
+{
+    extern struct task_struct *rxk_ListenerTask;
+    /* Note this unblocks signals on the rxk_Listener
+     * thread from a thread that is stopping rxk */
+    SIG_LOCK(rxk_ListenerTask);
+    sigdelset(&rxk_ListenerTask->blocked, SIGKILL);
+    SIG_UNLOCK(rxk_ListenerTask);
+}
+
 /* LOOKUP_POSITIVE is becoming the default */
 #ifndef LOOKUP_POSITIVE
 #define LOOKUP_POSITIVE 0
@@ -139,13 +138,7 @@ int osi_abspath(char *aname, char *buf, int buflen,
 	return -PTR_ERR(name);
     code = osi_lookupname_internal(name, followlink, &mnt, &dp);
     if (!code) {
-#if defined(D_PATH_TAKES_STRUCT_PATH)
-	afs_linux_path_t p = { .mnt = mnt, .dentry = dp };
-	path = d_path(&p, buf, buflen);
-#else
-	path = d_path(dp, mnt, buf, buflen);
-#endif
-
+	path = afs_d_path(dp, mnt, buf, buflen);
 	if (IS_ERR(path)) {
 	    code = -PTR_ERR(path);
 	} else {
diff --git a/src/afs/LINUX/osi_module.c b/src/afs/LINUX/osi_module.c
index d6172c1ad..47e32cf1b 100644
--- a/src/afs/LINUX/osi_module.c
+++ b/src/afs/LINUX/osi_module.c
@@ -50,13 +50,18 @@ int __init
 afs_init(void)
 {
     int err;
-    AFS_RWLOCK_INIT(&afs_xosi, "afs_xosi");
 
 #ifdef HAVE_LINUX_KUID_T
     afs_ns = afs_current_user_ns();
 #endif
 
     osi_Init();
+
+    /* Initialize CellLRU since it is used while traversing CellServDB proc
+     * entry */
+
+    QInit(&CellLRU);
+
 #if !defined(AFS_NONFSTRANS)
     osi_linux_nfssrv_init();
 #endif
diff --git a/src/afs/LINUX/osi_nfssrv.c b/src/afs/LINUX/osi_nfssrv.c
index 425ecd341..27f34448f 100644
--- a/src/afs/LINUX/osi_nfssrv.c
+++ b/src/afs/LINUX/osi_nfssrv.c
@@ -160,26 +160,6 @@ done:
 }
 
 
-#if 0
-/* This doesn't work, because they helpfully NULL out rqstp->authop
- * before calling us, so we have no way to tell what the original
- * auth flavor was.
- */
-static int
-svcauth_afs_release(struct svc_rqst *rqstp)
-{
-    struct nfs_server_thread *ns;
-
-    AFS_GLOCK();
-    ns = find_nfs_thread(0);
-    if (ns) ns->active = 0;
-    AFS_GUNLOCK();
-
-    return afs_orig_authtab[rqstp->rq_authop->flavour]->release(rqstp);
-}
-#endif
-
-
 int osi_linux_nfs_initreq(struct vrequest *av, afs_ucred_t *cr, int *code)
 {
     struct nfs_server_thread *ns;
diff --git a/src/afs/LINUX/osi_probe.c b/src/afs/LINUX/osi_probe.c
index 11a1be39d..aea4bc628 100644
--- a/src/afs/LINUX/osi_probe.c
+++ b/src/afs/LINUX/osi_probe.c
@@ -427,12 +427,6 @@ static int main_zapped_syscalls[] = {
     1132, 1136, 1135,
 #endif
 
-/* And the same deal for arm (not arm26), if we ever support that. */
-#if 0
-    /* create_module, query_module, get_kernel_sysms */
-    127, 167, 130,
-#endif
-
 /*
  * Alpha-Linux uses syscall number mappings chosen to be compatible
  * with OSF/1.  So, it doesn't have any of the traditional calls or
@@ -1179,14 +1173,14 @@ static void *try_harder(probectl *P, PROBETYPE *ptr, unsigned long datalen)
     if (probe_debug & 0x0001) {                                                              \
 	printk("<7>osi_probe: %s = 0x%016lx %s\n", P->symbol, (unsigned long)(x), (m)); \
     }                                                                                      \
-    if ((x) && ((int)(x)) != -ENOENT) {                                                    \
+    if ((x) && ((long)(x)) != -ENOENT) {                                                    \
 	*method = (m);                                                                     \
         final_answer = (void *)(x);                                                        \
     }                                                                                      \
 } while (0)
 #else
 #define check_result(x,m) do {  \
-    if ((x) && ((int)(x)) != -ENOENT) { \
+    if ((x) && ((long)(x)) != -ENOENT) { \
         *method = (m);          \
         return (void *)(x);     \
     }                           \
diff --git a/src/afs/LINUX/osi_proc.c b/src/afs/LINUX/osi_proc.c
index a1a572405..4ac51d3f4 100644
--- a/src/afs/LINUX/osi_proc.c
+++ b/src/afs/LINUX/osi_proc.c
@@ -124,12 +124,21 @@ afs_csdb_open(struct inode *inode, struct file *file)
     return seq_open(file, &afs_csdb_op);
 }
 
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+static struct proc_ops afs_csdb_operations = {
+    .proc_open    = afs_csdb_open,
+    .proc_read    = seq_read,
+    .proc_lseek  = seq_lseek,
+    .proc_release = seq_release,
+};
+#else
 static struct file_operations afs_csdb_operations = {
     .open    = afs_csdb_open,
     .read    = seq_read,
     .llseek  = seq_lseek,
     .release = seq_release,
 };
+#endif /* HAVE_LINUX_STRUCT_PROC_OPS */
 
 static void *
 uu_start(struct seq_file *m, loff_t *pos)
@@ -284,13 +293,21 @@ afs_unixuser_open(struct inode *inode, struct file *file)
     return seq_open(file, &afs_unixuser_seqop);
 }
 
-static struct file_operations afs_unixuser_fops = {
+#if defined(HAVE_LINUX_STRUCT_PROC_OPS)
+static struct proc_ops afs_unixuser_ops = {
+    .proc_open = afs_unixuser_open,
+    .proc_read = seq_read,
+    .proc_lseek = seq_lseek,
+    .proc_release = seq_release,
+};
+#else
+static struct file_operations afs_unixuser_ops = {
     .open    = afs_unixuser_open,
     .read    = seq_read,
     .llseek  = seq_lseek,
     .release = seq_release,
 };
-
+#endif /* HAVE_LINUX_STRUCT_PROC_OPS */
 
 #else /* HAVE_LINUX_SEQ_FILE_H */
 
@@ -381,7 +398,7 @@ osi_proc_init(void)
     openafs_procfs = proc_mkdir(path, NULL);
 #endif
 #ifdef HAVE_LINUX_SEQ_FILE_H
-    entry = afs_proc_create("unixusers", 0, openafs_procfs, &afs_unixuser_fops);
+    entry = afs_proc_create("unixusers", 0, openafs_procfs, &afs_unixuser_ops);
 # if defined(STRUCT_PROC_DIR_ENTRY_HAS_OWNER)
     if (entry)
 	entry->owner = THIS_MODULE;
diff --git a/src/afs/LINUX/osi_prototypes.h b/src/afs/LINUX/osi_prototypes.h
index 5002af1ca..130b5660e 100644
--- a/src/afs/LINUX/osi_prototypes.h
+++ b/src/afs/LINUX/osi_prototypes.h
@@ -35,7 +35,6 @@ extern void osi_linux_nfssrv_shutdown(void);
 extern afs_rwlock_t afs_xnfssrv;
 
 /* osi_file.c */
-extern afs_rwlock_t afs_xosi;
 extern int osi_InitCacheInfo(char *aname);
 extern int osi_rdwr(struct osi_file *osifile, struct uio *uiop, int rw);
 extern struct file *afs_linux_raw_open(afs_dcache_id_t *ainode);
@@ -45,7 +44,6 @@ extern void osi_ioctl_init(void);
 extern void osi_ioctl_clean(void);
 
 /* osi_misc.c */
-extern void afs_osi_SetTime(osi_timeval_t * tvp);
 extern int osi_lookupname_internal(char *aname, int followlink,
 				   struct vfsmount **mnt, struct dentry **dpp);
 extern int osi_lookupname(char *aname, uio_seg_t seg, int followlink,
diff --git a/src/afs/LINUX/osi_sleep.c b/src/afs/LINUX/osi_sleep.c
index 07bb7fed1..cdf22115f 100644
--- a/src/afs/LINUX/osi_sleep.c
+++ b/src/afs/LINUX/osi_sleep.c
@@ -140,7 +140,7 @@ int
 afs_osi_SleepSig(void *event)
 {
     struct afs_event *evp;
-    int seq, retval;
+    int seq;
     int code;
 
     evp = afs_getevent(event);
@@ -150,7 +150,6 @@ afs_osi_SleepSig(void *event)
     }
 
     seq = evp->seq;
-    retval = 0;
 
     AFS_GUNLOCK();
     code = wait_event_freezable(evp->cond, seq != evp->seq);
diff --git a/src/afs/LINUX/osi_sysctl.c b/src/afs/LINUX/osi_sysctl.c
index 5602c3d73..5980bdc01 100644
--- a/src/afs/LINUX/osi_sysctl.c
+++ b/src/afs/LINUX/osi_sysctl.c
@@ -18,6 +18,8 @@
 #include <linux/config.h>
 #endif
 
+#ifdef CONFIG_SYSCTL
+
 /* From afs_util.c */
 extern afs_int32 afs_md5inum;
 
@@ -31,206 +33,48 @@ extern afs_int32 afs_blocksUsed_2;
 extern afs_int32 afs_pct1;
 extern afs_int32 afs_pct2;
 
-#ifdef CONFIG_SYSCTL
+# ifdef STRUCT_CTL_TABLE_HAS_CTL_NAME
+#  ifdef CTL_UNNUMBERED
+#   define AFS_SYSCTL_NAME(num) .ctl_name = CTL_UNNUMBERED,
+#  else
+#   define AFS_SYSCTL_NAME(num) .ctl_name = num,
+#  endif
+# else
+#  define AFS_SYSCTL_NAME(num)
+# endif
+
+# define AFS_SYSCTL_INT2(num, perms, name, var) { \
+    AFS_SYSCTL_NAME(num) \
+    .procname		= name, \
+    .data		= &var, \
+    .maxlen		= sizeof(var), \
+    .mode		= perms, \
+    .proc_handler	= &proc_dointvec \
+}
+# define AFS_SYSCTL_INT(num, perms, var) \
+	AFS_SYSCTL_INT2(num, perms, #var, var)
+
 static struct ctl_table_header *afs_sysctl = NULL;
 
 static struct ctl_table afs_sysctl_table[] = {
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 1,
-#endif
-#endif
-	.procname	= "hm_retry_RO",
-	.data		= &hm_retry_RO,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 2,
-#endif
-#endif
-	.procname	= "hm_retry_RW",
-	.data		= &hm_retry_RW,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 3,
-#endif
-#endif
-	.procname	= "hm_retry_int",
-	.data		= &hm_retry_int,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 4,
-#endif
-#endif
-	.procname	= "GCPAGs",
-	.data		= &afs_gcpags,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 5,
-#endif
-#endif
-	.procname	= "rx_deadtime",
-	.data		= &afs_rx_deadtime,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 6,
-#endif
-#endif
-	.procname	= "bkVolPref",
-	.data		= &afs_bkvolpref,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 7,
-#endif
-#endif
-	.procname	= "afs_blocksUsed",
-	.data		= &afs_blocksUsed,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0444,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 8,
-#endif
-#endif
-	.procname	= "afs_blocksUsed_0",
-	.data		= &afs_blocksUsed_0,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 9,
-#endif
-#endif
-	.procname	= "afs_blocksUsed_1",
-	.data		= &afs_blocksUsed_1,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 10,
-#endif
-#endif
-	.procname	= "afs_blocksUsed_2",
-	.data		= &afs_blocksUsed_2,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 11,
-#endif
-#endif
-	.procname	= "afs_pct1",
-	.data		= &afs_pct1,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 12,
-#endif
-#endif
-	.procname	= "afs_pct2",
-	.data		= &afs_pct2,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler   = &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 13,
-#endif
-#endif
-	.procname	= "afs_cacheBlocks",
-	.data		= &afs_cacheBlocks,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
-    {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 14,
-#endif
-#endif
-	.procname	= "md5inum",
-	.data		= &afs_md5inum,
-	.maxlen		= sizeof(afs_int32),
-	.mode		= 0644,
-	.proc_handler	= &proc_dointvec
-    },
+    AFS_SYSCTL_INT(1, 0644, hm_retry_RO),
+    AFS_SYSCTL_INT(2, 0644, hm_retry_RW),
+    AFS_SYSCTL_INT(3, 0644, hm_retry_int),
+
+    AFS_SYSCTL_INT2(4, 0644, "GCPAGs",      afs_gcpags),
+    AFS_SYSCTL_INT2(5, 0644, "rx_deadtime", afs_rx_deadtime),
+    AFS_SYSCTL_INT2(6, 0644, "bkVolPref",   afs_bkvolpref),
+
+    AFS_SYSCTL_INT( 7, 0444, afs_blocksUsed),
+    AFS_SYSCTL_INT( 8, 0644, afs_blocksUsed_0),
+    AFS_SYSCTL_INT( 9, 0644, afs_blocksUsed_1),
+    AFS_SYSCTL_INT(10, 0644, afs_blocksUsed_2),
+
+    AFS_SYSCTL_INT( 11, 0644, afs_pct1),
+    AFS_SYSCTL_INT( 12, 0644, afs_pct2),
+    AFS_SYSCTL_INT( 13, 0644, afs_cacheBlocks),
+    AFS_SYSCTL_INT2(14, 0644, "md5inum", afs_md5inum),
+
     {
 	.procname	= 0
     }
@@ -238,13 +82,7 @@ static struct ctl_table afs_sysctl_table[] = {
 
 static struct ctl_table fs_sysctl_table[] = {
     {
-#if defined(STRUCT_CTL_TABLE_HAS_CTL_NAME)
-#if defined(CTL_UNNUMBERED)
-	.ctl_name	= CTL_UNNUMBERED,
-#else
-	.ctl_name	= 1,
-#endif
-#endif
+	AFS_SYSCTL_NAME(1)
 	.procname	= "afs",
 	.mode		= 0555,
 	.child		= afs_sysctl_table
@@ -257,11 +95,11 @@ static struct ctl_table fs_sysctl_table[] = {
 int
 osi_sysctl_init()
 {
-#if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
+# if defined(REGISTER_SYSCTL_TABLE_NOFLAG)
     afs_sysctl = register_sysctl_table(fs_sysctl_table);
-#else
+# else
     afs_sysctl = register_sysctl_table(fs_sysctl_table, 0);
-#endif
+# endif
     if (!afs_sysctl)
 	return -1;
 
diff --git a/src/afs/LINUX/osi_vcache.c b/src/afs/LINUX/osi_vcache.c
index 19840d1ad..e3be81a28 100644
--- a/src/afs/LINUX/osi_vcache.c
+++ b/src/afs/LINUX/osi_vcache.c
@@ -25,7 +25,7 @@ TryEvictDirDentries(struct inode *inode)
 
     afs_d_alias_lock(inode);
 
-restart:
+ restart:
 #if defined(D_ALIAS_IS_HLIST)
 # if defined(HLIST_ITERATOR_NO_NODE)
     hlist_for_each_entry(dentry, &inode->i_dentry, d_alias) {
@@ -88,7 +88,7 @@ restart:
     }
     afs_d_alias_unlock(inode);
 
-inuse:
+ inuse:
     return;
 }
 
@@ -103,8 +103,11 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
 	&& avc->opens == 0) {
 	struct inode *ip = AFSTOV(avc);
 
+	if (osi_vnhold(avc) != 0) {
+	    /* Can't grab a ref on avc; bail out. */
+	    return 0;
+	}
 	*slept = 1;
-	AFS_FAST_HOLD(avc);
 	ReleaseWriteLock(&afs_xvcache);
 	AFS_GUNLOCK();
 
@@ -205,7 +208,7 @@ osi_ResetRootVCache(afs_uint32 volid)
     credp = crref();
     if (afs_CreateReq(&treq, credp))
 	goto out;
-    vcp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
+    vcp = afs_GetVCache(&afs_rootFid, treq);
     if (!vcp)
 	goto out;
     afs_getattr(vcp, &vattr, credp);
@@ -232,7 +235,14 @@ osi_ResetRootVCache(afs_uint32 volid)
 
     AFS_RELE(root);
     afs_globalVp = vcp;
-out:
+ out:
     crfree(credp);
     afs_DestroyReq(treq);
 }
+
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/LINUX/osi_vfs.h b/src/afs/LINUX/osi_vfs.h
index f771dad38..b3006796e 100644
--- a/src/afs/LINUX/osi_vfs.h
+++ b/src/afs/LINUX/osi_vfs.h
@@ -70,9 +70,15 @@ typedef struct vattr {
     dev_t	va_rdev;
     ino_t	va_nodeid;	/* Inode number */
     nlink_t	va_nlink;	/* link count for file. */
-    struct timeval va_atime;
-    struct timeval va_mtime;
-    struct timeval va_ctime;
+#if defined(IATTR_TAKES_64BIT_TIME)
+    struct timespec64 va_atime;
+    struct timespec64 va_mtime;
+    struct timespec64 va_ctime;
+#else
+    struct timespec va_atime;
+    struct timespec va_mtime;
+    struct timespec va_ctime;
+#endif
 } vattr_t;
 
 #define VATTR_NULL(A) memset(A, 0, sizeof(struct vattr))
diff --git a/src/afs/LINUX/osi_vfsops.c b/src/afs/LINUX/osi_vfsops.c
index f87d137b3..b33db3a15 100644
--- a/src/afs/LINUX/osi_vfsops.c
+++ b/src/afs/LINUX/osi_vfsops.c
@@ -40,7 +40,7 @@ extern struct dentry_operations afs_dentry_operations;
 
 /* Forward declarations */
 static int afs_root(struct super_block *afsp);
-int afs_fill_super(struct super_block *sb, void *data, int silent);
+static int afs_fill_super(struct super_block *sb, void *data, int silent);
 
 
 /*
@@ -52,19 +52,22 @@ int afs_fill_super(struct super_block *sb, void *data, int silent);
 #if defined(STRUCT_FILE_SYSTEM_TYPE_HAS_MOUNT)
 static struct dentry *
 afs_mount(struct file_system_type *fs_type, int flags,
-           const char *dev_name, void *data) {
+	  const char *dev_name, void *data)
+{
     return mount_nodev(fs_type, flags, data, afs_fill_super);
 }
 #elif defined(GET_SB_HAS_STRUCT_VFSMOUNT)
 static int
 afs_get_sb(struct file_system_type *fs_type, int flags,
-	   const char *dev_name, void *data, struct vfsmount *mnt) {
+	   const char *dev_name, void *data, struct vfsmount *mnt)
+{
     return get_sb_nodev(fs_type, flags, data, afs_fill_super, mnt);
 }
 #else
 static struct super_block *
 afs_get_sb(struct file_system_type *fs_type, int flags,
-	   const char *dev_name, void *data) {
+	   const char *dev_name, void *data)
+{
     return get_sb_nodev(fs_type, flags, data, afs_fill_super);
 }
 #endif
@@ -83,7 +86,7 @@ struct file_system_type afs_fs_type = {
 
 struct backing_dev_info *afs_backing_dev_info;
 
-int
+static int
 afs_fill_super(struct super_block *sb, void *data, int silent)
 {
     int code = 0;
@@ -104,7 +107,11 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
    __module_get(THIS_MODULE);
 
     afs_globalVFS = sb;
+#if defined(SB_NOATIME)
+    sb->s_flags |= SB_NOATIME;
+#else
     sb->s_flags |= MS_NOATIME;
+#endif
     sb->s_blocksize = 1024;
     sb->s_blocksize_bits = 10;
     sb->s_magic = AFS_VFSMAGIC;
@@ -117,7 +124,9 @@ afs_fill_super(struct super_block *sb, void *data, int silent)
     code = super_setup_bdi(sb);
     if (code)
         goto out;
+# if defined(STRUCT_BACKING_DEV_INFO_HAS_NAME)
     sb->s_bdi->name = "openafs";
+# endif
     sb->s_bdi->ra_pages = 32;
 #else
     /* used for inodes backing_dev_info field, also */
@@ -195,7 +204,7 @@ afs_root(struct super_block *afsp)
 	}
 
 	if (!(code = afs_CreateReq(&treq, credp)) && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, treq);
 	    if (tvp) {
 		struct inode *ip = AFSTOV(tvp);
 		struct vattr *vattr = NULL;
@@ -366,7 +375,7 @@ afs_put_super(struct super_block *sbp)
  * statp is in user space, so we need to cobble together a statfs, then
  * copy it.
  */
-int
+static int
 #if defined(STATFS_TAKES_DENTRY)
 afs_statfs(struct dentry *dentry, struct kstatfs *statp)
 #else
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index 969a27b27..8d6946f8f 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -31,7 +31,11 @@
 #endif
 #include <linux/pagemap.h>
 #include <linux/writeback.h>
-#include <linux/pagevec.h>
+#if defined(HAVE_LINUX_LRU_CACHE_ADD_FILE)
+# include <linux/swap.h>
+#else
+# include <linux/pagevec.h>
+#endif
 #include <linux/aio.h>
 #include "afs/lock.h"
 #include "afs/afs_bypasscache.h"
@@ -39,10 +43,6 @@
 #include "osi_compat.h"
 #include "osi_pagecopy.h"
 
-#ifndef HAVE_LINUX_PAGEVEC_LRU_ADD_FILE
-#define __pagevec_lru_add_file __pagevec_lru_add
-#endif
-
 #ifndef MAX_ERRNO
 #define MAX_ERRNO 1000L
 #endif
@@ -69,6 +69,78 @@ extern struct backing_dev_info *afs_backing_dev_info;
 
 extern struct vcache *afs_globalVp;
 
+/* Handle interfacing with Linux's pagevec/lru facilities */
+
+#if defined(HAVE_LINUX_LRU_CACHE_ADD_FILE) || defined(HAVE_LINUX_LRU_CACHE_ADD)
+
+/*
+ * Linux's lru_cache_add_file provides a simplified LRU interface without
+ * needing a pagevec
+ */
+struct afs_lru_pages {
+    char unused;
+};
+
+static inline void
+afs_lru_cache_init(struct afs_lru_pages *alrupages)
+{
+    return;
+}
+
+static inline void
+afs_lru_cache_add(struct afs_lru_pages *alrupages, struct page *page)
+{
+# if defined(HAVE_LINUX_LRU_CACHE_ADD)
+    lru_cache_add(page);
+# elif defined(HAVE_LINUX_LRU_CACHE_ADD_FILE)
+    lru_cache_add_file(page);
+# else
+#  error need a kernel function to add a page to the kernel lru cache
+# endif
+}
+
+static inline void
+afs_lru_cache_finalize(struct afs_lru_pages *alrupages)
+{
+    return;
+}
+#else
+
+/* Linux's pagevec/lru interfaces require a pagevec */
+struct afs_lru_pages {
+    struct pagevec lrupv;
+};
+
+static inline void
+afs_lru_cache_init(struct afs_lru_pages *alrupages)
+{
+# if defined(PAGEVEC_INIT_COLD_ARG)
+    pagevec_init(&alrupages->lrupv, 0);
+# else
+    pagevec_init(&alrupages->lrupv);
+# endif
+}
+
+# ifndef HAVE_LINUX_PAGEVEC_LRU_ADD_FILE
+#  define __pagevec_lru_add_file __pagevec_lru_add
+# endif
+
+static inline void
+afs_lru_cache_add(struct afs_lru_pages *alrupages, struct page *page)
+{
+    get_page(page);
+    if (!pagevec_add(&alrupages->lrupv, page))
+	__pagevec_lru_add_file(&alrupages->lrupv);
+}
+
+static inline void
+afs_lru_cache_finalize(struct afs_lru_pages *alrupages)
+{
+    if (pagevec_count(&alrupages->lrupv))
+	__pagevec_lru_add_file(&alrupages->lrupv);
+}
+#endif /* !HAVE_LINUX_LRU_ADD_FILE */
+
 /* This function converts a positive error code from AFS into a negative
  * code suitable for passing into the Linux VFS layer. It checks that the
  * error code is within the permissable bounds for the ERR_PTR mechanism.
@@ -105,7 +177,7 @@ afs_linux_VerifyVCache(struct vcache *avc, cred_t **retcred) {
 
     code = afs_CreateReq(&treq, credp);
     if (code == 0) {
-        code = afs_VerifyVCache2(avc, treq);
+	code = afs_VerifyVCache(avc, treq);
 	afs_DestroyReq(treq);
     }
 
@@ -347,7 +419,7 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
 
     /* update the cache entry */
   tagain:
-    code = afs_convert_code(afs_VerifyVCache2(avc, treq));
+    code = afs_convert_code(afs_VerifyVCache(avc, treq));
     if (code)
 	goto out;
 
@@ -368,7 +440,7 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
      */
     while ((avc->f.states & CStatd)
 	   && (tdc->dflags & DFFetching)
-	   && hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+	   && afs_IsDCacheFresh(tdc, avc)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseWriteLock(&avc->lock);
 	afs_osi_Sleep(&tdc->validPos);
@@ -376,7 +448,7 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
 	ObtainReadLock(&tdc->lock);
     }
     if (!(avc->f.states & CStatd)
-	|| !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+	|| !afs_IsDCacheFresh(tdc, avc)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseWriteLock(&avc->lock);
 	afs_PutDCache(tdc);
@@ -401,11 +473,17 @@ afs_linux_readdir(struct file *fp, void *dirbuf, filldir_t filldir)
     offset = (int) fp->f_pos;
 #endif
     while (1) {
+        dirpos = 0;
 	code = BlobScan(tdc, offset, &dirpos);
-	if (code || !dirpos)
-	    break;
+        if (code == 0 && dirpos == 0) {
+            /* We've reached EOF of the dir blob, so we can stop looking for
+             * entries. */
+            break;
+        }
 
-	code = afs_dir_GetVerifiedBlob(tdc, dirpos, &entry);
+        if (code == 0) {
+            code = afs_dir_GetVerifiedBlob(tdc, dirpos, &entry);
+        }
 	if (code) {
 	    if (!(avc->f.states & CCorrupt)) {
 		struct cell *tc = afs_GetCellStale(avc->f.fid.Cell, READ_LOCK);
@@ -511,13 +589,11 @@ out1:
 extern int afs_xioctl(struct inode *ip, struct file *fp, unsigned int com,
 		      unsigned long arg);
 
-#if defined(HAVE_UNLOCKED_IOCTL) || defined(HAVE_COMPAT_IOCTL)
 static long afs_unlocked_xioctl(struct file *fp, unsigned int com,
                                unsigned long arg) {
     return afs_xioctl(FILE_INODE(fp), fp, com, arg);
 
 }
-#endif
 
 
 static int
@@ -527,9 +603,9 @@ afs_linux_mmap(struct file *fp, struct vm_area_struct *vmap)
     int code;
 
     AFS_GLOCK();
-    afs_Trace3(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp,
-	       ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_INT32,
-	       vmap->vm_end - vmap->vm_start);
+    afs_Trace4(afs_iclSetp, CM_TRACE_GMAP, ICL_TYPE_POINTER, vcp,
+	       ICL_TYPE_POINTER, vmap->vm_start, ICL_TYPE_LONG,
+	       vmap->vm_end - vmap->vm_start, ICL_TYPE_LONG, 0);
 
     /* get a validated vcache entry */
     code = afs_linux_VerifyVCache(vcp, NULL);
@@ -813,14 +889,8 @@ struct file_operations afs_dir_fops = {
 #else
   .readdir =	afs_linux_readdir,
 #endif
-#ifdef HAVE_UNLOCKED_IOCTL
   .unlocked_ioctl = afs_unlocked_xioctl,
-#else
-  .ioctl =	afs_xioctl,
-#endif
-#ifdef HAVE_COMPAT_IOCTL
   .compat_ioctl = afs_unlocked_xioctl,
-#endif
   .open =	afs_linux_open,
   .release =	afs_linux_release,
   .llseek =	default_llseek,
@@ -848,14 +918,8 @@ struct file_operations afs_file_fops = {
   .read =	afs_linux_read,
   .write =	afs_linux_write,
 #endif
-#ifdef HAVE_UNLOCKED_IOCTL
   .unlocked_ioctl = afs_unlocked_xioctl,
-#else
-  .ioctl =	afs_xioctl,
-#endif
-#ifdef HAVE_COMPAT_IOCTL
   .compat_ioctl = afs_unlocked_xioctl,
-#endif
   .mmap =	afs_linux_mmap,
   .open =	afs_linux_open,
   .flush =	afs_linux_flush,
@@ -1002,15 +1066,15 @@ iattr2vattr(struct vattr *vattrp, struct iattr *iattrp)
 	vattrp->va_size = iattrp->ia_size;
     if (iattrp->ia_valid & ATTR_ATIME) {
 	vattrp->va_atime.tv_sec = iattrp->ia_atime.tv_sec;
-	vattrp->va_atime.tv_usec = 0;
+	vattrp->va_atime.tv_nsec = 0;
     }
     if (iattrp->ia_valid & ATTR_MTIME) {
 	vattrp->va_mtime.tv_sec = iattrp->ia_mtime.tv_sec;
-	vattrp->va_mtime.tv_usec = 0;
+	vattrp->va_mtime.tv_nsec = 0;
     }
     if (iattrp->ia_valid & ATTR_CTIME) {
 	vattrp->va_ctime.tv_sec = iattrp->ia_ctime.tv_sec;
-	vattrp->va_ctime.tv_usec = 0;
+	vattrp->va_ctime.tv_nsec = 0;
     }
 }
 
@@ -1135,6 +1199,17 @@ parent_vcache_dv(struct inode *inode, cred_t *credp)
     return hgetlo(pvcp->f.m.DataVersion);
 }
 
+static inline int
+filter_enoent(int code)
+{
+#ifdef HAVE_LINUX_FATAL_SIGNAL_PENDING
+    if (code == ENOENT && fatal_signal_pending(current)) {
+        return EINTR;
+    }
+#endif
+    return code;
+}
+
 #ifndef D_SPLICE_ALIAS_RACE
 
 static inline void dentry_race_lock(void) {}
@@ -1272,20 +1347,6 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
 	    osi_Assert(vcp->mvid.parent != NULL);
 	}
 
-#ifdef notdef
-	/* If the last looker changes, we should make sure the current
-	 * looker still has permission to examine this file.  This would
-	 * always require a crref() which would be "slow".
-	 */
-	if (vcp->last_looker != treq.uid) {
-	    if (!afs_AccessOK(vcp, (vType(vcp) == VREG) ? PRSFS_READ : PRSFS_LOOKUP, &treq, CHECK_MODE_BITS)) {
-		goto bad_dentry;
-	    }
-
-	    vcp->last_looker = treq.uid;
-	}
-#endif
-
 	parent = dget_parent(dp);
 	pvcp = VTOAFS(parent->d_inode);
 	parent_dv = parent_vcache_dv(parent->d_inode, credp);
@@ -1304,6 +1365,7 @@ afs_linux_dentry_revalidate(struct dentry *dp, int flags)
 		credp = crref();
 	    }
 	    code = afs_lookup(pvcp, (char *)dp->d_name.name, &tvc, credp);
+            code = filter_enoent(code);
 
 	    if (code) {
 		/* We couldn't perform the lookup, so we're not okay. */
@@ -1435,12 +1497,20 @@ static void
 afs_dentry_iput(struct dentry *dp, struct inode *ip)
 {
     struct vcache *vcp = VTOAFS(ip);
+    int haveGlock = ISAFS_GLOCK();
+
+    if (!haveGlock) {
+        AFS_GLOCK();
+    }
 
-    AFS_GLOCK();
     if (!AFS_IS_DISCONNECTED || (vcp->f.states & CUnlinked)) {
 	(void) afs_InactiveVCache(vcp, NULL);
     }
-    AFS_GUNLOCK();
+
+    if (!haveGlock) {
+        AFS_GUNLOCK();
+    }
+
     afs_linux_clear_nfsfs_renamed(dp);
 
     iput(ip);
@@ -1595,6 +1665,7 @@ afs_linux_lookup(struct inode *dip, struct dentry *dp)
     AFS_GLOCK();
 
     code = afs_lookup(VTOAFS(dip), (char *)comp, &vcp, credp);
+    code = filter_enoent(code);
     if (code == ENOENT) {
         /* It's ok for the file to not be found. That's noted by the caller by
          * seeing that the dp->d_inode field is NULL (set by d_splice_alias or
@@ -2061,11 +2132,12 @@ afs_linux_put_link(struct dentry *dentry, struct nameidata *nd)
  * If task is NULL, the page copy occurs syncronously, and the routine
  * returns with page still locked. If task is non-NULL, then page copies
  * may occur in the background, and the page will be unlocked when it is
- * ready for use.
+ * ready for use. Note that if task is non-NULL and we encounter an error
+ * before we start the background copy, we MUST unlock 'page' before we return.
  */
 static int
 afs_linux_read_cache(struct file *cachefp, struct page *page,
-		     int chunk, struct pagevec *lrupv,
+		     int chunk, struct afs_lru_pages *alrupages,
 		     struct afs_pagecopy_task *task) {
     loff_t offset = page_offset(page);
     struct inode *cacheinode = cachefp->f_dentry->d_inode;
@@ -2107,11 +2179,7 @@ afs_linux_read_cache(struct file *cachefp, struct page *page,
 	    if (code == 0) {
 	        cachepage = newpage;
 	        newpage = NULL;
-
-	        get_page(cachepage);
-                if (!pagevec_add(lrupv, cachepage))
-                    __pagevec_lru_add_file(lrupv);
-
+		afs_lru_cache_add(alrupages, cachepage);
 	    } else {
 		put_page(newpage);
 		newpage = NULL;
@@ -2125,7 +2193,9 @@ afs_linux_read_cache(struct file *cachefp, struct page *page,
 
     if (!PageUptodate(cachepage)) {
 	ClearPageError(cachepage);
-        code = cachemapping->a_ops->readpage(NULL, cachepage);
+	/* Note that ->readpage always handles unlocking the given page, even
+	 * when an error is returned. */
+	code = cachemapping->a_ops->readpage(NULL, cachepage);
 	if (!code && !task) {
 	    wait_on_page_locked(cachepage);
 	}
@@ -2148,11 +2218,11 @@ afs_linux_read_cache(struct file *cachefp, struct page *page,
 	}
     }
 
+ out:
     if (code && task) {
         unlock_page(page);
     }
 
-out:
     if (cachepage)
 	put_page(cachepage);
 
@@ -2169,7 +2239,7 @@ afs_linux_readpage_fastpath(struct file *fp, struct page *pp, int *codep)
     struct file *cacheFp = NULL;
     int code;
     int dcLocked = 0;
-    struct pagevec lrupv;
+    struct afs_lru_pages lrupages;
 
     /* Not a UFS cache, don't do anything */
     if (cacheDiskType != AFS_FCACHE_TYPE_UFS)
@@ -2237,7 +2307,7 @@ afs_linux_readpage_fastpath(struct file *fp, struct page *pp, int *codep)
 	ObtainReadLock(&tdc->lock);
 
     /* Is the dcache we've been given currently up to date */
-    if (!hsame(avc->f.m.DataVersion, tdc->f.versionNo) ||
+    if (!afs_IsDCacheFresh(tdc, avc) ||
 	(tdc->dflags & DFFetching))
 	goto out;
 
@@ -2249,21 +2319,22 @@ afs_linux_readpage_fastpath(struct file *fp, struct page *pp, int *codep)
     /* XXX - I suspect we should be locking the inodes before we use them! */
     AFS_GUNLOCK();
     cacheFp = afs_linux_raw_open(&tdc->f.inode);
+    if (cacheFp == NULL) {
+	/* Problem getting the inode */
+	AFS_GLOCK();
+	goto out;
+    }
     if (!cacheFp->f_dentry->d_inode->i_mapping->a_ops->readpage) {
 	cachefs_noreadpage = 1;
 	AFS_GLOCK();
 	goto out;
     }
-#if defined(PAGEVEC_INIT_COLD_ARG)
-    pagevec_init(&lrupv, 0);
-#else
-    pagevec_init(&lrupv);
-#endif
 
-    code = afs_linux_read_cache(cacheFp, pp, tdc->f.chunk, &lrupv, NULL);
+    afs_lru_cache_init(&lrupages);
+
+    code = afs_linux_read_cache(cacheFp, pp, tdc->f.chunk, &lrupages, NULL);
 
-    if (pagevec_count(&lrupv))
-       __pagevec_lru_add_file(&lrupv);
+    afs_lru_cache_finalize(&lrupages);
 
     filp_close(cacheFp, NULL);
     AFS_GLOCK();
@@ -2276,6 +2347,9 @@ afs_linux_readpage_fastpath(struct file *fp, struct page *pp, int *codep)
     return 1;
 
 out:
+    if (cacheFp != NULL) {
+	filp_close(cacheFp, NULL);
+    }
     ReleaseWriteLock(&avc->lock);
     ReleaseReadLock(&tdc->lock);
     afs_PutDCache(tdc);
@@ -2393,7 +2467,7 @@ afs_linux_bypass_readpages(struct file *fp, struct address_space *mapping,
     struct iovec* iovecp;
     struct nocache_read_request *ancr;
     struct page *pp;
-    struct pagevec lrupv;
+    struct afs_lru_pages lrupages;
     afs_int32 code = 0;
 
     cred_t *credp;
@@ -2418,11 +2492,7 @@ afs_linux_bypass_readpages(struct file *fp, struct address_space *mapping,
     ancr->offset = auio->uio_offset;
     ancr->length = auio->uio_resid;
 
-#if defined(PAGEVEC_INIT_COLD_ARG)
-    pagevec_init(&lrupv, 0);
-#else
-    pagevec_init(&lrupv);
-#endif
+    afs_lru_cache_init(&lrupages);
 
     for(page_ix = 0; page_ix < num_pages; ++page_ix) {
 
@@ -2468,27 +2538,18 @@ afs_linux_bypass_readpages(struct file *fp, struct address_space *mapping,
 		lock_page(pp);
 	    }
 
-            /* increment page refcount--our original design assumed
-             * that locking it would effectively pin it;  protect
-             * ourselves from the possiblity that this assumption is
-             * is faulty, at low cost (provided we do not fail to
-             * do the corresponding decref on the other side) */
-            get_page(pp);
-
 	    /* save the page for background map */
             iovecp[page_ix].iov_base = (void*) pp;
 
 	    /* and put it on the LRU cache */
-	    if (!pagevec_add(&lrupv, pp))
-		__pagevec_lru_add_file(&lrupv);
+	    afs_lru_cache_add(&lrupages, pp);
         }
     }
 
     /* If there were useful pages in the page list, make sure all pages
      * are in the LRU cache, then schedule the read */
     if(page_count) {
-	if (pagevec_count(&lrupv))
-	    __pagevec_lru_add_file(&lrupv);
+	afs_lru_cache_finalize(&lrupages);
 	credp = crref();
         code = afs_ReadNoCache(avc, ancr, credp);
 	crfree(credp);
@@ -2563,6 +2624,7 @@ afs_linux_can_bypass(struct inode *ip) {
 	case LARGE_FILES_BYPASS_CACHE:
 	    if (i_size_read(ip) > cache_bypass_threshold)
 		return 1;
+	    AFS_FALLTHROUGH;
 	default:
 	    return 0;
      }
@@ -2618,7 +2680,7 @@ afs_linux_readpages(struct file *fp, struct address_space *mapping,
     int code;
     unsigned int page_idx;
     loff_t offset;
-    struct pagevec lrupv;
+    struct afs_lru_pages lrupages;
     struct afs_pagecopy_task *task;
 
     if (afs_linux_bypass_check(inode))
@@ -2643,11 +2705,9 @@ afs_linux_readpages(struct file *fp, struct address_space *mapping,
     task = afs_pagecopy_init_task();
 
     tdc = NULL;
-#if defined(PAGEVEC_INIT_COLD_ARG)
-    pagevec_init(&lrupv, 0);
-#else
-    pagevec_init(&lrupv);
-#endif
+
+    afs_lru_cache_init(&lrupages);
+
     for (page_idx = 0; page_idx < num_pages; page_idx++) {
 	struct page *page = list_entry(page_list->prev, struct page, lru);
 	list_del(&page->lru);
@@ -2659,15 +2719,17 @@ afs_linux_readpages(struct file *fp, struct address_space *mapping,
 	    afs_PutDCache(tdc);
 	    AFS_GUNLOCK();
 	    tdc = NULL;
-	    if (cacheFp)
+	    if (cacheFp) {
 		filp_close(cacheFp, NULL);
+		cacheFp = NULL;
+	    }
 	}
 
 	if (!tdc) {
 	    AFS_GLOCK();
 	    if ((tdc = afs_FindDCache(avc, offset))) {
 		ObtainReadLock(&tdc->lock);
-		if (!hsame(avc->f.m.DataVersion, tdc->f.versionNo) ||
+		if (!afs_IsDCacheFresh(tdc, avc) ||
 		    (tdc->dflags & DFFetching)) {
 		    ReleaseReadLock(&tdc->lock);
 		    afs_PutDCache(tdc);
@@ -2677,6 +2739,10 @@ afs_linux_readpages(struct file *fp, struct address_space *mapping,
 	    AFS_GUNLOCK();
 	    if (tdc) {
 		cacheFp = afs_linux_raw_open(&tdc->f.inode);
+		if (cacheFp == NULL) {
+		    /* Problem getting the inode */
+		    goto out;
+		}
 		if (!cacheFp->f_dentry->d_inode->i_mapping->a_ops->readpage) {
 		    cachefs_noreadpage = 1;
 		    goto out;
@@ -2686,19 +2752,18 @@ afs_linux_readpages(struct file *fp, struct address_space *mapping,
 
 	if (tdc && !add_to_page_cache(page, mapping, page->index,
 				      GFP_KERNEL)) {
-	    get_page(page);
-	    if (!pagevec_add(&lrupv, page))
-		__pagevec_lru_add_file(&lrupv);
+	    afs_lru_cache_add(&lrupages, page);
 
-	    afs_linux_read_cache(cacheFp, page, tdc->f.chunk, &lrupv, task);
+	    /* Note that add_to_page_cache() locked 'page'.
+	     * afs_linux_read_cache() is guaranteed to handle unlocking it. */
+	    afs_linux_read_cache(cacheFp, page, tdc->f.chunk, &lrupages, task);
 	}
 	put_page(page);
     }
-    if (pagevec_count(&lrupv))
-       __pagevec_lru_add_file(&lrupv);
+    afs_lru_cache_finalize(&lrupages);
 
 out:
-    if (tdc)
+    if (cacheFp)
 	filp_close(cacheFp, NULL);
 
     afs_pagecopy_put_task(task);
@@ -3080,6 +3145,10 @@ afs_linux_write_begin(struct file *file, struct address_space *mapping,
     int code;
 
     page = grab_cache_page_write_begin(mapping, index, flags);
+    if (!page) {
+        return -ENOMEM;
+    }
+
     *pagep = page;
 
     code = afs_linux_prepare_write(file, page, from, from + len);
diff --git a/src/afs/NBSD/osi_file.c b/src/afs/NBSD/osi_file.c
index dfacb695d..ead7d9961 100644
--- a/src/afs/NBSD/osi_file.c
+++ b/src/afs/NBSD/osi_file.c
@@ -16,7 +16,6 @@
 
 
 int afs_osicred_initialized;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct mount *afs_cacheVfsp;
 
@@ -60,7 +59,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     struct vattr tvattr;
 
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
 #ifdef AFS_NBSD50_ENV
 	code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp);
@@ -74,7 +72,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -108,7 +105,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     if (code || tstat.size <= asize)
 	return code;
 
-    ObtainWriteLock(&afs_xosi, 321);
     VATTR_NULL(&tvattr);
     tvattr.va_size = asize;
     AFS_GUNLOCK();
@@ -127,16 +123,12 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     AFS_GLOCK();
     if (code == 0)
 	afile->size = asize;
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
 void
 osi_DisableAtimes(struct vnode *avp)
 {
-#if 0
-    VTOI(avp)->i_flag &= ~IN_ACCESS;
-#endif
 }
 
 
diff --git a/src/afs/NBSD/osi_machdep.h b/src/afs/NBSD/osi_machdep.h
index d80ef3582..43aa62101 100644
--- a/src/afs/NBSD/osi_machdep.h
+++ b/src/afs/NBSD/osi_machdep.h
@@ -44,17 +44,12 @@ typedef char * caddr_t;
 #define osi_vfs_bsize	mnt_stat.f_bsize
 #define osi_vfs_iosize	mnt_stat.f_iosize
 #define osi_vfs_fsid	mnt_stat.f_fsid
-#if 0
-#define vfs_bsize	mnt_stat.f_bsize
-#define vfs_fsid	mnt_stat.f_fsid
-#endif
 #define vfs_vnodecovered mnt_vnodecovered
 #define v_vfsp		v_mount
 
 /* vnode */
 #define VN_HOLD(vp)	(vget(vp, 0))
 #define VN_RELE(vp)	(vrele(vp))
-#define osi_vnhold(avc, r) (VN_HOLD(AFSTOV(avc)))
 
 #define va_nodeid	va_fileid
 
@@ -101,7 +96,6 @@ typedef struct kauth_cred afs_ucred_t;
 
 /* time */
 #define	afs_hz		hz
-#define osi_GetTime(x)	getmicrotime(x)
 #define osi_Time()      time_second
 
 /* str */
@@ -212,4 +206,13 @@ extern int afs_debug;
 
 #define AFS_USE_NBSD_NAMECACHE 0
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    getmicrotime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/NBSD/osi_misc.c b/src/afs/NBSD/osi_misc.c
index d89f1116f..2f6f1c40a 100644
--- a/src/afs/NBSD/osi_misc.c
+++ b/src/afs/NBSD/osi_misc.c
@@ -62,7 +62,7 @@ such damages.
  * traditional BSD suser, see OBSD/osi_misc.c.
  */
 int
-afs_osi_suser(void *credp)
+afs_osi_suser(afs_ucred_t *credp)
 {
     int code;
 /*
@@ -100,21 +100,3 @@ afs_syscall_iincdec(int dev, int inode, int inode_p1, int amount)
 {
     return EINVAL;
 }
-
-/*
- * just calls kern_time.c:settime()
- */
-void
-afs_osi_SetTime(osi_timeval_t *atv)
-{
-#if 0
-    printf("afs attempted to set clock; use \"afsd -nosettime\"\n");
-#else
-    struct timespec ts;
-    AFS_GUNLOCK();
-    ts.tv_sec = atv->tv_sec;
-    ts.tv_nsec = atv->tv_usec * 1000;
-    settime(osi_curproc()->l_proc, &ts); /* really takes a process */
-    AFS_GLOCK();
-#endif
-}
diff --git a/src/afs/NBSD/osi_prototypes.h b/src/afs/NBSD/osi_prototypes.h
index 4bc45e9e8..6867e1549 100644
--- a/src/afs/NBSD/osi_prototypes.h
+++ b/src/afs/NBSD/osi_prototypes.h
@@ -6,7 +6,4 @@
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 #endif /* _OSI_PROTO_H_ */
diff --git a/src/afs/NBSD/osi_vcache.c b/src/afs/NBSD/osi_vcache.c
index 6ceefc9bc..2f99075b6 100644
--- a/src/afs/NBSD/osi_vcache.c
+++ b/src/afs/NBSD/osi_vcache.c
@@ -74,3 +74,9 @@ osi_PostPopulateVCache(struct vcache *avc)
     vSetType(avc, VREG);
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/NBSD/osi_vfsops.c b/src/afs/NBSD/osi_vfsops.c
index a52629b73..2b662c107 100644
--- a/src/afs/NBSD/osi_vfsops.c
+++ b/src/afs/NBSD/osi_vfsops.c
@@ -355,7 +355,7 @@ tryagain:
 
 	if (!(code = afs_InitReq(&treq, osi_curcred()))
 	    && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 
 	    if (tvp) {
 		if (afs_globalVp) {
diff --git a/src/afs/NBSD/osi_vnodeops.c b/src/afs/NBSD/osi_vnodeops.c
index b4899dcb8..2dc0a9b0c 100644
--- a/src/afs/NBSD/osi_vnodeops.c
+++ b/src/afs/NBSD/osi_vnodeops.c
@@ -194,9 +194,6 @@ const struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
     {&vop_islocked_desc, afs_nbsd_islocked},	/* islocked */
     {&vop_pathconf_desc, afs_nbsd_pathconf},	/* pathconf */
     {&vop_advlock_desc, afs_nbsd_advlock},	/* advlock */
-#if 0
-    {&vop_reallocblks_desc, afs_nbsd_reallocblks},	/* reallocblks */
-#endif
     {&vop_bwrite_desc, vn_bwrite},		/* bwrite */
     {&vop_getpages_desc, genfs_getpages},	/* getpages */
     {&vop_putpages_desc, genfs_putpages},	/* putpages */
@@ -377,13 +374,6 @@ afs_nbsd_lookup(void *v)
 #endif
 
  out:
-#if 0
-#ifdef AFS_NBSD50_ENV
-    if ((afs_debug & AFSDEB_VNLAYER) != 0 && (dvp->v_vflag & VV_ROOT) != 0)
-#else
-    if ((afs_debug & AFSDEB_VNLAYER) != 0 && (dvp->v_flag & VROOT) != 0)
-#endif
-#endif
     if ((afs_debug & AFSDEB_VNLAYER) != 0) {
 	printf("nbsd_lookup done dvp %p cnt %d\n", dvp, dvp->v_usecount);
     }
@@ -638,11 +628,6 @@ afs_nbsd_read(void *v)
 	printf("nbsd_read enter %p vp %p\n", ap, ap->a_vp);
     }
 
-#if 0
-    if (ap->a_uio->uio_offset > ap->a_vp->v_size) {
-	return 0; }
-#endif
-
     AFS_GLOCK();
     code = afs_read(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, 0);
     AFS_GUNLOCK();
@@ -1360,15 +1345,6 @@ afs_nbsd_bmap(void *v)
         *ap->a_vpp = ap->a_vp;
     if (ap->a_runp != NULL)
         *ap->a_runp = 1024 * 1024; /* XXX */
-#ifdef notyet
-    if (ap->a_runb != NULL)
-        *ap->a_runb = 0;
-#endif
-
-#if 0
-    if (afs_debug & AFSDEB_VNLAYER)
-        printf("nbsd_bmap: exit %p\n", ap);
-#endif
 
     return (0);
 }
diff --git a/src/afs/OBSD/osi_file.c b/src/afs/OBSD/osi_file.c
index 792914142..b4635a1c9 100644
--- a/src/afs/OBSD/osi_file.c
+++ b/src/afs/OBSD/osi_file.c
@@ -18,7 +18,6 @@
 
 int afs_osicred_initialized;
 afs_ucred_t afs_osi_cred;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct mount *afs_cacheVfsp;
 
@@ -63,7 +62,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     struct vattr tvattr;
 
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     AFS_GUNLOCK();
     code = VOP_GETATTR(afile->vnode, &tvattr, afs_osi_credp, curproc);
     AFS_GLOCK();
@@ -72,7 +70,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -106,7 +103,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     if (code || tstat.size <= asize)
 	return code;
 
-    ObtainWriteLock(&afs_xosi, 321);
     VATTR_NULL(&tvattr);
     tvattr.va_size = asize;
     AFS_GUNLOCK();
@@ -116,16 +112,12 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     AFS_GLOCK();
     if (code == 0)
 	afile->size = asize;
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
 void
 osi_DisableAtimes(struct vnode *avp)
 {
-#if 0
-    VTOI(avp)->i_flag &= ~IN_ACCESS;
-#endif
 }
 
 
diff --git a/src/afs/OBSD/osi_machdep.h b/src/afs/OBSD/osi_machdep.h
index 0b1e90165..1179e273c 100644
--- a/src/afs/OBSD/osi_machdep.h
+++ b/src/afs/OBSD/osi_machdep.h
@@ -45,7 +45,6 @@
 /* vnode */
 #define VN_HOLD(vp)	afs_vget((vp), 0)
 #define VN_RELE(vp)	vrele(vp)
-#define osi_vnhold(avc, r) afs_vget(AFSTOV(avc), 0)
 #define va_nodeid	va_fileid
 #define vnode_t		struct vnode
 
@@ -98,7 +97,6 @@ typedef struct ucred afs_ucred_t;
 
 /* time */
 #define	afs_hz		hz
-#define osi_GetTime(x)	microtime(x)
 extern time_t osi_Time();
 
 /* str */
@@ -244,4 +242,13 @@ extern int (**afs_vnodeop_p) ();
 
 #define osi_procname(procname, size) strncpy(procname, curproc->p_comm, size)
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    microtime(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/OBSD/osi_misc.c b/src/afs/OBSD/osi_misc.c
index 53911037d..5a7778aa2 100644
--- a/src/afs/OBSD/osi_misc.c
+++ b/src/afs/OBSD/osi_misc.c
@@ -65,7 +65,7 @@ such damages.
  */
 
 int
-afs_osi_suser(void *credp)
+afs_osi_suser(afs_ucred_t *credp)
 {
 #ifdef AFS_OBSD35_ENV
     return (suser_ucred((struct ucred *)credp) ? 0 : 1);
@@ -135,34 +135,6 @@ osi_obsd_Free(void *p, size_t asize)
 }
 #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)
      long *retval;
diff --git a/src/afs/OBSD/osi_prototypes.h b/src/afs/OBSD/osi_prototypes.h
index 4bc45e9e8..6867e1549 100644
--- a/src/afs/OBSD/osi_prototypes.h
+++ b/src/afs/OBSD/osi_prototypes.h
@@ -6,7 +6,4 @@
 #ifndef _OSI_PROTO_H_
 #define _OSI_PROTO_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 #endif /* _OSI_PROTO_H_ */
diff --git a/src/afs/OBSD/osi_sleep.c b/src/afs/OBSD/osi_sleep.c
index 3a4c8e72b..e12688de9 100644
--- a/src/afs/OBSD/osi_sleep.c
+++ b/src/afs/OBSD/osi_sleep.c
@@ -61,12 +61,6 @@ osi_Time()
     return now.tv_sec;
 }
 
-void
-afs_osi_SetTime(osi_timeval_t * atv)
-{
-    printf("afs attempted to set clock; use \"afsd -nosettime\"\n");
-}
-
 /* cancel osi_Wait */
 void
 afs_osi_CancelWait(struct afs_osi_WaitHandle *achandle)
diff --git a/src/afs/OBSD/osi_vcache.c b/src/afs/OBSD/osi_vcache.c
index f6e4fcae8..2798a5fbc 100644
--- a/src/afs/OBSD/osi_vcache.c
+++ b/src/afs/OBSD/osi_vcache.c
@@ -14,7 +14,8 @@
 #include "afsincludes.h"	/*AFS-based standard headers */
 
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     *slept = 0;
 
     if (!VREFCOUNT_GT(avc,0)
@@ -34,7 +35,8 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 }
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *tvc;
 
     tvc = afs_osi_Alloc(sizeof(struct vcache));
@@ -44,12 +46,14 @@ osi_NewVnode(void) {
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) {
+osi_AttachVnode(struct vcache *avc, int seq)
+{
     ReleaseWriteLock(&afs_xvcache);
     AFS_GUNLOCK();
     afs_obsd_getnewvnode(avc);	/* includes one refcount */
@@ -59,8 +63,14 @@ osi_AttachVnode(struct vcache *avc, int seq) {
 }
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     AFSTOV(avc)->v_mount = afs_globalVFS;
     vSetType(avc, VREG);
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    return afs_vget(AFSTOV(avc), 0);
+}
diff --git a/src/afs/OBSD/osi_vfsops.c b/src/afs/OBSD/osi_vfsops.c
index 4377494bb..78b7ed6e3 100644
--- a/src/afs/OBSD/osi_vfsops.c
+++ b/src/afs/OBSD/osi_vfsops.c
@@ -344,7 +344,7 @@ afs_root(struct mount *mp, struct vnode **vpp)
     AFS_GLOCK();
     if (!(code = afs_InitReq(&treq, osi_curcred()))
 	&& !(code = afs_CheckInit())) {
-	tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	tvp = afs_GetVCache(&afs_rootFid, &treq);
 	if (tvp) {
 	    /* There is really no reason to over-hold this bugger--it's held
 	     * by the root filesystem reference. */
diff --git a/src/afs/OBSD/osi_vnodeops.c b/src/afs/OBSD/osi_vnodeops.c
index 286336155..fa3a11244 100644
--- a/src/afs/OBSD/osi_vnodeops.c
+++ b/src/afs/OBSD/osi_vnodeops.c
@@ -937,14 +937,6 @@ afs_obsd_reclaim(void *v)
     int haveGlock = ISAFS_GLOCK();
     int haveVlock = CheckLock(&afs_xvcache);
 
-#if 0
-    printf("reclaim usecount %d\n", vp->v_usecount);
-    /* OK, there are no internal vrefCounts, so there shouldn't
-     * be any more refs here. */
-    vp->v_data = NULL;		/* remove from vnode */
-    avc->v = NULL;		/* also drop the ptr to vnode */
-    return 0;
-#else
     if (!haveGlock)
 	AFS_GLOCK();
     if (!haveVlock)
@@ -956,7 +948,6 @@ afs_obsd_reclaim(void *v)
     if (!haveGlock)
 	AFS_GUNLOCK();
     return code;
-#endif
 }
 
 #ifdef AFS_OBSD42_ENV
diff --git a/src/afs/SOLARIS/osi_file.c b/src/afs/SOLARIS/osi_file.c
index a3387eced..1f81f4ab8 100644
--- a/src/afs/SOLARIS/osi_file.c
+++ b/src/afs/SOLARIS/osi_file.c
@@ -18,7 +18,6 @@
 
 
 int afs_osicred_initialized = 0;
-afs_lock_t afs_xosi;		/* lock is for tvattr */
 extern struct osi_dev cacheDev;
 extern struct vfs *afs_cacheVfsp;
 
@@ -116,11 +115,6 @@ VnodeToSize(vnode_t * vp)
     int code;
     struct vattr vattr;
 
-    /*
-     * We lock xosi in osi_Stat, so we probably should
-     * lock it here too - RWH.
-     */
-    ObtainWriteLock(&afs_xosi, 578);
     vattr.va_mask = AT_SIZE;
     AFS_GUNLOCK();
 #ifdef AFS_SUN511_ENV
@@ -132,7 +126,6 @@ VnodeToSize(vnode_t * vp)
     if (code) {
 	osi_Panic("VnodeToSize");
     }
-    ReleaseWriteLock(&afs_xosi);
     return (afs_int32) (vattr.va_size);
 }
 
@@ -258,7 +251,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
     afs_int32 code;
     struct vattr tvattr;
     AFS_STATCNT(osi_Stat);
-    ObtainWriteLock(&afs_xosi, 320);
     /* Ufs doesn't seem to care about the flags so we pass 0 for now */
     tvattr.va_mask = AT_ALL;
     AFS_GUNLOCK();
@@ -273,7 +265,6 @@ afs_osi_Stat(struct osi_file *afile, struct osi_stat *astat)
 	astat->mtime = tvattr.va_mtime.tv_sec;
 	astat->atime = tvattr.va_atime.tv_sec;
     }
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
@@ -305,7 +296,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = afs_osi_Stat(afile, &tstat);
     if (code || tstat.size <= asize)
 	return code;
-    ObtainWriteLock(&afs_xosi, 321);
     tvattr.va_mask = AT_SIZE;
     tvattr.va_size = asize;
     /*
@@ -318,7 +308,6 @@ osi_UFSTruncate(struct osi_file *afile, afs_int32 asize)
     code = VOP_SETATTR(afile->vnode, &tvattr, 0, afs_osi_credp);
 #endif
     AFS_GLOCK();
-    ReleaseWriteLock(&afs_xosi);
     return code;
 }
 
diff --git a/src/afs/SOLARIS/osi_machdep.h b/src/afs/SOLARIS/osi_machdep.h
index 3f13bde2b..45ee8deb3 100644
--- a/src/afs/SOLARIS/osi_machdep.h
+++ b/src/afs/SOLARIS/osi_machdep.h
@@ -54,19 +54,6 @@ local_osi_Time()
 #define osi_Time() (hrestime.tv_sec)
 #endif
 
-#define osi_vnhold(avc, r)  do {    \
-    struct vnode *vp = AFSTOV(avc); \
-    uint_t prevcount;               \
-                                    \
-    mutex_enter(&vp->v_lock);       \
-    prevcount = vp->v_count++;      \
-    mutex_exit(&vp->v_lock);        \
-                                    \
-    if (prevcount == 0) {           \
-	VFS_HOLD(afs_globalVFS);    \
-    }                               \
-} while(0)
-
 #define gop_rdwr(rw,gp,base,len,offset,segflg,ioflag,ulimit,cr,aresid) \
   vn_rdwr((rw),(gp),(base),(len),(offset),(segflg),(ioflag),(ulimit),(cr),(aresid))
 #define gop_lookupname(fnamep,segflg,followlink,compvpp) \
@@ -138,4 +125,13 @@ struct afs_ifinfo {
 
 #define osi_procname(procname, size) strncpy(procname, PTOU(ttoproc(curthread))->u_comm, size)
 
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval32 now;
+    uniqtime32(&now);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/SOLARIS/osi_prototypes.h b/src/afs/SOLARIS/osi_prototypes.h
index 237a86833..49ba3d26a 100644
--- a/src/afs/SOLARIS/osi_prototypes.h
+++ b/src/afs/SOLARIS/osi_prototypes.h
@@ -10,9 +10,6 @@
 #ifndef _OSI_PROTOTYPES_H_
 #define _OSI_PROTOTYPES_H_
 
-/* osi_file.c */
-extern afs_rwlock_t afs_xosi;
-
 /* osi_vnodeops.c */
 int afs_putapage(struct vnode *vp, struct page *pages, u_offset_t * offp,
 		 size_t * lenp, int flags, afs_ucred_t *credp);
diff --git a/src/afs/SOLARIS/osi_vcache.c b/src/afs/SOLARIS/osi_vcache.c
index 4c40a7417..7f0b9f646 100644
--- a/src/afs/SOLARIS/osi_vcache.c
+++ b/src/afs/SOLARIS/osi_vcache.c
@@ -14,7 +14,8 @@
 #include "afsincludes.h"        /*AFS-based standard headers */
 
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     int code;
 
     if (!VREFCOUNT_GT(avc,0)
@@ -27,7 +28,8 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 }
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     struct vcache *avc;
 
     avc = afs_osi_Alloc(sizeof(struct vcache));
@@ -36,7 +38,8 @@ osi_NewVnode(void) {
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 
     QInit(&avc->multiPage);
@@ -45,6 +48,7 @@ osi_PrePopulateVCache(struct vcache *avc) {
 
     rw_init(&avc->rwlock, "vcache rwlock", RW_DEFAULT, NULL);
 
+#ifndef AFS_SUN511_ENV
     /* This is required if the kaio (kernel aynchronous io)
      ** module is installed. Inside the kernel, the function
      ** check_vp( common/os/aio.c) checks to see if the kernel has
@@ -57,13 +61,28 @@ osi_PrePopulateVCache(struct vcache *avc) {
      ** for the time being, we fill up the v_data field with the
      ** vnode pointer itself. */
     avc->v.v_data = (char *)avc;
+#endif /* !AFS_SUN511_ENV */
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) { }
+osi_AttachVnode(struct vcache *avc, int seq)
+{
+#ifdef AFS_SUN511_ENV
+    struct vnode *vp;
+
+    osi_Assert(AFSTOV(avc) == NULL);
+
+    vp = vn_alloc(KM_SLEEP);
+    osi_Assert(vp != NULL);
+
+    vp->v_data = avc;
+    AFSTOV(avc) = vp;
+#endif
+}
 
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     AFSTOV(avc)->v_op = afs_ops;
     AFSTOV(avc)->v_vfsp = afs_globalVFS;
     vSetType(avc, VREG);
@@ -73,3 +92,19 @@ osi_PostPopulateVCache(struct vcache *avc) {
      * 1 directly. So, we must explicitly VFS_HOLD here. */
     VFS_HOLD(afs_globalVFS);
 }
+
+int
+osi_vnhold(struct vcache *avc)
+{
+    struct vnode *vp = AFSTOV(avc);
+    uint_t prevcount;
+
+    mutex_enter(&vp->v_lock);
+    prevcount = vp->v_count++;
+    mutex_exit(&vp->v_lock);
+
+    if (prevcount == 0) {
+	VFS_HOLD(afs_globalVFS);
+    }
+    return 0;
+}
diff --git a/src/afs/SOLARIS/osi_vfsops.c b/src/afs/SOLARIS/osi_vfsops.c
index 86e5f7803..1f03b8f3d 100644
--- a/src/afs/SOLARIS/osi_vfsops.c
+++ b/src/afs/SOLARIS/osi_vfsops.c
@@ -121,7 +121,7 @@ afs_unmount(struct vfs *afsp, int flag, afs_ucred_t *credp)
 	 * besides the caller of afs_unmount */
 	rootvp = afs_globalVp;
 	afs_globalVp = NULL;
-	AFS_RELE(rootvp);
+	AFS_RELE(AFSTOV(rootvp));
     }
 
     AFS_GUNLOCK();
@@ -178,7 +178,7 @@ again:
 
 	if (!(code = afs_InitReq(&treq, proc->p_cred))
 	    && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 	    /* we really want this to stay around */
 	    if (tvp) {
 		if (afs_globalVp) {
@@ -193,7 +193,7 @@ again:
 	}
     }
     if (tvp) {
-	AFS_FAST_HOLD(tvp);
+	osi_Assert(osi_vnhold(tvp) == 0);
 	mutex_enter(&AFSTOV(tvp)->v_lock);
 	AFSTOV(tvp)->v_flag |= VROOT;
 	mutex_exit(&AFSTOV(tvp)->v_lock);
@@ -229,7 +229,7 @@ afs_statvfs(struct vfs *afsp, struct statvfs64 *abp)
     abp->f_bsize = afsp->vfs_bsize;
     abp->f_blocks = abp->f_bfree = abp->f_bavail = abp->f_files =
 	abp->f_favail = abp->f_ffree = AFS_VFS_FAKEFREE;
-    abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
+    abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID;
 
     AFS_GUNLOCK();
     return 0;
@@ -254,7 +254,11 @@ afs_vget(struct vfs *afsp, struct vnode **avcp, struct fid *fidp)
 
     *avcp = NULL;
     if (!(code = afs_InitReq(&treq, credp))) {
-	code = afs_osi_vget((struct vcache **)avcp, fidp, &treq);
+        struct vcache *tvc = NULL;
+	code = afs_osi_vget(&tvc, fidp, &treq);
+        if (tvc) {
+            *avcp = AFSTOV(tvc);
+        }
     }
 
     afs_Trace3(afs_iclSetp, CM_TRACE_VGET, ICL_TYPE_POINTER, *avcp,
diff --git a/src/afs/SOLARIS/osi_vnodeops.c b/src/afs/SOLARIS/osi_vnodeops.c
index 9aa4f1751..e2cedf08f 100644
--- a/src/afs/SOLARIS/osi_vnodeops.c
+++ b/src/afs/SOLARIS/osi_vnodeops.c
@@ -76,13 +76,16 @@ extern struct as kas;		/* kernel addr space */
 extern unsigned char *afs_indexFlags;
 extern afs_lock_t afs_xdcache;
 
-/* Additional vnodeops for SunOS 4.0.x */
-int afs_nfsrdwr(), afs_getpage(), afs_putpage(), afs_map();
-int afs_dump(), afs_cmp(), afs_realvp(), afs_GetOnePage();
+static int afs_nfsrdwr(struct vcache *avc, struct uio *auio, enum uio_rw arw,
+                       int ioflag, afs_ucred_t *acred);
+static int afs_GetOnePage(struct vnode *vp, u_offset_t off, u_int alen,
+                          u_int *protp, struct page *pl[], u_int plsz,
+                          struct seg *seg, caddr_t addr, enum seg_rw rw,
+                          afs_ucred_t *acred);
 
 int afs_pvn_vptrunc;
 
-int
+static int
 afs_addmap(struct vnode *avp, offset_t offset, struct as *asp, 
 	   caddr_t addr, int length, int prot, int maxprot, int flags, 
 	   afs_ucred_t *credp)
@@ -91,7 +94,7 @@ afs_addmap(struct vnode *avp, offset_t offset, struct as *asp,
     return (0);
 }
 
-int
+static int
 afs_delmap(struct vnode *avp, offset_t offset, struct as *asp, 
 	   caddr_t addr, int length, int prot, int maxprot, int flags, 
 	   afs_ucred_t *credp)
@@ -100,12 +103,11 @@ afs_delmap(struct vnode *avp, offset_t offset, struct as *asp,
     return (0);
 }
 
+static int
 #ifdef AFS_SUN510_ENV
-int
 afs_vmread(struct vnode *avp, struct uio *auio, int ioflag, 
 	   afs_ucred_t *acred, caller_context_t *ct)
 #else
-int
 afs_vmread(struct vnode *avp, struct uio *auio, int ioflag, 
 	   afs_ucred_t *acred)
 #endif
@@ -121,12 +123,11 @@ afs_vmread(struct vnode *avp, struct uio *auio, int ioflag,
 }
 
 
+static int
 #ifdef AFS_SUN510_ENV
-int
 afs_vmwrite(struct vnode *avp, struct uio *auio, int ioflag, 
 	    afs_ucred_t *acred, caller_context_t *ct)
 #else
-int
 afs_vmwrite(struct vnode *avp, struct uio *auio, int ioflag, 
 	    afs_ucred_t *acred)
 #endif
@@ -141,7 +142,7 @@ afs_vmwrite(struct vnode *avp, struct uio *auio, int ioflag,
     return code;
 }
 
-int
+static int
 afs_getpage(struct vnode *vp, offset_t off, u_int len, u_int *protp, 
 	    struct page *pl[], u_int plsz, struct seg *seg, caddr_t addr, 
 	    enum seg_rw rw, afs_ucred_t *acred)
@@ -198,7 +199,7 @@ afs_getpage(struct vnode *vp, offset_t off, u_int len, u_int *protp,
 }
 
 /* Return all the pages from [off..off+len) in file */
-int
+static int
 afs_GetOnePage(struct vnode *vp, u_offset_t off, u_int alen, u_int *protp, 
 	       struct page *pl[], u_int plsz, struct seg *seg, caddr_t addr, 
 	       enum seg_rw rw, afs_ucred_t *acred)
@@ -349,7 +350,7 @@ afs_GetOnePage(struct vnode *vp, u_offset_t off, u_int alen, u_int *protp,
 
     /* Check to see whether the cache entry is still valid */
     if (!(avc->f.states & CStatd)
-	|| !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+	|| !afs_IsDCacheFresh(tdc, avc)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseReadLock(&avc->lock);
 	afs_PutDCache(tdc);
@@ -473,7 +474,7 @@ afs_never_putapage(struct vnode *vp, struct page *pages, u_offset_t * offp,
     struct vcache *avc = VTOAFS(vp);
     osi_Assert((avc->f.states & CRO) != 0);
     osi_Panic("Dirty pages while flushing a read-only volume vnode.");
-    return EIO; /* unreachable */
+    AFS_UNREACHED(return EIO);
 }
 
 int
@@ -588,7 +589,6 @@ afs_putpage(struct vnode *vp, offset_t off, u_int len, int flags,
     return (code);
 }
 
-
 int
 afs_putapage(struct vnode *vp, struct page *pages, u_offset_t * offp,
 	     size_t * lenp, int flags, afs_ucred_t *credp)
@@ -640,7 +640,7 @@ afs_putapage(struct vnode *vp, struct page *pages, u_offset_t * offp,
     return code;
 }
 
-int
+static int
 afs_nfsrdwr(struct vcache *avc, struct uio *auio, enum uio_rw arw,
 	    int ioflag, afs_ucred_t *acred)
 {
@@ -886,12 +886,12 @@ afs_nfsrdwr(struct vcache *avc, struct uio *auio, enum uio_rw arw,
 		AFS_GLOCK();
 		dcp_newpage = afs_FindDCache(avc, pageBase);
 		if (dcp_newpage
-		    && hsame(avc->f.m.DataVersion, dcp_newpage->f.versionNo)) {
+		    && afs_IsDCacheFresh(dcp_newpage, avc)) {
 		    ObtainWriteLock(&avc->lock, 251);
 		    ObtainWriteLock(&avc->vlock, 576);
 		    ObtainReadLock(&dcp_newpage->lock);
 		    if ((avc->activeV == 0)
-			&& hsame(avc->f.m.DataVersion, dcp_newpage->f.versionNo)
+			&& afs_IsDCacheFresh(dcp_newpage, avc)
 			&& !(dcp_newpage->dflags & (DFFetching))) {
 			AFS_GUNLOCK();
 			segmap_pagecreate(segkmap, raddr, rsize, 1);
@@ -966,7 +966,7 @@ afs_nfsrdwr(struct vcache *avc, struct uio *auio, enum uio_rw arw,
     }
 }
 
-int
+static int
 afs_map(struct vnode *vp, offset_t off, struct as *as, caddr_t *addr, size_t len, u_char prot, u_char maxprot, u_int flags, afs_ucred_t *cred)
 {
     struct segvn_crargs crargs;
@@ -1013,7 +1013,11 @@ afs_map(struct vnode *vp, offset_t off, struct as *as, caddr_t *addr, size_t len
     AFS_GUNLOCK();
     as_rangelock(as);
     if ((flags & MAP_FIXED) == 0) {
+#ifdef MAPADDR_LACKS_VACALIGN
+	map_addr(addr, len, off, flags);
+#else
 	map_addr(addr, len, off, 1, flags);
+#endif
 	if (*addr == NULL) {
 	    as_rangeunlock(as);
 	    code = ENOMEM;
@@ -1049,7 +1053,7 @@ afs_map(struct vnode *vp, offset_t off, struct as *as, caddr_t *addr, size_t len
  * For Now We use standard local kernel params for AFS system values. Change this
  * at some point.
  */
-int
+static int
 #ifdef AFS_SUN511_ENV
 afs_pathconf(struct vnode *vp, int cmd, u_long *outdatap,
 	     afs_ucred_t *credp, caller_context_t *ct)
@@ -1092,21 +1096,21 @@ afs_pathconf(struct vnode *vp, int cmd, u_long *outdatap,
     return 0;
 }
 
-int
+static int
 afs_ioctl(struct vnode *vnp, int com, int arg, int flag, cred_t *credp, 
 	  int *rvalp)
 {
     return (ENOTTY);
 }
 
-void
+static void
 afs_rwlock(struct vnode *vnp, int wlock)
 {
     rw_enter(&(VTOAFS(vnp))->rwlock, (wlock ? RW_WRITER : RW_READER));
 }
 
 
-void
+static void
 afs_rwunlock(struct vnode *vnp, int wlock)
 {
     rw_exit(&(VTOAFS(vnp))->rwlock);
@@ -1114,7 +1118,7 @@ afs_rwunlock(struct vnode *vnp, int wlock)
 
 
 /* NOT SUPPORTED */
-int
+static int
 afs_seek(struct vnode *vnp, offset_t ooff, offset_t *noffp)
 {
     int code = 0;
@@ -1130,7 +1134,7 @@ afs_seek(struct vnode *vnp, offset_t ooff, offset_t *noffp)
     return code;
 }
 
-int
+static int
 #ifdef AFS_SUN59_ENV
 afs_frlock(struct vnode *vnp, int cmd, struct flock64 *ap, int flag, 
 	   offset_t off, struct flk_callback *flkcb, afs_ucred_t *credp)
@@ -1166,7 +1170,7 @@ afs_frlock(struct vnode *vnp, int cmd, struct flock64 *ap, int flag,
 }
 
 
-int
+static int
 afs_space(struct vnode *vnp, int cmd, struct flock64 *ap, int flag, 
 	  offset_t off, afs_ucred_t *credp)
 {
@@ -1186,7 +1190,7 @@ afs_space(struct vnode *vnp, int cmd, struct flock64 *ap, int flag,
     return (code);
 }
 
-int
+static int
 afs_dump(struct vnode *vp, caddr_t addr, int i1, int i2)
 {
     AFS_STATCNT(afs_dump);
@@ -1196,7 +1200,7 @@ afs_dump(struct vnode *vp, caddr_t addr, int i1, int i2)
 
 
 /* Nothing fancy here; just compare if vnodes are identical ones */
-int
+static int
 afs_cmp(struct vnode *vp1, struct vnode *vp2)
 {
     AFS_STATCNT(afs_cmp);
@@ -1204,7 +1208,7 @@ afs_cmp(struct vnode *vp1, struct vnode *vp2)
 }
 
 
-int
+static int
 afs_realvp(struct vnode *vp, struct vnode **vpp)
 {
     AFS_STATCNT(afs_realvp);
@@ -1212,7 +1216,7 @@ afs_realvp(struct vnode *vp, struct vnode **vpp)
 }
 
 
-int
+static int
 afs_pageio(struct vnode *vp, struct page *pp, u_int ui1, u_int ui2, int i1, 
 	   struct cred *credp)
 {
@@ -1220,7 +1224,7 @@ afs_pageio(struct vnode *vp, struct page *pp, u_int ui1, u_int ui2, int i1,
     return EINVAL;
 }
 
-int
+static int
 #ifdef AFS_SUN59_ENV
 afs_dumpctl(struct vnode *vp, int i, int *blkp)
 #else
@@ -1232,38 +1236,38 @@ afs_dumpctl(struct vnode *vp, int i)
 }
 
 #ifdef	AFS_SUN511_ENV
-extern void
+static void
 afs_dispose(struct vnode *vp, struct page *p, int fl, int dn, struct cred *cr, struct caller_context_t *ct)
 {
     fs_dispose(vp, p, fl, dn, cr,ct);
 }
 
-int
+static int
 afs_setsecattr(struct vnode *vp, vsecattr_t *vsecattr, int flag, struct cred *creds, struct caller_context_t *ct)
 {
     return ENOSYS;
 }
 
-int
+static int
 afs_getsecattr(struct vnode *vp, vsecattr_t *vsecattr, int flag, struct cred *creds, struct caller_context_t *ct)
 {
   return fs_fab_acl(vp, vsecattr, flag, creds,ct);
 }
 #else
-extern void
+static void
 afs_dispose(struct vnode *vp, struct page *p, int fl, int dn, struct cred *cr)
 {
     fs_dispose(vp, p, fl, dn, cr);
 }
 
-int
+static int
 afs_setsecattr(struct vnode *vp, vsecattr_t *vsecattr, int flag, 
 	       struct cred *creds)
 {
     return ENOSYS;
 }
 
-int
+static int
 afs_getsecattr(struct vnode *vp, vsecattr_t *vsecattr, int flag, struct cred *creds)
 {
     return fs_fab_acl(vp, vsecattr, flag, creds);
@@ -1271,323 +1275,141 @@ afs_getsecattr(struct vnode *vp, vsecattr_t *vsecattr, int flag, struct cred *cr
 #endif
 
 #ifdef	AFS_GLOBAL_SUNLOCK
-extern int gafs_open(struct vcache **avcp, afs_int32 aflags, 
-		     afs_ucred_t *acred);
-extern int gafs_close(struct vcache *avc, afs_int32 aflags, 
-		      int count, offset_t offset, afs_ucred_t *acred);
-extern int afs_ioctl(struct vnode *vnp, int com, int arg, int flag, 
-		     cred_t *credp, int *rvalp);
-extern int gafs_access(struct vcache *avc, afs_int32 amode,
-		       int flags, afs_ucred_t *acred);
-extern int gafs_getattr(struct vcache *avc, 
-			struct vattr *attrs, int flags, 
-			afs_ucred_t *acred);
-extern int gafs_setattr(struct vcache *avc, 
-			struct vattr *attrs, int flags, 
-			afs_ucred_t *acred);
-extern int gafs_lookup(struct vcache *adp, char *aname, 
-		       struct vcache **avcp, struct pathname *pnp,
-		       int flags, struct vnode *rdir, afs_ucred_t *acred);
-extern int gafs_remove(struct vcache *adp, char *aname, 
-		       afs_ucred_t *acred);
-extern int gafs_link(struct vcache *adp, struct vcache *avc,
-		     char *aname, afs_ucred_t *acred);
-extern int gafs_rename(struct vcache *aodp, char *aname1,
-		       struct vcache *andp, char *aname2,
-		       afs_ucred_t *acred);
-extern int gafs_symlink(struct vcache *adp, char *aname, 
-			struct vattr *attrs, char *atargetName, 
-			afs_ucred_t *acred);
-extern int gafs_rmdir(struct vcache *adp, char *aname, 
-		      struct vnode *cdirp, afs_ucred_t *acred);
-extern int gafs_mkdir(struct vcache *adp, char *aname, 
-		      struct vattr *attrs, struct vcache **avcp, 
-		      afs_ucred_t *acred);
-extern int gafs_fsync(struct vcache *avc, int flag, afs_ucred_t *acred);
-extern int gafs_readlink(struct vcache *avc, struct uio *auio, 
-			 afs_ucred_t *acred);
-extern int gafs_readdir(struct vcache *avc, struct uio *auio,
-			afs_ucred_t *acred, int *eofp);
-extern void gafs_inactive(struct vcache *avc, 
-			  afs_ucred_t *acred);
-extern int gafs_fid(struct vcache *avc, struct fid **fidpp);
-extern int gafs_create(struct vcache *adp, char *aname, 
-		       struct vattr *attrs, enum vcexcl aexcl, int amode, 
-		       struct vcache **avcp, afs_ucred_t *acred);
-#ifdef AFS_SUN511_ENV
-extern int afs_pathconf(struct vnode *vp, int cmd, u_long *outdatap,
-			afs_ucred_t *credp, caller_context_t *ct);
-#else
-extern int afs_pathconf(struct vnode *vp, int cmd, u_long *outdatap,
-			afs_ucred_t *credp);
-#endif /* AFS_SUN511_ENV */
 
-#if defined(AFS_SUN511_ENV)
-/* The following list must always be NULL-terminated */
-const fs_operation_def_t afs_vnodeops_template[] = {
-    VOPNAME_OPEN,		{ .vop_open = gafs_open },
-    VOPNAME_CLOSE,		{ .vop_close = gafs_close },
-    VOPNAME_READ,		{ .vop_read = afs_vmread },
-    VOPNAME_WRITE,		{ .vop_write = afs_vmwrite },
-    VOPNAME_IOCTL,		{ .vop_ioctl = afs_ioctl },
-    VOPNAME_SETFL,		{ .vop_setfl = fs_setfl },
-    VOPNAME_GETATTR,		{ .vop_getattr = gafs_getattr },
-    VOPNAME_SETATTR,		{ .vop_setattr = gafs_setattr },
-    VOPNAME_ACCESS,		{ .vop_access = gafs_access },
-    VOPNAME_LOOKUP,		{ .vop_lookup = gafs_lookup },
-    VOPNAME_CREATE,		{ .vop_create = gafs_create },
-    VOPNAME_REMOVE,		{ .vop_remove = gafs_remove },
-    VOPNAME_LINK,		{ .vop_link = gafs_link },
-    VOPNAME_RENAME,		{ .vop_rename = gafs_rename },
-    VOPNAME_MKDIR,		{ .vop_mkdir = gafs_mkdir },
-    VOPNAME_RMDIR,		{ .vop_rmdir = gafs_rmdir },
-    VOPNAME_READDIR,		{ .vop_readdir = gafs_readdir },
-    VOPNAME_SYMLINK,		{ .vop_symlink = gafs_symlink },   
-    VOPNAME_READLINK,		{ .vop_readlink = gafs_readlink },
-    VOPNAME_FSYNC,		{ .vop_fsync = gafs_fsync },
-    VOPNAME_INACTIVE,		{ .vop_inactive = gafs_inactive },
-    VOPNAME_FID,		{ .vop_fid = gafs_fid },
-    VOPNAME_RWLOCK,		{ .vop_rwlock = afs_rwlock },
-    VOPNAME_RWUNLOCK,		{ .vop_rwunlock = afs_rwunlock },
-    VOPNAME_SEEK,		{ .vop_seek = afs_seek },
-    VOPNAME_CMP,		{ .vop_cmp = afs_cmp },
-    VOPNAME_FRLOCK,		{ .vop_frlock = afs_frlock },
-    VOPNAME_SPACE,		{ .vop_space = afs_space },
-    VOPNAME_REALVP,		{ .vop_realvp = afs_realvp },
-    VOPNAME_GETPAGE,		{ .vop_getpage = afs_getpage },
-    VOPNAME_PUTPAGE,		{ .vop_putpage = afs_putpage },
-    VOPNAME_MAP,		{ .vop_map = afs_map },
-    VOPNAME_ADDMAP,		{ .vop_addmap = afs_addmap },
-    VOPNAME_DELMAP,		{ .vop_delmap = afs_delmap },
-    VOPNAME_POLL,		{ .vop_poll = fs_poll },
-    VOPNAME_PATHCONF,		{ .vop_pathconf = afs_pathconf },
-    VOPNAME_PAGEIO,		{ .vop_pageio = afs_pageio },
-    VOPNAME_DUMP,		{ .vop_dump = afs_dump },
-    VOPNAME_DUMPCTL,		{ .vop_dumpctl = afs_dumpctl },   
-    VOPNAME_DISPOSE,		{ .vop_dispose = afs_dispose },
-    VOPNAME_GETSECATTR,		{ .vop_getsecattr = afs_getsecattr },
-    VOPNAME_SETSECATTR, 	{ .vop_setsecattr = afs_setsecattr },
-    VOPNAME_SHRLOCK,		{ .vop_shrlock = fs_shrlock },
-    NULL,			NULL
-};
-vnodeops_t *afs_ops;
-#elif defined(AFS_SUN510_ENV)
-/* The following list must always be NULL-terminated */
-const fs_operation_def_t afs_vnodeops_template[] = {
-    VOPNAME_OPEN,		gafs_open,
-    VOPNAME_CLOSE,		gafs_close,
-    VOPNAME_READ,		afs_vmread,
-    VOPNAME_WRITE,		afs_vmwrite,
-    VOPNAME_IOCTL,		afs_ioctl,
-    VOPNAME_SETFL,		fs_setfl,
-    VOPNAME_GETATTR,		gafs_getattr,
-    VOPNAME_SETATTR,		gafs_setattr,
-    VOPNAME_ACCESS,		gafs_access,
-    VOPNAME_LOOKUP,		gafs_lookup,
-    VOPNAME_CREATE,		gafs_create,
-    VOPNAME_REMOVE,		gafs_remove,
-    VOPNAME_LINK,		gafs_link,
-    VOPNAME_RENAME,		gafs_rename,
-    VOPNAME_MKDIR,		gafs_mkdir,
-    VOPNAME_RMDIR,		gafs_rmdir,
-    VOPNAME_READDIR,		gafs_readdir,
-    VOPNAME_SYMLINK,		gafs_symlink,   
-    VOPNAME_READLINK,		gafs_readlink,
-    VOPNAME_FSYNC,		gafs_fsync,
-    VOPNAME_INACTIVE,		gafs_inactive,
-    VOPNAME_FID,		gafs_fid,
-    VOPNAME_RWLOCK,		afs_rwlock,
-    VOPNAME_RWUNLOCK,		afs_rwunlock,
-    VOPNAME_SEEK,		afs_seek,
-    VOPNAME_CMP,		afs_cmp,
-    VOPNAME_FRLOCK,		afs_frlock,
-    VOPNAME_SPACE,		afs_space,
-    VOPNAME_REALVP,		afs_realvp,
-    VOPNAME_GETPAGE,		afs_getpage,
-    VOPNAME_PUTPAGE,		afs_putpage,
-    VOPNAME_MAP,		afs_map,
-    VOPNAME_ADDMAP,		afs_addmap,
-    VOPNAME_DELMAP,		afs_delmap,
-    VOPNAME_POLL,		fs_poll,
-    VOPNAME_DUMP,		afs_dump,
-    VOPNAME_PATHCONF,		afs_pathconf,
-    VOPNAME_PAGEIO,		afs_pageio,
-    VOPNAME_DUMPCTL,		afs_dumpctl,   
-    VOPNAME_DISPOSE,		afs_dispose,
-    VOPNAME_GETSECATTR,       afs_getsecattr,
-    VOPNAME_SETSECATTR, 	afs_setsecattr,
-    VOPNAME_SHRLOCK,		fs_shrlock,
-    NULL,                     NULL
-};
-struct vnodeops *afs_ops;
-#else
-struct vnodeops Afs_vnodeops = {
-    gafs_open,
-    gafs_close,
-    afs_vmread,
-    afs_vmwrite,
-    afs_ioctl,
-    fs_setfl,
-    gafs_getattr,
-    gafs_setattr,
-    gafs_access,
-    gafs_lookup,
-    gafs_create,
-    gafs_remove,
-    gafs_link,
-    gafs_rename,
-    gafs_mkdir,
-    gafs_rmdir,
-    gafs_readdir,
-    gafs_symlink,
-    gafs_readlink,
-    gafs_fsync,
-    gafs_inactive,
-    gafs_fid,
-    afs_rwlock,
-    afs_rwunlock,
-    afs_seek,
-    afs_cmp,
-    afs_frlock,
-    afs_space,
-    afs_realvp,
-    afs_getpage,
-    afs_putpage,
-    afs_map,
-    afs_addmap,
-    afs_delmap,
-    fs_poll,
-    afs_dump,
-    afs_pathconf,
-    afs_pageio,
-    afs_dumpctl,
-    afs_dispose,
-    afs_setsecattr,
-    afs_getsecattr,
-    fs_shrlock,
-};
-struct vnodeops *afs_ops = &Afs_vnodeops;
-#endif
-
-int
-gafs_open(struct vcache **avcp, afs_int32 aflags, 
+static int
+gafs_open(struct vnode **vpp, afs_int32 aflags, 
 	  afs_ucred_t *acred)
 {
     int code;
+    struct vcache *avc = VTOAFS(*vpp);
 
     AFS_GLOCK();
-    code = afs_open(avcp, aflags, acred);
+    code = afs_open(&avc, aflags, acred);
     AFS_GUNLOCK();
+
+    /* afs_open currently never changes avc, but just in case... */
+    *vpp = AFSTOV(avc);
+
     return (code);
 }
 
-int
-gafs_close(struct vcache *avc, afs_int32 aflags, int count, 
+static int
+gafs_close(struct vnode *vp, afs_int32 aflags, int count, 
 	   offset_t offset, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_close(avc, aflags, count, offset, acred);
+    code = afs_close(VTOAFS(vp), aflags, count, offset, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
-int
-gafs_getattr(struct vcache *avc, struct vattr *attrs, 
+static int
+gafs_getattr(struct vnode *vp, struct vattr *attrs, 
 	     int flags, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_getattr(avc, attrs, flags, acred);
+    code = afs_getattr(VTOAFS(vp), attrs, flags, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
 
-int
-gafs_setattr(struct vcache *avc, struct vattr *attrs, 
+static int
+gafs_setattr(struct vnode *vp, struct vattr *attrs, 
 	     int flags, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_setattr(avc, attrs, flags, acred);
+    code = afs_setattr(VTOAFS(vp), attrs, flags, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
 
-int
-gafs_access(struct vcache *avc, afs_int32 amode, int flags, 
+static int
+gafs_access(struct vnode *vp, afs_int32 amode, int flags, 
 	    afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_access(avc, amode, flags, acred);
+    code = afs_access(VTOAFS(vp), amode, flags, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
 
-int
-gafs_lookup(struct vcache *adp, char *aname, 
-	    struct vcache **avcp, struct pathname *pnp, int flags, 
+static int
+gafs_lookup(struct vnode *dvp, char *aname, 
+	    struct vnode **vpp, struct pathname *pnp, int flags, 
 	    struct vnode *rdir, afs_ucred_t *acred)
 {
     int code;
+    struct vcache *tvc = NULL;
 
     AFS_GLOCK();
-    code = afs_lookup(adp, aname, avcp, pnp, flags, rdir, acred);
+    code = afs_lookup(VTOAFS(dvp), aname, &tvc, pnp, flags, rdir, acred);
     AFS_GUNLOCK();
+
+    *vpp = NULL;
+    if (tvc) {
+        *vpp = AFSTOV(tvc);
+    }
+
     return (code);
 }
 
 
-int
-gafs_create(struct vcache *adp, char *aname, struct vattr *attrs, 
-	    enum vcexcl aexcl, int amode, struct vcache **avcp, 
+static int
+gafs_create(struct vnode *dvp, char *aname, struct vattr *attrs, 
+	    enum vcexcl aexcl, int amode, struct vnode **vpp, 
 	    afs_ucred_t *acred)
 {
     int code;
+    struct vcache *tvc = NULL;
 
     AFS_GLOCK();
-    code = afs_create(adp, aname, attrs, aexcl, amode, avcp, acred);
+    code = afs_create(VTOAFS(dvp), aname, attrs, aexcl, amode, &tvc, acred);
     AFS_GUNLOCK();
+
+    *vpp = NULL;
+    if (tvc) {
+        *vpp = AFSTOV(tvc);
+    }
+
     return (code);
 }
 
-int
-gafs_remove(struct vcache *adp, char *aname, afs_ucred_t *acred)
+static int
+gafs_remove(struct vnode *vp, char *aname, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_remove(adp, aname, acred);
+    code = afs_remove(VTOAFS(vp), aname, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
-int
-gafs_link(struct vcache *adp, struct vcache *avc, 
+static int
+gafs_link(struct vnode *dvp, struct vnode *svp, 
 	  char *aname, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_link(adp, avc, aname, acred);
+    code = afs_link(VTOAFS(dvp), VTOAFS(svp), aname, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
-int
-gafs_rename(struct vcache *aodp, char *aname1, 
-	    struct vcache *andp, char *aname2, 
+static int
+gafs_rename(struct vnode *odvp, char *aname1, 
+	    struct vnode *ndvp, char *aname2, 
 	    afs_ucred_t *acred)
 {
     int code;
+    struct vcache *aodp = VTOAFS(odvp);
+    struct vcache *andp = VTOAFS(ndvp);
 
     AFS_GLOCK();
     code = afs_rename(aodp, aname1, andp, aname2, acred);
@@ -1611,7 +1433,7 @@ gafs_rename(struct vcache *aodp, char *aname1,
 	    vn_setpath(afs_globalVp, pvp, vp, aname2, strlen(aname2));
 # endif /* !HAVE_VN_RENAMEPATH */
 
-	    AFS_RELE(avcp);
+	    AFS_RELE(AFSTOV(avcp));
 	}
     }
 #endif
@@ -1619,79 +1441,81 @@ gafs_rename(struct vcache *aodp, char *aname1,
     return (code);
 }
 
-int
-gafs_mkdir(struct vcache *adp, char *aname, struct vattr *attrs, 
-	   struct vcache **avcp, afs_ucred_t *acred)
+static int
+gafs_mkdir(struct vnode *dvp, char *aname, struct vattr *attrs, 
+	   struct vnode **vpp, afs_ucred_t *acred)
 {
     int code;
+    struct vcache *tvc = NULL;
 
     AFS_GLOCK();
-    code = afs_mkdir(adp, aname, attrs, avcp, acred);
+    code = afs_mkdir(VTOAFS(dvp), aname, attrs, &tvc, acred);
     AFS_GUNLOCK();
+
+    *vpp = NULL;
+    if (tvc) {
+        *vpp = AFSTOV(tvc);
+    }
+
     return (code);
 }
 
-int
-gafs_rmdir(struct vcache *adp, char *aname, struct vnode *cdirp, 
+static int
+gafs_rmdir(struct vnode *vp, char *aname, struct vnode *cdirp, 
 	   afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_rmdir(adp, aname, cdirp, acred);
+    code = afs_rmdir(VTOAFS(vp), aname, cdirp, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
 
-int
-gafs_readdir(struct vcache *avc, struct uio *auio,
+static int
+gafs_readdir(struct vnode *vp, struct uio *auio,
 	     afs_ucred_t *acred, int *eofp)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_readdir(avc, auio, acred, eofp);
+    code = afs_readdir(VTOAFS(vp), auio, acred, eofp);
     AFS_GUNLOCK();
     return (code);
 }
 
-int
-gafs_symlink(struct vcache *adp, char *aname, struct vattr *attrs,
+static int
+gafs_symlink(struct vnode *vp, char *aname, struct vattr *attrs,
 	     char *atargetName, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_symlink(adp, aname, attrs, atargetName, NULL, acred);
+    code = afs_symlink(VTOAFS(vp), aname, attrs, atargetName, NULL, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
 
-int
-gafs_readlink(struct vcache *avc, struct uio *auio, afs_ucred_t *acred)
+static int
+gafs_readlink(struct vnode *vp, struct uio *auio, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_readlink(avc, auio, acred);
+    code = afs_readlink(VTOAFS(vp), auio, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
-int
-gafs_fsync(struct vcache *avc, int flag, afs_ucred_t *acred)
+static int
+gafs_fsync(struct vnode *vp, int flag, afs_ucred_t *acred)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_fsync(avc, flag, acred);
+    code = afs_fsync(VTOAFS(vp), flag, acred);
     AFS_GUNLOCK();
     return (code);
 }
 
-int
+static int
 afs_inactive(struct vcache *avc, afs_ucred_t *acred)
 {
     struct vnode *vp = AFSTOV(avc);
@@ -1740,24 +1564,170 @@ afs_inactive(struct vcache *avc, afs_ucred_t *acred)
     return 0;
 }
 
-void
-gafs_inactive(struct vcache *avc, afs_ucred_t *acred)
+static void
+gafs_inactive(struct vnode *vp, afs_ucred_t *acred)
 {
     AFS_GLOCK();
-    (void)afs_inactive(avc, acred);
+    (void)afs_inactive(VTOAFS(vp), acred);
     AFS_GUNLOCK();
 }
 
 
-int
-gafs_fid(struct vcache *avc, struct fid **fidpp)
+static int
+gafs_fid(struct vnode *vp, struct fid **fidpp)
 {
     int code;
-
     AFS_GLOCK();
-    code = afs_fid(avc, fidpp);
+    code = afs_fid(VTOAFS(vp), fidpp);
     AFS_GUNLOCK();
     return (code);
 }
 
+#if defined(AFS_SUN511_ENV)
+/* The following list must always be NULL-terminated */
+const fs_operation_def_t afs_vnodeops_template[] = {
+    VOPNAME_OPEN,		{ .vop_open = gafs_open },
+    VOPNAME_CLOSE,		{ .vop_close = gafs_close },
+    VOPNAME_READ,		{ .vop_read = afs_vmread },
+    VOPNAME_WRITE,		{ .vop_write = afs_vmwrite },
+    VOPNAME_IOCTL,		{ .vop_ioctl = afs_ioctl },
+    VOPNAME_SETFL,		{ .vop_setfl = fs_setfl },
+    VOPNAME_GETATTR,		{ .vop_getattr = gafs_getattr },
+    VOPNAME_SETATTR,		{ .vop_setattr = gafs_setattr },
+    VOPNAME_ACCESS,		{ .vop_access = gafs_access },
+    VOPNAME_LOOKUP,		{ .vop_lookup = gafs_lookup },
+    VOPNAME_CREATE,		{ .vop_create = gafs_create },
+    VOPNAME_REMOVE,		{ .vop_remove = gafs_remove },
+    VOPNAME_LINK,		{ .vop_link = gafs_link },
+    VOPNAME_RENAME,		{ .vop_rename = gafs_rename },
+    VOPNAME_MKDIR,		{ .vop_mkdir = gafs_mkdir },
+    VOPNAME_RMDIR,		{ .vop_rmdir = gafs_rmdir },
+    VOPNAME_READDIR,		{ .vop_readdir = gafs_readdir },
+    VOPNAME_SYMLINK,		{ .vop_symlink = gafs_symlink },
+    VOPNAME_READLINK,		{ .vop_readlink = gafs_readlink },
+    VOPNAME_FSYNC,		{ .vop_fsync = gafs_fsync },
+    VOPNAME_INACTIVE,		{ .vop_inactive = gafs_inactive },
+    VOPNAME_FID,		{ .vop_fid = gafs_fid },
+    VOPNAME_RWLOCK,		{ .vop_rwlock = afs_rwlock },
+    VOPNAME_RWUNLOCK,		{ .vop_rwunlock = afs_rwunlock },
+    VOPNAME_SEEK,		{ .vop_seek = afs_seek },
+    VOPNAME_CMP,		{ .vop_cmp = afs_cmp },
+    VOPNAME_FRLOCK,		{ .vop_frlock = afs_frlock },
+    VOPNAME_SPACE,		{ .vop_space = afs_space },
+    VOPNAME_REALVP,		{ .vop_realvp = afs_realvp },
+    VOPNAME_GETPAGE,		{ .vop_getpage = afs_getpage },
+    VOPNAME_PUTPAGE,		{ .vop_putpage = afs_putpage },
+    VOPNAME_MAP,		{ .vop_map = afs_map },
+    VOPNAME_ADDMAP,		{ .vop_addmap = afs_addmap },
+    VOPNAME_DELMAP,		{ .vop_delmap = afs_delmap },
+    VOPNAME_POLL,		{ .vop_poll = fs_poll },
+    VOPNAME_PATHCONF,		{ .vop_pathconf = afs_pathconf },
+    VOPNAME_PAGEIO,		{ .vop_pageio = afs_pageio },
+    VOPNAME_DUMP,		{ .vop_dump = afs_dump },
+    VOPNAME_DUMPCTL,		{ .vop_dumpctl = afs_dumpctl },
+    VOPNAME_DISPOSE,		{ .vop_dispose = afs_dispose },
+    VOPNAME_GETSECATTR,		{ .vop_getsecattr = afs_getsecattr },
+    VOPNAME_SETSECATTR, 	{ .vop_setsecattr = afs_setsecattr },
+    VOPNAME_SHRLOCK,		{ .vop_shrlock = fs_shrlock },
+    NULL,			NULL
+};
+vnodeops_t *afs_ops;
+#elif defined(AFS_SUN510_ENV)
+/* The following list must always be NULL-terminated */
+const fs_operation_def_t afs_vnodeops_template[] = {
+    VOPNAME_OPEN,		gafs_open,
+    VOPNAME_CLOSE,		gafs_close,
+    VOPNAME_READ,		afs_vmread,
+    VOPNAME_WRITE,		afs_vmwrite,
+    VOPNAME_IOCTL,		afs_ioctl,
+    VOPNAME_SETFL,		fs_setfl,
+    VOPNAME_GETATTR,		gafs_getattr,
+    VOPNAME_SETATTR,		gafs_setattr,
+    VOPNAME_ACCESS,		gafs_access,
+    VOPNAME_LOOKUP,		gafs_lookup,
+    VOPNAME_CREATE,		gafs_create,
+    VOPNAME_REMOVE,		gafs_remove,
+    VOPNAME_LINK,		gafs_link,
+    VOPNAME_RENAME,		gafs_rename,
+    VOPNAME_MKDIR,		gafs_mkdir,
+    VOPNAME_RMDIR,		gafs_rmdir,
+    VOPNAME_READDIR,		gafs_readdir,
+    VOPNAME_SYMLINK,		gafs_symlink,
+    VOPNAME_READLINK,		gafs_readlink,
+    VOPNAME_FSYNC,		gafs_fsync,
+    VOPNAME_INACTIVE,		gafs_inactive,
+    VOPNAME_FID,		gafs_fid,
+    VOPNAME_RWLOCK,		afs_rwlock,
+    VOPNAME_RWUNLOCK,		afs_rwunlock,
+    VOPNAME_SEEK,		afs_seek,
+    VOPNAME_CMP,		afs_cmp,
+    VOPNAME_FRLOCK,		afs_frlock,
+    VOPNAME_SPACE,		afs_space,
+    VOPNAME_REALVP,		afs_realvp,
+    VOPNAME_GETPAGE,		afs_getpage,
+    VOPNAME_PUTPAGE,		afs_putpage,
+    VOPNAME_MAP,		afs_map,
+    VOPNAME_ADDMAP,		afs_addmap,
+    VOPNAME_DELMAP,		afs_delmap,
+    VOPNAME_POLL,		fs_poll,
+    VOPNAME_DUMP,		afs_dump,
+    VOPNAME_PATHCONF,		afs_pathconf,
+    VOPNAME_PAGEIO,		afs_pageio,
+    VOPNAME_DUMPCTL,		afs_dumpctl,
+    VOPNAME_DISPOSE,		afs_dispose,
+    VOPNAME_GETSECATTR,       afs_getsecattr,
+    VOPNAME_SETSECATTR, 	afs_setsecattr,
+    VOPNAME_SHRLOCK,		fs_shrlock,
+    NULL,                     NULL
+};
+struct vnodeops *afs_ops;
+#else
+struct vnodeops Afs_vnodeops = {
+    gafs_open,
+    gafs_close,
+    afs_vmread,
+    afs_vmwrite,
+    afs_ioctl,
+    fs_setfl,
+    gafs_getattr,
+    gafs_setattr,
+    gafs_access,
+    gafs_lookup,
+    gafs_create,
+    gafs_remove,
+    gafs_link,
+    gafs_rename,
+    gafs_mkdir,
+    gafs_rmdir,
+    gafs_readdir,
+    gafs_symlink,
+    gafs_readlink,
+    gafs_fsync,
+    gafs_inactive,
+    gafs_fid,
+    afs_rwlock,
+    afs_rwunlock,
+    afs_seek,
+    afs_cmp,
+    afs_frlock,
+    afs_space,
+    afs_realvp,
+    afs_getpage,
+    afs_putpage,
+    afs_map,
+    afs_addmap,
+    afs_delmap,
+    fs_poll,
+    afs_dump,
+    afs_pathconf,
+    afs_pageio,
+    afs_dumpctl,
+    afs_dispose,
+    afs_setsecattr,
+    afs_getsecattr,
+    fs_shrlock,
+};
+struct vnodeops *afs_ops = &Afs_vnodeops;
+#endif
+
 #endif /* AFS_GLOBAL_SUNLOCK */
diff --git a/src/afs/SUNOS/osi_inode.h b/src/afs/SUNOS/osi_inode.h
deleted file mode 100644
index 89b35272a..000000000
--- a/src/afs/SUNOS/osi_inode.h
+++ /dev/null
@@ -1 +0,0 @@
-#error kernel code not supported on SunOS 4
diff --git a/src/afs/UKERNEL/afs_usrops.c b/src/afs/UKERNEL/afs_usrops.c
index 58e7b3057..8fbc109f7 100644
--- a/src/afs/UKERNEL/afs_usrops.c
+++ b/src/afs/UKERNEL/afs_usrops.c
@@ -166,13 +166,13 @@ getf(int fd)
  * Every user is a super user
  */
 int
-afs_osi_suser(void *credp)
+afs_osi_suser(afs_ucred_t *credp)
 {
     return 1;
 }
 
 int
-afs_suser(void *credp)
+afs_suser(afs_ucred_t *credp)
 {
     return 1;
 }
@@ -181,12 +181,6 @@ afs_suser(void *credp)
  * These are no-ops in user space
  */
 
-void
-afs_osi_SetTime(osi_timeval_t * atv)
-{
-    return;
-}
-
 /*
  * xflock should never fall through, the only files we know
  * about are AFS files
@@ -941,19 +935,6 @@ afs_osi_Visible(void)
     return;
 }
 
-int
-osi_GetTime(struct timeval *tv)
-{
-    gettimeofday(tv, NULL);
-    return 0;
-}
-
-int
-osi_SetTime(struct timeval *tv)
-{
-    return 0;
-}
-
 int
 osi_Active(struct vcache *avc)
 {
@@ -2405,11 +2386,10 @@ uafs_pread_nocache_r(int fd, char *buf, int len, off_t offset)
 
     /* these get freed in PrefetchNoCache, so... */
     bparms = afs_osi_Alloc(sizeof(struct nocache_read_request));
-    bparms->areq = afs_osi_Alloc(sizeof(struct vrequest));
 
-    code = afs_InitReq(bparms->areq, get_user_struct()->u_cred);
+    code = afs_CreateReq(&bparms->areq, get_user_struct()->u_cred);
     if (code) {
-	afs_osi_Free(bparms->areq, sizeof(struct vrequest));
+	afs_DestroyReq(bparms->areq);
 	afs_osi_Free(bparms, sizeof(struct nocache_read_request));
 	errno = code;
 	return -1;
diff --git a/src/afs/UKERNEL/osi_machdep.h b/src/afs/UKERNEL/osi_machdep.h
index e252c7623..27667eba6 100644
--- a/src/afs/UKERNEL/osi_machdep.h
+++ b/src/afs/UKERNEL/osi_machdep.h
@@ -49,11 +49,6 @@
 #undef gop_lookupname_user
 #define gop_lookupname_user(fnamep,segflg,followlink,compvpp) lookupname((fnamep),(segflg),(followlink),(compvpp))
 
-#define osi_vnhold(avc, r)  do { VN_HOLD(AFSTOV(avc)); } while(0)
-
-#if 0
-#define	afs_suser(x)	    suser(x)
-#endif
 /*
  * Global lock support.
  */
@@ -81,11 +76,21 @@ extern usr_mutex_t afs_global_lock;
 
 extern int afs_bufferpages;
 
-extern int afs_suser(void *credp);
+extern int afs_suser(afs_ucred_t *credp);
 
 #define setuerror(erval) get_user_struct()->u_error = (erval)
 #define getuerror(erval) get_user_struct()->u_error
 #define osi_curcred()    get_user_struct()->u_cred
 
 #define osi_procname(procname, size) strncpy(procname, "(unknown)", size)
+
+static_inline void
+osi_GetTime(osi_timeval32_t *atv)
+{
+    struct timeval now;
+    gettimeofday(&now, NULL);
+    atv->tv_sec = now.tv_sec;
+    atv->tv_usec = now.tv_usec;
+}
+
 #endif /* _OSI_MACHDEP_H_ */
diff --git a/src/afs/UKERNEL/osi_vcache.c b/src/afs/UKERNEL/osi_vcache.c
index dce051e84..b6846a6d9 100644
--- a/src/afs/UKERNEL/osi_vcache.c
+++ b/src/afs/UKERNEL/osi_vcache.c
@@ -14,7 +14,8 @@
 #include "afsincludes.h"        /*AFS-based standard headers */
 
 int
-osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
+osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep)
+{
     int code;
 
     if (!VREFCOUNT_GT(avc,0)
@@ -27,23 +28,34 @@ osi_TryEvictVCache(struct vcache *avc, int *slept, int defersleep) {
 }
 
 struct vcache *
-osi_NewVnode(void) {
+osi_NewVnode(void)
+{
     return afs_osi_Alloc(sizeof(struct vcache));
 }
 
 void
-osi_PrePopulateVCache(struct vcache *avc) {
+osi_PrePopulateVCache(struct vcache *avc)
+{
     memset(avc, 0, sizeof(struct vcache));
 }
 
 void
-osi_AttachVnode(struct vcache *avc, int seq) { }
+osi_AttachVnode(struct vcache *avc, int seq)
+{
+}
 
 extern struct vnodeops *afs_ops;
 void
-osi_PostPopulateVCache(struct vcache *avc) {
+osi_PostPopulateVCache(struct vcache *avc)
+{
     AFSTOV(avc)->v_vfsp = afs_globalVFS;
     AFSTOV(avc)->v_op = afs_ops;
     vSetType(avc, VREG);
 }
 
+int
+osi_vnhold(struct vcache *avc)
+{
+    VN_HOLD(AFSTOV(avc));
+    return 0;
+}
diff --git a/src/afs/UKERNEL/osi_vfsops.c b/src/afs/UKERNEL/osi_vfsops.c
index b50af8f0f..38b1e72ec 100644
--- a/src/afs/UKERNEL/osi_vfsops.c
+++ b/src/afs/UKERNEL/osi_vfsops.c
@@ -76,7 +76,7 @@ afs_root(OSI_VFS_DECL(afsp), struct vnode **avpp)
 
 	if (!(code = afs_InitReq(&treq, get_user_struct()->u_cred))
 	    && !(code = afs_CheckInit())) {
-	    tvp = afs_GetVCache(&afs_rootFid, &treq, NULL, NULL);
+	    tvp = afs_GetVCache(&afs_rootFid, &treq);
 	    /* we really want this to stay around */
 	    if (tvp) {
 		afs_globalVp = tvp;
@@ -129,7 +129,7 @@ afs_statvfs(struct vfs *afsp, struct statvfs *abp)
     abp->f_fsid.val[0] = AFS_VFSMAGIC;
     abp->f_fsid.val[1] = AFS_VFSFSID;
 #else
-    abp->f_fsid = (AFS_VFSMAGIC << 16) || AFS_VFSFSID;
+    abp->f_fsid = (AFS_VFSMAGIC << 16) | AFS_VFSFSID;
 #endif
 
     return 0;
diff --git a/src/afs/UKERNEL/sysincludes.h b/src/afs/UKERNEL/sysincludes.h
index fd906dea3..15000652f 100644
--- a/src/afs/UKERNEL/sysincludes.h
+++ b/src/afs/UKERNEL/sysincludes.h
@@ -82,23 +82,6 @@
 #include  <arpa/inet.h>
 #endif /* AFS_USR_HPUX_ENV */
 
-#ifdef AFS_USR_OSF_ENV
-#ifdef KERNEL
-#undef KERNEL
-#define AFS_USR_UNDEF_KERNEL_ENV 1
-#endif
-#include  <sys/param.h>
-#include  <sys/socket.h>
-#include  <net/if.h>
-#include  <sys/file.h>
-#include  <sys/ioctl.h>
-#include  <sys/stat.h>
-#include  <sys/fcntl.h>
-#include  <netinet/in.h>
-#include  <netdb.h>
-#include  <arpa/inet.h>
-#endif /* AFS_USR_OSF_ENV */
-
 #ifdef AFS_USR_LINUX22_ENV
 #include  <sys/ioctl.h>		/* _IOW() */
 #include  <sys/uio.h>		/* struct iovec */
@@ -256,11 +239,7 @@ typedef unsigned int fsblkcnt_t;
 
 enum usr_vcexcl { usr_NONEXCL, usr_EXCL };
 typedef long offset_t;
-#ifdef AFS_USR_OSF_ENV
-typedef int usr_ino_t;
-#else /* AFS_USR_OSF_ENV */
 typedef long usr_ino_t;
-#endif /* AFS_USR_OSF_ENV */
 
 #if defined(AFS_USR_AIX_ENV) || defined(AFS_USR_SGI_ENV)
 #define SYS_setgroups		101
@@ -836,7 +815,7 @@ static_inline void panic(const char *format, ...)
     vfprintf(stderr, format, ap);
     va_end(ap);
     assert(0);
-};
+}
 #define abort()			assert(0)
 #define usr_assert(A)		assert(A)
 
@@ -1242,11 +1221,7 @@ extern struct usr_in_ifaddr *usr_in_ifaddr;
 #endif /* UKERNEL */
 
 struct min_direct {
-#if defined(AFS_USR_OSF_ENV)
-    unsigned int d_fileno;
-#else				/* AFS_OFS_ENV || AFS_USR_OSF_ENV */
     unsigned long d_fileno;
-#endif				/* AFS_OFS_ENV || AFS_USR_OSF_ENV */
     unsigned short d_reclen;
     unsigned short d_namlen;
 };
diff --git a/src/afs/VNOPS/afs_vnop_access.c b/src/afs/VNOPS/afs_vnop_access.c
index 149dae9b8..8dd885b35 100644
--- a/src/afs/VNOPS/afs_vnop_access.c
+++ b/src/afs/VNOPS/afs_vnop_access.c
@@ -145,7 +145,7 @@ afs_AccessOK(struct vcache *avc, afs_int32 arights, struct vrequest *areq,
 	    dirFid.Fid.Vnode = avc->f.parent.vnode;
 	    dirFid.Fid.Unique = avc->f.parent.unique;
 	    /* Avoid this GetVCache call */
-	    tvc = afs_GetVCache(&dirFid, areq, NULL, NULL);
+	    tvc = afs_GetVCache(&dirFid, areq);
 	    if (tvc) {
 		dirBits = afs_GetAccessBits(tvc, arights, areq);
 		afs_PutVCache(tvc);
diff --git a/src/afs/VNOPS/afs_vnop_attrs.c b/src/afs/VNOPS/afs_vnop_attrs.c
index 26062d1b9..7166bf3c3 100644
--- a/src/afs/VNOPS/afs_vnop_attrs.c
+++ b/src/afs/VNOPS/afs_vnop_attrs.c
@@ -93,7 +93,7 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs)
     attrs->va_uid = fakedir ? 0 : avc->f.m.Owner;
     attrs->va_gid = fakedir ? 0 : avc->f.m.Group;	/* yeah! */
 #if defined(AFS_SUN5_ENV)
-    attrs->va_fsid = avc->v.v_vfsp->vfs_fsid.val[0];
+    attrs->va_fsid = AFSTOV(avc)->v_vfsp->vfs_fsid.val[0];
 #elif defined(AFS_DARWIN80_ENV)
     VATTR_RETURN(attrs, va_fsid, vfs_statfs(vnode_mount(AFSTOV(avc)))->f_fsid.val[0]);
 #elif defined(AFS_DARWIN_ENV)
@@ -141,7 +141,7 @@ afs_CopyOutAttrs(struct vcache *avc, struct vattr *attrs)
     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
 	attrs->va_ctime.tv_nsec = 0;
     attrs->va_gen = hgetlo(avc->f.m.DataVersion);
-#elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV)
+#elif defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_OBSD_ENV) || defined(AFS_NBSD_ENV) || defined(AFS_LINUX26_ENV)
     attrs->va_atime.tv_nsec = attrs->va_mtime.tv_nsec =
 	attrs->va_ctime.tv_nsec =
 	(hgetlo(avc->f.m.DataVersion) & 0x7ffff) * 1000;
@@ -248,7 +248,7 @@ afs_getattr(OSI_VC_DECL(avc), struct vattr *attrs, afs_ucred_t *acred)
 
     if (!(avc->f.states & CStatd)) {
 	if (!(code = afs_CreateReq(&treq, acred))) {
-	    code = afs_VerifyVCache2(avc, treq);
+	    code = afs_VerifyVCache(avc, treq);
 	    inited = 1;
 	}
     } else
@@ -433,7 +433,7 @@ afs_VAttrToAS(struct vcache *avc, struct vattr *av,
 #endif
 	mask |= AFS_SETMODTIME;
 #ifndef	AFS_SGI_ENV
-#if	defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if	defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV) || defined(AFS_LINUX26_ENV)
 	if (av->va_mtime.tv_nsec == -1)
 #else
 	if (av->va_mtime.tv_usec == -1)
diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c
index fe37eed36..dc0966d7a 100644
--- a/src/afs/VNOPS/afs_vnop_create.c
+++ b/src/afs/VNOPS/afs_vnop_create.c
@@ -149,7 +149,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
      * received a callback while we were waiting for the write lock.
      */
     if (!(adp->f.states & CStatd)
-	|| (tdc && !hsame(adp->f.m.DataVersion, tdc->f.versionNo))) {
+	|| (tdc && !afs_IsDCacheFresh(tdc, adp))) {
 	ReleaseWriteLock(&adp->lock);
 	if (tdc) {
 	    ReleaseSharedLock(&tdc->lock);
@@ -178,10 +178,10 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 	    newFid.Fid.Volume = adp->f.fid.Fid.Volume;
 	    tvc = NULL;
 	    if (newFid.Fid.Unique == 0) {
-		tvc = afs_LookupVCache(&newFid, treq, NULL, adp, aname);
+		tvc = afs_LookupVCache(&newFid, treq, adp, aname);
 	    }
 	    if (!tvc)		/* lookup failed or wasn't called */
-		tvc = afs_GetVCache(&newFid, treq, NULL, NULL);
+		tvc = afs_GetVCache(&newFid, treq);
 
 	    if (tvc) {
 		/* if the thing exists, we need the right access to open it.
@@ -451,7 +451,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 	    if (origCBs == finalCBs && origZaps == finalZaps) {
 		tvc->f.states |= CStatd;	/* we've fake entire thing, so don't stat */
 		tvc->f.states &= ~CBulkFetching;
-		if (!AFS_IS_DISCON_RW) {
+		if (!AFS_IS_DISCONNECTED && !AFS_IS_DISCON_RW) {
 		    tvc->cbExpires = CallBack.ExpirationTime;
 		    afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), volp);
 		}
@@ -543,7 +543,7 @@ afs_LocalHero(struct vcache *avc, struct dcache *adc,
     if (adc) {
 	/* does what's in the dcache *now* match what's in the vcache *now*,
 	 * and do we have a valid callback? if not, our local copy is not "ok" */
-	ok = (hsame(avc->f.m.DataVersion, adc->f.versionNo) && avc->callback
+	ok = (afs_IsDCacheFresh(adc, avc) && avc->callback
 	      && (avc->f.states & CStatd) && avc->cbExpires >= osi_Time());
     } else {
 	ok = 0;
diff --git a/src/afs/VNOPS/afs_vnop_dirops.c b/src/afs/VNOPS/afs_vnop_dirops.c
index 596651324..1ddda679a 100644
--- a/src/afs/VNOPS/afs_vnop_dirops.c
+++ b/src/afs/VNOPS/afs_vnop_dirops.c
@@ -228,7 +228,7 @@ afs_mkdir(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 	ReleaseWriteLock(&tvc->lock);
     } else {
     	/* now we're done with parent dir, create the real dir's cache entry */
-	tvc = afs_GetVCache(&newFid, treq, NULL, NULL);
+	tvc = afs_GetVCache(&newFid, treq);
     	if (tvc) {
 	    code = 0;
 	    *avcp = tvc;
@@ -323,13 +323,11 @@ afs_rmdir(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
 	unlinkFid.Fid.Vnode = 0;
 	code = afs_dir_Lookup(tdc, aname, &unlinkFid.Fid);
 	if (code == 0) {
-	    afs_int32 cached = 0;
-
 	    unlinkFid.Cell = adp->f.fid.Cell;
 	    unlinkFid.Fid.Volume = adp->f.fid.Fid.Volume;
 	    if (unlinkFid.Fid.Unique == 0) {
 		tvc =
-		    afs_LookupVCache(&unlinkFid, treq, &cached, adp, aname);
+		    afs_LookupVCache(&unlinkFid, treq, adp, aname);
 	    } else {
 		ObtainReadLock(&afs_xvcache);
 		tvc = afs_FindVCache(&unlinkFid, 0, 1 /* do xstats */ );
diff --git a/src/afs/VNOPS/afs_vnop_fid.c b/src/afs/VNOPS/afs_vnop_fid.c
index d10bcacb2..3fa2edb1f 100644
--- a/src/afs/VNOPS/afs_vnop_fid.c
+++ b/src/afs/VNOPS/afs_vnop_fid.c
@@ -113,7 +113,7 @@ afs_fid(OSI_VC_DECL(avc), struct fid **fidpp)
 	addr[0] = (long)avc;
 #ifndef AFS_AIX41_ENV
 	/* No post processing, so don't hold ref count. */
-	AFS_FAST_HOLD(avc);
+	osi_Assert(osi_vnhold(avc) == 0);
 #endif
     }
 #if	defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV)
diff --git a/src/afs/VNOPS/afs_vnop_flock.c b/src/afs/VNOPS/afs_vnop_flock.c
index 9efeeeb78..05363ff31 100644
--- a/src/afs/VNOPS/afs_vnop_flock.c
+++ b/src/afs/VNOPS/afs_vnop_flock.c
@@ -37,7 +37,7 @@ static int lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp,
 		      struct SimpleLocks *alp, int onlymine,
 		      int clid);
 
-/* int clid;  * non-zero on SGI, OSF, SunOS, Darwin, xBSD ** XXX ptr type */
+/* int clid;  * non-zero on SGI, Darwin, xBSD ** XXX ptr type */
 
 #if defined(AFS_SUN5_ENV)
 void
@@ -238,7 +238,7 @@ lockIdcmp2(struct AFS_FLOCK *flock1, struct vcache *vp,
     If called when disconnected support is unabled, the discon_lock must
     be held
 */
-/* clid - nonzero on sgi sunos osf1 only */
+/* clid - nonzero on sgi only */
 int
 HandleFlock(struct vcache *avc, int acom, struct vrequest *areq,
 	    pid_t clid, int onlymine)
diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c
index 08ad2afff..dd585e97a 100644
--- a/src/afs/VNOPS/afs_vnop_lookup.c
+++ b/src/afs/VNOPS/afs_vnop_lookup.c
@@ -58,7 +58,7 @@ EvalMountData(char type, char *data, afs_uint32 states, afs_uint32 cellnum,
     struct VenusFid tfid;
     struct cell *tcell;
     char *cpos, *volnamep = NULL;
-    char *buf, *endptr;
+    char *endptr;
     afs_int32 prefetch;		/* 1=>None  2=>RO  3=>BK */
     afs_int32 mtptCell, assocCell = 0, hac = 0;
     afs_int32 samecell, roname, len;
@@ -200,24 +200,6 @@ EvalMountData(char type, char *data, afs_uint32 states, afs_uint32 cellnum,
 				WRITE_LOCK);
     }
 
-    /* Still not found. If we are looking for the RO, then perhaps the RW 
-     * doesn't exist? Try adding ".readonly" to volname and look for that.
-     * Don't know why we do this. Would have still found it in above call - jpm.
-     */
-    if (!tvp && (prefetch == 2) && len < AFS_SMALLOCSIZ - 10) {
-	buf = osi_AllocSmallSpace(len + 10);
-
-	strcpy(buf, volnamep);
-	afs_strcat(buf, ".readonly");
-
-	tvp = afs_GetVolumeByName(buf, mtptCell, 1, areq, WRITE_LOCK);
-
-	/* Try the associated linked cell if failed */
-	if (!tvp && hac && areq->volumeError) {
-	    tvp = afs_GetVolumeByName(buf, assocCell, 1, areq, WRITE_LOCK);
-	}
-	osi_FreeSmallSpace(buf);
-    }
     /* done with volname */
     if (cpos)
 	*cpos = ':';
@@ -278,10 +260,6 @@ EvalMountPoint(struct vcache *avc, struct vcache *advc,
     afs_uint32 avnoid, auniq;
 
     AFS_STATCNT(EvalMountPoint);
-#ifdef notdef
-    if (avc->mvid.target_root && (avc->f.states & CMValid))
-	return 0;		/* done while racing */
-#endif
     *avolpp = NULL;
     code = afs_HandleLink(avc, areq);
     if (code)
@@ -399,16 +377,16 @@ afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
 
 	    do {
 		retry = 0;
-		ObtainWriteLock(&afs_xvcache, 597);
-		root_vp = afs_FindVCache(tvc->mvid.target_root, &retry, IS_WLOCK);
+		ObtainReadLock(&afs_xvcache);
+		root_vp = afs_FindVCache(tvc->mvid.target_root, &retry, 0);
 		if (root_vp && retry) {
-		    ReleaseWriteLock(&afs_xvcache);
+		    ReleaseReadLock(&afs_xvcache);
 		    afs_PutVCache(root_vp);
 		}
 	    } while (root_vp && retry);
-	    ReleaseWriteLock(&afs_xvcache);
+	    ReleaseReadLock(&afs_xvcache);
 	} else {
-	    root_vp = afs_GetVCache(tvc->mvid.target_root, areq, NULL, NULL);
+	    root_vp = afs_GetVCache(tvc->mvid.target_root, areq);
 	}
 	if (!root_vp) {
 	    code = canblock ? EIO : 0;
@@ -713,6 +691,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
     struct VenusFid dotdot = {0, {0, 0, 0}};
     int flagIndex = 0;		/* First file with bulk fetch flag set */
     struct rx_connection *rxconn;
+    int attempt_i;
     XSTATS_DECLS;
     dotdot.Cell = 0;
     dotdot.Fid.Unique = 0;
@@ -773,7 +752,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
      */
     while ((adp->f.states & CStatd)
 	   && (dcp->dflags & DFFetching)
-	   && hsame(adp->f.m.DataVersion, dcp->f.versionNo)) {
+	   && afs_IsDCacheFresh(dcp, adp)) {
 	afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING,
 		   __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, dcp,
 		   ICL_TYPE_INT32, dcp->dflags);
@@ -784,7 +763,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 	ObtainReadLock(&dcp->lock);
     }
     if (!(adp->f.states & CStatd)
-	|| !hsame(adp->f.m.DataVersion, dcp->f.versionNo)) {
+	|| !afs_IsDCacheFresh(dcp, adp)) {
 	ReleaseReadLock(&dcp->lock);
 	ReleaseReadLock(&adp->lock);
 	afs_PutDCache(dcp);
@@ -806,7 +785,18 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
     /* now we have dir data in the cache, so scan the dir page */
     fidIndex = 0;
     flagIndex = 0;
-    while (1) {			/* Should probably have some constant bound */
+
+    /*
+     * Only examine at most the next 'nentries*4' entries to find dir entries
+     * to stat. This is an arbitrary limit that we set so we don't waste time
+     * scanning an entire dir that contains stat'd entries. For example, if a
+     * dir contains 10k entries, and all or almost all of them are stat'd, then
+     * we'll examine 10k entries for no benefit. For each entry, we run
+     * afs_FindVCache, and grab and release afs_xvcache; doing this e.g. 10k
+     * times can have significant impact if the client is under a lot of load.
+     */
+    for (attempt_i = 0; attempt_i < nentries * 4; attempt_i++) {
+
 	/* look for first safe entry to examine in the directory.  BlobScan
 	 * looks for a the 1st allocated dir after the dirCookie slot.
 	 */
@@ -843,14 +833,15 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 	    tfid.Fid.Unique = ntohl(dirEntryp->fid.vunique);
 	    do {
 		retry = 0;
-		ObtainWriteLock(&afs_xvcache, 130);
-		tvcp = afs_FindVCache(&tfid, &retry, IS_WLOCK /* no stats | LRU */ );
+		ObtainSharedLock(&afs_xvcache, 130);
+		tvcp = afs_FindVCache(&tfid, &retry, IS_SLOCK /* no stats | LRU */ );
 		if (tvcp && retry) {
-		    ReleaseWriteLock(&afs_xvcache);
+		    ReleaseSharedLock(&afs_xvcache);
 		    afs_PutVCache(tvcp);
 		}
 	    } while (tvcp && retry);
 	    if (!tvcp) {	/* otherwise, create manually */
+		UpgradeSToWLock(&afs_xvcache, 129);
 		tvcp = afs_NewBulkVCache(&tfid, hostp, statSeqNo);
 		if (tvcp)
 		{
@@ -874,7 +865,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 		    ReleaseWriteLock(&afs_xvcache);
 		}
 	    } else {
-		ReleaseWriteLock(&afs_xvcache);
+		ReleaseSharedLock(&afs_xvcache);
 	    }
 	    if (!tvcp)
 	    {
@@ -941,7 +932,7 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 	if (temp <= 0)
 	    break;
 	dirCookie += temp;
-    }				/* while loop over all dir entries */
+    }				/* for loop over dir entries */
 
     /* now release the dir lock and prepare to make the bulk RPC */
     ReleaseReadLock(&dcp->lock);
@@ -1116,7 +1107,9 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
 	retry = 1;
     }
 #else
-    osi_vnhold(lruvcp, &retry);
+    if (osi_vnhold(lruvcp) != 0) {
+	retry = 1;
+    }
 #endif
     ReleaseReadLock(&afs_xvcache);	/* could be read lock */
     if (retry)
@@ -1341,13 +1334,49 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
     return code;
 }
 
-/* was: (AFS_DEC_ENV) || defined(AFS_OSF30_ENV) || defined(AFS_NCR_ENV) */
 #ifdef AFS_DARWIN80_ENV
 int AFSDOBULK = 0;
-#else
-static int AFSDOBULK = 1;
 #endif
 
+static int
+afs_ShouldTryBulkStat(struct vcache *adp)
+{
+#ifdef AFS_DARWIN80_ENV
+    if (!AFSDOBULK) {
+	return 0;
+    }
+#endif
+    if (AFS_IS_DISCONNECTED) {
+	/* We can't prefetch entries if we're offline. */
+	return 0;
+    }
+    if (adp->opens < 1) {
+	/* Don't bother prefetching entries if nobody is holding the dir open
+	 * while we're doing a lookup. */
+	return 0;
+    }
+    if (afs_VCacheStressed()) {
+	/* If we already have too many vcaches, don't create more vcaches we
+	 * may not even use. */
+	return 0;
+    }
+    if ((adp->f.states & CForeign)) {
+	/* Don't bulkstat for dfs xlator dirs. */
+	return 0;
+    }
+    if (afs_IsDynroot(adp)) {
+	/* Don't prefetch dynroot entries; that's pointless, since we generate
+	 * those locally. */
+	return 0;
+    }
+    if (afs_InReadDir(adp)) {
+	/* Don't bulkstat if we're in the middle of servicing a readdir() in
+	 * the same process. */
+	return 0;
+    }
+    return 1;
+}
+
 static_inline int
 osi_lookup_isdot(const char *aname)
 {
@@ -1388,6 +1417,11 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     int dynrootRetry = 1;
     struct afs_fakestat_state fakestate;
     int tryEvalOnly = 0;
+
+    /* Don't allow ENOENT errors, except for a specific code path where
+     * 'enoent_prohibited' is cleared below. */
+    int enoent_prohibited = 1;
+
     OSI_VC_CONVERT(adp);
 
     AFS_STATCNT(afs_lookup);
@@ -1453,7 +1487,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	}
 	/* otherwise we have the fid here, so we use it */
 	/*printf("Getting vcache\n");*/
-	tvc = afs_GetVCache(adp->mvid.parent, treq, NULL, NULL);
+	tvc = afs_GetVCache(adp->mvid.parent, treq);
 	afs_Trace3(afs_iclSetp, CM_TRACE_GETVCDOTDOT, ICL_TYPE_FID, adp->mvid.parent,
 		   ICL_TYPE_POINTER, tvc, ICL_TYPE_INT32, code);
 	*avcp = tvc;
@@ -1490,7 +1524,11 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
      */
     if (osi_lookup_isdot(aname)) {	/* special case */
 	ObtainReadLock(&afs_xvcache);
-	osi_vnhold(adp, 0);
+	if (osi_vnhold(adp) != 0) {
+	    ReleaseReadLock(&afs_xvcache);
+	    code = EIO;
+	    goto done;
+	}
 	ReleaseReadLock(&afs_xvcache);
 #ifdef AFS_DARWIN80_ENV
         vnode_get(AFSTOV(adp));
@@ -1512,7 +1550,11 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	aname[0] == '.' && aname[1] == '.' && !aname[2]) {
 
 	ObtainReadLock(&afs_xvcache);
-	osi_vnhold(afs_globalVp, 0);
+	if (osi_vnhold(afs_globalVp) != 0) {
+	    ReleaseReadLock(&afs_xvcache);
+	    code = EIO;
+	    goto done;
+	}
 	ReleaseReadLock(&afs_xvcache);
 #ifdef AFS_DARWIN80_ENV
         vnode_get(AFSTOV(afs_globalVp));
@@ -1549,7 +1591,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	    tfid.Fid.Vnode = VNUM_FROM_TYPEID(VN_TYPE_MOUNT, cellidx << 2);
 	    tfid.Fid.Unique = volid;
 	}
-	*avcp = tvc = afs_GetVCache(&tfid, treq, NULL, NULL);
+	*avcp = tvc = afs_GetVCache(&tfid, treq);
 	code = (tvc ? 0 : EIO);
 	hit = 1;
 	goto done;
@@ -1565,7 +1607,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	struct VenusFid tfid;
 
 	afs_GetDynrootMountFid(&tfid);
-	*avcp = tvc = afs_GetVCache(&tfid, treq, NULL, NULL);
+	*avcp = tvc = afs_GetVCache(&tfid, treq);
 	code = 0;
 	hit = 1;
 	goto done;
@@ -1643,7 +1685,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	if (!afs_InReadDir(adp)) {
 	    while ((adp->f.states & CStatd)
 		   && (tdc->dflags & DFFetching)
-		   && hsame(adp->f.m.DataVersion, tdc->f.versionNo)) {
+		   && afs_IsDCacheFresh(tdc, adp)) {
 		ReleaseReadLock(&tdc->lock);
 		ReleaseReadLock(&adp->lock);
 		afs_osi_Sleep(&tdc->validPos);
@@ -1651,7 +1693,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 		ObtainReadLock(&tdc->lock);
 	    }
 	    if (!(adp->f.states & CStatd)
-		|| !hsame(adp->f.m.DataVersion, tdc->f.versionNo)) {
+		|| !afs_IsDCacheFresh(tdc, adp)) {
 		ReleaseReadLock(&tdc->lock);
 		ReleaseReadLock(&adp->lock);
 		afs_PutDCache(tdc);
@@ -1727,8 +1769,10 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 		   ICL_TYPE_INT32, code);
 
 	if (code) {
-	    if (code != ENOENT) {
-		/*printf("LOOKUP dirLookupOff -> %d\n", code);*/
+	    if (code == ENOENT) {
+		/* The target name really doesn't exist (according to
+		 * afs_dir_LookupOffset, anyway). */
+		enoent_prohibited = 0;
 	    }
 	    goto done;
 	}
@@ -1736,9 +1780,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	/* prefetch some entries, if the dir is currently open.  The variable
 	 * dirCookie tells us where to start prefetching from.
 	 */
-	if (!AFS_IS_DISCONNECTED && 
-	    AFSDOBULK && adp->opens > 0 && !(adp->f.states & CForeign)
-	    && !afs_IsDynroot(adp) && !afs_InReadDir(adp)) {
+	if (afs_ShouldTryBulkStat(adp)) {
 	    afs_int32 retry;
 	    /* if the entry is not in the cache, or is in the cache,
 	     * but hasn't been statd, then do a bulk stat operation.
@@ -1773,12 +1815,11 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	 * the file has not yet been looked up.
 	 */
 	if (!tvc) {
-	    afs_int32 cached = 0;
 	    if (!tfid.Fid.Unique && (adp->f.states & CForeign)) {
-		tvc = afs_LookupVCache(&tfid, treq, &cached, adp, tname);
+		tvc = afs_LookupVCache(&tfid, treq, adp, tname);
 	    }
 	    if (!tvc && !bulkcode) {	/* lookup failed or wasn't called */
-		tvc = afs_GetVCache(&tfid, treq, &cached, NULL);
+		tvc = afs_GetVCache(&tfid, treq);
 	    }
 	}			/* if !tvc */
     }				/* sub-block just to reduce stack usage */
@@ -1838,9 +1879,9 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 		    if (tvolp && (tvolp->states & VForeign)) {
 			/* XXXX tvolp has ref cnt on but not locked! XXX */
 			tvc =
-			    afs_GetRootVCache(tvc->mvid.target_root, treq, NULL, tvolp);
+			    afs_GetRootVCache(tvc->mvid.target_root, treq, tvolp);
 		    } else {
-			tvc = afs_GetVCache(tvc->mvid.target_root, treq, NULL, NULL);
+			tvc = afs_GetVCache(tvc->mvid.target_root, treq);
 		    }
 		    afs_PutVCache(uvc);	/* we're done with it */
 
@@ -1948,6 +1989,16 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	 */
 	*avcp = NULL;
     }
+    if (code == ENOENT && enoent_prohibited) {
+	/*
+	 * We got an ENOENT error, but we didn't get it while looking up the
+	 * dir entry in the relevant dir blob. That means we likely hit some
+	 * other internal error; don't allow us to return ENOENT in this case,
+	 * since some platforms cache ENOENT errors, and the target path name
+	 * may actually exist.
+	 */
+	code = EIO;
+    }
 
     afs_PutFakeStat(&fakestate);
     afs_DestroyReq(treq);
diff --git a/src/afs/VNOPS/afs_vnop_read.c b/src/afs/VNOPS/afs_vnop_read.c
index 1b1c682f5..e5c664207 100644
--- a/src/afs/VNOPS/afs_vnop_read.c
+++ b/src/afs/VNOPS/afs_vnop_read.c
@@ -190,7 +190,7 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
 	     * 2 requests never return a null dcache entry, btw.
 	     */
 	    if (!(tdc->dflags & DFFetching)
-		&& !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+		&& !afs_IsDCacheFresh(tdc, avc)) {
 		/* have cache entry, it is not coming in now,
 		 * and we'll need new data */
 	      tagain:
@@ -270,7 +270,7 @@ afs_read(struct vcache *avc, struct uio *auio, afs_ucred_t *acred,
 	    } else {
 		/* no longer fetching, verify data version 
 		 * (avoid new GetDCache call) */
-		if (hsame(avc->f.m.DataVersion, tdc->f.versionNo)
+		if (afs_IsDCacheFresh(tdc, avc)
 		    && ((len = tdc->validPos - filePos) > 0)) {
 		    offset = filePos - AFS_CHUNKTOBASE(tdc->f.chunk);
 		} else {
@@ -486,7 +486,7 @@ afs_UFSReadUIO(afs_dcache_id_t *cacheId, struct uio *tuiop)
 
     tfile = (struct osi_file *) osi_UFSOpen(cacheId);
     if (!tfile)
-	return -1;
+	return EIO;
 
 #if defined(AFS_AIX41_ENV)
     AFS_GUNLOCK();
@@ -562,18 +562,12 @@ afs_UFSReadUIO(afs_dcache_id_t *cacheId, struct uio *tuiop)
     code = VOP_READ(tfile->vnode, tuiop, 0, afs_osi_credp);
     VOP_UNLOCK(tfile->vnode, 0, current_proc());
     AFS_GLOCK();
-#elif defined(AFS_FBSD80_ENV)
+#elif defined(AFS_FBSD_ENV)
     AFS_GUNLOCK();
     VOP_LOCK(tfile->vnode, LK_EXCLUSIVE);
     code = VOP_READ(tfile->vnode, tuiop, 0, afs_osi_credp);
     VOP_UNLOCK(tfile->vnode, 0);
     AFS_GLOCK();
-#elif defined(AFS_FBSD_ENV)
-    AFS_GUNLOCK();
-    VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread);
-    code = VOP_READ(tfile->vnode, tuiop, 0, afs_osi_credp);
-    VOP_UNLOCK(tfile->vnode, 0, curthread);
-    AFS_GLOCK();
 #elif defined(AFS_NBSD_ENV)
     tuiop->uio_rw = UIO_READ;
     AFS_GUNLOCK();
diff --git a/src/afs/VNOPS/afs_vnop_readdir.c b/src/afs/VNOPS/afs_vnop_readdir.c
index 9efe8eb5a..7bfc629f8 100644
--- a/src/afs/VNOPS/afs_vnop_readdir.c
+++ b/src/afs/VNOPS/afs_vnop_readdir.c
@@ -692,7 +692,7 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
      */
     while ((avc->f.states & CStatd)
 	   && (tdc->dflags & DFFetching)
-	   && hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+	   && afs_IsDCacheFresh(tdc, avc)) {
 	afs_Trace4(afs_iclSetp, CM_TRACE_DCACHEWAIT, ICL_TYPE_STRING,
 		   __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_POINTER, tdc,
 		   ICL_TYPE_INT32, tdc->dflags);
@@ -703,7 +703,7 @@ afs_readdir(OSI_VC_DECL(avc), struct uio *auio, afs_ucred_t *acred)
 	ObtainReadLock(&tdc->lock);
     }
     if (!(avc->f.states & CStatd)
-	|| !hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+	|| !afs_IsDCacheFresh(tdc, avc)) {
 	ReleaseReadLock(&tdc->lock);
 	ReleaseReadLock(&avc->lock);
 	afs_PutDCache(tdc);
diff --git a/src/afs/VNOPS/afs_vnop_remove.c b/src/afs/VNOPS/afs_vnop_remove.c
index f1e1fafae..4ab3eb65f 100644
--- a/src/afs/VNOPS/afs_vnop_remove.c
+++ b/src/afs/VNOPS/afs_vnop_remove.c
@@ -235,7 +235,7 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
      * received a callback while we were waiting for the write lock.
      */
     if (!(adp->f.states & CStatd)
-	|| (tdc && !hsame(adp->f.m.DataVersion, tdc->f.versionNo))) {
+	|| (tdc && !afs_IsDCacheFresh(tdc, adp))) {
 	ReleaseWriteLock(&adp->lock);
 	if (tdc) {
 	    ReleaseSharedLock(&tdc->lock);
@@ -255,13 +255,11 @@ afs_remove(OSI_VC_DECL(adp), char *aname, afs_ucred_t *acred)
 	if (tdc) {
 	    code = afs_dir_Lookup(tdc, aname, &unlinkFid.Fid);
 	    if (code == 0) {
-		afs_int32 cached = 0;
-
 		unlinkFid.Cell = adp->f.fid.Cell;
 		unlinkFid.Fid.Volume = adp->f.fid.Fid.Volume;
 		if (unlinkFid.Fid.Unique == 0) {
 		    tvc =
-			afs_LookupVCache(&unlinkFid, treq, &cached, adp,
+			afs_LookupVCache(&unlinkFid, treq, adp,
 					 aname);
 		} else {
 		    ObtainReadLock(&afs_xvcache);
@@ -423,7 +421,7 @@ afs_remunlink(struct vcache *avc, int doit)
 #if defined(AFS_DARWIN_ENV) && !defined(AFS_DARWIN80_ENV)
 	    VREF(AFSTOV(avc));
 #else
-	    AFS_FAST_HOLD(avc);
+	    osi_Assert(osi_vnhold(avc) == 0);
 #endif
 
 	    /* We'll only try this once. If it fails, just release the vnode.
@@ -437,7 +435,7 @@ afs_remunlink(struct vcache *avc, int doit)
 	    dirFid.Fid.Volume = avc->f.fid.Fid.Volume;
 	    dirFid.Fid.Vnode = avc->f.parent.vnode;
 	    dirFid.Fid.Unique = avc->f.parent.unique;
-	    adp = afs_GetVCache(&dirFid, treq, NULL, NULL);
+	    adp = afs_GetVCache(&dirFid, treq);
 
 	    if (adp) {
 		tdc = afs_FindDCache(adp, (afs_size_t) 0);
diff --git a/src/afs/VNOPS/afs_vnop_rename.c b/src/afs/VNOPS/afs_vnop_rename.c
index 2d4b9c185..f899d31c3 100644
--- a/src/afs/VNOPS/afs_vnop_rename.c
+++ b/src/afs/VNOPS/afs_vnop_rename.c
@@ -135,7 +135,7 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
      */
     if (tdc1) {
 	if (!(aodp->f.states & CStatd)
-	    || !hsame(aodp->f.m.DataVersion, tdc1->f.versionNo)) {
+	    || !afs_IsDCacheFresh(tdc1, aodp)) {
 
 	    ReleaseWriteLock(&aodp->lock);
 	    if (!oneDir) {
@@ -361,10 +361,10 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
 	unlinkFid.Cell = aodp->f.fid.Cell;
 	tvc = NULL;
 	if (!unlinkFid.Fid.Unique) {
-	    tvc = afs_LookupVCache(&unlinkFid, areq, NULL, aodp, aname1);
+	    tvc = afs_LookupVCache(&unlinkFid, areq, aodp, aname1);
 	}
 	if (!tvc)		/* lookup failed or wasn't called */
-	    tvc = afs_GetVCache(&unlinkFid, areq, NULL, NULL);
+	    tvc = afs_GetVCache(&unlinkFid, areq);
 
 	if (tvc) {
 	    ObtainWriteLock(&tvc->lock, 151);
@@ -392,9 +392,9 @@ afsrename(struct vcache *aodp, char *aname1, struct vcache *andp,
 	fileFid.Fid.Volume = aodp->f.fid.Fid.Volume;
 	fileFid.Cell = aodp->f.fid.Cell;
 	if (!fileFid.Fid.Unique)
-	    tvc = afs_LookupVCache(&fileFid, areq, NULL, andp, aname2);
+	    tvc = afs_LookupVCache(&fileFid, areq, andp, aname2);
 	else
-	    tvc = afs_GetVCache(&fileFid, areq, NULL, (struct vcache *)0);
+	    tvc = afs_GetVCache(&fileFid, areq);
 	if (tvc && (vType(tvc) == VDIR)) {
 	    ObtainWriteLock(&tvc->lock, 152);
 	    tdc1 = afs_FindDCache(tvc, (afs_size_t) 0);
diff --git a/src/afs/VNOPS/afs_vnop_strategy.c b/src/afs/VNOPS/afs_vnop_strategy.c
index 97b699310..978df8858 100644
--- a/src/afs/VNOPS/afs_vnop_strategy.c
+++ b/src/afs/VNOPS/afs_vnop_strategy.c
@@ -208,10 +208,8 @@ int afs_ustrategy(struct buf *abp)
 
 #if defined(AFS_AIX32_ENV)
     crfree(credp);
-#elif defined(AFS_FBSD60_ENV)
-    (*abp->b_iodone)(abp);
 #elif defined(AFS_FBSD_ENV)
-    biodone(&abp->b_io);
+    (*abp->b_iodone)(abp);
 #elif defined(AFS_NBSD40_ENV)
     abp->b_resid = tuio.uio_resid;
     biodone(abp);
diff --git a/src/afs/VNOPS/afs_vnop_symlink.c b/src/afs/VNOPS/afs_vnop_symlink.c
index 1dd461125..e88e09ecc 100644
--- a/src/afs/VNOPS/afs_vnop_symlink.c
+++ b/src/afs/VNOPS/afs_vnop_symlink.c
@@ -43,6 +43,7 @@ afs_DisconCreateSymlink(struct vcache *avc, char *aname,
     struct dcache *tdc;
     struct osi_file *tfile;
     afs_size_t offset, len;
+    int code = 0;
 
     tdc = afs_GetDCache(avc, 0, areq, &offset, &len, 0);
     if (!tdc) {
@@ -54,13 +55,18 @@ afs_DisconCreateSymlink(struct vcache *avc, char *aname,
     avc->f.m.Length = len;
 
     ObtainWriteLock(&tdc->lock, 720);
+    tfile = afs_CFileOpen(&tdc->f.inode);
+    if (!tfile) {
+	code = EIO;
+	goto done;
+    }
     afs_AdjustSize(tdc, len);
     tdc->validPos = len;
-    tfile = afs_CFileOpen(&tdc->f.inode);
     afs_CFileWrite(tfile, 0, aname, len);
     afs_CFileClose(tfile);
+ done:
     ReleaseWriteLock(&tdc->lock);
-    return 0;
+    return code;
 }
 
 /* don't set CDirty in here because RPC is called synchronously */
diff --git a/src/afs/VNOPS/afs_vnop_write.c b/src/afs/VNOPS/afs_vnop_write.c
index be6c63adf..32d69f4da 100644
--- a/src/afs/VNOPS/afs_vnop_write.c
+++ b/src/afs/VNOPS/afs_vnop_write.c
@@ -105,7 +105,7 @@ afs_UFSWriteUIO(struct vcache *avc, afs_dcache_id_t *inode, struct uio *tuiop)
 
     tfile = (struct osi_file *)osi_UFSOpen(inode);
     if (!tfile)
-	return -1;
+	return EIO;
 
 #if defined(AFS_AIX41_ENV)
     AFS_GUNLOCK();
@@ -130,8 +130,7 @@ afs_UFSWriteUIO(struct vcache *avc, afs_dcache_id_t *inode, struct uio *tuiop)
 # endif
     AFS_GLOCK();
     if (code == ENOSPC)
-	afs_warnuser
-	    ("\n\n\n*** Cache partition is full - decrease cachesize!!! ***\n\n\n");
+        afs_WarnENOSPC();
 #elif defined(AFS_SGI_ENV)
     AFS_GUNLOCK();
     avc->f.states |= CWritingUFS;
@@ -160,18 +159,12 @@ afs_UFSWriteUIO(struct vcache *avc, afs_dcache_id_t *inode, struct uio *tuiop)
     code = VOP_WRITE(tfile->vnode, tuiop, 0, afs_osi_credp);
     VOP_UNLOCK(tfile->vnode, 0, current_proc());
     AFS_GLOCK();
-#elif defined(AFS_FBSD80_ENV)
+#elif defined(AFS_FBSD_ENV)
     AFS_GUNLOCK();
     VOP_LOCK(tfile->vnode, LK_EXCLUSIVE);
     code = VOP_WRITE(tfile->vnode, tuiop, 0, afs_osi_credp);
     VOP_UNLOCK(tfile->vnode, 0);
     AFS_GLOCK();
-#elif defined(AFS_FBSD_ENV)
-    AFS_GUNLOCK();
-    VOP_LOCK(tfile->vnode, LK_EXCLUSIVE, curthread);
-    code = VOP_WRITE(tfile->vnode, tuiop, 0, afs_osi_credp);
-    VOP_UNLOCK(tfile->vnode, 0, curthread);
-    AFS_GLOCK();
 #elif defined(AFS_NBSD_ENV)
     AFS_GUNLOCK();
     VOP_LOCK(tfile->vnode, LK_EXCLUSIVE);
@@ -303,9 +296,16 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 #else
     afs_FakeOpen(avc);
 #endif
-    avc->f.states |= CDirty;
 
     while (totalLength > 0) {
+	/*
+	 * Note that we must set CDirty for every iteration of this loop.
+	 * CDirty may get cleared below (such as during afs_DoPartialStore),
+	 * but we're still writing to the file, so make sure CDirty is set
+	 * here.
+	 */
+	avc->f.states |= CDirty;
+
 	tdc = afs_ObtainDCacheForWriting(avc, filePos, totalLength, treq,
 					 noLock);
 	if (!tdc) {
@@ -335,6 +335,7 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 	    error = code;
 	    ZapDCE(tdc);	/* bad data */
 	    cfile = afs_CFileOpen(&tdc->f.inode);
+            osi_Assert(cfile);
 	    afs_CFileTruncate(cfile, 0);
 	    afs_CFileClose(cfile);
 	    afs_AdjustSize(tdc, 0);	/* sets f.chunkSize to 0 */
@@ -628,7 +629,7 @@ afs_close(OSI_VC_DECL(avc), afs_int32 aflags, afs_ucred_t *acred)
 	    code_checkcode = avc->vc_error;
 	    avc->vc_error = 0;
 	}
-#if defined(AFS_FBSD80_ENV)
+#if defined(AFS_FBSD_ENV)
         /* XXX */
         if (!avc->opens) {
             afs_int32 opens, is_free, is_gone, is_doomed, iflag;
diff --git a/src/afs/afs.h b/src/afs/afs.h
index d94f32825..407eb8902 100644
--- a/src/afs/afs.h
+++ b/src/afs/afs.h
@@ -46,14 +46,19 @@ extern enum afs_shutdown_state afs_shuttingdown;
  * Macros to uniquely identify the AFS vfs struct
  */
 #define	AFS_VFSMAGIC		0x1234
-#if defined(AFS_SUN5_ENV) || defined(AFS_HPUX90_ENV) || defined(AFS_LINUX20_ENV)
-#define	AFS_VFSFSID		99
-#else
-#if defined(AFS_SGI_ENV)
-#define AFS_VFSFSID		afs_fstype
+
+#if defined(UKERNEL)
+# if defined(AFS_USR_AIX_ENV) || defined(AFS_USR_SGI_ENV)
+#  define AFS_VFSFSID		AFS_MOUNT_AFS
+# else
+#  define AFS_VFSFSID		99
+# endif
+#elif defined(AFS_SUN5_ENV) || defined(AFS_HPUX90_ENV) || defined(AFS_LINUX20_ENV)
+# define AFS_VFSFSID		99
+#elif defined(AFS_SGI_ENV)
+# define AFS_VFSFSID		afs_fstype
 #else
-#define	AFS_VFSFSID		AFS_MOUNT_AFS
-#endif
+# define AFS_VFSFSID		AFS_MOUNT_AFS
 #endif
 /* use this value for reporting total space, free space, etc.
  * fake a high number to satisfy programs that use the statfs call to make sure
@@ -104,6 +109,8 @@ extern enum afs_shutdown_state afs_shuttingdown;
 
 #define AFS_MAXCBRSCALL	32	/* max to return in a given call (must be <= AFSCBMAX) */
 #define	VCACHE_FREE	5
+#define VCACHE_DYNAMIC_STRESSED 10000
+#define VCACHE_STRESS_LOGINTERVAL (60*60*4) /* 4 hours */
 #define	AFS_NRXPACKETS	80
 #define	AFS_RXDEADTIME	50
 #define AFS_HARDDEADTIME	120
@@ -148,6 +155,7 @@ struct sysname_info {
 #define	BOP_MOVE	5	 /* ptr1 afs_uspc_param ptr2 sname ptr3 dname */
 #endif
 #define BOP_PARTIAL_STORE 6     /* parm1 is chunk to store */
+#define BOP_INVALIDATE_SEGMENTS 7 /* no parms: just uses the 'bp->vc' vcache */
 
 #define	B_DONTWAIT	1	/* On failure return; don't wait */
 
@@ -190,7 +198,7 @@ struct VenusFid {
     struct AFSFid Fid;
 };
 
-/* Temporary struct to be passed between afs_fid and afs_vget; in SunOS4.x we can only pass a maximum of 10 bytes for a handle (we ideally need 16!) */
+/* Temporary struct to be passed between afs_fid and afs_vget */
 struct SmallFid {
     afs_int32 Volume;
     afs_int32 CellAndUnique;
@@ -641,7 +649,7 @@ struct SimpleLocks {
 #define CCore		0x00000010	/* storing a core file, needed since we don't get an open */
 #define CDirty		0x00000020	/* file has been modified since first open (... O_RDWR) */
 #define CSafeStore	0x00000040	/* close must wait for store to finish (should be in fd) */
-#define CMAPPED		0x00000080	/* Mapped files; primarily used by SunOS 4.0.x */
+#define CMAPPED		0x00000080	/* Mapped files */
 #define CNSHARE		0x00000100	/* support O_NSHARE semantics */
 #define CLied		0x00000200
 #define CTruth		0x00000400
@@ -716,6 +724,8 @@ struct SimpleLocks {
 #define	CPSIZE	    2
 #if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV)
 #define vrefCount   v->v_usecount
+#elif defined(AFS_SUN511_ENV)
+# define vrefCount v->v_count
 #else
 #define vrefCount   v.v_count
 #endif /* AFS_XBSD_ENV */
@@ -763,7 +773,7 @@ struct nbvdata {
 };
 #define VTOAFS(v) ((((struct nbvdata *)((v)->v_data)))->afsvc)
 #define AFSTOV(vc) ((vc)->v)
-#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
+#elif defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_SUN511_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
 #define VTOAFS(v) ((struct vcache *)(v)->v_data)
 #define AFSTOV(vc) ((vc)->v)
 #else
@@ -837,7 +847,7 @@ struct multiPage_range {
  * !(avc->nextfree) && !avc->vlruq.next => (FreeVCList == avc->nextfree)
  */
 struct vcache {
-#if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
+#if defined(AFS_XBSD_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_SUN511_ENV) || (defined(AFS_LINUX22_ENV) && !defined(STRUCT_SUPER_OPERATIONS_HAS_ALLOC_INODE))
     struct vnode *v;
 #else
     struct vnode v;		/* Has reference count in v.v_count */
@@ -1327,7 +1337,7 @@ struct afs_FetchOutput {
 	avc->f.states |= CCore;	/* causes close to be called later */ \
                                                                       \
 	/* The cred and vnode holds will be released in afs_FlushActiveVcaches */  \
-	AFS_FAST_HOLD(avc);	/* So it won't disappear */           \
+	osi_Assert(osi_vnhold(avc) == 0);	/* So it won't disappear */        \
 	CRKEEP(avc, acred); /* Should use a better place for the creds */ \
     }                                                                         \
     else {                                                                    \
@@ -1339,7 +1349,6 @@ struct afs_FetchOutput {
 
 #define	AFS_ZEROS   64		/* zero buffer */
 
-/*#define afs_DirtyPages(avc)	(((avc)->f.states & CDirty) || osi_VMDirty_p((avc)))*/
 #define	afs_DirtyPages(avc)	((avc)->f.states & CDirty)
 
 #define afs_InReadDir(avc) (((avc)->f.states & CReadDir) && (avc)->readdir_pid == MyPidxx2Pid(MyPidxx))
@@ -1398,10 +1407,6 @@ extern struct brequest afs_brs[NBRS];	/* request structures */
 #define AFS_VOLCHECK_MTPTS	0x4	/* mount point invalidation also */
 #define AFS_VOLCHECK_FORCE	0x8	/* do all forcibly */
 
-/* For volume ttl expiry checks. */
-#define AFS_MIN_VOLUME_TTL 600
-#define AFS_MAX_VOLUME_TTL MAX_AFS_INT32
-
 #endif /* KERNEL */
 
 #define	AFS_FSPORT	    ((unsigned short) htons(7000))
@@ -1594,7 +1599,7 @@ extern int Afs_syscall(struct afssysa *uap, rval_t *rvp);
 
 /*
  * Various definitions for osi_sleep and its event hash table
- * DFBSD and SUNOS have no osi_sleep, and HPUX has its own hack for this stuff
+ * DFBSD has no osi_sleep, and HPUX has its own hack for this stuff
  */
 #define AFS_EVHASHSIZE	128	/* size of afs_evhasht, must be power of 2 */
 
diff --git a/src/afs/afs_buffer.c b/src/afs/afs_buffer.c
index 2220ae301..1f2a4706a 100644
--- a/src/afs/afs_buffer.c
+++ b/src/afs/afs_buffer.c
@@ -231,24 +231,29 @@ DRead(struct dcache *adc, int page, struct DirBuffer *entry)
     ObtainWriteLock(&tb->lock, 260);
     tb->lockers++;
     ReleaseWriteLock(&afs_bufferLock);
-    if (page * AFS_BUFFER_PAGESIZE >= adc->f.chunkBytes) {
-	tb->fid = NULLIDX;
-	afs_reset_inode(&tb->inode);
-	tb->lockers--;
-	ReleaseWriteLock(&tb->lock);
-	return ENOENT; /* past the end */
+    code = 0;
+    if (adc->f.chunk == 0 && adc->f.chunkBytes == 0) {
+        /* The directory blob is empty, apparently. This is not a valid dir
+         * blob, so throw an error. */
+        code = EIO;
+	goto error;
+    } else if (page * AFS_BUFFER_PAGESIZE >= adc->f.chunkBytes) {
+        code = ENOENT; /* past the end */
+	goto error;
     }
+
     tfile = afs_CFileOpen(&adc->f.inode);
+    if (!tfile) {
+	code = EIO;
+	goto error;
+    }
     code =
 	afs_CFileRead(tfile, tb->page * AFS_BUFFER_PAGESIZE, tb->data,
 		      AFS_BUFFER_PAGESIZE);
     afs_CFileClose(tfile);
     if (code < AFS_BUFFER_PAGESIZE) {
-	tb->fid = NULLIDX;
-	afs_reset_inode(&tb->inode);
-	tb->lockers--;
-	ReleaseWriteLock(&tb->lock);
-	return EIO;
+	code = EIO;
+	goto error;
     }
     /* Note that findslot sets the page field in the buffer equal to
      * what it is searching for. */
@@ -256,6 +261,13 @@ DRead(struct dcache *adc, int page, struct DirBuffer *entry)
     entry->buffer = tb;
     entry->data = tb->data;
     return 0;
+
+ error:
+    tb->fid = NULLIDX;
+    afs_reset_inode(&tb->inode);
+    tb->lockers--;
+    ReleaseWriteLock(&tb->lock);
+    return code;
 }
 
 static void
@@ -372,6 +384,9 @@ afs_newslot(struct dcache *adc, afs_int32 apage, struct buffer *lp)
     if (lp->dirty) {
 	/* see DFlush for rationale for not getting and locking the dcache */
         tfile = afs_CFileOpen(&lp->inode);
+	if (!tfile)
+	    return NULL;    /* Callers will flag as EIO */
+
 	afs_CFileWrite(tfile, lp->page * AFS_BUFFER_PAGESIZE, lp->data,
 		       AFS_BUFFER_PAGESIZE);
 	lp->dirty = 0;
@@ -461,6 +476,7 @@ DFlushBuffer(struct buffer *ab)
     struct osi_file *tfile;
 
     tfile = afs_CFileOpen(&ab->inode);
+    osi_Assert(tfile);
     afs_CFileWrite(tfile, ab->page * AFS_BUFFER_PAGESIZE,
 		   ab->data, AFS_BUFFER_PAGESIZE);
     ab->dirty = 0;	/* Clear the dirty flag */
@@ -572,17 +588,20 @@ shutdown_bufferpackage(void)
     AFS_STATCNT(shutdown_bufferpackage);
     /* Free all allocated Buffers and associated buffer pages */
     DFlush();
+
+    dinit_flag = 0;
+    tp = Buffers;
+    for (i = 0; i < nbuffers; i += NPB, tp += NPB) {
+	afs_osi_Free(tp->data, NPB * AFS_BUFFER_PAGESIZE);
+    }
+    afs_osi_Free(Buffers, nbuffers * sizeof(struct buffer));
+    Buffers = NULL;
+    nbuffers = 0;
+    timecounter = 1;
+    for (i = 0; i < PHSIZE; i++)
+	phTable[i] = NULL;
+
     if (afs_cold_shutdown) {
-	dinit_flag = 0;
-	tp = Buffers;
-	for (i = 0; i < nbuffers; i += NPB, tp += NPB) {
-	    afs_osi_Free(tp->data, NPB * AFS_BUFFER_PAGESIZE);
-	}
-	afs_osi_Free(Buffers, nbuffers * sizeof(struct buffer));
-	nbuffers = 0;
-	timecounter = 1;
-	for (i = 0; i < PHSIZE; i++)
-	    phTable[i] = 0;
 	memset(&afs_bufferLock, 0, sizeof(afs_lock_t));
     }
 }
diff --git a/src/afs/afs_bypasscache.c b/src/afs/afs_bypasscache.c
index 76973d9c7..64da1ed19 100644
--- a/src/afs/afs_bypasscache.c
+++ b/src/afs/afs_bypasscache.c
@@ -614,7 +614,9 @@ afs_PrefetchNoCache(struct vcache *avc,
 	    } else {
 		afs_warn("BYPASS: StartRXAFS_FetchData failed: %d\n", code);
 		unlock_and_release_pages(auio);
-		afs_PutConn(tc, rxconn, SHARED_LOCK);
+		(void)afs_Analyze(tc, rxconn, code, &avc->f.fid, areq,
+				  AFS_STATS_FS_RPCIDX_FETCHDATA,
+				  SHARED_LOCK, NULL);
 		goto done;
 	    }
 	    if (code == 0) {
@@ -629,6 +631,9 @@ afs_PrefetchNoCache(struct vcache *avc,
 	    afs_warn("BYPASS: No connection.\n");
 	    code = -1;
 	    unlock_and_release_pages(auio);
+	    (void)afs_Analyze(tc, rxconn, code, &avc->f.fid, areq,
+			      AFS_STATS_FS_RPCIDX_FETCHDATA,
+			      SHARED_LOCK, NULL);
 	    goto done;
 	}
     } while (afs_Analyze(tc, rxconn, code, &avc->f.fid, areq,
@@ -642,7 +647,7 @@ done:
     if (!code)
 	afs_ProcessFS(avc, &tcallspec->OutStatus, areq);
 
-    osi_Free(areq, sizeof(struct vrequest));
+    afs_DestroyReq(areq);
     osi_Free(tcallspec, sizeof(struct tlocal1));
     osi_Free(bparms, sizeof(struct nocache_read_request));
 #ifndef UKERNEL
diff --git a/src/afs/afs_call.c b/src/afs/afs_call.c
index bec71c4d1..44bdcbe51 100644
--- a/src/afs/afs_call.c
+++ b/src/afs/afs_call.c
@@ -99,6 +99,7 @@ static int
 afs_InitSetup(int preallocs)
 {
     int code;
+    afs_uint32 host;
 
     if (afs_InitSetup_done)
 	return EAGAIN;
@@ -127,6 +128,14 @@ afs_InitSetup(int preallocs)
     /* start RX */
     if(!afscall_set_rxpck_received)
     rx_extraPackets = AFS_NRXPACKETS;	/* smaller # of packets */
+
+    host = ntohl(rx_bindhost);
+    afs_warn("afs: Binding rx to %d.%d.%d.%d:%d\n",
+             (host >> 24),
+             (host >> 16) & 0xff,
+             (host >>  8) & 0xff,
+             (host)       & 0xff,
+             7001);
     code = rx_InitHost(rx_bindhost, htons(7001));
     if (code) {
 	afs_warn("AFS: RX failed to initialize %d).\n", code);
@@ -697,6 +706,7 @@ afs_syscall_call(long parm, long parm2, long parm3,
 	if (!code) {
 	    mvParam->retval = 0;
 	    /* for reqs where pointers are strings: */
+#  ifdef AFS_DARWIN_ENV
 	    if (mvParam->reqtype == AFS_USPC_UMV) {
 		/* don't copy out random kernel memory */
 		AFS_COPYOUT(param2, AFSKPTR(parm4),
@@ -704,6 +714,7 @@ afs_syscall_call(long parm, long parm2, long parm3,
 		AFS_COPYOUT(param1, AFSKPTR(parm3),
 			    MIN(namebufsz, strlen((char *)param1)+1), code);
 	    }
+#  endif /* AFS_DARWIN_ENV */
 	    AFS_COPYOUT((caddr_t)mvParam, AFSKPTR(parm2),
 		       sizeof(struct afs_uspc_param), code);
 	}
@@ -1278,8 +1289,14 @@ afs_syscall_call(long parm, long parm2, long parm3,
     else if (parm == AFSOP_SET_DYNROOT) {
 	code = afs_SetDynrootEnable(parm2);
     } else if (parm == AFSOP_SET_FAKESTAT) {
-	afs_fakestat_enable = parm2;
-	code = 0;
+	if (parm2 >= 0 && parm2 <= 2) {
+	    afs_fakestat_enable = parm2;
+	    code = 0;
+	} else {
+	    afs_warn("afs: afsd gave us unknown fakestat value %ld (are afsd "
+	             "and libafs running the same version?\n", parm2);
+	    code = EINVAL;
+	}
     } else if (parm == AFSOP_SET_BACKUPTREE) {
 	afs_bkvolpref = parm2;
     } else if (parm == AFSOP_SET_RXPCK) {
@@ -1321,7 +1338,7 @@ afs_syscall_call(long parm, long parm2, long parm3,
 	}
     } else if (parm == AFSOP_SET_VOLUME_TTL) {
 	if ((parm2 < AFS_MIN_VOLUME_TTL) || (parm2 > AFS_MAX_VOLUME_TTL)) {
-	    code = EINVAL;
+	    code = EFAULT;
 	} else {
 	    afs_volume_ttl = parm2;
 	    code = 0;
@@ -1503,6 +1520,7 @@ afs_shutdown(void)
     shutdown_nfsclnt();
 #endif
     shutdown_afstest();
+    shutdown_dynroot();
     shutdown_AFS();
     /* The following hold the cm stats */
     memset(&afs_cmstats, 0, sizeof(struct afs_CMStats));
diff --git a/src/afs/afs_callback.c b/src/afs/afs_callback.c
index 61b2a75b7..73e9cfd6a 100644
--- a/src/afs/afs_callback.c
+++ b/src/afs/afs_callback.c
@@ -52,10 +52,6 @@ static struct ltable {
     "afs_xcbhash", (char *)&afs_xcbhash}, {
     "afs_xaxs", (char *)&afs_xaxs}, {
     "afs_xinterface", (char *)&afs_xinterface},
-#ifndef UKERNEL
-    {
-    "afs_xosi", (char *)&afs_xosi},
-#endif
     {
       "afs_xsrvAddr", (char *)&afs_xsrvAddr},
     {
@@ -70,7 +66,7 @@ static struct ltable {
 };
 unsigned long lastCallBack_vnode;
 unsigned int lastCallBack_dv;
-osi_timeval_t lastCallBack_time;
+osi_timeval32_t lastCallBack_time;
 
 /* these are for storing alternate interface addresses */
 struct interfaceAddr afs_cb_interface;
@@ -306,6 +302,7 @@ SRXAFSCB_GetLock(struct rx_call *a_call, afs_int32 a_index,
     XSTATS_START_CMTIME(AFS_STATS_CM_RPCIDX_GETLOCK);
 
     AFS_STATCNT(SRXAFSCB_GetLock);
+    memset(a_result, 0, sizeof(*a_result));
     nentries = sizeof(ltable) / sizeof(struct ltable);
     if (a_index < 0 || a_index >= nentries+afs_cellindex) {
 	/*
@@ -450,9 +447,6 @@ loop1:
 			    afs_osi_Sleep(&tvc->f.states);
 			    goto loop1;
 			}
-#if     defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
-			AFS_FAST_HOLD(tvc);
-#else
 #ifdef AFS_DARWIN80_ENV
 			if (tvc->f.states & CDeadVnode) {
 			    ReleaseReadLock(&afs_xvcache);
@@ -469,8 +463,9 @@ loop1:
 			    continue;
 			}
 #else
-			AFS_FAST_HOLD(tvc);
-#endif
+			if (osi_vnhold(tvc) != 0) {
+			    continue;
+			}
 #endif
 			ReleaseReadLock(&afs_xvcache);
 			afs_StaleVCacheFlags(tvc, 0, CUnique | CBulkFetching);
@@ -533,9 +528,6 @@ loop2:
 			afs_osi_Sleep(&tvc->f.states);
 			goto loop2;
 		    }
-#if     defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV)  || defined(AFS_HPUX_ENV) || defined(AFS_LINUX20_ENV)
-		    AFS_FAST_HOLD(tvc);
-#else
 #ifdef AFS_DARWIN80_ENV
 		    if (tvc->f.states & CDeadVnode) {
 			ReleaseReadLock(&afs_xvcache);
@@ -552,8 +544,9 @@ loop2:
 			continue;
 		    }
 #else
-		    AFS_FAST_HOLD(tvc);
-#endif
+		    if (osi_vnhold(tvc) != 0) {
+			continue;
+		    }
 #endif
 		    ReleaseReadLock(&afs_xvcache);
 		    afs_StaleVCacheFlags(tvc, 0, CUnique | CBulkFetching);
@@ -563,7 +556,7 @@ loop2:
 #ifdef CBDEBUG
 		    lastCallBack_vnode = afid->Vnode;
 		    lastCallBack_dv = tvc->mstat.DataVersion.low;
-		    osi_GetuTime(&lastCallBack_time);
+		    osi_GetTime(&lastCallBack_time);
 #endif /* CBDEBUG */
 #ifdef AFS_DARWIN80_ENV
 		    vnode_put(AFSTOV(tvc));
@@ -1618,6 +1611,7 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
     ObtainReadLock(&afs_xinterface);
 
     /* return all network interface addresses */
+    memset(addr, 0, sizeof(*addr));
     addr->numberOfInterfaces = afs_cb_interface.numberOfInterfaces;
     addr->uuid = afs_cb_interface.uuid;
     for (i = 0; i < afs_cb_interface.numberOfInterfaces; i++) {
@@ -1641,135 +1635,12 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call *a_call,
 }
 
 
-#if 0 && defined(AFS_LINUX24_ENV)
-extern struct vcache *afs_globalVp;
-
-int recurse_dcache_parent(parent, a_index, addr, inode, flags, time, fileName)
-     struct dentry * parent;
-    afs_int32 a_index;
-    afs_int32 *addr;
-    afs_int32 *inode;
-    afs_int32 *flags;
-    afs_int32 *time;
-    char ** fileName;
-{
-	struct dentry *this_parent = parent;
-	struct list_head *next;
-	int found = 0;
-	struct dentry *dentry;
-
-repeat:
-	next = this_parent->d_subdirs.next;
-resume:
-	while (next != &this_parent->d_subdirs) {
-		struct list_head *tmp = next;
-		dentry = list_entry(tmp, struct dentry, d_child);
-		if (a_index == 0)
-		  goto searchdone3;
-		a_index--;
-		next = tmp->next;
-		/*
-		 * Descend a level if the d_subdirs list is non-empty.
-		 */
-		if (!list_empty(&dentry->d_subdirs)) {
-			this_parent = dentry;
-			goto repeat;
-		}
-	}
-	/*
-	 * All done at this level ... ascend and resume the search.
-	 */
-	if (this_parent != parent) {
-		next = this_parent->d_child.next;
-		this_parent = this_parent->d_parent;
-		goto resume;
-	}
-	goto ret;
-
- searchdone3:
-    if (d_unhashed(dentry))
-      *flags = 1;
-    else
-      *flags = 0;
-
-    *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:"");
-    *inode = ITOAFS(dentry->d_inode);
-    *addr = atomic_read(&(dentry)->d_count);
-    *time = dentry->d_time;
-
-    return 0;
- ret:
-    return 1;
-}
-#endif
-
 int
 SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index, afs_int32 *addr,
 	       afs_int32 *inode, afs_int32 *flags, afs_int32 *time,
 	       char ** fileName)
 { /*SRXAFSCB_GetDE*/
     int code = 0;				/*Return code*/
-#if 0 && defined(AFS_LINUX24_ENV)
-    int i;			/*Loop variable*/
-    struct vcache *tvc = afs_globalVp;
-    struct dentry *dentry;
-    struct list_head *cur, *head = &(AFSTOI(tvc))->i_dentry;
-
-#ifdef RX_ENABLE_LOCKS
-    AFS_GLOCK();
-#endif /* RX_ENABLE_LOCKS */
-
-#if defined(AFS_LINUX24_ENV)
-    spin_lock(&dcache_lock);
-#endif
-
-    cur = head;
-    while ((cur = cur->next) != head) {
-      dentry = list_entry(cur, struct dentry, d_alias);
-
-      dget_locked(dentry);
-
-#if defined(AFS_LINUX24_ENV)
-      spin_unlock(&dcache_lock);
-#endif
-      if (a_index == 0)
-	goto searchdone2;
-      a_index--;
-
-      if (recurse_dcache_parent(dentry, a_index, addr, inode, flags, time, fileName) == 0) {
-	dput(dentry);
-	code = 0;
-	goto fcnDone;
-      }
-      dput(dentry);
-    }
- searchdone2:
-    if (cur == head) {
-	/*Past EOF*/
-	code = 1;
-	*fileName = afs_strdup("");
-	goto fcnDone;
-    }
-
-    if (d_unhashed(dentry))
-      *flags = 1;
-    else
-      *flags = 0;
-
-    *fileName = afs_strdup(dentry->d_name.name?dentry->d_name.name:"");
-    *inode = ITOAFS(dentry->d_inode);
-    *addr = atomic_read(&(dentry)->d_count);
-    *time = dentry->d_time;
-
-    dput(dentry);
-    code = 0;
-
-fcnDone:
-
-#ifdef RX_ENABLE_LOCKS
-    AFS_GUNLOCK();
-#endif /* RX_ENABLE_LOCKS */
-#endif
     return(code);
 
 } /*SRXAFSCB_GetDE*/
diff --git a/src/afs/afs_cell.c b/src/afs/afs_cell.c
index 10c04f6af..ac5d75c2c 100644
--- a/src/afs/afs_cell.c
+++ b/src/afs/afs_cell.c
@@ -1097,7 +1097,9 @@ shutdown_cell(void)
 	afs_osi_FreeStr(afs_cellname_inode.ufs);
     }
 #endif
-    AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
+    if (afs_cold_shutdown) {
+	AFS_RWLOCK_INIT(&afs_xcell, "afs_xcell");
+    }
 
     for (cq = CellLRU.next; cq != &CellLRU; cq = tq) {
 	tc = QTOC(cq);
@@ -1119,6 +1121,10 @@ shutdown_cell(void)
 	cn = next;
     }
 }
+    if (afs_thiscell) {
+	afs_osi_FreeStr(afs_thiscell);
+	afs_thiscell = NULL;
+    }
 }
 
 /*!
diff --git a/src/afs/afs_conn.c b/src/afs/afs_conn.c
index 92e560c97..92d36af94 100644
--- a/src/afs/afs_conn.c
+++ b/src/afs/afs_conn.c
@@ -103,7 +103,6 @@ find_preferred_connection(struct sa_conn_vector *xcv, int create)
     } /* for cix < CVEC_LEN */
 
     if (bix < 0) {
-        afs_warn("find_preferred_connection: no connection and !create\n");
         tc = NULL;
         goto out;
     }
@@ -153,7 +152,10 @@ release_conns_user_server(struct unixuser *xu, struct server *xs)
 			if (sa->natping == tc) {
 			    int cin;
 			    struct afs_conn *tcn;
+			    sa->natping = NULL;
 			    for (tcvn = sa->conns; tcvn; tcvn = tcvn->next) {
+				if (sa->natping != NULL)
+				    break;
 				if (tcvn == tcv)
 				    continue;
 				for(cin = 0; cin < CVEC_LEN; ++cin) {
diff --git a/src/afs/afs_daemons.c b/src/afs/afs_daemons.c
index b283f778c..07139c434 100644
--- a/src/afs/afs_daemons.c
+++ b/src/afs/afs_daemons.c
@@ -189,14 +189,11 @@ afs_Daemon(void)
 	if (last1MinCheck + 60 < now) {
 	    /* things to do every minute */
 	    DFlush();		/* write out dir buffers */
-	    afs_WriteThroughDSlots();	/* write through cacheinfo entries */
+	    (void)afs_WriteThroughDSlots();	/* write through cacheinfo entries */
 	    ObtainWriteLock(&afs_xvcache, 736);
 	    afs_FlushReclaimedVcaches();
 	    ReleaseWriteLock(&afs_xvcache);
 	    afs_FlushActiveVcaches(1);	/* keep flocks held & flush nfs writes */
-#if 0
-	    afs_StoreDirtyVcaches();
-#endif
 	    last1MinCheck = now;
 	}
 
@@ -598,6 +595,26 @@ BPartialStore(struct brequest *ab)
     afs_DestroyReq(treq);
 }
 
+static void
+BInvalidateSegments(struct brequest *ab)
+{
+    int code;
+    struct vcache *tvc = ab->vc;
+    osi_Assert(WriteLocked(&tvc->lock));
+
+    code = afs_InvalidateAllSegments_once(tvc);
+
+    /* Set return code, and wakeup anyone waiting. */
+    if ((ab->flags & BUVALID) == 0) {
+	ab->code_raw = ab->code_checkcode = code;
+	ab->flags |= BUVALID;
+	if ((ab->flags & BUWAIT)) {
+	    ab->flags &= ~BUWAIT;
+	    afs_osi_Wakeup(ab);
+	}
+    }
+}
+
 /* release a held request buffer */
 void
 afs_BRelease(struct brequest *ab)
@@ -649,7 +666,7 @@ afs_BQueue(short aopcode, struct vcache *avc,
 		crhold(tb->cred);
 	    }
 	    if (avc) {
-		AFS_FAST_HOLD(avc);
+		osi_Assert(osi_vnhold(avc) == 0);
 	    }
 	    tb->refCount = ause + 1;
 	    tb->size_parm[0] = asparm0;
@@ -1012,8 +1029,7 @@ afs_BackgroundDaemon(void)
         for (i = 0; i < NBRS; i++, tb++) {
             if (tb->ts == uspc->ts) {
                 /* copy the userspace status back in */
-                ((struct afs_uspc_param *) tb->ptr_parm[0])->retval =
-                    uspc->retval;
+                tb->code_raw = tb->code_checkcode = uspc->retval;
                 /* mark it valid and notify our caller */
                 tb->flags |= BUVALID;
                 if (tb->flags & BUWAIT) {
@@ -1044,7 +1060,9 @@ afs_BackgroundDaemon(void)
 	    ReleaseWriteLock(&afs_xbrs);
 	    afs_osi_Wakeup(&afs_termState);
 #ifdef AFS_NEW_BKG
-	    return -2;
+	    memset(uspc, 0, sizeof(*uspc));
+	    uspc->reqtype = AFS_USPC_SHUTDOWN;
+	    return 0;
 #else
 	    return;
 #endif
@@ -1095,6 +1113,8 @@ afs_BackgroundDaemon(void)
 #endif
 	    else if (tb->opcode == BOP_PARTIAL_STORE)
 		BPartialStore(tb);
+	    else if (tb->opcode == BOP_INVALIDATE_SEGMENTS)
+		BInvalidateSegments(tb);
 	    else
 		panic("background bop");
 	    brequest_release(tb);
diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c
index 60d2a3106..d39350c1a 100644
--- a/src/afs/afs_dcache.c
+++ b/src/afs/afs_dcache.c
@@ -411,10 +411,10 @@ afs_MaybeWakeupTruncateDaemon(void)
  * struct so we need only export one symbol for AIX.
  */
 static struct CTD_stats {
-    osi_timeval_t CTD_beforeSleep;
-    osi_timeval_t CTD_afterSleep;
-    osi_timeval_t CTD_sleepTime;
-    osi_timeval_t CTD_runTime;
+    osi_timeval32_t CTD_beforeSleep;
+    osi_timeval32_t CTD_afterSleep;
+    osi_timeval32_t CTD_sleepTime;
+    osi_timeval32_t CTD_runTime;
     int CTD_nSleeps;
 } CTD_stats;
 
@@ -449,7 +449,7 @@ afs_WakeCacheWaitersIfDrained(void)
 void
 afs_CacheTruncateDaemon(void)
 {
-    osi_timeval_t CTD_tmpTime;
+    osi_timeval32_t CTD_tmpTime;
     u_int counter;
     u_int cb_lowat;
     u_int dc_hiwat =
@@ -457,7 +457,7 @@ afs_CacheTruncateDaemon(void)
     afs_min_cache =
 	(((10 * AFS_CHUNKSIZE(0)) + afs_fsfragsize) & ~afs_fsfragsize) >> 10;
 
-    osi_GetuTime(&CTD_stats.CTD_afterSleep);
+    osi_GetTime(&CTD_stats.CTD_afterSleep);
     afs_TruncateDaemonRunning = 1;
     while (1) {
 	cb_lowat = PERCENT((CM_DCACHESPACEFREEPCT - CM_DCACHEEXTRAPCT), afs_cacheBlocks);
@@ -525,7 +525,7 @@ afs_CacheTruncateDaemon(void)
 	    && (afs_termState != AFSOP_STOP_TRUNCDAEMON)) {
 	    /* Collect statistics on truncate daemon. */
 	    CTD_stats.CTD_nSleeps++;
-	    osi_GetuTime(&CTD_stats.CTD_beforeSleep);
+	    osi_GetTime(&CTD_stats.CTD_beforeSleep);
 	    afs_stats_GetDiff(CTD_tmpTime, CTD_stats.CTD_afterSleep,
 			      CTD_stats.CTD_beforeSleep);
 	    afs_stats_AddTo(CTD_stats.CTD_runTime, CTD_tmpTime);
@@ -534,7 +534,7 @@ afs_CacheTruncateDaemon(void)
 	    afs_osi_Sleep((int *)afs_CacheTruncateDaemon);
 	    afs_TruncateDaemonRunning = 1;
 
-	    osi_GetuTime(&CTD_stats.CTD_afterSleep);
+	    osi_GetTime(&CTD_stats.CTD_afterSleep);
 	    afs_stats_GetDiff(CTD_tmpTime, CTD_stats.CTD_beforeSleep,
 			      CTD_stats.CTD_afterSleep);
 	    afs_stats_AddTo(CTD_stats.CTD_sleepTime, CTD_tmpTime);
@@ -1121,29 +1121,39 @@ afs_DiscardDCache(struct dcache *adc)
 /**
  * Get a dcache entry from the discard or free list
  *
+ * @param[out] adc    On success, a dcache from the given list. Otherwise, NULL.
  * @param[in] indexp  A pointer to the head of the dcache free list or discard
  *                    list (afs_freeDCList, or afs_discardDCList)
  *
- * @return A dcache from that list, or NULL if none could be retrieved.
+ * @return 0 on success. If there are no dcache slots available, return ENOSPC.
+ *         If we encountered an error in disk i/o while trying to find a
+ *         dcache, return EIO.
  *
  * @pre afs_xdcache is write-locked
  */
-static struct dcache *
-afs_GetDSlotFromList(afs_int32 *indexp)
+static int
+afs_GetDSlotFromList(struct dcache **adc, afs_int32 *indexp)
 {
     struct dcache *tdc;
 
-    for ( ; *indexp != NULLIDX; indexp = &afs_dvnextTbl[*indexp]) {
-	tdc = afs_GetUnusedDSlot(*indexp);
-	if (tdc) {
-	    osi_Assert(tdc->refCount == 1);
-	    ReleaseReadLock(&tdc->tlock);
-	    *indexp = afs_dvnextTbl[tdc->index];
-	    afs_dvnextTbl[tdc->index] = NULLIDX;
-	    return tdc;
-	}
+    *adc = NULL;
+
+    if (*indexp == NULLIDX) {
+        return ENOSPC;
     }
-    return NULL;
+
+    tdc = afs_GetUnusedDSlot(*indexp);
+    if (tdc == NULL) {
+        return EIO;
+    }
+
+    osi_Assert(tdc->refCount == 1);
+    ReleaseReadLock(&tdc->tlock);
+    *indexp = afs_dvnextTbl[tdc->index];
+    afs_dvnextTbl[tdc->index] = NULLIDX;
+
+    *adc = tdc;
+    return 0;
 }
 
 /*!
@@ -1170,7 +1180,7 @@ afs_FreeDiscardedDCache(void)
     /*
      * Get an entry from the list of discarded cache elements
      */
-    tdc = afs_GetDSlotFromList(&afs_discardDCList);
+    (void)afs_GetDSlotFromList(&tdc, &afs_discardDCList);
     if (!tdc) {
 	ReleaseWriteLock(&afs_xdcache);
 	return -1;
@@ -1188,6 +1198,7 @@ afs_FreeDiscardedDCache(void)
      * Truncate the element to reclaim its space
      */
     tfile = afs_CFileOpen(&tdc->f.inode);
+    osi_Assert(tfile);
     afs_CFileTruncate(tfile, 0);
     afs_CFileClose(tfile);
     afs_AdjustSize(tdc, 0);
@@ -1271,8 +1282,6 @@ afs_GetDownDSlot(int anumber)
 	if (tdc->refCount == 0) {
 	    if ((ix = tdc->index) == NULLIDX)
 		osi_Panic("getdowndslot");
-	    /* pull the entry out of the lruq and put it on the free list */
-	    QRemove(&tdc->lruq);
 
 	    /* write-through if modified */
 	    if (tdc->dflags & DFEntryMod) {
@@ -1294,12 +1303,23 @@ afs_GetDownDSlot(int anumber)
 		    AFS_GLOCK();
 		}
 #else
+		int code;
+
+		code = afs_WriteDCache(tdc, 1);
+		if (code) {
+		    /*
+		     * We couldn't flush it at this time; return early because
+		     * if afs_WriteDCache() failed once it is likely to
+		     * continue failing for subsequent dcaches.
+		     */
+		    return;
+		}
 		tdc->dflags &= ~DFEntryMod;
-		osi_Assert(afs_WriteDCache(tdc, 1) == 0);
 #endif
 	    }
 
-	    /* finally put the entry in the free list */
+	    /* pull the entry out of the lruq and put it on the free list */
+	    QRemove(&tdc->lruq);
 	    afs_indexTable[ix] = NULL;
 	    afs_indexFlags[ix] &= ~IFEverUsed;
 	    tdc->index = NULLIDX;
@@ -1408,9 +1428,9 @@ afs_TryToSmush(struct vcache *avc, afs_ucred_t *acred, int sync)
 	    tdc = afs_GetValidDSlot(index);
 	    if (!tdc) {
 		/* afs_TryToSmush is best-effort; we may not actually discard
-		 * everything, so failure to discard a dcache due to an i/o
+		 * everything, so failure to discard dcaches due to an i/o
 		 * error is okay. */
-		continue;
+		break;
 	    }
 	    if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
 		if (sync) {
@@ -1501,13 +1521,14 @@ afs_DCacheMissingChunks(struct vcache *avc)
         i = afs_dvnextTbl[index];
         if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
             tdc = afs_GetValidDSlot(index);
-	    if (tdc) {
-		if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
-		    totalChunks--;
-		}
-		ReleaseReadLock(&tdc->tlock);
-		afs_PutDCache(tdc);
-	    }
+            if (!tdc) {
+                break;
+            }
+            if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
+                totalChunks--;
+            }
+            ReleaseReadLock(&tdc->tlock);
+            afs_PutDCache(tdc);
         }
     }
     ReleaseWriteLock(&afs_xdcache);
@@ -1560,7 +1581,8 @@ afs_FindDCache(struct vcache *avc, afs_size_t abyte)
 		/* afs_FindDCache is best-effort; we may not find the given
 		 * file/offset, so if we cannot find the given dcache due to
 		 * i/o errors, that is okay. */
-		continue;
+                index = NULLIDX;
+		break;
 	    }
 	    ReleaseReadLock(&tdc->tlock);
 	    if (!FidCmp(&tdc->f.fid, &avc->f.fid) && chunk == tdc->f.chunk) {
@@ -1580,31 +1602,34 @@ afs_FindDCache(struct vcache *avc, afs_size_t abyte)
 }				/*afs_FindDCache */
 
 /* only call these from afs_AllocDCache() */
-static struct dcache *
-afs_AllocFreeDSlot(void)
+static int
+afs_AllocFreeDSlot(struct dcache **adc)
 {
+    int code;
     struct dcache *tdc;
 
-    tdc = afs_GetDSlotFromList(&afs_freeDCList);
-    if (!tdc) {
-	return NULL;
+    code = afs_GetDSlotFromList(&tdc, &afs_freeDCList);
+    if (code) {
+	return code;
     }
     afs_indexFlags[tdc->index] &= ~IFFree;
     ObtainWriteLock(&tdc->lock, 604);
     afs_freeDCCount--;
 
-    return tdc;
+    *adc = tdc;
+    return 0;
 }
-static struct dcache *
-afs_AllocDiscardDSlot(afs_int32 lock)
+static int
+afs_AllocDiscardDSlot(struct dcache **adc, afs_int32 lock)
 {
+    int code;
     struct dcache *tdc;
     afs_uint32 size = 0;
     struct osi_file *file;
 
-    tdc = afs_GetDSlotFromList(&afs_discardDCList);
-    if (!tdc) {
-	return NULL;
+    code = afs_GetDSlotFromList(&tdc, &afs_discardDCList);
+    if (code) {
+	return code;
     }
     afs_indexFlags[tdc->index] &= ~IFDiscarded;
     ObtainWriteLock(&tdc->lock, 605);
@@ -1619,17 +1644,20 @@ afs_AllocDiscardDSlot(afs_int32 lock)
     if ((lock & 2)) {
 	/* Truncate the chunk so zeroes get filled properly */
 	file = afs_CFileOpen(&tdc->f.inode);
+        osi_Assert(file);
 	afs_CFileTruncate(file, 0);
 	afs_CFileClose(file);
 	afs_AdjustSize(tdc, 0);
     }
 
-    return tdc;
+    *adc = tdc;
+    return 0;
 }
 
 /*!
  * Get a fresh dcache from the free or discarded list.
  *
+ * \param adc Set to the new dcache on success, and NULL on error.
  * \param avc Who's dcache is this going to be?
  * \param chunk The position where it will be placed in.
  * \param lock How are locks held.
@@ -1641,29 +1669,34 @@ afs_AllocDiscardDSlot(afs_int32 lock)
  * 	- avc (R if (lock & 1) set and W otherwise)
  * \note It write locks the new dcache. The caller must unlock it.
  *
- * \return The new dcache.
+ * \return If we're out of dslots, ENOSPC. If we encountered disk errors, EIO.
+ *         On success, return 0.
  */
-struct dcache *
-afs_AllocDCache(struct vcache *avc, afs_int32 chunk, afs_int32 lock,
-		struct VenusFid *ashFid)
+static int
+afs_AllocDCache(struct dcache **adc, struct vcache *avc, afs_int32 chunk,
+                afs_int32 lock, struct VenusFid *ashFid)
 {
+    int code;
     struct dcache *tdc = NULL;
 
+    *adc = NULL;
+
     /* if (lock & 2), prefer 'free' dcaches; otherwise, prefer 'discard'
-     * dcaches. In either case, try both if our first choice doesn't work. */
+     * dcaches. In either case, try both if our first choice doesn't work due
+     * to ENOSPC. */
     if ((lock & 2)) {
-	tdc = afs_AllocFreeDSlot();
-	if (!tdc) {
-	    tdc = afs_AllocDiscardDSlot(lock);
+	code = afs_AllocFreeDSlot(&tdc);
+	if (code == ENOSPC) {
+	    code = afs_AllocDiscardDSlot(&tdc, lock);
 	}
     } else {
-	tdc = afs_AllocDiscardDSlot(lock);
-	if (!tdc) {
-	    tdc = afs_AllocFreeDSlot();
+	code = afs_AllocDiscardDSlot(&tdc, lock);
+	if (code == ENOSPC) {
+	    code = afs_AllocFreeDSlot(&tdc);
 	}
     }
-    if (!tdc) {
-	return NULL;
+    if (code) {
+	return code;
     }
 
     /*
@@ -1700,7 +1733,167 @@ afs_AllocDCache(struct vcache *avc, afs_int32 chunk, afs_int32 lock,
     if (tdc->lruq.prev == &tdc->lruq)
 	osi_Panic("lruq 1");
 
-    return tdc;
+    *adc = tdc;
+    return 0;
+}
+
+static int
+IsDCacheSizeOK(struct dcache *adc, struct vcache *avc, afs_int32 chunk_bytes,
+	       afs_size_t file_length, afs_uint32 versionNo, int from_net)
+{
+    afs_size_t expected_bytes;
+    afs_size_t chunk_start = AFS_CHUNKTOBASE(adc->f.chunk);
+
+    if (vType(avc) == VDIR) {
+	/*
+	 * Directory blobs may be constructed locally (see afs_LocalHero), and
+	 * the size of the blob may differ slightly compared to what's on the
+	 * fileserver. So, skip size checks for directories.
+	 */
+	return 1;
+    }
+
+    if ((avc->f.states & CDirty)) {
+	/*
+	 * Our vcache may have writes that are local to our cache, but not yet
+	 * written to the fileserver. In such a situation, we may have dcaches
+	 * for that file that are "short". For example:
+	 *
+	 * Say we have a file that is 0 bytes long. A process opens that file,
+	 * and writes some data to offset 5M (keeping the file open). Another
+	 * process comes along and reads data from offset 1M. We'll try to
+	 * fetch data at offset 1M, and the fileserver will respond with 0
+	 * bytes, since our locally-written data hasn't been written to the
+	 * fileserver yet (on the fileserver, the file is still 0-bytes long).
+	 * So our dcache at offset 1M will have 0 bytes.
+	 *
+	 * So if CDirty is set, don't do any size/length checks at all, since
+	 * we have no idea if the avc length is valid.
+	 */
+	return 1;
+    }
+
+    if (!from_net && (adc->f.states & DRW)) {
+	/*
+	 * The dcache data we're looking at is from our local cache (not from a
+	 * fileserver), and it's for data in an RW volume. For cached RW data,
+	 * there are some edge cases that can cause the below length checks to
+	 * trigger false positives.
+	 *
+	 * For example: if the local client writes 4 bytes to a new file at
+	 * offset 0, and then 4 bytes at offset 0x400000, the file will be
+	 * 0x400004 bytes long, but the first dcache chunk will only contain 4
+	 * bytes. If such a file is fetched from a fileserver, the first chunk
+	 * will have a full chunk of data (most of it zeroes), but on the
+	 * client that did the write, the sparse data will not appear in the
+	 * dcache.
+	 *
+	 * Such false positives should only be possible with RW data, since
+	 * non-RW data is never generated locally. So to avoid the false
+	 * positives, assume the dcache length is OK for RW data if the dcache
+	 * came from our local cache (and not directly from a fileserver).
+	 */
+	return 1;
+    }
+
+    if (file_length < chunk_start) {
+	expected_bytes = 0;
+
+    } else {
+	expected_bytes = file_length - chunk_start;
+
+	if (vType(avc) != VDIR && expected_bytes > AFS_CHUNKTOSIZE(adc->f.chunk)) {
+	    /* A non-dir chunk cannot have more bytes than the chunksize. */
+	    expected_bytes = AFS_CHUNKTOSIZE(adc->f.chunk);
+	}
+    }
+
+    if (chunk_bytes != expected_bytes) {
+	static const afs_uint32 one_hour = 60 * 60;
+	static afs_uint32 last_warn;
+	afs_uint32 now = osi_Time();
+
+	if (now < last_warn) {
+	    /* clock went backwards */
+	    last_warn = now;
+	}
+
+	if (now - last_warn > one_hour) {
+	    unsigned int mtime = adc->f.modTime;
+
+	    last_warn = now;
+
+	    if (from_net) {
+		/*
+		 * The dcache we're looking at didn't come from the cache, but is
+		 * being populated from the net. Don't print out its mtime in that
+		 * case; that would be misleading since that's the mtime from the
+		 * last time this dcache slot was written to.
+		 */
+		mtime = 0;
+	    }
+
+	    afs_warn("afs: Detected corrupt dcache for file %d.%u.%u.%u: chunk %d "
+		     "(offset %lu) has %d bytes, but it should have %lu bytes\n",
+		     adc->f.fid.Cell,
+		     adc->f.fid.Fid.Volume,
+		     adc->f.fid.Fid.Vnode,
+		     adc->f.fid.Fid.Unique,
+		     adc->f.chunk,
+		     (unsigned long)chunk_start,
+		     chunk_bytes,
+		     (unsigned long)expected_bytes);
+	    afs_warn("afs: (dcache %p, file length %lu, DV %u, dcache mtime %u, "
+		     "index %d, dflags 0x%x, mflags 0x%x, states 0x%x, vcache "
+		     "states 0x%x)\n",
+		     adc,
+		     (unsigned long)file_length,
+		     versionNo,
+		     mtime,
+		     adc->index,
+		     (unsigned)adc->dflags,
+		     (unsigned)adc->mflags,
+		     (unsigned)adc->f.states,
+		     avc->f.states);
+	    afs_warn("afs: Ignoring the dcache for now, but this may indicate "
+		     "corruption in the AFS cache, or a bug.\n");
+	}
+	return 0;
+    }
+    return 1;
+}
+
+/*!
+ * Check if a dcache is "fresh". That is, if the dcache's DV matches the DV of
+ * the vcache for that file, and the dcache looks "sane" (its length makes
+ * sense, when considering the length of the given avc).
+ *
+ * \param adc The dcache to check
+ * \param avc The vcache for adc
+ *
+ * \return 1 if the dcache is "fresh". 0 otherwise.
+ */
+int
+afs_IsDCacheFresh(struct dcache *adc, struct vcache *avc)
+{
+    if (!hsame(adc->f.versionNo, avc->f.m.DataVersion)) {
+	return 0;
+    }
+
+    /*
+     * If we've reached here, the DV in adc matches the DV of our avc. Check if
+     * the number of bytes in adc agrees with the avc file length, as a sanity
+     * check. If they don't match, we'll pretend the DVs don't match, so the
+     * bad dcache data will not be used, and we'll probably re-fetch the chunk
+     * data, replacing the bad chunk.
+     */
+
+    if (!IsDCacheSizeOK(adc, avc, adc->f.chunkBytes, avc->f.m.Length,
+			hgetlo(adc->f.versionNo), 0)) {
+	return 0;
+    }
+
+    return 1;
 }
 
 /*
@@ -1741,7 +1934,7 @@ void
 updateV2DC(int lockVc, struct vcache *v, struct dcache *d, int src)
 {
     if (!lockVc || 0 == NBObtainWriteLock(&v->lock, src)) {
-	if (hsame(v->f.m.DataVersion, d->f.versionNo) && v->callback)
+	if (afs_IsDCacheFresh(d, v) && v->callback)
 	    v->dchint = d;
 	if (lockVc)
 	    ReleaseWriteLock(&v->lock);
@@ -1851,7 +2044,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 	    ReleaseReadLock(&afs_xdcache);
 	    shortcut = 1;
 
-	    if (hsame(tdc->f.versionNo, avc->f.m.DataVersion)
+	    if (afs_IsDCacheFresh(tdc, avc)
 		&& !(tdc->dflags & DFFetching)) {
 
 		afs_stats_cmperf.dcacheHits++;
@@ -1906,12 +2099,13 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 	    if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
 		tdc = afs_GetValidDSlot(index);
 		if (!tdc) {
-		    /* we got an i/o error when trying to get the given dslot,
-		     * but do not bail out just yet; it is possible the dcache
-		     * we're looking for is elsewhere, so it doesn't matter if
-		     * we can't load this one. */
+                    /* we got an i/o error when trying to get the given dslot.
+                     * it's possible the dslot we're looking for is elsewhere,
+                     * but most likely the disk cache is currently unusable, so
+                     * all afs_GetValidDSlot calls will fail, so just bail out. */
 		    dslot_error = 1;
-		    continue;
+                    index = NULLIDX;
+		    break;
 		}
 		ReleaseReadLock(&tdc->tlock);
 		/*
@@ -1967,19 +2161,37 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 		if (!setLocks)
 		    avc->f.states &= ~CDCLock;
 	    }
-	    tdc = afs_AllocDCache(avc, chunk, aflags, NULL);
-	    if (!tdc) {
-		/* If we can't get space for 5 mins we give up and panic */
-		if (++downDCount > 300)
-		    osi_Panic("getdcache");
+	    code = afs_AllocDCache(&tdc, avc, chunk, aflags, NULL);
+	    if (code) {
 		ReleaseWriteLock(&afs_xdcache);
-		/*
-		 * Locks held:
-		 * avc->lock(R) if setLocks
-		 * avc->lock(W) if !setLocks
-		 */
-		afs_osi_Wait(1000, 0, 0);
-		goto RetryLookup;
+                if (code == ENOSPC) {
+                    /* It looks like afs_AllocDCache failed because we don't
+                     * have any free dslots to use. Maybe if we wait a little
+                     * while, we'll be able to free up some slots, so try for 5
+                     * minutes, then bail out. */
+                    if (++downDCount > 300) {
+                        afs_warn("afs: Unable to get free cache space for file "
+                                 "%u:%u.%u.%u for 5 minutes; failing with an i/o error\n",
+                                 avc->f.fid.Cell,
+                                 avc->f.fid.Fid.Volume,
+                                 avc->f.fid.Fid.Vnode,
+                                 avc->f.fid.Fid.Unique);
+                        goto done;
+                    }
+                    afs_osi_Wait(1000, 0, 0);
+                    goto RetryLookup;
+                }
+
+                /* afs_AllocDCache failed, but not because we're out of free
+                 * dslots. Something must be screwy with the cache, so bail out
+                 * immediately without waiting. */
+                afs_warn("afs: Error while alloc'ing cache slot for file "
+                         "%u:%u.%u.%u; failing with an i/o error\n",
+                         avc->f.fid.Cell,
+                         avc->f.fid.Fid.Volume,
+                         avc->f.fid.Fid.Vnode,
+                         avc->f.fid.Fid.Unique);
+                goto done;
 	    }
 
 	    /*
@@ -2069,13 +2281,14 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 	if (AFS_CHUNKTOBASE(chunk) >= avc->f.m.Length &&
 #endif
 #endif /* defined(AFS_AIX32_ENV) || defined(AFS_SGI_ENV) */
-	    !hsame(avc->f.m.DataVersion, tdc->f.versionNo))
+	    !afs_IsDCacheFresh(tdc, avc))
 	    doReallyAdjustSize = 1;
 
 	if (doReallyAdjustSize || overWriteWholeChunk) {
 	    /* no data in file to read at this position */
 	    UpgradeSToWLock(&tdc->lock, 607);
 	    file = afs_CFileOpen(&tdc->f.inode);
+            osi_Assert(file);
 	    afs_CFileTruncate(file, 0);
 	    afs_CFileClose(file);
 	    afs_AdjustSize(tdc, 0);
@@ -2132,7 +2345,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
      * avc->lock(W) if !setLocks || slowPass
      * tdc->lock(S)
      */
-    if (!hsame(avc->f.m.DataVersion, tdc->f.versionNo) && !overWriteWholeChunk) {
+    if (!afs_IsDCacheFresh(tdc, avc) && !overWriteWholeChunk) {
 	/*
 	 * Version number mismatch.
 	 */
@@ -2202,7 +2415,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 	 */
 
 	/* Watch for standard race condition around osi_FlushText */
-	if (hsame(avc->f.m.DataVersion, tdc->f.versionNo)) {
+	if (afs_IsDCacheFresh(tdc, avc)) {
 	    updateV2DC(setLocks, avc, tdc, 569);	/* set hint */
 	    afs_stats_cmperf.dcacheHits++;
 	    ConvertWToSLock(&tdc->lock);
@@ -2295,6 +2508,14 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 	 */
 	DZap(tdc);	/* pages in cache may be old */
 	file = afs_CFileOpen(&tdc->f.inode);
+        if (!file) {
+            /* We can't access the file in the disk cache backing this dcache;
+             * bail out. */
+            ReleaseWriteLock(&tdc->lock);
+            afs_PutDCache(tdc);
+            tdc = NULL;
+            goto done;
+        }
 	afs_RemoveVCB(&avc->f.fid);
 	tdc->f.states |= DWriting;
 	tdc->dflags |= DFFetching;
@@ -2417,11 +2638,23 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 		     * validPos is updated by CacheFetchProc, and can only be
 		     * modifed under a dcache write lock, which we've blocked out
 		     */
+		    afs_size_t length;
+
 		    size = tdc->validPos - Position;	/* actual segment size */
 		    if (size < 0)
 			size = 0;
 		    afs_CFileTruncate(file, size);	/* prune it */
-		} else {
+
+		    /* Check that the amount of data that we fetched for the
+		     * dcache makes sense. */
+		    FillInt64(length, tsmall->OutStatus.Length_hi, tsmall->OutStatus.Length);
+		    if (!IsDCacheSizeOK(tdc, avc, size,
+					length,
+					tsmall->OutStatus.DataVersion, 1)) {
+			code = EIO;
+		    }
+		}
+		if (code) {
 		    if (!setLocks || slowPass) {
 			afs_StaleVCacheFlags(avc, AFS_STALEVC_CLEARCB, CUnique);
 		    } else {
@@ -2436,13 +2669,18 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
 			ReleaseWriteLock(&tdc->lock);
 			afs_PutDCache(tdc);
 			tdc = 0;
-			ReleaseReadLock(&avc->lock);
 
-			if (tc) {
-			    /* If we have a connection, we must put it back,
-			     * since afs_Analyze will not be called here. */
-			    afs_PutConn(tc, rxconn, SHARED_LOCK);
-			}
+			/*
+			 * Call afs_Analyze to manage the connection references
+			 * and handle the error code (possibly mark servers
+			 * down, etc). We are going to retry getting the
+			 * dcache regardless, so we just ignore the retry hint
+			 * returned by afs_Analyze on this call.
+			 */
+			(void)afs_Analyze(tc, rxconn, code, &avc->f.fid, areq,
+					  AFS_STATS_FS_RPCIDX_FETCHDATA, SHARED_LOCK, NULL);
+
+			ReleaseReadLock(&avc->lock);
 
 			slowPass = 1;
 			goto RetryGetDCache;
@@ -2652,11 +2890,12 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
  * Environment:
  *	The afs_xdcache is write-locked through this whole affair.
  */
-void
+int
 afs_WriteThroughDSlots(void)
 {
     struct dcache *tdc;
     afs_int32 i, touchedit = 0;
+    int code = 0;
 
     struct afs_q DirtyQ, *tq;
 
@@ -2692,7 +2931,7 @@ afs_WriteThroughDSlots(void)
 
 #define DQTODC(q)	((struct dcache *)(((char *) (q)) - sizeof(struct afs_q)))
 
-    for (tq = DirtyQ.prev; tq != &DirtyQ; tq = QPrev(tq)) {
+    for (tq = DirtyQ.prev; tq != &DirtyQ && code == 0; tq = QPrev(tq)) {
 	tdc = DQTODC(tq);
 	if (tdc->dflags & DFEntryMod) {
 	    int wrLock;
@@ -2703,9 +2942,15 @@ afs_WriteThroughDSlots(void)
 	    if (wrLock && (tdc->dflags & DFEntryMod)) {
 		tdc->dflags &= ~DFEntryMod;
 		ObtainWriteLock(&afs_xdcache, 620);
-		osi_Assert(afs_WriteDCache(tdc, 1) == 0);
+		code = afs_WriteDCache(tdc, 1);
 		ReleaseWriteLock(&afs_xdcache);
-		touchedit = 1;
+                if (code) {
+                    /* We didn't successfully write out the dslot; make sure we
+                     * try again later */
+                    tdc->dflags |= DFEntryMod;
+                } else {
+                    touchedit = 1;
+                }
 	    }
 	    if (wrLock)
 		ReleaseWriteLock(&tdc->lock);
@@ -2714,6 +2959,10 @@ afs_WriteThroughDSlots(void)
 	afs_PutDCache(tdc);
     }
 
+    if (code) {
+        return code;
+    }
+
     ObtainWriteLock(&afs_xdcache, 617);
     if (!touchedit && (cacheDiskType != AFS_FCACHE_TYPE_MEM)) {
 	/* Touch the file to make sure that the mtime on the file is kept
@@ -2726,6 +2975,7 @@ afs_WriteThroughDSlots(void)
 	afs_osi_Write(afs_cacheInodep, 0, &theader, sizeof(theader));
     }
     ReleaseWriteLock(&afs_xdcache);
+    return 0;
 }
 
 /*
@@ -3254,7 +3504,7 @@ afs_InitCacheFile(char *afile, ino_t ainode)
  * \param aflags
  *
  */
-void
+int
 afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags)
 {
     struct dcache *tdp;
@@ -3381,6 +3631,7 @@ afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags)
 	    afs_warn("afsd: memory cache too large for available memory.\n");
 	    afs_warn("afsd: AFS files cannot be accessed.\n\n");
 	    dcacheDisabled = 1;
+            return code;
 	} else
 	    afs_warn("Memory cache: Allocating %d dcache entries...",
 		   aDentries);
@@ -3388,6 +3639,7 @@ afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags)
 	cacheDiskType = AFS_FCACHE_TYPE_UFS;
 	afs_cacheType = &afs_UfsCacheOps;
     }
+    return 0;
 }
 
 /*!
@@ -3494,7 +3746,7 @@ afs_ObtainDCacheForWriting(struct vcache *avc, afs_size_t filePos,
 	tdc = afs_FindDCache(avc, filePos);
 	if (tdc) {
 	    ObtainWriteLock(&tdc->lock, 658);
-	    if (!hsame(tdc->f.versionNo, avc->f.m.DataVersion)
+	    if (!afs_IsDCacheFresh(tdc, avc)
 		|| (tdc->dflags & DFFetching)) {
 		ReleaseWriteLock(&tdc->lock);
 		afs_PutDCache(tdc);
@@ -3558,9 +3810,9 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
 {
     int i, code, ret_code = 0, written, trans_size;
     struct dcache *new_dc = NULL;
-    struct osi_file *tfile_src, *tfile_dst;
+    struct osi_file *tfile_src = NULL, *tfile_dst = NULL;
     struct VenusFid shadow_fid;
-    char *data;
+    char *data = NULL;
 
     /* Is this a dir? */
     if (vType(avc) != VDIR)
@@ -3577,7 +3829,7 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
     ObtainWriteLock(&afs_xdcache, 716);
 
     /* Get a fresh dcache. */
-    new_dc = afs_AllocDCache(avc, 0, 0, &shadow_fid);
+    (void)afs_AllocDCache(&new_dc, avc, 0, 0, &shadow_fid);
     osi_Assert(new_dc);
 
     ObtainReadLock(&adc->mflock);
@@ -3615,7 +3867,16 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
 
     /* Open the files. */
     tfile_src = afs_CFileOpen(&adc->f.inode);
+    if (!tfile_src) {
+	ret_code = EIO;
+	goto done;
+    }
+
     tfile_dst = afs_CFileOpen(&new_dc->f.inode);
+    if (!tfile_dst) {
+	ret_code = EIO;
+	goto done;
+    }
 
     /* And now copy dir dcache data into this dcache,
      * 4k at a time.
@@ -3643,10 +3904,14 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
 	written+=trans_size;
     }
 
-    afs_CFileClose(tfile_dst);
-    afs_CFileClose(tfile_src);
+ done:
+    if (tfile_dst)
+	afs_CFileClose(tfile_dst);
+    if (tfile_src)
+	afs_CFileClose(tfile_src);
 
-    afs_osi_Free(data, 4096);
+    if (data)
+	afs_osi_Free(data, 4096);
 
     ReleaseWriteLock(&new_dc->lock);
     afs_PutDCache(new_dc);
@@ -3663,7 +3928,6 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
 	avc->f.shadow.unique = shadow_fid.Fid.Unique;
     }
 
-done:
     return ret_code;
 }
 
diff --git a/src/afs/afs_disconnected.c b/src/afs/afs_disconnected.c
index 957bf9394..3b8858539 100644
--- a/src/afs/afs_disconnected.c
+++ b/src/afs/afs_disconnected.c
@@ -72,13 +72,15 @@ afs_FindDCacheByFid(struct VenusFid *afid)
     for (index = afs_dvhashTbl[i]; index != NULLIDX;) {
 	if (afs_indexUnique[index] == afid->Fid.Unique) {
 	    tdc = afs_GetValidDSlot(index);
-	    if (tdc) {
-		ReleaseReadLock(&tdc->tlock);
-		if (!FidCmp(&tdc->f.fid, afid)) {
-		    break;		/* leaving refCount high for caller */
-		}
-		afs_PutDCache(tdc);
-	    }
+	    if (!tdc) {
+                index = NULLIDX;
+                break;
+            }
+            ReleaseReadLock(&tdc->tlock);
+            if (!FidCmp(&tdc->f.fid, afid)) {
+                break;		/* leaving refCount high for caller */
+            }
+            afs_PutDCache(tdc);
 	}
 	index = afs_dvnextTbl[index];
     }
@@ -707,6 +709,12 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq,
 	}
 	ObtainReadLock(&tdc->lock);
 	tfile = afs_CFileOpen(&tdc->f.inode);
+	if (!tfile) {
+	    ReleaseReadLock(&tdc->lock);
+	    afs_PutDCache(tdc);
+	    code = EIO;
+	    goto end;
+	}
 	code = afs_CFileRead(tfile, 0, ttargetName, tlen);
 	ttargetName[tlen-1] = '\0';
 	afs_CFileClose(tfile);
@@ -858,6 +866,11 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq,
     for (index = afs_dvhashTbl[hash]; index != NULLIDX; index = hash) {
         hash = afs_dvnextTbl[index];
         tdc = afs_GetValidDSlot(index);
+        if (!tdc) {
+            ReleaseWriteLock(&afs_xdcache);
+            code = EIO;
+            goto end;
+        }
         ReleaseReadLock(&tdc->tlock);
 	if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
             if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
@@ -878,8 +891,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq,
 		memcpy(&tdc->f.fid, &newFid, sizeof(struct VenusFid));
            }                   /* if fid match */
 	}                       /* if uniquifier match */
-    	if (tdc)
-	    afs_PutDCache(tdc);
+        afs_PutDCache(tdc);
     }                           /* for all dcaches in this hash bucket */
     ReleaseWriteLock(&afs_xdcache);
 
@@ -1152,34 +1164,6 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred)
 	    tvc->f.ddirty_flags &= ~VDisconCreate;
 	    tvc->f.ddirty_flags |= VDisconCreated;
 	}
-#if 0
-  	/* Get server write lock. */
-  	do {
-	    tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn);
-  	    if (tc) {
-	    	XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_SETLOCK);
-  		RX_AFS_GUNLOCK();
-		code = RXAFS_SetLock(rxconn,
-					(struct AFSFid *)&tvc->f.fid.Fid,
-					LockWrite,
-					&tsync);
-		RX_AFS_GLOCK();
-		XSTATS_END_TIME;
-	   } else
-		code = -1;
-
-	} while (afs_Analyze(tc,
-			rxconn,
-			code,
-			&tvc->f.fid,
-			areq,
-			AFS_STATS_FS_RPCIDX_SETLOCK,
-			SHARED_LOCK,
-			NULL));
-
-	if (code)
-	    goto next_file;
-#endif
 	if (tvc->f.ddirty_flags & VDisconRename) {
 	    /* If we're renaming the file, do so now */
 	    code = afs_ProcessOpRename(tvc, areq);
@@ -1243,29 +1227,9 @@ afs_ResyncDisconFiles(struct vrequest *areq, afs_ucred_t *acred)
 	}		/* if DV match or client wins policy */
 
 unlock_srv_file:
-	/* Release server write lock. */
-#if 0
-	do {
-	    tc = afs_Conn(&tvc->f.fid, areq, SHARED_LOCK, &rxconn);
-	    if (tc) {
-	    	XSTATS_START_TIME(AFS_STATS_FS_RPCIDX_RELEASELOCK);
-	    	RX_AFS_GUNLOCK();
-		ucode = RXAFS_ReleaseLock(rxconn,
-				(struct AFSFid *) &tvc->f.fid.Fid,
-				&tsync);
-		RX_AFS_GLOCK();
-		XSTATS_END_TIME;
-	    } else
-		ucode = -1;
-	} while (afs_Analyze(tc,
-			rxconn,
-			ucode,
-			&tvc->f.fid,
-			areq,
-			AFS_STATS_FS_RPCIDX_RELEASELOCK,
-			SHARED_LOCK,
-			NULL));
-#endif
+	/* If we ever lock files while replaying changes, we should unlock the
+	 * file here. */
+
 next_file:
 	ObtainWriteLock(&afs_disconDirtyLock, 710);
 	if (code == 0) {
diff --git a/src/afs/afs_dynroot.c b/src/afs/afs_dynroot.c
index a18602f81..ab21f8abf 100644
--- a/src/afs/afs_dynroot.c
+++ b/src/afs/afs_dynroot.c
@@ -916,3 +916,26 @@ afs_DynrootVOPSymlink(struct vcache *avc, afs_ucred_t *acred,
     afs_DynrootInvalidate();
     return 0;
 }
+
+void
+shutdown_dynroot(void)
+{
+    if (!afs_dynrootEnable) {
+	return;
+    }
+
+    ObtainWriteLock(&afs_dynrootDirLock, 554);
+
+    if (afs_dynrootDir) {
+	afs_osi_Free(afs_dynrootDir, afs_dynrootDirLen);
+	afs_dynrootDir = NULL;
+	afs_dynrootDirLen = 0;
+    }
+    if (afs_dynrootMountDir) {
+	afs_osi_Free(afs_dynrootMountDir, afs_dynrootMountDirLen);
+	afs_dynrootMountDir = NULL;
+	afs_dynrootMountDirLen = 0;
+    }
+
+    ReleaseWriteLock(&afs_dynrootDirLock);
+}
diff --git a/src/afs/afs_error.c b/src/afs/afs_error.c
index dd346a0b8..42d3e23dd 100644
--- a/src/afs/afs_error.c
+++ b/src/afs/afs_error.c
@@ -190,6 +190,13 @@ init_et_to_sys_error(void)
     et2sys[(UAEDQUOT - ERROR_TABLE_BASE_uae)] = EDQUOT;
     et2sys[(UAENOMEDIUM - ERROR_TABLE_BASE_uae)] = ENOMEDIUM;
     et2sys[(UAEMEDIUMTYPE - ERROR_TABLE_BASE_uae)] = EMEDIUMTYPE;
+    et2sys[(UAECANCELED - ERROR_TABLE_BASE_uae)] = ECANCELED;
+    et2sys[(UAENOTRECOVERABLE - ERROR_TABLE_BASE_uae)] = ENOTRECOVERABLE;
+    et2sys[(UAENOTSUP - ERROR_TABLE_BASE_uae)] = ENOTSUP;
+    et2sys[(UAEOTHER - ERROR_TABLE_BASE_uae)] = EOTHER;
+    et2sys[(UAEOWNERDEAD - ERROR_TABLE_BASE_uae)] = EOWNERDEAD;
+    et2sys[(UAEPROCLIM - ERROR_TABLE_BASE_uae)] = EPROCLIM;
+    et2sys[(UAEDISCON - ERROR_TABLE_BASE_uae)] = EDISCON;
 }
 
 afs_int32
diff --git a/src/afs/afs_fetchstore.c b/src/afs/afs_fetchstore.c
index df31f4348..e2b3f2b4f 100644
--- a/src/afs/afs_fetchstore.c
+++ b/src/afs/afs_fetchstore.c
@@ -25,15 +25,15 @@ extern int cacheDiskType;
 
 #ifndef AFS_NOSTATS
 static void
-FillStoreStats(int code, int idx, osi_timeval_t xferStartTime,
+FillStoreStats(int code, int idx, osi_timeval32_t xferStartTime,
 	       afs_size_t bytesToXfer, afs_size_t bytesXferred)
 {
     struct afs_stats_xferData *xferP;
-    osi_timeval_t xferStopTime;
-    osi_timeval_t elapsedTime;
+    osi_timeval32_t xferStopTime;
+    osi_timeval32_t elapsedTime;
 
     xferP = &(afs_stats_cmfullperf.rpc.fsXferTimes[idx]);
-    osi_GetuTime(&xferStopTime);
+    osi_GetTime(&xferStopTime);
     (xferP->numXfers)++;
     if (!code) {
 	(xferP->numSuccesses)++;
@@ -270,6 +270,9 @@ afs_GenericStoreProc(struct storeOps *ops, void *rock,
     size = tdc->f.chunkBytes;
 
     tfile = afs_CFileOpen(&tdc->f.inode);
+    if (!tfile) {
+	return EIO;
+    }
 
     while ( size > 0 ) {
 	code = (*ops->prepare)(rock, size, &tlen);
@@ -323,12 +326,8 @@ struct storeOps rxfs_storeUfsOps = {
     .padd =	rxfs_storePadd,
     .close =	rxfs_storeClose,
     .destroy =	rxfs_storeDestroy,
-#if 0 && defined(AFS_LINUX26_ENV)
-    .storeproc = afs_linux_storeproc
-#else
     .storeproc = afs_GenericStoreProc
 #endif
-#endif
 };
 
 static
@@ -403,8 +402,8 @@ rxfs_storeInit(struct vcache *avc, struct afs_conn *tc,
 	code = -1;
     RX_AFS_GLOCK();
     if (code) {
-	osi_FreeSmallSpace(v);
-        return code;
+        *rock = v;
+        return rxfs_storeDestroy(rock, code);
     }
     if (cacheDiskType == AFS_FCACHE_TYPE_UFS) {
 	v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
@@ -418,19 +417,6 @@ rxfs_storeInit(struct vcache *avc, struct afs_conn *tc,
 	    osi_Panic
             ("rxfs_storeInit: osi_AllocSmallSpace for iovecs returned NULL\n");
 	*ops = (struct storeOps *) &rxfs_storeMemOps;
-#ifdef notdef
-	/* do this at a higher level now -- it's a parameter */
-	/* for now, only do 'continue from close' code if file fits in one
-	 * chunk.  Could clearly do better: if only one modified chunk
-	 * then can still do this.  can do this on *last* modified chunk */
-	length = avc->f.m.Length - 1; /* byte position of last byte we'll store */
-	if (shouldWake) {
-	    if (AFS_CHUNK(length) != 0)
-		*shouldWake = 0;
-	    else
-		*shouldWake = 1;
-	}
-#endif /* notdef */
     }
 
     *rock = (void *)v;
@@ -464,7 +450,7 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist,
     afs_size_t bytesXferred;
 
 #ifndef AFS_NOSTATS
-    osi_timeval_t xferStartTime;	/*FS xfer start time */
+    osi_timeval32_t xferStartTime;	/*FS xfer start time */
     afs_size_t bytesToXfer = 10000;	/* # bytes to xfer */
 #endif /* AFS_NOSTATS */
     XSTATS_DECLS;
@@ -508,7 +494,7 @@ afs_CacheStoreDCaches(struct vcache *avc, struct dcache **dclist,
 	 */
 	bytesToXfer = size;
 
-	osi_GetuTime(&xferStartTime);
+	osi_GetTime(&xferStartTime);
 #endif /* AFS_NOSTATS */
 	bytesXferred = 0;
 
@@ -1070,8 +1056,8 @@ rxfs_fetchInit(struct afs_conn *tc, struct rx_connection *rxconn,
     }
 
     if (code) {
-	osi_FreeSmallSpace(v);
-        return code;
+        *rock = v;
+        return rxfs_fetchDestroy(rock, code);
     }
     if (cacheDiskType == AFS_FCACHE_TYPE_UFS) {
 	v->tbuffer = osi_AllocLargeSpace(AFS_LRALLOCSIZ);
@@ -1130,7 +1116,7 @@ afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn,
 
     XSTATS_DECLS;
 #ifndef AFS_NOSTATS
-    osi_timeval_t xferStartTime;	/*FS xfer start time */
+    osi_timeval32_t xferStartTime;	/*FS xfer start time */
     afs_size_t bytesToXfer = 0, bytesXferred = 0;
 #endif
 
@@ -1148,16 +1134,20 @@ afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn,
 		tc, rxconn, avc, base, size, &length, adc, fP, &ops, &rock);
 
 #ifndef AFS_NOSTATS
-    osi_GetuTime(&xferStartTime);
+    osi_GetTime(&xferStartTime);
 #endif /* AFS_NOSTATS */
 
     adc->validPos = base;
 
-    if ( !code ) do {
+    if (code) {
+        goto done;
+    }
+
+    do {
 	if (avc->f.states & CForeign) {
 	    code = (*ops->more)(rock, &length, &moredata);
 	    if ( code )
-		break;
+		goto done;
 	}
 #ifndef AFS_NOSTATS
 	bytesToXfer += length;
@@ -1180,11 +1170,11 @@ afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn,
 			   ICL_TYPE_POINTER, avc, ICL_TYPE_INT32, code,
 			   ICL_TYPE_INT32, length);
 		code = -34;
-		break;
+		goto done;
 	    }
 	    code = (*ops->write)(rock, fP, offset, bytesread, &byteswritten);
 	    if ( code )
-		break;
+		goto done;
 	    offset += bytesread;
 	    base += bytesread;
 	    length -= bytesread;
@@ -1197,6 +1187,7 @@ afs_CacheFetchProc(struct afs_conn *tc, struct rx_connection *rxconn,
 	}
 	code = 0;
     } while (moredata);
+ done:
     if (!code)
 	code = (*ops->close)(rock, avc, adc, tsmall);
     if (ops)
diff --git a/src/afs/afs_icl.c b/src/afs/afs_icl.c
index 558d42a4a..6e4ce63f1 100644
--- a/src/afs/afs_icl.c
+++ b/src/afs/afs_icl.c
@@ -614,7 +614,7 @@ afs_icl_AppendRecord(struct afs_icl_log *logp, afs_int32 op,
 {
     int rsize;			/* record size in longs */
     int tsize;		/* temp size */
-    osi_timeval_t tv;
+    osi_timeval32_t tv;
     int t1, t2, t3, t4;
 
     t4 = types & 0x3f;		/* decode types */
diff --git a/src/afs/afs_init.c b/src/afs/afs_init.c
index acc7bef66..5d723197d 100644
--- a/src/afs/afs_init.c
+++ b/src/afs/afs_init.c
@@ -99,6 +99,7 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
 	      afs_int32 dynamic_vcaches)
 {
     afs_int32 i;
+    int code;
     struct volume *tv;
 
     AFS_STATCNT(afs_CacheInit);
@@ -152,7 +153,10 @@ afs_CacheInit(afs_int32 astatSize, afs_int32 afiles, afs_int32 ablocks,
     afs_cacheFiles = afiles;
     afs_cacheStats = astatSize;
     afs_vcacheInit(astatSize);
-    afs_dcacheInit(afiles, ablocks, aDentries, achunk, aflags);
+    code = afs_dcacheInit(afiles, ablocks, aDentries, achunk, aflags);
+    if (code) {
+        return code;
+    }
 #if defined(AFS_LINUX26_ENV) && defined(STRUCT_TASK_STRUCT_HAS_CRED)
     /*
      * Save current credentials for later access to disk cache files.
@@ -330,6 +334,9 @@ afs_InitVolumeInfo(char *afile)
     if (code)
 	return code;
     tfile = afs_CFileOpen(&volumeInode);
+    if (!tfile) {
+	return EIO;
+    }
     afs_CFileTruncate(tfile, 0);
     afs_CFileClose(tfile);
     return 0;
@@ -427,7 +434,7 @@ afs_InitCacheInfo(char *afile)
 #elif defined(AFS_DARWIN80_ENV)
         afs_cacheVfsp = vnode_mount(filevp);
 	if (afs_cacheVfsp && ((st = *(vfs_statfs(afs_cacheVfsp))),1))
-#elif defined(AFS_FBSD80_ENV)
+#elif defined(AFS_FBSD_ENV)
 	if (!VFS_STATFS(filevp->v_mount, &st))
 #elif defined(AFS_NBSD50_ENV)
 	if (!VFS_STATVFS(filevp->v_vfsp, &st))
@@ -692,7 +699,7 @@ void
 shutdown_cache(void)
 {
     AFS_STATCNT(shutdown_cache);
-    afs_WriteThroughDSlots();
+    osi_Assert(afs_WriteThroughDSlots() == 0);
     if (1/*afs_cold_shutdown*/) {
 	afs_cacheinit_flag = 0;
 	shutdown_dcache();
@@ -815,62 +822,67 @@ shutdown_AFS(void)
     int i;
 
     AFS_STATCNT(shutdown_AFS);
-    if (afs_cold_shutdown) {
-	afs_resourceinit_flag = 0;
 
-	shutdown_volume();
+    afs_resourceinit_flag = 0;
 
-	/*
-	 * Free FreeVolList allocations
-	 */
-	afs_osi_Free(Initialafs_freeVolList,
-		     afs_memvolumes * sizeof(struct volume));
-	afs_freeVolList = Initialafs_freeVolList = 0;
-
-	/* XXX HACK for MEM systems XXX
-	 *
-	 * For -memcache cache managers when we run out of free in memory volumes
-	 * we simply malloc more; we won't be able to free those additional volumes.
-	 */
+    shutdown_volume();
 
-	/*
-	 * Free Users table allocation
-	 */
-	{
-	    struct unixuser *tu, *ntu;
-	    for (i = 0; i < NUSERS; i++) {
-		for (tu = afs_users[i]; tu; tu = ntu) {
-		    ntu = tu->next;
-		    if (tu->tokens)
-			afs_FreeTokens(&tu->tokens);
-		    if (tu->exporter)
-			EXP_RELE(tu->exporter);
-		    afs_osi_Free(tu, sizeof(struct unixuser));
-		}
-		afs_users[i] = 0;
+    /*
+     * Free FreeVolList allocations
+     */
+    afs_osi_Free(Initialafs_freeVolList,
+		 afs_memvolumes * sizeof(struct volume));
+    afs_freeVolList = Initialafs_freeVolList = NULL;
+
+    /* XXX HACK for MEM systems XXX
+     *
+     * For -memcache cache managers when we run out of free in memory volumes
+     * we simply malloc more; we won't be able to free those additional volumes.
+     */
+
+    /*
+     * Free Users table allocation
+     */
+    {
+	struct unixuser *tu, *ntu;
+	for (i = 0; i < NUSERS; i++) {
+	    for (tu = afs_users[i]; tu; tu = ntu) {
+		ntu = tu->next;
+		if (tu->tokens)
+		    afs_FreeTokens(&tu->tokens);
+		if (tu->exporter)
+		    EXP_RELE(tu->exporter);
+		afs_osi_Free(tu, sizeof(struct unixuser));
 	    }
+	    afs_users[i] = NULL;
 	}
+    }
 
-	for (i = 0; i < NFENTRIES; i++)
-	    fvTable[i] = 0;
-	/* Reinitialize local globals to defaults */
-	for (i = 0; i < MAXNUMSYSNAMES; i++)
-	    afs_osi_Free(afs_sysnamelist[i], MAXSYSNAME);
-	afs_sysname = 0;
-	afs_sysnamecount = 0;
-	afs_marinerHost = 0;
-	afs_volCounter = 1;
-	afs_waitForever = afs_waitForeverCount = 0;
-	afs_FVIndex = -1;
-	afs_server = (struct rx_service *)0;
+    for (i = 0; i < NFENTRIES; i++)
+	fvTable[i] = 0;
+    /* Reinitialize local globals to defaults */
+    for (i = 0; i < MAXNUMSYSNAMES; i++) {
+	afs_osi_Free(afs_sysnamelist[i], MAXSYSNAME);
+	afs_sysnamelist[i] = NULL;
+    }
+    afs_sysname = NULL;
+    afs_sysnamecount = 0;
+    afs_marinerHost = 0;
+    afs_volCounter = 1;
+    afs_waitForever = afs_waitForeverCount = 0;
+    afs_FVIndex = -1;
+    afs_server = NULL;
+
+    if (afs_cold_shutdown) {
 	AFS_RWLOCK_INIT(&afs_xconn, "afs_xconn");
 	memset(&afs_rootFid, 0, sizeof(struct VenusFid));
 	AFS_RWLOCK_INIT(&afs_xuser, "afs_xuser");
 	AFS_RWLOCK_INIT(&afs_xvolume, "afs_xvolume");
 	AFS_RWLOCK_INIT(&afs_xserver, "afs_xserver");
 	LOCK_INIT(&afs_puttofileLock, "afs_puttofileLock");
-
-	shutdown_cell();
-	shutdown_server();
     }
+    shutdown_cell();
+    shutdown_server();
+    shutdown_rx();
+    shutdown_rxevent();
 }
diff --git a/src/afs/afs_lock.c b/src/afs/afs_lock.c
index f97e6ed65..e45023f44 100644
--- a/src/afs/afs_lock.c
+++ b/src/afs/afs_lock.c
@@ -122,13 +122,13 @@ ReleaseLock(struct afs_lock *lock, int how)
 void
 Afs_Lock_Obtain(struct afs_lock *lock, int how)
 {
-    osi_timeval_t tt1, tt2, et;
+    osi_timeval32_t tt1, tt2, et;
     afs_uint32 us;
 
     AFS_STATCNT(Lock_Obtain);
 
     AFS_ASSERT_GLOCK();
-    osi_GetuTime(&tt1);
+    osi_GetTime(&tt1);
 
     switch (how) {
 
@@ -176,7 +176,7 @@ Afs_Lock_Obtain(struct afs_lock *lock, int how)
 	osi_Panic("afs locktype");
     }
 
-    osi_GetuTime(&tt2);
+    osi_GetTime(&tt2);
     afs_stats_GetDiff(et, tt1, tt2);
     afs_stats_AddTo((lock->time_waiting), et);
     us = (et.tv_sec << 20) + et.tv_usec;
diff --git a/src/afs/afs_mariner.c b/src/afs/afs_mariner.c
index 30ec11ea3..0ae4d3cd2 100644
--- a/src/afs/afs_mariner.c
+++ b/src/afs/afs_mariner.c
@@ -104,7 +104,7 @@ afs_MarinerLog(char *astring, struct vcache *avc)
     dvec.iov_base = buf;
     dvec.iov_len = tp - buf;
     AFS_GUNLOCK();
-    (void)osi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp - buf, 0);
+    (void)rxi_NetSend(afs_server->socket, &taddr, &dvec, 1, tp - buf, 0);
     AFS_GLOCK();
     osi_FreeSmallSpace(buf);
 }				/*afs_MarinerLog */
diff --git a/src/afs/afs_nfsdisp.c b/src/afs/afs_nfsdisp.c
index 01f8e2e5d..4e5cf89f4 100644
--- a/src/afs/afs_nfsdisp.c
+++ b/src/afs/afs_nfsdisp.c
@@ -87,8 +87,8 @@ is_afs_fh(fhandle_t * fhp)
     return 0;
 }
 
-afs_int32
-nfs2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp,
+static afs_int32
+nfs2_to_afs_call(int which, void *args, fhandle_t ** fhpp,
 		 fhandle_t ** fh2pp)
 {
     struct vnode *vp;
@@ -97,84 +97,84 @@ nfs2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp,
     int errorcode;
 
     afs_Trace1(afs_iclSetp, CM_TRACE_NFSIN, ICL_TYPE_INT32, which);
-    *fh2pp = (fhandle_t *) 0;
+    *fh2pp = NULL;
     switch (which) {
     case RFS_GETATTR:
     case RFS_READLINK:
     case RFS_STATFS:
-	fhp1 = (fhandle_t *) args;
+	fhp1 = args;
 	break;
     case RFS_SETATTR:
 	{
-	    struct nfssaargs *sargs = (struct nfssaargs *)args;
+	    struct nfssaargs *sargs = args;
 	    fhp1 = (fhandle_t *) & sargs->saa_fh;
 	    break;
 	}
     case RFS_LOOKUP:
 	{
-	    struct nfsdiropargs *sargs = (struct nfsdiropargs *)args;
+	    struct nfsdiropargs *sargs = args;
 	    fhp1 = sargs->da_fhandle;
 	    break;
 	}
     case RFS_READ:
 	{
-	    struct nfsreadargs *sargs = (struct nfsreadargs *)args;
+	    struct nfsreadargs *sargs = args;
 	    fhp1 = (fhandle_t *) & sargs->ra_fhandle;
 	    break;
 	}
     case RFS_WRITE:
 	{
-	    struct nfswriteargs *sargs = (struct nfswriteargs *)args;
+	    struct nfswriteargs *sargs = args;
 	    fhp1 = (fhandle_t *) & sargs->wa_fhandle;
 	    break;
 	}
     case RFS_CREATE:
 	{
-	    struct nfscreatargs *sargs = (struct nfscreatargs *)args;
+	    struct nfscreatargs *sargs = args;
 	    fhp1 = sargs->ca_da.da_fhandle;
 	    break;
 	}
     case RFS_REMOVE:
 	{
-	    struct nfsdiropargs *sargs = (struct nfsdiropargs *)args;
+	    struct nfsdiropargs *sargs = args;
 	    fhp1 = sargs->da_fhandle;
 	    break;
 	}
     case RFS_RENAME:
 	{
-	    struct nfsrnmargs *sargs = (struct nfsrnmargs *)args;
+	    struct nfsrnmargs *sargs = args;
 	    fhp1 = sargs->rna_from.da_fhandle;
 	    fhp2 = sargs->rna_to.da_fhandle;
 	    break;
 	}
     case RFS_LINK:
 	{
-	    struct nfslinkargs *sargs = (struct nfslinkargs *)args;
+	    struct nfslinkargs *sargs = args;
 	    fhp1 = sargs->la_from;
 	    fhp2 = sargs->la_to.da_fhandle;
 	    break;
 	}
     case RFS_SYMLINK:
 	{
-	    struct nfsslargs *sargs = (struct nfsslargs *)args;
+	    struct nfsslargs *sargs = args;
 	    fhp1 = sargs->sla_from.da_fhandle;
 	    break;
 	}
     case RFS_MKDIR:
 	{
-	    struct nfscreatargs *sargs = (struct nfscreatargs *)args;
+	    struct nfscreatargs *sargs = args;
 	    fhp1 = sargs->ca_da.da_fhandle;
 	    break;
 	}
     case RFS_RMDIR:
 	{
-	    struct nfsdiropargs *sargs = (struct nfsdiropargs *)args;
+	    struct nfsdiropargs *sargs = args;
 	    fhp1 = sargs->da_fhandle;
 	    break;
 	}
     case RFS_READDIR:
 	{
-	    struct nfsrddirargs *sargs = (struct nfsrddirargs *)args;
+	    struct nfsrddirargs *sargs = args;
 	    fhp1 = (fhandle_t *) & sargs->rda_fh;
 	    break;
 	}
@@ -197,8 +197,8 @@ nfs2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp,
     return NULL;
 }
 
-afs_int32
-acl2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp)
+static afs_int32
+acl2_to_afs_call(int which, void *args, fhandle_t ** fhpp)
 {
     fhandle_t *fhp;
 
@@ -209,32 +209,32 @@ acl2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp)
 	}
     case ACLPROC2_GETACL:
 	{
-	    struct GETACL2args *sargs = (struct GETACL2args *)args;
+	    struct GETACL2args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
     case ACLPROC2_SETACL:
 	{
-	    struct SETACL2args *sargs = (struct SETACL2args *)args;
+	    struct SETACL2args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
     case ACLPROC2_GETATTR:
 	{
-	    struct GETATTR2args *sargs = (struct GETATTR2args *)args;
+	    struct GETATTR2args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
     case ACLPROC2_ACCESS:
 	{
-	    struct ACCESS2args *sargs = (struct ACCESS2args *)args;
+	    struct ACCESS2args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
 #if defined(AFS_SUN510_ENV)
     case ACLPROC2_GETXATTRDIR:
 	{
-	    struct GETXATTRDIR2args *sargs = (struct GETXATTRDIR2args *)args;
+	    struct GETXATTRDIR2args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
@@ -251,17 +251,17 @@ acl2_to_afs_call(int which, caddr_t * args, fhandle_t ** fhpp)
     return NULL;
 }
 
-int
-afs_nfs2_dispatcher(int type, afs_int32 which, char *argp,
-		    struct exportinfo **expp, struct svc_req *rp,
+static int
+afs_nfs2_dispatcher(int type, afs_int32 which, void *argp,
+		    struct exportinfo *exp, struct svc_req *rp,
 		    afs_ucred_t *crp)
 {
     afs_int32 call = 0;
     afs_int32 code = 0;
     afs_int32 client = 0;
     struct sockaddr *sa;
-    fhandle_t *fh = (fhandle_t *) argp;
-    fhandle_t *fh2 = (fhandle_t *) 0;
+    fhandle_t *fh = argp;
+    fhandle_t *fh2 = NULL;
 
     if (!xlatorinit_v2_done)
 	return 2;
@@ -289,20 +289,19 @@ afs_nfs2_dispatcher(int type, afs_int32 which, char *argp,
 	static int once = 0;
 	struct SmallFid Sfid;
 
-	memcpy((char *)&Sfid, fh->fh_data, SIZEOF_SMALLFID);
+	memcpy(&Sfid, fh->fh_data, SIZEOF_SMALLFID);
 
 	afs_Trace2(afs_iclSetp, CM_TRACE_NFSIN1, ICL_TYPE_POINTER, client,
 		   ICL_TYPE_FID, &Sfid);
 
 	/* We ran */
 	call = 1;
-	if (!once && *expp) {
-	    afs_nobody = (*expp)->exi_export.ex_anon;
+	if (!once && exp) {
+	    afs_nobody = exp->exi_export.ex_anon;
 	    once = 1;
 	}
 	code =
-	    afs_nfsclient_reqhandler((struct afs_exporter *)0, &crp, client,
-				     &dummy, &out);
+	    afs_nfsclient_reqhandler(NULL, &crp, client, &dummy, &out);
 
 	if (!code && out)
 	    EXP_RELE(out);
@@ -315,7 +314,7 @@ afs_nfs2_dispatcher(int type, afs_int32 which, char *argp,
     return call;
 }
 
-void
+static void
 afs_nfs2_smallfidder(struct nfsdiropres *dr)
 {
     fhandle_t *fhp = (fhandle_t *) & dr->dr_fhandle;
@@ -324,10 +323,10 @@ afs_nfs2_smallfidder(struct nfsdiropres *dr)
 
 #if defined(AFS_SUN5_64BIT_ENV)
     /* See also afs_fid() */
-    memcpy((char *)addr, fhp->fh_data, SIZEOF_SMALLFID);
+    memcpy(addr, fhp->fh_data, SIZEOF_SMALLFID);
     addr[1] = (addr[1] >> 48) & 0xffff;
 #else
-    memcpy((char *)addr, fhp->fh_data, 2 * sizeof(long));
+    memcpy(addr, fhp->fh_data, 2 * sizeof(long));
 #endif
 
     AFS_GLOCK();
@@ -346,7 +345,7 @@ afs_nfs2_smallfidder(struct nfsdiropres *dr)
 	    afs_PutCell(tcell, READ_LOCK);
 	    Sfid.Vnode = (u_short) (vcp->f.fid.Fid.Vnode & 0xffff);
 	    fhp->fh_len = SIZEOF_SMALLFID;
-	    memcpy(dr->dr_fhandle.fh_data, (char *)&Sfid, fhp->fh_len);
+	    memcpy(dr->dr_fhandle.fh_data, &Sfid, fhp->fh_len);
 
 	    afs_Trace3(afs_iclSetp, CM_TRACE_NFSOUT, ICL_TYPE_INT32, 0,
 		       ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid);
@@ -359,66 +358,66 @@ afs_nfs2_smallfidder(struct nfsdiropres *dr)
     AFS_GUNLOCK();
 }
 
-void
+static void
 afs_nfs2_noaccess(struct afs_nfs2_resp *resp)
 {
     resp->status = NFSERR_ACCES;
 }
 
-void
-afs_nfs2_null(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_null(void *args, void *xp, void *exp, void *rp, void *crp)
 {
 }
 
-void
-afs_nfs2_root(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_root(void *args, void *xp, void *exp, void *rp, void *crp)
 {
 }
 
-void
-afs_nfs2_writecache(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_writecache(void *args, void *xp, void *exp, void *rp, void *crp)
 {
 }
 
-void
-afs_nfs2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_getattr(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_GETATTR, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_GETATTR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_GETATTR].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_setattr(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_setattr(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_SETATTR, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_SETATTR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_SETATTR].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_lookup(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_LOOKUP, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_LOOKUP, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else {
 	(*afs_rfs_disp_tbl[RFS_LOOKUP].orig_proc) (args, xp, exp, rp, crp);
 	if (afs_NFSRootOnly && call)
@@ -428,60 +427,60 @@ afs_nfs2_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs2_readlink(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_readlink(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_READLINK, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_READLINK, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_READLINK].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_read(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_read(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_READ, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_READ, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_READ].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_write(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_write(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_WRITE, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_WRITE, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_WRITE].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_create(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_CREATE, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_CREATE, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else {
 	(*afs_rfs_disp_tbl[RFS_CREATE].orig_proc) (args, xp, exp, rp, crp);
 	if (afs_NFSRootOnly && call)
@@ -491,75 +490,75 @@ afs_nfs2_create(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs2_remove(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_remove(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_REMOVE, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_REMOVE, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_REMOVE].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_rename(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_rename(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_RENAME, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_RENAME, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_RENAME].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_link(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_link(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_LINK, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_LINK, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_LINK].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_symlink(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_symlink(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_SYMLINK, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_SYMLINK, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_SYMLINK].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_mkdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_MKDIR, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_MKDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else {
 	(*afs_rfs_disp_tbl[RFS_MKDIR].orig_proc) (args, xp, exp, rp, crp);
 	if (afs_NFSRootOnly && call)
@@ -569,45 +568,45 @@ afs_nfs2_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs2_rmdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_rmdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_RMDIR, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_RMDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_RMDIR].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_readdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_readdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_READDIR, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_READDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_READDIR].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
     return;
 }
 
-void
-afs_nfs2_statfs(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs2_statfs(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs2_dispatcher(0, RFS_STATFS, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs2_dispatcher(0, RFS_STATFS, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_rfs_disp_tbl[RFS_STATFS].orig_proc) (args, xp, exp, rp, crp);
     curthread->t_cred = svcred;
@@ -635,16 +634,16 @@ struct afs_nfs_disp_tbl afs_rfs_disp_tbl[RFS_NPROC] = {
     {afs_nfs2_statfs}
 };
 
-void
-afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl2_getacl(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs2_dispatcher(1, ACLPROC2_GETACL, (char *)args, &exp, rp, crp);
+	afs_nfs2_dispatcher(1, ACLPROC2_GETACL, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_acl_disp_tbl[ACLPROC2_GETACL].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -652,16 +651,16 @@ afs_acl2_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl2_setacl(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs2_dispatcher(1, ACLPROC2_SETACL, (char *)args, &exp, rp, crp);
+	afs_nfs2_dispatcher(1, ACLPROC2_SETACL, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_acl_disp_tbl[ACLPROC2_SETACL].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -669,16 +668,16 @@ afs_acl2_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl2_getattr(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, (char *)args, &exp, rp, crp);
+	afs_nfs2_dispatcher(1, ACLPROC2_GETATTR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_acl_disp_tbl[ACLPROC2_GETATTR].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -686,16 +685,16 @@ afs_acl2_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl2_access(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, (char *)args, &exp, rp, crp);
+	afs_nfs2_dispatcher(1, ACLPROC2_ACCESS, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_acl_disp_tbl[ACLPROC2_ACCESS].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -704,16 +703,16 @@ afs_acl2_access(char *args, char *xp, char *exp, char *rp, char *crp)
 }
 
 #if defined(AFS_SUN510_ENV)
-void
-afs_acl2_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl2_getxattrdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs2_dispatcher(1, ACLPROC2_GETXATTRDIR, (char *)args, &exp, rp, crp);
+	afs_nfs2_dispatcher(1, ACLPROC2_GETXATTRDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs2_noaccess((struct afs_nfs2_resp *)xp);
+	afs_nfs2_noaccess(xp);
     else
 	(*afs_acl_disp_tbl[ACLPROC2_GETXATTRDIR].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -784,22 +783,22 @@ is_afs_fh3(nfs_fh3 * fhp)
     return 0;
 }
 
-void
+static void
 afs_nfs3_noaccess(struct afs_nfs3_resp *resp)
 {
     resp->status = NFS3ERR_ACCES;
     resp->flags = FALSE;
 }
 
-void
+static void
 afs_nfs3_notsupp(struct afs_nfs3_resp *resp)
 {
     resp->status = NFS3ERR_NOTSUPP;
     resp->flags = FALSE;
 }
 
-afs_int32
-nfs3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
+static afs_int32
+nfs3_to_afs_call(int which, void *args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
 {
     struct vnode *vp;
     nfs_fh3 *fhp1 = 0;
@@ -807,133 +806,133 @@ nfs3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
     int errorcode;
 
     afs_Trace1(afs_iclSetp, CM_TRACE_NFS3IN, ICL_TYPE_INT32, which);
-    *fh2pp = (nfs_fh3 *) 0;
+    *fh2pp = NULL;
     switch (which) {
     case NFSPROC3_GETATTR:
 	{
-	    GETATTR3args *arg = (GETATTR3args *) args;
+	    GETATTR3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->object;
 	    break;
 	}
     case NFSPROC3_SETATTR:
 	{
-	    SETATTR3args *arg = (SETATTR3args *) args;
+	    SETATTR3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->object;
 	    break;
 	}
     case NFSPROC3_LOOKUP:
 	{
-	    LOOKUP3args *arg = (LOOKUP3args *) args;
+	    LOOKUP3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->what.dirp;
 	    break;
 	}
     case NFSPROC3_ACCESS:
 	{
-	    ACCESS3args *arg = (ACCESS3args *) args;
+	    ACCESS3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->object;
 	    break;
 	}
     case NFSPROC3_READLINK:
 	{
-	    READLINK3args *arg = (READLINK3args *) args;
+	    READLINK3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->symlink;
 	    break;
 	}
     case NFSPROC3_READ:
 	{
-	    READ3args *arg = (READ3args *) args;
+	    READ3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->file;
 	    break;
 	}
     case NFSPROC3_WRITE:
 	{
-	    WRITE3args *arg = (WRITE3args *) args;
+	    WRITE3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->file;
 	    break;
 	}
     case NFSPROC3_CREATE:
 	{
-	    CREATE3args *arg = (CREATE3args *) args;
+	    CREATE3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->where.dirp;
 	    break;
 	}
     case NFSPROC3_MKDIR:
 	{
-	    MKDIR3args *arg = (MKDIR3args *) args;
+	    MKDIR3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->where.dirp;
 	    break;
 	}
     case NFSPROC3_SYMLINK:
 	{
-	    SYMLINK3args *arg = (SYMLINK3args *) args;
+	    SYMLINK3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->where.dirp;
 	    break;
 	}
     case NFSPROC3_MKNOD:
 	{
-	    MKNOD3args *arg = (MKNOD3args *) args;
+	    MKNOD3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->where.dirp;
 	    break;
 	}
     case NFSPROC3_REMOVE:
 	{
-	    REMOVE3args *arg = (REMOVE3args *) args;
+	    REMOVE3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->object.dirp;
 	    break;
 	}
     case NFSPROC3_RMDIR:
 	{
-	    RMDIR3args *arg = (RMDIR3args *) args;
+	    RMDIR3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->object.dirp;
 	    break;
 	}
     case NFSPROC3_RENAME:
 	{
-	    RENAME3args *arg = (RENAME3args *) args;
+	    RENAME3args *arg = args;
 	    fhp1 = (nfs_fh3 *) arg->from.dirp;
 	    fhp2 = (nfs_fh3 *) arg->to.dirp;
 	    break;
 	}
     case NFSPROC3_LINK:
 	{
-	    LINK3args *arg = (LINK3args *) args;
+	    LINK3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->file;
 	    fhp2 = (nfs_fh3 *) arg->link.dirp;
 	    break;
 	}
     case NFSPROC3_READDIR:
 	{
-	    READDIR3args *arg = (READDIR3args *) args;
+	    READDIR3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->dir;
 	    break;
 	}
     case NFSPROC3_READDIRPLUS:
 	{
-	    READDIRPLUS3args *arg = (READDIRPLUS3args *) args;
+	    READDIRPLUS3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->dir;
 	    break;
 	}
     case NFSPROC3_FSSTAT:
 	{
-	    FSSTAT3args *arg = (FSSTAT3args *) args;
+	    FSSTAT3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->fsroot;
 	    break;
 	}
     case NFSPROC3_FSINFO:
 	{
-	    FSINFO3args *arg = (FSINFO3args *) args;
+	    FSINFO3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->fsroot;
 	    break;
 	}
     case NFSPROC3_PATHCONF:
 	{
-	    PATHCONF3args *arg = (PATHCONF3args *) args;
+	    PATHCONF3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->object;
 	    break;
 	}
     case NFSPROC3_COMMIT:
 	{
-	    COMMIT3args *arg = (COMMIT3args *) args;
+	    COMMIT3args *arg = args;
 	    fhp1 = (nfs_fh3 *) & arg->file;
 	    break;
 	}
@@ -955,28 +954,28 @@ nfs3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp, nfs_fh3 ** fh2pp)
     return NULL;
 }
 
-afs_int32
-acl3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp)
+static afs_int32
+acl3_to_afs_call(int which, void *args, nfs_fh3 ** fhpp)
 {
     nfs_fh3 *fhp;
 
     switch (which) {
     case ACLPROC3_GETACL:
 	{
-	    struct GETACL3args *sargs = (struct GETACL3args *)args;
+	    struct GETACL3args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
     case ACLPROC3_SETACL:
 	{
-	    struct SETACL3args *sargs = (struct SETACL3args *)args;
+	    struct SETACL3args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
 #if defined(AFS_SUN510_ENV)
     case ACLPROC3_GETXATTRDIR:
 	{
-	    struct GETXATTRDIR3args *sargs = (struct GETXATTRDIR3args *)args;
+	    struct GETXATTRDIR3args *sargs = args;
 	    fhp = &sargs->fh;
 	    break;
 	}
@@ -993,9 +992,9 @@ acl3_to_afs_call(int which, caddr_t * args, nfs_fh3 ** fhpp)
     return NULL;
 }
 
-int
-afs_nfs3_dispatcher(int type, afs_int32 which, char *argp,
-		    struct exportinfo **expp, struct svc_req *rp,
+static int
+afs_nfs3_dispatcher(int type, afs_int32 which, void *argp,
+		    struct exportinfo *exp, struct svc_req *rp,
 		    afs_ucred_t *crp)
 {
     afs_int32 call = 0;
@@ -1010,7 +1009,7 @@ afs_nfs3_dispatcher(int type, afs_int32 which, char *argp,
 
     sa = (struct sockaddr *)svc_getrpccaller(rp->rq_xprt)->buf;
     if (sa == NULL)
-	return;
+	return 3;
 
     if (sa->sa_family == AF_INET)
 	client = ((struct sockaddr_in *)sa)->sin_addr.s_addr;
@@ -1034,14 +1033,14 @@ afs_nfs3_dispatcher(int type, afs_int32 which, char *argp,
 	static int once = 0;
 	struct SmallFid Sfid;
 
-	memcpy((char *)&Sfid, fh->fh3_data, SIZEOF_SMALLFID);
+	memcpy(&Sfid, fh->fh3_data, SIZEOF_SMALLFID);
 
 	afs_Trace2(afs_iclSetp, CM_TRACE_NFS3IN1, ICL_TYPE_INT32, client,
 		   ICL_TYPE_FID, &Sfid);
 
 	call = 1;
-	if (!once && *expp) {
-	    afs_nobody = (*expp)->exi_export.ex_anon;
+	if (!once && exp) {
+	    afs_nobody = exp->exi_export.ex_anon;
 	    once = 1;
 	}
 	code =
@@ -1060,7 +1059,7 @@ afs_nfs3_dispatcher(int type, afs_int32 which, char *argp,
     return call;
 }
 
-void
+static void
 afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status)
 {
     afs_int32 addr[2];
@@ -1068,10 +1067,10 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status)
 
 #if defined(AFS_SUN5_64BIT_ENV)
     /* See also afs_fid() */
-    memcpy((char *)addr, fhp->fh3_data, 10);
+    memcpy(addr, fhp->fh3_data, 10);
     addr[1] = (addr[1] >> 48) & 0xffff;
 #else
-    memcpy((char *)addr, fhp->fh3_data, 2 * sizeof(long));
+    memcpy(addr, fhp->fh3_data, 2 * sizeof(long));
 #endif
 
     AFS_GLOCK();
@@ -1091,7 +1090,7 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status)
 	    afs_PutCell(tcell, READ_LOCK);
 	    Sfid.Vnode = (u_short) (vcp->f.fid.Fid.Vnode & 0xffff);
 	    fhp->fh3_len = SIZEOF_SMALLFID;
-	    memcpy(fhp->fh3_data, (char *)&Sfid, fhp->fh3_len);
+	    memcpy(fhp->fh3_data, &Sfid, fhp->fh3_len);
 
 	    afs_Trace3(afs_iclSetp, CM_TRACE_NFS3OUT, ICL_TYPE_INT32, status,
 		       ICL_TYPE_POINTER, vcp, ICL_TYPE_FID, &Sfid);
@@ -1104,17 +1103,17 @@ afs_nfs3_smallfidder(struct nfs_fh3 *fhp, int status)
     AFS_GUNLOCK();
 }
 
-void
-afs_nfs3_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_getattr(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_GETATTR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_GETATTR].orig_proc) (args, xp, exp, rp,
 							  crp);
@@ -1122,17 +1121,17 @@ afs_nfs3_getattr(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_setattr(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_setattr(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_SETATTR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_SETATTR].orig_proc) (args, xp, exp, rp,
 							  crp);
@@ -1140,22 +1139,22 @@ afs_nfs3_setattr(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_lookup(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_LOOKUP, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else {
 	(*afs_rfs3_disp_tbl[NFSPROC3_LOOKUP].orig_proc) (args, xp, exp, rp,
 							 crp);
 	if (afs_NFSRootOnly && call) {
-	    LOOKUP3res *resp = (LOOKUP3res *) xp;
+	    LOOKUP3res *resp = xp;
 	    afs_nfs3_smallfidder(&resp->resok.object, resp->status);
 	}
     }
@@ -1163,17 +1162,17 @@ afs_nfs3_lookup(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_access(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_access(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_ACCESS, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_ACCESS].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1181,18 +1180,18 @@ afs_nfs3_access(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_readlink(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_readlink(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_READLINK, (char *)args, &exp, rp,
+	afs_nfs3_dispatcher(0, NFSPROC3_READLINK, args, exp, rp,
 			    crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_READLINK].orig_proc) (args, xp, exp, rp,
 							   crp);
@@ -1200,16 +1199,16 @@ afs_nfs3_readlink(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_read(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_read(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs3_dispatcher(0, NFSPROC3_READ, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs3_dispatcher(0, NFSPROC3_READ, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_READ].orig_proc) (args, xp, exp, rp,
 						       crp);
@@ -1217,17 +1216,17 @@ afs_nfs3_read(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_write(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_write(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_WRITE, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_WRITE, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_WRITE].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -1235,17 +1234,17 @@ afs_nfs3_write(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_create(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_create(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_CREATE, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_CREATE, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else {
 	(*afs_rfs3_disp_tbl[NFSPROC3_CREATE].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1258,17 +1257,17 @@ afs_nfs3_create(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_mkdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_MKDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else {
 	(*afs_rfs3_disp_tbl[NFSPROC3_MKDIR].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -1281,17 +1280,17 @@ afs_nfs3_mkdir(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_symlink(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_symlink(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_SYMLINK, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else {
 	(*afs_rfs3_disp_tbl[NFSPROC3_SYMLINK].orig_proc) (args, xp, exp, rp,
 							  crp);
@@ -1304,22 +1303,22 @@ afs_nfs3_symlink(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_mknod(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_mknod(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_MKNOD, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else {
 	(*afs_rfs3_disp_tbl[NFSPROC3_MKNOD].orig_proc) (args, xp, exp, rp,
 							crp);
 	if (afs_NFSRootOnly && call) {
-	    MKNOD3res *resp = (MKNOD3res *) xp;
+	    MKNOD3res *resp = xp;
 	    afs_nfs3_smallfidder(&resp->resok.obj.handle, resp->status);
 	}
     }
@@ -1327,17 +1326,17 @@ afs_nfs3_mknod(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_remove(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_remove(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_REMOVE, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_REMOVE].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1345,17 +1344,17 @@ afs_nfs3_remove(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_rmdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_rmdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_RMDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_RMDIR].orig_proc) (args, xp, exp, rp,
 							crp);
@@ -1363,17 +1362,17 @@ afs_nfs3_rmdir(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_rename(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_rename(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_RENAME, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_RENAME, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_RENAME].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1381,16 +1380,16 @@ afs_nfs3_rename(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_link(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_link(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
-    call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, (char *)args, &exp, rp, crp);
+    curthread->t_cred = crp;
+    call = afs_nfs3_dispatcher(0, NFSPROC3_LINK, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_LINK].orig_proc) (args, xp, exp, rp,
 						       crp);
@@ -1398,17 +1397,17 @@ afs_nfs3_link(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_readdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_readdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_READDIR, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_READDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_READDIR].orig_proc) (args, xp, exp, rp,
 							  crp);
@@ -1416,20 +1415,20 @@ afs_nfs3_readdir(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_readdirplus(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_readdirplus(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, (char *)args, &exp, rp,
+	afs_nfs3_dispatcher(0, NFSPROC3_READDIRPLUS, args, exp, rp,
 			    crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else if (call == 1)
-	afs_nfs3_notsupp((struct afs_nfs3_resp *)xp);
+	afs_nfs3_notsupp(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_READDIRPLUS].orig_proc) (args, xp, exp,
 							      rp, crp);
@@ -1437,17 +1436,17 @@ afs_nfs3_readdirplus(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_fsstat(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_fsstat(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_FSSTAT, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_FSSTAT].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1455,17 +1454,17 @@ afs_nfs3_fsstat(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_fsinfo(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_fsinfo(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_FSINFO, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_FSINFO].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1473,18 +1472,18 @@ afs_nfs3_fsinfo(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_pathconf(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_pathconf(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, (char *)args, &exp, rp,
+	afs_nfs3_dispatcher(0, NFSPROC3_PATHCONF, args, exp, rp,
 			    crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_PATHCONF].orig_proc) (args, xp, exp, rp,
 							   crp);
@@ -1492,17 +1491,17 @@ afs_nfs3_pathconf(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_nfs3_commit(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_nfs3_commit(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_nfs3_resp dummy;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(0, NFSPROC3_COMMIT, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_rfs3_disp_tbl[NFSPROC3_COMMIT].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1535,16 +1534,16 @@ struct afs_nfs_disp_tbl afs_rfs3_disp_tbl[22] = {
     {afs_nfs3_commit}
 };
 
-void
-afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl3_getacl(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(1, ACLPROC3_GETACL, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(1, ACLPROC3_GETACL, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_acl3_disp_tbl[ACLPROC3_GETACL].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1552,16 +1551,16 @@ afs_acl3_getacl(char *args, char *xp, char *exp, char *rp, char *crp)
     return;
 }
 
-void
-afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl3_setacl(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(1, ACLPROC3_SETACL, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(1, ACLPROC3_SETACL, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_acl3_disp_tbl[ACLPROC3_SETACL].orig_proc) (args, xp, exp, rp,
 							 crp);
@@ -1570,16 +1569,16 @@ afs_acl3_setacl(char *args, char *xp, char *exp, char *rp, char *crp)
 }
 
 #if defined(AFS_SUN510_ENV)
-void
-afs_acl3_getxattrdir(char *args, char *xp, char *exp, char *rp, char *crp)
+static void
+afs_acl3_getxattrdir(void *args, void *xp, void *exp, void *rp, void *crp)
 {
     u_int call;
     afs_ucred_t *svcred = curthread->t_cred;
-    curthread->t_cred = (afs_ucred_t *)crp;
+    curthread->t_cred = crp;
     call =
-	afs_nfs3_dispatcher(1, ACLPROC3_GETXATTRDIR, (char *)args, &exp, rp, crp);
+	afs_nfs3_dispatcher(1, ACLPROC3_GETXATTRDIR, args, exp, rp, crp);
     if (call > 1)
-	afs_nfs3_noaccess((struct afs_nfs3_resp *)xp);
+	afs_nfs3_noaccess(xp);
     else
 	(*afs_acl3_disp_tbl[ACLPROC3_GETXATTRDIR].orig_proc) (args, xp, exp, rp,
 							 crp);
diff --git a/src/afs/afs_osi.c b/src/afs/afs_osi.c
index 93983766f..1289d2292 100644
--- a/src/afs/afs_osi.c
+++ b/src/afs/afs_osi.c
@@ -138,6 +138,9 @@ afs_osi_MaskSignals(void)
 void
 afs_osi_UnmaskRxkSignals(void)
 {
+#ifdef AFS_LINUX22_ENV
+    osi_linux_unmaskrxk();
+#endif
 }
 
 /* Two hacks to try and fix afsdb */
@@ -207,73 +210,6 @@ afs_osi_Visible(void)
 #endif
 }
 
-#if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV)
-/* set the real time */
-void
-afs_osi_SetTime(osi_timeval_t * atv)
-{
-#if defined(AFS_AIX32_ENV)
-    struct timestruc_t t;
-
-    t.tv_sec = atv->tv_sec;
-    t.tv_nsec = atv->tv_usec * 1000;
-    ksettimer(&t);		/*  Was -> settimer(TIMEOFDAY, &t); */
-#elif defined(AFS_SUN5_ENV)
-    stime(atv->tv_sec);
-#elif defined(AFS_SGI_ENV)
-    struct stimea {
-	sysarg_t time;
-    } sta;
-
-    AFS_GUNLOCK();
-    sta.time = atv->tv_sec;
-    stime(&sta);
-    AFS_GLOCK();
-#elif defined(AFS_DARWIN_ENV)
-#ifndef AFS_DARWIN80_ENV
-    AFS_GUNLOCK();
-    setthetime(atv);
-    AFS_GLOCK();
-#endif
-#else
-    /* stolen from kern_time.c */
-#ifndef	AFS_AUX_ENV
-    boottime.tv_sec += atv->tv_sec - time.tv_sec;
-#endif
-#ifdef AFS_HPUX_ENV
-    {
-#if !defined(AFS_HPUX1122_ENV)
-	/* drop the setting of the clock for now. spl7 is not
-	 * known on hpux11.22
-	 */
-	ulong_t s;
-	struct timeval t;
-	t.tv_sec = atv->tv_sec;
-	t.tv_usec = atv->tv_usec;
-	s = spl7();
-	time = t;
-	(void)splx(s);
-	resettodr(atv);
-#endif
-    }
-#else
-    {
-	int s;
-	s = splclock();
-	time = *atv;
-	(void)splx(s);
-    }
-    resettodr();
-#endif
-#ifdef	AFS_AUX_ENV
-    logtchg(atv->tv_sec);
-#endif
-#endif /* AFS_DARWIN_ENV */
-    AFS_STATCNT(osi_SetTime);
-}
-#endif /* AFS_LINUX20_ENV */
-
-
 void
 shutdown_osi(void)
 {
@@ -327,7 +263,7 @@ shutdown_osisleep(void)
 
 #if !defined(AFS_OBSD_ENV) && !defined(AFS_NBSD40_ENV)
 int
-afs_osi_suser(void *cr)
+afs_osi_suser(afs_ucred_t *cr)
 {
 #if defined(AFS_SUN510_ENV)
     return (priv_policy(cr, PRIV_SYS_SUSER_COMPAT, B_FALSE, EPERM, NULL) == 0);
diff --git a/src/afs/afs_osi.h b/src/afs/afs_osi.h
index af1c426be..b28b4a774 100644
--- a/src/afs/afs_osi.h
+++ b/src/afs/afs_osi.h
@@ -134,9 +134,9 @@ struct afs_osi_WaitHandle {
  * Darwin, all of the BSDs, and Linux have their own
  */
 #if !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_LINUX20_ENV)
-# define	vType(vc)	    (vc)->v.v_type
-# define	vSetType(vc,type)   (vc)->v.v_type = (type)
-# define	vSetVfsp(vc,vfsp)   (vc)->v.v_vfsp = (vfsp)
+# define	vType(vc)	    AFSTOV(vc)->v_type
+# define	vSetType(vc,type)   AFSTOV(vc)->v_type = (type)
+# define	vSetVfsp(vc,vfsp)   AFSTOV(vc)->v_vfsp = (vfsp)
 extern struct vnodeops *afs_ops;
 # define	IsAfsVnode(v)	    ((v)->v_op == afs_ops)
 # define	SetAfsVnode(v)	    (v)->v_op = afs_ops
@@ -149,6 +149,15 @@ extern void osi_PrePopulateVCache(struct vcache *);
 extern void osi_PostPopulateVCache(struct vcache *);
 extern void osi_AttachVnode(struct vcache *, int seq);
 
+/**
+ * Increment the refcount on the given vcache.
+ *
+ * @retval 0 Success
+ * @retval nonzero Error obtaining reference; the vcache is no longer valid and
+ *		   the caller should act as if it doesn't exist.
+ */
+extern int osi_vnhold(struct vcache *);
+
 /*
  * In IRIX 6.5 and NetBSD we cannot have DEBUG turned on since certain
  * system-defined structures are a different size with DEBUG on, the
@@ -165,34 +174,14 @@ extern void osi_AttachVnode(struct vcache *, int seq);
 #endif
 
 /*
- * Time related macros
+ * We use osi_timeval32_t because the native timeval varies in size on
+ * different platforms.  We require a fixed size timeval, at least for the
+ * xstats.
  */
-#define osi_GetuTime(x) osi_GetTime(x)
-
-/* osi_timeval_t exists because SGI 6.x has two sizes of timeval. */
-/** In 64 bit Solaris the timeval structure has members that are 64 bit
-  * In the GetTime() interface we expect pointers to afs_int32. So the need to
-  * define osi_timeval_t to have 32 bit members. To make this less ambiguous
-  * we now use 32 bit quantities consistently all over the code.
-  * In 64 bit HP-UX the timeval structure has a 64 bit member.
-  */
-
-#if defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL) || (defined(AFS_SGI61_ENV) && defined(KERNEL) && defined(_K64U64))
-typedef struct {
-    afs_int32 tv_sec;
-    afs_int32 tv_usec;
-} osi_timeval_t;
 typedef struct {
     afs_int32 tv_sec;
     afs_int32 tv_usec;
 } osi_timeval32_t;
-#elif defined(AFS_SUN5_ENV)
-typedef struct timeval32 osi_timeval_t;
-typedef struct timeval32 osi_timeval32_t;
-#else
-typedef struct timeval osi_timeval_t;
-typedef struct timeval osi_timeval32_t;
-#endif /* AFS_SGI61_ENV */
 
 #ifndef UKERNEL
 #define osi_getpid() 		getpid()
@@ -239,7 +228,7 @@ typedef struct timeval osi_timeval32_t;
 
 /* On an MP that uses multithreading, splnet is not sufficient to provide
  * mutual exclusion because the other processors will not see it.  On some
- * early multiprocessors (SunOS413 & SGI5.2) splnet actually obtains a global
+ * early multiprocessors (SGI5.2) splnet actually obtains a global
  * mutex, which this works in the UP expected way, it means that the whole MP
  * can only take one interrupt at a time; a serious performance penalty. */
 
@@ -266,9 +255,6 @@ typedef struct timeval osi_timeval32_t;
  * (Also, of course, the vnode is assumed to be one of ours.  Can't use this
  * macro for V-file vnodes.)
  */
-/* osi_vnhold is defined in PLATFORM/osi_machdep.h */
-#define AFS_FAST_HOLD(vp) osi_vnhold((vp), 0)
-
 #ifdef AFS_AIX_ENV
 #define AFS_FAST_RELE(vp) VREFCOUNT_DEC(vp)
 #else
diff --git a/src/afs/afs_osi_alloc.c b/src/afs/afs_osi_alloc.c
index 1e3648af8..78254d6ac 100644
--- a/src/afs/afs_osi_alloc.c
+++ b/src/afs/afs_osi_alloc.c
@@ -52,8 +52,6 @@ afs_osi_Alloc(size_t size)
     AFS_STATS(afs_stats_cmperf.OutStandingMemUsage += size);
 #ifdef AFS_LINUX20_ENV
     return osi_linux_alloc(size, 1);
-#elif defined(AFS_FBSD_ENV)
-    return osi_fbsd_alloc(size, 1);
 #else
     return AFS_KALLOC(size);
 #endif
@@ -63,15 +61,13 @@ void
 afs_osi_Free(void *x, size_t asize)
 {
     AFS_STATCNT(osi_Free);
-    if (x == &memZero)
+    if (x == &memZero || x == NULL)
 	return;			/* check for putting memZero back */
 
     AFS_STATS(afs_stats_cmperf.OutStandingAllocs--);
     AFS_STATS(afs_stats_cmperf.OutStandingMemUsage -= asize);
 #if defined(AFS_LINUX20_ENV)
     osi_linux_free(x);
-#elif defined(AFS_FBSD_ENV)
-    osi_fbsd_free(x);
 #else
     AFS_KFREE(x, asize);
 #endif
@@ -185,26 +181,29 @@ osi_AllocSmallSpace(size_t size)
 void
 shutdown_osinet(void)
 {
-    AFS_STATCNT(shutdown_osinet);
 #ifndef AFS_PRIVATE_OSI_ALLOCSPACES
-    if (afs_cold_shutdown) {
-	struct osi_packet *tp;
+    struct osi_packet *tp;
+#endif
+
+    AFS_STATCNT(shutdown_osinet);
 
-	while ((tp = freePacketList)) {
-	    freePacketList = tp->next;
-	    afs_osi_Free(tp, AFS_LRALLOCSIZ);
+#ifndef AFS_PRIVATE_OSI_ALLOCSPACES
+    while ((tp = freePacketList)) {
+	freePacketList = tp->next;
+	afs_osi_Free(tp, AFS_LRALLOCSIZ);
 #ifdef  KERNEL_HAVE_PIN
-	    unpin(tp, AFS_LRALLOCSIZ);
+	unpin(tp, AFS_LRALLOCSIZ);
 #endif
-	}
+    }
 
-	while ((tp = freeSmallList)) {
-	    freeSmallList = tp->next;
-	    afs_osi_Free(tp, AFS_SMALLOCSIZ);
+    while ((tp = freeSmallList)) {
+	freeSmallList = tp->next;
+	afs_osi_Free(tp, AFS_SMALLOCSIZ);
 #ifdef  KERNEL_HAVE_PIN
-	    unpin(tp, AFS_SMALLOCSIZ);
+	unpin(tp, AFS_SMALLOCSIZ);
 #endif
-	}
+    }
+    if (afs_cold_shutdown) {
 	LOCK_INIT(&osi_fsplock, "osi_fsplock");
 	LOCK_INIT(&osi_flplock, "osi_flplock");
     }
diff --git a/src/afs/afs_osi_pag.c b/src/afs/afs_osi_pag.c
index 6b9ae1ff5..c0667d9e1 100644
--- a/src/afs/afs_osi_pag.c
+++ b/src/afs/afs_osi_pag.c
@@ -139,7 +139,7 @@ static int afs_pag_sleepcnt = 0;
 static int afs_pag_timewarn = 0;
 
 static int
-afs_pag_sleep(afs_ucred_t **acred)
+afs_pag_sleep(afs_ucred_t *acred)
 {
     int rv = 0;
 
@@ -160,8 +160,10 @@ afs_pag_sleep(afs_ucred_t **acred)
 }
 
 static int
-afs_pag_wait(afs_ucred_t **acred)
+afs_pag_wait(afs_ucred_t *acred)
 {
+    int code = 0;
+
     if (afs_pag_sleep(acred)) {
 	if (!afs_pag_sleepcnt) {
 	    afs_warn("%s() PAG throttling triggered, pid %d... sleeping.  sleepcnt %d\n",
@@ -171,14 +173,13 @@ afs_pag_wait(afs_ucred_t **acred)
 	afs_pag_sleepcnt++;
 
 	do {
-	    /* XXX spins on EINTR */
-	    afs_osi_Wait(1000, (struct afs_osi_WaitHandle *)0, 0);
-	} while (afs_pag_sleep(acred));
+	    code = afs_osi_Wait(1000, (struct afs_osi_WaitHandle *)0, 0);
+	} while (!code && afs_pag_sleep(acred));
 
 	afs_pag_sleepcnt--;
     }
 
-    return 0;
+    return code;
 }
 
 int
@@ -196,11 +197,11 @@ afs_setpag(void)
 {
 
 #if     defined(AFS_SUN5_ENV)
-    afs_ucred_t **acred = *credpp;
+    afs_ucred_t *acred = *credpp;
 #elif  defined(AFS_OBSD_ENV)
-    afs_ucred_t **acred = &p->p_ucred;
+    afs_ucred_t *acred = p->p_ucred;
 #else
-    afs_ucred_t **acred = NULL;
+    afs_ucred_t *acred = NULL;
 #endif
 
     int code = 0;
@@ -212,7 +213,10 @@ afs_setpag(void)
 
     AFS_STATCNT(afs_setpag);
 
-    afs_pag_wait(acred);
+    code = afs_pag_wait(acred);
+    if (code) {
+	goto done;
+    }
 
 
 #if	defined(AFS_SUN5_ENV)
@@ -271,6 +275,7 @@ afs_setpag(void)
     code = AddPag(genpag(), &u.u_cred);
 #endif
 
+  done:
     afs_Trace1(afs_iclSetp, CM_TRACE_SETPAG, ICL_TYPE_INT32, code);
 
 #if defined(KERNEL_HAVE_UERROR)
@@ -306,11 +311,11 @@ afs_setpag_val(int pagval)
 {
 
 #if     defined(AFS_SUN5_ENV)
-    afs_ucred_t **acred = *credp;
+    afs_ucred_t *acred = *credp;
 #elif  defined(AFS_OBSD_ENV)
-    afs_ucred_t **acred = &p->p_ucred;
+    afs_ucred_t *acred = p->p_ucred;
 #else
-    afs_ucred_t **acred = NULL;
+    afs_ucred_t *acred = NULL;
 #endif
 
     int code = 0;
@@ -322,7 +327,10 @@ afs_setpag_val(int pagval)
 
     AFS_STATCNT(afs_setpag);
 
-    afs_pag_wait(acred);
+    code = afs_pag_wait(acred);
+    if (code) {
+	goto done;
+    }
 
 #if	defined(AFS_SUN5_ENV)
     code = AddPag(pagval, credpp);
@@ -372,6 +380,7 @@ afs_setpag_val(int pagval)
     code = AddPag(pagval, &u.u_cred);
 #endif
 
+  done:
     afs_Trace1(afs_iclSetp, CM_TRACE_SETPAG, ICL_TYPE_INT32, code);
 #if defined(KERNEL_HAVE_UERROR)
     if (!getuerror())
diff --git a/src/afs/afs_osi_vget.c b/src/afs/afs_osi_vget.c
index 5fd36bff6..cb9c017e4 100644
--- a/src/afs/afs_osi_vget.c
+++ b/src/afs/afs_osi_vget.c
@@ -62,7 +62,7 @@ afs_osi_vget(struct vcache **avcpp, struct fid *afidp, struct vrequest *areqp)
 	/* didn't find an entry. */
 	code = afs_CreateReq(&treq, afs_osi_credp);
 	if (code == 0) {
-	    *avcpp = afs_GetVCache(&vfid, treq, NULL, NULL);
+	    *avcpp = afs_GetVCache(&vfid, treq);
 	    afs_DestroyReq(treq);
 	}
     }
diff --git a/src/afs/afs_osi_vm.c b/src/afs/afs_osi_vm.c
index fa278cb40..5c1c03aa5 100644
--- a/src/afs/afs_osi_vm.c
+++ b/src/afs/afs_osi_vm.c
@@ -93,13 +93,9 @@ osi_FlushPages(struct vcache *avc, afs_ucred_t *credp)
 	       ICL_TYPE_INT32, origDV.low, ICL_TYPE_INT32, avc->f.m.Length);
 
     ReleaseWriteLock(&avc->lock);
-#ifndef AFS_FBSD70_ENV
     AFS_GUNLOCK();
-#endif
     osi_VM_FlushPages(avc, credp);
-#ifndef AFS_FBSD70_ENV
     AFS_GLOCK();
-#endif
     ObtainWriteLock(&avc->lock, 88);
 
     /* do this last, and to original version, since stores may occur
@@ -172,77 +168,6 @@ osi_FlushText_really(struct vcache *vp)
 }
 #endif /* AFS_TEXT_ENV */
 
-/* ? is it moderately likely that there are dirty VM pages associated with
- * this vnode?
- *
- *  Prereqs:  avc must be write-locked
- *
- *  System Dependencies:  - *must* support each type of system for which
- *                          memory mapped files are supported, even if all
- *                          it does is return TRUE;
- *
- * NB:  this routine should err on the side of caution for ProcessFS to work
- *      correctly (or at least, not to introduce worse bugs than already exist)
- */
-#ifdef	notdef
-int
-osi_VMDirty_p(struct vcache *avc)
-{
-    int dirtyPages;
-
-    if (avc->execsOrWriters <= 0)
-	return 0;		/* can't be many dirty pages here, I guess */
-
-#if defined (AFS_AIX32_ENV)
-#ifdef	notdef
-    /* because of the level of hardware involvment with VM and all the
-     * warnings about "This routine must be called at VMM interrupt
-     * level", I thought it would be safest to disable interrupts while
-     * looking at the software page fault table.  */
-
-    /* convert vm handle into index into array:  I think that stoinio is
-     * always zero...  Look into this XXX  */
-#define VMHASH(handle) ( \
-			( ((handle) & ~vmker.stoinio)  \
-			 ^ ((((handle) & ~vmker.stoinio) & vmker.stoimask) << vmker.stoihash) \
-			 ) & 0x000fffff)
-
-    if (avc->segid) {
-	unsigned int pagef, pri, index, next;
-
-	index = VMHASH(avc->segid);
-	if (scb_valid(index)) {	/* could almost be an ASSERT */
-
-	    pri = disable_ints();
-	    for (pagef = scb_sidlist(index); pagef >= 0; pagef = next) {
-		next = pft_sidfwd(pagef);
-		if (pft_modbit(pagef)) {	/* has page frame been modified? */
-		    enable_ints(pri);
-		    return 1;
-		}
-	    }
-	    enable_ints(pri);
-	}
-    }
-#undef VMHASH
-#endif
-#endif /* AFS_AIX32_ENV */
-
-#if defined (AFS_SUN5_ENV)
-    if (avc->f.states & CMAPPED) {
-	struct page *pg;
-	for (pg = avc->v.v_s.v_Pages; pg; pg = pg->p_vpnext) {
-	    if (pg->p_mod) {
-		return 1;
-	    }
-	}
-    }
-#endif
-    return 0;
-}
-#endif /* notdef */
-
-
 /*
  * Solaris osi_ReleaseVM should not drop and re-obtain the vcache entry lock.
  * This leads to bad races when osi_ReleaseVM() is called from
diff --git a/src/afs/afs_osidnlc.c b/src/afs/afs_osidnlc.c
index 9d267e4c0..7c6a65c09 100644
--- a/src/afs/afs_osidnlc.c
+++ b/src/afs/afs_osidnlc.c
@@ -7,6 +7,13 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
+/*-
+ * OSI Directory Name Lookup Cache
+ *
+ * Keep a local cache of lookup results to avoid needing to examine the disk
+ * cache, for frequently accessed names.
+ */
+
 #include <afsconfig.h>
 #include "afs/param.h"
 
@@ -32,7 +39,7 @@ extern struct afs_lock afs_xvcache;
 
 dnlcstats_t dnlcstats;
 
-#define NCSIZE 300
+#define NCSIZE 4096
 #define NHSIZE 256		/* must be power of 2. == NHASHENT in dir package */
 struct nc *ncfreelist = NULL;
 static struct nc nameCache[NCSIZE];
@@ -268,7 +275,11 @@ osi_dnlc_lookup(struct vcache *adp, char *aname, int locktype)
 	    return 0;
 	}
 #else
-	osi_vnhold(tvc, 0);
+	if (osi_vnhold(tvc) != 0) {
+	    dnlcstats.misses++;
+	    osi_dnlc_remove(adp, aname, tvc);
+	    tvc = NULL;
+	}
 #endif
 	ReleaseReadLock(&afs_xvcache);
 
diff --git a/src/afs/afs_pag_cred.c b/src/afs/afs_pag_cred.c
index d6ba2bb7f..651bb3a97 100644
--- a/src/afs/afs_pag_cred.c
+++ b/src/afs/afs_pag_cred.c
@@ -231,9 +231,6 @@ SPAGCB_GetCreds(struct rx_call *a_call, afs_int32 a_uid,
     memset(a_creds, 0, sizeof(struct CredInfos));
     if ((rx_HostOf(rx_PeerOf(rx_ConnectionOf(a_call))) != afs_nfs_server_addr
 	||  rx_PortOf(rx_PeerOf(rx_ConnectionOf(a_call))) != htons(7001))
-#if 0 /* for debugging ONLY! */
-	&&  rx_PortOf(rx_PeerOf(rx_ConnectionOf(a_call))) != htons(7901)
-#endif
         ) {
 	RX_AFS_GUNLOCK();
 	return UAEPERM;
diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c
index 6c8da541c..263487967 100644
--- a/src/afs/afs_pioctl.c
+++ b/src/afs/afs_pioctl.c
@@ -828,7 +828,7 @@ afs_xioctl(afs_proc_t *p, const struct ioctl_args *uap, register_t *retval)
 #if defined(AFS_NBSD50_ENV)
     if ((fd = fd_getfile(SCARG(uap, fd))) == NULL)
 	return (EBADF);
-#elif defined(AFS_FBSD100_ENV)
+#elif defined(AFS_FBSD_ENV)
     if ((uap->fd >= fdp->fd_nfiles)
 	|| ((fd = fdp->fd_ofiles[uap->fd].fde_file) == NULL))
 	return EBADF;
@@ -887,11 +887,7 @@ afs_xioctl(afs_proc_t *p, const struct ioctl_args *uap, register_t *retval)
 
     if (!ioctlDone) {
 # if defined(AFS_FBSD_ENV)
-#  if (__FreeBSD_version >= 900044)
 	return sys_ioctl(td, uap);
-#  else
-	return ioctl(td, uap);
-#  endif
 # elif defined(AFS_OBSD_ENV)
 	code = sys_ioctl(p, uap, retval);
 # elif defined(AFS_NBSD_ENV)
@@ -1123,7 +1119,9 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
 #endif
     }
 #endif /* AFS_NEED_CLIENTCONTEXT */
-    if ((com & 0xff) == 15) {
+
+    /* VIOCPREFETCH */
+    if ((com & 0xff00) >> 8 == 'V' && (com & 0xff) == 15) {
 	/* special case prefetch so entire pathname eval occurs in helper process.
 	 * otherwise, the pioctl call is essentially useless */
 #if	defined(AFS_SUN5_ENV) || defined(AFS_AIX41_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
@@ -1258,10 +1256,10 @@ afs_syscall_pioctl(char *path, unsigned int com, caddr_t cmarg, int follow)
 	dput(dp);
 	AFS_GLOCK();
 #else
-#if defined(AFS_FBSD80_ENV)
+#if defined(AFS_FBSD_ENV)
     if (VOP_ISLOCKED(vp))
 	VOP_UNLOCK(vp, 0);
-#endif /* AFS_FBSD80_ENV */
+#endif /* AFS_FBSD_ENV */
 	AFS_RELE(vp);		/* put vnode back */
 #endif
     }
@@ -1832,19 +1830,40 @@ _settok_tokenCell(char *cellName, int *cellNum, int *primary) {
 }
 
 
+#if defined(AFS_LINUX26_ENV)
+static_inline int
+_settok_setParentPag(afs_ucred_t **cred)
+{
+    afs_uint32 pag;
+    int code;
+    afs_ucred_t *old_cred = *cred;
+    code = setpag(cred, -1, &pag, 1);
+    if (code == 0) {
+	/* setpag() may have changed our credentials */
+	*cred = crref();
+	crfree(old_cred);
+    }
+    return code;
+}
+#elif defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 static_inline int
-_settok_setParentPag(afs_ucred_t **cred) {
+_settok_setParentPag(afs_ucred_t **cred)
+{
     afs_uint32 pag;
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
     char procname[256];
     osi_procname(procname, 256);
     afs_warnuser("Process %d (%s) tried to change pags in PSetTokens\n",
 	         MyPidxx2Pid(MyPidxx), procname);
     return setpag(osi_curproc(), cred, -1, &pag, 1);
+}
 #else
+static_inline int
+_settok_setParentPag(afs_ucred_t **cred)
+{
+    afs_uint32 pag;
     return setpag(cred, -1, &pag, 1);
-#endif
 }
+#endif
 
 /*!
  * VIOCSETTOK (3) - Set authentication tokens
@@ -2226,9 +2245,9 @@ DECL_PIOCTL(PNewStatMount)
     tfid.Cell = avc->f.fid.Cell;
     tfid.Fid.Volume = avc->f.fid.Fid.Volume;
     if (!tfid.Fid.Unique && (avc->f.states & CForeign)) {
-	tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
+	tvc = afs_LookupVCache(&tfid, areq, avc, bufp);
     } else {
-	tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+	tvc = afs_GetVCache(&tfid, areq);
     }
     if (!tvc) {
 	code = EIO;
@@ -2274,6 +2293,9 @@ getNthCell(afs_int32 uid, afs_int32 iterator) {
     int i;
     struct unixuser *tu = NULL;
 
+    if (iterator > afs_cellindex)
+	return NULL;		/* no point in looking */
+
     i = UHash(uid);
     ObtainReadLock(&afs_xuser);
     for (tu = afs_users[i]; tu; tu = tu->next) {
@@ -3284,9 +3306,9 @@ DECL_PIOCTL(PRemoveMount)
     tfid.Cell = avc->f.fid.Cell;
     tfid.Fid.Volume = avc->f.fid.Fid.Volume;
     if (!tfid.Fid.Unique && (avc->f.states & CForeign)) {
-	tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
+	tvc = afs_LookupVCache(&tfid, areq, avc, bufp);
     } else {
-	tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+	tvc = afs_GetVCache(&tfid, areq);
     }
     if (!tvc) {
 	code = EIO;
@@ -3444,7 +3466,7 @@ DECL_PIOCTL(PSetCellStatus)
     return 0;
 }
 
-static void
+static int
 FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
 {
     afs_int32 i;
@@ -3455,6 +3477,7 @@ FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
     afs_int32 cell = 0;
     afs_int32 volume = 0;
     struct afs_q *tq, *uq;
+    int code = 0;
 #ifdef AFS_DARWIN80_ENV
     vnode_t vp;
 #endif
@@ -3498,7 +3521,9 @@ FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
 		    continue;
 		}
 #else
-		AFS_FAST_HOLD(tvc);
+		if (osi_vnhold(tvc) != 0) {
+		    continue;
+		}
 #endif
 		ReleaseReadLock(&afs_xvcache);
 		ObtainWriteLock(&tvc->lock, 232);
@@ -3523,7 +3548,8 @@ FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
 	    continue;		/* never had any data */
 	tdc = afs_GetValidDSlot(i);
 	if (!tdc) {
-	    continue;
+            code = EIO;
+            break;
 	}
 	if (tdc->refCount <= 1) {    /* too high, in use by running sys call */
 	    ReleaseReadLock(&tdc->tlock);
@@ -3564,6 +3590,7 @@ FlushVolumeData(struct VenusFid *afid, afs_ucred_t * acred)
     /* probably, a user is doing this, probably, because things are screwed up.
      * maybe it's the dnlc's fault? */
     osi_dnlc_purge();
+    return code;
 }
 
 /*!
@@ -3594,8 +3621,7 @@ DECL_PIOCTL(PFlushVolumeData)
     if (!afs_resourceinit_flag)	/* afs daemons haven't started yet */
 	return EIO;		/* Inappropriate ioctl for device */
 
-    FlushVolumeData(&avc->f.fid, *acred);
-    return 0;
+    return FlushVolumeData(&avc->f.fid, *acred);
 }
 
 /*!
@@ -3625,8 +3651,7 @@ DECL_PIOCTL(PFlushAllVolumeData)
     if (!afs_resourceinit_flag)	/* afs daemons haven't started yet */
 	return EIO;		/* Inappropriate ioctl for device */
 
-    FlushVolumeData(NULL, *acred);
-    return 0;
+    return FlushVolumeData(NULL, *acred);
 }
 
 /*!
@@ -4617,7 +4642,7 @@ HandleClientContext(struct afs_ioctl *ablob, int *com,
 #ifdef AFS_AIX_ENV
     newcred->cr_ngrps = 2;
 #elif !defined(AFS_LINUX26_ENV) && !defined(AFS_SUN510_ENV)
-# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_FBSD80_ENV)
+# if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_LINUX22_ENV) || defined(AFS_FBSD_ENV)
     newcred->cr_ngroups = 2;
 # else
     for (i = 2; i < NGROUPS; i++)
@@ -4762,10 +4787,6 @@ DECL_PIOCTL(PSetCPrefs)
 
     if (ainSize < sizeof(struct setspref))
 	return EINVAL;
-#if 0				/* num_servers is unsigned */
-    if (sin->num_servers < 0)
-	return EINVAL;
-#endif
     if (sin->num_servers > AFS_MAX_INTERFACE_ADDR)
 	return ENOMEM;
 
@@ -4840,9 +4861,9 @@ DECL_PIOCTL(PFlushMount)
     tfid.Cell = avc->f.fid.Cell;
     tfid.Fid.Volume = avc->f.fid.Fid.Volume;
     if (!tfid.Fid.Unique && (avc->f.states & CForeign)) {
-	tvc = afs_LookupVCache(&tfid, areq, NULL, avc, bufp);
+	tvc = afs_LookupVCache(&tfid, areq, avc, bufp);
     } else {
-	tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+	tvc = afs_GetVCache(&tfid, areq);
     }
     if (!tvc) {
 	code = EIO;
@@ -4978,7 +4999,7 @@ DECL_PIOCTL(PPrefetchFromTape)
     tfid.Fid.Vnode = Fid->Vnode;
     tfid.Fid.Unique = Fid->Unique;
 
-    tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+    tvc = afs_GetVCache(&tfid, areq);
     if (!tvc) {
 	afs_Trace3(afs_iclSetp, CM_TRACE_PREFETCHCMD, ICL_TYPE_POINTER, tvc,
 		   ICL_TYPE_FID, &tfid, ICL_TYPE_FID, &avc->f.fid);
@@ -5049,7 +5070,7 @@ DECL_PIOCTL(PFsCmd)
     tfid.Fid.Vnode = Fid->Vnode;
     tfid.Fid.Unique = Fid->Unique;
 
-    tvc = afs_GetVCache(&tfid, areq, NULL, NULL);
+    tvc = afs_GetVCache(&tfid, areq);
     afs_Trace3(afs_iclSetp, CM_TRACE_RESIDCMD, ICL_TYPE_POINTER, tvc,
 	       ICL_TYPE_INT32, Inputs->command, ICL_TYPE_FID, &tfid);
     if (!tvc)
@@ -5163,7 +5184,7 @@ DECL_PIOCTL(PCallBackAddr)
     if (!afs_resourceinit_flag)	/* afs deamons havn't started yet */
 	return EIO;		/* Inappropriate ioctl for device */
 
-    if (!afs_osi_suser(acred))
+    if (!afs_osi_suser(*acred))
 	return EACCES;
 
     if (afs_pd_getInt(ain, &addr) != 0)
@@ -5240,6 +5261,7 @@ DECL_PIOCTL(PCallBackAddr)
 	}
 	afs_PutConn(tc, rxconn, SHARED_LOCK);	/* done with it now */
     }				/* Outer loop over addrs */
+    afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs));
 #endif /* UKERNEL */
     return 0;
 }
@@ -5364,15 +5386,7 @@ DECL_PIOCTL(PSetTokens2)
     }
 
     if (tokenSet.flags & AFSTOKEN_EX_SETPAG) {
-#if defined(AFS_LINUX26_ENV)
-	afs_ucred_t *old_cred = *acred;
-#endif
 	if (_settok_setParentPag(acred) == 0) {
-#if defined(AFS_LINUX26_ENV)
-	    /* setpag() may have changed our credentials */
-	    *acred = crref();
-	    crfree(old_cred);
-#endif
 	    code = afs_CreateReq(&treq, *acred);
 	    if (code) {
 		xdr_free((xdrproc_t) xdr_ktc_setTokenData, &tokenSet);
@@ -5438,6 +5452,26 @@ out:
     return code;
 }
 
+/*!
+ * VIOC_GETTOK2 (7) - Return a user's nth token, or token for a cell by
+ *			name.
+ *
+ * \ingroup pioctl
+ *
+ * \param[in] ain	EITHER	a string cellname
+ *			OR	an integer 'iterator' to specify the nth
+ *				token.
+ *
+ * \param[out] aout	XDR-encoded tokens from the user's tokenJar
+ *
+ * \retval EINVAL	invalid input (bad integer, or invalid string)
+ *			unable to extract token(s)
+ * \retval ENOMEM	insufficient memory (returned from called routines)
+ * \retval EDOM		(integer) request was out of bounds or the user has no tokens
+ * \retval ENOTCONN	user found but has no valid token(s)
+ * \retval E2BIG	token(s) do not fit in the output buffer
+ *
+ */
 DECL_PIOCTL(PGetTokens2)
 {
     struct cell *cell = NULL;
@@ -5446,6 +5480,7 @@ DECL_PIOCTL(PGetTokens2)
     char *cellName = NULL;
     afs_int32 cellNum;
     int code = 0;
+    int integer_in = 1;		/* assume integer input */
     time_t now;
     XDR xdrs;
     struct ktc_setTokenData tokenSet;
@@ -5457,11 +5492,23 @@ DECL_PIOCTL(PGetTokens2)
     memset(&tokenSet, 0, sizeof(tokenSet));
 
     /* No input data - return tokens for primary cell */
-    /* 4 octets of data is an iterator count */
+    /* 4 octets of data is PROBABLY an iterator count */
     /* Otherwise, treat as string & return tokens for that cell name */
 
     if (afs_pd_remaining(ain) == sizeof(afs_int32)) {
-	/* Integer iterator - return tokens for the n'th cell found for user */
+	char *scratch = afs_pd_where(ain);
+
+	if (scratch[3] == '\0' && strlen(scratch) == 3)
+	    integer_in = 0;
+    } else {
+	integer_in = 0;
+    }
+
+    if (integer_in) {
+	/* The misleadingly-named getNthCell actually return the nth valid
+	 * token found for the specified user; there can never be a gap
+	 * in the ordinals at this level.
+	 */
 	if (afs_pd_getInt(ain, &iterator) != 0)
 	    return EINVAL;
 	tu = getNthCell(areq->uid, iterator);
@@ -5534,7 +5581,7 @@ DECL_PIOCTL(PNFSNukeCreds)
 	    return EACCES;
 	}
 	afs_PutUser(tu, SHARED_LOCK);
-    } else if (!afs_osi_suser(acred)) {
+    } else if (!afs_osi_suser(*acred)) {
 	return EACCES;
     }
 
diff --git a/src/afs/afs_prototypes.h b/src/afs/afs_prototypes.h
index 3c503d682..c0b00c6fe 100644
--- a/src/afs/afs_prototypes.h
+++ b/src/afs/afs_prototypes.h
@@ -55,7 +55,7 @@ extern afs_int32 afs_evenZaps;
 extern afs_int32 afs_connectBacks;
 extern unsigned long lastCallBack_vnode;
 extern unsigned int lastCallBack_dv;
-extern osi_timeval_t lastCallBack_time;
+extern osi_timeval32_t lastCallBack_time;
 extern struct interfaceAddr afs_cb_interface;
 
 extern int afs_RXCallBackServer(void);
@@ -247,8 +247,8 @@ extern afs_dcache_id_t cacheInode;
 extern struct osi_file *afs_cacheInodep;
 extern int DCHash(struct VenusFid *fid, afs_int32 chunk);
 extern int DVHash(struct VenusFid *fid);
-extern void afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk,
-			   int aflags);
+extern int afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk,
+			  int aflags);
 extern int afs_PutDCache(struct dcache *adc);
 extern void afs_FlushDCache(struct dcache *adc);
 extern void shutdown_dcache(void);
@@ -275,7 +275,7 @@ extern void afs_TryToSmush(struct vcache *avc,
 			   afs_ucred_t *acred, int sync);
 extern void updateV2DC(int lockVc, struct vcache *v, struct dcache *d,
 		       int src);
-extern void afs_WriteThroughDSlots(void);
+extern int afs_WriteThroughDSlots(void);
 extern struct dcache *afs_UFSGetDSlot(afs_int32 aslot, dslot_state type);
 extern int afs_WriteDCache(struct dcache *adc, int atime);
 extern int afs_wakeup(struct vcache *avc);
@@ -288,6 +288,7 @@ extern struct dcache *afs_ObtainDCacheForWriting(struct vcache *avc,
 						 int noLock);
 extern void afs_PopulateDCache(struct vcache *avc, afs_size_t apos,
 			       struct vrequest *areq);
+extern int afs_IsDCacheFresh(struct dcache *adc, struct vcache *avc);
 
 /* afs_disconnected.c */
 
@@ -318,6 +319,7 @@ extern int afs_DynrootVOPRemove(struct vcache *avc, afs_ucred_t *acred,
 				char *aname);
 extern int afs_DynrootVOPSymlink(struct vcache *avc, afs_ucred_t *acred,
 				 char *aname, char *atargetName);
+extern void shutdown_dynroot(void);
 
 /* afs_error.c */
 extern void init_et_to_sys_error(void);
@@ -550,7 +552,7 @@ extern void afs_osi_Invisible(void);
 extern void shutdown_osi(void);
 extern void shutdown_osinet(void);
 extern void shutdown_osisleep(void);
-extern int afs_osi_suser(void *credp);
+extern int afs_osi_suser(afs_ucred_t *credp);
 extern void afs_osi_TraverseProcTable(void);
 #if defined(KERNEL) && !defined(UKERNEL)
 extern const afs_ucred_t *afs_osi_proc2cred(afs_proc_t * pr);
@@ -620,24 +622,14 @@ extern int osi_Active(struct vcache *avc);
 extern void osi_FlushPages(struct vcache *avc,
 			   afs_ucred_t *credp);
 extern void osi_FlushText_really(struct vcache *vp);
-extern int osi_VMDirty_p(struct vcache *avc);
 #ifndef UKERNEL
 extern void osi_ReleaseVM(struct vcache *avc, afs_ucred_t *acred);
 #endif
 
 
-/* LINUX/osi_fetchstore.c */
-#ifdef AFS_LINUX26_ENV
-extern int afs_linux_storeproc(struct storeOps *, void *, struct dcache *,
-			       int *, afs_size_t *);
-#endif
-
 /* ARCH/osi_crypto.c */
 extern int osi_readRandom(void *, afs_size_t);
 
-/* ARCH/osi_misc.c */
-extern void afs_osi_SetTime(osi_timeval_t * atv);
-
 /* LINUX/osi_misc.c */
 #ifdef AFS_LINUX20_ENV
 #ifdef AFS_LINUX24_ENV
@@ -652,7 +644,7 @@ extern int uiomove(char *dp, int length, uio_flag_t rw, struct uio *uiop);
 extern void osi_linux_free_inode_pages(void);
 #endif
 extern void osi_linux_mask(void);
-extern void osi_linux_unmask(void);
+extern void osi_linux_unmaskrxk(void);
 extern int setpag(cred_t ** cr, afs_uint32 pagvalue, afs_uint32 * newpag,
 		  int change_parent);
 #endif
@@ -843,7 +835,8 @@ extern int HandleIoctl(struct vcache *avc, afs_int32 acom,
 /* afs_segments.c */
 extern int afs_StoreAllSegments(struct vcache *avc,
 				struct vrequest *areq, int sync);
-extern int afs_InvalidateAllSegments(struct vcache *avc);
+extern void afs_InvalidateAllSegments(struct vcache *avc);
+extern int  afs_InvalidateAllSegments_once(struct vcache *avc);
 extern int afs_ExtendSegments(struct vcache *avc,
 			      afs_size_t alen, struct vrequest *areq);
 extern int afs_TruncateAllSegments(struct vcache *avc,
@@ -917,10 +910,6 @@ extern struct afs_stats_CMPerf afs_stats_cmperf;
 extern struct afs_stats_CMFullPerf afs_stats_cmfullperf;
 extern afs_int32 afs_stats_XferSumBytes[AFS_STATS_NUM_FS_XFER_OPS];
 extern void afs_InitStats(void);
-extern void afs_GetCMStat(char **ptr, unsigned *size);
-#ifndef AFS_NOSTATS
-extern void afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue);
-#endif
 
 /* afs_syscall.c */
 #ifdef AFS_DARWIN100_ENV
@@ -932,9 +921,6 @@ extern int copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst);
 #if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 #ifdef AFS_DARWIN100_ENV
 extern int afs3_syscall(afs_proc_t *p, void *args, unsigned int *retval);
-#elif (defined(AFS_FBSD90_ENV) || defined(AFS_FBSD82_ENV)) && (__FreeBSD_version < 900044)
-/* afs3_syscall prototype is in sys/sysproto.h
-   Yes, they put it in, then took it out again (renamed with a sys_ prefix) */
 #elif defined(AFS_FBSD_ENV)
 extern int afs3_syscall(struct thread *p, void *args);
 #elif defined(AFS_NBSD50_ENV)
@@ -971,7 +957,6 @@ extern int afs_ExtractTokensForPioctl(struct tokenJar *, time_t,
 extern void uafs_Shutdown(void);
 extern void osi_ReleaseVM(struct vcache *avc, int len,
 			  afs_ucred_t *credp);
-extern int osi_GetTime(struct timeval *tv);
 extern int iodone(struct usr_buf *bp);
 extern int usr_ioctl(void);
 extern int lookupname(char *fnamep, int segflg, int followlink,
@@ -1034,7 +1019,6 @@ extern void print_internet_address(char *preamble, struct srvAddr *sa,
 				   struct rx_connection *rxconn);
 extern afs_int32 afs_data_pointer_to_int32(const void *p);
 
-extern void afs_CheckLocks(void);
 extern int afs_badop(void);
 extern int afs_noop(void);
 extern afs_int32 afs_data_pointer_to_int32(const void *p);
@@ -1054,10 +1038,12 @@ extern void afs_warnuser(char *fmt, ...)
 extern void afs_warnall(char *fmt, ...)
 	AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
 #endif
+extern void afs_WarnENOSPC(void);
 
 /* afs_vcache.c */
 extern int VCHash(struct VenusFid *fid);
 extern int VCHashV(struct VenusFid *fid);
+extern int afs_VCacheStressed(void);
 extern int afs_ShakeLooseVCaches(afs_int32 anumber);
 extern afs_int32 afs_maxvcount;
 extern afs_int32 afs_vcount;
@@ -1091,13 +1077,12 @@ extern afs_int32 afs_FlushVCBs(afs_int32 lockit);
 extern void afs_InactiveVCache(struct vcache *avc, afs_ucred_t *acred);
 extern struct vcache *afs_LookupVCache(struct VenusFid *afid,
 				       struct vrequest *areq,
-				       afs_int32 * cached, struct vcache *adp,
+				       struct vcache *adp,
 				       char *aname);
 extern void afs_FlushAllVCaches(void);
 extern int afs_FlushVCache(struct vcache *avc, int *slept);
 extern struct vcache *afs_GetRootVCache(struct VenusFid *afid,
 					struct vrequest *areq,
-					afs_int32 * cached,
 					struct volume *tvolp);
 extern struct vcache *afs_NewVCache(struct VenusFid *afid,
 				    struct server *serverp);
@@ -1105,8 +1090,7 @@ extern struct vcache *afs_NewBulkVCache(struct VenusFid *afid,
 					struct server *serverp, int seq);
 extern int afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq);
 extern struct vcache *afs_GetVCache(struct VenusFid *afid,
-				    struct vrequest *areq, afs_int32 * cached,
-				    struct vcache *avc);
+				    struct vrequest *areq);
 extern void afs_PutVCache(struct vcache *avc);
 extern int afs_RefVCache(struct vcache *avc);
 
diff --git a/src/afs/afs_segments.c b/src/afs/afs_segments.c
index 9992a84a5..91e6f2854 100644
--- a/src/afs/afs_segments.c
+++ b/src/afs/afs_segments.c
@@ -380,7 +380,7 @@ afs_StoreAllSegments(struct vcache *avc, struct vrequest *areq,
 			 * be updated so we don't be able to use that cached
 			 * chunk in the future. That's inefficient, but not
 			 * an error. */
-			continue;
+			break;
 		    }
 		    ReleaseReadLock(&tdc->tlock);
 
@@ -496,29 +496,14 @@ afs_StoreAllSegments(struct vcache *avc, struct vrequest *areq,
 
 }				/*afs_StoreAllSegments (new 03/02/94) */
 
-
-/*
- * afs_InvalidateAllSegments
- *
- * Description:
- *	Invalidates all chunks for a given file
- *
- * Parameters:
- *	avc      : Pointer to vcache entry.
- *
- * Environment:
- *	For example, called after an error has been detected.  Called
- *	with avc write-locked, and afs_xdcache unheld.
- */
-
 int
-afs_InvalidateAllSegments(struct vcache *avc)
+afs_InvalidateAllSegments_once(struct vcache *avc)
 {
     struct dcache *tdc;
     afs_int32 hash;
     afs_int32 index;
-    struct dcache **dcList;
-    int i, dcListMax, dcListCount;
+    struct dcache **dcList = NULL;
+    int i, dcListMax, dcListCount = 0;
 
     AFS_STATCNT(afs_InvalidateAllSegments);
     afs_Trace2(afs_iclSetp, CM_TRACE_INVALL, ICL_TYPE_POINTER, avc,
@@ -543,17 +528,7 @@ afs_InvalidateAllSegments(struct vcache *avc)
 	if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
 	    tdc = afs_GetValidDSlot(index);
 	    if (!tdc) {
-		/* In the case of fatal errors during stores, we MUST
-		 * invalidate all of the relevant chunks. Otherwise, the chunks
-		 * will be left with the 'new' data that was never successfully
-		 * written to the server, but the DV in the dcache is still the
-		 * old DV. So, we may indefinitely serve data to applications
-		 * that is not actually in the file on the fileserver. If we
-		 * cannot afs_GetValidDSlot the appropriate entries, currently
-		 * there is no way to ensure the dcache is invalidated. So for
-		 * now, to avoid risking serving bad data from the cache, panic
-		 * instead. */
-		osi_Panic("afs_InvalidateAllSegments tdc count");
+		goto error;
 	    }
 	    ReleaseReadLock(&tdc->tlock);
 	    if (!FidCmp(&tdc->f.fid, &avc->f.fid))
@@ -564,17 +539,12 @@ afs_InvalidateAllSegments(struct vcache *avc)
     }
 
     dcList = osi_Alloc(dcListMax * sizeof(struct dcache *));
-    dcListCount = 0;
 
     for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
 	if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
 	    tdc = afs_GetValidDSlot(index);
 	    if (!tdc) {
-		/* We cannot proceed after getting this error; we risk serving
-		 * incorrect data to applications. So panic instead. See the
-		 * above comment next to the previous afs_GetValidDSlot call
-		 * for details. */
-		osi_Panic("afs_InvalidateAllSegments tdc store");
+		goto error;
 	    }
 	    ReleaseReadLock(&tdc->tlock);
 	    if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
@@ -611,6 +581,112 @@ afs_InvalidateAllSegments(struct vcache *avc)
     osi_Free(dcList, dcListMax * sizeof(struct dcache *));
 
     return 0;
+
+ error:
+    ReleaseWriteLock(&afs_xdcache);
+
+    if (dcList) {
+	for (i = 0; i < dcListCount; i++) {
+	    tdc = dcList[i];
+	    if (tdc) {
+		afs_PutDCache(tdc);
+	    }
+	}
+	osi_Free(dcList, dcListMax * sizeof(struct dcache *));
+    }
+    return EIO;
+}
+
+
+/*
+ * afs_InvalidateAllSegments
+ *
+ * Description:
+ *	Invalidates all chunks for a given file
+ *
+ * Parameters:
+ *	avc      : Pointer to vcache entry.
+ *
+ * Environment:
+ *	For example, called after an error has been detected.  Called
+ *	with avc write-locked, and afs_xdcache unheld.
+ */
+
+void
+afs_InvalidateAllSegments(struct vcache *avc)
+{
+    int code;
+    afs_uint32 last_warn;
+
+    code = afs_InvalidateAllSegments_once(avc);
+    if (code == 0) {
+	/* Success; nothing more to do. */
+	return;
+    }
+
+    /*
+     * If afs_InvalidateAllSegments_once failed, we cannot simply return an
+     * error to our caller. This function is called when we encounter a fatal
+     * error during stores, in which case we MUST invalidate all chunks for the
+     * given file. If we fail to invalidate some chunks, they will be left with
+     * the 'new' dirty/written data that was never successfully stored on the
+     * server, but the DV in the dcache is still the old DV. So, if its left
+     * alone, we may indefinitely serve data to applications that is not
+     * actually in the file on the fileserver.
+     *
+     * So to make sure we never serve userspace bad data after such a failure,
+     * we must keep trying to invalidate the dcaches for the given file. (Note
+     * that we cannot simply set a flag on the vcache to retry the invalidate
+     * later on, because the vcache may go away, but the 'bad' dcaches could
+     * remain.) We do this below, via background daemon requests because in
+     * some scenarios we can always get I/O errors on accessing the cache if we
+     * access via a user pid. (e.g. on LINUX, this can happen if the pid has a
+     * pending SIGKILL.) Doing this via background daemon ops should avoid
+     * that.
+     */
+
+    last_warn = osi_Time();
+    afs_warn("afs: Failed to invalidate cache chunks for fid %d.%d.%d.%d; our "
+	     "local disk cache may be throwing errors. We must invalidate "
+	     "these chunks to avoid possibly serving incorrect data, so we'll "
+	     "retry until we succeed. If AFS access seems to hang, this may "
+	     "be why.\n",
+	     avc->f.fid.Cell, avc->f.fid.Fid.Volume, avc->f.fid.Fid.Vnode,
+	     avc->f.fid.Fid.Unique);
+
+    do {
+	static const afs_uint32 warn_int = 60*60; /* warn once every hour */
+	afs_uint32 now = osi_Time();
+	struct brequest *bp;
+
+	if (now < last_warn || now - last_warn > warn_int) {
+	    last_warn = now;
+	    afs_warn("afs: Still trying to invalidate cache chunks for fid "
+		     "%d.%d.%d.%d. We will retry until we succeed; if AFS "
+		     "access seems to hang, this may be why.\n",
+		     avc->f.fid.Cell, avc->f.fid.Fid.Volume,
+		     avc->f.fid.Fid.Vnode, avc->f.fid.Fid.Unique);
+	}
+
+	/* Wait 10 seconds between attempts. */
+	afs_osi_Wait(1000 * 10, NULL, 0);
+
+	/*
+	 * Ask a background daemon to do this request for us. Note that _we_ hold
+	 * the write lock on 'avc', while the background daemon does the work. This
+	 * is a little weird, but it helps avoid any issues with lock ordering
+	 * or if our caller does not expect avc->lock to be dropped while
+	 * running.
+	 */
+	bp = afs_BQueue(BOP_INVALIDATE_SEGMENTS, avc, 0, 1, NULL, 0, 0, NULL,
+			NULL, NULL);
+	while ((bp->flags & BUVALID) == 0) {
+	    bp->flags |= BUWAIT;
+	    afs_osi_Sleep(bp);
+	}
+	code = bp->code_raw;
+	afs_BRelease(bp);
+    } while (code);
 }
 
 /*!
@@ -651,6 +727,12 @@ afs_ExtendSegments(struct vcache *avc, afs_size_t alen, struct vrequest *areq)
 	    toAdd = AFS_CHUNKTOSIZE(tdc->f.chunk) - offset;
 	}
         tfile = afs_CFileOpen(&tdc->f.inode);
+	if (!tfile) {
+	    ReleaseWriteLock(&tdc->lock);
+	    afs_PutDCache(tdc);
+	    code = EIO;
+	    break;
+	}
 	while(tdc->validPos < avc->f.m.Length + toAdd) {
 	     afs_size_t towrite;
 
@@ -819,6 +901,7 @@ afs_TruncateAllSegments(struct vcache *avc, afs_size_t alen,
 	    UpgradeSToWLock(&tdc->lock, 673);
 	    tdc->f.states |= DWriting;
 	    tfile = afs_CFileOpen(&tdc->f.inode);
+            osi_Assert(tfile);
 	    afs_CFileTruncate(tfile, (afs_int32)newSize);
 	    afs_CFileClose(tfile);
 	    afs_AdjustSize(tdc, (afs_int32)newSize);
diff --git a/src/afs/afs_server.c b/src/afs/afs_server.c
index 79b4704ec..24ec05397 100644
--- a/src/afs/afs_server.c
+++ b/src/afs/afs_server.c
@@ -129,7 +129,7 @@ afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown)
 {
     struct server *a_serverP = sa->server;
     struct srvAddr *sap;
-    osi_timeval_t currTime, *currTimeP;	/*Current time */
+    osi_timeval32_t currTime, *currTimeP;	/*Current time */
     afs_int32 downTime;		/*Computed downtime, in seconds */
     struct afs_stats_SrvUpDownInfo *upDownP;	/*Ptr to up/down info record */
 
@@ -172,7 +172,7 @@ afs_MarkServerUpOrDown(struct srvAddr *sa, int a_isDown)
      * updated; we'll need them one way or another.
      */
     currTimeP = &currTime;
-    osi_GetuTime(currTimeP);
+    osi_GetTime(currTimeP);
 
     upDownP = GetUpDownStats(a_serverP);
 
@@ -354,8 +354,8 @@ afs_CountServers(void)
     int currIdx;		/*Curr idx into srv table */
     struct server *currSrvP;	/*Ptr to curr server record */
     afs_int32 currChainLen;	/*Length of curr hash chain */
-    osi_timeval_t currTime;	/*Current time */
-    osi_timeval_t *currTimeP;	/*Ptr to above */
+    osi_timeval32_t currTime;	/*Current time */
+    osi_timeval32_t *currTimeP;	/*Ptr to above */
     afs_int32 srvRecordAge;	/*Age of server record, in secs */
     struct afs_stats_SrvUpDownInfo *upDownP;	/*Ptr to current up/down
 						 * info being manipulated */
@@ -400,7 +400,7 @@ afs_CountServers(void)
      * Compute the current time, used to figure out server record ages.
      */
     currTimeP = &currTime;
-    osi_GetuTime(currTimeP);
+    osi_GetTime(currTimeP);
 
     /*
      * Sweep the server hash table, tallying all we need to know.
@@ -515,6 +515,8 @@ ForceAllNewConnections(void)
         sa = addrs[i];
 	ForceNewConnections(sa);
     }
+
+    afs_osi_Free(addrs, srvAddrCount * sizeof(*addrs));
 }
 
 static void
@@ -821,13 +823,15 @@ afs_random(void)
 
     AFS_STATCNT(afs_random);
     if (!state) {
-	osi_timeval_t t;
+	osi_timeval32_t t;
 	osi_GetTime(&t);
 	/*
-	 * 0xfffffff0 was changed to (~0 << 4) since it works no matter how many
-	 * bits are in a tv_usec
+	 * Clear the low nybble of tv_usec in a size-independent manner before adding
+	 * in the rest of the state.
 	 */
-	state = (t.tv_usec & (~0 << 4)) + (rxi_getaddr() & 0xff);
+	state = t.tv_usec;
+	state ^= (state & 0x0f);
+	state += rxi_getaddr() & 0xff;
 	state += (t.tv_sec & 0xff);
 	for (i = 0; i < 30; i++) {
 	    ranstage(state);
@@ -1353,13 +1357,12 @@ afs_SetServerPrefs(struct srvAddr *const sa)
 #elif defined(AFS_FBSD_ENV)
     {
 	struct in_ifaddr *ifa;
-#if defined(AFS_FBSD80_ENV)
-	  TAILQ_FOREACH(ifa, &V_in_ifaddrhead, ia_link) {
-#else
-	  TAILQ_FOREACH(ifa, &in_ifaddrhead, ia_link) {
-#endif
+	CURVNET_SET(rx_socket->so_vnet);
+	TAILQ_FOREACH(ifa, &V_in_ifaddrhead, ia_link) {
 	    afsi_SetServerIPRank(sa, &ifa->ia_ifa);
-    }}
+	}
+	CURVNET_RESTORE();
+    }
 #elif defined(AFS_OBSD_ENV)
     {
 	extern struct in_ifaddrhead in_ifaddr;
@@ -1517,7 +1520,9 @@ afs_GetCapabilities(struct server *ts)
     }
     /* InitCallBackStateN, triggered by our RPC, may need this */
     ReleaseWriteLock(&afs_xserver);
+    AFS_GUNLOCK();
     code = RXAFS_GetCapabilities(rxconn, &caps);
+    AFS_GLOCK();
     ObtainWriteLock(&afs_xserver, 723);
     /* we forced a conn above; important we mark it down if needed */
     if ((code < 0) && (code != RXGEN_OPCODE)) {
@@ -1810,8 +1815,8 @@ afs_GetServer(afs_uint32 *aserverp, afs_int32 nservers, afs_int32 acell,
 void
 afs_ActivateServer(struct srvAddr *sap)
 {
-    osi_timeval_t currTime;	/*Filled with current time */
-    osi_timeval_t *currTimeP;	/*Ptr to above */
+    osi_timeval32_t currTime;	/*Filled with current time */
+    osi_timeval32_t *currTimeP;	/*Ptr to above */
     struct afs_stats_SrvUpDownInfo *upDownP;	/*Ptr to up/down info record */
     struct server *aserver = sap->server;
 
@@ -1822,7 +1827,7 @@ afs_ActivateServer(struct srvAddr *sap)
 	 */
 	aserver->flags |= AFS_SERVER_FLAG_ACTIVATED;
 	currTimeP = &currTime;
-	osi_GetuTime(currTimeP);
+	osi_GetTime(currTimeP);
 	aserver->activationTime = currTime.tv_sec;
 	upDownP = GetUpDownStats(aserver);
 	if (aserver->flags & SRVR_ISDOWN) {
diff --git a/src/afs/afs_stat.c b/src/afs/afs_stat.c
index 81873eeb0..7145001e1 100644
--- a/src/afs/afs_stat.c
+++ b/src/afs/afs_stat.c
@@ -72,19 +72,3 @@ afs_InitStats(void)
 	xferP->minBytes = 999999999;
     }
 }
-
-void
-afs_GetCMStat(char **ptr, unsigned *size)
-{
-#ifndef AFS_NOSTATS
-    AFS_STATCNT(afs_GetCMStat);
-    *ptr = (char *)&afs_cmstats;
-    *size = sizeof(afs_cmstats);
-#endif /* AFS_NOSTATS */
-}
-
-void
-afs_AddToMean(struct afs_MeanStats *oldMean, afs_int32 newValue)
-{
-    AFS_STATCNT(afs_AddToMean);
-}
diff --git a/src/afs/afs_stats.h b/src/afs/afs_stats.h
index 0d9eb91f1..0fd529831 100644
--- a/src/afs/afs_stats.h
+++ b/src/afs/afs_stats.h
@@ -50,17 +50,17 @@ typedef struct {
 #endif /* !KERNEL */
 
 #define XSTATS_DECLS struct afs_stats_opTimingData *opP = NULL; \
-    osi_timeval_t opStartTime = { 0, 0}, opStopTime, elapsedTime
+    osi_timeval32_t opStartTime = { 0, 0}, opStopTime, elapsedTime
 
 #define XSTATS_START_TIME(arg) \
   opP = &(afs_stats_cmfullperf.rpc.fsRPCTimes[arg]); \
-  osi_GetuTime(&opStartTime);
+  osi_GetTime(&opStartTime);
 
 #define XSTATS_START_CMTIME(arg) \
   opP = &(afs_stats_cmfullperf.rpc.cmRPCTimes[arg]); \
-  osi_GetuTime(&opStartTime);
+  osi_GetTime(&opStartTime);
 
-#define XSTATS_END_TIME osi_GetuTime(&opStopTime); \
+#define XSTATS_END_TIME osi_GetTime(&opStopTime); \
   (opP->numOps)++; \
   if (!code) { (opP->numSuccesses)++; \
      afs_stats_GetDiff(elapsedTime, opStartTime, opStopTime); \
@@ -501,7 +501,7 @@ struct afs_MeanStats {
     AFS_CS(fprf)		/* afs_resource.c */ \
     AFS_CS(fprint)		/* afs_resource.c */ \
     AFS_CS(fprintn)		/* afs_resource.c */ \
-    AFS_CS(afs_CheckLocks)	/* afs_resource.c */ \
+    AFS_CS(afs_CheckLocks)	/* UNUSED */ \
     AFS_CS(puttofile)		/* afs_resource.c */ \
     AFS_CS(shutdown_AFS)	/* afs_resource.c */ \
     AFS_CS(afs_CheckCacheResets)	/* afs_resource.c */ \
@@ -523,8 +523,8 @@ struct afs_MeanStats {
     AFS_CS(HaveCallBacksFrom)	/* afs_resource.c */ \
     AFS_CS(ServerDown)		/* afs_resource.c */ \
     AFS_CS(afs_CheckServers)	/* afs_resource.c */ \
-    AFS_CS(afs_AddToMean)	/* afs_stat.c */ \
-    AFS_CS(afs_GetCMStat)	/* afs_stat.c */ \
+    AFS_CS(afs_AddToMean)	/* UNUSED */ \
+    AFS_CS(afs_GetCMStat)	/* UNUSED */ \
     AFS_CS(afs_getpage)		/* afs_sun_subr.c */ \
     AFS_CS(afs_putpage)		/* afs_sun_subr.c */ \
     AFS_CS(afs_nfsrdwr)		/* afs_sun_subr.c */ \
@@ -1169,14 +1169,6 @@ struct afs_stats_CMFullPerf {
     struct afs_stats_AuthorInfo author;	/*Authorship stats */
 };
 
-/*
- * These are the storage declarations for the structures accessible
- * via the xstat package.
- */
-/* extern struct afs_stats_CMPerf afs_stats_cmperf; */
-/* extern struct afs_stats_CMFullPerf afs_stats_cmfullperf; */
-/* extern afs_int32 afs_stats_XferSumBytes[]; */
-
 #ifndef AFS_NOSTATS
 /*
  * We define routines to keep running counts and means.  For the
@@ -1186,9 +1178,6 @@ struct afs_stats_CMFullPerf {
  */
 #define AFS_STATCNT(arg)  ((afs_cmstats.callInfo.C_ ## arg)++)
 
-#define AFS_MEANCNT(arg, value) \
-    (afs_AddToMean(((afs_cmstats.meanInfo).(arg)),value))
-
 #endif /* AFS_NOSTATS */
 
 
diff --git a/src/afs/afs_syscall.c b/src/afs/afs_syscall.c
index b2b644ae1..ce6afdf9a 100644
--- a/src/afs/afs_syscall.c
+++ b/src/afs/afs_syscall.c
@@ -141,6 +141,8 @@ copyin_afs_ioctl(caddr_t cmarg, struct afs_ioctl *dst)
     if (test_thread_flag(TIF_31BIT))
 #elif defined(AFS_S390X_LINUX20_ENV)
     if (current->thread.flags & S390_FLAG_31BIT)
+#elif defined(AFS_ARM64_LINUX26_ENV)
+    if (is_compat_task())
 
 #else
 #error pioctl32 not done for this linux
@@ -416,6 +418,8 @@ copyin_iparam(caddr_t cmarg, struct iparam *dst)
     if (test_thread_flag(TIF_31BIT))
 #elif defined(AFS_S390X_LINUX20_ENV)
     if (current->thread.flags & S390_FLAG_31BIT)
+#elif defined(AFS_ARM64_LINUX26_ENV)
+    if (is_compat_task())
 
 #else
 #error iparam32 not done for this linux platform
diff --git a/src/afs/afs_tokens.c b/src/afs/afs_tokens.c
index 2dc4c3074..7b5f3cfa5 100644
--- a/src/afs/afs_tokens.c
+++ b/src/afs/afs_tokens.c
@@ -43,7 +43,8 @@
  * 	accessed using the appropriate element of the union.
  */
 union tokenUnion *
-afs_FindToken(struct tokenJar *tokens, rx_securityIndex type) {
+afs_FindToken(struct tokenJar *tokens, rx_securityIndex type)
+{
     while (tokens != NULL) {
 	if (tokens->type == type) {
 	    return &tokens->content;
@@ -54,39 +55,43 @@ afs_FindToken(struct tokenJar *tokens, rx_securityIndex type) {
 }
 
 /*!
- * Free a single token
- *
- * This will free the given token. No attempt is made to unlink
- * the token from its container, and it is an error to attempt to
- * free a token which is still linked.
+ * Unlink and free a single token
  *
- * This performs a secure free, setting all token information to 0
- * before returning allocated data blocks to the kernel.
+ * This will unlink the first token in the given tokenJar, and free that token.
+ * This attempts to perform a secure free, setting all token information to 0
+ * before returning allocated data blocks to the kernel.  (Optimizing compilers
+ * may eliminate such a "dead store", though.)
  *
  * Intended primarily for internal use.
  *
- * @param[in] token
- * 	The token to free
+ * @param[inout] tokenPtr
+ * 	The token to unlink and free
  */
+static void
+afs_FreeFirstToken(struct tokenJar **tokenPtr)
+{
+    struct tokenJar *token = *tokenPtr;
+    if (token == NULL) {
+	return;
+    }
 
-void
-afs_FreeOneToken(struct tokenJar *token) {
-    if (token->next != NULL)
-	osi_Panic("Freeing linked token");
+    /* Unlink the token. */
+    *tokenPtr = token->next;
+    token->next = NULL;
 
     switch (token->type) {
       case RX_SECIDX_KAD:
 	if (token->content.rxkad.ticket != NULL) {
-		memset(token->content.rxkad.ticket, 0, token->content.rxkad.ticketLen);
-		afs_osi_Free(token->content.rxkad.ticket,
-			     token->content.rxkad.ticketLen);
+	    memset(token->content.rxkad.ticket, 0, token->content.rxkad.ticketLen);
+	    afs_osi_Free(token->content.rxkad.ticket,
+			 token->content.rxkad.ticketLen);
 	}
 	break;
       default:
 	break;
     }
-    memset(token, 0, sizeof(struct tokenJar));
-    afs_osi_Free(token, sizeof(struct tokenJar));
+    memset(token, 0, sizeof(*token));
+    afs_osi_Free(token, sizeof(*token));
 }
 
 /*!
@@ -99,16 +104,10 @@ afs_FreeOneToken(struct tokenJar *token) {
  * 	A pointer to the address of the tokenjar to free.
  */
 void
-afs_FreeTokens(struct tokenJar **tokenPtr) {
-    struct tokenJar *next, *tokens;
-
-    tokens = *tokenPtr;
-    *tokenPtr = NULL;
-    while(tokens != NULL) {
-	next = tokens->next;
-	tokens->next = NULL; /* Unlink from chain */
-	afs_FreeOneToken(tokens);
-	tokens = next;
+afs_FreeTokens(struct tokenJar **tokenPtr)
+{
+    while (*tokenPtr != NULL) {
+	afs_FreeFirstToken(tokenPtr);
     }
 }
 
@@ -130,10 +129,11 @@ afs_FreeTokens(struct tokenJar **tokenPtr) {
  * 	which may then be used to populate the token.
  */
 union tokenUnion *
-afs_AddToken(struct tokenJar **tokens, rx_securityIndex type) {
+afs_AddToken(struct tokenJar **tokens, rx_securityIndex type)
+{
     struct tokenJar *newToken;
 
-    newToken = afs_osi_Alloc(sizeof(struct tokenJar));
+    newToken = afs_osi_Alloc(sizeof(*newToken));
     osi_Assert(newToken != NULL);
     memset(newToken, 0, sizeof(*newToken));
 
@@ -156,8 +156,9 @@ afs_AddToken(struct tokenJar **tokens, rx_securityIndex type) {
  * @returns
  * 	True if the token has expired, false otherwise
  */
-int
-afs_IsTokenExpired(struct tokenJar *token, afs_int32 now) {
+static int
+afs_IsTokenExpired(struct tokenJar *token, afs_int32 now)
+{
     switch (token->type) {
       case RX_SECIDX_KAD:
 	if (token->content.rxkad.clearToken.EndTimestamp < now - NOTOKTIMEOUT)
@@ -166,7 +167,7 @@ afs_IsTokenExpired(struct tokenJar *token, afs_int32 now) {
       default:
 	return 0;
     }
-    return 0; /* not reached, but keep gcc happy */
+    return 0;
 }
 
 /*!
@@ -183,8 +184,9 @@ afs_IsTokenExpired(struct tokenJar *token, afs_int32 now) {
  * @returns
  * 	True if the token is usable, false otherwise
  */
-int
-afs_IsTokenUsable(struct tokenJar *token, afs_int32 now) {
+static int
+afs_IsTokenUsable(struct tokenJar *token, afs_int32 now)
+{
 
     if (afs_IsTokenExpired(token, now))
 	return 0;
@@ -212,15 +214,11 @@ afs_IsTokenUsable(struct tokenJar *token, afs_int32 now) {
  */
 
 void
-afs_DiscardExpiredTokens(struct tokenJar **tokenPtr, afs_int32 now) {
-    struct tokenJar *next;
-
+afs_DiscardExpiredTokens(struct tokenJar **tokenPtr, afs_int32 now)
+{
     while (*tokenPtr != NULL) {
 	if (afs_IsTokenExpired(*tokenPtr, now)) {
-	    next = (*tokenPtr)->next;
-	    (*tokenPtr)->next = NULL;
-	    afs_FreeOneToken(*tokenPtr);
-	    *tokenPtr = next;
+	    afs_FreeFirstToken(tokenPtr);
 	} else {
 	    tokenPtr = &(*tokenPtr)->next;
         }
@@ -239,7 +237,8 @@ afs_DiscardExpiredTokens(struct tokenJar **tokenPtr, afs_int32 now) {
  * 	True if the jar contains usable tokens, otherwise false
  */
 int
-afs_HasUsableTokens(struct tokenJar *token, afs_int32 now) {
+afs_HasUsableTokens(struct tokenJar *token, afs_int32 now)
+{
     while (token != NULL) {
         if (afs_IsTokenUsable(token, now))
 	    return 1;
@@ -261,7 +260,8 @@ afs_HasUsableTokens(struct tokenJar *token, afs_int32 now) {
  *
  */
 int
-afs_HasValidTokens(struct tokenJar *token, afs_int32 now) {
+afs_HasValidTokens(struct tokenJar *token, afs_int32 now)
+{
     while (token != NULL) {
         if (!afs_IsTokenExpired(token, now))
 	    return 1;
@@ -284,7 +284,8 @@ afs_HasValidTokens(struct tokenJar *token, afs_int32 now) {
  * 	The number of valid tokens in the jar
  */
 static int
-countValidTokens(struct tokenJar *token, time_t now) {
+countValidTokens(struct tokenJar *token, time_t now)
+{
     int count = 0;
 
     while (token != NULL) {
@@ -309,7 +310,8 @@ countValidTokens(struct tokenJar *token, time_t now) {
  */
 void
 afs_AddRxkadToken(struct tokenJar **tokens, char *ticket, int ticketLen,
-		  struct ClearToken *clearToken) {
+		  struct ClearToken *clearToken)
+{
     union tokenUnion *tokenU;
     struct rxkadToken *rxkad;
 
@@ -325,7 +327,8 @@ afs_AddRxkadToken(struct tokenJar **tokens, char *ticket, int ticketLen,
 
 static int
 afs_AddRxkadTokenFromPioctl(struct tokenJar **tokens,
-			    struct ktc_tokenUnion *pioctlToken) {
+			    struct ktc_tokenUnion *pioctlToken)
+{
     struct ClearToken clear;
 
     clear.AuthHandle = pioctlToken->ktc_tokenUnion_u.at_kad.rk_kvno;
@@ -346,7 +349,8 @@ afs_AddRxkadTokenFromPioctl(struct tokenJar **tokens,
 
 static int
 rxkad_extractTokenForPioctl(struct tokenJar *token,
-			       struct ktc_tokenUnion *pioctlToken) {
+			       struct ktc_tokenUnion *pioctlToken)
+{
 
     struct token_rxkad *rxkadPioctl;
     struct rxkadToken *rxkadInternal;
@@ -385,7 +389,8 @@ rxkad_extractTokenForPioctl(struct tokenJar *token,
  */
 int
 afs_AddTokenFromPioctl(struct tokenJar **tokens,
-		       struct ktc_tokenUnion *pioctlToken) {
+		       struct ktc_tokenUnion *pioctlToken)
+{
 
     switch (pioctlToken->at_type) {
       case RX_SECIDX_KAD:
@@ -397,14 +402,15 @@ afs_AddTokenFromPioctl(struct tokenJar **tokens,
 
 static int
 extractPioctlToken(struct tokenJar *token,
-		   struct token_opaque *opaque) {
+		   struct token_opaque *opaque)
+{
     XDR xdrs;
     struct ktc_tokenUnion *pioctlToken;
     int code;
 
     memset(opaque, 0, sizeof(token_opaque));
 
-    pioctlToken = osi_Alloc(sizeof(struct ktc_tokenUnion));
+    pioctlToken = osi_Alloc(sizeof(*pioctlToken));
     if (pioctlToken == NULL)
 	return ENOMEM;
 
@@ -448,9 +454,9 @@ extractPioctlToken(struct tokenJar *token,
     }
     xdr_destroy(&xdrs);
 
-out:
+ out:
     xdr_free((xdrproc_t) xdr_ktc_tokenUnion, &pioctlToken);
-    osi_Free(pioctlToken, sizeof(struct ktc_tokenUnion));
+    osi_Free(pioctlToken, sizeof(*pioctlToken));
 
     if (code != 0) {
 	if (opaque->token_opaque_val != NULL)
@@ -473,7 +479,7 @@ afs_ExtractTokensForPioctl(struct tokenJar *token,
 
     tokenSet->tokens.tokens_len = numTokens;
     tokenSet->tokens.tokens_val
-	= xdr_alloc(sizeof(struct token_opaque) * numTokens);
+	= xdr_alloc(sizeof(tokenSet->tokens.tokens_val[0]) * numTokens);
 
     if (tokenSet->tokens.tokens_val == NULL)
 	return ENOMEM;
@@ -487,7 +493,7 @@ afs_ExtractTokensForPioctl(struct tokenJar *token,
 	pos++;
     }
 
-out:
+ out:
     if (code)
 	xdr_free((xdrproc_t) xdr_ktc_setTokenData, tokenSet);
 
diff --git a/src/afs/afs_util.c b/src/afs/afs_util.c
index 8bd595cc1..d8fe1125d 100644
--- a/src/afs/afs_util.c
+++ b/src/afs/afs_util.c
@@ -230,93 +230,6 @@ print_internet_address(char *preamble, struct srvAddr *sa, char *postamble,
     }
 }				/*print_internet_address */
 
-
-
-/* run everywhere, checking locks */
-void
-afs_CheckLocks(void)
-{
-    int i;
-
-    afs_warn("Looking for locked data structures.\n");
-    afs_warn("conn %p, volume %p, user %p, cell %p, server %p\n", &afs_xconn,
-	     &afs_xvolume, &afs_xuser, &afs_xcell, &afs_xserver);
-    {
-	struct vcache *tvc;
-	AFS_STATCNT(afs_CheckLocks);
-
-	for (i = 0; i < VCSIZE; i++) {
-	    for (tvc = afs_vhashT[i]; tvc; tvc = tvc->hnext) {
-                if (tvc->f.states & CVInit) continue;
-#ifdef AFS_DARWIN80_ENV
-		if (vnode_isinuse(AFSTOV(tvc), 0))
-#else
-		if (VREFCOUNT(tvc))
-#endif
-		    afs_warn("Stat cache entry at %p is held\n", tvc);
-		if (CheckLock(&tvc->lock))
-		    afs_warn("Stat entry at %p is locked\n", tvc);
-	    }
-	}
-    }
-    {
-	struct dcache *tdc;
-	for (i = 0; i < afs_cacheFiles; i++) {
-	    tdc = afs_indexTable[i];
-	    if (tdc) {
-		if (tdc->refCount)
-		    afs_warn("Disk entry %d at %p is held\n", i, tdc);
-	    }
-	    if (afs_indexFlags[i] & IFDataMod)
-		afs_warn("Disk entry %d at %p has IFDataMod flag set.\n", i,
-			 tdc);
-	}
-    }
-    {
-	struct srvAddr *sa;
-	struct server *ts;
-        struct sa_conn_vector *tcv;
-	for (i = 0; i < NSERVERS; i++) {
-	    for (ts = afs_servers[i]; ts; ts = ts->next) {
-		if (ts->flags & SRVR_ISDOWN)
-		    afs_warn("Server entry %p is marked down\n", ts);
-		for (sa = ts->addr; sa; sa = sa->next_sa) {
-                    for (tcv = sa->conns; tcv; tcv = tcv->next) {
-                        if (tcv->refCount)
-                            afs_warn("conn at %p (server %x) is held\n", tcv,
-				     sa->sa_ip);
-		    }
-		}
-	    }
-	}
-    }
-    {
-	struct volume *tv;
-	for (i = 0; i < NVOLS; i++) {
-	    for (tv = afs_volumes[i]; tv; tv = tv->next) {
-		if (CheckLock(&tv->lock))
-		    afs_warn("volume at %p is locked\n", tv);
-		if (tv->refCount)
-		    afs_warn("volume at %p is held\n", tv);
-	    }
-	}
-    }
-    {
-	struct unixuser *tu;
-
-	for (i = 0; i < NUSERS; i++) {
-	    for (tu = afs_users[i]; tu; tu = tu->next) {
-		if (CheckLock(&tu->lock))
-		    afs_warn("user at %p is locked\n", tu);
-		if (tu->refCount)
-		    afs_warn("user at %lx is held\n", (unsigned long)tu);
-	    }
-	}
-    }
-    afs_warn("Done.\n");
-}
-
-
 int
 afs_noop(void)
 {
@@ -329,7 +242,7 @@ afs_badop(void)
 {
     AFS_STATCNT(afs_badop);
     osi_Panic("afs bad vnode op");
-    return 0;
+    AFS_UNREACHED(return 0);
 }
 
 /*
diff --git a/src/afs/afs_vcache.c b/src/afs/afs_vcache.c
index 36334c0ae..407e5a6ba 100644
--- a/src/afs/afs_vcache.c
+++ b/src/afs/afs_vcache.c
@@ -22,7 +22,6 @@
  * afs_WriteVCacheDiscon
  * afs_SimpleVStat
  * afs_ProcessFS
- * TellALittleWhiteLie
  * afs_RemoteLookup
  * afs_GetVCache
  * afs_LookupVCache
@@ -101,7 +100,7 @@ int VCHash(struct VenusFid *fid)
 /* Hash only on volume to speed up volume callbacks. */
 int VCHashV(struct VenusFid *fid)
 {
-    return opr_jhash_int(fid->Fid.Vnode, 0) & opr_jhash_mask(VCSIZEBITS);
+    return opr_jhash_int(fid->Fid.Volume, 0) & opr_jhash_mask(VCSIZEBITS);
 }
 
 /*!
@@ -234,16 +233,22 @@ afs_FlushVCache(struct vcache *avc, int *slept)
     /* OK, there are no internal vrefCounts, so there shouldn't
      * be any more refs here. */
     if (avc->v) {
-#ifdef AFS_DARWIN80_ENV
+# ifdef AFS_DARWIN80_ENV
 	vnode_clearfsnode(AFSTOV(avc));
         vnode_removefsref(AFSTOV(avc));
-#else
+# else
 	avc->v->v_data = NULL;	/* remove from vnode */
-#endif
+# endif
 	AFSTOV(avc) = NULL;             /* also drop the ptr to vnode */
     }
 #endif
-#ifdef AFS_SUN510_ENV
+
+#ifdef AFS_SUN511_ENV
+    if (avc->v) {
+        vn_free(avc->v);
+        avc->v = NULL;
+    }
+#elif defined(AFS_SUN510_ENV)
     /* As we use private vnodes, cleanup is up to us */
     vn_reinit(AFSTOV(avc));
 #endif
@@ -311,7 +316,7 @@ afs_InactiveVCache(struct vcache *avc, afs_ucred_t *acred)
 	/* we can't keep trying to push back dirty data forever.  Give up. */
 	afs_InvalidateAllSegments(avc);	/* turns off dirty bit */
     }
-    avc->f.states &= ~CMAPPED;	/* mainly used by SunOS 4.0.x */
+    avc->f.states &= ~CMAPPED;
     avc->f.states &= ~CDirty;	/* Turn it off */
     if (avc->f.states & CUnlinked) {
 	if (CheckLock(&afs_xvcache) || CheckLock(&afs_xdcache)) {
@@ -695,14 +700,14 @@ afs_FlushReclaimedVcaches(void)
 	    /* printf("Reclaim list flush %lx failed: %d\n", (unsigned long) tvc, code); */
 	}
         if (tvc->f.states & (CVInit
-#ifdef AFS_DARWIN80_ENV
+# ifdef AFS_DARWIN80_ENV
 			  | CDeadVnode
-#endif
+# endif
            )) {
 	   tvc->f.states &= ~(CVInit
-#ifdef AFS_DARWIN80_ENV
+# ifdef AFS_DARWIN80_ENV
 			    | CDeadVnode
-#endif
+# endif
 	   );
 	   afs_osi_Wakeup(&tvc->f.states);
 	}
@@ -741,16 +746,69 @@ afs_PostPopulateVCache(struct vcache *avc, struct VenusFid *afid, int seq)
     afs_osi_Wakeup(&avc->f.states);
 }
 
+/*
+ * afs_VCacheStressed() is intended to determine if the stat cache looks
+ * stressed / full-ish. Due to the different strategies of allocating vcaches
+ * on different platforms, the definition of "stressed" varies, and is somewhat
+ * arbitrary. We just try to make a reasonable guess here.
+ *
+ * Returns 1 if the stat cache looks stressed, and 0 otherwise.
+ */
+#ifdef AFS_LINUX26_ENV
+int
+afs_VCacheStressed(void)
+{
+    if (afsd_dynamic_vcaches) {
+	/*
+	 * For dynamic vcaches, the number of vcaches in use can vary wildly.
+	 * Consider us stressed if we're significantly above the configured
+	 * threshold. VCACHE_DYNAMIC_STRESSED is the arbitrary point at which
+	 * we're considered "significantly" over the threshold.
+	 */
+	if (afs_vcount > afs_cacheStats + VCACHE_DYNAMIC_STRESSED) {
+	    return 1;
+	}
+	return 0;
+
+    } else {
+	/*
+	 * For non-dynamic vcaches, we should never go above the configured
+	 * limit, and ShakeLooseVCaches should try to get us to VCACHE_FREE
+	 * under the limit. So if we're closer then VCACHE_FREE/2, then we're
+	 * very close to the limit, so consider us stressed.
+	 */
+	if (afs_vcount > afs_cacheStats || afs_cacheStats - afs_vcount < VCACHE_FREE/2) {
+	    return 1;
+	}
+	return 0;
+    }
+}
+#else /* AFS_LINUX26_ENV */
+int
+afs_VCacheStressed(void)
+{
+    /* If we don't have any vcaches in the free list, then consider the stat
+     * cache stressed. */
+    if (freeVCList != NULL) {
+	return 0;
+    }
+    return 1;
+}
+#endif /* AFS_LINUX26_ENV */
+
 int
 afs_ShakeLooseVCaches(afs_int32 anumber)
 {
+    /* Try not to run for more than about 3 seconds */
+    static const int DEADLINE = 3;
+
     afs_int32 i, loop;
     int evicted;
     struct vcache *tvc;
     struct afs_q *tq, *uq;
     int fv_slept, defersleep = 0;
     int limit;
-    afs_int32 target = anumber;
+    afs_uint32 start = osi_Time();
 
     loop = 0;
 
@@ -779,8 +837,33 @@ afs_ShakeLooseVCaches(afs_int32 anumber)
 	}
 
 	if (fv_slept) {
-	    if (loop++ > 100)
-		break;
+	    if (loop++ > 100) {
+		afs_uint32 now = osi_Time();
+		loop = 0;
+		if (now < start) {
+		    start = now;
+		}
+		if (now - start >= DEADLINE) {
+		    static afs_uint32 last_warned;
+		    /* Warn about this at most every VCACHE_STRESS_LOGINTERVAL secs */
+		    if (now < last_warned ||
+			now - last_warned > VCACHE_STRESS_LOGINTERVAL) {
+			last_warned = now;
+			afs_warn("afs: Warning: it took us a long time (around "
+				 "%d seconds) to try to trim our stat cache "
+				 "down to a reasonable size. This may indicate "
+				 "someone is accessing an excessive number of "
+				 "files, or something is wrong with the AFS "
+				 "cache.\n",
+				 now - start);
+			afs_warn("afs: Consider raising the afsd -stat parameter "
+				 "(current setting: %d, current vcount: %d), or "
+				 "figure out what is accessing so many files.\n",
+				 afs_cacheStats, afs_vcount);
+		    }
+		    break;
+		}
+	    }
 	    if (!evicted) {
 		/*
 		 * This vcache was busy and we slept while trying to evict it.
@@ -800,9 +883,27 @@ afs_ShakeLooseVCaches(afs_int32 anumber)
 	    break;
 	}
     }
-    if (!afsd_dynamic_vcaches && anumber == target) {
-	afs_warn("afs_ShakeLooseVCaches: warning none freed, using %d of %d\n",
-	       afs_vcount, afs_maxvcount);
+
+    if (afs_VCacheStressed()) {
+	/*
+	 * If it looks like we have too many vcaches, right after
+	 * ShakeLooseVCaches has tried to trim down the number of vcaches, then
+	 * maybe -stat should be increased. Log a warning, so if this is
+	 * causing problems the user has a chance at noticing.
+	 */
+	static afs_uint32 last_warned;
+	afs_uint32 now = osi_Time();
+
+	/* Warn about this at most once every VCACHE_STRESS_LOGINTERVAL secs */
+	if (now - last_warned > VCACHE_STRESS_LOGINTERVAL) {
+	    last_warned = now;
+	    afs_warn("afs: Warning: We are having trouble keeping the AFS stat "
+		     "cache trimmed down under the configured limit (current "
+		     "-stat setting: %d, current vcache usage: %d).\n",
+		     afs_cacheStats, afs_vcount);
+	    afs_warn("afs: If AFS access seems slow, consider raising the "
+		     "-stat setting for afsd.\n");
+	}
     }
 
     return 0;
@@ -1008,7 +1109,7 @@ afs_NewVCache_int(struct VenusFid *afid, struct server *serverp, int seq)
 
 #if defined(AFS_LINUX22_ENV)
     /* Hold it for the LRU (should make count 2) */
-    AFS_FAST_HOLD(tvc);
+    osi_Assert(osi_vnhold(tvc) == 0);
 #elif !(defined (AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV))
     VREFCOUNT_SET(tvc, 1);	/* us */
 #endif
@@ -1072,8 +1173,10 @@ afs_FlushActiveVcaches(afs_int32 doflocks)
 #endif
 	    if (doflocks && tvc->flockCount != 0) {
 		struct rx_connection *rxconn;
+		if (osi_vnhold(tvc) != 0) {
+		    continue;
+		}
 		/* if this entry has an flock, send a keep-alive call out */
-		osi_vnhold(tvc, 0);
 		ReleaseReadLock(&afs_xvcache);
 		ObtainWriteLock(&tvc->lock, 51);
 		do {
@@ -1116,7 +1219,9 @@ afs_FlushActiveVcaches(afs_int32 doflocks)
 		 * this code.  Also, drop the afs_xvcache lock while
 		 * getting vcache locks.
 		 */
-		osi_vnhold(tvc, 0);
+		if (osi_vnhold(tvc) != 0) {
+		    continue;
+		}
 		ReleaseReadLock(&afs_xvcache);
 #if defined(AFS_SGI_ENV)
 		/*
@@ -1240,7 +1345,7 @@ afs_VerifyVCache2(struct vcache *avc, struct vrequest *areq)
     ReleaseWriteLock(&avc->lock);
 
     /* fetch the status info */
-    tvc = afs_GetVCache(&avc->f.fid, areq, NULL, avc);
+    tvc = afs_GetVCache(&avc->f.fid, areq);
     if (!tvc)
 	return EIO;
     /* Put it back; caller has already incremented vrefCount */
@@ -1446,18 +1551,6 @@ afs_WriteVCacheDiscon(struct vcache *avc,
 	if (astatus->Mask & AFS_SETMODE) {
 		avc->f.m.Mode = astatus->UnixModeBits;
 
-#if 0 	/* XXX: Leaving this out, so it doesn't mess up the file type flag.*/
-
-		if (vType(avc) == VREG) {
-			avc->f.m.Mode |= S_IFREG;
-		} else if (vType(avc) == VDIR) {
-			avc->f.m.Mode |= S_IFDIR;
-		} else if (vType(avc) == VLNK) {
-			avc->f.m.Mode |= S_IFLNK;
-			if ((avc->f.m.Mode & 0111) == 0)
-				avc->mvstat = AFS_MVSTAT_MTPT;
-		}
-#endif
 		flags |= VDisconSetMode;
 	 } 		/* if(astatus.Mask & AFS_SETMODE) */
 
@@ -1637,8 +1730,6 @@ afs_RemoteLookup(struct VenusFid *afid, struct vrequest *areq,
  * \param afid File ID.
  * \param areq Ptr to associated vrequest structure, specifying the
  *  user whose authentication tokens will be used.
- * \param avc Caller may already have a vcache for this file, which is
- *  already held.
  *
  * \note Environment:
  *	The cache entry is returned with an increased vrefCount field.
@@ -1658,13 +1749,9 @@ afs_RemoteLookup(struct VenusFid *afid, struct vrequest *areq,
  *	locking directories in a constant order.
  *
  * \note NB.  NewVCache -> FlushVCache presently (4/10/95) drops the xvcache lock.
- *
- * \note Might have a vcache structure already, which must
- *  already be held by the caller
  */
 struct vcache *
-afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
-	      afs_int32 * cached, struct vcache *avc)
+afs_GetVCache(struct VenusFid *afid, struct vrequest *areq)
 {
 
     afs_int32 code, newvcache = 0;
@@ -1674,9 +1761,6 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
 
     AFS_STATCNT(afs_GetVCache);
 
-    if (cached)
-	*cached = 0;		/* Init just in case */
-
 #if	defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
   loop:
 #endif
@@ -1692,8 +1776,6 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
 #endif
     }
     if (tvc) {
-	if (cached)
-	    *cached = 1;
 	osi_Assert((tvc->f.states & CVInit) == 0);
 	/* If we are in readdir, return the vnode even if not statd */
 	if ((tvc->f.states & CStatd) || afs_InReadDir(tvc)) {
@@ -1729,7 +1811,7 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
 /* Darwin 8.0 only has bufs in nfs, so we shouldn't have to worry about them.
    What about ubc? */
 #else
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+# if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
     /*
      * XXX - I really don't like this.  Should try to understand better.
      * It seems that sometimes, when we get called, we already hold the
@@ -1745,7 +1827,7 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
 	struct vnode *vp = AFSTOV(tvc);
 	int iheldthelock;
 
-#if defined(AFS_DARWIN_ENV)
+#  if defined(AFS_DARWIN_ENV)
 	iheldthelock = VOP_ISLOCKED(vp);
 	if (!iheldthelock)
 	    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, current_proc());
@@ -1759,44 +1841,24 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
 	  ObtainWriteLock(&tvc->lock, 954);
 	if (!iheldthelock)
 	    VOP_UNLOCK(vp, LK_EXCLUSIVE, current_proc());
-#elif defined(AFS_FBSD80_ENV)
+#  elif defined(AFS_FBSD_ENV)
+	AFS_GUNLOCK();
 	iheldthelock = VOP_ISLOCKED(vp);
 	if (!iheldthelock) {
-	    /* nosleep/sleep lock order reversal */
-	    int glocked = ISAFS_GLOCK();
-	    if (glocked)
-		AFS_GUNLOCK();
 	    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
-	    if (glocked)
-		AFS_GLOCK();
 	}
 	vinvalbuf(vp, V_SAVE, PINOD, 0); /* changed late in 8.0-CURRENT */
 	if (!iheldthelock)
 	    VOP_UNLOCK(vp, 0);
-#elif defined(AFS_FBSD60_ENV)
-	iheldthelock = VOP_ISLOCKED(vp, curthread);
-	if (!iheldthelock)
-	    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
-	AFS_GUNLOCK();
-	vinvalbuf(vp, V_SAVE, curthread, PINOD, 0);
 	AFS_GLOCK();
-	if (!iheldthelock)
-	    VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
-#elif defined(AFS_FBSD_ENV)
-	iheldthelock = VOP_ISLOCKED(vp, curthread);
-	if (!iheldthelock)
-	    vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curthread);
-	vinvalbuf(vp, V_SAVE, osi_curcred(), curthread, PINOD, 0);
-	if (!iheldthelock)
-	    VOP_UNLOCK(vp, LK_EXCLUSIVE, curthread);
-#elif defined(AFS_OBSD_ENV)
+#  elif defined(AFS_OBSD_ENV)
 	iheldthelock = VOP_ISLOCKED(vp, curproc);
 	if (!iheldthelock)
 	    VOP_LOCK(vp, LK_EXCLUSIVE | LK_RETRY, curproc);
 	uvm_vnp_uncache(vp);
 	if (!iheldthelock)
 	    VOP_UNLOCK(vp, 0, curproc);
-#elif defined(AFS_NBSD40_ENV)
+#  elif defined(AFS_NBSD40_ENV)
 	iheldthelock = VOP_ISLOCKED(vp);
 	if (!iheldthelock) {
 	    VOP_LOCK(vp, LK_EXCLUSIVE | LK_RETRY);
@@ -1804,9 +1866,9 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
 	uvm_vnp_uncache(vp);
 	if (!iheldthelock)
 	    VOP_UNLOCK(vp, 0);
-#endif
+#  endif
     }
-#endif
+# endif
 #endif
 
     afs_StaleVCacheFlags(tvc, AFS_STALEVC_NODNLC | AFS_STALEVC_CLEARCB,
@@ -1899,7 +1961,6 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
  *
  * \param afid
  * \param areq
- * \param cached Is element cached? If NULL, don't answer.
  * \param adp
  * \param aname
  *
@@ -1907,7 +1968,7 @@ afs_GetVCache(struct VenusFid *afid, struct vrequest *areq,
  */
 struct vcache *
 afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
-		 afs_int32 * cached, struct vcache *adp, char *aname)
+		 struct vcache *adp, char *aname)
 {
     afs_int32 code, now, newvcache = 0;
     struct VenusFid nfid;
@@ -1921,8 +1982,6 @@ afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
     afs_int32 retry;
 
     AFS_STATCNT(afs_GetVCache);
-    if (cached)
-	*cached = 0;		/* Init just in case */
 
 #if	defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
   loop1:
@@ -1942,9 +2001,6 @@ afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
 	ObtainReadLock(&tvc->lock);
 
 	if (tvc->f.states & CStatd) {
-	    if (cached) {
-		*cached = 1;
-	    }
 	    ReleaseReadLock(&tvc->lock);
 	    return tvc;
 	}
@@ -2069,7 +2125,7 @@ afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
 
 struct vcache *
 afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
-		  afs_int32 * cached, struct volume *tvolp)
+		  struct volume *tvolp)
 {
     afs_int32 code = 0, i, newvcache = 0, haveStatus = 0;
     afs_int32 getNewFid = 0;
@@ -2138,6 +2194,10 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
 		AFS_GLOCK();
 	        continue;
 	    }
+#else
+	    if (osi_vnhold(tvc) != 0) {
+		continue;
+	    }
 #endif
 	    break;
 	}
@@ -2146,14 +2206,19 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
     if (!haveStatus && (!tvc || !(tvc->f.states & CStatd))) {
 	/* Mount point no longer stat'd or unknown. FID may have changed. */
 	getNewFid = 1;
-	ReleaseSharedLock(&afs_xvcache);
 #ifdef AFS_DARWIN80_ENV
+	ReleaseSharedLock(&afs_xvcache);
         if (tvc) {
             AFS_GUNLOCK();
             vnode_put(AFSTOV(tvc));
             vnode_rele(AFSTOV(tvc));
             AFS_GLOCK();
         }
+#else
+	if (tvc) {
+	    AFS_FAST_RELE(tvc);
+	}
+	ReleaseSharedLock(&afs_xvcache);
 #endif
         tvc = NULL;
 	goto newmtpt;
@@ -2171,14 +2236,7 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
 	newvcache = 1;
 	afs_stats_cmperf.vcacheMisses++;
     } else {
-	if (cached)
-	    *cached = 1;
 	afs_stats_cmperf.vcacheHits++;
-#if	defined(AFS_DARWIN80_ENV)
-	/* we already bumped the ref count in the for loop above */
-#else /* AFS_DARWIN80_ENV */
-	osi_vnhold(tvc, 0);
-#endif
 	UpgradeSToWLock(&afs_xvcache, 24);
 	if ((VLRU.next->prev != &VLRU) || (VLRU.prev->next != &VLRU)) {
 	    refpanic("GRVC VLRU inconsistent0");
@@ -2444,145 +2502,6 @@ afs_FetchStatus(struct vcache * avc, struct VenusFid * afid,
     return code;
 }
 
-#if 0
-/*
- * afs_StuffVcache
- *
- * Description:
- *	Stuff some information into the vcache for the given file.
- *
- * Parameters:
- *	afid	  : File in question.
- *	OutStatus : Fetch status on the file.
- *	CallBack  : Callback info.
- *	tc	  : RPC connection involved.
- *	areq	  : vrequest involved.
- *
- * Environment:
- *	Nothing interesting.
- */
-void
-afs_StuffVcache(struct VenusFid *afid,
-		struct AFSFetchStatus *OutStatus,
-		struct AFSCallBack *CallBack, struct afs_conn *tc,
-		struct vrequest *areq)
-{
-    afs_int32 code, i, newvcache = 0;
-    struct vcache *tvc;
-    struct AFSVolSync tsync;
-    struct volume *tvp;
-    struct axscache *ac;
-    afs_int32 retry;
-
-    AFS_STATCNT(afs_StuffVcache);
-#ifdef IFS_VCACHECOUNT
-    ifs_gvcachecall++;
-#endif
-
-  loop:
-    ObtainSharedLock(&afs_xvcache, 8);
-
-    tvc = afs_FindVCache(afid, &retry, DO_VLRU| IS_SLOCK /* no stats */ );
-    if (tvc && retry) {
-#if	defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
-	ReleaseSharedLock(&afs_xvcache);
-	spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD);
-	goto loop;
-#endif
-    }
-
-    if (!tvc) {
-	/* no cache entry, better grab one */
-	UpgradeSToWLock(&afs_xvcache, 25);
-	tvc = afs_NewVCache(afid, NULL);
-	newvcache = 1;
-	ConvertWToSLock(&afs_xvcache);
-	if (!tvc)
-	{
-		ReleaseSharedLock(&afs_xvcache);
-		return NULL;
-	}
-    }
-
-    ReleaseSharedLock(&afs_xvcache);
-    ObtainWriteLock(&tvc->lock, 58);
-
-    afs_StaleVCacheFlags(tvc, AFS_STALEVC_NOCB, 0);
-
-    /* Is it always appropriate to throw away all the access rights? */
-    afs_FreeAllAxs(&(tvc->Access));
-
-    /*Copy useful per-volume info */
-    tvp = afs_GetVolume(afid, areq, READ_LOCK);
-    if (tvp) {
-	if (newvcache && (tvp->states & VForeign))
-	    tvc->f.states |= CForeign;
-	if (tvp->states & VRO)
-	    tvc->f.states |= CRO;
-	if (tvp->states & VBackup)
-	    tvc->f.states |= CBackup;
-	/*
-	 * Now, copy ".." entry back out of volume structure, if
-	 * necessary
-	 */
-	if (tvc->mvstat == AFS_MVSTAT_ROOT && tvp->dotdot.Fid.Volume != 0) {
-	    if (!tvc->mvid.parent)
-		tvc->mvid.parent = (struct VenusFid *)
-		    osi_AllocSmallSpace(sizeof(struct VenusFid));
-	    *tvc->mvid.parent = tvp->dotdot;
-	}
-    }
-    /* store the stat on the file */
-    afs_RemoveVCB(afid);
-    afs_ProcessFS(tvc, OutStatus, areq);
-    tvc->callback = tc->srvr->server;
-
-    /* we use osi_Time twice below.  Ideally, we would use the time at which
-     * the FetchStatus call began, instead, but we don't have it here.  So we
-     * make do with "now".  In the CRO case, it doesn't really matter. In
-     * the other case, we hope that the difference between "now" and when the
-     * call actually began execution on the server won't be larger than the
-     * padding which the server keeps.  Subtract 1 second anyway, to be on
-     * the safe side.  Can't subtract more because we don't know how big
-     * ExpirationTime is.  Possible consistency problems may arise if the call
-     * timeout period becomes longer than the server's expiration padding.  */
-    ObtainWriteLock(&afs_xcbhash, 470);
-    if (CallBack->ExpirationTime != 0) {
-	tvc->cbExpires = CallBack->ExpirationTime + osi_Time() - 1;
-	tvc->f.states |= CStatd;
-	tvc->f.states &= ~CBulkFetching;
-	afs_QueueCallback(tvc, CBHash(CallBack->ExpirationTime), tvp);
-    } else if (tvc->f.states & CRO) {
-	/* old-fashioned AFS 3.2 style */
-	tvc->cbExpires = 3600 + osi_Time();
-	 /*XXX*/ tvc->f.states |= CStatd;
-	tvc->f.states &= ~CBulkFetching;
-	afs_QueueCallback(tvc, CBHash(3600), tvp);
-    } else {
-	afs_StaleVCacheFlags(tvc, AFS_STALEVC_CBLOCKED | AFS_STALEVC_CLEARCB,
-			     CUnique);
-    }
-    ReleaseWriteLock(&afs_xcbhash);
-    if (tvp)
-	afs_PutVolume(tvp, READ_LOCK);
-
-    /* look in per-pag cache */
-    if (tvc->Access && (ac = afs_FindAxs(tvc->Access, areq->uid)))
-	ac->axess = OutStatus->CallerAccess;	/* substitute pags */
-    else			/* not found, add a new one if possible */
-	afs_AddAxs(tvc->Access, areq->uid, OutStatus->CallerAccess);
-
-    ReleaseWriteLock(&tvc->lock);
-    afs_Trace4(afs_iclSetp, CM_TRACE_STUFFVCACHE, ICL_TYPE_POINTER, tvc,
-	       ICL_TYPE_POINTER, tvc->callback, ICL_TYPE_INT32,
-	       tvc->cbExpires, ICL_TYPE_INT32, tvc->cbExpires - osi_Time());
-    /*
-     * Release ref count... hope this guy stays around...
-     */
-    afs_PutVCache(tvc);
-}				/*afs_StuffVcache */
-#endif
-
 /*!
  * Decrements the reference count on a cache entry.
  *
@@ -2703,7 +2622,9 @@ afs_RefVCache(struct vcache *tvc)
 	return -1;
     }
 #else
-	osi_vnhold(tvc, 0);
+    if (osi_vnhold(tvc) != 0) {
+	return -1;
+    }
 #endif
     return 0;
 }				/*afs_RefVCache */
@@ -2755,8 +2676,6 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
 
     /* should I have a read lock on the vnode here? */
     if (tvc) {
-	if (retry)
-	    *retry = 0;
 #if defined(AFS_DARWIN80_ENV)
 	tvp = AFSTOV(tvc);
 	if (vnode_get(tvp))
@@ -2782,10 +2701,12 @@ afs_FindVCache(struct VenusFid *afid, afs_int32 * retry, afs_int32 flag)
 	AFS_GLOCK();
 	tvc->f.states &= ~CUBCinit;
 #else
-	osi_vnhold(tvc, retry);	/* already held, above */
-	if (retry && *retry)
-	    return 0;
+	if (osi_vnhold(tvc) != 0) {
+	    tvc = NULL;
+	}
 #endif
+    }
+    if (tvc) {
 	/*
 	 * only move to front of vlru if we have proper vcache locking)
 	 */
@@ -2897,11 +2818,19 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
 		AFS_GLOCK();
 		continue;
 	    }
+#else
+	    if (osi_vnhold(tvc) != 0) {
+		continue;
+	    }
 #endif /* AFS_DARWIN80_ENV */
 	    count++;
 	    if (found_tvc) {
 		/* Duplicates */
 		afs_duplicate_nfs_fids++;
+#ifndef AFS_DARWIN80_ENV
+		AFS_FAST_RELE(tvc);
+		AFS_FAST_RELE(found_tvc);
+#endif
 		ReleaseSharedLock(&afs_xvcache);
 #ifdef AFS_DARWIN80_ENV
                 /* Drop our reference counts. */
@@ -2917,21 +2846,6 @@ afs_NFSFindVCache(struct vcache **avcp, struct VenusFid *afid)
     tvc = found_tvc;
     /* should I have a read lock on the vnode here? */
     if (tvc) {
-#ifndef AFS_DARWIN80_ENV
-#if defined(AFS_SGI_ENV) && !defined(AFS_SGI53_ENV)
-	afs_int32 retry = 0;
-	osi_vnhold(tvc, &retry);
-	if (retry) {
-	    count = 0;
-	    found_tvc = (struct vcache *)0;
-	    ReleaseSharedLock(&afs_xvcache);
-	    spunlock_psema(tvc->v.v_lock, retry, &tvc->v.v_sync, PINOD);
-	    goto loop;
-	}
-#else
-	osi_vnhold(tvc, (int *)0);	/* already held, above */
-#endif
-#endif
 	/*
 	 * We obtained the xvcache lock above.
 	 */
@@ -3027,12 +2941,12 @@ afs_vcacheInit(int astatSize)
 	tvc->vc_rwlockid = OSI_NO_LOCKID;
 	initnsema(&tvc->vc_rwlock, 1,
 		  makesname(name, "vrw", tvc->v.v_number));
-#ifndef	AFS_SGI53_ENV
+# ifndef	AFS_SGI53_ENV
 	initnsema(&tvc->v.v_sync, 0, makesname(name, "vsy", tvc->v.v_number));
-#endif
-#ifndef AFS_SGI62_ENV
+# endif
+# ifndef AFS_SGI62_ENV
 	initnlock(&tvc->v.v_lock, makesname(name, "vlk", tvc->v.v_number));
-#endif /* AFS_SGI62_ENV */
+# endif /* AFS_SGI62_ENV */
     }
 #endif
     QInit(&VLRU);
@@ -3085,7 +2999,7 @@ shutdown_vcache(void)
 #ifdef	AFS_AIX_ENV
 		if (tvc->v.v_gnode)
 		    afs_osi_Free(tvc->v.v_gnode, sizeof(struct gnode));
-#ifdef	AFS_AIX32_ENV
+# ifdef	AFS_AIX32_ENV
 		if (tvc->segid) {
 		    AFS_GUNLOCK();
 		    vms_delete(tvc->segid);
@@ -3098,7 +3012,7 @@ shutdown_vcache(void)
 		    crfree(tvc->credp);
 		    tvc->credp = NULL;
 		}
-#endif
+# endif
 #endif
 #if	defined(AFS_SUN5_ENV)
 		if (tvc->credp) {
@@ -3252,7 +3166,8 @@ afs_StaleVCacheFlags(struct vcache *avc, afs_stalevc_flags_t flags,
     }
 
     if (do_dnlc) {
-	if ((avc->f.fid.Fid.Vnode & 1) || vType(avc) == VDIR ||
+	if ((avc->f.fid.Fid.Vnode & 1) ||
+	    AFSTOV(avc) == NULL || vType(avc) == VDIR ||
 	    (avc->f.states & CForeign)) {
 	    /* This vcache is (or could be) a directory. */
 	    osi_dnlc_purgedp(avc);
diff --git a/src/afs/afs_volume.c b/src/afs/afs_volume.c
index ff7cc4718..28179db00 100644
--- a/src/afs/afs_volume.c
+++ b/src/afs/afs_volume.c
@@ -248,8 +248,10 @@ afs_UFSGetVolSlot(afs_int32 volid, struct cell *tcell)
     }
 
     /* read volume item data from disk for the gotten slot */
-    for (j = fvTable[FVHash(tcell->cellNum, volid)]; j != 0; j = tf->next) {
+    for (j = fvTable[FVHash(tcell->cellNum, volid)]; j != 0; j = staticFVolume.next) {
 	if (afs_FVIndex != j) {
+	    /* The data in staticFVolume is currently for a different slot.
+	     * Read the data for slot 'j' into staticFVolume. */
 	    tfile = osi_UFSOpen(&volumeInode);
 	    if (!tfile) {
 		afs_warn("afs_UFSGetVolSlot: unable to open volumeinfo\n");
@@ -274,11 +276,9 @@ afs_UFSGetVolSlot(afs_int32 volid, struct cell *tcell)
 	    }
 	    afs_FVIndex = j;
 	}
-	if (j != 0) {		/* volume items record 0 is not used */
+	if (staticFVolume.cell == tcell->cellNum && staticFVolume.volume == volid) {
 	    tf = &staticFVolume;
-	    if (tf->cell == tcell->cellNum && tf->volume == volid) {
-		break;
-	    }
+	    break;
 	}
     }
 
@@ -548,7 +548,9 @@ loop:
 			continue;
 		    }
 #else
-		    AFS_FAST_HOLD(tvc);
+		    if (osi_vnhold(tvc) != 0) {
+			continue;
+		    }
 #endif
 		    ReleaseReadLock(&afs_xvcache);
 
@@ -910,25 +912,6 @@ afs_NewVolumeByName(char *aname, afs_int32 acell, int agood,
 			 SHARED_LOCK, tcell));
 
     if (code) {
-	/* If the client has yet to contact this cell and contact failed due
-	 * to network errors, mark the VLDB servers as back up.
-	 * That the client tried and failed can be determined from the
-	 * fact that there was a downtime incident, but CHasVolRef is not set.
-	 */
-    /* RT 48959 - unclear if this should really go */
-#if 0
-	if (areq->networkError && !(tcell->states & CHasVolRef)) {
-	    int i;
-	    struct server *sp;
-	    struct srvAddr *sap;
-	    for (i = 0; i < AFS_MAXCELLHOSTS; i++) {
-		if ((sp = tcell->cellHosts[i]) == NULL)
-		    break;
-		for (sap = sp->addr; sap; sap = sap->next_sa)
-		    afs_MarkServerUpOrDown(sap, 0);
-	    }
-	}
-#endif
 	afs_CopyError(treq, areq);
 	osi_FreeLargeSpace(tbuffer);
 	afs_PutCell(tcell, READ_LOCK);
diff --git a/src/afs/afs_warn.c b/src/afs/afs_warn.c
index 289593d6b..ba0b757ac 100644
--- a/src/afs/afs_warn.c
+++ b/src/afs/afs_warn.c
@@ -164,6 +164,7 @@ afs_vwarnuser (char *fmt, va_list ap)
 	snprintf(buf, sizeof(buf), "warn$");
 	vsnprintf(buf+strlen(buf), sizeof(buf)-strlen(buf), fmt, aq);
 	afs_MarinerLog(buf, NULL);
+	va_end(aq);
     }
     vprintf(fmt, ap);
 
@@ -253,3 +254,18 @@ afs_warnall(char *fmt, ...)
 # endif /* AFS_LINUX20_ENV */
 }
 #endif /* AFS_AIX_ENV */
+
+/*
+ * Log a warning when we encounter an ENOSPC error when writing to the cache
+ * partition. We should not normally encounter ENOSPC errors, since we limit
+ * our space usage according to the client config, which should be configured
+ * such that we never run out of space.
+ */
+void
+afs_WarnENOSPC(void)
+{
+    afs_warnuser("afs: Cache partition is FULL! This should not happen, and "
+                 "can result in errors in userspace applications. To avoid "
+                 "this, reduce the configured cache size so we do not run out "
+                 "of space.\n");
+}
diff --git a/src/afs/lock.h b/src/afs/lock.h
index 9d7fef485..9df8b996b 100644
--- a/src/afs/lock.h
+++ b/src/afs/lock.h
@@ -84,6 +84,7 @@ typedef unsigned int afs_lock_tracker_t;
 typedef struct task_struct * afs_lock_tracker_t;
 # define MyPidxx (current)
 # define MyPidxx2Pid(x) (x? (x)->pid : 0)
+# define MyPid_NULL (NULL)
 #elif defined(AFS_DARWIN_ENV)
 # if defined(AFS_DARWIN80_ENV)
 typedef unsigned int afs_lock_tracker_t;
@@ -108,6 +109,10 @@ typedef unsigned int afs_lock_tracker_t;
 # define MyPidxx2Pid(x) (x)
 #endif
 
+#ifndef MyPid_NULL
+# define MyPid_NULL (0)
+#endif
+
 /* all locks wait on excl_locked except for READ_LOCK, which waits on readers_reading */
 struct afs_lock {
     unsigned char wait_states;	/* type of lockers waiting */
@@ -115,7 +120,7 @@ struct afs_lock {
     unsigned short readers_reading;	/* # readers actually with read locks */
     unsigned short num_waiting;	/* probably need this soon */
     unsigned short spare;	/* not used now */
-    osi_timeval_t time_waiting;	/* for statistics gathering */
+    osi_timeval32_t time_waiting;	/* for statistics gathering */
 #if defined(INSTRUMENT_LOCKS)
     /* the following are useful for debugging
      ** the field 'src_indicator' is updated only by ObtainLock() and
@@ -219,7 +224,7 @@ extern int afs_trclock;
 	    (lock)->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK);\
 	    ((lock)->readers_reading)++;\
 	    (lock)->pid_last_reader = MyPidxx ; \
-	    (lock)->pid_writer = 0;\
+	    (lock)->pid_writer = MyPid_NULL;\
 	    Afs_Lock_ReleaseR(lock);\
 	ENDMAC
 
@@ -229,7 +234,7 @@ extern int afs_trclock;
 	    (lock)->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK);\
 	    ((lock)->readers_reading)++;\
 	    (lock)->pid_last_reader = MyPidxx ; \
-	    (lock)->pid_writer = 0;\
+	    (lock)->pid_writer = MyPid_NULL;\
 	    Afs_Lock_ReleaseR(lock);\
 	ENDMAC
 
@@ -239,7 +244,7 @@ extern int afs_trclock;
 	    if (!(--((lock)->readers_reading)) && (lock)->wait_states)\
 		Afs_Lock_ReleaseW(lock) ; \
 	if ( (lock)->pid_last_reader == MyPidxx ) \
-		(lock)->pid_last_reader =0;\
+		(lock)->pid_last_reader = MyPid_NULL;\
 	ENDMAC
 
 #define ReleaseWriteLock(lock)\
@@ -247,7 +252,7 @@ extern int afs_trclock;
 	AFS_LOCK_TRACE(CM_TRACE_LOCKDONE, lock, WRITE_LOCK);\
 	    (lock)->excl_locked &= ~WRITE_LOCK;\
 	    if ((lock)->wait_states) Afs_Lock_ReleaseR(lock);\
-	    (lock)->pid_writer=0; \
+	    (lock)->pid_writer = MyPid_NULL; \
         ENDMAC
 
 /* can be used on shared or boosted (write) locks */
@@ -256,7 +261,7 @@ extern int afs_trclock;
 	AFS_LOCK_TRACE(CM_TRACE_LOCKDONE, lock, SHARED_LOCK);\
 	    (lock)->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK);\
 	    if ((lock)->wait_states) Afs_Lock_ReleaseR(lock);\
-	    (lock)->pid_writer=0; \
+	    (lock)->pid_writer = MyPid_NULL; \
         ENDMAC
 
 #else /* INSTRUMENT_LOCKS */
diff --git a/src/afs/sysincludes.h b/src/afs/sysincludes.h
index 0e09271cd..dbe7ab6cb 100644
--- a/src/afs/sysincludes.h
+++ b/src/afs/sysincludes.h
@@ -122,6 +122,7 @@
 # include <linux/kdev_t.h>
 # include <linux/ioctl.h>
 # if defined(AFS_LINUX26_ENV)
+#  include <linux/compat.h>
 #  include <linux/backing-dev.h>
 #  include <linux/pagemap.h>
 #  include <linux/namei.h>
@@ -181,12 +182,6 @@ struct xfs_inode_info {
 # endif
 
 #else /* AFS_LINUX22_ENV */
-# if defined(AFS_DARWIN_ENV)
-#  ifndef _MACH_ETAP_H_
-#   define _MACH_ETAP_H_
-typedef unsigned short etap_event_t;
-#  endif
-# endif
 
 # include "h/errno.h"
 # include "h/types.h"
diff --git a/src/afs/unified_afs.et b/src/afs/unified_afs.et
index 2b56483e6..f14f73bef 100644
--- a/src/afs/unified_afs.et
+++ b/src/afs/unified_afs.et
@@ -122,4 +122,11 @@ error_table uae
  ec UAEDQUOT, "Quota exceeded"
  ec UAENOMEDIUM, "No medium found"
  ec UAEMEDIUMTYPE, "Wrong medium type"
+ ec UAECANCELED, "Operation canceled"
+ ec UAENOTRECOVERABLE, "State not recoverable"
+ ec UAENOTSUP, "Not supported"
+ ec UAEOTHER, "Other"
+ ec UAEOWNERDEAD, "Owner dead"
+ ec UAEPROCLIM, "Too many processes"
+ ec UAEDISCON, "Graceful shutdown in progress"
 end
diff --git a/src/afs/unified_afs.p.h b/src/afs/unified_afs.p.h
index 84de57024..0bec91f9e 100644
--- a/src/afs/unified_afs.p.h
+++ b/src/afs/unified_afs.p.h
@@ -375,3 +375,24 @@
 #ifndef EMEDIUMTYPE
 #define EMEDIUMTYPE EIO
 #endif /* EMEDIUMTYPE */
+#ifndef ECANCELED
+#define ECANCELED EIO
+#endif /* ECANCELED */
+#ifndef ENOTRECOVERABLE
+#define ENOTRECOVERABLE EIO
+#endif /* ENOTRECOVERABLE */
+#ifndef ENOTSUP
+#define ENOTSUP EIO
+#endif /* ENOTSUP */
+#ifndef EOTHER
+#define EOTHER EIO
+#endif /* EOTHER */
+#ifndef EOWNERDEAD
+#define EOWNERDEAD EIO
+#endif /* EOWNERDEAD */
+#ifndef EPROCLIM
+#define EPROCLIM EIO
+#endif /* EPROCLIM */
+#ifndef EDISCON
+#define EDISCON EIO
+#endif /* EDISCON */
diff --git a/src/afsd/CellServDB b/src/afsd/CellServDB
index eaca48763..a6bd8fc38 100644
--- a/src/afsd/CellServDB
+++ b/src/afsd/CellServDB
@@ -1,4 +1,4 @@
->grand.central.org      #GCO Public CellServDB 14 Mar 2017
+>grand.central.org      #GCO Public CellServDB 14 May 2018
 18.9.48.14                      #grand.mit.edu
 128.2.13.219                    #grand-old-opry.central.org
 >wu-wien.ac.at          #University of Economics, Vienna, Austria
@@ -270,10 +270,10 @@
 >acm.jhu.edu            #Johns Hopkins ACM chapter
 128.220.35.191                  #chicago.acm.jhu.edu
 128.220.70.76                   #typhon.acm.jhu.edu
->athena.mit.edu         #Cell Name
+>athena.mit.edu         #MIT/Athena cell
+18.7.45.11                      #leda.mit.edu
 18.9.48.11                      #castor.mit.edu
 18.9.48.12                      #pollux.mit.edu
-18.27.2.14                      #prill.mit.edu
 >csail.mit.edu          #MIT Computer Science & Artificial Intelligence Lab
 128.30.2.13                     #titanic.csail.mit.edu
 128.30.2.31                     #vasa.csail.mit.edu
@@ -286,12 +286,10 @@
 18.7.62.60                      #willy.mit.edu
 18.9.48.15                      #moby.mit.edu
 18.9.48.16                      #springer.mit.edu
->numenor.mit.edu        #Project Numenor
-18.243.2.49                     #numenor.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.4.60.19                      #reynelda.mit.edu
+18.4.60.22                      #rosebud.mit.edu
+18.4.60.23                      #ronald-ann.mit.edu
 >msu.edu                #Michigan State University Main Cell
 35.9.7.10                       #afsdb0.cl.msu.edu
 35.9.7.11                       #afsdb1.cl.msu.edu
@@ -535,11 +533,11 @@
 >laroia.net             #Laroia Networks
 66.66.102.254                   #supercore.laroia.net
 >pallissard.net         #pallissard.net
-198.98.51.77                    #a001.pallissard.net
+35.184.35.247                   #files.pallissard.net
 >sinenomine.net         #Sine Nomine Associates
-199.167.73.142                  #afsdb1.sinenomine.net
-199.167.73.152                  #afsdb4.sinenomine.net
-199.167.73.153                  #afsdb5.sinenomine.net
+207.89.43.108                   #afsdb3.sinenomine.net
+207.89.43.109                   #afsdb4.sinenomine.net
+207.89.43.110                   #afsdb5.sinenomine.net
 >slackers.net           #The Slackers' Network
 199.4.150.159                   #alexandria.slackers.net
 >tproa.net              #The People's Republic of Ames
@@ -610,11 +608,9 @@
 130.237.233.143                 #castor.mech.kth.se
 130.237.233.144                 #pollux.mech.kth.se
 >nada.kth.se            #Royal Institute of Technology, NADA
-130.237.222.20                  #afsdb-1.csc.kth.se
 130.237.223.12                  #afsdb-2.csc.kth.se
 130.237.224.78                  #afsdb-3.csc.kth.se
 130.237.227.23                  #afsdb-4.csc.kth.se
-130.237.228.28                  #afsdb-5.csc.kth.se
 >pdc.kth.se             #Royal Institute of Technology, PDC
 130.237.232.29                  #crab.pdc.kth.se
 130.237.232.112                 #anna.pdc.kth.se
@@ -644,7 +640,6 @@
 194.190.165.201                 #fs0001.ihep.su
 194.190.165.202                 #fs0002.ihep.su
 >motherfsck.tech        #motherfsck.tech
-198.98.52.149                   #a001.motherfsck.tech
 >hep-ex.physics.metu.edu.tr #METU Department of Physics, Experimental HEP group, Ankara/Turke
 144.122.31.131                  #neutrino.physics.metu.edu.tr
 >phy.bris.ac.uk         #Bristol University - physics
diff --git a/src/afsd/Makefile.in b/src/afsd/Makefile.in
index 4e7319c74..ec46658b2 100644
--- a/src/afsd/Makefile.in
+++ b/src/afsd/Makefile.in
@@ -114,9 +114,6 @@ dest: afsd vsys @ENABLE_FUSE_CLIENT@
 		sun*_511 ) \
 			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/modload ; \
 			${INSTALL_SCRIPT} ${srcdir}/afs.rc.solaris.2.11 ${DEST}/root.client/usr/vice/etc/modload/afs.rc ;;\
-		alpha_osf* ) \
-			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
-			${INSTALL_SCRIPT} ${srcdir}/afs.rc.alpha ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\
 		hp_ux1122 ) \
 			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
 			${INSTALL_SCRIPT} ${srcdir}/afs.rc.hpux10 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;\
@@ -125,9 +122,6 @@ dest: afsd vsys @ENABLE_FUSE_CLIENT@
 			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
 			${INSTALL_SCRIPT} ${srcdir}/afs.rc.hpux10 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;\
 			${INSTALL_DATA} ${srcdir}/afs.hpux102.driver ${DEST}/root.client/usr/vice/etc/afs.driver ;;\
-		alpha_dux* ) \
-			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
-			${INSTALL_SCRIPT} ${srcdir}/afs.rc.alpha_dux40 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\
 	        hp?00_ux10? ) \
 			${INSTALL} -d ${DEST}/root.client/usr/vice/etc/dkload ; \
 			${INSTALL_SCRIPT} ${srcdir}/afs.rc.hpux10 ${DEST}/root.client/usr/vice/etc/dkload/afs.rc ;;\
diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c
index 46921728a..2d37aa184 100644
--- a/src/afsd/afsd.c
+++ b/src/afsd/afsd.c
@@ -496,11 +496,6 @@ afsd_install_events(void)
 		   (NULL, kSCDynamicStoreDomainState,
 		    kSCCompAnyRegex, kSCEntNetIPv4));
 
-#if 0
-	/* This should tell us when the hostname(s) change. do we care? */
-	keys[N] = SCDynamicStoreKeyCreateHostNames (NULL);
-#endif
-
 	if (keys[0] != NULL) {
 	    CFArrayRef pattern_array;
 
@@ -1133,12 +1128,6 @@ doSweepAFSCache(int *vFilesFound,
 	    SetNoBackupAttr(fullpn_CellInfoFile);
 	} else if ((strcmp(currp->d_name, ".") == 0)
 		   || (strcmp(currp->d_name, "..") == 0) ||
-#ifdef AFS_DECOSF_ENV
-		   /* these are magic AdvFS files */
-		   (strcmp(currp->d_name, ".tags") == 0)
-		   || (strcmp(currp->d_name, "quota.user") == 0)
-		   || (strcmp(currp->d_name, "quota.group") == 0) ||
-#endif
 #ifdef AFS_LINUX22_ENV
 		   /* this is the ext3 journal file */
 		   (strcmp(currp->d_name, ".journal") == 0) ||
@@ -1549,18 +1538,20 @@ BkgHandler(void)
     uspc->ts = -1;
 
     while (1) {
-	pid_t child = 0;
-	int status;
-	char srcpath[BUFSIZ];
-	char dstpath[BUFSIZ];
-
 	/* pushing in a buffer this large */
 	uspc->bufSz = 256;
 
 	code = afsd_syscall(AFSOP_BKG_HANDLER, uspc, srcName, dstName);
 	if (code) {		/* Something is wrong? */
-	    if (code == -2) /* shutting down */
-		break;
+	    if (code == -2) {
+		/*
+		 * Before AFS_USPC_SHUTDOWN existed, the kernel module used to
+		 * indicate it was shutting down by returning -2. Treat this
+		 * like a AFS_USPC_SHUTDOWN, in case we're running with an
+		 * older kernel module.
+		 */
+		return;
+	    }
 
 	    sleep(1);
 	    uspc->retval = -1;
@@ -1568,72 +1559,84 @@ BkgHandler(void)
 	}
 
 	switch (uspc->reqtype) {
-	case AFS_USPC_UMV:
-	    snprintf(srcpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
-		     uspc->req.umv.sCell, uspc->req.umv.sVolume,
-		     uspc->req.umv.sVnode, uspc->req.umv.sUnique, srcName);
-	    snprintf(dstpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
-		     uspc->req.umv.dCell, uspc->req.umv.dVolume,
-		     uspc->req.umv.dVnode, uspc->req.umv.dUnique, dstName);
-	    if ((child = fork()) == 0) {
-		/* first child does cp; second, rm. mv would re-enter. */
-
-		switch (uspc->req.umv.idtype) {
-		case IDTYPE_UID:
-		    if (setuid(uspc->req.umv.id) != 0) {
-			exit(-1);
-		    }
-		    break;
-		default:
-		    exit(-1);
-		    break; /* notreached */
-		}
-		execl("/bin/cp", "(afsd EXDEV helper)", "-PRp", "--", srcpath,
-		      dstpath, (char *) NULL);
-	    }
-	    if (child == (pid_t) -1) {
-		uspc->retval = -1;
-		continue;
-	    }
+	case AFS_USPC_SHUTDOWN:
+	    /* Client is shutting down */
+	    return;
 
-	    if (waitpid(child, &status, 0) == -1)
-		uspc->retval = EIO;
-	    else if (WIFEXITED(status) != 0 && WEXITSTATUS(status) == 0) {
-		if ((child = fork()) == 0) {
-		    switch (uspc->req.umv.idtype) {
-		    case IDTYPE_UID:
-			if (setuid(uspc->req.umv.id) != 0) {
-			    exit(-1);
-			}
-			break;
-		    default:
-			exit(-1);
-			break; /* notreached */
-		    }
-		    execl("/bin/rm", "(afsd EXDEV helper)", "-rf", "--",
-			  srcpath, (char *) NULL);
-		}
-		if (child == (pid_t) -1) {
-		    uspc->retval = -1;
-		    continue;
-		}
-		if (waitpid(child, &status, 0) == -1)
-		    uspc->retval = EIO;
-		else if (WIFEXITED(status) != 0) {
-		    /* rm exit status */
-		    uspc->retval = WEXITSTATUS(status);
-		} else {
-		    /* rm signal status */
-		    uspc->retval = -(WTERMSIG(status));
-		}
-	    } else {
-		/* error from cp: exit or signal status */
-		uspc->retval = (WIFEXITED(status) != 0) ?
-		    WEXITSTATUS(status) : -(WTERMSIG(status));
-	    }
+# ifdef AFS_DARWIN_ENV
+	case AFS_USPC_UMV:
+            {
+                pid_t child = 0;
+                int status;
+                char srcpath[BUFSIZ];
+                char dstpath[BUFSIZ];
+                snprintf(srcpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
+                         uspc->req.umv.sCell, uspc->req.umv.sVolume,
+                         uspc->req.umv.sVnode, uspc->req.umv.sUnique, srcName);
+                snprintf(dstpath, BUFSIZ, "/afs/.:mount/%d:%d:%d:%d/%s",
+                         uspc->req.umv.dCell, uspc->req.umv.dVolume,
+                         uspc->req.umv.dVnode, uspc->req.umv.dUnique, dstName);
+                if ((child = fork()) == 0) {
+                    /* first child does cp; second, rm. mv would re-enter. */
+
+                    switch (uspc->req.umv.idtype) {
+                    case IDTYPE_UID:
+                        if (setuid(uspc->req.umv.id) != 0) {
+                            exit(-1);
+                        }
+                        break;
+                    default:
+                        exit(-1);
+                        break; /* notreached */
+                    }
+                    execl("/bin/cp", "(afsd EXDEV helper)", "-PRp", "--", srcpath,
+                          dstpath, (char *) NULL);
+                }
+                if (child == (pid_t) -1) {
+                    uspc->retval = -1;
+                    continue;
+                }
+
+                if (waitpid(child, &status, 0) == -1)
+                    uspc->retval = EIO;
+                else if (WIFEXITED(status) != 0 && WEXITSTATUS(status) == 0) {
+                    if ((child = fork()) == 0) {
+                        switch (uspc->req.umv.idtype) {
+                        case IDTYPE_UID:
+                            if (setuid(uspc->req.umv.id) != 0) {
+                                exit(-1);
+                            }
+                            break;
+                        default:
+                            exit(-1);
+                            break; /* notreached */
+                        }
+                        execl("/bin/rm", "(afsd EXDEV helper)", "-rf", "--",
+                              srcpath, (char *) NULL);
+                    }
+                    if (child == (pid_t) -1) {
+                        uspc->retval = -1;
+                        continue;
+                    }
+                    if (waitpid(child, &status, 0) == -1)
+                        uspc->retval = EIO;
+                    else if (WIFEXITED(status) != 0) {
+                        /* rm exit status */
+                        uspc->retval = WEXITSTATUS(status);
+                    } else {
+                        /* rm signal status */
+                        uspc->retval = -(WTERMSIG(status));
+                    }
+                } else {
+                    /* error from cp: exit or signal status */
+                    uspc->retval = (WIFEXITED(status) != 0) ?
+                        WEXITSTATUS(status) : -(WTERMSIG(status));
+                }
+            }
 	    memset(srcName, 0, sizeof(srcName));
 	    memset(dstName, 0, sizeof(dstName));
 	    break;
+# endif /* AFS_DARWIN_ENV */
 
 	default:
 	    /* unknown req type */
@@ -2069,20 +2072,6 @@ afsd_run(void)
 	    if (afsd_verbose)
 		printf("%s: cacheFiles autotuned to %d\n", rn, cacheFiles);
 	}
-#if 0
-       /* This actually needs to
-          1) use powers of 2
-          2) not second-guess when a chunksize comes from the command line
-          3) be less, um, small. 2^2??
-       */
-	/* Sanity check chunkSize */
-	i = max(cacheBlocks / 1000, cacheBlocks / cacheFiles);
-	chunkSize = min(chunkSize, i);
-	chunkSize = max(chunkSize, 2);
-	if (afsd_verbose)
-	    printf("%s: chunkSize autotuned to %d\n", rn, chunkSize);
-#endif
-
 	if (!sawDCacheSize) {
 	    dCacheSize = cacheFiles / 2;
 	    if (dCacheSize > 10000) {
@@ -2250,7 +2239,11 @@ afsd_run(void)
     cparams.setTimeFlag = 0;
     cparams.memCacheFlag = cacheFlags;
     cparams.dynamic_vcaches = afsd_dynamic_vcaches;
-    afsd_syscall(AFSOP_CACHEINIT, &cparams);
+    code = afsd_syscall(AFSOP_CACHEINIT, &cparams);
+    if (code) {
+	printf("%s: Error %d during cache init.\n", rn, code);
+        exit(1);
+    }
 
     /* do it before we init the cache inodes */
     if (enable_splitcache) {
@@ -2433,8 +2426,20 @@ afsd_run(void)
 	if (afsd_verbose)
 	    printf("%s: Calling AFSOP_SET_VOLUME_TTL with '%d'\n", rn, volume_ttl);
 	code = afsd_syscall(AFSOP_SET_VOLUME_TTL, volume_ttl);
-	if (code != 0)
-	    printf("%s: Error setting volume ttl to %d seconds; code=%d.\n", rn, volume_ttl, code);
+	if (code == EFAULT) {
+	    if (volume_ttl < AFS_MIN_VOLUME_TTL)
+		printf("%s: Failed to set volume ttl to %d seconds; "
+		       "value is too low.\n", rn, volume_ttl);
+	    else if (volume_ttl > AFS_MAX_VOLUME_TTL)
+		printf("%s: Failed to set volume ttl to %d seconds; "
+		       "value is too high.\n", rn, volume_ttl);
+	    else
+		printf("%s: Failed to set volume ttl to %d seconds; "
+		       "value is out of range.\n", rn, volume_ttl);
+	} else if (code != 0) {
+	    printf("%s: Failed to set volume ttl to %d seconds; "
+		   "code=%d.\n", rn, volume_ttl, code);
+	}
     }
 
     /*
diff --git a/src/afsd/afsd_kernel.c b/src/afsd/afsd_kernel.c
index b15df7476..6f4442b3e 100644
--- a/src/afsd/afsd_kernel.c
+++ b/src/afsd/afsd_kernel.c
@@ -124,6 +124,72 @@ kern_return_t DiskArbDiskAppearedWithMountpointPing_auto(char *, unsigned int,
 # endif
 #endif
 
+static char *afsd_syscalls[AFSOP_MAX_OPCODE + 1]; /* For syscall tracing. */
+
+static void
+afsd_init_syscall_opcodes(void)
+{
+#define add_opcode(x) afsd_syscalls[x] = #x
+    add_opcode(AFSOP_START_RXCALLBACK);
+    add_opcode(AFSOP_START_AFS);
+    add_opcode(AFSOP_START_BKG);
+    add_opcode(AFSOP_START_TRUNCDAEMON);
+    add_opcode(AFSOP_START_CS);
+    add_opcode(AFSOP_ADDCELL);
+    add_opcode(AFSOP_CACHEINIT);
+    add_opcode(AFSOP_CACHEINFO);
+    add_opcode(AFSOP_VOLUMEINFO);
+    add_opcode(AFSOP_CACHEFILE);
+    add_opcode(AFSOP_CACHEINODE);
+    add_opcode(AFSOP_AFSLOG);
+    add_opcode(AFSOP_ROOTVOLUME);
+    add_opcode(AFSOP_STARTLOG);
+    add_opcode(AFSOP_ENDLOG);
+    add_opcode(AFSOP_AFS_VFSMOUNT);
+    add_opcode(AFSOP_ADVISEADDR);
+    add_opcode(AFSOP_CLOSEWAIT);
+    add_opcode(AFSOP_RXEVENT_DAEMON);
+    add_opcode(AFSOP_GETMTU);
+    add_opcode(AFSOP_GETIFADDRS);
+    add_opcode(AFSOP_ADDCELL2);
+    add_opcode(AFSOP_AFSDB_HANDLER);
+    add_opcode(AFSOP_SET_DYNROOT);
+    add_opcode(AFSOP_ADDCELLALIAS);
+    add_opcode(AFSOP_SET_FAKESTAT);
+    add_opcode(AFSOP_CELLINFO);
+    add_opcode(AFSOP_SET_THISCELL);
+    add_opcode(AFSOP_BASIC_INIT);
+    add_opcode(AFSOP_SET_BACKUPTREE);
+    add_opcode(AFSOP_SET_RXPCK);
+    add_opcode(AFSOP_BUCKETPCT);
+    add_opcode(AFSOP_SET_RXMAXMTU);
+    add_opcode(AFSOP_BKG_HANDLER);
+    add_opcode(AFSOP_GETMASK);
+    add_opcode(AFSOP_SET_RXMAXFRAGS);
+    add_opcode(AFSOP_SET_RMTSYS_FLAG);
+    add_opcode(AFSOP_SEED_ENTROPY);
+    add_opcode(AFSOP_SET_INUMCALC);
+    add_opcode(AFSOP_RXLISTENER_DAEMON);
+    add_opcode(AFSOP_CACHEBASEDIR);
+    add_opcode(AFSOP_CACHEDIRS);
+    add_opcode(AFSOP_CACHEFILES);
+    add_opcode(AFSOP_SETINT);
+    add_opcode(AFSOP_GO);
+    add_opcode(AFSOP_CHECKLOCKS);
+    add_opcode(AFSOP_SHUTDOWN);
+    add_opcode(AFSOP_STOP_RXCALLBACK);
+    add_opcode(AFSOP_STOP_AFS);
+    add_opcode(AFSOP_STOP_BKG);
+    add_opcode(AFSOP_STOP_TRUNCDAEMON);
+    /* AFSOP_STOP_RXEVENT -- not a syscall opcode */
+    /* AFSOP_STOP_COMPLETE -- not a syscall opcode */
+    add_opcode(AFSOP_STOP_CS);
+    /* AFSOP_STOP_RXK_LISTENER -- not a syscall opcode */
+    add_opcode(AFSOP_STOP_AFSDB);
+    add_opcode(AFSOP_STOP_NETIF);
+#undef add_opcode
+}
+
 void
 afsd_set_rx_rtpri(void)
 {
@@ -274,13 +340,36 @@ afsd_call_syscall(struct afsd_syscall_args *args)
     error = os_syscall(args);
 
     if (afsd_debug) {
+	char *opcode;
+	char buffer[32];
+        const char *syscall_str;
+
+#if defined(AFS_SYSCALL)
+        syscall_str = AFS_STRINGIZE(AFS_SYSCALL);
+#else
+        syscall_str = "[AFS_SYSCALL]";
+#endif
+
+	if ((args->syscall < 0) ||
+	    (args->syscall >= (sizeof(afsd_syscalls) / sizeof(*afsd_syscalls))))
+	    opcode = NULL;
+	else
+	    opcode = afsd_syscalls[args->syscall];
+
+	if (opcode == NULL) {
+	    snprintf(buffer, sizeof(buffer), "unknown (%d)", args->syscall);
+	    opcode = buffer;
+	}
+
 	if (error == -1) {
 	    char *s = strerror(errno);
-	    printf("SScall(%d, %d, %d)=%d (%d, %s)\n", AFS_SYSCALL, AFSCALL_CALL,
-		   (int)args->params[0], error, errno, s);
+	    printf("os_syscall(%s, %d, %s, 0x%lx)=%d (%d, %s)\n",
+		    syscall_str, AFSCALL_CALL, opcode,
+		   (long)args->params[0], error, errno, s);
 	} else {
-	    printf("SScall(%d, %d, %d)=%d\n", AFS_SYSCALL, AFSCALL_CALL,
-		   (int)args->params[0], error);
+	    printf("os_syscall(%s %d %s, 0x%lx)=%d\n",
+		    syscall_str, AFSCALL_CALL, opcode,
+		   (long)args->params[0], error);
 	}
     }
 
@@ -488,11 +577,9 @@ afsd_mount_afs(const char *rn, const char *cacheMountDir)
     if (afsd_verbose)
 	printf("%s: Mounting the AFS root on '%s', flags: %d.\n", rn,
 	    cacheMountDir, mountFlags);
-#if defined(AFS_FBSD60_ENV)
+#if defined(AFS_FBSD_ENV)
     /* data must be non-const non-NULL but is otherwise ignored */
     if ((mount(MOUNT_AFS, cacheMountDir, mountFlags, &mountFlags)) < 0) {
-#elif defined(AFS_FBSD_ENV)
-    if ((mount("AFS", cacheMountDir, mountFlags, (caddr_t) 0)) < 0) {
 #elif defined(AFS_AIX_ENV)
     if (aix_vmount(cacheMountDir)) {
 #elif defined(AFS_HPUX100_ENV)
@@ -567,6 +654,7 @@ main(int argc, char **argv)
 {
     int code;
 
+    afsd_init_syscall_opcodes();
     afsd_init();
 
     code = afsd_parse(argc, argv);
diff --git a/src/afsd/vsys.c b/src/afsd/vsys.c
index 44f428162..6b5d3b9bc 100644
--- a/src/afsd/vsys.c
+++ b/src/afsd/vsys.c
@@ -57,9 +57,13 @@ main(int argc, char **argv)
 	    numberFlag = 1;
 	}
     }
+#ifdef AFS_SYSCALL
     code =
 	syscall(AFS_SYSCALL, parms[0], parms[1], parms[2], parms[3], parms[4],
 		parms[5]);
+#else
+    code = -1;
+#endif
     printf("code %d\n", code);
     return 0;
 }
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/bldkernel b/src/afsinstall/lib/InstallGuides/SUN4x_4x/bldkernel
deleted file mode 100644
index f43826e05..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/bldkernel
+++ /dev/null
@@ -1,31 +0,0 @@
-# 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
-
-# An InstallGuide for installing static AFS kernel libraries
-# For SUN systems running SunOS 4.x
-#
-
-sub bldkernel {
-my($arch);
-&ErrorsAreFatal(1);
-$arch = `/bin/uname -m`;
-chop $arch;
-&ErrorMsg("Couldn't get sun kernel architecture type with","/bin/uname -m") 
- unless ($arch =~ /sun/);
-&ErrorsAreFatal(0);
-
-if ($Configuration{"NFSEXTENSIONS"}) {
-  &Copy("root.client/bin/libafs.a",  "/usr/sys/$arch/OBJ/libafs.o");  }
-else {
-  &Copy("root.client/bin/libafs.nonfs.a",  "/usr/sys/$arch/OBJ/libafs.o");  }
-&VPrint("Running ranlib on library");
-system("ranlib /usr/sys/$arch/OBJ/libafs.o");
-
-&Copy("root.client/usr/vice/etc/afsd", "/usr/vice/etc");
-&Chmod(0744, "/usr/vice/etc/afsd");
-&Copy("bin/fs", "/usr/vice/etc/fs");
-}
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/build b/src/afsinstall/lib/InstallGuides/SUN4x_4x/build
deleted file mode 100644
index 70353cd5c..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/build
+++ /dev/null
@@ -1,44 +0,0 @@
-# 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
-
-# An InstallGuide for compiling a new kernel
-# For SUN systems running SunOS 4.x
-#
-
-sub build {
-my ($arch, $hostname);
-$arch = `/bin/uname -m`;
-chop $arch;
-$hostname = `/bin/uname -n`;
-chop $hostname;
-$hostname =~ tr/a-z/A-Z/;
-
-&Print("Starting compile with command \"/etc/config $hostname\"");
-&Print("in directory /usr/sys/$arch/conf");
-
-&ErrorsAreFatal(1);
-$rc = chdir("/usr/sys/$arch/conf");
-&ErrorMsg("Could not change to dir", "/usr/sys/$arch/conf") if (!$rc);
-
-$rc = system("/etc/config $hostname");
-$rc = $rc >> 8;
-&Print("Returned code $rc");
-&ErrorMsg("Stopping compile") if ($rc);
-
-
-&Print("Finishing compile with command \"make vmunix\"");
-&Print("in directory /usr/sys/$arch/$hostname");
-&Print("New kernel will be /usr/sys/$arch/$hostname/vmunix");
-&Print("and should be installed as /vmunix");
-
-$rc = chdir("/usr/sys/$arch/$hostname");
-&ErrorMsg("Could not change to dir", "/usr/sys/$arch/$hostname") if (!$rc);
-
-$rc = system("make vmunix");
-$rc = $rc >> 8;
-&Print("Returned code $rc");
-}
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/installkernel b/src/afsinstall/lib/InstallGuides/SUN4x_4x/installkernel
deleted file mode 100644
index 058f7eba9..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/installkernel
+++ /dev/null
@@ -1,23 +0,0 @@
-# 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
-
-# build
-#
-# An InstallGuide for installing a new kernel
-# For SUN systems running SunOS 4.x
-#
-
-sub installkernel {
-my ($arch, $hostname);
-$arch = `/bin/uname -m`;
-chop $arch;
-$hostname = `/bin/uname -n`;
-chop $hostname;
-$hostname =~ tr/a-z/A-Z/;
-
-&VersionCopyFile("/usr/sys/$arch/$hostname/vmunix", "/vmunix");
-}
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/modkernel b/src/afsinstall/lib/InstallGuides/SUN4x_4x/modkernel
deleted file mode 100644
index be03b5b96..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/modkernel
+++ /dev/null
@@ -1,35 +0,0 @@
-# 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
-
-# An InstallGuide for dynamic kernel loaded libraries
-# For SUN systems running SunOS 4.x
-#
-
-sub modkernel {
-&ErrorsAreFatal(1);
-&CreateDir("/usr/vice/etc/modload");
-&CreateDir("/usr/vice/etc/dkload");
-&ErrorsAreFatal(0);
-
-
-&Copy("root.client/usr/vice/etc/dkload/dkload",      "/usr/vice/etc/dkload");
-&Copy("root.client/usr/vice/etc/dkload/kalloc.o",    "/usr/vice/etc/dkload");
-&Copy("root.client/usr/vice/etc/dkload/libcommon.a", "/usr/vice/etc/dkload");
-
-if ($Configuration{"NFSEXTENSIONS"}) {
-  &Copy("root.client/usr/vice/etc/modload/libafs.o","/usr/vice/etc/modload");
-  &Copy("root.client/usr/vice/etc/dkload/libafs.a", "/usr/vice/etc/dkload");  }
-else {
-  &Copy("root.client/usr/vice/etc/modload/libafs.nonfs.o",
-                                                    "/usr/vice/etc/modload");
-  &Copy("root.client/usr/vice/etc/dkload/libafs.nonfs.a", 
-                                                     "/usr/vice/etc/dkload"); }
-
-&Copy("root.client/usr/vice/etc/afsd", "/usr/vice/etc");
-&Chmod(0744, "/usr/vice/etc/afsd");
-&Copy("bin/fs", "/usr/vice/etc/fs");
-}
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/rc b/src/afsinstall/lib/InstallGuides/SUN4x_4x/rc
deleted file mode 100644
index 607b5c365..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/rc
+++ /dev/null
@@ -1,84 +0,0 @@
-# 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
-
-# afs.rc
-#
-# An InstallGuide for AFS startup scripts
-# For Sun systems running SunOS 4.x
-#
-
-sub SUNrc {
-my($nfsext, $othernfsext, $rcfile);
-$rcfile = "/etc/rc.afs";
-&ErrorsAreFatal(1);
-
-# Start an AFS RC file
-if ($Configuration{"NFSEXTENSIONS"}) {
-  $nfsext="";
-  $othernfsext=".nonfs"; }
-else {
-  $nfsext=".nonfs";
-  $othernfsext="";
-};
-
-&VPrint("Creating AFS startup script");
-&DisplaceFile($rcfile);
-$rc = open(RC, "> $rcfile");
-&ErrorMsg("Could not write to file", $rcfile) if (!$rc);
-print RC <<"EORC";
-#!/bin/sh
-#
-
-# Choose one of the following depending on how to load AFS into the kernel
-loader="modload"
-#loader="dkload"
-
-# Choose one of the following depending on whether or not system uses NFS
-NFS="$nfsext"
-#NFS="$othernfsext"
-
-if [ "\$loader" -eq "modload" ]; then
-  library="libafs${NFS}.o"
-  program="/usr/etc/modload"
-  options=""
-else
-  library="libafs${NFS}.a"
-  program="./dkload"
-  options="-quiet"
-fi
-
-if [ -d /usr/vice/etc/\$loader ]; then
-  echo 'Invoking \$loader kernel loader...'>/dev/console
-  cd /usr/vice/etc/\$loader
-  if [ -f "\$library" ]; then
-    echo "Loading AFS" > /dev/console
-    \$program \$options \$library 1> /dev/console 2>&1
-    if [ $? != 0 ]; then
-      echo "Error loading AFS" > /dev/console
-    fi
-  else
-    echo "Cannot load AFS - no kernel library object" > /dev/console
-  fi
-  cd /
-fi
-
-EORC
-close(RC);
-&Chmod(0744, $rcfile);
-
-# Append the generic RC file
-&ReadInstallGuide("$InstallGuideDir/GENERIC/rc");
-&Appendrc;
-
-&Print("AFS startup script created as $rcfile");
-}
-
-
-
-sub rc {
-goto &SUNrc;
-}
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/unix b/src/afsinstall/lib/InstallGuides/SUN4x_4x/unix
deleted file mode 100644
index bc024c658..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/unix
+++ /dev/null
@@ -1,66 +0,0 @@
-# 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
-
-# An InstallGuide for the AFS modified Unix commands
-# For SUN systems running SunOS 4.x
-#
-
-sub SUNunix {
-  &Copy("etc/inetd", "/usr/etc/inetd.afs");
-  &Copy("etc/ftpd",  "/usr/etc/in.ftpd.afs");
-  &Copy("etc/rlogind",  "/usr/etc/in.rlogind.afs");
-
-  &ErrorsAreFatal(1);
-  &Patch::Verbose if ($InstallVerbose);
-  &CreateDir("/usr/vice/bin");
-
-  &Copy("bin/rcp", "/usr/vice/bin");
-  &Chown (0,2,   "/usr/vice/bin/rcp");
-  &Chmod (04755, "/usr/vice/bin/rcp");
-
-  &Copy("bin/rsh", "/usr/vice/bin");
-  &Chown (0,2,   "/usr/vice/bin/rsh");
-  &Chmod (04755, "/usr/vice/bin/rsh");
-
-  # Create the inetd.conf.afs file
-  $InetdConfAfs = "/etc/inetd.conf.afs";
-  open(INETD, ">$InetdConfAfs") || &ErrorMsg("Can't open file", $InetdConfAfs);
-  print INETD <<"EOINETD";
-ftp		stream tcp nowait root /usr/etc/in.ftpd.afs	in.ftpd.afs
-shell		stream tcp nowait root /usr/etc/in.rshd	in.rshd
-login		stream tcp nowait root /usr/etc/in.rlogind.afs in.rlogind.afs
-ta-rauth	stream tcp nowait root internal			ta-rauth
-EOINETD
-
-  # comment out the lines in inetd.conf
-  $InetdConf = "/etc/inetd.conf";
-  &CopyStat($InetdConf, $InetdConfAfs);
-  &Patch::FileOpen($InetdConf);
-
-  $Search1 = "^(ftp\\s+.+)";
-  $Replace1 = '"#".$1';
-
-  $Search2 = "^(shell\\s+.+)";
-  $Replace2 = '"#".$1';
-
-  $Search3 = "^(login\\s+.+)";
-  $Replace3 = '"#".$1';
-
-  if (!&Patch::Patch($InetdConf, [[1, "Substitution", $Search1, $Replace1],
-				  [1, "Substitution", $Search2, $Replace2],
-				  [1, "Substitution", $Search3, $Replace3]])) {
-    &ErrorMsg("Did not succeed with patch", $InetdConf);
-  }
-
-  # Modify the /etc/services file
-  &ReadInstallGuide("$InstallGuideDir/GENERIC/unix");
-  &unix;
-}
-
-sub unix {
-  goto &SUNunix;
-}
diff --git a/src/afsinstall/lib/InstallGuides/SUN4x_4x/vfsck b/src/afsinstall/lib/InstallGuides/SUN4x_4x/vfsck
deleted file mode 100644
index 61605f321..000000000
--- a/src/afsinstall/lib/InstallGuides/SUN4x_4x/vfsck
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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
-
-# An InstallGuide for installing the AFS aware file system checker
-# For SUN systems running SunOS 4.x
-#
-
-sub vfsck {
-&ErrorsAreFatal(1);
-&Copy ("root.server/etc/vfsck", "/usr/etc");
-&Symlink ("../usr/etc/fsck", "/etc/fsck");
-&Symlink ("vfsck", "/usr/etc/fsck");
-}
diff --git a/src/afsmonitor/Makefile.in b/src/afsmonitor/Makefile.in
index 73ef4d226..ea9ab15e0 100644
--- a/src/afsmonitor/Makefile.in
+++ b/src/afsmonitor/Makefile.in
@@ -7,7 +7,7 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
 
 
 INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
@@ -26,17 +26,19 @@ INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
 	${TOP_INCDIR}/afs/xstat_cm.h \
 	afsmonitor.h \
 	afsmon-labels.h
-LIBS=${TOP_LIBDIR}/libxstat_fs.a \
-	${TOP_LIBDIR}/libxstat_cm.a \
-	${TOP_LIBDIR}/libgtx.a \
-	${TOP_LIBDIR}/libafsint.a \
-	${TOP_LIBDIR}/libcmd.a \
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/libafshcrypto_lwp.a \
-	${TOP_LIBDIR}/liblwp.a \
-	${TOP_LIBDIR}/libsys.a \
-	$(TOP_LIBDIR)/libopr.a \
-	${TOP_LIBDIR}/util.a
+
+LT_deps=\
+	$(top_builddir)/src/xstat/liboafs_xstat_fs.la \
+	$(top_builddir)/src/xstat/liboafs_xstat_cm.la \
+	$(top_builddir)/src/gtx/liboafs_gtx.la \
+	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
+	$(top_builddir)/src/fsint/liboafs_fsint.la \
+	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/opr/liboafs_opr.la \
+	$(top_builddir)/src/lwp/liboafs_lwpcompat.la \
+	$(top_builddir)/src/volser/liboafs_volser.la \
+
 
 EXTRA_LIBS=${LIB_curses} ${XLIBS}
 
@@ -46,13 +48,13 @@ afsmon-output.o: afsmon-output.c ${INCLS}
 afsmon-win.o: afsmon-win.c ${INCLS}
 afsmonitor.o: afsmonitor.c ${INCLS} AFS_component_version_number.c
 
-afsmonitor: afsmonitor.o afsmon-win.o afsmon-output.o ${LIBS}
-	$(AFS_LDRULE) afsmonitor.o afsmon-win.o afsmon-output.o \
-		${LIBS} $(LIB_roken) ${EXTRA_LIBS}
+afsmonitor: afsmonitor.o afsmon-win.o afsmon-output.o ${LT_deps}
+	$(LT_LDRULE_static) afsmonitor.o afsmon-win.o afsmon-output.o \
+		${LT_deps} $(LIB_roken) ${EXTRA_LIBS}
 
-afsmon-parselog:  afsmon-parselog.o ${LIBS}
-	$(AFS_LDRULE) afsmon-parselog.c \
-		${LIBS} $(LIB_roken) ${EXTRA_LIBS}
+afsmon-parselog:  afsmon-parselog.o ${LT_deps}
+	$(LT_LDRULE_static) afsmon-parselog.c \
+		${LT_deps} $(LIB_roken) ${EXTRA_LIBS}
 
 install: afsmonitor
 	${INSTALL} -d ${DESTDIR}${bindir}
@@ -63,6 +65,7 @@ dest: afsmonitor
 	${INSTALL_PROGRAM} afsmonitor ${DEST}/bin/afsmonitor
 
 clean:
+	$(LT_CLEAN)
 	$(RM) -f *.o afsmonitor AFS_component_version_number.c
 
 include ../config/Makefile.version
diff --git a/src/afsmonitor/afsmon-win.c b/src/afsmonitor/afsmon-win.c
index 4209fd5c2..c5417ff22 100644
--- a/src/afsmonitor/afsmon-win.c
+++ b/src/afsmonitor/afsmon-win.c
@@ -27,10 +27,6 @@
 #include <afs/gtxwindows.h>		/*Generic window package */
 #include <afs/gtxobjects.h>		/*Object definitions */
 #include <afs/gtxkeymap.h>
-#if 0
-#include <afs/gtxtextcb.h>		/*Text object circular buffer interface */
-#include <afs/gtxtextobj.h>		/*Text object interface */
-#endif
 #include <afs/gtxlightobj.h>	/*Light object interface */
 #include <afs/gtxcurseswin.h>	/*Curses window package */
 #include <afs/gtxdumbwin.h>		/*Dumb terminal window package */
diff --git a/src/afsmonitor/afsmonitor.c b/src/afsmonitor/afsmonitor.c
index e7b303071..2dc9ec6a0 100644
--- a/src/afsmonitor/afsmonitor.c
+++ b/src/afsmonitor/afsmonitor.c
@@ -56,7 +56,6 @@ int afsmon_debug = 0;		/* debug info to file ? */
 FILE *debugFD;			/* debugging file descriptor */
 static int afsmon_output = 0;	/* output to file ? */
 static int afsmon_detOutput = 0;	/* detailed output ? */
-static int afsmon_onceOnly = 0;	/* probe once only ? (not implemented) */
 int afsmon_probefreq;		/* probe frequency */
 static int wpkg_to_use;		/* graphics package to use */
 static char output_filename[80];	/* output filename */
@@ -455,8 +454,8 @@ afsmon_Exit(int a_exitVal)	/* exit code */
 		        /* free xstat_cm_Results data */
 		        free(tmp_xstat_cmPR->data.AFSCB_CollData_val);
 		        free(tmp_xstat_cmPR->connP);
+		        free(tmp_xstat_cmPR);
 		    }
-		    free(tmp_cmlist->cmResults);
 
 		    /* free the cm list item */
 		    free(tmp_cmlist);
@@ -3724,7 +3723,6 @@ afsmon_execute(void)
     int FSinitFlags = 0;	/* flags for xstat_fs_Init */
     int CMinitFlags = 0;	/* flags for xstat_cm_Init */
     int code;			/* function return code */
-    struct timeval tv;		/* time structure */
     int i;
     short index;
 
@@ -3794,8 +3792,6 @@ afsmon_execute(void)
 	}
 
 	FSinitFlags = 0;
-	if (afsmon_onceOnly)	/* option not provided at this time */
-	    FSinitFlags |= XSTAT_FS_INITFLAG_ONE_SHOT;
 
 	if (afsmon_debug) {
 	    fprintf(debugFD, "[ %s ] Calling xstat_fs_Init \n", rn);
@@ -3867,8 +3863,6 @@ afsmon_execute(void)
 	collIDs[num_cm_collections++] = AFSCB_XSTATSCOLL_FULL_PERF_INFO;
 
 	CMinitFlags = 0;
-	if (afsmon_onceOnly)	/* once only ? */
-	    CMinitFlags |= XSTAT_CM_INITFLAG_ONE_SHOT;
 
 	if (afsmon_debug) {
 	    fprintf(debugFD, "[ %s ] Calling xstat_cm_Init \n", rn);
@@ -3892,19 +3886,6 @@ afsmon_execute(void)
 
 
     /* end of process cache manager entries */
-    /* if only one probe was required setup a waiting process for the
-     * termination signal */
-    if (afsmon_onceOnly) {
-	code = LWP_WaitProcess(&terminationEvent);
-	if (code) {
-	    if (afsmon_debug) {
-		fprintf(debugFD, "LWP_WaitProcess() returned error %d\n",
-			code);
-		fflush(debugFD);
-	    }
-	    afsmon_Exit(135);
-	}
-    }
 
     /* start the gtx input server */
     code = (intptr_t)gtx_InputServer(afsmon_win);
@@ -3915,24 +3896,8 @@ afsmon_execute(void)
 
     /* This part of the code is reached only if the input server is not started
      * for debugging purposes */
-
-    /* sleep forever */
-    tv.tv_sec = 24 * 60;
-    tv.tv_usec = 0;
-    fprintf(stderr, "[ %s ] going to sleep ...\n", rn);
-    while (1) {
-	code = IOMGR_Select(0,	/*Num fds */
-			    0,	/*Descriptors ready for reading */
-			    0,	/*Descriptors ready for writing */
-			    0,	/*Descriptors with exceptional conditions */
-			    &tv);	/*Timeout structure */
-	if (code) {
-	    fprintf(stderr,
-		    "[ %s ] IOMGR_Select() returned non-zero value %d\n", rn,
-		    code);
-	    afsmon_Exit(145);
-	}
-    }				/* while sleep */
+    xstat_cm_Wait(0); /* sleep forever */
+    return 0;
 }
 
 
@@ -3990,25 +3955,6 @@ afsmonInit(struct cmd_syndesc *as, void *arock)
 
 
     /* use curses always until we support other packages */
-#ifdef notdef
-    wpkg_to_use = atoi(as->parms[P_PACKAGE].items->data);
-
-    switch (wpkg_to_use) {
-    case GATOR_WIN_CURSES:
-	fprintf(stderr, "curses\n");
-	break;
-    case GATOR_WIN_DUMB:
-	fprintf(stderr, "dumb terminal\n");
-	break;
-    case GATOR_WIN_X11:
-	fprintf(stderr, "X11\n");
-	break;
-    default:
-	fprintf(stderr, "Illegal graphics package: %d\n", wpkg_to_use);
-	afsmon_Exit(155);
-    }				/*end switch (wpkg_to_use) */
-#endif
-
     wpkg_to_use = GATOR_WIN_CURSES;
 
     /* get probe frequency . We check for meaningful bounds on the frequency
@@ -4263,11 +4209,6 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-output", CMD_SINGLE, CMD_OPTIONAL, "storage file name");
     cmd_AddParm(ts, "-detailed", CMD_FLAG, CMD_OPTIONAL,
 		"output detailed statistics to storage file");
-#ifdef notdef
-    /* we hope to use this .... eventually! */
-    cmd_AddParm(ts, "-package", CMD_SINGLE, CMD_REQUIRED,
-		"Graphics Package to use");
-#endif
     cmd_AddParm(ts, "-debug", CMD_SINGLE, CMD_OPTIONAL,
 		"turn debugging output on to the named file");
     cmd_AddParm(ts, "-fshosts", CMD_LIST, CMD_OPTIONAL,
diff --git a/src/afsweb/apache_afs_utils.c b/src/afsweb/apache_afs_utils.c
index ba0d919fa..c185c54dd 100644
--- a/src/afsweb/apache_afs_utils.c
+++ b/src/afsweb/apache_afs_utils.c
@@ -44,7 +44,13 @@ do_pioctl(char *in_buffer, int in_size, char *out_buffer, int out_size,
 int
 do_setpag()
 {
-    return lsetpag();
+    int code;
+
+    do {
+	code = lsetpag();
+    } while (code && errno == EINTR);
+
+    return code;
 }
 
 /*
diff --git a/src/afsweb/apache_includes/1.2/conf.h b/src/afsweb/apache_includes/1.2/conf.h
index 771988fd7..d1fd419f7 100644
--- a/src/afsweb/apache_includes/1.2/conf.h
+++ b/src/afsweb/apache_includes/1.2/conf.h
@@ -404,8 +404,7 @@ extern char *crypt();
 #define HAVE_MMAP
 #define DEFAULT_USER "nobody"
 #define DEFAULT_GROUP "nogroup"
-#if defined(__bsdi__) || \
-(defined(__FreeBSD_version) && (__FreeBSD_version < 220000))
+#if defined(__bsdi__)
 typedef quad_t rlim_t;
 #endif
 #define USE_FLOCK_SERIALIZED_ACCEPT
diff --git a/src/afsweb/apache_includes/1.3.1/ap_config.h b/src/afsweb/apache_includes/1.3.1/ap_config.h
index 7bcad2ce4..47a6c2526 100644
--- a/src/afsweb/apache_includes/1.3.1/ap_config.h
+++ b/src/afsweb/apache_includes/1.3.1/ap_config.h
@@ -599,8 +599,7 @@ stat() properly */
 #ifndef DEFAULT_GROUP
 #define DEFAULT_GROUP "nogroup"
 #endif
-#if defined(__bsdi__) || \
-(defined(__FreeBSD_version) && (__FreeBSD_version < 220000))
+#if defined(__bsdi__)
     typedef quad_t rlim_t;
 #endif
 #define USE_FLOCK_SERIALIZED_ACCEPT
diff --git a/src/afsweb/apache_includes/1.3.6/ap_config.h b/src/afsweb/apache_includes/1.3.6/ap_config.h
index e921d448c..9bc41315b 100644
--- a/src/afsweb/apache_includes/1.3.6/ap_config.h
+++ b/src/afsweb/apache_includes/1.3.6/ap_config.h
@@ -682,8 +682,7 @@ stat() properly */
 #ifndef DEFAULT_GROUP
 #define DEFAULT_GROUP "nogroup"
 #endif
-#if defined(__bsdi__) || \
-(defined(__FreeBSD_version) && (__FreeBSD_version < 220000))
+#if defined(__bsdi__)
     typedef quad_t rlim_t;
 #endif
 #define USE_FLOCK_SERIALIZED_ACCEPT
diff --git a/src/afsweb/apache_includes/conf.h b/src/afsweb/apache_includes/conf.h
index 1310d679e..58ec27b20 100644
--- a/src/afsweb/apache_includes/conf.h
+++ b/src/afsweb/apache_includes/conf.h
@@ -404,8 +404,7 @@ extern char *crypt();
 #define HAVE_MMAP
 #define DEFAULT_USER "nobody"
 #define DEFAULT_GROUP "nogroup"
-#if defined(__bsdi__) || \
-(defined(__FreeBSD_version) && (__FreeBSD_version < 220000))
+#if defined(__bsdi__)
 typedef quad_t rlim_t;
 #endif
 #define USE_FLOCK_SERIALIZED_ACCEPT
diff --git a/src/afsweb/nsafs.c b/src/afsweb/nsafs.c
index 10dc19503..bcb2b7241 100644
--- a/src/afsweb/nsafs.c
+++ b/src/afsweb/nsafs.c
@@ -916,13 +916,7 @@ nsafs_basic(pblock * pb, Session * sn, Request * rq)
     code = uafs_klog(user, cell, passwd, &reason);
     memset((void *)&passwd[0], 0, NSAFS_PASSWORD_MAX);
     if (code != 0) {
-#if 0
-	sprintf(txtbuf, "%s@%s: %s\n", user, cell, reason);
-	pblock_nvinsert("status", "Login Failed", rq->vars);
-	return nsafs_error_check(EPERM, txtbuf, pb, sn, rq);
-#else /* 0 */
 	return REQ_PROCEED;
-#endif /* 0 */
     }
     expiration = u.u_expiration;
     usr_assert(expiration != 0);
diff --git a/src/aklog/aklog.c b/src/aklog/aklog.c
index 1eaa95e89..3dba5f456 100644
--- a/src/aklog/aklog.c
+++ b/src/aklog/aklog.c
@@ -119,6 +119,7 @@
 #define DIRSTRING "/"		/* String form of above */
 #define VOLMARKER ':'		/* Character separating cellname from mntpt */
 #define VOLMARKERSTRING ":"	/* String form of above */
+#define AKIMP_LIFETIME_MAX 720  /* Max token lifetime for akimpersonate in hours (30 days) */
 
 typedef struct {
     char cell[BUFSIZ];
@@ -145,6 +146,7 @@ static int get_user_realm(krb5_context, char **);
 
 #define TRYAGAIN(x) (x == AKLOG_TRYAGAIN || \
 		     x == KRB5KDC_ERR_S_PRINCIPAL_UNKNOWN || \
+		     x == KRB5_KT_NOTFOUND || \
 		     x == KRB5KRB_ERR_GENERIC)
 
 #if defined(HAVE_KRB5_PRINC_SIZE) || defined(krb5_princ_size)
@@ -167,6 +169,11 @@ static int get_user_realm(krb5_context, char **);
 #error "Must have either krb5_princ_size or krb5_principal_get_comp_string"
 #endif
 
+#if defined(HAVE_ENCODE_KRB5_TICKET)
+extern krb5_error_code encode_krb5_ticket (const krb5_ticket *rep,
+					   krb5_data **code);
+#endif
+
 #if !defined(HAVE_KRB5_ENCRYPT_TKT_PART) && defined(HAVE_ENCODE_KRB5_ENC_TKT_PART) && defined(HAVE_KRB5_C_ENCRYPT)
 extern krb5_error_code encode_krb5_enc_tkt_part (const krb5_enc_tkt_part *rep,
 						 krb5_data **code);
@@ -297,6 +304,8 @@ static char *client = NULL;     /* client principal for akimpersonate */
 static linked_list zsublist;	/* List of zephyr subscriptions */
 static linked_list hostlist;	/* List of host addresses */
 static linked_list authedcells;	/* List of cells already logged to */
+static int akimp_lifetime = 36000;  /* Lifetime for akimpersonate tokens. Default 10 hrs */ 
+static int akimplifetime_present = 0; /* Whether a lifetime was specified for akimpersonate */
 
 /* A com_error bodge. The idea here is that this routine lets us lookup
  * things in the system com_err, if the AFS one just tells us the error
@@ -317,9 +326,10 @@ redirect_errors(const char *who, afs_int32 code, const char *fmt, va_list ap)
 	    krb5_svc_get_msg(code,&str);
 #elif defined(HAVE_KRB5_GET_ERROR_MESSAGE)
 	    krb5_context context;
-	    krb5_init_context(&context);
-	    str = krb5_get_error_message(context, code);
-	    krb5_free_context(context);
+	    if (krb5_init_context(&context) == 0) {
+                str = krb5_get_error_message(context, code);
+                krb5_free_context(context);
+            }
 #else
 	    ; /* IRIX apparently has neither: use the string we have */
 #endif
@@ -382,19 +392,24 @@ get_cellconfig(const char *config, char *cell,
 	exit(AKLOG_AFS);
     }
 
-    if (afsconf_GetLocalCell(configdir, *local_cell, MAXCELLCHARS)) {
-	fprintf(stderr, "%s: can't determine local cell.\n", progname);
-	exit(AKLOG_AFS);
+    if (cell != NULL && cell[0] == '\0') {
+	/* Use the local cell */
+	cell = NULL;
     }
 
-    if ((cell == NULL) || (cell[0] == 0))
-	cell = *local_cell;
-
     /* XXX - This function modifies 'cell' by passing it through lcstring */
     if (afsconf_GetCellInfo(configdir, cell, NULL, cellconfig)) {
-	fprintf(stderr, "%s: Can't get information about cell %s.\n",
-		progname, cell);
+	if (cell != NULL) {
+	    fprintf(stderr, "%s: Can't get information about cell %s.\n",
+		    progname, cell);
+	} else {
+	    fprintf(stderr, "%s: Can't get information about the local cell.\n",
+		    progname);
+	}
 	status = AKLOG_AFS;
+    } else if (afsconf_GetLocalCell(configdir, *local_cell, MAXCELLCHARS)) {
+	fprintf(stderr, "%s: can't determine local cell.\n", progname);
+	exit(AKLOG_AFS);
     }
 
     afsconf_Close(configdir);
@@ -853,7 +868,7 @@ rxkad_get_converted_token(krb5_context context, krb5_creds *v5cred,
 static int
 rxkad_get_token(krb5_context context, struct afsconf_cell *cell, char *realm,
 		struct ktc_tokenUnion **token, char **authuser, int *foreign) {
-    krb5_creds *v5cred;
+    krb5_creds *v5cred = NULL;
     char *realmUsed = NULL;
     char *username = NULL;
     int status;
@@ -864,7 +879,7 @@ rxkad_get_token(krb5_context context, struct afsconf_cell *cell, char *realm,
 
     status = rxkad_get_ticket(context, realm, cell, &v5cred, &realmUsed);
     if (status)
-	return status;
+	goto out;
 
     if (do524)
 	status = rxkad_get_converted_token(context, v5cred, token, &username);
@@ -895,6 +910,8 @@ out:
 	free(realmUsed);
     if (username)
 	free(username);
+    if (v5cred)
+        krb5_free_creds(context, v5cred);
 
     return status;
 }
@@ -1089,7 +1106,7 @@ auth_to_cell(krb5_context context, const char *config,
 	    afs_dprintf("Setting tokens for cell %s\n", cellconf.name);
 	}
 
-#ifndef AFS_AIX51_ENV
+#if defined(AFS_AIX_ENV) && !defined(AFS_AIX51_ENV)
 	/* on AIX 4.1.4 with AFS 3.4a+ if a write is not done before
 	 * this routine, it will not add the token. It is not clear what
 	 * is going on here! So we will do the following operation.
@@ -1097,8 +1114,9 @@ auth_to_cell(krb5_context context, const char *config,
 	 * We don't care about the return value, but need to collect it
 	 * to avoid compiler warnings.
 	 */
-	if (write(2,"",0) < 0) /* dummy write */
-	    ; /* don't care */
+	if (write(2,"",0) < 0) {
+	    /* dummy write, don't care */
+	}
 #endif
 	token_setPag(token, afssetpag);
 	status = ktc_SetTokenEx(token);
@@ -1421,7 +1439,7 @@ usage(void)
 	    "[-d] [[-cell | -c] cell [-k krb_realm]] ",
 	    "[[-p | -path] pathname]\n",
 	    "    [-zsubs] [-hosts] [-noauth] [-noprdb] [-force] [-setpag] \n"
-		"    [-linked]"
+		"    [-linked] [-insecure_des]"
 #ifndef HAVE_NO_KRB5_524
 		" [-524]"
 #endif
@@ -1440,6 +1458,7 @@ usage(void)
 #ifndef HAVE_NO_KRB5_524
     fprintf(stderr, "    -524 means use the 524 converter instead of V5 directly\n");
 #endif
+    fprintf(stderr, "    -insecure_des enables insecure single-DES for krb5.\n");
     fprintf(stderr, "    No commandline arguments means ");
     fprintf(stderr, "authenticate to the local cell.\n");
     fprintf(stderr, "\n");
@@ -1453,6 +1472,7 @@ main(int argc, char *argv[])
     int status = AKLOG_SUCCESS;
     int i;
     int somethingswrong = FALSE;
+    int insecure_des = 0;
 
     cellinfo_t cellinfo;
 
@@ -1532,19 +1552,6 @@ main(int argc, char *argv[])
     initialize_PT_error_table();
     afs_set_com_err_hook(redirect_errors);
 
-    /*
-     * Enable DES enctypes, which are currently still required for AFS.
-     * krb5_allow_weak_crypto is MIT Kerberos 1.8.  krb5_enctype_enable is
-     * Heimdal.
-     */
-#if defined(HAVE_KRB5_ENCTYPE_ENABLE)
-    i = krb5_enctype_valid(context, ETYPE_DES_CBC_CRC);
-    if (i)
-        krb5_enctype_enable(context, ETYPE_DES_CBC_CRC);
-#elif defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO)
-    krb5_allow_weak_crypto(context, 1);
-#endif
-
     /* Initialize list of cells to which we have authenticated */
     ll_init(&authedcells);
 
@@ -1584,6 +1591,28 @@ main(int argc, char *argv[])
 	    }
 	    else
 		usage();
+        else if ((strcmp(argv[i], "-token-lifetime") == 0))
+	    if (++i < argc) {
+		status = util_GetInt32(argv[i], &akimp_lifetime);
+		if (status) {
+		    fprintf(stderr,
+			    "%s: invalid value specified for token-lifetime.\n",
+			    progname);
+		    exit(AKLOG_MISC);
+		}
+
+		if (akimp_lifetime < 0 || akimp_lifetime > AKIMP_LIFETIME_MAX) {
+		    fprintf(stderr,
+                            "%s: token-lifetime must be within 0 and %d hrs.\n",
+			    progname, AKIMP_LIFETIME_MAX);
+		    exit(AKLOG_MISC);
+		}
+
+		akimp_lifetime = akimp_lifetime * 60 * 60;
+		akimplifetime_present = TRUE;
+	    }
+	    else
+		usage();
 	else if ((strcmp(argv[i], "-principal") == 0))
 	    if (++i < argc) {
 		client = argv[i];
@@ -1604,6 +1633,8 @@ main(int argc, char *argv[])
 	    }
 	    else
 		usage();
+	else if (strcmp(argv[i], "-insecure_des") == 0)
+	    insecure_des = 1;
 	else if (argv[i][0] == '-')
 	    usage();
 	else if (!pmode && !cmode) {
@@ -1620,6 +1651,26 @@ main(int argc, char *argv[])
 	else
 	    usage();
 
+    /*
+     * Enable DES enctypes if requested.  This is not required when rxkad-k5
+     * is used, but some sites may not have updated.
+     * krb5_allow_weak_crypto is MIT Kerberos 1.8.  krb5_enctype_enable is
+     * Heimdal.
+     */
+    if (insecure_des) {
+#if defined(HAVE_KRB5_ENCTYPE_ENABLE)
+	i = krb5_enctype_valid(context, ETYPE_DES_CBC_CRC);
+	if (i)
+	    krb5_enctype_enable(context, ETYPE_DES_CBC_CRC);
+#elif defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO)
+	krb5_allow_weak_crypto(context, 1);
+#else
+	fprintf(stderr,
+	    "%s: -insecure_des is not supported by this libkrb5\n", progname);
+	exit(AKLOG_MISC);
+#endif
+    }
+
 	if (cmode) {
 	    if (((i + 1) < argc) && (strcmp(argv[i + 1], "-k") == 0)) {
 		i+=2;
@@ -1673,6 +1724,13 @@ main(int argc, char *argv[])
 	}
     }
 
+    if (akimplifetime_present && !keytab) {
+	fprintf(stderr,
+	        "%s: -token-lifetime is valid only if -keytab is specified.\n",
+	        progname);
+	exit(AKLOG_MISC);
+    }
+
     /* If nothing was given, log to the local cell. */
     if ((cells.nelements + paths.nelements) == 0) {
 	struct passwd *pwd;
@@ -1806,14 +1864,12 @@ get_credv5_akimpersonate(krb5_context context,
 			 krb5_principal client_principal,
 			 time_t starttime,
 			 time_t endtime,
-			 int *allowed_enctypes,
 			 int *paddress,
 			 krb5_creds** out_creds /* out */ )
 {
-#if defined(USING_HEIMDAL) || (defined(HAVE_ENCODE_KRB5_ENC_TKT) && defined(HAVE_ENCODE_KRB5_TICKET) && defined(HAVE_KRB5_C_ENCRYPT))
+#if defined(USING_HEIMDAL) || (defined(HAVE_ENCODE_KRB5_ENC_TKT_PART) && defined(HAVE_ENCODE_KRB5_TICKET) && defined(HAVE_KRB5_C_ENCRYPT))
     krb5_error_code code;
     krb5_keytab kt = 0;
-    krb5_kt_cursor cursor[1];
     krb5_keytab_entry entry[1];
     krb5_ccache cc = 0;
     krb5_creds *creds = 0;
@@ -1834,14 +1890,11 @@ get_credv5_akimpersonate(krb5_context context,
     krb5_data * temp;
 #endif
     int i;
-    static int any_enctype[] = {0};
     *out_creds = 0;
     if (!(creds = malloc(sizeof *creds))) {
         code = ENOMEM;
         goto cleanup;
     }
-    if (!allowed_enctypes)
-        allowed_enctypes = any_enctype;
 
     cc = 0;
     enctype = 0; /* AKIMPERSONATE_IGNORE_ENCTYPE */
@@ -1860,54 +1913,17 @@ get_credv5_akimpersonate(krb5_context context,
         goto cleanup;
     }
 
-    if (service_principal) {
-        for (i = 0; (enctype = allowed_enctypes[i]) || !i; ++i) {
-	    code = krb5_kt_get_entry(context,
-				     kt,
-				     service_principal,
-				     kvno,
-				     enctype,
-				     entry);
-	    if (!code) {
-		if (allowed_enctypes[i])
-		    deref_keyblock_enctype(session_key) = allowed_enctypes[i];
-		break;
-	    }
-        }
-        if (code) {
-	    afs_com_err(progname, code,"while scanning keytab entries");
-	    goto cleanup;
-        }
-    } else {
-        krb5_keytab_entry new[1];
-        int best = -1;
-        memset(new, 0, sizeof *new);
-        if ((code = krb5_kt_start_seq_get(context, kt, cursor))) {
-            afs_com_err(progname, code, "while starting keytab scan");
-            goto cleanup;
-        }
-        while (!(code = krb5_kt_next_entry(context, kt, new, cursor))) {
-            for (i = 0;
-                    allowed_enctypes[i] && allowed_enctypes[i]
-		     != deref_entry_enctype(new); ++i)
-                ;
-            if ((!i || allowed_enctypes[i]) &&
-		(best < 0 || best > i)) {
-                krb5_free_keytab_entry_contents(context, entry);
-                *entry = *new;
-                memset(new, 0, sizeof *new);
-            } else krb5_free_keytab_entry_contents(context, new);
-        }
-        if ((i = krb5_kt_end_seq_get(context, kt, cursor))) {
-            afs_com_err(progname, i, "while ending keytab scan");
-            code = i;
-            goto cleanup;
-        }
-        if (best < 0) {
-            afs_com_err(progname, code, "while scanning keytab");
-            goto cleanup;
-        }
+    code = krb5_kt_get_entry(context,
+			     kt,
+			     service_principal,
+			     kvno,
+			     enctype,
+			     entry);
+    if (!code)
         deref_keyblock_enctype(session_key) = deref_entry_enctype(entry);
+    else {
+        afs_com_err(progname, code, "while scanning keytab entries");
+        goto cleanup;
     }
 
     /* Make Ticket */
@@ -1930,10 +1946,6 @@ get_credv5_akimpersonate(krb5_context context,
     enc_tkt_reply->authtime = starttime;
     enc_tkt_reply->starttime = temp_time;
     *enc_tkt_reply->starttime = starttime;
-#if 0
-    enc_tkt_reply->renew_till = temp_time + 1;
-    *enc_tkt_reply->renew_till = endtime;
-#endif
     enc_tkt_reply->endtime = endtime;
 #else
     if ((code = krb5_c_make_random_key(context,
@@ -2103,10 +2115,6 @@ cleanup:
     if (deref_enc_data(&ticket_reply->enc_part))
         free(deref_enc_data(&ticket_reply->enc_part));
     krb5_free_keytab_entry_contents(context, entry);
-    if (client_principal)
-        krb5_free_principal(context, client_principal);
-    if (service_principal)
-        krb5_free_principal(context, service_principal);
     if (cc)
         krb5_cc_close(context, cc);
     if (kt)
@@ -2126,7 +2134,6 @@ get_credv5(krb5_context context, char *name, char *inst, char *realm,
 {
     krb5_creds increds;
     krb5_error_code r;
-    static krb5_principal client_principal = 0;
 
     afs_dprintf("Getting tickets: %s%s%s@%s\n", name,
 	    (inst && inst[0]) ? "/" : "", inst ? inst : "", realm);
@@ -2138,50 +2145,63 @@ get_credv5(krb5_context context, char *name, char *inst, char *realm,
 				  name,
 				  (inst && strlen(inst)) ? inst : NULL,
 				  NULL))) {
-        return r;
+        goto out;
     }
 
 
     if (!_krb425_ccache) {
         r = krb5_cc_default(context, &_krb425_ccache);
 	if (r)
-	    return r;
+	    goto out;
     }
-    if (!client_principal) {
-	if (client) {
-	    r = krb5_parse_name(context, client,  &client_principal);
-	} else {
-	    r = krb5_cc_get_principal(context, _krb425_ccache, &client_principal);
-	}
-	if (r)
-	    return r;
+
+    if (client) {
+        r = krb5_parse_name(context, client,  &increds.client);
+    } else {
+        r = krb5_cc_get_principal(context, _krb425_ccache, &increds.client);
     }
 
-    increds.client = client_principal;
+    if (r)
+	goto out;
+
     increds.times.endtime = 0;
     if (do524)
 	/* Ask for DES since that is what V4 understands */
 	get_creds_enctype((&increds)) = ENCTYPE_DES_CBC_CRC;
 
     if (keytab) {
-	int allowed_enctypes[] = {
-	    ENCTYPE_DES_CBC_CRC, 0
-	};
+	afs_int32 start, end;
+	start = time(NULL);
+
+	if (akimp_lifetime == 0) {
+	    end = MAX_AFS_INT32;
+	} else {
+	    end = start + akimp_lifetime;
+	}
 
 	r = get_credv5_akimpersonate(context,
 				     keytab,
 				     increds.server,
 				     increds.client,
-				     300, ((~0U)>>1),
-				     allowed_enctypes,
+				     start, end,
 				     0 /* paddress */,
 				     creds /* out */);
     } else {
 	r = krb5_get_credentials(context, 0, _krb425_ccache, &increds, creds);
     }
-    return r;
-}
 
+ out:
+
+   if (increds.server) {
+       krb5_free_principal(context, increds.server);
+   }
+
+   if (increds.client) {
+       krb5_free_principal(context, increds.client);
+   }
+
+   return r;
+}
 
 static int
 get_user_realm(krb5_context context, char **realm)
diff --git a/src/aklog/asetkey.c b/src/aklog/asetkey.c
index 603a6e950..83f137a67 100644
--- a/src/aklog/asetkey.c
+++ b/src/aklog/asetkey.c
@@ -35,6 +35,8 @@ stringToType(const char *string) {
 	return afsconf_rxkad;
     if (strcmp(string, "rxkad_krb5") == 0)
 	return afsconf_rxkad_krb5;
+    if (strcmp(string, "rxgk") == 0)
+	return afsconf_rxgk;
 
     return atoi(string);
 }
@@ -93,16 +95,16 @@ keyFromCommandLine(afsconf_keyType type, int kvno, int subType,
 
 #ifdef USING_HEIMDAL
 #define deref_key_length(key)			\
-	    key->keyvalue.length
+	    (key)->keyvalue.length
 
 #define deref_key_contents(key)			\
-	    key->keyvalue.data
+	    (key)->keyvalue.data
 #else
 #define deref_key_length(key)			\
-	    key->length
+	    (key)->length
 
 #define deref_key_contents(key)			\
-	    key->contents
+	    (key)->contents
 #endif
 
 static struct afsconf_typedKey *
@@ -134,7 +136,7 @@ keyFromKeytab(int kvno, afsconf_keyType type, int subtype, const char *keytab, c
 	    retval = krb5_kt_read_service_key(context, (char *)keytab,
 					      principal, kvno,
 					      ENCTYPE_DES_CBC_MD4, &key);
-    } else if (type == afsconf_rxkad_krb5) {
+    } else if (type == afsconf_rxkad_krb5 || type == afsconf_rxgk) {
 	retval = krb5_kt_read_service_key(context, (char *)keytab, principal,
 					  kvno, subtype, &key);
     } else {
@@ -198,9 +200,8 @@ addKey(struct afsconf_dir *dir, int argc, char **argv) {
 	kvno = atoi(argv[3]);
 	if (type == afsconf_rxkad) {
 	    typedKey = keyFromCommandLine(afsconf_rxkad, kvno, 0, argv[5], 8);
-	} else if (type == afsconf_rxkad_krb5){
-	    fprintf(stderr, "Raw keys for afsconf_rxkad_krb5 are unsupported");
-	    exit(1);
+	} else if (type == afsconf_rxgk || type == afsconf_rxkad_krb5) {
+	    typedKey = keyFromCommandLine(type, kvno, atoi(argv[4]), argv[5], strlen(argv[5])/2);
 	} else {
 	    fprintf(stderr, "Unknown key type %s\n", argv[2]);
 	    exit(1);
@@ -209,7 +210,7 @@ addKey(struct afsconf_dir *dir, int argc, char **argv) {
       case 7:
 	type = stringToType(argv[2]);
 	kvno = atoi(argv[3]);
-	if (type == afsconf_rxkad || type == afsconf_rxkad_krb5) {
+	if (type == afsconf_rxkad || type == afsconf_rxkad_krb5 || type == afsconf_rxgk) {
 	    typedKey = keyFromKeytab(kvno, type, atoi(argv[4]), argv[5],
 				     argv[6]);
 	} else {
@@ -236,21 +237,132 @@ addKey(struct afsconf_dir *dir, int argc, char **argv) {
     }
 }
 
+static struct afsconf_typedKey *
+random_key(char **argv, int type, int kvno, int subtype)
+{
+    struct afsconf_typedKey *typedKey;
+    krb5_context ctx;
+    krb5_keyblock keyblock;
+    struct rx_opaque key;
+    int code;
+
+    code = krb5_init_context(&ctx);
+    if (code) {
+        afs_com_err(argv[0], code, "while initializing krb5 ctx");
+        exit(1);
+    }
+
+    memset(&keyblock, 0, sizeof(keyblock));
+    code = krb5_c_make_random_key(ctx, subtype, &keyblock);
+    if (code) {
+        afs_com_err(argv[0], code, "while generating random key");
+        exit(1);
+    }
+
+    memset(&key, 0, sizeof(key));
+    key.len = deref_key_length(&keyblock);
+    key.val = deref_key_contents(&keyblock);
+
+    typedKey = afsconf_typedKey_new(type, kvno, subtype, &key);
+
+    krb5_free_keyblock_contents(ctx, &keyblock);
+    krb5_free_context(ctx);
+
+    return typedKey;
+}
+
+static void
+addRandomKey(struct afsconf_dir *dir, int argc, char **argv)
+{
+    struct afsconf_typedKey *typedKey;
+    int type;
+    int kvno;
+    int code;
+    int subtype;
+
+    /* Just pick a reasonable enctype */
+    const int RAND_ENCTYPE = ENCTYPE_AES128_CTS_HMAC_SHA1_96;
+
+    subtype = RAND_ENCTYPE;
+
+    switch (argc) {
+    case 5:
+        subtype = atoi(argv[4]);
+        AFS_FALLTHROUGH;
+    case 4:
+        type = stringToType(argv[2]);
+        kvno = atoi(argv[3]);
+
+        typedKey = random_key(argv, type, kvno, subtype);
+
+        code = afsconf_AddTypedKey(dir, typedKey, 1);
+        afsconf_typedKey_put(&typedKey);
+        if (code) {
+            afs_com_err(argv[0], code, "while adding random key");
+            exit(1);
+        }
+
+        printf("Added random key with type %d kvno %d subtype %d\n",
+               type, kvno, subtype);
+        break;
+
+    default:
+	fprintf(stderr, "%s add-random: usage is '%s add-random <type> <kvno>\n",
+                argv[0], argv[0]);
+	fprintf(stderr, "\tOR\n\t%s add-random <type> <kvno> <subtype>\n", argv[0]);
+        exit(1);
+    }
+}
+
 static void
 deleteKey(struct afsconf_dir *dir, int argc, char **argv)
 {
+    int type;
+    int subtype;
     int kvno;
     int code;
 
-    if (argc != 3) {
+    switch (argc) {
+    case 3:
+	kvno = atoi(argv[2]);
+	code = afsconf_DeleteKey(dir, kvno);
+	if (code) {
+	    afs_com_err(argv[0], code, "while deleting key %d", kvno);
+	    exit(1);
+	}
+	printf("Deleted rxkad key %d\n", kvno);
+	break;
+
+    case 4:
+	type = stringToType(argv[2]);
+	kvno = atoi(argv[3]);
+	code = afsconf_DeleteKeyByType(dir, type, kvno);
+	if (code) {
+	    afs_com_err(argv[0], code, "while deleting key (type %d kvno %d)",
+			type, kvno);
+	    exit(1);
+	}
+	printf("Deleted key (type %d kvno %d)\n", type, kvno);
+	break;
+
+    case 5:
+	type = stringToType(argv[2]);
+	kvno = atoi(argv[3]);
+	subtype = atoi(argv[4]);
+	code = afsconf_DeleteKeyBySubType(dir, type, kvno, subtype);
+	if (code) {
+	    afs_com_err(argv[0], code, "while deleting key (type %d kvno %d subtype %d)\n",
+			type, kvno, subtype);
+	    exit(1);
+	}
+	printf("Deleted key (type %d kvno %d subtype %d)\n", type, kvno, subtype);
+	break;
+
+    default:
 	fprintf(stderr, "%s delete: usage is '%s delete <kvno>\n",
 		argv[0], argv[0]);
-	exit(1);
-    }
-    kvno = atoi(argv[2]);
-    code = afsconf_DeleteKey(dir, kvno);
-    if (code) {
-	afs_com_err(argv[0], code, "while deleting key %d", kvno);
+	fprintf(stderr, "\tOR\n\t%s delete <type> <kvno>\n", argv[0]);
+	fprintf(stderr, "\tOR\n\t%s delete <type> <kvno> <subtype>\n", argv[0]);
 	exit(1);
     }
 }
@@ -289,6 +401,13 @@ listKey(struct afsconf_dir *dir, int argc, char **argv)
 		printKey(keyMaterial);
 	    }
 	    break;
+	  case afsconf_rxgk:
+	    if (kvno != -1) {
+		printf("rxgk\tkvno %4d enctype %d; key is: ",
+		       kvno, minorType);
+		printKey(keyMaterial);
+	    }
+	    break;
 	  default:
 	    printf("unknown(%d)\tkvno %4d subtype %d; key is: ", type,
 	           kvno, minorType);
@@ -315,7 +434,11 @@ main(int argc, char *argv[])
 	fprintf(stderr, "\tOR\n\t%s add <type> <kvno> <subtype> <keyfile> <princ>\n",
 	        argv[0]);
 	fprintf(stderr, "\t\tEx: %s add 0 \"80b6a7cd7a9dadb6\"\n", argv[0]);
+	fprintf(stderr, "\t%s add-random <type> <kvno>\n", argv[0]);
+	fprintf(stderr, "\t%s add-random <type> <kvno> <subtype>\n", argv[0]);
 	fprintf(stderr, "\t%s delete <kvno>\n", argv[0]);
+	fprintf(stderr, "\t%s delete <type> <kvno>\n", argv[0]);
+	fprintf(stderr, "\t%s delete <type> <kvno> <subtype>\n", argv[0]);
 	fprintf(stderr, "\t%s list\n", argv[0]);
 	exit(1);
     }
@@ -338,6 +461,9 @@ main(int argc, char *argv[])
 	listKey(tdir, argc, argv);
 
     }
+    else if (strcmp(argv[1], "add-random") == 0) {
+        addRandomKey(tdir, argc, argv);
+    }
     else {
 	fprintf(stderr, "%s: unknown operation '%s', type '%s' for "
 		"assistance\n", argv[0], argv[1], argv[0]);
diff --git a/src/aklog/klog.c b/src/aklog/klog.c
index 88e49070a..df4a06279 100644
--- a/src/aklog/klog.c
+++ b/src/aklog/klog.c
@@ -116,6 +116,7 @@ main(int argc, char *argv[])
 #define aUNWRAP 11
 #define aK5 12
 #define aK4 13
+#define aDES 14
 
     cmd_AddParm(ts, "-x", CMD_FLAG, CMD_OPTIONAL, "obsolete, noop");
     cmd_Seek(ts, aPRINCIPAL);
@@ -126,6 +127,7 @@ main(int argc, char *argv[])
     cmd_AddParm(ts, "-pipe", CMD_FLAG, CMD_OPTIONAL,
 		"read password from stdin");
     cmd_AddParm(ts, "-silent", CMD_FLAG, CMD_OPTIONAL, "silent operation");
+    /* Note: -lifetime is not implemented in this version of klog. */
     cmd_AddParm(ts, "-lifetime", CMD_SINGLE, CMD_OPTIONAL,
 		"ticket lifetime in hh[:mm[:ss]]");
     cmd_AddParm(ts, "-setpag", CMD_FLAG, CMD_OPTIONAL,
@@ -141,6 +143,8 @@ main(int argc, char *argv[])
     ++ts->nParms;	/* skip -k5 */
     cmd_AddParm(ts, "-k4", CMD_FLAG, CMD_OPTIONAL|CMD_HIDDEN, 0);
 #endif
+    cmd_AddParm(ts, "-insecure_des", CMD_FLAG, CMD_OPTIONAL,
+		"enable insecure single-DES for krb5");
 
     code = cmd_Dispatch(argc, argv);
     KLOGEXIT(code);
@@ -214,7 +218,7 @@ whoami(struct ktc_token *atoken,
     int *vicep)
 {
     int code;
-    char tempname[PR_MAXNAMELEN + 1];
+    char tempname[2*PR_MAXNAMELEN];
 
     code = pr_Initialize(0, AFSDIR_CLIENT_ETC_DIRPATH, cellconfig->name);
     if (code)
@@ -243,12 +247,12 @@ k5_to_k4_name(krb5_context k5context,
 	    i = get_princ_len(k5context, k5princ, 1);
 	    if (i > MAXKTCNAMELEN-1) i = MAXKTCNAMELEN-1;
 	    memcpy(ktcprinc->instance, get_princ_str(k5context, k5princ, 1), i);
-	    /* fall through */
+	    AFS_FALLTHROUGH;
 	case 1:
 	    i = get_princ_len(k5context, k5princ, 0);
 	    if (i > MAXKTCNAMELEN-1) i = MAXKTCNAMELEN-1;
 	    memcpy(ktcprinc->name, get_princ_str(k5context, k5princ, 0), i);
-	    /* fall through */
+	    AFS_FALLTHROUGH;
 	case 0:
 	    break;
 	}
@@ -358,7 +362,6 @@ CommandProc(struct cmd_syndesc *as, void *arock)
     int authtype;
 #endif
     krb5_data enc_part[1];
-    time_t lifetime;		/* requested ticket lifetime */
     krb5_prompter_fct pf = NULL;
     char *pass = 0;
     void *pa = 0;
@@ -413,13 +416,15 @@ CommandProc(struct cmd_syndesc *as, void *arock)
      * krb5_allow_weak_crypto is MIT Kerberos 1.8.  krb5_enctype_enable is
      * Heimdal.
      */
+    if (as->parms[aDES].items) {
 #if defined(HAVE_KRB5_ENCTYPE_ENABLE)
-    i = krb5_enctype_valid(k5context, ETYPE_DES_CBC_CRC);
-    if (i)
-        krb5_enctype_enable(k5context, ETYPE_DES_CBC_CRC);
+	i = krb5_enctype_valid(k5context, ETYPE_DES_CBC_CRC);
+	if (i)
+	    krb5_enctype_enable(k5context, ETYPE_DES_CBC_CRC);
 #elif defined(HAVE_KRB5_ALLOW_WEAK_CRYPTO)
-    krb5_allow_weak_crypto(k5context, 1);
+	krb5_allow_weak_crypto(k5context, 1);
 #endif
+    }
 
     /* Parse remaining arguments. */
 
@@ -508,36 +513,6 @@ CommandProc(struct cmd_syndesc *as, void *arock)
 	pass = passwd;
     }
 
-    if (as->parms[aLIFETIME].items) {
-	char *life = as->parms[aLIFETIME].items->data;
-	char *sp;		/* string ptr to rest of life */
-	lifetime = 3600 * strtol(life, &sp, 0);	/* hours */
-	if (sp == life) {
-	  bad_lifetime:
-	    if (!Silent)
-		fprintf(stderr, "%s: translating '%s' to lifetime failed\n",
-			rn, life);
-	    return 1;
-	}
-	if (*sp == ':') {
-	    life = sp + 1;	/* skip the colon */
-	    lifetime += 60 * strtol(life, &sp, 0);	/* minutes */
-	    if (sp == life)
-		goto bad_lifetime;
-	    if (*sp == ':') {
-		life = sp + 1;
-		lifetime += strtol(life, &sp, 0);	/* seconds */
-		if (sp == life)
-		    goto bad_lifetime;
-		if (*sp)
-		    goto bad_lifetime;
-	    } else if (*sp)
-		goto bad_lifetime;
-	} else if (*sp)
-	    goto bad_lifetime;
-    } else
-	lifetime = 0;
-
     /* Get the password if it wasn't provided. */
     if (!pass) {
 	if (Pipe) {
diff --git a/src/audit/audit.c b/src/audit/audit.c
index 4701d61d1..1f641f0c5 100644
--- a/src/audit/audit.c
+++ b/src/audit/audit.c
@@ -24,6 +24,7 @@
 
 #include <afs/opr.h>
 #include "afs/afsint.h"
+#include "afs/butc.h"
 #include <rx/rx.h>
 #include <rx/rxkad.h>
 #include "audit.h"
@@ -138,6 +139,95 @@ audmakebuf(char *audEvent, va_list vaList)
 		bufferPtr += sizeof(struct AFSFid);
 		break;
 	    }
+	/* butc tape label */
+	case AUD_TLBL:
+	    {
+		struct tc_tapeLabel *label;
+
+		label = (struct tc_tapeLabel *)va_arg(vaList,
+						      struct tc_tapeLabel *);
+		if (label)
+		    memcpy(bufferPtr, label, sizeof(*label));
+		else
+		    memset(bufferPtr, 0, sizeof(*label));
+		bufferPtr += sizeof(label);
+		break;
+	    }
+	/* butc dump interface */
+	case AUD_TDI:
+	    {
+		struct tc_dumpInterface *di;
+
+		di = (struct tc_dumpInterface *)
+			va_arg(vaList, struct tc_dumpInterface *);
+		if (di)
+		    memcpy(bufferPtr, di, sizeof(*di));
+		else
+		    memset(bufferPtr, 0, sizeof(*di));
+		bufferPtr += sizeof(*di);
+		break;
+	    }
+	/*
+	 * butc dump array
+	 * An array of dump descriptions, but the AIX audit package assumes fixed
+	 * length, so we can only do the first one for now.
+	 */
+	case AUD_TDA:
+	    {
+		struct tc_dumpArray *da;
+
+		da = (struct tc_dumpArray *)
+			va_arg(vaList, struct tc_dumpArray *);
+		if (da && da->tc_dumpArray_len) {
+		    memcpy(bufferPtr, &da->tc_dumpArray_len, sizeof(u_int));
+		    bufferPtr += sizeof(u_int);
+		    memcpy(bufferPtr, da->tc_dumpArray_val,
+			   sizeof(da->tc_dumpArray_val[0]));
+		} else {
+		    memset(bufferPtr, 0, sizeof(u_int));
+		    bufferPtr += sizeof(u_int);
+		    memset(bufferPtr, 0, sizeof(da->tc_dumpArray_val[0]));
+		}
+		bufferPtr += sizeof(da->tc_dumpArray_val[0]);
+		break;
+	    }
+	/*
+	 * butc restore array
+	 * An array of restore descriptions, but the AIX audit package assumes
+	 * fixed length, so we can only do the first one for now.
+	 */
+	case AUD_TRA:
+	    {
+		struct tc_restoreArray *ra;
+
+		ra = (struct tc_restoreArray *)
+			va_arg(vaList, struct tc_restoreArray *);
+		if (ra && ra->tc_restoreArray_len) {
+		    memcpy(bufferPtr, &ra->tc_restoreArray_len, sizeof(u_int));
+		    bufferPtr += sizeof(u_int);
+		    memcpy(bufferPtr, ra->tc_restoreArray_val,
+			   sizeof(ra->tc_restoreArray_val[0]));
+		} else {
+		    memset(bufferPtr, 0, sizeof(u_int));
+		    bufferPtr += sizeof(u_int);
+		    memset(bufferPtr, 0, sizeof(ra->tc_restoreArray_val[0]));
+		}
+		bufferPtr += sizeof(ra->tc_restoreArray_val[0]);
+		break;
+	    }
+	/* butc tape controller status */
+	    {
+		struct tciStatusS *status;
+
+		status = (struct tciStatusS *)va_arg(vaList,
+						     struct tciStatusS *);
+		if (status)
+		    memcpy(bufferPtr, status, sizeof(*status));
+		else
+		    memset(bufferPtr, 0, sizeof(*status));
+		bufferPtr += sizeof(*status);
+		break;
+	    }
 	default:
 #ifdef AFS_AIX32_ENV
 	    code =
@@ -163,6 +253,11 @@ printbuf(int rec, char *audEvent, char *afsName, afs_int32 hostId,
     char *vaStr;
     struct AFSFid *vaFid;
     struct AFSCBFids *vaFids;
+    struct tc_tapeLabel *vaLabel;
+    struct tc_dumpInterface *vaDI;
+    struct tc_dumpArray *vaDA;
+    struct tc_restoreArray *vaRA;
+    struct tciStatusS *vaTCstatus;
     int num = LogThreadNum();
     struct in_addr hostAddr;
     time_t currenttime;
@@ -258,6 +353,102 @@ printbuf(int rec, char *audEvent, char *afsName, afs_int32 hostId,
 
             }
 	    break;
+	case AUD_TLBL:		/* butc tape label */
+	    vaLabel = va_arg(vaList, struct tc_tapeLabel *);
+
+	    if (vaLabel) {
+		audit_ops->append_msg("TAPELABEL %d:%.*s:%.*s:%u ",
+				      vaLabel->size,
+				      TC_MAXTAPELEN, vaLabel->afsname,
+				      TC_MAXTAPELEN, vaLabel->pname,
+				      vaLabel->tapeId);
+	    } else {
+		audit_ops->append_msg("TAPELABEL <null>");
+	    }
+	    break;
+	case AUD_TDI:
+	    vaDI = va_arg(vaList, struct tc_dumpInterface *);
+
+	    if (vaDI) {
+		audit_ops->append_msg(
+    "TCDUMPINTERFACE %.*s:%.*s:%.*s:%d:%d:%d:%d:%.*s:%.*s:%d:%d:%d:%d:%d ",
+    TC_MAXDUMPPATH, vaDI->dumpPath, TC_MAXNAMELEN, vaDI->volumeSetName,
+    TC_MAXNAMELEN, vaDI->dumpName, vaDI->parentDumpId, vaDI->dumpLevel,
+    vaDI->doAppend,
+    vaDI->tapeSet.id, TC_MAXHOSTLEN, vaDI->tapeSet.tapeServer,
+    TC_MAXFORMATLEN, vaDI->tapeSet.format, vaDI->tapeSet.maxTapes,
+    vaDI->tapeSet.a, vaDI->tapeSet.b, vaDI->tapeSet.expDate,
+    vaDI->tapeSet.expType);
+	    } else {
+		audit_ops->append_msg("TCDUMPINTERFACE <null>");
+	    }
+	    break;
+	case AUD_TDA:
+	    vaDA = va_arg(vaList, struct tc_dumpArray *);
+
+	    if (vaDA) {
+		u_int i;
+		struct tc_dumpDesc *desc;
+		struct in_addr hostAddr;
+
+		desc = vaDA->tc_dumpArray_val;
+		if (desc) {
+		    audit_ops->append_msg("DUMPS %d ", vaDA->tc_dumpArray_len);
+		    for (i = 0; i < vaDA->tc_dumpArray_len; i++, desc++) {
+			hostAddr.s_addr = desc->hostAddr;
+			audit_ops->append_msg("DUMP %d:%d:%.*s:%d:%d:%d:%s ",
+			    desc->vid, desc->vtype, TC_MAXNAMELEN, desc->name,
+			    desc->partition, desc->date, desc->cloneDate,
+			    inet_ntoa(hostAddr));
+		    }
+		} else {
+		    audit_ops->append_msg("DUMPS 0 DUMP 0:0::0:0:0:0.0.0.0");
+		}
+	    }
+	    break;
+	case AUD_TRA:
+	    vaRA = va_arg(vaList, struct tc_restoreArray *);
+
+	    if (vaRA) {
+		u_int i;
+		struct tc_restoreDesc *desc;
+		struct in_addr hostAddr;
+
+		desc = vaRA->tc_restoreArray_val;
+		if (desc) {
+		    audit_ops->append_msg("RESTORES %d ",
+					  vaRA->tc_restoreArray_len);
+		    for(i = 0; i < vaRA->tc_restoreArray_len; i++, desc++) {
+			hostAddr.s_addr = desc->hostAddr;
+			audit_ops->append_msg(
+			    "RESTORE %d:%.*s:%d:%d:%d:%d:%d:%d:%d:%s:%.*s:%.*s ",
+			    desc->flags, TC_MAXTAPELEN, desc->tapeName,
+			    desc->dbDumpId, desc->initialDumpId,
+			    desc->position, desc->origVid, desc->vid,
+			    desc->partition, desc->dumpLevel,
+			    inet_ntoa(hostAddr), TC_MAXNAMELEN,
+			    desc->oldName, TC_MAXNAMELEN, desc->newName);
+		    }
+		} else {
+		    audit_ops->append_msg(
+			"RESTORES 0 RESTORE 0::0:0:0:0:0:0:0:0.0.0.0::: ");
+		}
+	    }
+	    break;
+	case AUD_TSTT:
+	    vaTCstatus = va_arg(vaList, struct tciStatusS *);
+
+	    if (vaTCstatus)
+		audit_ops->append_msg("TCSTATUS %.*s:%d:%d:%d:%d:%.*s:%d:%d ",
+				      TC_MAXNAMELEN, vaTCstatus->taskName,
+				      vaTCstatus->taskId, vaTCstatus->flags,
+				      vaTCstatus->dbDumpId, vaTCstatus->nKBytes,
+				      TC_MAXNAMELEN, vaTCstatus->volumeName,
+				      vaTCstatus->volsFailed,
+				      vaTCstatus->lastPolled);
+	    else
+		audit_ops->append_msg("TCSTATUS <null>");
+	    break;
 	default:
 	    audit_ops->append_msg("--badval-- ");
 	    break;
diff --git a/src/audit/audit.h b/src/audit/audit.h
index f8b4100b5..6188cf60d 100644
--- a/src/audit/audit.h
+++ b/src/audit/audit.h
@@ -23,6 +23,12 @@
 #define AUD_RESID 20		/* resid         in variable list */
 #define AUD_RSSIZERANGE 21	/* rssizerange   in variable list */
 #define AUD_LOOKUPINFO 22	/* LookupInfo    in variable list */
+/* next 5 lines for butc */
+#define AUD_TLBL 30             /* Tape Controller label */
+#define AUD_TDI  31             /* Tape Controller dump interface */
+#define AUD_TDA  32             /* Tape Controller dump array */
+#define AUD_TRA  33             /* Tape Controller restore array */
+#define AUD_TSTT 34             /* Tape Controller status struct */
 
 /*
  * Note: the master definitions of these error codes come from *.et
@@ -296,6 +302,21 @@
 #define SREMIORemoteGetHSMdata  "AFS_RE_HSMdata"
 #define SREMIOPrefetch          "AFS_RE_Prefetch"
 
+#define TC_StartEvent           "AFS_TC_Start"
+#define TC_LabelTapeEvent       "AFS_TC_LabelTape"
+#define TC_PerformDumpEvent     "AFS_TC_PerformDump"
+#define TC_PerformRestoreEvent  "AFS_TC_PerformRestore"
+#define TC_ReadLabelEvent       "AFS_TC_ReadLabel"
+#define TC_RestoreDbEvent       "AFS_TC_RestoreDb"
+#define TC_SaveDbEvent          "AFS_TC_SaveDb"
+#define TC_ScanDumpsEvent       "AFS_TC_ScanDumps"
+#define TC_TCInfoEvent          "AFS_TC_TCInfo"
+#define TC_DeleteDumpEvent      "AFS_TC_DeleteDump"
+#define TC_GetStatusEvent       "AFS_TC_GetStatus"
+#define TC_EndStatusEvent       "AFS_TC_EndStatus"
+#define TC_RequestAbortEvent    "AFS_TC_RequestAbort"
+#define TC_ScanStatusEvent      "AFS_TC_ScanStatus"
+
 
 /* prototypes for audit functions */
 int osi_audit(char *audEvent, afs_int32 errCode, ...);
diff --git a/src/auth/Makefile.in b/src/auth/Makefile.in
index 8dec8a6c0..1d12db34d 100644
--- a/src/auth/Makefile.in
+++ b/src/auth/Makefile.in
@@ -10,7 +10,7 @@ include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.lwp
 include @TOP_OBJDIR@/src/config/Makefile.lwptool
 
-BASE_objs= cellconfig.lo keys.lo userok.lo writeconfig.lo authcon.lo \
+BASE_objs= cellconfig.lo keys.lo userok.lo authcon.lo \
 	 acfg_errors.lo ktc_errors.lo netrestrict.lo token.xdr.lo token.lo \
 	 realms.lo
 
@@ -23,7 +23,8 @@ LT_deps= $(top_builddir)/src/opr/liboafs_opr.la \
 	 $(top_builddir)/src/rxkad/liboafs_rxkad.la \
 	 $(top_builddir)/src/audit/liboafs_audit.la \
 	 $(top_builddir)/src/util/liboafs_util.la \
-	 $(top_builddir)/src/sys/liboafs_sys.la
+	 $(top_builddir)/src/sys/liboafs_sys.la \
+	 @RXGK_LIBS@
 
 LT_libs= $(LDFLAGS_roken) $(LIB_roken)
 
@@ -76,7 +77,6 @@ ${TOP_LIBDIR}/libauth.krb.a: libauth.krb.a
 cellconfig.lo: cellconfig.c ${INCLS}
 keys.lo: keys.c ${INCLS}
 ktc.lo: ktc.c ${INCLS} ${TOP_INCDIR}/afs/vice.h
-writeconfig.lo: writeconfig.c ${INCLS}
 authcon.lo: authcon.c ${INCLS}
 userok.lo: userok.c ${INCLS}
 cellconfig.lo: cellconfig.c ${INCLS}
@@ -128,7 +128,6 @@ netrestrict.lo: cellconfig.h
 realms.lo: cellconfig.h
 setkey.o: cellconfig.h
 userok.lo: cellconfig.h
-writeconfig.lo: cellconfig.h
 
 ktc_errors.c: ktc_errors.et
 	${COMPILE_ET_C} -p ${srcdir} ktc_errors
@@ -177,8 +176,9 @@ dest: libauth.a libauth.krb.a auth.h cellconfig.h
 #
 # Misc. targets
 #
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 clean:
 	$(LT_CLEAN)
diff --git a/src/auth/NTMakefile b/src/auth/NTMakefile
index 1c306b8e3..c680d31d6 100644
--- a/src/auth/NTMakefile
+++ b/src/auth/NTMakefile
@@ -39,7 +39,6 @@ AFSAUTH_LIBOBJS =\
 	$(OUT)\cellconfig.obj \
 	$(OUT)\keys.obj \
 	$(OUT)\userok.obj \
-	$(OUT)\writeconfig.obj \
 	$(OUT)\authcon.obj \
 	$(OUT)\realms.obj \
 	$(OUT)\acfg_errors.obj \
@@ -67,7 +66,6 @@ AFSAUTH_KRB_LIBFILE = $(DESTDIR)\lib\afs\afsauth.krb.lib
 AFSAUTH_KRB_LIBOBJS =\
 	$(OUT)\cellconfig.obj \
 	$(OUT)\userok.obj \
-	$(OUT)\writeconfig.obj \
 	$(OUT)\authcon.obj \
 	$(OUT)\realms.obj \
 	$(OUT)\acfg_errors.obj \
diff --git a/src/auth/authcon.c b/src/auth/authcon.c
index 21ef54fcf..afb8f3f3b 100644
--- a/src/auth/authcon.c
+++ b/src/auth/authcon.c
@@ -31,6 +31,10 @@
 #include "ktc.h"
 #include "auth.h"
 
+#ifdef AFS_RXGK_ENV
+# include <rx/rxgk.h>
+#endif
+
 /* return a null security object if nothing else can be done */
 static afs_int32
 QuickAuth(struct rx_securityClass **astr, afs_int32 *aindex)
@@ -164,10 +168,7 @@ GenericAuth(struct afsconf_dir *adir,
 	return QuickAuth(astr, aindex);
     }
 
-    /* Next, we have ticket, kvno and session key, authenticate the connection.
-     * We use a magic # instead of a constant because of basic compilation
-     * order when compiling the system from scratch (rx/rxkad.h isn't installed
-     * yet). */
+    /* Next, we have ticket, kvno and session key, authenticate the connection.*/
     tclass = (struct rx_securityClass *)
 	rxkad_NewClientSecurityObject(enclevel, &session, kvno, ticketLen,
 				      tbuffer);
@@ -210,6 +211,90 @@ afsconf_ClientAuthSecure(void *arock,
     return rc;
 }
 
+/**
+ * Print an rxgk token and make a security class with it
+ *
+ * Print an rxgk token and build a security class from it, returning the
+ * correct index along with the class.
+ *
+ * As with the other ClientAuth variants, fall back to rxnull on errors.
+ * The caller can check the returned aindex if necessary.
+ *
+ * If 'crypt' is nonzero, use the _CRYPT security level. Otherwise, if 'auth'
+ * is nonzero, use the _AUTH security level. Otherwise, use _CLEAR.
+ */
+static afs_int32
+_ClientAuthRXGK(void *arock, struct rx_securityClass **aclass,
+		afs_int32 *aindex, int crypt, int auth)
+{
+#ifdef AFS_RXGK_ENV
+    struct rx_securityClass *tclass;
+    struct rx_opaque token = RX_EMPTY_OPAQUE;
+    RXGK_Level level;
+    RXGK_TokenInfo tokeninfo;
+    rxgk_key cell_key = NULL, k0 = NULL;
+    afs_int32 code, kvno, cell_enctype, k0_enctype;
+
+    memset(&tokeninfo, 0, sizeof(tokeninfo));
+
+    if (crypt)
+	level = RXGK_LEVEL_CRYPT;
+    else if (auth)
+	level = RXGK_LEVEL_AUTH;
+    else
+	level = RXGK_LEVEL_CLEAR;
+
+    code = afsconf_GetLatestRXGKKey(arock, &kvno, &cell_enctype, &cell_key);
+    if (code != 0)
+	goto done;
+
+    /* assume that cell_key's enctype works for the our token's k0, too */
+    k0_enctype = cell_enctype;
+
+    tokeninfo.enctype = k0_enctype;
+    tokeninfo.level = level;
+    code = rxgk_print_token_and_key(&token, &tokeninfo, cell_key, kvno,
+				    cell_enctype, &k0);
+    if (code != 0)
+	goto done;
+    tclass = rxgk_NewClientSecurityObject(level, k0_enctype, k0, &token);
+    if (tclass == NULL)
+	code = RXGK_INCONSISTENCY;
+ done:
+    rxgk_release_key(&cell_key);
+    rxgk_release_key(&k0);
+    rx_opaque_freeContents(&token);
+    if (code != 0)
+	return QuickAuth(aclass, aindex);
+    *aclass = tclass;
+    *aindex = RX_SECIDX_GK;
+    return code;
+#else	/* AFS_RXGK_ENV */
+    return QuickAuth(aclass, aindex);
+#endif	/* !AFS_RXGK_ENV */
+}
+
+afs_int32
+afsconf_ClientAuthRXGKClear(void *arock, struct rx_securityClass **aclass,
+			    afs_int32 *aindex)
+{
+    return _ClientAuthRXGK(arock, aclass, aindex, 0, 0);
+}
+
+afs_int32
+afsconf_ClientAuthRXGKAuth(void *arock, struct rx_securityClass **aclass,
+			    afs_int32 *aindex)
+{
+    return _ClientAuthRXGK(arock, aclass, aindex, 0, 1);
+}
+
+afs_int32
+afsconf_ClientAuthRXGKCrypt(void *arock, struct rx_securityClass **aclass,
+			    afs_int32 *aindex)
+{
+    return _ClientAuthRXGK(arock, aclass, aindex, 1, 0);
+}
+
 /*!
  * Build a security class from the user's current tokens
  *
@@ -247,6 +332,12 @@ afsconf_ClientAuthToken(struct afsconf_cell *info,
     *sc = NULL;
     *scIndex = RX_SECIDX_NULL;
 
+    if ((flags & AFSCONF_SECOPTS_RXGK)) {
+	/* We don't support non-printed rxgk tokens yet */
+	code = AFSCONF_NO_SECURITY_CLASS;
+	goto out;
+    }
+
     code = ktc_GetTokenEx(info->name, &tokenSet);
     if (code)
 	goto out;
@@ -303,15 +394,11 @@ afsconf_BuildServerSecurityObjects(void *rock,
 {
     struct afsconf_dir *dir = rock;
 
-    if (dir->securityFlags & AFSCONF_SECOPTS_ALWAYSENCRYPT)
-	*numClasses = 4;
-    else
-	*numClasses = 3;
+    *numClasses = RX_SECIDX_GK+1;
 
     *classes = calloc(*numClasses, sizeof(**classes));
 
     (*classes)[RX_SECIDX_NULL] = rxnull_NewServerSecurityObject();
-    (*classes)[RX_SECIDX_VAB] = NULL;
     (*classes)[RX_SECIDX_KAD] =
 	rxkad_NewKrb5ServerSecurityObject(0, dir, afsconf_GetKey,
 					  _afsconf_GetRxkadKrb5Key, NULL);
@@ -320,6 +407,10 @@ afsconf_BuildServerSecurityObjects(void *rock,
 	(*classes)[RX_SECIDX_KAE] =
 	    rxkad_NewKrb5ServerSecurityObject(rxkad_crypt, dir, afsconf_GetKey,
 					      _afsconf_GetRxkadKrb5Key, NULL);
+#ifdef AFS_RXGK_ENV
+    (*classes)[RX_SECIDX_GK] =
+        rxgk_NewServerSecurityObject(rock, afsconf_GetRXGKKey);
+#endif
 }
 
 /*!
@@ -341,6 +432,13 @@ afsconf_BuildServerSecurityObjects(void *rock,
  * 	 	than authentication or integrity modes.
  * 	- AFSCONF_SECOPTS_FALLBACK_NULL - if no suitable class can be found,
  * 		then fallback to the rxnull security class.
+ * 	- AFSCONF_SECOPTS_NEVERENCRYPT - avoid encrypting classes (currently
+ * 		only valid with _RXGK)
+ * 	- AFSCONF_SECOPTS_ALWAYSCLEAR - avoid encrypting or authenticating
+ * 		classes (always use "clear" security classes) (currently
+ * 		only valid with _RXGK)
+ * 	- AFSCONF_SECOPTS_RXGK - only use rxgk security classes (currently
+ * 		only valid with _LOCALAUTH)
  * @param[in] info
  * 	The cell information structure for the current cell. If this is NULL,
  * 	then use a version locally obtained using the cellName.
@@ -377,7 +475,15 @@ afsconf_PickClientSecObj(struct afsconf_dir *dir, afsconf_secflags flags,
 	    return AFSCONF_NOCELLDB;
 
 	if (flags & AFSCONF_SECOPTS_LOCALAUTH) {
-	    if (flags & AFSCONF_SECOPTS_ALWAYSENCRYPT)
+	    if ((flags & AFSCONF_SECOPTS_RXGK)) {
+		if ((flags & AFSCONF_SECOPTS_ALWAYSCLEAR))
+		    code = afsconf_ClientAuthRXGKClear(dir, sc, scIndex);
+		else if ((flags & AFSCONF_SECOPTS_NEVERENCRYPT))
+		    code = afsconf_ClientAuthRXGKAuth(dir, sc, scIndex);
+		else
+		    code = afsconf_ClientAuthRXGKCrypt(dir, sc, scIndex);
+
+	    } else if (flags & AFSCONF_SECOPTS_ALWAYSENCRYPT)
 		code = afsconf_ClientAuthSecure(dir, sc, scIndex);
 	    else
 		code = afsconf_ClientAuth(dir, sc, scIndex);
diff --git a/src/auth/cellconfig.c b/src/auth/cellconfig.c
index 80b6e1e98..d41d4d2a3 100644
--- a/src/auth/cellconfig.c
+++ b/src/auth/cellconfig.c
@@ -73,13 +73,12 @@ static int TrimLine(char *abuffer, int abufsize);
 static int GetCellNT(struct afsconf_dir *adir);
 #endif
 static int GetCellUnix(struct afsconf_dir *adir);
-static int afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
-				char clones[]);
+static int LoadConfig(struct afsconf_dir *adir);
 static int ParseHostLine(char *aline, struct sockaddr_in *addr,
-			 char *aname, char *aclone);
+			 char *aname, char *aclone /* boolean */);
 static int ParseCellLine(char *aline, char *aname,
 			 char *alname);
-static int afsconf_CloseInternal(struct afsconf_dir *adir);
+static int UnloadConfig(struct afsconf_dir *adir);
 static int afsconf_Reopen(struct afsconf_dir *adir);
 
 #ifndef T_AFSDB
@@ -196,12 +195,39 @@ afsconf_fgets(char *s, int n, afsconf_FILE *iop)
 	}
     }
 }
-#define fopen afsconf_fopen
-#define fclose afsconf_fclose
-#define fgets afsconf_fgets
-#else
-#define afsconf_FILE FILE
-#endif /* AFS_SUN5_ENV && ! __sparcv9 */
+
+#else /* AFS_SUN5_ENV && !__sparcv9 */
+
+/*
+ * On all other platforms, we use the native stdio functions. We still go
+ * through our afsconf_f* wrappers here, to still do compile-time checks to
+ * make sure we don't mix afsconf_fopen with real stdio calls.
+ */
+struct afsconf_iobuffer;
+
+typedef struct afsconf_iobuffer afsconf_FILE;
+
+static afsconf_FILE *
+afsconf_fopen(const char *fname, const char *fmode)
+{
+    return (afsconf_FILE*)fopen(fname, fmode);
+}
+
+static int
+afsconf_fclose(afsconf_FILE *iop)
+{
+    FILE *fh = (FILE *)iop;
+    return fclose(fh);
+}
+
+static char *
+afsconf_fgets(char *s, int n, afsconf_FILE *iop)
+{
+    FILE *fh = (FILE *)iop;
+    return fgets(s, n, fh);
+}
+
+#endif /* AFS_SUN5_ENV && !__sparcv9 */
 
 /* return port number in network byte order in the low 16 bits of a long; return -1 if not found */
 afs_int32
@@ -214,11 +240,7 @@ afsconf_FindService(const char *aname)
     if (aname == NULL || aname[0] == '\0')
 	return -1;
 
-#if     defined(AFS_OSF_ENV)
-    ts = getservbyname(aname, "");
-#else
     ts = (struct servent *) getservbyname(aname, NULL);
-#endif
     if (ts) {
 	/* we found it in /etc/services, so we use this value */
 	return ts->s_port;	/* already in network byte order */
@@ -320,32 +342,32 @@ _afsconf_IsClientConfigDirectory(const char *path)
 
 #ifdef AFS_NT40_ENV
 static void
-_afsconf_CellServDBPath(struct afsconf_dir *adir, char **path)
+_afsconf_CellServDBPath(const char *dirname, char **path)
 {
     char *p;
 
     /* NT client CellServDB has different file name than NT server or Unix */
-    if (_afsconf_IsClientConfigDirectory(adir->name)) {
+    if (_afsconf_IsClientConfigDirectory(dirname)) {
 	if (!afssw_GetClientCellServDBDir(&p)) {
 	    if (asprintf(path, "%s/%s", p, AFSDIR_CELLSERVDB_FILE_NTCLIENT) < 0)
 		*path = NULL;
 	    free(p);
 	} else {
-	    if (asprintf(path, "%s/%s", adir->name,
+	    if (asprintf(path, "%s/%s", dirname,
 			 AFSDIR_CELLSERVDB_FILE_NTCLIENT) < 0)
 		*path = NULL;
 	}
     } else {
-	if (asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE) < 0)
+	if (asprintf(path, "%s/%s", dirname, AFSDIR_CELLSERVDB_FILE) < 0)
 	    *path = NULL;
     }
     return;
 }
 #else
 static void
-_afsconf_CellServDBPath(struct afsconf_dir *adir, char **path)
+_afsconf_CellServDBPath(const char *dirname, char **path)
 {
-    if (asprintf(path, "%s/%s", adir->name, AFSDIR_CELLSERVDB_FILE) < 0)
+    if (asprintf(path, "%s/%s", dirname, AFSDIR_CELLSERVDB_FILE) < 0)
 	*path = NULL;
 }
 #endif /* AFS_NT40_ENV */
@@ -353,7 +375,6 @@ _afsconf_CellServDBPath(struct afsconf_dir *adir, char **path)
 int
 _afsconf_UpToDate(struct afsconf_dir *adir)
 {
-    char *cellservDB;
     struct stat tstat;
     int code;
     time_t now = time(0);
@@ -363,12 +384,10 @@ _afsconf_UpToDate(struct afsconf_dir *adir)
     }
     adir->timeCheck = now;
 
-    _afsconf_CellServDBPath(adir, &cellservDB);
-    if (cellservDB == NULL)
+    if (adir->cellservDB == NULL)
 	return 0;
 
-    code = stat(cellservDB, &tstat);
-    free(cellservDB);
+    code = stat(adir->cellservDB, &tstat);
     if (code < 0)
 	return 0; /* Can't throw the error, so just say we're not up to date */
 
@@ -407,7 +426,6 @@ _afsconf_Check(struct afsconf_dir *adir)
 int
 _afsconf_Touch(struct afsconf_dir *adir)
 {
-    char *cellservDB;
     int code;
 #ifndef AFS_NT40_ENV
     struct timeval tvp[2];
@@ -416,22 +434,129 @@ _afsconf_Touch(struct afsconf_dir *adir)
     adir->timeRead = 0;		/* just in case */
     adir->timeCheck = 0;
 
-    _afsconf_CellServDBPath(adir, &cellservDB);
-    if (cellservDB == NULL)
+    if (adir->cellservDB == NULL)
 	return ENOMEM;
 
 #ifdef AFS_NT40_ENV
-    code = _utime(cellservDB, NULL);
+    code = _utime(adir->cellservDB, NULL);
 #else
     gettimeofday(&tvp[0], NULL);
     tvp[1] = tvp[0];
-    code = utimes(cellservDB, tvp);
+    code = utimes(adir->cellservDB, tvp);
 #endif /* AFS_NT40_ENV */
-    free(cellservDB);
 
     return code;
 }
 
+/**
+ * Read a single line from a file.
+ *
+ * Retreive the first line of a file if present. The trailing new
+ * line is stripped.
+ *
+ * @note The returned string must be freed by the caller.
+ *
+ * @param[in]  pathname    pathname to the file
+ * @param[out] aline       address of a string
+ *
+ * @return 0            success
+ *         ENOENT       unable to open file
+ *         EIO          empty file or read error
+ *         ENOMEM       unable to allocate output
+ *         ENAMETOOLONG first line of file exceeds MAXPATHLEN
+ */
+static int
+ReadFirstLine(const char *pathname, char **aline)
+{
+    char *line = NULL;
+    char buffer[MAXPATHLEN + 2]; /* Extra char for truncation check. */
+    afsconf_FILE *fp;
+    size_t len = 0;
+
+    fp = afsconf_fopen(pathname, "r");
+    if (!fp)
+	return ENOENT;
+    if (afsconf_fgets(buffer, sizeof(buffer), fp) != NULL)
+	len = strlen(buffer);
+    afsconf_fclose(fp);
+    if (len == 0)
+	return EIO;
+    /* Trim the trailing newline, if one. */
+    if (buffer[len - 1] == '\n') {
+	buffer[len - 1] = '\0';
+	len--;
+    }
+    /* Truncation check. */
+    if (len > MAXPATHLEN)
+        return ENAMETOOLONG;
+    line = strdup(buffer);
+    if (line == NULL)
+	return ENOMEM;
+    *aline = line;
+    return 0;
+}
+
+/**
+ * Find an alternative path to the configuration directory.
+ *
+ * Attempt to find an alternative configuration directory pathname.  First
+ * check for the presence of the AFSCONF environment variable, then check for
+ * the contents of the $HOME/.AFSCONF file, then check for the contents of the
+ * /.AFSCONF file.
+ *
+ * The AFSCONF environment, or contents of $HOME/.AFSCONF, or /.AFSCONF will be
+ * typically set to something like /afs/<cell>/common/etc where, by convention,
+ * the default files for ThisCell and CellServDB will reside. Note that a major
+ * drawback is that a given afs client on that cell may NOT contain the same
+ * contents.
+ *
+ * @param[out] aconfdir  pointer to an allocated string if a path was found
+ *
+ * @return 0 on success
+ *
+ * @note The returned string in pathp must be freed by the caller.
+ */
+static int
+GetAlternatePath(char **aconfdir)
+{
+    int code;
+    char *confdir = NULL;
+    char *afsconf_path = getenv("AFSCONF");
+
+    if (afsconf_path) {
+	confdir = strdup(afsconf_path);
+	if (!confdir)
+	    return ENOMEM;
+    }
+
+    if (!confdir) {
+	char *home_dir = getenv("HOME");
+	if (home_dir) {
+	    char *pathname = NULL;
+	    int r = asprintf(&pathname, "%s/%s", home_dir, ".AFSCONF");
+	    if (r < 0 || !pathname)
+		return ENOMEM;
+	    code = ReadFirstLine(pathname, &confdir);
+	    free(pathname);
+	    pathname = NULL;
+	    if (code && code != ENOENT)
+		return code;
+	}
+    }
+
+    if (!confdir) {
+	code = ReadFirstLine("/.AFSCONF", &confdir);
+	if (code && code != ENOENT)
+	    return code;
+    }
+
+    if (!confdir)
+	return ENOENT;
+
+    *aconfdir = confdir;
+    return 0;
+}
+
 struct afsconf_dir *
 afsconf_Open(const char *adir)
 {
@@ -439,61 +564,23 @@ afsconf_Open(const char *adir)
     afs_int32 code;
 
     LOCK_GLOBAL_MUTEX;
-    /* zero structure and fill in name; rest is done by internal routine */
-    tdir = calloc(1, sizeof(struct afsconf_dir));
+    /* Zero structure and fill in name, the rest is done by LoadConfig. */
+    tdir = calloc(1, sizeof(*tdir));
+    if (!tdir)
+	goto fail;
     tdir->name = strdup(adir);
+    if (!tdir->name)
+	goto fail;
 
-    code = afsconf_OpenInternal(tdir, 0, 0);
+    code = LoadConfig(tdir);
     if (code) {
-	char *afsconf_path, afs_confdir[128];
-
 	free(tdir->name);
-	/* Check global place only when local Open failed for whatever reason */
-	if (!(afsconf_path = getenv("AFSCONF"))) {
-	    /* The "AFSCONF" environment (or contents of "/.AFSCONF") will be typically set to something like "/afs/<cell>/common/etc" where, by convention, the default files for "ThisCell" and "CellServDB" will reside; note that a major drawback is that a given afs client on that cell may NOT contain the same contents... */
-	    char *home_dir;
-	    afsconf_FILE *fp;
-	    size_t len = 0;
-	    int r;
-
-	    if (!(home_dir = getenv("HOME"))) {
-		/* Our last chance is the "/.AFSCONF" file */
-		fp = fopen("/.AFSCONF", "r");
-		if (fp == 0)
-		    goto fail;
-
-	    } else {
-		char *pathname = NULL;
-
-		r = asprintf(&pathname, "%s/%s", home_dir, ".AFSCONF");
-		if (r < 0 || pathname == NULL)
-		    goto fail;
-
-		fp = fopen(pathname, "r");
-		free(pathname);
-
-		if (fp == 0) {
-		    /* Our last chance is the "/.AFSCONF" file */
-		    fp = fopen("/.AFSCONF", "r");
-		    if (fp == 0)
-			goto fail;
-		}
-	    }
-	    if (fgets(afs_confdir, 128, fp) != NULL)
-		len = strlen(afs_confdir);
-	    fclose(fp);
-	    if (len == 0)
-		goto fail;
-
-	    if (afs_confdir[len - 1] == '\n') {
-		afs_confdir[len - 1] = 0;
-	    }
-	    afsconf_path = afs_confdir;
-	}
-	tdir->name = strdup(afsconf_path);
-	code = afsconf_OpenInternal(tdir, 0, 0);
+	tdir->name = NULL;
+	code = GetAlternatePath(&tdir->name);
+	if (code)
+	    goto fail;
+	code = LoadConfig(tdir);
 	if (code) {
-	    free(tdir->name);
 	    goto fail;
 	}
     }
@@ -501,6 +588,8 @@ afsconf_Open(const char *adir)
     return tdir;
 
 fail:
+    if (tdir)
+	free(tdir->name);
     free(tdir);
     UNLOCK_GLOBAL_MUTEX;
     return NULL;
@@ -516,12 +605,12 @@ GetCellUnix(struct afsconf_dir *adir)
 
     strcompose(tbuffer, 256, adir->name, "/", AFSDIR_THISCELL_FILE,
 	(char *)NULL);
-    fp = fopen(tbuffer, "r");
+    fp = afsconf_fopen(tbuffer, "r");
     if (fp == 0) {
 	return -1;
     }
-    rc = fgets(tbuffer, 256, fp);
-    fclose(fp);
+    rc = afsconf_fgets(tbuffer, 256, fp);
+    afsconf_fclose(fp);
     if (rc == NULL)
         return -1;
 
@@ -617,10 +706,25 @@ cm_enumCellRegistryProc(void *rockp, char * cellNamep)
 }
 #endif /* AFS_NT40_ENV */
 
-
+/**
+ * Load the cell configuration into memory.
+ *
+ * Read the cell configuration into a newly allocated or cleared afsconf_dir
+ * structure. Reads the CellServDB file, and if present, the cell alias file,
+ * the key files, and kerberos related files.
+ *
+ * If the configuration cannot be loaded for any reason, any partial changes
+ * are freed. The name member is preserved.
+ *
+ * @param[in,out] adir  pointer to the cell configuration
+ *                      the name member must be set to the pathname of the
+ *                      cell configuration to be loaded. All other members
+ *                      must be unassigned.
+ *
+ * @returns 0 on success
+ */
 static int
-afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
-		     char clones[])
+LoadConfig(struct afsconf_dir *adir)
 {
     afsconf_FILE *tf;
     char *tp, *bp;
@@ -630,13 +734,12 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
     afs_int32 i;
     char tbuffer[256];
     struct stat tstat;
-    char *cellservDB;
 
 #ifdef AFS_NT40_ENV
     cm_enumCellRegistry_t enumCellRegistry = {0, 0};
 #endif /* AFS_NT40_ENV */
 
-    /* init the keys queue before any call to afsconf_CloseInternal() */
+    /* init the keys queue before any call to UnloadConfig() */
     _afsconf_InitKeys(adir);
 
     /* figure out the local cell name */
@@ -656,20 +759,20 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
     /* now parse the individual lines */
     curEntry = 0;
 
-    _afsconf_CellServDBPath(adir, &cellservDB);
+    _afsconf_CellServDBPath(adir->name, &adir->cellservDB);
 
 #ifdef AFS_NT40_ENV
     if (_afsconf_IsClientConfigDirectory(adir->name))
         enumCellRegistry.client = 1;
 #endif /* AFS_NT40_ENV */
 
-    if (!stat(cellservDB, &tstat)) {
+    if (!stat(adir->cellservDB, &tstat)) {
 	adir->timeRead = tstat.st_mtime;
     } else {
 	adir->timeRead = 0;
     }
 
-    tf = fopen(cellservDB, "r");
+    tf = afsconf_fopen(adir->cellservDB, "r");
     if (!tf) {
 	return -1;
     }
@@ -687,7 +790,7 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
      */
 
     while (1) {
-	tp = fgets(tbuffer, sizeof(tbuffer), tf);
+	tp = afsconf_fgets(tbuffer, sizeof(tbuffer), tf);
 	if (!tp)
 	    break;
 	TrimLine(tbuffer, sizeof tbuffer);	/* remove white space */
@@ -706,8 +809,8 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
 	    code =
 		ParseCellLine(tbuffer, curEntry->cellInfo.name, linkedcell);
 	    if (code) {
-		afsconf_CloseInternal(adir);
-		fclose(tf);
+		UnloadConfig(adir);
+		afsconf_fclose(tf);
 		free(curEntry);
 		return -1;
 	    }
@@ -716,24 +819,16 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
 	} else {
 	    /* new host in the current cell */
 	    if (!curEntry) {
-		afsconf_CloseInternal(adir);
-		fclose(tf);
+		UnloadConfig(adir);
+		afsconf_fclose(tf);
 		return -1;
 	    }
 	    i = curEntry->cellInfo.numServers;
 	    if (i < MAXHOSTSPERCELL) {
-		if (cell && !strcmp(cell, curEntry->cellInfo.name))
-		    code =
-			ParseHostLine(tbuffer,
-				      &curEntry->cellInfo.hostAddr[i],
-				      curEntry->cellInfo.hostName[i],
-				      &clones[i]);
-		else
-		    code =
-			ParseHostLine(tbuffer,
-				      &curEntry->cellInfo.hostAddr[i],
-				      curEntry->cellInfo.hostName[i], 0);
-
+		code = ParseHostLine(tbuffer,
+				     &curEntry->cellInfo.hostAddr[i],
+				     curEntry->cellInfo.hostName[i],
+				     &curEntry->cellInfo.clone[i]);
 		if (code) {
 		    if (code == AFSCONF_SYNTAX) {
 			for (bp = tbuffer; *bp != '\n'; bp++) {	/* Take out the <cr> from the buffer */
@@ -743,23 +838,22 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
 			*bp = '\0';
 			fprintf(stderr,
 				"Can't properly parse host line \"%s\" in configuration file %s\n",
-				tbuffer, cellservDB);
+				tbuffer, adir->cellservDB);
 		    }
 		    free(curEntry);
-		    fclose(tf);
-		    afsconf_CloseInternal(adir);
+		    afsconf_fclose(tf);
+		    UnloadConfig(adir);
 		    return -1;
 		}
 		curEntry->cellInfo.numServers = ++i;
 	    } else {
 		fprintf(stderr,
 			"Too many hosts for cell %s in configuration file %s\n",
-			curEntry->cellInfo.name, cellservDB);
+			curEntry->cellInfo.name, adir->cellservDB);
 	    }
 	}
     }
-    fclose(tf);			/* close the file now */
-    free(cellservDB);
+    afsconf_fclose(tf);			/* close the file now */
 
     /* end the last partially-completed cell */
     if (curEntry) {
@@ -783,11 +877,11 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
     strcompose(tbuffer, 256, adir->name, "/", AFSDIR_CELLALIAS_FILE,
 	(char *)NULL);
 
-    tf = fopen(tbuffer, "r");
+    tf = afsconf_fopen(tbuffer, "r");
     while (tf) {
 	char *aliasPtr;
 
-	tp = fgets(tbuffer, sizeof(tbuffer), tf);
+	tp = afsconf_fgets(tbuffer, sizeof(tbuffer), tf);
 	if (!tp)
 	    break;
 	TrimLine(tbuffer, sizeof tbuffer);	/* remove white space */
@@ -822,7 +916,7 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
     }
 
     if (tf != NULL)
-	fclose(tf);
+	afsconf_fclose(tf);
 
     /* now read the fs keys, if possible */
     code = _afsconf_LoadKeys(adir);
@@ -841,7 +935,7 @@ afsconf_OpenInternal(struct afsconf_dir *adir, char *cell,
  */
 static int
 ParseHostLine(char *aline, struct sockaddr_in *addr, char *aname,
-	      char *aclone)
+	      char *aclone /* boolean */)
 {
     int i;
     int c[4];
@@ -955,18 +1049,15 @@ afsconf_GetExtendedCellInfo(struct afsconf_dir *adir, char *acellName,
 			    char clones[])
 {
     afs_int32 code;
-    char *cell;
+    int i;
 
     code = afsconf_GetCellInfo(adir, acellName, aservice, acellInfo);
     if (code)
 	return code;
 
-    if (acellName)
-	cell = acellName;
-    else
-	cell = (char *)&acellInfo->name;
-
-    code = afsconf_OpenInternal(adir, cell, clones);
+    for (i = 0; i < acellInfo->numServers; i++) {
+	clones[i] = acellInfo->clone[i];
+    }
     return code;
 }
 
@@ -1416,9 +1507,11 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice,
             short numServers=0;		                        /*Num active servers for the cell */
             struct sockaddr_in hostAddr[MAXHOSTSPERCELL];	/*IP addresses for cell's servers */
             char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];	/*Names for cell's servers */
+            char clone[MAXHOSTSPERCELL];			/*Indicates which ones are clones. */
 
             memset(&hostAddr, 0, sizeof(hostAddr));
             memset(&hostName, 0, sizeof(hostName));
+            memset(&clone, 0, sizeof(clone));
 
             for ( j=0; j<acellInfo->numServers && numServers < MAXHOSTSPERCELL; j++ ) {
                 struct hostent *he = gethostbyname(acellInfo->hostName[j]);
@@ -1447,6 +1540,7 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice,
 #endif
                         memcpy(&hostAddr[numServers].sin_addr.s_addr, he->h_addr_list[i], sizeof(afs_uint32));
                         strcpy(hostName[numServers], acellInfo->hostName[j]);
+                        clone[numServers] = acellInfo->clone[j];
                         foundAddr = 1;
                         numServers++;
                     }
@@ -1454,6 +1548,7 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice,
                 if (!foundAddr) {
                     hostAddr[numServers] = acellInfo->hostAddr[j];
                     strcpy(hostName[numServers], acellInfo->hostName[j]);
+                    clone[numServers] = acellInfo->clone[j];
                     numServers++;
                 }
             }
@@ -1461,6 +1556,7 @@ afsconf_GetCellInfo(struct afsconf_dir *adir, char *acellName, char *aservice,
             for (i=0; i<numServers; i++) {
                 acellInfo->hostAddr[i] = hostAddr[i];
                 strcpy(acellInfo->hostName[i], hostName[i]);
+                acellInfo->clone[i] = clone[i];
             }
             acellInfo->numServers = numServers;
             acellInfo->flags |= AFSCONF_CELL_FLAG_DNS_QUERIED;
@@ -1542,8 +1638,12 @@ afsconf_GetLocalCell(struct afsconf_dir *adir, char *aname, afs_int32 alen)
 int
 afsconf_Close(struct afsconf_dir *adir)
 {
+    if (adir == NULL) {
+	return 0;
+    }
+
     LOCK_GLOBAL_MUTEX;
-    afsconf_CloseInternal(adir);
+    UnloadConfig(adir);
     if (adir->name)
 	free(adir->name);
     free(adir);
@@ -1551,18 +1651,36 @@ afsconf_Close(struct afsconf_dir *adir)
     return 0;
 }
 
+/**
+ * Free members of a cell configuration, except the name.
+ *
+ * Free all of the memory allocated by the LoadConfig function and
+ * reset the afsconf_dir to zeros.  The pathname to the configuration
+ * is preserved to allow for a subquent call the LoadConfig to load
+ * a new configuration.
+ *
+ * @param[in,out] adir  pointer to the cell configuration
+ *
+ * @returns 0 on success
+ */
 static int
-afsconf_CloseInternal(struct afsconf_dir *adir)
+UnloadConfig(struct afsconf_dir *adir)
 {
     struct afsconf_entry *td, *nd;
     struct afsconf_aliasentry *ta, *na;
     char *tname;
 
+    if (adir == NULL) {
+	return 0;
+    }
+
     tname = adir->name;		/* remember name, since that's all we preserve */
 
     /* free everything we can find */
     if (adir->cellName)
 	free(adir->cellName);
+    if (adir->cellservDB)
+	free(adir->cellservDB);
     for (td = adir->entries; td; td = nd) {
 	nd = td->next;
 	if (td->cellInfo.linkedCell)
@@ -1587,9 +1705,206 @@ static int
 afsconf_Reopen(struct afsconf_dir *adir)
 {
     afs_int32 code;
-    code = afsconf_CloseInternal(adir);
+    code = UnloadConfig(adir);
     if (code)
 	return code;
-    code = afsconf_OpenInternal(adir, 0, 0);
+    code = LoadConfig(adir);
+    return code;
+}
+
+static int
+VerifyEntries(struct afsconf_cell *aci)
+{
+    int i;
+    struct hostent *th;
+
+    for (i = 0; i < aci->numServers; i++) {
+	if (aci->hostAddr[i].sin_addr.s_addr == 0) {
+	    /* no address spec'd */
+	    if (*(aci->hostName[i]) != 0) {
+		int code;
+		struct addrinfo hints;
+		struct addrinfo *result;
+		struct addrinfo *rp;
+
+		memset(&hints, 0, sizeof(struct addrinfo));
+		hints.ai_family = AF_INET;
+		hints.ai_socktype = SOCK_DGRAM;
+
+		code = getaddrinfo(aci->hostName[i], NULL, &hints, &result);
+		if (code) {
+		    printf("Host %s not found in host database...\n",
+			   aci->hostName[i]);
+		    return AFSCONF_FAILURE;
+		}
+		for (rp = result; rp != NULL; rp = rp->ai_next) {
+		    struct sockaddr_in *sa = (struct sockaddr_in *)rp->ai_addr;
+		    if (!rx_IsLoopbackAddr(ntohl(sa->sin_addr.s_addr))) {
+			aci->hostAddr[i].sin_addr.s_addr = sa->sin_addr.s_addr;
+			break;
+		    }
+		}
+		freeaddrinfo(result);
+		if (aci->hostAddr[i].sin_addr.s_addr == 0) {
+		    printf("No non-loopback addresses found for host %s\n",
+			   aci->hostName[i]);
+		    return AFSCONF_FAILURE;
+		}
+	    }
+	    /* otherwise we're deleting this entry */
+	} else {
+	    /* address spec'd, perhaps no name known */
+	    if (aci->hostName[i][0] != 0)
+		continue;	/* name known too */
+	    /* figure out name, if possible */
+	    th = gethostbyaddr((char *)(&aci->hostAddr[i].sin_addr), 4,
+			       AF_INET);
+	    if (!th) {
+		strcpy(aci->hostName[i], "UNKNOWNHOST");
+	    } else {
+		if (strlcpy(aci->hostName[i],
+			    th->h_name,
+			    sizeof(aci->hostName[i]))
+			>= sizeof(aci->hostName[i])) {
+		   strcpy(aci->hostName[i], "UNKNOWNHOST");
+		}
+	    }
+	}
+    }
+    return 0;
+}
+
+/**
+ * Set cell information (deprecated)
+ *
+ * Write ThisCell and CellServDB containing exactly one cell's info specified
+ * by acellInfo param.  Useful only on the server (which describes only one
+ * cell).
+ *
+ * @param adir       cell configuation data; may be NULL
+ * @param apath      cell configuration path
+ * @param acellInfo  cell information
+ *
+ * @note This interface was changed at some point to optionally accept the
+ *       afsconf_dir data structure.  This is a handle to the internal cache
+ *       that is maintained by the bosserver.
+ *
+ * @return 0 on success
+ */
+int
+afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
+		    struct afsconf_cell *acellInfo)
+{
+    afs_int32 code;
+
+    code = afsconf_SetExtendedCellInfo(adir, apath, acellInfo, NULL);
     return code;
 }
+
+/**
+ * Set cell information
+ *
+ * Write ThisCell and CellServDB containing exactly one cell's info specified
+ * by acellInfo param.  Useful only on the server (which describes only one
+ * cell).
+ *
+ * @param adir       cell configuation data; may be NULL
+ * @param apath      cell configuration path
+ * @param acellInfo  cell information
+ * @param clones     array of booleans to indicate which hosts are clones
+ *
+ * @return 0 on success
+ */
+int
+afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
+			    const char *apath,
+			    struct afsconf_cell *acellInfo, char clones[])
+{
+    afs_int32 code;
+    int fd;
+    char tbuffer[1024];
+    FILE *tf;
+    afs_int32 i;
+
+    opr_Assert(apath);
+    opr_Assert(acellInfo);
+
+    LOCK_GLOBAL_MUTEX;
+    /* write ThisCell file */
+    strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, (char *)NULL);
+
+    fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
+    if (fd < 0) {
+	UNLOCK_GLOBAL_MUTEX;
+	return errno;
+    }
+    i = (int)strlen(acellInfo->name);
+    code = write(fd, acellInfo->name, i);
+    if (code != i) {
+	close(fd);
+	UNLOCK_GLOBAL_MUTEX;
+	return AFSCONF_FAILURE;
+    }
+    if (close(fd) < 0) {
+	UNLOCK_GLOBAL_MUTEX;
+	return errno;
+    }
+
+    /* make sure we have both name and address for each host, looking up other
+     * if need be */
+    code = VerifyEntries(acellInfo);
+    if (code) {
+	UNLOCK_GLOBAL_MUTEX;
+	return code;
+    }
+
+    /* write CellServDB */
+    if (adir) {
+	tf = fopen(adir->cellservDB, "w");
+    } else {
+	char *cellservDB = NULL;
+	_afsconf_CellServDBPath(apath, &cellservDB);
+	if (cellservDB)
+	    tf = fopen(cellservDB, "w");
+	else
+	    tf = NULL;
+	free(cellservDB);
+    }
+    if (!tf) {
+	UNLOCK_GLOBAL_MUTEX;
+	return AFSCONF_NOTFOUND;
+    }
+    fprintf(tf, ">%s	#Cell name\n", acellInfo->name);
+    for (i = 0; i < acellInfo->numServers; i++) {
+	code = acellInfo->hostAddr[i].sin_addr.s_addr;	/* net order */
+	if (code == 0)
+	    continue;		/* delete request */
+	code = ntohl(code);	/* convert to host order */
+	if (clones && clones[i])
+	    fprintf(tf, "[%d.%d.%d.%d]  #%s\n", (code >> 24) & 0xff,
+		    (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff,
+		    acellInfo->hostName[i]);
+	else
+	    fprintf(tf, "%d.%d.%d.%d    #%s\n", (code >> 24) & 0xff,
+		    (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff,
+		    acellInfo->hostName[i]);
+    }
+    if (ferror(tf)) {
+	fclose(tf);
+	UNLOCK_GLOBAL_MUTEX;
+	return AFSCONF_FAILURE;
+    }
+    code = fclose(tf);
+
+    /* Reset the timestamp in the cache, so that
+     * the CellServDB is read into the cache next time.
+     * Resolves the lost update problem due to an inconsistent cache
+     */
+    if (adir)
+	adir->timeRead = 0;
+
+    UNLOCK_GLOBAL_MUTEX;
+    if (code == EOF)
+	return AFSCONF_FAILURE;
+    return 0;
+}
diff --git a/src/auth/cellconfig.p.h b/src/auth/cellconfig.p.h
index 3b91e01bf..2212f39b3 100644
--- a/src/auth/cellconfig.p.h
+++ b/src/auth/cellconfig.p.h
@@ -40,6 +40,8 @@ Creation date:
 #include <rx/rx_opaque.h>
 #include <opr/queue.h>
 
+#include <rx/rxgk_types.h>
+
 #define	MAXCELLCHARS	64
 #define	MAXHOSTCHARS	64
 #define MAXHOSTSPERCELL  8
@@ -58,6 +60,7 @@ struct afsconf_cell {
     short flags;		/* useful flags */
     struct sockaddr_in hostAddr[MAXHOSTSPERCELL];	/*IP addresses for cell's servers */
     char hostName[MAXHOSTSPERCELL][MAXHOSTCHARS];	/*Names for cell's servers */
+    char clone[MAXHOSTSPERCELL];			/*Indicates which ones are clones */
     char *linkedCell;		/* Linked cell name, if any */
     int timeout;		/* Data timeout, if non-zero */
 };
@@ -86,11 +89,15 @@ struct afsconf_aliasentry {
 #define AFSCONF_SECOPTS_LOCALAUTH     0x2
 #define AFSCONF_SECOPTS_ALWAYSENCRYPT 0x4
 #define AFSCONF_SECOPTS_FALLBACK_NULL 0x8
+#define AFSCONF_SECOPTS_NEVERENCRYPT  0x10
+#define AFSCONF_SECOPTS_ALWAYSCLEAR   0x20
+#define AFSCONF_SECOPTS_RXGK          0x40
 typedef afs_uint32 afsconf_secflags;
 
 struct afsconf_dir {
     char *name;			/* pointer to dir prefix */
     char *cellName;		/* cell name, if any, we're in */
+    char *cellservDB;		/* pathname of the CellServDB file */
     struct afsconf_entry *entries;	/* list of cell entries */
     struct opr_queue keyList;		/* list of keys */
     afs_int32 timeRead;		/* time stamp of file last read */
@@ -127,6 +134,10 @@ extern int afsconf_GetLocalCell(struct afsconf_dir *adir,
 				char *aname, afs_int32 alen);
 extern int afsconf_Close(struct afsconf_dir *adir);
 extern int afsconf_UpToDate(void *rock);
+int afsconf_SetExtendedCellInfo(struct afsconf_dir *adir, const char *apath,
+				struct afsconf_cell *acellInfo, char clones[]);
+int afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
+		        struct afsconf_cell *acellInfo);
 
 struct afsconf_keys;
 extern int afsconf_GetKeys(struct afsconf_dir *adir,
@@ -136,8 +147,13 @@ struct ktc_encryptionKey;
 extern afs_int32 afsconf_GetLatestKey(struct afsconf_dir *adir,
 				      afs_int32 * avno,
 				      struct ktc_encryptionKey *akey);
+extern afs_int32 afsconf_GetLatestRXGKKey(struct afsconf_dir *adir,
+					  afs_int32 *avno, afs_int32 *enctype,
+					  rxgk_key *key);
 extern int afsconf_GetKey(void *rock, int avno,
 			  struct ktc_encryptionKey *akey);
+extern int afsconf_GetRXGKKey(void *rock, afs_int32 *avno, afs_int32 *enctype,
+			      rxgk_key *key);
 extern int afsconf_AddKey(struct afsconf_dir *adir, afs_int32 akvno,
 			  char akey[8], afs_int32 overwrite);
 extern int afsconf_DeleteKey(struct afsconf_dir *adir, afs_int32 akvno);
@@ -168,6 +184,7 @@ extern void afsconf_typedKey_values(struct afsconf_typedKey *key,
 				  int *minorType,
 				  struct rx_opaque **keyMaterial);
 
+extern int afsconf_CountKeys(struct afsconf_dir *);
 extern int afsconf_GetAllKeys(struct afsconf_dir *,
 			      struct afsconf_typedKeyList **);
 extern int afsconf_GetKeysByType(struct afsconf_dir *dir,
@@ -203,6 +220,15 @@ extern afs_int32 afsconf_ClientAuth(void *arock,
 extern afs_int32 afsconf_ClientAuthSecure(void *arock,
 				          struct rx_securityClass **astr,
 				          afs_int32 * aindex);
+extern afs_int32 afsconf_ClientAuthRXGKClear(void *arock,
+					     struct rx_securityClass **aclass,
+					     afs_int32 *aindex);
+extern afs_int32 afsconf_ClientAuthRXGKAuth(void *arock,
+					    struct rx_securityClass **aclass,
+					    afs_int32 *aindex);
+extern afs_int32 afsconf_ClientAuthRXGKCrypt(void *arock,
+					     struct rx_securityClass **aclass,
+					     afs_int32 *aindex);
 
 
 extern afs_int32 afsconf_ClientAuthToken(struct afsconf_cell *info,
@@ -227,11 +253,6 @@ extern void afsconf_BuildServerSecurityObjects(void *,
 					       struct rx_securityClass ***,
 					       afs_int32 *);
 
-/* writeconfig.c */
-int afsconf_SetExtendedCellInfo(struct afsconf_dir *adir, const char *apath,
-				struct afsconf_cell *acellInfo, char clones[]);
-int afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
-		        struct afsconf_cell *acellInfo);
 
 
 /* userok.c */
diff --git a/src/auth/keys.c b/src/auth/keys.c
index 54ad95503..1c054933d 100644
--- a/src/auth/keys.c
+++ b/src/auth/keys.c
@@ -32,7 +32,11 @@
 /* Need rx/rx.h to get working assert(), used by LOCK_GLOBAL_MUTEX */
 #include <rx/rx.h>
 #include <rx/rx_atomic.h>
+#ifdef AFS_RXGK_ENV
+#include <rx/rxgk.h>
+#endif
 
+#include <afs/opr.h>
 #include <afs/stds.h>
 #include <afs/pthread_glock.h>
 #include <afs/afsutil.h>
@@ -768,6 +772,117 @@ afsconf_GetKey(void *rock, int kvno, struct ktc_encryptionKey *key)
     return 0;
 }
 
+static int
+_afsconf_GetLatestRXGKKey(afsconf_keyType type, struct afsconf_dir *rock,
+			  afs_int32 *avno, afs_int32 *enctype, rxgk_key *key)
+{
+#ifdef AFS_RXGK_ENV
+    struct afsconf_typedKeyList *list = NULL;
+    struct afsconf_typedKey *typedKey = NULL;
+    afs_int32 code;
+    int key_i;
+
+    code = afsconf_GetLatestKeysByType(rock, type, &list);
+    if (code != 0)
+	goto done;
+
+    for (key_i = 0; key_i < list->nkeys; key_i++) {
+	if (typedKey == NULL)
+	    typedKey = list->keys[key_i];
+	else if (rxgk_enctype_better(typedKey->subType, list->keys[key_i]->subType))
+	    typedKey = list->keys[key_i];
+    }
+
+    opr_Assert(typedKey != NULL);
+
+    /* We picked a key; copy to the output parameters */
+    code = rxgk_make_key(key, typedKey->key.val, typedKey->key.len,
+			 typedKey->subType);
+    if (code != 0)
+	goto done;
+    if (avno != NULL)
+	*avno = typedKey->kvno;
+    if (enctype != NULL)
+	*enctype = typedKey->subType;
+
+ done:
+    afsconf_PutTypedKeyList(&list);
+    return code;
+#else	/* AFS_RXGK_ENV */
+    return AFSCONF_NOTFOUND;
+#endif
+}
+
+/**
+ * Obtain the "best" rxgk key from KeyFileExt
+ *
+ * Return the key and its enctype and kvno, for encrypting outgoing tokens.
+ *
+ * @param[in] rock	The configuration directory to be used.
+ * @param[out] avno	The key version number of key.
+ * @param[out] enctype	The RFC 3961 enctype of key.
+ * @param[out] key	The returned rxgk key.
+ */
+int
+afsconf_GetLatestRXGKKey(struct afsconf_dir *rock, afs_int32 *avno,
+			 afs_int32 *enctype, rxgk_key *key)
+{
+    return _afsconf_GetLatestRXGKKey(afsconf_rxgk, rock, avno, enctype, key);
+}
+
+static int
+_afsconf_GetRXGKKey(afsconf_keyType type, void *rock, afs_int32 *avno,
+		    afs_int32 *enctype, rxgk_key *key)
+{
+#ifdef AFS_RXGK_ENV
+    struct afsconf_dir *dir = rock;
+    struct afsconf_typedKey *typedKey;
+    afs_int32 code;
+
+    /* No information at all means "pick the best/newest one". */
+    if (*avno == 0 && *enctype == 0)
+	return _afsconf_GetLatestRXGKKey(type, dir, avno, enctype, key);
+
+    code = afsconf_GetKeyByTypes(dir, type, *avno, *enctype, &typedKey);
+    if (code != 0)
+	return code;
+
+    code = rxgk_make_key(key, typedKey->key.val, typedKey->key.len,
+			 typedKey->subType);
+    afsconf_typedKey_put(&typedKey);
+
+    return code;
+#else	/* AFS_RXGK_ENV */
+    return AFSCONF_NOTFOUND;
+#endif
+}
+
+/**
+ * Obtain a particular RXGK key from KeyFileExt
+ *
+ * Use the specified kvno and enctype to fetch an rxgk key from KeyFileExt
+ * and return it as an rxgk_key.  Specifying the kvno/enctype pair as both
+ * zeros causes the "best" rxgk key to be returned, and the kvno/enctype
+ * of that key returned to the caller.
+ *
+ * @param[in] rock      An afsconf_dir* for the configuration directory. This
+ *			is a void* just so this can be easily used as a
+ *			callback function that uses a void* rock.
+ * @param[inout] avno	The requested kvno (if non-zero), or zero to request
+ *			the latest key and have its kvno returned in this
+ *			parameter.
+ * @param[inout] enctype	The requested enctype (if non-zero), or zero
+ *				to request the latest key and have its
+ *				enctype returned in this parameter.
+ * @param[out] key	The returned rxgk key.
+ */
+int
+afsconf_GetRXGKKey(void *rock, afs_int32 *avno,
+		   afs_int32 *enctype, rxgk_key *key)
+{
+    return _afsconf_GetRXGKKey(afsconf_rxgk, rock, avno, enctype, key);
+}
+
 int
 afsconf_AddKey(struct afsconf_dir *dir, afs_int32 kvno, char key[8],
 	       afs_int32 overwrite)
@@ -821,6 +936,39 @@ out:
     return code;
 }
 
+int
+_afsconf_CountKeys(struct afsconf_dir *dir)
+{
+    int count = 0;
+    struct opr_queue *typeCursor;
+    struct keyTypeList *typeEntry;
+    struct opr_queue *kvnoCursor;
+    struct kvnoList *kvnoEntry;
+    struct opr_queue *subCursor;
+
+    for (opr_queue_Scan(&dir->keyList, typeCursor)) {
+	typeEntry = opr_queue_Entry(typeCursor, struct keyTypeList, link);
+	for (opr_queue_Scan(&typeEntry->kvnoList, kvnoCursor)) {
+	    kvnoEntry = opr_queue_Entry(kvnoCursor, struct kvnoList, link);
+	    for (opr_queue_Scan(&kvnoEntry->subTypeList, subCursor))
+		count++;
+	}
+    }
+    return count;
+}
+
+int
+afsconf_CountKeys(struct afsconf_dir *dir)
+{
+    int count = 0;
+
+    LOCK_GLOBAL_MUTEX;
+    count = _afsconf_CountKeys(dir);
+    UNLOCK_GLOBAL_MUTEX;
+
+    return count;
+}
+
 int
 afsconf_GetAllKeys(struct afsconf_dir *dir, struct afsconf_typedKeyList **keys)
 {
@@ -840,16 +988,8 @@ afsconf_GetAllKeys(struct afsconf_dir *dir, struct afsconf_typedKeyList **keys)
     if (code)
 	goto out;
 
-    count = 0;
     /* First, work out how many keys we have in total */
-    for (opr_queue_Scan(&dir->keyList, typeCursor)) {
-	typeEntry = opr_queue_Entry(typeCursor, struct keyTypeList, link);
-	for (opr_queue_Scan(&typeEntry->kvnoList, kvnoCursor)) {
-	    kvnoEntry = opr_queue_Entry(kvnoCursor, struct kvnoList, link);
-	    for (opr_queue_Scan(&kvnoEntry->subTypeList, subCursor))
-		count++;
-	}
-    }
+    count = _afsconf_CountKeys(dir);
 
     /* Allocate space for all of these */
     retval = malloc(sizeof(struct afsconf_typedKeyList));
@@ -1006,6 +1146,10 @@ afsconf_PutTypedKeyList(struct afsconf_typedKeyList **keys)
 {
      int i;
 
+     if (*keys == NULL) {
+        return;
+     }
+
      for (i=0;i<(*keys)->nkeys;i++)
 	afsconf_typedKey_put(&((*keys)->keys[i]));
 
diff --git a/src/auth/ktc.c b/src/auth/ktc.c
index b53479a2e..c04bc863b 100644
--- a/src/auth/ktc.c
+++ b/src/auth/ktc.c
@@ -118,9 +118,7 @@ int afs_tf_dest_tkt(void);
 static void ktc_LocalCell(void);
 #endif /* AFS_KERBEROS_ENV */
 
-#ifdef AFS_DUX40_ENV
-#define PIOCTL afs_pioctl
-#elif defined(UKERNEL)
+#if defined(UKERNEL)
 #define PIOCTL(A,B,C,D) (errno = (call_syscall(AFSCALL_PIOCTL,A,B,C,D)), errno?-1:0)
 #else
 #define PIOCTL pioctl
@@ -180,8 +178,9 @@ SetToken(struct ktc_principal *aserver, struct ktc_token *atoken,
 			0)) {
 		    found = i;	/* replace existing entry */
 		    break;
-		} else		/* valid, but no match */
-		    ;
+		} else {
+		    /* valid, but no match */
+		}
 	    } else
 		found = i;	/* remember this empty slot */
 	if (found == -1)
@@ -298,6 +297,15 @@ SetToken(struct ktc_principal *aserver, struct ktc_token *atoken,
 #endif /* NO_AFS_CLIENT */
     if (code)
 	return KTC_PIOCTLFAIL;
+#if defined(AFS_LINUX26_ENV) && defined(SYS_keyctl)
+    else
+        /*
+         * If we're using keyring based PAGs and the SESSION_TO_PARENT keyctl
+         * is available, use it to copy the session keyring to the parent process
+         */
+        if (flags & AFS_SETTOK_SETPAG)
+            syscall(SYS_keyctl, KEYCTL_SESSION_TO_PARENT);
+#endif
     return 0;
 }
 
@@ -795,6 +803,9 @@ ktc_ListTokensEx(int prevIndex, int *newIndex, char **cellName) {
 
 	code = PIOCTL(0, VIOC_GETTOK2, &iob, 0);
 
+	if (code == -1 && errno == EDOM)
+	    return KTC_NOENT;	/* no more tokens to be found */
+
 	/* Can't use new pioctl, so must use old one */
 	if (code == -1 && errno == EINVAL) {
 	    struct ktc_principal server;
@@ -1108,11 +1119,6 @@ ktc_curpag(void)
   * <mit-copyright.h>.
   */
 
-#if 0
-#include <sys/file.h>
-#include <krb.h>
-#endif
-
 #define TOO_BIG -1
 #define TF_LCK_RETRY ((unsigned)2)	/* seconds to sleep before
 					 * retry if ticket file is
diff --git a/src/auth/ktc_nt.c b/src/auth/ktc_nt.c
index 8a9172050..36575be80 100644
--- a/src/auth/ktc_nt.c
+++ b/src/auth/ktc_nt.c
@@ -650,12 +650,8 @@ ktc_GetTokenEx(char *cellName, struct ktc_setTokenData **tokenSet) {
 	}
     }
 
-#if 0
-    code = pioctl(0, VIOC_GETTOK2, &iob, 0);
-#else
-    code = -1;   /* not yet implemented */
-	errno = EINVAL;
-#endif
+    code = -1;   /* VIOC_GETTOK2 not yet implemented */
+    errno = EINVAL;
 
     ReleaseMutex(ktcMutex);
     CloseHandle(ktcMutex);
@@ -1084,12 +1080,8 @@ ktc_ListTokensEx(int prevIndex, int *newIndex, char **cellName) {
 	iob.out = tbuffer;
 	iob.out_size = sizeof(tbuffer);
 
-#if 0
-	code = pioctl(0, VIOC_GETTOK2, &iob, 0);
-#else
-    code = -1;      /* not yet implemented */
+	code = -1;      /* VIOC_GETTOK2 not yet implemented */
 	errno = EINVAL;
-#endif
 
 	/* Can't use new pioctl, so must use old one */
 	if (code == -1 && errno == EINVAL) {
diff --git a/src/auth/liboafs_auth.la.sym b/src/auth/liboafs_auth.la.sym
index 5497f994a..561ddfa5f 100644
--- a/src/auth/liboafs_auth.la.sym
+++ b/src/auth/liboafs_auth.la.sym
@@ -5,9 +5,13 @@ afsconf_CellApply
 afsconf_CheckAuth
 afsconf_CheckRestrictedQuery
 afsconf_ClientAuth
+afsconf_ClientAuthRXGKAuth
+afsconf_ClientAuthRXGKClear
+afsconf_ClientAuthRXGKCrypt
 afsconf_ClientAuthSecure
 afsconf_ClientAuthToken
 afsconf_Close
+afsconf_CountKeys
 afsconf_DeleteKey
 afsconf_GetAfsdbInfo
 afsconf_GetAllKeys
@@ -15,8 +19,10 @@ afsconf_GetCellInfo
 afsconf_GetExtendedCellInfo
 afsconf_GetKey
 afsconf_GetLatestKey
+afsconf_GetLatestRXGKKey
 afsconf_GetLocalCell
 afsconf_GetNoAuthFlag
+afsconf_GetRXGKKey
 afsconf_IsLocalRealmMatch
 afsconf_Open
 afsconf_ParseNetFiles
diff --git a/src/auth/realms.c b/src/auth/realms.c
index db5fd31b8..6508047ad 100644
--- a/src/auth/realms.c
+++ b/src/auth/realms.c
@@ -411,11 +411,13 @@ _afsconf_FreeRealms(struct afsconf_dir *dir)
 	if (dir->local_realms) {
 	    destroy_tree(dir->local_realms);
 	    free_realm_entries(&dir->local_realms->list);
+	    free(dir->local_realms);
 	    dir->local_realms = NULL;
 	}
 	if (dir->exclusions) {
 	    destroy_tree(dir->exclusions);
 	    free_realm_entries(&dir->exclusions->list);
+	    free(dir->exclusions);
 	    dir->exclusions = NULL;
 	}
     }
@@ -485,10 +487,12 @@ _afsconf_LoadRealms(struct afsconf_dir *dir)
     if (local_realms) {
 	destroy_tree(local_realms);
 	free_realm_entries(&local_realms->list);
+	free(local_realms);
     }
     if (exclusions) {
 	destroy_tree(dir->exclusions);
 	free_realm_entries(&exclusions->list);
+	free(exclusions);
     }
     return code;
 }
diff --git a/src/auth/test/.gitignore b/src/auth/test/.gitignore
index d9008e83c..3ec50a71d 100644
--- a/src/auth/test/.gitignore
+++ b/src/auth/test/.gitignore
@@ -1,3 +1,4 @@
 /ktctest
 /testcellconf
+/testnetrestrict
 
diff --git a/src/auth/test/Makefile.in b/src/auth/test/Makefile.in
index ee8ebdedd..57407c766 100644
--- a/src/auth/test/Makefile.in
+++ b/src/auth/test/Makefile.in
@@ -8,13 +8,16 @@
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
+top_builddir=@top_builddir@
 
 LT_deps = \
 	$(TOP_OBJDIR)/src/auth/liboafs_auth.la \
 	$(TOP_OBJDIR)/src/sys/liboafs_sys.la \
 	$(TOP_OBJDIR)/src/rx/liboafs_rx.la \
 	$(TOP_OBJDIR)/src/util/liboafs_util.la \
-	$(TOP_OBJDIR)/src/opr/liboafs_opr.la
+	$(TOP_OBJDIR)/src/opr/liboafs_opr.la \
+	$(TOP_OBJDIR)/src/cmd/liboafs_cmd.la
 LT_libs = $(LDFLAGS_roken) $(LIB_roken)
 
 tests all: testcellconf ktctest testnetrestrict
@@ -25,12 +28,12 @@ testcellconf: testcellconf.lo
 ktctest: ktctest.lo
 	$(LT_LDRULE_static) ktctest.lo $(LT_deps) $(LT_libs)
 
-testnetrestrict: testnetrestrict.o
-	$(AFS_LDRULE) testnetrestrict.o $(TOP_LIBDIR)/libauth.a $(TOP_LIBDIR)/libopr.a
+testnetrestrict: testnetrestrict.lo
+	$(LT_LDRULE_static) testnetrestrict.lo $(LT_deps) $(LT_libs)
 
 clean:
 	$(LT_CLEAN)
-	$(RM) -f copyauth testcellconf ktctest setkey auth.h cellconfig.h acfg_errors.c ktc_errors.c core
+	$(RM) -f *.o copyauth testcellconf ktctest testnetrestrict core
 
 install:
 
diff --git a/src/auth/test/testcellconf.c b/src/auth/test/testcellconf.c
index cff88768f..a16a9dd19 100644
--- a/src/auth/test/testcellconf.c
+++ b/src/auth/test/testcellconf.c
@@ -30,6 +30,7 @@ Creation date:
 #include <stddef.h>
 #include <stdlib.h>
 #include <stdio.h>
+#include <unistd.h>
 #include <afs/afsutil.h>
 #ifdef AFS_NT40_ENV
 #include <winsock2.h>
@@ -37,8 +38,17 @@ Creation date:
 #include <netinet/in.h>
 #endif
 #include <afs/cellconfig.h>
+#include <afs/cmd.h>
 
-int 
+int _afsconf_Touch(struct afsconf_dir *adir);
+
+enum optionsList {
+    OPT_confdir,
+    OPT_cell,
+    OPT_reload
+};
+
+static int
 PrintOneCell(struct afsconf_cell *ainfo, void *arock, struct afsconf_dir *adir)
 {
     int i;
@@ -47,51 +57,60 @@ PrintOneCell(struct afsconf_cell *ainfo, void *arock, struct afsconf_dir *adir)
     printf("Cell %s:\n", ainfo->name);
     for (i = 0; i < ainfo->numServers; i++) {
 	memcpy(&temp, &ainfo->hostAddr[i].sin_addr, sizeof(long));
-	printf("    host %s at %lx.%x\n", ainfo->hostName[i], temp,
-	       ainfo->hostAddr[i].sin_port);
+	printf(" %d host %s at %lx port %x clone %s\n", i, ainfo->hostName[i], temp,
+	       ainfo->hostAddr[i].sin_port, (ainfo->clone[i] ? "yes" : "no"));
     }
     return 0;
 }
 
-/*Main for testcellconfig*/
-int
-main(int argc, char *argv[])
+static void
+PrintClones(char *clones, int numServers)
+{
+    int i;
+
+    printf("Clones:\n");
+    for (i = 0; i < numServers; i++) {
+	printf(" %d clone %s\n", i, (clones[i] ? "yes" : "no"));
+    }
+}
+
+static int
+TestCellConfig(struct cmd_syndesc *as, void *arock)
 {
     struct afsconf_dir *theDir;
     char tbuffer[1024];
     struct afsconf_cell theCell;
-    long i;
-    long code;
-    char *dirName;
+    int code;
+    char *dirName = NULL;
+    char clones[MAXHOSTSPERCELL];
+    int reload = 0;
+    struct cmd_item *cells = NULL;
 
-#ifdef AFS_NT40_ENV
-    WSADATA WSAjunk;
-    /* Start up sockets */
-    WSAStartup(0x0101, &WSAjunk);
-#endif /* AFS_NT40_ENV */
+    memset(clones, 0, sizeof(clones));
 
-    if (argc < 2) {
-	printf
-	    ("usage: testcellconfig <conf-dir-name> [<cell-to-display>]*\n");
-	exit(1);
-    }
+    cmd_OptionAsString(as, OPT_confdir, &dirName);
+    reload = cmd_OptionPresent(as, OPT_reload);
 
-    dirName = argv[1];
+    if (!dirName)
+	dirName = strdup(AFSDIR_SERVER_ETC_DIRPATH);
     theDir = afsconf_Open(dirName);
     if (!theDir) {
 	printf("could not open configuration files in '%s'\n", dirName);
-	exit(1);
+	free(dirName);
+	return 1;
     }
 
     /* get the cell */
     code = afsconf_GetLocalCell(theDir, tbuffer, sizeof(tbuffer));
     if (code != 0) {
-	printf("get local cell failed, code %ld\n", code);
-	exit(1);
+	printf("get local cell failed, code %d\n", code);
+	afsconf_Close(theDir);
+	free(dirName);
+	return 1;
     }
     printf("Local cell is '%s'\n\n", tbuffer);
 
-    if (argc == 2) {
+    if (cmd_OptionAsList(as, OPT_cell, &cells) != 0) {
 	printf("About to print cell database contents:\n");
 	afsconf_CellApply(theDir, PrintOneCell, 0);
 	printf("Done.\n\n");
@@ -99,11 +118,19 @@ main(int argc, char *argv[])
 	printf("start of special test\n");
 	code = afsconf_GetCellInfo(theDir, NULL, "afsprot", &theCell);
 	if (code)
-	    printf("failed to find afsprot service (%ld)\n", code);
+	    printf("failed to find afsprot service (%d)\n", code);
 	else {
 	    printf("AFSPROT service:\n");
 	    PrintOneCell(&theCell, NULL, theDir);
 	}
+	code = afsconf_GetExtendedCellInfo(theDir, NULL, "afsprot", &theCell, clones);
+	if (code) {
+	    printf("failed to find extended cell info (%d)\n", code);
+	} else {
+	    printf("AFSPROT service extended info:\n");
+	    PrintOneCell(&theCell, NULL, theDir);
+	    PrintClones(clones, theCell.numServers);
+	}
 	code = afsconf_GetCellInfo(theDir, 0, "bozotheclown", &theCell);
 	if (code == 0)
 	    printf("unexpectedly found service 'bozotheclown'\n");
@@ -112,17 +139,69 @@ main(int argc, char *argv[])
 	PrintOneCell(&theCell, NULL, theDir);
 	printf("done with special test\n");
     } else {
-	/* now print out specified cell info */
-	for (i = 2; i < argc; i++) {
-	    code = afsconf_GetCellInfo(theDir, argv[i], 0, &theCell);
+	/* Now print out specified cell info. */
+	for (; cells != NULL; cells = cells->next) {
+	    char *cell = cells->data;
+	    code = afsconf_GetCellInfo(theDir, cell, 0, &theCell);
 	    if (code) {
-		printf("Could not find info for cell '%s', code %ld\n",
-		       argv[i], code);
+		printf("Could not find info for cell '%s', code %d\n",
+		       cell, code);
 	    } else
 		PrintOneCell(&theCell, NULL, theDir);
+
+	    /* And print extended cell info. */
+	    memset(clones, 0, sizeof(clones));
+	    code = afsconf_GetExtendedCellInfo(theDir, cell, "afsprot", &theCell, clones);
+	    if (code) {
+		printf("Could not find extended info for cell '%s', code %d\n",
+		       cell, code);
+	    } else {
+		PrintOneCell(&theCell, NULL, theDir);
+		PrintClones(clones, theCell.numServers);
+	    }
+	}
+    }
+
+    if (reload) {
+	printf("Forcing reload\n");
+	code = _afsconf_Touch(theDir);
+	if (code) {
+	    printf("Unable to touch cellservdb file (%d)\n", code);
+	} else {
+	    sleep(2);
+	    code = afsconf_GetCellInfo(theDir, NULL, "afsprot", &theCell);
+	    if (code)
+		printf("failed to find afsprot service (%d)\n", code);
+	    else
+		PrintOneCell(&theCell, NULL, theDir);
 	}
     }
 
     /* all done */
-    exit(0);
+    afsconf_Close(theDir);
+    free(dirName);
+    return 0;
+}
+
+
+int
+main(int argc, char *argv[])
+{
+    afs_int32 code;
+    struct cmd_syndesc *ts;
+
+#ifdef AFS_NT40_ENV
+    WSADATA WSAjunk;
+    /* Start up sockets */
+    WSAStartup(0x0101, &WSAjunk);
+#endif /* AFS_NT40_ENV */
+
+    ts = cmd_CreateSyntax("initcmd", TestCellConfig, NULL, 0, "Test cell configuration");
+    cmd_AddParmAtOffset(ts, OPT_confdir, "-confdir", CMD_SINGLE, CMD_OPTIONAL,
+		"Configuration directory pathname");
+    cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_LIST, CMD_OPTIONAL, "Cell to display");
+    cmd_AddParmAtOffset(ts, OPT_reload, "-reload", CMD_FLAG, CMD_OPTIONAL, "Perform reload test");
+
+    code = cmd_Dispatch(argc, argv);
+    return code;
 }
diff --git a/src/auth/test/testnetrestrict.c b/src/auth/test/testnetrestrict.c
index 26ff9578a..6bd1f8a40 100644
--- a/src/auth/test/testnetrestrict.c
+++ b/src/auth/test/testnetrestrict.c
@@ -17,6 +17,10 @@
 
 char *interfaceList, *filenameNetInfo, *filenameNetRestrict;
 
+/* Prototype for a deprecated function. */
+int afsconf_ParseNetInfoFile(afs_uint32 outAddrs[], afs_uint32 outMask[], afs_uint32 outMtu[],
+			 int max, char reason[], const char *fileName);
+
 int
 rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[],
 		     afs_uint32 maskBuffer[],
diff --git a/src/auth/userok.c b/src/auth/userok.c
index fdb3038f1..52afca3e5 100644
--- a/src/auth/userok.c
+++ b/src/auth/userok.c
@@ -20,6 +20,9 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rx_identity.h>
+#ifdef AFS_RXGK_ENV
+# include <rx/rxgk.h>
+#endif
 #include <afs/afsutil.h>
 #include <afs/fileutil.h>
 
@@ -513,6 +516,9 @@ afsconf_IsSuperIdentity(struct afsconf_dir *adir,
     int match;
     afs_int32 code;
 
+    if (user->kind == RX_ID_SUPERUSER)
+	return 1;
+
     tbuffer = malloc(AFSDIR_PATH_MAX);
     if (tbuffer == NULL)
 	return 0;
@@ -720,6 +726,32 @@ rxkadSuperUser(struct afsconf_dir *adir, struct rx_call *acall,
     return kerberosSuperUser(adir, tname, tinst, tcell, identity);
 }
 
+#ifdef AFS_RXGK_ENV
+static int
+rxgkSuperUser(struct afsconf_dir *adir, struct rx_call *acall,
+	      struct rx_identity **identity_out)
+{
+    struct rx_identity *identity = NULL;
+    int is_super = 0;
+
+    if (rxgk_GetServerInfo(rx_ConnectionOf(acall), NULL /*level*/, NULL /*expiry*/,
+                           &identity) != 0)
+        return 0;
+
+    if (afsconf_IsSuperIdentity(adir, identity)) {
+        is_super = 1;
+        if (identity_out != NULL) {
+            *identity_out = identity;
+            identity = NULL;
+        }
+    }
+    if (identity != NULL) {
+        rx_identity_free(&identity);
+    }
+    return is_super;
+}
+#endif /* AFS_RXGK_ENV */
+
 /*!
  * Check whether the user authenticated on a given RX call is a super
  * user or not. If they are, return a pointer to the identity of that
@@ -770,6 +802,12 @@ afsconf_SuperIdentity(struct afsconf_dir *adir, struct rx_call *acall,
 	flag = rxkadSuperUser(adir, acall, identity);
 	UNLOCK_GLOBAL_MUTEX;
 	return flag;
+#ifdef AFS_RXGK_ENV
+    } else if (code == RX_SECIDX_GK) {
+	flag = rxgkSuperUser(adir, acall, identity);
+	UNLOCK_GLOBAL_MUTEX;
+	return flag;
+#endif
     } else {			/* some other auth type */
 	UNLOCK_GLOBAL_MUTEX;
 	return 0;		/* mysterious, just say no */
diff --git a/src/auth/writeconfig.c b/src/auth/writeconfig.c
deleted file mode 100644
index 5655dba77..000000000
--- a/src/auth/writeconfig.c
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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>
-
-#include <roken.h>
-#include <afs/opr.h>
-
-#include <afs/pthread_glock.h>
-#include <afs/afsutil.h>
-#include <rx/rxkad.h>
-
-#include "cellconfig.h"
-#include "keys.h"
-
-/* write ThisCell and CellServDB containing exactly one cell's info specified
-    by acellInfo parm.   Useful only on the server (which describes only one cell).
-*/
-
-static int
-VerifyEntries(struct afsconf_cell *aci)
-{
-    int i;
-    struct hostent *th;
-
-    for (i = 0; i < aci->numServers; i++) {
-	if (aci->hostAddr[i].sin_addr.s_addr == 0) {
-	    /* no address spec'd */
-	    if (*(aci->hostName[i]) != 0) {
-		int code;
-		struct addrinfo hints;
-		struct addrinfo *result;
-		struct addrinfo *rp;
-
-		memset(&hints, 0, sizeof(struct addrinfo));
-		hints.ai_family = AF_INET;
-		hints.ai_socktype = SOCK_DGRAM;
-
-		code = getaddrinfo(aci->hostName[i], NULL, &hints, &result);
-		if (code) {
-		    printf("Host %s not found in host database...\n",
-			   aci->hostName[i]);
-		    return AFSCONF_FAILURE;
-		}
-		for (rp = result; rp != NULL; rp = rp->ai_next) {
-		    struct sockaddr_in *sa = (struct sockaddr_in *)rp->ai_addr;
-		    if (!rx_IsLoopbackAddr(ntohl(sa->sin_addr.s_addr))) {
-			aci->hostAddr[i].sin_addr.s_addr = sa->sin_addr.s_addr;
-			break;
-		    }
-		}
-		freeaddrinfo(result);
-		if (aci->hostAddr[i].sin_addr.s_addr == 0) {
-		    printf("No non-loopback addresses found for host %s\n",
-			   aci->hostName[i]);
-		    return AFSCONF_FAILURE;
-		}
-	    }
-	    /* otherwise we're deleting this entry */
-	} else {
-	    /* address spec'd, perhaps no name known */
-	    if (aci->hostName[i][0] != 0)
-		continue;	/* name known too */
-	    /* figure out name, if possible */
-	    th = gethostbyaddr((char *)(&aci->hostAddr[i].sin_addr), 4,
-			       AF_INET);
-	    if (!th) {
-		strcpy(aci->hostName[i], "UNKNOWNHOST");
-	    } else {
-		if (strlcpy(aci->hostName[i],
-			    th->h_name,
-			    sizeof(aci->hostName[i]))
-			>= sizeof(aci->hostName[i])) {
-		   strcpy(aci->hostName[i], "UNKNOWNHOST");
-		}
-	    }
-	}
-    }
-    return 0;
-}
-
-/* Changed the interface to accept the afsconf_dir datastructure.
-   This is a handle to the internal cache that is maintained by the bosserver.
-   */
-
-int
-afsconf_SetCellInfo(struct afsconf_dir *adir, const char *apath,
-		    struct afsconf_cell *acellInfo)
-{
-    afs_int32 code;
-
-    code = afsconf_SetExtendedCellInfo(adir, apath, acellInfo, NULL);
-    return code;
-}
-
-int
-afsconf_SetExtendedCellInfo(struct afsconf_dir *adir,
-			    const char *apath,
-			    struct afsconf_cell *acellInfo, char clones[])
-{
-    afs_int32 code;
-    int fd;
-    char tbuffer[1024];
-    FILE *tf;
-    afs_int32 i;
-
-    LOCK_GLOBAL_MUTEX;
-    /* write ThisCell file */
-    strcompose(tbuffer, 1024, apath, "/", AFSDIR_THISCELL_FILE, (char *)NULL);
-
-    fd = open(tbuffer, O_RDWR | O_CREAT | O_TRUNC, 0666);
-    if (fd < 0) {
-	UNLOCK_GLOBAL_MUTEX;
-	return errno;
-    }
-    i = (int)strlen(acellInfo->name);
-    code = write(fd, acellInfo->name, i);
-    if (code != i) {
-	UNLOCK_GLOBAL_MUTEX;
-	return AFSCONF_FAILURE;
-    }
-    if (close(fd) < 0) {
-	UNLOCK_GLOBAL_MUTEX;
-	return errno;
-    }
-
-    /* make sure we have both name and address for each host, looking up other
-     * if need be */
-    code = VerifyEntries(acellInfo);
-    if (code) {
-	UNLOCK_GLOBAL_MUTEX;
-	return code;
-    }
-
-    /* write CellServDB */
-    strcompose(tbuffer, 1024, apath, "/", AFSDIR_CELLSERVDB_FILE, (char *)NULL);
-    tf = fopen(tbuffer, "w");
-    if (!tf) {
-	UNLOCK_GLOBAL_MUTEX;
-	return AFSCONF_NOTFOUND;
-    }
-    fprintf(tf, ">%s	#Cell name\n", acellInfo->name);
-    for (i = 0; i < acellInfo->numServers; i++) {
-	code = acellInfo->hostAddr[i].sin_addr.s_addr;	/* net order */
-	if (code == 0)
-	    continue;		/* delete request */
-	code = ntohl(code);	/* convert to host order */
-	if (clones && clones[i])
-	    fprintf(tf, "[%d.%d.%d.%d]  #%s\n", (code >> 24) & 0xff,
-		    (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff,
-		    acellInfo->hostName[i]);
-	else
-	    fprintf(tf, "%d.%d.%d.%d    #%s\n", (code >> 24) & 0xff,
-		    (code >> 16) & 0xff, (code >> 8) & 0xff, code & 0xff,
-		    acellInfo->hostName[i]);
-    }
-    if (ferror(tf)) {
-	fclose(tf);
-	UNLOCK_GLOBAL_MUTEX;
-	return AFSCONF_FAILURE;
-    }
-    code = fclose(tf);
-
-    /* Reset the timestamp in the cache, so that
-     * the CellServDB is read into the cache next time.
-     * Resolves the lost update problem due to an inconsistent cache
-     */
-    if (adir)
-	adir->timeRead = 0;
-
-    UNLOCK_GLOBAL_MUTEX;
-    if (code == EOF)
-	return AFSCONF_FAILURE;
-    return 0;
-}
diff --git a/src/bozo/.gitignore b/src/bozo/.gitignore
index 9d9c80095..e0d0a4609 100644
--- a/src/bozo/.gitignore
+++ b/src/bozo/.gitignore
@@ -8,5 +8,4 @@
 /boserr.c
 /bosint.h
 /bosserver
-/smail-notifier
 /test/testproc
diff --git a/src/bozo/Makefile.in b/src/bozo/Makefile.in
index 6b24f055d..a8916cc26 100644
--- a/src/bozo/Makefile.in
+++ b/src/bozo/Makefile.in
@@ -45,8 +45,7 @@ LIBS=   ${TOP_LIBDIR}/librx.a \
 OBJS=bosserver.o bnode.o ezbnodeops.o fsbnodeops.o bosint.ss.o bosint.xdr.o \
 bosoprocs.o cronbnodeops.o
 
-all: bosserver ${TOP_INCDIR}/afs/bosint.h bos ${TOP_LIBDIR}/libbos.a bos_util \
-    smail-notifier
+all: bosserver ${TOP_INCDIR}/afs/bosint.h bos ${TOP_LIBDIR}/libbos.a bos_util
 
 generated: bosint.ss.c bosint.xdr.c bosint.cs.c bosint.h bnode.h boserr.c
 
@@ -126,11 +125,6 @@ bosserver: $(OBJS) $(LIBS)
 	$(AFS_LDRULE) $(OBJS) \
 		$(LIBS) $(LIB_roken) $(LIB_crypt) ${XLIBS}
 
-smail-notifier.o: smail-notifier.c ${INCLS}
-
-smail-notifier: smail-notifier.o $(LIBS)
-	$(AFS_LDRULE) smail-notifier.o $(LIBS) $(LIB_roken) ${XLIBS}
-
 #
 # Install targets
 #
@@ -165,12 +159,13 @@ dest: bosserver bos bos_util libbos.a bosint.h bnode.h
 # Misc. targets
 #
 clean:
-	$(RM) -f  *.a *.o bos bosserver smail-notifier bos_util \
+	$(RM) -f  *.a *.o bos bosserver bos_util \
 		bosint.cs.c bosint.ss.c bosint.xdr.c bosint.h \
 		core boserr.c bnode.h AFS_component_version_number.c
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 include ../config/Makefile.version
 
diff --git a/src/bozo/bnode.c b/src/bozo/bnode.c
index d117311bd..9dab6d0e6 100644
--- a/src/bozo/bnode.c
+++ b/src/bozo/bnode.c
@@ -681,7 +681,7 @@ bproc(void *unused)
 	    }
 	}
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static afs_int32
@@ -706,10 +706,6 @@ SendNotifierData(int fd, struct bnode_proc *tp)
     bufp += strlen(bufp);
     (void)sprintf(bufp, "lastExit: %ld\n", afs_printable_int32_ld(tp->lastExit));
     bufp += strlen(bufp);
-#ifdef notdef
-    (void)sprintf(bufp, "lastSignal: %ld\n", afs_printable_int32_ld(tp->lastSignal));
-    bufp += strlen(bufp);
-#endif
     (void)sprintf(bufp, "flags: %ld\n", afs_printable_int32_ld(tp->flags));
     bufp += strlen(bufp);
     (void)sprintf(bufp, "END bnode_proc\n");
diff --git a/src/bozo/bos.c b/src/bozo/bos.c
index 0e2e3f45d..7bcd20afe 100644
--- a/src/bozo/bos.c
+++ b/src/bozo/bos.c
@@ -139,7 +139,7 @@ GetConn(struct cmd_syndesc *as, int aencrypt)
 	exit(1);
     }
 
-    if (scIndex == RX_SECIDX_NULL)
+    if (scIndex == RX_SECIDX_NULL && !(secFlags & AFSCONF_SECOPTS_NOAUTH))
 	fprintf(stderr, "bos: running unauthenticated\n");
 
     tconn =
diff --git a/src/bozo/bosserver.c b/src/bozo/bosserver.c
index f97745cf8..5346df0ca 100644
--- a/src/bozo/bosserver.c
+++ b/src/bozo/bosserver.c
@@ -633,7 +633,7 @@ BozoDaemon(void *unused)
 	    bnode_ApplyInstance(bdrestart, 0);
 	}
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 #ifdef AFS_AIX32_ENV
@@ -1116,6 +1116,12 @@ main(int argc, char **argv, char **envp)
     /* opened the cell databse */
     bozo_confdir = tdir;
 
+    if (afsconf_CountKeys(bozo_confdir) == 0) {
+	bozo_Log("WARNING: No encryption keys found! "
+		 "All authenticated accesses will fail. "
+		 "Run akeyconvert or asetkey to import encryption keys.\n");
+    }
+
     code = bnode_Init();
     if (code) {
 	printf("bosserver: could not init bnode package, code %d\n", code);
@@ -1153,11 +1159,7 @@ main(int argc, char **argv, char **envp)
 	host = GetRxBindAddress();
     }
     for (i = 0; i < 10; i++) {
-	if (rxBind) {
-	    code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
-	} else {
-	    code = rx_Init(htons(AFSCONF_NANNYPORT));
-	}
+	code = rx_InitHost(host, htons(AFSCONF_NANNYPORT));
 	if (code) {
 	    bozo_Log("can't initialize rx: code=%d\n", code);
 	    sleep(3);
@@ -1214,8 +1216,12 @@ main(int argc, char **argv, char **envp)
     rx_SetMaxProcs(tservice, 4);
     rx_SetStackSize(tservice, BOZO_LWP_STACKSIZE);	/* so gethostbyname works (in cell stuff) */
     if (rxkadDisableDotCheck) {
-        rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
-                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	code = rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
+					   (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	if (code) {
+	    bozo_Log("Failed to allow dotted principals: code %d\n", code);
+	    exit(1);
+	}
     }
 
     tservice =
@@ -1262,4 +1268,5 @@ bozo_Log(const char *format, ...)
 	    fclose(bozo_logFile);
 	}
     }
+    va_end(ap);
 }
diff --git a/src/bozo/smail-notifier.c b/src/bozo/smail-notifier.c
deleted file mode 100644
index e9a0aa6e0..000000000
--- a/src/bozo/smail-notifier.c
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * 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>
-#include <afs/stds.h>
-
-#include <roken.h>
-
-#include <afs/afsutil.h>
-#ifdef HAVE_SYS_WAIT_H
-#include <sys/wait.h>
-#endif
-
-/*
- * XXX CHANGE the following depedent stuff XXX
- */
-#define	SENDMAIL	"/afs/cellname/fs/dev/localtools/dest/bin/rcs-sendmail"
-/*
- * Replace it with  a bboard (i.e. transarc.bosserver.auto-reports)
- */
-#define	RECIPIENT	"foo@cellname"
-
-#include "AFS_component_version_number.c"
-
-int
-main(int argc, char **argv)
-{
-    struct stat tstat;
-    FILE *fin = stdin;
-    char buf[BUFSIZ], *bufp, *bufp1, *typep, *cmd, *bp;
-    afs_int32 code, c, fd, pflags = -1, len, core = 0;
-    char comLine[60], coreName[40], name[40];
-    afs_int32 pid = -1, rsCount = -1;
-    afs_int32 procStarts = -1;
-    afs_int32 errorCode = -1, errorSignal = -1, goal = -1;
-    time_t procStartTime = -1, rsTime = -1, lastAnyExit = -1, lastErrorExit = -1;
-    char *timeStamp;
-
-    typep = malloc(50);
-    cmd = malloc(50);
-    bufp = bufp1 = malloc(1000);
-    while (fgets(buf, sizeof(buf), fin)) {
-	code = sscanf(buf, "%s %s\n", typep, cmd);
-	if (code < 2) {
-	    continue;
-	}
-	if (!strcmp(typep, "BEGIN") && !strcmp(cmd, "bnode_proc")) {
-	    while (fgets(buf, sizeof(buf), fin)) {
-		code = sscanf(buf, "%s %s\n", typep, cmd);
-		if (code < 2) {
-		    printf("**bnode_proc**: typed=%s, cmd=%s\n", typep, cmd);
-		    break;
-		}
-		if (!strcmp(typep, "comLine:"))
-		    strcpy(comLine, cmd);
-		else if (!strcmp(typep, "coreName:"))
-		    strcpy(coreName, cmd);
-		else if (!strcmp(typep, "pid:"))
-		    pid = atoi(cmd);
-		else if (!strcmp(typep, "flags:"))
-		    pflags = atoi(cmd);
-		else if (!strcmp(typep, "END")) {
-		    break;
-		} else {
-		    printf
-			("Unexpected token %s in the bnode_proc (should be END)\n",
-			 typep);
-		    exit(1);
-		}
-	    }
-	} else if (!strcmp(typep, "BEGIN") && !strcmp(cmd, "bnode")) {
-	    while (fgets(buf, sizeof(buf), fin)) {
-		code = sscanf(buf, "%s %s\n", typep, cmd);
-		if (code < 2) {
-		    printf("**bnode**: typed=%s, cmd=%s\n", typep, cmd);
-		    break;
-		}
-		if (!strcmp(typep, "name:"))
-		    strcpy(name, cmd);
-		else if (!strcmp(typep, "rsTime:"))
-		    rsTime = atoi(cmd);
-		else if (!strcmp(typep, "rsCount:"))
-		    rsCount = atoi(cmd);
-		else if (!strcmp(typep, "procStartTime:"))
-		    procStartTime = atoi(cmd);
-		else if (!strcmp(typep, "procStarts:"))
-		    procStarts = atoi(cmd);
-		else if (!strcmp(typep, "lastAnyExit:"))
-		    lastAnyExit = atoi(cmd);
-		else if (!strcmp(typep, "lastErrorExit:"))
-		    lastErrorExit = atoi(cmd);
-		else if (!strcmp(typep, "errorCode:"))
-		    errorCode = atoi(cmd);
-		else if (!strcmp(typep, "errorSignal:"))
-		    errorSignal = atoi(cmd);
-/*
-		else if (!strcmp(typep, "lastErrorName:"))
-		    strcpy(lastErrorName, cmd);
-*/
-		else if (!strcmp(typep, "goal:"))
-		    goal = atoi(cmd);
-		else if (!strcmp(typep, "END")) {
-		    break;
-		} else {
-		    printf
-			("Unexpected token %s in the bnode (should be END)\n",
-			 typep);
-		    exit(1);
-		}
-	    }
-	} else {
-	    printf("Unexpected token %s (should be BEGIN)\n", typep);
-	    exit(1);
-	}
-    }
-    /*
-     * Now make up the text for the post
-     */
-    sprintf(buf, "/tmp/snote.%d", getpid());
-    fd = open(buf, O_RDWR | O_CREAT | O_TRUNC, 0600);
-    if (fd == -1) {
-	perror(buf);
-	printf("Unable to create temp file, %s\n", buf);
-	exit(1);
-    }
-    (void)sprintf(bufp, "Subject: Bosserver's automatic notification\n\n");
-    bufp += strlen(bufp);
-    (void)sprintf(bufp,
-		  "AUTOMATIC NOTIFICATION EVENT FOR AFS SERVER INSTANCE %s\n\n",
-		  name);
-    bufp += strlen(bufp);
-    (void)sprintf(bufp, "Server Process id was: %d\n", pid);
-    bufp += strlen(bufp);
-    (void)sprintf(bufp, "Server command line: %s\n", comLine);
-    bufp += strlen(bufp);
-    if (strcmp(coreName, "(null)"))
-	core = 1;
-    bp = comLine;
-    strcpy(bp, AFSDIR_SERVER_CORELOG_FILEPATH);
-    if (core) {
-	strcat(bp, coreName);
-	strcat(bp, ".");
-    }
-    strcat(bp, name);
-    if ((code = stat(bp, &tstat)) == 0) {
-	c = 1;
-	if ((lastAnyExit - tstat.st_ctime) > 300)	/* > 5 mins old */
-	    c = 0;
-	core = 1;
-    } else
-	core = 0;
-    strcat(bp, " ");
-    (void)sprintf(bufp, "There is %score dump left %sfor this server\n",
-		  (core ? (c ? "a recent " : "an 'old' ") : "no "),
-		  (core ? bp : ""));
-    bufp += strlen(bufp);
-    if (pflags == 1)
-	strcpy(bp, "PROCESS STARTED");
-    else if (pflags == 2)
-	strcpy(bp, "PROCESS EXITED");
-    else
-	strcpy(bp, "UNKNOWN");
-    (void)sprintf(bufp, "Process state %d (%s)\n", pflags, bp);
-    bufp += strlen(bufp);
-    timeStamp = ctime(&rsTime);
-    timeStamp[24] = 0;
-    (void)sprintf(bufp, "\nNumber of restarts since %s is %d\n", timeStamp,
-		  rsCount);
-    bufp += strlen(bufp);
-    if (procStartTime) {
-	timeStamp = ctime(&procStartTime);
-	timeStamp[24] = 0;
-	(void)sprintf(bufp,
-		      "Number of process restarts since the process started %s is %d\n",
-		      timeStamp, procStarts);
-    }
-    bufp += strlen(bufp);
-    if (lastAnyExit) {
-	timeStamp = ctime(&lastAnyExit);
-	timeStamp[24] = 0;
-	(void)sprintf(bufp, "Last time process exited for any reason: %s\n",
-		      timeStamp);
-    }
-    bufp += strlen(bufp);
-    if (lastErrorExit) {
-	timeStamp = ctime(&lastErrorExit);
-	timeStamp[24] = 0;
-	(void)sprintf(bufp, "Last time process exited unexpectedly: %s\n",
-		      timeStamp);
-    }
-    bufp += strlen(bufp);
-    (void)sprintf(bufp, "Last exit return code %d\n", errorCode);
-    bufp += strlen(bufp);
-    (void)sprintf(bufp, "Last process terminating signal %d\n", errorSignal);
-    bufp += strlen(bufp);
-    (void)sprintf(bufp, "The server is now %srunning\n",
-		  (goal ? "" : "not "));
-    bufp += strlen(bufp);
-    len = (int)(bufp - bufp1);
-    if (write(fd, bufp1, len) < 0) {
-	perror("Write");
-	exit(1);
-    }
-    close(fd);
-    /*
-     * Send the mail out
-     */
-    sprintf(bufp1, "%s %s -s TESTING < %s", SENDMAIL, RECIPIENT, buf);
-    code = system(bufp1);
-    if (code == -1)
-	perror("system");
-    else if (code == 127)
-	fprintf(stderr, "system: unable to execute shell\n");
-#ifdef WTERMSIG
-    else if (WIFSIGNALED(code))
-	fprintf(stderr, "%s terminated with signal %d\n", SENDMAIL,
-	    WTERMSIG(code));
-    else if (WEXITSTATUS(code) != 0)
-	fprintf(stderr, "%s exited with status %d\n", SENDMAIL,
-	    WEXITSTATUS(code));
-#endif /* WTERMSIG */
-    unlink(buf);
-    exit(0);
-}
diff --git a/src/bucoord/bc_status.c b/src/bucoord/bc_status.c
index 818cc5821..04b2ba9d8 100644
--- a/src/bucoord/bc_status.c
+++ b/src/bucoord/bc_status.c
@@ -69,32 +69,6 @@ nextItem(statusP linkPtr)
     return ((statusP) ptr);
 }
 
-#ifdef notdef
-static statusP
-nextItem(linkPtr)
-     statusP linkPtr;
-{
-    dlqlinkP ptr;
-
-    ptr = (dlqlinkP) linkPtr;
-
-    /* if last known item has terminated, reset ptr */
-    if (ptr == 0) {
-	ptr = &statusHead;
-	if (dlqEmpty(ptr))
-	    return (0);
-    }
-
-    ptr = ptr->dlq_next;
-
-    /* if we're back at the head again */
-    if (ptr == &statusHead) {
-	ptr = ptr->dlq_next;
-    }
-    return ((statusP) ptr);
-}
-#endif /* notdef */
-
 char *cmdLine;
 
 void *
@@ -388,7 +362,7 @@ statusWatcher(void *unused)
 	    curPollPtr = 0;
 	}			/*done */
     }				/*w */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /* bc_jobNumber
diff --git a/src/bucoord/bucoord_internal.h b/src/bucoord/bucoord_internal.h
index 543bf0009..7866f47cd 100644
--- a/src/bucoord/bucoord_internal.h
+++ b/src/bucoord/bucoord_internal.h
@@ -117,6 +117,8 @@ extern afs_int32 bc_UpdateDumpSchedule(void);
 extern int bc_SaveDumpSchedule(void);
 
 /* main.c */
+extern int localauth, nobutcauth;
+extern char tcell[];
 extern time_t tokenExpires;
 extern afs_int32 doDispatch(afs_int32, char *[], afs_int32);
 extern void bc_HandleMisc(afs_int32 code);
diff --git a/src/bucoord/config.c b/src/bucoord/config.c
index bcaf017a0..5735f707e 100644
--- a/src/bucoord/config.c
+++ b/src/bucoord/config.c
@@ -16,26 +16,6 @@
 
 struct bc_config *bc_globalConfig;
 
-#if 0
-static int
-TrimLine(char *abuffer, afs_int32 *aport)
-{
-    int tc;
-    char garb[100];
-
-    *aport = 0;
-    sscanf(abuffer, "%s %u", garb, aport);
-    while ((tc = *abuffer)) {
-	if (tc == ' ') {
-	    *abuffer = 0;
-	    return 0;
-	}
-	abuffer++;
-    }
-    return 0;
-}
-#endif
-
 FILE *
 bc_open(struct bc_config *aconfig, char *aname, char *aext, char *amode)
 {
diff --git a/src/bucoord/dsstub.c b/src/bucoord/dsstub.c
index 01b1c78e7..95577e94f 100644
--- a/src/bucoord/dsstub.c
+++ b/src/bucoord/dsstub.c
@@ -174,21 +174,6 @@ static afs_int32 DeleteDump(afs_int32 adumpID)
     return code;
 }
 
-#if 0
-static afs_int32 DeleteTape(char * atapeName)
-{
-    char *tp;
-    afs_int32 code;
-
-    tp = TapeName(atapeName);
-    if (tp == NULL)
-	return ENOMEM;
-    code = unlink(tp);
-    free(tp);
-    return code;
-}
-#endif
-
 /* tailCompPtr
  *	name is a pathname style name, determine trailing name and return
  *	pointer to it
@@ -247,25 +232,6 @@ ScanDumpHdr(FILE *afile, char *aname, char *dumpName, afs_int32 *aparent, afs_in
     return 0;
 }
 
-#if 0
-/* scan a tape header out of a tape file, leaving the file ptr positioned just past the header */
-static afs_int32 ScanTapeHdr(FILE *afile, afs_int32 *adumpID, afs_int32 *aseq, afs_int32 *adamage)
-{
-    char tbuffer[256];
-    char *tp;
-    afs_int32 code;
-
-    tp = fgets(tbuffer, sizeof(tbuffer), afile);
-    if (!tp)
-	return -1;
-    code = sscanf(tbuffer, "%ld %ld %ld", (long int *)adumpID,
-		  (long int *)aseq, (long int *)adamage);
-    if (code != 3)
-	return -1;
-    return 0;
-}
-#endif
-
 /* ScanTapeVolume
  *	scan a tape volume record from a dump file, leaving the file ptr
  *	positioned past the just-scanned record.
@@ -323,23 +289,3 @@ afs_int32 ScanVolClone(FILE *tdump, char *volName, afs_int32 *cloneTime)
     }
     return (-1);
 }
-
-#if 0
-/* seek a dump file (after a header scan has been done) to position apos */
-static int SeekDump(FILE *afile, afs_int32 apos)
-{
-    afs_int32 i;
-    char *tp;
-    char tbuffer[256];
-
-    /* now skip to appropriate position */
-    for (i = 0; i < apos; i++) {
-	tp = fgets(tbuffer, sizeof(tbuffer), afile);
-	if (!tp) {
-	    fclose(afile);
-	    return -1;
-	}
-    }
-    return 0;
-}
-#endif
diff --git a/src/bucoord/dump.c b/src/bucoord/dump.c
index 5d1f58aa3..a85484d24 100644
--- a/src/bucoord/dump.c
+++ b/src/bucoord/dump.c
@@ -17,6 +17,7 @@
 #include <roken.h>
 
 #include <afs/cmd.h>
+#include <afs/cellconfig.h>
 #include <lwp.h>
 #include <rx/rx.h>
 #include <afs/bubasics.h>
@@ -307,33 +308,6 @@ bc_StartDmpRst(struct bc_config *aconfig, char *adname, char *avname,
     return 0;
 }
 
-#ifdef notdef
-/* bc_FindDumpSlot
- * 	Returns the dump slot of the dump with dumpID
- * entry:
- *	dumpID - id to look for
- *	port - portoffset for tape coordinator
- * exit:
- *	0-n - i.e. 0 or positive number, is the dump slot
- *	-1 - failed to find dumpID
- */
-
-afs_int32
-bc_FindDumpSlot(afs_int32 dumpID, afs_int32 port)
-{
-    int i;
-
-    for (i = 0; i < BC_MAXSIMDUMPS; i++) {
-	if ((bc_dumpTasks[i].flags & BC_DI_INUSE)
-	    && (bc_dumpTasks[i].dumpID == dumpID)
-	    && ((afs_int32) bc_dumpTasks[i].portOffset == port)) {
-	    return (i);
-	}
-    }
-    return (-1);
-}
-#endif
-
 /* bc_LabelTape
  *	opens a connection to the tape coordinator and requests that it
  *	label a tape
@@ -470,15 +444,40 @@ bc_GetConn(struct bc_config *aconfig, afs_int32 aport,
 	   struct rx_connection **tconn)
 {
     afs_uint32 host;
+    afs_int32 code;
     unsigned short port;
     static struct rx_securityClass *rxsc;
+    static afs_int32 scIndex;
     struct bc_hostEntry *te;
 
     *tconn = (struct rx_connection *)0;
 
     /* use non-secure connections to butc */
-    if (!rxsc)
-	rxsc = rxnull_NewClientSecurityObject();
+    if (!rxsc) {
+	struct afsconf_dir *dir;
+	afsconf_secflags flags = AFSCONF_SECOPTS_FALLBACK_NULL;
+	char *cname;
+
+	if (nobutcauth)
+	    flags |= AFSCONF_SECOPTS_NOAUTH;
+	if (localauth) {
+	    flags |= AFSCONF_SECOPTS_LOCALAUTH;
+	    dir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
+	} else {
+	    dir = afsconf_Open(AFSDIR_CLIENT_ETC_DIRPATH);
+	}
+	if (tcell[0] == '\0')
+	    cname = NULL;
+	else
+	    cname = tcell;
+	/* No need for cell info since butc is not a registered service */
+	code = afsconf_PickClientSecObj(dir, flags, NULL, cname, &rxsc, &scIndex,
+					NULL);
+	if (dir)
+	    afsconf_Close(dir);
+	if (code)
+	    return -1;
+    }
     if (!rxsc || !aconfig)
 	return (-1);
 
@@ -491,8 +490,8 @@ bc_GetConn(struct bc_config *aconfig, afs_int32 aport,
 
 	    port = htons(BC_TAPEPORT + aport);
 
-	    /* servers is 1; sec index is 0 */
-	    *tconn = rx_NewConnection(host, port, 1, rxsc, 0);
+	    /* servers is 1 */
+	    *tconn = rx_NewConnection(host, port, 1, rxsc, scIndex);
 	    return ((*tconn ? 0 : -1));
 	}
     }
diff --git a/src/bucoord/main.c b/src/bucoord/main.c
index 34a3a7926..a453cc9dd 100644
--- a/src/bucoord/main.c
+++ b/src/bucoord/main.c
@@ -41,15 +41,15 @@
 #include "bucoord_internal.h"
 #include "bucoord_prototypes.h"
 
-int localauth, interact;
+int localauth, interact, nobutcauth;
 char tcell[64];
 
 /*
  * Global configuration information for the Backup Coordinator.
  */
-struct bc_config *bc_globalConfig;	/*Ptr to global BC configuration info */
+extern struct bc_config *bc_globalConfig;	/*Ptr to global BC configuration info */
 
-struct ubik_client *cstruct;	/* Ptr to Ubik client structure */
+extern struct ubik_client *cstruct;	/* Ptr to Ubik client structure */
 time_t tokenExpires;		/* The token's expiration time */
 
 static const char *DefaultConfDir;	/*Default backup config directory */
@@ -162,8 +162,6 @@ bc_InitTextConfig(void)
     udbClientTextP ctPtr;
     int i;
 
-    extern struct bc_config *bc_globalConfig;
-
     mkdir(DefaultConfDir, 777);	/* temporary */
 
     /* initialize the client text structures */
@@ -292,6 +290,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
     /* Handling the command line opcode */
     if (!bcInit) {
 	localauth = ((as && as->parms[14].items) ? 1 : 0);
+	nobutcauth = ((as && as->parms[16].items) ? 1 : 0);
 	if (as && as->parms[15].items)
 	    strcpy(tcell, as->parms[15].items->data);
 	else
@@ -432,6 +431,8 @@ add_std_args(struct cmd_syndesc *ts)
     cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
 		"local authentication");
     cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
+    cmd_AddParm(ts, "-nobutcauth", CMD_FLAG, CMD_OPTIONAL,
+		"no authentication to butc");
 }
 
 int
diff --git a/src/bucoord/ubik_db_if.c b/src/bucoord/ubik_db_if.c
index 8978e4b78..14d4880f7 100644
--- a/src/bucoord/ubik_db_if.c
+++ b/src/bucoord/ubik_db_if.c
@@ -815,8 +815,8 @@ vldbClientInit(int noAuthFlag, int localauth, char *cellName,
 
     code = afsconf_GetCellInfo(acdir, cellName, AFSCONF_VLDBSERVICE, &info);
     if (code) {
-	afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s/%s",
-		    cellName, confdir, AFSDIR_CELLSERVDB_FILE);
+	afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s",
+		    cellName, acdir->cellservDB);
 	ERROR(BC_NOCELLCONFIG);
     }
 
@@ -888,8 +888,8 @@ udbClientInit(int noAuthFlag, int localauth, char *cellName)
 
     code = afsconf_GetCellInfo(acdir, cellName, 0, &info);
     if (code) {
-	afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s/%s",
-		    cellName, confdir, AFSDIR_CELLSERVDB_FILE);
+	afs_com_err(whoami, code, "; Can't find cell %s's hosts in %s",
+		    cellName, acdir->cellservDB);
 	ERROR(BC_NOCELLCONFIG);
     }
 
@@ -1002,13 +1002,10 @@ ubik_Call_SingleServer(int (*aproc) (), struct ubik_client *aclient,
 		       char *p14, char *p15, char *p16)
 {
     afs_int32 code;
-    afs_int32 someCode, newHost, thisHost;
-    afs_int32 i;
+    afs_int32 someCode;
     afs_int32 count;
-    int chaseCount;
     int pass;
     struct rx_connection *tc;
-    struct rx_peer *rxp;
 
     if ((aflags & (UF_SINGLESERVER | UF_END_SINGLESERVER)) != 0) {
 	if (((aflags & UF_SINGLESERVER) != 0)
@@ -1033,7 +1030,6 @@ ubik_Call_SingleServer(int (*aproc) (), struct ubik_client *aclient,
     }
 
     someCode = UNOSERVERS;
-    chaseCount = 0;
     pass = 0;
     count = 0;
     while (1) {			/*w */
@@ -1063,38 +1059,12 @@ ubik_Call_SingleServer(int (*aproc) (), struct ubik_client *aclient,
 	 * requires a sync site, ubik will return UNOTSYNC, indicating the
 	 * operation won't work until you find a sync site
 	 */
-	if (code == UNOTSYNC) {	/*ns */
-	    /* means that this requires a sync site to work */
-	    someCode = code;	/* remember an error, if this fails */
-
-	    /* now see if we can find the sync site host */
-	    code = VOTE_GetSyncSite(tc, &newHost);
-	    if (code == 0 && newHost != 0) {
-		newHost = htonl(newHost);	/* convert back to network order */
-
-		/* position count at the appropriate slot in the client
-		 * structure and retry. If we can't find in slot, we'll just
-		 * continue through the whole list
-		 */
-		for (i = 0; i < MAXSERVERS; i++) {	/*f */
-		    rxp = rx_PeerOf(aclient->conns[i]);
-		    if (!(thisHost = rx_HostOf(rxp))) {
-			count++;	/* host not found, try the next dude */
-			break;
-		    }
-		    if (thisHost == newHost) {
-			/* avoid asking in a loop */
-			if (chaseCount++ > 2)
-			    break;
-			count = i;	/* we were told to use this one */
-			break;
-		    }
-		}		/*f */
-	    } else
-		count++;	/* not directed, keep looking for a sync site */
-	    continue;
-	} /*ns */
-	else if (code == UNOQUORUM) {	/* this guy is still recovering */
+
+	/*
+	 * Means that this requires a sync site to work or this guy is still
+	 * recovering.
+	 */
+	if (code == UNOTSYNC || code == UNOQUORUM) {
 	    someCode = code;
 	    count++;
 	    continue;
diff --git a/src/budb/budb.rg b/src/budb/budb.rg
index 1ec45f1ca..6e61652ff 100644
--- a/src/budb/budb.rg
+++ b/src/budb/budb.rg
@@ -224,7 +224,7 @@ typedef struct budb_volumeEntry budb_volumeList<BUDB_MAX_RETURN_LIST>;
 typedef struct budb_dumpEntry budb_dumpList<BUDB_MAX_RETURN_LIST>;
 typedef struct budb_tapeEntry budb_tapeList<BUDB_MAX_RETURN_LIST>;
 typedef afs_int32                  budb_dumpsList<BUDB_MAX_RETURN_LIST>;
-typedef char charListT<>;
+typedef char charListT<4096>;
 
 %#define BUDB_TEXT_COMPLETE	1
 
diff --git a/src/budb/database.c b/src/budb/database.c
index a57d830b1..a68b1f241 100644
--- a/src/budb/database.c
+++ b/src/budb/database.c
@@ -108,8 +108,8 @@ dbread(struct ubik_trans *ut, afs_int32 pos, void *buff, afs_int32 len)
     }
     code = ubik_Read(ut, buff, len);
     if (code) {
-	LogError(code, "dbread: ubik_Read pos %d, buff %"AFS_PTR_FMT
-		 ", len %d\n", pos, buff, len);
+	LogError(code, "dbread: ubik_Read pos %d, buff %p, len %d\n",
+		 pos, buff, len);
 	ERROR(code);
     }
 
@@ -143,8 +143,8 @@ cdbread(struct ubik_trans *ut, int type, afs_int32 pos, void *buff, afs_int32 le
     }
     code = ubik_Read(ut, buff, len);
     if (code) {
-	LogError(code, "cdbread: ubik_Read pos 0x%x, buff %"AFS_PTR_FMT
-		 ", len %d\n", pos, buff, len);
+	LogError(code, "cdbread: ubik_Read pos 0x%x, buff %p, len %d\n",
+		 pos, buff, len);
 	ERROR(code);
     }
 
diff --git a/src/budb/database.h b/src/budb/database.h
index b808234ea..e283b6cb3 100644
--- a/src/budb/database.h
+++ b/src/budb/database.h
@@ -281,7 +281,6 @@ struct memoryHashTable {
 };
 
 struct memoryDB {		/* in core copies of database structures */
-    struct Lock lock;
     Date readTime;
     struct dbHeader h;
     struct memoryHashTable volName;
@@ -311,12 +310,6 @@ extern struct memoryDB db;
 	      (char *)(addr)),					      \
 	     sizeof(afs_int32))
 
-#ifdef notdef
-/* simple min/max macros */
-#define MIN(x,y)        ((x) < (y) ? (x) : (y))
-#define MAX(x,y)        ((x) > (y) ? (x) : (y))
-#endif /* notdef */
-
 struct memoryHashTable *ht_GetType(int type, int *e_sizeP);
 extern afs_uint32 ht_HashEntry(struct memoryHashTable *mht, char *e);
 extern dbadr ht_LookupBucket(struct ubik_trans *ut,
diff --git a/src/budb/db_dump.c b/src/budb/db_dump.c
index d4d1fcd45..504514443 100644
--- a/src/budb/db_dump.c
+++ b/src/budb/db_dump.c
@@ -771,26 +771,3 @@ writeDatabase(struct ubik_trans *ut, int fid)
     doneWriting(code);
     return (code);
 }
-
-
-#ifdef notdef
-
-afs_int32
-canWrite(int fid)
-{
-    afs_int32 in, out, except;
-    struct timeval tp;
-    afs_int32 code;
-
-    tp.tv_sec = 0;
-    tp.tv_usec = 0;
-
-    out = (1 << fid);
-    in = 0;
-    except = 0;
-
-    code = IOMGR_Select(32, &in, &out, &except, &tp);
-    return (code);
-}
-
-#endif /* notdef */
diff --git a/src/budb/db_hash.c b/src/budb/db_hash.c
index 7aa2847ad..e87f8fcf4 100644
--- a/src/budb/db_hash.c
+++ b/src/budb/db_hash.c
@@ -532,7 +532,7 @@ ht_minHBlocks(struct memoryHashTable *mht)
 
     default:
 	db_panic("Illegal hash function type");
-	retval = -1; /* not reached */
+	AFS_UNREACHED(return -1);
     }
     return (retval);
 }
@@ -567,7 +567,7 @@ ht_HashEntry(struct memoryHashTable *mht,
 
     default:
 	db_panic("illegal hash function");
-	retval = -1; /* not reached */
+	AFS_UNREACHED(return -1);
     }
 
     return (retval);
@@ -630,8 +630,7 @@ ht_KeyMatch(int type, char *key, char *e)
     default:
 	db_panic("illegal hash function");
     }
-    /* not reached */
-    return 0;
+    AFS_UNREACHED(return 0);
 }
 
 /* ht_LookupEntry
@@ -844,62 +843,6 @@ ht_MoveEntries(struct ubik_trans *ut, struct memoryHashTable *mht)
 }
 
 
-#ifdef notdef
-static afs_int32
-ht_MoveEntries(struct ubik_trans *ut, struct memoryHashTable *mht)
-{
-    afs_uint32 hash;
-    int bo;
-    struct memoryHTBlock *block;
-    afs_int32 code;
-
-    if (mht->oldLength == 0)
-	return 0;
-
-    LogDebug(3, "ht_MoveEntries:\n");
-    /* we assume here that the hash function will map numbers smaller than the
-     * size of the hash table straight through to hash table indexes.
-     */
-    hash = mht->progress;
-
-    /* get hash table block ? */
-    code = ht_GetTableBlock(ut, mht, hash, 1 /*old */ , &block, &bo);
-    if (code)
-	return code;
-
-    if (block == 0)
-	return BUDB_INTERNALERROR;
-
-    do {
-	mht->progress++;
-	if (block->b.bucket[bo]) {
-	    code = ht_HashInList(ut, mht, ntohl(block->b.bucket[bo]));
-	    if (code) {
-		Log("ht_MoveEntries: ht_HashInList failed\n");
-		return (BUDB_IO);
-	    }
-	    code =
-		set_word_addr(ut, block->a, &block->b, &block->b.bucket[bo],
-			      0);
-	    if (code) {
-		Log("ht_MoveEntries: clear old entry failed\n");
-		return BUDB_IO;
-	    }
-	    break;
-	}
-    } while (++bo < nHTBuckets);
-
-    if (mht->progress >= mht->oldLength)
-	return (ht_FreeTable(ut, mht));
-
-    if (set_word_addr(ut, 0, &db.h, &mht->ht->progress, htonl(mht->progress))) {
-	Log("ht_MoveEntries: progress set failed\n");
-	return BUDB_IO;
-    }
-    return 0;
-}
-#endif /* notdef */
-
 afs_int32
 ht_HashIn(struct ubik_trans *ut,
 	  struct memoryHashTable *mht,
@@ -940,7 +883,7 @@ ht_HashIn(struct ubik_trans *ut,
 		      htonl(ea));
     if (code)
 	return BUDB_IO;
-    LogDebug(5, "Hashin: set %"AFS_PTR_FMT" to %d\n",
+    LogDebug(5, "Hashin: set %p to %d\n",
 	     &block->b.bucket[bo], htonl(ea));
 
     pentries = &ht->entries;
@@ -1016,34 +959,6 @@ ht_HashOutT(struct ubik_trans *ut, struct memoryHashTable *mht,
 		       ea, e, (dbadr *) (e + mht->threadOffset));
     if (code)
 	return code;
-#if 0
-    net_ea = htonl(ea);
-    unthread_ea = *(afs_int32 *) ((char *)e + mht->threadOffset);
-    if (block->b.bucket[bo] == net_ea) {
-	if (set_word_addr
-	    (ut, block->a, &block->b, &block->b.bucket[bo], unthread_ea))
-	    return BUDB_IO;
-	goto done;
-    }
-    loop_a = ntohl(block->b.bucket[bo]);
-    while (1) {
-	if (dbread
-	    (ut, loop_a + mht->threadOffset, (char *)&next_loop_a,
-	     sizeof(dbadr)))
-	    return BUDB_IO;
-	if (next_loop_a == 0)
-	    return -1;		/* not found */
-	if (net_ea == next_loop_a) {
-	    if (dbwrite
-		(ut, loop_a + mht->threadOffset, (char *)&unthread_ea,
-		 sizeof(dbadr)))
-		return BUDB_IO;
-	    goto done;
-	}
-	loop_a = ntohl(next_loop_a);
-    }
-  done:
-#endif
     pentries = &mht->ht->entries;
     if (set_word_addr
 	(ut, 0, &db.h, pentries, htonl(ntohl(mht->ht->entries) - 1)))
diff --git a/src/budb/db_text.c b/src/budb/db_text.c
index e88ef51e7..d66d8344d 100644
--- a/src/budb/db_text.c
+++ b/src/budb/db_text.c
@@ -69,8 +69,8 @@ GetText(struct rx_call *call, afs_uint32 lockHandle, afs_int32 textType,
     char *textPtr;
     afs_int32 code;
 
-    LogDebug(5, "GetText: type %d, offset %d, nextOffset %"AFS_PTR_FMT
-	     ", maxLength %d\n", textType, offset, nextOffset, maxLength);
+    LogDebug(5, "GetText: type %d, offset %d, nextOffset %p, maxLength %d\n",
+		textType, offset, nextOffset, maxLength);
 
     if (callPermitted(call) == 0) {
 	code = BUDB_NOTPERMITTED;
diff --git a/src/budb/dbs_dump.c b/src/budb/dbs_dump.c
index b1e4003bf..0d7083713 100644
--- a/src/budb/dbs_dump.c
+++ b/src/budb/dbs_dump.c
@@ -61,7 +61,7 @@ setupDbDump(void *param)
     int writeFid = (intptr_t)param;
     afs_int32 code = 0;
 
-    afs_pthread_setname_self("Database Dumper");
+    opr_threadname_set("Database Dumper");
     code = InitRPC(&dumpSyncPtr->ut, LOCKREAD, 1);
     if (code)
 	goto error_exit;
@@ -327,7 +327,7 @@ dumpWatcher(void *unused)
 {
     afs_int32 code;
 
-    afs_pthread_setname_self("Database Dump Watchdog");
+    opr_threadname_set("Database Dump Watchdog");
     while (1) {			/*w */
 
 	/* printf("dumpWatcher\n"); */
diff --git a/src/budb/procs.c b/src/budb/procs.c
index f2987d311..780262f0c 100644
--- a/src/budb/procs.c
+++ b/src/budb/procs.c
@@ -424,6 +424,7 @@ FillDumpEntry(struct ubik_trans *ut, dbadr da, void *rock)
     struct budb_dumpEntry *dump = (struct budb_dumpEntry *)rock;
     struct dump d, ad;
 
+    memset(dump, 0, sizeof(*dump));
     if (dbread(ut, da, &d, sizeof(d)))
 	return BUDB_IO;
     dump->id = ntohl(d.id);
@@ -1644,7 +1645,7 @@ ListDumps(struct rx_call *call, afs_int32 sflags, afs_int32 groupid,
 					count * sizeof(afs_int32));
 			}
 			if (!dumps->budb_dumpsList_val
-			    || !dumps->budb_dumpsList_val)
+                            || !flags->budb_dumpsList_val)
 			    ABORT(BUDB_NOMEM);
 		    }
 
@@ -1912,91 +1913,6 @@ FindClone(struct rx_call *call, afs_int32 dumpID, char *volName,
     return (code);
 }
 
-#ifdef notdef
-/*
- *      Searches each tape and each volume in the dump until the volume is found.
- *      If the volume is not in the dump, then we search it's parent dump.
- *
- *	Re-write to do lookups by volume name.
- */
-afs_int32
-FindClone(struct rx_call *call, afs_int32 dumpID, char *volName,
-	  afs_int32 *clonetime)
-{
-    struct ubik_trans *ut;
-    dbadr diskAddr, tapeAddr, volFragmentAddr;
-    struct dump dump;
-    struct tape tape;
-    struct volFragment volFragment;
-    struct volInfo volInfo;
-    afs_int32 eval, code = 0;
-
-    if (!callPermitted(call))
-	return BUDB_NOTPERMITTED;
-
-    eval = InitRPC(&ut, LOCKREAD, 1);
-    if (eval)
-	return (eval);
-
-    *clonetime = 0;
-
-    for (; dumpID; dumpID = ntohl(dump.parent)) {	/*d */
-	/* Get the dump entry */
-	eval = ht_LookupEntry(ut, &db.dumpIden, &dumpID, &diskAddr, &dump);
-	if (eval)
-	    ABORT(eval);
-	if (!diskAddr)
-	    ABORT(BUDB_NODUMPID);
-
-	/* just to be sure */
-	if (ntohl(dump.id) != dumpID) {
-	    LogDebug(4, "BUDB_FindClone: requested %d, found %d\n", dumpID,
-		     ntohl(dump.id));
-	    ABORT(BUDB_INTERNALERROR);
-	}
-
-	/* search all the tapes in this dump */
-	for (tapeAddr = ntohl(dump.firstTape); tapeAddr; tapeAddr = ntohl(tape.nextTape)) {	/*t */
-	    /* Get the tape entry */
-	    eval = dbread(ut, tapeAddr, &tape, sizeof(tape));
-	    if (eval)
-		ABORT(eval);
-
-	    /* search all the volume fragments on this tape */
-	    for (volFragmentAddr = ntohl(tape.firstVol); volFragmentAddr; volFragmentAddr = ntohl(volFragment.sameTapeChain)) {	/*vf */
-		/* Get the volume fragment entry */
-		eval =
-		    dbread(ut, volFragmentAddr, &volFragment,
-			   sizeof(volFragment));
-		if (eval)
-		    ABORT(eval);
-
-		/* Get the volume info entry */
-		eval =
-		    dbread(ut, ntohl(volFragment.vol), &volInfo,
-			   sizeof(volInfo));
-		if (eval)
-		    ABORT(eval);
-
-		/* check if this volume is the one we want */
-		if (strcmp(volInfo.name, volName) == 0) {
-		    *clonetime = ntohl(volFragment.clone);
-		    ERROR(0);
-		}
-	    }			/*vf */
-	}			/*t */
-    }				/*d */
-
-  error_exit:
-    code = ubik_EndTrans(ut);
-    return (code);
-
-  abort_exit:
-    ubik_EndTrans(ut);
-    return (code);
-}
-#endif
-
 /* BUDB_FindDump
  *      Find latest volume dump before adate.
  *      Used by restore code when restoring a user requested volume(s)
@@ -2229,7 +2145,9 @@ FindLatestDump(struct rx_call *call, char *vsname, char *dumpPath,
 
   finished:
     /* return the dump found */
-    FillDumpEntry(ut, retdbaddr, dumpentry);
+    eval = FillDumpEntry(ut, retdbaddr, dumpentry);
+    if (eval)
+	ABORT(eval);
 
     code = ubik_EndTrans(ut);
     return (code);
@@ -3690,86 +3608,6 @@ volFragsDump(struct ubik_trans *ut, FILE *dumpfid, dbadr dbAddr)
     return (0);
 }
 
-#ifdef notdef
-/* utilities - network to host conversion
- *	currently used for debug only
- */
-
-void
-volFragmentDiskToHost(struct volFragment *diskVfPtr,
-		      struct volFragment *hostVfPtr)
-{
-    hostVfPtr->vol = ntohl(diskVfPtr->vol);
-    hostVfPtr->sameNameChain = ntohl(diskVfPtr->sameNameChain);
-    hostVfPtr->tape = ntohl(diskVfPtr->tape);
-    hostVfPtr->sameTapeChain = ntohl(diskVfPtr->sameTapeChain);
-    hostVfPtr->position = ntohl(diskVfPtr->position);
-    hostVfPtr->clone = ntohl(diskVfPtr->clone);
-    hostVfPtr->incTime = ntohl(diskVfPtr->incTime);
-    hostVfPtr->startByte = ntohl(diskVfPtr->startByte);
-    hostVfPtr->nBytes = ntohl(diskVfPtr->nBytes);
-    hostVfPtr->flags = ntohs(diskVfPtr->flags);
-    hostVfPtr->sequence = ntohs(diskVfPtr->sequence);
-}
-
-void
-volInfoDiskToHost(struct volInfo *diskViPtr, struct volInfo *hostViPtr)
-{
-    strcpy(hostViPtr->name, diskViPtr->name);
-    hostViPtr->nameHashChain = ntohl(diskViPtr->nameHashChain);
-    hostViPtr->id = ntohl(diskViPtr->id);
-    strcpy(hostViPtr->server, diskViPtr->server);
-    hostViPtr->partition = ntohl(diskViPtr->partition);
-    hostViPtr->flags = ntohl(diskViPtr->flags);
-    hostViPtr->sameNameHead = ntohl(diskViPtr->sameNameHead);
-    hostViPtr->sameNameChain = ntohl(diskViPtr->sameNameChain);
-    hostViPtr->firstFragment = ntohl(diskViPtr->firstFragment);
-    hostViPtr->nFrags = ntohl(diskViPtr->nFrags);
-}
-
-void
-tapeDiskToHost(struct tape *diskTapePtr, struct tape *hostTapePtr)
-{
-    strcpy(hostTapePtr->name, diskTapePtr->name);
-    hostTapePtr->nameHashChain = ntohl(diskTapePtr->nameHashChain);
-    hostTapePtr->flags = ntohl(diskTapePtr->flags);
-
-    /* tape id conversion here */
-    hostTapePtr->written = ntohl(diskTapePtr->written);
-    hostTapePtr->nBytes = ntohl(diskTapePtr->nBytes);
-    hostTapePtr->nFiles = ntohl(diskTapePtr->nFiles);
-    hostTapePtr->nVolumes = ntohl(diskTapePtr->nVolumes);
-    hostTapePtr->seq = ntohl(diskTapePtr->seq);
-    hostTapePtr->dump = ntohl(diskTapePtr->dump);
-    hostTapePtr->nextTape = ntohl(diskTapePtr->nextTape);
-    hostTapePtr->firstVol = ntohl(diskTapePtr->firstVol);
-    hostTapePtr->useCount = ntohl(diskTapePtr->useCount);
-}
-
-void
-dumpDiskToHost(struct dump *diskDumpPtr, struct dump *hostDumpPtr)
-{
-    hostDumpPtr->id = ntohl(diskDumpPtr->id);
-    hostDumpPtr->idHashChain = ntohl(diskDumpPtr->idHashChain);
-    strcpy(hostDumpPtr->dumpName, diskDumpPtr->dumpName);
-    strcpy(hostDumpPtr->dumpPath, diskDumpPtr->dumpPath);
-    strcpy(hostDumpPtr->volumeSet, diskDumpPtr->volumeSet);
-    hostDumpPtr->nameHashChain = ntohl(diskDumpPtr->nameHashChain);
-    hostDumpPtr->flags = ntohl(diskDumpPtr->flags);
-    hostDumpPtr->parent = ntohl(diskDumpPtr->parent);
-    hostDumpPtr->created = ntohl(diskDumpPtr->created);
-/*  hostDumpPtr->incTime = ntohl(diskDumpPtr->incTime); */
-    hostDumpPtr->nVolumes = ntohl(diskDumpPtr->nVolumes);
-
-    /* tapeset conversion here */
-
-    hostDumpPtr->firstTape = ntohl(diskDumpPtr->firstTape);
-
-    /* principal conversion here */
-}
-
-#endif /* notdef */
-
 int
 checkHash(struct ubik_trans *ut, int hashType)
 {
diff --git a/src/budb/server.c b/src/budb/server.c
index 3a8091845..f35f47fe2 100644
--- a/src/budb/server.c
+++ b/src/budb/server.c
@@ -370,6 +370,7 @@ main(int argc, char **argv)
     struct afsconf_cell *cellinfo = NULL;
     time_t currentTime;
     afs_int32 code = 0;
+    char hoststr[16];
     afs_uint32 host = ntohl(INADDR_ANY);
     int r;
 
@@ -467,6 +468,12 @@ main(int argc, char **argv)
 	ERROR(BUDB_NOCELLS);
     }
 
+    if (afsconf_CountKeys(BU_conf) == 0) {
+	LogError(0, "WARNING: No encryption keys found! "
+		    "All authenticated accesses will fail. "
+		    "Run akeyconvert or asetkey to import encryption keys.\n");
+    }
+
     code = afsconf_GetLocalCell(BU_conf, lcell, sizeof(lcell));
     if (code) {
 	LogError(0, "** Can't determine local cell name!\n");
@@ -531,10 +538,18 @@ main(int argc, char **argv)
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-	    rx_InitHost(host, htons(AFSCONF_BUDBPORT));
 	}
     }
 
+    Log("buserver binding rx to %s:%d\n",
+        afs_inet_ntoa_r(host, hoststr), AFSCONF_BUDBPORT);
+    code = rx_InitHost(host, htons(AFSCONF_BUDBPORT));
+    if (code) {
+	LogError(code, "rx init failed\n");
+	afs_com_err(whoami, code, "rx init failed");
+	ERROR(code);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();
 
diff --git a/src/butc/Makefile.in b/src/butc/Makefile.in
index 4648f96b7..fbdc49f14 100644
--- a/src/butc/Makefile.in
+++ b/src/butc/Makefile.in
@@ -38,6 +38,7 @@ LIBS=${TOP_LIBDIR}/libbudb.a \
         ${TOP_LIBDIR}/libsys.a  \
 	${TOP_LIBDIR}/librx.a \
         ${TOP_LIBDIR}/libsys.a  \
+	${TOP_LIBDIR}/libaudit.a \
 	${TOP_LIBDIR}/liblwp.a \
         ${TOP_LIBDIR}/libcmd.a \
 	${TOP_LIBDIR}/libafscom_err.a \
@@ -96,7 +97,7 @@ clean:
 install: butc read_tape
 	${INSTALL} -d ${DESTDIR}${sbindir}
 	@case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux*) \
+	sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux*) \
 		echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \
 	*_darwin_[1-6][0-9]) \
 		echo ${INSTALL_PROGRAM} butc ${DESTDIR}${sbindir}/butc ; \
@@ -112,7 +113,7 @@ install: butc read_tape
 dest: butc read_tape
 	${INSTALL} -d ${DEST}/etc
 	@case ${SYS_NAME} in \
-	alpha_dux*|sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux*) \
+	sgi_*|sun4x_*|sunx86_*|rs_aix*|*linux*|hp_ux*) \
 		echo "Don't install butc for ${SYS_NAME} (will install from tbutc)" ;; \
 	*_darwin_[1-6][0-9]) \
 		echo ${INSTALL_PROGRAM} butc ${DEST}/etc/butc ; \
diff --git a/src/butc/NTMakefile b/src/butc/NTMakefile
index 719333c1e..70b89f86c 100644
--- a/src/butc/NTMakefile
+++ b/src/butc/NTMakefile
@@ -47,6 +47,7 @@ EXELIBS =\
         $(DESTDIR)\lib\afs\afscmd.lib \
         $(DESTDIR)\lib\afs\afscom_err.lib \
         $(DESTDIR)\lib\afs\afsutil.lib \
+        $(DESTDIR)\lib\afs\afsaudit.lib \
         $(DESTDIR)\lib\afs\afsusd.lib \
 	$(DESTDIR)\lib\afs\afsprocmgmt.lib \
 	$(DESTDIR)\lib\afs\afspioctl.lib \
diff --git a/src/butc/afsxbsa.c b/src/butc/afsxbsa.c
index ee296bad8..aee6b48e4 100644
--- a/src/butc/afsxbsa.c
+++ b/src/butc/afsxbsa.c
@@ -66,26 +66,6 @@ dsInt16_t (* AFSdsmRegisterFS)( dsUint32_t dsmHandle, regFSData *regFilespaceP);
 dsInt16_t (* AFSdsmBindMC)( dsUint32_t dsmHandle, dsmObjName *objNameP, dsmSendType sendType, mcBindKey *mcBindKeyP);
 dsInt16_t (* AFSdsmSendObj)( dsUint32_t dsmHandle, dsmSendType sendType, void *sendBuff, dsmObjName *objNameP, ObjAttr *objAttrPtr, DataBlk *dataBlkPtr);
 dsInt16_t (* AFSdsmChangePW)( dsUint32_t dsmHandle, char *oldPW, char *newPW);
-#if 0
-dsInt16_t (* AFSdsmCleanUp)( dsBool_t mtFlag);
-dsInt16_t (* AFSdsmDeleteAccess)( dsUint32_t dsmHandle, dsUint32_t ruleNum);
-dsInt16_t (* AFSdsmDeleteFS)( dsUint32_t dsmHandle, char *fsName, dsUint8_t repository);
-dsInt16_t (* AFSdsmEndGetDataEx)( dsmEndGetDataExIn_t *dsmEndGetDataExInP, dsmEndGetDataExOut_t *dsmEndGetDataExOutP);
-dsInt16_t (* AFSdsmEndSendObjEx)( dsmEndSendObjExIn_t *dsmEndSendObjExInP, dsmEndSendObjExOut_t *dsmEndSendObjExOutP);
-dsInt16_t (* AFSdsmEndTxnEx)( dsmEndTxnExIn_t *dsmEndTxnExInP, dsmEndTxnExOut_t *dsmEndTxnExOutP);
-dsInt16_t (* AFSdsmGroupHandler)( dsmGroupHandlerIn_t *dsmGroupHandlerInP, dsmGroupHandlerOut_t  *dsmGroupHandlerOutP);
-dsInt16_t (* AFSdsmInitEx)( dsUint32_t *dsmHandleP, dsmInitExIn_t *dsmInitExInP, dsmInitExOut_t *dsmInitExOutP);
-dsInt16_t (* AFSdsmLogEvent)( dsUint32_t dsmHandle, logInfo *lopInfoP);
-dsInt16_t (* AFSdsmQueryAccess)( dsUint32_t dsmHandle, qryRespAccessData **accessListP, dsUint16_t *numberOfRules);
-void      (* AFSdsmQueryApiVersionEx)( dsmApiVersionEx *apiVersionP);
-dsInt16_t (* AFSdsmQueryCliOptions)( optStruct *optstructP);
-dsInt16_t (* AFSdsmQuerySessOptions)( dsUint32_t dsmHandle, optStruct *optstructP);
-dsInt16_t (* AFSdsmRenameObj)( dsmRenameIn_t *dsmRenameInP, dsmRenameOut_t *dsmRenameOutP);
-dsInt16_t (* AFSdsmSetAccess)( dsUint32_t dsmHandle, dsmAccessType accessType, dsmObjName *objNameP, char *node, char *owner);
-dsInt16_t (* AFSdsmSetUp)( dsBool_t mtFlag, envSetUp *envSetUpPi);
-dsInt16_t (* AFSdsmUpdateFS)( dsUint32_t dsmHandle, char *fs, dsmFSUpd *fsUpdP, dsUint32_t fsUpdAct);
-dsInt16_t (* AFSdsmUpdateObj)( dsUint32_t dsmHandle, dsmSendType sendType, void *sendBuff, dsmObjName *objNameP, ObjAttr *objAttrPtr, dsUint32_t objUpdAct);
-#endif
 /* <<< TSM function pointers. */
 
 typedef struct s_delList {
diff --git a/src/butc/butc_prototypes.h b/src/butc/butc_prototypes.h
index 1c62c34b4..85a379963 100644
--- a/src/butc/butc_prototypes.h
+++ b/src/butc/butc_prototypes.h
@@ -32,5 +32,10 @@ extern void *saveDbToTape(void *);
 extern void *restoreDbFromTape(void *);
 extern void *KeepAlive(void *);
 
+/* tcmain.c */
+
+extern struct afsconf_dir *butc_confdir;
+extern int allow_unauth;
+
 #endif
 
diff --git a/src/butc/dbentries.c b/src/butc/dbentries.c
index 3a358cef4..867a22522 100644
--- a/src/butc/dbentries.c
+++ b/src/butc/dbentries.c
@@ -12,6 +12,7 @@
 
 #include <roken.h>
 
+#include <afs/opr.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
@@ -31,7 +32,7 @@
 #include "error_macros.h"
 
 dlqlinkT savedEntries;
-dlqlinkT entries_to_flush;
+static dlqlinkT entries_to_flush;
 
 int dbWatcherinprogress;
 
@@ -328,7 +329,7 @@ dbWatcher(void *unused)
     afs_int32 code = 0;
     int i, c, addedDump;
 
-    afs_pthread_setname_self("dbWatcher");
+    opr_threadname_set("dbWatcher");
     dlqInit(&entries_to_flush);
     dlqInit(&savedEntries);
 
@@ -483,5 +484,5 @@ dbWatcher(void *unused)
 	IOMGR_Sleep(2);
 #endif
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
diff --git a/src/butc/dump.c b/src/butc/dump.c
index cd5d59193..3750ef721 100644
--- a/src/butc/dump.c
+++ b/src/butc/dump.c
@@ -12,6 +12,7 @@
 
 #include <roken.h>
 
+#include <afs/opr.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
@@ -42,8 +43,7 @@ extern int isafile;
 extern int forcemultiple;
 
 extern struct ubik_client *cstruct;
-dlqlinkT savedEntries;
-dlqlinkT entries_to_flush;
+extern dlqlinkT savedEntries;
 
 extern afs_int32 groupId;
 extern afs_int32 BufferSize;
@@ -61,8 +61,8 @@ extern char *xbsalGName;
 extern char *globalButcLog;
 #endif /*xbsa */
 
-afs_int32 dataSize;		/* Size of data to read on each rx_Read() call */
-afs_int32 tapeblocks;		/* Number of 16K tape datablocks in buffer (!CONF_XBSA) */
+extern afs_int32 dataSize;		/* Size of data to read on each rx_Read() call */
+extern afs_int32 tapeblocks;		/* Number of 16K tape datablocks in buffer (!CONF_XBSA) */
 
 /* TBD
  *
@@ -81,12 +81,6 @@ afs_int32 tapeblocks;		/* Number of 16K tape datablocks in buffer (!CONF_XBSA) *
  *	least something usable.
  */
 
-#define DUMPNAME(dumpname, name, dbDumpId) \
-   if (dbDumpId == 0) \
-     sprintf(dumpname, "%s", name); \
-   else \
-     sprintf(dumpname, "%s (DumpId %u)", name, dbDumpId);
-
 struct dumpRock {
     /* status only */
     int tapeSeq;
@@ -538,7 +532,6 @@ xbsaDumpVolume(struct tc_dumpDesc * curDump, struct dumpRock * dparamsPtr)
     afs_uint32 statuscount = statusSize, tsize = 0, esize;
     afs_hyper_t estSize;
 
-    char dumpIdStr[XBSA_MAX_OSNAME];
     char volumeNameStr[XBSA_MAX_PATHNAME];
     static char *dumpDescription = "AFS volume dump";
     static char *objectDescription = "XBSA - butc";
@@ -598,14 +591,12 @@ xbsaDumpVolume(struct tc_dumpDesc * curDump, struct dumpRock * dparamsPtr)
     dparamsPtr->curVolStartPos = tapeInfoPtr->position;
 
     /* Tell XBSA what the name and size of volume to write */
-    strcpy(dumpIdStr, butcdumpIdStr);	/* "backup_afs_volume_dumps" */
-    sprintf(volumeNameStr, "/%d", dparamsPtr->databaseDumpId);
-    strcat(volumeNameStr, "/");
-    strcat(volumeNameStr, curDump->name);	/* <dumpid>/<volname> */
+    snprintf(volumeNameStr, sizeof(volumeNameStr), "/%d/%s",
+	     dparamsPtr->databaseDumpId, curDump->name);
     hset32(estSize, esize);
     hshlft(estSize, 10);	/* Multiply by 1024 so its in KB */
 
-    rc = xbsa_WriteObjectBegin(&butxInfo, dumpIdStr, volumeNameStr,
+    rc = xbsa_WriteObjectBegin(&butxInfo, butcdumpIdStr, volumeNameStr,
 			       xbsalGName, estSize, dumpDescription,
 			       objectDescription);
     if (rc != XBSA_SUCCESS) {
@@ -877,8 +868,7 @@ dumpPass(struct dumpRock * dparamsPtr, int passNumber)
 		    dparamsPtr->volumesFailed++;
 		    continue;
 		}
-		/* Fall into RWVOL case */
-
+		AFS_FALLTHROUGH;
 	    case RWVOL:
 		for (e = 0; e < vldbEntry.nServers; e++) {	/* Find the RW volume */
 		    if (vldbEntry.serverFlags[e] & VLSF_RWVOL)
@@ -1115,9 +1105,9 @@ Dumper(void *param)
     int dumpedvolumes = 0;
     int nodumpvolumes = 0;
     char strlevel[5];
-    char msg[20];
-    char finishedMsg1[50];
-    char finishedMsg2[50];
+    char msg[128];
+    char finishedMsg1[128];
+    char finishedMsg2[128];
     time_t startTime = 0;
     time_t endTime = 0;
     afs_int32 allocbufferSize;
@@ -1125,7 +1115,7 @@ Dumper(void *param)
     extern struct deviceSyncNode *deviceLatch;
     extern struct tapeConfig globalTapeConfig;
 
-    afs_pthread_setname_self("dumper");
+    opr_threadname_set("dumper");
     taskId = nodePtr->taskID;	/* Get task Id */
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);
@@ -1186,7 +1176,7 @@ Dumper(void *param)
      * Used when requesting a tape. Done now because once we create the dump, the
      * routine will then find the newly created dump.
      */
-    sprintf(strlevel, "%d", nodePtr->level);
+    snprintf(strlevel, sizeof(strlevel), "%d", nodePtr->level);
     code =
 	bcdb_FindLatestDump(nodePtr->volumeSetName, strlevel,
 			    &dparams.lastDump);
@@ -1291,15 +1281,21 @@ Dumper(void *param)
 
     lastPass = 1;		/* In case we aborted */
 
-    DUMPNAME(finishedMsg1, nodePtr->dumpSetName, dparams.databaseDumpId);
-    sprintf(finishedMsg2, "%d volumes dumped", dumpedvolumes);
+    /* Format and log finished message. */
+    snprintf(finishedMsg1, sizeof(finishedMsg1), "%s", nodePtr->dumpSetName);
+    if (dparams.databaseDumpId != 0) {
+	snprintf(msg, sizeof(msg), " (DumpId %u)", dparams.databaseDumpId);
+	strlcat(finishedMsg1, msg, sizeof(finishedMsg1));
+    }
+    snprintf(finishedMsg2, sizeof(finishedMsg2),
+	     "%d volumes dumped", dumpedvolumes);
     if (failedvolumes) {
-	sprintf(msg, ", %d failed", failedvolumes);
-	strcat(finishedMsg2, msg);
+	snprintf(msg, sizeof(msg), ", %d failed", failedvolumes);
+	strlcat(finishedMsg2, msg, sizeof(finishedMsg2));
     }
     if (nodumpvolumes) {
-	sprintf(msg, ", %d unchanged", nodumpvolumes);
-	strcat(finishedMsg2, msg);
+	snprintf(msg, sizeof(msg), ", %d unchanged", nodumpvolumes);
+	strlcat(finishedMsg2, msg, sizeof(finishedMsg2));
     }
 
     if (code == TC_ABORTEDBYREQUEST) {
@@ -1320,7 +1316,7 @@ Dumper(void *param)
     if (centralLogIO && startTime) {
 	long timediff;
 	afs_int32 hrs, min, sec, tmp;
-	char line[1024];
+	char *line = NULL;
 	struct tm tmstart, tmend;
 
 	localtime_r(&startTime, &tmstart);
@@ -1331,7 +1327,7 @@ Dumper(void *param)
 	min = tmp / 60;
 	sec = tmp % 60;
 
-	sprintf(line,
+	code = asprintf(&line,
 		"%-5d  %02d/%02d/%04d %02d:%02d:%02d  "
 		"%02d/%02d/%04d %02d:%02d:%02d  " "%02d:%02d:%02d  "
 		"%s %d of %d volumes dumped (%lu KB)\n", taskId,
@@ -1342,9 +1338,13 @@ Dumper(void *param)
 		nodePtr->volumeSetName, dumpedvolumes,
 		dumpedvolumes + failedvolumes,
 		afs_printable_uint32_lu(dparams.tapeInfoPtr->kBytes + 1));
-
-	fwrite(line, strlen(line), 1, centralLogIO);
-	fflush(centralLogIO);
+	if (code < 0)
+	    line = NULL;
+	if (line != NULL) {
+	    fwrite(line, strlen(line), 1, centralLogIO);
+	    fflush(centralLogIO);
+	}
+	free(line);
     }
 
     setStatus(taskId, TASK_DONE);
@@ -1694,7 +1694,7 @@ getDumpTape(struct dumpRock *dparamsPtr, int interactiveFlag,
 			code = bcdb_FindDumpByID(dmp, &de);
 			if (code)
 			    break;
-			sprintf(strlevel, "%d", de.level);
+			snprintf(strlevel, sizeof(strlevel), "%d", de.level);
 			code =
 			    bcdb_FindLatestDump(de.volumeSetName, strlevel,
 						&de2);
@@ -2032,7 +2032,7 @@ DeleteDump(void *param)
     dumpid = ptr->dumpID;
     taskId = ptr->taskId;	/* Get task Id */
 
-    afs_pthread_setname_self("deletedump");
+    opr_threadname_set("deletedump");
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);
     clearStatus(taskId, DRIVE_WAIT);
@@ -2128,15 +2128,14 @@ DeleteDump(void *param)
 	for (i = 0; i < vl.budb_volumeList_len; i++) {
 	    if (dumpEntry.flags & BUDB_DUMP_BUTA) {
 		/* dump was from buta, use old buta style names */
-		sprintf(dumpIdStr, "/%d", dumpid);
-		strcpy(volumeNameStr, "/");
-		strcat(volumeNameStr, (char *)vl.budb_volumeList_val[i].name);
+		snprintf(dumpIdStr, sizeof(dumpIdStr), "/%d", dumpid);
+		snprintf(volumeNameStr, sizeof(volumeNameStr), "/%s",
+			 (char *)vl.budb_volumeList_val[i].name);
 	    } else {		/* BUDB_DUMP_ADSM */
 		/* dump was from butc to ADSM, use butc names */
-		strcpy(dumpIdStr, butcdumpIdStr);
-		sprintf(volumeNameStr, "/%d", dumpid);
-		strcat(volumeNameStr, "/");
-		strcat(volumeNameStr, (char *)vl.budb_volumeList_val[i].name);
+		snprintf(dumpIdStr, sizeof(dumpIdStr), "%s", butcdumpIdStr);
+		snprintf(volumeNameStr, sizeof(volumeNameStr), "/%d/%s",
+			 dumpid, (char *)vl.budb_volumeList_val[i].name);
 	    }
 
 	    rc = xbsa_DeleteObject(&butxInfo, dumpIdStr, volumeNameStr);
diff --git a/src/butc/lwps.c b/src/butc/lwps.c
index d262991d8..3078d7382 100644
--- a/src/butc/lwps.c
+++ b/src/butc/lwps.c
@@ -51,7 +51,7 @@ extern int forcemultiple;
 #endif
 
 /* XBSA Global Parameters */
-afs_int32 xbsaType;
+extern afs_int32 xbsaType;
 #ifdef xbsa
 struct butx_transactionInfo butxInfo;
 #endif
@@ -1636,7 +1636,7 @@ Restorer(void *param) {
     time_t startTime, endTime;
     afs_int32 goodrestore = 0;
 
-    afs_pthread_setname_self("restorer");
+    opr_threadname_set("restorer");
     taskId = newNode->taskID;
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);
@@ -2102,7 +2102,7 @@ Labeller(void *param)
     afs_uint32 taskId;
     afs_int32 code = 0;
 
-    afs_pthread_setname_self("labeller");
+    opr_threadname_set("labeller");
     taskId = labelIfPtr->taskId;
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);
diff --git a/src/butc/recoverDb.c b/src/butc/recoverDb.c
index b1f5c90e4..36abc5616 100644
--- a/src/butc/recoverDb.c
+++ b/src/butc/recoverDb.c
@@ -12,6 +12,7 @@
 
 #include <roken.h>
 
+#include <afs/opr.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
@@ -660,15 +661,6 @@ getScanTape(afs_int32 taskId, struct butm_tapeInfo *tapeInfoPtr, char *tname,
 	/* If no name, accept any tape */
 	if (strcmp(tname, "") == 0) {
 	    break;		/* Start scan on any tape */
-#ifdef notdef
-	    if (curseq == 1)
-		break;		/* The first tape */
-	    else {
-		TLog(taskId, "Expected first tape of dump, label seen %s\n",
-		     gotname);
-		goto newtape;
-	    }
-#endif
 	}
 
 	if (strcmp(tname, tapeLabelPtr->AFSName)
@@ -706,7 +698,7 @@ ScanDumps(void *param)
     afs_uint32 taskId;
     afs_int32 code = 0;
 
-    afs_pthread_setname_self("scandump");
+    opr_threadname_set("scandump");
     taskId = ptr->taskId;
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);
diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c
index 197fe256a..84029639f 100644
--- a/src/butc/tcmain.c
+++ b/src/butc/tcmain.c
@@ -41,6 +41,7 @@
 #include <afs/keys.h>
 #include <afs/volser.h>
 #include <ubik.h>
+#include <afs/audit.h>
 #include <afs/com_err.h>
 #include <afs/cmd.h>
 #include <afs/tcdata.h>
@@ -65,12 +66,12 @@
 #define TL_PREFIX  "TL"
 #define CFG_PREFIX "CFG"
 
-struct ubik_client *cstruct;
+extern struct ubik_client *cstruct;
 FILE *logIO, *ErrorlogIO, *centralLogIO, *lastLogIO;
 char lFile[AFSDIR_PATH_MAX];
-char logFile[256];
-char ErrorlogFile[256];
-char lastLogFile[256];
+char logFile[AFSDIR_PATH_MAX + 256];
+char ErrorlogFile[AFSDIR_PATH_MAX + 256];
+char lastLogFile[AFSDIR_PATH_MAX + 256];
 char eFile[AFSDIR_PATH_MAX];
 char tapeConfigFile[AFSDIR_PATH_MAX];
 char pFile[AFSDIR_PATH_MAX];
@@ -105,18 +106,12 @@ afs_int32 BufferSize;		/* Size in B stored for data */
 char *centralLogFile;
 afs_int32 lastLog;		/* Log last pass info */
 int rxBind = 0;
+struct afsconf_dir *butc_confdir;
+int allow_unauth = 0;
 
 #define ADDRSPERSITE 16         /* Same global is in rx/rx_user.c */
 afs_uint32 SHostAddrs[ADDRSPERSITE];
 
-/* dummy routine for the audit work.  It should do nothing since audits */
-/* occur at the server level and bos is not a server. */
-int
-osi_audit(void)
-{
-    return 0;
-}
-
 static afs_int32
 SafeATOL(char *anum)
 {
@@ -242,31 +237,14 @@ atocl(char *numstring, char crunit, afs_int32 *number)
 	total *= 1024.0;
 
     total += 0.5;		/* Round up */
-    if ((total > 0x7fffffff) || (total < 0))	/* Don't go over 2G */
-	total = 0x7fffffff;
+    if ((total >= 2147483648.0) || (total < 0))	/* Don't go over 2G */
+	*number = 2147483647;
+    else
+	*number = total;
 
-    *number = total;
     return (0);
 }
 
-/* replace last two ocurrences of / by _ */
-#if 0
-static int
-stringReplace(char *name)
-{
-    char *pos;
-    char buffer[256];
-
-    pos = strrchr(name, '/');
-    *pos = '_';
-    strcpy(buffer, pos);
-    pos = strrchr(name, '/');
-    *pos = '\0';
-    strcat(name, buffer);
-    return 0;
-}
-#endif
-
 static int
 stringNowReplace(char *logFile, char *deviceName)
 {
@@ -408,7 +386,7 @@ GetDeviceConfig(char *filename, struct tapeConfig *config, afs_int32 portOffset)
 static afs_int32
 GetConfigParams(char *filename, afs_int32 port)
 {
-    char paramFile[256];
+    char paramFile[AFSDIR_PATH_MAX + 257];
     FILE *devFile = 0;
     char line[LINESIZE], cmd[LINESIZE], value[LINESIZE];
     afs_int32 code = 0;
@@ -442,13 +420,13 @@ GetConfigParams(char *filename, afs_int32 port)
     groupId = 0;		/* Group id for multiple dumps */
 
     /* Try opening the CFG_<port> file */
-    sprintf(paramFile, "%s_%d", filename, port);
+    snprintf(paramFile, sizeof(paramFile), "%s_%d", filename, port);
     devFile = fopen(paramFile, "r");
     if (devFile) {
 	/* Set log names to TL_<port>, TL_<port>.lp and TE_<port> */
-	sprintf(logFile, "%s_%d", lFile, port);
-	sprintf(lastLogFile, "%s_%d.lp", lFile, port);
-	sprintf(ErrorlogFile, "%s_%d", eFile, port);
+	snprintf(logFile, sizeof(logFile), "%s_%d", lFile, port);
+	snprintf(lastLogFile, sizeof(lastLogFile), "%s_%d.lp", lFile, port);
+	snprintf(ErrorlogFile, sizeof(ErrorlogFile), "%s_%d", eFile, port);
     } else if (CONF_XBSA) {
 	/* If configured as XBSA, a configuration file CFG_<port> must exist */
 	printf("Cannot open configuration file %s", paramFile);
@@ -588,7 +566,7 @@ GetConfigParams(char *filename, afs_int32 port)
 
 	else if (!strcmp(cmd, "BUFFERSIZE")) {
 	    afs_int32 size;
-	    afs_int32 tapeblocks;
+	    afs_int32 numTapeblocks;
 
 	    if (!CONF_XBSA) {
 		if (atocl(value, 'K', &size)) {
@@ -599,11 +577,11 @@ GetConfigParams(char *filename, afs_int32 port)
 		/* A tapeblock is 16KB. Determine # of tapeblocks. Then
 		 * determine BufferSize needed for that many tapeblocks.
 		 */
-		tapeblocks = size / 16;
-		if (tapeblocks <= 0)
-		    tapeblocks = 1;
-		printf("BUFFERSIZE is %u KBytes\n", (tapeblocks * 16));
-		BufferSize = tapeblocks * BUTM_BLOCKSIZE;
+		numTapeblocks = size / 16;
+		if (numTapeblocks <= 0)
+		    numTapeblocks = 1;
+		printf("BUFFERSIZE is %u KBytes\n", (numTapeblocks * 16));
+		BufferSize = numTapeblocks * BUTM_BLOCKSIZE;
 	    } else {
 #ifdef xbsa
 		if (atocl(value, 'B', &size)) {
@@ -831,11 +809,26 @@ xbsa_shutdown(int x)
 }
 #endif
 
+static int
+tc_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
+{
+    struct afsconf_dir *dir = (struct afsconf_dir *)rock;
+    afs_int32 islocal = 0;	/* default to no */
+    int code;
+
+    code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell);
+    if (code) {
+	TLog(0, "Failed local realm check; code=%d, name=%s, inst=%s, cell=%s\n",
+		 code, name, inst, cell);
+    }
+    return islocal;
+}
+
 static int
 WorkerBee(struct cmd_syndesc *as, void *arock)
 {
-    afs_int32 code;
-    struct rx_securityClass *(securityObjects[1]);
+    afs_int32 code, numClasses;
+    struct rx_securityClass *(nullObjects[1]), **secObjs, **allObjs;
     struct rx_service *service;
     time_t tokenExpires;
     char cellName[64];
@@ -849,7 +842,10 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 #else
     PROCESS dbWatcherPid;
 #endif
+    char hoststr[16];
     afs_uint32 host = htonl(INADDR_ANY);
+    char *auditFileName = NULL;
+    char *auditInterface = NULL;
 
     debugLevel = 0;
 
@@ -995,6 +991,36 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 	}
     }
 
+    /* Open the configuration directory */
+    butc_confdir = afsconf_Open(AFSDIR_SERVER_ETC_DIRPATH);
+    if (butc_confdir == NULL) {
+	TLog(0, "Failed to open server configuration directory");
+	exit(1);
+    }
+
+    if (afsconf_CountKeys(butc_confdir) == 0) {
+	TLog(0, "WARNING: No encryption keys found! "
+		"All authenticated accesses will fail. "
+		"Run akeyconvert or asetkey to import encryption keys.\n");
+    }
+
+    /* Start auditing */
+    osi_audit_init();
+    if (as->parms[9].items) {
+	auditFileName = as->parms[9].items->data;
+    }
+    if (auditFileName != NULL)
+	osi_audit_file(auditFileName);
+    if (as->parms[10].items) {
+	auditInterface = as->parms[10].items->data;
+	if (osi_audit_interface(auditInterface)) {
+	    TLog(0, "Invalid audit interface '%s'\n", auditInterface);
+	    exit(1);
+	}
+    }
+    osi_audit(TC_StartEvent, 0, AUD_END);
+    osi_audit_set_user_check(butc_confdir, tc_IsLocalRealmMatch);
+
     if (as->parms[1].items) {
 	debugLevel = SafeATOL(as->parms[1].items->data);
 	if (debugLevel == -1) {
@@ -1035,6 +1061,13 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     localauth = (as->parms[5].items ? 1 : 0);
     rxBind = (as->parms[8].items ? 1 : 0);
+    allow_unauth = (as->parms[11].items ? 1 : 0);
+
+    if (!allow_unauth && !localauth) {
+	const char *errstr = "Neither -localauth nor -allow_unauthenticated was provided; refusing to start in unintended insecure configuration\n";
+	TLog(0, "%s", (char *)errstr);
+	exit(1);
+    }
 
     if (rxBind) {
         afs_int32 ccode;
@@ -1053,6 +1086,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
             host = SHostAddrs[0];
     }
 
+    TLog(0, "butc binding rx to %s:%d\n",
+         afs_inet_ntoa_r(host, hoststr), BC_TAPEPORT + portOffset);
     code = rx_InitHost(host, htons(BC_TAPEPORT + portOffset));
     if (code) {
 	TapeLog(0, 0, code, 0, "rx init failed on port %u\n",
@@ -1079,19 +1114,48 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     /* initialize database support, volume support, and logs */
 
-    /* Create a single security object, in this case the null security
-     * object, for unauthenticated connections, which will be used to control
-     * security on connections made to this server
+    /*
+     * Create security objects for the Rx server functionality.  Historically
+     * this was a single rxnull security object, since the tape controller was
+     * run by an operator that had local access to the tape device and some
+     * administrative privilege in the cell (to be able to perform volume-level
+     * accesses), but on a machine that was not necessarily trusted to hold the
+     * cell-wide key.
+     *
+     * Such a configuration is, of course, insecure because anyone can make
+     * inbound RPCs and manipulate the database, including creating bogus
+     * dumps and restoring them!  Additionally, in modern usage, butc is
+     * frequently run with -localauth to authenticate its outbound connections
+     * to the volservers and budb with the cell-wide key, in which case the
+     * cell-wide key is present and could be used to authenticate incoming
+     * connections as well.
+     *
+     * If -localauth is in use, create the full barrage of server security
+     * objects, including rxkad, so that inbound connections can be verified
+     * to only be made by authenticated clients.  Otherwise, only the rxnull
+     * class is in use with a single server security object.  Note that butc
+     * will refuse to start in this configuration unless the
+     * "-allow_unauthenticated" flag is provided, indicating that the operator
+     * has ensured that incoming connections are appropriately restricted by
+     * firewall configuration or network topology.
      */
 
-    securityObjects[RX_SECIDX_NULL] = rxnull_NewServerSecurityObject();
-    if (!securityObjects[RX_SECIDX_NULL]) {
-	TLog(0, "rxnull_NewServerSecurityObject");
-	exit(1);
+    if (allow_unauth) {
+	nullObjects[RX_SECIDX_NULL] = rxnull_NewServerSecurityObject();
+	if (!nullObjects[RX_SECIDX_NULL]) {
+	    TLog(0, "rxnull_NewServerSecurityObject");
+	    exit(1);
+	}
+	numClasses = 1;
+	secObjs = nullObjects;
+    } else {
+	/* Must be -localauth, so the cell keys are available. */
+	afsconf_BuildServerSecurityObjects(butc_confdir, &allObjs, &numClasses);
+	secObjs = allObjs;
     }
 
     service =
-	rx_NewServiceHost(host, 0, 1, "BUTC", securityObjects, 1, TC_ExecuteRequest);
+	rx_NewServiceHost(host, 0, 1, "BUTC", secObjs, numClasses, TC_ExecuteRequest);
     if (!service) {
 	TLog(0, "rx_NewService");
 	exit(1);
@@ -1194,6 +1258,11 @@ main(int argc, char **argv)
 		"Force multiple XBSA server support");
     cmd_AddParm(ts, "-rxbind", CMD_FLAG, CMD_OPTIONAL,
 		"bind Rx socket");
+    cmd_AddParm(ts, "-auditlog", CMD_SINGLE, CMD_OPTIONAL, "location of audit log");
+    cmd_AddParm(ts, "-audit-interface", CMD_SINGLE, CMD_OPTIONAL,
+		"interface to use for audit logging");
+    cmd_AddParm(ts, "-allow_unauthenticated", CMD_FLAG, CMD_OPTIONAL,
+		"allow unauthenticated inbound RPCs (requires firewalling)");
 
     /* Initialize dirpaths */
     if (!(initAFSDirPath() & AFSDIR_SERVER_PATHS_OK)) {
diff --git a/src/butc/tcprocs.c b/src/butc/tcprocs.c
index d41112a80..c51b1f14d 100644
--- a/src/butc/tcprocs.c
+++ b/src/butc/tcprocs.c
@@ -33,21 +33,41 @@
 #include "butc_xbsa.h"
 #include "butc_prototypes.h"
 #include "butc_internal.h"
+#include "afs/audit.h"
 
 static int CopyDumpDesc(struct tc_dumpDesc *, tc_dumpArray *);
 static int CopyRestoreDesc(struct tc_restoreDesc *, tc_restoreArray *);
 static int CopyTapeSetDesc(struct tc_tapeSet *, struct tc_tapeSet *);
 
+/* Helpers implementing RPC backends */
+static afs_int32 SLabelTape(struct rx_call *acid, struct tc_tapeLabel *label,
+			    afs_uint32 *taskId);
+static afs_int32 SPerformDump(struct rx_call *rxCallId,
+			      struct tc_dumpInterface *tcdiPtr,
+			      tc_dumpArray *tc_dumpArrayPtr, afs_int32 *taskId);
+static afs_int32 SPerformRestore(struct rx_call *acid, char *dumpSetName,
+				 tc_restoreArray *arestores, afs_int32 *taskId);
+static afs_int32 SReadLabel(struct rx_call *acid, struct tc_tapeLabel *label,
+			    afs_uint32 *taskId);
+static afs_int32 SRestoreDb(struct rx_call *rxCall, afs_uint32 *taskId);
+static afs_int32 SSaveDb(struct rx_call *rxCall, Date archiveTime,
+			 afs_uint32 *taskId);
+static afs_int32 SScanDumps(struct rx_call *acid, afs_int32 addDbFlag,
+			    afs_uint32 *taskId);
+static afs_int32 STCInfo(struct rx_call *acid, struct tc_tcInfo *tciptr);
+static afs_int32 SDeleteDump(struct rx_call *acid, afs_uint32 dumpID,
+			     afs_uint32 *taskId);
+
 int
 callPermitted(struct rx_call *call)
 {
     /*
-     * Before this code can be used, the rx connection, on the bucoord side,
-     * must be changed so that it will set up for token passing instead of
-     * using a simple rx connection that, below, returns a value of
-     * RX_SECIDX_NULL from rx_SecurityClassOf.
+     * If in backwards compat mode, allow anyone; otherwise, only
+     * superusers are allowed.
      */
-    return 1;
+    if (allow_unauth)
+	return 1;
+    return afsconf_SuperIdentity(butc_confdir, call, NULL);
 }
 
 /* -----------------------------
@@ -129,6 +149,17 @@ CopyTapeSetDesc(struct tc_tapeSet *toPtr, struct tc_tapeSet *fromPtr)
 
 afs_int32
 STC_LabelTape(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId)
+{
+    afs_int32 code;
+
+    code = SLabelTape(acid, label, taskId);
+    osi_auditU(acid, TC_LabelTapeEvent, code,
+	       AUD_TLBL, label, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SLabelTape(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId)
 {
 #ifdef AFS_PTHREAD_ENV
     pthread_t pid;
@@ -204,7 +235,20 @@ STC_LabelTape(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *task
  */
 
 afs_int32
-STC_PerformDump(struct rx_call *rxCallId, struct tc_dumpInterface *tcdiPtr, tc_dumpArray *tc_dumpArrayPtr, afs_int32 *taskId)
+STC_PerformDump(struct rx_call *call, struct tc_dumpInterface *di,
+		tc_dumpArray *da, afs_int32 *taskId)
+{
+    afs_int32 code;
+
+    code = SPerformDump(call, di, da, taskId);
+    osi_auditU(call, TC_PerformDumpEvent, code,
+	       AUD_TDI, di, AUD_TDA, da, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SPerformDump(struct rx_call *rxCallId, struct tc_dumpInterface *tcdiPtr,
+	     tc_dumpArray *tc_dumpArrayPtr, afs_int32 *taskId)
 {
     struct dumpNode *newNode = 0;
     statusP statusPtr = 0;
@@ -295,7 +339,20 @@ STC_PerformDump(struct rx_call *rxCallId, struct tc_dumpInterface *tcdiPtr, tc_d
 }
 
 afs_int32
-STC_PerformRestore(struct rx_call *acid, char *dumpSetName, tc_restoreArray *arestores, afs_int32 *taskID)
+STC_PerformRestore(struct rx_call *call, char *dumpSetName,
+		   tc_restoreArray *ra, afs_int32 *taskId)
+{
+    afs_int32 code;
+
+    code = SPerformRestore(call, dumpSetName, ra, taskId);
+    osi_auditU(call, TC_PerformRestoreEvent, code,
+	       AUD_STR, dumpSetName, AUD_TRA, ra, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SPerformRestore(struct rx_call *acid, char *dumpSetName,
+	        tc_restoreArray *arestores, afs_int32 *taskID)
 {
     struct dumpNode *newNode;
     statusP statusPtr;
@@ -368,10 +425,24 @@ STC_PerformRestore(struct rx_call *acid, char *dumpSetName, tc_restoreArray *are
 }
 
 afs_int32
-STC_ReadLabel(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId)
+STC_ReadLabel(struct rx_call *call, struct tc_tapeLabel *label, afs_uint32 *taskId)
+{
+    afs_int32 code;
+
+    code = SReadLabel(call, label, taskId);
+    osi_auditU(call, TC_ReadLabelEvent, code,
+	       AUD_TLBL, label, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SReadLabel(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *taskId)
 {
     afs_int32 code;
 
+    memset(label, 0, sizeof(*label));
+    /* Synchronous, so no "real" ID; don't send stack garbage on the wire */
+    *taskId = 0;
 #ifdef xbsa
     if (CONF_XBSA)
 	return (TC_BADTASK);	/* ReadLabel does not apply if XBSA */
@@ -389,7 +460,17 @@ STC_ReadLabel(struct rx_call *acid, struct tc_tapeLabel *label, afs_uint32 *task
  */
 
 afs_int32
-STC_RestoreDb(struct rx_call *rxCall, afs_uint32 *taskId)
+STC_RestoreDb(struct rx_call *call, afs_uint32 *taskId)
+{
+    afs_int32 code;
+
+    code = SRestoreDb(call, taskId);
+    osi_auditU(call, TC_RestoreDbEvent, code, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SRestoreDb(struct rx_call *rxCall, afs_uint32 *taskId)
 {
 #ifdef AFS_PTHREAD_ENV
     pthread_t pid;
@@ -455,7 +536,18 @@ STC_RestoreDb(struct rx_call *rxCall, afs_uint32 *taskId)
  */
 
 afs_int32
-STC_SaveDb(struct rx_call *rxCall, Date archiveTime, afs_uint32 *taskId)
+STC_SaveDb(struct rx_call *call, Date archiveTime, afs_uint32 *taskId)
+{
+    afs_int32 code;
+
+    code = SSaveDb(call, archiveTime, taskId);
+    osi_auditU(call, TC_SaveDbEvent, code,
+	       AUD_DATE, archiveTime, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SSaveDb(struct rx_call *rxCall, Date archiveTime, afs_uint32 *taskId)
 {
 #ifdef AFS_PTHREAD_ENV
     pthread_t pid;
@@ -534,7 +626,18 @@ STC_SaveDb(struct rx_call *rxCall, Date archiveTime, afs_uint32 *taskId)
  */
 
 afs_int32
-STC_ScanDumps(struct rx_call *acid, afs_int32 addDbFlag, afs_uint32 *taskId)
+STC_ScanDumps(struct rx_call *call, afs_int32 addDbFlag, afs_uint32 *taskId)
+{
+    afs_int32 code;
+
+    code = SScanDumps(call, addDbFlag, taskId);
+    osi_auditU(call, TC_ScanDumpsEvent, code,
+	       AUD_INT, addDbFlag, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SScanDumps(struct rx_call *acid, afs_int32 addDbFlag, afs_uint32 *taskId)
 {
 #ifdef AFS_PTHREAD_ENV
     pthread_t pid;
@@ -609,7 +712,17 @@ STC_ScanDumps(struct rx_call *acid, afs_int32 addDbFlag, afs_uint32 *taskId)
  */
 
 afs_int32
-STC_TCInfo(struct rx_call *acid, struct tc_tcInfo *tciptr)
+STC_TCInfo(struct rx_call *call, struct tc_tcInfo *ti)
+{
+    afs_int32 code;
+
+    code = STCInfo(call, ti);
+    osi_auditU(call, TC_TCInfoEvent, code, AUD_INT, ti->tcVersion, AUD_END);
+    return code;
+}
+
+static afs_int32
+STCInfo(struct rx_call *acid, struct tc_tcInfo *tciptr)
 {
     if (callPermitted(acid) == 0)
 	return (TC_NOTPERMITTED);
@@ -621,7 +734,18 @@ STC_TCInfo(struct rx_call *acid, struct tc_tcInfo *tciptr)
 /* STC_DeleteDump
  */
 afs_int32
-STC_DeleteDump(struct rx_call *acid, afs_uint32 dumpID, afs_uint32 *taskId)
+STC_DeleteDump(struct rx_call *call, afs_uint32 dumpID, afs_uint32 *taskId)
+{
+    afs_int32 code;
+
+    code = SDeleteDump(call, dumpID, taskId);
+    osi_auditU(call, TC_DeleteDumpEvent, code,
+	       AUD_DATE, dumpID, AUD_INT, *taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SDeleteDump(struct rx_call *acid, afs_uint32 dumpID, afs_uint32 *taskId)
 {
     afs_int32 code = TC_BADTASK;	/* If not compiled -Dxbsa then fail */
 #ifdef xbsa
diff --git a/src/butc/tcstatus.c b/src/butc/tcstatus.c
index fbe46a49f..b67ae1eee 100644
--- a/src/butc/tcstatus.c
+++ b/src/butc/tcstatus.c
@@ -23,6 +23,7 @@
 #include "butc_internal.h"
 #include "error_macros.h"
 #include "butc_xbsa.h"
+#include "afs/audit.h"
 
 /* tape coordinator - task status management */
 extern afs_int32 xbsaType;
@@ -31,6 +32,13 @@ dlqlinkT statusHead;
 struct Lock statusQueueLock;
 struct Lock cmdLineLock;
 
+static afs_int32 SGetStatus(struct rx_call *call, afs_uint32 taskId,
+			    struct tciStatusS *statusPtr);
+static afs_int32 SEndStatus(struct rx_call *call, afs_uint32 taskId);
+static afs_int32 SRequestAbort(struct rx_call *call, afs_uint32 taskId);
+static afs_int32 SScanStatus(struct rx_call *call, afs_uint32 *taskId,
+			     struct tciStatusS *statusPtr, afs_uint32 *flags);
+
 /* STC_GetStatus
  *	get the status of a task
  * entry:
@@ -41,19 +49,30 @@ struct Lock cmdLineLock;
 
 afs_int32
 STC_GetStatus(struct rx_call *call, afs_uint32 taskId,
-	      struct tciStatusS *statusPtr)
+	      struct tciStatusS *status)
+{
+    afs_int32 code;
+
+    code = SGetStatus(call, taskId, status);
+    osi_auditU(call, TC_GetStatusEvent, code,
+	       AUD_INT, taskId, AUD_TSTT, status, AUD_END);
+    return code;
+}
+
+static afs_int32
+SGetStatus(struct rx_call *call, afs_uint32 taskId,
+	   struct tciStatusS *statusPtr)
 {
     statusP ptr;
     int retval = 0;
 
+    memset(statusPtr, 0, sizeof(*statusPtr));
     if (callPermitted(call) == 0)
 	return (TC_NOTPERMITTED);
 
     lock_Status();
     ptr = findStatus(taskId);
     if (ptr) {
-	/* strcpy(statusPtr->status, ptr->status); */
-
 	strcpy(statusPtr->taskName, ptr->taskName);
 	strcpy(statusPtr->volumeName, ptr->volumeName);
 	statusPtr->taskId = ptr->taskId;
@@ -72,6 +91,16 @@ STC_GetStatus(struct rx_call *call, afs_uint32 taskId,
 
 afs_int32
 STC_EndStatus(struct rx_call *call, afs_uint32 taskId)
+{
+    afs_int32 code;
+
+    code = SEndStatus(call, taskId);
+    osi_auditU(call, TC_EndStatusEvent, code, AUD_INT, taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SEndStatus(struct rx_call *call, afs_uint32 taskId)
 {
     statusP ptr;
     int retval = 0;
@@ -93,6 +122,16 @@ STC_EndStatus(struct rx_call *call, afs_uint32 taskId)
 
 afs_int32
 STC_RequestAbort(struct rx_call *call, afs_uint32 taskId)
+{
+    afs_int32 code;
+
+    code = SRequestAbort(call, taskId);
+    osi_auditU(call, TC_RequestAbortEvent, code, AUD_INT, taskId, AUD_END);
+    return code;
+}
+
+static afs_int32
+SRequestAbort(struct rx_call *call, afs_uint32 taskId)
 {
     statusP ptr;
     int retval = 0;
@@ -128,11 +167,24 @@ STC_RequestAbort(struct rx_call *call, afs_uint32 taskId)
 
 afs_int32
 STC_ScanStatus(struct rx_call *call, afs_uint32 *taskId,
-	       struct tciStatusS *statusPtr, afs_uint32 *flags)
+	       struct tciStatusS *status, afs_uint32 *flags)
+{
+    afs_int32 code;
+
+    code = SScanStatus(call, taskId, status, flags);
+    osi_auditU(call, TC_ScanStatusEvent, code,
+	       AUD_INT, *taskId, AUD_TSTT, status, AUD_INT, *flags, AUD_END);
+    return code;
+}
+
+static afs_int32
+SScanStatus(struct rx_call *call, afs_uint32 *taskId,
+	    struct tciStatusS *statusPtr, afs_uint32 *flags)
 {
     statusP ptr = 0;
     dlqlinkP dlqPtr;
 
+    memset(statusPtr, 0, sizeof(*statusPtr));
     if (callPermitted(call) == 0)
 	return (TC_NOTPERMITTED);
 
diff --git a/src/butc/tcudbprocs.c b/src/butc/tcudbprocs.c
index b9ecf495d..5cd6c321b 100644
--- a/src/butc/tcudbprocs.c
+++ b/src/butc/tcudbprocs.c
@@ -641,7 +641,7 @@ saveDbToTape(void *param)
     extern struct deviceSyncNode *deviceLatch;
     extern struct tapeConfig globalTapeConfig;
 
-    afs_pthread_setname_self("Db save");
+    opr_threadname_set("Db save");
     expires = (saveDbIfPtr->archiveTime ? NEVERDATE : 0);
     taskId = saveDbIfPtr->taskId;
     dumpEntry.id = 0;
@@ -1022,7 +1022,7 @@ restoreDbFromTape(void *param)
     extern struct tapeConfig globalTapeConfig;
     extern struct deviceSyncNode *deviceLatch;
 
-    afs_pthread_setname_self("Db restore");
+    opr_threadname_set("Db restore");
     setStatus(taskId, DRIVE_WAIT);
     EnterDeviceQueue(deviceLatch);	/* lock tape device */
     clearStatus(taskId, DRIVE_WAIT);
@@ -1120,7 +1120,7 @@ KeepAlive(void *unused)
 
     extern struct udbHandleS udbHandle;
 
-    afs_pthread_setname_self("Keep-alive");
+    opr_threadname_set("Keep-alive");
     while (1) {
 #ifdef AFS_PTHREAD_ENV
 	sleep(5);
diff --git a/src/butm/file_tm.c b/src/butm/file_tm.c
index d25da7047..fd4c8d750 100644
--- a/src/butm/file_tm.c
+++ b/src/butm/file_tm.c
@@ -209,8 +209,9 @@ ForkIoctl(usd_handle_t fd, int op, int count)
 	 * If this fails, there's nothing we can do, but we must test
 	 * it in order to avoid complier warnings on some platforms.
 	 */
-	if (write(pipefd[1], &ioctl_rc, sizeof(int)) < 0)
-	    ; /* don't care */
+	if (write(pipefd[1], &ioctl_rc, sizeof(int)) < 0) {
+	    /* don't care */
+	}
 
 	exit(0);
     } else {			/* parent process */
@@ -337,8 +338,9 @@ ForkOpen(char *device)
 	 * If this fails, there's nothing we can do, but we must test
 	 * it in order to avoid complier warnings on some platforms.
 	 */
-	if (write(pipefd[1], &open_rc, sizeof(open_rc)) < 0)
-	    ; /* don't care */
+	if (write(pipefd[1], &open_rc, sizeof(open_rc)) < 0) {
+	    /* don't care */
+	}
 
 	exit(0);
     } else {			/* parent process */
@@ -468,8 +470,9 @@ ForkClose(usd_handle_t fd)
 	 * block until the parent is ready.  But we must do something
 	 * with the result, to avoid complier warnings on some platforms.
 	 */
-	if (read(ctlpipe[0], &close_rc, sizeof(int)) < 0)
-	    ; /* don't care */
+	if (read(ctlpipe[0], &close_rc, sizeof(int)) < 0) {
+	    /* don't care */
+	}
 	close(ctlpipe[0]);
 
 	/* do the close */
@@ -480,8 +483,9 @@ ForkClose(usd_handle_t fd)
 	 * If this fails, there's nothing we can do, but we must test
 	 * it in order to avoid complier warnings on some platforms.
 	 */
-	if (write(pipefd[1], &close_rc, sizeof(int)) < 0)
-	    ; /* don't care */
+	if (write(pipefd[1], &close_rc, sizeof(int)) < 0) {
+	    /* don't care */
+	}
 
 	exit(0);
     } else {			/* parent process */
diff --git a/src/cf/afs-libtool.m4 b/src/cf/afs-libtool.m4
new file mode 100644
index 000000000..63ec5c18f
--- /dev/null
+++ b/src/cf/afs-libtool.m4
@@ -0,0 +1,30 @@
+dnl Change the default 'nm' in some situations
+AC_DEFUN([AFS_LT_PATH_NM],
+  [AC_REQUIRE([AC_CANONICAL_HOST])
+   AS_CASE([$host_os],
+
+dnl Starting around Solaris 11.3, the default 'nm' tool starts reporting
+dnl symbols with the 'C' code when given '-p'. Libtool currently cannot deal
+dnl with this, and it fails to figure out how to extract symbols from object
+dnl files (see libtool bug #22373). To work around this, try to use the GNU nm
+dnl instead by default, which is either always or almost always available.
+dnl libtool, of course, works with that just fine.
+     [solaris2.11*],
+     [AS_IF([test x"$NM" = x && test -x /usr/sfw/bin/gnm],
+       [NM=/usr/sfw/bin/gnm])])])
+
+dnl Our local wrapper around LT_INIT, to work around some bugs/limitations in
+dnl libtool.
+AC_DEFUN([AFS_LT_INIT],
+  [AC_REQUIRE([AFS_LT_PATH_NM])
+
+   LT_INIT
+
+dnl If libtool cannot figure out how to extract symbol names from 'nm', then it
+dnl will log a failure and lt_cv_sys_global_symbol_pipe will be unset, but it
+dnl will not cause configure to bail out. Later on, when we try to link with
+dnl libtool, it will cause a very confusing error message (see libtool bug
+dnl #20947).  To try and avoid that bad error message, try to catch that
+dnl situation here, closer to when the error actually occurs.
+   AS_IF([test x"$lt_cv_sys_global_symbol_pipe" = x],
+     [AC_MSG_ERROR([libtool cannot figure out how to extract symbol names; look above for failures involving 'nm'])])])
diff --git a/src/cf/ax_gcc_func_attribute.m4 b/src/cf/ax_gcc_func_attribute.m4
new file mode 100644
index 000000000..30bf4c175
--- /dev/null
+++ b/src/cf/ax_gcc_func_attribute.m4
@@ -0,0 +1,238 @@
+# ===========================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE)
+#
+# DESCRIPTION
+#
+#   This macro checks if the compiler supports one of GCC's function
+#   attributes; many other compilers also provide function attributes with
+#   the same syntax. Compiler warnings are used to detect supported
+#   attributes as unsupported ones are ignored by default so quieting
+#   warnings when using this macro will yield false positives.
+#
+#   The ATTRIBUTE parameter holds the name of the attribute to be checked.
+#
+#   If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_<ATTRIBUTE>.
+#
+#   The macro caches its result in the ax_cv_have_func_attribute_<attribute>
+#   variable.
+#
+#   The macro currently supports the following function attributes:
+#
+#    alias
+#    aligned
+#    alloc_size
+#    always_inline
+#    artificial
+#    cold
+#    const
+#    constructor
+#    constructor_priority for constructor attribute with priority
+#    deprecated
+#    destructor
+#    dllexport
+#    dllimport
+#    error
+#    externally_visible
+#    fallthrough
+#    flatten
+#    format
+#    format_arg
+#    gnu_inline
+#    hot
+#    ifunc
+#    leaf
+#    malloc
+#    noclone
+#    noinline
+#    nonnull
+#    noreturn
+#    nothrow
+#    optimize
+#    pure
+#    sentinel
+#    sentinel_position
+#    unused
+#    used
+#    visibility
+#    warning
+#    warn_unused_result
+#    weak
+#    weakref
+#
+#   Unsupported function attributes will be tested with a prototype
+#   returning an int and not accepting any arguments and the result of the
+#   check might be wrong or meaningless so use with care.
+#
+# LICENSE
+#
+#   Copyright (c) 2013 Gabriele Svelto <gabriele.svelto@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 9 with local fix for fallthrough attribute
+
+AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [
+    AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1])
+
+    AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([
+            m4_case([$1],
+                [alias], [
+                    int foo( void ) { return 0; }
+                    int bar( void ) __attribute__(($1("foo")));
+                ],
+                [aligned], [
+                    int foo( void ) __attribute__(($1(32)));
+                ],
+                [alloc_size], [
+                    void *foo(int a) __attribute__(($1(1)));
+                ],
+                [always_inline], [
+                    inline __attribute__(($1)) int foo( void ) { return 0; }
+                ],
+                [artificial], [
+                    inline __attribute__(($1)) int foo( void ) { return 0; }
+                ],
+                [cold], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [const], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [constructor_priority], [
+                    int foo( void ) __attribute__((__constructor__(65535/2)));
+                ],
+                [constructor], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [deprecated], [
+                    int foo( void ) __attribute__(($1("")));
+                ],
+                [destructor], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [dllexport], [
+                    __attribute__(($1)) int foo( void ) { return 0; }
+                ],
+                [dllimport], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [error], [
+                    int foo( void ) __attribute__(($1("")));
+                ],
+                [externally_visible], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [fallthrough], [
+                    void foo( int x ) {switch (x) { case 1: __attribute__(($1)); case 2: break ; }};
+                ],
+                [flatten], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [format], [
+                    int foo(const char *p, ...) __attribute__(($1(printf, 1, 2)));
+                ],
+                [format_arg], [
+                    char *foo(const char *p) __attribute__(($1(1)));
+                ],
+                [gnu_inline], [
+                    inline __attribute__(($1)) int foo( void ) { return 0; }
+                ],
+                [hot], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [ifunc], [
+                    int my_foo( void ) { return 0; }
+                    static int (*resolve_foo(void))(void) { return my_foo; }
+                    int foo( void ) __attribute__(($1("resolve_foo")));
+                ],
+                [leaf], [
+                    __attribute__(($1)) int foo( void ) { return 0; }
+                ],
+                [malloc], [
+                    void *foo( void ) __attribute__(($1));
+                ],
+                [noclone], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [noinline], [
+                    __attribute__(($1)) int foo( void ) { return 0; }
+                ],
+                [nonnull], [
+                    int foo(char *p) __attribute__(($1(1)));
+                ],
+                [noreturn], [
+                    void foo( void ) __attribute__(($1));
+                ],
+                [nothrow], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [optimize], [
+                    __attribute__(($1(3))) int foo( void ) { return 0; }
+                ],
+                [pure], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [sentinel], [
+                    int foo(void *p, ...) __attribute__(($1));
+                ],
+                [sentinel_position], [
+                    int foo(void *p, ...) __attribute__(($1(1)));
+                ],
+                [returns_nonnull], [
+                    void *foo( void ) __attribute__(($1));
+                ],
+                [unused], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [used], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [visibility], [
+                    int foo_def( void ) __attribute__(($1("default")));
+                    int foo_hid( void ) __attribute__(($1("hidden")));
+                    int foo_int( void ) __attribute__(($1("internal")));
+                    int foo_pro( void ) __attribute__(($1("protected")));
+                ],
+                [warning], [
+                    int foo( void ) __attribute__(($1("")));
+                ],
+                [warn_unused_result], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [weak], [
+                    int foo( void ) __attribute__(($1));
+                ],
+                [weakref], [
+                    static int foo( void ) { return 0; }
+                    static int bar( void ) __attribute__(($1("foo")));
+                ],
+                [
+                 m4_warn([syntax], [Unsupported attribute $1, the test may fail])
+                 int foo( void ) __attribute__(($1));
+                ]
+            )], [])
+            ],
+            dnl GCC doesn't exit with an error if an unknown attribute is
+            dnl provided but only outputs a warning, so accept the attribute
+            dnl only if no warning were issued.
+            [AS_IF([test -s conftest.err],
+                [AS_VAR_SET([ac_var], [no])],
+                [AS_VAR_SET([ac_var], [yes])])],
+            [AS_VAR_SET([ac_var], [no])])
+    ])
+
+    AS_IF([test yes = AS_VAR_GET([ac_var])],
+        [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1,
+            [Define to 1 if the system has the `$1' function attribute])], [])
+
+    AS_VAR_POPDEF([ac_var])
+])
diff --git a/src/cf/bigendian.m4 b/src/cf/bigendian.m4
index f260cd1ff..768d468ff 100644
--- a/src/cf/bigendian.m4
+++ b/src/cf/bigendian.m4
@@ -17,22 +17,22 @@ AC_ARG_ENABLE([littleendian],
 
 AC_CACHE_CHECK(whether byte order is known at compile time,
 openafs_cv_c_bigendian_compile,
-[AC_TRY_COMPILE([
+[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <sys/param.h>],[
+#include <sys/param.h>]], [[
 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
  bogus endian macros
-#endif], openafs_cv_c_bigendian_compile=yes, openafs_cv_c_bigendian_compile=no)])
+#endif]])],[openafs_cv_c_bigendian_compile=yes],[openafs_cv_c_bigendian_compile=no])])
 AC_CACHE_CHECK(whether byte ordering is bigendian, openafs_cv_c_bigendian,[
   if test "$openafs_cv_c_bigendian_compile" = "yes"; then
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
-#include <sys/param.h>],[
+#include <sys/param.h>]], [[
 #if BYTE_ORDER != BIG_ENDIAN
   not big endian
-#endif], openafs_cv_c_bigendian=yes, openafs_cv_c_bigendian=no)
+#endif]])],[openafs_cv_c_bigendian=yes],[openafs_cv_c_bigendian=no])
   else
-    AC_TRY_RUN([main () {
+    AC_RUN_IFELSE([AC_LANG_SOURCE([[main () {
       /* Are we little or big endian?  From Harbison&Steele.  */
       union
       {
@@ -41,8 +41,10 @@ AC_CACHE_CHECK(whether byte ordering is bigendian, openafs_cv_c_bigendian,[
     } u;
     u.l = 1;
     exit (u.c[sizeof (long) - 1] == 1);
-  }], openafs_cv_c_bigendian=no, openafs_cv_c_bigendian=yes,
-  AC_MSG_ERROR([specify either --enable-bigendian or --enable-littleendian]))
+  }]])],
+      [openafs_cv_c_bigendian=no],
+      [openafs_cv_c_bigendian=yes],
+      [AC_MSG_ERROR(specify either --enable-bigendian or --enable-littleendian)])
   fi
 ])
 if test "$openafs_cv_c_bigendian" = "yes"; then
diff --git a/src/cf/bsd.m4 b/src/cf/bsd.m4
index e8027d9ed..84dc2d76f 100644
--- a/src/cf/bsd.m4
+++ b/src/cf/bsd.m4
@@ -10,7 +10,8 @@ if test "x$with_bsd_kernel_build" != "x"; then
 else
     case $AFS_SYSNAME in
         *_fbsd_*)
-            BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"
+	    AS_IF([test -d "${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"],
+	          [BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/${HOST_CPU}/compile/GENERIC"])
             ;;
         *_nbsd*)
             BSD_KERNEL_BUILD="${BSD_KERNEL_PATH}/arch/${HOST_CPU}/compile/GENERIC"
diff --git a/src/cf/c-atomic.m4 b/src/cf/c-atomic.m4
index 3356e5262..aab210560 100644
--- a/src/cf/c-atomic.m4
+++ b/src/cf/c-atomic.m4
@@ -1,9 +1,12 @@
 AC_DEFUN([OPENAFS_C_ATOMIC_CHECKS], [
 AC_CACHE_CHECK([if compiler has __sync_add_and_fetch],
     [ac_cv_sync_fetch_and_add],
-    [AC_TRY_LINK(, [int var; return __sync_add_and_fetch(&var, 1);],
-            [ac_cv_sync_fetch_and_add=yes],
-            [ac_cv_sync_fetch_and_add=no])
+    [AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[]],
+        [[int var; return __sync_add_and_fetch(&var, 1);]])],
+      [ac_cv_sync_fetch_and_add=yes],
+      [ac_cv_sync_fetch_and_add=no])
 ])
 AS_IF([test "$ac_cv_sync_fetch_and_add" = "yes"],
       [AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD, 1,
diff --git a/src/cf/c-attribute.m4 b/src/cf/c-attribute.m4
index c179d903a..97dbfb35d 100644
--- a/src/cf/c-attribute.m4
+++ b/src/cf/c-attribute.m4
@@ -1,27 +1,22 @@
 dnl
-dnl $Id$
+dnl GCC-style function __attribute__ checks.
 dnl
-
-dnl
-dnl Test for __attribute__
+dnl Define HAVE___ATTRIBUTE__ if and only if we specifically support the
+dnl `format' function attribute. This is done for the imported roken
+dnl headers, which use that symbol to conditionally declare functions with
+dnl printf-like arguments. This is the only use of function attributes in
+dnl roken.  The HAVE___ATTRIBUTE__ symbol is not used in the OpenAFS code.
 dnl
-
 AC_DEFUN([OPENAFS_C_ATTRIBUTE], [
-AC_MSG_CHECKING(for __attribute__)
-AC_CACHE_VAL(ac_cv___attribute__, [
-AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
-static void foo(void) __attribute__ ((noreturn));
+  AX_GCC_FUNC_ATTRIBUTE([always_inline])
+  AX_GCC_FUNC_ATTRIBUTE([fallthrough])
+  AX_GCC_FUNC_ATTRIBUTE([format])
+  AX_GCC_FUNC_ATTRIBUTE([nonnull])
+  AX_GCC_FUNC_ATTRIBUTE([noreturn])
+  AX_GCC_FUNC_ATTRIBUTE([unused])
 
-static void
-foo(void)
-{
-  exit(1);
-}
-]])],
-[ac_cv___attribute__=yes],
-[ac_cv___attribute__=no])])
-if test "$ac_cv___attribute__" = "yes"; then
-  AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
-fi
-AC_MSG_RESULT($ac_cv___attribute__)
+  AS_IF([test "$ax_cv_have_func_attribute_format" = "yes"], [
+    AC_DEFINE([HAVE___ATTRIBUTE__], [1],
+      [define if your compiler has __attribute__((format))])
+  ])
 ])
diff --git a/src/cf/c-struct-label.m4 b/src/cf/c-struct-label.m4
index 9232c7d4c..67f3c256e 100644
--- a/src/cf/c-struct-label.m4
+++ b/src/cf/c-struct-label.m4
@@ -1,7 +1,7 @@
 AC_DEFUN([OPENAFS_C_STRUCT_LABEL_CHECK],[
 dnl Check to see if the compiler support labels in structs
 AC_MSG_CHECKING(for label support in structs)
-AC_TRY_COMPILE([], [
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
 extern void osi_UFSOpen(void);
 struct labeltest {
    void (*open) (void);
@@ -9,10 +9,9 @@ struct labeltest {
 struct labeltest struct_labeltest = {
    .open       = osi_UFSOpen,
 }
-],
-[AC_MSG_RESULT(yes)
-    AC_DEFINE(HAVE_STRUCT_LABEL_SUPPORT, 1, [Define to 1 if your compiler supports labels in structs.])
-],
-[AC_MSG_RESULT(no)
+]])],[AC_MSG_RESULT(yes)
+    AC_DEFINE(HAVE_STRUCT_LABEL_SUPPORT, 1,
+      [Define to 1 if your compiler supports labels in structs.])
+],[AC_MSG_RESULT(no)
 ])
 ])
diff --git a/src/cf/ctf-tools.m4 b/src/cf/ctf-tools.m4
index 3880a88b8..955078a65 100644
--- a/src/cf/ctf-tools.m4
+++ b/src/cf/ctf-tools.m4
@@ -1,6 +1,6 @@
 AC_DEFUN([OPENAFS_CTF_TOOLS_CHECKS],[
 
-CTF_DEFAULT_PATH="$PATH:/usr/bin:/opt/onbld/bin/$HOST_CPU"
+CTF_DEFAULT_PATH="$PATH:/usr/bin:/opt/onbld/bin/$(uname -p)"
 
 AC_ARG_WITH([ctf-tools],
         AS_HELP_STRING([--with-ctf-tools@<:@=DIR@:>@],
@@ -14,17 +14,25 @@ AS_CASE([$CTF_TOOLS],
 
         [yes],   [AC_PATH_PROG([CTFCONVERT], [ctfconvert], [], [$CTF_DEFAULT_PATH])
                   AC_PATH_PROG([CTFMERGE], [ctfmerge], [], [$CTF_DEFAULT_PATH])
-                  AS_IF([test "x$CTFCONVERT" = "x"], [AC_ERROR("ctfconvert not found")])
-                  AS_IF([test "x$CTFMERGE" = "x"], [AC_ERROR("ctfmerge not found")])],
+                  AS_IF([test "x$CTFCONVERT" = "x"], [AC_MSG_ERROR("ctfconvert not found")])
+                  AS_IF([test "x$CTFMERGE" = "x"], [AC_MSG_ERROR("ctfmerge not found")])],
 
         [no],    [],
 
         [AC_PATH_PROG([CTFCONVERT], [ctfconvert], [], [$CTF_TOOLS])
          AC_PATH_PROG([CTFMERGE], [ctfmerge], [], [$CTF_TOOLS])
-         AS_IF([test "x$CTFCONVERT" = "x"], [AC_ERROR("ctfconvert not found")])
-         AS_IF([test "x$CTFMERGE" = "x"], [AC_ERROR("ctfmerge not found")])]
+         AS_IF([test "x$CTFCONVERT" = "x"], [AC_MSG_ERROR("ctfconvert not found")])
+         AS_IF([test "x$CTFMERGE" = "x"], [AC_MSG_ERROR("ctfmerge not found")])]
 )
 
+CC_WRAPPER=
+LD_WRAPPER=
+AS_IF([test x"$CTFCONVERT" != x && test x"$CTFMERGE" != x],
+      [CC_WRAPPER="$TOP_SRCDIR/config/cc-wrapper cc"
+       LD_WRAPPER="$TOP_SRCDIR/config/cc-wrapper ld"])
+AC_SUBST([CC_WRAPPER])
+AC_SUBST([LD_WRAPPER])
+
 AC_ARG_VAR([CTFCONVERT], [Path to ctfconvert])
 AC_ARG_VAR([CTFMERGE], [Path to ctfmerge])
 ])
diff --git a/src/cf/curses.m4 b/src/cf/curses.m4
index 261305ce1..24c653554 100644
--- a/src/cf/curses.m4
+++ b/src/cf/curses.m4
@@ -37,8 +37,10 @@ AC_DEFUN([_OPENAFS_CURSES_GETMAXYX_XTI],
  AC_CACHE_CHECK([getmaxyx macro], [openafs_cv_curses_getmaxyx],
    [save_LIBS="$LIBS"
     LIBS="$LIBS $LIB_curses"
-    AC_TRY_LINK(_OPENAFS_CURSES_HEADERS,
-		[int mx, my; initscr(); getmaxyx(stdscr, my, mx); endwin();],
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM(
+		_OPENAFS_CURSES_HEADERS,
+		[int mx, my; initscr(); getmaxyx(stdscr, my, mx); endwin();])],
 		[openafs_cv_curses_getmaxyx=yes],
 		[openafs_cv_curses_getmaxyx=no])
     LIBS="$save_LIBS"])
diff --git a/src/cf/functions.m4 b/src/cf/functions.m4
index ac4f5d937..442f759f1 100644
--- a/src/cf/functions.m4
+++ b/src/cf/functions.m4
@@ -12,6 +12,7 @@ AC_CHECK_FUNCS([ \
     getuid \
     getrlimit \
     issetugid \
+    mkdtemp \
     mkstemp \
     openlog \
     poll \
diff --git a/src/cf/gss.m4 b/src/cf/gss.m4
new file mode 100644
index 000000000..002685e05
--- /dev/null
+++ b/src/cf/gss.m4
@@ -0,0 +1,51 @@
+AC_DEFUN([OPENAFS_GSS],
+dnl Probe for GSSAPI
+  [RRA_LIB_GSSAPI
+dnl Check for the characteristics of whatever GSSAPI we found, if we found one
+  BUILD_GSSAPI=no
+  AS_IF([test x"$GSSAPI_LIBS" != x],
+      [BUILD_GSSAPI=yes
+       RRA_LIB_GSSAPI_SWITCH
+       AC_CHECK_FUNCS([gss_pseudo_random \
+                       krb5_gss_register_acceptor_identity \
+                       gss_krb5_ccache_name])
+       RRA_LIB_GSSAPI_RESTORE])
+  AC_SUBST([BUILD_GSSAPI])
+
+dnl Determine if we should build rxgk
+  BUILD_RXGK=no
+  AS_IF([test x"$BUILD_GSSAPI" = xyes],
+    [BUILD_RXGK=yes
+dnl At this point, we're not using any GSS-API bits yet, but we'll need
+dnl gss_pseudo_random() in the future
+     AS_IF([test x"$ac_cv_func_gss_pseudo_random" != xyes],
+       [AC_MSG_NOTICE([GSS-API does not have gss_pseudo_random, this may break in the future])])])
+  AC_SUBST([BUILD_RXGK])
+  AS_IF([test x"$BUILD_RXGK" = xyes],
+        [AC_DEFINE([BUILD_RXGK], [1], [Build rxgk])])
+
+dnl Determine if we should enable rxgk support (note that this is a different
+dnl decision than whether we should build rxgk)
+  ENABLE_RXGK="no"
+  RXGK_LIBS=""
+  RXGK_LIBS_RPC=""
+  RXGK_CFLAGS=""
+  RXGK_GSSAPI_LIBS=""
+  AS_IF([test "$enable_rxgk" = yes],
+    [AS_IF([test "$BUILD_RXGK" = yes],
+       [ENABLE_RXGK="yes"
+        RXGK_LIBS="\$(top_builddir)/src/rxgk/liboafs_rxgk.la"
+        RXGK_LIBS_RPC="\$(top_builddir)/src/rxgk/librxgk_pic.la"
+        RXGK_CFLAGS="\$(CPPFLAGS_gssapi)"
+        RXGK_GSSAPI_LIBS="\$(LDFLAGS_gssapi) \$(LIB_gssapi)"
+        AC_DEFINE([ENABLE_RXGK], [1],
+                  [Build rxgk support into applications])],
+
+       [AC_MSG_ERROR([Insufficient GSS-API support to enable rxgk])])],
+    [ENABLE_RXGK="no"])
+
+  AC_SUBST([ENABLE_RXGK])
+  AC_SUBST([RXGK_LIBS])
+  AC_SUBST([RXGK_LIBS_RPC])
+  AC_SUBST([RXGK_CFLAGS])
+  AC_SUBST([RXGK_GSSAPI_LIBS])])
diff --git a/src/cf/hcrypto.m4 b/src/cf/hcrypto.m4
index 2a9998884..66502627e 100644
--- a/src/cf/hcrypto.m4
+++ b/src/cf/hcrypto.m4
@@ -83,20 +83,23 @@ AC_DEFUN([OPENAFS_HCRYPTO], [
   AC_SUBST(hcrypto_install_target)
 
   AC_ARG_WITH([hcrypto],
-    [AC_HELP_STRING([--with-hcrypto=DIR],
+    [AS_HELP_STRING(
+      [--with-hcrypto=DIR],
       [Location of the hcrypto library, or 'internal'])],
     [AS_IF([test x"$withval" = xno],
-      [AC_ERROR("OpenAFS requires hcrypto to build")],
+      [AC_MSG_ERROR("OpenAFS requires hcrypto to build")],
       [AS_IF([test x"$withval" != xyes],
 	[hcrypto_root="$withval"])])]
   )
   AC_ARG_WITH([hcrypto-include],
-    [AC_HELP_STRING([--with-hcrypto-include=DIR],
+    [AS_HELP_STRING(
+      [--with-hcrypto-include=DIR],
       [Location of hcrypto headers])],
     [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
       [hcrypto_includedir=$withval])])
   AC_ARG_WITH([hcrypto-lib],
-    [AC_HELP_STRING([--with-hcrypto-lib=DIR],
+    [AS_HELP_STRING(
+      [--with-hcrypto-lib=DIR],
       [Location of the hcrypto library])],
     [AS_IF([test x"$withval" != xyes && test x"$withval" != xno],
       [hcrypto_libdir=$withval])])
diff --git a/src/cf/headers.m4 b/src/cf/headers.m4
index 913af4403..af4a4ddb8 100644
--- a/src/cf/headers.m4
+++ b/src/cf/headers.m4
@@ -88,7 +88,8 @@ AC_CHECK_HEADERS([security/pam_modules.h],[],[],[AC_INCLUDES_DEFAULT
 # include <security/pam_appl.h>
 #endif])
 
-AC_CHECK_HEADERS(linux/errqueue.h,,,[#include <linux/types.h>])
+AC_CHECK_HEADERS(linux/errqueue.h,,,[#include <linux/types.h>
+#include <linux/time.h>])
 
 AC_CHECK_TYPES([fsblkcnt_t],,,[
 #include <sys/types.h>
diff --git a/src/cf/irix-test.m4 b/src/cf/irix-test.m4
index 712759a1e..a07112d9e 100644
--- a/src/cf/irix-test.m4
+++ b/src/cf/irix-test.m4
@@ -1,16 +1,16 @@
 AC_DEFUN([IRIX_SYS_SYSTM_H_HAS_MEM_FUNCS], [
   AC_CACHE_CHECK([for mem* in sys/systm.h],
                  [ac_cv_irix_sys_systm_h_has_mem_funcs],
- [
+  [
     save_CPPFLAGS="$CPPFLAGS"
     CPPFLAGS="$CPPFLAGS -D_KERNEL -D__STRING_H__"
-    AC_TRY_COMPILE(
-[#include <sys/types.h>
-#include <sys/systm.h>],
-[extern void     *memcpy(char *, const void *, size_t);
-],
-[ac_cv_irix_sys_systm_h_has_mem_funcs=no],
-[ac_cv_irix_sys_systm_h_has_mem_funcs=yes])
+    AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <sys/types.h>
+          #include <sys/systm.h>]],
+        [[extern void     *memcpy(char *, const void *, size_t);]])],
+      [ac_cv_irix_sys_systm_h_has_mem_funcs=no],
+      [ac_cv_irix_sys_systm_h_has_mem_funcs=yes])
     CPPFLAGS="$save_CPPFLAGS"
   ])
   AS_IF([test "$ac_cv_irix_sys_systm_h_has_mem_funcs" = "yes"],
diff --git a/src/cf/java.m4 b/src/cf/java.m4
deleted file mode 100644
index 2b1277eef..000000000
--- a/src/cf/java.m4
+++ /dev/null
@@ -1,4 +0,0 @@
-AC_DEFUN([OPENAFS_JAVA],[
-dnl Why is configure creating this directory?
-mkdir -p ${TOP_OBJDIR}/src/JAVA/libjafs
-])
diff --git a/src/cf/krb5.m4 b/src/cf/krb5.m4
new file mode 100644
index 000000000..23ed8a765
--- /dev/null
+++ b/src/cf/krb5.m4
@@ -0,0 +1,70 @@
+AC_DEFUN([OPENAFS_KRB5],
+dnl Probe for Kerberos.  We have a few platform-specific overrides due to
+dnl weird Kerberos implementations and installation locations.
+  [AS_CASE([$AFS_SYSNAME],
+     [*_obsd*],
+     [KRB5_CPPFLAGS="-I/usr/include/kerberosV"],
+
+     [ppc_darwin_70],
+     [KRB5_CPPFLAGS="-I/usr/include"
+      KRB5_LDFLAGS="-L/usr/lib -Wl,-search_paths_first"])
+   RRA_LIB_KRB5_OPTIONAL
+   AS_CASE([$AFS_SYSNAME],
+     [hp_ux*|*_hpux*],
+     [KRB5_LIBS="-l:libkrb5.sl -l:libcom_err.sl"])
+
+dnl Check for the characteristics of whatever Kerberos we found, if we found
+dnl one.
+  BUILD_KRB5=no
+  MAKE_KRB5="#"
+  AS_IF([test x"$KRB5_LIBS" != x],
+    [BUILD_KRB5=yes
+     MAKE_KRB5=
+     RRA_LIB_KRB5_SWITCH
+     AC_CHECK_FUNCS([add_error_table \
+                     add_to_error_table \
+                     encode_krb5_enc_tkt_part \
+                     encode_krb5_ticket \
+                     krb5_524_conv_principal \
+                     krb5_allow_weak_crypto \
+                     krb5_c_encrypt \
+                     krb5_decode_ticket \
+                     krb5_enctype_enable \
+                     krb5_free_keytab_entry_contents \
+                     krb5_free_unparsed_name \
+                     krb5_get_init_creds_opt_alloc \
+                     krb5_get_prompt_types \
+                     krb5_princ_size \
+                     krb5_principal_get_comp_string])
+     AC_CHECK_FUNCS([krb5_524_convert_creds], [],
+       [AC_CHECK_FUNCS([krb524_convert_creds_kdc], [],
+          [AC_CHECK_LIB([krb524], [krb524_convert_creds_kdc],
+             [LIBS="-lkrb524 $LIBS"
+              KRB5_LIBS="-lkrb524 $KRB5_LIBS"
+              AC_CHECK_LIB([krb524], [krb5_524_conv_principal],
+                [AC_DEFINE([HAVE_KRB5_524_CONV_PRINCIPAL], [1],
+                           [Define to 1 if you have the `krb5_524_conv_principal' function.])])
+              AC_DEFINE([HAVE_KRB524_CONVERT_CREDS_KDC], [1],
+                        [Define to 1 if you have the `krb524_convert_creds_kdc' function.])])])])
+     AC_CHECK_HEADERS([kerberosIV/krb.h])
+     AC_CHECK_HEADERS([kerberosV/heim_err.h])
+     AC_CHECK_HEADERS([com_err.h et/com_err.h krb5/com_err.h])
+     AS_IF([test x"$ac_cv_header_com_err_h" != xyes \
+               && test x"$ac_cv_header_et_com_err_h" != xyes \
+               && test x"$ac_cv_header_krb5_com_err_h" != xyes],
+       [AC_MSG_ERROR([Cannot find a usable com_err.h])])
+     AC_CHECK_MEMBERS([krb5_creds.keyblock, krb5_creds.keyblock.enctype, krb5_creds.session,
+                       krb5_prompt.type], [], [], [#include <krb5.h>])
+     AC_CHECK_MEMBERS([krb5_keytab_entry.key, krb5_keytab_entry.keyblock],
+                      [], [], [#include <krb5.h>])
+dnl If we have krb5_creds.session, we are using heimdal
+dnl If we're using heimdal, aklog needs libasn1 for encode_EncTicketPart and a
+dnl few other functions. But just aklog; not any of the other stuff that uses
+dnl krb5.
+     AS_IF([test x"$ac_cv_member_krb5_creds_session" = xyes],
+           [AC_CHECK_LIB([asn1], [encode_EncTicketPart],
+                         [AKLOG_KRB5_LIBS="-lasn1"])])
+     RRA_LIB_KRB5_RESTORE])
+  AC_SUBST([BUILD_KRB5])
+  AC_SUBST([MAKE_KRB5])
+  AC_SUBST([AKLOG_KRB5_LIBS])])
diff --git a/src/cf/lex.m4 b/src/cf/lex.m4
index 4658815d4..938b1082c 100644
--- a/src/cf/lex.m4
+++ b/src/cf/lex.m4
@@ -1,5 +1,5 @@
 AC_DEFUN([OPENAFS_LEX],[
-AM_PROG_LEX
+AC_PROG_LEX
 dnl if we are flex, be lex-compatible
 OPENAFS_LEX_IS_FLEX([AC_SUBST([LEX], ["$LEX -l"])])
 ])
diff --git a/src/cf/library.m4 b/src/cf/library.m4
index 17d9220a5..c2c31affa 100644
--- a/src/cf/library.m4
+++ b/src/cf/library.m4
@@ -8,7 +8,9 @@ else
 
   dnl darwin wants it, aix hates it
   AC_MSG_CHECKING(for the useability of arpa/nameser_compat.h)
-  AC_TRY_COMPILE([
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+      [[
   #include <stdlib.h>
   #include <stdio.h>
   #include <sys/types.h>
@@ -18,11 +20,12 @@ else
   #include <arpa/nameser.h>
   #include <arpa/nameser_compat.h>
   #include <resolv.h>
-  ], [static int i; i = 0;],
-  [AC_MSG_RESULT(yes)
-   AC_DEFINE(HAVE_ARPA_NAMESER_COMPAT_H, 1, [define if arpa/nameser_compat.h exists])],
-  [AC_MSG_RESULT(no)
-   ])
+      ]],
+      [[static int i; i = 0;]])],
+   [AC_MSG_RESULT(yes)
+    AC_DEFINE(HAVE_ARPA_NAMESER_COMPAT_H, 1,
+     [define if arpa/nameser_compat.h exists])],
+   [AC_MSG_RESULT(no)])
 
   openafs_save_libs="$LIBS"
   AC_MSG_CHECKING([for res_search])
diff --git a/src/cf/linux-checks.m4 b/src/cf/linux-checks.m4
index a433aff5c..f0d2dafeb 100644
--- a/src/cf/linux-checks.m4
+++ b/src/cf/linux-checks.m4
@@ -14,16 +14,14 @@ AC_DEFUN([_OPENAFS_LINUX_KBUILD_SETUP],[
 if test "x$enable_debug_kernel" = "xno"; then
     LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -fomit-frame-pointer"
 fi
-OPENAFS_GCC_SUPPORTS_MARCH
-AC_SUBST(P5PLUS_KOPTS)
-OPENAFS_GCC_NEEDS_NO_STRENGTH_REDUCE
-OPENAFS_GCC_NEEDS_NO_STRICT_ALIASING
-OPENAFS_GCC_SUPPORTS_NO_COMMON
-OPENAFS_GCC_SUPPORTS_PIPE
+AX_APPEND_COMPILE_FLAGS([-fno-strict-aliasing -fno-strength-reduce \
+                         -fno-common -pipe],
+                        [LINUX_GCC_KOPTS])
 AC_SUBST(LINUX_GCC_KOPTS)
 
 dnl Setup the kernel build environment
 LINUX_KBUILD_USES_EXTRA_CFLAGS
+LINUX_KBUILD_SPARSE_CHECKS
 LINUX_KERNEL_COMPILE_WORKS
 ])
 
diff --git a/src/cf/linux-guess-version.m4 b/src/cf/linux-guess-version.m4
index 365051ad9..c0f9af0d3 100644
--- a/src/cf/linux-guess-version.m4
+++ b/src/cf/linux-guess-version.m4
@@ -6,8 +6,6 @@ else
     GUESS_LINUX_VERSION=`uname -r`
 fi
 case "$GUESS_LINUX_VERSION" in
-    2.2.*) AFS_SYSKVERS=22 ;;
-    2.4.*) AFS_SYSKVERS=24 ;;
     [2.6.* | [3-9]* | [1-2][0-9]*]) AFS_SYSKVERS=26 ;;
     *) AC_MSG_ERROR(Couldn't guess your Linux version [2]) ;;
 esac
diff --git a/src/cf/linux-kernel-assorted.m4 b/src/cf/linux-kernel-assorted.m4
index 384cbca2b..6fa6051f8 100644
--- a/src/cf/linux-kernel-assorted.m4
+++ b/src/cf/linux-kernel-assorted.m4
@@ -9,6 +9,7 @@ LINUX_KMEM_CACHE_CREATE_CTOR_TAKES_VOID
 LINUX_D_PATH_TAKES_STRUCT_PATH
 LINUX_NEW_EXPORT_OPS
 LINUX_INODE_SETATTR_RETURN_TYPE
+LINUX_IATTR_64BIT_TIME
 LINUX_IOP_I_CREATE_TAKES_NAMEIDATA
 LINUX_IOP_I_LOOKUP_TAKES_NAMEIDATA
 LINUX_IOP_I_PERMISSION_TAKES_FLAGS
@@ -54,6 +55,7 @@ LINUX_DOP_D_REVALIDATE_TAKES_UNSIGNED
 LINUX_IOP_LOOKUP_TAKES_UNSIGNED
 LINUX_D_INVALIDATE_IS_VOID
 LINUX_KERNEL_READ_OFFSET_IS_LAST
+LINUX_KEYRING_SEARCH_TAKES_RECURSE
 ])
 
 
@@ -73,5 +75,4 @@ if test "x$ac_cv_linux_func_page_get_link" != "xyes" -a "x$ac_cv_linux_struct_in
     AC_MSG_ERROR([Your kernel does not use follow_link - not supported without symlink cache API])
     exit 1
 fi
-: dnl remnant no-op
 ])
diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4
index 0b17e172e..10b7c97dd 100644
--- a/src/cf/linux-kernel-func.m4
+++ b/src/cf/linux-kernel-func.m4
@@ -42,6 +42,9 @@ AC_CHECK_LINUX_FUNC([d_make_root],
 AC_CHECK_LINUX_FUNC([do_sync_read],
                     [#include <linux/fs.h>],
                     [do_sync_read(NULL, NULL, 0, NULL);])
+AC_CHECK_LINUX_FUNC([fatal_signal_pending],
+                    [#include <linux/sched.h>],
+                    [fatal_signal_pending(NULL);])
 AC_CHECK_LINUX_FUNC([file_dentry],
                     [#include <linux/fs.h>],
                     [struct file *f; file_dentry(f);])
@@ -72,9 +75,20 @@ AC_CHECK_LINUX_FUNC([iter_file_splice_write],
 AC_CHECK_LINUX_FUNC([kernel_setsockopt],
                     [#include <linux/net.h>],
                     [kernel_setsockopt(NULL, 0, 0, NULL, 0);])
+AC_CHECK_LINUX_FUNC([ktime_get_coarse_real_ts64],
+                    [#include <linux/ktime.h>],
+                    [struct timespec64 *s;
+                    ktime_get_coarse_real_ts64(s);])
+AC_CHECK_LINUX_FUNC([ktime_get_real_ts64],
+                    [#include <linux/ktime.h>],
+                    [struct timespec64 *s;
+                    ktime_get_real_ts64(s);])
 AC_CHECK_LINUX_FUNC([locks_lock_file_wait],
                     [#include <linux/fs.h>],
                     [locks_lock_file_wait(NULL, NULL);])
+AC_CHECK_LINUX_FUNC([override_creds],
+                    [#include <linux/cred.h>],
+                    [override_creds(0);])
 AC_CHECK_LINUX_FUNC([page_follow_link],
                     [#include <linux/fs.h>],
                     [page_follow_link(0,0);])
@@ -135,6 +149,24 @@ AC_CHECK_LINUX_FUNC([inode_lock],
                     [#include <linux/fs.h>],
                     [inode_lock(NULL);])
 
+dnl lru_cache_add_file added to Linux 2.6.28.
+dnl                    removed in Linux 5.8
+AC_CHECK_LINUX_FUNC([lru_cache_add_file],
+                    [#include <linux/swap.h>],
+                    [lru_cache_add_file(NULL);])
+
+dnl lru_cache_add exported in Linux 5.8
+dnl    replaces lru_cache_add_file
+AC_CHECK_LINUX_FUNC([lru_cache_add],
+                    [#include <linux/swap.h>],
+                    [lru_cache_add(NULL);])
+
+dnl Linux 5.8 replaced kernel_setsockopt with helper functions
+dnl e.g. ip_sock_set_mtu_discover, ip_sock_set_recverr
+AC_CHECK_LINUX_FUNC([ip_sock_set],
+                    [#include <net/ip.h>],
+                    [ip_sock_set_mtu_discover(NULL, 0);])
+
 dnl Consequences - things which get set as a result of the
 dnl                above tests
 AS_IF([test "x$ac_cv_linux_func_d_alloc_anon" = "xno"],
diff --git a/src/cf/linux-kernel-path.m4 b/src/cf/linux-kernel-path.m4
index ac43a859d..2c6212ad8 100644
--- a/src/cf/linux-kernel-path.m4
+++ b/src/cf/linux-kernel-path.m4
@@ -4,7 +4,6 @@ if test "x$with_linux_kernel_headers" != "x"; then
 else
   for utsdir in "/lib/modules/`uname -r`/build" \
                 "/lib/modules/`uname -r`/source" \
-                "/usr/src/linux-2.4" \
                 "/usr/src/linux"; do
     LINUX_KERNEL_PATH="$utsdir"
     for utsfile in "include/generated/utsrelease.h" \
diff --git a/src/cf/linux-kernel-struct.m4 b/src/cf/linux-kernel-struct.m4
index c97450f93..003d34ab8 100644
--- a/src/cf/linux-kernel-struct.m4
+++ b/src/cf/linux-kernel-struct.m4
@@ -30,6 +30,7 @@ AC_CHECK_LINUX_STRUCT([key_type], [preparse], [key-type.h])
 AC_CHECK_LINUX_STRUCT([msghdr], [msg_iter], [socket.h])
 AC_CHECK_LINUX_STRUCT([nameidata], [path], [namei.h])
 AC_CHECK_LINUX_STRUCT([proc_dir_entry], [owner], [proc_fs.h])
+AC_CHECK_LINUX_STRUCT([proc_ops], [proc_compat_ioctl], [proc_fs.h])
 AC_CHECK_LINUX_STRUCT([super_block], [s_bdi], [fs.h])
 AC_CHECK_LINUX_STRUCT([super_block], [s_d_op], [fs.h])
 AC_CHECK_LINUX_STRUCT([super_operations], [alloc_inode],
diff --git a/src/cf/linux-kernel-type.m4 b/src/cf/linux-kernel-type.m4
index 57c8b3729..444317da5 100644
--- a/src/cf/linux-kernel-type.m4
+++ b/src/cf/linux-kernel-type.m4
@@ -2,4 +2,6 @@ AC_DEFUN([OPENAFS_LINUX_KERNEL_TYPE_CHECKS],[
 dnl Type existence checks
 AC_CHECK_LINUX_TYPE([struct vfs_path], [dcache.h])
 AC_CHECK_LINUX_TYPE([kuid_t], [uidgid.h])
+AC_CHECK_LINUX_TYPE([struct proc_ops], [proc_fs.h])
+AC_CHECK_LINUX_TYPE([time_t], [types.h])
 ])
diff --git a/src/cf/linux-test1.m4 b/src/cf/linux-test1.m4
index 95e4af025..9390b9a6d 100644
--- a/src/cf/linux-test1.m4
+++ b/src/cf/linux-test1.m4
@@ -27,8 +27,8 @@ $2
 
 MODULE_LICENSE("http://www.openafs.org/dl/license10.html");
 _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 &&
+    echo make -C $LINUX_KERNEL_BUILD M=$SRCDIR_PARENT/conftest.dir $SPARSE_MAKEFLAGS modules KBUILD_VERBOSE=1 >&AS_MESSAGE_LOG_FD &&
+    make -C $LINUX_KERNEL_BUILD M=$SRCDIR_PARENT/conftest.dir $SPARSE_MAKEFLAGS modules KBUILD_VERBOSE=1 >&AS_MESSAGE_LOG_FD 2>conftest.err &&
     ! grep -i "WARNING: .* undefined!$" conftest.err >/dev/null 2>&1
     then [$3]
     else
@@ -47,9 +47,9 @@ _ACEOF
 AC_DEFUN([AC_TRY_KBUILD24], [
   ac_save_CPPFLAGS="$CPPFLAGS"
   CPPFLAGS="-I$LINUX_KERNEL_PATH/include -D__KERNEL__ -Werror-implicit-function-declaration $CPPFLAGS"
-  AC_TRY_COMPILE([
+  AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <linux/kernel.h>
-$1], [$2], [$3], [$4])
+$1]], [[$2]])],[$3],[$4])
   CPPFLAGS="$ac_save_CPPFLAGS"])
 
 
@@ -85,6 +85,28 @@ AC_DEFUN([LINUX_KBUILD_USES_EXTRA_CFLAGS], [
     CPPFLAGS="$save_CPPFLAGS"
     AC_MSG_RESULT($ac_linux_kbuild_requires_extra_cflags)])
 
+AC_DEFUN([LINUX_KBUILD_SPARSE_CHECKS], [
+  AC_ARG_WITH([sparse],
+              AS_HELP_STRING([--with-sparse@<:@=PATH@:>@],
+                             [Location of the 'sparse' tool]),
+              [SPARSE="$withval"],
+              [SPARSE=check])
+
+  AS_CASE([$SPARSE],
+          [check], [AC_PATH_PROG([SPARSE], [sparse], [])],
+          [yes],   [AC_PATH_PROG([SPARSE], [sparse], [])
+                    AS_IF([test "x$SPARSE" = "x"], [AC_MSG_ERROR([sparse not found])])],
+          [no],    [SPARSE=])
+
+  AS_IF([test x"$SPARSE" != x],
+        [SPARSE_MAKEFLAGS="C=2 CHECK=$SPARSE"])
+
+  AC_SUBST([SPARSE_MAKEFLAGS])
+
+  AC_ARG_VAR([SPARSE], [Path to the 'sparse' tool])
+])
+
+
 dnl AC_CHECK_LINUX_BUILD([msg], [var], [includes], [code], [define], [CFLAGS])
 AC_DEFUN([AC_CHECK_LINUX_BUILD],
  [AS_VAR_PUSHDEF([ac_linux_build], [$2])dnl
diff --git a/src/cf/linux-test4.m4 b/src/cf/linux-test4.m4
index cdac30fba..f7699cec3 100644
--- a/src/cf/linux-test4.m4
+++ b/src/cf/linux-test4.m4
@@ -183,7 +183,22 @@ AC_DEFUN([LINUX_INODE_SETATTR_RETURN_TYPE], [
 		       [])
 ])
 
-
+AC_DEFUN([LINUX_IATTR_64BIT_TIME], [
+  AC_CHECK_LINUX_BUILD([whether struct iattr->ia_ctime takes struct timespec64 or 32-bit struct timespec],
+                       [ac_cv_linux_func_iattr_ctime_takes_timespec64],
+                       [#include <linux/fs.h>
+                        #include <linux/timekeeping.h>],
+                       [struct iattr _attrs;
+                       #if defined(HAVE_LINUX_KTIME_GET_COARSE_REAL_TS64)
+                        ktime_get_coarse_real_ts64(&_attrs.ia_ctime);
+                       #else
+                        _attrs.ia_ctime = current_kernel_time64();
+                       #endif
+                       ],
+                       [IATTR_TAKES_64BIT_TIME],
+                       [define if struct iattr->ia_ctime takes struct timespec64],
+                       [])
+])
 
 AC_DEFUN([LINUX_AOP_WRITEBACK_CONTROL], [
   AC_CHECK_LINUX_BUILD([whether aop.writepage takes a writeback_control],
@@ -821,3 +836,16 @@ AC_DEFUN([LINUX_KERNEL_READ_OFFSET_IS_LAST], [
                        [define if your kernel_read has offset as the last argument],
                        [])
 ])
+
+AC_DEFUN([LINUX_KEYRING_SEARCH_TAKES_RECURSE], [
+  AC_CHECK_LINUX_BUILD([whether keyring_search has the recurse parameter],
+                       [ac_cv_linux_func_keyring_search_takes_recurse],
+                       [#include <linux/key.h>
+                       key_ref_t tkey;],
+                       [
+                       keyring_search(tkey, NULL, NULL, 0);
+                       ],
+                       [KEYRING_SEARCH_TAKES_RECURSE],
+                       [define if your keyring_search has the recurse parameter],
+                       [])
+])
diff --git a/src/cf/linux-test5.m4 b/src/cf/linux-test5.m4
deleted file mode 100644
index 90c312cba..000000000
--- a/src/cf/linux-test5.m4
+++ /dev/null
@@ -1,78 +0,0 @@
-dnl These options seem to only be used for the 2.4.x
-dnl Linux kernel build
-AC_DEFUN([OPENAFS_GCC_SUPPORTS_MARCH], [
-  AC_CACHE_CHECK([if $CC accepts -march=pentium],
-    [openafs_cv_gcc_supports_march],
-    [save_CFLAGS="$CFLAGS"
-     CFLAGS="-MARCH=pentium"
-     AC_TRY_COMPILE([],
-		    [int x;],
-		    [openafs_cv_gcc_supports_march=yes],
-		    [openafs_cv_gcc_supports_march=no])
-     CFLAGS="$save_CFLAGS"
-    ])
-  AS_IF([test x$openafs_cv_gcc_supports_march = xyes],
-        [P5PLUS_KOPTS="-march=pentium"],
-        [P5PLUS_KOPTS="-m486 -malign-loops=2 -malign-jumps=2 -malign-functions=2"])
-])
-
-AC_DEFUN([OPENAFS_GCC_NEEDS_NO_STRICT_ALIASING], [
-  AC_CACHE_CHECK([if $CC needs -fno-strict-aliasing],
-    [openafs_cv_gcc_needs_no_strict_aliasing],
-    [save_CFLAGS="$CFLAGS"
-     CFLAGS="-fno-strict-aliasing"
-     AC_TRY_COMPILE([],
-		    [int x;],
-		    [openafs_cv_gcc_needs_no_strict_aliasing=yes],
-		    [openafs_cv_gcc_needs_no_strict_aliasing=no])
-     CFLAGS="$save_CFLAGS"
-  ])
-  AS_IF([test x$openafs_cv_gcc_needs_no_strict_aliasing = xyes],
-        [LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -fno-strict-aliasing"])
-])
-
-AC_DEFUN([OPENAFS_GCC_NEEDS_NO_STRENGTH_REDUCE], [
-  AC_CACHE_CHECK([if $CC needs -fno-strength-reduce],
-    [openafs_cv_gcc_needs_no_strength_reduce],
-    [save_CFLAGS="$CFLAGS"
-     CFLAGS="-fno-strength-reduce"
-     AC_TRY_COMPILE([],
-		    [int x;],
-		    [openafs_cv_gcc_needs_no_strength_reduce=yes],
-		    [openafs_cv_gcc_needs_no_strength_reduce=no])
-     CFLAGS="$save_CFLAGS"
-  ])
-  AS_IF([test x$openafs_cv_gcc_needs_no_strength_reduce = xyes],
-        [LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -fno-strength-reduce"])
-])
-
-AC_DEFUN([OPENAFS_GCC_SUPPORTS_NO_COMMON], [
-  AC_CACHE_CHECK([if $CC supports -fno-common],
-    [openafs_cv_gcc_supports_no_common],
-    [save_CFLAGS="$CFLAGS"
-     CFLAGS="-fno-common"
-     AC_TRY_COMPILE([],
-		    [int x;],
-		    [openafs_cv_gcc_supports_no_common=yes],
-		    [openafs_cv_gcc_supports_no_common=no])
-
-     CFLAGS="$save_CFLAGS"
-  ])
-  AS_IF([test x$openafs_cv_gcc_supports_no_common = xyes],
-	[LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -fno-common"])
-])
-
-AC_DEFUN([OPENAFS_GCC_SUPPORTS_PIPE], [
-  AC_CACHE_CHECK([if $CC supports -pipe],
-    [openafs_cv_gcc_supports_pipe],
-    [save_CFLAGS="$CFLAGS"
-     CFLAGS="-pipe"
-     AC_TRY_COMPILE([],
-		    [int x;],
-		    [openafs_cv_gcc_supports_pipe=yes],
-		    [openafs_cv_gcc_supports_pipe=no])
-  CFLAGS="$save_CFLAGS"
-  ])
-  AS_IF([test x$openafs_cv_gcc_supports_pipe = xyes],
-	  [LINUX_GCC_KOPTS="$LINUX_GCC_KOPTS -pipe"])
-])
diff --git a/src/cf/options.m4 b/src/cf/options.m4
index a92b7c04a..904e09791 100644
--- a/src/cf/options.m4
+++ b/src/cf/options.m4
@@ -53,7 +53,7 @@ AC_ARG_WITH([linux-kernel-headers],
     [AS_HELP_STRING([--with-linux-kernel-headers=path],
         [use the kernel headers found at path (optional, defaults to
          /lib/modules/`uname -r`/build, then /lib/modules/`uname -r`/source,
-         then /usr/src/linux-2.4, and lastly /usr/src/linux)])
+         and lastly /usr/src/linux)])
 ])
 AC_ARG_WITH([linux-kernel-build],
     [AS_HELP_STRING([--with-linux-kernel-build=path],
@@ -107,6 +107,16 @@ AC_ARG_ENABLE([kauth],
     [enable_kauth="no"
      enable_pam="no"])
 
+dnl modern crypto
+dnl Note that this flag only dictates whether or not rxgk support is turned on
+dnl in various daemons, utilities, etc. Without this flag, we still always try
+dnl to build rxgk when we can (when a suitable gssapi is available).
+AC_ARG_ENABLE([rxgk],
+    [AS_HELP_STRING([--enable-rxgk],
+        [Include experimental support for the RXGK security class (defaults to disabled)])],
+    [],
+    [enable_rxgk="no"])
+
 dnl Optimization and debugging flags.
 AC_ARG_ENABLE([strip-binaries],
     [AS_HELP_STRING([--disable-strip-binaries],
@@ -241,7 +251,7 @@ AC_ARG_WITH([docbook-stylesheets],
                  /opt/local/share/xsl/docbook-xsl],
                 [$HTML_XSL])
            AS_IF([test "x$DOCBOOK_STYLESHEETS" = "x"],
-                [AC_WARN([Docbook stylesheets not found; some documentation can't be built])
+                [AC_MSG_WARN(Docbook stylesheets not found; some documentation can't be built)
            ])
         ])
 
@@ -337,4 +347,12 @@ fi
 if test "x$enable_pthreaded_ubik" = "xyes"; then
 ENABLE_PTHREADED_UBIK=yes
 fi
+
+dnl If the libtool --disable-shared option is specified, comment out the
+dnl @SHARED_ONLY@ lines in our Makefiles.
+AS_IF([test x"$enable_shared" = xyes],
+ [SHARED_ONLY=],
+ [SHARED_ONLY=#])
+AC_SUBST([SHARED_ONLY])
+
 ])
diff --git a/src/cf/osconf.m4 b/src/cf/osconf.m4
index 214dc49b8..53ded31e4 100644
--- a/src/cf/osconf.m4
+++ b/src/cf/osconf.m4
@@ -25,57 +25,41 @@ PAM_OPTMZ=
 
 dnl standard programs
 AC_PROG_RANLIB
-AC_CHECK_PROGS(AS, as, [${am_missing_run}as])
-AC_CHECK_PROGS(AR, ar, [${am_missing_run}ar])
-AC_CHECK_PROGS(MV, mv, [${am_missing_run}mv])
-AC_CHECK_PROGS(RM, rm, [${am_missing_run}rm])
-AC_CHECK_PROGS(LD, ld, [${am_missing_run}ld])
-AC_CHECK_PROGS(CP, cp, [${am_missing_run}cp])
-AC_CHECK_PROGS(STRIP, strip, [${am_missing_run}strip])
-AC_CHECK_PROGS(LORDER, lorder, [${am_missing_run}lorder])
-AC_CHECK_PROGS(GENCAT, gencat, [${am_missing_run}gencat])
+AC_CHECK_PROGS(AS, as, [false])
+AC_CHECK_PROGS(MV, mv, [false])
+AC_CHECK_PROGS(RM, rm, [false])
+AC_CHECK_PROGS(LD, ld, [false])
+AC_CHECK_PROGS(CP, cp, [false])
+AC_CHECK_PROGS(GENCAT, gencat, [false])
+
+dnl if ar is not present, libtool.m4 (provided by libtool) sets AR to false
+dnl if strip is not present, libtool.m4 (provided by libtool) sets STRIP to :
+AS_IF([test "x$AR" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'ar'])])
+AS_IF([test "x$AS" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'as'])])
+AS_IF([test "x$MV" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'mv'])])
+AS_IF([test "x$RM" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'rm'])])
+AS_IF([test "x$LD" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'ld'])])
+AS_IF([test "x$CP" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'cp'])])
+AS_IF([test "x$GENCAT" = "xfalse"], [AC_MSG_ERROR([cannot find required command 'gencat'])])
 
 dnl TODO - need to disable STRIP if we are doing debugging in any user space code
 
 case $AFS_SYSNAME in
-	alpha_dux40)
-		CC="cc"
-		CSTATIC="-non_shared"
-		DBG="-g3"
-		MT_CFLAGS='-D_REENTRANT=1 -pthread'
-		MT_LIBS="-pthread -lpthread -lmach -lexc -lc"
-		XCFLAGS="-D_NO_PROTO -DOSF"
-		SHLIB_LINKER="${CC} -all -shared -expect_unresolved \"*\""
-		;;
-
-	alpha_dux50 | alpha_dux51)
-		CC="cc"
-		DBG="-g3"
-		CSTATIC="-non_shared"
-		LWP_OPTMZ="-O2"
-		MT_CFLAGS='-D_REENTRANT=1 -pthread'
-		MT_LIBS="-pthread -lpthread -lmach -lexc -lc"
-		XCFLAGS="-D_NO_PROTO -DOSF"
-		SHLIB_LINKER="${CC} -all -shared -expect_unresolved \"*\""
-		;;
-
 	alpha_linux_22 | alpha_linux_24 | alpha_linux_26)
 		CCOBJ="\$(CC) -fPIC"
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
-	arm_linux_24 | arm_linux26)
+	arm_linux_24 | arm_linux26 | arm64_linux26)
 		CCOBJ="\$(CC) -fPIC"
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
@@ -94,7 +78,6 @@ case $AFS_SYSNAME in
 		PAM_LIBS="/usr/lib/libpam.1"
 		RANLIB="/usr/bin/ranlib"
 		RM="/bin/rm"
-		SHLIB_LDFLAGS="-b -Bsymbolic"
 		SHLIB_SUFFIX="sl"
 		VFSCK_CFLAGS="-D_FILE64"
 		XCFLAGS0="-ldld -lc -Wp,-H200000 -Wl,-a,archive -DAUTH_DBM_LOG +z -Wl,+k -D_LARGEFILE64_SOURCE"
@@ -119,7 +102,6 @@ case $AFS_SYSNAME in
 		PAM_LIBS="/usr/lib/libpam.1"
 		RANLIB="/usr/bin/ranlib"
 		RM="/bin/rm"
-		SHLIB_LDFLAGS="-b -Bsymbolic"
 		SHLIB_SUFFIX="sl"
 		VFSCK_CFLAGS="-I/usr/old/usr/include -D_FILE64"
 		XCFLAGS0="-ldld -lc -Wp,-H200000 -Wl,-a,archive -DAUTH_DBM_LOG +z -Wl,+k -D_LARGEFILE64_SOURCE"
@@ -145,7 +127,6 @@ case $AFS_SYSNAME in
 		PAM_LIBS="/usr/lib/hpux32/libpam.so"
 		RANLIB="/usr/bin/ranlib"
 		RM="/bin/rm"
-		SHLIB_LDFLAGS="-b -Bsymbolic"
 		SHLIB_SUFFIX="sl"
 		VFSCK_CFLAGS="-I/usr/old/usr/include -D_FILE64"
 		XCFLAGS0="-ldld -lc -Wp,-H200000 -Wl,-a,archive_shared -DAUTH_DBM_LOG +z -Wl,+k -D_LARGEFILE64_SOURCE"
@@ -160,7 +141,6 @@ case $AFS_SYSNAME in
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-pipe -fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		XCFLAGS="-pipe"
 		;;
@@ -169,7 +149,6 @@ case $AFS_SYSNAME in
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-pipe -fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		XCFLAGS="-pipe"
 		;;
@@ -177,7 +156,6 @@ case $AFS_SYSNAME in
 	amd64_fbsd_*)
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_CFLAGS="-O2 -pipe -fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		XCFLAGS="-O2 -pipe -fPIC"
 		;;
@@ -187,7 +165,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-pipe -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		XCFLAGS="-pipe"
 		;;
@@ -196,7 +173,6 @@ case $AFS_SYSNAME in
 		MT_LIBS='${XLIBS}'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-pipe -fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		XCFLAGS="-pipe"
 		;;
@@ -207,7 +183,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		XCFLAGS="-G0"
 		SHLIB_LINKER="${CC} -shared"
 		;;
@@ -219,15 +194,13 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
-	ppc64_linux26)
+	ppc64_linux26|ppc64le_linux26)
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_CFLAGS="-fPIC"
 		SHLIB_LINKER="${CC} -shared -m64"
 		XCFLAGS="-m64"
@@ -245,7 +218,6 @@ case $AFS_SYSNAME in
 		OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
@@ -258,7 +230,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
@@ -270,7 +241,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-pipe -fpic"
 		SHLIB_CFLAGS="-fpic"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		XCFLAGS=
 		;;
@@ -344,7 +314,7 @@ case $AFS_SYSNAME in
 		XLIBS="${LIB_AFSDB} -framework CoreFoundation"
 		;;
 
-	*_darwin_100 | *_darwin_110 | *_darwin_120 | *_darwin_130 | *_darwin_140 | *_darwin_150 | *_darwin_160 | *_darwin_170)
+	*_darwin_100 | *_darwin_110 | *_darwin_120 | *_darwin_130 | *_darwin_140 | *_darwin_150 | *_darwin_160 | *_darwin_170 | *_darwin_180)
 		AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration -framework SystemConfiguration -framework IOKit -framework CoreFoundation"
 		MT_CFLAGS="-D_REENTRANT"
 		MT_LIBS='${XLIBS}'
@@ -363,13 +333,31 @@ case $AFS_SYSNAME in
 		XLIBS="${LIB_AFSDB} -framework CoreFoundation"
 		;;
 
+	*_darwin_190)
+		AFSD_LDFLAGS="-F/System/Library/PrivateFrameworks -framework DiskArbitration -framework SystemConfiguration -framework IOKit -framework CoreFoundation"
+		MT_CFLAGS="-D_REENTRANT"
+		MT_LIBS='${XLIBS}'
+		KROOT='/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk'
+		KINCLUDES='-I$(KROOT)/System/Library/Frameworks/Kernel.framework/Headers'
+		LD="cc"
+		KERN_OPTMZ="-Os"
+		LWP_OPTMZ="-Os"
+		OPTMZ="-Os"
+		PAM_LIBS="-lpam"
+		REGEX_OBJ="regex.lo"
+		EXTRA_VLIBOBJS="fstab.o"
+		SHLIB_LINKER="${CC} \${ARCHFLAGS} -dynamiclib"
+		SHLIB_SUFFIX="dylib"
+		RANLIB="ranlib"
+		XLIBS="${LIB_AFSDB} -framework CoreFoundation"
+		;;
+
 	ppc_linux*)
 		KERN_OPTMZ=-O2
 		MT_CFLAGS='-pthread -D_REENTRANT'
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
@@ -419,7 +407,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		SHLIB_LINKER="${CC} -shared"
 		;;
 
@@ -431,7 +418,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x -Xlinker -Bsymbolic"
 		OPTMZ=-O
 		XCFLAGS="-D__s390x__"
 		SHLIB_LINKER="${CC} -shared"
@@ -492,7 +478,6 @@ case $AFS_SYSNAME in
 		PAM_OPTMZ=-O2
 		PAM_CFLAGS="-Dlinux -DLINUX_PAM -fPIC"
 		SHLIB_CFLAGS="-fPIC"
-		SHLIB_LDFLAGS="-shared -Xlinker -x"
 		XCFLAGS64="-m64"
 		XLDFLAGS64="-m64"
 		SHLIB_LINKER="${CC} -shared"
@@ -505,7 +490,6 @@ case $AFS_SYSNAME in
 		PAM_CFLAGS="-KPIC"
 		PAM_LIBS="-lc -lpam -lsocket -lnsl -lm"
 		SHLIB_CFLAGS="-KPIC"
-		SHLIB_LDFLAGS="-G -Bsymbolic"
 		XCFLAGS64='${XCFLAGS} -m64'
 		XCFLAGS="-dy -Bdynamic"
 		XLIBELFA="-lelf"
@@ -544,7 +528,6 @@ case $AFS_SYSNAME in
 		PAM_CFLAGS="-KPIC"
 		PAM_LIBS="-lc -lpam -lsocket -lnsl -lm"
 		SHLIB_CFLAGS="-KPIC"
-		SHLIB_LDFLAGS="-G -Bsymbolic"
 		XCFLAGS0="-dy -Bdynamic"
 		XCFLAGS64="${XCFLAGS0} -m64"
 		XCFLAGS="${XCFLAGS0} ${XARCHFLAGS}"
@@ -639,6 +622,7 @@ CFLAGS_NOERROR=
 CFLAGS_NOSTRICT=-fno-strict-aliasing
 CFLAGS_NOUNUSED=
 CFLAGS_NOOLDSTYLE=
+CFLAGS_NOIMPLICIT_FALLTHROUGH=
 XCFLAGS_NOCHECKING="$XCFLAGS"
 
 if test "x$GCC" = "xyes"; then
@@ -646,11 +630,14 @@ if test "x$GCC" = "xyes"; then
     XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Wpointer-arith"
   fi
   if test "x$enable_checking" != "xno"; then
-    XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith"
+    XCFLAGS="${XCFLAGS} -Wall -Wstrict-prototypes -Wold-style-definition -Werror -fdiagnostics-show-option -Wpointer-arith -fno-common"
+    CFLAGS_WERROR="-Werror"
     if test "x$enable_checking" != "xall"; then
       CFLAGS_NOERROR="-Wno-error"
       CFLAGS_NOUNUSED="-Wno-unused"
       CFLAGS_NOOLDSTYLE="-Wno-old-style-definition"
+      AX_APPEND_COMPILE_FLAGS([-Wno-implicit-fallthrough],
+                               [CFLAGS_NOIMPLICIT_FALLTHROUGH])
       AC_DEFINE(IGNORE_SOME_GCC_WARNINGS, 1, [define to disable some gcc warnings in warnings-as-errors mode])
     else
       CFLAGS_NOSTRICT=
@@ -674,6 +661,11 @@ else
   esac
 fi
 
+dnl add additional checks if compilers support the flags
+AS_IF([test "x$enable_checking" != "xno"],
+      [AX_APPEND_COMPILE_FLAGS([-Wimplicit-fallthrough], [XCFLAGS])
+])
+
 dnl horribly cheating, assuming double / is ok.
 case $INSTALL in
   ./* ) 
@@ -718,7 +710,6 @@ AC_SUBST(REGEX_OBJ)
 AC_SUBST(RM)
 AC_SUBST(RXDEBUG)
 AC_SUBST(SHLIB_CFLAGS)
-AC_SUBST(SHLIB_LDFLAGS)
 AC_SUBST(SHLIB_LINKER)
 AC_SUBST(SHLIB_SUFFIX)
 AC_SUBST(VFSCK_CFLAGS)
@@ -727,6 +718,8 @@ AC_SUBST(CFLAGS_NOERROR)
 AC_SUBST(CFLAGS_NOSTRICT)
 AC_SUBST(CFLAGS_NOUNUSED)
 AC_SUBST(CFLAGS_NOOLDSTYLE)
+AC_SUBST(CFLAGS_NOIMPLICIT_FALLTHROUGH)
+AC_SUBST(CFLAGS_WERROR)
 AC_SUBST(XCFLAGS64)
 AC_SUBST(XLDFLAGS)
 AC_SUBST(XLDFLAGS64)
@@ -734,6 +727,8 @@ AC_SUBST(XLIBELFA)
 AC_SUBST(XLIBKVM)
 AC_SUBST(XLIBS)
 AC_SUBST(YACC)
+AC_SUBST(KROOT)
+AC_SUBST(KINCLUDES)
 
 
 ])
diff --git a/src/cf/ostype.m4 b/src/cf/ostype.m4
index ae4da4633..76e2b0ce8 100644
--- a/src/cf/ostype.m4
+++ b/src/cf/ostype.m4
@@ -18,11 +18,6 @@ case $system in
                 AC_MSG_RESULT(sun4)
                 OPENAFS_SOLARIS_OSTYPE
                 ;;
-        *-sunos*)
-                MKAFS_OSTYPE=SUNOS
-                enable_kernel_module=no
-                AC_MSG_RESULT(sun4)
-                ;;
         *-hpux*)
                 MKAFS_OSTYPE=HPUX
                 AC_MSG_RESULT(hp_ux)
diff --git a/src/cf/hpux.m4 b/src/cf/pio.m4
similarity index 96%
rename from src/cf/hpux.m4
rename to src/cf/pio.m4
index 0ceed168a..6286e5dba 100644
--- a/src/cf/hpux.m4
+++ b/src/cf/pio.m4
@@ -1,4 +1,4 @@
-AC_DEFUN([OPENAFS_HPUX_CHECKS],[
+AC_DEFUN([OPENAFS_PIO_CHECKS],[
 case $AFS_SYSNAME in
 *hp_ux* | *hpux*)
    AC_MSG_WARN([Some versions of HP-UX have a buggy positional I/O implementation. Forcing no positional I/O.])
diff --git a/src/cf/pthread.m4 b/src/cf/pthread.m4
index 02292c5ac..94aadad9c 100644
--- a/src/cf/pthread.m4
+++ b/src/cf/pthread.m4
@@ -1,76 +1,71 @@
-AC_DEFUN([OPENAFS_PTHREAD_CHECKS],[
-PTHREAD_LIBS=error
-if test "x$MKAFS_OSTYPE" = OBSD; then
-        PTHREAD_LIBS="-pthread"
-fi
-if test "x$MKAFS_OSTYPE" = xDFBSD; then
-        PTHREAD_LIBS="-pthread"
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_LIB(pthread, pthread_attr_init,
-                PTHREAD_LIBS="-lpthread")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_LIB(pthreads, pthread_attr_init,
-                PTHREAD_LIBS="-lpthreads")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_LIB(c_r, pthread_attr_init,
-                PTHREAD_LIBS="-lc_r")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_CHECK_FUNC(pthread_attr_init, PTHREAD_LIBS="")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        # pthread_attr_init is a macro under HPUX 11.0 and 11.11
-        AC_CHECK_LIB(pthread, pthread_attr_destroy,
-                PTHREAD_LIBS="-lpthread")
-fi
-if test "x$PTHREAD_LIBS" = xerror; then
-        AC_MSG_WARN(*** Unable to locate working posix thread library ***)
-fi
-AC_SUBST(PTHREAD_LIBS)
-])
+AC_DEFUN([OPENAFS_PTHREAD_CHECKS],
+[PTHREAD_LIBS=error
+AS_IF([test "x$MKAFS_OSTYPE" = OBSD],
+  [PTHREAD_LIBS="-pthread"])
+AS_IF([test "x$MKAFS_OSTYPE" = xDFBSD],
+  [PTHREAD_LIBS="-pthread"])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_LIB([pthread], [pthread_attr_init],
+                [PTHREAD_LIBS="-lpthread"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_LIB([pthreads], [pthread_attr_init],
+                [PTHREAD_LIBS="-lpthreads"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_LIB([c_r], [pthread_attr_init],
+                [PTHREAD_LIBS="-lc_r"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_CHECK_FUNC([pthread_attr_init], [PTHREAD_LIBS=""])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [# pthread_attr_init is a macro under HPUX 11.0 and 11.11
+   AC_CHECK_LIB([pthread], [pthread_attr_destroy],
+                [PTHREAD_LIBS="-lpthread"])])
+AS_IF([test "x$PTHREAD_LIBS" = xerror],
+  [AC_MSG_WARN([*** Unable to locate working posix thread library ***])])
+AC_SUBST([PTHREAD_LIBS])
+]) # OPENAFS_PTHREADS_CHECKS
 
-AC_DEFUN([OPENAFS_MORE_PTHREAD_CHECKS],[
-dnl Look for "non-portable" pthreads functions.
+AC_DEFUN([OPENAFS_MORE_PTHREAD_CHECKS],
+[dnl Look for "non-portable" pthreads functions.
 save_LIBS="$LIBS"
 LIBS="$LIBS $PTHREAD_LIBS"
 AC_CHECK_FUNCS([ \
-        pthread_set_name_np \
-        pthread_setname_np \
+  pthread_set_name_np \
+  pthread_setname_np \
 ])
-
 dnl Sadly, there are three different versions of pthread_setname_np.
 dnl Try to cater for all of them.
-if test "$ac_cv_func_pthread_setname_np" = "yes" ; then
-    AC_MSG_CHECKING([for signature of pthread_setname_np])
-    AC_TRY_COMPILE([
-#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
-], [pthread_setname_np(pthread_self(), "test", (void *)0)], [
-        AC_MSG_RESULT([three arguments])
-        pthread_setname_np_args=3], [
-        AC_TRY_COMPILE([
-#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
-], [pthread_setname_np(pthread_self(), "test")], [
-            AC_MSG_RESULT([two arguments])
-            pthread_setname_np_args=2], [
-            AC_TRY_COMPILE([
-#include <pthread.h>
-#ifdef HAVE_PTHREAD_NP_H
-#include <pthread_np.h>
-#endif
-], [pthread_setname_np("test")], [
-                AC_MSG_RESULT([one argument])
-                pthread_setname_np_args=1], [pthread_setname_np_args=0])
-])
-])
-AC_DEFINE_UNQUOTED([PTHREAD_SETNAME_NP_ARGS], $pthread_setname_np_args, [Number of arguments required by pthread_setname_np() function])
-fi
-])
+AS_IF([test "$ac_cv_func_pthread_setname_np" = "yes"],
+  [AC_MSG_CHECKING([for signature of pthread_setname_np])
+  AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM(
+      [#include <pthread.h>
+       #ifdef HAVE_PTHREAD_NP_H
+       #include <pthread_np.h>
+       #endif],
+      [pthread_setname_np(pthread_self(), "test", (void *)0)])],
+    [AC_MSG_RESULT([three arguments])
+     pthread_setname_np_args=3],
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [#include <pthread.h>
+         #ifdef HAVE_PTHREAD_NP_H
+         #include <pthread_np.h>
+         #endif],
+        [pthread_setname_np(pthread_self(), "test")])],
+      [AC_MSG_RESULT([two arguments])
+       pthread_setname_np_args=2],
+      [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM(
+          [#include <pthread.h>
+           #ifdef HAVE_PTHREAD_NP_H
+           #include <pthread_np.h>
+           #endif],
+          [pthread_setname_np("test")])],
+          [AC_MSG_RESULT([one argument])
+           pthread_setname_np_args=1],
+          [pthread_setname_np_args=0])])])
+  AC_DEFINE_UNQUOTED(
+    [PTHREAD_SETNAME_NP_ARGS],
+    [$pthread_setname_np_args],
+    [Number of arguments required by pthread_setname_np() function])])
+]) # OPENAFS_MORE_PTHREAD_CHECKS
diff --git a/src/cf/ressearch.m4 b/src/cf/ressearch.m4
index 7326edb11..94d7a72da 100644
--- a/src/cf/ressearch.m4
+++ b/src/cf/ressearch.m4
@@ -1,19 +1,17 @@
 AC_DEFUN([AC_CHECK_RESOLV_RETRANS],[
   AC_CACHE_CHECK([for retransmit support in res_state],
     [ac_cv_res_retransretry],[
-    AC_TRY_COMPILE( [
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #if defined(__sun__)
 #include <inet/ip.h>
 #endif
 #include <netinet/in.h>
 #include <resolv.h>
-],[
+]], [[
     _res.retrans = 2;
     _res.retry = 1;
-],
-      [ac_cv_res_retransretry="yes"],
-      [ac_cv_res_retransretry="no"])
+]])],[ac_cv_res_retransretry="yes"],[ac_cv_res_retransretry="no"])
   ])
   AS_IF([test "$ac_cv_res_retransretry" = "yes"],
         [AC_DEFINE([HAVE_RES_RETRANSRETRY], 1,
@@ -23,15 +21,14 @@ AC_DEFUN([AC_CHECK_RESOLV_RETRANS],[
 
 AC_DEFUN([AC_FUNC_RES_SEARCH], [
   ac_cv_func_res_search=no
-  AC_TRY_LINK([
+  AC_LINK_IFELSE([AC_LANG_PROGRAM([[
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/nameser.h>
 #ifdef HAVE_ARPA_NAMESER_COMPAT_H
 #include <arpa/nameser_compat.h>
 #endif
-#include <resolv.h>],
-  [
+#include <resolv.h>]], [[
 const char host[11]="openafs.org";
 u_char ans[1024];
 int r;
@@ -41,6 +38,5 @@ res_init();
  */
 r =  res_search( host, C_IN, T_MX, (u_char *)&ans, sizeof(ans));
 return 0;
-  ],
-  ac_cv_func_res_search=yes)
+  ]])],[ac_cv_func_res_search=yes],[])
 ])
diff --git a/src/cf/retsigtype.m4 b/src/cf/retsigtype.m4
deleted file mode 100644
index ab8577bc2..000000000
--- a/src/cf/retsigtype.m4
+++ /dev/null
@@ -1,18 +0,0 @@
-dnl
-dnl $Id$
-dnl
-dnl Figure out return type of signal handlers, and define SIGRETURN macro
-dnl that can be used to return from one
-dnl
-AC_DEFUN([OPENAFS_RETSIGTYPE],[
-AC_TYPE_SIGNAL
-if test "$ac_cv_type_signal" = "void" ; then
-	AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
-fi
-
-AH_BOTTOM([#ifdef VOID_RETSIGTYPE
-#define SIGRETURN(x) return
-#else
-#define SIGRETURN(x) return (RETSIGTYPE)(x)
-#endif])
-])
diff --git a/src/cf/roken.m4 b/src/cf/roken.m4
index 7826b0f95..9a937c42d 100644
--- a/src/cf/roken.m4
+++ b/src/cf/roken.m4
@@ -88,7 +88,7 @@ AC_DEFUN([OPENAFS_ROKEN], [
     [AS_HELP_STRING([--with-roken=DIR],
         [Location of the roken library, or 'internal'])],
     [AS_IF([test x"$withval" = xno],
-           [AC_ERROR("OpenAFS requires roken to build")],
+           [AC_MSG_ERROR("OpenAFS requires roken to build")],
            [AS_IF([test x"$withval" != xyes],
                   [roken_root="$withval"])
            ])
diff --git a/src/cf/sizet.m4 b/src/cf/sizet.m4
index 1a0e7889a..e61649d6b 100644
--- a/src/cf/sizet.m4
+++ b/src/cf/sizet.m4
@@ -1,8 +1,9 @@
 AC_DEFUN([OPENAFS_PRINTF_TAKES_Z_LEN],
 [
 AC_CACHE_CHECK([whether printf understands the %z length modifier],
-[openafs_cv_printf_takes_z], [
-        AC_TRY_RUN([
+[openafs_cv_printf_takes_z],
+  [AC_RUN_IFELSE(
+    [AC_LANG_SOURCE([[
 #include <stdio.h>
 #include <string.h>
 
@@ -15,13 +16,14 @@ int main(void) {
         } else {
                 return 1;
         }
-}],
-                [openafs_cv_printf_takes_z="yes"],
-                [openafs_cv_printf_takes_z="no"],
-                [openafs_cv_printf_takes_z="no"])
+}]])],
+    [openafs_cv_printf_takes_z="yes"],
+    [openafs_cv_printf_takes_z="no"],
+    [openafs_cv_printf_takes_z="no"])
 ])
 
 if test "x$openafs_cv_printf_takes_z" = "xyes"; then
-        AC_DEFINE([PRINTF_TAKES_Z_LEN], 1, [define if printf and friends understand the %z length modifier])
+  AC_DEFINE([PRINTF_TAKES_Z_LEN], 1,
+    [define if printf and friends understand the %z length modifier])
 fi
 ])
diff --git a/src/cf/socket.m4 b/src/cf/socket.m4
index 466f42364..f10f14ecc 100644
--- a/src/cf/socket.m4
+++ b/src/cf/socket.m4
@@ -1,11 +1,13 @@
 AC_DEFUN([OPENAFS_SOCKET_CHECKS],[
 AC_CACHE_CHECK([if struct sockaddr has sa_len field],
     [ac_cv_sockaddr_len],
-    [AC_TRY_COMPILE( [#include <sys/types.h>
-#include <sys/socket.h>],
-                     [struct sockaddr *a; a->sa_len=0;],
-                     [ac_cv_sockaddr_len=yes],
-                     [ac_cv_sockaddr_len=no])
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <sys/types.h>
+          #include <sys/socket.h>]],
+        [[struct sockaddr *a; a->sa_len=0;]])],
+      [ac_cv_sockaddr_len=yes],
+      [ac_cv_sockaddr_len=no])
 ])
 AS_IF([test "$ac_cv_sockaddr_len" = "yes"],
       [AC_DEFINE(STRUCT_SOCKADDR_HAS_SA_LEN, 1,
@@ -15,14 +17,15 @@ AS_IF([test "$ac_cv_sockaddr_len" = "yes"],
 AC_DEFUN([OPENAFS_SOCKOPT_CHECK],[
 AC_CACHE_CHECK([for setsockopt(, SOL_IP, IP_RECVERR)],
     [ac_cv_setsockopt_iprecverr],
-    [AC_TRY_COMPILE( [
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>],
-[int on=1;
-setsockopt(0, SOL_IP, IP_RECVERR, &on, sizeof(on));],
-        [ac_cv_setsockopt_iprecverr=yes],
-        [ac_cv_setsockopt_iprecverr=no])])
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <sys/types.h>
+          #include <sys/socket.h>
+          #include <netinet/in.h>]],
+        [[int on=1;
+          setsockopt(0, SOL_IP, IP_RECVERR, &on, sizeof(on));]])],
+      [ac_cv_setsockopt_iprecverr=yes],
+      [ac_cv_setsockopt_iprecverr=no])])
 
 AS_IF([test "$ac_cv_setsockopt_iprecverr" = "yes"],
       [AC_DEFINE([HAVE_SETSOCKOPT_IP_RECVERR], [1],
diff --git a/src/cf/solaris-cc.m4 b/src/cf/solaris-cc.m4
index 820108ea2..cc61a3026 100644
--- a/src/cf/solaris-cc.m4
+++ b/src/cf/solaris-cc.m4
@@ -3,6 +3,7 @@ AC_DEFUN([SOLARIS_PATH_CC], [
     [m4_join([:],
       [/opt/SUNWspro/bin],
       [/opt/SunStudioExpress/bin],
+      [/opt/developerstudio12.6/bin],
       [/opt/developerstudio12.5/bin],
       [/opt/solarisstudio12.4/bin],
       [/opt/solarisstudio12.3/bin],
diff --git a/src/cf/solaris-dqrwlock.m4 b/src/cf/solaris-dqrwlock.m4
index 69c654f93..19f5dca0a 100644
--- a/src/cf/solaris-dqrwlock.m4
+++ b/src/cf/solaris-dqrwlock.m4
@@ -1,13 +1,14 @@
 AC_DEFUN([SOLARIS_UFSVFS_HAS_DQRWLOCK], [
   AC_CACHE_CHECK([for vfs_dqrwlock in struct ufsvfs],
     [ac_cv_solaris_ufsvfs_has_dqrwlock],
-    [AC_TRY_COMPILE(
-        [#define _KERNEL
-#include <sys/fs/ufs_inode.h>],
-	[struct ufsvfs _ufsvfs;
-(void) _ufsvfs.vfs_dqrwlock;], 
-	[ac_cv_solaris_ufsvfs_has_dqrwlock=yes],
-	[ac_cv_solaris_ufsvfs_has_dqrwlock=no])
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#define _KERNEL
+          #include <sys/fs/ufs_inode.h>]],
+        [[struct ufsvfs _ufsvfs;
+          (void) _ufsvfs.vfs_dqrwlock;]])],
+        [ac_cv_solaris_ufsvfs_has_dqrwlock=yes],
+        [ac_cv_solaris_ufsvfs_has_dqrwlock=no])
     ])
   AS_IF([test "$ac_cv_solaris_ufsvfs_has_dqrwlock" = "yes"],
 	[AC_DEFINE(HAVE_VFS_DQRWLOCK, 1,
diff --git a/src/cf/solaris-fs-rolled.m4 b/src/cf/solaris-fs-rolled.m4
index 0a0ea4209..17f0326a9 100644
--- a/src/cf/solaris-fs-rolled.m4
+++ b/src/cf/solaris-fs-rolled.m4
@@ -1,10 +1,12 @@
 AC_DEFUN([SOLARIS_FS_HAS_FS_ROLLED], [
   AC_CACHE_CHECK([for fs_rolled in struct proc],
     [ac_cv_solaris_fs_has_fs_rolled],
-    [AC_TRY_COMPILE([#include <sys/fs/ufs_fs.h>],
-		    [struct fs _fs; (void) _fs.fs_rolled;],
-		    [ac_cv_solaris_fs_has_fs_rolled=yes],
-		    [ac_cv_solaris_fs_has_fs_rolled=no])
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#include <sys/fs/ufs_fs.h>]],
+        [[struct fs _fs; (void) _fs.fs_rolled;]])],
+      [ac_cv_solaris_fs_has_fs_rolled=yes],
+      [ac_cv_solaris_fs_has_fs_rolled=no])
   ])
   AS_IF([test "$ac_cv_solaris_fs_has_fs_rolled" = "yes"],
 	[AC_DEFINE(STRUCT_FS_HAS_FS_ROLLED, 1,
diff --git a/src/cf/solaris-mapaddr.m4 b/src/cf/solaris-mapaddr.m4
new file mode 100644
index 000000000..8af92a2ed
--- /dev/null
+++ b/src/cf/solaris-mapaddr.m4
@@ -0,0 +1,25 @@
+dnl This checks if the map_addr() function lacks the 'vacalign' argument. It
+dnl was removed some time around Solaris 11.4.
+dnl
+dnl Note that the map_addr() function has had arguments added in the past
+dnl (before Solaris 10). This check then only makes sense for newer Solaris;
+dnl don't rely on it for pre-10 Solaris releases.
+dnl
+AC_DEFUN([SOLARIS_MAPADDR_LACKS_VACALIGN],
+ [AC_CACHE_CHECK([for a map_addr without vacalign],
+   [ac_cv_solaris_mapaddr_lacks_vacalign],
+   [AC_COMPILE_IFELSE(
+     [AC_LANG_PROGRAM(
+       [[#define _KERNEL
+         #include <sys/vmsystm.h>]],
+       [[caddr_t *addrp;
+         size_t len;
+         offset_t off;
+         uint_t flags;
+         map_addr(addrp, len, off, flags);]])],
+     [ac_cv_solaris_mapaddr_lacks_vacalign=yes],
+     [ac_cv_solaris_mapaddr_lacks_vacalign=no])])
+
+  AS_IF([test "x$ac_cv_solaris_mapaddr_lacks_vacalign" = "xyes"],
+        [AC_DEFINE([MAPADDR_LACKS_VACALIGN], [1],
+                   [define if the function map_addr lacks the vacalign argument])])])
diff --git a/src/cf/solaris-ostype.m4 b/src/cf/solaris-ostype.m4
index 2fdfc6b6d..adf8c41fe 100644
--- a/src/cf/solaris-ostype.m4
+++ b/src/cf/solaris-ostype.m4
@@ -6,4 +6,5 @@ SOLARIS_UFSVFS_HAS_DQRWLOCK
 SOLARIS_FS_HAS_FS_ROLLED
 SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS
 SOLARIS_HAVE_VN_RENAMEPATH
+SOLARIS_MAPADDR_LACKS_VACALIGN
 ])
diff --git a/src/cf/solaris-solookup.m4 b/src/cf/solaris-solookup.m4
index 4eb53f18f..b804894c0 100644
--- a/src/cf/solaris-solookup.m4
+++ b/src/cf/solaris-solookup.m4
@@ -1,14 +1,15 @@
 AC_DEFUN([SOLARIS_SOLOOKUP_TAKES_SOCKPARAMS], [
   AC_CACHE_CHECK([whether solookup takes a sockparams],
     [ac_cv_solaris_solookup_takes_sockparams],
-    [AC_TRY_COMPILE(
-	[#define _KERNEL
-#include <sys/systm.h>
-#include <sys/socketvar.h>],
-	[struct sockparams *sp;
-(void) solookup(AF_INET, SOCK_DGRAM, 0, &sp);], 
-	[ac_cv_solaris_solookup_takes_sockparams=yes],
-	[ac_cv_solaris_solookup_takes_sockparams=no])
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM(
+        [[#define _KERNEL
+          #include <sys/systm.h>
+          #include <sys/socketvar.h>]],
+        [[struct sockparams *sp;
+          (void) solookup(AF_INET, SOCK_DGRAM, 0, &sp);]])],
+        [ac_cv_solaris_solookup_takes_sockparams=yes],
+        [ac_cv_solaris_solookup_takes_sockparams=no])
   ])
   AS_IF([test "$ac_cv_solaris_solookup_takes_sockparams" = "yes"],
 	[AC_DEFINE(SOLOOKUP_TAKES_SOCKPARAMS, 1,
diff --git a/src/cf/solaris-test1.m4 b/src/cf/solaris-test1.m4
index a0b572ee2..201445e47 100644
--- a/src/cf/solaris-test1.m4
+++ b/src/cf/solaris-test1.m4
@@ -8,17 +8,6 @@ dnl   BAD TRAP: type=7 (#nm Device not available)
 dnl
 dnl
 AC_DEFUN([SOLARIS_CC_TAKES_XVECTOR_NONE], [
-  AC_CACHE_CHECK([if $CC accepts -xvector=%none],
-    [ac_cv_solaris_cc_takes_xvector_none],
-    [save_CFLAGS="$CFLAGS"
-     CFLAGS="$CFLAGS -xvector=%none"
-     AC_TRY_COMPILE([],
-		    [int x;],
-		    [ac_cv_solaris_cc_takes_xvector_none=yes],
-		    [ac_cv_solaris_cc_takes_xvector_none=no])
-     CFLAGS="$save_CFLAGS"
-    ])
-
 dnl -xvector=%none first appeared in Studio 11, but has only been
 dnl documented as required for Solaris x86 kernel code since Studio
 dnl 12.3.  Studio 12.3 is when the compiler started making more
@@ -28,11 +17,8 @@ dnl required to prevent these optimizations, it is not sufficient.
 dnl Experiments have shown that -xregs=no%float is also needed to
 dnl 1) eliminate a few optimizations not squelched by -xvector=%none,
 dnl and 2) prevent actual use of floating point types in the kernel
-dnl module.  -xregs=no%float has been present since before Studio 8, so
-dnl it is safe to assume its presence when -xvector=%none is present.
+dnl module.
 dnl
-
-  AS_IF([test "$ac_cv_solaris_cc_takes_xvector_none" = "yes"],
-        [SOLARIS_CC_KOPTS="-xvector=%none -xregs=no%float "])
+  AX_APPEND_COMPILE_FLAGS([-xvector=%none -xregs=no%float], [SOLARIS_CC_KOPTS])
 ])
 
diff --git a/src/cf/summary.m4 b/src/cf/summary.m4
index 1b969326b..2967b029d 100644
--- a/src/cf/summary.m4
+++ b/src/cf/summary.m4
@@ -59,7 +59,7 @@ AC_DEFUN([OPENAFS_SUMMARY],[
 ***************************************************************
 OpenAFS configure summary
 
-  version : ${VERSION}
+  version : ${PACKAGE_VERSION}
   sysname : ${AFS_SYSNAME}
 
 debug:
@@ -75,10 +75,10 @@ options:
   install kauth          : ${INSTALL_KAUTH}
   ubik read while write  : ${enable_ubik_read_while_write}
 build:
+  kernel module          : ${enable_kernel_module}
   scout/afsmonitor       : ${summary_build_scout}
   pam                    : ${HAVE_PAM}
   login                  : ${BUILD_LOGIN}
-  uss                    : ${BUILD_USS}
 doc generation:
   docbook stylesheets    : ${summary_docbook_stylesheets}
   doxygen                : ${summary_doxygen}
diff --git a/src/cf/sysname.m4 b/src/cf/sysname.m4
index c4895a92a..268703b11 100644
--- a/src/cf/sysname.m4
+++ b/src/cf/sysname.m4
@@ -174,6 +174,22 @@ else
                         AFS_SYSNAME="x86_darwin_170"
                         OSXSDK="macosx10.13"
                         ;;
+		x86_64-apple-darwin18.*)
+			AFS_SYSNAME="x86_darwin_180"
+			OSXSDK="macosx10.14"
+			;;
+		i?86-apple-darwin18.*)
+			AFS_SYSNAME="x86_darwin_180"
+			OSXSDK="macosx10.14"
+			;;
+		x86_64-apple-darwin19.*)
+			AFS_SYSNAME="x86_darwin_190"
+			OSXSDK="macosx10.15"
+			;;
+		i?86-apple-darwin19.*)
+			AFS_SYSNAME="x86_darwin_190"
+			OSXSDK="macosx10.15"
+			;;
                 sparc-sun-solaris2.8)
                         AFS_SYSNAME="sun4x_58"
                         ;;
@@ -198,15 +214,6 @@ else
                 i386-pc-solaris2.11)
                         AFS_SYSNAME="sunx86_511"
                         ;;
-                alpha*-dec-osf4.0*)
-                        AFS_SYSNAME="alpha_dux40"
-                        ;;
-                alpha*-dec-osf5.0*)
-                        AFS_SYSNAME="alpha_dux50"
-                        ;;
-                alpha*-dec-osf5.1*)
-                        AFS_SYSNAME="alpha_dux51"
-                        ;;
                 mips-sgi-irix6.5)
                         AFS_SYSNAME="sgi_65"
                         enable_pam="no"
@@ -220,6 +227,9 @@ else
                 powerpc64-*-linux*)
                         AFS_SYSNAME="ppc64_linuxXX"
                         ;;
+                powerpc64le-*-linux*)
+                        AFS_SYSNAME="ppc64le_linuxXX"
+                        ;;
                 alpha*-linux*)
                         AFS_SYSNAME="alpha_linux_XX"
                         ;;
@@ -241,6 +251,9 @@ else
                 arm*-linux*)
                         AFS_SYSNAME="arm_linuxXX"
                         ;;
+                aarch64*-linux*)
+                        AFS_SYSNAME="arm64_linuxXX"
+                        ;;
                 parisc-*-linux-gnu|hppa-*-linux-gnu)
                         AFS_SYSNAME="parisc_linuxXX"
                         enable_pam="no"
diff --git a/src/cf/test_package.m4 b/src/cf/test_package.m4
index 5afe81a54..9fc3f8b50 100644
--- a/src/cf/test_package.m4
+++ b/src/cf/test_package.m4
@@ -54,11 +54,11 @@ save_LIBS="$LIBS"
 ires= lres=
 for i in $header_dirs; do
     CFLAGS="-I$i $save_CFLAGS"
-    AC_TRY_COMPILE([$2],,ires=$i;break)
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[$2]], [[]])],[ires=$i;break],[])
 done
 for i in $lib_dirs; do
     LIBS="-L$i $3 $4 $save_LIBS"
-    AC_TRY_LINK([$2],,lres=$i;break)
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[]])],[lres=$i;break],[])
 done
 CFLAGS="$save_CFLAGS"
 LIBS="$save_LIBS"
diff --git a/src/cf/types.m4 b/src/cf/types.m4
index fa65b018f..660bf8f38 100644
--- a/src/cf/types.m4
+++ b/src/cf/types.m4
@@ -4,8 +4,6 @@ LIBS="$save_LIBS"
 openafs_cv_saved_CFLAGS="$CFLAGS"
 CFLAGS="$CFLAGS $XCFLAGS_NOCHECKING"
 
-AC_TYPE_SIGNAL
-OPENAFS_RETSIGTYPE
 AC_CHECK_SIZEOF(void *)
 AC_CHECK_SIZEOF(unsigned long long)
 AC_CHECK_SIZEOF(unsigned long)
@@ -50,7 +48,7 @@ AC_CHECK_TYPES([struct addrinfo], [], [], [
 ])
 AC_CHECK_TYPES([long long], [], [], [])
 
-AC_SIZEOF_TYPE(long)
+AC_CHECK_SIZEOF([long])
 
 CFLAGS="$openafs_cv_saved_CFLAGS"
 ])
diff --git a/src/cf/ucontext.m4 b/src/cf/ucontext.m4
index e6c702528..73b3e623f 100644
--- a/src/cf/ucontext.m4
+++ b/src/cf/ucontext.m4
@@ -4,7 +4,9 @@ dnl and return to the original user context.
 dnl
 AC_DEFUN([OPENAFS_WORKING_UCONTEXT],[
   AC_MSG_CHECKING([if user context manipulation is complete])
-  AC_TRY_RUN([
+  AC_RUN_IFELSE(
+    [AC_LANG_SOURCE(
+      [[
 #include <stdio.h>
 #include <stdlib.h>
 #ifdef HAVE_UCONTEXT_H
@@ -47,6 +49,10 @@ main(int argc, char **argv)
 
 	free(alt_stack);
 	exit(EXIT_SUCCESS);
-}],AC_MSG_RESULT([yes])
-   AC_DEFINE([HAVE_WORKING_SWAPCONTEXT],[1],[user context manipulation is complete]),
-   AC_MSG_RESULT([no]))])
+}
+      ]])],
+      [AC_MSG_RESULT(yes)
+       AC_DEFINE(HAVE_WORKING_SWAPCONTEXT, 1,
+         user context manipulation is complete)],
+      [AC_MSG_RESULT(no)],
+      [])])
diff --git a/src/cmd/cmd.c b/src/cmd/cmd.c
index e2e8e3a08..4aa9242a1 100644
--- a/src/cmd/cmd.c
+++ b/src/cmd/cmd.c
@@ -176,7 +176,7 @@ ParmHelpString(struct cmd_parmdesc *aparm)
 		     aparm->help?aparm->help:"arg",
 		     aparm->type == CMD_LIST?"+":"",
 		     aparm->type == CMD_SINGLE_OR_FLAG?"]":"") < 0)
-	    return "<< OUT OF MEMORY >>";
+	    return NULL;
 	return str;
     }
 }
@@ -220,6 +220,10 @@ PrintSyntax(struct cmd_syndesc *as)
 	/* The parameter name is the real name, plus any aliases */
 	if (!tp->aliases) {
 	    name = strdup(tp->name);
+	    if (!name) {
+		fprintf(stderr, "Out of memory.\n");
+		return;
+	    }
 	} else {
 	    size_t namelen;
 	    struct cmd_item *alias;
@@ -228,6 +232,10 @@ PrintSyntax(struct cmd_syndesc *as)
 		namelen+=strlen(alias->data) + 3;
 
 	    name = malloc(namelen);
+	    if (!name) {
+		fprintf(stderr, "Out of memory.\n");
+		return;
+	    }
 	    strlcpy(name, tp->name, namelen);
 
 	    for (alias = tp->aliases; alias != NULL; alias = alias->next) {
@@ -239,6 +247,11 @@ PrintSyntax(struct cmd_syndesc *as)
 	/* Work out if we can fit what we want to on this line, or if we need to
 	 * start a new one */
 	str = ParmHelpString(tp);
+	if (!str) {
+	    fprintf(stderr, "Out of memory.\n");
+	    free(name);
+	    return;
+	}
 	xtralen = 1 + strlen(name) + strlen(str) +
 		  ((tp->flags & CMD_OPTIONAL)? 2: 0);
 
@@ -357,11 +370,35 @@ HelpProc(struct cmd_syndesc *as, void *arock)
     int code = 0;
 
     if (as->parms[0].items == 0) {
-	printf("%sCommands are:\n", NName(as->a0name, ": "));
+	struct cmd_syndesc *initcmd = NULL;
+	int count = 0;
+
+	/*
+	 * Print the usage of the initcmd command when it is the only
+	 * non-hidden, explicit command, otherwise, list the all the commands.
+	 */
 	for (ts = allSyntax; ts; ts = ts->next) {
-	    if ((ts->flags & CMD_ALIAS) || (ts->flags & CMD_HIDDEN))
+	    if (ts->flags & (CMD_ALIAS | CMD_HIDDEN | CMD_IMPLICIT)) {
+		continue; /* skip aliases, hidden, and implied commands */
+	    }
+	    if (strcmp(ts->name, initcmd_opcode) == 0) {
+		initcmd = ts; /* save the initcmd */
 		continue;
-	    printf("%-15s %s\n", ts->name, (ts->help ? ts->help : ""));
+	    }
+	    count++;
+	}
+	if (initcmd && count == 0) {
+	    initcmd->a0name = as->a0name;
+	    PrintAliases(initcmd);
+	    PrintSyntax(initcmd);
+	    PrintFlagHelp(initcmd);
+	} else {
+	    printf("%sCommands are:\n", NName(as->a0name, ": "));
+	    for (ts = allSyntax; ts; ts = ts->next) {
+		if ((ts->flags & CMD_ALIAS) || (ts->flags & CMD_HIDDEN))
+		    continue;
+		printf("%-15s %s\n", ts->name, (ts->help ? ts->help : ""));
+	    }
 	}
     } else {
 	/* print out individual help topics */
@@ -439,7 +476,7 @@ SortSyntax(struct cmd_syndesc *as)
  * \param[in] aname  name used to invoke the command
  * \param[in] aproc  procedure to be called when command is invoked
  * \param[in] arock  opaque data pointer to be passed to aproc
- * \param[in] aflags command option flags (CMD_HIDDEN)
+ * \param[in] aflags command option flags
  * \param[in] ahelp  help string to display for this command
  *
  * \return a pointer to the cmd_syndesc or NULL if error.
@@ -456,7 +493,7 @@ cmd_CreateSyntax(char *aname,
 	return NULL;
 
     /* Allow only valid cmd flags. */
-    if (aflags & ~CMD_HIDDEN) {
+    if (aflags & ~(CMD_HIDDEN | CMD_IMPLICIT)) {
 	return NULL;
     }
 
@@ -654,7 +691,7 @@ ResetSyntax(struct cmd_syndesc *as)
 	case CMD_SINGLE_OR_FLAG:
 	    if (tp->items == &dummy)
 		break;
-	    /* Deliberately fall through here */
+	    AFS_FALLTHROUGH;
 	case CMD_SINGLE:
 	case CMD_LIST:
 	    /* free whole list in both cases, just for fun */
@@ -763,20 +800,20 @@ initSyntax(void)
     struct cmd_syndesc *ts;
 
     if (!noOpcodes) {
-	ts = cmd_CreateSyntax("help", HelpProc, NULL, 0,
+	ts = cmd_CreateSyntax("help", HelpProc, NULL, CMD_IMPLICIT,
 			      "get help on commands");
 	cmd_AddParm(ts, "-topic", CMD_LIST, CMD_OPTIONAL, "help string");
 
-	ts = cmd_CreateSyntax("apropos", AproposProc, NULL, 0,
+	ts = cmd_CreateSyntax("apropos", AproposProc, NULL, CMD_IMPLICIT,
 			      "search by help text");
 	cmd_AddParm(ts, "-topic", CMD_SINGLE, CMD_REQUIRED, "help string");
 
-	cmd_CreateSyntax("version", VersionProc, NULL, 0,
+	cmd_CreateSyntax("version", VersionProc, NULL, CMD_IMPLICIT,
 			 "show version");
-	cmd_CreateSyntax("-version", VersionProc, NULL, CMD_HIDDEN, NULL);
-	cmd_CreateSyntax("-help", HelpProc, NULL, CMD_HIDDEN, NULL);
-	cmd_CreateSyntax("--version", VersionProc, NULL, CMD_HIDDEN, NULL);
-	cmd_CreateSyntax("--help", HelpProc, NULL, CMD_HIDDEN, NULL);
+	cmd_CreateSyntax("-version", VersionProc, NULL, (CMD_HIDDEN | CMD_IMPLICIT), NULL);
+	cmd_CreateSyntax("-help", HelpProc, NULL, (CMD_HIDDEN | CMD_IMPLICIT), NULL);
+	cmd_CreateSyntax("--version", VersionProc, NULL, (CMD_HIDDEN | CMD_IMPLICIT), NULL);
+	cmd_CreateSyntax("--help", HelpProc, NULL, (CMD_HIDDEN | CMD_IMPLICIT), NULL);
     }
 }
 
diff --git a/src/cmd/cmd.p.h b/src/cmd/cmd.p.h
index 4a5f3031a..30ce7d127 100644
--- a/src/cmd/cmd.p.h
+++ b/src/cmd/cmd.p.h
@@ -19,6 +19,7 @@
 /* syndesc flags */
 #define	CMD_ALIAS	1	/* this is an alias */
 #define CMD_HIDDEN      4	/* A hidden command - similar to CMD_HIDE */
+#define CMD_IMPLICIT    8	/* A built-in command - apropos, help, version (and variations) */
 
 #define CMD_HELPPARM	(CMD_MAXPARMS-1)	/* last one is used by -help switch */
 #define	CMD_MAXPARMS	64	/* max number of parm types to a cmd line */
diff --git a/src/comerr/Makefile.in b/src/comerr/Makefile.in
index b94f1c616..d906feb81 100644
--- a/src/comerr/Makefile.in
+++ b/src/comerr/Makefile.in
@@ -89,8 +89,9 @@ clean:
 		et_lex.lex.c test1.h test1.c test2.h test2.c \
 		eddep makedep core AFS_component_version_number.c
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 compile_et.o:  AFS_component_version_number.c
 # specify yacc build product as a dependency so our .c.o rule will apply
diff --git a/src/comerr/error_table.y b/src/comerr/error_table.y
index 05f524bff..6690c6520 100644
--- a/src/comerr/error_table.y
+++ b/src/comerr/error_table.y
@@ -389,6 +389,11 @@ int char_to_1num(char c)
         exit (1);
 }
 
+#if defined(IGNORE_SOME_GCC_WARNINGS) && defined(__clang__) && defined(HAVE_FUNC_ATTRIBUTE_FALLTHROUGH)
+/* flex generates fallthroughs in case blocks that get flagged by clang */
+# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
+#endif
+
 #ifdef AFS_NT40_ENV
 #include "et_lex.lex_nt.c"
 #else
diff --git a/src/comerr/error_table_nt.c b/src/comerr/error_table_nt.c
index 6bcef5b6c..70c1408aa 100755
--- a/src/comerr/error_table_nt.c
+++ b/src/comerr/error_table_nt.c
@@ -863,14 +863,6 @@ yyparse(YYPARSE_PARAM)
 
   yyerrdefault:		/* current state does not do anything special for the error token. */
 
-#if 0
-    /* This is wrong; only states that explicitly want error tokens
-     * should shift them.  */
-    yyn = yydefact[yystate];	/* If its default is to accept any token, ok.  Otherwise pop it. */
-    if (yyn)
-	goto yydefault;
-#endif
-
   yyerrpop:			/* pop the current state because it cannot handle the error token */
 
     if (yyssp == yyss)
diff --git a/src/config/.gitignore b/src/config/.gitignore
index 62ebae6fc..9a3d95309 100644
--- a/src/config/.gitignore
+++ b/src/config/.gitignore
@@ -14,6 +14,7 @@
 /Makefile.version-CML
 /afsconfig.h
 /afsconfig.h.in
+/cc-wrapper
 /config
 /mkvers
 /param.h.new
diff --git a/src/config/Makefile.config.in b/src/config/Makefile.config.in
index af51d6ecc..3c908e71f 100644
--- a/src/config/Makefile.config.in
+++ b/src/config/Makefile.config.in
@@ -58,6 +58,7 @@ LD = @LD@
 LDFLAGS_roken = @LDFLAGS_roken@
 LDFLAGS_hcrypto = @LDFLAGS_hcrypto@
 LDFLAGS_krb5 = @KRB5_LDFLAGS@
+LDFLAGS_gssapi = @GSSAPI_LDFLAGS@
 CPPFLAGS_gssapi = @GSSAPI_CPPFLAGS@
 LEX = @LEX@
 LIB_AFSDB = @LIB_AFSDB@
@@ -97,11 +98,11 @@ REGEX_OBJ = @REGEX_OBJ@
 REGEX_OBJ_PIC = @REGEX_OBJ_PIC@
 RM = @RM@
 RXDEBUG = @RXDEBUG@
+RXGK_GSSAPI_LIBS = @RXGK_GSSAPI_LIBS@
 ROKEN_HEADERS = @ROKEN_HEADERS@
 ROKEN_LTLIBOBJS = @LTLIBOBJS@
 SED = @SED@
 SHLIB_CFLAGS = @SHLIB_CFLAGS@
-SHLIB_LDFLAGS = @SHLIB_LDFLAGS@
 SHLIB_LINKER = @SHLIB_LINKER@
 SHLIB_SUFFIX = @SHLIB_SUFFIX@
 SYS_NAME = @AFS_SYSNAME@
@@ -119,6 +120,8 @@ XLIBELFA = @XLIBELFA@
 XLIBKVM = @XLIBKVM@
 XLIBS = @XLIBS@
 YACC = @YACC@
+KROOT = @KROOT@
+KINCLUDES = @KINCLUDES@
 
 #
 # Install targets
@@ -150,11 +153,15 @@ KERNELDIR = ../libafs
 #
 # Build helper apps
 #
+CC_WRAPPER = @CC_WRAPPER@
+LD_WRAPPER = @LD_WRAPPER@
 COMPILE_ET = @COMPILE_ET_PATH@
 CONFIGTOOL = @CONFIGTOOL_PATH@
 RXGEN = @RXGEN_PATH@
 SHELL = @SHELL@
-LWPTOOL = ${TOP_SRCDIR}/config/lwptool
+
+LWPTOOL_FLAGS_V0 = --quiet
+LWPTOOL = ${TOP_SRCDIR}/config/lwptool $(LWPTOOL_FLAGS_V$(V))
 
 #
 # "Pretty" build line stuff
@@ -227,24 +234,18 @@ COMMON_LDFLAGS=$(LDFLAGS) $(LDFLAGS_hcrypto) $(LDFLAGS_roken) $(DBG) $(OPTMZ)
 # LWP Flags
 LWP_CFLAGS=$(MODULE_CFLAGS) $(COMMON_CFLAGS)
 LWP_LDFLAGS=$(MODULE_LDFLAGS) $(COMMON_LDFLAGS) $(XLDFLAGS) $(ARCHFLAGS)
-LWP_CCRULE        =$(RUN_CC) $(CCOBJ) $(CPPFLAGS_$(@)) $(LWP_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
-LWP_CCRULE_NOQ=$(RUN_CC_NOQ) $(CCOBJ) $(CPPFLAGS_$(@)) $(LWP_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
+LWP_CCRULE        =$(RUN_CC) $(CC_WRAPPER) $(CCOBJ) $(CPPFLAGS_$(@)) $(LWP_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
+LWP_CCRULE_NOQ=$(RUN_CC_NOQ) $(CC_WRAPPER) $(CCOBJ) $(CPPFLAGS_$(@)) $(LWP_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
 
 # Pthreaded
 PTH_CFLAGS=$(MODULE_CFLAGS) $(COMMON_CFLAGS) $(MT_CFLAGS)
 PTH_LDFLAGS=$(MODULE_LDFLAGS) $(COMMON_LDFLAGS) $(MT_LDFLAGS)
-PTH_CCRULE        =$(RUN_CC) $(MT_CC) $(CPPFLAGS_$(@)) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
-PTH_CCRULE_NOQ=$(RUN_CC_NOQ) $(MT_CC) $(CPPFLAGS_$(@)) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
-
-# Shared
-SHD_CFLAGS=$(MODULE_CFLAGS) $(COMMON_CFLAGS) $(MT_CFLAGS) $(SHLIB_CFLAGS)
-SHD_LDFLAGS=$(MODULE_LDFLAGS) $(COMMON_LDFLAGS) $(SHLIB_LDFLAGS)
-SHD_CCRULE        =$(RUN_CC) $(MT_CC) $(CPPFLAGS_$(@)) $(SHD_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
-SHD_CCRULE_NOQ=$(RUN_CC_NOQ) $(MT_CC) $(CPPFLAGS_$(@)) $(SHD_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
+PTH_CCRULE        =$(RUN_CC) $(CC_WRAPPER) $(MT_CC) $(CPPFLAGS_$(@)) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
+PTH_CCRULE_NOQ=$(RUN_CC_NOQ) $(CC_WRAPPER) $(MT_CC) $(CPPFLAGS_$(@)) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
 
 # Libtool - for objects that are part of pthread-only libraries
 LT_CCRULE=$(RUN_CC) $(LIBTOOL) --quiet --mode=compile --tag=CC \
-	      $(MT_CC) $(CPPFLAGS_$(@)) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
+	      $(CC_WRAPPER) $(MT_CC) $(CPPFLAGS_$(@)) $(PTH_CFLAGS) $(CFLAGS_$(@)) -o $@ -c
 
 LT_current=0
 LT_revision=0
@@ -252,31 +253,33 @@ LT_age=0
 
 # Basic rule to link a shared library.
 LT_LDLIB_shlib_common=$(LIBTOOL) --quiet --mode=link --tag=CC \
-		      $(MT_CC) -rpath $(libdir) \
+		      $(LD_WRAPPER) $(MT_CC) -rpath $(libdir) \
 		      $(PTH_LDFLAGS) $(PTH_CFLAGS) $(LDFLAGS_$(@)) \
 		      -o $@ \
 		      -version-info $(LT_current):$(LT_revision):$(LT_age)
 
 LT_LDLIB_shlib=$(LT_LDLIB_shlib_common) -export-symbols $(srcdir)/$@.sym
 
-LT_LDLIB_shlib_missing=$(LT_LDLIB_shlib_common) -export-symbols-regex \
-	"($$(sed -e 's/^/^/' -e 's/$$/$$/' $(srcdir)/$@.sym | tr '\n' '|' | \
-	sed -e 's/|$$//'))"
+LT_LDLIB_shlib_only=$(LT_LDLIB_shlib_common) -shared -export-symbols $(srcdir)/$@.sym
+
+LT_LDLIB_shlib_missing=$(LT_LDLIB_shlib_common) -shared -export-symbols-regex \
+	"($$(sed -e 's/^/^/' -e 's/$$/$$|/' -e '$$ s/|$$//' $(srcdir)/$@.sym | \
+	tr -d '\n'))"
 
 # Link a static convenience library (contains no PIC code)
 LT_LDLIB_static=$(LIBTOOL) --quiet --mode=link --tag=CC \
-		 $(MT_CC) -static $(LDFLAGS) $(DBG) $(OPTMZ) \
+		 $(LD_WRAPPER) $(MT_CC) -static $(LDFLAGS) $(DBG) $(OPTMZ) \
 		 $(LDFLAGS_$(@)) -o $@
 
 # Link a convenience library for use in other libs (contains PIC code)
 LT_LDLIB_pic= $(LIBTOOL) --quiet --mode=link --tag=CC \
-	       $(MT_CC) $(LDFLAGS) $(DBG) $(OPTMZ) \
+	       $(LD_WRAPPER) $(MT_CC) $(LDFLAGS) $(DBG) $(OPTMZ) \
 	       $(LDFLAGS_$(@)) -o $@
 
 # Libtool - for objects that are built for both pthread and lwp libraries
 LTLWP_CCRULE=$(RUN_CC) $(LWPTOOL) --mode compile \
-	         --lwpcc "$(CCOBJ)" \
-		 --mtcc "$(LIBTOOL) --quiet --mode=compile --tag=CC $(MT_CC) $(MT_CFLAGS)" \
+	         --lwpcc "$(CC_WRAPPER) $(CCOBJ)" \
+		 --mtcc "$(LIBTOOL) --quiet --mode=compile --tag=CC $(CC_WRAPPER) $(MT_CC) $(MT_CFLAGS)" \
 		 -o $@ \
 		 -- \
 		 $(CPPFLAGS_$(@)) $(MODULE_CFLAGS) $(COMMON_CFLAGS) $(CFLAGS_$(@)) \
@@ -296,15 +299,15 @@ LT_LDLIB_lwp_NOQ=$(RUN_LD_NOQ) $(LWPTOOL) --mode link \
 
 # Use this to link an executable with one or more libtool libraries
 LT_LDRULE        = $(RUN_LD) $(LIBTOOL) --quiet --mode=link --tag=CC \
-		             $(MT_CC) $(PTH_LDFLAGS) $(PTH_CFLAGS) \
+		             $(LD_WRAPPER) $(MT_CC) $(PTH_LDFLAGS) $(PTH_CFLAGS) \
 			     $(LDFLAGS_$(@)) -o $@
 
 LT_LDRULE_static = $(RUN_LD) $(LIBTOOL) --quiet --mode=link --tag=CC \
-			     $(MT_CC) -static $(PTH_LDFLAGS) $(PTH_CFLAGS) \
+			     $(LD_WRAPPER) $(MT_CC) -static $(PTH_LDFLAGS) $(PTH_CFLAGS) \
 			     $(LDFLAGS_$(@)) -o $@
 
 LT_LDRULE_static_NOQ = $(RUN_LD_NOQ) $(LIBTOOL) --quiet --mode=link --tag=CC \
-			     $(MT_CC) -static $(PTH_LDFLAGS) $(PTH_CFLAGS) \
+			     $(LD_WRAPPER) $(MT_CC) -static $(PTH_LDFLAGS) $(PTH_CFLAGS) \
 			     $(LDFLAGS_$(@)) -o $@
 
 LT_INSTALL_DATA=$(LIBTOOL) --quiet --mode=install $(INSTALL_DATA)
@@ -315,36 +318,5 @@ LT_CLEAN=$(RM) -rf .lwp .libs *.la *.lo
 # Default rules. These will be overriden if the module Makefile specifically
 # includes a particular type (lwp, pthread, or shared)
 
-AFS_LDRULE         =$(RUN_LD) $(CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
-AFS_LDRULE_NOQ =$(RUN_LD_NOQ) $(CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
-
-RUN_CTFCONVERT=@RUN_CTFCONVERT() { \
-    CTFLABEL=$$1 ; \
-    CTFDBG=$$2 ; \
-    shift ; shift ; \
-    if test "x$${CTFDBG}" = "x" ; then exit 0; fi; \
-    if test "x${CTFCONVERT}" = "x" ; then exit 0; fi; \
-    if test "x${CTFMERGE}" = "x" ; then \
-        echo "refusing to run ctfconvert; missing ctfmerge"; \
-        exit 1; \
-    fi; \
-    for t in $$@ ; do \
-        echo "${CTFCONVERT} -g -l $${CTFLABEL} $$t"; \
-        ${CTFCONVERT} -g -l $${CTFLABEL} $$t; \
-    done ; \
-} ; RUN_CTFCONVERT
-
-RUN_CTFMERGE=@RUN_CTFMERGE () { \
-    CTFLABEL=$$1 ; \
-    CTFDBG=$$2 ; \
-    shift ; shift ; \
-    if test "x$${CTFDBG}" = "x" ; then exit 0; fi; \
-    if test "x${CTFMERGE}" = "x" ; then exit 0; fi; \
-    if test "x${CTFCONVERT}" = "x" ; then \
-        echo "refusing to run ctfmerge; missing ctfconvert"; \
-        exit 1; \
-    fi; \
-    echo "$(CTFMERGE) -g -l $${CTFLABEL} -o $$@"; \
-    $(CTFMERGE) -g -l $${CTFLABEL} -o $$@; \
-} ; RUN_CTFMERGE
-
+AFS_LDRULE         =$(RUN_LD) $(LD_WRAPPER) $(CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
+AFS_LDRULE_NOQ =$(RUN_LD_NOQ) $(LD_WRAPPER) $(CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
diff --git a/src/config/Makefile.pthread.in b/src/config/Makefile.pthread.in
index f4af720d7..e95936af9 100644
--- a/src/config/Makefile.pthread.in
+++ b/src/config/Makefile.pthread.in
@@ -3,8 +3,8 @@ AFS_LDFLAGS=$(PTH_LDFLAGS)
 AFS_CCRULE=$(PTH_CCRULE)
 AFS_CCRULE_NOQ=$(PTH_CCRULE_NOQ)
 
-AFS_LDRULE=$(RUN_LD) $(MT_CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
-AFS_LDRULE_NOQ=$(RUN_LD_NOQ) $(MT_CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
+AFS_LDRULE=$(RUN_LD) $(LD_WRAPPER) $(MT_CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
+AFS_LDRULE_NOQ=$(RUN_LD_NOQ) $(LD_WRAPPER) $(MT_CC) $(AFS_LDFLAGS) $(AFS_CFLAGS) $(LDFLAGS_$(@)) -o $@
 
 .c.o:
 	$(AFS_CCRULE) $<
diff --git a/src/config/Makefile.version-CML.in b/src/config/Makefile.version-CML.in
index 45c4b8491..0a08a9209 100644
--- a/src/config/Makefile.version-CML.in
+++ b/src/config/Makefile.version-CML.in
@@ -5,8 +5,8 @@
 # License.  For details, see the LICENSE file in the top-level source
 # directory or online at http://www.openafs.org/dl/license10.html
 
-PACKAGE=@PACKAGE@
-VERSION=@VERSION@
+PACKAGE=@PACKAGE_TARNAME@
+VERSION=@PACKAGE_VERSION@
 
 AFS_component_version_number.o: AFS_component_version_number.c $(TOP_SRCDIR)/config/mkvers
 version.xml version.txt: $(TOP_SRCDIR)/config/mkvers
diff --git a/src/config/Makefile.version-NOCML.in b/src/config/Makefile.version-NOCML.in
index c65cfe915..8a11ee898 100644
--- a/src/config/Makefile.version-NOCML.in
+++ b/src/config/Makefile.version-NOCML.in
@@ -5,12 +5,12 @@
 # License.  For details, see the LICENSE file in the top-level source
 # directory or online at http://www.openafs.org/dl/license10.html
 
-PACKAGE=@PACKAGE@
+PACKAGE=@PACKAGE_TARNAME@
 
 AFS_component_version_number.o: AFS_component_version_number.c
 
 AFS_component_version_number.c: @TOP_OBJDIR@/src/config/Makefile.version
-	( VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@ "@VERSION@"` && \
+	( VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@ "@PACKAGE_VERSION@"` && \
 	if [ "$$SOURCE_DATE_EPOCH" ]; then \
 	     echo 'char cml_version_number[]="@(#)OpenAFS '$$VERSION `date -u -d "@$$SOURCE_DATE_EPOCH" +"%Y-%m-%d" 2>/dev/null || date -u -r "$$SOURCE_DATE_EPOCH" +"%Y-%m-%d"`'";'; \
 	else \
@@ -22,7 +22,7 @@ AFS_component_version_number.c: @TOP_OBJDIR@/src/config/Makefile.version
 	rm -f AFS_component_version_number.c.NEW
 
 version.xml:
-	VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@ "@VERSION@"` && \
+	VERSION=`@abs_top_srcdir@/build-tools/git-version @abs_top_srcdir@ "@PACKAGE_VERSION@"` && \
 	echo '<?xml version="1.0" encoding="UTF-8"?>' >version.xml && \
 	echo '<revision>' >>version.xml && \
 	echo '<revnumber>'$$VERSION'</revnumber>' >>version.xml && \
diff --git a/src/config/NTMakefile b/src/config/NTMakefile
index 8ae12145d..0ff166d16 100644
--- a/src/config/NTMakefile
+++ b/src/config/NTMakefile
@@ -205,12 +205,6 @@ idirs: doclink
 !	IF (!EXIST($(OJT)\rxstat))
 		$(MKDIR) $(OJT)\rxstat
 !	ENDIF
-!	IF (!EXIST($(OJT)\shlibafsauthent))
-		$(MKDIR) $(OJT)\shlibafsauthent
-!	ENDIF
-!	IF (!EXIST($(OJT)\shlibafsrpc))
-		$(MKDIR) $(OJT)\shlibafsrpc
-!	ENDIF
 !	IF (!EXIST($(OJT)\sys))
 		$(MKDIR) $(OJT)\sys
 !	ENDIF
diff --git a/src/config/NTMakefile.amd64_w2k b/src/config/NTMakefile.amd64_w2k
index c01ba45e6..820df56c1 100644
--- a/src/config/NTMakefile.amd64_w2k
+++ b/src/config/NTMakefile.amd64_w2k
@@ -85,10 +85,10 @@ LIB = $(AFSDEV_LIB)
 AFSPRODUCT_VER_MAJOR=1
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
-AFSPRODUCT_VER_MINOR=7
+AFSPRODUCT_VER_MINOR=9
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
-AFSPRODUCT_VER_PATCH=9904
+AFSPRODUCT_VER_PATCH=0000
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
 AFSPRODUCT_VER_BUILD=0
diff --git a/src/config/NTMakefile.i386_nt40 b/src/config/NTMakefile.i386_nt40
index cafdf09c6..ee12d3968 100644
--- a/src/config/NTMakefile.i386_nt40
+++ b/src/config/NTMakefile.i386_nt40
@@ -85,10 +85,10 @@ LIB = $(AFSDEV_LIB)
 AFSPRODUCT_VER_MAJOR=1
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
-AFSPRODUCT_VER_MINOR=7
+AFSPRODUCT_VER_MINOR=9
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
-AFSPRODUCT_VER_PATCH=9904
+AFSPRODUCT_VER_PATCH=0000
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
 AFSPRODUCT_VER_BUILD=0
diff --git a/src/config/NTMakefile.i386_w2k b/src/config/NTMakefile.i386_w2k
index 43cc31207..193e61826 100644
--- a/src/config/NTMakefile.i386_w2k
+++ b/src/config/NTMakefile.i386_w2k
@@ -89,10 +89,10 @@ LIB = $(AFSDEV_LIB)
 AFSPRODUCT_VER_MAJOR=1
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_MINOR)
-AFSPRODUCT_VER_MINOR=7
+AFSPRODUCT_VER_MINOR=9
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
-AFSPRODUCT_VER_PATCH=9904
+AFSPRODUCT_VER_PATCH=0000
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
 AFSPRODUCT_VER_BUILD=0
diff --git a/src/config/afs_args.h b/src/config/afs_args.h
index 4fa286ba3..3ea8af3ab 100644
--- a/src/config/afs_args.h
+++ b/src/config/afs_args.h
@@ -12,6 +12,9 @@
 
 /*
  * AFS system call opcodes
+ *
+ * When adding new opcodes, please also update afsd_init_syscall_opcodes()
+ * for syscall tracing.
  */
 
 #define AFSOP_START_RXCALLBACK	  0	/* no aux parms */
@@ -125,11 +128,6 @@
 #define AFSCALL_RXSTATS_DISABLE	0x2	/* Disable RX stats */
 #define AFSCALL_RXSTATS_CLEAR	0x4	/* Clear RX stats */
 
-/* Main afs syscall entry; this number may vary per system (i.e. defined in afs/param.h) */
-#ifndef	AFS_SYSCALL
-#define AFS_SYSCALL		31
-#endif
-
 /* arguments passed by afsd */
 #define IDTYPE_UID 0
 
@@ -147,7 +145,10 @@ struct afs_umv_param {
     afs_int32 dUnique;
 };
 
-#define AFS_USPC_UMV 1
+#ifdef AFS_DARWIN_ENV
+# define AFS_USPC_UMV 1
+#endif
+#define AFS_USPC_SHUTDOWN 2
 
 struct afs_uspc_param {
     afs_int32 retval;
@@ -179,6 +180,9 @@ enum {
     AFS_INUMCALC_MD5 = 1
 };
 
+/* Supported volume ttl range. */
+#define AFS_MIN_VOLUME_TTL 600
+#define AFS_MAX_VOLUME_TTL MAX_AFS_INT32
 
 /*
  * Note that the AFS_*ALLOCSIZ values should be multiples of sizeof(void*) to
diff --git a/src/config/afs_sysnames.h b/src/config/afs_sysnames.h
index be27ae651..6f3df14f1 100644
--- a/src/config/afs_sysnames.h
+++ b/src/config/afs_sysnames.h
@@ -88,6 +88,12 @@
 #define SYS_NAME_ID_x86_darwin_170       535
 #define SYS_NAME_ID_amd64_darwin_170     536
 #define SYS_NAME_ID_arm_darwin_170       537
+#define SYS_NAME_ID_x86_darwin_180       538
+#define SYS_NAME_ID_amd64_darwin_180     539
+#define SYS_NAME_ID_arm_darwin_180       540
+#define SYS_NAME_ID_x86_darwin_190       541
+#define SYS_NAME_ID_amd64_darwin_190     542
+#define SYS_NAME_ID_arm_darwin_190       543
 
 #define SYS_NAME_ID_next_mach20		 601
 #define SYS_NAME_ID_next_mach30		 602
@@ -234,7 +240,10 @@
 #define SYS_NAME_ID_i386_fbsd_104      2154
 #define SYS_NAME_ID_i386_fbsd_110      2140
 #define SYS_NAME_ID_i386_fbsd_111      2141
+#define SYS_NAME_ID_i386_fbsd_112      2142
+#define SYS_NAME_ID_i386_fbsd_113      2143
 #define SYS_NAME_ID_i386_fbsd_120      2160
+#define SYS_NAME_ID_i386_fbsd_121      2161
 
 #define SYS_NAME_ID_ia64_linux2		2200
 #define SYS_NAME_ID_ia64_linux22	2201
@@ -347,7 +356,10 @@
 #define SYS_NAME_ID_amd64_fbsd_104     3054
 #define SYS_NAME_ID_amd64_fbsd_110     3040
 #define SYS_NAME_ID_amd64_fbsd_111     3041
+#define SYS_NAME_ID_amd64_fbsd_112     3042
+#define SYS_NAME_ID_amd64_fbsd_113     3043
 #define SYS_NAME_ID_amd64_fbsd_120     3060
+#define SYS_NAME_ID_amd64_fbsd_121     3061
 
 #define SYS_NAME_ID_amd64_w2k           3400
 
@@ -385,6 +397,10 @@
 #define SYS_NAME_ID_amd64_obsd53        4022
 #define SYS_NAME_ID_amd64_obsd54        4023
 
+#define SYS_NAME_ID_arm64_linux2	4100
+#define SYS_NAME_ID_arm64_linux26	4103
+
+#define SYS_NAME_ID_ppc64le_linux26	4203
 
 #define	AFS_REALM_SZ	64
 
diff --git a/src/config/afsconfig-windows.h b/src/config/afsconfig-windows.h
index 6e6a6c2ea..9c2baa0d2 100644
--- a/src/config/afsconfig-windows.h
+++ b/src/config/afsconfig-windows.h
@@ -30,10 +30,6 @@
 /* Define if you need to in order for stat and other things to work.  */
 #undef _POSIX_SOURCE
 
-/* Define as the return type of signal handlers (int or void).  */
-#undef RETSIGTYPE
-
-
 /* The size of `long', as computed by sizeof. */
 #define SIZEOF_LONG 4
 
@@ -163,7 +159,7 @@
 #undef HAVE_VFS_DQRWLOCK
 
 /* define if you have pread() and pwrite() */
-#define HAVE_PIO 1
+#undef HAVE_PIO
 
 #undef PACKAGE
 #undef VERSION
diff --git a/src/config/cc-wrapper.in b/src/config/cc-wrapper.in
new file mode 100644
index 000000000..8ef305fc9
--- /dev/null
+++ b/src/config/cc-wrapper.in
@@ -0,0 +1,112 @@
+#!/bin/sh
+#
+# usage:
+# cc-wrapper cc /path/to/cc -c -o foo.o foo.c
+# cc-wrapper ld /path/to/ld -o foo foo.o
+#
+# This wraps running the compiler or linker, so we can tweak the files
+# generated. Currently, this just involves running ctfconvert or ctfmerge on
+# the relevant files, if available.
+
+set -e
+
+CTFCONVERT=@CTFCONVERT@
+CTFMERGE=@CTFMERGE@
+ctf_label=openafs
+
+mode="$1"
+shift
+
+# First, run the command that we're wrapping.
+"$@"
+
+# If we've reached here, the compiler/linker finished successfully, so now we
+# can run ctfconvert/ctfmerge, if we're configured to. If we're not going to
+# process ctf stuff, we can just exit immediately.
+if [ x"$CTFCONVERT" = x ] || [ x"$CTFMERGE" = x ] ; then
+    exit 0
+fi
+
+# Look for our target file (indicated by '-o target'), and if debugging is
+# turned on (indicated by '-g')
+target=
+target_next=
+debug=
+for arg in "$@" ; do
+    if [ x"$target_next" = x1 ] ; then
+        target="$arg"
+        target_next=
+        continue
+    fi
+
+    case "$arg" in
+    -o) target_next=1
+        ;;
+    -g) debug=1
+        ;;
+    esac
+done
+
+if [ x"$OPENAFS_CC_WRAPPER_DEBUG_FLAG" != x ] ; then
+    # Normally we try to determine if debugging is turned on by searching $@
+    # for "-g". But sometimes we link something with debugging info and don't
+    # pass -g (the Solaris kernel module, for example). In this case, the
+    # caller can specify whether that debugging is turned on by setting the env
+    # var OPENAFS_CC_WRAPPER_DEBUG_FLAG to a nonempty string.
+    debug=1
+fi
+
+if [ x"$debug" = x ] ; then
+    # Don't run ctfconvert/ctfmerge if debugging isn't turned on.
+    exit 0
+fi
+
+if [ x"$target" = x ] ; then
+    echo "$0: error: cannot extract target from args" >&2
+    exit 1
+fi
+
+echo_run() {
+    if [ x"$V" != x0 ] ; then
+        echo "$@"
+    fi
+    "$@"
+}
+
+case "$mode" in
+cc)
+    # It looks like we compiled a single object. For that, we just need to run
+    # 'ctfconvert' against the target .o.
+    echo_run "$CTFCONVERT" -g -l $ctf_label "$target"
+    ;;
+
+ld)
+    # It looks like we're linking an executable. For that, we need to give
+    # 'ctfmerge' every .o and .a that we're linking against.
+
+    merge_objs=
+    for arg in "$@" ; do
+        case "$arg" in
+        *.[oa])
+            merge_objs="$merge_objs $arg"
+            ;;
+        esac
+    done
+
+    if [ x"$merge_objs" = x ] ; then
+        # If we can't find any .o or .a files that we're linking into the
+        # target executable, our caller is probably compiling/linking directly
+        # from foo.c into foo (skipping foo.o). For that, we just need to run
+        # ctfconvert/ctfmerge on the executable itself.
+        echo_run "$CTFCONVERT" -g -l $ctf_label "$target"
+        merge_objs="$target"
+    fi
+
+    echo_run "$CTFMERGE" -g -l $ctf_label -o "$target" $merge_objs
+    ;;
+
+*)
+    echo "$0: Unknown mode '$mode'" >&2
+    exit 1
+    ;;
+esac
diff --git a/src/config/lwptool b/src/config/lwptool
index 2cb55e68b..36046114f 100755
--- a/src/config/lwptool
+++ b/src/config/lwptool
@@ -11,6 +11,7 @@ ranlib=
 mode=
 object=
 done=
+quiet=
 
 while [ -z "$done" ] && [ $# -gt 0 ] ; do
     case "$1" in
@@ -39,6 +40,10 @@ while [ -z "$done" ] && [ $# -gt 0 ] ; do
 	ranlib="$1"
 	shift
 	;;
+    --quiet)
+	shift
+	quiet="1"
+	;;
     -o)
 	shift
 	object="$1"
@@ -55,6 +60,18 @@ while [ -z "$done" ] && [ $# -gt 0 ] ; do
     esac
 done
 
+_run_cmd() {
+    if [ x"$quiet" != x1 ] ; then
+	echo "$@"
+    fi
+    if "$@" ; then
+	:
+    else
+	echo "FAILED LWPTOOL COMMAND: $@" >&2
+	exit 1
+    fi
+}
+
 case "$mode" in
 compile)
     if [ -z "$object" ] || [ -z "$lwpcc" ] || \
@@ -69,10 +86,8 @@ compile)
     lwpobj=".lwp/$lwpobj"
 
     mkdir .lwp 2>/dev/null
-    echo $lwpcc -o $lwpobj "$@"
-    $lwpcc -o $lwpobj "$@" || exit 1
-    echo $mtcc -o $object "$@"
-    $mtcc -o $object "$@" || exit 1
+    _run_cmd $lwpcc -o $lwpobj "$@"
+    _run_cmd $mtcc -o $object "$@"
     ;;
 link)
     if [ -z "$object" ] || [ -z "$linker" ] || \
@@ -95,9 +110,7 @@ link)
     done
 
     rm -f $object 2>/dev/null
-    echo $linker $object $objects
-    $linker $object $objects
-    echo $ranlib $object
-    $ranlib $object
+    _run_cmd $linker $object $objects
+    _run_cmd $ranlib $object
     ;;
 esac
diff --git a/src/config/param.amd64_fbsd_100.h b/src/config/param.amd64_fbsd_100.h
index 7a8a26559..adc44ea2a 100644
--- a/src/config/param.amd64_fbsd_100.h
+++ b/src/config/param.amd64_fbsd_100.h
@@ -12,71 +12,12 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
-
 #else /* !defined(UKERNEL) */
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
-
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_101.h b/src/config/param.amd64_fbsd_101.h
index d092cd98f..455b77829 100644
--- a/src/config/param.amd64_fbsd_101.h
+++ b/src/config/param.amd64_fbsd_101.h
@@ -12,74 +12,18 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 
 #else /* !defined(UKERNEL) */
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_102.h b/src/config/param.amd64_fbsd_102.h
index 6aad21d68..17a634d0f 100644
--- a/src/config/param.amd64_fbsd_102.h
+++ b/src/config/param.amd64_fbsd_102.h
@@ -12,47 +12,9 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD102_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD102_ENV 1
 
@@ -60,29 +22,11 @@
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD102_ENV 1
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_103.h b/src/config/param.amd64_fbsd_103.h
index b768999bb..17986d010 100644
--- a/src/config/param.amd64_fbsd_103.h
+++ b/src/config/param.amd64_fbsd_103.h
@@ -12,48 +12,10 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD102_ENV 1
 #define AFS_FBSD103_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD102_ENV 1
 #define AFS_X86_FBSD103_ENV 1
@@ -62,30 +24,12 @@
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD102_ENV 1
 #define AFS_USR_FBSD103_ENV 1
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_104.h b/src/config/param.amd64_fbsd_104.h
index 26950fa2e..d5e9e92b9 100644
--- a/src/config/param.amd64_fbsd_104.h
+++ b/src/config/param.amd64_fbsd_104.h
@@ -12,49 +12,11 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD102_ENV 1
 #define AFS_FBSD103_ENV 1
 #define AFS_FBSD104_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD102_ENV 1
 #define AFS_X86_FBSD103_ENV 1
@@ -64,26 +26,6 @@
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD102_ENV 1
 #define AFS_USR_FBSD103_ENV 1
@@ -91,4 +33,6 @@
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_110.h b/src/config/param.amd64_fbsd_110.h
index 2e896a843..954a7e8e9 100644
--- a/src/config/param.amd64_fbsd_110.h
+++ b/src/config/param.amd64_fbsd_110.h
@@ -12,74 +12,18 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD110_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD110_ENV 1
 
 #else /* !defined(UKERNEL) */
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD110_ENV 1
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_111.h b/src/config/param.amd64_fbsd_111.h
index 34d724e13..7bd52614f 100644
--- a/src/config/param.amd64_fbsd_111.h
+++ b/src/config/param.amd64_fbsd_111.h
@@ -12,47 +12,15 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
 #define AFS_FBSD110_ENV 1
 #define AFS_FBSD111_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
 #define AFS_X86_FBSD110_ENV 1
 #define AFS_X86_FBSD111_ENV 1
 
@@ -60,29 +28,14 @@
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
 #define AFS_USR_FBSD110_ENV 1
 #define AFS_USR_FBSD111_ENV 1
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_112.h b/src/config/param.amd64_fbsd_112.h
new file mode 100644
index 000000000..de7574e17
--- /dev/null
+++ b/src/config/param.amd64_fbsd_112.h
@@ -0,0 +1,44 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"amd64_fbsd_112"
+#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_112
+
+#define AFS_64BITPOINTER_ENV 1
+
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#define AFS_64BITUSERPOINTER_ENV 1
+
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD110_ENV 1
+#define AFS_FBSD111_ENV 1
+#define AFS_FBSD112_ENV 1
+
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD110_ENV 1
+#define AFS_X86_FBSD111_ENV 1
+#define AFS_X86_FBSD112_ENV 1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD110_ENV 1
+#define AFS_USR_FBSD111_ENV 1
+#define AFS_USR_FBSD112_ENV 1
+
+#endif /* !defined(UKERNEL) */
+
+#define USE_UCONTEXT
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_113.h b/src/config/param.amd64_fbsd_113.h
new file mode 100644
index 000000000..44b0e7f5e
--- /dev/null
+++ b/src/config/param.amd64_fbsd_113.h
@@ -0,0 +1,47 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"amd64_fbsd_113"
+#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_113
+
+#define AFS_64BITPOINTER_ENV 1
+
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#define AFS_64BITUSERPOINTER_ENV 1
+
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD110_ENV 1
+#define AFS_FBSD111_ENV 1
+#define AFS_FBSD112_ENV 1
+#define AFS_FBSD113_ENV 1
+
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD110_ENV 1
+#define AFS_X86_FBSD111_ENV 1
+#define AFS_X86_FBSD112_ENV 1
+#define AFS_X86_FBSD113_ENV 1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD110_ENV 1
+#define AFS_USR_FBSD111_ENV 1
+#define AFS_USR_FBSD112_ENV 1
+#define AFS_USR_FBSD113_ENV 1
+
+#endif /* !defined(UKERNEL) */
+
+#define USE_UCONTEXT
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_120.h b/src/config/param.amd64_fbsd_120.h
index dac0f28c9..4b17ab28f 100644
--- a/src/config/param.amd64_fbsd_120.h
+++ b/src/config/param.amd64_fbsd_120.h
@@ -12,48 +12,18 @@
 
 #define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD104_ENV 1
 #define AFS_FBSD110_ENV 1
 #define AFS_FBSD111_ENV 1
 #define AFS_FBSD120_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD104_ENV 1
 #define AFS_X86_FBSD110_ENV 1
 #define AFS_X86_FBSD111_ENV 1
 #define AFS_X86_FBSD120_ENV 1
@@ -62,30 +32,16 @@
 
 /* This section for user space compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD104_ENV 1
 #define AFS_USR_FBSD110_ENV 1
 #define AFS_USR_FBSD111_ENV 1
 #define AFS_USR_FBSD120_ENV 1
 
 #endif /* !defined(UKERNEL) */
 
+#define USE_UCONTEXT
+
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_121.h b/src/config/param.amd64_fbsd_121.h
new file mode 100644
index 000000000..f95b5f19d
--- /dev/null
+++ b/src/config/param.amd64_fbsd_121.h
@@ -0,0 +1,50 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"amd64_fbsd_121"
+#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_121
+
+#define AFS_64BITPOINTER_ENV 1
+
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#define AFS_64BITUSERPOINTER_ENV 1
+
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD104_ENV 1
+#define AFS_FBSD110_ENV 1
+#define AFS_FBSD111_ENV 1
+#define AFS_FBSD120_ENV 1
+#define AFS_FBSD121_ENV 1
+
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD104_ENV 1
+#define AFS_X86_FBSD110_ENV 1
+#define AFS_X86_FBSD111_ENV 1
+#define AFS_X86_FBSD120_ENV 1
+#define AFS_X86_FBSD121_ENV 1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD104_ENV 1
+#define AFS_USR_FBSD110_ENV 1
+#define AFS_USR_FBSD111_ENV 1
+#define AFS_USR_FBSD120_ENV 1
+#define AFS_USR_FBSD121_ENV 1
+
+#endif /* !defined(UKERNEL) */
+
+#define USE_UCONTEXT
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_80.h b/src/config/param.amd64_fbsd_80.h
deleted file mode 100644
index 29b03462c..000000000
--- a/src/config/param.amd64_fbsd_80.h
+++ /dev/null
@@ -1,55 +0,0 @@
-#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 AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_81.h b/src/config/param.amd64_fbsd_81.h
deleted file mode 100644
index 006e06436..000000000
--- a/src/config/param.amd64_fbsd_81.h
+++ /dev/null
@@ -1,58 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_81"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_81
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_82.h b/src/config/param.amd64_fbsd_82.h
deleted file mode 100644
index c8d95917c..000000000
--- a/src/config/param.amd64_fbsd_82.h
+++ /dev/null
@@ -1,61 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_82"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_82
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_83.h b/src/config/param.amd64_fbsd_83.h
deleted file mode 100644
index d27d314d2..000000000
--- a/src/config/param.amd64_fbsd_83.h
+++ /dev/null
@@ -1,64 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_83"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_83
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_84.h b/src/config/param.amd64_fbsd_84.h
deleted file mode 100644
index 903c83bb4..000000000
--- a/src/config/param.amd64_fbsd_84.h
+++ /dev/null
@@ -1,67 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_84"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_84
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_90.h b/src/config/param.amd64_fbsd_90.h
deleted file mode 100644
index e56c2d097..000000000
--- a/src/config/param.amd64_fbsd_90.h
+++ /dev/null
@@ -1,70 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_90"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_90
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_91.h b/src/config/param.amd64_fbsd_91.h
deleted file mode 100644
index 3ef236a97..000000000
--- a/src/config/param.amd64_fbsd_91.h
+++ /dev/null
@@ -1,73 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_91"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_91
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_92.h b/src/config/param.amd64_fbsd_92.h
deleted file mode 100644
index 95c6e19c6..000000000
--- a/src/config/param.amd64_fbsd_92.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_92"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_92
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.amd64_fbsd_93.h b/src/config/param.amd64_fbsd_93.h
deleted file mode 100644
index 1a798c8f8..000000000
--- a/src/config/param.amd64_fbsd_93.h
+++ /dev/null
@@ -1,79 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"amd64_fbsd_93"
-#define SYS_NAME_ID	SYS_NAME_ID_amd64_fbsd_93
-
-#define AFS_64BITPOINTER_ENV 1
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#define AFS_64BITUSERPOINTER_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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_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_FBSD72_ENV 1
-#define AFS_X86_FBSD73_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.arm64_linux26.h b/src/config/param.arm64_linux26.h
new file mode 100644
index 000000000..02e867a33
--- /dev/null
+++ b/src/config/param.arm64_linux26.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *
+ * This software has been released under the terms of the IBM Public
+ * License. For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+
+#ifndef AFS_PARAM_H
+#define AFS_PARAM_H
+
+#ifndef UKERNEL
+
+/* This section for kernel libafs compiles only */
+#define AFS_ARM64_LINUX26_ENV	1
+#define AFS_LINUX_64BIT_KERNEL	1
+#define AFS_64BITPOINTER_ENV	1	/* pointers are 64 bits */
+#define AFS_64BITUSERPOINTER_ENV	1
+#define AFS_MAXVCOUNT_ENV       1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+#define UKERNEL			1	/* user space kernel */
+
+#endif /* !defined(UKERNEL) */
+
+#ifndef USE_UCONTEXT
+#define USE_UCONTEXT
+#endif
+
+/* Machine / Operating system information */
+#define SYS_NAME		"arm64_linux26"
+#define SYS_NAME_ID		SYS_NAME_ID_arm64_linux26
+#define AFSLITTLE_ENDIAN	1
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.arm_darwin_100.h b/src/config/param.arm_darwin_100.h
index 2344be0b8..2783416b4 100644
--- a/src/config/param.arm_darwin_100.h
+++ b/src/config/param.arm_darwin_100.h
@@ -133,7 +133,6 @@ struct rt_addrinfo {
 #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
diff --git a/src/config/param.generic_fbsd.h b/src/config/param.generic_fbsd.h
index bc193bf66..e388db820 100644
--- a/src/config/param.generic_fbsd.h
+++ b/src/config/param.generic_fbsd.h
@@ -68,7 +68,6 @@
 #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)
diff --git a/src/config/param.hp_ux102.h b/src/config/param.hp_ux102.h
index bf83b16bd..93fd121d5 100644
--- a/src/config/param.hp_ux102.h
+++ b/src/config/param.hp_ux102.h
@@ -63,7 +63,6 @@
 #define	AFS_UIOUSER	UIOSEG_USER
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	do { struct timeval osi_GetTimeVar; uniqtime(&osi_GetTimeVar); (x)->tv_sec = osi_GetTimeVar.tv_sec; (x)->tv_usec = osi_GetTimeVar.tv_usec; } while(0)
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
 #define	VATTR_NULL	vattr_null
diff --git a/src/config/param.hp_ux110.h b/src/config/param.hp_ux110.h
index 8f0616b0a..ca541f955 100644
--- a/src/config/param.hp_ux110.h
+++ b/src/config/param.hp_ux110.h
@@ -64,7 +64,6 @@
 #define	AFS_UIOUSER	UIOSEG_USER
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	do { struct timeval osi_GetTimeVar; uniqtime(&osi_GetTimeVar); (x)->tv_sec = osi_GetTimeVar.tv_sec; (x)->tv_usec = osi_GetTimeVar.tv_usec; } while(0)
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
 #define	VATTR_NULL	vattr_null
diff --git a/src/config/param.hp_ux1123.h b/src/config/param.hp_ux1123.h
index fd5246c01..1ac65ab72 100644
--- a/src/config/param.hp_ux1123.h
+++ b/src/config/param.hp_ux1123.h
@@ -69,7 +69,6 @@
 #define	AFS_UIOUSER	UIOSEG_USER
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	do { struct timeval osi_GetTimeVar; uniqtime(&osi_GetTimeVar); (x)->tv_sec = osi_GetTimeVar.tv_sec; (x)->tv_usec = osi_GetTimeVar.tv_usec; } while(0)
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
 #define	VATTR_NULL	vattr_null
diff --git a/src/config/param.hp_ux11i.h b/src/config/param.hp_ux11i.h
index 074db768c..9a76aec1e 100644
--- a/src/config/param.hp_ux11i.h
+++ b/src/config/param.hp_ux11i.h
@@ -68,7 +68,6 @@
 #define	AFS_UIOUSER	UIOSEG_USER
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	do { struct timeval osi_GetTimeVar; uniqtime(&osi_GetTimeVar); (x)->tv_sec = osi_GetTimeVar.tv_sec; (x)->tv_usec = osi_GetTimeVar.tv_usec; } while(0)
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
 #define	VATTR_NULL	vattr_null
diff --git a/src/config/param.i386_fbsd_100.h b/src/config/param.i386_fbsd_100.h
index 0e898c4ce..e8cb97d02 100644
--- a/src/config/param.i386_fbsd_100.h
+++ b/src/config/param.i386_fbsd_100.h
@@ -10,77 +10,10 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
-
 #else /* !defined(UKERNEL) */
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
-
 #endif /* !defined(UKERNEL) */
 
 #endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_101.h b/src/config/param.i386_fbsd_101.h
index 6224bf2ad..9981ee037 100644
--- a/src/config/param.i386_fbsd_101.h
+++ b/src/config/param.i386_fbsd_101.h
@@ -10,78 +10,14 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 
 #else /* !defined(UKERNEL) */
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 
 #endif /* !defined(UKERNEL) */
diff --git a/src/config/param.i386_fbsd_102.h b/src/config/param.i386_fbsd_102.h
index 32c8b8e67..37a186bf7 100644
--- a/src/config/param.i386_fbsd_102.h
+++ b/src/config/param.i386_fbsd_102.h
@@ -10,52 +10,9 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD102_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD102_ENV 1
 
@@ -63,27 +20,6 @@
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD102_ENV 1
 
diff --git a/src/config/param.i386_fbsd_103.h b/src/config/param.i386_fbsd_103.h
index 55eb48e19..c2b22089b 100644
--- a/src/config/param.i386_fbsd_103.h
+++ b/src/config/param.i386_fbsd_103.h
@@ -10,53 +10,10 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD102_ENV 1
 #define AFS_FBSD103_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD102_ENV 1
 #define AFS_X86_FBSD103_ENV 1
@@ -65,27 +22,6 @@
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD102_ENV 1
 #define AFS_USR_FBSD103_ENV 1
diff --git a/src/config/param.i386_fbsd_104.h b/src/config/param.i386_fbsd_104.h
index 2af6a8b95..47ee4bf77 100644
--- a/src/config/param.i386_fbsd_104.h
+++ b/src/config/param.i386_fbsd_104.h
@@ -10,54 +10,11 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD102_ENV 1
 #define AFS_FBSD103_ENV 1
 #define AFS_FBSD104_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD102_ENV 1
 #define AFS_X86_FBSD103_ENV 1
@@ -67,27 +24,6 @@
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD102_ENV 1
 #define AFS_USR_FBSD103_ENV 1
diff --git a/src/config/param.i386_fbsd_110.h b/src/config/param.i386_fbsd_110.h
index 066c842b0..d554d7404 100644
--- a/src/config/param.i386_fbsd_110.h
+++ b/src/config/param.i386_fbsd_110.h
@@ -10,52 +10,9 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
 #define AFS_FBSD110_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
 #define AFS_X86_FBSD110_ENV 1
 
@@ -63,27 +20,6 @@
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
 #define AFS_USR_FBSD110_ENV 1
 
diff --git a/src/config/param.i386_fbsd_111.h b/src/config/param.i386_fbsd_111.h
index bc68b9833..1d8d2a07e 100644
--- a/src/config/param.i386_fbsd_111.h
+++ b/src/config/param.i386_fbsd_111.h
@@ -10,54 +10,15 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
 #define AFS_FBSD110_ENV 1
 #define AFS_FBSD111_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
 #define AFS_X86_FBSD110_ENV 1
 #define AFS_X86_FBSD111_ENV 1
 
@@ -65,28 +26,9 @@
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
 #define AFS_USR_FBSD110_ENV 1
 #define AFS_USR_FBSD111_ENV 1
 
diff --git a/src/config/param.i386_fbsd_112.h b/src/config/param.i386_fbsd_112.h
new file mode 100644
index 000000000..1724c6d27
--- /dev/null
+++ b/src/config/param.i386_fbsd_112.h
@@ -0,0 +1,40 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"i386_fbsd_112"
+#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_112
+
+#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
+
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD110_ENV 1
+#define AFS_FBSD111_ENV 1
+#define AFS_FBSD112_ENV 1
+
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD110_ENV 1
+#define AFS_X86_FBSD111_ENV 1
+#define AFS_X86_FBSD112_ENV 1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD110_ENV 1
+#define AFS_USR_FBSD111_ENV 1
+#define AFS_USR_FBSD112_ENV 1
+
+#endif /* !defined(UKERNEL) */
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_113.h b/src/config/param.i386_fbsd_113.h
new file mode 100644
index 000000000..de77e8666
--- /dev/null
+++ b/src/config/param.i386_fbsd_113.h
@@ -0,0 +1,43 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"i386_fbsd_113"
+#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_113
+
+#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
+
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD110_ENV 1
+#define AFS_FBSD111_ENV 1
+#define AFS_FBSD112_ENV 1
+#define AFS_FBSD113_ENV 1
+
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD110_ENV 1
+#define AFS_X86_FBSD111_ENV 1
+#define AFS_X86_FBSD112_ENV 1
+#define AFS_X86_FBSD113_ENV 1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD110_ENV 1
+#define AFS_USR_FBSD111_ENV 1
+#define AFS_USR_FBSD112_ENV 1
+#define AFS_USR_FBSD113_ENV 1
+
+#endif /* !defined(UKERNEL) */
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_120.h b/src/config/param.i386_fbsd_120.h
index e27faa567..ff1e140fc 100644
--- a/src/config/param.i386_fbsd_120.h
+++ b/src/config/param.i386_fbsd_120.h
@@ -10,55 +10,18 @@
 #ifndef UKERNEL
 /* This section for kernel libafs compiles only */
 
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-#define AFS_FBSD100_ENV 1
 #define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD104_ENV 1
 #define AFS_FBSD110_ENV 1
 #define AFS_FBSD111_ENV 1
 #define AFS_FBSD120_ENV 1
 
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-#define AFS_X86_FBSD100_ENV 1
 #define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD104_ENV 1
 #define AFS_X86_FBSD110_ENV 1
 #define AFS_X86_FBSD111_ENV 1
 #define AFS_X86_FBSD120_ENV 1
@@ -67,28 +30,10 @@
 
 /* This section for user space compiles only */
 
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-#define AFS_USR_FBSD100_ENV 1
 #define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD104_ENV 1
 #define AFS_USR_FBSD110_ENV 1
 #define AFS_USR_FBSD111_ENV 1
 #define AFS_USR_FBSD120_ENV 1
diff --git a/src/config/param.i386_fbsd_121.h b/src/config/param.i386_fbsd_121.h
new file mode 100644
index 000000000..88b58fbc9
--- /dev/null
+++ b/src/config/param.i386_fbsd_121.h
@@ -0,0 +1,46 @@
+#ifndef	AFS_PARAM_H
+#define	AFS_PARAM_H
+
+/* Machine / Operating system information */
+#define SYS_NAME	"i386_fbsd_121"
+#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_121
+
+#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
+
+#ifndef UKERNEL
+/* This section for kernel libafs compiles only */
+
+#define AFS_FBSD101_ENV 1
+#define AFS_FBSD102_ENV 1
+#define AFS_FBSD103_ENV 1
+#define AFS_FBSD104_ENV 1
+#define AFS_FBSD110_ENV 1
+#define AFS_FBSD111_ENV 1
+#define AFS_FBSD120_ENV 1
+#define AFS_FBSD121_ENV 1
+
+#define AFS_X86_FBSD101_ENV 1
+#define AFS_X86_FBSD102_ENV 1
+#define AFS_X86_FBSD103_ENV 1
+#define AFS_X86_FBSD104_ENV 1
+#define AFS_X86_FBSD110_ENV 1
+#define AFS_X86_FBSD111_ENV 1
+#define AFS_X86_FBSD120_ENV 1
+#define AFS_X86_FBSD121_ENV 1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+
+#define AFS_USR_FBSD101_ENV 1
+#define AFS_USR_FBSD102_ENV 1
+#define AFS_USR_FBSD103_ENV 1
+#define AFS_USR_FBSD104_ENV 1
+#define AFS_USR_FBSD110_ENV 1
+#define AFS_USR_FBSD111_ENV 1
+#define AFS_USR_FBSD120_ENV 1
+#define AFS_USR_FBSD121_ENV 1
+
+#endif /* !defined(UKERNEL) */
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_80.h b/src/config/param.i386_fbsd_80.h
deleted file mode 100644
index 02a52d363..000000000
--- a/src/config/param.i386_fbsd_80.h
+++ /dev/null
@@ -1,59 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_80"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_80
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_81.h b/src/config/param.i386_fbsd_81.h
deleted file mode 100644
index 5112efe30..000000000
--- a/src/config/param.i386_fbsd_81.h
+++ /dev/null
@@ -1,62 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_81"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_81
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_82.h b/src/config/param.i386_fbsd_82.h
deleted file mode 100644
index 12f15c492..000000000
--- a/src/config/param.i386_fbsd_82.h
+++ /dev/null
@@ -1,65 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_82"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_82
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_83.h b/src/config/param.i386_fbsd_83.h
deleted file mode 100644
index 9116291d8..000000000
--- a/src/config/param.i386_fbsd_83.h
+++ /dev/null
@@ -1,68 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_83"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_83
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_84.h b/src/config/param.i386_fbsd_84.h
deleted file mode 100644
index 5e6eab937..000000000
--- a/src/config/param.i386_fbsd_84.h
+++ /dev/null
@@ -1,71 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_84"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_84
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_90.h b/src/config/param.i386_fbsd_90.h
deleted file mode 100644
index c35cc2446..000000000
--- a/src/config/param.i386_fbsd_90.h
+++ /dev/null
@@ -1,74 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_90"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_90
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_91.h b/src/config/param.i386_fbsd_91.h
deleted file mode 100644
index 9ab6de4d3..000000000
--- a/src/config/param.i386_fbsd_91.h
+++ /dev/null
@@ -1,77 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_91"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_91
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_92.h b/src/config/param.i386_fbsd_92.h
deleted file mode 100644
index d084b58b3..000000000
--- a/src/config/param.i386_fbsd_92.h
+++ /dev/null
@@ -1,80 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_92"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_92
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.i386_fbsd_93.h b/src/config/param.i386_fbsd_93.h
deleted file mode 100644
index 39086a7dd..000000000
--- a/src/config/param.i386_fbsd_93.h
+++ /dev/null
@@ -1,83 +0,0 @@
-#ifndef	AFS_PARAM_H
-#define	AFS_PARAM_H
-
-/* Machine / Operating system information */
-#define SYS_NAME	"i386_fbsd_93"
-#define SYS_NAME_ID	SYS_NAME_ID_i386_fbsd_93
-
-#define AFS_FAKEOPEN_ENV 1	/* call afs_FakeOpen as if !AFS_VM_RDWR */
-
-#ifndef UKERNEL
-/* This section for kernel libafs compiles only */
-
-#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_FBSD72_ENV 1
-#define AFS_FBSD73_ENV 1
-#define AFS_FBSD74_ENV 1
-#define AFS_FBSD80_ENV 1
-#define AFS_FBSD81_ENV 1
-#define AFS_FBSD82_ENV 1
-#define AFS_FBSD83_ENV 1
-#define AFS_FBSD84_ENV 1
-#define AFS_FBSD90_ENV 1
-#define AFS_FBSD91_ENV 1
-#define AFS_FBSD92_ENV 1
-#define AFS_FBSD93_ENV 1
-
-#define AFS_X86_FBSD50_ENV 1
-#define AFS_X86_FBSD51_ENV 1
-#define AFS_X86_FBSD52_ENV 1
-#define AFS_X86_FBSD53_ENV 1
-#define AFS_X86_FBSD60_ENV 1
-#define AFS_X86_FBSD61_ENV 1
-#define AFS_X86_FBSD62_ENV 1
-#define AFS_X86_FBSD70_ENV 1
-#define AFS_X86_FBSD71_ENV 1
-#define AFS_X86_FBSD72_ENV 1
-#define AFS_X86_FBSD74_ENV 1
-#define AFS_X86_FBSD80_ENV 1
-#define AFS_X86_FBSD81_ENV 1
-#define AFS_X86_FBSD82_ENV 1
-#define AFS_X86_FBSD83_ENV 1
-#define AFS_X86_FBSD84_ENV 1
-#define AFS_X86_FBSD90_ENV 1
-#define AFS_X86_FBSD91_ENV 1
-#define AFS_X86_FBSD92_ENV 1
-#define AFS_X86_FBSD93_ENV 1
-
-#else /* !defined(UKERNEL) */
-
-/* This section for user space compiles only */
-
-#define AFS_USR_FBSD50_ENV 1
-#define AFS_USR_FBSD51_ENV 1
-#define AFS_USR_FBSD52_ENV 1
-#define AFS_USR_FBSD53_ENV 1
-#define AFS_USR_FBSD60_ENV 1
-#define AFS_USR_FBSD61_ENV 1
-#define AFS_USR_FBSD62_ENV 1
-#define AFS_USR_FBSD70_ENV 1
-#define AFS_USR_FBSD71_ENV 1
-#define AFS_USR_FBSD72_ENV 1
-#define AFS_USR_FBSD73_ENV 1
-#define AFS_USR_FBSD80_ENV 1
-#define AFS_USR_FBSD81_ENV 1
-#define AFS_USR_FBSD82_ENV 1
-#define AFS_USR_FBSD83_ENV 1
-#define AFS_USR_FBSD84_ENV 1
-#define AFS_USR_FBSD90_ENV 1
-#define AFS_USR_FBSD91_ENV 1
-#define AFS_USR_FBSD92_ENV 1
-#define AFS_USR_FBSD93_ENV 1
-
-#endif /* !defined(UKERNEL) */
-
-#endif /* AFS_PARAM_H */
diff --git a/src/config/param.ia64_hpux1122.h b/src/config/param.ia64_hpux1122.h
index 82435e831..d659b4931 100644
--- a/src/config/param.ia64_hpux1122.h
+++ b/src/config/param.ia64_hpux1122.h
@@ -68,7 +68,6 @@
 #define	AFS_UIOUSER	UIOSEG_USER
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	do { struct timeval osi_GetTimeVar; uniqtime(&osi_GetTimeVar); (x)->tv_sec = osi_GetTimeVar.tv_sec; (x)->tv_usec = osi_GetTimeVar.tv_usec; } while(0)
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
 #define	VATTR_NULL	vattr_null
diff --git a/src/config/param.ia64_hpux1123.h b/src/config/param.ia64_hpux1123.h
index 00b513fe7..5931bc80a 100644
--- a/src/config/param.ia64_hpux1123.h
+++ b/src/config/param.ia64_hpux1123.h
@@ -69,7 +69,6 @@
 #define	AFS_UIOUSER	UIOSEG_USER
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	do { struct timeval osi_GetTimeVar; uniqtime(&osi_GetTimeVar); (x)->tv_sec = osi_GetTimeVar.tv_sec; (x)->tv_usec = osi_GetTimeVar.tv_usec; } while(0)
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
 #define	VATTR_NULL	vattr_null
diff --git a/src/config/param.linux26.h b/src/config/param.linux26.h
index 37de8d6ea..3ea6a394c 100644
--- a/src/config/param.linux26.h
+++ b/src/config/param.linux26.h
@@ -37,6 +37,7 @@
 #define AFS_VM_RDWR_ENV		1	/* read/write implemented via VM */
 #define AFS_USE_GETTIMEOFDAY	1	/* use gettimeofday to implement rx clock */
 #define AFS_MAXVCOUNT_ENV       1
+#define AFS_NEW_BKG             1
 
 #define AFS_PRIVATE_OSI_ALLOCSPACES	1
 
diff --git a/src/config/param.nbsd15.h b/src/config/param.nbsd15.h
index 905a1c107..9714ee609 100644
--- a/src/config/param.nbsd15.h
+++ b/src/config/param.nbsd15.h
@@ -67,7 +67,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd16.h b/src/config/param.nbsd16.h
index bb88fe200..6694be28a 100644
--- a/src/config/param.nbsd16.h
+++ b/src/config/param.nbsd16.h
@@ -68,7 +68,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd20.h b/src/config/param.nbsd20.h
index 07e741567..c294b77b2 100644
--- a/src/config/param.nbsd20.h
+++ b/src/config/param.nbsd20.h
@@ -74,7 +74,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd21.h b/src/config/param.nbsd21.h
index bb63588df..7de8d329a 100644
--- a/src/config/param.nbsd21.h
+++ b/src/config/param.nbsd21.h
@@ -74,7 +74,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd30.h b/src/config/param.nbsd30.h
index 95a1c0246..2c67a8ff9 100644
--- a/src/config/param.nbsd30.h
+++ b/src/config/param.nbsd30.h
@@ -70,7 +70,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd40.h b/src/config/param.nbsd40.h
index d4b473081..076160707 100644
--- a/src/config/param.nbsd40.h
+++ b/src/config/param.nbsd40.h
@@ -10,14 +10,6 @@
 #define AFS_MOUNT_AFS "afs"	/* The name of the filesystem type. */
 #define AFS_SYSCALL 318 /* 210 */
 
-#if 0
-/* including this file before sysincludes.h is canonical, but
- * NBSD40's mount.h defines MOUNT_AFS */
-#ifndef	MOUNT_AFS
-#define	MOUNT_AFS AFS_MOUNT_AFS
-#endif
-#endif
-
 #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
 
 #define AFS_NBSD_ENV 1
@@ -80,7 +72,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd50.h b/src/config/param.nbsd50.h
index a65e5c980..0be55a184 100644
--- a/src/config/param.nbsd50.h
+++ b/src/config/param.nbsd50.h
@@ -15,16 +15,6 @@
 #define AFS_KFREE               kmem_free
 #define VATTR_NULL              vattr_null
 
-#if 0
-/* including this file before sysincludes.h is canonical, but
- * NBSD40's mount.h defines MOUNT_AFS */
-
-#ifndef	MOUNT_AFS
-#define	MOUNT_AFS AFS_MOUNT_AFS
-#endif
-
-#endif /* 0 */
-
 #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
 
 #define AFS_NBSD_ENV 1
@@ -80,7 +70,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd60.h b/src/config/param.nbsd60.h
index 196e9d40b..f6a1aef6e 100644
--- a/src/config/param.nbsd60.h
+++ b/src/config/param.nbsd60.h
@@ -15,16 +15,6 @@
 #define AFS_KFREE               kmem_free
 #define VATTR_NULL              vattr_null
 
-#if 0
-/* including this file before sysincludes.h is canonical, but
- * NBSD40's mount.h defines MOUNT_AFS */
-
-#ifndef	MOUNT_AFS
-#define	MOUNT_AFS AFS_MOUNT_AFS
-#endif
-
-#endif /* 0 */
-
 #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
 
 #define AFS_NBSD_ENV 1
@@ -81,7 +71,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.nbsd70.h b/src/config/param.nbsd70.h
index f01ecb9b4..ac5b98d39 100644
--- a/src/config/param.nbsd70.h
+++ b/src/config/param.nbsd70.h
@@ -15,16 +15,6 @@
 #define AFS_KFREE               kmem_free
 #define VATTR_NULL              vattr_null
 
-#if 0
-/* including this file before sysincludes.h is canonical, but
- * NBSD40's mount.h defines MOUNT_AFS */
-
-#ifndef	MOUNT_AFS
-#define	MOUNT_AFS AFS_MOUNT_AFS
-#endif
-
-#endif /* 0 */
-
 #define AFS_XBSD_ENV 1		/* {Free,Open,Net}BSD */
 
 #define AFS_NBSD_ENV 1
@@ -82,7 +72,6 @@
 #define	AFS_UIOSYS	UIO_SYSSPACE
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
-#define	osi_GetTime(x)	microtime(x)
 #define	AFS_KALLOC(x)	kalloc(x)
 #define	AFS_KFREE(x,y)	kfree(x,y)
 #define	v_count		v_usecount
diff --git a/src/config/param.ppc64le_linux26.h b/src/config/param.ppc64le_linux26.h
new file mode 100644
index 000000000..9c8b8224d
--- /dev/null
+++ b/src/config/param.ppc64le_linux26.h
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2000, International Business Machines Corporation and others.
+ * All Rights Reserved.
+ *
+ * This software has been released under the terms of the IBM Public
+ * License.  For details, see the LICENSE file in the top-level source
+ * directory or online at http://www.openafs.org/dl/license10.html
+ */
+
+#ifndef AFS_PARAM_H
+#define AFS_PARAM_H
+
+#ifndef UKERNEL
+/* This section for kernel space compiles only */
+#define AFS_PPC64_LINUX20_ENV	1
+#define AFS_PPC64_LINUX22_ENV	1
+#define AFS_PPC64_LINUX24_ENV	1
+#define AFS_PPC64_LINUX26_ENV	1
+#define AFS_LINUX_64BIT_KERNEL	1
+#define AFS_64BITPOINTER_ENV	1     /* pointers are 64 bits */
+#define AFS_64BITUSERPOINTER_ENV	1
+
+#else /* !defined(UKERNEL) */
+
+/* This section for user space compiles only */
+#define UKERNEL			1	/* user space kernel */
+
+#endif /* !defined(UKERNEL) */
+
+/* Machine / Operating system information */
+#define SYS_NAME	"ppc64le_linux26"
+#define SYS_NAME_ID	SYS_NAME_ID_ppc64le_linux26
+
+#endif /* AFS_PARAM_H */
diff --git a/src/config/param.ppc_darwin_70.h b/src/config/param.ppc_darwin_70.h
index e72b317f0..7a71a32c5 100644
--- a/src/config/param.ppc_darwin_70.h
+++ b/src/config/param.ppc_darwin_70.h
@@ -50,7 +50,6 @@
 #define AFS_UIOSYS      UIO_SYSSPACE
 #define AFS_UIOUSER     UIO_USERSPACE
 #define AFS_CLBYTES     CLBYTES
-#define osi_GetTime(x)  microtime(x)
 #define AFS_KALLOC(x)   kalloc(x)
 #define AFS_KFREE(x,y)  kfree(x,y)
 #define v_count         v_usecount
diff --git a/src/config/param.ppc_darwin_80.h b/src/config/param.ppc_darwin_80.h
index 874353010..7b4a4d1f9 100644
--- a/src/config/param.ppc_darwin_80.h
+++ b/src/config/param.ppc_darwin_80.h
@@ -75,7 +75,6 @@
 #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
diff --git a/src/config/param.ppc_darwin_90.h b/src/config/param.ppc_darwin_90.h
index 01e3ad135..bce4212c2 100644
--- a/src/config/param.ppc_darwin_90.h
+++ b/src/config/param.ppc_darwin_90.h
@@ -80,7 +80,6 @@
 #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
diff --git a/src/config/param.rs_aix42.h b/src/config/param.rs_aix42.h
index b993bb5eb..dc38566aa 100644
--- a/src/config/param.rs_aix42.h
+++ b/src/config/param.rs_aix42.h
@@ -68,7 +68,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
 #define	osi_GTime(x)	time	/* something for the silly time(0)?? */
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
diff --git a/src/config/param.rs_aix51.h b/src/config/param.rs_aix51.h
index 6e265010e..08304c9eb 100644
--- a/src/config/param.rs_aix51.h
+++ b/src/config/param.rs_aix51.h
@@ -69,7 +69,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
 #define	osi_GTime(x)	time	/* something for the silly time(0)?? */
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
diff --git a/src/config/param.rs_aix52.h b/src/config/param.rs_aix52.h
index cd9f29d78..4a6487973 100644
--- a/src/config/param.rs_aix52.h
+++ b/src/config/param.rs_aix52.h
@@ -70,7 +70,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
 #define	osi_GTime(x)	time	/* something for the silly time(0)?? */
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
diff --git a/src/config/param.rs_aix53.h b/src/config/param.rs_aix53.h
index 8cec48395..382af535e 100644
--- a/src/config/param.rs_aix53.h
+++ b/src/config/param.rs_aix53.h
@@ -71,7 +71,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
 #define	osi_GTime(x)	time	/* something for the silly time(0)?? */
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
diff --git a/src/config/param.rs_aix61.h b/src/config/param.rs_aix61.h
index 85fbdc8ba..868fe9f3d 100644
--- a/src/config/param.rs_aix61.h
+++ b/src/config/param.rs_aix61.h
@@ -72,7 +72,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	CLBYTES
 #define	AFS_MINCHANGE	2
-#define osi_GetTime(x)          do {curtime(x); (x)->tv_usec = (x)->tv_usec/1000;} while (0)
 #define	osi_GTime(x)	time	/* something for the silly time(0)?? */
 #define	AFS_KALLOC	kmem_alloc
 #define	AFS_KFREE	kmem_free
diff --git a/src/config/param.sgi_65.h b/src/config/param.sgi_65.h
index 389bc8f71..bd40c4bd4 100644
--- a/src/config/param.sgi_65.h
+++ b/src/config/param.sgi_65.h
@@ -62,16 +62,6 @@
 #define AFS_SGI_XFS_IOPS_ENV 	1	/* turns on XFS inode ops. */
 #define AFS_64BIT_IOPS_ENV	1	/* inode ops expect 64 bit inodes */
 
-/* Vnode size and access differs between Octane and Origin. The number
- * can be used to indicate which altername vnodeX_t to use for future
- * changes.
- */
-#ifdef notdef
-/* SGI may have cleared this problem up. */
-#define AFS_SGI_VNODE_GLUE	1
-#endif
-
-
 /* File system entry (used if mount.h doesn't define MOUNT_AFS */
 #define AFS_MOUNT_AFS	 "afs"
 
@@ -101,11 +91,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	MCLBYTES
 #define	AFS_MINCHANGE	2
-#ifdef _K64U64
-#define	osi_GetTime(x)	irix5_microtime((struct __irix5_timeval*)(x))
-#else
-#define	osi_GetTime(x)	microtime(x)
-#endif
 #define	AFS_KALLOC(n)	kmem_alloc(n, KM_SLEEP)
 #define	AFS_KALLOC_NOSLEEP(n)	kmem_alloc(n, KM_NOSLEEP)
 #define	AFS_KFREE	kmem_free
diff --git a/src/config/param.sun4x_510.h b/src/config/param.sun4x_510.h
index 7225b56e7..803ea2a51 100644
--- a/src/config/param.sun4x_510.h
+++ b/src/config/param.sun4x_510.h
@@ -74,7 +74,6 @@
 #define	AFS_UIOUSER		UIO_USERSPACE
 #define	AFS_CLBYTES		MCLBYTES
 #define	AFS_MINCHANGE		2
-#define	osi_GetTime(x)		uniqtime32(x)
 
 /**
   * These defines are for the 64 bit Solaris 7 port
@@ -122,10 +121,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #define	AFS_SYSCALL		65
 
diff --git a/src/config/param.sun4x_511.h b/src/config/param.sun4x_511.h
index 714aa0ff7..a6891bb9a 100644
--- a/src/config/param.sun4x_511.h
+++ b/src/config/param.sun4x_511.h
@@ -77,7 +77,6 @@
 #define	AFS_UIOUSER		UIO_USERSPACE
 #define	AFS_CLBYTES		MCLBYTES
 #define	AFS_MINCHANGE		2
-#define	osi_GetTime(x)		uniqtime32(x)
 
 /**
   * These defines are for the 64 bit Solaris 7 port
@@ -126,10 +125,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 
 /* so we get _IOW() when we include sys/ioctl.h */
diff --git a/src/config/param.sun4x_58.h b/src/config/param.sun4x_58.h
index fff3b841c..df290549c 100644
--- a/src/config/param.sun4x_58.h
+++ b/src/config/param.sun4x_58.h
@@ -70,7 +70,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	MCLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	uniqtime32(x)
 
 /**
   * These defines are for the 64 bit Solaris 7 port
@@ -120,10 +119,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #define	AFS_SYSCALL		65
 
diff --git a/src/config/param.sun4x_59.h b/src/config/param.sun4x_59.h
index a80573c21..6ee6d6b1c 100644
--- a/src/config/param.sun4x_59.h
+++ b/src/config/param.sun4x_59.h
@@ -71,7 +71,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	MCLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	uniqtime32(x)
 
 /**
   * These defines are for the 64 bit Solaris 7 port
@@ -122,10 +121,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #define	AFS_SYSCALL		65
 
diff --git a/src/config/param.sunx86_510.h b/src/config/param.sunx86_510.h
index af43b1e3d..371e5eec3 100644
--- a/src/config/param.sunx86_510.h
+++ b/src/config/param.sunx86_510.h
@@ -84,7 +84,6 @@
 #define	AFS_UIOUSER		UIO_USERSPACE
 #define	AFS_CLBYTES		MCLBYTES
 #define	AFS_MINCHANGE		2
-#define	osi_GetTime(x)		uniqtime32(x)
 
 /**
   * These defines are for the 64 bit Solaris 7 port
@@ -132,10 +131,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #define	AFS_SYSCALL		65
 
diff --git a/src/config/param.sunx86_511.h b/src/config/param.sunx86_511.h
index c94bd8100..b20c0d0ee 100644
--- a/src/config/param.sunx86_511.h
+++ b/src/config/param.sunx86_511.h
@@ -87,7 +87,6 @@
 #define	AFS_UIOUSER		UIO_USERSPACE
 #define	AFS_CLBYTES		MCLBYTES
 #define	AFS_MINCHANGE		2
-#define	osi_GetTime(x)		uniqtime32(x)
 
 /**
   * These defines are for the 64 bit Solaris 7 port
@@ -135,10 +134,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 
 /* so we get _IOW() when we include sys/ioctl.h */
diff --git a/src/config/param.sunx86_58.h b/src/config/param.sunx86_58.h
index 246e99d05..e9969d35e 100644
--- a/src/config/param.sunx86_58.h
+++ b/src/config/param.sunx86_58.h
@@ -81,7 +81,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	MCLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	uniqtime32(x)
 
 #define	AFS_KALLOC(n)	kmem_alloc(n, KM_SLEEP)
 #define AFS_KALLOC_NOSLEEP(n)   kmem_alloc(n, KM_NOSLEEP)
@@ -129,10 +128,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #define	AFS_SYSCALL		65
 
diff --git a/src/config/param.sunx86_59.h b/src/config/param.sunx86_59.h
index 8eb9a15e2..0c072f707 100644
--- a/src/config/param.sunx86_59.h
+++ b/src/config/param.sunx86_59.h
@@ -82,7 +82,6 @@
 #define	AFS_UIOUSER	UIO_USERSPACE
 #define	AFS_CLBYTES	MCLBYTES
 #define	AFS_MINCHANGE	2
-#define	osi_GetTime(x)	uniqtime32(x)
 
 #define	AFS_KALLOC(n)	kmem_alloc(n, KM_SLEEP)
 #define AFS_KALLOC_NOSLEEP(n)   kmem_alloc(n, KM_NOSLEEP)
@@ -133,10 +132,6 @@
 
 #include <afs/afs_sysnames.h>
 
-#if 0
-#define AFS_GLOBAL_SUNLOCK	1	/* For global locking */
-#endif
-
 #define	AFS_3DISPARES		1	/* Utilize the 3 available disk inode 'spares' */
 #define	AFS_SYSCALL		65
 
diff --git a/src/config/param.x86_darwin_100.h b/src/config/param.x86_darwin_100.h
index 9d8de1041..554eb24a8 100644
--- a/src/config/param.x86_darwin_100.h
+++ b/src/config/param.x86_darwin_100.h
@@ -113,7 +113,6 @@
 #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
diff --git a/src/config/param.x86_darwin_110.h b/src/config/param.x86_darwin_110.h
index eae598370..ca893b9e9 100644
--- a/src/config/param.x86_darwin_110.h
+++ b/src/config/param.x86_darwin_110.h
@@ -116,7 +116,6 @@
 #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
diff --git a/src/config/param.x86_darwin_120.h b/src/config/param.x86_darwin_120.h
index da6f48a77..a6c881a9e 100644
--- a/src/config/param.x86_darwin_120.h
+++ b/src/config/param.x86_darwin_120.h
@@ -119,7 +119,6 @@
 #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
diff --git a/src/config/param.x86_darwin_130.h b/src/config/param.x86_darwin_130.h
index a29a9380c..7571e05fe 100644
--- a/src/config/param.x86_darwin_130.h
+++ b/src/config/param.x86_darwin_130.h
@@ -122,7 +122,6 @@
 #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
diff --git a/src/config/param.x86_darwin_140.h b/src/config/param.x86_darwin_140.h
index 83e009f5d..989e39b2e 100644
--- a/src/config/param.x86_darwin_140.h
+++ b/src/config/param.x86_darwin_140.h
@@ -125,7 +125,6 @@
 #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
diff --git a/src/config/param.x86_darwin_150.h b/src/config/param.x86_darwin_150.h
index 6c0df1185..666c1de7f 100644
--- a/src/config/param.x86_darwin_150.h
+++ b/src/config/param.x86_darwin_150.h
@@ -128,7 +128,6 @@
 #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
diff --git a/src/config/param.x86_darwin_160.h b/src/config/param.x86_darwin_160.h
index 064875297..f2d786a53 100644
--- a/src/config/param.x86_darwin_160.h
+++ b/src/config/param.x86_darwin_160.h
@@ -131,7 +131,6 @@
 #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
diff --git a/src/config/param.x86_darwin_170.h b/src/config/param.x86_darwin_170.h
index b9be38064..99c8cd78f 100644
--- a/src/config/param.x86_darwin_170.h
+++ b/src/config/param.x86_darwin_170.h
@@ -134,7 +134,6 @@
 #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
diff --git a/src/config/param.x86_darwin_180.h b/src/config/param.x86_darwin_180.h
new file mode 100644
index 000000000..6b6ac0183
--- /dev/null
+++ b/src/config/param.x86_darwin_180.h
@@ -0,0 +1,281 @@
+#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__) || defined(__amd64__)
+#define AFS_X86_ENV		1
+#else
+#error Unsupported architecture
+#endif
+#ifdef __amd64__
+#define AFS_64BITUSERPOINTER_ENV 1
+#endif
+#define AFS_64BIT_SIZEOF 1 /* seriously? */
+#include <afs/afs_sysnames.h>
+
+#define AFS_DARWIN_ENV
+#define AFS_DARWIN70_ENV
+#define AFS_DARWIN80_ENV
+#define AFS_DARWIN90_ENV
+#define AFS_DARWIN100_ENV
+#define AFS_DARWIN110_ENV
+#define AFS_DARWIN120_ENV
+#define AFS_DARWIN130_ENV
+#define AFS_DARWIN140_ENV
+#define AFS_DARWIN150_ENV
+#define AFS_DARWIN160_ENV
+#define AFS_DARWIN170_ENV
+#define AFS_DARWIN180_ENV
+#undef  AFS_NONFSTRANS
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define AFS_NAMEI_ENV 1
+#define DARWIN_REFBASE 3
+#define AFS_WARNUSER_MARINER_ENV 1
+#define AFS_CACHE_VNODE_PATH
+#define AFS_NEW_BKG 1
+#define NEED_IOCTL32
+
+/* 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(__ppc64__)
+#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_ppc64_darwin_100	1
+#define SYS_NAME		"ppc64_darwin_100"
+#define SYS_NAME_ID		SYS_NAME_ID_ppc64_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_x86_darwin_110      1
+#define sys_x86_darwin_120      1
+#define sys_x86_darwin_130      1
+#define sys_x86_darwin_140	1
+#define sys_x86_darwin_150	1
+#define sys_x86_darwin_160	1
+#define sys_x86_darwin_170	1
+#define sys_x86_darwin_180	1
+#define SYS_NAME		"x86_darwin_180"
+#define SYS_NAME_ID		SYS_NAME_ID_x86_darwin_180
+#define AFSLITTLE_ENDIAN	1
+#elif defined(__amd64__)
+#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_amd64_darwin_100	1
+#define sys_amd64_darwin_110      1
+#define sys_amd64_darwin_120      1
+#define sys_amd64_darwin_130      1
+#define sys_amd64_darwin_140	  1
+#define sys_amd64_darwin_150	  1
+#define sys_amd64_darwin_160	  1
+#define sys_amd64_darwin_170	  1
+#define sys_amd64_darwin_180	  1
+#define SYS_NAME		"amd64_darwin_180"
+#define SYS_NAME_ID		SYS_NAME_ID_amd64_darwin_180
+#define AFSLITTLE_ENDIAN	1
+#else
+#error Unsupported architecture
+#endif
+#define AFS_HAVE_FFS    1	/* Use system's ffs. */
+
+#define AFS_GCPAGS               0
+#define RXK_UPCALL_ENV         1
+#define RXK_TIMEDSLEEP_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 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_ENV                 1
+#define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
+#define AFS_64BIT_CLIENT        1
+#if defined(__ppc__)
+#define AFS_PPC_ENV		1
+#elif defined(__i386__) || defined(__amd64__)
+#define AFS_X86_ENV		1
+#else
+#error Unsupported architecture
+#endif
+#ifdef __amd64__
+#define AFS_64BITUSERPOINTER_ENV 1
+#endif
+
+#include <afs/afs_sysnames.h>
+#define AFS_USERSPACE_ENV
+#define AFS_USR_DARWIN_ENV
+#define AFS_USR_DARWIN70_ENV
+#define AFS_USR_DARWIN80_ENV
+#define AFS_USR_DARWIN90_ENV
+#define AFS_USR_DARWIN100_ENV
+#define AFS_USR_DARWIN110_ENV
+#define AFS_USR_DARWIN120_ENV
+#define AFS_USR_DARWIN130_ENV
+#define AFS_USR_DARWIN140_ENV
+#define AFS_USR_DARWIN150_ENV
+#define AFS_USR_DARWIN160_ENV
+#define AFS_USR_DARWIN170_ENV
+#define AFS_USR_DARWIN180_ENV
+#undef  AFS_NONFSTRANS
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define DARWIN_REFBASE 0
+#define AFS_WARNUSER_MARINER_ENV 1
+
+/* 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_x86_darwin_110	1
+#define sys_x86_darwin_120	1
+#define sys_x86_darwin_130      1
+#define sys_x64_darwin_140	1
+#define sys_x64_darwin_150	1
+#define sys_x64_darwin_160	1
+#define sys_x64_darwin_170	1
+#define sys_x64_darwin_180	1
+#define SYS_NAME		"x86_darwin_180"
+#define SYS_NAME_ID		SYS_NAME_ID_x86_darwin_180
+#define AFSLITTLE_ENDIAN	1
+#elif defined(__amd64__)
+#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_amd64_darwin_100	1
+#define sys_amd64_darwin_110	1
+#define sys_amd64_darwin_120	1
+#define sys_amd64_darwin_130    1
+#define sys_amd64_darwin_140	1
+#define sys_amd64_darwin_150	1
+#define sys_amd64_darwin_160	1
+#define sys_amd64_darwin_170	1
+#define sys_amd64_darwin_180	1
+#define SYS_NAME		"amd64_darwin_180"
+#define SYS_NAME_ID		SYS_NAME_ID_amd64_darwin_180
+#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) */
diff --git a/src/config/param.x86_darwin_190.h b/src/config/param.x86_darwin_190.h
new file mode 100644
index 000000000..17dfbe4d1
--- /dev/null
+++ b/src/config/param.x86_darwin_190.h
@@ -0,0 +1,287 @@
+#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__) || defined(__amd64__)
+#define AFS_X86_ENV		1
+#else
+#error Unsupported architecture
+#endif
+#ifdef __amd64__
+#define AFS_64BITUSERPOINTER_ENV 1
+#endif
+#define AFS_64BIT_SIZEOF 1 /* seriously? */
+#include <afs/afs_sysnames.h>
+
+#define AFS_DARWIN_ENV
+#define AFS_DARWIN70_ENV
+#define AFS_DARWIN80_ENV
+#define AFS_DARWIN90_ENV
+#define AFS_DARWIN100_ENV
+#define AFS_DARWIN110_ENV
+#define AFS_DARWIN120_ENV
+#define AFS_DARWIN130_ENV
+#define AFS_DARWIN140_ENV
+#define AFS_DARWIN150_ENV
+#define AFS_DARWIN160_ENV
+#define AFS_DARWIN170_ENV
+#define AFS_DARWIN180_ENV
+#define AFS_DARWIN190_ENV
+#undef  AFS_NONFSTRANS
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define AFS_NAMEI_ENV 1
+#define DARWIN_REFBASE 3
+#define AFS_WARNUSER_MARINER_ENV 1
+#define AFS_CACHE_VNODE_PATH
+#define AFS_NEW_BKG 1
+#define NEED_IOCTL32
+
+/* 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(__ppc64__)
+#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_ppc64_darwin_100	1
+#define SYS_NAME		"ppc64_darwin_100"
+#define SYS_NAME_ID		SYS_NAME_ID_ppc64_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_x86_darwin_110      1
+#define sys_x86_darwin_120      1
+#define sys_x86_darwin_130      1
+#define sys_x86_darwin_140	1
+#define sys_x86_darwin_150	1
+#define sys_x86_darwin_160	1
+#define sys_x86_darwin_170	1
+#define sys_x86_darwin_180	1
+#define sys_x86_darwin_190	1
+#define SYS_NAME		"x86_darwin_190"
+#define SYS_NAME_ID		SYS_NAME_ID_x86_darwin_190
+#define AFSLITTLE_ENDIAN	1
+#elif defined(__amd64__)
+#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_amd64_darwin_100	1
+#define sys_amd64_darwin_110      1
+#define sys_amd64_darwin_120      1
+#define sys_amd64_darwin_130      1
+#define sys_amd64_darwin_140	  1
+#define sys_amd64_darwin_150	  1
+#define sys_amd64_darwin_160	  1
+#define sys_amd64_darwin_170	  1
+#define sys_amd64_darwin_180	  1
+#define sys_amd64_darwin_190	  1
+#define SYS_NAME		"amd64_darwin_190"
+#define SYS_NAME_ID		SYS_NAME_ID_amd64_darwin_190
+#define AFSLITTLE_ENDIAN	1
+#else
+#error Unsupported architecture
+#endif
+#define AFS_HAVE_FFS    1	/* Use system's ffs. */
+
+#define AFS_GCPAGS               0
+#define RXK_UPCALL_ENV         1
+#define RXK_TIMEDSLEEP_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 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_ENV                 1
+#define AFS_64BIT_ENV           1	/* Defines afs_int32 as int, not long. */
+#define AFS_64BIT_CLIENT        1
+#if defined(__ppc__)
+#define AFS_PPC_ENV		1
+#elif defined(__i386__) || defined(__amd64__)
+#define AFS_X86_ENV		1
+#else
+#error Unsupported architecture
+#endif
+#ifdef __amd64__
+#define AFS_64BITUSERPOINTER_ENV 1
+#endif
+
+#include <afs/afs_sysnames.h>
+#define AFS_USERSPACE_ENV
+#define AFS_USR_DARWIN_ENV
+#define AFS_USR_DARWIN70_ENV
+#define AFS_USR_DARWIN80_ENV
+#define AFS_USR_DARWIN90_ENV
+#define AFS_USR_DARWIN100_ENV
+#define AFS_USR_DARWIN110_ENV
+#define AFS_USR_DARWIN120_ENV
+#define AFS_USR_DARWIN130_ENV
+#define AFS_USR_DARWIN140_ENV
+#define AFS_USR_DARWIN150_ENV
+#define AFS_USR_DARWIN160_ENV
+#define AFS_USR_DARWIN170_ENV
+#define AFS_USR_DARWIN180_ENV
+#define AFS_USR_DARWIN190_ENV
+#undef  AFS_NONFSTRANS
+#define AFS_NONFSTRANS
+#define AFS_SYSCALL             230
+#define DARWIN_REFBASE 0
+#define AFS_WARNUSER_MARINER_ENV 1
+
+/* 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_x86_darwin_110	1
+#define sys_x86_darwin_120	1
+#define sys_x86_darwin_130      1
+#define sys_x64_darwin_140	1
+#define sys_x64_darwin_150	1
+#define sys_x64_darwin_160	1
+#define sys_x64_darwin_170	1
+#define sys_x64_darwin_180	1
+#define sys_x64_darwin_190	1
+#define SYS_NAME		"x86_darwin_190"
+#define SYS_NAME_ID		SYS_NAME_ID_x86_darwin_190
+#define AFSLITTLE_ENDIAN	1
+#elif defined(__amd64__)
+#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_amd64_darwin_100	1
+#define sys_amd64_darwin_110	1
+#define sys_amd64_darwin_120	1
+#define sys_amd64_darwin_130    1
+#define sys_amd64_darwin_140	1
+#define sys_amd64_darwin_150	1
+#define sys_amd64_darwin_160	1
+#define sys_amd64_darwin_170	1
+#define sys_amd64_darwin_180	1
+#define sys_amd64_darwin_190	1
+#define SYS_NAME		"amd64_darwin_190"
+#define SYS_NAME_ID		SYS_NAME_ID_amd64_darwin_190
+#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) */
diff --git a/src/config/param.x86_darwin_80.h b/src/config/param.x86_darwin_80.h
index 2a079a7b1..fc70f9836 100644
--- a/src/config/param.x86_darwin_80.h
+++ b/src/config/param.x86_darwin_80.h
@@ -75,7 +75,6 @@
 #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
diff --git a/src/config/param.x86_darwin_90.h b/src/config/param.x86_darwin_90.h
index 6814c28d2..7f832f99f 100644
--- a/src/config/param.x86_darwin_90.h
+++ b/src/config/param.x86_darwin_90.h
@@ -80,7 +80,6 @@
 #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
diff --git a/src/config/stds.h b/src/config/stds.h
index a031bfdd2..254856d1a 100644
--- a/src/config/stds.h
+++ b/src/config/stds.h
@@ -128,30 +128,6 @@ typedef afs_uint32 afs_uintmax_t;
  * some assistence in this matter.  The hyper type is supposed to be compatible
  * with the afsHyper type: the same macros will work on both. */
 
-#if 0
-
-typedef unsigned long afs_hyper_t;
-
-#define	hcmp(a,b)	((a) < (b) ? -1 : ((a) > (b) ? 1 : 0))
-#define	hsame(a,b)	((a) == (b))
-#define	hiszero(a)	((a) == 0)
-#define	hfitsin32(a)	((a) & 0xffffffff00000000) == 0)
-#define	hset(a,b)	((a) = (b))
-#define	hzero(a)	((a) = 0)
-#define	hones(a)	((a) = ~((unsigned long)0))
-#define	hget32(i,a)	((i) = (unsigned int)(a))
-#define	hget64(hi,lo,a)	((lo) = ((unsigned int)(a)), (hi) = ((a) & (0xffffffff00000000)))
-#define	hset32(a,i)	((a) = ((unsigned int)(i)))
-#define	hset64(a,hi,lo)	((a) = (((hi) << 32) | (lo)))
-#define hgetlo(a)	((a) & 0xffffffff)
-#define hgethi(a)	(((unsigned int)(a)) >> 32)
-#define	hadd(a,b)	((a) += (b))
-/* XXX */
-#define	hadd32(a,b)	((a) += (b))
-#define hshlft(a,n)     ((a)<<(n))
-
-#else /* 0*/
-
 typedef struct afs_hyper_t {	/* unsigned 64 bit integers */
     unsigned int high;
     unsigned int low;
@@ -199,7 +175,6 @@ typedef struct afs_hyper_t {	/* unsigned 64 bit integers */
      (a).low += (int)(i))
 
 #define hadd(a,b) (hadd32(a,(b).low), (a).high += (b).high)
-#endif /* 0 */
 
 #if !defined(KERNEL) || defined(UKERNEL)
 #ifndef AFS_NT40_ENV
@@ -238,18 +213,26 @@ typedef struct afsUUID afsUUID;
 #define AFS_DEMAND_ATTACH_FS 1
 #endif
 
+#if defined(BUILD_RXGK) && defined(AFS_PTHREAD_ENV) && !defined(KERNEL)
+/* Only build GSS bits of code on non-kernel pthread builds */
+# define AFS_RXGK_GSS_ENV 1
+#endif
+
+#if defined(ENABLE_RXGK) && !defined(UKERNEL) && (defined(AFS_PTHREAD_ENV) || defined(KERNEL))
+/* Only enable RXGK bits for userspace pthread or non-ukernel kernel code */
+# define AFS_RXGK_ENV 1
+#endif
+
 /* 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 "I64d"
 # define AFS_UINT64_FMT "I64u"
-# define AFS_PTR_FMT   "p"
 # define AFS_SIZET_FMT "Iu"
 #else
 # define AFS_INT64_FMT "lld"
 # define AFS_UINT64_FMT "llu"
-# define AFS_PTR_FMT   "p"
 # ifdef PRINTF_TAKES_Z_LEN
 #  define AFS_SIZET_FMT "zu"
 # else
@@ -275,7 +258,8 @@ typedef struct afsUUID afsUUID;
 #elif defined(AFS_SGI_ENV) || defined(AFS_USR_SGI_ENV)
 #define static_inline static
 #define hdr_static_inline(x) x
-#elif defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV)
+#elif defined(AFS_NBSD_ENV) && !defined(AFS_NBSD50_ENV) \
+      && defined(HAVE_FUNC_ATTRIBUTE_ALWAYS_INLINE)
 #define static_inline static __inline __attribute__((always_inline))
 #define hdr_static_inline(x) static __inline __attribute__((always_inline)) x
 #else
@@ -299,21 +283,45 @@ hdr_static_inline(unsigned long long) afs_printable_uint64_lu(afs_uint64 d) { re
 #define afs_int_to_pointer(i)      ((void *)  (i))
 #endif
 
-#if defined(__GNUC__) && __GNUC__ > 2
-#define AFS_UNUSED __attribute__((unused))
-#define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
-#define AFS_NORETURN __attribute__((__noreturn__))
-#define AFS_NONNULL(x) __attribute__((__nonnull__ x))
-#elif defined (__clang__)
-#define AFS_UNUSED __attribute__((unused))
-#define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
-#define AFS_NORETURN __attribute__((__noreturn__))
-#define AFS_NONNULL(x) __attribute__((__nonnull__ x))
+#ifdef HAVE_FUNC_ATTRIBUTE_UNUSED
+# define AFS_UNUSED __attribute__((unused))
+#else
+# define AFS_UNUSED
+#endif
+
+#ifdef HAVE_FUNC_ATTRIBUTE_FORMAT
+# define AFS_ATTRIBUTE_FORMAT(style,x,y) __attribute__((format(style, x, y)))
+#else
+# define AFS_ATTRIBUTE_FORMAT(style,x,y)
+#endif
+
+#ifdef HAVE_FUNC_ATTRIBUTE_NORETURN
+# define AFS_NORETURN __attribute__((__noreturn__))
+#else
+# define AFS_NORETURN
+#endif
+
+#ifdef HAVE_FUNC_ATTRIBUTE_NONNULL
+# define AFS_NONNULL(x) __attribute__((__nonnull__ x))
+#else
+# define AFS_NONNULL(x)
+#endif
+
+#if defined(AFS_LINUX26_ENV) && defined(fallthrough)
+# define AFS_FALLTHROUGH fallthrough
+#elif defined(HAVE_FUNC_ATTRIBUTE_FALLTHROUGH)
+# define AFS_FALLTHROUGH __attribute__((fallthrough))
+#else
+# define AFS_FALLTHROUGH do {} while(0)
+#endif
+
+/*
+ * Conditionally remove unreached statements under Solaris Studio.
+ */
+#if defined(__SUNPRO_C)
+# define AFS_UNREACHED(x)
 #else
-#define AFS_UNUSED
-#define AFS_ATTRIBUTE_FORMAT(style,x,y)
-#define AFS_NORETURN
-#define AFS_NONNULL(x)
+# define AFS_UNREACHED(x)  x
 #endif
 
 #endif /* OPENAFS_CONFIG_AFS_STDS_H */
diff --git a/src/crypto/hcrypto/Makefile.in b/src/crypto/hcrypto/Makefile.in
index 16abc10b7..32622696e 100644
--- a/src/crypto/hcrypto/Makefile.in
+++ b/src/crypto/hcrypto/Makefile.in
@@ -42,9 +42,12 @@ UPSTREAM= ${TOP_SRCDIR}/external/heimdal
 
 MODULE_INCLUDE=-I${srcdir} -I${TOP_INCDIR}/hcrypto -I$(UPSTREAM)/hcrypto
 
+@SHARED_ONLY@SHARED_LIBS = libafshcrypto.la
+@SHARED_ONLY@SHARED_SHLIBS_TOP = ${TOP_LIBDIR}/libafshcrypto.$(SHLIB_SUFFIX)
+
 all: @hcrypto_all_target@
 
-all-internal: ${HEADERS} ${TOP_LIBDIR}/libafshcrypto.$(SHLIB_SUFFIX) \
+all-internal: ${HEADERS} $(SHARED_SHLIBS_TOP) \
 	${TOP_LIBDIR}/libafshcrypto.a \
 	${TOP_LIBDIR}/libafshcrypto_lwp.a
 
@@ -54,14 +57,14 @@ buildtools: ${HEADERS} ${TOP_LIBDIR}/libafshcrypto.a
 
 install: @hcrypto_install_target@
 
-install-internal: libafshcrypto.la libafshcrypto.a
-	${LT_INSTALL_DATA} libafshcrypto.la ${DESTDIR}${libdir}/libafshcrypto.la
-	${RM} ${DESTDIR}${libdir}/libafshcrypto.la
+install-internal: $(SHARED_LIBS) libafshcrypto.a
+	@SHARED_ONLY@${LT_INSTALL_DATA} libafshcrypto.la ${DESTDIR}${libdir}/libafshcrypto.la
+	@SHARED_ONLY@${RM} ${DESTDIR}${libdir}/libafshcrypto.la
 	${INSTALL_DATA} libafshcrypto.a ${DESTDIR}${libdir}/libafshcrypto.a
 
-dest: libafshcrypto.la libafshcrypto.a
-	${LT_INSTALL_DATA} libafshcrypto.la ${DEST}/lib/libafshcrypto.la
-	${RM} ${DEST}/lib/libafshcrypto.la
+dest: $(SHARED_LIBS) libafshcrypto.a
+	@SHARED_ONLY@${LT_INSTALL_DATA} libafshcrypto.la ${DEST}/lib/libafshcrypto.la
+	@SHARED_ONLY@${RM} ${DEST}/lib/libafshcrypto.la
 	${INSTALL_DATA} libafshcrypto.a ${DEST}/lib/libafshcrypto.a
 
 clean:
@@ -71,8 +74,8 @@ clean:
 
 $(LT_objs): $(HEADERS)
 
-libafshcrypto.la: libafshcrypto.la.sym $(LT_objs)
-	$(LT_LDLIB_shlib) $(LT_objs) $(LT_libs)
+libafshcrypto.la: libafshcrypto.la.sym $(LT_objs) libafshcrypto.a
+	$(LT_LDLIB_shlib_only) $(LT_objs) $(LT_libs)
 
 libafshcrypto.a: $(LT_objs)
 	$(LT_LDLIB_static) $(LT_objs)
@@ -80,8 +83,8 @@ libafshcrypto.a: $(LT_objs)
 libafshcrypto_lwp.a: $(LT_objs)
 	$(LT_LDLIB_lwp) $(LT_objs)
 
-test_cipher: test_cipher.lo libafshcrypto.la
-	$(LT_LDRULE_static) test_cipher.lo libafshcrypto.la
+test_cipher: test_cipher.lo libafshcrypto.a
+	$(LT_LDRULE_static) test_cipher.lo libafshcrypto.a
 
 ${TOP_INCDIR}/hcrypto/aes.h: ${UPSTREAM}/hcrypto/aes.h
 	${INSTALL_DATA} $? $@
diff --git a/src/crypto/hcrypto/config.h b/src/crypto/hcrypto/config.h
index 233cd090e..ce5637e55 100644
--- a/src/crypto/hcrypto/config.h
+++ b/src/crypto/hcrypto/config.h
@@ -50,4 +50,7 @@
 #define ENGINE_up_ref _oafs_h_ENGINE_up_ref
 #define ENGINE_finish _oafs_h_ENGINE_finish
 
+#define RETSIGTYPE void
+#define SIGRETURN(x) return
+
 #endif /* OAFS_HCRYPTO_CONFIG_H */
diff --git a/src/crypto/hcrypto/kernel/config.h b/src/crypto/hcrypto/kernel/config.h
index 81c2944d5..dd7608dae 100644
--- a/src/crypto/hcrypto/kernel/config.h
+++ b/src/crypto/hcrypto/kernel/config.h
@@ -95,10 +95,29 @@ static_inline int close(int d) {return -1;}
 #if defined(HAVE_GETUID)
 #undef HAVE_GETUID
 #endif
+#ifdef HAVE_ARC4RANDOM
+# undef HAVE_ARC4RANDOM
+#endif
+
+#if !defined(AFS_LINUX26_ENV)
+/*
+ * gettimeofday is only used in rand-fortuna.c, not built for Linux.
+ * Linux 5.6 removes the native struct timeval, so this stub would not build.
+ */
 static_inline int gettimeofday(struct timeval *tp, void *tzp)
     {if (tp == NULL) return -1; tp->tv_sec = osi_Time(); tp->tv_usec = 0; return 0;}
+#endif
 
-#ifdef AFS_SUN5_ENV
-/* workaround to allow --disable-optimize-kernel on Solaris */
-#define double int
+#if defined(KERNEL) && (defined(AFS_SUN5_ENV) || defined(AFS_ARM64_LINUX26_ENV))
+/*
+ * Some functions such as RAND_add take a 'double' as an argument, but floating
+ * point code generally cannot be used in kernelspace. We never actually use
+ * that argument in kernel code, but just that it exists as an argument is
+ * enough to break the kernel code on Linux (on arm64) and Solaris (depending
+ * on the compiler version and flags). Change all instances of double to void*
+ * to avoid this; if someone does try to use that argument, hopefully the fact
+ * that it is now a void* will flag an error at compile time before it causes
+ * any further problems.
+ */
+# define double void*
 #endif
diff --git a/src/crypto/hcrypto/kernel/rand.c b/src/crypto/hcrypto/kernel/rand.c
index 81064863b..72cc41877 100644
--- a/src/crypto/hcrypto/kernel/rand.c
+++ b/src/crypto/hcrypto/kernel/rand.c
@@ -15,6 +15,15 @@
  */
 afs_kmutex_t hckernel_mutex;
 
+/*
+ * For these platforms, we use the fortuna RNG from heimdal (seeded from afsd
+ * userspace on startup). Otherwise, we rely on osi_readRandom() as the source
+ * of random data.
+ */
+#if defined(AFS_AIX_ENV) || defined(AFS_DFBSD_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SGI_ENV)
+# define USE_FORTUNA
+#endif
+
 /* Called from osi_Init(); will only run once. */
 void
 init_hckernel_mutex(void)
@@ -25,8 +34,10 @@ init_hckernel_mutex(void)
 void
 RAND_seed(const void *indata, size_t size)
 {
+#ifdef USE_FORTUNA
     const RAND_METHOD *m = RAND_fortuna_method();
     m->seed(indata, size);
+#endif
 }
 
 int
@@ -34,7 +45,7 @@ RAND_bytes(void *outdata, size_t size)
 {
     if (size == 0)
 	return 0;
-#if defined(AFS_AIX_ENV) || defined(AFS_DFBSD_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SGI_ENV)
+#ifdef USE_FORTUNA
     const RAND_METHOD *m = RAND_fortuna_method();
     return m->bytes(outdata, size);
 #else
diff --git a/src/crypto/rfc3961/afsrfc3961.def b/src/crypto/rfc3961/afsrfc3961.def
index 9fad6c953..c43965dde 100644
--- a/src/crypto/rfc3961/afsrfc3961.def
+++ b/src/crypto/rfc3961/afsrfc3961.def
@@ -14,3 +14,4 @@ EXPORTS
 	oafs_h_krb5_copy_keyblock_contents          @13
 	oafs_h_krb5_free_keyblock                   @14
 	oafs_h_krb5_free_keyblock_contents          @15
+	oafs_h_krb5_enctype_keysize                 @16
diff --git a/src/crypto/rfc3961/krb5_locl.h b/src/crypto/rfc3961/krb5_locl.h
index 5e9d46bdc..e7166fa8e 100644
--- a/src/crypto/rfc3961/krb5_locl.h
+++ b/src/crypto/rfc3961/krb5_locl.h
@@ -193,7 +193,6 @@ typedef struct krb5_crypto_iov {
 #define krb5_crypto_getpadsize _oafs_h_krb5_crypto_getpadsize
 #define krb5_crypto_length _oafs_h_krb5_crypto_length
 #define krb5_crypto_length_iov _oafs_h_krb5_crypto_length_iov
-#define krb5_crypto_prf_length _oafs_h_krb5_crypto_prf_length
 #define krb5_decrypt_EncryptedData _oafs_h_krb5_decrypt_EncryptedData
 #define krb5_decrypt_iov_ivec _oafs_h_krb5_decrypt_iov_ivec
 #define krb5_decrypt_ivec _oafs_h_krb5_decrypt_ivec
@@ -206,7 +205,6 @@ typedef struct krb5_crypto_iov {
 #define _krb5_enctype_arcfour_hmac_md5 _oafs_h__krb5_enctype_arcfour_hmac_md5
 #define krb5_enctype_disable _oafs_h_krb5_enctype_disable
 #define krb5_enctype_enable _oafs_h_krb5_enctype_enable
-#define krb5_enctype_keysize _oafs_h_krb5_enctype_keysize
 #define krb5_enctype_to_keytype _oafs_h_krb5_enctype_to_keytype
 #define krb5_enctype_to_string _oafs_h_krb5_enctype_to_string
 #define krb5_generate_random_keyblock _oafs_h_krb5_generate_random_keyblock
@@ -254,9 +252,6 @@ krb5_error_code krb5_derive_key(krb5_context context, const krb5_keyblock *key,
 				krb5_enctype etype, const void *constant,
 				size_t constant_len,
 				krb5_keyblock **derived_key);
-krb5_error_code krb5_enctype_keysize(krb5_context context,
-				     krb5_enctype type,
-				     size_t *keysize);
 krb5_ssize_t _krb5_put_int(void *buffer, unsigned long value, size_t size);
 void krb5_data_zero(krb5_data *p);
 krb5_error_code krb5_data_copy(krb5_data *p, const void *data, size_t len);
diff --git a/src/crypto/rfc3961/liboafs_rfc3961.la.sym b/src/crypto/rfc3961/liboafs_rfc3961.la.sym
index fb3910607..d63e892ae 100644
--- a/src/crypto/rfc3961/liboafs_rfc3961.la.sym
+++ b/src/crypto/rfc3961/liboafs_rfc3961.la.sym
@@ -4,14 +4,17 @@ oafs_h_krb5_copy_keyblock
 oafs_h_krb5_copy_keyblock_contents
 oafs_h_krb5_create_checksum
 oafs_h_krb5_crypto_destroy
+oafs_h_krb5_crypto_fx_cf2
 oafs_h_krb5_crypto_init
 oafs_h_krb5_crypto_overhead
 oafs_h_krb5_crypto_prf
+oafs_h_krb5_crypto_prf_length
 oafs_h_krb5_data_alloc
 oafs_h_krb5_data_free
 oafs_h_krb5_decrypt
 oafs_h_krb5_encrypt
 oafs_h_krb5_enctype_keybits
+oafs_h_krb5_enctype_keysize
 oafs_h_krb5_enctype_valid
 oafs_h_krb5_free_context
 oafs_h_krb5_free_keyblock
@@ -19,4 +22,6 @@ oafs_h_krb5_free_keyblock_contents
 oafs_h_krb5_init_context
 oafs_h_krb5_keyblock_get_enctype
 oafs_h_krb5_keyblock_init
+oafs_h_krb5_random_to_key
 oafs_h_krb5_verify_checksum
+oafs_h_krb5_generate_random_block
diff --git a/src/crypto/rfc3961/rfc3961.h b/src/crypto/rfc3961/rfc3961.h
index 2656f9b40..057b3807f 100644
--- a/src/crypto/rfc3961/rfc3961.h
+++ b/src/crypto/rfc3961/rfc3961.h
@@ -103,6 +103,7 @@ typedef int krb5_enctype;
 #define krb5_encrypt oafs_h_krb5_encrypt
 #define krb5_decrypt oafs_h_krb5_decrypt
 #define krb5_enctype_keybits oafs_h_krb5_enctype_keybits
+#define krb5_enctype_keysize oafs_h_krb5_enctype_keysize
 #define krb5_data_free oafs_h_krb5_data_free
 #define krb5_data_alloc oafs_h_krb5_data_alloc
 #define krb5_keyblock_init oafs_h_krb5_keyblock_init
@@ -144,6 +145,9 @@ krb5_error_code krb5_decrypt(krb5_context context,
 krb5_error_code krb5_enctype_keybits(krb5_context context,
 				     krb5_enctype type,
 				     size_t *keybits);
+krb5_error_code krb5_enctype_keysize(krb5_context context,
+				     krb5_enctype type,
+				     size_t *keysize);
 
 void krb5_data_free(krb5_data *p);
 
@@ -153,6 +157,7 @@ void krb5_free_keyblock_contents(krb5_context context,
 				 krb5_keyblock *keyblock);
 
 #define krb5_crypto_prf oafs_h_krb5_crypto_prf
+#define krb5_crypto_prf_length oafs_h_krb5_crypto_prf_length
 #define krb5_crypto_fx_cf2 oafs_h_krb5_crypto_fx_cf2
 #define krb5_generate_random_block oafs_h_krb5_generate_random_block
 #define krb5_random_to_key oafs_h_krb5_random_to_key
@@ -163,6 +168,10 @@ krb5_error_code krb5_crypto_prf(krb5_context context,
 				const krb5_data *input,
 				krb5_data *output);
 
+krb5_error_code krb5_crypto_prf_length(krb5_context context,
+				       krb5_enctype type,
+				       size_t *length);
+
 krb5_error_code krb5_crypto_fx_cf2(krb5_context context,
 				   const krb5_crypto crypto1,
 				   const krb5_crypto crypto2,
diff --git a/src/dir/Makefile.in b/src/dir/Makefile.in
index 978ddc118..34c63f5b7 100644
--- a/src/dir/Makefile.in
+++ b/src/dir/Makefile.in
@@ -28,8 +28,9 @@ libdir.a: buffer.o dir.o salvage.o AFS_component_version_number.o
 	$(AR) crv $@ buffer.o dir.o salvage.o  AFS_component_version_number.o
 	$(RANLIB) $@
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 buffer.o: buffer.c dir.h
 
diff --git a/src/dir/dir.c b/src/dir/dir.c
index 6db96b242..8aa336d53 100644
--- a/src/dir/dir.c
+++ b/src/dir/dir.c
@@ -38,11 +38,6 @@
 #   include "h/user.h"
 #  endif /* AFS_SGI64_ENV */
 #  include "h/uio.h"
-#  ifdef	AFS_OSF_ENV
-#   include <sys/mount.h>
-#   include <sys/vnode.h>
-#   include <ufs/inode.h>
-#  endif
 #  if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_HPUX110_ENV)
 #   include "h/mbuf.h"
 #  endif
@@ -104,13 +99,18 @@ afs_dir_Create(dir_file_t dir, char *entry, void *voidfid)
     struct DirBuffer entrybuf, prevbuf, headerbuf;
     struct DirEntry *ep;
     struct DirHeader *dhp;
+    int code;
 
     /* check name quality */
     if (*entry == 0)
 	return EINVAL;
 
     /* First check if file already exists. */
-    if (FindItem(dir, entry, &prevbuf, &entrybuf) == 0) {
+    code = FindItem(dir, entry, &prevbuf, &entrybuf);
+    if (code && code != ENOENT) {
+        return code;
+    }
+    if (code == 0) {
 	DRelease(&entrybuf, 0);
 	DRelease(&prevbuf, 0);
 	return EEXIST;
@@ -180,9 +180,12 @@ afs_dir_Delete(dir_file_t dir, char *entry)
     struct DirBuffer entrybuf, prevbuf;
     struct DirEntry *firstitem;
     unsigned short *previtem;
+    int code;
 
-    if (FindItem(dir, entry, &prevbuf, &entrybuf) != 0)
-	return ENOENT;
+    code = FindItem(dir, entry, &prevbuf, &entrybuf);
+    if (code) {
+        return code;
+    }
 
     firstitem = (struct DirEntry *)entrybuf.data;
     previtem = (unsigned short *)prevbuf.data;
@@ -366,9 +369,12 @@ afs_dir_Lookup(dir_file_t dir, char *entry, void *voidfid)
     afs_int32 *fid = (afs_int32 *) voidfid;
     struct DirBuffer firstbuf, prevbuf;
     struct DirEntry *firstitem;
+    int code;
 
-    if (FindItem(dir, entry, &prevbuf, &firstbuf) != 0)
-	return ENOENT;
+    code = FindItem(dir, entry, &prevbuf, &firstbuf);
+    if (code) {
+        return code;
+    }
     DRelease(&prevbuf, 0);
     firstitem = (struct DirEntry *)firstbuf.data;
 
@@ -387,9 +393,12 @@ afs_dir_LookupOffset(dir_file_t dir, char *entry, void *voidfid,
     afs_int32 *fid = (afs_int32 *) voidfid;
     struct DirBuffer firstbuf, prevbuf;
     struct DirEntry *firstitem;
+    int code;
 
-    if (FindItem(dir, entry, &prevbuf, &firstbuf) != 0)
-	return ENOENT;
+    code = FindItem(dir, entry, &prevbuf, &firstbuf);
+    if (code) {
+        return code;
+    }
     DRelease(&prevbuf, 0);
     firstitem = (struct DirEntry *)firstbuf.data;
 
@@ -612,16 +621,15 @@ FindItem(dir_file_t dir, char *ename, struct DirBuffer *prevbuf,
     i = afs_dir_DirHash(ename);
     if (dhp->hashTable[i] == 0) {
 	/* no such entry */
-	DRelease(&prev, 0);
-	return ENOENT;
+	code = ENOENT;
+	goto out;
     }
 
     code = afs_dir_GetVerifiedBlob(dir,
 				   (u_short) ntohs(dhp->hashTable[i]),
 				   &curr);
     if (code) {
-	DRelease(&prev, 0);
-	return code;
+	goto out;
     }
 
     prev.data = &(dhp->hashTable[i]);
@@ -644,8 +652,11 @@ FindItem(dir_file_t dir, char *ename, struct DirBuffer *prevbuf,
 	prev = curr;
 	prev.data = &(tp->next);
 
-	if (tp->next == 0)
-	    goto out; /* The end of the line */
+	if (tp->next == 0) {
+	    /* The end of the line */
+	    code = ENOENT;
+	    goto out;
+	}
 
 	code = afs_dir_GetVerifiedBlob(dir, (u_short) ntohs(tp->next),
 				       &curr);
@@ -653,9 +664,13 @@ FindItem(dir_file_t dir, char *ename, struct DirBuffer *prevbuf,
 	    goto out;
     }
 
+    /* If we've reached here, we've hit our loop limit. Something is weird with
+     * the directory; maybe a circular hash chain? */
+    code = EIO;
+
 out:
     DRelease(&prev, 0);
-    return ENOENT;
+    return code;
 }
 
 static int
@@ -730,8 +745,10 @@ afs_dir_InverseLookup(void *dir, afs_uint32 vnode, afs_uint32 unique,
     struct DirEntry *entry;
     int code = 0;
 
-    if (FindFid(dir, vnode, unique, &entrybuf) != 0)
-	return ENOENT;
+    code = FindFid(dir, vnode, unique, &entrybuf);
+    if (code) {
+        return code;
+    }
     entry = (struct DirEntry *)entrybuf.data;
 
     if (strlen(entry->name) >= length)
@@ -759,10 +776,13 @@ afs_dir_ChangeFid(dir_file_t dir, char *entry, afs_uint32 *old_fid,
     struct DirEntry *firstitem;
     struct MKFid *fid_old = (struct MKFid *) old_fid;
     struct MKFid *fid_new = (struct MKFid *) new_fid;
+    int code;
 
     /* Find entry. */
-    if (FindItem(dir, entry, &prevbuf, &entrybuf) != 0)
-	return ENOENT;
+    code = FindItem(dir, entry, &prevbuf, &entrybuf);
+    if (code) {
+        return code;
+    }
     firstitem = (struct DirEntry *)entrybuf.data;
     DRelease(&prevbuf, 1);
 
diff --git a/src/dir/salvage.c b/src/dir/salvage.c
index a20a67dad..3fb195cee 100644
--- a/src/dir/salvage.c
+++ b/src/dir/salvage.c
@@ -95,7 +95,7 @@ DirOK(void *file)
 	if (DErrno != 0) {
 	    printf("Could not read first page in directory (%d)\n", DErrno);
 	    Die("dirok1");
-	    return 1;
+	    AFS_UNREACHED(return 1);
 	}
 	printf("First page in directory does not exist.\n");
 	return 0;
@@ -178,7 +178,7 @@ DirOK(void *file)
 		/* couldn't read page, but not because it wasn't there permanently */
 		printf("Failed to read dir page %d (errno %d)\n", i, DErrno);
 		Die("dirok2");
-		return 1;
+		AFS_UNREACHED(return 1);
 	    }
 	    printf("Directory shorter than alloMap indicates (page %d)\n", i);
 	    return 0;
@@ -291,8 +291,8 @@ DirOK(void *file)
 
 	    /* A null name is no good */
 	    if (ep->name[0] == '\000') {
-		printf("Dir entry %"AFS_PTR_FMT
-		       " in chain %d has bogus (null) name.\n", ep, i);
+		printf("Dir entry %p in chain %d has bogus (null) name.\n",
+			ep, i);
 		DRelease(&entrybuf, 0);
 		DRelease(&headerbuf, 0);
 		return 0;
@@ -300,8 +300,8 @@ DirOK(void *file)
 
 	    /* The entry flag better be FFIRST */
 	    if (ep->flag != FFIRST) {
-		printf("Dir entry %"AFS_PTR_FMT
-		       " in chain %d has bogus flag field.\n", ep, i);
+		printf("Dir entry %p in chain %d has bogus flag field.\n",
+			ep, i);
 		DRelease(&entrybuf, 0);
 		DRelease(&headerbuf, 0);
 		return 0;
@@ -310,8 +310,7 @@ DirOK(void *file)
 	    /* Check the size of the name */
 	    j = strlen(ep->name);
 	    if (j >= MAXENAME) {	/* MAXENAME counts the null */
-		printf("Dir entry %"AFS_PTR_FMT
-		       " in chain %d has too-long name.\n", ep, i);
+		printf("Dir entry %p in chain %d has too-long name.\n", ep, i);
 		DRelease(&entrybuf, 0);
 		DRelease(&headerbuf, 0);
 		return 0;
@@ -327,8 +326,7 @@ DirOK(void *file)
 
 	    /* Hash the name and make sure it is in the correct name hash */
 	    if ((j = afs_dir_DirHash(ep->name)) != i) {
-		printf("Dir entry %"AFS_PTR_FMT
-		       " should be in hash bucket %d but IS in %d.\n",
+		printf("Dir entry %p should be in hash bucket %d but IS in %d.\n",
 		       ep, j, i);
 		DRelease(&entrybuf, 0);
 		DRelease(&headerbuf, 0);
@@ -341,8 +339,7 @@ DirOK(void *file)
 		    havedot = 1;
 		} else {
 		    printf
-			("Dir entry %"AFS_PTR_FMT
-			 ", index 13 has name '%s' should be '.'\n",
+			("Dir entry %p, index 13 has name '%s' should be '.'\n",
 			 ep, ep->name);
 		    DRelease(&entrybuf, 0);
 		    DRelease(&headerbuf, 0);
@@ -356,8 +353,7 @@ DirOK(void *file)
 		    havedotdot = 1;
 		} else {
 		    printf
-			("Dir entry %"AFS_PTR_FMT
-			 ", index 14 has name '%s' should be '..'\n",
+			("Dir entry %p, index 14 has name '%s' should be '..'\n",
 			 ep, ep->name);
 		    DRelease(&entrybuf, 0);
 		    DRelease(&headerbuf, 0);
diff --git a/src/dviced/NTMakefile b/src/dviced/NTMakefile
index 0c6e0ad30..af7a0f5f1 100644
--- a/src/dviced/NTMakefile
+++ b/src/dviced/NTMakefile
@@ -34,7 +34,7 @@ LIBACLOBJS = $(OUT)\aclprocs.obj $(OUT)\netprocs.obj
 
 DIROBJS = $(OUT)\buffer.obj $(OUT)\dir.obj $(OUT)\salvage.obj
 
-FSINTOBJS = $(OUT)\afsaux.obj $(OUT)\afscbint.cs.obj $(OUT)\afsint.ss.obj $(OUT)\afsint.xdr.obj
+FSINTOBJS = $(OUT)\afscbint.cs.obj $(OUT)\afsint.ss.obj $(OUT)\afsint.xdr.obj
 
 EXEOBJS = $(VICEDOBJS) $(TVICEDOBJS) $(DAFS_VICEDRES) $(LIBACLOBJS) \
 	  $(DIROBJS) $(FSINTOBJS) $(RXOBJS)
diff --git a/src/export/cfgafs.c b/src/export/cfgafs.c
index 5f55fb10f..fdc8c4d0b 100644
--- a/src/export/cfgafs.c
+++ b/src/export/cfgafs.c
@@ -111,9 +111,6 @@ main(argc, argv)
 	    sysconfig(SYS_KULOAD, &cload, sizeof(cload));
 	    exit(1);
 	}
-#ifdef notdef
-	printf("cfgafs -d 0x%x # to remove AFS\n", cload.kmid);
-#endif
 	strcpy(PidFile, file);
 	strcat(PidFile, ".kmid");
 	fp = fopen(PidFile, "w");
diff --git a/src/export/cfgexport.c b/src/export/cfgexport.c
index 762b7ebe2..f4ab5d5a2 100644
--- a/src/export/cfgexport.c
+++ b/src/export/cfgexport.c
@@ -420,16 +420,6 @@ xlate_xtok(xp, kp, strp, szp)
 	while (len >= left) {
 	    fprintf(stderr, "cfgexport: Out of memory. Increase SYMBUFSIZE and recompile\n");
 	    exit(1);
-#if 0
-	    /* Something is broken with this code, after being here
-	       cfgexport segfaults */
-	    export_strings = (char *)realloc(*strp, sz += SYMBUFSIZE);
-	    if (!export_strings)
-		error("no memory for EXPORT string table");
-	    *strp = export_strings;
-	    left += SYMBUFSIZE;
-	    prev = "";		/* lazy */
-#endif
 	}
 
 	strcpy(prev = *strp + offset, xstrings + xp->n_offset);
diff --git a/src/export/export.c b/src/export/export.c
index c02ee6629..5aacec725 100644
--- a/src/export/export.c
+++ b/src/export/export.c
@@ -165,9 +165,6 @@ import_kfunc(struct k_func * kfp)
 {
     sym_t *sym;
     int i, pri;
-#if 0
-    static caddr_t *g_toc;
-#endif
 
     if (!myg_toc) {
 #ifdef __XCOFF64__
diff --git a/src/external/autoconf-archive-author b/src/external/autoconf-archive-author
new file mode 100644
index 000000000..1c668c50b
--- /dev/null
+++ b/src/external/autoconf-archive-author
@@ -0,0 +1 @@
+Autoconf Archive Maintainers <autoconf-archive-maintainers@gnu.org>
diff --git a/src/external/autoconf-archive-files b/src/external/autoconf-archive-files
new file mode 100644
index 000000000..eddcf27a3
--- /dev/null
+++ b/src/external/autoconf-archive-files
@@ -0,0 +1,4 @@
+m4/ax_append_compile_flags.m4	m4/ax_append_compile_flags.m4
+m4/ax_append_flag.m4		m4/ax_append_flag.m4
+m4/ax_check_compile_flag.m4	m4/ax_check_compile_flag.m4
+m4/ax_require_defined.m4	m4/ax_require_defined.m4
diff --git a/src/external/autoconf-archive-last b/src/external/autoconf-archive-last
new file mode 100644
index 000000000..8bf2750b1
--- /dev/null
+++ b/src/external/autoconf-archive-last
@@ -0,0 +1 @@
+24358c8c5ca679949ef522964d94e4d1cd1f941a
diff --git a/src/external/autoconf-archive/m4/ax_append_compile_flags.m4 b/src/external/autoconf-archive/m4/ax_append_compile_flags.m4
new file mode 100644
index 000000000..9c856356c
--- /dev/null
+++ b/src/external/autoconf-archive/m4/ax_append_compile_flags.m4
@@ -0,0 +1,46 @@
+# ============================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+#   AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   For every FLAG1, FLAG2 it is checked whether the compiler works with the
+#   flag.  If it does, the flag is added FLAGS-VARIABLE
+#
+#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+#   CFLAGS) is used.  During the check the flag is always added to the
+#   current language's flags.
+#
+#   If EXTRA-FLAGS is defined, it is added to the current language's default
+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
+#   force the compiler to issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+#   NOTE: This macro depends on the AX_APPEND_FLAG and
+#   AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
+#   AX_APPEND_LINK_FLAGS.
+#
+# LICENSE
+#
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 7
+
+AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+for flag in $1; do
+  AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3], [$4])
+done
+])dnl AX_APPEND_COMPILE_FLAGS
diff --git a/src/external/autoconf-archive/m4/ax_append_flag.m4 b/src/external/autoconf-archive/m4/ax_append_flag.m4
new file mode 100644
index 000000000..dd6d8b614
--- /dev/null
+++ b/src/external/autoconf-archive/m4/ax_append_flag.m4
@@ -0,0 +1,50 @@
+# ===========================================================================
+#      https://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+#   FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+#   added in between.
+#
+#   If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+#   CFLAGS) is used.  FLAGS-VARIABLE is not changed if it already contains
+#   FLAG.  If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+#   FLAG.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 8
+
+AC_DEFUN([AX_APPEND_FLAG],
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+  AS_CASE([" AS_VAR_GET(FLAGS) "],
+    [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
+    [
+     AS_VAR_APPEND(FLAGS,[" $1"])
+     AC_RUN_LOG([: FLAGS="$FLAGS"])
+    ])
+  ],
+  [
+  AS_VAR_SET(FLAGS,[$1])
+  AC_RUN_LOG([: FLAGS="$FLAGS"])
+  ])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/src/external/autoconf-archive/m4/ax_check_compile_flag.m4 b/src/external/autoconf-archive/m4/ax_check_compile_flag.m4
new file mode 100644
index 000000000..bd753b34d
--- /dev/null
+++ b/src/external/autoconf-archive/m4/ax_check_compile_flag.m4
@@ -0,0 +1,53 @@
+# ===========================================================================
+#  https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+#   Check whether the given FLAG works with the current language's compiler
+#   or gives an error.  (Warnings, however, are ignored)
+#
+#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+#   success/failure.
+#
+#   If EXTRA-FLAGS is defined, it is added to the current language's default
+#   flags (e.g. CFLAGS) when the check is done.  The check is thus made with
+#   the flags: "CFLAGS EXTRA-FLAGS FLAG".  This can for example be used to
+#   force the compiler to issue an error when a bad flag is given.
+#
+#   INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+#   NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+#   macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+#   Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved.  This file is offered as-is, without any
+#   warranty.
+
+#serial 6
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+  ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+  _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+  AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+    [AS_VAR_SET(CACHEVAR,[yes])],
+    [AS_VAR_SET(CACHEVAR,[no])])
+  _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+  [m4_default([$2], :)],
+  [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/src/external/autoconf-archive/m4/ax_require_defined.m4 b/src/external/autoconf-archive/m4/ax_require_defined.m4
new file mode 100644
index 000000000..17c3eab7d
--- /dev/null
+++ b/src/external/autoconf-archive/m4/ax_require_defined.m4
@@ -0,0 +1,37 @@
+# ===========================================================================
+#    https://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+#   AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+#   AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+#   been defined and thus are available for use.  This avoids random issues
+#   where a macro isn't expanded.  Instead the configure script emits a
+#   non-fatal:
+#
+#     ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+#   It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+#   Here's an example:
+#
+#     AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+#   Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+#   Copying and distribution of this file, with or without modification, are
+#   permitted in any medium without royalty provided the copyright notice
+#   and this notice are preserved. This file is offered as-is, without any
+#   warranty.
+
+#serial 2
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+  m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
diff --git a/src/external/c-tap-harness-last b/src/external/c-tap-harness-last
index 34209570e..3f9f4cbf2 100644
--- a/src/external/c-tap-harness-last
+++ b/src/external/c-tap-harness-last
@@ -1 +1 @@
-d3fc03606efc8e76ff34f04470e6133db25a3982
+abdb66561ffd4d2f238fdb06f448ccf09d80c059
diff --git a/src/external/c-tap-harness/LICENSE b/src/external/c-tap-harness/LICENSE
index 5f9581671..783d17628 100644
--- a/src/external/c-tap-harness/LICENSE
+++ b/src/external/c-tap-harness/LICENSE
@@ -1,138 +1,154 @@
-The C TAP Harness package as a whole is:
+Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Comment: This file documents the copyright statements and licenses for
+ every file in this package in a machine-readable format.  For a less
+ detailed, higher-level overview, see README.
+ .
+ For any copyright year range specified as YYYY-ZZZZ in this file, the
+ range specifies every single year in that closed interval.
+
+Files: *
+Copyright: 2000-2001, 2004, 2006-2020 Russ Allbery <eagle@eyrie.org>
+  2001-2002, 2004-2014
+    The Board of Trustees of the Leland Stanford Junior University
+License: Expat
+
+Files: .clang-format docs/api/bail.3 docs/api/bail.pod
+ docs/api/bcalloc_type.3 docs/api/bcalloc_type.pod docs/api/bmalloc.3
+ docs/api/bmalloc.pod docs/api/breallocarray.3 docs/api/breallocarray.pod
+ docs/api/diag.3 docs/api/diag.pod docs/api/diag_file_add.3
+ docs/api/diag_file_add.pod docs/api/is_int.3 docs/api/is_int.pod
+ docs/api/ok.3 docs/api/ok.pod docs/api/plan.3 docs/api/plan.pod
+ docs/api/skip.3 docs/api/skip.pod docs/api/skip_all.3
+ docs/api/skip_all.pod docs/api/test_cleanup_register.3
+ docs/api/test_cleanup_register.pod docs/api/test_file_path.3
+ docs/api/test_file_path.pod docs/api/test_tmpdir.3
+ docs/api/test_tmpdir.pod docs/runtests.1 docs/runtests.pod
+ docs/writing-tests tests/data/cppcheck.supp
+Copyright: 2009-2020 Russ Allbery <eagle@eyrie.org>
+License: all-permissive
+ Copying and distribution of this file, with or without modification, are
+ permitted in any medium without royalty provided the copyright notice and
+ this notice are preserved.  This file is offered as-is, without any
+ warranty.
+
+Files: Makefile.in
+Copyright: 1994-2020 Free Software Foundation, Inc.
+  2008-2020 Russ Allbery <eagle@eyrie.org>
+License: FSF-unlimited and Expat
+
+Files: aclocal.m4
+Copyright: 1996-2020 Free Software Foundation, Inc.
+License: FSF-unlimited
+
+Files: build-aux/ar-lib build-aux/compile build-aux/depcomp
+ build-aux/missing
+Copyright: 1996-2020 Free Software Foundation, Inc.
+License: GPL-2+ with Autoconf exception or Expat
+
+Files: build-aux/install-sh
+Copyright: 1994 X Consortium
+License: X11
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+ .
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ OTHER DEALINGS IN THE SOFTWARE.
+ .
+ Except as contained in this notice, the name of the X Consortium shall
+ not be used in advertising or otherwise to promote the sale, use or other
+ dealings in this Software without prior written authorization from the X
+ Consortium.
+
+Files: configure
+Copyright: 1992-1996, 1998-2012 Free Software Foundation, Inc.
+License: FSF-configure
+ This script is free software; the Free Software Foundation gives unlimited
+ permission to copy, distribute and modify it.
+
+Files: m4/cc-flags.m4
+Copyright: 2006, 2009, 2016 Internet Systems Consortium, Inc.
+  2016-2020 Russ Allbery <eagle@eyrie.org>
+License: ISC
+ Permission to use, copy, modify, and distribute this software for any
+ purpose with or without fee is hereby granted, provided that the above
+ copyright notice and this permission notice appear in all copies.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY
+ SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+Files: m4/clang.m4
+Copyright: 2015 Russ Allbery <eagle@eyrie.org>
+License: unlimited
+ This file is free software; the authors give unlimited permission to copy
+ and/or distribute it, with or without modifications, as long as this
+ notice is preserved.
+
+License: Expat
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to permit
+ persons to whom the Software is furnished to do so, subject to the
+ following conditions:
+ .
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+ .
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
+ OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
+ THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+License: FSF-unlimited
+ This file is free software; the Free Software Foundation gives unlimited
+ permission to copy and/or distribute it, with or without modifications, as
+ long as this notice is preserved.
+ .
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+License: GPL-2+ with Autoconf exception
+ This file is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+ .
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+ Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License along
+ with this program.  If not, see <https://www.gnu.org/licenses/>.
+ .
+ As a special exception to the GNU General Public License, if you
+ distribute this file as part of a program that contains a configuration
+ script generated by Autoconf, you may include it under the same
+ distribution terms that you use for the rest of that program.
+Comment: The option described in the license has been accepted and these
+ files are distributed under the same terms as the package as a whole, as
+ described at the top of this file.
 
-  Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-      Russ Allbery <rra@stanford.edu>
-  Copyright 2006, 2007, 2008, 2009, 2011, 2012
-      The Board of Trustees of the Leland Stanford Junior University
-
-and released under the following license:
-
-  Permission is hereby granted, free of charge, to any person obtaining a
-  copy of this software and associated documentation files (the
-  "Software"), to deal in the Software without restriction, including
-  without limitation the rights to use, copy, modify, merge, publish,
-  distribute, sublicense, and/or sell copies of the Software, and to
-  permit persons to whom the Software is furnished to do so, subject to
-  the following conditions:
-
-  The above copyright notice and this permission notice shall be included
-  in all copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-  IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-  CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-  TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-All individual files without an explicit exception below are released
-under this license.  Some files may have additional copyright holders as
-noted in those files.
-
-Some files in this distribution are individually released under different
-licenses, all of which are compatible with the above general package
-license but which may require preservation of additional notices.  All
-required notices are preserved in this file.  Of the files intended to be
-copied into other packages, only docs/writing-tests has a different
-license notice, and its requirements are met by preserving the license
-section of that document in any derivative works.
-
-Collected copyright notices for the entire package:
-
-  Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-      Russ Allbery <rra@stanford.edu>
-  Copyright 2006, 2007, 2008, 2009, 2011, 2012
-      The Board of Trustees of the Leland Stanford Junior University
-  Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-      2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-      Free Software Foundation, Inc.
-  Copyright 1994 X Consortium
-
-The file docs/writing-tests is released under the following license:
-
-  Copying and distribution of this file, with or without modification, are
-  permitted in any medium without royalty provided the copyright notice
-  and this notice are preserved.  This file is offered as-is, without any
-  warranty.
-
-The files Makefile.in and aclocal.m4 are generated by GNU Automake and
-released under the following copyright and license:
-
-  Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-  2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software
-  Foundation, Inc.  This file is free software; the Free Software
-  Foundation gives unlimited permission to copy and/or distribute it, with
-  or without modifications, as long as this notice is preserved.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-  even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-  PARTICULAR PURPOSE.
-
-The file configure is generated by GNU Autoconf and is released under the
-following copyright and license:
-
-  Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
-  2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
-  Foundation, Inc.  This configure script is free software; the Free
-  Software Foundation gives unlimited permission to copy, distribute and
-  modify it.
-
-The files build-aux/compile, build-aux/depcomp, and build-aux/missing are
-taken from GNU Automake and are released under the following copyright and
-license:
-
-  Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006,
-  2007, 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc.
-
-  This program is free software; you can redistribute it and/or modify it
-  under the terms of the GNU General Public License as published by the
-  Free Software Foundation; either version 2, or (at your option) any
-  later version.
-
-  This program is distributed in the hope that it will be useful, but
-  WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-  General Public License for more details.
-
-  As a special exception to the GNU General Public License, if you
-  distribute this file as part of a program that contains a configuration
-  script generated by Autoconf, you may include it under the same
-  distribution terms that you use for the rest of that program.
-
-For the C TAP Harness distribution, the option described in the last
-paragraph has been accepted and these files are distributed under the same
-terms as the C TAP Harness package as a whole, as described at the top of
-this file.
-
-The file build-aux/install-sh is released under the following copyright
-and license:
-
-  Copyright (C) 1994 X Consortium
-
-  Permission is hereby granted, free of charge, to any person obtaining a
-  copy of this software and associated documentation files (the
-  "Software"), to deal in the Software without restriction, including
-  without limitation the rights to use, copy, modify, merge, publish,
-  distribute, sublicense, and/or sell copies of the Software, and to
-  permit persons to whom the Software is furnished to do so, subject to
-  the following conditions:
-
-  The above copyright notice and this permission notice shall be included
-  in all copies or substantial portions of the Software.
-
-  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
-  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
-  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-  OTHER DEALINGS IN THE SOFTWARE.
-
-  Except as contained in this notice, the name of the X Consortium shall
-  not be used in advertising or otherwise to promote the sale, use or
-  other dealings in this Software without prior written authorization
-  from the X Consortium.
-
-  FSF changes to this file are in the public domain.
diff --git a/src/external/c-tap-harness/NEWS b/src/external/c-tap-harness/NEWS
index be4aba8a0..7e4a61716 100644
--- a/src/external/c-tap-harness/NEWS
+++ b/src/external/c-tap-harness/NEWS
@@ -1,5 +1,275 @@
                     User-Visible C TAP Harness Changes
 
+C TAP Harness 4.7 (2020-05-16)
+
+    Allow the package test suite to be run with C_TAP_VERBOSE without
+    breaking test results via inheritance of that setting.
+
+    Fix warnings with GCC 10.
+
+C TAP Harness 4.6 (2020-01-07)
+
+    Reformat all C source using clang-format 10 and the formatting rules
+    specified in .clang-format.
+
+    Update to rra-c-util 8.1:
+
+    * Drop support for Perl versions prior to Perl 5.8.
+
+C TAP Harness 4.5 (2019-08-31)
+
+    Add new bcalloc_type and breallocarray_type macros that take a type
+    instead of a size as their third argument and cast the return value to
+    a pointer to that type.  These are more friendly to C++ code than
+    C-style allocation functions returning void *.
+
+    The test harness and libtap C library can now alternatively be
+    compiled with a C++ compiler, making it easier to incorporate them
+    into a C++ project.  Thanks to Peter Paris for the initial report.
+
+C TAP Harness 4.4 (2018-12-25)
+
+    Add test_cleanup_register_with_data to the C TAP library.  This is the
+    same as test_cleanup_register except takes a generic pointer, which is
+    then passed to the cleanup function as a third argument.  This should
+    have been the only API from the beginning, but test_cleanup_register
+    is preserved for backward compatibility.  Patch from Marc Dionne.
+
+    Fix error checking for malloc failure in bstrndup function (caught by
+    cppcheck).
+
+    Update to rra-c-util 8.0:
+
+    * Skip tests requiring Test::More if it isn't available.
+    * Check for pre-SPDX license grant strings.
+    * Improved test for obsolete strings in package source files.
+
+C TAP Harness 4.3 (2018-05-06)
+
+    Add support for valgrind and libtool test options in test lists.  Test
+    lists now take a space-separated set of options after the test name.
+    If the valgrind option is present and C_TAP_VALGRIND is set in the
+    environment, the test will be run by passing it as an option to the
+    command given in C_TAP_VALGRIND.  If the libtool option is also set,
+    valgrind will be run via the libtool script set in C_TAP_LIBTOOL,
+    using --mode=execute, so that valgrind will run on the underlying
+    binary and not the libtool shell wrapper.
+
+    On test failures, report the values as left and right instead of
+    wanted and seen.  This idea is stolen from the Rust assert framework.
+    It avoids having to care about the order in which values are passed
+    into the test functions.
+
+    Fix is_string comparisons involving NULL pointers so that the string
+    "(null)" will no longer compare equal to NULL (although the diagnostic
+    output on test failure is still mildly confusing).
+
+    Add new check-cppcheck target that runs cppcheck on all source code,
+    and fix one unnecessary check for NULL that it uncovered.
+
+    Add SPDX-License-Identifier headers to all substantial source files,
+    and add a test to check for them.  This imports more supporting test
+    machinery whose canonical home is in rra-c-util.  If you want to use
+    files in tests/tap/perl, copy them from rra-c-util instead of this
+    package.
+
+    C TAP Harness now imports the Perl test modules from rra-c-util to
+    support some checks, so tests/docs/pod-spelling-t and tests/docs/pod-t
+    have been updated to the versions from rra-c-util.  Projects that were
+    previously copying those tests should be able to continue to use them,
+    but will now need the modules in tests/tap/perl (the canonical version
+    of which are maintained in rra-c-util).
+
+C TAP Harness 4.2 (2017-12-30)
+
+    Add is_blob function to the C test library.  This tests whether two
+    regions of memory are identical, similar to ok(memcmp(...)) but
+    reporting where the regions differ.  Patch from Daniel Collins.
+
+    Avoid zero-length realloc allocations in breallocarray.
+
+    Fix new fall-through warning in GCC 7.
+
+    Switch to the compiler warning Autoconf macros and warning set from
+    rra-c-util with the addition of -ansi -pedantic for GCC and
+    -pedantic-errors for Clang.  Add some casts to fix warnings from
+    -Wconversion, and suppress some spurious warnings from Clang about
+    tests/tap/float.c.
+
+C TAP Harness 4.1 (2016-12-23)
+
+    Add is_bool function to the C test library.  This compares its two
+    arguments only for their truthfulness.  is_bool(true, arg) is the same
+    as ok(arg), but there are times (such as when testing for a false
+    value) where this allows for clearer code or clearer output.
+
+C TAP Harness 4.0 (2016-05-07)
+
+    When building runtests, one must now set the C_TAP_SOURCE and
+    C_TAP_BUILD C preprocessor symbols to the source and build
+    directories, instead of SOURCE and BUILD.  An updated Makefile.am
+    recipe is documented in README.
+
+    runtests now sets C_TAP_SOURCE and C_TAP_BUILD in the environment in
+    addition to SOURCE and BUILD.  All test programs using this harness
+    should switch to the new C_TAP_SOURCE and C_TAP_BUILD environment
+    variables.  SOURCE and BUILD are very generic and may conflict with
+    other programs and uses, and setting them will be removed in a later
+    version.
+
+    The TAP test libraries (C and shell) now use C_TAP_SOURCE and
+    C_TAP_BUILD environment variables instead of SOURCE and BUILD for the
+    test_file_path() and test_tmpdir() functions.  If you were using these
+    libraries with another test harness, you will need to set the new
+    environment variables.
+
+    Fix missing va_end() call in is_double(), which would have caused
+    compilation failures or other problems on some platforms.  Thanks,
+    Julien Ã‰LIE.
+
+    Rename the script to bootstrap from a Git checkout to bootstrap,
+    matching the emerging consensus in the Autoconf world.
+
+C TAP Harness 3.4 (2015-08-18)
+
+    Fix segfault in runtests when given a test list containing only
+    comments and blank lines.  Thanks, aherbert.
+
+C TAP Harness 3.3 (2015-04-26)
+
+    If runtests is given the -v option, or if the environment variable
+    C_TAP_VERBOSE is set, the complete output of each test program will be
+    shown instead of the summary of total and failing tests.  Based on
+    work by D. Brashear.
+
+    C TAP Harness now compiles cleanly with Clang with -Weverything
+    -Wno-padded -pedantic-errors, and automatically detects Clang and
+    switches warning flags for make warnings.
+
+C TAP Harness 3.2 (2014-12-25)
+
+    The runtests harness now supports ignoring comments and blank lines in
+    the test list specified with -l.  Leading whitespace before the test
+    name is also ignored.
+
+C TAP Harness 3.1 (2014-07-02)
+
+    ok, okv, and all is_* functions now return true if the test succeeds
+    and false if it fails, matching the return status of the corresponding
+    Perl Test::More functions.  This allows more succinct code when the
+    actions of a test program should vary based on the success or failure
+    of previous tests.  Based on a patch by Peter PÃ¶schl.
+
+    diag and sysdiag now always return 1, making it easier to insert calls
+    into compound statements when debugging tests.  Based on a patch by
+    Peter PÃ¶schl.
+
+    Add new breallocarray API that does the same as realloc but takes
+    calloc-style arguments to specify the size and checks internally for
+    integer overflow.  Inspired by the OpenBSD reallocarray function.
+
+    Check for integer overflows on memory allocation.  All the possible
+    issues for this code are rather theoretical, but one may as well
+    strive for correctness.
+
+    Replace all uses of sprintf with a simpler string concatenation
+    function that checks for allocation overflow.  (The standards
+    assumptions for this package don't permit assuming asprintf or a
+    sufficiently non-broken snprintf to simulate asprintf.)
+
+C TAP Harness 3.0 (2014-01-28)
+
+    The test_cleanup_register API has changed in this release.  Cleanup
+    functions must now take two parameters, not one, and are called from
+    all test processes, not just the primary one.  The new second argument
+    indicates whether the cleanup function was called in the primary
+    process (the one in which plan or plan_lazy was called).  External
+    resources, such as files, should generally only be freed when the
+    cleanup function is called in the primary process, but tests may want
+    to free internal resources, like memory, in all processes to ease
+    analysis with tools like valgrind.
+
+    When running test programs from a list, reopen standard input for each
+    program to /dev/null, and be more careful about closing all duplicates
+    of file descriptors left behind after setting up standard output and
+    standard error so that extraneous file descriptors aren't leaked to
+    the child process.
+
+C TAP Harness 2.4 (2013-12-25)
+
+    Add new diag_file_add and diag_file_remove APIs to the basic C TAP
+    library.  These functions manage a list of registered file that
+    contains supplemental diagnostic information.  Each registered file is
+    checked before each output function for any new lines, and any lines
+    are displayed as if they'd been passed to diag().  This can be useful
+    if, for example, the test involves a background daemon whose output
+    can be logged to a disk file.
+
+C TAP Harness 2.3 (2013-11-13)
+
+    Add new test_cleanup_register API to the basic C TAP library.  This
+    registers a C callback function that's called during exit from the
+    test and passed in a boolean argument indicating whether the test
+    succeeded or failed.
+
+    Suppress lazy plans and the summary of tests at the end of a test
+    program if the program aborted with bail or sysbail.
+
+    Add warn_unused_result gcc attributes to the C TAP library functions
+    where ignoring the return value is almost certainly a bug (such as all
+    the malloc functions).
+
+    Add portability for warn_unsed_result attributes to tap/macros.h.
+
+C TAP Harness 2.2 (2013-08-14)
+
+    bail and sysbail now exit with status 255 to match the behavior of
+    BAIL_OUT in Perl's Test::More.
+
+    Document that runtests handling of test cases that bail out differs
+    from the documented behavior of BAIL_OUT in Perl's Test::More and the
+    behavior of prove, and document why.
+
+C TAP Harness 2.1 (2013-03-15)
+
+    When locating test programs, try a suffix (-t, .t, or no suffix) with
+    all bases before moving on to the next suffix.  The behavior in the
+    previous release was not backward-compatible: it would find the
+    unsuffixed helper program in the build directory instead of the actual
+    test in the source directory for some rra-c-util tests when the build
+    directory and the source directory weren't the same.
+
+    Document that TAP version directives in the TAP output are ignored.
+
+C TAP Harness 2.0 (2013-03-14)
+
+    The default behavior of tests/runtests has changed to make it act more
+    like other test drivers.  Now, to provide a file containing a list of
+    tests, use the -l option.  Existing users should add -l to the command
+    line in front of the test list.  Otherwise, the command-line arguments
+    are taken as tests to run, as if they were all listed in a test list
+    file.
+
+    runtests now tries the test name without any extension if the test
+    name with either -t or .t was not found.  It also does not consider a
+    directory to be a valid test when searching for the executable, even
+    if the directory is executable.
+
+    Flush the harness output after each test.  This effectively implements
+    line buffering even when standard output is not a terminal and
+    therefore output isn't flushed after each line of test output.
+
+    When displaying partial status of tests with a deferred plan, show the
+    total number of tests as ? rather than the number of tests seen so
+    far.  This matches the behavior of Perl's prove utility.
+
+    More correctly handle backspacing over the test count in several abort
+    cases when reporting status to a terminal.
+
+    Add GCC annotations to some internal functions in runtests to help
+    clang --analyze better understand code correctness.  Remove a dead
+    store caught by clang --analyze.
+
 C TAP Harness 1.12 (2012-05-11)
 
     Fix additional uses of local in the shell TAP library for portability
@@ -54,7 +324,7 @@ C TAP Harness 1.11 (2012-04-25)
 
     Move the is_double C TAP test function into a separate source file.
     Including this function may require linking with libm on some
-    platforms, which is undesireable if the package otherwise doesn't use
+    platforms, which is undesirable if the package otherwise doesn't use
     math functions.  The new tests/tap/float.c and tests/tap/float.h files
     need only be included in a package that wants to do floating point
     tests.  Users of is_double will now need to include tests/tap/float.h
diff --git a/src/external/c-tap-harness/README b/src/external/c-tap-harness/README
index ddcfc914d..3a6bb55b0 100644
--- a/src/external/c-tap-harness/README
+++ b/src/external/c-tap-harness/README
@@ -1,12 +1,12 @@
-                            C TAP Harness 1.12
+                            C TAP Harness 4.7
                (C harness for running TAP-compliant tests)
+               Maintained by Russ Allbery <eagle@eyrie.org>
 
-                Written by Russ Allbery <rra@stanford.edu>
-
-  Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011, 2012
-  Russ Allbery <rra@stanford.edu>.  This software is distributed under a
-  BSD-style license.  Please see the file LICENSE in the distribution for
-  more information.
+  Copyright 2000-2001, 2004, 2006-2020 Russ Allbery <eagle@eyrie.org>.
+  Copyright 2006-2009, 2011-2013 The Board of Trustees of the Leland
+  Stanford Junior University.  This software is distributed under a
+  BSD-style license.  Please see the section LICENSE below for more
+  information.
 
 BLURB
 
@@ -28,7 +28,7 @@ DESCRIPTION
   merges all the various versions into a single code base that all my
   packages can pull from.
 
-  C TAP Harness provides a full TAP specification (apart from a few
+  C TAP Harness provides a full TAP specification driver (apart from a few
   possible edge cases) and has additional special features for supporting
   builds outside the source directory.  It's mostly useful for packages
   using Autoconf and Automake and because it doesn't assume or require
@@ -44,7 +44,11 @@ DESCRIPTION
 
   Also included in this package are C and shell libraries that provide
   utility functions for writing test scripts that use TAP to report
-  exists.
+  results.  The C library also provides a variety of utility functions
+  useful for test programs running as part of an Automake-built package:
+  finding test data files, creating temporary files, reporting output from
+  external programs running in the background, and similar common
+  problems.
 
 REQUIREMENTS
 
@@ -55,50 +59,68 @@ REQUIREMENTS
   Bourne-compatible shell.  Outside of the test suite, C TAP Harness has
   no other prerequisites or requirements.
 
-  To run the test suite, you will need Perl plus the Perl modules
-  Test::More and Test::Pod.  Test::More comes with Perl 5.8 and later.
-  Test::Pod is available from CPAN and currently must be installed
-  separately, but the POD tests will be skipped without interfering with
-  the rest of the tests if it's not installed.
-
-  To check spelling in the POD documentation, Pod::Spell (available from
-  CPAN) and either aspell or ispell with the american dictionary are also
-  required.  The user's path is searched for aspell or ispell and aspell
-  is preferred.  Spelling tests are disabled by default since spelling
-  dictionaries differ too much between systems.  To enable those tests,
-  set RRA_MAINTAINER_TESTS to a true value.
+  C TAP Harness can also be built with a C++ compiler and should be
+  similarly portable to any recent C++ compiler, although it is only
+  tested with g++.
 
   To bootstrap from a Git checkout, or if you change the Automake files
   and need to regenerate Makefile.in, you will need Automake 1.11 or
   later.  For bootstrap or if you change configure.ac or any of the m4
   files it includes and need to regenerate configure or config.h.in, you
-  will need Autoconf 2.64 or later.  Perl is also required to generate the
-  manual page from a fresh Git checkout.
+  will need Autoconf 2.64 or later.  Perl is also required to generate
+  manual pages from a fresh Git checkout.
 
-BUILDING AND TESTING
+BUILDING
 
-  You can build C TAP Harness and run its internal test suite with:
+  You can build C TAP Harness with the standard commands:
 
       ./configure
       make
-      make check
 
-  While there is a configure script, it exists just to drive the build
-  system and do some path substitution and isn't doing portability
-  probes.  Pass --enable-silent-rules to configure for a quieter build
-  (similar to the Linux kernel).
+  If you are building from a Git clone, first run ./bootstrap in the
+  source directory to generate the build files.  Building outside of the
+  source directory is also supported, if you wish, by creating an empty
+  directory and then running configure with the correct relative path.
+
+  Pass --enable-silent-rules to configure for a quieter build (similar to
+  the Linux kernel).  Use make warnings instead of make to build with full
+  compiler warnings (requires either GCC or Clang and may require a
+  relatively current version of the compiler).
+
+  Installing C TAP Harness is not normally done.  Instead, see the section
+  on using the harness below.
+
+TESTING
 
-  Use make warnings instead of make to build with full GCC compiler
-  warnings (requires a relatively current version of GCC).
+  C TAP Harness comes with a comprehensive test suite, which you can run
+  after building with:
+
+      make check
 
   If a test fails, you can run a single test with verbose output via:
 
-      ./runtests -b `pwd`/tests -s `pwd`/tests -o <name-of-test>
+      tests/runtests -b $(pwd)/tests -s $(pwd)/tests -o <name-of-test>
 
   Do this instead of running the test program directly since it will
   ensure that necessary environment variables are set up.  You may need to
-  change the -s option if you build with a separate build directory from
-  the source directory.
+  change the -s option argument if you build with a separate build
+  directory from the source directory.
+
+  To run the test suite, you will need Perl 5.8 or later.  The following
+  additional Perl modules will be used by the test suite if present:
+
+  * Test::Pod
+  * Test::Spelling
+
+  All are available on CPAN.  Those tests will be skipped if the modules
+  are not available.
+
+  To enable tests that don't detect functionality problems but are used to
+  sanity-check the release, set the environment variable RELEASE_TESTING
+  to a true value.  To enable tests that may be sensitive to the local
+  environment or that produce a lot of false positives without uncovering
+  many problems, set the environment variable AUTHOR_TESTING to a true
+  value.
 
 USING THE HARNESS
 
@@ -123,8 +145,8 @@ USING THE HARNESS
     library:
 
         check_PROGRAMS = tests/runtests
-        tests_runtests_CPPFLAGS = -DSOURCE='"$(abs_top_srcdir)/tests"' \
-                -DBUILD='"$(abs_top_builddir)/tests"'
+        tests_runtests_CPPFLAGS = -DC_TAP_SOURCE='"$(abs_top_srcdir)/tests"' \
+                -DC_TAP_BUILD='"$(abs_top_builddir)/tests"'
         check_LIBRARIES = tests/tap/libtap.a
         tests_tap_libtap_a_CPPFLAGS = -I$(abs_top_srcdir)/tests
         tests_tap_libtap_a_SOURCES = tests/tap/basic.c tests/tap/basic.h \
@@ -132,8 +154,8 @@ USING THE HARNESS
 
     Omit float.c and float.h from the last line if your package doesn't
     need the is_double function.  Building the build and source
-    directories into runtests will let tests/runtests -o <test> to work
-    for users without requiring that they set any other variables, even if
+    directories into runtests will let tests/runtests -o <test> work for
+    users without requiring that they set any other variables, even if
     they're doing an out-of-source build.
 
     Add additional source files and headers that should go into the TAP
@@ -142,16 +164,18 @@ USING THE HARNESS
   * Add code to Makefile.am to run the test suite:
 
         check-local: $(check_PROGRAMS)
-              cd tests && ./runtests $(abs_top_srcdir)/tests/TESTS
+              cd tests && ./runtests -l $(abs_top_srcdir)/tests/TESTS
+
+    See the Makefile.am in this package for an example.
+
+  * List the test programs in the tests/TESTS file.  This should have the
+    name of the test executable with the trailing "-t" or ".t" (you can
+    use either extension as you prefer) omitted.
 
-    See the Makefile.am in this package for an example (although note that
-    it keeps runtests in an unusual location).
+    Test programs must be executable.
 
-  * List the test programs in the TESTS file.  This should have the name
-    of the test executable with the trailing "-t" or ".t" (you can use
-    either extension as you prefer) omitted.  For any test programs that
-    need to be compiled, add build rules for them in Makefile.am, simliar
-    to:
+    For any test programs that need to be compiled, add build rules for
+    them in Makefile.am, similar to:
 
         tests_libtap_c_basic_LDADD = tests/tap/libtap.a
 
@@ -173,7 +197,7 @@ USING THE HARNESS
     the tap subdirectory of your tests directory and add it to EXTRA_DIST.
     Shell programs should start with:
 
-        . "${SOURCE}/tap/libtap.sh"
+        . "${C_TAP_SOURCE}/tap/libtap.sh"
 
     and can then use the functions defined in the library.
 
@@ -186,43 +210,93 @@ USING THE HARNESS
 
   If you have data files that your test cases use, conventionally they go
   into tests/data.  You can then find the data directory relative to the
-  SOURCE environment variable (set by runtests) in your test program.  If
-  you have data that's compiled or generated by Autoconf, it will be
-  relative to the BUILD environment variable.  Don't forget to add test
-  data to EXTRA_DIST as necessary.
+  C_TAP_SOURCE environment variable (set by runtests) in your test
+  program.  If you have data that's compiled or generated by Autoconf, it
+  will be relative to the BUILD environment variable.  Don't forget to add
+  test data to EXTRA_DIST as necessary.
 
   For more TAP library add-ons, generally ones that rely on additional
   portability code not shipped in this package or with narrower uses, see
-  the rra-c-util package:
+  the rra-c-util package [1].  There are several additional TAP library
+  add-ons in the tests/tap directory in that package.  It's also an
+  example of how to use this test harness in another package.
 
-      http://www.eyrie.org/~eagle/software/rra-c-util/
+  [1] https://www.eyrie.org/~eagle/software/rra-c-util/
 
-  There are several additional TAP library add-ons in the tests/tap
-  directory in that package.  It's also an example of how to use this test
-  harness in another package.
-
-HOMEPAGE AND SOURCE REPOSITORY
+SUPPORT
 
   The C TAP Harness web page at:
 
-      http://www.eyrie.org/~eagle/software/c-tap-harness/
+      https://www.eyrie.org/~eagle/software/c-tap-harness/
 
   will always have the current version of this package, the current
   documentation, and pointers to any additional resources.
 
-  C TAP Harness is maintained using Git.  You can access the current
-  source by cloning the repository at:
+  For bug tracking, use the issue tracker on GitHub:
 
-      git://git.eyrie.org/devel/c-tap-harness.git
+      https://github.com/rra/c-tap-harness/issues
 
-  or view the repository via the web at:
+  However, please be aware that I tend to be extremely busy and work
+  projects often take priority.  I'll save your report and get to it as
+  soon as I can, but it may take me a couple of months.
 
-      http://git.eyrie.org/?p=devel/c-tap-harness.git
+SOURCE REPOSITORY
 
-  C TAP Harness is also available via github at:
+  C TAP Harness is maintained using Git.  You can access the current
+  source on GitHub at:
+
+      https://github.com/rra/c-tap-harness
+
+  or by cloning the repository at:
 
-      http://github.com/rra/c-tap-harness
+      https://git.eyrie.org/git/devel/c-tap-harness.git
+
+  or view the repository via the web at:
 
-  and the github wiki and issue tracker are available on an experimental
-  basis.  If you like using the github facilities, try filing issues or
-  adding supplemental documentation there.
+      https://git.eyrie.org/?p=devel/c-tap-harness.git
+
+  The eyrie.org repository is the canonical one, maintained by the author,
+  but using GitHub is probably more convenient for most purposes.  Pull
+  requests are gratefully reviewed and normally accepted.
+
+LICENSE
+
+  The C TAP Harness package as a whole is covered by the following
+  copyright statement and license:
+
+    Copyright 2000-2001, 2004, 2006-2020 Russ Allbery <eagle@eyrie.org>
+    Copyright 2006-2009, 2011-2013
+        The Board of Trustees of the Leland Stanford Junior University
+
+    Permission is hereby granted, free of charge, to any person obtaining
+    a copy of this software and associated documentation files (the
+    "Software"), to deal in the Software without restriction, including
+    without limitation the rights to use, copy, modify, merge, publish,
+    distribute, sublicense, and/or sell copies of the Software, and to
+    permit persons to whom the Software is furnished to do so, subject to
+    the following conditions:
+
+    The above copyright notice and this permission notice shall be
+    included in all copies or substantial portions of the Software.
+
+    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+    IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+    CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+    TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+    SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+  Some files in this distribution are individually released under
+  different licenses, all of which are compatible with the above general
+  package license but which may require preservation of additional
+  notices.  All required notices, and detailed information about the
+  licensing of each file, are recorded in the LICENSE file.
+
+  Files covered by a license with an assigned SPDX License Identifier
+  include SPDX-License-Identifier tags to enable automated processing of
+  license information.  See https://spdx.org/licenses/ for more
+  information.
+
+  For any copyright range specified by files in this package as YYYY-ZZZZ,
+  the range specifies every single year in that closed interval.
diff --git a/src/external/c-tap-harness/tests/runtests.c b/src/external/c-tap-harness/tests/runtests.c
index 424987568..1050120c7 100644
--- a/src/external/c-tap-harness/tests/runtests.c
+++ b/src/external/c-tap-harness/tests/runtests.c
@@ -1,17 +1,53 @@
 /*
  * Run a set of tests, reporting results.
  *
+ * Test suite driver that runs a set of tests implementing a subset of the
+ * Test Anything Protocol (TAP) and reports the results.
+ *
+ * Any bug reports, bug fixes, and improvements are very much welcome and
+ * should be sent to the e-mail address below.  This program is part of C TAP
+ * Harness <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ *
+ * Copyright 2000-2001, 2004, 2006-2019 Russ Allbery <eagle@eyrie.org>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+/*
  * Usage:
  *
- *      runtests [-b <build-dir>] [-s <source-dir>] <test-list>
- *      runtests -o [-b <build-dir>] [-s <source-dir>] <test>
+ *      runtests [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>
+ *      runtests [-hv] [-b <build-dir>] [-s <source-dir>] <test> [<test> ...]
+ *      runtests -o [-h] [-b <build-dir>] [-s <source-dir>] <test>
  *
  * In the first case, expects a list of executables located in the given file,
- * one line per executable.  For each one, runs it as part of a test suite,
- * reporting results.  Test output should start with a line containing the
- * number of tests (numbered from 1 to this number), optionally preceded by
- * "1..", although that line may be given anywhere in the output.  Each
- * additional line should be in the following format:
+ * one line per executable, possibly followed by a space-separated list of
+ * options.  For each one, runs it as part of a test suite, reporting results.
+ * In the second case, use the same infrastructure, but run only the tests
+ * listed on the command line.
+ *
+ * Test output should start with a line containing the number of tests
+ * (numbered from 1 to this number), optionally preceded by "1..", although
+ * that line may be given anywhere in the output.  Each additional line should
+ * be in the following format:
  *
  *      ok <number>
  *      not ok <number>
@@ -44,49 +80,30 @@
  * output.  This is intended for use with failing tests so that the person
  * running the test suite can get more details about what failed.
  *
- * If built with the C preprocessor symbols SOURCE and BUILD defined, C TAP
- * Harness will export those values in the environment so that tests can find
- * the source and build directory and will look for tests under both
- * directories.  These paths can also be set with the -b and -s command-line
- * options, which will override anything set at build time.
+ * If built with the C preprocessor symbols C_TAP_SOURCE and C_TAP_BUILD
+ * defined, C TAP Harness will export those values in the environment so that
+ * tests can find the source and build directory and will look for tests under
+ * both directories.  These paths can also be set with the -b and -s
+ * command-line options, which will override anything set at build time.
  *
- * Any bug reports, bug fixes, and improvements are very much welcome and
- * should be sent to the e-mail address below.  This program is part of C TAP
- * Harness <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
- *
- * Copyright 2000, 2001, 2004, 2006, 2007, 2008, 2009, 2010, 2011
- *     Russ Allbery <rra@stanford.edu>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
-*/
+ * If the -v option is given, or the C_TAP_VERBOSE environment variable is set,
+ * display the full output of each test as it runs rather than showing a
+ * summary of the results of each test.
+ */
 
 /* Required for fdopen(), getopt(), and putenv(). */
 #if defined(__STRICT_ANSI__) || defined(PEDANTIC)
-# ifndef _XOPEN_SOURCE
-#  define _XOPEN_SOURCE 500
-# endif
+#    ifndef _XOPEN_SOURCE
+#        define _XOPEN_SOURCE 500
+#    endif
 #endif
 
 #include <ctype.h>
 #include <errno.h>
 #include <fcntl.h>
+#include <limits.h>
 #include <stdarg.h>
+#include <stddef.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -101,63 +118,81 @@
 /* sys/time.h must be included before sys/resource.h on some platforms. */
 #include <sys/resource.h>
 
-/* AIX doesn't have WCOREDUMP. */
+/* AIX 6.1 (and possibly later) doesn't have WCOREDUMP. */
 #ifndef WCOREDUMP
-# define WCOREDUMP(status)      ((unsigned)(status) & 0x80)
+#    define WCOREDUMP(status) ((unsigned) (status) &0x80)
+#endif
+
+/*
+ * POSIX requires that these be defined in <unistd.h>, but they're not always
+ * available.  If one of them has been defined, all the rest almost certainly
+ * have.
+ */
+#ifndef STDIN_FILENO
+#    define STDIN_FILENO  0
+#    define STDOUT_FILENO 1
+#    define STDERR_FILENO 2
 #endif
 
+/*
+ * Used for iterating through arrays.  Returns the number of elements in the
+ * array (useful for a < upper bound in a for loop).
+ */
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+
 /*
  * The source and build versions of the tests directory.  This is used to set
- * the SOURCE and BUILD environment variables and find test programs, if set.
- * Normally, this should be set as part of the build process to the test
- * subdirectories of $(abs_top_srcdir) and $(abs_top_builddir) respectively.
+ * the C_TAP_SOURCE and C_TAP_BUILD environment variables (and the SOURCE and
+ * BUILD environment variables set for backward compatibility) and find test
+ * programs, if set.  Normally, this should be set as part of the build
+ * process to the test subdirectories of $(abs_top_srcdir) and
+ * $(abs_top_builddir) respectively.
  */
-#ifndef SOURCE
-# define SOURCE NULL
+#ifndef C_TAP_SOURCE
+#    define C_TAP_SOURCE NULL
 #endif
-#ifndef BUILD
-# define BUILD NULL
+#ifndef C_TAP_BUILD
+#    define C_TAP_BUILD NULL
 #endif
 
 /* Test status codes. */
-enum test_status {
-    TEST_FAIL,
-    TEST_PASS,
-    TEST_SKIP,
-    TEST_INVALID
-};
+enum test_status { TEST_FAIL, TEST_PASS, TEST_SKIP, TEST_INVALID };
+
+/* Really, just a boolean, but this is more self-documenting. */
+enum test_verbose { CONCISE = 0, VERBOSE = 1 };
 
 /* Indicates the state of our plan. */
 enum plan_status {
-    PLAN_INIT,                  /* Nothing seen yet. */
-    PLAN_FIRST,                 /* Plan seen before any tests. */
-    PLAN_PENDING,               /* Test seen and no plan yet. */
-    PLAN_FINAL                  /* Plan seen after some tests. */
+    PLAN_INIT,    /* Nothing seen yet. */
+    PLAN_FIRST,   /* Plan seen before any tests. */
+    PLAN_PENDING, /* Test seen and no plan yet. */
+    PLAN_FINAL    /* Plan seen after some tests. */
 };
 
 /* Error exit statuses for test processes. */
-#define CHILDERR_DUP    100     /* Couldn't redirect stderr or stdout. */
-#define CHILDERR_EXEC   101     /* Couldn't exec child process. */
-#define CHILDERR_STDERR 102     /* Couldn't open stderr file. */
+#define CHILDERR_DUP    100 /* Couldn't redirect stderr or stdout. */
+#define CHILDERR_EXEC   101 /* Couldn't exec child process. */
+#define CHILDERR_STDIN  102 /* Couldn't open stdin file. */
+#define CHILDERR_STDERR 103 /* Couldn't open stderr file. */
 
 /* Structure to hold data for a set of tests. */
 struct testset {
-    char *file;                 /* The file name of the test. */
-    char *path;                 /* The path to the test program. */
-    enum plan_status plan;      /* The status of our plan. */
-    unsigned long count;        /* Expected count of tests. */
-    unsigned long current;      /* The last seen test number. */
-    unsigned int length;        /* The length of the last status message. */
-    unsigned long passed;       /* Count of passing tests. */
-    unsigned long failed;       /* Count of failing lists. */
-    unsigned long skipped;      /* Count of skipped tests (passed). */
-    unsigned long allocated;    /* The size of the results table. */
-    enum test_status *results;  /* Table of results by test number. */
-    unsigned int aborted;       /* Whether the set as aborted. */
-    int reported;               /* Whether the results were reported. */
-    int status;                 /* The exit status of the test. */
-    unsigned int all_skipped;   /* Whether all tests were skipped. */
-    char *reason;               /* Why all tests were skipped. */
+    char *file;                /* The file name of the test. */
+    char **command;            /* The argv vector to run the command. */
+    enum plan_status plan;     /* The status of our plan. */
+    unsigned long count;       /* Expected count of tests. */
+    unsigned long current;     /* The last seen test number. */
+    unsigned int length;       /* The length of the last status message. */
+    unsigned long passed;      /* Count of passing tests. */
+    unsigned long failed;      /* Count of failing lists. */
+    unsigned long skipped;     /* Count of skipped tests (passed). */
+    unsigned long allocated;   /* The size of the results table. */
+    enum test_status *results; /* Table of results by test number. */
+    unsigned int aborted;      /* Whether the set was aborted. */
+    unsigned int reported;     /* Whether the results were reported. */
+    int status;                /* The exit status of the test. */
+    unsigned int all_skipped;  /* Whether all tests were skipped. */
+    char *reason;              /* Why all tests were skipped. */
 };
 
 /* Structure to hold a linked list of test sets. */
@@ -167,21 +202,27 @@ struct testlist {
 };
 
 /*
- * Usage message.  Should be used as a printf format with two arguments: the
- * path to runtests, given twice.
+ * Usage message.  Should be used as a printf format with four arguments: the
+ * path to runtests, given three times, and the usage_description.  This is
+ * split into variables to satisfy the pedantic ISO C90 limit on strings.
  */
 static const char usage_message[] = "\
-Usage: %s [-b <build-dir>] [-s <source-dir>] <test-list>\n\
-       %s -o [-b <build-dir>] [-s <source-dir>] <test>\n\
+Usage: %s [-hv] [-b <build-dir>] [-s <source-dir>] <test> ...\n\
+       %s [-hv] [-b <build-dir>] [-s <source-dir>] -l <test-list>\n\
+       %s -o [-h] [-b <build-dir>] [-s <source-dir>] <test>\n\
 \n\
 Options:\n\
     -b <build-dir>      Set the build directory to <build-dir>\n\
+%s";
+static const char usage_extra[] = "\
+    -l <list>           Take the list of tests to run from <test-list>\n\
     -o                  Run a single test rather than a list of tests\n\
     -s <source-dir>     Set the source directory to <source-dir>\n\
+    -v                  Show the full output of each test\n\
 \n\
-runtests normally runs each test listed in a file whose path is given as\n\
-its command-line argument.  With the -o option, it instead runs a single\n\
-test and shows its complete output.\n";
+runtests normally runs each test listed on the command line.  With the -l\n\
+option, it instead runs every test listed in a file.  With the -o option,\n\
+it instead runs a single test and shows its complete output.\n";
 
 /*
  * Header used for test output.  %s is replaced by the file name of the list
@@ -197,9 +238,83 @@ Failed Set                 Fail/Total (%) Skip Stat  Failing Tests\n\
 -------------------------- -------------- ---- ----  ------------------------";
 
 /* Include the file name and line number in malloc failures. */
-#define xmalloc(size)     x_malloc((size), __FILE__, __LINE__)
-#define xrealloc(p, size) x_realloc((p), (size), __FILE__, __LINE__)
+#define xcalloc(n, type) \
+    ((type *) x_calloc((n), sizeof(type), __FILE__, __LINE__))
+#define xmalloc(size)     ((char *) x_malloc((size), __FILE__, __LINE__))
 #define xstrdup(p)        x_strdup((p), __FILE__, __LINE__)
+#define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__)
+#define xreallocarray(p, n, type) \
+    ((type *) x_reallocarray((p), (n), sizeof(type), __FILE__, __LINE__))
+
+/*
+ * __attribute__ is available in gcc 2.5 and later, but only with gcc 2.7
+ * could you use the __format__ form of the attributes, which is what we use
+ * (to avoid confusion with other macros).
+ */
+#ifndef __attribute__
+#    if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#        define __attribute__(spec) /* empty */
+#    endif
+#endif
+
+/*
+ * We use __alloc_size__, but it was only available in fairly recent versions
+ * of GCC.  Suppress warnings about the unknown attribute if GCC is too old.
+ * We know that we're GCC at this point, so we can use the GCC variadic macro
+ * extension, which will still work with versions of GCC too old to have C99
+ * variadic macro support.
+ */
+#if !defined(__attribute__) && !defined(__alloc_size__)
+#    if defined(__GNUC__) && !defined(__clang__)
+#        if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+#            define __alloc_size__(spec, args...) /* empty */
+#        endif
+#    endif
+#endif
+
+/*
+ * LLVM and Clang pretend to be GCC but don't support all of the __attribute__
+ * settings that GCC does.  For them, suppress warnings about unknown
+ * attributes on declarations.  This unfortunately will affect the entire
+ * compilation context, but there's no push and pop available.
+ */
+#if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
+#    pragma GCC diagnostic ignored "-Wattributes"
+#endif
+
+/* Declare internal functions that benefit from compiler attributes. */
+static void die(const char *, ...)
+    __attribute__((__nonnull__, __noreturn__, __format__(printf, 1, 2)));
+static void sysdie(const char *, ...)
+    __attribute__((__nonnull__, __noreturn__, __format__(printf, 1, 2)));
+static void *x_calloc(size_t, size_t, const char *, int)
+    __attribute__((__alloc_size__(1, 2), __malloc__, __nonnull__));
+static void *x_malloc(size_t, const char *, int)
+    __attribute__((__alloc_size__(1), __malloc__, __nonnull__));
+static void *x_reallocarray(void *, size_t, size_t, const char *, int)
+    __attribute__((__alloc_size__(2, 3), __malloc__, __nonnull__(4)));
+static char *x_strdup(const char *, const char *, int)
+    __attribute__((__malloc__, __nonnull__));
+static char *x_strndup(const char *, size_t, const char *, int)
+    __attribute__((__malloc__, __nonnull__));
+
+
+/*
+ * Report a fatal error and exit.
+ */
+static void
+die(const char *format, ...)
+{
+    va_list args;
+
+    fflush(stdout);
+    fprintf(stderr, "runtests: ");
+    va_start(args, format);
+    vfprintf(stderr, format, args);
+    va_end(args);
+    fprintf(stderr, "\n");
+    exit(1);
+}
 
 
 /*
@@ -222,6 +337,24 @@ sysdie(const char *format, ...)
 }
 
 
+/*
+ * Allocate zeroed memory, reporting a fatal error and exiting on failure.
+ */
+static void *
+x_calloc(size_t n, size_t size, const char *file, int line)
+{
+    void *p;
+
+    n = (n > 0) ? n : 1;
+    size = (size > 0) ? size : 1;
+    p = calloc(n, size);
+    if (p == NULL)
+        sysdie("failed to calloc %lu bytes at %s line %d",
+               (unsigned long) size, file, line);
+    return p;
+}
+
+
 /*
  * Allocate memory, reporting a fatal error and exiting on failure.
  */
@@ -240,14 +373,29 @@ x_malloc(size_t size, const char *file, int line)
 
 /*
  * Reallocate memory, reporting a fatal error and exiting on failure.
+ *
+ * We should technically use SIZE_MAX here for the overflow check, but
+ * SIZE_MAX is C99 and we're only assuming C89 + SUSv3, which does not
+ * guarantee that it exists.  They do guarantee that UINT_MAX exists, and we
+ * can assume that UINT_MAX <= SIZE_MAX.  And we should not be allocating
+ * anything anywhere near that large.
+ *
+ * (In theory, C89 and C99 permit size_t to be smaller than unsigned int, but
+ * I disbelieve in the existence of such systems and they will have to cope
+ * without overflow checks.)
  */
 static void *
-x_realloc(void *p, size_t size, const char *file, int line)
+x_reallocarray(void *p, size_t n, size_t size, const char *file, int line)
 {
-    p = realloc(p, size);
+    n = (n > 0) ? n : 1;
+    size = (size > 0) ? size : 1;
+
+    if (n > 0 && UINT_MAX / n <= size)
+        sysdie("realloc too large at %s line %d", file, line);
+    p = realloc(p, n * size);
     if (p == NULL)
         sysdie("failed to realloc %lu bytes at %s line %d",
-               (unsigned long) size, file, line);
+               (unsigned long) (n * size), file, line);
     return p;
 }
 
@@ -262,15 +410,93 @@ x_strdup(const char *s, const char *file, int line)
     size_t len;
 
     len = strlen(s) + 1;
-    p = malloc(len);
+    p = (char *) malloc(len);
     if (p == NULL)
-        sysdie("failed to strdup %lu bytes at %s line %d",
-               (unsigned long) len, file, line);
+        sysdie("failed to strdup %lu bytes at %s line %d", (unsigned long) len,
+               file, line);
     memcpy(p, s, len);
     return p;
 }
 
 
+/*
+ * Copy the first n characters of a string, reporting a fatal error and
+ * existing on failure.
+ *
+ * Avoid using the system strndup function since it may not exist (on Mac OS
+ * X, for example), and there's no need to introduce another portability
+ * requirement.
+ */
+char *
+x_strndup(const char *s, size_t size, const char *file, int line)
+{
+    const char *p;
+    size_t len;
+    char *copy;
+
+    /* Don't assume that the source string is nul-terminated. */
+    for (p = s; (size_t)(p - s) < size && *p != '\0'; p++)
+        ;
+    len = (size_t)(p - s);
+    copy = (char *) malloc(len + 1);
+    if (copy == NULL)
+        sysdie("failed to strndup %lu bytes at %s line %d",
+               (unsigned long) len, file, line);
+    memcpy(copy, s, len);
+    copy[len] = '\0';
+    return copy;
+}
+
+
+/*
+ * Form a new string by concatenating multiple strings.  The arguments must be
+ * terminated by (const char *) 0.
+ *
+ * This function only exists because we can't assume asprintf.  We can't
+ * simulate asprintf with snprintf because we're only assuming SUSv3, which
+ * does not require that snprintf with a NULL buffer return the required
+ * length.  When those constraints are relaxed, this should be ripped out and
+ * replaced with asprintf or a more trivial replacement with snprintf.
+ */
+static char *
+concat(const char *first, ...)
+{
+    va_list args;
+    char *result;
+    const char *string;
+    size_t offset;
+    size_t length = 0;
+
+    /*
+     * Find the total memory required.  Ensure we don't overflow length.  We
+     * aren't guaranteed to have SIZE_MAX, so use UINT_MAX as an acceptable
+     * substitute (see the x_nrealloc comments).
+     */
+    va_start(args, first);
+    for (string = first; string != NULL; string = va_arg(args, const char *)) {
+        if (length >= UINT_MAX - strlen(string)) {
+            errno = EINVAL;
+            sysdie("strings too long in concat");
+        }
+        length += strlen(string);
+    }
+    va_end(args);
+    length++;
+
+    /* Create the string. */
+    result = xmalloc(length);
+    va_start(args, first);
+    offset = 0;
+    for (string = first; string != NULL; string = va_arg(args, const char *)) {
+        memcpy(result + offset, string, strlen(string));
+        offset += strlen(string);
+    }
+    va_end(args);
+    result[offset] = '\0';
+    return result;
+}
+
+
 /*
  * Given a struct timeval, return the number of seconds it represents as a
  * double.  Use difftime() to convert a time_t to a double.
@@ -278,7 +504,7 @@ x_strdup(const char *s, const char *file, int line)
 static double
 tv_seconds(const struct timeval *tv)
 {
-    return difftime(tv->tv_sec, 0) + tv->tv_usec * 1e-6;
+    return difftime(tv->tv_sec, 0) + (double) tv->tv_usec * 1e-6;
 }
 
 
@@ -309,7 +535,20 @@ tv_sum(const struct timeval *tv1, const struct timeval *tv2)
 static const char *
 skip_whitespace(const char *p)
 {
-    while (isspace((unsigned char)(*p)))
+    while (isspace((unsigned char) (*p)))
+        p++;
+    return p;
+}
+
+
+/*
+ * Given a pointer to a string, skip any non-whitespace characters and return
+ * a pointer to the first whitespace character, or to the end of the string.
+ */
+static const char *
+skip_non_whitespace(const char *p)
+{
+    while (*p != '\0' && !isspace((unsigned char) (*p)))
         p++;
     return p;
 }
@@ -321,38 +560,65 @@ skip_whitespace(const char *p)
  * argument.  Returns the PID of the new process.  Errors are fatal.
  */
 static pid_t
-test_start(const char *path, int *fd)
+test_start(char *const *command, int *fd)
 {
-    int fds[2], errfd;
+    int fds[2], infd, errfd;
     pid_t child;
 
+    /* Create a pipe used to capture the output from the test program. */
     if (pipe(fds) == -1) {
         puts("ABORTED");
         fflush(stdout);
         sysdie("can't create pipe");
     }
+
+    /* Fork a child process, massage the file descriptors, and exec. */
     child = fork();
-    if (child == (pid_t) -1) {
+    switch (child) {
+    case -1:
         puts("ABORTED");
         fflush(stdout);
         sysdie("can't fork");
-    } else if (child == 0) {
-        /* In child.  Set up our stdout and stderr. */
+
+    /* In the child.  Set up our standard output. */
+    case 0:
+        close(fds[0]);
+        close(STDOUT_FILENO);
+        if (dup2(fds[1], STDOUT_FILENO) < 0)
+            _exit(CHILDERR_DUP);
+        close(fds[1]);
+
+        /* Point standard input at /dev/null. */
+        close(STDIN_FILENO);
+        infd = open("/dev/null", O_RDONLY);
+        if (infd < 0)
+            _exit(CHILDERR_STDIN);
+        if (infd != STDIN_FILENO) {
+            if (dup2(infd, STDIN_FILENO) < 0)
+                _exit(CHILDERR_DUP);
+            close(infd);
+        }
+
+        /* Point standard error at /dev/null. */
+        close(STDERR_FILENO);
         errfd = open("/dev/null", O_WRONLY);
         if (errfd < 0)
             _exit(CHILDERR_STDERR);
-        if (dup2(errfd, 2) == -1)
-            _exit(CHILDERR_DUP);
-        close(fds[0]);
-        if (dup2(fds[1], 1) == -1)
-            _exit(CHILDERR_DUP);
+        if (errfd != STDERR_FILENO) {
+            if (dup2(errfd, STDERR_FILENO) < 0)
+                _exit(CHILDERR_DUP);
+            close(errfd);
+        }
 
         /* Now, exec our process. */
-        if (execl(path, path, (char *) 0) == -1)
+        if (execv(command[0], command) == -1)
             _exit(CHILDERR_EXEC);
-    } else {
-        /* In parent.  Close the extra file descriptor. */
+        break;
+
+    /* In parent.  Close the extra file descriptor. */
+    default:
         close(fds[1]);
+        break;
     }
     *fd = fds[0];
     return child;
@@ -379,6 +645,55 @@ test_backspace(struct testset *ts)
 }
 
 
+/*
+ * Allocate or resize the array of test results to be large enough to contain
+ * the test number in.
+ */
+static void
+resize_results(struct testset *ts, unsigned long n)
+{
+    unsigned long i;
+    size_t s;
+
+    /* If there's already enough space, return quickly. */
+    if (n <= ts->allocated)
+        return;
+
+    /*
+     * If no space has been allocated, do the initial allocation.  Otherwise,
+     * resize.  Start with 32 test cases and then add 1024 with each resize to
+     * try to reduce the number of reallocations.
+     */
+    if (ts->allocated == 0) {
+        s = (n > 32) ? n : 32;
+        ts->results = xcalloc(s, enum test_status);
+    } else {
+        s = (n > ts->allocated + 1024) ? n : ts->allocated + 1024;
+        ts->results = xreallocarray(ts->results, s, enum test_status);
+    }
+
+    /* Set the results for the newly-allocated test array. */
+    for (i = ts->allocated; i < s; i++)
+        ts->results[i] = TEST_INVALID;
+    ts->allocated = s;
+}
+
+
+/*
+ * Report an invalid test number and set the appropriate flags.  Pulled into a
+ * separate function since we do this in several places.
+ */
+static void
+invalid_test_number(struct testset *ts, long n, enum test_verbose verbose)
+{
+    if (!verbose)
+        test_backspace(ts);
+    printf("ABORTED (invalid test number %ld)\n", n);
+    ts->aborted = 1;
+    ts->reported = 1;
+}
+
+
 /*
  * Read the plan line of test output, which should contain the range of test
  * numbers.  We may initialize the testset structure here if we haven't yet
@@ -386,9 +701,8 @@ test_backspace(struct testset *ts)
  * continue, false otherwise.
  */
 static int
-test_plan(const char *line, struct testset *ts)
+test_plan(const char *line, struct testset *ts, enum test_verbose verbose)
 {
-    unsigned long i;
     long n;
 
     /*
@@ -401,12 +715,14 @@ test_plan(const char *line, struct testset *ts)
         line += 3;
 
     /*
-     * Get the count, check it for validity, and initialize the struct.  If we
-     * have something of the form "1..0 # skip foo", the whole file was
+     * Get the count and check it for validity.
+     *
+     * If we have something of the form "1..0 # skip foo", the whole file was
      * skipped; record that.  If we do skip the whole file, zero out all of
-     * our statistics, since they're no longer relevant.  strtol is called
-     * with a second argument to advance the line pointer past the count to
-     * make it simpler to detect the # skip case.
+     * our statistics, since they're no longer relevant.
+     *
+     * strtol is called with a second argument to advance the line pointer
+     * past the count to make it simpler to detect the # skip case.
      */
     n = strtol(line, (char **) &line, 10);
     if (n == 0) {
@@ -435,29 +751,27 @@ test_plan(const char *line, struct testset *ts)
         ts->reported = 1;
         return 0;
     }
-    if (ts->plan == PLAN_INIT && ts->allocated == 0) {
-        ts->count = n;
-        ts->allocated = n;
+
+    /*
+     * If we are doing lazy planning, check the plan against the largest test
+     * number that we saw and fail now if we saw a check outside the plan
+     * range.
+     */
+    if (ts->plan == PLAN_PENDING && (unsigned long) n < ts->count) {
+        invalid_test_number(ts, (long) ts->count, verbose);
+        return 0;
+    }
+
+    /*
+     * Otherwise, allocated or resize the results if needed and update count,
+     * and then record that we've seen a plan.
+     */
+    resize_results(ts, (unsigned long) n);
+    ts->count = (unsigned long) n;
+    if (ts->plan == PLAN_INIT)
         ts->plan = PLAN_FIRST;
-        ts->results = xmalloc(ts->count * sizeof(enum test_status));
-        for (i = 0; i < ts->count; i++)
-            ts->results[i] = TEST_INVALID;
-    } else if (ts->plan == PLAN_PENDING) {
-        if ((unsigned long) n < ts->count) {
-            printf("ABORTED (invalid test number %lu)\n", ts->count);
-            ts->aborted = 1;
-            ts->reported = 1;
-            return 0;
-        }
-        ts->count = n;
-        if ((unsigned long) n > ts->allocated) {
-            ts->results = xrealloc(ts->results, n * sizeof(enum test_status));
-            for (i = ts->allocated; i < ts->count; i++)
-                ts->results[i] = TEST_INVALID;
-            ts->allocated = n;
-        }
+    else if (ts->plan == PLAN_PENDING)
         ts->plan = PLAN_FINAL;
-    }
     return 1;
 }
 
@@ -469,13 +783,13 @@ test_plan(const char *line, struct testset *ts)
  * reported status.
  */
 static void
-test_checkline(const char *line, struct testset *ts)
+test_checkline(const char *line, struct testset *ts, enum test_verbose verbose)
 {
     enum test_status status = TEST_PASS;
     const char *bail;
     char *end;
     long number;
-    unsigned long i, current;
+    unsigned long current;
     int outlen;
 
     /* Before anything, check for a test abort. */
@@ -488,7 +802,8 @@ test_checkline(const char *line, struct testset *ts)
             length = strlen(bail);
             if (bail[length - 1] == '\n')
                 length--;
-            test_backspace(ts);
+            if (!verbose)
+                test_backspace(ts);
             printf("ABORTED (%.*s)\n", (int) length, bail);
             ts->reported = 1;
         }
@@ -508,14 +823,16 @@ test_checkline(const char *line, struct testset *ts)
         return;
 
     /* If we haven't yet seen a plan, look for one. */
-    if (ts->plan == PLAN_INIT && isdigit((unsigned char)(*line))) {
-        if (!test_plan(line, ts))
+    if (ts->plan == PLAN_INIT && isdigit((unsigned char) (*line))) {
+        if (!test_plan(line, ts, verbose))
             return;
     } else if (strncmp(line, "1..", 3) == 0) {
         if (ts->plan == PLAN_PENDING) {
-            if (!test_plan(line, ts))
+            if (!test_plan(line, ts, verbose))
                 return;
         } else {
+            if (!verbose)
+                test_backspace(ts);
             puts("ABORTED (multiple plans)");
             ts->aborted = 1;
             ts->reported = 1;
@@ -534,39 +851,30 @@ test_checkline(const char *line, struct testset *ts)
     errno = 0;
     number = strtol(line, &end, 10);
     if (errno != 0 || end == line)
-        number = ts->current + 1;
-    current = number;
-    if (number <= 0 || (current > ts->count && ts->plan == PLAN_FIRST)) {
-        test_backspace(ts);
-        printf("ABORTED (invalid test number %lu)\n", current);
-        ts->aborted = 1;
-        ts->reported = 1;
+        current = ts->current + 1;
+    else if (number <= 0) {
+        invalid_test_number(ts, number, verbose);
+        return;
+    } else
+        current = (unsigned long) number;
+    if (current > ts->count && ts->plan == PLAN_FIRST) {
+        invalid_test_number(ts, (long) current, verbose);
         return;
     }
 
     /* We have a valid test result.  Tweak the results array if needed. */
     if (ts->plan == PLAN_INIT || ts->plan == PLAN_PENDING) {
         ts->plan = PLAN_PENDING;
+        resize_results(ts, current);
         if (current > ts->count)
             ts->count = current;
-        if (current > ts->allocated) {
-            unsigned long n;
-
-            n = (ts->allocated == 0) ? 32 : ts->allocated * 2;
-            if (n < current)
-                n = current;
-            ts->results = xrealloc(ts->results, n * sizeof(enum test_status));
-            for (i = ts->allocated; i < n; i++)
-                ts->results[i] = TEST_INVALID;
-            ts->allocated = n;
-        }
     }
 
     /*
      * Handle directives.  We should probably do something more interesting
      * with unexpected passes of todo tests.
      */
-    while (isdigit((unsigned char)(*line)))
+    while (isdigit((unsigned char) (*line)))
         line++;
     line = skip_whitespace(line);
     if (*line == '#') {
@@ -579,7 +887,8 @@ test_checkline(const char *line, struct testset *ts)
 
     /* Make sure that the test number is in range and not a duplicate. */
     if (ts->results[current - 1] != TEST_INVALID) {
-        test_backspace(ts);
+        if (!verbose)
+            test_backspace(ts);
         printf("ABORTED (duplicate test number %lu)\n", current);
         ts->aborted = 1;
         ts->reported = 1;
@@ -588,17 +897,27 @@ test_checkline(const char *line, struct testset *ts)
 
     /* Good results.  Increment our various counters. */
     switch (status) {
-        case TEST_PASS: ts->passed++;   break;
-        case TEST_FAIL: ts->failed++;   break;
-        case TEST_SKIP: ts->skipped++;  break;
-        case TEST_INVALID:              break;
+    case TEST_PASS:
+        ts->passed++;
+        break;
+    case TEST_FAIL:
+        ts->failed++;
+        break;
+    case TEST_SKIP:
+        ts->skipped++;
+        break;
+    case TEST_INVALID:
+        break;
     }
     ts->current = current;
     ts->results[current - 1] = status;
-    test_backspace(ts);
-    if (isatty(STDOUT_FILENO)) {
-        outlen = printf("%lu/%lu", current, ts->count);
-        ts->length = (outlen >= 0) ? outlen : 0;
+    if (!verbose && isatty(STDOUT_FILENO)) {
+        test_backspace(ts);
+        if (ts->plan == PLAN_PENDING)
+            outlen = printf("%lu/?", current);
+        else
+            outlen = printf("%lu/%lu", current, ts->count);
+        ts->length = (outlen >= 0) ? (unsigned int) outlen : 0;
         fflush(stdout);
     }
 }
@@ -614,7 +933,7 @@ test_checkline(const char *line, struct testset *ts)
  * disable this).
  */
 static unsigned int
-test_print_range(unsigned long first, unsigned long last, unsigned int chars,
+test_print_range(unsigned long first, unsigned long last, unsigned long chars,
                  unsigned int limit)
 {
     unsigned int needed = 0;
@@ -754,6 +1073,7 @@ test_analyze(struct testset *ts)
             if (!ts->reported)
                 puts("ABORTED (execution failed -- not found?)");
             break;
+        case CHILDERR_STDIN:
         case CHILDERR_STDERR:
             if (!ts->reported)
                 puts("ABORTED (can't open /dev/null)");
@@ -783,7 +1103,7 @@ test_analyze(struct testset *ts)
  * false otherwise.
  */
 static int
-test_run(struct testset *ts)
+test_run(struct testset *ts, enum test_verbose verbose)
 {
     pid_t testpid, child;
     int outfd, status;
@@ -792,7 +1112,7 @@ test_run(struct testset *ts)
     char buffer[BUFSIZ];
 
     /* Run the test program. */
-    testpid = test_start(ts->path, &outfd);
+    testpid = test_start(ts->command, &outfd);
     output = fdopen(outfd, "r");
     if (!output) {
         puts("ABORTED");
@@ -800,12 +1120,19 @@ test_run(struct testset *ts)
         sysdie("fdopen failed");
     }
 
-    /* Pass each line of output to test_checkline(). */
-    while (!ts->aborted && fgets(buffer, sizeof(buffer), output))
-        test_checkline(buffer, ts);
+    /*
+     * Pass each line of output to test_checkline(), and print the line if
+     * verbosity is requested.
+     */
+    while (!ts->aborted && fgets(buffer, sizeof(buffer), output)) {
+        if (verbose)
+            printf("%s", buffer);
+        test_checkline(buffer, ts, verbose);
+    }
     if (ferror(output) || ts->plan == PLAN_INIT)
         ts->aborted = 1;
-    test_backspace(ts);
+    if (!verbose)
+        test_backspace(ts);
 
     /*
      * Consume the rest of the test output, close the output descriptor,
@@ -813,7 +1140,8 @@ test_run(struct testset *ts)
      * for eventual output.
      */
     while (fgets(buffer, sizeof(buffer), output))
-        ;
+        if (verbose)
+            printf("%s", buffer);
     fclose(output);
     child = waitpid(testpid, &ts->status, 0);
     if (child == (pid_t) -1) {
@@ -846,6 +1174,7 @@ test_fail_summary(const struct testlist *fails)
     struct testset *ts;
     unsigned int chars;
     unsigned long i, first, last, total;
+    double failed;
 
     puts(header);
 
@@ -854,8 +1183,9 @@ test_fail_summary(const struct testlist *fails)
     for (; fails; fails = fails->next) {
         ts = fails->ts;
         total = ts->count - ts->skipped;
+        failed = (double) ts->failed;
         printf("%-26.26s %4lu/%-4lu %3.0f%% %4lu ", ts->file, ts->failed,
-               total, total ? (ts->failed * 100.0) / total : 0,
+               total, total ? (failed * 100.0) / (double) total : 0,
                ts->skipped);
         if (WIFEXITED(ts->status))
             printf("%4d  ", WEXITSTATUS(ts->status));
@@ -883,109 +1213,325 @@ test_fail_summary(const struct testlist *fails)
         if (first != 0)
             test_print_range(first, last, chars, 19);
         putchar('\n');
-        free(ts->file);
-        free(ts->path);
-        free(ts->results);
-        if (ts->reason != NULL)
-            free(ts->reason);
-        free(ts);
     }
 }
 
 
+/*
+ * Check whether a given file path is a valid test.  Currently, this checks
+ * whether it is executable and is a regular file.  Returns true or false.
+ */
+static int
+is_valid_test(const char *path)
+{
+    struct stat st;
+
+    if (access(path, X_OK) < 0)
+        return 0;
+    if (stat(path, &st) < 0)
+        return 0;
+    if (!S_ISREG(st.st_mode))
+        return 0;
+    return 1;
+}
+
+
 /*
  * Given the name of a test, a pointer to the testset struct, and the source
  * and build directories, find the test.  We try first relative to the current
  * directory, then in the build directory (if not NULL), then in the source
  * directory.  In each of those directories, we first try a "-t" extension and
- * then a ".t" extension.  When we find an executable program, we fill in the
- * path member of the testset struct.  If none of those paths are executable,
- * just fill in the name of the test with "-t" appended.
+ * then a ".t" extension.  When we find an executable program, we return the
+ * path to that program.  If none of those paths are executable, just fill in
+ * the name of the test as is.
  *
  * The caller is responsible for freeing the path member of the testset
  * struct.
  */
-static void
-find_test(const char *name, struct testset *ts, const char *source,
-          const char *build)
+static char *
+find_test(const char *name, const char *source, const char *build)
 {
-    char *path;
-    const char *bases[4];
-    unsigned int i;
+    char *path = NULL;
+    const char *bases[3], *suffix, *base;
+    unsigned int i, j;
+    const char *suffixes[3] = {"-t", ".t", ""};
 
+    /* Possible base directories. */
     bases[0] = ".";
     bases[1] = build;
     bases[2] = source;
-    bases[3] = NULL;
 
-    for (i = 0; i < 3; i++) {
-        if (bases[i] == NULL)
+    /* Try each suffix with each base. */
+    for (i = 0; i < ARRAY_SIZE(suffixes); i++) {
+        suffix = suffixes[i];
+        for (j = 0; j < ARRAY_SIZE(bases); j++) {
+            base = bases[j];
+            if (base == NULL)
+                continue;
+            path = concat(base, "/", name, suffix, (const char *) 0);
+            if (is_valid_test(path))
+                return path;
+            free(path);
+            path = NULL;
+        }
+    }
+    if (path == NULL)
+        path = xstrdup(name);
+    return path;
+}
+
+
+/*
+ * Parse a single line of a test list and store the test name and command to
+ * execute it in the given testset struct.
+ *
+ * Normally, each line is just the name of the test, which is located in the
+ * test directory and turned into a command to run.  However, each line may
+ * have whitespace-separated options, which change the command that's run.
+ * Current supported options are:
+ *
+ * valgrind
+ *     Run the test under valgrind if C_TAP_VALGRIND is set.  The contents
+ *     of that environment variable are taken as the valgrind command (with
+ *     options) to run.  The command is parsed with a simple split on
+ *     whitespace and no quoting is supported.
+ *
+ * libtool
+ *     If running under valgrind, use libtool to invoke valgrind.  This avoids
+ *     running valgrind on the wrapper shell script generated by libtool.  If
+ *     set, C_TAP_LIBTOOL must be set to the full path to the libtool program
+ *     to use to run valgrind and thus the test.  Ignored if the test isn't
+ *     being run under valgrind.
+ */
+static void
+parse_test_list_line(const char *line, struct testset *ts, const char *source,
+                     const char *build)
+{
+    const char *p, *end, *option, *libtool;
+    const char *valgrind = NULL;
+    unsigned int use_libtool = 0;
+    unsigned int use_valgrind = 0;
+    size_t len, i;
+
+    /* Determine the name of the test. */
+    p = skip_non_whitespace(line);
+    ts->file = xstrndup(line, p - line);
+
+    /* Check if any test options are set. */
+    p = skip_whitespace(p);
+    while (*p != '\0') {
+        end = skip_non_whitespace(p);
+        if (strncmp(p, "libtool", end - p) == 0) {
+            use_libtool = 1;
+        } else if (strncmp(p, "valgrind", end - p) == 0) {
+            valgrind = getenv("C_TAP_VALGRIND");
+            use_valgrind = (valgrind != NULL);
+        } else {
+            option = xstrndup(p, end - p);
+            die("unknown test list option %s", option);
+        }
+        p = skip_whitespace(end);
+    }
+
+    /* Construct the argv to run the test.  First, find the length. */
+    len = 1;
+    if (use_valgrind && valgrind != NULL) {
+        p = skip_whitespace(valgrind);
+        while (*p != '\0') {
+            len++;
+            p = skip_whitespace(skip_non_whitespace(p));
+        }
+        if (use_libtool)
+            len += 2;
+    }
+
+    /* Now, build the command. */
+    ts->command = xcalloc(len + 1, char *);
+    i = 0;
+    if (use_valgrind && valgrind != NULL) {
+        if (use_libtool) {
+            libtool = getenv("C_TAP_LIBTOOL");
+            if (libtool == NULL)
+                die("valgrind with libtool requested, but C_TAP_LIBTOOL is not"
+                    " set");
+            ts->command[i++] = xstrdup(libtool);
+            ts->command[i++] = xstrdup("--mode=execute");
+        }
+        p = skip_whitespace(valgrind);
+        while (*p != '\0') {
+            end = skip_non_whitespace(p);
+            ts->command[i++] = xstrndup(p, end - p);
+            p = skip_whitespace(end);
+        }
+    }
+    if (i != len - 1)
+        die("internal error while constructing command line");
+    ts->command[i++] = find_test(ts->file, source, build);
+    ts->command[i] = NULL;
+}
+
+
+/*
+ * Read a list of tests from a file, returning the list of tests as a struct
+ * testlist, or NULL if there were no tests (such as a file containing only
+ * comments).  Reports an error to standard error and exits if the list of
+ * tests cannot be read.
+ */
+static struct testlist *
+read_test_list(const char *filename, const char *source, const char *build)
+{
+    FILE *file;
+    unsigned int line;
+    size_t length;
+    char buffer[BUFSIZ];
+    const char *start;
+    struct testlist *listhead, *current;
+
+    /* Create the initial container list that will hold our results. */
+    listhead = xcalloc(1, struct testlist);
+    current = NULL;
+
+    /*
+     * Open our file of tests to run and read it line by line, creating a new
+     * struct testlist and struct testset for each line.
+     */
+    file = fopen(filename, "r");
+    if (file == NULL)
+        sysdie("can't open %s", filename);
+    line = 0;
+    while (fgets(buffer, sizeof(buffer), file)) {
+        line++;
+        length = strlen(buffer) - 1;
+        if (buffer[length] != '\n') {
+            fprintf(stderr, "%s:%u: line too long\n", filename, line);
+            exit(1);
+        }
+        buffer[length] = '\0';
+
+        /* Skip comments, leading spaces, and blank lines. */
+        start = skip_whitespace(buffer);
+        if (strlen(start) == 0)
             continue;
-        path = xmalloc(strlen(bases[i]) + strlen(name) + 4);
-        sprintf(path, "%s/%s-t", bases[i], name);
-        if (access(path, X_OK) != 0)
-            path[strlen(path) - 2] = '.';
-        if (access(path, X_OK) == 0)
-            break;
-        free(path);
-        path = NULL;
+        if (start[0] == '#')
+            continue;
+
+        /* Allocate the new testset structure. */
+        if (current == NULL)
+            current = listhead;
+        else {
+            current->next = xcalloc(1, struct testlist);
+            current = current->next;
+        }
+        current->ts = xcalloc(1, struct testset);
+        current->ts->plan = PLAN_INIT;
+
+        /* Parse the line and store the results in the testset struct. */
+        parse_test_list_line(start, current->ts, source, build);
     }
-    if (path == NULL) {
-        path = xmalloc(strlen(name) + 3);
-        sprintf(path, "%s-t", name);
+    fclose(file);
+
+    /* If there were no tests, current is still NULL. */
+    if (current == NULL) {
+        free(listhead);
+        return NULL;
     }
-    ts->path = path;
+
+    /* Return the results. */
+    return listhead;
 }
 
 
 /*
- * Run a batch of tests from a given file listing each test on a line by
- * itself.  Takes two additional parameters: the root of the source directory
- * and the root of the build directory.  Test programs will be first searched
- * for in the current directory, then the build directory, then the source
- * directory.  The file must be rewindable.  Returns true iff all tests
- * passed.
+ * Build a list of tests from command line arguments.  Takes the argv and argc
+ * representing the command line arguments and returns a newly allocated test
+ * list, or NULL if there were no tests.  The caller is responsible for
+ * freeing.
+ */
+static struct testlist *
+build_test_list(char *argv[], int argc, const char *source, const char *build)
+{
+    int i;
+    struct testlist *listhead, *current;
+
+    /* Create the initial container list that will hold our results. */
+    listhead = xcalloc(1, struct testlist);
+    current = NULL;
+
+    /* Walk the list of arguments and create test sets for them. */
+    for (i = 0; i < argc; i++) {
+        if (current == NULL)
+            current = listhead;
+        else {
+            current->next = xcalloc(1, struct testlist);
+            current = current->next;
+        }
+        current->ts = xcalloc(1, struct testset);
+        current->ts->plan = PLAN_INIT;
+        current->ts->file = xstrdup(argv[i]);
+        current->ts->command = xcalloc(2, char *);
+        current->ts->command[0] = find_test(current->ts->file, source, build);
+        current->ts->command[1] = NULL;
+    }
+
+    /* If there were no tests, current is still NULL. */
+    if (current == NULL) {
+        free(listhead);
+        return NULL;
+    }
+
+    /* Return the results. */
+    return listhead;
+}
+
+
+/* Free a struct testset. */
+static void
+free_testset(struct testset *ts)
+{
+    size_t i;
+
+    free(ts->file);
+    for (i = 0; ts->command[i] != NULL; i++)
+        free(ts->command[i]);
+    free(ts->command);
+    free(ts->results);
+    free(ts->reason);
+    free(ts);
+}
+
+
+/*
+ * Run a batch of tests.  Takes two additional parameters: the root of the
+ * source directory and the root of the build directory.  Test programs will
+ * be first searched for in the current directory, then the build directory,
+ * then the source directory.  Returns true iff all tests passed, and always
+ * frees the test list that's passed in.
  */
 static int
-test_batch(const char *testlist, const char *source, const char *build)
+test_batch(struct testlist *tests, enum test_verbose verbose)
 {
-    FILE *tests;
-    unsigned int length, i;
-    unsigned int longest = 0;
-    char buffer[BUFSIZ];
-    unsigned int line;
-    struct testset ts, *tmp;
+    size_t length, i;
+    size_t longest = 0;
+    unsigned int count = 0;
+    struct testset *ts;
     struct timeval start, end;
     struct rusage stats;
     struct testlist *failhead = NULL;
     struct testlist *failtail = NULL;
-    struct testlist *next;
+    struct testlist *current, *next;
+    int succeeded;
     unsigned long total = 0;
     unsigned long passed = 0;
     unsigned long skipped = 0;
     unsigned long failed = 0;
     unsigned long aborted = 0;
 
-    /*
-     * Open our file of tests to run and scan it, checking for lines that
-     * are too long and searching for the longest line.
-     */
-    tests = fopen(testlist, "r");
-    if (!tests)
-        sysdie("can't open %s", testlist);
-    line = 0;
-    while (fgets(buffer, sizeof(buffer), tests)) {
-        line++;
-        length = strlen(buffer) - 1;
-        if (buffer[length] != '\n') {
-            fprintf(stderr, "%s:%u: line too long\n", testlist, line);
-            exit(1);
-        }
+    /* Walk the list of tests to find the longest name. */
+    for (current = tests; current != NULL; current = current->next) {
+        length = strlen(current->ts->file);
         if (length > longest)
             longest = length;
     }
-    if (fseek(tests, 0, SEEK_SET) == -1)
-        sysdie("can't rewind %s", testlist);
 
     /*
      * Add two to longest and round up to the nearest tab stop.  This is how
@@ -998,64 +1544,54 @@ test_batch(const char *testlist, const char *source, const char *build)
     /* Start the wall clock timer. */
     gettimeofday(&start, NULL);
 
-    /*
-     * Now, plow through our tests again, running each one.  Check line
-     * length again out of paranoia.
-     */
-    line = 0;
-    while (fgets(buffer, sizeof(buffer), tests)) {
-        line++;
-        length = strlen(buffer) - 1;
-        if (buffer[length] != '\n') {
-            fprintf(stderr, "%s:%u: line too long\n", testlist, line);
-            exit(1);
-        }
-        buffer[length] = '\0';
-        fputs(buffer, stdout);
-        for (i = length; i < longest; i++)
-            putchar('.');
+    /* Now, plow through our tests again, running each one. */
+    for (current = tests; current != NULL; current = current->next) {
+        ts = current->ts;
+
+        /* Print out the name of the test file. */
+        fputs(ts->file, stdout);
+        if (verbose)
+            fputs("\n\n", stdout);
+        else
+            for (i = strlen(ts->file); i < longest; i++)
+                putchar('.');
         if (isatty(STDOUT_FILENO))
             fflush(stdout);
-        memset(&ts, 0, sizeof(ts));
-        ts.plan = PLAN_INIT;
-        ts.file = xstrdup(buffer);
-        find_test(buffer, &ts, source, build);
-        ts.reason = NULL;
-        if (test_run(&ts)) {
-            free(ts.file);
-            free(ts.path);
-            free(ts.results);
-            if (ts.reason != NULL)
-                free(ts.reason);
-        } else {
-            tmp = xmalloc(sizeof(struct testset));
-            memcpy(tmp, &ts, sizeof(struct testset));
-            if (!failhead) {
-                failhead = xmalloc(sizeof(struct testset));
-                failhead->ts = tmp;
-                failhead->next = NULL;
+
+        /* Run the test. */
+        succeeded = test_run(ts, verbose);
+        fflush(stdout);
+        if (verbose)
+            putchar('\n');
+
+        /* Record cumulative statistics. */
+        aborted += ts->aborted;
+        total += ts->count + ts->all_skipped;
+        passed += ts->passed;
+        skipped += ts->skipped + ts->all_skipped;
+        failed += ts->failed;
+        count++;
+
+        /* If the test fails, we shuffle it over to the fail list. */
+        if (!succeeded) {
+            if (failhead == NULL) {
+                failhead = xcalloc(1, struct testlist);
                 failtail = failhead;
             } else {
-                failtail->next = xmalloc(sizeof(struct testset));
+                failtail->next = xcalloc(1, struct testlist);
                 failtail = failtail->next;
-                failtail->ts = tmp;
-                failtail->next = NULL;
             }
+            failtail->ts = ts;
+            failtail->next = NULL;
         }
-        aborted += ts.aborted;
-        total += ts.count + ts.all_skipped;
-        passed += ts.passed;
-        skipped += ts.skipped + ts.all_skipped;
-        failed += ts.failed;
     }
     total -= skipped;
-    fclose(tests);
 
     /* Stop the timer and get our child resource statistics. */
     gettimeofday(&end, NULL);
     getrusage(RUSAGE_CHILDREN, &stats);
 
-    /* Print out our final results. */
+    /* Summarize the failures and free the failure list. */
     if (failhead != NULL) {
         test_fail_summary(failhead);
         while (failhead != NULL) {
@@ -1064,6 +1600,16 @@ test_batch(const char *testlist, const char *source, const char *build)
             failhead = next;
         }
     }
+
+    /* Free the memory used by the test lists. */
+    while (tests != NULL) {
+        next = tests->next;
+        free_testset(tests->ts);
+        free(tests);
+        tests = next;
+    }
+
+    /* Print out the final test summary. */
     putchar('\n');
     if (aborted != 0) {
         if (aborted == 1)
@@ -1071,12 +1617,11 @@ test_batch(const char *testlist, const char *source, const char *build)
         else
             printf("Aborted %lu test sets", aborted);
         printf(", passed %lu/%lu tests", passed, total);
-    }
-    else if (failed == 0)
+    } else if (failed == 0)
         fputs("All tests successful", stdout);
     else
         printf("Failed %lu/%lu tests, %.2f%% okay", failed, total,
-               (total - failed) * 100.0 / total);
+               (double) (total - failed) * 100.0 / (double) total);
     if (skipped != 0) {
         if (skipped == 1)
             printf(", %lu test skipped", skipped);
@@ -1084,10 +1629,10 @@ test_batch(const char *testlist, const char *source, const char *build)
             printf(", %lu tests skipped", skipped);
     }
     puts(".");
-    printf("Files=%u,  Tests=%lu", line, total);
+    printf("Files=%u,  Tests=%lu", count, total);
     printf(",  %.2f seconds", tv_diff(&end, &start));
-    printf(" (%.2f usr + %.2f sys = %.2f CPU)\n",
-           tv_seconds(&stats.ru_utime), tv_seconds(&stats.ru_stime),
+    printf(" (%.2f usr + %.2f sys = %.2f CPU)\n", tv_seconds(&stats.ru_utime),
+           tv_seconds(&stats.ru_stime),
            tv_sum(&stats.ru_utime, &stats.ru_stime));
     return (failed == 0 && aborted == 0);
 }
@@ -1100,18 +1645,18 @@ test_batch(const char *testlist, const char *source, const char *build)
 static void
 test_single(const char *program, const char *source, const char *build)
 {
-    struct testset ts;
+    char *path;
 
-    memset(&ts, 0, sizeof(ts));
-    find_test(program, &ts, source, build);
-    if (execl(ts.path, ts.path, (char *) 0) == -1)
-        sysdie("cannot exec %s", ts.path);
+    path = find_test(program, source, build);
+    if (execl(path, path, (char *) 0) == -1)
+        sysdie("cannot exec %s", path);
 }
 
 
 /*
- * Main routine.  Set the SOURCE and BUILD environment variables and then,
- * given a file listing tests, run each test listed.
+ * Main routine.  Set the C_TAP_SOURCE, C_TAP_BUILD, SOURCE, and BUILD
+ * environment variables and then, given a file listing tests, run each test
+ * listed.
  */
 int
 main(int argc, char *argv[])
@@ -1119,20 +1664,29 @@ main(int argc, char *argv[])
     int option;
     int status = 0;
     int single = 0;
+    enum test_verbose verbose = CONCISE;
+    char *c_tap_source_env = NULL;
+    char *c_tap_build_env = NULL;
     char *source_env = NULL;
     char *build_env = NULL;
-    const char *list;
-    const char *source = SOURCE;
-    const char *build = BUILD;
-
-    while ((option = getopt(argc, argv, "b:hos:")) != EOF) {
+    const char *program;
+    const char *shortlist;
+    const char *list = NULL;
+    const char *source = C_TAP_SOURCE;
+    const char *build = C_TAP_BUILD;
+    struct testlist *tests;
+
+    program = argv[0];
+    while ((option = getopt(argc, argv, "b:hl:os:v")) != EOF) {
         switch (option) {
         case 'b':
             build = optarg;
             break;
         case 'h':
-            printf(usage_message, argv[0], argv[0]);
+            printf(usage_message, program, program, program, usage_extra);
             exit(0);
+        case 'l':
+            list = optarg;
             break;
         case 'o':
             single = 1;
@@ -1140,49 +1694,77 @@ main(int argc, char *argv[])
         case 's':
             source = optarg;
             break;
+        case 'v':
+            verbose = VERBOSE;
+            break;
         default:
             exit(1);
         }
     }
-    if (argc - optind != 1) {
-        fprintf(stderr, usage_message, argv[0], argv[0]);
+    argv += optind;
+    argc -= optind;
+    if ((list == NULL && argc < 1) || (list != NULL && argc > 0)) {
+        fprintf(stderr, usage_message, program, program, program, usage_extra);
         exit(1);
     }
-    argc -= optind;
-    argv += optind;
 
+    /*
+     * If C_TAP_VERBOSE is set in the environment, that also turns on verbose
+     * mode.
+     */
+    if (getenv("C_TAP_VERBOSE") != NULL)
+        verbose = VERBOSE;
+
+    /*
+     * Set C_TAP_SOURCE and C_TAP_BUILD environment variables.  Also set
+     * SOURCE and BUILD for backward compatibility, although we're trying to
+     * migrate to the ones with a C_TAP_* prefix.
+     */
     if (source != NULL) {
-        source_env = xmalloc(strlen("SOURCE=") + strlen(source) + 1);
-        sprintf(source_env, "SOURCE=%s", source);
+        c_tap_source_env = concat("C_TAP_SOURCE=", source, (const char *) 0);
+        if (putenv(c_tap_source_env) != 0)
+            sysdie("cannot set C_TAP_SOURCE in the environment");
+        source_env = concat("SOURCE=", source, (const char *) 0);
         if (putenv(source_env) != 0)
             sysdie("cannot set SOURCE in the environment");
     }
     if (build != NULL) {
-        build_env = xmalloc(strlen("BUILD=") + strlen(build) + 1);
-        sprintf(build_env, "BUILD=%s", build);
+        c_tap_build_env = concat("C_TAP_BUILD=", build, (const char *) 0);
+        if (putenv(c_tap_build_env) != 0)
+            sysdie("cannot set C_TAP_BUILD in the environment");
+        build_env = concat("BUILD=", build, (const char *) 0);
         if (putenv(build_env) != 0)
             sysdie("cannot set BUILD in the environment");
     }
 
+    /* Run the tests as instructed. */
     if (single)
         test_single(argv[0], source, build);
-    else {
-        list = strrchr(argv[0], '/');
-        if (list == NULL)
-            list = argv[0];
+    else if (list != NULL) {
+        shortlist = strrchr(list, '/');
+        if (shortlist == NULL)
+            shortlist = list;
         else
-            list++;
-        printf(banner, list);
-        status = test_batch(argv[0], source, build) ? 0 : 1;
+            shortlist++;
+        printf(banner, shortlist);
+        tests = read_test_list(list, source, build);
+        status = test_batch(tests, verbose) ? 0 : 1;
+    } else {
+        tests = build_test_list(argv, argc, source, build);
+        status = test_batch(tests, verbose) ? 0 : 1;
     }
 
-    /* For valgrind cleanliness. */
+    /* For valgrind cleanliness, free all our memory. */
     if (source_env != NULL) {
+        putenv((char *) "C_TAP_SOURCE=");
         putenv((char *) "SOURCE=");
+        free(c_tap_source_env);
         free(source_env);
     }
     if (build_env != NULL) {
+        putenv((char *) "C_TAP_BUILD=");
         putenv((char *) "BUILD=");
+        free(c_tap_build_env);
         free(build_env);
     }
     exit(status);
diff --git a/src/external/c-tap-harness/tests/tap/basic.c b/src/external/c-tap-harness/tests/tap/basic.c
index e8196fc87..b5f42d021 100644
--- a/src/external/c-tap-harness/tests/tap/basic.c
+++ b/src/external/c-tap-harness/tests/tap/basic.c
@@ -10,10 +10,11 @@
  * up the TAP output format, or finding things in the test environment.
  *
  * This file is part of C TAP Harness.  The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012 Russ Allbery <rra@stanford.edu>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2019 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -33,17 +34,20 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
  */
 
 #include <errno.h>
+#include <limits.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #ifdef _WIN32
-# include <direct.h>
+#    include <direct.h>
 #else
-# include <sys/stat.h>
+#    include <sys/stat.h>
 #endif
 #include <sys/types.h>
 #include <unistd.h>
@@ -52,13 +56,13 @@
 
 /* Windows provides mkdir and rmdir under different names. */
 #ifdef _WIN32
-# define mkdir(p, m) _mkdir(p)
-# define rmdir(p)    _rmdir(p)
+#    define mkdir(p, m) _mkdir(p)
+#    define rmdir(p)    _rmdir(p)
 #endif
 
 /*
  * The test count.  Always contains the number that will be used for the next
- * test status.
+ * test status.  This is exported to callers of the library.
  */
 unsigned long testnum = 1;
 
@@ -66,72 +70,324 @@ unsigned long testnum = 1;
  * Status information stored so that we can give a test summary at the end of
  * the test case.  We store the planned final test and the count of failures.
  * We can get the highest test count from testnum.
- *
- * We also store the PID of the process that called plan() and only summarize
+ */
+static unsigned long _planned = 0;
+static unsigned long _failed = 0;
+
+/*
+ * Store the PID of the process that called plan() and only summarize
  * results when that process exits, so as to not misreport results in forked
  * processes.
- *
- * If _lazy is true, we're doing lazy planning and will print out the plan
- * based on the last test number at the end of testing.
  */
-static unsigned long _planned = 0;
-static unsigned long _failed  = 0;
 static pid_t _process = 0;
+
+/*
+ * If true, we're doing lazy planning and will print out the plan based on the
+ * last test number at the end of testing.
+ */
 static int _lazy = 0;
 
+/*
+ * If true, the test was aborted by calling bail().  Currently, this is only
+ * used to ensure that we pass a false value to any cleanup functions even if
+ * all tests to that point have passed.
+ */
+static int _aborted = 0;
+
+/*
+ * Registered cleanup functions.  These are stored as a linked list and run in
+ * registered order by finish when the test program exits.  Each function is
+ * passed a boolean value indicating whether all tests were successful.
+ */
+struct cleanup_func {
+    test_cleanup_func func;
+    test_cleanup_func_with_data func_with_data;
+    void *data;
+    struct cleanup_func *next;
+};
+static struct cleanup_func *cleanup_funcs = NULL;
+
+/*
+ * Registered diag files.  Any output found in these files will be printed out
+ * as if it were passed to diag() before any other output we do.  This allows
+ * background processes to log to a file and have that output interleaved with
+ * the test output.
+ */
+struct diag_file {
+    char *name;
+    FILE *file;
+    char *buffer;
+    size_t bufsize;
+    struct diag_file *next;
+};
+static struct diag_file *diag_files = NULL;
+
+/*
+ * Print a specified prefix and then the test description.  Handles turning
+ * the argument list into a va_args structure suitable for passing to
+ * print_desc, which has to be done in a macro.  Assumes that format is the
+ * argument immediately before the variadic arguments.
+ */
+#define PRINT_DESC(prefix, format)  \
+    do {                            \
+        if (format != NULL) {       \
+            va_list args;           \
+            printf("%s", prefix);   \
+            va_start(args, format); \
+            vprintf(format, args);  \
+            va_end(args);           \
+        }                           \
+    } while (0)
+
+
+/*
+ * Form a new string by concatenating multiple strings.  The arguments must be
+ * terminated by (const char *) 0.
+ *
+ * This function only exists because we can't assume asprintf.  We can't
+ * simulate asprintf with snprintf because we're only assuming SUSv3, which
+ * does not require that snprintf with a NULL buffer return the required
+ * length.  When those constraints are relaxed, this should be ripped out and
+ * replaced with asprintf or a more trivial replacement with snprintf.
+ */
+static char *
+concat(const char *first, ...)
+{
+    va_list args;
+    char *result;
+    const char *string;
+    size_t offset;
+    size_t length = 0;
+
+    /*
+     * Find the total memory required.  Ensure we don't overflow length.  See
+     * the comment for breallocarray for why we're using UINT_MAX here.
+     */
+    va_start(args, first);
+    for (string = first; string != NULL; string = va_arg(args, const char *)) {
+        if (length >= UINT_MAX - strlen(string))
+            bail("strings too long in concat");
+        length += strlen(string);
+    }
+    va_end(args);
+    length++;
+
+    /* Create the string. */
+    result = bcalloc_type(length, char);
+    va_start(args, first);
+    offset = 0;
+    for (string = first; string != NULL; string = va_arg(args, const char *)) {
+        memcpy(result + offset, string, strlen(string));
+        offset += strlen(string);
+    }
+    va_end(args);
+    result[offset] = '\0';
+    return result;
+}
+
+
+/*
+ * Helper function for check_diag_files to handle a single line in a diag
+ * file.
+ *
+ * The general scheme here used is as follows: read one line of output.  If we
+ * get NULL, check for an error.  If there was one, bail out of the test
+ * program; otherwise, return, and the enclosing loop will check for EOF.
+ *
+ * If we get some data, see if it ends in a newline.  If it doesn't end in a
+ * newline, we have one of two cases: our buffer isn't large enough, in which
+ * case we resize it and try again, or we have incomplete data in the file, in
+ * which case we rewind the file and will try again next time.
+ *
+ * Returns a boolean indicating whether the last line was incomplete.
+ */
+static int
+handle_diag_file_line(struct diag_file *file, fpos_t where)
+{
+    int size;
+    size_t length;
+
+    /* Read the next line from the file. */
+    size = file->bufsize > INT_MAX ? INT_MAX : (int) file->bufsize;
+    if (fgets(file->buffer, size, file->file) == NULL) {
+        if (ferror(file->file))
+            sysbail("cannot read from %s", file->name);
+        return 0;
+    }
+
+    /*
+     * See if the line ends in a newline.  If not, see which error case we
+     * have.
+     */
+    length = strlen(file->buffer);
+    if (file->buffer[length - 1] != '\n') {
+        int incomplete = 0;
+
+        /* Check whether we ran out of buffer space and resize if so. */
+        if (length < file->bufsize - 1)
+            incomplete = 1;
+        else {
+            file->bufsize += BUFSIZ;
+            file->buffer =
+                breallocarray_type(file->buffer, file->bufsize, char);
+        }
+
+        /*
+         * On either incomplete lines or too small of a buffer, rewind
+         * and read the file again (on the next pass, if incomplete).
+         * It's simpler than trying to double-buffer the file.
+         */
+        if (fsetpos(file->file, &where) < 0)
+            sysbail("cannot set position in %s", file->name);
+        return incomplete;
+    }
+
+    /* We saw a complete line.  Print it out. */
+    printf("# %s", file->buffer);
+    return 0;
+}
+
+
+/*
+ * Check all registered diag_files for any output.  We only print out the
+ * output if we see a complete line; otherwise, we wait for the next newline.
+ */
+static void
+check_diag_files(void)
+{
+    struct diag_file *file;
+    fpos_t where;
+    int incomplete;
+
+    /*
+     * Walk through each file and read each line of output available.
+     */
+    for (file = diag_files; file != NULL; file = file->next) {
+        clearerr(file->file);
+
+        /* Store the current position in case we have to rewind. */
+        if (fgetpos(file->file, &where) < 0)
+            sysbail("cannot get position in %s", file->name);
+
+        /* Continue until we get EOF or an incomplete line of data. */
+        incomplete = 0;
+        while (!feof(file->file) && !incomplete) {
+            incomplete = handle_diag_file_line(file, where);
+        }
+    }
+}
+
 
 /*
  * Our exit handler.  Called on completion of the test to report a summary of
  * results provided we're still in the original process.  This also handles
  * printing out the plan if we used plan_lazy(), although that's suppressed if
- * we never ran a test (due to an early bail, for example).
+ * we never ran a test (due to an early bail, for example), and running any
+ * registered cleanup functions.
  */
 static void
 finish(void)
 {
+    int success, primary;
+    struct cleanup_func *current;
     unsigned long highest = testnum - 1;
+    struct diag_file *file, *tmp;
+
+    /* Check for pending diag_file output. */
+    check_diag_files();
+
+    /* Free the diag_files. */
+    file = diag_files;
+    while (file != NULL) {
+        tmp = file;
+        file = file->next;
+        fclose(tmp->file);
+        free(tmp->name);
+        free(tmp->buffer);
+        free(tmp);
+    }
+    diag_files = NULL;
+
+    /*
+     * Determine whether all tests were successful, which is needed before
+     * calling cleanup functions since we pass that fact to the functions.
+     */
+    if (_planned == 0 && _lazy)
+        _planned = highest;
+    success = (!_aborted && _planned == highest && _failed == 0);
+
+    /*
+     * If there are any registered cleanup functions, we run those first.  We
+     * always run them, even if we didn't run a test.  Don't do anything
+     * except free the diag_files and call cleanup functions if we aren't the
+     * primary process (the process in which plan or plan_lazy was called),
+     * and tell the cleanup functions that fact.
+     */
+    primary = (_process == 0 || getpid() == _process);
+    while (cleanup_funcs != NULL) {
+        if (cleanup_funcs->func_with_data) {
+            void *data = cleanup_funcs->data;
+
+            cleanup_funcs->func_with_data(success, primary, data);
+        } else {
+            cleanup_funcs->func(success, primary);
+        }
+        current = cleanup_funcs;
+        cleanup_funcs = cleanup_funcs->next;
+        free(current);
+    }
+    if (!primary)
+        return;
+
+    /* Don't do anything further if we never planned a test. */
+    if (_planned == 0)
+        return;
 
-    if (_planned == 0 && !_lazy)
+    /* If we're aborting due to bail, don't print summaries. */
+    if (_aborted)
         return;
+
+    /* Print out the lazy plan if needed. */
     fflush(stderr);
-    if (_process != 0 && getpid() == _process) {
-        if (_lazy && highest > 0) {
-            printf("1..%lu\n", highest);
-            _planned = highest;
-        }
-        if (_planned > highest)
-            printf("# Looks like you planned %lu test%s but only ran %lu\n",
-                   _planned, (_planned > 1 ? "s" : ""), highest);
-        else if (_planned < highest)
-            printf("# Looks like you planned %lu test%s but ran %lu extra\n",
-                   _planned, (_planned > 1 ? "s" : ""), highest - _planned);
-        else if (_failed > 0)
-            printf("# Looks like you failed %lu test%s of %lu\n", _failed,
-                   (_failed > 1 ? "s" : ""), _planned);
-        else if (_planned > 1)
-            printf("# All %lu tests successful or skipped\n", _planned);
-        else
-            printf("# %lu test successful or skipped\n", _planned);
-    }
+    if (_lazy && _planned > 0)
+        printf("1..%lu\n", _planned);
+
+    /* Print out a summary of the results. */
+    if (_planned > highest)
+        diag("Looks like you planned %lu test%s but only ran %lu", _planned,
+             (_planned > 1 ? "s" : ""), highest);
+    else if (_planned < highest)
+        diag("Looks like you planned %lu test%s but ran %lu extra", _planned,
+             (_planned > 1 ? "s" : ""), highest - _planned);
+    else if (_failed > 0)
+        diag("Looks like you failed %lu test%s of %lu", _failed,
+             (_failed > 1 ? "s" : ""), _planned);
+    else if (_planned != 1)
+        diag("All %lu tests successful or skipped", _planned);
+    else
+        diag("%lu test successful or skipped", _planned);
 }
 
 
 /*
  * Initialize things.  Turns on line buffering on stdout and then prints out
- * the number of tests in the test suite.
+ * the number of tests in the test suite.  We intentionally don't check for
+ * pending diag_file output here, since it should really come after the plan.
  */
 void
 plan(unsigned long count)
 {
     if (setvbuf(stdout, NULL, _IOLBF, BUFSIZ) != 0)
-        fprintf(stderr, "# cannot set stdout to line buffered: %s\n",
-                strerror(errno));
+        sysdiag("cannot set stdout to line buffered");
     fflush(stderr);
     printf("1..%lu\n", count);
     testnum = 1;
     _planned = count;
     _process = getpid();
-    atexit(finish);
+    if (atexit(finish) != 0) {
+        sysdiag("cannot register exit handler");
+        diag("cleanups will not be run");
+    }
 }
 
 
@@ -143,83 +399,66 @@ void
 plan_lazy(void)
 {
     if (setvbuf(stdout, NULL, _IOLBF, BUFSIZ) != 0)
-        fprintf(stderr, "# cannot set stdout to line buffered: %s\n",
-                strerror(errno));
+        sysdiag("cannot set stdout to line buffered");
     testnum = 1;
     _process = getpid();
     _lazy = 1;
-    atexit(finish);
+    if (atexit(finish) != 0)
+        sysbail("cannot register exit handler to display plan");
 }
 
 
 /*
  * Skip the entire test suite and exits.  Should be called instead of plan(),
- * not after it, since it prints out a special plan line.
+ * not after it, since it prints out a special plan line.  Ignore diag_file
+ * output here, since it's not clear if it's allowed before the plan.
  */
 void
 skip_all(const char *format, ...)
 {
     fflush(stderr);
     printf("1..0 # skip");
-    if (format != NULL) {
-        va_list args;
-
-        putchar(' ');
-        va_start(args, format);
-        vprintf(format, args);
-        va_end(args);
-    }
+    PRINT_DESC(" ", format);
     putchar('\n');
     exit(0);
 }
 
 
-/*
- * Print the test description.
- */
-static void
-print_desc(const char *format, va_list args)
-{
-    printf(" - ");
-    vprintf(format, args);
-}
-
-
 /*
  * Takes a boolean success value and assumes the test passes if that value
  * is true and fails if that value is false.
  */
-void
+int
 ok(int success, const char *format, ...)
 {
     fflush(stderr);
+    check_diag_files();
     printf("%sok %lu", success ? "" : "not ", testnum++);
     if (!success)
         _failed++;
-    if (format != NULL) {
-        va_list args;
-
-        va_start(args, format);
-        print_desc(format, args);
-        va_end(args);
-    }
+    PRINT_DESC(" - ", format);
     putchar('\n');
+    return success;
 }
 
 
 /*
  * Same as ok(), but takes the format arguments as a va_list.
  */
-void
+int
 okv(int success, const char *format, va_list args)
 {
     fflush(stderr);
+    check_diag_files();
     printf("%sok %lu", success ? "" : "not ", testnum++);
     if (!success)
         _failed++;
-    if (format != NULL)
-        print_desc(format, args);
+    if (format != NULL) {
+        printf(" - ");
+        vprintf(format, args);
+    }
     putchar('\n');
+    return success;
 }
 
 
@@ -230,15 +469,9 @@ void
 skip(const char *reason, ...)
 {
     fflush(stderr);
+    check_diag_files();
     printf("ok %lu # skip", testnum++);
-    if (reason != NULL) {
-        va_list args;
-
-        va_start(args, reason);
-        putchar(' ');
-        vprintf(reason, args);
-        va_end(args);
-    }
+    PRINT_DESC(" ", reason);
     putchar('\n');
 }
 
@@ -246,25 +479,21 @@ skip(const char *reason, ...)
 /*
  * Report the same status on the next count tests.
  */
-void
-ok_block(unsigned long count, int status, const char *format, ...)
+int
+ok_block(unsigned long count, int success, const char *format, ...)
 {
     unsigned long i;
 
     fflush(stderr);
+    check_diag_files();
     for (i = 0; i < count; i++) {
-        printf("%sok %lu", status ? "" : "not ", testnum++);
-        if (!status)
+        printf("%sok %lu", success ? "" : "not ", testnum++);
+        if (!success)
             _failed++;
-        if (format != NULL) {
-            va_list args;
-
-            va_start(args, format);
-            print_desc(format, args);
-            va_end(args);
-        }
+        PRINT_DESC(" - ", format);
         putchar('\n');
     }
+    return success;
 }
 
 
@@ -277,101 +506,157 @@ skip_block(unsigned long count, const char *reason, ...)
     unsigned long i;
 
     fflush(stderr);
+    check_diag_files();
     for (i = 0; i < count; i++) {
         printf("ok %lu # skip", testnum++);
-        if (reason != NULL) {
-            va_list args;
-
-            va_start(args, reason);
-            putchar(' ');
-            vprintf(reason, args);
-            va_end(args);
-        }
+        PRINT_DESC(" ", reason);
         putchar('\n');
     }
 }
 
 
 /*
- * Takes an expected integer and a seen integer and assumes the test passes
- * if those two numbers match.
+ * Takes two boolean values and requires the truth value of both match.
  */
-void
-is_int(long wanted, long seen, const char *format, ...)
+int
+is_bool(int left, int right, const char *format, ...)
 {
+    int success;
+
     fflush(stderr);
-    if (wanted == seen)
+    check_diag_files();
+    success = (!!left == !!right);
+    if (success)
         printf("ok %lu", testnum++);
     else {
-        printf("# wanted: %ld\n#   seen: %ld\n", wanted, seen);
+        diag(" left: %s", !!left ? "true" : "false");
+        diag("right: %s", !!right ? "true" : "false");
         printf("not ok %lu", testnum++);
         _failed++;
     }
-    if (format != NULL) {
-        va_list args;
-
-        va_start(args, format);
-        print_desc(format, args);
-        va_end(args);
-    }
+    PRINT_DESC(" - ", format);
     putchar('\n');
+    return success;
 }
 
 
 /*
- * Takes a string and what the string should be, and assumes the test passes
- * if those strings match (using strcmp).
+ * Takes two integer values and requires they match.
  */
-void
-is_string(const char *wanted, const char *seen, const char *format, ...)
+int
+is_int(long left, long right, const char *format, ...)
 {
-    if (wanted == NULL)
-        wanted = "(null)";
-    if (seen == NULL)
-        seen = "(null)";
+    int success;
+
     fflush(stderr);
-    if (strcmp(wanted, seen) == 0)
+    check_diag_files();
+    success = (left == right);
+    if (success)
         printf("ok %lu", testnum++);
     else {
-        printf("# wanted: %s\n#   seen: %s\n", wanted, seen);
+        diag(" left: %ld", left);
+        diag("right: %ld", right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
-    if (format != NULL) {
-        va_list args;
+    PRINT_DESC(" - ", format);
+    putchar('\n');
+    return success;
+}
 
-        va_start(args, format);
-        print_desc(format, args);
-        va_end(args);
+
+/*
+ * Takes two strings and requires they match (using strcmp).  NULL arguments
+ * are permitted and handled correctly.
+ */
+int
+is_string(const char *left, const char *right, const char *format, ...)
+{
+    int success;
+
+    fflush(stderr);
+    check_diag_files();
+
+    /* Compare the strings, being careful of NULL. */
+    if (left == NULL)
+        success = (right == NULL);
+    else if (right == NULL)
+        success = 0;
+    else
+        success = (strcmp(left, right) == 0);
+
+    /* Report the results. */
+    if (success)
+        printf("ok %lu", testnum++);
+    else {
+        diag(" left: %s", left == NULL ? "(null)" : left);
+        diag("right: %s", right == NULL ? "(null)" : right);
+        printf("not ok %lu", testnum++);
+        _failed++;
     }
+    PRINT_DESC(" - ", format);
     putchar('\n');
+    return success;
 }
 
 
 /*
- * Takes an expected unsigned long and a seen unsigned long and assumes the
- * test passes if the two numbers match.  Otherwise, reports them in hex.
+ * Takes two unsigned longs and requires they match.  On failure, reports them
+ * in hex.
  */
-void
-is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+int
+is_hex(unsigned long left, unsigned long right, const char *format, ...)
 {
+    int success;
+
     fflush(stderr);
-    if (wanted == seen)
+    check_diag_files();
+    success = (left == right);
+    if (success)
         printf("ok %lu", testnum++);
     else {
-        printf("# wanted: %lx\n#   seen: %lx\n", (unsigned long) wanted,
-               (unsigned long) seen);
+        diag(" left: %lx", (unsigned long) left);
+        diag("right: %lx", (unsigned long) right);
         printf("not ok %lu", testnum++);
         _failed++;
     }
-    if (format != NULL) {
-        va_list args;
+    PRINT_DESC(" - ", format);
+    putchar('\n');
+    return success;
+}
+
+
+/*
+ * Takes pointers to a regions of memory and requires that len bytes from each
+ * match.  Otherwise reports any bytes which didn't match.
+ */
+int
+is_blob(const void *left, const void *right, size_t len, const char *format,
+        ...)
+{
+    int success;
+    size_t i;
+
+    fflush(stderr);
+    check_diag_files();
+    success = (memcmp(left, right, len) == 0);
+    if (success)
+        printf("ok %lu", testnum++);
+    else {
+        const unsigned char *left_c = (const unsigned char *) left;
+        const unsigned char *right_c = (const unsigned char *) right;
 
-        va_start(args, format);
-        print_desc(format, args);
-        va_end(args);
+        for (i = 0; i < len; i++) {
+            if (left_c[i] != right_c[i])
+                diag("offset %lu: left %02x, right %02x", (unsigned long) i,
+                     left_c[i], right_c[i]);
+        }
+        printf("not ok %lu", testnum++);
+        _failed++;
     }
+    PRINT_DESC(" - ", format);
     putchar('\n');
+    return success;
 }
 
 
@@ -383,14 +668,16 @@ bail(const char *format, ...)
 {
     va_list args;
 
+    _aborted = 1;
     fflush(stderr);
+    check_diag_files();
     fflush(stdout);
     printf("Bail out! ");
     va_start(args, format);
     vprintf(format, args);
     va_end(args);
     printf("\n");
-    exit(1);
+    exit(255);
 }
 
 
@@ -403,51 +690,110 @@ sysbail(const char *format, ...)
     va_list args;
     int oerrno = errno;
 
+    _aborted = 1;
     fflush(stderr);
+    check_diag_files();
     fflush(stdout);
     printf("Bail out! ");
     va_start(args, format);
     vprintf(format, args);
     va_end(args);
     printf(": %s\n", strerror(oerrno));
-    exit(1);
+    exit(255);
 }
 
 
 /*
- * Report a diagnostic to stderr.
+ * Report a diagnostic to stderr.  Always returns 1 to allow embedding in
+ * compound statements.
  */
-void
+int
 diag(const char *format, ...)
 {
     va_list args;
 
     fflush(stderr);
+    check_diag_files();
     fflush(stdout);
     printf("# ");
     va_start(args, format);
     vprintf(format, args);
     va_end(args);
     printf("\n");
+    return 1;
 }
 
 
 /*
- * Report a diagnostic to stderr, appending strerror(errno).
+ * Report a diagnostic to stderr, appending strerror(errno).  Always returns 1
+ * to allow embedding in compound statements.
  */
-void
+int
 sysdiag(const char *format, ...)
 {
     va_list args;
     int oerrno = errno;
 
     fflush(stderr);
+    check_diag_files();
     fflush(stdout);
     printf("# ");
     va_start(args, format);
     vprintf(format, args);
     va_end(args);
     printf(": %s\n", strerror(oerrno));
+    return 1;
+}
+
+
+/*
+ * Register a new file for diag_file processing.
+ */
+void
+diag_file_add(const char *name)
+{
+    struct diag_file *file, *prev;
+
+    file = bcalloc_type(1, struct diag_file);
+    file->name = bstrdup(name);
+    file->file = fopen(file->name, "r");
+    if (file->file == NULL)
+        sysbail("cannot open %s", name);
+    file->buffer = bcalloc_type(BUFSIZ, char);
+    file->bufsize = BUFSIZ;
+    if (diag_files == NULL)
+        diag_files = file;
+    else {
+        for (prev = diag_files; prev->next != NULL; prev = prev->next)
+            ;
+        prev->next = file;
+    }
+}
+
+
+/*
+ * Remove a file from diag_file processing.  If the file is not found, do
+ * nothing, since there are some situations where it can be removed twice
+ * (such as if it's removed from a cleanup function, since cleanup functions
+ * are called after freeing all the diag_files).
+ */
+void
+diag_file_remove(const char *name)
+{
+    struct diag_file *file;
+    struct diag_file **prev = &diag_files;
+
+    for (file = diag_files; file != NULL; file = file->next) {
+        if (strcmp(file->name, name) == 0) {
+            *prev = file->next;
+            fclose(file->file);
+            free(file->name);
+            free(file->buffer);
+            free(file);
+            return;
+        }
+        prev = &file->next;
+    }
 }
 
 
@@ -461,7 +807,7 @@ bcalloc(size_t n, size_t size)
 
     p = calloc(n, size);
     if (p == NULL)
-        sysbail("failed to calloc %lu", (unsigned long)(n * size));
+        sysbail("failed to calloc %lu", (unsigned long) (n * size));
     return p;
 }
 
@@ -494,6 +840,34 @@ brealloc(void *p, size_t size)
 }
 
 
+/*
+ * The same as brealloc, but determine the size by multiplying an element
+ * count by a size, similar to calloc.  The multiplication is checked for
+ * integer overflow.
+ *
+ * We should technically use SIZE_MAX here for the overflow check, but
+ * SIZE_MAX is C99 and we're only assuming C89 + SUSv3, which does not
+ * guarantee that it exists.  They do guarantee that UINT_MAX exists, and we
+ * can assume that UINT_MAX <= SIZE_MAX.
+ *
+ * (In theory, C89 and C99 permit size_t to be smaller than unsigned int, but
+ * I disbelieve in the existence of such systems and they will have to cope
+ * without overflow checks.)
+ */
+void *
+breallocarray(void *p, size_t n, size_t size)
+{
+    if (n > 0 && UINT_MAX / n <= size)
+        bail("reallocarray too large");
+    if (n == 0)
+        n = 1;
+    p = realloc(p, n * size);
+    if (p == NULL)
+        sysbail("failed to realloc %lu bytes", (unsigned long) (n * size));
+    return p;
+}
+
+
 /*
  * Copy a string, reporting a fatal error with bail on failure.
  */
@@ -504,7 +878,7 @@ bstrdup(const char *s)
     size_t len;
 
     len = strlen(s) + 1;
-    p = malloc(len);
+    p = (char *) malloc(len);
     if (p == NULL)
         sysbail("failed to strdup %lu bytes", (unsigned long) len);
     memcpy(p, s, len);
@@ -525,11 +899,11 @@ bstrndup(const char *s, size_t n)
     size_t length;
 
     /* Don't assume that the source string is nul-terminated. */
-    for (p = s; (size_t) (p - s) < n && *p != '\0'; p++)
+    for (p = s; (size_t)(p - s) < n && *p != '\0'; p++)
         ;
-    length = p - s;
-    copy = malloc(length + 1);
-    if (p == NULL)
+    length = (size_t)(p - s);
+    copy = (char *) malloc(length + 1);
+    if (copy == NULL)
         sysbail("failed to strndup %lu bytes", (unsigned long) length);
     memcpy(copy, s, length);
     copy[length] = '\0';
@@ -538,31 +912,24 @@ bstrndup(const char *s, size_t n)
 
 
 /*
- * Locate a test file.  Given the partial path to a file, look under BUILD and
- * then SOURCE for the file and return the full path to the file.  Returns
- * NULL if the file doesn't exist.  A non-NULL return should be freed with
- * test_file_path_free().
- *
- * This function uses sprintf because it attempts to be independent of all
- * other portability layers.  The use immediately after a memory allocation
- * should be safe without using snprintf or strlcpy/strlcat.
+ * Locate a test file.  Given the partial path to a file, look under
+ * C_TAP_BUILD and then C_TAP_SOURCE for the file and return the full path to
+ * the file.  Returns NULL if the file doesn't exist.  A non-NULL return
+ * should be freed with test_file_path_free().
  */
 char *
 test_file_path(const char *file)
 {
     char *base;
     char *path = NULL;
-    size_t length;
-    const char *envs[] = { "BUILD", "SOURCE", NULL };
+    const char *envs[] = {"C_TAP_BUILD", "C_TAP_SOURCE", NULL};
     int i;
 
     for (i = 0; envs[i] != NULL; i++) {
         base = getenv(envs[i]);
         if (base == NULL)
             continue;
-        length = strlen(base) + 1 + strlen(file) + 1;
-        path = bmalloc(length);
-        sprintf(path, "%s/%s", base, file);
+        path = concat(base, "/", file, (const char *) 0);
         if (access(path, R_OK) == 0)
             break;
         free(path);
@@ -580,13 +947,12 @@ test_file_path(const char *file)
 void
 test_file_path_free(char *path)
 {
-    if (path != NULL)
-        free(path);
+    free(path);
 }
 
 
 /*
- * Create a temporary directory, tmp, under BUILD if set and the current
+ * Create a temporary directory, tmp, under C_TAP_BUILD if set and the current
  * directory if it does not.  Returns the path to the temporary directory in
  * newly allocated memory, and calls bail on any failure.  The return value
  * should be freed with test_tmpdir_free.
@@ -600,14 +966,11 @@ test_tmpdir(void)
 {
     const char *build;
     char *path = NULL;
-    size_t length;
 
-    build = getenv("BUILD");
+    build = getenv("C_TAP_BUILD");
     if (build == NULL)
         build = ".";
-    length = strlen(build) + strlen("/tmp") + 1;
-    path = bmalloc(length);
-    sprintf(path, "%s/tmp", build);
+    path = concat(build, "/tmp", (const char *) 0);
     if (access(path, X_OK) < 0)
         if (mkdir(path, 0777) < 0)
             sysbail("error creating temporary directory %s", path);
@@ -623,7 +986,44 @@ test_tmpdir(void)
 void
 test_tmpdir_free(char *path)
 {
-    rmdir(path);
     if (path != NULL)
-        free(path);
+        rmdir(path);
+    free(path);
+}
+
+static void
+register_cleanup(test_cleanup_func func,
+                 test_cleanup_func_with_data func_with_data, void *data)
+{
+    struct cleanup_func *cleanup, **last;
+
+    cleanup = bcalloc_type(1, struct cleanup_func);
+    cleanup->func = func;
+    cleanup->func_with_data = func_with_data;
+    cleanup->data = data;
+    cleanup->next = NULL;
+    last = &cleanup_funcs;
+    while (*last != NULL)
+        last = &(*last)->next;
+    *last = cleanup;
+}
+
+/*
+ * Register a cleanup function that is called when testing ends.  All such
+ * registered functions will be run by finish.
+ */
+void
+test_cleanup_register(test_cleanup_func func)
+{
+    register_cleanup(func, NULL, NULL);
+}
+
+/*
+ * Same as above, but also allows an opaque pointer to be passed to the cleanup
+ * function.
+ */
+void
+test_cleanup_register_with_data(test_cleanup_func_with_data func, void *data)
+{
+    register_cleanup(NULL, func, data);
 }
diff --git a/src/external/c-tap-harness/tests/tap/basic.h b/src/external/c-tap-harness/tests/tap/basic.h
index fa4adafe2..45f15f289 100644
--- a/src/external/c-tap-harness/tests/tap/basic.h
+++ b/src/external/c-tap-harness/tests/tap/basic.h
@@ -2,10 +2,11 @@
  * Basic utility routines for the TAP protocol.
  *
  * This file is part of C TAP Harness.  The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2009, 2010, 2011, 2012 Russ Allbery <rra@stanford.edu>
- * Copyright 2001, 2002, 2004, 2005, 2006, 2007, 2008, 2011, 2012
+ * Written by Russ Allbery <eagle@eyrie.org>
+ * Copyright 2009-2019 Russ Allbery <eagle@eyrie.org>
+ * Copyright 2001-2002, 2004-2008, 2011-2012, 2014
  *     The Board of Trustees of the Leland Stanford Junior University
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -25,14 +26,16 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
  */
 
 #ifndef TAP_BASIC_H
 #define TAP_BASIC_H 1
 
+#include <stdarg.h> /* va_list */
+#include <stddef.h> /* size_t */
 #include <tests/tap/macros.h>
-#include <stdarg.h>             /* va_list */
-#include <sys/types.h>          /* size_t */
 
 /*
  * Used for iterating through arrays.  ARRAY_SIZE returns the number of
@@ -40,8 +43,8 @@
  * ARRAY_END returns a pointer to the element past the end (ISO C99 makes it
  * legal to refer to such a pointer as long as it's never dereferenced).
  */
-#define ARRAY_SIZE(array)       (sizeof(array) / sizeof((array)[0]))
-#define ARRAY_END(array)        (&(array)[ARRAY_SIZE(array)])
+#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))
+#define ARRAY_END(array)  (&(array)[ARRAY_SIZE(array)])
 
 BEGIN_DECLS
 
@@ -55,7 +58,7 @@ extern unsigned long testnum;
 void plan(unsigned long count);
 
 /*
- * Prepare for lazy planning, in which the plan will be  printed automatically
+ * Prepare for lazy planning, in which the plan will be printed automatically
  * at the end of the test program.
  */
 void plan_lazy(void);
@@ -67,27 +70,40 @@ void skip_all(const char *format, ...)
 /*
  * Basic reporting functions.  The okv() function is the same as ok() but
  * takes the test description as a va_list to make it easier to reuse the
- * reporting infrastructure when writing new tests.
+ * reporting infrastructure when writing new tests.  ok() and okv() return the
+ * value of the success argument.
  */
-void ok(int success, const char *format, ...)
+int ok(int success, const char *format, ...)
     __attribute__((__format__(printf, 2, 3)));
-void okv(int success, const char *format, va_list args);
-void skip(const char *reason, ...)
-    __attribute__((__format__(printf, 1, 2)));
+int okv(int success, const char *format, va_list args)
+    __attribute__((__format__(printf, 2, 0)));
+void skip(const char *reason, ...) __attribute__((__format__(printf, 1, 2)));
 
-/* Report the same status on, or skip, the next count tests. */
-void ok_block(unsigned long count, int success, const char *format, ...)
+/*
+ * Report the same status on, or skip, the next count tests.  ok_block()
+ * returns the value of the success argument.
+ */
+int ok_block(unsigned long count, int success, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
 void skip_block(unsigned long count, const char *reason, ...)
     __attribute__((__format__(printf, 2, 3)));
 
-/* Check an expected value against a seen value. */
-void is_int(long wanted, long seen, const char *format, ...)
+/*
+ * Compare two values.  Returns true if the test passes and false if it fails.
+ * is_bool takes an int since the bool type isn't fully portable yet, but
+ * interprets both arguments for their truth value, not for their numeric
+ * value.
+ */
+int is_bool(int, int, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-void is_string(const char *wanted, const char *seen, const char *format, ...)
+int is_int(long, long, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
-void is_hex(unsigned long wanted, unsigned long seen, const char *format, ...)
+int is_string(const char *, const char *, const char *format, ...)
     __attribute__((__format__(printf, 3, 4)));
+int is_hex(unsigned long, unsigned long, const char *format, ...)
+    __attribute__((__format__(printf, 3, 4)));
+int is_blob(const void *, const void *, size_t, const char *format, ...)
+    __attribute__((__format__(printf, 4, 5)));
 
 /* Bail out with an error.  sysbail appends strerror(errno). */
 void bail(const char *format, ...)
@@ -96,39 +112,81 @@ void sysbail(const char *format, ...)
     __attribute__((__noreturn__, __nonnull__, __format__(printf, 1, 2)));
 
 /* Report a diagnostic to stderr prefixed with #. */
-void diag(const char *format, ...)
+int diag(const char *format, ...)
     __attribute__((__nonnull__, __format__(printf, 1, 2)));
-void sysdiag(const char *format, ...)
+int sysdiag(const char *format, ...)
     __attribute__((__nonnull__, __format__(printf, 1, 2)));
 
+/*
+ * Register or unregister a file that contains supplementary diagnostics.
+ * Before any other output, all registered files will be read, line by line,
+ * and each line will be reported as a diagnostic as if it were passed to
+ * diag().  Nul characters are not supported in these files and will result in
+ * truncated output.
+ */
+void diag_file_add(const char *file) __attribute__((__nonnull__));
+void diag_file_remove(const char *file) __attribute__((__nonnull__));
+
 /* Allocate memory, reporting a fatal error with bail on failure. */
 void *bcalloc(size_t, size_t)
-    __attribute__((__alloc_size__(1, 2), __malloc__));
+    __attribute__((__alloc_size__(1, 2), __malloc__, __warn_unused_result__));
 void *bmalloc(size_t)
-    __attribute__((__alloc_size__(1), __malloc__));
+    __attribute__((__alloc_size__(1), __malloc__, __warn_unused_result__));
+void *breallocarray(void *, size_t, size_t)
+    __attribute__((__alloc_size__(2, 3), __malloc__, __warn_unused_result__));
 void *brealloc(void *, size_t)
-    __attribute__((__alloc_size__(2), __malloc__));
+    __attribute__((__alloc_size__(2), __malloc__, __warn_unused_result__));
 char *bstrdup(const char *)
-    __attribute__((__malloc__, __nonnull__));
+    __attribute__((__malloc__, __nonnull__, __warn_unused_result__));
 char *bstrndup(const char *, size_t)
-    __attribute__((__malloc__, __nonnull__));
+    __attribute__((__malloc__, __nonnull__, __warn_unused_result__));
 
 /*
- * Find a test file under BUILD or SOURCE, returning the full path.  The
- * returned path should be freed with test_file_path_free().
+ * Macros that cast the return value from b* memory functions, making them
+ * usable in C++ code and providing some additional type safety.
+ */
+#define bcalloc_type(n, type) ((type *) bcalloc((n), sizeof(type)))
+#define breallocarray_type(p, n, type) \
+    ((type *) breallocarray((p), (n), sizeof(type)))
+
+/*
+ * Find a test file under C_TAP_BUILD or C_TAP_SOURCE, returning the full
+ * path.  The returned path should be freed with test_file_path_free().
  */
 char *test_file_path(const char *file)
-    __attribute__((__malloc__, __nonnull__));
+    __attribute__((__malloc__, __nonnull__, __warn_unused_result__));
 void test_file_path_free(char *path);
 
 /*
- * Create a temporary directory relative to BUILD and return the path.  The
- * returned path should be freed with test_tmpdir_free.
+ * Create a temporary directory relative to C_TAP_BUILD and return the path.
+ * The returned path should be freed with test_tmpdir_free().
  */
-char *test_tmpdir(void)
-    __attribute__((__malloc__));
+char *test_tmpdir(void) __attribute__((__malloc__, __warn_unused_result__));
 void test_tmpdir_free(char *path);
 
+/*
+ * Register a cleanup function that is called when testing ends.  All such
+ * registered functions will be run during atexit handling (and are therefore
+ * subject to all the same constraints and caveats as atexit functions).
+ *
+ * The function must return void and will be passed two arguments: an int that
+ * will be true if the test completed successfully and false otherwise, and an
+ * int that will be true if the cleanup function is run in the primary process
+ * (the one that called plan or plan_lazy) and false otherwise.  If
+ * test_cleanup_register_with_data is used instead, a generic pointer can be
+ * provided and will be passed to the cleanup function as a third argument.
+ *
+ * test_cleanup_register_with_data is the better API and should have been the
+ * only API.  test_cleanup_register was an API error preserved for backward
+ * cmpatibility.
+ */
+typedef void (*test_cleanup_func)(int, int);
+typedef void (*test_cleanup_func_with_data)(int, int, void *);
+
+void test_cleanup_register(test_cleanup_func) __attribute__((__nonnull__));
+void test_cleanup_register_with_data(test_cleanup_func_with_data, void *)
+    __attribute__((__nonnull__));
+
 END_DECLS
 
 #endif /* TAP_BASIC_H */
diff --git a/src/external/c-tap-harness/tests/tap/float.c b/src/external/c-tap-harness/tests/tap/float.c
index 67dd555f3..8fbd441ae 100644
--- a/src/external/c-tap-harness/tests/tap/float.c
+++ b/src/external/c-tap-harness/tests/tap/float.c
@@ -8,9 +8,9 @@
  * otherwise care about floating point.
  *
  * This file is part of C TAP Harness.  The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2010, 2012 Russ Allbery <rra@stanford.edu>
+ * Copyright 2008, 2010, 2012-2019 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -29,13 +29,15 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
  */
 
 /* Required for isnan() and isinf(). */
 #if defined(__STRICT_ANSI__) || defined(PEDANTIC)
-# ifndef _XOPEN_SOURCE
-#  define _XOPEN_SOURCE 600
-# endif
+#    ifndef _XOPEN_SOURCE
+#        define _XOPEN_SOURCE 600
+#    endif
 #endif
 
 #include <math.h>
@@ -46,22 +48,49 @@
 #include <tests/tap/float.h>
 
 /*
- * Takes an expected double and a seen double and assumes the test passes if
- * those two numbers are within delta of each other.
+ * Clang 4.0.1 gets very confused by this file and produces warnings about
+ * floating point implicit conversion from the isnan() and isinf() macros.
+ */
+#if defined(__llvm__) || defined(__clang__)
+#    pragma clang diagnostic ignored "-Wconversion"
+#    pragma clang diagnostic ignored "-Wdouble-promotion"
+#endif
+
+/*
+ * Returns true if the two doubles are equal infinities, false otherwise.
+ * This requires a bit of machination since isinf is not required to return
+ * different values for positive and negative infinity, and we're trying to
+ * avoid direct comparisons between floating point numbers.
+ */
+static int
+is_equal_infinity(double left, double right)
+{
+    if (!isinf(left) || !isinf(right))
+        return 0;
+    return !!(left < 0) == !!(right < 0);
+}
+
+/*
+ * Takes two doubles and requires they be within epsilon of each other.
  */
-void
-is_double(double wanted, double seen, double epsilon, const char *format, ...)
+int
+is_double(double left, double right, double epsilon, const char *format, ...)
 {
     va_list args;
+    int success;
 
     va_start(args, format);
     fflush(stderr);
-    if ((isnan(wanted) && isnan(seen))
-        || (isinf(wanted) && isinf(seen) && wanted == seen)
-        || fabs(wanted - seen) <= epsilon)
+    if ((isnan(left) && isnan(right)) || is_equal_infinity(left, right)
+        || fabs(left - right) <= epsilon) {
+        success = 1;
         okv(1, format, args);
-    else {
-        printf("# wanted: %g\n#   seen: %g\n", wanted, seen);
+    } else {
+        success = 0;
+        diag(" left: %g", left);
+        diag("right: %g", right);
         okv(0, format, args);
     }
+    va_end(args);
+    return success;
 }
diff --git a/src/external/c-tap-harness/tests/tap/float.h b/src/external/c-tap-harness/tests/tap/float.h
index 746453564..bdf845108 100644
--- a/src/external/c-tap-harness/tests/tap/float.h
+++ b/src/external/c-tap-harness/tests/tap/float.h
@@ -2,9 +2,9 @@
  * Floating point check function for the TAP protocol.
  *
  * This file is part of C TAP Harness.  The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2010, 2012 Russ Allbery <rra@stanford.edu>
+ * Copyright 2008, 2010, 2012, 2014, 2018 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -23,6 +23,8 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
  */
 
 #ifndef TAP_FLOAT_H
@@ -32,9 +34,8 @@
 
 BEGIN_DECLS
 
-/* Check an expected value against a seen value within epsilon. */
-void is_double(double wanted, double seen, double epsilon,
-               const char *format, ...)
+/* Compare two values within epsilon. */
+int is_double(double, double, double epsilon, const char *format, ...)
     __attribute__((__format__(printf, 4, 5)));
 
 END_DECLS
diff --git a/src/external/c-tap-harness/tests/tap/libtap.sh b/src/external/c-tap-harness/tests/tap/libtap.sh
index f9347d80b..1827a689e 100644
--- a/src/external/c-tap-harness/tests/tap/libtap.sh
+++ b/src/external/c-tap-harness/tests/tap/libtap.sh
@@ -7,11 +7,11 @@
 #
 # This file provides a TAP-compatible shell function library useful for
 # writing test cases.  It is part of C TAP Harness, which can be found at
-# <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+# <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
 #
-# Written by Russ Allbery <rra@stanford.edu>
-# Copyright 2009, 2010, 2011, 2012 Russ Allbery <rra@stanford.edu>
-# Copyright 2006, 2007, 2008
+# Written by Russ Allbery <eagle@eyrie.org>
+# Copyright 2009-2012, 2016 Russ Allbery <eagle@eyrie.org>
+# Copyright 2006-2008, 2013
 #     The Board of Trustees of the Leland Stanford Junior University
 #
 # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -31,6 +31,8 @@
 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.
+#
+# SPDX-License-Identifier: MIT
 
 # Print out the number of test cases we expect to run.
 plan () {
@@ -204,7 +206,7 @@ strip_colon_error() {
 # Bail out with an error message.
 bail () {
     echo 'Bail out!' "$@"
-    exit 1
+    exit 255
 }
 
 # Output a diagnostic on standard error, preceded by the required # mark.
@@ -212,32 +214,32 @@ diag () {
     echo '#' "$@"
 }
 
-# Search for the given file first in $BUILD and then in $SOURCE and echo the
-# path where the file was found, or the empty string if the file wasn't
-# found.
+# Search for the given file first in $C_TAP_BUILD and then in $C_TAP_SOURCE
+# and echo the path where the file was found, or the empty string if the file
+# wasn't found.
 #
 # This macro uses puts, so don't run it using backticks inside double quotes
 # or bizarre quoting behavior will happen with Solaris sh.
 test_file_path () {
-    if [ -n "$BUILD" ] && [ -f "$BUILD/$1" ] ; then
-        puts "$BUILD/$1"
-    elif [ -n "$SOURCE" ] && [ -f "$SOURCE/$1" ] ; then
-        puts "$SOURCE/$1"
+    if [ -n "$C_TAP_BUILD" ] && [ -f "$C_TAP_BUILD/$1" ] ; then
+        puts "$C_TAP_BUILD/$1"
+    elif [ -n "$C_TAP_SOURCE" ] && [ -f "$C_TAP_SOURCE/$1" ] ; then
+        puts "$C_TAP_SOURCE/$1"
     else
         echo ''
     fi
 }
 
-# Create $BUILD/tmp for use by tests for storing temporary files and return
-# the path (via standard output).
+# Create $C_TAP_BUILD/tmp for use by tests for storing temporary files and
+# return the path (via standard output).
 #
 # This macro uses puts, so don't run it using backticks inside double quotes
 # or bizarre quoting behavior will happen with Solaris sh.
 test_tmpdir () {
-    if [ -z "$BUILD" ] ; then
+    if [ -z "$C_TAP_BUILD" ] ; then
         tap_tmpdir="./tmp"
     else
-        tap_tmpdir="$BUILD"/tmp
+        tap_tmpdir="$C_TAP_BUILD"/tmp
     fi
     if [ ! -d "$tap_tmpdir" ] ; then
         mkdir "$tap_tmpdir" || bail "Error creating $tap_tmpdir"
diff --git a/src/external/c-tap-harness/tests/tap/macros.h b/src/external/c-tap-harness/tests/tap/macros.h
index 33fee42d9..c2c8b5c73 100644
--- a/src/external/c-tap-harness/tests/tap/macros.h
+++ b/src/external/c-tap-harness/tests/tap/macros.h
@@ -6,9 +6,9 @@
  * everyone can pull them in.
  *
  * This file is part of C TAP Harness.  The current version plus supporting
- * documentation is at <http://www.eyrie.org/~eagle/software/c-tap-harness/>.
+ * documentation is at <https://www.eyrie.org/~eagle/software/c-tap-harness/>.
  *
- * Copyright 2008, 2012 Russ Allbery <rra@stanford.edu>
+ * Copyright 2008, 2012-2013, 2015 Russ Allbery <eagle@eyrie.org>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -27,6 +27,8 @@
  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  * DEALINGS IN THE SOFTWARE.
+ *
+ * SPDX-License-Identifier: MIT
  */
 
 #ifndef TAP_MACROS_H
@@ -40,9 +42,9 @@
  * the other attributes to work with GCC versions between 2.7 and 2.96.
  */
 #ifndef __attribute__
-# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
-#  define __attribute__(spec)   /* empty */
-# endif
+#    if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 96)
+#        define __attribute__(spec) /* empty */
+#    endif
 #endif
 
 /*
@@ -53,9 +55,18 @@
  * variadic macro support.
  */
 #if !defined(__attribute__) && !defined(__alloc_size__)
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
-#  define __alloc_size__(spec, args...) /* empty */
-# endif
+#    if defined(__GNUC__) && !defined(__clang__)
+#        if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 3)
+#            define __alloc_size__(spec, args...) /* empty */
+#        endif
+#    endif
+#endif
+
+/* Suppress __warn_unused_result__ if gcc is too old. */
+#if !defined(__attribute__) && !defined(__warn_unused_result__)
+#    if __GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4)
+#        define __warn_unused_result__ /* empty */
+#    endif
 #endif
 
 /*
@@ -65,7 +76,7 @@
  * compilation context, but there's no push and pop available.
  */
 #if !defined(__attribute__) && (defined(__llvm__) || defined(__clang__))
-# pragma GCC diagnostic ignored "-Wattributes"
+#    pragma GCC diagnostic ignored "-Wattributes"
 #endif
 
 /* Used for unused parameters to silence gcc warnings. */
@@ -78,11 +89,11 @@
 #undef BEGIN_DECLS
 #undef END_DECLS
 #ifdef __cplusplus
-# define BEGIN_DECLS    extern "C" {
-# define END_DECLS      }
+#    define BEGIN_DECLS extern "C" {
+#    define END_DECLS   }
 #else
-# define BEGIN_DECLS    /* empty */
-# define END_DECLS      /* empty */
+#    define BEGIN_DECLS /* empty */
+#    define END_DECLS   /* empty */
 #endif
 
 #endif /* TAP_MACROS_H */
diff --git a/src/fsint/Makefile.in b/src/fsint/Makefile.in
index c4cd13cea..aa4acf67e 100644
--- a/src/fsint/Makefile.in
+++ b/src/fsint/Makefile.in
@@ -11,7 +11,6 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp
 include @TOP_OBJDIR@/src/config/Makefile.lwptool
 
 LT_objs = \
-	afsaux.lo \
 	afscbint.cs.lo \
 	afsint.cs.lo \
 	afsint.xdr.lo
@@ -63,8 +62,6 @@ ${TOP_INCDIR}/afs/afscbint.h: afscbint.h
 ${TOP_INCDIR}/afs/pagcb.h: pagcb.h
 	${INSTALL_DATA} $? $@
 
-afsaux.lo: afsaux.c afsint.h
-
 Kcallback.cs.c: common.xg afscbint.xg Kvice.h Kcallback.h
 	${RXGEN} -A -x -k -C -o Kcallback.cs.c ${srcdir}/afscbint.xg
 
diff --git a/src/fsint/NTMakefile b/src/fsint/NTMakefile
index 72d0c644f..e262974da 100644
--- a/src/fsint/NTMakefile
+++ b/src/fsint/NTMakefile
@@ -30,7 +30,6 @@ LIBOBJS =\
 	$(OUT)\afsint.cs.obj 	\
 	$(OUT)\afsint.ss.obj 	\
 	$(OUT)\afsint.xdr.obj 	\
-	$(OUT)\afsaux.obj      \
 	$(OUT)\AFS_component_version_number.obj
 
 $(LIBFILE): $(LIBOBJS)
@@ -73,7 +72,6 @@ MT_LIBOBJS =\
 	$(OUT)\afsint.cs_mt.obj 	\
 	$(OUT)\afsint.ss_mt.obj 	\
 	$(OUT)\afsint.xdr_mt.obj 	\
-	$(OUT)\afsaux_mt.obj      \
 	$(OUT)\AFS_component_version_number.obj
 
 
@@ -95,9 +93,6 @@ $(OUT)\afsint.ss_mt.obj:afsint.ss.c
 $(OUT)\afsint.xdr_mt.obj:afsint.xdr.c
 	$(C2OBJ) $** -DAFS_PTHREAD_ENV
 
-$(OUT)\afsaux_mt.obj:afsaux.c
-	$(C2OBJ) $** -DAFS_PTHREAD_ENV
-
 $(MT_LIBFILE): $(MT_LIBOBJS)
 	$(LIBARCH)
 
diff --git a/src/fsint/afsaux.c b/src/fsint/afsaux.c
deleted file mode 100644
index cc1cbfecc..000000000
--- a/src/fsint/afsaux.c
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * 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>
-
-
-#ifdef KERNEL
-#if defined(UKERNEL)
-#include "afs/sysincludes.h"
-#include "afsincludes.h"
-#include "rx/xdr.h"
-#else /* defined(UKERNEL) */
-#if defined(AFS_NBSD50_ENV)
-#include "afs/afs_osi.h"
-#endif
-#if defined(AFS_OSF_ENV) || defined(AFS_LINUX20_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
-#include "afs/sysincludes.h"
-#include "afsincludes.h"
-#else
-#include "h/types.h"
-#include "rx/xdr.h"
-#endif
-#if !defined(AFS_ALPHA_ENV)
-#ifndef	XDR_GETINT32
-#define	XDR_GETINT32	XDR_GETLONG
-#endif
-#ifndef	XDR_PUTINT32
-#define	XDR_PUTINT32	XDR_PUTLONG
-#endif
-#endif
-#endif /* defined(UKERNEL) */
-#include "afsint.h"
-#else /* KERNEL */
-# include <roken.h>
-# include <rx/xdr.h>
-# include "afsint.h"
-#endif /* KERNEL */
-
-#ifdef KERNEL
-#define	NVALLOC(a)	osi_Alloc(a)
-#define	NVFREE(a,b)	osi_Free(a,b)
-#else /* KERNEL */
-#define MAXBS	2048		/* try to avoid horrible allocs */
-static afs_int32 bslosers = 0;
-#define	NVALLOC(a)	malloc(a)
-#define	NVFREE(a,b)	free(a)
-#endif /* KERNEL */
-
-/* these things are defined in R (but not RX's) library.  For now, we add them
-    only for the kernel system.  Later, when R is expunged, we'll remove the ifdef */
-#ifdef KERNEL
-#ifndef AFS_USR_DARWIN_ENV
-/*
- * Wrapper for xdr_string that can be called directly from
- * routines like clnt_call; from user-mode xdr package.
- */
-#ifndef	AFS_SUN5_ENV
-#ifndef AFS_HPUX110_ENV
-bool_t
-xdr_wrapstring(XDR * xdrs, char **cpp)
-{
-    if (xdr_string(xdrs, cpp, 1024)) {
-	return (TRUE);
-    }
-    return (FALSE);
-}
-#endif /* AFS_HPUX110_ENV */
-#endif /* AFS_SUN5_ENV */
-
-#endif
-#endif /* KERNEL */
-
-#ifndef KERNEL
-bool_t
-xdr_CBS(XDR * x, struct CBS * abbs)
-{
-    afs_int32 len;
-    if (x->x_op == XDR_FREE) {
-	NVFREE(abbs->SeqBody, abbs->SeqLen);
-	return TRUE;
-    }
-
-    if (x->x_op == XDR_ENCODE) {
-	xdr_afs_int32(x, &abbs->SeqLen);
-	xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
-	return TRUE;
-    } else {
-	xdr_afs_int32(x, &len);
-	if (len < 0 || len > MAXBS) {
-	    bslosers++;
-	    return FALSE;
-	}
-	if (!abbs->SeqBody)
-	    abbs->SeqBody = NVALLOC(len);
-	abbs->SeqLen = len;
-	xdr_opaque(x, abbs->SeqBody, len);
-	return TRUE;
-    }
-}
-
-bool_t
-xdr_BBS(XDR * x, struct BBS * abbs)
-{
-    afs_int32 maxLen, len;
-    if (x->x_op == XDR_FREE) {
-	NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
-	return TRUE;
-    }
-
-    if (x->x_op == XDR_ENCODE) {
-	xdr_afs_int32(x, &abbs->MaxSeqLen);
-	xdr_afs_int32(x, &abbs->SeqLen);
-	xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
-	return TRUE;
-    } else {
-	xdr_afs_int32(x, &maxLen);
-	xdr_afs_int32(x, &len);
-	if (len < 0 || len > MAXBS || len > maxLen) {
-	    bslosers++;
-	    return FALSE;
-	}
-	if (!abbs->SeqBody)
-	    abbs->SeqBody = NVALLOC(maxLen);
-	abbs->MaxSeqLen = maxLen;
-	abbs->SeqLen = len;
-	xdr_opaque(x, abbs->SeqBody, len);
-	return TRUE;
-    }
-}
-
-bool_t
-xdr_AFSAccessList(XDR * x, AFSAccessList * abbs)
-{
-    afs_int32 maxLen, len;
-    if (x->x_op == XDR_FREE) {
-	NVFREE(abbs->SeqBody, abbs->MaxSeqLen);
-	return TRUE;
-    }
-
-    if (x->x_op == XDR_ENCODE) {
-	xdr_afs_int32(x, &abbs->MaxSeqLen);
-	xdr_afs_int32(x, &abbs->SeqLen);
-	xdr_opaque(x, abbs->SeqBody, abbs->SeqLen);
-	return TRUE;
-    } else {
-	xdr_afs_int32(x, &maxLen);
-	xdr_afs_int32(x, &len);
-	if (len < 0 || len > MAXBS || len > maxLen) {
-	    bslosers++;
-	    return FALSE;
-	}
-	if (!abbs->SeqBody)
-	    abbs->SeqBody = NVALLOC(maxLen);
-	abbs->MaxSeqLen = maxLen;
-	abbs->SeqLen = len;
-	xdr_opaque(x, abbs->SeqBody, len);
-	return TRUE;
-    }
-}
-#endif /* KERNEL */
diff --git a/src/fsint/afsint.xg b/src/fsint/afsint.xg
index 9fe4980c6..704f61bc3 100644
--- a/src/fsint/afsint.xg
+++ b/src/fsint/afsint.xg
@@ -18,23 +18,6 @@
 %#define VICETOKENDEAD	1235
 %#define AFS_LOCKWAIT	(5*60)
 
-customized struct CBS {
-    afs_int32 SeqLen;
-    char *SeqBody;
-};
-
-customized struct BBS {
-    afs_int32 MaxSeqLen;
-    afs_int32 SeqLen;
-    char *SeqBody;
-};
-
-customized struct AFSAccessList {
-    afs_int32 MaxSeqLen;
-    afs_int32 SeqLen;
-    char *SeqBody;
-};
-
 typedef afs_int32 ViceDataType;
 
 %#define Invalid 0
@@ -46,12 +29,6 @@ typedef afs_int32 ViceDataType;
 %#define      afs_xdr_array(a,b,c,d,e,f)  afs_xdr_arrayN(a,b,c,d,e,f)
 %#endif
 
-struct BD {
-    afs_int32 host;
-    afs_int32 portal;
-    afs_int32 session;
-};
-
 struct AFSVolSync {
     afs_uint32 spare1;
     afs_uint32 spare2;
@@ -61,25 +38,6 @@ struct AFSVolSync {
     afs_uint32 spare6;
 };
 
-struct AFSOldFetchStatus {
-    afs_uint32 InterfaceVersion;
-    afs_uint32 FileType;
-    afs_uint32 LinkCount;
-    afs_uint32 Length;
-    afs_uint32 DataVersion;
-    afs_uint32 Author;
-    afs_uint32 Owner;
-    afs_uint32 CallerAccess;
-    afs_uint32 AnonymousAccess;
-    afs_uint32 UnixModeBits;
-    afs_uint32 ParentVnode;
-    afs_uint32 ParentUnique;
-    afs_uint32 SegSize;
-    afs_uint32 ClientModTime;
-    afs_uint32 ServerModTime;
-    afs_uint32 Group;
-};
-
 struct AFSFetchStatus {
     afs_uint32 InterfaceVersion;
     afs_uint32 FileType;
diff --git a/src/fsprobe/.gitignore b/src/fsprobe/.gitignore
index bf549b4dd..72f58f19e 100644
--- a/src/fsprobe/.gitignore
+++ b/src/fsprobe/.gitignore
@@ -2,4 +2,6 @@
 #     git ls-files -i --exclude-standard
 # to check that you haven't inadvertently ignored any tracked files.
 
+/afscbint.h
+/afscbint.ss.c
 /fsprobe_test
diff --git a/src/fsprobe/Makefile.in b/src/fsprobe/Makefile.in
index 3056500e7..fa9cb2619 100644
--- a/src/fsprobe/Makefile.in
+++ b/src/fsprobe/Makefile.in
@@ -7,29 +7,30 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
-
-
-RPCINCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/rx/rx.h
-
-INCLS=fsprobe.h ${RPCINCLS}
-
-LIBS=${TOP_LIBDIR}/libvolser.a ${TOP_LIBDIR}/vlib.a ${TOP_LIBDIR}/libacl.a \
-        ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libvldb.a \
-        ${TOP_LIBDIR}/libubik.a \
-        ${TOP_LIBDIR}/libauth.a ${TOP_LIBDIR}/libsys.a \
-        ${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/librxkad.a \
-        ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/libkauth.a \
-	${TOP_LIBDIR}/libaudit.a \
-	${TOP_LIBDIR}/libafsint.a \
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/liblwp.a \
-	${TOP_LIBDIR}/libsys.a \
-	${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libopr.a \
-	${TOP_LIBDIR}/libafsrfc3961.a \
-	${TOP_LIBDIR}/libafshcrypto_lwp.a
-
-all: ${TOP_INCDIR}/afs/fsprobe.h ${TOP_LIBDIR}/libfsprobe.a fsprobe_test
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
+
+INCLS=fsprobe.h ${TOP_INCDIR}/rx/rx.h
+
+LT_deps = \
+	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
+	$(top_builddir)/src/fsint/liboafs_fsint.la \
+	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/opr/liboafs_opr.la \
+	$(top_builddir)/src/volser/liboafs_volser.la
+
+LT_objs = \
+    fsprobe.lo \
+    fsprobe_callback.lo \
+    afscbint.ss.lo \
+    AFS_component_version_number.lo
+
+all: \
+    liboafs_fsprobe.la \
+    ${TOP_INCDIR}/afs/fsprobe.h \
+    ${TOP_LIBDIR}/libfsprobe.a \
+    fsprobe_test
 
 ${TOP_INCDIR}/afs/fsprobe.h: fsprobe.h
 	${INSTALL_DATA} $? $@
@@ -40,18 +41,29 @@ ${TOP_LIBDIR}/libfsprobe.a: libfsprobe.a
 #
 # Build targets
 #
-libfsprobe.a: fsprobe.o fsprobe_callback.o AFS_component_version_number.o
-	-$(RM) -f $@
-	$(AR) crv $@ fsprobe.o fsprobe_callback.o AFS_component_version_number.o
-	$(RANLIB) $@
+liboafs_fsprobe.la: liboafs_fsprobe.la.sym $(LT_objs) $(LT_deps)
+	$(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
 
-fsprobe.o: fsprobe.c ${INCLS} AFS_component_version_number.c
+libfsprobe.a: $(LT_objs)
+	$(LT_LDLIB_static) $(LT_objs)
 
-fsprobe_callback.o: fsprobe_callback.c ${INCLS}
+# afscbint.ss.c is required for RXAFSCB_ExecuteRequest.
+afscbint.h: $(top_builddir)/src/fsint/afscbint.h
+	${INSTALL_DATA} $? $@
 
-fsprobe_test: fsprobe_test.o libfsprobe.a ${LIBS}
-	$(AFS_LDRULE) fsprobe_test.o libfsprobe.a \
-		${LIBS} $(LIB_roken) ${XLIBS}
+afscbint.ss.c: $(top_builddir)/src/fsint/afscbint.ss.c
+	${INSTALL_DATA} $? $@
+
+fsprobe.lo: fsprobe.c ${INCLS} AFS_component_version_number.c
+fsprobe_callback.lo: fsprobe_callback.c ${INCLS}
+afscbint.ss.lo: afscbint.ss.c afscbint.h
+
+#
+# Test programs
+#
+fsprobe_test: fsprobe_test.o libfsprobe.a $(LT_deps)
+	$(LT_LDRULE_static) fsprobe_test.o libfsprobe.a \
+		$(LT_deps) $(LIB_roken) ${XLIBS}
 
 #
 # Install targets
@@ -72,6 +84,8 @@ dest: fsprobe.h libfsprobe.a
 # Misc others
 #
 clean:
-	$(RM) -f *.o fsprobe_test libfsprobe.a core AFS_component_version_number.c
+	$(LT_CLEAN)
+	$(RM) -f *.o afscbint.ss.c afscbint.h fsprobe_test libfsprobe.a \
+		core AFS_component_version_number.c
 
 include ../config/Makefile.version
diff --git a/src/fsprobe/fsprobe.c b/src/fsprobe/fsprobe.c
index 1ca1b5ad7..e19600eeb 100644
--- a/src/fsprobe/fsprobe.c
+++ b/src/fsprobe/fsprobe.c
@@ -18,7 +18,7 @@
 
 #include <roken.h>
 
-#include <lwp.h>		/*Lightweight process package */
+#include <pthread.h>
 #include <afs/cellconfig.h>
 #include <afs/afsint.h>
 #include <afs/afsutil.h>
@@ -29,8 +29,6 @@
 
 #include "fsprobe.h"		/*Interface for this module */
 
-#define LWP_STACK_SIZE	(16 * 1024)
-
 /*
  * Exported variables.
  */
@@ -45,9 +43,11 @@ int fsprobe_ProbeFreqInSecs;	/*Probe freq. in seconds */
 static int fsprobe_initflag = 0;	/*Was init routine called? */
 static int fsprobe_debug = 0;	/*Debugging output enabled? */
 static int (*fsprobe_Handler) (void);	/*Probe handler routine */
-static PROCESS probeLWP_ID;	/*Probe LWP process ID */
+static pthread_t fsprobe_thread;	/*Probe thread */
 static int fsprobe_statsBytes;	/*Num bytes in stats block */
 static int fsprobe_probeOKBytes;	/*Num bytes in probeOK block */
+static opr_mutex_t fsprobe_force_lock;	/*Lock to force probe */
+static opr_cv_t fsprobe_force_cv;	/*Condvar to force probe */
 
 /*------------------------------------------------------------------------
  * [private] fsprobe_CleanupInit
@@ -194,7 +194,7 @@ fsprobe_Cleanup(int a_releaseMem)
  * [private] fsprobe_LWP
  *
  * Description:
- *	This LWP iterates over the server connections and gathers up
+ *	This thread iterates over the server connections and gathers up
  *	the desired statistics from each one on a regular basis.  When
  *	the sweep is done, the associated handler function is called
  *	to process the new data.
@@ -218,6 +218,7 @@ fsprobe_LWP(void *unused)
     static char rn[] = "fsprobe_LWP";	/*Routine name */
     afs_int32 code;	/*Results of calls */
     struct timeval tv;		/*Time structure */
+    struct timespec wait;	/*Time to wait */
     int conn_idx;		/*Connection index */
     struct fsprobe_ConnectionInfo *curr_conn;	/*Current connection */
     struct ProbeViceStatistics *curr_stats;	/*Current stats region */
@@ -352,24 +353,19 @@ fsprobe_LWP(void *unused)
 		    rn, code);
 
 	/*
-	 * Fall asleep for the prescribed number of seconds.
+	 * Fall asleep for the prescribed number of seconds or wakeup
+	 * sooner if forced.
 	 */
-	tv.tv_sec = fsprobe_ProbeFreqInSecs;
-	tv.tv_usec = 0;
-	if (fsprobe_debug)
-	    fprintf(stderr, "[%s] Falling asleep for %d seconds\n", rn,
-		    fsprobe_ProbeFreqInSecs);
-	code = IOMGR_Select(0,	/*Num fids */
-			    0,	/*Descriptors ready for reading */
-			    0,	/*Descriptors ready for writing */
-			    0,	/*Descriptors w/exceptional conditions */
-			    &tv);	/*Ptr to timeout structure */
-	if (code)
-	    fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn, code);
+	gettimeofday(&tv, NULL);
+	wait.tv_sec = tv.tv_sec + fsprobe_ProbeFreqInSecs;
+	wait.tv_nsec = tv.tv_usec * 1000;
+	opr_mutex_enter(&fsprobe_force_lock);
+	code = opr_cv_timedwait(&fsprobe_force_cv, &fsprobe_force_lock, &wait);
+	opr_Assert(code == 0 || code == ETIMEDOUT);
+	opr_mutex_exit(&fsprobe_force_lock);
     }				/*Service loop */
-    free(stats64.ViceStatistics64_val);
-
-    return NULL;
+    AFS_UNREACHED(free(stats64.ViceStatistics64_val));
+    AFS_UNREACHED(return(NULL));
 }				/*fsprobe_LWP */
 
 /*list all the partitions on <aserver> */
@@ -440,7 +436,7 @@ XListPartitions(struct rx_connection *aconn, struct partList *ptrPartList,
  *
  * Description:
  *	Initialize the fsprobe module: set up Rx connections to the
- *	given set of servers, start up the probe and callback LWPs,
+ *	given set of servers, start up the probe and callback threads,
  *	and associate the routine to be called when a probe completes.
  *
  * Arguments:
@@ -453,7 +449,7 @@ XListPartitions(struct rx_connection *aconn, struct partList *ptrPartList,
  * Returns:
  *	0 on success,
  *	-2 for (at least one) connection error,
- *	LWP process creation code, if it failed,
+ *	thread process creation code, if it failed,
  *	-1 for other fatal errors.
  *
  * Environment:
@@ -492,6 +488,9 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     } else
 	fsprobe_initflag = 1;
 
+    opr_mutex_init(&fsprobe_force_lock);
+    opr_cv_init(&fsprobe_force_cv);
+
     /*
      * Check the parameters for bogosities.
      */
@@ -510,7 +509,7 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 		a_ProbeFreqInSecs);
 	arg_errfound = 1;
     }
-    if (a_ProbeHandler == (int (*)())0) {
+    if (a_ProbeHandler == NULL) {
 	fprintf(stderr, "[%s] Null probe handler function argument\n", rn);
 	arg_errfound = 1;
     }
@@ -544,11 +543,6 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 		(a_numServers * sizeof(struct fsprobe_ConnectionInfo)));
 	return (-1);		/*No cleanup needs to be done yet */
     }
-#if 0
-    else
-	fprintf(stderr, "[%s] fsprobe_ConnInfo allocated (%d bytes)\n", rn,
-		a_numServers * sizeof(struct fsprobe_ConnectionInfo));
-#endif /* 0 */
 
     fsprobe_statsBytes = a_numServers * sizeof(struct ProbeViceStatistics);
     fsprobe_Results.stats = (struct ProbeViceStatistics *)
@@ -610,18 +604,18 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 
     /*
      * Create a null Rx client security object, to be used by the
-     * probe LWP.
+     * probe thread.
      */
     secobj = rxnull_NewClientSecurityObject();
     if (secobj == (struct rx_securityClass *)0) {
 	fprintf(stderr,
-		"[%s] Can't create client security object for probe LWP.\n",
+		"[%s] Can't create client security object for probe thread.\n",
 		rn);
 	fsprobe_Cleanup(1);	/*Delete already-malloc'ed areas */
 	return (-1);
     }
     if (fsprobe_debug)
-	fprintf(stderr, "[%s] Probe LWP client security object created\n",
+	fprintf(stderr, "[%s] Probe thread client security object created\n",
 		rn);
 
     curr_conn = fsprobe_ConnInfo;
@@ -744,37 +738,20 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
      */
     if (fsprobe_debug)
 	fprintf(stderr, "[%s] Starting up callback listener.\n", rn);
-    rx_StartServer(0 /*Don't donate yourself to LWP pool */ );
+    rx_StartServer(0 /*Don't donate yourself to thread pool */ );
 
     /*
-     * Start up the probe LWP.
+     * Start up the probe thread.
      */
     if (fsprobe_debug)
-	fprintf(stderr, "[%s] Creating the probe LWP\n", rn);
-    code = LWP_CreateProcess(fsprobe_LWP,	/*Function to start up */
-			     LWP_STACK_SIZE,	/*Stack size in bytes */
-			     1,	/*Priority */
-			     (void *)0,	/*Parameters */
-			     "fsprobe Worker",	/*Name to use */
-			     &probeLWP_ID);	/*Returned LWP process ID */
+	fprintf(stderr, "[%s] Creating the probe thread\n", rn);
+    code = pthread_create(&fsprobe_thread, NULL, fsprobe_LWP, NULL);
     if (code) {
-	fprintf(stderr, "[%s] Can't create fsprobe LWP!  Error is %d\n", rn,
+	fprintf(stderr, "[%s] Can't create fsprobe thread!  Error is %d\n", rn,
 		code);
 	fsprobe_Cleanup(1);	/*Delete already-malloc'ed areas */
 	return (code);
     }
-    if (fsprobe_debug)
-	fprintf(stderr, "[%s] Probe LWP process structure located at %p\n",
-		rn, probeLWP_ID);
-
-#if 0
-    /*
-     * Do I need to do this?
-     */
-    if (fsprobe_debug)
-	fprintf(stderr, "[%s] Calling osi_Wakeup()\n", rn);
-    osi_Wakeup(&rxsrv_afsserver);	/*Wake up anyone waiting for it */
-#endif /* 0 */
 
     /*
      * Return the final results.
@@ -791,7 +768,7 @@ fsprobe_Init(int a_numServers, struct sockaddr_in *a_socketArray,
  * [exported] fsprobe_ForceProbeNow
  *
  * Description:
- *	Wake up the probe LWP, forcing it to execute a probe immediately.
+ *	Wake up the probe thread, forcing it to execute a probe immediately.
  *
  * Arguments:
  *	None.
@@ -824,7 +801,9 @@ fsprobe_ForceProbeNow(void)
     /*
      * Kick the sucker in the side.
      */
-    IOMGR_Cancel(probeLWP_ID);
+    opr_mutex_enter(&fsprobe_force_lock);
+    opr_cv_signal(&fsprobe_force_cv);
+    opr_mutex_exit(&fsprobe_force_lock);
 
     /*
      * We did it, so report the happy news.
@@ -832,3 +811,44 @@ fsprobe_ForceProbeNow(void)
     return (0);
 
 }				/*fsprobe_ForceProbeNow */
+
+/*------------------------------------------------------------------------
+ * [exported] fsprobe_Wait
+ *
+ * Description:
+ *	Wait for the collection to complete.
+ *
+ * Arguments:
+ *    int sleep_secs : time to wait in seconds. 0 means sleep forever.
+ *
+ * Returns:
+ *	0 on success,
+ *	Error value otherwise.
+ *
+ * Environment:
+ *	The module must have been initialized.
+ *
+ * Side Effects:
+ *	As advertised.
+ *------------------------------------------------------------------------*/
+int
+fsprobe_Wait(int sleep_secs)
+{
+    int code;
+    struct timeval tv;
+
+    if (sleep_secs == 0) {
+	while (1) {
+	    tv.tv_sec = 30;
+	    tv.tv_usec = 0;
+	    code = select(0, 0, 0, 0, &tv);
+	    if (code < 0)
+		break;
+	}
+    } else {
+	tv.tv_sec = sleep_secs;
+	tv.tv_usec = 0;
+	code = select(0, 0, 0, 0, &tv);
+    }
+    return code;
+}
diff --git a/src/fsprobe/fsprobe.h b/src/fsprobe/fsprobe.h
index 94083bfe9..70c3637e9 100644
--- a/src/fsprobe/fsprobe.h
+++ b/src/fsprobe/fsprobe.h
@@ -103,7 +103,6 @@ struct fsprobe_ProbeResults {
 
 extern int fsprobe_numServers;	/*# servers connected */
 extern struct fsprobe_ConnectionInfo *fsprobe_ConnInfo;	/*Ptr to connections */
-extern int numCollections;	/*Num data collections */
 extern struct fsprobe_ProbeResults fsprobe_Results;	/*Latest probe results */
 
 extern int fsprobe_Init(int, struct sockaddr_in *, int, int (*)(void), int );
@@ -152,4 +151,6 @@ extern int fsprobe_Cleanup(int);
      *          with the fsprobe connection array.
      */
 
+extern int fsprobe_Wait(int);
+
 #endif /* __fsprobe_h */
diff --git a/src/fsprobe/fsprobe_test.c b/src/fsprobe/fsprobe_test.c
index 941c8c728..7d78b6a1a 100644
--- a/src/fsprobe/fsprobe_test.c
+++ b/src/fsprobe/fsprobe_test.c
@@ -148,7 +148,6 @@ main(int argc, char **argv)
     afs_int32 code;	/*Return code */
     struct sockaddr_in FSSktArray[3];	/*socket array */
     struct hostent *he;		/*Host entry */
-    struct timeval tv;		/*Time structure */
     int sleep_secs;		/*Number of seconds to sleep */
 
     printf("\n\nTest of the fsprobe facility.\n\n");
@@ -211,20 +210,7 @@ main(int argc, char **argv)
 	("Fsprobe service started, main thread sleeping for %d seconds...\n",
 	 sleep_secs);
 
-    /*
-     * Let's just fall asleep for a while, then we'll clean up.
-     */
-    tv.tv_sec = sleep_secs;
-    tv.tv_usec = 0;
-    code = IOMGR_Select(0,	/*Num fds */
-			0,	/*Descriptors ready for reading */
-			0,	/*Descriptors ready for writing */
-			0,	/*Descriptors with exceptional conditions */
-			&tv);	/*Timeout structure */
-    if (code) {
-	fprintf(stderr, "[%s] IOMGR_Select() returned non-zero value: %d\n",
-		rn, code);
-    }
+    fsprobe_Wait(sleep_secs);
 
     /*
      * We're all done.  Clean up, put the last nail in Rx, then
diff --git a/src/fsprobe/liboafs_fsprobe.la.sym b/src/fsprobe/liboafs_fsprobe.la.sym
new file mode 100644
index 000000000..8178f234c
--- /dev/null
+++ b/src/fsprobe/liboafs_fsprobe.la.sym
@@ -0,0 +1,4 @@
+fsprobe_Cleanup
+fsprobe_ForceProbeNow
+fsprobe_Init
+fsprobe_Wait
diff --git a/src/gtx/Makefile.in b/src/gtx/Makefile.in
index 1688e6f5e..31a25a395 100644
--- a/src/gtx/Makefile.in
+++ b/src/gtx/Makefile.in
@@ -9,10 +9,11 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
 
-
-INCLS=gtxobjects.h \
+INCLS = \
+	gtxobjects.h \
 	gtxwindows.h \
 	gtxcurseswin.h \
 	gtxinput.h \
@@ -28,50 +29,31 @@ INCLS=gtxobjects.h \
 	${TOP_INCDIR}/afs/cellconfig.h \
 	${TOP_INCDIR}/afs/cmd.h
 
-LIBS=\
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/liblwp.a \
-	${TOP_LIBDIR}/libsys.a \
-	${TOP_LIBDIR}/libcmd.a \
-	${TOP_LIBDIR}/libkauth.a \
-	${TOP_LIBDIR}/libauth.a \
-	${TOP_LIBDIR}/librxkad.a \
-	${TOP_LIBDIR}/libafsrfc3961.a \
-	${TOP_LIBDIR}/libafscom_err.a \
-	${TOP_LIBDIR}/libopr.a \
-	${TOP_LIBDIR}/util.a
-
-EXTRA_LIBS=${LIB_curses} ${XLIBS}
-
-KEYMAP_SRCS=keymap.c input.c frame.c
-
-KEYMAP_OBJS=keymap.o input.o frame.o
-
-WINDOW_SRCS=curseswindows.c \
-	dumbwindows.c \
-	X11windows.c \
-	windows.c
-
-WINDOW_OBJS=curseswindows.o \
-	dumbwindows.o \
-	X11windows.o \
-	windows.o
-
-OBJECT_SRCS=objects.c \
-	lightobject.c \
-	textobject.c
-
-OBJECT_OBJS=objects.o \
-	lightobject.o \
-	textobject.o
-
-DICT_SRCS=objdict.c
-DICT_OBJS=objdict.o
-
-CB_SRCS=textcb.c
-CB_OBJS=textcb.o
-
-all: gtxtest \
+LT_objs = \
+    AFS_component_version_number.lo \
+    keymap.lo \
+    input.lo \
+    frame.lo \
+    curseswindows.lo \
+    dumbwindows.lo \
+    X11windows.lo \
+    windows.lo \
+    objects.lo \
+    lightobject.lo \
+    textobject.lo \
+    objdict.lo \
+    textcb.lo
+
+LT_libs = \
+	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
+	$(top_builddir)/src/fsint/liboafs_fsint.la \
+	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/opr/liboafs_opr.la \
+	$(top_builddir)/src/lwp/liboafs_lwpcompat.la
+
+all: \
+    liboafs_gtx.la \
 	${TOP_LIBDIR}/libgtx.a \
 	${TOP_INCDIR}/afs/gtxcurseswin.h \
 	${TOP_INCDIR}/afs/gtxdumbwin.h \
@@ -125,72 +107,50 @@ ${TOP_INCDIR}/afs/gtxwindows.h: gtxwindows.h
 ${TOP_INCDIR}/afs/gtxX11win.h: gtxX11win.h
 	${INSTALL_DATA} $? $@
 
-tests: object_test screen_test curses_test cb_test gtxtest
-
-# All objects in the library
-LIBSRCS = ${KEYMAP_SRCS} ${WINDOW_SRCS} ${OBJECT_SRCS} ${DICT_SRCS} ${CB_SRCS}
-LIBOBJS = $(KEYMAP_OBJS) ${WINDOW_OBJS} ${OBJECT_OBJS} ${DICT_OBJS} ${CB_OBJS}
-
-${LIBSRCS}: ${INCLS}
-$(LIBOBJS): ${INCLS}
-
-keymap.o: keymap.c ${INCLS}
-
-frame.o: frame.c $(INCLS)
-
-input.o: input.c ${INCLS}
-
-curseswindows.o: curseswindows.c ${INCLS}
-
-dumbwindows.o: dumbwindows.c ${INCLS}
-
-X11windows.o: X11windows.c ${INCLS}
-
-windows.o: windows.c ${INCLS}
-
-lightobject.o: lightobject.c ${INCLS}
-
-textobject.o: textobject.c ${INCLS}
-
-textcb.o: textcb.c ${INCLS}
-
 #
-# Test programs.
+# Build targets
 #
-curses_test.o: curses_test.c ${INCLS} AFS_component_version_number.o
-
-curses_test: curses_test.o $(LIBS)
-	$(AFS_LDRULE) curses_test.o $(LIBS) ${EXTRA_LIBS}
-
-screen_test.o: screen_test.c ${INCLS} AFS_component_version_number.o
-
-screen_test: screen_test.o ${WINDOW_OBJS} ${LIBS}
-	$(AFS_LDRULE) screen_test.o ${WINDOW_OBJS} ${LIBS} ${EXTRA_LIBS}
+liboafs_gtx.la: liboafs_gtx.la.sym $(LT_objs) $(LT_deps)
+	$(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
+
+libgtx.a: $(LT_objs)
+	$(LT_LDLIB_static) $(LT_objs)
+
+keymap.lo: keymap.c ${INCLS}
+frame.lo: frame.c $(INCLS)
+input.lo: input.c ${INCLS}
+curseswindows.lo: curseswindows.c ${INCLS}
+dumbwindows.lo: dumbwindows.c ${INCLS}
+X11windows.lo: X11windows.c ${INCLS}
+windows.lo: windows.c ${INCLS}
+lightobject.lo: lightobject.c ${INCLS}
+textobject.lo: textobject.c ${INCLS}
+objdict.lo: objdict.c ${INCLS}
+textcb.lo: textcb.c ${INCLS}
 
-cb_test.o: cb_test.c ${INCLS} AFS_component_version_number.o
+#
+# Test programs
+#
+tests: object_test screen_test curses_test cb_test gtxtest
 
-cb_test: cb_test.o ${CB_OBJS} ${LIBS}
-	$(AFS_LDRULE) cb_test.o ${CB_OBJS} ${LIBS} ${EXTRA_LIBS}
+object_test: object_test.o liboafs_gtx.la
+	$(LT_LDRULE_static) object_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-gtxtest.o: gtxtest.c ${INCLS} AFS_component_version_number.o
+screen_test: screen_test.o liboafs_gtx.la
+	$(LT_LDRULE_static) screen_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-gtxtest: gtxtest.o libgtx.a ${LIBS}
-	$(AFS_LDRULE) gtxtest.o libgtx.a ${LIBS} ${EXTRA_LIBS}
+curses_test: curses_test.o liboafs_gtx.la
+	$(LT_LDRULE_static) curses_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-object_test.o: object_test.c ${INCLS} AFS_component_version_number.o
+cb_test: cb_test.o liboafs_gtx.la
+	$(LT_LDRULE_static) cb_test.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
-object_test: object_test.o ${WINDOW_OBJS} ${DICT_OBJS} ${OBJECT_OBJS} ${CB_OBJS} ${LIBS}
-	$(AFS_LDRULE) object_test.o ${WINDOW_OBJS} ${DICT_OBJS} \
-		${OBJECT_OBJS} ${CB_OBJS} ${LIBS} ${EXTRA_LIBS}
+gtxtest: gtxtest.o liboafs_gtx.la
+	$(LT_LDRULE_static) gtxtest.o liboafs_gtx.la ${LIB_curses} ${XLIBS}
 
 #
 # Installation targets
 #
-libgtx.a: ${LIBOBJS} AFS_component_version_number.o
-	-$(RM) -f $@
-	$(AR) crv $@ ${LIBOBJS} AFS_component_version_number.o
-	${RANLIB} $@
-
 install: libgtx.a
 	${INSTALL} -d ${DESTDIR}${libdir}/afs
 	${INSTALL} -d ${DESTDIR}${includedir}/afs
@@ -229,6 +189,7 @@ dest: libgtx.a
 # Misc targets
 #
 clean:
+	$(LT_CLEAN)
 	$(RM) -f  *.o *.a *.ln object_test screen_test curses_test core cb_test gtxtest AFS_component_version_number.c
 
 include ../config/Makefile.version
diff --git a/src/gtx/curses_test.c b/src/gtx/curses_test.c
index c2710d1fb..7c1fd7fa8 100644
--- a/src/gtx/curses_test.c
+++ b/src/gtx/curses_test.c
@@ -51,14 +51,6 @@ main(argc, argv)
     refresh();
     standend();
 
-#if 0
-    box addstr("Enter a string and a number: ");
-    refresh();
-    scanw(stdscr, "%s %d", str, &i);
-    wprintw(stdscr, "String was '%s', number was %d\n", str, i);
-    refresh();
-#endif /* 0 */
-
     endwin();
 
 }				/*main */
diff --git a/src/gtx/curseswindows.c b/src/gtx/curseswindows.c
index ecd6d8b83..0c2001794 100644
--- a/src/gtx/curseswindows.c
+++ b/src/gtx/curseswindows.c
@@ -20,7 +20,7 @@
 
 #include <roken.h>
 
-#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD80_ENV)
+#if !defined(AFS_SUN5_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_FBSD_ENV)
 #include <sgtty.h>
 #endif
 
diff --git a/src/gtx/gtxX11win.h b/src/gtx/gtxX11win.h
index f911b9709..8527809f1 100644
--- a/src/gtx/gtxX11win.h
+++ b/src/gtx/gtxX11win.h
@@ -15,17 +15,6 @@
 /*Value for gwin w_type field*/
 #define	GATOR_WIN_X11    3
 
-/*Private data for a X11 gwin*/
-#if 0
-struct gator_X11gwin {
-    WINDOW *wp;			/*Window pointer */
-    int charwidth;		/*Character width in pixels */
-    int charheight;		/*Character height in pixels */
-    char box_vertchar;		/*Vertical char for boxing purposes */
-    char box_horizchar;		/*Horizontal char for boxing purposes */
-};
-#endif /* 0 */
-
 /*X11 gwin's creation parameters*/
 struct gator_X11gwin_params {
     struct gwin_createparams gwin_params;	/*Basic params for the window */
diff --git a/src/gtx/gtxdumbwin.h b/src/gtx/gtxdumbwin.h
index dc0789e59..0d5f8500f 100644
--- a/src/gtx/gtxdumbwin.h
+++ b/src/gtx/gtxdumbwin.h
@@ -15,17 +15,6 @@
 /*Value for gwin w_type field*/
 #define	GATOR_WIN_DUMB    1
 
-/*Private data for a dumb gwin*/
-#if 0
-struct gator_dumbgwin {
-    WINDOW *wp;			/*Window pointer */
-    int charwidth;		/*Character width in pixels */
-    int charheight;		/*Character height in pixels */
-    char box_vertchar;		/*Vertical char for boxing purposes */
-    char box_horizchar;		/*Horizontal char for boxing purposes */
-};
-#endif /* 0 */
-
 /*Dumb gwin's creation parameters*/
 struct gator_dumbgwin_params {
     struct gwin_createparams gwin_params;	/*Basic params for the window */
diff --git a/src/gtx/gtxtest.c b/src/gtx/gtxtest.c
index 3626a36d7..64876e7c7 100644
--- a/src/gtx/gtxtest.c
+++ b/src/gtx/gtxtest.c
@@ -234,7 +234,7 @@ main(int argc, char **argv)
     keymap_BindToString(frameB->keymap, "a", SwitchToACmd, NULL, NULL);
     keymap_BindToString(frameB->keymap, "b", StupidCmd, NULL, NULL);
     keymap_BindToString(frameB->keymap, "d", NoCallCmd, NULL, NULL);
-    keymap_BindToString(frameB->keymap, "d", (int (*)())0, NULL, NULL);
+    keymap_BindToString(frameB->keymap, "d", NULL, NULL, NULL);
     keymap_BindToString(frameB->keymap, "\033d", NoCallCmd, NULL, NULL);
     gtxframe_AddMenu(frameB, "FrameA", "a");
 
diff --git a/src/gtx/input.c b/src/gtx/input.c
index f7303f6aa..c1f1c479f 100644
--- a/src/gtx/input.c
+++ b/src/gtx/input.c
@@ -12,7 +12,7 @@
 
 #include <roken.h>
 
-#include <lwp.h>
+#include <pthread.h>
 
 #include "gtxobjects.h"
 #include "gtxwindows.h"
@@ -21,6 +21,7 @@
 #include "gtxkeymap.h"
 #include "gtxframe.h"
 #include <afs/stds.h>
+#include <afs/opr.h>
 
 
 /* process input */
@@ -65,7 +66,7 @@ struct gwin *
 gtx_Init(int astartInput,
 	 int atype)			/* type of window to create */
 {
-    PROCESS junk;
+    pthread_t thread_id;
     struct onode_initparams oi_params;	/* object init params */
     struct gwin_initparams wi_params;	/* window initialization params */
     struct gwin *twin;
@@ -91,12 +92,8 @@ gtx_Init(int astartInput,
 	return NULL;
 
     /* if we start input thread */
-    IOMGR_Initialize();		/* input thread uses it */
     if (astartInput) {
-	code = LWP_CreateProcess(gtx_InputServer, 8192, LWP_NORMAL_PRIORITY,
-			         NULL, "gx-listener", &junk);
-	if (code)
-	    return NULL;
+	opr_Verify(pthread_create(&thread_id, NULL, gtx_InputServer, NULL) == 0);
     }
 
     /* all done */
diff --git a/src/gtx/liboafs_gtx.la.sym b/src/gtx/liboafs_gtx.la.sym
new file mode 100644
index 000000000..e84d031b1
--- /dev/null
+++ b/src/gtx/liboafs_gtx.la.sym
@@ -0,0 +1,99 @@
+gator_cursesgwin_box
+gator_cursesgwin_cleanup
+gator_cursesgwin_clear
+gator_cursesgwin_create
+gator_cursesgwin_destroy
+gator_cursesgwin_display
+gator_cursesgwin_drawchar
+gator_cursesgwin_drawline
+gator_cursesgwin_drawrectangle
+gator_cursesgwin_drawstring
+gator_cursesgwin_getchar
+gator_cursesgwin_getdimensions
+gator_cursesgwin_init
+gator_cursesgwin_invert
+gator_cursesgwin_wait
+gator_dumbgwin_box
+gator_dumbgwin_cleanup
+gator_dumbgwin_clear
+gator_dumbgwin_create
+gator_dumbgwin_destroy
+gator_dumbgwin_display
+gator_dumbgwin_drawchar
+gator_dumbgwin_drawline
+gator_dumbgwin_drawrectangle
+gator_dumbgwin_drawstring
+gator_dumbgwin_getchar
+gator_dumbgwin_getdimensions
+gator_dumbgwin_init
+gator_dumbgwin_invert
+gator_dumbgwin_wait
+gator_light_create
+gator_light_destroy
+gator_light_display
+gator_light_release
+gator_light_set
+gator_objdict_add
+gator_objdict_delete
+gator_objdict_init
+gator_objdict_lookup
+gator_objects_create
+gator_objects_init
+gator_objects_lookup
+gator_text_BlankLine
+gator_textcb_BlankLine
+gator_textcb_Create
+gator_textcb_Delete
+gator_textcb_Init
+gator_textcb_Write
+gator_text_create
+gator_text_destroy
+gator_text_display
+gator_text_release
+gator_text_Scroll
+gator_text_Write
+gator_X11gwin_box
+gator_X11gwin_cleanup
+gator_X11gwin_clear
+gator_X11gwin_create
+gator_X11gwin_destroy
+gator_X11gwin_display
+gator_X11gwin_drawchar
+gator_X11gwin_drawline
+gator_X11gwin_drawrectangle
+gator_X11gwin_drawstring
+gator_X11gwin_getchar
+gator_X11gwin_getdimensions
+gator_X11gwin_init
+gator_X11gwin_invert
+gator_X11gwin_wait
+gtx_CopyString
+gtxframe_AddMenu
+gtxframe_AddToList
+gtxframe_AskForString
+gtxframe_ClearList
+gtxframe_ClearMenus
+gtxframe_ClearMessageLine
+gtxframe_Create
+gtxframe_CtrlHCmd
+gtxframe_CtrlUCmd
+gtxframe_Delete
+gtxframe_DeleteMenu
+gtxframe_Display
+gtxframe_DisplayString
+gtxframe_ExitCmd
+gtxframe_GetFrame
+gtxframe_RecursiveEndCmd
+gtxframe_RecursiveErrCmd
+gtxframe_RemoveFromList
+gtxframe_SelfInsertCmd
+gtxframe_SetFrame
+gtx_Init
+gtx_InputServer
+gw_init
+keymap_BindToString
+keymap_Create
+keymap_Delete
+keymap_InitState
+keymap_ProcessKey
+keymap_ResetState
diff --git a/src/gtx/object_test.c b/src/gtx/object_test.c
index ad6ce97de..2b26d0c44 100644
--- a/src/gtx/object_test.c
+++ b/src/gtx/object_test.c
@@ -66,12 +66,6 @@ test_objects(pkg)
     int code;		/*Return code */
     struct onode_initparams oi_params;	/*Init params */
     struct gwin_initparams wi_params;	/*Window initialization params */
-#if 0
-    /*We don't need these, do we? */
-    struct gator_cursesgwin_params c_crparams;	/*Curses window creation params */
-    struct gator_dumbgwin_params d_crparams;	/*Dumb terminal window creation params */
-    struct gator_X11gwin_params x_crparams;	/*X11 window creation params */
-#endif /* 0 */
     struct gator_light_crparams light_crparams;	/*Light creation params */
     char helpstring1[128];	/*Help string to use */
     char helpstring2[128];	/*Help string to use */
diff --git a/src/gtx/windows.c b/src/gtx/windows.c
index b9fd4e971..c9fa5e047 100644
--- a/src/gtx/windows.c
+++ b/src/gtx/windows.c
@@ -20,11 +20,6 @@
 
 #include <roken.h>
 
-/* On DUX "IN" is a variable in curses.h, so this can be a bit of a problem */
-#ifdef IN
-#undef IN
-#endif
-
 #include "gtxwindows.h"		/*Interface for this module */
 #include "gtxcurseswin.h"	/*Interface for the curses module */
 #include "gtxdumbwin.h"		/*Interface for the dumb terminal module */
diff --git a/src/kauth/admin_tools.c b/src/kauth/admin_tools.c
index 9ec57062e..769a9a9ac 100644
--- a/src/kauth/admin_tools.c
+++ b/src/kauth/admin_tools.c
@@ -1546,47 +1546,6 @@ ForgetTicket(struct cmd_syndesc *as, void *arock)
 {
     afs_int32 code;
 
-#ifdef notdef
-    struct ktc_principal server;
-
-    if (as->parms[0].items) {
-	char *name = as->parms[0].items->data;
-	code =
-	    ka_ParseLoginName(name, server.name, server.instance,
-			      server.cell);
-	if (code) {
-	    afs_com_err(whoami, code, "couldn't interpret name '%s'", name);
-	    return code;
-	}
-	if (server.cell[0] == 0) {
-	    if (code = DefaultCell())
-		return code;
-	    strcpy(server.cell, cell);
-	} else {
-	    code = ka_ExpandCell(server.cell, server.cell, 0 /*local */ );
-	    if (code) {
-		afs_com_err(whoami, code, "Can't expand cell name");
-		return code;
-	    }
-	}
-	code = ktc_ForgetToken(&server);
-	if (code) {
-	    afs_com_err(whoami, code, "couldn't remove tokens for %s",
-		    PrintedPrincipal(&server));
-	    return code;
-	}
-    } else {
-	if (!as->parms[1].items) {
-	    fprintf(stderr, "Must specify server name or -all\n");
-	    return KABADCMD;
-	}
-	code = ktc_ForgetAllTokens();
-	if (code) {
-	    afs_com_err(whoami, code, "couldn't delete all tokens");
-	    return code;
-	}
-    }
-#endif
     code = ktc_ForgetAllTokens();
     if (code) {
 	afs_com_err(whoami, code, "couldn't delete all tokens");
@@ -1790,10 +1749,6 @@ ka_AdminInteractive(int cmd_argc, char *cmd_argv[])
 
     ts = cmd_CreateSyntax("forgetticket", ForgetTicket, NULL, 0,
 			  "delete user's tickets");
-#ifdef notdef
-    cmd_AddParm(ts, "-name", CMD_SINGLE, (CMD_OPTIONAL | CMD_HIDE),
-		"name of server");
-#endif
     cmd_AddParm(ts, "-all", CMD_FLAG, CMD_OPTIONAL, "delete all tickets");
 
     ts = cmd_CreateSyntax("listtickets", ListTickets, NULL, 0,
diff --git a/src/kauth/crypt.c b/src/kauth/crypt.c
index 45ea6189f..6de8dfe34 100644
--- a/src/kauth/crypt.c
+++ b/src/kauth/crypt.c
@@ -908,62 +908,6 @@ init_perm(C_block perm[64 / CHUNKBITS][1 << CHUNKBITS],
     }
 }
 
-/*
- * "setkey" routine (for backwards compatibility)
- */
-#if 0				/* static and doesn't appear to be referenced */
-STATIC int
-setkey(key)
-     const char *key;
-{
-    int i, j, k;
-    C_block keyblock;
-
-    for (i = 0; i < 8; i++) {
-	k = 0;
-	for (j = 0; j < 8; j++) {
-	    k <<= 1;
-	    k |= (unsigned char)*key++;
-	}
-	keyblock.b[i] = k;
-    }
-    return (des_setkey((char *)keyblock.b));
-}
-#endif
-
-#if 0
-/*
- * "encrypt" routine (for backwards compatibility)
- */
-int
-encrypt(block, flag)
-     char *block;
-     int flag;
-{
-    int i, j, k;
-    C_block cblock;
-
-    for (i = 0; i < 8; i++) {
-	k = 0;
-	for (j = 0; j < 8; j++) {
-	    k <<= 1;
-	    k |= (unsigned char)*block++;
-	}
-	cblock.b[i] = k;
-    }
-    if (des_cipher((char *)&cblock, (char *)&cblock, 0L, (flag ? -1 : 1)))
-	return (1);
-    for (i = 7; i >= 0; i--) {
-	k = cblock.b[i];
-	for (j = 7; j >= 0; j--) {
-	    *--block = k & 01;
-	    k >>= 1;
-	}
-    }
-    return (0);
-}
-#endif
-
 #ifdef CRYPT_DEBUG
 STATIC
 prtab(char *s, unsigned char *t, int num_rows)
diff --git a/src/kauth/kadatabase.c b/src/kauth/kadatabase.c
index 78f490094..c63f643ef 100644
--- a/src/kauth/kadatabase.c
+++ b/src/kauth/kadatabase.c
@@ -933,17 +933,3 @@ name_instance_legal(char *name, char *instance)
 	dynamic_statistics.string_checks++;
     return code;
 }
-
-#if 0
-static int
-string_legal(char *str, char *map)
-{
-    int slen;
-
-    slen = strlen(str);
-    if (slen >= MAXKTCNAMELEN)
-	return 0;		/* with trailing null must fit in data base */
-    return (slen == strspn(str, map));	/* strspn returns length(str) if all chars in map */
-}
-#endif
-
diff --git a/src/kauth/kaprocs.c b/src/kauth/kaprocs.c
index 315096a46..f7c639eb4 100644
--- a/src/kauth/kaprocs.c
+++ b/src/kauth/kaprocs.c
@@ -1144,15 +1144,6 @@ Authenticate(int version, struct rx_call *call, char *aname, char *ainstance,
 #endif /* EXPIREPW */
 
     if (check_ka_skew(request.time, now, KTC_TIME_UNCERTAINTY)) {
-#if 0
-	if (oanswer->MaxSeqLen < sizeof(afs_int32))
-	    code = KAANSWERTOOLONG;
-	else {			/* return our time if possible */
-	    oanswer->SeqLen = sizeof(afs_int32);
-	    request.time = htonl(now);
-	    memcpy(oanswer->SeqBody, &request.time, sizeof(afs_int32));
-	}
-#endif
 	code = KACLOCKSKEW;
 	goto abort;
     }
@@ -1701,6 +1692,7 @@ kamListEntry(struct rx_call *call,
     struct kaentry tentry;
 
     COUNT_REQ(ListEntry);
+    memset(name, 0, sizeof(*name));
     if ((code = InitAuthServ(&tt, LOCKREAD, this_op)))
 	return code;
     code = check_auth(call, tt, 1, &caller);
diff --git a/src/kauth/kaserver.c b/src/kauth/kaserver.c
index da824bc77..584b6113d 100644
--- a/src/kauth/kaserver.c
+++ b/src/kauth/kaserver.c
@@ -169,6 +169,7 @@ main(int argc, char *argv[])
     int level;			/* security level for Ubik */
     afs_int32 i;
     char clones[MAXHOSTSPERCELL];
+    char hoststr[16];
     afs_uint32 host = ntohl(INADDR_ANY);
     char *auditFileName = NULL;
     struct logOptions logopts;
@@ -410,10 +411,17 @@ main(int argc, char *argv[])
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-	    rx_InitHost(host, htons(AFSCONF_KAUTHPORT));
 	}
     }
 
+    ViceLog(0, ("kaserver binding rx to %s:%d\n",
+            afs_inet_ntoa_r(host, hoststr), AFSCONF_KAUTHPORT));
+    code = rx_InitHost(host, htons(AFSCONF_KAUTHPORT));
+    if (code) {
+	afs_com_err(whoami, code, "rx init failed");
+	exit(2);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();
 
diff --git a/src/kauth/kpasswd.c b/src/kauth/kpasswd.c
index fbe9cbf54..f83e799d7 100644
--- a/src/kauth/kpasswd.c
+++ b/src/kauth/kpasswd.c
@@ -155,21 +155,6 @@ read_pass(char *passwd, int len, char *prompt, int verify)
     return code;
 }
 
-#if 0
-static int
-password_ok(char *newpw, int *insist)
-{
-    if (insist == 0) {
-	/* see if it is reasonable, but don't get so obnoxious */
-	/* FIXME: null pointer derefence!!! */
-	(*insist)++;		/* so we don't get called again */
-	if (strlen(newpw) < 6)
-	    return 0;
-    }
-    return 1;			/* lie about it */
-}
-#endif
-
 static char rn[] = "kpasswd";	/* Routine name */
 static int Pipe = 0;		/* reading from a pipe */
 
@@ -474,13 +459,6 @@ CommandProc(struct cmd_syndesc *as, void *arock)
 	    memset(passwd, 0, sizeof(passwd));
 	    code = ka_GetAdminToken(pw->pw_name, instance, realm, &key, ADMIN_LIFETIME, &token,	/*!new */
 				    0);
-#ifdef notdef
-	    /* the folks in testing really *hate* this message */
-	    if (code == 0) {
-		fprintf(stderr,
-			"Warning: only the first 8 characters of your old password were significant.\n");
-	    }
-#endif
 	    if (code == 0) {
 		if (dess2k == -1)
 		    dess2k = 0;
diff --git a/src/kauth/krb_udp.c b/src/kauth/krb_udp.c
index f4b84775d..a5960f35f 100644
--- a/src/kauth/krb_udp.c
+++ b/src/kauth/krb_udp.c
@@ -113,7 +113,7 @@ FiveMinuteCheckLWP(void *unused)
 	/* close the log so it can be removed */
 	ReOpenLog();	/* no trunc, just append */
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 
diff --git a/src/kauth/user.c b/src/kauth/user.c
index cc678aaef..14cd1b09a 100644
--- a/src/kauth/user.c
+++ b/src/kauth/user.c
@@ -167,9 +167,6 @@ ka_UserAuthenticateGeneral(afs_int32 flags, char *name, char *instance,
     /* handle smoothly the case where no AFS system calls exists (yet) */
     (void)signal(SIGSYS, SIG_IGN);
 #endif
-#ifdef	AFS_DECOSF_ENV
-    (void)signal(SIGTRAP, SIG_IGN);
-#endif /* AFS_DECOSF_ENV */
     if (instance == 0)
 	instance = "";
     if (flags & KA_USERAUTH_ONLY_VERIFY) {
@@ -179,14 +176,9 @@ ka_UserAuthenticateGeneral(afs_int32 flags, char *name, char *instance,
 	    code = ka_VerifyUserToken(name, instance, realm, &key);
 	}
     } else {
-#ifdef AFS_DUX40_ENV
-	if (flags & KA_USERAUTH_DOSETPAG)
-	    afs_setpag();
-#else
 #if !defined(AFS_NT40_ENV)
 	if (flags & KA_USERAUTH_DOSETPAG)
 	    setpag();
-#endif
 #endif
 	if (flags & KA_USERAUTH_DOSETPAG2)
 	    dosetpag = 1;
diff --git a/src/kopenafs/Makefile.in b/src/kopenafs/Makefile.in
index 7a1c8f558..22ab1249a 100644
--- a/src/kopenafs/Makefile.in
+++ b/src/kopenafs/Makefile.in
@@ -24,7 +24,10 @@ MODULE_INCLUDE	= -I. -I${srcdir} -I../sys
 SFLAGS		= -I${TOP_INCDIR}
 SYS		= ${srcdir}/../sys
 
-all: ${TOP_LIBDIR}/libkopenafs.${SHLIB_SUFFIX} ${TOP_LIBDIR}/libkopenafs.a \
+@SHARED_ONLY@SHARED_LIBS = libkopenafs.la
+@SHARED_ONLY@SHARED_SHLIBS_TOP = ${TOP_LIBDIR}/libkopenafs.${SHLIB_SUFFIX}
+
+all: $(SHARED_SHLIBS_TOP) ${TOP_LIBDIR}/libkopenafs.a \
 		${TOP_INCDIR}/kopenafs.h
 
 ${TOP_LIBDIR}/libkopenafs.${SHLIB_SUFFIX}: libkopenafs.la
@@ -74,31 +77,31 @@ syscall.lo: $(SYS)/syscall.s
 libkopenafs.a: $(LT_objs)
 	$(LT_LDLIB_static) $(LT_objs)
 
-libkopenafs.la: libkopenafs.la.sym $(LT_objs)
-	$(LT_LDLIB_shlib) $(LT_objs)
+libkopenafs.la: libkopenafs.la.sym $(LT_objs) libkopenafs.a
+	$(LT_LDLIB_shlib_only) $(LT_objs)
 
-test-unlog: test-unlog.lo libkopenafs.la
-	$(LT_LDRULE_static) test-unlog.lo libkopenafs.la $(XLIBS)
+test-unlog: test-unlog.lo libkopenafs.a
+	$(LT_LDRULE_static) test-unlog.lo libkopenafs.a $(XLIBS)
 
-test-setpag: test-setpag.lo libkopenafs.la
-	$(LT_LDRULE_static) test-setpag.lo libkopenafs.la $(XLIBS)
+test-setpag: test-setpag.lo libkopenafs.a
+	$(LT_LDRULE_static) test-setpag.lo libkopenafs.a $(XLIBS)
 
 #
 # Installation targets
 #
-install: libkopenafs.la libkopenafs.a
+install: $(SHARED_LIBS) libkopenafs.a
 	${INSTALL} -d ${DESTDIR}${libdir}
 	${INSTALL} -d ${DESTDIR}${includedir}
-	${LT_INSTALL_DATA} libkopenafs.la ${DESTDIR}${libdir}/libkopenafs.la
-	${RM} ${DESTDIR}${libdir}/libkopenafs.la
+	@SHARED_ONLY@${LT_INSTALL_DATA} libkopenafs.la ${DESTDIR}${libdir}/libkopenafs.la
+	@SHARED_ONLY@${RM} ${DESTDIR}${libdir}/libkopenafs.la
 	${INSTALL_DATA} libkopenafs.a ${DESTDIR}${libdir}/libkopenafs.a
 	${INSTALL_DATA} ${srcdir}/kopenafs.h ${DESTDIR}${includedir}/kopenafs.h
 
-dest: libkopenafs.la libkopenafs.a
+dest: $(SHARED_LIBS) libkopenafs.a
 	${INSTALL} -d ${DEST}/lib
 	${INSTALL} -d ${DEST}/include
-	${LT_INSTALL_DATA} libkopenafs.la ${DEST}/lib/libkopenafs.la
-	${RM} ${DEST}/lib/libkopenafs.la
+	@SHARED_ONLY@${LT_INSTALL_DATA} libkopenafs.la ${DEST}/lib/libkopenafs.la
+	@SHARED_ONLY@${RM} ${DEST}/lib/libkopenafs.la
 	${INSTALL_DATA} libkopenafs.a ${DEST}/lib/libkopenafs.a
 	${INSTALL_DATA} ${srcdir}/kopenafs.h ${DEST}/include/kopenafs.h
 
diff --git a/src/kopenafs/kopenafs.c b/src/kopenafs/kopenafs.c
index 279c264f9..143c3bb7f 100644
--- a/src/kopenafs/kopenafs.c
+++ b/src/kopenafs/kopenafs.c
@@ -30,7 +30,7 @@ static volatile sig_atomic_t syscall_okay = 1;
 
 /* Signal handler to catch failed system calls and change the okay flag. */
 #ifdef SIGSYS
-static RETSIGTYPE
+static void
 sigsys_handler(int s)
 {
     syscall_okay = 0;
@@ -43,7 +43,7 @@ k_hasafs(void)
 {
     struct ViceIoctl iob;
     int okay, saved_errno;
-    RETSIGTYPE (*saved_func)(int);
+    void (*saved_func)(int);
 
     saved_errno = errno;
 
@@ -71,7 +71,13 @@ k_hasafs(void)
 int
 k_setpag(void)
 {
-    return lsetpag();
+    int code;
+
+    do {
+	code = lsetpag();
+    } while (code && errno == EINTR);
+
+    return code;
 }
 
 int
diff --git a/src/libacl/Makefile.in b/src/libacl/Makefile.in
index f2c90f539..fbf532c81 100644
--- a/src/libacl/Makefile.in
+++ b/src/libacl/Makefile.in
@@ -64,8 +64,9 @@ dest: libacl.a acl.h prs_fs.h
 #
 # Misc. targets
 #
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 clean:
 	$(LT_CLEAN)
diff --git a/src/libadmin/adminutil/afs_utilAdmin.c b/src/libadmin/adminutil/afs_utilAdmin.c
index 05b66b5f0..518365431 100644
--- a/src/libadmin/adminutil/afs_utilAdmin.c
+++ b/src/libadmin/adminutil/afs_utilAdmin.c
@@ -126,8 +126,8 @@ util_AdminErrorCodeTranslate(afs_status_t errorCode, int langId,
  */
 
 typedef struct database_server_get {
-    int total;
-    int index;
+    unsigned int total;
+    unsigned int index;
     struct afsconf_dir *conf;
     struct afsconf_cell cell;
     util_databaseServerEntry_t server[CACHED_ITEMS];
diff --git a/src/libadmin/client/afs_clientAdmin.c b/src/libadmin/client/afs_clientAdmin.c
index d0f61f106..aa4935878 100644
--- a/src/libadmin/client/afs_clientAdmin.c
+++ b/src/libadmin/client/afs_clientAdmin.c
@@ -205,7 +205,7 @@ afsclient_TokenGetExisting(const char *cellName, void **tokenHandle,
 					  t_handle->afs_token.ticketLen,
 					  t_handle->afs_token.ticket);
 	if ((t_handle->afs_sc[t_handle->sc_index] == NULL)
-	    || (t_handle->afs_sc[t_handle->sc_index] == NULL)) {
+	    || (t_handle->afs_encrypt_sc[t_handle->sc_index] == NULL)) {
 	    tst = ADMCLIENTTOKENHANDLENOSECURITY;
 	    goto fail_afsclient_TokenGetExisting;
 	} else {
diff --git a/src/libadmin/samples/Makefile.in b/src/libadmin/samples/Makefile.in
index 0893f8969..765d55c07 100644
--- a/src/libadmin/samples/Makefile.in
+++ b/src/libadmin/samples/Makefile.in
@@ -39,9 +39,11 @@ SAMPLELIBS =\
 	${TOP_LIBDIR}/libclientadmin.a \
 	${TOP_LIBDIR}/libvosadmin.a \
 	${TOP_LIBDIR}/libbosadmin.a \
-	${TOP_LIBDIR}/libafsauthent.a \
 	${TOP_LIBDIR}/libafsrpc.a \
+	$(top_builddir)/src/auth/liboafs_auth.la \
+	$(top_builddir)/src/kauth/liboafs_kauth.la \
 	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/ubik/liboafs_ubik.la \
 	$(top_builddir)/src/opr/liboafs_opr.la \
 	${TOP_LIBDIR}/libafshcrypto_lwp.a
 
@@ -139,9 +141,33 @@ CFLAGS_rxstat_query_peer.o = @CFLAGS_NOERROR@
 CFLAGS_rxstat_query_process.o = @CFLAGS_NOERROR@
 
 #######################################################################
-install:
-
-dest:
+install: all
+	${INSTALL} -d ${DESTDIR}${sbindir}
+	${INSTALL_PROGRAM} rxstat_clear_peer ${DESTDIR}${sbindir}/rxstat_clear_peer
+	${INSTALL_PROGRAM} rxstat_clear_process ${DESTDIR}${sbindir}/rxstat_clear_process
+	${INSTALL_PROGRAM} rxstat_disable_peer ${DESTDIR}${sbindir}/rxstat_disable_peer
+	${INSTALL_PROGRAM} rxstat_disable_process ${DESTDIR}${sbindir}/rxstat_disable_process
+	${INSTALL_PROGRAM} rxstat_enable_peer ${DESTDIR}${sbindir}/rxstat_enable_peer
+	${INSTALL_PROGRAM} rxstat_enable_process ${DESTDIR}${sbindir}/rxstat_enable_process
+	${INSTALL_PROGRAM} rxstat_get_peer ${DESTDIR}${sbindir}/rxstat_get_peer
+	${INSTALL_PROGRAM} rxstat_get_process ${DESTDIR}${sbindir}/rxstat_get_process
+	${INSTALL_PROGRAM} rxstat_get_version ${DESTDIR}${sbindir}/rxstat_get_version
+	${INSTALL_PROGRAM} rxstat_query_peer ${DESTDIR}${sbindir}/rxstat_query_peer
+	${INSTALL_PROGRAM} rxstat_query_process ${DESTDIR}${sbindir}/rxstat_query_process
+
+dest: all
+	${INSTALL} -d ${DEST}/etc
+	${INSTALL_PROGRAM} rxstat_clear_peer ${DEST}/etc/rxstat_clear_peer
+	${INSTALL_PROGRAM} rxstat_clear_process ${DEST}/etc/rxstat_clear_process
+	${INSTALL_PROGRAM} rxstat_disable_peer ${DEST}/etc/rxstat_disable_peer
+	${INSTALL_PROGRAM} rxstat_disable_process ${DEST}/etc/rxstat_disable_process
+	${INSTALL_PROGRAM} rxstat_enable_peer ${DEST}/etc/rxstat_enable_peer
+	${INSTALL_PROGRAM} rxstat_enable_process ${DEST}/etc/rxstat_enable_process
+	${INSTALL_PROGRAM} rxstat_get_peer ${DEST}/etc/rxstat_get_peer
+	${INSTALL_PROGRAM} rxstat_get_process ${DEST}/etc/rxstat_get_process
+	${INSTALL_PROGRAM} rxstat_get_version ${DEST}/etc/rxstat_get_version
+	${INSTALL_PROGRAM} rxstat_query_peer ${DEST}/etc/rxstat_query_peer
+	${INSTALL_PROGRAM} rxstat_query_process ${DEST}/etc/rxstat_query_process
 
 clean:
 	$(LT_CLEAN)
diff --git a/src/libadmin/test/Makefile.in b/src/libadmin/test/Makefile.in
index 7e31ab660..300cb351d 100644
--- a/src/libadmin/test/Makefile.in
+++ b/src/libadmin/test/Makefile.in
@@ -20,10 +20,12 @@ AFSCPLIBS =\
 	$(TOP_LIBDIR)/libvosadmin.a \
 	$(TOP_LIBDIR)/libkasadmin.a \
 	$(TOP_LIBDIR)/libptsadmin.a \
-	$(TOP_LIBDIR)/libafsauthent.a \
 	$(TOP_LIBDIR)/libafsrpc.a \
+	$(top_builddir)/src/auth/liboafs_auth.la \
 	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/kauth/liboafs_kauth.la \
 	$(top_builddir)/src/opr/liboafs_opr.la \
+	$(top_builddir)/src/ubik/liboafs_ubik.la \
 	$(top_builddir)/src/util/liboafs_util.la \
 	${TOP_LIBDIR}/libafshcrypto_lwp.a
 
diff --git a/src/libadmin/test/bos.c b/src/libadmin/test/bos.c
index 4da787959..badf34b4b 100644
--- a/src/libadmin/test/bos.c
+++ b/src/libadmin/test/bos.c
@@ -1473,6 +1473,8 @@ DoBosExecutableRestartTimeSet(struct cmd_syndesc *as, void *arock)
 	if (ktime_ParsePeriodic(as->parms[TIME].items->data, &time) == -1) {
 	    ERR_EXT("error parsing time");
 	}
+    } else {
+	ERR_EXT("Mandatory time argument not supplied");
     }
 
     if (!bos_ExecutableRestartTimeSet(bos_server, type, time, &st)) {
@@ -1787,22 +1789,6 @@ DoBosSalvage(struct cmd_syndesc *as, void *arock)
     return 0;
 }
 
-#if 0
-static void
-Print_afs_RPCStatsState_p(afs_RPCStatsState_p state, const char *prefix)
-{
-    printf("%sThe rpc stats state is: ", prefix);
-    switch (*state) {
-    case AFS_RPC_STATS_DISABLED:
-	printf("disabled\n");
-	break;
-    case AFS_RPC_STATS_ENABLED:
-	printf("enabled\n");
-	break;
-    }
-}
-#endif
-
 void
 SetupBosAdminCmd(void)
 {
diff --git a/src/libadmin/test/vos.c b/src/libadmin/test/vos.c
index 43312567b..dd51425c5 100644
--- a/src/libadmin/test/vos.c
+++ b/src/libadmin/test/vos.c
@@ -135,14 +135,6 @@ GetAddressFromString(const char *addr_str)
     return ntohl(addr);
 }
 
-#if 0
-static void
-PrintMessage(vos_messageType_t type, char *message)
-{
-    printf("%s\n", message);
-}
-#endif
-
 int
 DoVosBackupVolumeCreate(struct cmd_syndesc *as, void *arock)
 {
diff --git a/src/libadmin/vos/vsprocs.c b/src/libadmin/vos/vsprocs.c
index ecc618b97..f22f42f0b 100644
--- a/src/libadmin/vos/vsprocs.c
+++ b/src/libadmin/vos/vsprocs.c
@@ -1181,109 +1181,6 @@ DelVol(struct rx_connection *conn, afs_uint32 vid, afs_int32 part,
 #define ONERROR(ec, ep, es) if (ec) { fprintf(STDERR, (es), (ep)); error = (ec); goto rfail; }
 #define ERROREXIT(ec) { error = (ec); goto rfail; }
 
-#if 0				/* doesn't appear to be used, why compile it */
-static int
-CloneVol(afs_cell_handle_p cellHandle, struct rx_connection *conn,
-	 afs_uint32 rwvid, afs_int32 part, afs_uint32 * rovidp, int nottemp,
-	 struct nvldbentry *entry, afs_int32 * vidCreateDate, afs_status_p st)
-{
-    int rc = 0;
-    afs_status_t tst = 0, etst = 0;
-    afs_int32 rcode = 0, tid = 0;
-    struct volser_status volstatus;
-    char vname[64];
-
-    /* Begin transaction on RW volume marking it busy (clients will wait) */
-    tst = AFSVolTransCreate(conn, rwvid, part, ITBusy, &tid);
-    if (tst) {
-	goto fail_CloneVol;
-    }
-
-    /* Get the RO volume id. Allocate a new one if need to */
-    *rovidp = entry->volumeId[ROVOL];
-    if (*rovidp == INVALID_BID) {
-	tst = ubik_VL_GetNewVolumeId(cellHandle->vos, 0, 1, rovidp);
-	if (tst) {
-	    goto fail_CloneVol;
-	}
-
-	entry->volumeId[ROVOL] = *rovidp;
-    }
-
-    /* If we are creating the ro clone, what are we calling it.
-     * Depends on whether its a temporary clone or not.
-     */
-    if (nottemp) {
-	strcpy(vname, entry->name);
-	strcat(vname, ".readonly");
-    } else {
-	strcpy(vname, "readonly-clone-temp");	/* Should be unique? */
-    }
-
-    /* Create the new clone. If it exists, then reclone it */
-    tst = AFSVolClone(conn, tid, 0, readonlyVolume, vname, rovidp);
-    if (tst == VVOLEXISTS) {
-	tst = AFSVolReClone(conn, tid, *rovidp);
-	if (tst) {
-	    goto fail_CloneVol;
-	}
-    }
-    if (tst) {
-	goto fail_CloneVol;
-    }
-
-    /* Bring the volume back on-line as soon as possible */
-    if (nottemp) {
-	afs_int32 fromtid = 0;
-
-	/* Now bring the RO clone on-line */
-	tst = AFSVolTransCreate(conn, *rovidp, part, ITOffline, &fromtid);
-	if (tst) {
-	    goto fail_CloneVol;
-	}
-
-	tst = AFSVolSetFlags(conn, fromtid, 0);
-	if (tst) {
-	    goto fail_CloneVol;
-	}
-
-	tst = AFSVolEndTrans(conn, fromtid, &rcode);
-	fromtid = 0;
-	if (!tst)
-	    tst = rcode;
-	if (tst) {
-	    goto fail_CloneVol;
-	}
-    }
-
-    /* Get the time the RW was created for return information */
-    tst = AFSVolGetStatus(conn, tid, &volstatus);
-    if (tst) {
-	goto fail_CloneVol;
-    }
-    *vidCreateDate = volstatus.creationDate;
-    rc = 1;
-
-  fail_CloneVol:
-
-    if (tid) {
-	tst = AFSVolEndTrans(conn, tid, &rcode);
-	tid = 0;
-	if (!tst)
-	    tst = rcode;
-	if (tst) {
-	    rc = 0;
-	    goto fail_CloneVol;
-	}
-    }
-
-    if (st != NULL) {
-	*st = tst;
-    }
-    return rc;
-}
-#endif
-
 /* Get a "transaction" on this replica.  Create the volume 
  * if necessary.  Return the time from which a dump should
  * be made (0 if it's a new volume)
@@ -4090,8 +3987,7 @@ UV_SetVolume(struct rx_connection *server, afs_int32 partition,
 
     if (tid) {
 	etst = AFSVolEndTrans(server, tid, &rcode);
-	/* FIXME: this looks like a typo */
-	if (etst || etst) {
+	if (etst || rcode) {
 	    if (!tst)
 		tst = (etst ? etst : rcode);
 	}
diff --git a/src/libafs/.gitignore b/src/libafs/.gitignore
index 225e979de..4ff29e702 100644
--- a/src/libafs/.gitignore
+++ b/src/libafs/.gitignore
@@ -20,10 +20,13 @@
 /export.exp
 /export64.exp
 /h
+/inet
 /linux
 /net
 /netinet
+/nfs
 /rpc
 /sys
 /rx
+/ufs
 /.makelog
diff --git a/src/libafs/Makefile.common.in b/src/libafs/Makefile.common.in
index 406b8e05d..03e03741c 100644
--- a/src/libafs/Makefile.common.in
+++ b/src/libafs/Makefile.common.in
@@ -42,20 +42,21 @@ COMMON_INCLUDE = -I. -I.. -I../nfs \
 	-I${TOP_INCDIR}/afs 
 
 # Build rules - CC and CFLAGS are defined in system specific MakefileProtos.
-.SUFFIXES:	.i
-.c.i:
-	$(CC) $(COMMON_INCLUDE) $(CFLAGS) -P -c $<
-
 .c.o:
-	$(RUN_CC) $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(CFLAGS-$(@)) $(KERN_DBG) -c $<
-CRULE_NOOPT=	$(RUN_CC) $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS) $(CFLAGS-$(@)) -o $@ -c
-CRULE_OPT=	$(RUN_CC) $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS) $(CFLAGS-$(@)) -o $@ -c
+	$(RUN_CC) $(CC_WRAPPER) $(CC) $(COMMON_INCLUDE) $(CFLAGS) $(CFLAGS-$(@)) $(KERN_DBG) -c $<
+CRULE_NOOPT=	$(RUN_CC) $(CC_WRAPPER) $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(CFLAGS) $(CFLAGS-$(@)) -o $@ -c
+CRULE_OPT=	$(RUN_CC) $(CC_WRAPPER) $(CC) $(COMMON_INCLUDE) $(KERN_DBG) $(KERN_OPTMZ) $(CFLAGS) $(CFLAGS-$(@)) -o $@ -c
 
 system:	all
 
 install:	all $(INSTDIRS)
 dest:		all $(DESTDIRS)
 
+# Don't let INSTDIRS or DESTDIRS run in parallel with COMPDIRS. They both do
+# some work in sub-makes in the same directory that may conflict with each
+# other (e.g. generating AFS_component_version_number.c).
+$(INSTDIRS) $(DESTDIRS): $(COMPDIRS)
+
 all:	setup $(COMPDIRS)
 
 single_compdir single_instdir single_destdir: setup
@@ -72,7 +73,6 @@ depsrcs:
 
 AFSAOBJS = \
 	sha256-kernel.o \
-	rand-fortuna-kernel.o \
 	rand-timer-kernel.o \
 	afs_atomlist.o \
 	afs_lhash.o \
@@ -130,7 +130,6 @@ AFSAOBJS = \
 	afs_vnop_write.o \
 	afs_volume.o \
 	afs_warn.o \
-	afsaux.o		\
 	xdr_update.o	\
 	xdr_refernce.o	\
 	Kvice.xdr.o	\
@@ -217,7 +216,6 @@ AFSNONFSOBJS = \
 # init daemons call pioctl
 AFSPAGOBJS = \
 	sha256-kernel.o \
-	rand-fortuna-kernel.o \
 	rand-timer-kernel.o \
 	md5.o		\
 	evp.o		\
@@ -242,7 +240,6 @@ AFSPAGOBJS = \
 	afs_syscall.o \
 	afs_tokens.o \
 	afs_warn.o \
-	afsaux.o		\
 	xdr_update.o	\
 	xdr_refernce.o	\
 	xdr_arrayn.o	\
@@ -500,8 +497,6 @@ Krmtsys.xdr.o: $(TOP_OBJ_SYS)/Krmtsys.xdr.c
 	$(CRULE_NOOPT) $(TOP_OBJ_SYS)/Krmtsys.xdr.c
 Krmtsys.cs.o: $(TOP_OBJ_SYS)/Krmtsys.cs.c
 	$(CRULE_NOOPT) $(TOP_OBJ_SYS)/Krmtsys.cs.c
-afsaux.o: $(TOP_SRC_FSINT)/afsaux.c
-	$(CRULE_NOOPT) $(TOP_SRC_FSINT)/afsaux.c
 xdr_update.o: $(TOP_SRC_RX)/xdr_update.c
 	$(CRULE_NOOPT) $(TOP_SRC_RX)/xdr_update.c
 xdr_refernce.o: $(TOP_SRC_RX)/xdr_refernce.c
@@ -712,8 +707,6 @@ osi_timeout.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_timeout.c
 	$(CRULE_NOOPT) $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_timeout.c
 osi_pagecopy.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_pagecopy.c
 	$(CRULE_NOOPT) $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_pagecopy.c
-osi_fetchstore.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_fetchstore.c
-	$(CRULE_NOOPT) $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_fetchstore.c
 osi_vcache.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_vcache.c
 	$(CRULE_NOOPT) $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_vcache.c
 osi_crypto.o: $(TOP_SRCDIR)/afs/$(MKAFS_OSTYPE)/osi_crypto.c
diff --git a/src/libafs/MakefileProto.AIX.in b/src/libafs/MakefileProto.AIX.in
index 5c2b7467c..697ba7aa9 100644
--- a/src/libafs/MakefileProto.AIX.in
+++ b/src/libafs/MakefileProto.AIX.in
@@ -24,7 +24,8 @@ AFS_OS_OBJS = \
 	osi_sleep.o \
 	osi_timeout.o \
 	osi_vcache.o \
-	osi_vm.o
+	osi_vm.o \
+	rand-fortuna-kernel.o
 
 AFSNOIAUTHOBJS = \
 	afs_call.o \
diff --git a/src/libafs/MakefileProto.DARWIN.in b/src/libafs/MakefileProto.DARWIN.in
index 555c22dbc..fc0945480 100644
--- a/src/libafs/MakefileProto.DARWIN.in
+++ b/src/libafs/MakefileProto.DARWIN.in
@@ -28,8 +28,8 @@ AFS_OS_OBJS = \
 	osi_vcache.o \
 	osi_vm.o \
 	osi_vnodeops.o \
-	osi_module.o
-
+	osi_module.o \
+	rand-fortuna-kernel.o
 
 #AFS_OS_NFSOBJS = osi_vfsops_nfs.o
 
@@ -40,7 +40,6 @@ AFS_OS_NONFSOBJS = osi_vfsops.o
 KDEFS=
 DBUG = 
 DEFINES= -D_KERNEL -DKERNEL -DKERNEL_PRIVATE -DDIAGNOSTIC -DUSE_SELECT -DMACH_USER_API -DMACH_KERNEL
-KINCLUDES=-I${KROOT}/System/Library/Frameworks/Kernel.framework/Headers
 
 <ppc_darwin_70 ppc_darwin_80 x86_darwin_80>
 KOPTS_DBUG=-g
@@ -59,9 +58,9 @@ OBJ_ppc=$(shell echo "${ARCH_ppc}" | grep -q -w yes && echo "$@.ppc")
 OBJ_x86=$(shell echo "${ARCH_x86}" | grep -q -w yes && echo "$@.x86")
 OBJ_amd64=$(shell echo "${ARCH_amd64}" | grep -q -w yes && echo "$@.amd64")
 
-<all -ppc_darwin_70 -ppc_darwin_80 -x86_darwin_80 -ppc_darwin_90 -x86_darwin_90 -x86_darwin_160 -x86_darwin_170>
+<all -ppc_darwin_70 -ppc_darwin_80 -x86_darwin_80 -ppc_darwin_90 -x86_darwin_90 -x86_darwin_160 -x86_darwin_170 -x86_darwin_180 -x86_darwin_190>
 MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib $(ARCHFLAGS) -Xlinker -kext
-<ppc_darwin_70 ppc_darwin_80 x86_darwin_80 ppc_darwin_90 x86_darwin_90 x86_darwin_160 x86_darwin_170>
+<ppc_darwin_70 ppc_darwin_80 x86_darwin_80 ppc_darwin_90 x86_darwin_90 x86_darwin_160 x86_darwin_170 x86_darwin_180 x86_darwin_190>
 MODLD=$(CC) -static $(KOPTS_DBUG) -nostdlib $(ARCHFLAGS)
 <all>
 
@@ -172,10 +171,10 @@ dest_libafs: $(LIBAFSNONFS) $(LIBAFSNONFSDSYM) ;
 ${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
 	$(MODLD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS} -lcc_kext
 
-<all -x86_darwin_160 -x86_darwin_170>
+<all -x86_darwin_160 -x86_darwin_170 -x86_darwin_180 -x86_darwin_190>
 ${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
 	$(MODLD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS} -lcc_kext
-<x86_darwin_160 x86_darwin_170>
+<x86_darwin_160 x86_darwin_170 x86_darwin_180 x86_darwin_190>
 ${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
 	$(MODLD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS} -lcc_kext -Xlinker -kext
 
diff --git a/src/libafs/MakefileProto.DFBSD.in b/src/libafs/MakefileProto.DFBSD.in
index 41e1b5140..9c06a50a7 100644
--- a/src/libafs/MakefileProto.DFBSD.in
+++ b/src/libafs/MakefileProto.DFBSD.in
@@ -20,7 +20,8 @@ AFS_OS_OBJS = \
 	osi_vcache.o \
 	osi_vm.o \
 	osi_vnodeops.o \
-	osi_module.o 
+	osi_module.o \
+	rand-fortuna-kernel.o
 
 #AFS_OS_NFSOBJS = \
 #	osi_vfsops_nfs.o
diff --git a/src/libafs/MakefileProto.DUX.in b/src/libafs/MakefileProto.DUX.in
deleted file mode 100644
index c189d9c83..000000000
--- a/src/libafs/MakefileProto.DUX.in
+++ /dev/null
@@ -1,112 +0,0 @@
-# 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
-
-srcdir=@srcdir@
-include @TOP_OBJDIR@/src/config/Makefile.config
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-
-
-# OS specific object files:
-AFS_OS_OBJS = \
-	osi_gcpags.o \
-	osi_groups.o \
-	osi_file.o \
-	osi_inode.o \
-	osi_misc.o \
-	osi_sleep.o \
-	osi_vcache.o \
-	osi_vm.o \
-	osi_vnodeops.o 
-
-AFS_OS_NFSOBJS = \
-	osi_vfsops_nfs.o
-
-AFS_OS_NONFSOBJS = \
-	osi_vfsops.o
-
-HEADER_RT = @HEADER_RT@
-
-# System specific build commands and flags
-KDEFS=-DLANGUAGE_C -G 4 -I/usr/sys/include -I../include \
-	 -I/usr/sys/${HEADER_RT} -I/usr/sys/BINARY \
-	-DDEC3000_500 -DSWAPTYPE=1 -DUERF -DOSF -DCOMPAT_43 -DMACH -DUFS \
-	-DRT -DKERNEL -D_KERNEL  -signed  -no_excpt -Wb,-static -Wco,-nofloat \
-	-Olimit 1000 -D__alpha -Umips -UMIPS 
-DBUG = -O2 -g3
-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 = STATIC
-
-# This tells Makefile.common to use it's single directory build target.
-COMPDIRS = single_compdir
-INSTDIRS = single_instdir
-DESTDIRS = single_destdir
-
-include Makefile.common
-
-setup:
-	-mkdir $(KOBJ)
-	-$(RM) $(KOBJ)/Makefile $(KOBJ)/Makefile.common $(KOBJ)/config
-	ln -fs ../Makefile $(KOBJ)/Makefile
-	ln -fs ../Makefile.common $(KOBJ)/Makefile.common
-	ln -fs ../config $(KOBJ)/config
-	-$(RM) -f  h net netinet rpc ufs nfs  machine sys vm
-	-ln -fs /usr/sys/include/net net
-	-ln -fs /usr/sys/include/machine machine
-	-ln -fs /usr/sys/include/netinet netinet
-	-ln -fs /usr/sys/include/nfs nfs
-	-ln -fs /usr/sys/include/rpc rpc
-	-ln -fs /usr/sys/include/sys sys
-	-ln -fs /usr/sys/include/ufs ufs
-	-ln -fs /usr/sys/include/sys h
-	-ln -fs /usr/sys/include/vm vm
-	-touch $(KOBJ)/sec_net.h
-
-
-# Below this line are targets when in the COMMON directory:
-LIBAFS = libafs.o
-LIBAFSNONFS = libafs.nonfs.o
-AFSMOD = afs.mod
-
-INST_LIBAFS = ${DESTDIR}${afskerneldir}/${LIBAFS}
-INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/${LIBAFSNONFS}
-INST_AFSMOD = ${DESTDIR}${afskerneldir}/${AFSMOD}
-
-DEST_LIBAFS = ${DEST}/root.client/bin/${LIBAFS}
-DEST_LIBAFSNONFS = ${DEST}/root.client/bin/${LIBAFSNONFS}
-DEST_AFSMOD = ${DEST}/root.client/bin/${AFSMOD}
-
-
-.PHONY: libafs install_libafs
-libafs:	${LIBAFSNONFS} ${AFSMOD}
-
-install_libafs:	${LIBAFSNONFS} ${AFSMOD}
-	${INSTALL} -d ${DESTDIR}${afskerneldir}
-	$(INSTALL) -m 644 ${LIBAFSNONFS} ${INST_LIBAFSNONFS}
-	$(INSTALL) -m 644 ${AFSMOD} ${INST_AFSMOD}
-
-dest_libafs: ${LIBAFSNONFS} ${AFSMOD}
-	${INSTALL} -d ${DEST}/root.client/bin
-	$(INSTALL) -m 644 ${LIBAFSNONFS} ${DEST_LIBAFSNONFS}
-	$(INSTALL) -m 644 ${AFSMOD} ${DEST_AFSMOD}
-
-${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
-	$(LD) -r -o ${LIBAFS} ${AFSAOBJS} ${AFSNFSOBJS}
-
-${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
-	$(LD) -r -o ${LIBAFSNONFS} ${AFSAOBJS} ${AFSNONFSOBJS}
-
-${AFSMOD}: ${LIBAFSNONFS}
-	$(LD) -dc -r -o ${AFSMOD} ${LIBAFSNONFS}
diff --git a/src/libafs/MakefileProto.FBSD.in b/src/libafs/MakefileProto.FBSD.in
index 4c3c0cd8e..be7d2708e 100644
--- a/src/libafs/MakefileProto.FBSD.in
+++ b/src/libafs/MakefileProto.FBSD.in
@@ -31,6 +31,9 @@ SRCS+= \
 	osi_vnodeops.c \
 	osi_module.c
 
+AFS_OS_OBJS = \
+	rand-fortuna-kernel.o
+
 #AFS_OS_NFSOBJS = \
 #	osi_vfsops_nfs.o
 
@@ -41,10 +44,15 @@ AFS_OS_NONFSOBJS = \
 KSRC = @BSD_KERNEL_PATH@
 KBLD = @BSD_KERNEL_BUILD@
 
+LIBAFS_REQ_DIRS = $(DESTDIR)$(KMODDIR)/
+
 # keep symbols if --enable-debug-kernel
 AC_DEBUG_FLAGS = @DEBUG_FLAGS@
 .if !empty(AC_DEBUG_FLAGS)
 DEBUG_FLAGS=	${AC_DEBUG_FLAGS}
+
+# For debug builds, we also need /usr/lib/debug/* dirs to exist
+LIBAFS_REQ_DIRS += ${DESTDIR}${KERN_DEBUGDIR}${KMODDIR}/
 .endif
 
 # We are not doing very well (WARNS=2 brings in printf format type checking)
@@ -55,8 +63,12 @@ CWARNFLAGS+= -Wno-redundant-decls
 # setup for bsd.kmod.mk infrastructure
 .PATH:	${TOP_SRCDIR}/afs/FBSD
 KMODDIR=/boot/modules
+KERN_DEBUGDIR=/usr/lib/debug
 KMOD=	libafs
 SYSDIR= ${KSRC}
+.if !empty(KBLD)
+KERNBUILDDIR=${KBLD}
+.endif
 
 # Name of directory to hold object files and libraries.
 KOBJ = MODLOAD
@@ -87,6 +99,8 @@ include Makefile.common
 # we only do the no-NFS case
 OBJS=	${AFSAOBJS} ${AFSNONFSOBJS}
 
+$(OBJS): vnode_if.h
+
 LIBAFSNONFS=	libafs.ko
 DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
 CFLAGS+= $(DEFINES) ${COMMON_INCLUDE}
@@ -97,7 +111,13 @@ INST_LIBAFSNONFS = ${DESTDIR}${afskerneldir}/${LIBAFSNONFS}
 DEST_LIBAFS = ${DEST}/root.client/bin/${LIBAFS}
 DEST_LIBAFSNONFS = ${DEST}/root.client/bin/${LIBAFSNONFS}
 
-install_libafs:	$(LIBAFSNONFS) install
+$(DESTDIR)$(KMODDIR)/:
+	$(INSTALL) -d $@
+
+${DESTDIR}${KERN_DEBUGDIR}${KMODDIR}/:
+	$(INSTALL) -d $@
+
+install_libafs:	$(LIBAFSNONFS) $(LIBAFS_REQ_DIRS) install
 
 dest_libafs: $(LIBAFSNONFS)
 	${INSTALL} -d ${DEST}/root.client/bin
diff --git a/src/libafs/MakefileProto.HPUX.in b/src/libafs/MakefileProto.HPUX.in
index 929884e23..0925a3f96 100644
--- a/src/libafs/MakefileProto.HPUX.in
+++ b/src/libafs/MakefileProto.HPUX.in
@@ -24,7 +24,8 @@ AFS_OS_OBJS = \
 	osi_sleep.o \
 	osi_vcache.o \
 	osi_vnodeops.o \
-	osi_vm.o
+	osi_vm.o \
+	rand-fortuna-kernel.o
 
 AFS_OS_NFSOBJS = \
 <ia64_hpux1123 hp_ux1123>
diff --git a/src/libafs/MakefileProto.IRIX.in b/src/libafs/MakefileProto.IRIX.in
index 310db13fb..4142b413f 100644
--- a/src/libafs/MakefileProto.IRIX.in
+++ b/src/libafs/MakefileProto.IRIX.in
@@ -26,7 +26,8 @@ AFS_OS_OBJS = \
 	osi_sleep.o \
 	osi_vcache.o \
 	osi_vm.o \
-	osi_vnodeops.o
+	osi_vnodeops.o \
+	rand-fortuna-kernel.o
 
 AFS_OS_NFSOBJS = \
 	osi_vfsops_nfs.o
diff --git a/src/libafs/MakefileProto.LINUX.in b/src/libafs/MakefileProto.LINUX.in
index 564b2ef0c..7dd1f3bf4 100644
--- a/src/libafs/MakefileProto.LINUX.in
+++ b/src/libafs/MakefileProto.LINUX.in
@@ -42,8 +42,7 @@ AFS_OS_OBJS = \
 	osi_ioctl.o \
 	osi_proc.o \
 	osi_vnodeops.o \
-	osi_pagecopy.o \
-	osi_fetchstore.o
+	osi_pagecopy.o
 
 AFS_OS_PAGOBJS = \
 	osi_alloc.o \
@@ -83,7 +82,6 @@ CFLAGS_evp.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto \
 	       -DHAVE_CONFIG_H
 CFLAGS_evp-algs.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
 CFLAGS_evp-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
-CFLAGS_rand-fortuna-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
 CFLAGS_rand-timer-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
 CFLAGS_rand-kernel.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
 CFLAGS_aes.o = -I$(TOP_SRCDIR)/external/heimdal/hcrypto
@@ -127,7 +125,7 @@ EXTRA_CFLAGS = -I$(LINUX_KERNEL_PATH)/arch/um/include -I$(LINUX_KERNEL_PATH)/arc
 INCLUDES = -I. -I../ -I${TOP_OBJDIR}/src/config \
   -I${TOP_SRCDIR}/rx -I${TOP_OBJDIR}/src/rxstat
 
-CFLAGS = $(CCFLAGS) $(KERN_DBG) $(DEFINES) $(INCLUDES)
+CFLAGS = $(CCFLAGS) $(KERN_DBG) $(DEFINES) $(INCLUDES) @CFLAGS_WERROR@
 
 # Name of directory to hold object files and libraries.
 KOBJ = MODLOAD
@@ -297,6 +295,8 @@ SYSTEM_LIBAFS = /lib/modules/${CLIENT}/extra/${LINUX_LIBAFS_NAME}/${LINUX_LIBAFS
 INST_SYSTEM = ${DESTDIR}${SYSTEM_LIBAFS}
 DEST_SYSTEM = ${DEST}/root.client${SYSTEM_LIBAFS}
 
+SPARSE_MAKEFLAGS = @SPARSE_MAKEFLAGS@
+
 libafs:	$(LIBAFS) 
 	echo SP Build Complete
 
@@ -320,7 +320,7 @@ ${LIBAFS} ${LIBAFS_MP} ${LIBAFS_EP} ${LIBAFS_BM}: ${LINUX_LIBAFS_NAME}.ko
 ${LINUX_LIBAFS_NAME}.ko afspag.ko: .FORCE
 	env EXTRA_CFLAGS="${EXTRA_CFLAGS}" @TOP_SRCDIR@/libafs/make_kbuild_makefile.pl ${KDIR} $@ @TOP_OBJDIR@/src/config/Makefile.config Makefile.afs Makefile.common
 	( env EXTRA_CFLAGS="${EXTRA_CFLAGS}" \
-		$(MAKE) -C ${LINUX_KERNEL_BUILD} M=@TOP_OBJDIR@/src/libafs/${KDIR} modules 2>&1 \
+		$(MAKE) -C ${LINUX_KERNEL_BUILD} M=@TOP_OBJDIR@/src/libafs/${KDIR} $(SPARSE_MAKEFLAGS) modules 2>&1 \
 		|| echo "FAILURE: make exit code $$?" ) | tee .makelog
 	@if grep -E -q '^(FAILURE|WARNING)' .makelog; then \
 		grep -q '^WARNING' .makelog && echo "Error: Undefined symbols in modules" ; \
diff --git a/src/libafs/MakefileProto.NBSD.in b/src/libafs/MakefileProto.NBSD.in
index 892dea2e9..f1669339e 100644
--- a/src/libafs/MakefileProto.NBSD.in
+++ b/src/libafs/MakefileProto.NBSD.in
@@ -24,7 +24,8 @@ AFS_OS_OBJS = \
 	osi_sleep.o \
 	osi_vcache.o \
 	osi_vm.o \
-	osi_vnodeops.o
+	osi_vnodeops.o \
+	rand-fortuna-kernel.o
 
 AFS_OS_NFSOBJS = \
 	osi_vfsops_nfs.o
diff --git a/src/libafs/MakefileProto.OBSD.in b/src/libafs/MakefileProto.OBSD.in
index 3e3beaae7..69871cc37 100644
--- a/src/libafs/MakefileProto.OBSD.in
+++ b/src/libafs/MakefileProto.OBSD.in
@@ -44,7 +44,8 @@ AFS_OS_OBJS = \
 	osi_sleep.o \
 	osi_vcache.o \
 	osi_vm.o \
-	osi_vnodeops.o
+	osi_vnodeops.o \
+	rand-fortuna-kernel.o
 
 #AFS_OS_NFSOBJS = osi_vfsops_nfs.o
 
diff --git a/src/libafs/MakefileProto.SOLARIS.in b/src/libafs/MakefileProto.SOLARIS.in
index af30068f1..ca4366438 100644
--- a/src/libafs/MakefileProto.SOLARIS.in
+++ b/src/libafs/MakefileProto.SOLARIS.in
@@ -26,7 +26,8 @@ AFS_OS_OBJS = \
 	osi_sleep.o \
 	osi_vcache.o \
 	osi_vm.o \
-	osi_vnodeops.o
+	osi_vnodeops.o \
+	rand-fortuna-kernel.o
 
 AFS_OS_NFSOBJS = \
 	osi_vfsops_nfs.o
@@ -38,7 +39,6 @@ AFS_OS_NONFSOBJS = \
 DEFINES= -DAFSDEBUG -DKERNEL -DAFS -DVICE -DNFS -DUFS -DINET -DQUOTA -DGETMOUNT
 #These are redundant
 #LD = /usr/ccs/bin/ld
-#LORDER = /usr/ccs/bin/lorder
 #CC = /opt/SUNWspro/bin/cc
 KDEFS= -D_KERNEL -DSYSV -dn ${ARCH_DEFS}
 <sunx86_510 sunx86_511>
@@ -48,10 +48,14 @@ DBUG= -Wu,-save_args
 KDEFS_32 = -xarch=v8
 KDEFS_64 = -xarch=v9 
 
-<sunx86_58 sunx86_59 sunx86_510 sunx86_511>
+<sunx86_58 sunx86_59 sunx86_510>
 KDEFS_32 = 
 KDEFS_64 = -xarch=amd64 -xmodel=kernel
 
+<sunx86_511>
+KDEFS_32 =
+KDEFS_64 = -m64 -xmodel=kernel
+
 <all>
 CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KDEFS) @SOLARIS_CC_KOPTS@ ${DBUG}
 
@@ -62,7 +66,7 @@ LDFLAGS=-r -dy -N drv/ip -N drv/udp -N strmod/rpcmod
 LDFLAGS=-r -dy -N drv/ip -N drv/udp -N strmod/rpcmod -N fs/ufs
 
 # Name of directory to hold object files and libraries.
-<all -sun4x_510 sun4x_511 sunx86_511>
+<all -sun4x_510 -sun4x_511 -sunx86_511>
 KOBJ = MODLOAD32 MODLOAD64
 <sun4x_510 sun4x_511 sunx86_511>
 KOBJ = MODLOAD64
@@ -99,7 +103,7 @@ setup:
 ## This is the target for a Solaris 7. Here we build both the 32 bit and
 ## the 64 bit libafs in MODLOAD32 and MODLOAD64 directories respectively
 
-${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
+${COMPDIRS} ${INSTDIRS} ${DESTDIRS}: setup
 	for t in ${KOBJ} ; do \
 		echo Building directory: $$t ; \
 		case $$t in \
@@ -112,9 +116,7 @@ ${COMPDIRS} ${INSTDIRS} ${DESTDIRS}:
 		esac ; \
 		export ARCH_DEFS ; \
 		export BITS ; \
-		cd $$t  ; \
-		$(MAKE) $@_libafs || exit $$? ; \
-		cd ../ ;\
+		( cd $$t && $(MAKE) $@_libafs ) || exit $$? ; \
 	done
 
 solaris_compdirs_libafs: depsrcs libafs
@@ -146,15 +148,13 @@ dest_libafs: $(LIBAFS) $(LIBAFSNONFS)
 	${INSTALL} -m 644 $(LIBAFS) $(DEST_LIBAFS)
 	${INSTALL} -m 644 $(LIBAFSNONFS) $(DEST_LIBAFSNONFS)
 
+# See $TOP_SRCDIR/config/cc-wrapper for an explanation/usage of
+# OPENAFS_CC_WRAPPER_DEBUG_FLAG
+
 ${LIBAFS}: $(AFSAOBJS) $(AFSNFSOBJS)
 	$(RM) -f $@
-	$(RUN_CTFCONVERT) libafs "${KERN_DBG}" ${AFSAOBJS} ${AFSNFSOBJS}
-	$(LD) $(LDFLAGS) -o $@ $(AFSAOBJS) ${AFSNFSOBJS}
-	$(RUN_CTFMERGE) libafs "${KERN_DBG}" $@ $(AFSAOBJS) ${AFSNFSOBJS}
+	OPENAFS_CC_WRAPPER_DEBUG_FLAG="$(KERN_DBG)" $(LD_WRAPPER) $(LD) $(LDFLAGS) -o $@ $(AFSAOBJS) ${AFSNFSOBJS}
 
 ${LIBAFSNONFS}:  $(AFSAOBJS) $(AFSNONFSOBJS)
 	$(RM) -f $@
-	$(RUN_CTFCONVERT) libafs "${KERN_DBG}" ${AFSAOBJS} ${AFSNONFSOBJS}
-	$(LD) $(LDFLAGS) -o $@ $(AFSAOBJS) ${AFSNONFSOBJS}
-	$(RUN_CTFMERGE) libafs "${KERN_DBG}" $@ $(AFSAOBJS) ${AFSNONFSOBJS}
-
+	OPENAFS_CC_WRAPPER_DEBUG_FLAG="$(KERN_DBG)" $(LD_WRAPPER) $(LD) $(LDFLAGS) -o $@ $(AFSAOBJS) ${AFSNONFSOBJS}
diff --git a/src/libafs/afs.x86_darwin_180.plist.in b/src/libafs/afs.x86_darwin_180.plist.in
new file mode 100644
index 000000000..a1385718c
--- /dev/null
+++ b/src/libafs/afs.x86_darwin_180.plist.in
@@ -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>
diff --git a/src/libafs/afs.x86_darwin_190.plist.in b/src/libafs/afs.x86_darwin_190.plist.in
new file mode 100644
index 000000000..a1385718c
--- /dev/null
+++ b/src/libafs/afs.x86_darwin_190.plist.in
@@ -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>
diff --git a/src/libafsauthent/Makefile.in b/src/libafsauthent/Makefile.in
index 1993b8fb0..adc88500f 100644
--- a/src/libafsauthent/Makefile.in
+++ b/src/libafsauthent/Makefile.in
@@ -34,19 +34,21 @@ LT_deps = \
 
 LT_libs = $(LIB_hcrypto) $(LIB_roken) $(LIB_crypt) $(LIB_AFSDB) $(MT_LIBS)
 
-all: libafsauthent.la libafsauthent_pic.la \
+@SHARED_ONLY@SHARED_LIBS = libafsauthent.la
+
+all: $(SHARED_LIBS) libafsauthent_pic.la \
 	$(TOP_LIBDIR)/libafsauthent.a \
 	$(TOP_LIBDIR)/libafsauthent_pic.a
 
-libafsauthent.la: libafsauthent.la.sym $(LT_objs) $(LT_deps) libafsauthent_pic.la
-	$(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
+libafsauthent.la: libafsauthent.la.sym $(LT_objs) $(LT_deps) libafsauthent_pic.la libafsauthent.a
+	$(LT_LDLIB_shlib_only) $(LT_objs) $(LT_deps) $(LT_libs)
 
 libafsauthent_pic.la: $(LT_objs)
 	$(LT_LDLIB_pic) $(LT_objs)
 
 # On AIX, libtool can only produce one of shared and static libraries in a
 # given invocation, so we need separate rules.
-libafsauthent.a: $(LT_objs) libafsauthent.la
+libafsauthent.a: $(LT_objs)
 	$(LT_LDLIB_static) $(LT_objs)
 
 ${TOP_LIBDIR}/libafsauthent.a: libafsauthent.a
@@ -59,10 +61,10 @@ clean:
 	$(LT_CLEAN)
 	$(RM) -f *.o libafsauthent.a
 
-install: libafsauthent.la libafsauthent.a libafsauthent_pic.la
+install: $(SHARED_LIBS) libafsauthent.a libafsauthent_pic.la
 	${INSTALL} -d ${DESTDIR}${libdir}
-	${LT_INSTALL_DATA} libafsauthent.la ${DESTDIR}${libdir}/libafsauthent.la
-	${RM} ${DESTDIR}${libdir}/libafsauthent.la
+	@SHARED_ONLY@${LT_INSTALL_DATA} libafsauthent.la ${DESTDIR}${libdir}/libafsauthent.la
+	@SHARED_ONLY@${RM} ${DESTDIR}${libdir}/libafsauthent.la
 	${INSTALL_DATA}  libafsauthent.a ${DESTDIR}${libdir}/libafsauthent.a
 	${INSTALL_DATA}  .libs/libafsauthent_pic.a ${DESTDIR}${libdir}/libafsauthent_pic.a
 
diff --git a/src/libafsauthent/NTMakefile b/src/libafsauthent/NTMakefile
index f1f055c46..171a04abc 100644
--- a/src/libafsauthent/NTMakefile
+++ b/src/libafsauthent/NTMakefile
@@ -35,7 +35,6 @@ AUDITOBJS = \
 AUTHOBJS = \
 	$(OUT)\cellconfig.obj \
 	$(OUT)\userok.obj \
-	$(OUT)\writeconfig.obj \
 	$(OUT)\authcon.obj \
 	$(OUT)\realms.obj \
 	$(OUT)\ktc_errors.obj \
@@ -63,7 +62,6 @@ RXKADOBJS = \
 	$(OUT)\rxkad_errs.obj
 
 PTSERVEROBJS = \
-	$(OUT)\ptclient.obj \
 	$(OUT)\ptint.cs.obj \
 	$(OUT)\ptint.xdr.obj \
 	$(OUT)\ptuser.obj \
diff --git a/src/libafsauthent/afsauthent.def b/src/libafsauthent/afsauthent.def
index 2aa445ea2..79574940d 100644
--- a/src/libafsauthent/afsauthent.def
+++ b/src/libafsauthent/afsauthent.def
@@ -111,7 +111,7 @@ EXPORTS
 ;	ka_KeyCheckSum					@110   /* duplicate */
 	rx_Finalize					@111
 	rx_InitHost					@112
-	VOTE_GetSyncSite				@113
+;	VOTE_GetSyncSite				@113   /* broken */
 	ubik_RefreshConn				@114
         rx_SetSecurityConfiguration                     @115
         pioctl_utf8                                     @116
@@ -167,3 +167,47 @@ EXPORTS
         afsconf_GetAllKeys                              @166
 	afsconf_CheckRestrictedQuery			@167
         string_PR_IDToName				@168
+        initialize_ACFG_error_table			@169
+        initialize_KA_error_table			@170
+        initialize_KTC_error_table			@171
+        initialize_PT_error_table			@172
+        initialize_U_error_table			@173
+;        initialize_VL_error_table			@174
+;        initialize_VOLS_error_table			@175
+        afs_getDirPath					@176
+        afsconf_AddIdentity				@177
+        afsconf_CellAliasApply				@178
+        afsconf_DeleteIdentity				@179
+        afsconf_DeleteKeyBySubType			@180
+        afsconf_DeleteKeyByType				@181
+        afsconf_FindIANAName				@182
+        afsconf_FindService				@183
+        afsconf_GetAfsdbInfo				@184
+        afsconf_GetKeyByTypes				@185
+        afsconf_GetKeysByType				@186
+        afsconf_GetLatestKeyByTypes			@187
+        afsconf_GetLatestKeysByType			@188
+        afsconf_GetNthIdentity				@189
+        afsconf_IsSuperIdentity				@190
+        afsconf_ParseNetRestrictFile			@191
+        afsconf_PutTypedKeyList				@192
+        afsconf_SuperIdentity				@193
+        afsconf_typedKey_free				@194
+        afsconf_typedKey_get				@195
+        token_SetsEquivalent				@196
+        token_addToken					@197
+        token_buildTokenJar				@198
+        token_findByType				@199
+        token_freeToken					@200
+        token_freeTokenContents				@201
+        token_replaceToken				@202
+        token_setPag					@203
+        token_setRxkadViceId				@204
+        ugen_ClientInitCell				@205
+        ugen_ClientInitFlags				@206
+        ugen_ClientInitServer				@207
+        xdr_idlist					@208
+        xdr_namelist					@209
+        xdr_prlist					@210
+        afsconf_CountKeys				@211
+        ubik_CallRock					@212
diff --git a/src/libafsauthent/libafsauthent.la.sym b/src/libafsauthent/libafsauthent.la.sym
index 02914924b..c8a9bae4a 100644
--- a/src/libafsauthent/libafsauthent.la.sym
+++ b/src/libafsauthent/libafsauthent.la.sym
@@ -1,27 +1,68 @@
 afs_get_pag_from_groups
+afs_getDirPath
+afsconf_AddIdentity
 afsconf_AddKey
+afsconf_AddTypedKey
 afsconf_AddUser
+afsconf_BuildServerSecurityObjects
+afsconf_CellAliasApply
 afsconf_CellApply
 afsconf_CheckAuth
 afsconf_CheckRestrictedQuery
 afsconf_ClientAuth
 afsconf_ClientAuthSecure
+afsconf_ClientAuthToken
 afsconf_Close
+afsconf_DeleteIdentity
 afsconf_DeleteKey
+afsconf_DeleteKeyBySubType
+afsconf_DeleteKeyByType
 afsconf_DeleteUser
+afsconf_FindIANAName
+afsconf_FindService
+afsconf_GetAfsdbInfo
+afsconf_GetAllKeys
 afsconf_GetCellInfo
+afsconf_GetExtendedCellInfo
 afsconf_GetKey
+afsconf_GetKeyByTypes
 afsconf_GetKeys
+afsconf_GetKeysByType
 afsconf_GetLatestKey
+afsconf_GetLatestKeyByTypes
+afsconf_GetLatestKeysByType
 afsconf_GetLocalCell
 afsconf_GetNoAuthFlag
+afsconf_GetNthIdentity
 afsconf_GetNthUser
+afsconf_IsLocalRealmMatch
+afsconf_IsSuperIdentity
 afsconf_Open
+afsconf_ParseNetFiles
+afsconf_ParseNetRestrictFile
+afsconf_PickClientSecObj
+afsconf_PutTypedKeyList
 afsconf_ServerAuth
 afsconf_SetCellInfo
+afsconf_SetExtendedCellInfo
+afsconf_SetLocalRealm
 afsconf_SetNoAuthFlag
 afsconf_SetSecurityFlags
+afsconf_SuperIdentity
 afsconf_SuperUser
+afsconf_UpToDate
+afsconf_typedKey_free
+afsconf_typedKey_get
+afsconf_typedKey_new
+afsconf_typedKey_put
+afsconf_typedKey_values
+initialize_ACFG_error_table
+initialize_KA_error_table
+initialize_KTC_error_table
+initialize_PT_error_table
+initialize_U_error_table
+initialize_VL_error_table
+initialize_VOLS_error_table
 ka_AuthServerConn
 ka_AuthSpecificServersConn
 ka_Authenticate
@@ -48,9 +89,12 @@ ka_VerifyUserToken
 ktc_ForgetAllTokens
 ktc_ForgetToken
 ktc_GetToken
+ktc_GetTokenEx
 ktc_ListTokens
+ktc_ListTokensEx
 ktc_OldPioctl
 ktc_SetToken
+ktc_SetTokenEx
 ktc_curpag
 pioctl
 pr_End
@@ -63,9 +107,51 @@ pr_NameToId
 pr_SNameToId
 setpag
 string_PR_IDToName
+token_FreeSet
+token_SetsEquivalent
+token_addToken
+token_buildTokenJar
+token_extractRxkad
+token_findByType
+token_freeToken
+token_freeTokenContents
+token_replaceToken
+token_setPag
+token_setRxkadViceId
 ubik_Call
 ubik_CallIter
+ubik_CallRock
 ubik_Call_New
 ubik_ClientDestroy
 ubik_ClientInit
 ubik_ParseClientList
+ubik_PR_AddToGroup
+ubik_PR_ChangeEntry
+ubik_PR_Delete
+ubik_PR_DumpEntry
+ubik_PR_GetCPS
+ubik_PR_GetCPS2
+ubik_PR_GetHostCPS
+ubik_PR_IDToName
+ubik_PR_INewEntry
+ubik_PR_IsAMemberOf
+ubik_PR_ListElements
+ubik_PR_ListEntries
+ubik_PR_ListEntry
+ubik_PR_ListMax
+ubik_PR_ListOwned
+ubik_PR_ListSuperGroups
+ubik_PR_NameToID
+ubik_PR_NewEntry
+ubik_PR_RemoveFromGroup
+ubik_PR_SetFieldsEntry
+ubik_PR_SetMax
+ubik_PR_UpdateEntry
+ubik_PR_WhereIsIt
+ugen_ClientInit
+ugen_ClientInitCell
+ugen_ClientInitFlags
+ugen_ClientInitServer
+xdr_idlist
+xdr_namelist
+xdr_prlist
diff --git a/src/libafscp/afscp_server.c b/src/libafscp/afscp_server.c
index 726d2e5a3..590b1fefe 100644
--- a/src/libafscp/afscp_server.c
+++ b/src/libafscp/afscp_server.c
@@ -264,9 +264,9 @@ afscp_ServerById(struct afscp_cell *thecell, afsUUID * u)
     bulkaddrs addrs;
     struct ListAddrByAttributes attrs;
     afs_int32 nentries, uniq;
-    char s[512];
-    afsUUID_to_string(u, s, 511);
-    afs_dprintf(("GetServerByID %s\n", s));
+    struct uuid_fmtbuf s;
+    afsUUID_to_string(u, &s);
+    afs_dprintf(("GetServerByID %s\n", s.buffer));
 
     for (i = 0; i < thecell->nservers; i++) {
 	if (afs_uuid_equal(&thecell->fsservers[i]->id, u)) {
@@ -400,10 +400,10 @@ afscp_ServerByAddr(struct afscp_cell *thecell, afs_uint32 addr)
 					 1, thecell->security,
 					 thecell->scindex);
     } else {
-	char s[512];
+	struct uuid_fmtbuf s;
 
-	afsUUID_to_string(&uuid, s, 511);
-	afs_dprintf(("GetServerByAddr 0x%x -> uuid %s\n", addr, s));
+	afsUUID_to_string(&uuid, &s);
+	afs_dprintf(("GetServerByAddr 0x%x -> uuid %s\n", addr, s.buffer));
 
 	if (nentries > AFS_MAXHOSTS) {
 	    nentries = AFS_MAXHOSTS;
diff --git a/src/libafscp/afscp_util.c b/src/libafscp/afscp_util.c
index 47fcfcd56..0e5a0e28c 100644
--- a/src/libafscp/afscp_util.c
+++ b/src/libafscp/afscp_util.c
@@ -216,7 +216,7 @@ _GetSecurityObject(struct afscp_cell *cell)
 {
     int code = ENOENT;
 #ifdef HAVE_KERBEROS
-    krb5_context context;
+    krb5_context context = NULL;
     krb5_creds match;
     krb5_creds *cred;
     krb5_ccache cc;
@@ -286,7 +286,6 @@ _GetSecurityObject(struct afscp_cell *cell)
 	krb5_free_cred_contents(context, &match);
 	if (cc)
 	    krb5_cc_close(context, cc);
-	krb5_free_context(context);
 	goto try_anon;
     }
 
@@ -303,7 +302,6 @@ _GetSecurityObject(struct afscp_cell *cell)
 	    krb5_free_cred_contents(context, &match);
 	    if (cc)
 		krb5_cc_close(context, cc);
-	    krb5_free_context(context);
 	    goto try_anon;
 	}
     }
@@ -325,7 +323,10 @@ _GetSecurityObject(struct afscp_cell *cell)
     cell->scindex = 2;
     return 0;
 
-    try_anon:
+ try_anon:
+    if (context != NULL) {
+        krb5_free_context(context);
+    }
 #endif /* HAVE_KERBEROS */
     if (try_anonymous)
 	return _GetNullSecurityObject(cell);
diff --git a/src/libafsdep b/src/libafsdep
index 08ff23759..3d0f92ac5 100644
--- a/src/libafsdep
+++ b/src/libafsdep
@@ -4,7 +4,6 @@ util/uuid.c
 util/unified_afs.*
 dir/dir.c
 des/stats.h
-fsint/afsaux.c
 fsint/K*.[ch]
 fsint/*.xg
 rxstat/K*.[ch]
diff --git a/src/libafsrpc/Makefile.in b/src/libafsrpc/Makefile.in
index dc03648c6..b451e7eab 100644
--- a/src/libafsrpc/Makefile.in
+++ b/src/libafsrpc/Makefile.in
@@ -25,13 +25,14 @@ LT_objs = \
 	$(top_builddir)/src/rxstat/librxstat_pic.la \
 	$(top_builddir)/src/sys/libafsrpc_sys.la \
 	$(top_builddir)/src/lwp/liblwpcompat_pic.la \
-	$(top_builddir)/src/opr/libopr_pic.la
+	$(top_builddir)/src/opr/libopr_pic.la \
+	@RXGK_LIBS_RPC@
 
-LT_deps =
+LT_libs = $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS) $(RXGK_GSSAPI_LIBS)
 
-LT_libs = $(LIB_hcrypto) $(LIB_roken) $(MT_LIBS)
+@SHARED_ONLY@SHARED_LIBS = libafsrpc.la
 
-all: libafsrpc.la libafsrpc.a libafsrpc_pic.la \
+all: $(SHARED_LIBS) libafsrpc.a libafsrpc_pic.la \
 	$(TOP_LIBDIR)/libafsrpc.a \
 	$(TOP_LIBDIR)/libafsrpc_pic.a
 
@@ -39,13 +40,13 @@ all: libafsrpc.la libafsrpc.a libafsrpc_pic.la \
 # there doesn't seem to be any way to get libtool to remember this requirement
 # when it links the libafsrpc_sys.la convenience library.
 
-libafsrpc.la: libafsrpc.la.sym $(LT_objs) $(LT_deps) libafsrpc_pic.la
+libafsrpc.la: libafsrpc.la.sym $(LT_objs) $(LT_deps) libafsrpc_pic.la libafsrpc.a
 	@set -e; set -x; case "$(SYS_NAME)" in \
 	rs_aix*) \
-	    $(LT_LDLIB_shlib) -Wl,-bI:../sys/afsl.exp \
+	    $(LT_LDLIB_shlib_only) -Wl,-bI:../sys/afsl.exp \
 		$(LT_objs) $(LT_deps) $(LT_libs) ;; \
 	*) \
-	    $(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs);; \
+	    $(LT_LDLIB_shlib_only) $(LT_objs) $(LT_deps) $(LT_libs);; \
 	esac
 
 libafsrpc_pic.la: $(LT_objs)
@@ -54,7 +55,7 @@ libafsrpc_pic.la: $(LT_objs)
 # AIX needs libafsrpc to also be linked against the syscall import list
 # On most platforms, libtool will make shared and static libraries at the
 # same time, but not on AIX, so we need separate rules.
-libafsrpc.a: $(LT_objs) libafsrpc.la
+libafsrpc.a: $(LT_objs)
 	$(LT_LDLIB_static) $(LT_objs)
 	@set -e; set -x; case "${SYS_NAME}" in \
 	    rs_aix*) \
@@ -67,17 +68,17 @@ ${TOP_LIBDIR}/libafsrpc.a: libafsrpc.a
 ${TOP_LIBDIR}/libafsrpc_pic.a: libafsrpc_pic.la
 	${INSTALL_DATA} .libs/libafsrpc_pic.a $@
 
-install: libafsrpc.la libafsrpc.a libafsrpc_pic.la
+install: $(SHARED_LIBS) libafsrpc.a libafsrpc_pic.la
 	${INSTALL} -d ${DESTDIR}${libdir}
-	$(LT_INSTALL_DATA) libafsrpc.la $(DESTDIR)$(libdir)/libafsrpc.la
-	$(RM) $(DESTDIR)$(libdir)/libafsrpc.la
+	@SHARED_ONLY@$(LT_INSTALL_DATA) libafsrpc.la $(DESTDIR)$(libdir)/libafsrpc.la
+	@SHARED_ONLY@$(RM) $(DESTDIR)$(libdir)/libafsrpc.la
 	$(INSTALL_DATA) libafsrpc.a $(DESTDIR)$(libdir)/libafsrpc.a
 	$(INSTALL_DATA) .libs/libafsrpc_pic.a $(DESTDIR)$(libdir)/libafsrpc_pic.a
 
-dest: libafsrpc.la libafsrpc.a
+dest: $(SHARED_LIBS) libafsrpc.a
 	${INSTALL} -d ${DEST}/lib
-	${LT_INSTALL_DATA} libafsrpc.la ${DEST}/lib/libafsrpc.la
-	${RM} ${DEST}/lib/libafsrpc.la
+	@SHARED_ONLY@${LT_INSTALL_DATA} libafsrpc.la ${DEST}/lib/libafsrpc.la
+	@SHARED_ONLY@${RM} ${DEST}/lib/libafsrpc.la
 	${INSTALL_DATA} libafsrpc.a ${DEST}/lib/libafsrpc.a
 	${INSTALL_DATA} .libs/libafsrpc_pic.a ${DEST}/lib/libafsrpc_pic.a
 
diff --git a/src/libafsrpc/NTMakefile b/src/libafsrpc/NTMakefile
index f2a5b3821..14122fc40 100644
--- a/src/libafsrpc/NTMakefile
+++ b/src/libafsrpc/NTMakefile
@@ -57,8 +57,7 @@ LWPOBJS = $(OUT)\lock.obj $(OUT)\fasttime.obj $(OUT)\threadname.obj
 FSINTBJS = $(OUT)\afsint.cs.obj \
            $(OUT)\afsint.xdr.obj \
            $(OUT)\afscbint.cs.obj \
-           $(OUT)\afscbint.xdr.obj \
-	   $(OUT)\afsaux.obj
+           $(OUT)\afscbint.xdr.obj
 
 DLLOBJS = $(MULTIOBJS) $(RXOBJS) $(XDROBJS) $(RXSTATBJS) $(LIBRXKAD_OBJS) \
 	$(LIBRXKAD_REGOBJS) $(UTILOBJS) $(COMERRBJS) \
diff --git a/src/libafsrpc/afsrpc.def b/src/libafsrpc/afsrpc.def
index 43a3b2c2c..631fe013d 100755
--- a/src/libafsrpc/afsrpc.def
+++ b/src/libafsrpc/afsrpc.def
@@ -343,6 +343,11 @@ EXPORTS
 	rxkad_NewKrb5ServerSecurityObject       @348
 	tkt_MakeTicket5                         @349
 	tkt_DeriveDesKey                        @350
+;	opr_AssertFailU                         @351
+;	opr_AssertionFailed                     @352
+;	xdr_Capabilities                        @353
+	xdr_rpcStats                            @354
+	rx_GetCallStatus                        @355
 
 ; for performance testing
         rx_TSFPQGlobSize                        @2001 DATA
diff --git a/src/libafsrpc/afsrpc.exp b/src/libafsrpc/afsrpc.exp
index 0355bc9b1..8df1eef8d 100755
--- a/src/libafsrpc/afsrpc.exp
+++ b/src/libafsrpc/afsrpc.exp
@@ -21,6 +21,7 @@ rx_EventPost
 rx_Finalize
 rx_GetCachedConnection
 rx_GetCall
+rx_GetCallStatus
 rx_GetIFInfo
 rx_Init
 rx_NewCall
diff --git a/src/libafsrpc/libafsrpc.la.sym b/src/libafsrpc/libafsrpc.la.sym
index 8ea0d04a9..05583ae7c 100644
--- a/src/libafsrpc/libafsrpc.la.sym
+++ b/src/libafsrpc/libafsrpc.la.sym
@@ -38,17 +38,22 @@ multi_Finalize
 multi_Finalize_Ignore
 multi_Init
 multi_Select
+opr_AssertionFailed
 osi_AssertFailU
 osi_Panic
 rx_ConnError
 rx_ConnectionOf
 rx_DestroyConnection
 rx_EndCall
+rx_Error
 rx_Finalize
 rx_FlushWrite
 rx_FreeRPCStats
+rx_FreeStatistics
 rx_GetCachedConnection
 rx_GetCall
+rx_GetCallAbortCode
+rx_GetCallStatus
 rx_GetConnectionEpoch
 rx_GetConnectionId
 rx_GetIFInfo
@@ -64,7 +69,10 @@ rx_GetServerDebug
 rx_GetServerPeers
 rx_GetServerStats
 rx_GetServerVersion
+rx_GetServiceSpecific
 rx_GetSpecific
+rx_GetStatistics
+rx_GetRemoteStatus
 rx_HostOf
 rx_IncrementTimeAndCount
 rx_Init
@@ -83,6 +91,7 @@ rx_PrintTheseStats
 rx_ReadProc
 rx_RecordCallStatistics
 rx_ReleaseCachedConnection
+rx_ReleaseRPCStats
 rx_RetrievePeerRPCStats
 rx_RetrieveProcessRPCStats
 rx_SecurityClassOf
@@ -90,9 +99,13 @@ rx_SecurityObjectOf
 rx_ServerProc
 rx_ServiceIdOf
 rx_ServiceOf
+rx_SetCallAbortCode
 rx_SetConnDeadTime
 rx_SetConnHardDeadTime
 rx_SetConnIdleDeadTime
+rx_SetConnSecondsUntilNatPing
+rx_SetLocalStatus
+rx_SetMaxMTU
 rx_SetMaxReceiveWindow
 rx_SetMaxSendWindow
 rx_SetMinPeerTimeout
@@ -100,10 +113,12 @@ rx_SetNoJumbo
 rx_SetSecurityData
 rx_SetSecurityHeaderSize
 rx_SetSecurityMaxTrailerSize
+rx_SetServiceSpecific
 rx_SetSpecific
 rx_SlowReadPacket
 rx_SlowWritePacket
 rx_StartServer
+rx_StatsOnOff
 rx_UdpBufSize
 rx_WriteProc
 rx_connDeadTime
@@ -142,6 +157,7 @@ rx_tranquil
 rxevent_Init
 rxevent_Post
 rxevent_debugFile
+rxgk_GetServerInfo
 rxi_Alloc
 rxi_AllocDataBuf
 rxi_Free
@@ -164,10 +180,12 @@ tkt_DecodeTicket
 tkt_DeriveDesKey
 tkt_MakeTicket
 tkt_MakeTicket5
+xdr_Capabilities
 xdr_afsUUID
 xdr_afs_int32
 xdr_afs_int64
 xdr_afs_uint32
 xdr_afs_uint64
+xdr_rpcStats
 xdrlen_create
 xdrrx_create
diff --git a/src/libuafs/Makefile.common.in b/src/libuafs/Makefile.common.in
index daf09494c..513808d56 100644
--- a/src/libuafs/Makefile.common.in
+++ b/src/libuafs/Makefile.common.in
@@ -10,7 +10,7 @@
 
 # Each MakefileProto includes Makefile.config, so we should only need
 # minor tweaks here.
-MODULE_CFLAGS=-DKERNEL
+MODULE_CFLAGS=${UAFS_CFLAGS} -DKERNEL -I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 LT_objs = \
 	afs_atomlist.lo \
@@ -82,7 +82,6 @@ LT_objs = \
 	osi_groups.lo \
 	osi_gcpags.lo \
 	osi_vcache.lo \
-	afsaux.lo \
 	Kvice.xdr.lo \
 	xdr_array.lo \
 	xdr_arrayn.lo \
@@ -194,9 +193,6 @@ ${TOP_LIBDIR}/libuafs_pic.a: libuafs_pic.la
 
 $(LT_objs): h
 
-libuafs.la: $(LT_objs)
-	$(LT_LDLIB_shlib) $(LT_objs)
-
 libuafs.a: $(LT_objs)
 	$(LT_LDLIB_static) $(LT_objs)
 
@@ -216,7 +212,7 @@ ${TOP_LIBDIR}/perl/AFS/ukernel.pm: setup_perllib PERLUAFS/ukernel.pm
 LIBUAFS_BUILD_PERL: ${TOP_LIBDIR}/perl/ukernel.so ${TOP_LIBDIR}/perl/AFS/ukernel.pm
 
 linktest: libuafs.a
-	$(CC) $(TEST_CFLAGS) $(TEST_LDFLAGS) \
+	$(CC) $(COMMON_CFLAGS) $(TEST_CFLAGS) $(TEST_LDFLAGS) \
 		$(LDFLAGS_roken) $(LDFLAGS_hcrypto) -o linktest \
 		${srcdir}/linktest.c $(MODULE_INCLUDE) -DUKERNEL \
 		libuafs.a ${TOP_LIBDIR}/libcmd.a \
@@ -416,8 +412,6 @@ Kvice.xdr.lo: $(TOP_OBJ_FSINT)/Kvice.xdr.c
 	$(LT_CCRULE) $(TOP_OBJ_FSINT)/Kvice.xdr.c
 Kvice.cs.lo: $(TOP_OBJ_FSINT)/Kvice.cs.c
 	$(LT_CCRULE) $(TOP_OBJ_FSINT)/Kvice.cs.c
-afsaux.lo: $(TOP_SRC_FSINT)/afsaux.c
-	$(LT_CCRULE) $(TOP_SRC_FSINT)/afsaux.c
 xdr_arrayn.lo: $(TOP_SRC_RX)/xdr_arrayn.c
 	$(LT_CCRULE) $(TOP_SRC_RX)/xdr_arrayn.c
 xdr_array.lo: $(TOP_SRC_RX)/xdr_array.c
diff --git a/src/libuafs/MakefileProto.AIX.in b/src/libuafs/MakefileProto.AIX.in
index 6a27a7506..881b3c935 100644
--- a/src/libuafs/MakefileProto.AIX.in
+++ b/src/libuafs/MakefileProto.AIX.in
@@ -16,7 +16,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 
 # System specific build commands and flags
 DEFINES= -DKERNEL -DUKERNEL
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 AR = /usr/bin/ar
 ARFLAGS = -r
 RANLIB = /bin/ranlib
diff --git a/src/libuafs/MakefileProto.DARWIN.in b/src/libuafs/MakefileProto.DARWIN.in
index 19920e2f6..c5f99fbef 100644
--- a/src/libuafs/MakefileProto.DARWIN.in
+++ b/src/libuafs/MakefileProto.DARWIN.in
@@ -16,7 +16,7 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 # System specific build commands and flags
 DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
 KOPTS=
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS) $(ARCHFLAGS)
+UAFS_CFLAGS=$(ARCHFLAGS)
 
 TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV $(XCFLAGS) $(ARCHFLAGS)
 TEST_LDFLAGS=$(XLDFLAGS) $(ARCHFLAGS)
diff --git a/src/libuafs/MakefileProto.DFBSD.in b/src/libuafs/MakefileProto.DFBSD.in
index 0c49f05ee..fac1a852d 100644
--- a/src/libuafs/MakefileProto.DFBSD.in
+++ b/src/libuafs/MakefileProto.DFBSD.in
@@ -16,7 +16,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 CC = @CC@
 DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
 KOPTS=
-CFLAGS=-I. -I..  -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_DFFBSD_ENV $(XCFLAGS)
 TEST_LDFLAGS=
diff --git a/src/libuafs/MakefileProto.DUX.in b/src/libuafs/MakefileProto.DUX.in
deleted file mode 100644
index 99f898910..000000000
--- a/src/libuafs/MakefileProto.DUX.in
+++ /dev/null
@@ -1,24 +0,0 @@
-# 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
-
-srcdir=@srcdir@
-include @TOP_OBJDIR@/src/config/Makefile.config
-INSTALL = @INSTALL@
-INSTALL_DATA = @INSTALL_DATA@
-INSTALL_PROGRAM = @INSTALL_PROGRAM@
-INSTALL_SCRIPT = @INSTALL_SCRIPT@
-
-# System specific build commands and flags
-DEFINES=-DKERNEL -DUKERNEL -D_NO_PROTO -DOSF
-KOPTS=
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS) -pthread
-
-TEST_CFLAGS=-pthread -D_NO_PROTO -D_REENTRANT -DAFS_PTHREAD_ENV -Dosf -DAFS_OSF_ENV -DOSF $(XCFLAGS)
-TEST_LDFLAGS=-pthread
-TEST_LIBS=-lm
-
-include Makefile.common
diff --git a/src/libuafs/MakefileProto.FBSD.in b/src/libuafs/MakefileProto.FBSD.in
index c7dfea659..67a11fdc2 100644
--- a/src/libuafs/MakefileProto.FBSD.in
+++ b/src/libuafs/MakefileProto.FBSD.in
@@ -17,9 +17,8 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 CC = @CC@
 DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
 KOPTS=
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
-TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_FBSD50_ENV $(XCFLAGS)
+TEST_CFLAGS=-D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_FBSD_ENV $(XCFLAGS)
 TEST_LDFLAGS=
 TEST_LIBS=-lpthread
 
diff --git a/src/libuafs/MakefileProto.HPUX.in b/src/libuafs/MakefileProto.HPUX.in
index d8dc557d5..109c21970 100644
--- a/src/libuafs/MakefileProto.HPUX.in
+++ b/src/libuafs/MakefileProto.HPUX.in
@@ -19,9 +19,6 @@ DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
 KOPTS=-Wp,-H200000 -Wl,-a,archive +DA1.0 +z
 <ia64_hpux1122 ia64_hpux1123>
 KOPTS=-Wp,-H200000 -Wl,-a,archive_shared
-<all>
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
-
 <hp_ux102 hp_ux110 hp_ux11i>
 TEST_CFLAGS= -Wp,-H200000 +DA1.0 +z -D_POSIX_C_SOURCE=199506L -DAFS_PTHREAD_ENV -Dhpux -DAFS_HPUX_ENV $(XCFLAGS)
 <ia64_hpux1122 ia64_hpux1123>
diff --git a/src/libuafs/MakefileProto.IRIX.in b/src/libuafs/MakefileProto.IRIX.in
index 757e71bf6..3b1b67c8e 100644
--- a/src/libuafs/MakefileProto.IRIX.in
+++ b/src/libuafs/MakefileProto.IRIX.in
@@ -15,7 +15,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 # System specific build commands and flags
 CC = cc
 DEFINES=-D_SGI_MP_SOURCE -DKERNEL -DUKERNEL
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 TEST_CFLAGS=-D_SGI_MP_SOURCE -DAFS_PTHREAD_ENV -Dirix -DAFS_SGI_ENV $(XCFLAGS)
 TEST_LDFLAGS=-ignore_minor
diff --git a/src/libuafs/MakefileProto.LINUX.in b/src/libuafs/MakefileProto.LINUX.in
index d415a4a16..3647a4d5f 100644
--- a/src/libuafs/MakefileProto.LINUX.in
+++ b/src/libuafs/MakefileProto.LINUX.in
@@ -19,11 +19,8 @@ DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
 KOPTS=
 SYS_NAME=@AFS_SYSNAME@
 ifeq (${SYS_NAME}, ppc64_linux26)
-CFLAGS=-fPIC
-else
-CFLAGS=
+UAFS_CFLAGS=-fPIC
 endif
-CFLAGS+= -I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 TEST_CFLAGS=-pthread -D_REENTRANT -DAFS_PTHREAD_ENV -DAFS_LINUX22_ENV $(XCFLAGS)
 TEST_LDFLAGS=
diff --git a/src/libuafs/MakefileProto.NBSD.in b/src/libuafs/MakefileProto.NBSD.in
index 6a2150861..f2883268f 100644
--- a/src/libuafs/MakefileProto.NBSD.in
+++ b/src/libuafs/MakefileProto.NBSD.in
@@ -17,7 +17,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 CC = gcc
 DEFINES= -DKERNEL -DUKERNEL
 KOPTS=
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 TEST_CFLAGS=	-DAFS_NBSD_ENV $(XCFLAGS)
 TEST_LDFLAGS=
diff --git a/src/libuafs/MakefileProto.OBSD.in b/src/libuafs/MakefileProto.OBSD.in
index 8db60b07f..9bd7be191 100644
--- a/src/libuafs/MakefileProto.OBSD.in
+++ b/src/libuafs/MakefileProto.OBSD.in
@@ -17,7 +17,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 CC = gcc
 DEFINES= -DKERNEL -DUKERNEL
 KOPTS=
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 TEST_CFLAGS=	-DAFS_OBSD_ENV $(XCFLAGS)
 TEST_LDFLAGS=
diff --git a/src/libuafs/MakefileProto.SOLARIS.in b/src/libuafs/MakefileProto.SOLARIS.in
index 8e51a9525..3be917b99 100644
--- a/src/libuafs/MakefileProto.SOLARIS.in
+++ b/src/libuafs/MakefileProto.SOLARIS.in
@@ -14,7 +14,6 @@ INSTALL_SCRIPT = @INSTALL_SCRIPT@
 
 # System specific build commands and flags
 DEFINES= -D_REENTRANT -DKERNEL -DUKERNEL
-CFLAGS=-I. -I.. -I${TOP_OBJDIR}/src/config ${FSINCLUDES} $(DEFINES) $(KOPTS) ${DBG} $(XCFLAGS)
 
 TEST_CFLAGS=-mt -DAFS_PTHREAD_ENV -Dsolaris -DAFS_SUN5_ENV $(XCFLAGS)
 TEST_LDFLAGS=
diff --git a/src/log/Makefile.in b/src/log/Makefile.in
index e067d3ab9..f1cbf7381 100644
--- a/src/log/Makefile.in
+++ b/src/log/Makefile.in
@@ -102,7 +102,8 @@ clean:
 	$(RM) -f *.o unlog tokens kseal pagsh pagsh.krb \
 		core AFS_component_version_number.c tokens.krb
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 include ../config/Makefile.version
diff --git a/src/lwp/Makefile.in b/src/lwp/Makefile.in
index ce1fb1148..6fe53960f 100644
--- a/src/lwp/Makefile.in
+++ b/src/lwp/Makefile.in
@@ -130,6 +130,8 @@ process.o	: process.default.s process.i386.s process.amd64.s process.c lwp.o
 		${CCOBJ} -DIGNORE_STDS_H -E -I${srcdir} -I${TOP_INCDIR} process.S > process.s ; \
 		${AS} process.s -o process.o ;  \
 		$(RM) -f process.s process.S ;;\
+	amd64_fbsd_1??) \
+		$(AFS_CCRULE_NOQ) -c ${srcdir}/process.c;; \
 	amd64_*bsd*) \
 		cp ${srcdir}/process.amd64.s process.S ; \
 		${CCOBJ} -DIGNORE_STDS_H -E -I${srcdir} -I${TOP_INCDIR} process.S > process.s ; \
@@ -155,9 +157,6 @@ process.o	: process.default.s process.i386.s process.amd64.s process.c lwp.o
 		$(RM) process.s ;; \
 	hp* | *_linux* | *_umlinux* | sgi_64 | sgi_65 ) \
 		$(AFS_CCRULE_NOQ) -c ${srcdir}/process.c;; \
-	alpha_osf1 | alpha_osf20 |  alpha_osf30 | alpha_osf32 | alpha_osf32c | alpha_dux?? ) \
-		${AS} -v  -P -DOSF -I${TOP_INCDIR} -DASSEMBLER ${srcdir}/process.default.s; \
-		${AS} -v process.i -o process.o;; \
 	ia64_hpux11* | hp_ux11* ) \
 		$(AFS_CCRULE_NOQ) -c ${srcdir}/process.c;; \
 	i386_*) \
diff --git a/src/lwp/iomgr.c b/src/lwp/iomgr.c
index dcd94d158..670fd293a 100644
--- a/src/lwp/iomgr.c
+++ b/src/lwp/iomgr.c
@@ -527,7 +527,7 @@ static void *IOMGR(void *dummy)
 	       /* Tape drives on Sun boxes do not support select and return ENXIO */
 	       if (errno == ENXIO) e=0, code=1;
 #endif
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_AIX32_ENV)
+#if defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV)
 	       /* For SGI and SVR4 - poll & select can return EAGAIN ... */
 	       if (errno == EAGAIN) e=0;
 #endif
@@ -583,7 +583,7 @@ static void *IOMGR(void *dummy)
 	}
 	LWP_DispatchProcess();
     }
-    return (void *)-1; /* keeps compilers happy. */
+    AFS_UNREACHED(return((void *)-1)); /* keeps compilers happy. */
 }
 
 /************************\
@@ -843,11 +843,11 @@ int IOMGR_Select(int fds, fd_set *readfds, fd_set *writefds,
 #ifdef DEBUG
 	    if (lwp_debug != 0) puts("[Polling SELECT]");
 #endif /* DEBUG */
-#if	defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_NT40_ENV)
+#if	defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV) || defined(AFS_NT40_ENV)
 again:
 #endif
 	    code = select(fds, readfds, writefds, exceptfds, timeout);
-#if	defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV) || defined(AFS_AIX32_ENV)
+#if	defined(AFS_SGI_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_AIX32_ENV)
 	    /*
 	     * For SGI and SVR4 - poll & select can return EAGAIN ...
 	     */
diff --git a/src/lwp/lock.h b/src/lwp/lock.h
index c0081fba3..f0f0efc18 100644
--- a/src/lwp/lock.h
+++ b/src/lwp/lock.h
@@ -167,15 +167,6 @@ void Lock_Destroy(struct Lock *lock);
 	    LOCK_UNLOCK(lock); \
 	ENDMAC
 
-#ifdef notdef
-/* this is what UnboostSharedLock looked like before the hi-C compiler */
-/* this must only be called with a WRITE or boosted SHARED lock! */
-#define UnboostSharedLock(lock)\
-	((lock)->excl_locked = SHARED_LOCK,\
-	((lock)->wait_states ?\
-		Afs_Lock_ReleaseR(lock) : 0))
-#endif /* notdef */
-
 #define ReleaseReadLock(lock)\
 	BEGINMAC\
 	    LOCK_LOCK(lock); \
@@ -185,15 +176,6 @@ void Lock_Destroy(struct Lock *lock);
 	ENDMAC
 
 
-#ifdef notdef
-/* This is what the previous definition should be, but the hi-C compiler generates
-  a warning for each invocation */
-#define ReleaseReadLock(lock)\
-	(!--(lock)->readers_reading && (lock)->wait_states ?\
-		Afs_Lock_ReleaseW(lock)    :\
-		0)
-#endif /* notdef */
-
 #define ReleaseWriteLock(lock)\
 	BEGINMAC\
 	    LOCK_LOCK(lock); \
@@ -202,15 +184,6 @@ void Lock_Destroy(struct Lock *lock);
 	    LOCK_UNLOCK(lock); \
 	ENDMAC
 
-#ifdef notdef
-/* This is what the previous definition should be, but the hi-C compiler generates
-   a warning for each invocation */
-#define ReleaseWriteLock(lock)\
-	((lock)->excl_locked &= ~WRITE_LOCK,\
-	((lock)->wait_states ?\
-		Afs_Lock_ReleaseR(lock) : 0))
-#endif /* notdef */
-
 /* can be used on shared or boosted (write) locks */
 #define ReleaseSharedLock(lock)\
 	BEGINMAC\
@@ -220,16 +193,6 @@ void Lock_Destroy(struct Lock *lock);
 	    LOCK_UNLOCK(lock); \
 	ENDMAC
 
-#ifdef notdef
-/* This is what the previous definition should be, but the hi-C compiler generates
-   a warning for each invocation */
-/* can be used on shared or boosted (write) locks */
-#define ReleaseSharedLock(lock)\
-	((lock)->excl_locked &= ~(SHARED_LOCK | WRITE_LOCK),\
-	((lock)->wait_states ?\
-		Afs_Lock_ReleaseR(lock) : 0))
-#endif /* notdef */
-
 /* convert a write lock to a read lock */
 #define ConvertWriteToReadLock(lock)\
 	BEGINMAC\
diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c
index 9cf84b9a6..199d5edeb 100644
--- a/src/lwp/lwp.c
+++ b/src/lwp/lwp.c
@@ -34,7 +34,7 @@ int setlim(int limcon, uchar_t hard, int limit);
 #endif
 
 #ifndef AFS_ARM_LINUX20_ENV
-#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
+#if defined(AFS_S390_LINUX20_ENV)
 int PRE_Block;	/* Remnants of preemption support. */
 #else
 char PRE_Block;	/* Remnants of preemption support. */
@@ -342,6 +342,7 @@ LWP_CreateProcess(void *(*ep) (void *), int stacksize, int priority, void *parm,
 	if ((stackmemory = malloc(stacksize + 7)) == NULL)
 #endif /* !AFS_DARWIN_ENV */
 	{
+	    free(temp);
 	    Set_LWP_RC();
 	    return LWP_ENOMEM;
 	}
@@ -353,6 +354,10 @@ LWP_CreateProcess(void *(*ep) (void *), int stacksize, int priority, void *parm,
 #endif /* !AFS_DARWIN_ENV */
 #endif
 	if (priority < 0 || priority >= MAX_PRIORITIES) {
+	    free(temp);
+#ifndef AFS_AIX32_ENV
+	    free(stackmemory);
+#endif
 	    Set_LWP_RC();
 	    return LWP_EBADPRI;
 	}
@@ -920,7 +925,7 @@ Dispatcher(void)
 #endif
 	printf("stackcheck = %u: stack = %u \n", lwp_cpptr->stackcheck,
 	       *(int *)lwp_cpptr->stack);
-	printf("topstack = 0x%" AFS_PTR_FMT ": stackptr = 0x%" AFS_PTR_FMT ": stacksize = 0x%x\n",
+	printf("topstack = %p: stackptr = %p: stacksize = 0x%x\n",
 	       (void *)(uintptr_t)lwp_cpptr->context.topstack,
 	       (void *)(uintptr_t)lwp_cpptr->stack,
 	       lwp_cpptr->stacksize);
diff --git a/src/lwp/lwp.h b/src/lwp/lwp.h
index 3b58c5917..68d3d4274 100644
--- a/src/lwp/lwp.h
+++ b/src/lwp/lwp.h
@@ -269,6 +269,11 @@ extern int LWP_QWait(void);
 extern int LWP_QSignal(PROCESS pid);
 #endif
 
+#ifdef AFS_SUN5_ENV
+extern int LWP_NoYieldSignal(void *event);
+extern int LWP_SignalProcess(void *event);
+#endif
+
 extern afs_int32 savecontext(void (*ep)(void),
 			     struct lwp_context *savearea, char *sp);
 extern void returnto(struct lwp_context *savearea);
diff --git a/src/lwp/process.c b/src/lwp/process.c
index 75a71058b..954057193 100644
--- a/src/lwp/process.c
+++ b/src/lwp/process.c
@@ -18,7 +18,7 @@
 
 #include "lwp.h"
 
-#if defined(AFS_OSF_ENV) || defined(AFS_S390_LINUX20_ENV)
+#if defined(AFS_S390_LINUX20_ENV)
 extern int PRE_Block;		/* used in lwp.c and process.s */
 #else
 extern char PRE_Block;		/* used in lwp.c and process.s */
@@ -26,23 +26,27 @@ extern char PRE_Block;		/* used in lwp.c and process.s */
 
 #if defined(USE_UCONTEXT) && defined(HAVE_UCONTEXT_H)
 
+# if defined(AFS_LINUX20_ENV) || defined(AFS_XBSD_ENV)
+#  define AFS_UCONTEXT_NOSTACK
+# endif
+
 afs_int32
 savecontext(void (*ep) (void), struct lwp_context *savearea, char *newsp)
 {
-#if defined(AFS_LINUX20_ENV)
+# ifdef AFS_UCONTEXT_NOSTACK
     /* getcontext does not export stack info */
     int stackvar;
-#endif
+# endif
 
     PRE_Block = 1;
 
     savearea->state = 0;
     getcontext(&savearea->ucontext);
-#if defined(AFS_LINUX20_ENV)
+# ifdef AFS_UCONTEXT_NOSTACK
     savearea->topstack = (char *)&stackvar;
-#else
+# else
     savearea->topstack = savearea->ucontext.uc_stack.ss_sp;
-#endif
+# endif
     switch (savearea->state) {
     case 0:
 	if (newsp) {
diff --git a/src/lwp/process.default.s b/src/lwp/process.default.s
index dda0e5dd3..35a71d091 100644
--- a/src/lwp/process.default.s
+++ b/src/lwp/process.default.s
@@ -1042,22 +1042,11 @@ returnto:
 
 #ifdef __alpha
 /* Code for DEC Alpha architecture */
-#ifdef	AFS_OSF_ENV
+#if defined(AFS_XBSD_ENV)
 #include <machine/asm.h>
-#include <machine/regdef.h>
-#define	fs0	$f2
-#define	fs1	$f3
-#define	fs2	$f4
-#define	fs3	$f5
-#define	fs4	$f6
-#define	fs5	$f7
-#define	fs6	$f8
-#define	fs7	$f9
-#elif defined(AFS_XBSD_ENV)
-#include <machine/asm.h>
-#else	/* !OSF && !XBSD */
+#else	/* !XBSD */
 #include <mach/alpha/asm.h>
-#endif	/* OSF */
+#endif	/* !XBSD */
 
 #define FRAMESIZE ((8*8)+8+(7*8))
 #define floats 0
@@ -1065,15 +1054,8 @@ returnto:
 #define returnaddr (FRAMESIZE-8)
 #define topstack 0
 
-#ifdef AFS_OSF_ENV
-IMPORT(PRE_Block,4)
-#endif
 .align	4
-#ifdef	AFS_OSF_ENV
-NESTED(savecontext,FRAMESIZE,ra)
-#else	/* OSF */
 NESTED(savecontext,3,FRAMESIZE,ra,0x0400f700,0x000003fc)
-#endif	/* OSF */
 	ldgp	gp,0(pv)
 	lda	t0, 1(zero)
 	stl	t0, PRE_Block
@@ -1110,11 +1092,7 @@ samestack:
 	jsr	ra,(pv),0		/* off we go */
 	END(savecontext)
 
-#ifdef	AFS_OSF_ENV
-LEAF(returnto)
-#else	
 LEAF(returnto,1)
-#endif	
 	ldgp	gp,0(pv)
 
 	.prologue	1
diff --git a/src/lwp/test/selserver.c b/src/lwp/test/selserver.c
index a459ba94c..c60b6e205 100644
--- a/src/lwp/test/selserver.c
+++ b/src/lwp/test/selserver.c
@@ -322,13 +322,6 @@ handleRequest(char *arg)
 	    Log("Probed from client at %s\n",
 		inet_ntoa(ch->ch_addr.sin_addr));
 	    break;
-#ifdef notdef
-	case SC_OOB:
-	    nThreads--;
-	    ch->ch_fd = 0;
-	    ch->ch_state = CH_FREE;
-	    return;
-#endif
 	case SC_WRITE:
 	    handleWrite(ch, &sc);
 	    break;
diff --git a/src/opr/Makefile.in b/src/opr/Makefile.in
index 76ae679a7..a6cc4afff 100644
--- a/src/opr/Makefile.in
+++ b/src/opr/Makefile.in
@@ -3,7 +3,8 @@ include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 include @TOP_OBJDIR@/src/config/Makefile.libtool
 
-LT_objs = assert.lo casestrcpy.lo dict.lo fmt.lo proc.lo rbtree.lo softsig.lo uuid.lo
+LT_objs = assert.lo cache.lo casestrcpy.lo dict.lo fmt.lo proc.lo rbtree.lo \
+	  softsig.lo threadname.lo uuid.lo
 LT_libs = $(LIB_hcrypto) $(LIB_roken)
 
 HEADERS = $(TOP_INCDIR)/afs/opr.h \
@@ -84,15 +85,21 @@ clean:
 	$(LT_CLEAN)
 	rm -f libopr.a *.o
 
-install: libopr.a
+install: libopr.a ${srcdir}/opr.h ${srcdir}/opr_lock.h
 	$(INSTALL_DATA) libopr.a $(DESTDIR)$(libdir)/libopr.a
 	$(INSTALL) -d $(DESTDIR)$(includedir)/opr
 	$(INSTALL_DATA) ${srcdir}/queue.h $(DESTDIR)$(includedir)/opr/queue.h
+	$(INSTALL_DATA) ${srcdir}/opr_lock.h $(DESTDIR)$(includedir)/opr/lock.h
+	$(INSTALL) -d $(DESTDIR)$(includedir)/afs
+	$(INSTALL_DATA) ${srcdir}/opr.h $(DESTDIR)$(includedir)/afs/opr.h
 
-dest: libopr.a
+dest: libopr.a ${srcdir}/opr.h ${srcdir}/opr_lock.h
 	$(INSTALL_DATA) libopr.a $(DEST)/lib/libopr.a
 	$(INSTALL) -d $(DEST)/include/opr
 	$(INSTALL_DATA) ${srcdir}/queue.h $(DEST)/include/opr/queue.h
+	$(INSTALL_DATA) ${srcdir}/opr_lock.h $(DEST)/include/opr/lock.h
+	$(INSTALL) -d $(DEST)/include/afs
+	$(INSTALL_DATA) ${srcdir}/opr.h $(DEST)/include/afs/opr.h
 
 buildtools: $(HEADERS) $(TOP_LIBDIR)/libopr.a
 
diff --git a/src/opr/NTMakefile b/src/opr/NTMakefile
index d2866e0d2..98c9d3d6d 100644
--- a/src/opr/NTMakefile
+++ b/src/opr/NTMakefile
@@ -36,6 +36,7 @@ LIBFILE = $(DESTDIR)\lib\opr.lib
 
 LIBOBJS = \
 	$(OUT)\assert.obj \
+	$(OUT)\cache.obj \
 	$(OUT)\casestrcpy.obj \
 	$(OUT)\dict.obj \
 	$(OUT)\fmt.obj \
diff --git a/src/opr/assert.c b/src/opr/assert.c
index e3d3543b3..7db8b0817 100644
--- a/src/opr/assert.c
+++ b/src/opr/assert.c
@@ -28,15 +28,3 @@ opr_AssertionFailed(const char *file, int line)
     fflush(stderr);
     opr_abort();
 }
-
-void
-opr_AssertFailU(const char *expr, const char *file, int line)
-{
-    fprintf(stderr, "Fatal Rx error: assertion failed: %s, "
-		    "file: %s, line: %d\n",
-	    expr, file, line);
-    fflush(stderr);
-    fflush(stdout);
-    opr_abort();
-}
-
diff --git a/src/opr/cache.c b/src/opr/cache.c
new file mode 100644
index 000000000..54fbf3ea2
--- /dev/null
+++ b/src/opr/cache.c
@@ -0,0 +1,450 @@
+/*
+ * Copyright (c) 2019 Sine Nomine Associates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * opr_cache - A simple general-purpose in-memory cache implementation. Keys
+ * and values are simple flat memory buffers (keys are compared with memcmp),
+ * and currently the only cache eviction strategy is a semi-random approach. We
+ * hash values using opr_jhash_opaque.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+
+#include <roken.h>
+#include <afs/opr.h>
+
+#include <opr/dict.h>
+#include <opr/queue.h>
+#include <opr/jhash.h>
+#ifdef AFS_PTHREAD_ENV
+# include <opr/lock.h>
+#else
+# include <opr/lockstub.h>
+#endif
+
+#define MIN_BUCKETS (4)
+#define MAX_BUCKETS (1024*1024)
+
+#define MIN_ENTRIES (4)
+#define MAX_ENTRIES (1024*1024*1024)
+
+struct opr_cache {
+    /*
+     * This lock protects everything in the opr_cache structure. This lock must
+     * be held before touching anything in opr_cache, and before calling any of
+     * our internal functions (unless we're allocating or freeing the cache; in
+     * which case, we had better be the only one touching it!).
+     */
+    opr_mutex_t lock;
+
+    /* How many items are present in the cache? */
+    afs_uint32 n_entries;
+
+    /* The max number of items we can hold in the cache. */
+    afs_uint32 max_entries;
+
+    /* Our dictionary holding the cached items. Contains cache_entry structs,
+     * linked together via 'link'. */
+    struct opr_dict *dict;
+};
+
+struct cache_entry {
+    struct opr_queue link;
+
+    size_t key_len;
+    void *key_buf;
+
+    size_t val_len;
+    void *val_buf;
+};
+
+static void
+free_entry_contents(struct cache_entry *entry)
+{
+    opr_queue_Remove(&entry->link);
+
+    free(entry->key_buf);
+    free(entry->val_buf);
+
+    entry->key_buf = entry->val_buf = NULL;
+    entry->key_len = entry->val_len = 0;
+}
+
+/**
+ * Evict an entry from the cache.
+ *
+ * @pre cache is full.
+ * @pre cache->lock is held.
+ *
+ * @param[in] cache	The opr_cache to use.
+ * @param[out] a_entry	Set to the cache entry that was evicted. Its contents
+ *			have been freed; it can be treated like a
+ *			newly-allocated cache entry.
+ */
+static void
+evict_entry(struct opr_cache *cache, struct cache_entry **a_entry)
+{
+    unsigned int safety, bucket;
+    struct cache_entry *entry = NULL;
+
+    opr_Assert(cache->dict->size > 0);
+    opr_Assert(cache->n_entries > 0);
+
+    /*
+     * For cache eviction, we pick an entry somewhat randomly, since random
+     * eviction performs fairly well, and is very simple to implement.
+     *
+     * Our approach slightly differs from pure random eviction: we pick a
+     * random hash bucket, and evict the least-recently-used entry in that
+     * bucket. If the bucket we picked is empty, just use the next bucket.
+     */
+    bucket = rand() % cache->dict->size;
+
+    for (safety = 0; safety < cache->dict->size; safety++) {
+	struct opr_queue *chain;
+	chain = &cache->dict->table[bucket];
+
+	if (!opr_queue_IsEmpty(chain)) {
+	    entry = opr_queue_Last(chain, struct cache_entry, link);
+	    break;
+	}
+
+	bucket++;
+	bucket = bucket % cache->dict->size;
+    }
+    opr_Assert(entry != NULL);
+
+    free_entry_contents(entry);
+
+    *a_entry = entry;
+}
+
+/**
+ * Alloc a new entry in the cache.
+ *
+ * @pre cache->lock is held.
+ * @pre The given key does not already exist in the cache.
+ *
+ * @param[in] cache	The opr_cache to use.
+ * @param[inout] a_key_buf  The key for the new cache entry. Set to NULL on
+ *			    success; the memory is used in the new cache entry,
+ *			    and must not be freed or otherwise used by the
+ *			    caller.
+ * @param[in] key_len	The size of *a_key_buf.
+ * @param[out] a_entry	Set to the new cache entry on success. The entry has
+ *			been inserted into the cache, and the key has been
+ *			populated; it looks identical to a normal entry in the
+ *			cache, except the value is set to NULL.
+ *
+ * @return errno status codes
+ */
+static int
+alloc_entry(struct opr_cache *cache, void **a_key_buf, size_t key_len,
+	    struct cache_entry **a_entry)
+{
+    struct cache_entry *entry = NULL;
+    unsigned int hash;
+
+    if (cache->n_entries >= cache->max_entries) {
+	/*
+	 * The cache is full. "Alloc" an entry by picking an existing entry to
+	 * evict, and just re-use that entry.
+	 */
+	evict_entry(cache, &entry);
+
+    } else {
+	entry = calloc(1, sizeof(*entry));
+	if (entry == NULL) {
+	    return ENOMEM;
+	}
+	cache->n_entries++;
+    }
+
+    entry->key_len = key_len;
+    entry->key_buf = *a_key_buf;
+    *a_key_buf = NULL;
+
+    hash = opr_jhash_opaque(entry->key_buf, entry->key_len, 0);
+    opr_dict_Prepend(cache->dict, hash, &entry->link);
+
+    *a_entry = entry;
+    return 0;
+}
+
+/**
+ * Find a cache entry in the cache.
+ *
+ * @pre cache->lock is held.
+ *
+ * @param[in] cache	The opr_cache to use.
+ * @param[in] key_buf	The key of the entry to find.
+ * @param[in] key_len	The size of 'key_buf'.
+ * @param[out] a_entry	The found cache entry.
+ *
+ * @return errno status codes
+ * @retval ENOENT The given key does not exist in the cache.
+ */
+static int
+find_entry(struct opr_cache *cache, void *key_buf, size_t key_len,
+	   struct cache_entry **a_entry)
+{
+    struct opr_queue *cursor;
+    unsigned int hash;
+
+    hash = opr_jhash_opaque(key_buf, key_len, 0);
+
+    for (opr_dict_ScanBucket(cache->dict, hash, cursor)) {
+	struct cache_entry *entry;
+	entry = opr_queue_Entry(cursor, struct cache_entry, link);
+	if (key_len != entry->key_len) {
+	    continue;
+	}
+	if (memcmp(key_buf, entry->key_buf, key_len) != 0) {
+	    continue;
+	}
+	opr_dict_Promote(cache->dict, hash, &entry->link);
+	*a_entry = entry;
+	return 0;
+    }
+
+    return ENOENT;
+}
+
+/**
+ * Fetch an item from the cache.
+ *
+ * If NULL is given for 'cache' or 'key_buf', or if 0 is given for key_len, we
+ * always return ENOENT. Conceptually, we treat a NULL cache as an empty cache,
+ * and NULL/0-length keys are not allowed in an opr_cache, so returning ENOENT
+ * in these cases is consistent.
+ *
+ * @param[in] cache	The opr_cache to use.
+ * @param[in] key_buf	The key to lookup.
+ * @param[in] key_len	The size of 'key_buf'.
+ * @param[out] val_buf	On success, where to store the looked-up value.
+ * @param[inout] a_val_len  On entry, set to the max size available in
+ *			    'val_buf'. On successful return, set to the number
+ *			    of bytes copied into 'val_buf'.
+ * @return errno status codes
+ * @retval 0 success
+ * @retval ENOENT key not found
+ * @retval ENOSPC a_val_len is too small to store the retrieved value
+ */
+int
+opr_cache_get(struct opr_cache *cache, void *key_buf, size_t key_len,
+	      void *val_buf, size_t *a_val_len)
+{
+    struct cache_entry *entry;
+    int code;
+
+    if (cache == NULL || key_buf == NULL || key_len < 1) {
+	return ENOENT;
+    }
+
+    opr_mutex_enter(&cache->lock);
+
+    code = find_entry(cache, key_buf, key_len, &entry);
+    if (code != 0) {
+	goto done;
+    }
+
+    if (entry->val_len > *a_val_len) {
+	code = ENOSPC;
+	goto done;
+    }
+
+    memcpy(val_buf, entry->val_buf, entry->val_len);
+    *a_val_len = entry->val_len;
+
+ done:
+    opr_mutex_exit(&cache->lock);
+    return code;
+}
+
+static void*
+memdup(void *src, size_t len)
+{
+    void *buf = malloc(len);
+    if (buf == NULL) {
+	return NULL;
+    }
+    memcpy(buf, src, len);
+    return buf;
+}
+
+/**
+ * Store an item in the cache.
+ *
+ * This operation is a no-op if NULL is given for 'cache', 'key_buf', or
+ * 'val_buf', or if 'key_len' or 'val_len' are 0. Conceptually, a NULL
+ * opr_cache represents an empty cache, and NULL/0-length keys and values are
+ * not allowed in an opr_cache.
+ *
+ * @param[in] cache	The opr_cache to use.
+ * @param[in] key_buf	The key for the stored value.
+ * @param[in] key_len	The size of 'key_buf'.
+ * @param[in] val_buf	The value to store.
+ * @param[in] val_len	The size of 'val_buf'.
+ */
+void
+opr_cache_put(struct opr_cache *cache, void *key_buf, size_t key_len,
+	      void *val_buf, size_t val_len)
+{
+    int code;
+    struct cache_entry *entry;
+    void *key_dup = NULL;
+    void *val_dup = NULL;
+
+    if (cache == NULL || key_buf == NULL || val_buf == NULL || key_len < 1 ||
+	val_len < 1) {
+	goto done;
+    }
+
+    key_dup = memdup(key_buf, key_len);
+    val_dup = memdup(val_buf, val_len);
+    if (key_dup == NULL || val_dup == NULL) {
+	goto done;
+    }
+
+    opr_mutex_enter(&cache->lock);
+
+    code = find_entry(cache, key_buf, key_len, &entry);
+    if (code == ENOENT) {
+	code = alloc_entry(cache, &key_dup, key_len, &entry);
+    }
+    if (code != 0) {
+	goto done_locked;
+    }
+
+    free(entry->val_buf);
+    entry->val_buf = val_dup;
+    entry->val_len = val_len;
+    val_dup = NULL;
+
+ done_locked:
+    opr_mutex_exit(&cache->lock);
+ done:
+    free(key_dup);
+    free(val_dup);
+}
+
+static_inline int
+isPowerOf2(int value)
+{
+    return (value > 0) && (value & (value - 1)) == 0;
+}
+
+static_inline int
+nextPowerOf2(int target)
+{
+    int next = 1;
+    /*
+     * Make sure we have a reasonable target and cannot overflow; callers
+     * should do their own range checks before we get here.
+     */
+    opr_Assert(target > 0 && target <= 0x40000000);
+    while (next < target) {
+	next *= 2;
+    }
+    return next;
+}
+
+/**
+ * Create a new opr_cache.
+ *
+ * @param[in] opts  What options to use for the cache.
+ * @param[out] a_cache  The newly-allocated cache.
+ *
+ * @return errno status codes
+ * @retval EINVAL   invalid option values
+ */
+int
+opr_cache_init(struct opr_cache_opts *opts, struct opr_cache **a_cache)
+{
+    struct opr_cache *cache;
+    int n_buckets = opts->n_buckets;
+
+    if (n_buckets < MIN_BUCKETS || n_buckets > MAX_BUCKETS) {
+	return EINVAL;
+    }
+    if (opts->max_entries < MIN_ENTRIES || opts->max_entries > MAX_ENTRIES) {
+	return EINVAL;
+    }
+
+    n_buckets = nextPowerOf2(n_buckets);
+    opr_Assert(isPowerOf2(n_buckets));
+    opr_Assert(n_buckets >= MIN_BUCKETS);
+    opr_Assert(n_buckets <= MAX_BUCKETS);
+
+    cache = calloc(1, sizeof(*cache));
+    if (cache == NULL) {
+	return ENOMEM;
+    }
+
+    opr_mutex_init(&cache->lock);
+    cache->max_entries = opts->max_entries;
+
+    cache->dict = opr_dict_Init(n_buckets);
+    if (cache->dict == NULL) {
+	opr_cache_free(&cache);
+	return ENOMEM;
+    }
+
+    *a_cache = cache;
+    return 0;
+}
+
+/**
+ * Free an opr_cache.
+ *
+ * @param[inout] a_cache    The cache to free. Set to NULL on return.
+ */
+void
+opr_cache_free(struct opr_cache **a_cache)
+{
+    struct opr_cache *cache = *a_cache;
+    if (cache == NULL) {
+	return;
+    }
+    *a_cache = NULL;
+
+    if (cache->dict != NULL) {
+	int bucket;
+	for (bucket = 0; bucket < cache->dict->size; bucket++) {
+	    struct opr_queue *cursor, *tmp;
+	    for (opr_dict_ScanBucketSafe(cache->dict, bucket, cursor, tmp)) {
+		struct cache_entry *entry;
+		entry = opr_queue_Entry(cursor, struct cache_entry, link);
+		free_entry_contents(entry);
+		free(entry);
+	    }
+	}
+	opr_dict_Free(&cache->dict);
+    }
+
+    opr_mutex_destroy(&cache->lock);
+
+    free(cache);
+}
diff --git a/src/opr/jhash.h b/src/opr/jhash.h
index 9c82f9c98..5fedaa1f7 100644
--- a/src/opr/jhash.h
+++ b/src/opr/jhash.h
@@ -79,10 +79,10 @@ opr_jhash(const afs_uint32 *k, size_t length, afs_uint32 initval)
 
     /* All the case statements fall through */
     switch(length) {
-      case 3 : c+=k[2];
-      case 2 : b+=k[1];
+      case 3 : c+=k[2];			AFS_FALLTHROUGH;
+      case 2 : b+=k[1];			AFS_FALLTHROUGH;
       case 1 : a+=k[0];
-	opr_jhash_final(a, b, c);
+	opr_jhash_final(a, b, c);	AFS_FALLTHROUGH;
       case 0:     /* case 0: nothing left to add */
 	break;
     }
@@ -147,19 +147,19 @@ opr_jhash_opaque(const void *val, size_t length, afs_uint32 initval)
 
     /* All the case statements fall through */
     switch(length) {
-      case 12 : c += (afs_uint32) str[11]<<24;
-      case 11 : c += (afs_uint32) str[10]<<16;
-      case 10 : c += (afs_uint32) str[9]<<8;
-      case 9  : c += (afs_uint32) str[8];
-      case 8  : b += (afs_uint32) str[7]<<24;
-      case 7  : b += (afs_uint32) str[6]<<16;
-      case 6  : b += (afs_uint32) str[5]<<8;
-      case 5  : b += (afs_uint32) str[4];
-      case 4  : a += (afs_uint32) str[3]<<24;
-      case 3  : a += (afs_uint32) str[2]<<16;
-      case 2  : a += (afs_uint32) str[1]<<8;
+      case 12 : c += (afs_uint32) str[11]<<24;	AFS_FALLTHROUGH;
+      case 11 : c += (afs_uint32) str[10]<<16;	AFS_FALLTHROUGH;
+      case 10 : c += (afs_uint32) str[9]<<8;	AFS_FALLTHROUGH;
+      case 9  : c += (afs_uint32) str[8];	AFS_FALLTHROUGH;
+      case 8  : b += (afs_uint32) str[7]<<24;	AFS_FALLTHROUGH;
+      case 7  : b += (afs_uint32) str[6]<<16;	AFS_FALLTHROUGH;
+      case 6  : b += (afs_uint32) str[5]<<8;	AFS_FALLTHROUGH;
+      case 5  : b += (afs_uint32) str[4];	AFS_FALLTHROUGH;
+      case 4  : a += (afs_uint32) str[3]<<24;	AFS_FALLTHROUGH;
+      case 3  : a += (afs_uint32) str[2]<<16;	AFS_FALLTHROUGH;
+      case 2  : a += (afs_uint32) str[1]<<8;	AFS_FALLTHROUGH;
       case 1  : a += (afs_uint32) str[0];
-	opr_jhash_final(a, b, c);
+	opr_jhash_final(a, b, c);		AFS_FALLTHROUGH;
       case 0:     /* case 0: nothing left to add */
 	break;
     }
diff --git a/src/opr/liboafs_opr.la.sym b/src/opr/liboafs_opr.la.sym
index bf24b6064..2a0cc2cbc 100644
--- a/src/opr/liboafs_opr.la.sym
+++ b/src/opr/liboafs_opr.la.sym
@@ -14,6 +14,7 @@ opr_rbtree_replace
 opr_stolower
 opr_stoupper
 opr_strcompose
+opr_threadname_set
 opr_ucstring
 opr_softsig_Init
 opr_softsig_Register
diff --git a/src/opr/lockstub.h b/src/opr/lockstub.h
index db375b23f..07360af50 100644
--- a/src/opr/lockstub.h
+++ b/src/opr/lockstub.h
@@ -34,6 +34,7 @@
 #  error "Do not use the opr/lockstub.h header with pthreaded code"
 # endif
 
+typedef int opr_mutex_t;
 typedef int opr_cv_t;
 
 # define opr_mutex_init(mutex)
diff --git a/src/opr/opr.h b/src/opr/opr.h
index 5891a707f..1130b335a 100644
--- a/src/opr/opr.h
+++ b/src/opr/opr.h
@@ -17,7 +17,6 @@ extern void opr_NTAbort(void);
 #endif
 
 extern void opr_AssertionFailed(const char *, int) AFS_NORETURN;
-extern void opr_AssertFailU(const char *, const char *, int) AFS_NORETURN;
 
 /* opr_Assert is designed to work in a similar way to the operating
  * system's assert function. This means that in future, it may compile
@@ -71,8 +70,38 @@ extern void opr_AssertFailU(const char *, const char *, int) AFS_NORETURN;
 
 extern char *opr_lcstring(char *d, const char *s, int n) AFS_NONNULL((1,2));
 extern char *opr_ucstring(char *d, const char *s, int n) AFS_NONNULL((1,2));
-extern void opr_stolower(char *s) AFS_NONNULL(());
-extern void opr_stoupper(char *s) AFS_NONNULL(());
+extern void opr_stolower(char *s) AFS_NONNULL((1));
+extern void opr_stoupper(char *s) AFS_NONNULL((1));
 extern char *opr_strcompose(char *buf, size_t len, ...) AFS_NONNULL((1));
 
+/* threadname.c */
+
+#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
+extern void opr_threadname_set(const char *threadname);
+#else
+static_inline void
+opr_threadname_set(const char *threadname)
+{
+    /* noop */
+}
+#endif
+
+/* cache.c */
+
+struct opr_cache_opts {
+    afs_uint32 max_entries;
+    afs_uint32 n_buckets;
+};
+struct opr_cache;
+
+extern int opr_cache_init(struct opr_cache_opts *opts,
+			  struct opr_cache **a_cache) AFS_NONNULL();
+extern void opr_cache_free(struct opr_cache **a_cache) AFS_NONNULL();
+
+extern int opr_cache_get(struct opr_cache *cache, void *key_buf,
+			 size_t key_len, void *val_buf, size_t *a_val_len)
+			 AFS_NONNULL((4,5));
+extern void opr_cache_put(struct opr_cache *cache, void *key_buf,
+			  size_t key_len, void *val_buf, size_t val_len);
+
 #endif
diff --git a/src/opr/softsig.c b/src/opr/softsig.c
index 469bd43e1..fa4fcad4d 100644
--- a/src/opr/softsig.c
+++ b/src/opr/softsig.c
@@ -76,7 +76,7 @@ signalHandler(void *arg)
 	    handlers[receivedSignal].handler(receivedSignal);
 	}
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static void
diff --git a/src/opr/softsig.h b/src/opr/softsig.h
index dd9d09b7d..1c1bfd4d9 100644
--- a/src/opr/softsig.h
+++ b/src/opr/softsig.h
@@ -28,4 +28,8 @@
 int opr_softsig_Init(void);
 int opr_softsig_Register(int sig, void (*handler)(int));
 
+#ifdef AFS_NT40_ENV
+# include <afs/procmgmt_softsig.h>
+#endif
+
 #endif
diff --git a/src/util/pthread_threadname.c b/src/opr/threadname.c
similarity index 75%
rename from src/util/pthread_threadname.c
rename to src/opr/threadname.c
index b085b4ab1..c963cbf9a 100644
--- a/src/util/pthread_threadname.c
+++ b/src/opr/threadname.c
@@ -26,7 +26,7 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-#include "afsutil.h"
+#include <afs/opr.h>
 
 #if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
 # include <pthread.h>
@@ -35,24 +35,24 @@
 # endif
 
 void
-afs_pthread_setname_self(const char *threadname)
+opr_threadname_set(const char *threadname)
 {
 # if defined(HAVE_PTHREAD_SET_NAME_NP)
-	/* FreeBSD style */
-	pthread_set_name_np(pthread_self(), threadname);
+    /* FreeBSD style */
+    pthread_set_name_np(pthread_self(), threadname);
 # elif defined(HAVE_PTHREAD_SETNAME_NP)
 #  if PTHREAD_SETNAME_NP_ARGS == 3
-	/* DECthreads style */
-	pthread_setname_np(pthread_self(), threadname, (void *)0);
+    /* DECthreads style */
+    pthread_setname_np(pthread_self(), threadname, (void *)0);
 #  elif PTHREAD_SETNAME_NP_ARGS == 2
-	/* GNU libc on Linux style */
-	pthread_setname_np(pthread_self(), threadname);
+    /* GNU libc on Linux style */
+    pthread_setname_np(pthread_self(), threadname);
 #  elif PTHREAD_SETNAME_NP_ARGS == 1
-	/* Mac OS style */
-	pthread_setname_np(threadname);
+    /* Mac OS style */
+    pthread_setname_np(threadname);
 #  else
-#    error "Could not identify your pthread_setname_np() implementation"
-#  endif
-# endif
+#   error "Could not identify your pthread_setname_np() implementation"
+#  endif /* PTHREAD_SETNAME_NP_ARGS */
+# endif /* HAVE_PTHREAD_SETNAME_NP */
 }
-#endif
+#endif /* AFS_PTHREAD_ENV && !AFS_NT40_ENV */
diff --git a/src/packaging/MacOS/InstallationCheck.18 b/src/packaging/MacOS/InstallationCheck.18
new file mode 100644
index 000000000..485a63b00
--- /dev/null
+++ b/src/packaging/MacOS/InstallationCheck.18
@@ -0,0 +1,19 @@
+#!/bin/sh
+majorvers=`uname -r | sed 's/\..*//'`
+if [ $majorvers -ne 18 ]; then
+	exit 112
+fi
+
+# check for temporary versions of ThisCell and CellAlias
+# and move them aside
+tmpthiscell=/private/tmp/org.OpenAFS.Install.ThisCell.$USER
+tmpcellalias=/private/tmp/org.OpenAFS.Install.CellAlias.$USER
+date=`date +%Y%m%d%H%M`
+if [ -e $tmpthiscell ]; then
+    mv -f $tmpthiscell $tmpthiscell.$date
+fi
+if [ -e $tmpcellalias ]; then
+    mv -f $tmpcellalias $tmpcellalias.$date
+fi
+
+exit 0
diff --git a/src/packaging/MacOS/InstallationCheck.19 b/src/packaging/MacOS/InstallationCheck.19
new file mode 100644
index 000000000..53d3eb376
--- /dev/null
+++ b/src/packaging/MacOS/InstallationCheck.19
@@ -0,0 +1,19 @@
+#!/bin/sh
+majorvers=`uname -r | sed 's/\..*//'`
+if [ $majorvers -ne 19 ]; then
+	exit 112
+fi
+
+# check for temporary versions of ThisCell and CellAlias
+# and move them aside
+tmpthiscell=/private/tmp/org.OpenAFS.Install.ThisCell.$USER
+tmpcellalias=/private/tmp/org.OpenAFS.Install.CellAlias.$USER
+date=`date +%Y%m%d%H%M`
+if [ -e $tmpthiscell ]; then
+    mv -f $tmpthiscell $tmpthiscell.$date
+fi
+if [ -e $tmpcellalias ]; then
+    mv -f $tmpcellalias $tmpcellalias.$date
+fi
+
+exit 0
diff --git a/src/packaging/MacOS/InstallationCheck.strings.18 b/src/packaging/MacOS/InstallationCheck.strings.18
new file mode 100644
index 000000000..f4df0dddb
--- /dev/null
+++ b/src/packaging/MacOS/InstallationCheck.strings.18
@@ -0,0 +1 @@
+"16" = "This OpenAFS release requires Mojave (10.14)";
diff --git a/src/packaging/MacOS/InstallationCheck.strings.19 b/src/packaging/MacOS/InstallationCheck.strings.19
new file mode 100644
index 000000000..ace343b5b
--- /dev/null
+++ b/src/packaging/MacOS/InstallationCheck.strings.19
@@ -0,0 +1 @@
+"16" = "This OpenAFS release requires Catalina (10.15)";
diff --git a/src/packaging/MacOS/OpenAFS-debug.Description.plist.in b/src/packaging/MacOS/OpenAFS-debug.Description.plist.in
index 2667452f0..dfbb4dc30 100644
--- a/src/packaging/MacOS/OpenAFS-debug.Description.plist.in
+++ b/src/packaging/MacOS/OpenAFS-debug.Description.plist.in
@@ -9,6 +9,6 @@
 	<key>IFPkgDescriptionTitle</key>
 	<string>OpenAFS debug extension</string>
 	<key>IFPkgDescriptionVersion</key>
-	<string>@VERSION@</string>
+	<string>@PACKAGE_VERSION@</string>
 </dict>
 </plist>
diff --git a/src/packaging/MacOS/OpenAFS.Description.plist.in b/src/packaging/MacOS/OpenAFS.Description.plist.in
index 8dece17c2..3cab1f7e3 100644
--- a/src/packaging/MacOS/OpenAFS.Description.plist.in
+++ b/src/packaging/MacOS/OpenAFS.Description.plist.in
@@ -9,6 +9,6 @@
 	<key>IFPkgDescriptionTitle</key>
 	<string>OpenAFS</string>
 	<key>IFPkgDescriptionVersion</key>
-	<string>@VERSION@</string>
+	<string>@PACKAGE_VERSION@</string>
 </dict>
 </plist>
diff --git a/src/packaging/MacOS/OpenAFS.info.in b/src/packaging/MacOS/OpenAFS.info.in
index a3d04a5bc..ac40126af 100644
--- a/src/packaging/MacOS/OpenAFS.info.in
+++ b/src/packaging/MacOS/OpenAFS.info.in
@@ -1,5 +1,5 @@
 Title OpenAFS
-Version @VERSION@
+Version @PACKAGE_VERSION@
 Description The OpenAFS distributed filesystem. This package installs a ready-to-run client for OpenAFS. See http://www.openafs.org for more information.
 DefaultLocation /
 Diskname (null)
diff --git a/src/packaging/MacOS/OpenAFS.post_install b/src/packaging/MacOS/OpenAFS.post_install
index b9ef27b40..ad6e70429 100644
--- a/src/packaging/MacOS/OpenAFS.post_install
+++ b/src/packaging/MacOS/OpenAFS.post_install
@@ -4,7 +4,12 @@ if [ -d /afs -a ! -h /afs ]; then
    rmdir /afs
 fi
 majorvers=`uname -r | sed 's/\..*//'`
-if [ $majorvers -ge 7 ]; then
+if [ $majorvers -ge 19 ]; then
+  # Root mount point is read-only. To workaround this restriction, add a
+  # synthetic entity for afs into /etc/synthetic.conf. For more information,
+  # please read man synthetic.conf(5).
+  grep -qs '^afs$' /etc/synthetic.conf || echo 'afs' >> /etc/synthetic.conf
+elif [ $majorvers -ge 7 ]; then
   # /Network is now readonly, so put AFS in /afs; make sure /afs is a directory
   if [ -e /afs ]; then
     if [ -h /afs -o ! -d /afs ]; then
@@ -136,3 +141,21 @@ fi
 #here we should run tools which configure the client, and then if it's enabled:
 #start the new launchd daemon
 launchctl load -w /Library/LaunchDaemons/org.openafs.filesystems.afs.plist
+
+if [ $majorvers -ge 19 ]; then
+    # Assume that, if /afs is not present, either OpenAFS is being installed for
+    # the first time or the system was not rebooted after the installation.
+    # If so, inform what needs to be done to load the client. This procedure is
+    # unnecessary if OpenAFS is being reinstalled.
+    if [ ! -d /afs ]; then
+	osascript -e 'display alert "OpenAFS successfully installed" message Â¬
+	"If OpenAFS is being installed for the first time on this machine, " & Â¬
+	"follow the steps below:\n\n" & Â¬
+	"1. Navigate to System Preferences > Security & Privacy;\n\n" & Â¬
+	"2. Under the General tab towards the bottom of the window, allow " & Â¬
+	"the OpenAFS kernel extension to load by clicking on Allow;\n\n" & Â¬
+	"3. Reboot the machine;\n\n" & Â¬
+	"Note: An entry for /afs was added in /etc/synthetic.conf. This " & Â¬
+	"change takes effectÂ onlyÂ after rebooting the system."'
+    fi
+fi
diff --git a/src/packaging/MacOS/ReadMe.rtf.18 b/src/packaging/MacOS/ReadMe.rtf.18
new file mode 100644
index 000000000..bea7c1c0b
--- /dev/null
+++ b/src/packaging/MacOS/ReadMe.rtf.18
@@ -0,0 +1,7 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\margl1440\margr1440\vieww9000\viewh9000\viewkind0
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f0\fs24 \cf0 This release of OpenAFS is targeted at MacOS 10.14 (Mojave) and is not recommended for use with any other version.}
diff --git a/src/packaging/MacOS/ReadMe.rtf.19 b/src/packaging/MacOS/ReadMe.rtf.19
new file mode 100644
index 000000000..a4fb8bd08
--- /dev/null
+++ b/src/packaging/MacOS/ReadMe.rtf.19
@@ -0,0 +1,7 @@
+{\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf320
+{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
+{\colortbl;\red255\green255\blue255;}
+\margl1440\margr1440\vieww9000\viewh9000\viewkind0
+\pard\tx1440\tx2880\tx4320\tx5760\tx7200\ql\qnatural
+
+\f0\fs24 \cf0 This release of OpenAFS is targeted at MacOS 10.15 (Catalina) and is not recommended for use with any other version.}
diff --git a/src/packaging/MacOS/buildpkg.sh.in b/src/packaging/MacOS/buildpkg.sh.in
index 143bda777..ec3711cff 100644
--- a/src/packaging/MacOS/buildpkg.sh.in
+++ b/src/packaging/MacOS/buildpkg.sh.in
@@ -306,14 +306,14 @@ if [ $secondpass = yes ]; then
     if [ $majorvers -ge 8 ]; then
 	mv $CURDIR/OpenAFS-debug-extension.pkg $CURDIR/dmg
     fi
-    rm -rf $CURDIR/OpenAFS-@VERSION@-$RELNAME.dmg
+    rm -rf $CURDIR/OpenAFS-@PACKAGE_VERSION@-$RELNAME.dmg
     cp $RESSRC/Uninstall $CURDIR/dmg/Uninstall.command
     cp $RESSRC/DS_Store $CURDIR/dmg/.DS_Store
     mkdir $CURDIR/dmg/.background
     cp $RESSRC/afslogo.jpg $CURDIR/dmg/.background
 #    hdiutil create -srcfolder $CURDIR/dmg -volname OpenAFS -anyowners $CURDIR/OpenAFS.dmg
     hdiutil makehybrid -hfs -hfs-volume-name OpenAFS -hfs-openfolder $CURDIR/dmg $CURDIR/dmg -o $CURDIR/TMP.dmg
-    hdiutil convert -format UDZO $CURDIR/TMP.dmg -o $CURDIR/OpenAFS-@VERSION@-$RELNAME.dmg
+    hdiutil convert -format UDZO $CURDIR/TMP.dmg -o $CURDIR/OpenAFS-@PACKAGE_VERSION@-$RELNAME.dmg
     rm $CURDIR/TMP.dmg
     rm -rf $CURDIR/dmg
     # Unfortunately, sudo sets $USER to root, so I can't chown the 
diff --git a/src/packaging/MacOS/notarize.pl b/src/packaging/MacOS/notarize.pl
new file mode 100755
index 000000000..026563012
--- /dev/null
+++ b/src/packaging/MacOS/notarize.pl
@@ -0,0 +1,186 @@
+#!/usr/bin/perl
+#
+# Copyright (c) 2019 Sine Nomine Associates
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# 1. Redistributions of source code must retain the above copyright
+#    notice, this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright
+#    notice, this list of conditions and the following disclaimer in the
+#    documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+# Description:
+#
+# Script used to automatically notarize the OpenAFS package.
+#
+# On success, the following output can be expected:
+#
+# $ sudo notarize.pl foo@bar.com "@keychain:PASSWORD" OpenAFS.dmg
+#
+# notarize.pl: submitting package...
+# notarize.pl: checking status...
+# notarize.pl: checking status...
+# notarize.pl: checking status...
+# (...)
+# notarize.pl: checking status...
+# notarize.pl: package successfully notarized
+
+use strict;
+use File::Which;
+
+sub usage {
+    print(STDERR "usage: notarize.pl <username> <password> <package>\n");
+    print(STDERR "\tusername: apple id\n");
+    print(STDERR "\tpassword: password of your apple id account\n");
+    print(STDERR "\tpackage: package to be notarized\n");
+    print(STDERR "\tnote: must be root\n");
+    print(STDERR "\t      <password> can be a reference to a keychain item.\n");
+    print(STDERR "\t      <password> as cleartext is not recommended.\n");
+    print(STDERR "e.g.: \$ sudo notarize.pl foo\@bar.com \"\@keychain:PASSWORD\" OpenAFS.dmg\n\n");
+    exit(1);
+}
+
+sub check_prerequisites {
+    my (@ARGS) = @_;
+
+    if ($> != 0) {
+	print(STDERR "error: must be root\n\n");
+	usage();
+    }
+    if (scalar @ARGS != 3) {
+	print(STDERR "error: check arguments\n\n");
+	usage();
+    }
+    if (!which('xcrun')) {
+	print(STDERR "error: xcrun not found in \$PATH\n\n");
+	usage();
+    }
+    if (not -e $ARGS[2]) {
+	print(STDERR "error: package not found\n\n");
+    }
+}
+
+sub submit_package {
+    my ($username, $password, $package) = @_;
+
+    print(STDOUT "notarize.pl: submitting package...\n");
+
+    my $output = qx(xcrun altool -t osx -f "$package" --primary-bundle-id org.openafs.OpenAFS --notarize-app --username "$username" --password "$password" 2>&1);
+    my $exitcode = $? >> 8;
+
+    if ($exitcode) {
+	print(STDERR "error: $exitcode\n");
+	print(STDERR $output);
+	exit(1);
+    }
+    # $output looks like the following sample:
+    #
+    # No errors uploading 'OpenAFS.dmg'.
+    # RequestUUID = 565a4d1b-9608-47a6-aba9-53136c991bb8
+    $output =~ m{RequestUUID = ([A-Za-z0-9\-]+)};
+    if (not defined $1) {
+	print(STDERR "error: uuid not found\n");
+	exit(1);
+    }
+    return $1;
+}
+
+sub check_status {
+    my ($username, $password, $uuid) = @_;
+    my $output;
+    my $status;
+    my $exitcode;
+
+    while (1) {
+	print(STDOUT "notarize.pl: checking status...\n");
+	$output = qx(xcrun altool --notarization-info "$uuid" --username "$username" --password "$password" 2>&1);
+	$exitcode = $? >> 8;
+
+	if ($exitcode) {
+	    print(STDERR "error: $exitcode\n");
+	    print(STDERR $output);
+	    exit(1);
+	}
+	# $output looks like the following samples:
+	#
+	# First, second, ..., (N-1)'th attempts:
+	#
+	# No errors getting notarization info.
+	#
+	# Date: 2019-11-26 21:07:46 +0000
+	# Hash: 4e10ebb01518de9eb007d4579006acda2d6ff773fe040d97786bcc686ec93gg1
+	# RequestUUID: 565a4d1b-9608-47a6-aba9-53136c991bb8
+	# Status: in progress
+	#
+	# N'th attempt:
+	#
+	# No errors getting notarization info.
+	#
+	# Date: 2019-11-26 21:07:46 +0000
+	# Hash: 4e10ebb01518de9eb007d4579006acda2d6ff773fe040d97786bcc686ec93gg1
+	# RequestUUID: 565a4d1b-9608-47a6-aba9-53136c991bb8
+	# Status: in progress
+	# Status Code: 0
+	# Status Message: Package Approved
+	$output =~ m{Status Code: (\d+)};
+	if (defined $1) {
+	    $status = $1;
+	    last;
+	}
+	sleep(5);
+    }
+    if ($status) {
+	print(STDERR "error: $status (uuid: $uuid)\n");
+	print(STDERR $output);
+	exit(1);
+    }
+}
+
+sub notarize_package {
+    my ($package, $uuid) = @_;
+
+    print(STDOUT "notarize.pl: notarizing package...\n");
+
+    my $output = qx(xcrun stapler staple -v "$package" 2>&1);
+    my $exitcode = $? >> 8;
+
+    if ($exitcode) {
+	print(STDERR "error: package could not be notarized (uuid: $uuid)\n");
+	print(STDERR $output);
+	exit(1);
+    }
+    print(STDOUT "notarize.pl: package successfully notarized\n");
+}
+
+sub main {
+    my (@ARGS) = @_;
+
+    check_prerequisites(@ARGS);
+    my $username = $ARGS[0];
+    my $password = $ARGS[1];
+    my $package = $ARGS[2];
+
+    my $uuid = submit_package($username, $password, $package);
+    check_status($username, $password, $uuid);
+    notarize_package($package, $uuid);
+
+    exit(0);
+}
+main(@ARGV);
diff --git a/src/packaging/MacOS/pkgbuild.sh.in b/src/packaging/MacOS/pkgbuild.sh.in
index 2a3f4a048..18143046e 100644
--- a/src/packaging/MacOS/pkgbuild.sh.in
+++ b/src/packaging/MacOS/pkgbuild.sh.in
@@ -6,10 +6,20 @@ usage() {
     exec >&2
 
     echo 'Usage: pkgbuild.sh [-x] [--app-key <appkey>] [--inst-key <instkey>]'
+    echo '                   [--apple-id <appleid> <password>]'
     echo '                   [--pass N] [--csdb <CellServDB>] <binary-dir>'
     echo
     echo '--app-key and --inst-key are for signing. -x prints all comamnds as '
-    echo 'they are run.'
+    echo 'they are run. --apple-id is for notarizing.'
+    echo
+    echo 'Note: the password associated with <appleid> can be a reference to a'
+    echo 'keychain item. Including your password as cleartext is not'
+    echo 'recommended. e.g.'
+    echo
+    echo '--apple-id foo@bar.com "@keychain:PASSWORD"'
+    echo
+    echo 'In this case, keychain must hold a keychain item named PASSWORD with'
+    echo 'an account matching foo@bar.com.'
     echo
     echo 'By default, all passes are run. Available passes:'
     echo '    --pass 1: prepare pkgroot'
@@ -30,9 +40,13 @@ PASS2=
 
 APP_KEY=
 INST_KEY=
+APPLE_ID=
+APPLE_PW=
 DEST_DIR=
 CSDB=
 
+CODESIGN_OPTS=
+
 while [ x"$#" != x0 ] ; do
     key="$1"
     shift
@@ -46,6 +60,12 @@ while [ x"$#" != x0 ] ; do
 	INST_KEY="$1"
 	shift
 	;;
+    --apple-id)
+	APPLE_ID="$1"
+	shift
+	APPLE_PW="$1"
+	shift
+	;;
     --csdb)
 	CSDB="$1"
 	shift
@@ -135,6 +155,14 @@ elif [ x"$majorvers" = x17 ]; then
     RELNAME="HighSierra"
     THISREL=13
 
+elif [ x"$majorvers" = x18 ]; then
+    RELNAME="Mojave"
+    THISREL=14
+
+elif [ x"$majorvers" = x19 ]; then
+    RELNAME="Catalina"
+    THISREL=15
+
 elif [ x"$majorvers" = x ] ; then
     echo "Error running uname" >&2
     exit 1
@@ -144,6 +172,11 @@ else
     exit 1
 fi
 
+if [ $THISREL -ge 14 ]; then
+    # Enable the Hardened Runtime capability, required as of 10.14.5.
+    CODESIGN_OPTS="--options runtime"
+fi
+
 SEP=:
 
 PKGROOT="$CURDIR"/pkgroot
@@ -307,6 +340,10 @@ if [ x"$PASS1" = x1 ]; then
     chmod  og-rx "$PKGROOT"/private/var/db/openafs/cache
 
     if [ x"$APP_KEY" != x ] ; then
+	# To be notarized by Apple, all files must be signed.
+	find "$PKGROOT" -type f -exec codesign --verbose --force \
+	    --timestamp --sign "$APP_KEY" $CODESIGN_OPTS {} \;
+
 	# Sign each 'thing' that we have (commands, kexts, etc)
 	for obj in "$DPKGROOT"/Library/OpenAFS/Debug/afs.kext \
 		   "$PKGROOT"/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.kext \
@@ -316,11 +353,14 @@ if [ x"$PASS1" = x1 ]; then
 		   "$PKGROOT"/Library/Security/SecurityAgentPlugins/aklog.bundle \
 		   "$PKGROOT"/Library/OpenAFS/Tools/tools/growlagent-openafs.app \
 		   "$PKGROOT"/Library/OpenAFS/Tools/tools/aklog.bundle \
+		   "$PKGROOT"/Library/OpenAFS/Tools/tools/OpenAFS.prefPane/Contents/Resources/AFSBackgrounder.app \
+		   "$PKGROOT"/Library/OpenAFS/Tools/tools/OpenAFS.prefPane \
 		   "$PLUGINS"/afscell.bundle
 	do
-	    codesign --verbose --force --timestamp --sign "$APP_KEY" "$obj"
+	    codesign --verbose --force --timestamp --sign "$APP_KEY" $CODESIGN_OPTS "$obj"
 	done
 
+
 	# Check if our signatures for our kexts are valid. 'kextutil' will exit
 	# with an error and print out a message if something is wrong with the
 	# signature. Note that a code signing cert must have the
@@ -330,7 +370,13 @@ if [ x"$PASS1" = x1 ]; then
 		    "$PKGROOT"/Library/OpenAFS/Tools/root.client/usr/vice/etc/afs.kext \
 		    "$PKGROOT"/private/var/db/openafs/etc/afs.kext
 	do
-	    kextutil -no-load -print-diagnostics "$kext"
+	    # This check will fail on systems that require notarization, because we haven't
+	    # notarized anything yet.  For now, just disable the check for those versions.
+	    if [ $THISREL -ge 14 ]; then
+	    	echo "Skipping kextutil checks for $kext"
+	    else
+	    	kextutil -no-load -print-diagnostics "$kext"
+	    fi
 	done
     fi
 
@@ -422,7 +468,7 @@ if [ x"$PASS2" = x1 ]; then
 
     rm -rf "$CURDIR"/OpenAFS-debug-extension.pkg
     /usr/bin/pkgbuild --root "$DPKGROOT" --id org.openafs.OpenAFS-debug.pkg \
-		      --version '@VERSION@' \
+		      --version '@PACKAGE_VERSION@' \
 	     "$CURDIR"/OpenAFS-debug-extension.pkg
 
     cd "$RESSRC"
@@ -441,7 +487,7 @@ if [ x"$PASS2" = x1 ]; then
 
     rm -rf "$CURDIR"/OpenAFS-dist.pkg
     /usr/bin/pkgbuild --root "$PKGROOT" --id org.openafs.OpenAFS.pkg \
-		      --version '@VERSION@' \
+		      --version '@PACKAGE_VERSION@' \
 		      --scripts "$PKGRES" "$CURDIR"/OpenAFS-dist.pkg
 
     rm -rf "$PKGRES"
@@ -462,7 +508,7 @@ if [ x"$PASS2" = x1 ]; then
     sed -e "s/%%OSX_MAJOR_CUR%%/$THISREL/g" \
 	-e "s/%%OSX_MAJOR_NEXT%%/$(( $THISREL + 1 ))/g" \
 	-e "s,%%PRES_EXTRA%%,$PRES_EXTRA,g" \
-	-e "s/%%OPENAFS_VERSION%%/@VERSION@/g" \
+	-e "s/%%OPENAFS_VERSION%%/@PACKAGE_VERSION@/g" \
 	< Distribution.xml.in > Distribution.xml
 
     rm -rf "$CURDIR/prod"
@@ -480,7 +526,7 @@ if [ x"$PASS2" = x1 ]; then
 
     rm -rf "$CURDIR/dmg"
     rm -f "$CURDIR/TMP.dmg"
-    rm -rf "$CURDIR/OpenAFS-@VERSION@-$RELNAME.dmg"
+    rm -rf "$CURDIR/OpenAFS-@PACKAGE_VERSION@-$RELNAME.dmg"
 
     mkdir "$CURDIR"/dmg
     mv "$CURDIR"/OpenAFS.pkg "$CURDIR"/dmg
@@ -491,13 +537,19 @@ if [ x"$PASS2" = x1 ]; then
 
     if [ x"$APP_KEY" != x ] ; then
 	codesign --verbose --force --timestamp --sign "$APP_KEY" "$CURDIR"/dmg/Uninstall.command
+	codesign --verbose --force --timestamp --sign "$APP_KEY" "$CURDIR"/dmg/OpenAFS.pkg
     fi
 
     hdiutil create -srcfolder "$CURDIR"/dmg -volname OpenAFS \
 	    -o "$CURDIR"/TMP.dmg
     hdiutil convert -format UDZO "$CURDIR"/TMP.dmg \
-	    -o "$CURDIR/OpenAFS-@VERSION@-$RELNAME".dmg
+	    -o "$CURDIR/OpenAFS-@PACKAGE_VERSION@-$RELNAME".dmg
 
     echo
-    echo "Created $CURDIR/OpenAFS-@VERSION@-$RELNAME".dmg
+    echo "Created $CURDIR/OpenAFS-@PACKAGE_VERSION@-$RELNAME".dmg
+
+    if [ x"$APPLE_ID" != x ] ; then
+	echo "Notarizing package..."
+	./notarize.pl "$APPLE_ID" "$APPLE_PW" "$CURDIR/OpenAFS-@PACKAGE_VERSION@-$RELNAME.dmg"
+    fi
 fi
diff --git a/src/packaging/RedHat/makesrpm.pl b/src/packaging/RedHat/makesrpm.pl
index c46e99473..7d6e1a96f 100755
--- a/src/packaging/RedHat/makesrpm.pl
+++ b/src/packaging/RedHat/makesrpm.pl
@@ -3,24 +3,39 @@
 use strict;
 use warnings;
 
+use Getopt::Long;
+use Pod::Usage;
 use IO::Dir;
 use IO::File;
 use File::Path;
 use File::Copy;
 use File::Temp;
+use File::Basename;
+use File::Spec;
 
 # Build an SRPM for OpenAFS, given a src and doc tarball, release notes,
 # and ChangeLog.
 
+my $help = 0;
+my $man = 0;
+my $dir = ".";
+
+GetOptions(
+    "help|?" => \$help,
+    "man" => \$man,
+    "dir=s" => \$dir,
+) or pod2usage(-exitval => 1, -verbose => 1);
+pod2usage(-exitval => 0, -verbose => 1) if $help;
+pod2usage(-exitval => 0, -verbose => 2, -noperldoc => 1) if $man;
+
 my $srcball = shift;
 my $docball = shift;
 my $relnotes = shift;
 my $changelog = shift;
 my $cellservdb = shift;
 
-if (!$srcball && !$docball) {
-  printf "Usage:  makesrpm <src.tar.bz2> <doc.tar.bz2> [<relnotes> [<changelog> [<cellservdb>]]]\n";
-  exit(1);
+if (!defined($srcball) || !defined($docball)) {
+    pod2usage(-exitval => 1, -verbose => 1);
 }
 
 if (! -f $srcball) {
@@ -77,15 +92,12 @@ if ($afsversion=~m/(.*)-([0-9]+)-(g[a-f0-9]+)$/) {
     $linuxrel.=".$2.$3";
 }
 
-print "Linux release is $linuxrel\n";
-print "Linux version is $linuxver\n";
+# Avoid illegal characters in RPM package version and release strings.
+$linuxver =~ s/-/_/g;
+$linuxrel =~ s/-/_/g;
 
-# Figure out a major, minor and release so that we know which version we're
-# building, and therefore what the srpm is going to be called
-$linuxver=~/([0-9]+)\.([0-9]+)\.([0-9]+)/;
-my $major = $1;
-my $minor = $2;
-my $patchlevel = $3;
+print "Package version is $linuxver\n";
+print "Package release is $linuxrel\n";
 
 # Build the RPM root
 
@@ -118,13 +130,12 @@ while (defined($file = $pkgdirh->read)) {
 }
 undef $dirh;
 
-# Some files need particular modes.
-chmod 0755, $tmpdir."/rpmdir/SOURCES/openafs-kernel-version.sh";
+# This file needs particular modes.
 chmod 0755, $tmpdir."/rpmdir/SOURCES/openafs-kvers-is.sh";
 
 # Create the specfile. Use sed for this, cos its easier
 system("cat ".$srcdir."/src/packaging/RedHat/openafs.spec.in | ".
-       "sed -e 's/\@VERSION\@/$afsversion/g' ".
+       "sed -e 's/\@PACKAGE_VERSION\@/$afsversion/g' ".
        "    -e 's/\@LINUX_PKGVER\@/$linuxver/g' ".
        "    -e 's/\@LINUX_PKGREL\@/$linuxrel/g' ".
        "    -e 's/\%define afsvers.*/%define afsvers $afsversion/g' ".
@@ -166,18 +177,49 @@ system("rpmbuild -bs --nodeps --define \"dist %undefined\" ".
   or die "rpmbuild failed : $!\n";
 
 # Copy it out to somewhere useful
-if (!defined($major) || $major > 1 || ($major == 1 && $minor >= 6)) {
-  File::Copy::copy("$tmpdir/rpmdir/SRPMS/openafs-$linuxver-$linuxrel.src.rpm",
-	           "openafs-$linuxver-$linuxrel.src.rpm")
-    or die "Unable to copy output RPM : $!\n";
+my @srpms = glob("$tmpdir/rpmdir/SRPMS/*.src.rpm");
+if (scalar(@srpms) != 1) {
+    die "Generated SRPM file not found.\n";
+}
+my $filename = File::Basename::fileparse($srpms[0]);
+my $srpm = File::Spec->rel2abs("$dir/$filename");
+File::Path::make_path($dir);
+File::Copy::copy($srpms[0], $srpm)
+    or die "Failed to copy '$srpms[0]' to '$srpm': $!\n";
+print "SRPM is $srpm\n";
 
-  print "SRPM is openafs-$linuxver-$linuxrel.src.rpm\n";
-} else {
-  File::Copy::copy("$tmpdir/rpmdir/SRPMS/openafs-$linuxver-1.$linuxrel.src.rpm",
-	           "openafs-$linuxver-1.$linuxrel.src.rpm")
-    or die "Unable to copy output RPM : $!\n";
+__END__
 
-  print "SRPM is openafs-$linuxver-1.$linuxrel.src.rpm\n";
-}
+=head1 NAME
+
+makesrpm.pl - Build the SRPM for OpenAFS from source distibution files
+
+=head1 SYNOPSIS
+
+makesrpm.pl [options] <src.tar.bz2> <doc.tar.bz2> [<relnotes> [<changelog> [<cellservdb>]]]
+
+=head1 DESCRIPTION
+
+Build the SRPM for OpenAFS from source distibution files. Generate empty RELNOTES
+and ChangeLog files if not provided. Download the CellServDB file from
+grand.central.org if one is not provided.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<--help>
+
+Print help message and exit.
+
+=item B<--man>
+
+Print full man page and exit.
+
+=item B<--dir> I<path>
+
+Place the generated SRPM file in I<path> instead of the current directory.
 
+=back
 
+=cut
diff --git a/src/packaging/RedHat/openafs-client.service b/src/packaging/RedHat/openafs-client.service
index 09379bea3..f79240c7f 100644
--- a/src/packaging/RedHat/openafs-client.service
+++ b/src/packaging/RedHat/openafs-client.service
@@ -1,7 +1,7 @@
 [Unit]
 Description=OpenAFS Client Service
 Wants=network-online.target
-After=syslog.target network-online.target
+After=syslog.target network-online.target dkms.service
 Before=remote-fs.target
 
 [Service]
diff --git a/src/packaging/RedHat/openafs-kernel-version.sh b/src/packaging/RedHat/openafs-kernel-version.sh
deleted file mode 100755
index d3a0e490e..000000000
--- a/src/packaging/RedHat/openafs-kernel-version.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/bin/sh
-#
-# investigate the name of the kernel
-#
-# $Revision$
-
-if [ "x$1" = "x" ] ; then
-    kernvers=`uname -r`
-    if [ ! -d /lib/modules/$kernvers/build/include ] ; then
-        kernvers=`/bin/ls /lib/modules/*/build/include/linux/version.h | \
-        cut -d/ -f4 | \
-        sort -u | \
-        tail -1`
-    fi
-else
-    kernvers=$1
-fi
-
-if [ -z "$kernvers" ]; then echo "unable to determine kernel version" >&2; exit 1; fi
-
-# strip "kernel-" off of the front
-if expr "$kernvers" : "kernel-" >&/dev/null
-then
-    kernvers=`expr "$kernvers" : 'kernel-\(.*\)'`
-fi
-
-# Strip kernel config mnemonic off 2.4 kernels.
-case $kernvers in
-  2.4.*)
-    # strip kernel config mnemonic off of the tail
-    case "$kernvers" in
-      *smp)
-         kernvers=`expr "$kernvers" : '\(.*\)smp'`
-         ;;
-      *bigmem)
-         kernvers=`expr "$kernvers" : '\(.*\)bigmem'`
-         ;;
-      *hugemem)
-         kernvers=`expr "$kernvers" : '\(.*\)hugemem'`
-         ;;
-      *enterprise)
-         kernvers=`expr "$kernvers" : '\(.*\)enterprise'`
-         ;;
-    esac
-    ;;
-esac
-
-echo $kernvers
-exit 0
diff --git a/src/packaging/RedHat/openafs-kmodtool b/src/packaging/RedHat/openafs-kmodtool
index b6dee3287..5ee68261c 100644
--- a/src/packaging/RedHat/openafs-kmodtool
+++ b/src/packaging/RedHat/openafs-kmodtool
@@ -92,21 +92,37 @@ get_rpmtemplate ()
     esac
 
     cat <<EOF
+
+%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*openafs\.ko.*' -o kmod-debuginfo.list
+
 %package       -n kmod-${kmod_name}${dashvariant}
 Summary:          ${kmod_name} kernel module(s)
 Group:            System Environment/Kernel
 Provides:         kernel-modules = ${kname}
 Provides:         ${kmod_name}-kmod = %{?epoch:%{epoch}:}%{version}-%{release}
-Provides:         openafs-kernel = %{PACKAGE_VERSION}
+Provides:         openafs-kernel = %{version}
 Requires:         ${kdep}
 Requires:         ${kmod_name}-kmod-common >= %{?epoch:%{epoch}:}%{version}
 Requires(post):   ${depmod}
 Requires(postun): ${depmod}
 Release:          %{pkgrel}.%(echo ${verrel} | tr - _)
 BuildRequires:    kernel${dashvariant}-devel-%{_target_cpu} = ${verrel}
+%if 0%{?rhel} >= 8
+BuildRequires: elfutils-devel
+%endif
 %description   -n kmod-${kmod_name}${dashvariant}
 This package provides the ${kmod_name} kernel modules built for the Linux
 kernel ${kname} for the %{_target_cpu} family of processors.
+
+%package       -n kmod-%{kmod_name}${dashvariant}-debuginfo
+Summary:          Debug information for %{kmod_name} kernel modules
+Group:            Development/Debug
+Release:          %{pkgrel}.%(echo ${verrel} | tr - _)
+AutoReqProv:      no
+%description   -n kmod-%{kmod_name}${dashvariant}-debuginfo
+This package provides debug information for the %{kmod_name} kernel modules
+built for the Linux kernel ${kname} for the %{_target_cpu} family of processors.
+
 %post          -n kmod-${kmod_name}${dashvariant}
 ${depmod} -aeF /boot/System.map-${kname} ${kname} > /dev/null || :
 %postun        -n kmod-${kmod_name}${dashvariant}
@@ -115,6 +131,9 @@ ${depmod} -aF /boot/System.map-${kname} ${kname} &> /dev/null || :
 %defattr(644,root,root,755)
 /lib/modules/${kname}/extra/${kmod_name}/
 
+%files -f kmod-debuginfo.list -n kmod-%{kmod_name}${dashvariant}-debuginfo
+%defattr(-,root,root)
+
 EOF
 }
 
diff --git a/src/packaging/RedHat/openafs.spec.in b/src/packaging/RedHat/openafs.spec.in
index 410ddc74e..5c54e2ede 100644
--- a/src/packaging/RedHat/openafs.spec.in
+++ b/src/packaging/RedHat/openafs.spec.in
@@ -1,6 +1,6 @@
-# Openafs Spec $Revision$
+# Openafs Spec
 
-%define afsvers @VERSION@
+%define afsvers @PACKAGE_VERSION@
 %define pkgvers @LINUX_PKGVER@
 # for beta/rc releases make pkgrel 0.<tag>
 # for real releases make pkgrel 1 (or more for extra releases)
@@ -12,14 +12,10 @@
 # Determine presence of rpmbuild command line --define arguments and set
 # defaults if not present.
 #
-%define kernvers_on_cmdline %{?kernvers:1}%{!?kernvers:0}
 %define build_userspace_on_cmdline %{?build_userspace:1}%{!?build_userspace:0}
 %define build_modules_on_cmdline %{?build_modules:1}%{!?build_modules:0}
 %define debugspec_on_cmdline %{?debugspec:1}%{!?debugspec:0}
 
-%if !%{kernvers_on_cmdline}
-%define kernvers %(uname -r)
-%endif
 %if !%{build_userspace_on_cmdline}
 %define build_userspace 1
 %endif
@@ -91,7 +87,7 @@ URL: http://www.openafs.org
 BuildRoot: %{_tmppath}/%{name}-%{version}-root
 Packager: OpenAFS Gatekeepers <openafs-gatekeepers@openafs.org>
 Group: Networking/Filesystems
-BuildRequires: %{?kdepend:%{kdepend}, } pam-devel, ncurses-devel, flex, bison
+BuildRequires: %{?kdepend:%{kdepend}, } pam-devel, ncurses-devel, make, flex, bison
 %if 0%{?fedora} >= 15 || 0%{?rhel} >= 7
 BuildRequires: systemd-units
 %endif
@@ -104,11 +100,13 @@ BuildRequires: krb5-devel
 %endif
 %if %{build_modules}
 BuildRequires: kernel-devel
+%if 0%{?rhel} >= 8
+BuildRequires: elfutils-devel
+%endif
 %endif
 
-ExclusiveArch: %{ix86} x86_64 ia64 s390 s390x sparc64 ppc ppc64
+ExclusiveArch: %{ix86} x86_64 ia64 s390 s390x sparc64 ppc ppc64 ppc64le aarch64
 
-#    http://dl.openafs.org/dl/openafs/candidate/%{afsvers}/...
 Source0: http://www.openafs.org/dl/openafs/%{afsvers}/openafs-%{afsvers}-src.tar.bz2
 Source1: http://www.openafs.org/dl/openafs/%{afsvers}/openafs-%{afsvers}-doc.tar.bz2
 %define srcdir openafs-%{afsvers}
@@ -116,9 +114,8 @@ Source1: http://www.openafs.org/dl/openafs/%{afsvers}/openafs-%{afsvers}-doc.tar
 Source10: http://www.openafs.org/dl/openafs/%{afsvers}/RELNOTES-%{afsvers}
 Source11: http://www.openafs.org/dl/openafs/%{afsvers}/ChangeLog
 
-Source20: https://www.central.org/dl/cellservdb/CellServDB.2017-03-14
+Source20: https://www.central.org/dl/cellservdb/CellServDB.2018-05-14
 
-Source30: openafs-kernel-version.sh
 Source996: openafs-kvers-is.sh
 Source997: openafs-buildfedora.pl
 Source998: openafs-buildall.sh
@@ -232,8 +229,7 @@ Summary:        DKMS-ready kernel source for AFS distributed filesystem
 Group:          Development/Kernel
 Provides:       openafs-kernel = %{version}
 Provides: %{name}-kmod = %{version}
-Requires(pre):  dkms
-Requires(pre):  flex
+Requires(pre):  dkms, make, flex
 Requires(post): dkms
 Requires:	%{name}-kmod-common = %{version}
 
@@ -330,7 +326,6 @@ module.
 Summary: OpenAFS client compatibility symlinks
 Requires: openafs = %{version}, openafs-client = %{version}
 Group: Networking/Filesystems
-Obsoletes: openafs-client-compat
 
 %description compat
 The AFS distributed filesystem.  AFS is a distributed filesystem
@@ -403,17 +398,6 @@ krb4 lookalike services.
 ##############################################################################
 %if %{build_modules}
 
-# Make debuginfo for the kernel components into their own package
-# so we can upgrade kernel and userspace seperately and still debug each
-%package -n %{name}-kernel-debuginfo
-Summary: Debug information for %{name} kernel modules
-Group: Development/Debug
-AutoReqProv: no
-%description -n %{name}-kernel-debuginfo
-This package provides debug information for %{name} kernel modules.
-
-%{expand:%%global _find_debuginfo_opts %{?_find_debuginfo_opts} -p '.*openafs.ko(\.debug)?' -o kmod-debuginfo.list}
-
 %{expand:%(%{kmodtool} rpmtemplate %{kmod_name} %{kverrel} %{depmod} %{kvariants} 2>/dev/null)}
 
 %endif
@@ -428,7 +412,7 @@ This package provides debug information for %{name} kernel modules.
 
 : @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 : @@@
-: @@@ kernel version:     %{kernvers}
+: @@@ kernel version:     %{kverrel}
 : @@@ kernel variations:  %{kvariants}
 : @@@ PAM modules dir:    %{pamdir}
 : @@@ build userspace:    %{build_userspace}
@@ -439,7 +423,6 @@ This package provides debug information for %{name} kernel modules.
 : @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
 
 # Install OpenAFS src and doc
-#%setup -q -n %{srcdir}
 %setup -q -b 1 -n %{srcdir}
 
 ##############################################################################
@@ -452,6 +435,7 @@ case %{_arch} in
        x86_64)                         sysname=amd64_linux26        ;;
        alpha*)                         sysname=alpha_linux_26       ;;
        i386|i486|i586|i686|athlon)     sysname=i386_linux26         ;;
+       aarch64)                        sysname=arm64_linux26        ;;
        *)                              sysname=%{_arch}_linux26     ;;
 esac
 
@@ -606,6 +590,8 @@ export KRB5_CONFIG
        --with-linux-kernel-packaging \
 %if %{build_modules}
        --with-linux-kernel-headers=${ksrc} \
+%else
+       --disable-kernel-module \
 %endif
 %if %{krb5support}
 	--with-krb5 \
@@ -619,7 +605,7 @@ export KRB5_CONFIG
        || exit 1
 
 # Build the libafs tree
-make only_libafs_tree || exit 1
+make %{_smp_mflags} only_libafs_tree || exit 1
 
 %if %{krb5support}
 %if %{?krb5config:1}%{!?krb5config:0}
@@ -668,7 +654,7 @@ done
 
 %if %{build_userspace}
 # Build the user-space AFS stuff
-make all_nolibafs
+make %{_smp_mflags} all_nolibafs
 %endif
 
 %if %{build_modules}
@@ -676,10 +662,10 @@ for kvariant in %{kvariants}
 do
   if [ -n "${kvariant}" ] ; then
     pushd _kmod_build_$kvariant;
-    make all
+    make %{_smp_mflags} all
     popd
   else
-    make libafs
+    make %{_smp_mflags} libafs
   fi
 done
 %endif
@@ -706,7 +692,7 @@ export DONT_GPRINTIFY=1 # Do not modify initscripts.
 #-----------------------------------------------------------------------------
 # Install userspace files
 #-----------------------------------------------------------------------------
-make install_nolibafs DESTDIR="$RPM_BUILD_ROOT"
+make %{_smp_mflags} install_nolibafs DESTDIR="$RPM_BUILD_ROOT"
 
 # Set the executable bit on libraries in libdir, so rpmbuild knows to
 # create "Provides" entries in the package metadata for the libraries
@@ -815,7 +801,7 @@ rm -f $RPM_BUILD_ROOT%{_mandir}/man5/AuthLog.5
 rm -f $RPM_BUILD_ROOT%{_mandir}/man5/AuthLog.dir.5
 %endif
 %if !(0%{?fedora} >= 15 || 0%{?rhel} >= 6)
-rm -f %{_mandir}/man3/AFS::ukernel.3
+rm -f $RPM_BUILD_ROOT%{_mandir}/man3/AFS::ukernel.3
 %endif
 
 #-----------------------------------------------------------------------------
@@ -864,12 +850,13 @@ PACKAGE_VERSION="%{dkms_version}"
 # Items below here should not have to change with each driver version.
 PACKAGE_NAME="%{name}"
 MAKE[0]='./configure --with-linux-kernel-headers=${kernel_source_dir} --with-linux-kernel-packaging && make && case "${kernelver_array[0]}${kernelver[0]}" in 2.4.*) mv src/libafs/MODLOAD-*/libafs-* openafs.o ;; *) mv src/libafs/MODLOAD-*/openafs.ko . ;; esac'
-CLEAN="make -C src/libafs clean"
+CLEAN="if [ -e src/libafs/Makefile ]; then make -C src/libafs clean; else true; fi"
 
 BUILT_MODULE_NAME[0]="$PACKAGE_NAME"
-DEST_MODULE_LOCATION[0]="/kernel/3rdparty/$PACKAGE_NAME/"
+DEST_MODULE_LOCATION[0]="/extra/$PACKAGE_NAME/"
 STRIP[0]=no
 AUTOINSTALL=yes
+NO_WEAK_MODULES="true"
 
 EOF
 
@@ -1141,6 +1128,17 @@ dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
 %{_sbindir}/fstrace
 %{_sbindir}/read_tape
 %{_sbindir}/rxdebug
+%{_sbindir}/rxstat_clear_peer
+%{_sbindir}/rxstat_clear_process
+%{_sbindir}/rxstat_disable_peer
+%{_sbindir}/rxstat_disable_process
+%{_sbindir}/rxstat_enable_peer
+%{_sbindir}/rxstat_enable_process
+%{_sbindir}/rxstat_get_peer
+%{_sbindir}/rxstat_get_process
+%{_sbindir}/rxstat_get_version
+%{_sbindir}/rxstat_query_peer
+%{_sbindir}/rxstat_query_process
 %{_sbindir}/uss
 %{_sbindir}/vos
 %{_sbindir}/vsys
@@ -1346,6 +1344,7 @@ dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
 %{_includedir}/timer.h
 %{_includedir}/ubik.h
 %{_includedir}/ubik_int.h
+%{_includedir}/opr/lock.h
 %{_includedir}/opr/queue.h
 %{_libdir}/afs
 %{_libdir}/libafshcrypto.a
@@ -1463,11 +1462,6 @@ dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
 %{_mandir}/man8/akeyconvert.8.gz
 %{_mandir}/man8/asetkey.8.gz
 %endif
-%endif  # build_userspace
-
-%if %{build_modules}
-%files -f kmod-debuginfo.list -n %{name}-kernel-debuginfo
-%defattr(-,root,root)
 %endif
 
 ##############################################################################
diff --git a/src/platform/DARWIN/AFSPreference/AFSBackgrounder/resource/AFSBackounderMainMenu.xib b/src/platform/DARWIN/AFSPreference/AFSBackgrounder/resource/AFSBackounderMainMenu.xib
index 6d0be7d5f..fa31fbdec 100644
--- a/src/platform/DARWIN/AFSPreference/AFSBackgrounder/resource/AFSBackounderMainMenu.xib
+++ b/src/platform/DARWIN/AFSPreference/AFSBackgrounder/resource/AFSBackounderMainMenu.xib
@@ -1,294 +1,42 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
-	<data>
-		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9J61</string>
-		<string key="IBDocument.InterfaceBuilderVersion">680</string>
-		<string key="IBDocument.AppKitVersion">949.46</string>
-		<string key="IBDocument.HIToolboxVersion">353.00</string>
-		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="1"/>
-		</object>
-		<object class="NSArray" key="IBDocument.PluginDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string>com.apple.InterfaceBuilderKit</string>
-			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-		</object>
-		<object class="NSMutableDictionary" key="IBDocument.Metadata">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSArray" key="dict.sortedKeys">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-			</object>
-			<object class="NSMutableArray" key="dict.values">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-			</object>
-		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSCustomObject" id="1001">
-				<string key="NSClassName">NSObject</string>
-			</object>
-			<object class="NSCustomObject" id="1003">
-				<string key="NSClassName">FirstResponder</string>
-			</object>
-			<object class="NSCustomObject" id="1004">
-				<string key="NSClassName">NSApplication</string>
-			</object>
-			<object class="NSMenu" id="913072818">
-				<string key="NSTitle"/>
-				<object class="NSMutableArray" key="NSMenuItems">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="NSMenuItem" id="77178862">
-						<reference key="NSMenu" ref="913072818"/>
-						<string key="NSTitle">Start AFS</string>
-						<string key="NSKeyEquiv"/>
-						<int key="NSMnemonicLoc">2147483647</int>
-						<object class="NSCustomResource" key="NSOnImage" id="769352467">
-							<string key="NSClassName">NSImage</string>
-							<string key="NSResourceName">NSMenuCheckmark</string>
-						</object>
-						<object class="NSCustomResource" key="NSMixedImage" id="863282242">
-							<string key="NSClassName">NSImage</string>
-							<string key="NSResourceName">NSMenuMixedState</string>
-						</object>
-					</object>
-					<object class="NSMenuItem" id="661887258">
-						<reference key="NSMenu" ref="913072818"/>
-						<bool key="NSIsDisabled">YES</bool>
-						<bool key="NSIsSeparator">YES</bool>
-						<string key="NSTitle"/>
-						<string key="NSKeyEquiv"/>
-						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="769352467"/>
-						<reference key="NSMixedImage" ref="863282242"/>
-					</object>
-					<object class="NSMenuItem" id="10398219">
-						<reference key="NSMenu" ref="913072818"/>
-						<string key="NSTitle">Get Token</string>
-						<string key="NSKeyEquiv"/>
-						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="769352467"/>
-						<reference key="NSMixedImage" ref="863282242"/>
-					</object>
-				</object>
-			</object>
-			<object class="NSCustomObject" id="437456796">
-				<string key="NSClassName">AFSBackgrounderDelegate</string>
-			</object>
-		</object>
-		<object class="IBObjectContainer" key="IBDocument.Objects">
-			<object class="NSMutableArray" key="connectionRecords">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">delegate</string>
-						<reference key="source" ref="1004"/>
-						<reference key="destination" ref="437456796"/>
-					</object>
-					<int key="connectionID">6</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">backgrounderMenu</string>
-						<reference key="source" ref="437456796"/>
-						<reference key="destination" ref="913072818"/>
-					</object>
-					<int key="connectionID">12</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">startStopEvent:</string>
-						<reference key="source" ref="437456796"/>
-						<reference key="destination" ref="77178862"/>
-					</object>
-					<int key="connectionID">15</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">getReleaseTokenEvent:</string>
-						<reference key="source" ref="437456796"/>
-						<reference key="destination" ref="10398219"/>
-					</object>
-					<int key="connectionID">16</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">getReleaseTokenMenuItem</string>
-						<reference key="source" ref="437456796"/>
-						<reference key="destination" ref="10398219"/>
-					</object>
-					<int key="connectionID">17</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">startStopMenuItem</string>
-						<reference key="source" ref="437456796"/>
-						<reference key="destination" ref="77178862"/>
-					</object>
-					<int key="connectionID">18</int>
-				</object>
-			</object>
-			<object class="IBMutableOrderedSet" key="objectRecords">
-				<object class="NSArray" key="orderedObjects">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="IBObjectRecord">
-						<int key="objectID">0</int>
-						<object class="NSArray" key="object" id="1002">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<reference key="children" ref="1000"/>
-						<nil key="parent"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-2</int>
-						<reference key="object" ref="1001"/>
-						<reference key="parent" ref="1002"/>
-						<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-1</int>
-						<reference key="object" ref="1003"/>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">First Responder</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-3</int>
-						<reference key="object" ref="1004"/>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">Application</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1</int>
-						<reference key="object" ref="913072818"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="77178862"/>
-							<reference ref="661887258"/>
-							<reference ref="10398219"/>
-						</object>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">StatusMenu</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">5</int>
-						<reference key="object" ref="437456796"/>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">Delegate</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">9</int>
-						<reference key="object" ref="77178862"/>
-						<reference key="parent" ref="913072818"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">10</int>
-						<reference key="object" ref="661887258"/>
-						<reference key="parent" ref="913072818"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">11</int>
-						<reference key="object" ref="10398219"/>
-						<reference key="parent" ref="913072818"/>
-					</object>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="flattenedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSMutableArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>-1.IBPluginDependency</string>
-					<string>-2.IBPluginDependency</string>
-					<string>-3.IBPluginDependency</string>
-					<string>1.IBEditorWindowLastContentRect</string>
-					<string>1.IBPluginDependency</string>
-					<string>10.IBPluginDependency</string>
-					<string>11.IBPluginDependency</string>
-					<string>5.IBPluginDependency</string>
-					<string>9.IBPluginDependency</string>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilderKit</string>
-					<string>com.apple.InterfaceBuilderKit</string>
-					<string>{{120, 603}, {125, 53}}</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="unlocalizedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="activeLocalization"/>
-			<object class="NSMutableDictionary" key="localizations">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="sourceID"/>
-			<int key="maxID">19</int>
-		</object>
-		<object class="IBClassDescriber" key="IBDocument.Classes">
-			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSBackgrounderDelegate</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>getReleaseTokenEvent:</string>
-							<string>getToken:</string>
-							<string>releaseToken:</string>
-							<string>startStopEvent:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>backgrounderMenu</string>
-							<string>getReleaseTokenMenuItem</string>
-							<string>startStopMenuItem</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSMenu</string>
-							<string>NSMenuItem</string>
-							<string>NSMenuItem</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">AFSBackgrounder/AFSBackgrounderDelegate.h</string>
-					</object>
-				</object>
-			</object>
-		</object>
-		<int key="IBDocument.localizationMode">0</int>
-		<string key="IBDocument.LastKnownRelativeProjectPath">../../OpenAFS.xcodeproj</string>
-		<int key="IBDocument.defaultPropertyAccessControl">3</int>
-	</data>
-</archive>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+	<deployment version="101400" identifier="macosx"/>
+	<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
+	<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+	<customObject id="-2" userLabel="File's Owner"/>
+	<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+	<customObject id="-3" userLabel="Application">
+	    <connections>
+		<outlet property="delegate" destination="5" id="6"/>
+	    </connections>
+	</customObject>
+	<menu id="1" userLabel="StatusMenu">
+	    <items>
+		<menuItem title="Start AFS" id="9">
+		    <modifierMask key="keyEquivalentModifierMask"/>
+		    <connections>
+			<action selector="startStopEvent:" target="5" id="15"/>
+		    </connections>
+		</menuItem>
+		<menuItem isSeparatorItem="YES" id="10"/>
+		<menuItem title="Get Token" id="11">
+		    <modifierMask key="keyEquivalentModifierMask"/>
+		    <connections>
+			<action selector="getReleaseTokenEvent:" target="5" id="16"/>
+		    </connections>
+		</menuItem>
+	    </items>
+	    <point key="canvasLocation" x="140" y="152"/>
+	</menu>
+	<customObject id="5" userLabel="Delegate" customClass="AFSBackgrounderDelegate">
+	    <connections>
+		<outlet property="backgrounderMenu" destination="1" id="12"/>
+		<outlet property="getReleaseTokenMenuItem" destination="11" id="17"/>
+		<outlet property="startStopMenuItem" destination="9" id="18"/>
+	    </connections>
+	</customObject>
+    </objects>
+</document>
diff --git a/src/platform/DARWIN/AFSPreference/English.lproj/CredentialPanel.xib b/src/platform/DARWIN/AFSPreference/English.lproj/CredentialPanel.xib
index c3f419eef..f0afc20a5 100644
--- a/src/platform/DARWIN/AFSPreference/English.lproj/CredentialPanel.xib
+++ b/src/platform/DARWIN/AFSPreference/English.lproj/CredentialPanel.xib
@@ -1,710 +1,104 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
-	<data>
-		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9C31</string>
-		<string key="IBDocument.InterfaceBuilderVersion">648</string>
-		<string key="IBDocument.AppKitVersion">949.26</string>
-		<string key="IBDocument.HIToolboxVersion">352.00</string>
-		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-		</object>
-		<object class="NSArray" key="IBDocument.PluginDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="500241113">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSCustomObject" id="483479706">
-				<string key="NSClassName">AFSCommanderPref</string>
-			</object>
-			<object class="NSCustomObject" id="194032068">
-				<string key="NSClassName">FirstResponder</string>
-			</object>
-			<object class="NSCustomObject" id="136977041">
-				<string key="NSClassName">NSApplication</string>
-			</object>
-			<object class="NSWindowTemplate" id="317089838">
-				<int key="NSWindowStyleMask">3</int>
-				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{594, 606}, {360, 116}}</string>
-				<int key="NSWTFlags">1886912512</int>
-				<string key="NSWindowTitle">Panel</string>
-				<object class="NSMutableString" key="NSWindowClass">
-					<characters key="NS.bytes">NSPanel</characters>
-				</object>
-				<object class="NSMutableString" key="NSViewClass">
-					<characters key="NS.bytes">View</characters>
-				</object>
-				<string key="NSWindowContentMinSize">{213, 107}</string>
-				<object class="NSView" key="NSWindowView" id="897176997">
-					<nil key="NSNextResponder"/>
-					<int key="NSvFlags">256</int>
-					<object class="NSMutableArray" key="NSSubviews">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSTextField" id="1043652849">
-							<reference key="NSNextResponder" ref="897176997"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{19, 75}, {63, 14}}</string>
-							<reference key="NSSuperview" ref="897176997"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="285386094">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">272629760</int>
-								<string key="NSContents">Username:</string>
-								<object class="NSFont" key="NSSupport" id="26">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">1.100000e+01</double>
-									<int key="NSfFlags">3100</int>
-								</object>
-								<reference key="NSControlView" ref="1043652849"/>
-								<object class="NSColor" key="NSBackgroundColor" id="39862648">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlColor</string>
-									<object class="NSColor" key="NSColor">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor" id="625691461">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlTextColor</string>
-									<object class="NSColor" key="NSColor" id="993541148">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MAA</bytes>
-									</object>
-								</object>
-							</object>
-						</object>
-						<object class="NSTextField" id="6777892">
-							<reference key="NSNextResponder" ref="897176997"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{21, 47}, {61, 14}}</string>
-							<reference key="NSSuperview" ref="897176997"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="941629363">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">272629760</int>
-								<string key="NSContents">Password:</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="6777892"/>
-								<reference key="NSBackgroundColor" ref="39862648"/>
-								<reference key="NSTextColor" ref="625691461"/>
-							</object>
-						</object>
-						<object class="NSTextField" id="167535534">
-							<reference key="NSNextResponder" ref="897176997"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{87, 73}, {253, 19}}</string>
-							<reference key="NSSuperview" ref="897176997"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="690718153">
-								<int key="NSCellFlags">-1804468671</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents"/>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="167535534"/>
-								<bool key="NSDrawsBackground">YES</bool>
-								<object class="NSColor" key="NSBackgroundColor" id="547292417">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textBackgroundColor</string>
-									<object class="NSColor" key="NSColor">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MQA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor" id="303282358">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textColor</string>
-									<reference key="NSColor" ref="993541148"/>
-								</object>
-							</object>
-						</object>
-						<object class="NSTextField" id="944739158">
-							<reference key="NSNextResponder" ref="897176997"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{87, 45}, {253, 19}}</string>
-							<reference key="NSSuperview" ref="897176997"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="590522050">
-								<int key="NSCellFlags">-1804468671</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents"/>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="944739158"/>
-								<bool key="NSDrawsBackground">YES</bool>
-								<reference key="NSBackgroundColor" ref="547292417"/>
-								<reference key="NSTextColor" ref="303282358"/>
-							</object>
-						</object>
-						<object class="NSButton" id="394185848">
-							<reference key="NSNextResponder" ref="897176997"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{242, 13}, {103, 28}}</string>
-							<reference key="NSSuperview" ref="897176997"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="543624439">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Get Token</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="394185848"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<object class="NSFont" key="NSAlternateImage" id="961233622">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">1.100000e+01</double>
-									<int key="NSfFlags">16</int>
-								</object>
-								<string key="NSAlternateContents"/>
-								<string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-						<object class="NSButton" id="37378773">
-							<reference key="NSNextResponder" ref="897176997"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{160, 13}, {80, 28}}</string>
-							<reference key="NSSuperview" ref="897176997"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="464336313">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Cancel</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="37378773"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="961233622"/>
-								<string key="NSAlternateContents"/>
-								<string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-					</object>
-					<string key="NSFrame">{{1, 1}, {360, 116}}</string>
-				</object>
-				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
-				<string key="NSMinSize">{213, 129}</string>
-				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
-			</object>
-			<object class="NSCustomObject" id="643915252">
-				<string key="NSClassName">TokenCredentialController</string>
-			</object>
-		</object>
-		<object class="IBObjectContainer" key="IBDocument.Objects">
-			<object class="NSMutableArray" key="connectionRecords">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsCommanderPref</string>
-						<reference key="source" ref="643915252"/>
-						<reference key="destination" ref="483479706"/>
-					</object>
-					<int key="connectionID">8</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">credentialCommander</string>
-						<reference key="source" ref="483479706"/>
-						<reference key="destination" ref="643915252"/>
-					</object>
-					<int key="connectionID">9</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">credentialSheet</string>
-						<reference key="source" ref="483479706"/>
-						<reference key="destination" ref="317089838"/>
-					</object>
-					<int key="connectionID">10</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">credentialPanel</string>
-						<reference key="source" ref="643915252"/>
-						<reference key="destination" ref="317089838"/>
-					</object>
-					<int key="connectionID">11</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textEditUserName</string>
-						<reference key="source" ref="643915252"/>
-						<reference key="destination" ref="167535534"/>
-					</object>
-					<int key="connectionID">18</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textEditPassword</string>
-						<reference key="source" ref="643915252"/>
-						<reference key="destination" ref="944739158"/>
-					</object>
-					<int key="connectionID">19</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">getToken:</string>
-						<reference key="source" ref="643915252"/>
-						<reference key="destination" ref="394185848"/>
-					</object>
-					<int key="connectionID">20</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">closePanel:</string>
-						<reference key="source" ref="643915252"/>
-						<reference key="destination" ref="37378773"/>
-					</object>
-					<int key="connectionID">21</int>
-				</object>
-			</object>
-			<object class="IBMutableOrderedSet" key="objectRecords">
-				<object class="NSArray" key="orderedObjects">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="IBObjectRecord">
-						<int key="objectID">0</int>
-						<object class="NSArray" key="object" id="0">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<reference key="children" ref="500241113"/>
-						<nil key="parent"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-2</int>
-						<reference key="object" ref="483479706"/>
-						<reference key="parent" ref="0"/>
-						<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-1</int>
-						<reference key="object" ref="194032068"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">First Responder</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">5</int>
-						<reference key="object" ref="317089838"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="897176997"/>
-						</object>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">Panel</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">6</int>
-						<reference key="object" ref="897176997"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1043652849"/>
-							<reference ref="6777892"/>
-							<reference ref="167535534"/>
-							<reference ref="944739158"/>
-							<reference ref="394185848"/>
-							<reference ref="37378773"/>
-						</object>
-						<reference key="parent" ref="317089838"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">12</int>
-						<reference key="object" ref="1043652849"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="285386094"/>
-						</object>
-						<reference key="parent" ref="897176997"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">13</int>
-						<reference key="object" ref="6777892"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="941629363"/>
-						</object>
-						<reference key="parent" ref="897176997"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">14</int>
-						<reference key="object" ref="167535534"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="690718153"/>
-						</object>
-						<reference key="parent" ref="897176997"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">15</int>
-						<reference key="object" ref="944739158"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="590522050"/>
-						</object>
-						<reference key="parent" ref="897176997"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">16</int>
-						<reference key="object" ref="394185848"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="543624439"/>
-						</object>
-						<reference key="parent" ref="897176997"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">17</int>
-						<reference key="object" ref="37378773"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="464336313"/>
-						</object>
-						<reference key="parent" ref="897176997"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">7</int>
-						<reference key="object" ref="643915252"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">TokenCredentialController</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">23</int>
-						<reference key="object" ref="285386094"/>
-						<reference key="parent" ref="1043652849"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">24</int>
-						<reference key="object" ref="941629363"/>
-						<reference key="parent" ref="6777892"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">25</int>
-						<reference key="object" ref="690718153"/>
-						<reference key="parent" ref="167535534"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">26</int>
-						<reference key="object" ref="590522050"/>
-						<reference key="parent" ref="944739158"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">27</int>
-						<reference key="object" ref="543624439"/>
-						<reference key="parent" ref="394185848"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">28</int>
-						<reference key="object" ref="464336313"/>
-						<reference key="parent" ref="37378773"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-3</int>
-						<reference key="object" ref="136977041"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">Application</string>
-					</object>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="flattenedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSMutableArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>-1.IBPluginDependency</string>
-					<string>-2.IBPluginDependency</string>
-					<string>12.IBPluginDependency</string>
-					<string>12.ImportedFromIB2</string>
-					<string>13.IBPluginDependency</string>
-					<string>13.ImportedFromIB2</string>
-					<string>14.IBPluginDependency</string>
-					<string>14.ImportedFromIB2</string>
-					<string>15.CustomClassName</string>
-					<string>15.IBPluginDependency</string>
-					<string>15.ImportedFromIB2</string>
-					<string>16.IBPluginDependency</string>
-					<string>16.ImportedFromIB2</string>
-					<string>17.IBPluginDependency</string>
-					<string>17.ImportedFromIB2</string>
-					<string>5.IBPluginDependency</string>
-					<string>5.ImportedFromIB2</string>
-					<string>5.windowTemplate.hasMinSize</string>
-					<string>5.windowTemplate.minSize</string>
-					<string>6.IBPluginDependency</string>
-					<string>6.ImportedFromIB2</string>
-					<string>7.IBPluginDependency</string>
-					<string>7.ImportedFromIB2</string>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1" id="5"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<string>NSSecureTextField</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<reference ref="5"/>
-					<string>{213, 107}</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="5"/>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="unlocalizedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="activeLocalization"/>
-			<object class="NSMutableDictionary" key="localizations">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="sourceID"/>
-			<int key="maxID">28</int>
-		</object>
-		<object class="IBClassDescriber" key="IBDocument.Classes">
-			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSCommanderPref</string>
-					<string key="superclassName">NSPreferencePane</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addRemoveCell:</string>
-							<string>afsMenuActivationEvent:</string>
-							<string>aklogSwitchEvent:</string>
-							<string>getNewToken:</string>
-							<string>info:</string>
-							<string>refreshConfiguration:</string>
-							<string>saveCacheManagerParam:</string>
-							<string>saveConfiguration:</string>
-							<string>searchCellTextEvent:</string>
-							<string>showCellIP:</string>
-							<string>startStopAfs:</string>
-							<string>tableDoubleAction:</string>
-							<string>unlog:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addCellButton</string>
-							<string>afsCommanderView</string>
-							<string>afsDB</string>
-							<string>afsDefaultCellLabel</string>
-							<string>afsMenucheckBox</string>
-							<string>afsRootMountPoint</string>
-							<string>afsVersionLabel</string>
-							<string>cacheDimension</string>
-							<string>cellIpButton</string>
-							<string>cellList</string>
-							<string>credentialCommander</string>
-							<string>credentialSheet</string>
-							<string>dCacheDim</string>
-							<string>daemonNumber</string>
-							<string>dynRoot</string>
-							<string>groupsBox</string>
-							<string>infoController</string>
-							<string>infoSheet</string>
-							<string>installationPathTextField</string>
-							<string>ipConfControllerCommander</string>
-							<string>ipConfigurationSheet</string>
-							<string>labelSaveResult</string>
-							<string>nVolEntry</string>
-							<string>refreshConfigurationButton</string>
-							<string>removeCellButton</string>
-							<string>saveConfigurationButton</string>
-							<string>startStopButton</string>
-							<string>statCacheEntry</string>
-							<string>textSearchField</string>
-							<string>tokensButton</string>
-							<string>tokensTable</string>
-							<string>unlogButton</string>
-							<string>useAklogCheck</string>
-							<string>verbose</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>NSView</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSBox</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSSearchField</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">AFSCommanderPref.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSCommanderPref</string>
-					<string key="superclassName">NSPreferencePane</string>
-					<object class="NSMutableDictionary" key="outlets">
-						<string key="NS.key.0">cellNameTextEdit</string>
-						<string key="NS.object.0">id</string>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">FirstResponder</string>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">NSPreferencePane</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>_firstKeyView</string>
-							<string>_initialKeyView</string>
-							<string>_lastKeyView</string>
-							<string>_window</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSView</string>
-							<string>NSView</string>
-							<string>NSView</string>
-							<string>NSWindow</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">TokenCredentialController</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>closePanel:</string>
-							<string>getToken:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>afsCommanderPref</string>
-							<string>credentialPanel</string>
-							<string>textEditPassword</string>
-							<string>textEditUserName</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">TokenCredentialController.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">TokenCredentialController</string>
-					<string key="superclassName">NSObject</string>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-			</object>
-		</object>
-		<int key="IBDocument.localizationMode">0</int>
-		<nil key="IBDocument.LastKnownRelativeProjectPath"/>
-		<int key="IBDocument.defaultPropertyAccessControl">3</int>
-	</data>
-</archive>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+	<deployment version="101400" identifier="macosx"/>
+	<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
+	<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+	<customObject id="-2" userLabel="File's Owner" customClass="AFSCommanderPref">
+	    <connections>
+		<outlet property="credentialCommander" destination="7" id="9"/>
+		<outlet property="credentialSheet" destination="5" id="10"/>
+	    </connections>
+	</customObject>
+	<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+	<customObject id="-3" userLabel="Application"/>
+	<window title="Panel" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="Panel" customClass="NSPanel">
+	    <windowStyleMask key="styleMask" titled="YES" closable="YES"/>
+	    <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+	    <rect key="contentRect" x="594" y="606" width="360" height="116"/>
+	    <rect key="screenRect" x="0.0" y="0.0" width="1024" height="745"/>
+	    <value key="minSize" type="size" width="213" height="107"/>
+	    <view key="contentView" id="6">
+		<rect key="frame" x="0.0" y="0.0" width="360" height="116"/>
+		<autoresizingMask key="autoresizingMask"/>
+		<subviews>
+		    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="59" translatesAutoresizingMaskIntoConstraints="NO" id="12">
+			<rect key="frame" x="19" y="75" width="63" height="14"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Username:" id="23">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="57" translatesAutoresizingMaskIntoConstraints="NO" id="13">
+			<rect key="frame" x="21" y="47" width="61" height="14"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Password:" id="24">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="14">
+			<rect key="frame" x="87" y="73" width="253" height="19"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="25">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="15" customClass="NSSecureTextField">
+			<rect key="frame" x="87" y="45" width="253" height="19"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="26">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="16">
+			<rect key="frame" x="242" y="13" width="103" height="28"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<buttonCell key="cell" type="push" title="Get Token" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="27">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+			</buttonCell>
+			<connections>
+			    <action selector="getToken:" target="7" id="20"/>
+			</connections>
+		    </button>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="17">
+			<rect key="frame" x="160" y="13" width="80" height="28"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="28">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+			</buttonCell>
+			<connections>
+			    <action selector="closePanel:" target="7" id="21"/>
+			</connections>
+		    </button>
+		</subviews>
+	    </view>
+	    <point key="canvasLocation" x="140" y="147"/>
+	</window>
+	<customObject id="7" userLabel="TokenCredentialController" customClass="TokenCredentialController">
+	    <connections>
+		<outlet property="afsCommanderPref" destination="-2" id="8"/>
+		<outlet property="credentialPanel" destination="5" id="11"/>
+		<outlet property="textEditPassword" destination="15" id="19"/>
+		<outlet property="textEditUserName" destination="14" id="18"/>
+	    </connections>
+	</customObject>
+    </objects>
+</document>
diff --git a/src/platform/DARWIN/AFSPreference/English.lproj/IpPanel.xib b/src/platform/DARWIN/AFSPreference/English.lproj/IpPanel.xib
index 956ef57c2..e2b39b213 100644
--- a/src/platform/DARWIN/AFSPreference/English.lproj/IpPanel.xib
+++ b/src/platform/DARWIN/AFSPreference/English.lproj/IpPanel.xib
@@ -1,1313 +1,198 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
-	<data>
-		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9J61</string>
-		<string key="IBDocument.InterfaceBuilderVersion">680</string>
-		<string key="IBDocument.AppKitVersion">949.46</string>
-		<string key="IBDocument.HIToolboxVersion">353.00</string>
-		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="6"/>
-		</object>
-		<object class="NSArray" key="IBDocument.PluginDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-		</object>
-		<object class="NSMutableDictionary" key="IBDocument.Metadata">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSArray" key="dict.sortedKeys">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-			</object>
-			<object class="NSMutableArray" key="dict.values">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-			</object>
-		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="429600039">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSCustomObject" id="657952263">
-				<string key="NSClassName">AFSCommanderPref</string>
-			</object>
-			<object class="NSCustomObject" id="930067686">
-				<string key="NSClassName">FirstResponder</string>
-			</object>
-			<object class="NSCustomObject" id="784296185">
-				<string key="NSClassName">NSApplication</string>
-			</object>
-			<object class="NSWindowTemplate" id="249730404">
-				<int key="NSWindowStyleMask">11</int>
-				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{622, 551}, {525, 345}}</string>
-				<int key="NSWTFlags">813170688</int>
-				<string key="NSWindowTitle">Panel</string>
-				<object class="NSMutableString" key="NSWindowClass">
-					<characters key="NS.bytes">NSPanel</characters>
-				</object>
-				<object class="NSMutableString" key="NSViewClass">
-					<characters key="NS.bytes">View</characters>
-				</object>
-				<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
-				<string key="NSWindowContentMinSize">{525, 345}</string>
-				<object class="NSView" key="NSWindowView" id="274468230">
-					<reference key="NSNextResponder"/>
-					<int key="NSvFlags">256</int>
-					<object class="NSMutableArray" key="NSSubviews">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSButton" id="800283714">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">289</int>
-							<string key="NSFrame">{{428, 12}, {80, 28}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="1042040079">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Ok</string>
-								<object class="NSFont" key="NSSupport" id="26">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">1.100000e+01</double>
-									<int key="NSfFlags">3100</int>
-								</object>
-								<reference key="NSControlView" ref="800283714"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<object class="NSFont" key="NSAlternateImage" id="845391598">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">1.100000e+01</double>
-									<int key="NSfFlags">16</int>
-								</object>
-								<string key="NSAlternateContents"/>
-								<object class="NSMutableString" key="NSKeyEquivalent">
-									<characters key="NS.bytes"/>
-								</object>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-						<object class="NSButton" id="956015576">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">289</int>
-							<string key="NSFrame">{{346, 12}, {80, 28}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="441391248">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Cancel</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="956015576"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="845391598"/>
-								<string key="NSAlternateContents"/>
-								<object class="NSMutableString" key="NSKeyEquivalent">
-									<characters key="NS.bytes"/>
-								</object>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-						<object class="NSTextField" id="680338282">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">268</int>
-							<string key="NSFrame">{{51, 319}, {54, 16}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="496687085">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">272760832</int>
-								<string type="base64-UTF8" key="NSContents">QWZzIENlbGw6Cg</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="680338282"/>
-								<object class="NSColor" key="NSBackgroundColor" id="319048697">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlColor</string>
-									<object class="NSColor" key="NSColor" id="315060860">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor" id="513483274">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlTextColor</string>
-									<object class="NSColor" key="NSColor" id="350675897">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MAA</bytes>
-									</object>
-								</object>
-							</object>
-						</object>
-						<object class="NSBox" id="338197250">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">274</int>
-							<object class="NSMutableArray" key="NSSubviews">
-								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSView" id="612441040">
-									<reference key="NSNextResponder" ref="338197250"/>
-									<int key="NSvFlags">256</int>
-									<object class="NSMutableArray" key="NSSubviews">
-										<bool key="EncodedWithXMLCoder">YES</bool>
-										<object class="NSScrollView" id="585065386">
-											<reference key="NSNextResponder" ref="612441040"/>
-											<int key="NSvFlags">274</int>
-											<object class="NSMutableArray" key="NSSubviews">
-												<bool key="EncodedWithXMLCoder">YES</bool>
-												<object class="NSClipView" id="786132725">
-													<reference key="NSNextResponder" ref="585065386"/>
-													<int key="NSvFlags">2304</int>
-													<object class="NSMutableArray" key="NSSubviews">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<object class="NSTableView" id="234348651">
-															<reference key="NSNextResponder" ref="786132725"/>
-															<int key="NSvFlags">256</int>
-															<string key="NSFrameSize">{453, 165}</string>
-															<reference key="NSSuperview" ref="786132725"/>
-															<bool key="NSEnabled">YES</bool>
-															<object class="NSTableHeaderView" key="NSHeaderView" id="367895900">
-																<reference key="NSNextResponder" ref="336840699"/>
-																<int key="NSvFlags">256</int>
-																<string key="NSFrameSize">{453, 17}</string>
-																<reference key="NSSuperview" ref="336840699"/>
-																<reference key="NSTableView" ref="234348651"/>
-															</object>
-															<object class="_NSCornerView" key="NSCornerView" id="211425262">
-																<reference key="NSNextResponder" ref="585065386"/>
-																<int key="NSvFlags">-2147483392</int>
-																<string key="NSFrame">{{-22, 0}, {12, 17}}</string>
-																<reference key="NSSuperview" ref="585065386"/>
-															</object>
-															<object class="NSMutableArray" key="NSTableColumns">
-																<bool key="EncodedWithXMLCoder">YES</bool>
-																<object class="NSTableColumn" id="304822933">
-																	<string key="NSIdentifier">1</string>
-																	<double key="NSWidth">2.080000e+02</double>
-																	<double key="NSMinWidth">4.000000e+01</double>
-																	<double key="NSMaxWidth">1.000000e+03</double>
-																	<object class="NSTableHeaderCell" key="NSHeaderCell">
-																		<int key="NSCellFlags">75628032</int>
-																		<int key="NSCellFlags2">0</int>
-																		<string key="NSContents">IP</string>
-																		<reference key="NSSupport" ref="26"/>
-																		<object class="NSColor" key="NSBackgroundColor" id="87486732">
-																			<int key="NSColorSpace">3</int>
-																			<bytes key="NSWhite">MC4zMzMzMzI5OQA</bytes>
-																		</object>
-																		<object class="NSColor" key="NSTextColor" id="446718123">
-																			<int key="NSColorSpace">6</int>
-																			<string key="NSCatalogName">System</string>
-																			<string key="NSColorName">headerTextColor</string>
-																			<reference key="NSColor" ref="350675897"/>
-																		</object>
-																	</object>
-																	<object class="NSTextFieldCell" key="NSDataCell" id="204595378">
-																		<int key="NSCellFlags">337772096</int>
-																		<int key="NSCellFlags2">133120</int>
-																		<string key="NSContents">Text Cell</string>
-																		<reference key="NSSupport" ref="26"/>
-																		<reference key="NSControlView" ref="234348651"/>
-																		<object class="NSColor" key="NSBackgroundColor" id="189347581">
-																			<int key="NSColorSpace">6</int>
-																			<string key="NSCatalogName">System</string>
-																			<string key="NSColorName">controlBackgroundColor</string>
-																			<reference key="NSColor" ref="315060860"/>
-																		</object>
-																		<reference key="NSTextColor" ref="513483274"/>
-																	</object>
-																	<int key="NSResizingMask">3</int>
-																	<bool key="NSIsResizeable">YES</bool>
-																	<bool key="NSIsEditable">YES</bool>
-																	<reference key="NSTableView" ref="234348651"/>
-																</object>
-																<object class="NSTableColumn" id="1066913939">
-																	<string key="NSIdentifier">2</string>
-																	<double key="NSWidth">2.389761e+02</double>
-																	<double key="NSMinWidth">5.997607e+01</double>
-																	<double key="NSMaxWidth">1.000000e+03</double>
-																	<object class="NSTableHeaderCell" key="NSHeaderCell">
-																		<int key="NSCellFlags">75628032</int>
-																		<int key="NSCellFlags2">0</int>
-																		<string key="NSContents">Comment</string>
-																		<reference key="NSSupport" ref="26"/>
-																		<reference key="NSBackgroundColor" ref="87486732"/>
-																		<reference key="NSTextColor" ref="446718123"/>
-																	</object>
-																	<object class="NSTextFieldCell" key="NSDataCell" id="228999791">
-																		<int key="NSCellFlags">337772096</int>
-																		<int key="NSCellFlags2">133120</int>
-																		<string key="NSContents">Text Cell</string>
-																		<reference key="NSSupport" ref="26"/>
-																		<reference key="NSControlView" ref="234348651"/>
-																		<reference key="NSBackgroundColor" ref="189347581"/>
-																		<reference key="NSTextColor" ref="513483274"/>
-																	</object>
-																	<int key="NSResizingMask">3</int>
-																	<bool key="NSIsResizeable">YES</bool>
-																	<bool key="NSIsEditable">YES</bool>
-																	<reference key="NSTableView" ref="234348651"/>
-																</object>
-															</object>
-															<double key="NSIntercellSpacingWidth">3.000000e+00</double>
-															<double key="NSIntercellSpacingHeight">2.000000e+00</double>
-															<object class="NSColor" key="NSBackgroundColor" id="875926337">
-																<int key="NSColorSpace">3</int>
-																<bytes key="NSWhite">MQA</bytes>
-															</object>
-															<object class="NSColor" key="NSGridColor">
-																<int key="NSColorSpace">6</int>
-																<string key="NSCatalogName">System</string>
-																<string key="NSColorName">gridColor</string>
-																<object class="NSColor" key="NSColor">
-																	<int key="NSColorSpace">3</int>
-																	<bytes key="NSWhite">MC41AA</bytes>
-																</object>
-															</object>
-															<double key="NSRowHeight">1.700000e+01</double>
-															<int key="NSTvFlags">-692060160</int>
-															<int key="NSColumnAutoresizingStyle">4</int>
-															<int key="NSDraggingSourceMaskForLocal">15</int>
-															<int key="NSDraggingSourceMaskForNonLocal">0</int>
-															<bool key="NSAllowsTypeSelect">YES</bool>
-														</object>
-													</object>
-													<string key="NSFrame">{{1, 17}, {453, 165}}</string>
-													<reference key="NSSuperview" ref="585065386"/>
-													<reference key="NSNextKeyView" ref="234348651"/>
-													<reference key="NSDocView" ref="234348651"/>
-													<reference key="NSBGColor" ref="189347581"/>
-													<int key="NScvFlags">4</int>
-												</object>
-												<object class="NSScroller" id="592355064">
-													<reference key="NSNextResponder" ref="585065386"/>
-													<int key="NSvFlags">-2147483392</int>
-													<string key="NSFrame">{{-22, 17}, {11, 189}}</string>
-													<reference key="NSSuperview" ref="585065386"/>
-													<int key="NSsFlags">256</int>
-													<reference key="NSTarget" ref="585065386"/>
-													<string key="NSAction">_doScroller:</string>
-													<double key="NSPercent">9.947369e-01</double>
-												</object>
-												<object class="NSScroller" id="814656055">
-													<reference key="NSNextResponder" ref="585065386"/>
-													<int key="NSvFlags">-2147483392</int>
-													<string key="NSFrame">{{1, -22}, {442, 11}}</string>
-													<reference key="NSSuperview" ref="585065386"/>
-													<int key="NSsFlags">257</int>
-													<reference key="NSTarget" ref="585065386"/>
-													<string key="NSAction">_doScroller:</string>
-													<double key="NSPercent">9.757174e-01</double>
-												</object>
-												<object class="NSClipView" id="336840699">
-													<reference key="NSNextResponder" ref="585065386"/>
-													<int key="NSvFlags">2304</int>
-													<object class="NSMutableArray" key="NSSubviews">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<reference ref="367895900"/>
-													</object>
-													<string key="NSFrame">{{1, 0}, {453, 17}}</string>
-													<reference key="NSSuperview" ref="585065386"/>
-													<reference key="NSNextKeyView" ref="367895900"/>
-													<reference key="NSDocView" ref="367895900"/>
-													<reference key="NSBGColor" ref="189347581"/>
-													<int key="NScvFlags">4</int>
-												</object>
-												<reference ref="211425262"/>
-											</object>
-											<string key="NSFrame">{{16, 30}, {455, 183}}</string>
-											<reference key="NSSuperview" ref="612441040"/>
-											<reference key="NSNextKeyView" ref="786132725"/>
-											<int key="NSsFlags">562</int>
-											<reference key="NSVScroller" ref="592355064"/>
-											<reference key="NSHScroller" ref="814656055"/>
-											<reference key="NSContentView" ref="786132725"/>
-											<reference key="NSHeaderClipView" ref="336840699"/>
-											<reference key="NSCornerView" ref="211425262"/>
-											<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
-										</object>
-										<object class="NSButton" id="216429474">
-											<reference key="NSNextResponder" ref="612441040"/>
-											<int key="NSvFlags">289</int>
-											<string key="NSFrame">{{315, 6}, {75, 16}}</string>
-											<reference key="NSSuperview" ref="612441040"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="305136955">
-												<int key="NSCellFlags">604110336</int>
-												<int key="NSCellFlags2">134479872</int>
-												<string key="NSContents">Delete</string>
-												<object class="NSFont" key="NSSupport" id="22">
-													<string key="NSName">LucidaGrande</string>
-													<double key="NSSize">9.000000e+00</double>
-													<int key="NSfFlags">3614</int>
-												</object>
-												<reference key="NSControlView" ref="216429474"/>
-												<int key="NSButtonFlags">-2038284033</int>
-												<int key="NSButtonFlags2">1</int>
-												<object class="NSFont" key="NSAlternateImage" id="160758642">
-													<string key="NSName">LucidaGrande</string>
-													<double key="NSSize">9.000000e+00</double>
-													<int key="NSfFlags">16</int>
-												</object>
-												<string key="NSAlternateContents"/>
-												<object class="NSMutableString" key="NSKeyEquivalent">
-													<characters key="NS.bytes"/>
-												</object>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
-											</object>
-										</object>
-										<object class="NSButton" id="655780437">
-											<reference key="NSNextResponder" ref="612441040"/>
-											<int key="NSvFlags">289</int>
-											<string key="NSFrame">{{396, 6}, {75, 16}}</string>
-											<reference key="NSSuperview" ref="612441040"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="675738899">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">134479872</int>
-												<string key="NSContents">Add</string>
-												<reference key="NSSupport" ref="22"/>
-												<reference key="NSControlView" ref="655780437"/>
-												<int key="NSButtonFlags">-2038284033</int>
-												<int key="NSButtonFlags2">1</int>
-												<reference key="NSAlternateImage" ref="160758642"/>
-												<string key="NSAlternateContents"/>
-												<object class="NSMutableString" key="NSKeyEquivalent">
-													<characters key="NS.bytes"/>
-												</object>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
-											</object>
-										</object>
-									</object>
-									<string key="NSFrame">{{2, 2}, {487, 224}}</string>
-									<reference key="NSSuperview" ref="338197250"/>
-								</object>
-							</object>
-							<string key="NSFrame">{{17, 41}, {491, 241}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<string key="NSOffsets">{0, 0}</string>
-							<object class="NSTextFieldCell" key="NSTitleCell">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">0</int>
-								<string key="NSContents">Authentication server ip</string>
-								<reference key="NSSupport" ref="26"/>
-								<object class="NSColor" key="NSBackgroundColor" id="383485033">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textBackgroundColor</string>
-									<reference key="NSColor" ref="875926337"/>
-								</object>
-								<object class="NSColor" key="NSTextColor">
-									<int key="NSColorSpace">3</int>
-									<bytes key="NSWhite">MCAwLjgwMDAwMDAxAA</bytes>
-								</object>
-							</object>
-							<reference key="NSContentView" ref="612441040"/>
-							<int key="NSBorderType">3</int>
-							<int key="NSBoxType">0</int>
-							<int key="NSTitlePosition">2</int>
-							<bool key="NSTransparent">NO</bool>
-						</object>
-						<object class="NSTextField" id="953679499">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">268</int>
-							<string key="NSFrame">{{44, 289}, {61, 16}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="847361982">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">272760832</int>
-								<string type="base64-UTF8" key="NSContents">Q29tbWVudDoKA</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="953679499"/>
-								<reference key="NSBackgroundColor" ref="319048697"/>
-								<reference key="NSTextColor" ref="513483274"/>
-							</object>
-						</object>
-						<object class="NSTextField" id="379757882">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">266</int>
-							<string key="NSFrame">{{110, 319}, {389, 19}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="620196816">
-								<int key="NSCellFlags">-1804468671</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents"/>
-								<reference key="NSSupport" ref="26"/>
-								<string key="NSPlaceholderString">cell name</string>
-								<reference key="NSControlView" ref="379757882"/>
-								<bool key="NSDrawsBackground">YES</bool>
-								<reference key="NSBackgroundColor" ref="383485033"/>
-								<object class="NSColor" key="NSTextColor" id="563830179">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textColor</string>
-									<reference key="NSColor" ref="350675897"/>
-								</object>
-							</object>
-						</object>
-						<object class="NSTextField" id="523190513">
-							<reference key="NSNextResponder" ref="274468230"/>
-							<int key="NSvFlags">266</int>
-							<string key="NSFrame">{{110, 290}, {389, 19}}</string>
-							<reference key="NSSuperview" ref="274468230"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="115478350">
-								<int key="NSCellFlags">-1804468671</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents"/>
-								<reference key="NSSupport" ref="26"/>
-								<string key="NSPlaceholderString">Comment</string>
-								<reference key="NSControlView" ref="523190513"/>
-								<bool key="NSDrawsBackground">YES</bool>
-								<reference key="NSBackgroundColor" ref="383485033"/>
-								<reference key="NSTextColor" ref="563830179"/>
-							</object>
-						</object>
-					</object>
-					<string key="NSFrameSize">{525, 345}</string>
-					<reference key="NSSuperview"/>
-				</object>
-				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
-				<string key="NSMinSize">{525, 367}</string>
-				<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
-			</object>
-			<object class="NSCustomObject" id="446101933">
-				<string key="NSClassName">IpConfiguratorCommander</string>
-			</object>
-			<object class="NSCustomObject" id="934847714">
-				<string key="NSClassName">AFSCommanderPref</string>
-			</object>
-		</object>
-		<object class="IBObjectContainer" key="IBDocument.Objects">
-			<object class="NSMutableArray" key="connectionRecords">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">ipConfigurationSheet</string>
-						<reference key="source" ref="657952263"/>
-						<reference key="destination" ref="249730404"/>
-					</object>
-					<int key="connectionID">15</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">cancel:</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="956015576"/>
-					</object>
-					<int key="connectionID">17</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">save:</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="800283714"/>
-					</object>
-					<int key="connectionID">18</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">confPanel</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="249730404"/>
-					</object>
-					<int key="connectionID">19</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsCommanderPref</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="657952263"/>
-					</object>
-					<int key="connectionID">20</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">ipConfControllerCommander</string>
-						<reference key="source" ref="657952263"/>
-						<reference key="destination" ref="446101933"/>
-					</object>
-					<int key="connectionID">22</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">tableViewCellIP</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="234348651"/>
-					</object>
-					<int key="connectionID">40</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">deleteButton</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="216429474"/>
-					</object>
-					<int key="connectionID">41</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">createButton</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="655780437"/>
-					</object>
-					<int key="connectionID">43</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">cancelIP:</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="216429474"/>
-					</object>
-					<int key="connectionID">48</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">createNewIP:</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="655780437"/>
-					</object>
-					<int key="connectionID">50</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">delegate</string>
-						<reference key="source" ref="249730404"/>
-						<reference key="destination" ref="446101933"/>
-					</object>
-					<int key="connectionID">52</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textFieldCellName</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="379757882"/>
-					</object>
-					<int key="connectionID">57</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textFieldComment</string>
-						<reference key="source" ref="446101933"/>
-						<reference key="destination" ref="523190513"/>
-					</object>
-					<int key="connectionID">58</int>
-				</object>
-			</object>
-			<object class="IBMutableOrderedSet" key="objectRecords">
-				<object class="NSArray" key="orderedObjects">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="IBObjectRecord">
-						<int key="objectID">0</int>
-						<object class="NSArray" key="object" id="0">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<reference key="children" ref="429600039"/>
-						<nil key="parent"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-2</int>
-						<reference key="object" ref="657952263"/>
-						<reference key="parent" ref="0"/>
-						<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-1</int>
-						<reference key="object" ref="930067686"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">First Responder</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-3</int>
-						<reference key="object" ref="784296185"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">Application</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">5</int>
-						<reference key="object" ref="249730404"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="274468230"/>
-						</object>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">IpConfigurator</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">6</int>
-						<reference key="object" ref="274468230"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="680338282"/>
-							<reference ref="338197250"/>
-							<reference ref="953679499"/>
-							<reference ref="379757882"/>
-							<reference ref="523190513"/>
-							<reference ref="800283714"/>
-							<reference ref="956015576"/>
-						</object>
-						<reference key="parent" ref="249730404"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">7</int>
-						<reference key="object" ref="800283714"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1042040079"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">8</int>
-						<reference key="object" ref="956015576"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="441391248"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">14</int>
-						<reference key="object" ref="680338282"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="496687085"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">25</int>
-						<reference key="object" ref="338197250"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="585065386"/>
-							<reference ref="655780437"/>
-							<reference ref="216429474"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">53</int>
-						<reference key="object" ref="953679499"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="847361982"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">55</int>
-						<reference key="object" ref="379757882"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="620196816"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">56</int>
-						<reference key="object" ref="523190513"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="115478350"/>
-						</object>
-						<reference key="parent" ref="274468230"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">16</int>
-						<reference key="object" ref="446101933"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">IpConfiguratorCommander1</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">21</int>
-						<reference key="object" ref="934847714"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">AFSCommanderPref</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">62</int>
-						<reference key="object" ref="1042040079"/>
-						<reference key="parent" ref="800283714"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">63</int>
-						<reference key="object" ref="441391248"/>
-						<reference key="parent" ref="956015576"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">64</int>
-						<reference key="object" ref="496687085"/>
-						<reference key="parent" ref="680338282"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">67</int>
-						<reference key="object" ref="847361982"/>
-						<reference key="parent" ref="953679499"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">68</int>
-						<reference key="object" ref="620196816"/>
-						<reference key="parent" ref="379757882"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">69</int>
-						<reference key="object" ref="115478350"/>
-						<reference key="parent" ref="523190513"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">27</int>
-						<reference key="object" ref="585065386"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="367895900"/>
-							<reference ref="814656055"/>
-							<reference ref="592355064"/>
-							<reference ref="234348651"/>
-						</object>
-						<reference key="parent" ref="338197250"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">74</int>
-						<reference key="object" ref="367895900"/>
-						<reference key="parent" ref="585065386"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">73</int>
-						<reference key="object" ref="814656055"/>
-						<reference key="parent" ref="585065386"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">72</int>
-						<reference key="object" ref="592355064"/>
-						<reference key="parent" ref="585065386"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">28</int>
-						<reference key="object" ref="234348651"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1066913939"/>
-							<reference ref="304822933"/>
-						</object>
-						<reference key="parent" ref="585065386"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">30</int>
-						<reference key="object" ref="1066913939"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="228999791"/>
-						</object>
-						<reference key="parent" ref="234348651"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">29</int>
-						<reference key="object" ref="304822933"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="204595378"/>
-						</object>
-						<reference key="parent" ref="234348651"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">70</int>
-						<reference key="object" ref="204595378"/>
-						<reference key="parent" ref="304822933"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">71</int>
-						<reference key="object" ref="228999791"/>
-						<reference key="parent" ref="1066913939"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">38</int>
-						<reference key="object" ref="216429474"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="305136955"/>
-						</object>
-						<reference key="parent" ref="338197250"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">65</int>
-						<reference key="object" ref="305136955"/>
-						<reference key="parent" ref="216429474"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">39</int>
-						<reference key="object" ref="655780437"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="675738899"/>
-						</object>
-						<reference key="parent" ref="338197250"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">66</int>
-						<reference key="object" ref="675738899"/>
-						<reference key="parent" ref="655780437"/>
-					</object>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="flattenedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSMutableArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>-1.IBPluginDependency</string>
-					<string>-2.IBPluginDependency</string>
-					<string>-3.IBPluginDependency</string>
-					<string>-3.ImportedFromIB2</string>
-					<string>14.IBPluginDependency</string>
-					<string>14.ImportedFromIB2</string>
-					<string>16.IBPluginDependency</string>
-					<string>16.ImportedFromIB2</string>
-					<string>21.IBPluginDependency</string>
-					<string>21.ImportedFromIB2</string>
-					<string>25.IBPluginDependency</string>
-					<string>25.ImportedFromIB2</string>
-					<string>27.IBPluginDependency</string>
-					<string>27.ImportedFromIB2</string>
-					<string>28.IBPluginDependency</string>
-					<string>28.ImportedFromIB2</string>
-					<string>29.IBPluginDependency</string>
-					<string>29.ImportedFromIB2</string>
-					<string>30.IBPluginDependency</string>
-					<string>30.ImportedFromIB2</string>
-					<string>38.IBPluginDependency</string>
-					<string>38.ImportedFromIB2</string>
-					<string>39.IBPluginDependency</string>
-					<string>39.ImportedFromIB2</string>
-					<string>5.IBEditorWindowLastContentRect</string>
-					<string>5.IBViewEditorWindowController.showingBoundsRectangles</string>
-					<string>5.IBViewEditorWindowController.showingLayoutRectangles</string>
-					<string>5.IBWindowTemplateEditedContentRect</string>
-					<string>5.ImportedFromIB2</string>
-					<string>5.windowTemplate.hasMinSize</string>
-					<string>5.windowTemplate.minSize</string>
-					<string>53.IBPluginDependency</string>
-					<string>53.ImportedFromIB2</string>
-					<string>55.IBPluginDependency</string>
-					<string>55.ImportedFromIB2</string>
-					<string>56.IBPluginDependency</string>
-					<string>56.ImportedFromIB2</string>
-					<string>6.IBPluginDependency</string>
-					<string>6.ImportedFromIB2</string>
-					<string>62.IBPluginDependency</string>
-					<string>63.IBPluginDependency</string>
-					<string>64.IBPluginDependency</string>
-					<string>65.IBPluginDependency</string>
-					<string>66.IBPluginDependency</string>
-					<string>67.IBPluginDependency</string>
-					<string>68.IBPluginDependency</string>
-					<string>69.IBPluginDependency</string>
-					<string>7.IBPluginDependency</string>
-					<string>7.ImportedFromIB2</string>
-					<string>70.IBPluginDependency</string>
-					<string>70.IBShouldRemoveOnLegacySave</string>
-					<string>71.IBPluginDependency</string>
-					<string>71.IBShouldRemoveOnLegacySave</string>
-					<string>72.IBPluginDependency</string>
-					<string>72.IBShouldRemoveOnLegacySave</string>
-					<string>73.IBPluginDependency</string>
-					<string>73.IBShouldRemoveOnLegacySave</string>
-					<string>74.IBPluginDependency</string>
-					<string>74.IBShouldRemoveOnLegacySave</string>
-					<string>8.IBPluginDependency</string>
-					<string>8.ImportedFromIB2</string>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1" id="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>{{76, 288}, {525, 345}}</string>
-					<boolean value="YES" id="5"/>
-					<reference ref="5"/>
-					<string>{{76, 288}, {525, 345}}</string>
-					<reference ref="9"/>
-					<reference ref="9"/>
-					<string>{525, 345}</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<reference ref="9"/>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="unlocalizedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="activeLocalization"/>
-			<object class="NSMutableDictionary" key="localizations">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="sourceID"/>
-			<int key="maxID">74</int>
-		</object>
-		<object class="IBClassDescriber" key="IBDocument.Classes">
-			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSCommanderPref</string>
-					<string key="superclassName">NSPreferencePane</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addLink:</string>
-							<string>addRemoveCell:</string>
-							<string>afsMenuActivationEvent:</string>
-							<string>afsStartupSwitchEvent:</string>
-							<string>aklogSwitchEvent:</string>
-							<string>credentialAtLoginTimeEvent:</string>
-							<string>enableLink:</string>
-							<string>getNewToken:</string>
-							<string>info:</string>
-							<string>krb5KredentialAtLoginTimeEvent:</string>
-							<string>manageBackgrounderActivation:</string>
-							<string>refreshConfiguration:</string>
-							<string>removeLink:</string>
-							<string>saveCacheManagerParam:</string>
-							<string>saveConfiguration:</string>
-							<string>searchCellTextEvent:</string>
-							<string>showCellIP:</string>
-							<string>startStopAfs:</string>
-							<string>tableDoubleAction:</string>
-							<string>unlog:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addCellButton</string>
-							<string>afsCommanderView</string>
-							<string>afsDB</string>
-							<string>afsDefaultCellLabel</string>
-							<string>afsMenucheckBox</string>
-							<string>afsRootMountPoint</string>
-							<string>afsVersionLabel</string>
-							<string>aklogCredentialAtLoginTime</string>
-							<string>backgrounderActivationCheck</string>
-							<string>buttonAddLink</string>
-							<string>buttonRemoveLink</string>
-							<string>cacheDimension</string>
-							<string>cellIpButton</string>
-							<string>cellList</string>
-							<string>checkButtonAfsAtBootTime</string>
-							<string>checkEnableLink</string>
-							<string>credentialCommander</string>
-							<string>credentialSheet</string>
-							<string>dCacheDim</string>
-							<string>daemonNumber</string>
-							<string>dynRoot</string>
-							<string>groupsBox</string>
-							<string>infoController</string>
-							<string>infoSheet</string>
-							<string>installKRB5AuthAtLoginButton</string>
-							<string>ipConfControllerCommander</string>
-							<string>ipConfigurationSheet</string>
-							<string>labelSaveResult</string>
-							<string>lyncCreationSheet</string>
-							<string>lynkCreationController</string>
-							<string>nVolEntry</string>
-							<string>removeCellButton</string>
-							<string>saveConfigurationButton</string>
-							<string>startStopButton</string>
-							<string>statCacheEntry</string>
-							<string>textFieldDevInfoLabel</string>
-							<string>textSearchField</string>
-							<string>tokensButton</string>
-							<string>tokensTable</string>
-							<string>unlogButton</string>
-							<string>useAklogCheck</string>
-							<string>verbose</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>NSView</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSBox</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>LynkCreationController</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSSearchField</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">AFSCommanderPref.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSCommanderPref</string>
-					<string key="superclassName">NSPreferencePane</string>
-					<object class="NSMutableDictionary" key="actions">
-						<string key="NS.key.0">addMoifyCell:</string>
-						<string key="NS.object.0">id</string>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<string key="NS.key.0">cellNameTextEdit</string>
-						<string key="NS.object.0">id</string>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">FirstResponder</string>
-					<string key="superclassName">NSObject</string>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">IpConfiguratorCommander</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>cancel:</string>
-							<string>cancelIP:</string>
-							<string>createNewIP:</string>
-							<string>save:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>afsCommanderPref</string>
-							<string>confPanel</string>
-							<string>createButton</string>
-							<string>deleteButton</string>
-							<string>modifyButton</string>
-							<string>tableViewCellIP</string>
-							<string>textFieldCellName</string>
-							<string>textFieldComment</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">IpConfiguratorCommander.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">IpConfiguratorCommander</string>
-					<string key="superclassName">NSObject</string>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">LynkCreationController</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>cancell:</string>
-							<string>save:</string>
-							<string>selectLinkDest:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>lynkCreationSheet</string>
-							<string>textFieldLinkDestPath</string>
-							<string>textfieldLinkName</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSPanel</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">LynkCreationController.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">NSPreferencePane</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>_firstKeyView</string>
-							<string>_initialKeyView</string>
-							<string>_lastKeyView</string>
-							<string>_window</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSView</string>
-							<string>NSView</string>
-							<string>NSView</string>
-							<string>NSWindow</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBUserSource</string>
-						<string key="minorKey"/>
-					</object>
-				</object>
-			</object>
-		</object>
-		<int key="IBDocument.localizationMode">0</int>
-		<string key="IBDocument.LastKnownRelativeProjectPath">../OpenAFS.xcodeproj</string>
-		<int key="IBDocument.defaultPropertyAccessControl">3</int>
-	</data>
-</archive>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+	<deployment version="101400" identifier="macosx"/>
+	<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
+	<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+	<customObject id="-2" userLabel="File's Owner" customClass="AFSCommanderPref">
+	    <connections>
+		<outlet property="ipConfControllerCommander" destination="16" id="22"/>
+		<outlet property="ipConfigurationSheet" destination="5" id="15"/>
+	    </connections>
+	</customObject>
+	<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+	<customObject id="-3" userLabel="Application"/>
+	<window title="Panel" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" visibleAtLaunch="NO" animationBehavior="default" id="5" userLabel="IpConfigurator" customClass="NSPanel">
+	    <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
+	    <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+	    <rect key="contentRect" x="622" y="551" width="525" height="345"/>
+	    <rect key="screenRect" x="0.0" y="0.0" width="1024" height="745"/>
+	    <value key="minSize" type="size" width="525" height="345"/>
+	    <view key="contentView" id="6">
+		<rect key="frame" x="0.0" y="0.0" width="525" height="345"/>
+		<autoresizingMask key="autoresizingMask"/>
+		<subviews>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="7">
+			<rect key="frame" x="428" y="12" width="80" height="28"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+			<buttonCell key="cell" type="push" title="Ok" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="62">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			</buttonCell>
+			<connections>
+			    <action selector="save:" target="16" id="18"/>
+			</connections>
+		    </button>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8">
+			<rect key="frame" x="346" y="12" width="80" height="28"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+			<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="63">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			</buttonCell>
+			<connections>
+			    <action selector="cancel:" target="16" id="17"/>
+			</connections>
+		    </button>
+		    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="50" translatesAutoresizingMaskIntoConstraints="NO" id="14">
+			<rect key="frame" x="51" y="319" width="54" height="16"/>
+			<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="64">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <string key="title">Afs Cell:
+</string>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <box fixedFrame="YES" title="Authentication server ip" translatesAutoresizingMaskIntoConstraints="NO" id="25">
+			<rect key="frame" x="17" y="41" width="491" height="241"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+			<view key="contentView" id="aBE-Ub-qac">
+			    <rect key="frame" x="3" y="3" width="485" height="223"/>
+			    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+			    <subviews>
+				<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="27">
+				    <rect key="frame" x="16" y="30" width="451" height="181"/>
+				    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+				    <clipView key="contentView" ambiguous="YES" id="YRu-5I-P24">
+					<rect key="frame" x="1" y="0.0" width="449" height="180"/>
+					<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+					<subviews>
+					    <tableView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" headerView="74" id="28">
+						<rect key="frame" x="0.0" y="0.0" width="449" height="155"/>
+						<autoresizingMask key="autoresizingMask"/>
+						<size key="intercellSpacing" width="3" height="2"/>
+						<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+						<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+						<tableColumns>
+						    <tableColumn identifier="1" width="208" minWidth="40" maxWidth="1000" id="29">
+							<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="IP">
+							    <font key="font" metaFont="controlContent" size="11"/>
+							    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/>
+							</tableHeaderCell>
+							<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="70">
+							    <font key="font" metaFont="controlContent" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+						    </tableColumn>
+						    <tableColumn identifier="2" width="234.9761" minWidth="59.97607" maxWidth="1000" id="30">
+							<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Comment">
+							    <font key="font" metaFont="controlContent" size="11"/>
+							    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" white="0.33333299" alpha="1" colorSpace="calibratedWhite"/>
+							</tableHeaderCell>
+							<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="71">
+							    <font key="font" metaFont="controlContent" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+						    </tableColumn>
+						</tableColumns>
+					    </tableView>
+					</subviews>
+				    </clipView>
+				    <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" controlSize="small" horizontal="YES" id="73">
+					<rect key="frame" x="1" y="-22" width="442" height="11"/>
+					<autoresizingMask key="autoresizingMask"/>
+				    </scroller>
+				    <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" controlSize="small" horizontal="NO" id="72">
+					<rect key="frame" x="-22" y="17" width="11" height="189"/>
+					<autoresizingMask key="autoresizingMask"/>
+				    </scroller>
+				    <tableHeaderView key="headerView" id="74">
+					<rect key="frame" x="0.0" y="0.0" width="449" height="25"/>
+					<autoresizingMask key="autoresizingMask"/>
+				    </tableHeaderView>
+				</scrollView>
+				<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="38">
+				    <rect key="frame" x="311" y="6" width="75" height="16"/>
+				    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+				    <buttonCell key="cell" type="push" title="Delete" bezelStyle="rounded" alignment="center" controlSize="mini" enabled="NO" borderStyle="border" inset="2" id="65">
+					<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+					<font key="font" metaFont="miniSystem"/>
+				    </buttonCell>
+				    <connections>
+					<action selector="cancelIP:" target="16" id="48"/>
+				    </connections>
+				</button>
+				<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="39">
+				    <rect key="frame" x="392" y="6" width="75" height="16"/>
+				    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+				    <buttonCell key="cell" type="push" title="Add" bezelStyle="rounded" alignment="center" controlSize="mini" borderStyle="border" inset="2" id="66">
+					<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+					<font key="font" metaFont="miniSystem"/>
+				    </buttonCell>
+				    <connections>
+					<action selector="createNewIP:" target="16" id="50"/>
+				    </connections>
+				</button>
+			    </subviews>
+			</view>
+		    </box>
+		    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="57" translatesAutoresizingMaskIntoConstraints="NO" id="53">
+			<rect key="frame" x="44" y="289" width="61" height="16"/>
+			<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" sendsActionOnEndEditing="YES" id="67">
+			    <font key="font" metaFont="message" size="11"/>
+			    <string key="title">Comment:
+</string>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="55">
+			<rect key="frame" x="110" y="319" width="389" height="19"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="cell name" drawsBackground="YES" id="68">
+			    <font key="font" metaFont="message" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="56">
+			<rect key="frame" x="110" y="290" width="389" height="19"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" placeholderString="Comment" drawsBackground="YES" id="69">
+			    <font key="font" metaFont="message" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		</subviews>
+	    </view>
+	    <connections>
+		<outlet property="delegate" destination="16" id="52"/>
+	    </connections>
+	    <point key="canvasLocation" x="140" y="148"/>
+	</window>
+	<customObject id="16" userLabel="IpConfiguratorCommander1" customClass="IpConfiguratorCommander">
+	    <connections>
+		<outlet property="afsCommanderPref" destination="-2" id="20"/>
+		<outlet property="confPanel" destination="5" id="19"/>
+		<outlet property="createButton" destination="39" id="43"/>
+		<outlet property="deleteButton" destination="38" id="41"/>
+		<outlet property="tableViewCellIP" destination="28" id="40"/>
+		<outlet property="textFieldCellName" destination="55" id="57"/>
+		<outlet property="textFieldComment" destination="56" id="58"/>
+	    </connections>
+	</customObject>
+	<customObject id="21" userLabel="AFSCommanderPref" customClass="AFSCommanderPref"/>
+    </objects>
+</document>
diff --git a/src/platform/DARWIN/AFSPreference/English.lproj/OpenAFSPreference.xib b/src/platform/DARWIN/AFSPreference/English.lproj/OpenAFSPreference.xib
index b1190ba41..ba9b375ec 100644
--- a/src/platform/DARWIN/AFSPreference/English.lproj/OpenAFSPreference.xib
+++ b/src/platform/DARWIN/AFSPreference/English.lproj/OpenAFSPreference.xib
@@ -1,6271 +1,1029 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
-	<data>
-		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">11D50d</string>
-		<string key="IBDocument.InterfaceBuilderVersion">2182</string>
-		<string key="IBDocument.AppKitVersion">1138.32</string>
-		<string key="IBDocument.HIToolboxVersion">568.00</string>
-		<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
-			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
-			<string key="NS.object.0">2182</string>
-		</object>
-		<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string>NSTabView</string>
-			<string>NSStepper</string>
-			<string>NSButton</string>
-			<string>NSCustomObject</string>
-			<string>NSTableView</string>
-			<string>NSCustomView</string>
-			<string>NSSearchField</string>
-			<string>NSTextField</string>
-			<string>NSNumberFormatter</string>
-			<string>NSSearchFieldCell</string>
-			<string>NSWindowTemplate</string>
-			<string>NSTextFieldCell</string>
-			<string>NSStepperCell</string>
-			<string>NSButtonCell</string>
-			<string>NSTableColumn</string>
-			<string>NSBox</string>
-			<string>NSView</string>
-			<string>NSScrollView</string>
-			<string>NSTabViewItem</string>
-			<string>NSTextView</string>
-			<string>NSScroller</string>
-			<string>NSTableHeaderView</string>
-		</object>
-		<object class="NSArray" key="IBDocument.PluginDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-		</object>
-		<object class="NSMutableDictionary" key="IBDocument.Metadata">
-			<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
-			<integer value="1" key="NS.object.0"/>
-		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="84888716">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSCustomObject" id="773588579">
-				<string key="NSClassName">AFSCommanderPref</string>
-			</object>
-			<object class="NSCustomObject" id="270520968">
-				<string key="NSClassName">FirstResponder</string>
-			</object>
-			<object class="NSCustomObject" id="173116405">
-				<string key="NSClassName">NSApplication</string>
-			</object>
-			<object class="NSWindowTemplate" id="61231707">
-				<int key="NSWindowStyleMask">15</int>
-				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{423, 652}, {595, 486}}</string>
-				<int key="NSWTFlags">1081606144</int>
-				<string key="NSWindowTitle">&lt;&lt; do not localize &gt;&gt;</string>
-				<string key="NSWindowClass">NSWindow</string>
-				<object class="NSMutableString" key="NSViewClass">
-					<characters key="NS.bytes">View</characters>
-				</object>
-				<nil key="NSUserInterfaceItemIdentifier"/>
-				<object class="NSView" key="NSWindowView" id="645279396">
-					<reference key="NSNextResponder"/>
-					<int key="NSvFlags">274</int>
-					<object class="NSMutableArray" key="NSSubviews">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSTextField" id="415603882">
-							<reference key="NSNextResponder" ref="645279396"/>
-							<int key="NSvFlags">256</int>
-							<string key="NSFrame">{{17, 1}, {304, 14}}</string>
-							<reference key="NSSuperview" ref="645279396"/>
-							<reference key="NSWindow"/>
-							<reference key="NSNextKeyView" ref="1047946385"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="947523856">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">272629760</int>
-								<string key="NSContents"/>
-								<object class="NSFont" key="NSSupport" id="22">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">9</double>
-									<int key="NSfFlags">3614</int>
-								</object>
-								<reference key="NSControlView" ref="415603882"/>
-								<object class="NSColor" key="NSBackgroundColor" id="568311573">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlColor</string>
-									<object class="NSColor" key="NSColor" id="277525007">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor" id="276594776">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlTextColor</string>
-									<object class="NSColor" key="NSColor" id="39932154">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MAA</bytes>
-									</object>
-								</object>
-							</object>
-						</object>
-						<object class="NSBox" id="748501112">
-							<reference key="NSNextResponder" ref="645279396"/>
-							<int key="NSvFlags">266</int>
-							<object class="NSMutableArray" key="NSSubviews">
-								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSView" id="520583273">
-									<reference key="NSNextResponder" ref="748501112"/>
-									<int key="NSvFlags">274</int>
-									<object class="NSMutableArray" key="NSSubviews">
-										<bool key="EncodedWithXMLCoder">YES</bool>
-										<object class="NSButton" id="709840556">
-											<reference key="NSNextResponder" ref="520583273"/>
-											<int key="NSvFlags">268</int>
-											<string key="NSFrame">{{13, 7}, {109, 28}}</string>
-											<reference key="NSSuperview" ref="520583273"/>
-											<reference key="NSWindow"/>
-											<reference key="NSNextKeyView" ref="713307252"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="675447498">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">134348800</int>
-												<string key="NSContents">On</string>
-												<object class="NSFont" key="NSSupport" id="26">
-													<string key="NSName">LucidaGrande</string>
-													<double key="NSSize">11</double>
-													<int key="NSfFlags">3100</int>
-												</object>
-												<reference key="NSControlView" ref="709840556"/>
-												<int key="NSButtonFlags">-2038284033</int>
-												<int key="NSButtonFlags2">1</int>
-												<reference key="NSAlternateImage" ref="26"/>
-												<string key="NSAlternateContents"/>
-												<object class="NSMutableString" key="NSKeyEquivalent">
-													<characters key="NS.bytes"/>
-												</object>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
-											</object>
-										</object>
-										<object class="NSButton" id="871603218">
-											<reference key="NSNextResponder" ref="520583273"/>
-											<int key="NSvFlags">265</int>
-											<string key="NSFrame">{{526, 9}, {21, 23}}</string>
-											<reference key="NSSuperview" ref="520583273"/>
-											<reference key="NSWindow"/>
-											<reference key="NSNextKeyView" ref="739317740"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="1009755861">
-												<int key="NSCellFlags">-2080244224</int>
-												<int key="NSCellFlags2">134217728</int>
-												<string key="NSContents"/>
-												<object class="NSFont" key="NSSupport" id="275217208">
-													<string key="NSName">LucidaGrande</string>
-													<double key="NSSize">13</double>
-													<int key="NSfFlags">1044</int>
-												</object>
-												<reference key="NSControlView" ref="871603218"/>
-												<int key="NSButtonFlags">-2038284033</int>
-												<int key="NSButtonFlags2">33</int>
-												<reference key="NSAlternateImage" ref="275217208"/>
-												<string key="NSAlternateContents"/>
-												<object class="NSMutableString" key="NSKeyEquivalent">
-													<characters key="NS.bytes"/>
-												</object>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
-											</object>
-										</object>
-										<object class="NSButton" id="713307252">
-											<reference key="NSNextResponder" ref="520583273"/>
-											<int key="NSvFlags">268</int>
-											<string key="NSFrame">{{138, 13}, {117, 18}}</string>
-											<reference key="NSSuperview" ref="520583273"/>
-											<reference key="NSWindow"/>
-											<reference key="NSNextKeyView" ref="871603218"/>
-											<bool key="NSEnabled">YES</bool>
-											<object class="NSButtonCell" key="NSCell" id="98390178">
-												<int key="NSCellFlags">67239424</int>
-												<int key="NSCellFlags2">131072</int>
-												<string key="NSContents">Start AFS at boot</string>
-												<reference key="NSSupport" ref="26"/>
-												<reference key="NSControlView" ref="713307252"/>
-												<int key="NSButtonFlags">1211912703</int>
-												<int key="NSButtonFlags2">130</int>
-												<object class="NSCustomResource" key="NSNormalImage" id="502435249">
-													<string key="NSClassName">NSImage</string>
-													<string key="NSResourceName">NSSwitch</string>
-												</object>
-												<object class="NSButtonImageSource" key="NSAlternateImage" id="894136682">
-													<string key="NSImageName">NSSwitch</string>
-												</object>
-												<string key="NSAlternateContents"/>
-												<string key="NSKeyEquivalent"/>
-												<int key="NSPeriodicDelay">200</int>
-												<int key="NSPeriodicInterval">25</int>
-											</object>
-										</object>
-									</object>
-									<string key="NSFrame">{{1, 1}, {562, 43}}</string>
-									<reference key="NSSuperview" ref="748501112"/>
-									<reference key="NSWindow"/>
-									<reference key="NSNextKeyView" ref="709840556"/>
-								</object>
-							</object>
-							<string key="NSFrame">{{17, 423}, {564, 45}}</string>
-							<reference key="NSSuperview" ref="645279396"/>
-							<reference key="NSWindow"/>
-							<reference key="NSNextKeyView" ref="520583273"/>
-							<string key="NSOffsets">{0, 0}</string>
-							<object class="NSTextFieldCell" key="NSTitleCell">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">0</int>
-								<string key="NSContents">Box</string>
-								<reference key="NSSupport" ref="26"/>
-								<object class="NSColor" key="NSBackgroundColor" id="878835253">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textBackgroundColor</string>
-									<object class="NSColor" key="NSColor" id="400556243">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MQA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor">
-									<int key="NSColorSpace">3</int>
-									<bytes key="NSWhite">MCAwLjgwMDAwMDAxMTkAA</bytes>
-								</object>
-							</object>
-							<reference key="NSContentView" ref="520583273"/>
-							<int key="NSBorderType">1</int>
-							<int key="NSBoxType">0</int>
-							<int key="NSTitlePosition">0</int>
-							<bool key="NSTransparent">NO</bool>
-							<object class="NSColor" key="NSBorderColor2">
-								<int key="NSColorSpace">1</int>
-								<bytes key="NSRGB">MCAwIDAgMC40MDk5OTk5OTY0AA</bytes>
-							</object>
-						</object>
-						<object class="NSTabView" id="739317740">
-							<reference key="NSNextResponder" ref="645279396"/>
-							<int key="NSvFlags">274</int>
-							<string key="NSFrame">{{13, 15}, {572, 401}}</string>
-							<reference key="NSSuperview" ref="645279396"/>
-							<reference key="NSWindow"/>
-							<reference key="NSNextKeyView" ref="1020318718"/>
-							<object class="NSMutableArray" key="NSTabViewItems">
-								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSTabViewItem" id="269508902">
-									<object class="NSMutableString" key="NSIdentifier">
-										<characters key="NS.bytes">1</characters>
-									</object>
-									<object class="NSView" key="NSView" id="1020318718">
-										<reference key="NSNextResponder" ref="739317740"/>
-										<int key="NSvFlags">256</int>
-										<object class="NSMutableArray" key="NSSubviews">
-											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSScrollView" id="440720679">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">266</int>
-												<object class="NSMutableArray" key="NSSubviews">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSClipView" id="457121079">
-														<reference key="NSNextResponder" ref="440720679"/>
-														<int key="NSvFlags">2304</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSTableView" id="313963250">
-																<reference key="NSNextResponder" ref="457121079"/>
-																<int key="NSvFlags">256</int>
-																<string key="NSFrameSize">{516, 140}</string>
-																<reference key="NSSuperview" ref="457121079"/>
-																<reference key="NSWindow"/>
-																<reference key="NSNextKeyView" ref="884311606"/>
-																<int key="NSTag">1</int>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTableHeaderView" key="NSHeaderView" id="1048519426">
-																	<reference key="NSNextResponder" ref="214413149"/>
-																	<int key="NSvFlags">256</int>
-																	<string key="NSFrameSize">{516, 17}</string>
-																	<reference key="NSSuperview" ref="214413149"/>
-																	<reference key="NSWindow"/>
-																	<reference key="NSNextKeyView" ref="457121079"/>
-																	<reference key="NSTableView" ref="313963250"/>
-																</object>
-																<object class="_NSCornerView" key="NSCornerView">
-																	<nil key="NSNextResponder"/>
-																	<int key="NSvFlags">-2147483392</int>
-																	<string key="NSFrame">{{-22, 0}, {12, 17}}</string>
-																</object>
-																<object class="NSMutableArray" key="NSTableColumns">
-																	<bool key="EncodedWithXMLCoder">YES</bool>
-																	<object class="NSTableColumn" id="10567446">
-																		<double key="NSWidth">513</double>
-																		<double key="NSMinWidth">41.0966796875</double>
-																		<double key="NSMaxWidth">1000</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Token</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<object class="NSColor" key="NSBackgroundColor">
-																				<int key="NSColorSpace">3</int>
-																				<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
-																			</object>
-																			<object class="NSColor" key="NSTextColor" id="716292118">
-																				<int key="NSColorSpace">6</int>
-																				<string key="NSCatalogName">System</string>
-																				<string key="NSColorName">headerTextColor</string>
-																				<reference key="NSColor" ref="39932154"/>
-																			</object>
-																		</object>
-																		<object class="NSTextFieldCell" key="NSDataCell" id="361287568">
-																			<int key="NSCellFlags">337772096</int>
-																			<int key="NSCellFlags2">264192</int>
-																			<string key="NSContents">Text Cell</string>
-																			<reference key="NSSupport" ref="22"/>
-																			<reference key="NSControlView" ref="313963250"/>
-																			<object class="NSColor" key="NSBackgroundColor" id="252569531">
-																				<int key="NSColorSpace">6</int>
-																				<string key="NSCatalogName">System</string>
-																				<string key="NSColorName">controlBackgroundColor</string>
-																				<reference key="NSColor" ref="277525007"/>
-																			</object>
-																			<reference key="NSTextColor" ref="276594776"/>
-																		</object>
-																		<int key="NSResizingMask">3</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<reference key="NSTableView" ref="313963250"/>
-																	</object>
-																</object>
-																<double key="NSIntercellSpacingWidth">3</double>
-																<double key="NSIntercellSpacingHeight">2</double>
-																<reference key="NSBackgroundColor" ref="400556243"/>
-																<object class="NSColor" key="NSGridColor" id="850792713">
-																	<int key="NSColorSpace">6</int>
-																	<string key="NSCatalogName">System</string>
-																	<string key="NSColorName">gridColor</string>
-																	<object class="NSColor" key="NSColor">
-																		<int key="NSColorSpace">3</int>
-																		<bytes key="NSWhite">MC41AA</bytes>
-																	</object>
-																</object>
-																<double key="NSRowHeight">12</double>
-																<int key="NSTvFlags">-155189248</int>
-																<reference key="NSDelegate"/>
-																<reference key="NSDataSource"/>
-																<int key="NSGridStyleMask">2</int>
-																<int key="NSColumnAutoresizingStyle">5</int>
-																<int key="NSDraggingSourceMaskForLocal">15</int>
-																<int key="NSDraggingSourceMaskForNonLocal">0</int>
-																<bool key="NSAllowsTypeSelect">YES</bool>
-																<int key="NSTableViewDraggingDestinationStyle">0</int>
-																<int key="NSTableViewGroupRowStyle">1</int>
-															</object>
-														</object>
-														<string key="NSFrame">{{1, 17}, {516, 140}}</string>
-														<reference key="NSSuperview" ref="440720679"/>
-														<reference key="NSWindow"/>
-														<reference key="NSNextKeyView" ref="313963250"/>
-														<reference key="NSDocView" ref="313963250"/>
-														<reference key="NSBGColor" ref="252569531"/>
-														<int key="NScvFlags">4</int>
-													</object>
-													<object class="NSScroller" id="884311606">
-														<reference key="NSNextResponder" ref="440720679"/>
-														<int key="NSvFlags">-2147483392</int>
-														<string key="NSFrame">{{494, 17}, {11, 80}}</string>
-														<reference key="NSSuperview" ref="440720679"/>
-														<reference key="NSWindow"/>
-														<reference key="NSNextKeyView" ref="258996751"/>
-														<int key="NSsFlags">256</int>
-														<reference key="NSTarget" ref="440720679"/>
-														<string key="NSAction">_doScroller:</string>
-														<double key="NSPercent">0.87912088632583618</double>
-													</object>
-													<object class="NSScroller" id="258996751">
-														<reference key="NSNextResponder" ref="440720679"/>
-														<int key="NSvFlags">-2147483392</int>
-														<string key="NSFrame">{{1, 97}, {505, 11}}</string>
-														<reference key="NSSuperview" ref="440720679"/>
-														<reference key="NSWindow"/>
-														<reference key="NSNextKeyView" ref="893552286"/>
-														<int key="NSsFlags">257</int>
-														<reference key="NSTarget" ref="440720679"/>
-														<string key="NSAction">_doScroller:</string>
-														<double key="NSPercent">0.99801981449127197</double>
-													</object>
-													<object class="NSClipView" id="214413149">
-														<reference key="NSNextResponder" ref="440720679"/>
-														<int key="NSvFlags">2304</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<reference ref="1048519426"/>
-														</object>
-														<string key="NSFrame">{{1, 0}, {516, 17}}</string>
-														<reference key="NSSuperview" ref="440720679"/>
-														<reference key="NSWindow"/>
-														<reference key="NSNextKeyView" ref="1048519426"/>
-														<reference key="NSDocView" ref="1048519426"/>
-														<reference key="NSBGColor" ref="252569531"/>
-														<int key="NScvFlags">4</int>
-													</object>
-												</object>
-												<string key="NSFrame">{{17, 199}, {518, 158}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView" ref="214413149"/>
-												<int key="NSsFlags">133682</int>
-												<reference key="NSVScroller" ref="884311606"/>
-												<reference key="NSHScroller" ref="258996751"/>
-												<reference key="NSContentView" ref="457121079"/>
-												<reference key="NSHeaderClipView" ref="214413149"/>
-												<bytes key="NSScrollAmts">QSAAAEEgAABBYAAAQWAAAA</bytes>
-											</object>
-											<object class="NSButton" id="210387551">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">265</int>
-												<string key="NSFrame">{{329, 164}, {80, 28}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView" ref="977607312"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="327131725">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">Unlog</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="210387551"/>
-													<int key="NSButtonFlags">-2038284033</int>
-													<int key="NSButtonFlags2">1</int>
-													<reference key="NSAlternateImage" ref="26"/>
-													<string key="NSAlternateContents"/>
-													<object class="NSMutableString" key="NSKeyEquivalent">
-														<characters key="NS.bytes"/>
-													</object>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-											<object class="NSButton" id="977607312">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">265</int>
-												<string key="NSFrame">{{407, 164}, {133, 28}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView" ref="802059200"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="73578210">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">Get new Token</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="977607312"/>
-													<int key="NSButtonFlags">-2038284033</int>
-													<int key="NSButtonFlags2">1</int>
-													<reference key="NSAlternateImage" ref="26"/>
-													<string key="NSAlternateContents"/>
-													<object class="NSMutableString" key="NSKeyEquivalent">
-														<characters key="NS.bytes"/>
-													</object>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-											<object class="NSButton" id="893552286">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">268</int>
-												<string key="NSFrame">{{14, 172}, {86, 18}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView" ref="343070533"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="428850916">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">131072</int>
-													<string key="NSContents">AFS Menu</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="893552286"/>
-													<int key="NSButtonFlags">1211912703</int>
-													<int key="NSButtonFlags2">2</int>
-													<reference key="NSNormalImage" ref="502435249"/>
-													<reference key="NSAlternateImage" ref="894136682"/>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-											<object class="NSBox" id="184192603">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">12</int>
-												<object class="NSMutableArray" key="NSSubviews">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSView" id="1000204505">
-														<reference key="NSNextResponder" ref="184192603"/>
-														<int key="NSvFlags">274</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSButton" id="478533800">
-																<reference key="NSNextResponder" ref="1000204505"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{5, 32}, {75, 18}}</string>
-																<reference key="NSSuperview" ref="1000204505"/>
-																<reference key="NSWindow"/>
-																<reference key="NSNextKeyView" ref="541208829"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="989004902">
-																	<int key="NSCellFlags">67239424</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">Use aklog</string>
-																	<reference key="NSSupport" ref="26"/>
-																	<reference key="NSControlView" ref="478533800"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">130</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-															<object class="NSButton" id="541208829">
-																<reference key="NSNextResponder" ref="1000204505"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{5, 12}, {167, 18}}</string>
-																<reference key="NSSuperview" ref="1000204505"/>
-																<reference key="NSWindow"/>
-																<reference key="NSNextKeyView" ref="210387551"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="95048095">
-																	<int key="NSCellFlags">67239424</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">get credential at login time</string>
-																	<reference key="NSSupport" ref="26"/>
-																	<reference key="NSControlView" ref="541208829"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">130</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-															<object class="NSButton" id="239701474">
-																<reference key="NSNextResponder" ref="1000204505"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{5, 52}, {170, 18}}</string>
-																<reference key="NSSuperview" ref="1000204505"/>
-																<reference key="NSWindow"/>
-																<reference key="NSNextKeyView" ref="478533800"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="855912809">
-																	<int key="NSCellFlags">67239424</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">Get Krb5 credential at login</string>
-																	<reference key="NSSupport" ref="26"/>
-																	<reference key="NSControlView" ref="239701474"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">130</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-														</object>
-														<string key="NSFrame">{{1, 1}, {193, 78}}</string>
-														<reference key="NSSuperview" ref="184192603"/>
-														<reference key="NSWindow"/>
-														<reference key="NSNextKeyView" ref="239701474"/>
-													</object>
-												</object>
-												<string key="NSFrame">{{113, 97}, {195, 94}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView" ref="1000204505"/>
-												<string key="NSOffsets">{0, 0}</string>
-												<object class="NSTextFieldCell" key="NSTitleCell">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Kerberos Setting</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSBackgroundColor" ref="878835253"/>
-													<object class="NSColor" key="NSTextColor">
-														<int key="NSColorSpace">3</int>
-														<bytes key="NSWhite">MCAwLjgwMDAwMDAxMTkAA</bytes>
-													</object>
-												</object>
-												<reference key="NSContentView" ref="1000204505"/>
-												<int key="NSBorderType">1</int>
-												<int key="NSBoxType">0</int>
-												<int key="NSTitlePosition">2</int>
-												<bool key="NSTransparent">NO</bool>
-											</object>
-											<object class="NSButton" id="343070533">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">268</int>
-												<string key="NSFrame">{{14, 152}, {96, 18}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView" ref="184192603"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="237101992">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">131072</int>
-													<string key="NSContents">Backgrounder</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="343070533"/>
-													<int key="NSButtonFlags">1211912703</int>
-													<int key="NSButtonFlags2">130</int>
-													<reference key="NSNormalImage" ref="502435249"/>
-													<reference key="NSAlternateImage" ref="894136682"/>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-											<object class="NSCustomView" id="802059200">
-												<reference key="NSNextResponder" ref="1020318718"/>
-												<int key="NSvFlags">268</int>
-												<string key="NSFrame">{{3, 3}, {400, 40}}</string>
-												<reference key="NSSuperview" ref="1020318718"/>
-												<reference key="NSWindow"/>
-												<reference key="NSNextKeyView"/>
-												<string key="NSReuseIdentifierKey">_NS:9</string>
-												<string key="NSClassName">SFAuthorizationView</string>
-											</object>
-										</object>
-										<string key="NSFrame">{{10, 25}, {552, 363}}</string>
-										<reference key="NSSuperview" ref="739317740"/>
-										<reference key="NSWindow"/>
-										<reference key="NSNextKeyView" ref="440720679"/>
-									</object>
-									<string key="NSLabel">Tokens</string>
-									<reference key="NSColor" ref="568311573"/>
-									<reference key="NSTabView" ref="739317740"/>
-								</object>
-								<object class="NSTabViewItem" id="443722606">
-									<string key="NSIdentifier">2</string>
-									<object class="NSView" key="NSView" id="1069727156">
-										<nil key="NSNextResponder"/>
-										<int key="NSvFlags">256</int>
-										<object class="NSMutableArray" key="NSSubviews">
-											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSSearchField" id="530233415">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">265</int>
-												<string key="NSFrame">{{337, 335}, {198, 19}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSSearchFieldCell" key="NSCell" id="497389328">
-													<int key="NSCellFlags">343014976</int>
-													<int key="NSCellFlags2">134349824</int>
-													<string key="NSContents"/>
-													<reference key="NSSupport" ref="26"/>
-													<string key="NSPlaceholderString">CellServDB Search</string>
-													<reference key="NSControlView" ref="530233415"/>
-													<bool key="NSDrawsBackground">YES</bool>
-													<int key="NSTextBezelStyle">1</int>
-													<reference key="NSBackgroundColor" ref="878835253"/>
-													<reference key="NSTextColor" ref="276594776"/>
-													<object class="NSButtonCell" key="NSSearchButtonCell">
-														<int key="NSCellFlags">130560</int>
-														<int key="NSCellFlags2">0</int>
-														<string key="NSContents">search</string>
-														<reference key="NSControlView" ref="530233415"/>
-														<string key="NSAction">_searchFieldSearch:</string>
-														<reference key="NSTarget" ref="497389328"/>
-														<int key="NSButtonFlags">138690815</int>
-														<int key="NSButtonFlags2">0</int>
-														<string key="NSKeyEquivalent"/>
-														<int key="NSPeriodicDelay">400</int>
-														<int key="NSPeriodicInterval">75</int>
-													</object>
-													<object class="NSButtonCell" key="NSCancelButtonCell">
-														<int key="NSCellFlags">130560</int>
-														<int key="NSCellFlags2">0</int>
-														<string key="NSContents">clear</string>
-														<object class="NSMutableArray" key="NSAccessibilityOverriddenAttributes">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSMutableDictionary">
-																<bool key="EncodedWithXMLCoder">YES</bool>
-																<object class="NSArray" key="dict.sortedKeys">
-																	<bool key="EncodedWithXMLCoder">YES</bool>
-																	<string>AXDescription</string>
-																	<string>NSAccessibilityEncodedAttributesValueType</string>
-																</object>
-																<object class="NSArray" key="dict.values">
-																	<bool key="EncodedWithXMLCoder">YES</bool>
-																	<string>cancel</string>
-																	<integer value="1"/>
-																</object>
-															</object>
-														</object>
-														<string key="NSAction">_searchFieldCancel:</string>
-														<reference key="NSTarget" ref="497389328"/>
-														<int key="NSButtonFlags">138428671</int>
-														<int key="NSButtonFlags2">0</int>
-														<string key="NSKeyEquivalent"/>
-														<int key="NSPeriodicDelay">400</int>
-														<int key="NSPeriodicInterval">75</int>
-													</object>
-													<string key="NSRecentsAutosaveName">cell_searc</string>
-													<int key="NSMaximumRecents">255</int>
-													<bytes key="NSSearchFieldFlags">CAAAAA</bytes>
-												</object>
-											</object>
-											<object class="NSTextField" id="1038382119">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">268</int>
-												<string key="NSFrame">{{17, 335}, {76, 17}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="269454663">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">272629760</int>
-													<string key="NSContents">Default Cell:</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="1038382119"/>
-													<reference key="NSBackgroundColor" ref="568311573"/>
-													<reference key="NSTextColor" ref="276594776"/>
-												</object>
-											</object>
-											<object class="NSButton" id="788506691">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">292</int>
-												<string key="NSFrame">{{17, 7}, {30, 25}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<int key="NSTag">1</int>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="934170338">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">+</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="788506691"/>
-													<int key="NSTag">1</int>
-													<int key="NSButtonFlags">-2038021889</int>
-													<int key="NSButtonFlags2">35</int>
-													<object class="NSFont" key="NSAlternateImage" id="894635401">
-														<string key="NSName">LucidaGrande</string>
-														<double key="NSSize">11</double>
-														<int key="NSfFlags">16</int>
-													</object>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">400</int>
-													<int key="NSPeriodicInterval">75</int>
-												</object>
-											</object>
-											<object class="NSButton" id="537320483">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">292</int>
-												<string key="NSFrame">{{50, 7}, {30, 25}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<int key="NSTag">2</int>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="1045702831">
-													<int key="NSCellFlags">604110336</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">-</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="537320483"/>
-													<int key="NSTag">2</int>
-													<int key="NSButtonFlags">-2038021889</int>
-													<int key="NSButtonFlags2">35</int>
-													<reference key="NSAlternateImage" ref="894635401"/>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">400</int>
-													<int key="NSPeriodicInterval">75</int>
-												</object>
-											</object>
-											<object class="NSButton" id="593598121">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">292</int>
-												<string key="NSFrame">{{82, 7}, {72, 25}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="567447351">
-													<int key="NSCellFlags">604110336</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">Modify</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="593598121"/>
-													<int key="NSButtonFlags">-2038021889</int>
-													<int key="NSButtonFlags2">35</int>
-													<reference key="NSAlternateImage" ref="894635401"/>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">400</int>
-													<int key="NSPeriodicInterval">75</int>
-												</object>
-											</object>
-											<object class="NSButton" id="335179878">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">289</int>
-												<string key="NSFrame">{{387, 4}, {151, 28}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="372630674">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">Save Cell Configuration</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="335179878"/>
-													<int key="NSButtonFlags">-2038284033</int>
-													<int key="NSButtonFlags2">1</int>
-													<reference key="NSAlternateImage" ref="894635401"/>
-													<string key="NSAlternateContents"/>
-													<object class="NSMutableString" key="NSKeyEquivalent">
-														<characters key="NS.bytes"/>
-													</object>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-											<object class="NSScrollView" id="96110784">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">274</int>
-												<object class="NSMutableArray" key="NSSubviews">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSClipView" id="259172039">
-														<reference key="NSNextResponder" ref="96110784"/>
-														<int key="NSvFlags">2304</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSTableView" id="536830463">
-																<reference key="NSNextResponder" ref="259172039"/>
-																<int key="NSvFlags">256</int>
-																<string key="NSFrameSize">{516, 271}</string>
-																<reference key="NSSuperview" ref="259172039"/>
-																<int key="NSTag">2</int>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTableHeaderView" key="NSHeaderView" id="993816125">
-																	<reference key="NSNextResponder" ref="281754774"/>
-																	<int key="NSvFlags">256</int>
-																	<string key="NSFrameSize">{516, 17}</string>
-																	<reference key="NSSuperview" ref="281754774"/>
-																	<reference key="NSTableView" ref="536830463"/>
-																</object>
-																<object class="_NSCornerView" key="NSCornerView" id="772760699">
-																	<reference key="NSNextResponder" ref="96110784"/>
-																	<int key="NSvFlags">-2147483392</int>
-																	<string key="NSFrame">{{-22, 0}, {12, 17}}</string>
-																	<reference key="NSSuperview" ref="96110784"/>
-																</object>
-																<object class="NSMutableArray" key="NSTableColumns">
-																	<bool key="EncodedWithXMLCoder">YES</bool>
-																	<object class="NSTableColumn" id="136480779">
-																		<string key="NSIdentifier">0</string>
-																		<double key="NSWidth">47</double>
-																		<double key="NSMinWidth">10</double>
-																		<double key="NSMaxWidth">3.4028230607370965e+38</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Default</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<object class="NSColor" key="NSBackgroundColor" id="496166923">
-																				<int key="NSColorSpace">6</int>
-																				<string key="NSCatalogName">System</string>
-																				<string key="NSColorName">headerColor</string>
-																				<reference key="NSColor" ref="400556243"/>
-																			</object>
-																			<reference key="NSTextColor" ref="716292118"/>
-																		</object>
-																		<object class="NSButtonCell" key="NSDataCell" id="787517969">
-																			<int key="NSCellFlags">67239424</int>
-																			<int key="NSCellFlags2">134348800</int>
-																			<string key="NSContents"/>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSControlView" ref="536830463"/>
-																			<int key="NSButtonFlags">1215582719</int>
-																			<int key="NSButtonFlags2">130</int>
-																			<reference key="NSNormalImage" ref="502435249"/>
-																			<reference key="NSAlternateImage" ref="894136682"/>
-																			<string key="NSAlternateContents"/>
-																			<string key="NSKeyEquivalent"/>
-																			<int key="NSPeriodicDelay">200</int>
-																			<int key="NSPeriodicInterval">25</int>
-																		</object>
-																		<int key="NSResizingMask">3</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<bool key="NSIsEditable">YES</bool>
-																		<reference key="NSTableView" ref="536830463"/>
-																	</object>
-																	<object class="NSTableColumn" id="720585546">
-																		<string key="NSIdentifier">1</string>
-																		<double key="NSWidth">47</double>
-																		<double key="NSMinWidth">10</double>
-																		<double key="NSMaxWidth">3.4028230607370965e+38</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Tokens</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSBackgroundColor" ref="496166923"/>
-																			<reference key="NSTextColor" ref="716292118"/>
-																		</object>
-																		<object class="NSButtonCell" key="NSDataCell" id="110685339">
-																			<int key="NSCellFlags">67239424</int>
-																			<int key="NSCellFlags2">134348800</int>
-																			<string key="NSContents">Check</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSControlView" ref="536830463"/>
-																			<int key="NSButtonFlags">1212436991</int>
-																			<int key="NSButtonFlags2">130</int>
-																			<reference key="NSNormalImage" ref="502435249"/>
-																			<reference key="NSAlternateImage" ref="894136682"/>
-																			<string key="NSAlternateContents"/>
-																			<string key="NSKeyEquivalent"/>
-																			<int key="NSPeriodicDelay">200</int>
-																			<int key="NSPeriodicInterval">25</int>
-																		</object>
-																		<int key="NSResizingMask">2</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<bool key="NSIsEditable">YES</bool>
-																		<reference key="NSTableView" ref="536830463"/>
-																	</object>
-																	<object class="NSTableColumn" id="909348673">
-																		<string key="NSIdentifier">2</string>
-																		<double key="NSWidth">167</double>
-																		<double key="NSMinWidth">40</double>
-																		<double key="NSMaxWidth">1000</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Name</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<object class="NSColor" key="NSBackgroundColor">
-																				<int key="NSColorSpace">3</int>
-																				<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
-																			</object>
-																			<reference key="NSTextColor" ref="716292118"/>
-																		</object>
-																		<object class="NSTextFieldCell" key="NSDataCell" id="990091450">
-																			<int key="NSCellFlags">337772096</int>
-																			<int key="NSCellFlags2">133120</int>
-																			<string key="NSContents">Text Cell</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSControlView" ref="536830463"/>
-																			<reference key="NSBackgroundColor" ref="252569531"/>
-																			<reference key="NSTextColor" ref="276594776"/>
-																		</object>
-																		<int key="NSResizingMask">3</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<reference key="NSTableView" ref="536830463"/>
-																	</object>
-																	<object class="NSTableColumn" id="145486834">
-																		<string key="NSIdentifier">3</string>
-																		<double key="NSWidth">243</double>
-																		<double key="NSMinWidth">65.0908203125</double>
-																		<double key="NSMaxWidth">1000</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Description</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSBackgroundColor" ref="496166923"/>
-																			<reference key="NSTextColor" ref="716292118"/>
-																		</object>
-																		<object class="NSTextFieldCell" key="NSDataCell" id="345168793">
-																			<int key="NSCellFlags">337772096</int>
-																			<int key="NSCellFlags2">133120</int>
-																			<string key="NSContents">Text Cell</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSControlView" ref="536830463"/>
-																			<reference key="NSBackgroundColor" ref="252569531"/>
-																			<reference key="NSTextColor" ref="276594776"/>
-																		</object>
-																		<int key="NSResizingMask">3</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<reference key="NSTableView" ref="536830463"/>
-																	</object>
-																</object>
-																<double key="NSIntercellSpacingWidth">3</double>
-																<double key="NSIntercellSpacingHeight">2</double>
-																<reference key="NSBackgroundColor" ref="400556243"/>
-																<reference key="NSGridColor" ref="850792713"/>
-																<double key="NSRowHeight">15</double>
-																<int key="NSTvFlags">2059403264</int>
-																<reference key="NSDelegate"/>
-																<reference key="NSDataSource"/>
-																<int key="NSGridStyleMask">1</int>
-																<int key="NSColumnAutoresizingStyle">4</int>
-																<int key="NSDraggingSourceMaskForLocal">15</int>
-																<int key="NSDraggingSourceMaskForNonLocal">0</int>
-																<bool key="NSAllowsTypeSelect">YES</bool>
-																<int key="NSTableViewDraggingDestinationStyle">0</int>
-																<int key="NSTableViewGroupRowStyle">1</int>
-															</object>
-														</object>
-														<string key="NSFrame">{{1, 17}, {516, 271}}</string>
-														<reference key="NSSuperview" ref="96110784"/>
-														<reference key="NSNextKeyView" ref="536830463"/>
-														<reference key="NSDocView" ref="536830463"/>
-														<reference key="NSBGColor" ref="252569531"/>
-														<int key="NScvFlags">4</int>
-													</object>
-													<object class="NSScroller" id="177605134">
-														<reference key="NSNextResponder" ref="96110784"/>
-														<int key="NSvFlags">-2147483392</int>
-														<string key="NSFrame">{{506, 17}, {11, 198}}</string>
-														<reference key="NSSuperview" ref="96110784"/>
-														<int key="NSsFlags">256</int>
-														<reference key="NSTarget" ref="96110784"/>
-														<string key="NSAction">_doScroller:</string>
-														<double key="NSPercent">0.94736838340759277</double>
-													</object>
-													<object class="NSScroller" id="172641834">
-														<reference key="NSNextResponder" ref="96110784"/>
-														<int key="NSvFlags">-2147483392</int>
-														<string key="NSFrame">{{1, 215}, {516, 11}}</string>
-														<reference key="NSSuperview" ref="96110784"/>
-														<int key="NSsFlags">257</int>
-														<reference key="NSTarget" ref="96110784"/>
-														<string key="NSAction">_doScroller:</string>
-														<double key="NSCurValue">1</double>
-														<double key="NSPercent">0.99421972036361694</double>
-													</object>
-													<object class="NSClipView" id="281754774">
-														<reference key="NSNextResponder" ref="96110784"/>
-														<int key="NSvFlags">2304</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<reference ref="993816125"/>
-														</object>
-														<string key="NSFrame">{{1, 0}, {516, 17}}</string>
-														<reference key="NSSuperview" ref="96110784"/>
-														<reference key="NSNextKeyView" ref="993816125"/>
-														<reference key="NSDocView" ref="993816125"/>
-														<reference key="NSBGColor" ref="252569531"/>
-														<int key="NScvFlags">4</int>
-													</object>
-													<reference ref="772760699"/>
-												</object>
-												<string key="NSFrame">{{15, 41}, {518, 289}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<reference key="NSNextKeyView" ref="259172039"/>
-												<int key="NSsFlags">133682</int>
-												<reference key="NSVScroller" ref="177605134"/>
-												<reference key="NSHScroller" ref="172641834"/>
-												<reference key="NSContentView" ref="259172039"/>
-												<reference key="NSHeaderClipView" ref="281754774"/>
-												<bytes key="NSScrollAmts">QSAAAEEgAABBiAAAQYgAAA</bytes>
-											</object>
-											<object class="NSTextField" id="747536303">
-												<reference key="NSNextResponder" ref="1069727156"/>
-												<int key="NSvFlags">268</int>
-												<string key="NSFrame">{{95, 338}, {237, 14}}</string>
-												<reference key="NSSuperview" ref="1069727156"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSTextFieldCell" key="NSCell" id="579088625">
-													<int key="NSCellFlags">68288064</int>
-													<int key="NSCellFlags2">272630784</int>
-													<string key="NSContents">Default Cell</string>
-													<reference key="NSSupport" ref="894635401"/>
-													<reference key="NSControlView" ref="747536303"/>
-													<reference key="NSBackgroundColor" ref="568311573"/>
-													<object class="NSColor" key="NSTextColor">
-														<int key="NSColorSpace">1</int>
-														<bytes key="NSRGB">MCAwLjEwOTg1MTgzNzIgMQA</bytes>
-													</object>
-												</object>
-											</object>
-										</object>
-										<string key="NSFrame">{{10, 25}, {552, 363}}</string>
-									</object>
-									<string key="NSLabel">CellServDB Editor</string>
-									<reference key="NSColor" ref="568311573"/>
-									<reference key="NSTabView" ref="739317740"/>
-								</object>
-								<object class="NSTabViewItem" id="584361947">
-									<string key="NSIdentifier">3</string>
-									<object class="NSView" key="NSView" id="537928258">
-										<nil key="NSNextResponder"/>
-										<int key="NSvFlags">256</int>
-										<object class="NSMutableArray" key="NSSubviews">
-											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSBox" id="1056952440">
-												<reference key="NSNextResponder" ref="537928258"/>
-												<int key="NSvFlags">266</int>
-												<object class="NSMutableArray" key="NSSubviews">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSView" id="1006532054">
-														<reference key="NSNextResponder" ref="1056952440"/>
-														<int key="NSvFlags">274</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSTextField" id="748314809">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{18, 112}, {114, 14}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="1008754563">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">NÂ° stat chache entry</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="748314809"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="411322031">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{140, 107}, {55, 19}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="1051935415">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">272761856</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="455485314">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>minimum</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>numberStyle</string>
-																				<string>positiveFormat</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<integer value="1"/>
-																				<integer value="1040"/>
-																				<object class="NSLocale" id="925904638">
-																					<string key="NS.identifier"/>
-																				</object>
-																				<real value="1000"/>
-																				<integer value="4"/>
-																				<real value="0.0"/>
-																				<string>#</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#0000</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<nil key="NS.nil"/>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<object class="NSDictionary" key="NSAttributes" id="571560357">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<object class="NSArray" key="dict.sortedKeys" id="0">
-																					<bool key="EncodedWithXMLCoder">YES</bool>
-																				</object>
-																				<reference key="dict.values" ref="0"/>
-																			</object>
-																		</object>
-																		<real value="1000" key="NS.min"/>
-																		<object class="NSDecimalNumberPlaceholder" key="NS.max" id="139642944">
-																			<int key="NS.exponent">0</int>
-																			<int key="NS.length">0</int>
-																			<bool key="NS.negative">YES</bool>
-																			<bool key="NS.compact">NO</bool>
-																			<int key="NS.mantissa.bo">1</int>
-																			<bytes key="NS.mantissa">AAAAAAAAAAAAAAAAAAAAAA</bytes>
-																		</object>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="411322031"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<object class="NSColor" key="NSTextColor" id="568125270">
-																		<int key="NSColorSpace">6</int>
-																		<string key="NSCatalogName">System</string>
-																		<string key="NSColorName">textColor</string>
-																		<reference key="NSColor" ref="39932154"/>
-																	</object>
-																</object>
-															</object>
-															<object class="NSTextField" id="761947305">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{140, 81}, {55, 19}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="19899457">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">-1874721792</int>
-																	<string key="NSContents">0</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="248712560">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>minimum</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>positiveFormat</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<integer value="1"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<real value="100"/>
-																				<integer value="3"/>
-																				<string>#</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#000</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<nil key="NS.nil"/>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="100" key="NS.min"/>
-																		<reference key="NS.max" ref="139642944"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="761947305"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="560081349">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{83, 83}, {49, 14}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="628600719">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">DCache</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="560081349"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="23658009">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{140, 52}, {25, 19}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="463621063">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">272761856</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="833073507">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximumIntegerDigits</string>
-																				<string>minimum</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>positiveFormat</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<integer value="1"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<integer value="2"/>
-																				<integer value="1"/>
-																				<integer value="1"/>
-																				<string>#</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#0</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<nil key="NS.nil"/>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<integer value="1" key="NS.min"/>
-																		<reference key="NS.max" ref="139642944"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="23658009"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="217732195">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{47, 54}, {85, 14}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="1057450635">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">NÂ° of daemons</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="217732195"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSButton" id="1070305297">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">297</int>
-																<string key="NSFrame">{{413, 109}, {93, 18}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="474187509">
-																	<int key="NSCellFlags">604110336</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">Encryption</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="1070305297"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">2</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-															<object class="NSTextField" id="358834889">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">301</int>
-																<string key="NSFrame">{{209, 112}, {103, 14}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="120617252">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">NÂ° Volume entries</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="358834889"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="255735511">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">301</int>
-																<string key="NSFrame">{{313, 109}, {37, 19}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="310838537">
-																	<int key="NSCellFlags">343014977</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="547764719">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatWidth</string>
-																				<string>formatterBehavior</string>
-																				<string>generatesDecimalNumbers</string>
-																				<string>groupingSize</string>
-																				<string>locale</string>
-																				<string>maximumFractionDigits</string>
-																				<string>maximumIntegerDigits</string>
-																				<string>minimum</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>numberStyle</string>
-																				<string>positiveFormat</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<real value="0.0"/>
-																				<real value="0.0"/>
-																				<integer value="1040"/>
-																				<real value="0.0"/>
-																				<real value="0.0"/>
-																				<reference ref="925904638"/>
-																				<real value="0.0"/>
-																				<integer value="3"/>
-																				<real value="10"/>
-																				<integer value="2"/>
-																				<integer value="1"/>
-																				<string>#</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#00</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<nil key="NS.nil"/>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="10" key="NS.min"/>
-																		<reference key="NS.max" ref="139642944"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">NO</bool>
-																	</object>
-																	<reference key="NSControlView" ref="255735511"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="640588663">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{46, 23}, {86, 14}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="35880329">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">Afs Root Mount</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="640588663"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="850669444">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{140, 21}, {55, 19}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="456324371">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">/</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="850669444"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="972024631">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">301</int>
-																<string key="NSFrame">{{215, 81}, {97, 14}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="383369569">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">Cache Dimension</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="972024631"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="627718334">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">301</int>
-																<string key="NSFrame">{{313, 79}, {52, 19}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="756462877">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="592804150">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>minimum</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>numberStyle</string>
-																				<string>positiveFormat</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<integer value="1"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<real value="10000"/>
-																				<integer value="5"/>
-																				<integer value="1"/>
-																				<string>#</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#00000</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<nil key="NS.nil"/>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="10000" key="NS.min"/>
-																		<reference key="NS.max" ref="139642944"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="627718334"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSButton" id="892096934">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">297</int>
-																<string key="NSFrame">{{400, 15}, {104, 17}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="728535364">
-																	<int key="NSCellFlags">-2080244224</int>
-																	<int key="NSCellFlags2">134348800</int>
-																	<string key="NSContents">Save Param</string>
-																	<reference key="NSSupport" ref="26"/>
-																	<reference key="NSControlView" ref="892096934"/>
-																	<int key="NSButtonFlags">-2038152961</int>
-																	<int key="NSButtonFlags2">164</int>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">400</int>
-																	<int key="NSPeriodicInterval">75</int>
-																</object>
-															</object>
-															<object class="NSTextField" id="835771463">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">297</int>
-																<string key="NSFrame">{{388, 4}, {126, 13}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="672812502">
-																	<int key="NSCellFlags">67239488</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">will force client restart</string>
-																	<object class="NSFont" key="NSSupport">
-																		<string key="NSName">LucidaGrande</string>
-																		<double key="NSSize">10</double>
-																		<int key="NSfFlags">16</int>
-																	</object>
-																	<reference key="NSControlView" ref="835771463"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<object class="NSColor" key="NSTextColor">
-																		<int key="NSColorSpace">1</int>
-																		<bytes key="NSRGB">MSAwLjAyNDA1ODExNDc0IDAuMDEyMjY4NTQzMjQAA</bytes>
-																	</object>
-																</object>
-															</object>
-															<object class="NSButton" id="805322468">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">297</int>
-																<string key="NSFrame">{{413, 89}, {76, 18}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="703486492">
-																	<int key="NSCellFlags">-2080244224</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">DynRoot</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="805322468"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">2</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-															<object class="NSButton" id="1064737768">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">297</int>
-																<string key="NSFrame">{{413, 49}, {66, 18}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="533239018">
-																	<int key="NSCellFlags">-2080244224</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">Verbose</string>
-																	<reference key="NSSupport" ref="26"/>
-																	<reference key="NSControlView" ref="1064737768"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">130</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-															<object class="NSButton" id="509563943">
-																<reference key="NSNextResponder" ref="1006532054"/>
-																<int key="NSvFlags">297</int>
-																<string key="NSFrame">{{413, 69}, {63, 18}}</string>
-																<reference key="NSSuperview" ref="1006532054"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="442311508">
-																	<int key="NSCellFlags">-2080244224</int>
-																	<int key="NSCellFlags2">131072</int>
-																	<string key="NSContents">AfsDB</string>
-																	<reference key="NSSupport" ref="894635401"/>
-																	<reference key="NSControlView" ref="509563943"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">130</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-														</object>
-														<string key="NSFrame">{{1, 1}, {522, 139}}</string>
-														<reference key="NSSuperview" ref="1056952440"/>
-													</object>
-												</object>
-												<string key="NSFrame">{{14, 202}, {524, 155}}</string>
-												<reference key="NSSuperview" ref="537928258"/>
-												<string key="NSOffsets">{0, 0}</string>
-												<object class="NSTextFieldCell" key="NSTitleCell">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Cache Manager</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSBackgroundColor" ref="878835253"/>
-													<object class="NSColor" key="NSTextColor">
-														<int key="NSColorSpace">3</int>
-														<bytes key="NSWhite">MCAwLjgwMDAwMDAxMTkAA</bytes>
-													</object>
-												</object>
-												<reference key="NSContentView" ref="1006532054"/>
-												<int key="NSBorderType">1</int>
-												<int key="NSBoxType">0</int>
-												<int key="NSTitlePosition">2</int>
-												<bool key="NSTransparent">NO</bool>
-											</object>
-										</object>
-										<string key="NSFrame">{{10, 25}, {552, 363}}</string>
-									</object>
-									<string key="NSLabel">Parameter</string>
-									<reference key="NSColor" ref="568311573"/>
-									<reference key="NSTabView" ref="739317740"/>
-								</object>
-								<object class="NSTabViewItem" id="126070858">
-									<string key="NSIdentifier">4</string>
-									<object class="NSView" key="NSView" id="786994103">
-										<nil key="NSNextResponder"/>
-										<int key="NSvFlags">256</int>
-										<object class="NSMutableArray" key="NSSubviews">
-											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSScrollView" id="284115188">
-												<reference key="NSNextResponder" ref="786994103"/>
-												<int key="NSvFlags">274</int>
-												<object class="NSMutableArray" key="NSSubviews">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSClipView" id="229139620">
-														<reference key="NSNextResponder" ref="284115188"/>
-														<int key="NSvFlags">2304</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSTableView" id="1029505942">
-																<reference key="NSNextResponder" ref="229139620"/>
-																<int key="NSvFlags">256</int>
-																<string key="NSFrameSize">{501, 283}</string>
-																<reference key="NSSuperview" ref="229139620"/>
-																<int key="NSTag">3</int>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTableHeaderView" key="NSHeaderView" id="209519573">
-																	<reference key="NSNextResponder" ref="785725164"/>
-																	<int key="NSvFlags">256</int>
-																	<string key="NSFrameSize">{501, 17}</string>
-																	<reference key="NSSuperview" ref="785725164"/>
-																	<reference key="NSTableView" ref="1029505942"/>
-																</object>
-																<object class="_NSCornerView" key="NSCornerView" id="151502956">
-																	<reference key="NSNextResponder" ref="284115188"/>
-																	<int key="NSvFlags">256</int>
-																	<string key="NSFrame">{{502, 0}, {16, 17}}</string>
-																	<reference key="NSSuperview" ref="284115188"/>
-																</object>
-																<object class="NSMutableArray" key="NSTableColumns">
-																	<bool key="EncodedWithXMLCoder">YES</bool>
-																	<object class="NSTableColumn" id="604570943">
-																		<string key="NSIdentifier">0</string>
-																		<double key="NSWidth">84</double>
-																		<double key="NSMinWidth">40</double>
-																		<double key="NSMaxWidth">1000</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Mount Name</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<object class="NSColor" key="NSBackgroundColor" id="869401119">
-																				<int key="NSColorSpace">3</int>
-																				<bytes key="NSWhite">MC4zMzMzMzI5ODU2AA</bytes>
-																			</object>
-																			<reference key="NSTextColor" ref="716292118"/>
-																		</object>
-																		<object class="NSTextFieldCell" key="NSDataCell" id="404459918">
-																			<int key="NSCellFlags">337772096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Text Cell</string>
-																			<reference key="NSSupport" ref="894635401"/>
-																			<reference key="NSControlView" ref="1029505942"/>
-																			<reference key="NSBackgroundColor" ref="252569531"/>
-																			<reference key="NSTextColor" ref="276594776"/>
-																		</object>
-																		<int key="NSResizingMask">3</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<bool key="NSIsEditable">YES</bool>
-																		<reference key="NSTableView" ref="1029505942"/>
-																	</object>
-																	<object class="NSTableColumn" id="915858279">
-																		<string key="NSIdentifier">1</string>
-																		<double key="NSWidth">411</double>
-																		<double key="NSMinWidth">40</double>
-																		<double key="NSMaxWidth">1000</double>
-																		<object class="NSTableHeaderCell" key="NSHeaderCell">
-																			<int key="NSCellFlags">75628096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Mount Path</string>
-																			<reference key="NSSupport" ref="26"/>
-																			<reference key="NSBackgroundColor" ref="869401119"/>
-																			<reference key="NSTextColor" ref="716292118"/>
-																		</object>
-																		<object class="NSTextFieldCell" key="NSDataCell" id="367407167">
-																			<int key="NSCellFlags">337772096</int>
-																			<int key="NSCellFlags2">2048</int>
-																			<string key="NSContents">Text Cell</string>
-																			<reference key="NSSupport" ref="894635401"/>
-																			<reference key="NSControlView" ref="1029505942"/>
-																			<reference key="NSBackgroundColor" ref="252569531"/>
-																			<reference key="NSTextColor" ref="276594776"/>
-																		</object>
-																		<int key="NSResizingMask">3</int>
-																		<bool key="NSIsResizeable">YES</bool>
-																		<bool key="NSIsEditable">YES</bool>
-																		<reference key="NSTableView" ref="1029505942"/>
-																	</object>
-																</object>
-																<double key="NSIntercellSpacingWidth">3</double>
-																<double key="NSIntercellSpacingHeight">2</double>
-																<reference key="NSBackgroundColor" ref="400556243"/>
-																<reference key="NSGridColor" ref="850792713"/>
-																<double key="NSRowHeight">17</double>
-																<int key="NSTvFlags">-20971520</int>
-																<reference key="NSDelegate"/>
-																<reference key="NSDataSource"/>
-																<int key="NSGridStyleMask">2</int>
-																<int key="NSColumnAutoresizingStyle">4</int>
-																<int key="NSDraggingSourceMaskForLocal">15</int>
-																<int key="NSDraggingSourceMaskForNonLocal">0</int>
-																<bool key="NSAllowsTypeSelect">YES</bool>
-																<int key="NSTableViewDraggingDestinationStyle">0</int>
-																<int key="NSTableViewGroupRowStyle">1</int>
-															</object>
-														</object>
-														<string key="NSFrame">{{1, 17}, {501, 283}}</string>
-														<reference key="NSSuperview" ref="284115188"/>
-														<reference key="NSNextKeyView" ref="1029505942"/>
-														<reference key="NSDocView" ref="1029505942"/>
-														<reference key="NSBGColor" ref="252569531"/>
-														<int key="NScvFlags">4</int>
-													</object>
-													<object class="NSScroller" id="497462431">
-														<reference key="NSNextResponder" ref="284115188"/>
-														<int key="NSvFlags">256</int>
-														<string key="NSFrame">{{502, 17}, {15, 283}}</string>
-														<reference key="NSSuperview" ref="284115188"/>
-														<reference key="NSTarget" ref="284115188"/>
-														<string key="NSAction">_doScroller:</string>
-														<double key="NSCurValue">37</double>
-														<double key="NSPercent">0.1947367936372757</double>
-													</object>
-													<object class="NSScroller" id="145484441">
-														<reference key="NSNextResponder" ref="284115188"/>
-														<int key="NSvFlags">256</int>
-														<string key="NSFrame">{{1, 300}, {501, 15}}</string>
-														<reference key="NSSuperview" ref="284115188"/>
-														<int key="NSsFlags">1</int>
-														<reference key="NSTarget" ref="284115188"/>
-														<string key="NSAction">_doScroller:</string>
-														<double key="NSPercent">0.57142859697341919</double>
-													</object>
-													<object class="NSClipView" id="785725164">
-														<reference key="NSNextResponder" ref="284115188"/>
-														<int key="NSvFlags">2304</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<reference ref="209519573"/>
-														</object>
-														<string key="NSFrame">{{1, 0}, {501, 17}}</string>
-														<reference key="NSSuperview" ref="284115188"/>
-														<reference key="NSNextKeyView" ref="209519573"/>
-														<reference key="NSDocView" ref="209519573"/>
-														<reference key="NSBGColor" ref="252569531"/>
-														<int key="NScvFlags">4</int>
-													</object>
-													<reference ref="151502956"/>
-												</object>
-												<string key="NSFrame">{{17, 41}, {518, 316}}</string>
-												<reference key="NSSuperview" ref="786994103"/>
-												<reference key="NSNextKeyView" ref="229139620"/>
-												<int key="NSsFlags">133170</int>
-												<reference key="NSVScroller" ref="497462431"/>
-												<reference key="NSHScroller" ref="145484441"/>
-												<reference key="NSContentView" ref="229139620"/>
-												<reference key="NSHeaderClipView" ref="785725164"/>
-												<bytes key="NSScrollAmts">QSAAAEEgAABBmAAAQZgAAA</bytes>
-											</object>
-											<object class="NSButton" id="642014996">
-												<reference key="NSNextResponder" ref="786994103"/>
-												<int key="NSvFlags">292</int>
-												<string key="NSFrame">{{17, 16}, {81, 18}}</string>
-												<reference key="NSSuperview" ref="786994103"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="865151679">
-													<int key="NSCellFlags">-2080244224</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">Add New Path</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="642014996"/>
-													<int key="NSButtonFlags">-2033434369</int>
-													<int key="NSButtonFlags2">160</int>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">400</int>
-													<int key="NSPeriodicInterval">75</int>
-												</object>
-											</object>
-											<object class="NSButton" id="635503948">
-												<reference key="NSNextResponder" ref="786994103"/>
-												<int key="NSvFlags">292</int>
-												<string key="NSFrame">{{106, 16}, {78, 18}}</string>
-												<reference key="NSSuperview" ref="786994103"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="713243405">
-													<int key="NSCellFlags">-1543373312</int>
-													<int key="NSCellFlags2">134348800</int>
-													<string key="NSContents">Remove Path</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="635503948"/>
-													<int key="NSButtonFlags">-2033434369</int>
-													<int key="NSButtonFlags2">160</int>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">400</int>
-													<int key="NSPeriodicInterval">75</int>
-												</object>
-											</object>
-											<object class="NSButton" id="224507096">
-												<reference key="NSNextResponder" ref="786994103"/>
-												<int key="NSvFlags">289</int>
-												<string key="NSFrame">{{400, 17}, {137, 18}}</string>
-												<reference key="NSSuperview" ref="786994103"/>
-												<bool key="NSEnabled">YES</bool>
-												<object class="NSButtonCell" key="NSCell" id="378183006">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">131072</int>
-													<string key="NSContents">Enable Symbolic Link</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSControlView" ref="224507096"/>
-													<int key="NSButtonFlags">1211912703</int>
-													<int key="NSButtonFlags2">130</int>
-													<reference key="NSNormalImage" ref="502435249"/>
-													<reference key="NSAlternateImage" ref="894136682"/>
-													<string key="NSAlternateContents"/>
-													<string key="NSKeyEquivalent"/>
-													<int key="NSPeriodicDelay">200</int>
-													<int key="NSPeriodicInterval">25</int>
-												</object>
-											</object>
-										</object>
-										<string key="NSFrame">{{10, 25}, {552, 363}}</string>
-									</object>
-									<string key="NSLabel">Mounts</string>
-									<reference key="NSColor" ref="568311573"/>
-									<reference key="NSTabView" ref="739317740"/>
-								</object>
-								<object class="NSTabViewItem" id="585584503">
-									<string key="NSIdentifier">Item 4</string>
-									<object class="NSView" key="NSView" id="626243774">
-										<nil key="NSNextResponder"/>
-										<int key="NSvFlags">256</int>
-										<object class="NSMutableArray" key="NSSubviews">
-											<bool key="EncodedWithXMLCoder">YES</bool>
-											<object class="NSBox" id="731215349">
-												<reference key="NSNextResponder" ref="626243774"/>
-												<int key="NSvFlags">10</int>
-												<object class="NSMutableArray" key="NSSubviews">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSView" id="660074200">
-														<reference key="NSNextResponder" ref="731215349"/>
-														<int key="NSvFlags">274</int>
-														<object class="NSMutableArray" key="NSSubviews">
-															<bool key="EncodedWithXMLCoder">YES</bool>
-															<object class="NSTextField" id="628152029">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{15, 133}, {224, 17}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="733262466">
-																	<int key="NSCellFlags">68288064</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">Requested ticket lifetime(D:H:M:S):</string>
-																	<object class="NSFont" key="NSSupport" id="1918678">
-																		<string key="NSName">LucidaGrande</string>
-																		<double key="NSSize">12</double>
-																		<int key="NSfFlags">16</int>
-																	</object>
-																	<reference key="NSControlView" ref="628152029"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="716552409">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{237, 70}, {96, 22}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<int key="NSTag">3</int>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="583586222">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">71304192</int>
-																	<real value="3600" key="NSContents"/>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="786136385">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximumFractionDigits</string>
-																				<string>minimum</string>
-																				<string>minimumFractionDigits</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>negativeInfinitySymbol</string>
-																				<string>nilSymbol</string>
-																				<string>numberStyle</string>
-																				<string>positiveInfinitySymbol</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<boolean value="YES"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<integer value="0"/>
-																				<real value="60"/>
-																				<integer value="0"/>
-																				<integer value="0"/>
-																				<string>-âˆž</string>
-																				<string/>
-																				<integer value="0"/>
-																				<string>+âˆž</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<object class="NSAttributedString" key="NS.nil">
-																			<string key="NSString"/>
-																		</object>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="60" key="NS.min"/>
-																		<reference key="NS.max" ref="139642944"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="716552409"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="763432112">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{15, 72}, {207, 17}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="449287045">
-																	<int key="NSCellFlags">68288064</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">Ticket renewal check frequency:</string>
-																	<reference key="NSSupport" ref="1918678"/>
-																	<reference key="NSControlView" ref="763432112"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="40613678">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{237, 100}, {96, 22}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<int key="NSTag">2</int>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="131938172">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">71304192</int>
-																	<real value="3600" key="NSContents"/>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="230053326">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximumFractionDigits</string>
-																				<string>minimum</string>
-																				<string>minimumFractionDigits</string>
-																				<string>minimumIntegerDigits</string>
-																				<string>negativeInfinitySymbol</string>
-																				<string>nilSymbol</string>
-																				<string>numberStyle</string>
-																				<string>positiveInfinitySymbol</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<boolean value="YES"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<integer value="0"/>
-																				<real value="60"/>
-																				<integer value="0"/>
-																				<integer value="0"/>
-																				<string>-âˆž</string>
-																				<string/>
-																				<integer value="0"/>
-																				<string>+âˆž</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<object class="NSAttributedString" key="NS.nil">
-																			<string key="NSString"/>
-																		</object>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="60" key="NS.min"/>
-																		<reference key="NS.max" ref="139642944"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="40613678"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="745195065">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{15, 102}, {217, 17}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="27217273">
-																	<int key="NSCellFlags">68288064</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">Seconds before expire to renew:</string>
-																	<reference key="NSSupport" ref="1918678"/>
-																	<reference key="NSControlView" ref="745195065"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSButton" id="912875055">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">265</int>
-																<string key="NSFrame">{{16, 41}, {148, 18}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSButtonCell" key="NSCell" id="488289338">
-																	<int key="NSCellFlags">67239424</int>
-																	<int key="NSCellFlags2">0</int>
-																	<string key="NSContents">Enable auto-renew</string>
-																	<reference key="NSSupport" ref="1918678"/>
-																	<reference key="NSControlView" ref="912875055"/>
-																	<int key="NSButtonFlags">1211912703</int>
-																	<int key="NSButtonFlags2">2</int>
-																	<reference key="NSNormalImage" ref="502435249"/>
-																	<reference key="NSAlternateImage" ref="894136682"/>
-																	<string key="NSAlternateContents"/>
-																	<string key="NSKeyEquivalent"/>
-																	<int key="NSPeriodicDelay">200</int>
-																	<int key="NSPeriodicInterval">25</int>
-																</object>
-															</object>
-															<object class="NSStepper" id="719182296">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{260, 127}, {19, 27}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSStepperCell" key="NSCell" id="119237369">
-																	<int key="NSCellFlags">917024</int>
-																	<int key="NSCellFlags2">0</int>
-																	<reference key="NSControlView" ref="719182296"/>
-																	<double key="NSMaxValue">30</double>
-																	<double key="NSIncrement">1</double>
-																	<bool key="NSAutorepeat">YES</bool>
-																</object>
-															</object>
-															<object class="NSTextField" id="724013147">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{237, 130}, {24, 22}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="16767965">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">138413056</int>
-																	<real value="1" key="NSContents"/>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="830532180">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximum</string>
-																				<string>minimum</string>
-																				<string>negativeInfinitySymbol</string>
-																				<string>nilSymbol</string>
-																				<string>numberStyle</string>
-																				<string>positiveInfinitySymbol</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<boolean value="YES"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<real value="30"/>
-																				<real value="0.0"/>
-																				<string>-âˆž</string>
-																				<string/>
-																				<integer value="0"/>
-																				<string>+âˆž</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<object class="NSAttributedString" key="NS.nil">
-																			<string key="NSString"/>
-																		</object>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="0.0" key="NS.min"/>
-																		<real value="30" key="NS.max"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="724013147"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSStepper" id="338319881">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{307, 127}, {19, 27}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSStepperCell" key="NSCell" id="180280161">
-																	<int key="NSCellFlags">917024</int>
-																	<int key="NSCellFlags2">0</int>
-																	<reference key="NSControlView" ref="338319881"/>
-																	<double key="NSMaxValue">24</double>
-																	<double key="NSIncrement">1</double>
-																	<bool key="NSAutorepeat">YES</bool>
-																</object>
-															</object>
-															<object class="NSTextField" id="791385502">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{284, 130}, {24, 22}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="670432292">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">138413056</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="68665996">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximum</string>
-																				<string>minimum</string>
-																				<string>negativeInfinitySymbol</string>
-																				<string>nilSymbol</string>
-																				<string>numberStyle</string>
-																				<string>positiveInfinitySymbol</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<boolean value="YES"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<real value="24"/>
-																				<real value="0.0"/>
-																				<string>-âˆž</string>
-																				<string/>
-																				<integer value="0"/>
-																				<string>+âˆž</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<object class="NSAttributedString" key="NS.nil">
-																			<string key="NSString"/>
-																		</object>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="0.0" key="NS.min"/>
-																		<real value="24" key="NS.max"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="791385502"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSStepper" id="564887063">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{355, 127}, {19, 27}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSStepperCell" key="NSCell" id="529108778">
-																	<int key="NSCellFlags">917024</int>
-																	<int key="NSCellFlags2">0</int>
-																	<reference key="NSControlView" ref="564887063"/>
-																	<double key="NSMaxValue">60</double>
-																	<double key="NSIncrement">1</double>
-																	<bool key="NSAutorepeat">YES</bool>
-																</object>
-															</object>
-															<object class="NSTextField" id="826525177">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{332, 130}, {24, 22}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="136428454">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">138413056</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="746851166">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximum</string>
-																				<string>minimum</string>
-																				<string>negativeInfinitySymbol</string>
-																				<string>nilSymbol</string>
-																				<string>numberStyle</string>
-																				<string>positiveInfinitySymbol</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<boolean value="YES"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<real value="60"/>
-																				<real value="0.0"/>
-																				<string>-âˆž</string>
-																				<string/>
-																				<integer value="0"/>
-																				<string>+âˆž</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<object class="NSAttributedString" key="NS.nil">
-																			<string key="NSString"/>
-																		</object>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="0.0" key="NS.min"/>
-																		<real value="60" key="NS.max"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="826525177"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="607193498">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{275, 133}, {9, 17}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="178986221">
-																	<int key="NSCellFlags">68288064</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">:</string>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<reference key="NSControlView" ref="607193498"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="704926497">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{322, 133}, {9, 17}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="1028068410">
-																	<int key="NSCellFlags">68288064</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">:</string>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<reference key="NSControlView" ref="704926497"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-															<object class="NSStepper" id="724827539">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{403, 127}, {19, 27}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSStepperCell" key="NSCell" id="426972560">
-																	<int key="NSCellFlags">917024</int>
-																	<int key="NSCellFlags2">0</int>
-																	<reference key="NSControlView" ref="724827539"/>
-																	<double key="NSMaxValue">60</double>
-																	<double key="NSIncrement">1</double>
-																	<bool key="NSAutorepeat">YES</bool>
-																</object>
-															</object>
-															<object class="NSTextField" id="681255345">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{380, 130}, {24, 22}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="60716744">
-																	<int key="NSCellFlags">-1804468671</int>
-																	<int key="NSCellFlags2">138413056</int>
-																	<real value="0.0" key="NSContents"/>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<object class="NSNumberFormatter" key="NSFormatter" id="67110106">
-																		<object class="NSMutableDictionary" key="NS.attributes">
-																			<bool key="EncodedWithXMLCoder">YES</bool>
-																			<object class="NSArray" key="dict.sortedKeys">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<string>allowsFloats</string>
-																				<string>formatterBehavior</string>
-																				<string>locale</string>
-																				<string>maximum</string>
-																				<string>minimum</string>
-																				<string>negativeInfinitySymbol</string>
-																				<string>nilSymbol</string>
-																				<string>numberStyle</string>
-																				<string>positiveInfinitySymbol</string>
-																			</object>
-																			<object class="NSArray" key="dict.values">
-																				<bool key="EncodedWithXMLCoder">YES</bool>
-																				<boolean value="YES"/>
-																				<integer value="1040"/>
-																				<reference ref="925904638"/>
-																				<real value="60"/>
-																				<real value="0.0"/>
-																				<string>-âˆž</string>
-																				<string/>
-																				<integer value="0"/>
-																				<string>+âˆž</string>
-																			</object>
-																		</object>
-																		<string key="NS.positiveformat">#</string>
-																		<string key="NS.negativeformat">#</string>
-																		<nil key="NS.positiveattrs"/>
-																		<nil key="NS.negativeattrs"/>
-																		<nil key="NS.zero"/>
-																		<object class="NSAttributedString" key="NS.nil">
-																			<string key="NSString"/>
-																		</object>
-																		<object class="NSAttributedString" key="NS.nan">
-																			<string key="NSString">NaN</string>
-																			<reference key="NSAttributes" ref="571560357"/>
-																		</object>
-																		<real value="0.0" key="NS.min"/>
-																		<real value="60" key="NS.max"/>
-																		<object class="NSDecimalNumberHandler" key="NS.rounding">
-																			<int key="NS.roundingmode">3</int>
-																			<bool key="NS.raise.overflow">YES</bool>
-																			<bool key="NS.raise.underflow">YES</bool>
-																			<bool key="NS.raise.dividebyzero">YES</bool>
-																		</object>
-																		<string key="NS.decimal">.</string>
-																		<string key="NS.thousand">,</string>
-																		<bool key="NS.hasthousands">NO</bool>
-																		<bool key="NS.localized">NO</bool>
-																		<bool key="NS.allowsfloats">YES</bool>
-																	</object>
-																	<reference key="NSControlView" ref="681255345"/>
-																	<bool key="NSDrawsBackground">YES</bool>
-																	<reference key="NSBackgroundColor" ref="878835253"/>
-																	<reference key="NSTextColor" ref="568125270"/>
-																</object>
-															</object>
-															<object class="NSTextField" id="719264885">
-																<reference key="NSNextResponder" ref="660074200"/>
-																<int key="NSvFlags">268</int>
-																<string key="NSFrame">{{370, 133}, {9, 17}}</string>
-																<reference key="NSSuperview" ref="660074200"/>
-																<bool key="NSEnabled">YES</bool>
-																<object class="NSTextFieldCell" key="NSCell" id="989093559">
-																	<int key="NSCellFlags">68288064</int>
-																	<int key="NSCellFlags2">272630784</int>
-																	<string key="NSContents">:</string>
-																	<reference key="NSSupport" ref="275217208"/>
-																	<reference key="NSControlView" ref="719264885"/>
-																	<reference key="NSBackgroundColor" ref="568311573"/>
-																	<reference key="NSTextColor" ref="276594776"/>
-																</object>
-															</object>
-														</object>
-														<string key="NSFrame">{{1, 1}, {517, 162}}</string>
-														<reference key="NSSuperview" ref="731215349"/>
-													</object>
-												</object>
-												<string key="NSFrame">{{19, 179}, {519, 178}}</string>
-												<reference key="NSSuperview" ref="626243774"/>
-												<string key="NSOffsets">{0, 0}</string>
-												<object class="NSTextFieldCell" key="NSTitleCell">
-													<int key="NSCellFlags">67239424</int>
-													<int key="NSCellFlags2">0</int>
-													<string key="NSContents">Kerberos Renew Ticket Option</string>
-													<reference key="NSSupport" ref="26"/>
-													<reference key="NSBackgroundColor" ref="878835253"/>
-													<object class="NSColor" key="NSTextColor">
-														<int key="NSColorSpace">3</int>
-														<bytes key="NSWhite">MCAwLjgwMDAwMDAxMTkAA</bytes>
-													</object>
-												</object>
-												<reference key="NSContentView" ref="660074200"/>
-												<int key="NSBorderType">1</int>
-												<int key="NSBoxType">0</int>
-												<int key="NSTitlePosition">2</int>
-												<bool key="NSTransparent">NO</bool>
-											</object>
-										</object>
-										<string key="NSFrame">{{10, 25}, {552, 363}}</string>
-									</object>
-									<string key="NSLabel">Option</string>
-									<reference key="NSColor" ref="568311573"/>
-									<reference key="NSTabView" ref="739317740"/>
-								</object>
-							</object>
-							<reference key="NSSelectedTabViewItem" ref="269508902"/>
-							<reference key="NSFont" ref="26"/>
-							<int key="NSTvFlags">134217728</int>
-							<bool key="NSAllowTruncatedLabels">YES</bool>
-							<bool key="NSDrawsBackground">YES</bool>
-							<object class="NSMutableArray" key="NSSubviews">
-								<bool key="EncodedWithXMLCoder">YES</bool>
-								<reference ref="1020318718"/>
-							</object>
-						</object>
-						<object class="NSTextField" id="1047946385">
-							<reference key="NSNextResponder" ref="645279396"/>
-							<int key="NSvFlags">289</int>
-							<string key="NSFrame">{{323, 3}, {258, 11}}</string>
-							<reference key="NSSuperview" ref="645279396"/>
-							<reference key="NSWindow"/>
-							<reference key="NSNextKeyView"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="999146642">
-								<int key="NSCellFlags">68288064</int>
-								<int key="NSCellFlags2">71435264</int>
-								<string key="NSContents">afs version</string>
-								<object class="NSFont" key="NSSupport">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">9</double>
-									<int key="NSfFlags">16</int>
-								</object>
-								<reference key="NSControlView" ref="1047946385"/>
-								<reference key="NSBackgroundColor" ref="568311573"/>
-								<reference key="NSTextColor" ref="276594776"/>
-							</object>
-						</object>
-					</object>
-					<string key="NSFrameSize">{595, 486}</string>
-					<reference key="NSSuperview"/>
-					<reference key="NSWindow"/>
-					<reference key="NSNextKeyView" ref="748501112"/>
-				</object>
-				<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
-				<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
-				<bool key="NSWindowIsRestorable">YES</bool>
-			</object>
-			<object class="NSWindowTemplate" id="52789773">
-				<int key="NSWindowStyleMask">9</int>
-				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{1006, 707}, {715, 485}}</string>
-				<int key="NSWTFlags">1886912512</int>
-				<string key="NSWindowTitle">Panel</string>
-				<object class="NSMutableString" key="NSWindowClass">
-					<characters key="NS.bytes">NSPanel</characters>
-				</object>
-				<object class="NSMutableString" key="NSViewClass">
-					<characters key="NS.bytes">View</characters>
-				</object>
-				<nil key="NSUserInterfaceItemIdentifier"/>
-				<object class="NSView" key="NSWindowView" id="1017822711">
-					<nil key="NSNextResponder"/>
-					<int key="NSvFlags">256</int>
-					<object class="NSMutableArray" key="NSSubviews">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSScrollView" id="935020490">
-							<reference key="NSNextResponder" ref="1017822711"/>
-							<int key="NSvFlags">274</int>
-							<object class="NSMutableArray" key="NSSubviews">
-								<bool key="EncodedWithXMLCoder">YES</bool>
-								<object class="NSClipView" id="853671207">
-									<reference key="NSNextResponder" ref="935020490"/>
-									<int key="NSvFlags">2304</int>
-									<object class="NSMutableArray" key="NSSubviews">
-										<bool key="EncodedWithXMLCoder">YES</bool>
-										<object class="NSTextView" id="297493656">
-											<reference key="NSNextResponder" ref="853671207"/>
-											<int key="NSvFlags">2322</int>
-											<string key="NSFrameSize">{673, 14}</string>
-											<reference key="NSSuperview" ref="853671207"/>
-											<object class="NSTextContainer" key="NSTextContainer" id="512204159">
-												<object class="NSLayoutManager" key="NSLayoutManager">
-													<object class="NSTextStorage" key="NSTextStorage">
-														<object class="NSMutableString" key="NSString">
-															<characters key="NS.bytes"/>
-														</object>
-														<nil key="NSDelegate"/>
-													</object>
-													<object class="NSMutableArray" key="NSTextContainers">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<reference ref="512204159"/>
-													</object>
-													<int key="NSLMFlags">6</int>
-													<nil key="NSDelegate"/>
-												</object>
-												<reference key="NSTextView" ref="297493656"/>
-												<double key="NSWidth">673</double>
-												<int key="NSTCFlags">1</int>
-											</object>
-											<object class="NSTextViewSharedData" key="NSSharedData">
-												<int key="NSFlags">67111777</int>
-												<int key="NSTextCheckingTypes">0</int>
-												<nil key="NSMarkedAttributes"/>
-												<reference key="NSBackgroundColor" ref="400556243"/>
-												<object class="NSDictionary" key="NSSelectedAttributes">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSArray" key="dict.sortedKeys">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<string>NSBackgroundColor</string>
-														<string>NSColor</string>
-													</object>
-													<object class="NSArray" key="dict.values">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<object class="NSColor">
-															<int key="NSColorSpace">6</int>
-															<string key="NSCatalogName">System</string>
-															<string key="NSColorName">selectedTextBackgroundColor</string>
-															<reference key="NSColor" ref="277525007"/>
-														</object>
-														<object class="NSColor">
-															<int key="NSColorSpace">6</int>
-															<string key="NSCatalogName">System</string>
-															<string key="NSColorName">selectedTextColor</string>
-															<reference key="NSColor" ref="39932154"/>
-														</object>
-													</object>
-												</object>
-												<reference key="NSInsertionColor" ref="39932154"/>
-												<object class="NSDictionary" key="NSLinkAttributes">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<object class="NSArray" key="dict.sortedKeys">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<string>NSColor</string>
-														<string>NSUnderline</string>
-													</object>
-													<object class="NSArray" key="dict.values">
-														<bool key="EncodedWithXMLCoder">YES</bool>
-														<object class="NSColor">
-															<int key="NSColorSpace">1</int>
-															<bytes key="NSRGB">MCAwIDEAA</bytes>
-														</object>
-														<integer value="1"/>
-													</object>
-												</object>
-												<nil key="NSDefaultParagraphStyle"/>
-												<nil key="NSTextFinder"/>
-												<int key="NSPreferredTextFinderStyle">0</int>
-											</object>
-											<int key="NSTVFlags">6</int>
-											<string key="NSMaxSize">{1337, 10000000}</string>
-											<string key="NSMinize">{114, 0}</string>
-											<nil key="NSDelegate"/>
-										</object>
-									</object>
-									<string key="NSFrame">{{1, 1}, {673, 423}}</string>
-									<reference key="NSSuperview" ref="935020490"/>
-									<reference key="NSNextKeyView" ref="297493656"/>
-									<reference key="NSDocView" ref="297493656"/>
-									<reference key="NSBGColor" ref="400556243"/>
-									<object class="NSCursor" key="NSCursor">
-										<string key="NSHotSpot">{4, 5}</string>
-										<object class="NSImage" key="NSImage">
-											<int key="NSImageFlags">79691776</int>
-											<object class="NSArray" key="NSReps">
-												<bool key="EncodedWithXMLCoder">YES</bool>
-												<object class="NSArray">
-													<bool key="EncodedWithXMLCoder">YES</bool>
-													<integer value="5"/>
-													<object class="NSURL">
-														<nil key="NS.base"/>
-														<string key="NS.relative">file://localhost/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Resources/DVTIbeamCursor.tiff</string>
-													</object>
-												</object>
-											</object>
-											<object class="NSColor" key="NSColor">
-												<int key="NSColorSpace">3</int>
-												<bytes key="NSWhite">MCAwAA</bytes>
-											</object>
-										</object>
-									</object>
-									<int key="NScvFlags">4</int>
-								</object>
-								<object class="NSScroller" id="11642274">
-									<reference key="NSNextResponder" ref="935020490"/>
-									<int key="NSvFlags">256</int>
-									<string key="NSFrame">{{663, 1}, {11, 423}}</string>
-									<reference key="NSSuperview" ref="935020490"/>
-									<int key="NSsFlags">256</int>
-									<reference key="NSTarget" ref="935020490"/>
-									<string key="NSAction">_doScroller:</string>
-									<double key="NSCurValue">1</double>
-								</object>
-								<object class="NSScroller" id="574894181">
-									<reference key="NSNextResponder" ref="935020490"/>
-									<int key="NSvFlags">-2147483392</int>
-									<string key="NSFrame">{{-100, -100}, {87, 18}}</string>
-									<reference key="NSSuperview" ref="935020490"/>
-									<int key="NSsFlags">257</int>
-									<reference key="NSTarget" ref="935020490"/>
-									<string key="NSAction">_doScroller:</string>
-									<double key="NSCurValue">1</double>
-									<double key="NSPercent">0.94565218687057495</double>
-								</object>
-							</object>
-							<string key="NSFrame">{{20, 40}, {675, 425}}</string>
-							<reference key="NSSuperview" ref="1017822711"/>
-							<reference key="NSNextKeyView" ref="853671207"/>
-							<int key="NSsFlags">133138</int>
-							<reference key="NSVScroller" ref="11642274"/>
-							<reference key="NSHScroller" ref="574894181"/>
-							<reference key="NSContentView" ref="853671207"/>
-						</object>
-						<object class="NSButton" id="729692979">
-							<reference key="NSNextResponder" ref="1017822711"/>
-							<int key="NSvFlags">293</int>
-							<string key="NSFrame">{{318, 8}, {80, 28}}</string>
-							<reference key="NSSuperview" ref="1017822711"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="278933381">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Close</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="729692979"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">1</int>
-								<reference key="NSAlternateImage" ref="26"/>
-								<string key="NSAlternateContents"/>
-								<object class="NSMutableString" key="NSKeyEquivalent">
-									<characters key="NS.bytes"/>
-								</object>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-					</object>
-					<string key="NSFrameSize">{715, 485}</string>
-				</object>
-				<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
-				<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
-				<bool key="NSWindowIsRestorable">YES</bool>
-			</object>
-			<object class="NSCustomObject" id="176554930">
-				<string key="NSClassName">InfoController</string>
-			</object>
-		</object>
-		<object class="IBObjectContainer" key="IBDocument.Objects">
-			<object class="NSMutableArray" key="connectionRecords">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">_window</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="61231707"/>
-					</object>
-					<int key="connectionID">100</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">cellList</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="536830463"/>
-					</object>
-					<int key="connectionID">187</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">cellIpButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="593598121"/>
-					</object>
-					<int key="connectionID">188</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">removeCellButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="537320483"/>
-					</object>
-					<int key="connectionID">189</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">addCellButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="788506691"/>
-					</object>
-					<int key="connectionID">190</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">addRemoveCell:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="788506691"/>
-					</object>
-					<int key="connectionID">191</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">addRemoveCell:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="537320483"/>
-					</object>
-					<int key="connectionID">192</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">showCellIP:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="593598121"/>
-					</object>
-					<int key="connectionID">193</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">saveConfiguration:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="335179878"/>
-					</object>
-					<int key="connectionID">202</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">infoSheet</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="52789773"/>
-					</object>
-					<int key="connectionID">217</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">infoController</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="176554930"/>
-					</object>
-					<int key="connectionID">225</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsCommanderView</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="645279396"/>
-					</object>
-					<int key="connectionID">303</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">statCacheEntry</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="411322031"/>
-					</object>
-					<int key="connectionID">418</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">dCacheDim</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="761947305"/>
-					</object>
-					<int key="connectionID">419</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">daemonNumber</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="23658009"/>
-					</object>
-					<int key="connectionID">420</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsRootMountPoint</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="850669444"/>
-					</object>
-					<int key="connectionID">421</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nVolEntry</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="255735511"/>
-					</object>
-					<int key="connectionID">422</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">cacheDimension</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="627718334"/>
-					</object>
-					<int key="connectionID">423</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">dynRoot</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="805322468"/>
-					</object>
-					<int key="connectionID">424</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">saveCacheManagerParam:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="892096934"/>
-					</object>
-					<int key="connectionID">474</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textSearchField</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="530233415"/>
-					</object>
-					<int key="connectionID">812</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">searchCellTextEvent:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="530233415"/>
-					</object>
-					<int key="connectionID">817</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">startStopAfs:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="709840556"/>
-					</object>
-					<int key="connectionID">1105</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">startStopButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="709840556"/>
-					</object>
-					<int key="connectionID">1106</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">afsMenuActivationEvent:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="893552286"/>
-					</object>
-					<int key="connectionID">1109</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsMenucheckBox</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="893552286"/>
-					</object>
-					<int key="connectionID">1110</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">info:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="871603218"/>
-					</object>
-					<int key="connectionID">1113</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">tokensTable</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="313963250"/>
-					</object>
-					<int key="connectionID">1206</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">unlog:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="210387551"/>
-					</object>
-					<int key="connectionID">1211</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">getNewToken:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="977607312"/>
-					</object>
-					<int key="connectionID">1212</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">useAklogCheck</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="478533800"/>
-					</object>
-					<int key="connectionID">1282</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">aklogSwitchEvent:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="478533800"/>
-					</object>
-					<int key="connectionID">1353</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">unlogButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="210387551"/>
-					</object>
-					<int key="connectionID">1644</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">tokensButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="977607312"/>
-					</object>
-					<int key="connectionID">1645</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsVersionLabel</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="1047946385"/>
-					</object>
-					<int key="connectionID">1717</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsDefaultCellLabel</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="747536303"/>
-					</object>
-					<int key="connectionID">1847</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">afsDB</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="509563943"/>
-					</object>
-					<int key="connectionID">1904</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">verbose</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="1064737768"/>
-					</object>
-					<int key="connectionID">1962</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">aklogCredentialAtLoginTime</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="541208829"/>
-					</object>
-					<int key="connectionID">2014</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">credentialAtLoginTimeEvent:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="541208829"/>
-					</object>
-					<int key="connectionID">2015</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">installKRB5AuthAtLoginButton</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="239701474"/>
-					</object>
-					<int key="connectionID">2020</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">krb5KredentialAtLoginTimeEvent:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="855912809"/>
-					</object>
-					<int key="connectionID">2021</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">checkEnableLink</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="224507096"/>
-					</object>
-					<int key="connectionID">2042</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">buttonAddLink</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="642014996"/>
-					</object>
-					<int key="connectionID">2045</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">addLink:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="642014996"/>
-					</object>
-					<int key="connectionID">2046</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">removeLink:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="635503948"/>
-					</object>
-					<int key="connectionID">2047</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">enableLink:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="224507096"/>
-					</object>
-					<int key="connectionID">2048</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">checkButtonAfsAtBootTime</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="713307252"/>
-					</object>
-					<int key="connectionID">2051</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">afsStartupSwitchEvent:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="713307252"/>
-					</object>
-					<int key="connectionID">2052</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textFieldDevInfoLabel</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="415603882"/>
-					</object>
-					<int key="connectionID">2053</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">backgrounderActivationCheck</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="343070533"/>
-					</object>
-					<int key="connectionID">2056</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">manageBackgrounderActivation:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="343070533"/>
-					</object>
-					<int key="connectionID">2057</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">tableViewLink</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="1029505942"/>
-					</object>
-					<int key="connectionID">2059</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">buttonRemoveLink</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="635503948"/>
-					</object>
-					<int key="connectionID">2063</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsTextFieldKrb5RenewCheckIntervall</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="716552409"/>
-					</object>
-					<int key="connectionID">2081</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsTextFieldKrb5SecToExpireDateForRenew</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="40613678"/>
-					</object>
-					<int key="connectionID">2083</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsButtonEnableDisableKrb5RenewCheck</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="912875055"/>
-					</object>
-					<int key="connectionID">2089</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">krb5RenewParamChange:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="40613678"/>
-					</object>
-					<int key="connectionID">2091</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">krb5RenewParamChange:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="716552409"/>
-					</object>
-					<int key="connectionID">2092</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">enableDisableKrb5RenewCheck:</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="912875055"/>
-					</object>
-					<int key="connectionID">2093</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsTextFieldKrb5RenewTimeD</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="724013147"/>
-					</object>
-					<int key="connectionID">2142</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsTextFieldKrb5RenewTimeH</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="791385502"/>
-					</object>
-					<int key="connectionID">2143</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsTextFieldKrb5RenewTimeM</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="826525177"/>
-					</object>
-					<int key="connectionID">2144</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsTextFieldKrb5RenewTimeS</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="681255345"/>
-					</object>
-					<int key="connectionID">2145</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsStepperKrb5RenewTimeD</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="719182296"/>
-					</object>
-					<int key="connectionID">2146</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsStepperKrb5RenewTimeH</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="338319881"/>
-					</object>
-					<int key="connectionID">2147</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsStepperKrb5RenewTimeM</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="564887063"/>
-					</object>
-					<int key="connectionID">2148</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">nsStepperKrb5RenewTimeS</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="724827539"/>
-					</object>
-					<int key="connectionID">2149</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">authView</string>
-						<reference key="source" ref="773588579"/>
-						<reference key="destination" ref="802059200"/>
-					</object>
-					<int key="connectionID">2151</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">delegate</string>
-						<reference key="source" ref="739317740"/>
-						<reference key="destination" ref="773588579"/>
-					</object>
-					<int key="connectionID">669</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">delegate</string>
-						<reference key="source" ref="530233415"/>
-						<reference key="destination" ref="773588579"/>
-					</object>
-					<int key="connectionID">886</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">infoPanel</string>
-						<reference key="source" ref="176554930"/>
-						<reference key="destination" ref="52789773"/>
-					</object>
-					<int key="connectionID">226</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">texEditInfo</string>
-						<reference key="source" ref="176554930"/>
-						<reference key="destination" ref="297493656"/>
-					</object>
-					<int key="connectionID">227</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">closePanel:</string>
-						<reference key="source" ref="176554930"/>
-						<reference key="destination" ref="729692979"/>
-					</object>
-					<int key="connectionID">228</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">dataSource</string>
-						<reference key="source" ref="1029505942"/>
-						<reference key="destination" ref="773588579"/>
-					</object>
-					<int key="connectionID">2060</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">delegate</string>
-						<reference key="source" ref="1029505942"/>
-						<reference key="destination" ref="773588579"/>
-					</object>
-					<int key="connectionID">2061</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntValueFrom:</string>
-						<reference key="source" ref="719182296"/>
-						<reference key="destination" ref="724013147"/>
-					</object>
-					<int key="connectionID">2128</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntegerValueFrom:</string>
-						<reference key="source" ref="724013147"/>
-						<reference key="destination" ref="719182296"/>
-					</object>
-					<int key="connectionID">2104</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntegerValueFrom:</string>
-						<reference key="source" ref="338319881"/>
-						<reference key="destination" ref="791385502"/>
-					</object>
-					<int key="connectionID">2127</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntegerValueFrom:</string>
-						<reference key="source" ref="791385502"/>
-						<reference key="destination" ref="338319881"/>
-					</object>
-					<int key="connectionID">2114</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntValueFrom:</string>
-						<reference key="source" ref="564887063"/>
-						<reference key="destination" ref="826525177"/>
-					</object>
-					<int key="connectionID">2129</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntegerValueFrom:</string>
-						<reference key="source" ref="826525177"/>
-						<reference key="destination" ref="564887063"/>
-					</object>
-					<int key="connectionID">2120</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntValueFrom:</string>
-						<reference key="source" ref="724827539"/>
-						<reference key="destination" ref="681255345"/>
-					</object>
-					<int key="connectionID">2141</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">takeIntegerValueFrom:</string>
-						<reference key="source" ref="681255345"/>
-						<reference key="destination" ref="724827539"/>
-					</object>
-					<int key="connectionID">2140</int>
-				</object>
-			</object>
-			<object class="IBMutableOrderedSet" key="objectRecords">
-				<object class="NSArray" key="orderedObjects">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="IBObjectRecord">
-						<int key="objectID">0</int>
-						<reference key="object" ref="0"/>
-						<reference key="children" ref="84888716"/>
-						<nil key="parent"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-2</int>
-						<reference key="object" ref="773588579"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">File's Owner</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-1</int>
-						<reference key="object" ref="270520968"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">First Responder</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-3</int>
-						<reference key="object" ref="173116405"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">Application</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">12</int>
-						<reference key="object" ref="61231707"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="645279396"/>
-						</object>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">PrefPane</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">6</int>
-						<reference key="object" ref="645279396"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1047946385"/>
-							<reference ref="415603882"/>
-							<reference ref="739317740"/>
-							<reference ref="748501112"/>
-						</object>
-						<reference key="parent" ref="61231707"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">101</int>
-						<reference key="object" ref="739317740"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="269508902"/>
-							<reference ref="443722606"/>
-							<reference ref="584361947"/>
-							<reference ref="126070858"/>
-							<reference ref="585584503"/>
-						</object>
-						<reference key="parent" ref="645279396"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">104</int>
-						<reference key="object" ref="269508902"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1020318718"/>
-						</object>
-						<reference key="parent" ref="739317740"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">105</int>
-						<reference key="object" ref="1020318718"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="440720679"/>
-							<reference ref="977607312"/>
-							<reference ref="184192603"/>
-							<reference ref="893552286"/>
-							<reference ref="343070533"/>
-							<reference ref="210387551"/>
-							<reference ref="802059200"/>
-						</object>
-						<reference key="parent" ref="269508902"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1107</int>
-						<reference key="object" ref="893552286"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="428850916"/>
-						</object>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1199</int>
-						<reference key="object" ref="440720679"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="313963250"/>
-							<reference ref="884311606"/>
-							<reference ref="258996751"/>
-							<reference ref="1048519426"/>
-						</object>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1203</int>
-						<reference key="object" ref="313963250"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="10567446"/>
-						</object>
-						<reference key="parent" ref="440720679"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1204</int>
-						<reference key="object" ref="10567446"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="361287568"/>
-						</object>
-						<reference key="parent" ref="313963250"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1207</int>
-						<reference key="object" ref="210387551"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="327131725"/>
-						</object>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1209</int>
-						<reference key="object" ref="977607312"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="73578210"/>
-						</object>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">177</int>
-						<reference key="object" ref="443722606"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1069727156"/>
-						</object>
-						<reference key="parent" ref="739317740"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">178</int>
-						<reference key="object" ref="1069727156"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="96110784"/>
-							<reference ref="788506691"/>
-							<reference ref="537320483"/>
-							<reference ref="593598121"/>
-							<reference ref="530233415"/>
-							<reference ref="335179878"/>
-							<reference ref="1038382119"/>
-							<reference ref="747536303"/>
-						</object>
-						<reference key="parent" ref="443722606"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">179</int>
-						<reference key="object" ref="96110784"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="536830463"/>
-							<reference ref="177605134"/>
-							<reference ref="172641834"/>
-							<reference ref="993816125"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">180</int>
-						<reference key="object" ref="536830463"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="145486834"/>
-							<reference ref="909348673"/>
-							<reference ref="720585546"/>
-							<reference ref="136480779"/>
-						</object>
-						<reference key="parent" ref="96110784"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">181</int>
-						<reference key="object" ref="145486834"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="345168793"/>
-						</object>
-						<reference key="parent" ref="536830463"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">182</int>
-						<reference key="object" ref="909348673"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="990091450"/>
-						</object>
-						<reference key="parent" ref="536830463"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1422</int>
-						<reference key="object" ref="720585546"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="110685339"/>
-						</object>
-						<reference key="parent" ref="536830463"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1426</int>
-						<reference key="object" ref="110685339"/>
-						<reference key="parent" ref="720585546"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1787</int>
-						<reference key="object" ref="136480779"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="787517969"/>
-						</object>
-						<reference key="parent" ref="536830463"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1789</int>
-						<reference key="object" ref="787517969"/>
-						<reference key="parent" ref="136480779"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">183</int>
-						<reference key="object" ref="788506691"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="934170338"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">184</int>
-						<reference key="object" ref="537320483"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1045702831"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">185</int>
-						<reference key="object" ref="593598121"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="567447351"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">186</int>
-						<reference key="object" ref="530233415"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="497389328"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">200</int>
-						<reference key="object" ref="335179878"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="372630674"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">265</int>
-						<reference key="object" ref="1038382119"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="269454663"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1845</int>
-						<reference key="object" ref="747536303"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="579088625"/>
-						</object>
-						<reference key="parent" ref="1069727156"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">337</int>
-						<reference key="object" ref="584361947"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="537928258"/>
-						</object>
-						<reference key="parent" ref="739317740"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">338</int>
-						<reference key="object" ref="537928258"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1056952440"/>
-						</object>
-						<reference key="parent" ref="584361947"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">339</int>
-						<reference key="object" ref="1056952440"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="748314809"/>
-							<reference ref="411322031"/>
-							<reference ref="761947305"/>
-							<reference ref="560081349"/>
-							<reference ref="23658009"/>
-							<reference ref="217732195"/>
-							<reference ref="1070305297"/>
-							<reference ref="358834889"/>
-							<reference ref="255735511"/>
-							<reference ref="640588663"/>
-							<reference ref="850669444"/>
-							<reference ref="972024631"/>
-							<reference ref="627718334"/>
-							<reference ref="892096934"/>
-							<reference ref="835771463"/>
-							<reference ref="805322468"/>
-							<reference ref="1064737768"/>
-							<reference ref="509563943"/>
-						</object>
-						<reference key="parent" ref="537928258"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">207</int>
-						<reference key="object" ref="415603882"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="947523856"/>
-						</object>
-						<reference key="parent" ref="645279396"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1122</int>
-						<reference key="object" ref="748501112"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="709840556"/>
-							<reference ref="713307252"/>
-							<reference ref="871603218"/>
-						</object>
-						<reference key="parent" ref="645279396"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1715</int>
-						<reference key="object" ref="1047946385"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="999146642"/>
-						</object>
-						<reference key="parent" ref="645279396"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">208</int>
-						<reference key="object" ref="52789773"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1017822711"/>
-						</object>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">Info</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">209</int>
-						<reference key="object" ref="1017822711"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="935020490"/>
-							<reference ref="729692979"/>
-						</object>
-						<reference key="parent" ref="52789773"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">214</int>
-						<reference key="object" ref="935020490"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="297493656"/>
-							<reference ref="11642274"/>
-							<reference ref="574894181"/>
-						</object>
-						<reference key="parent" ref="1017822711"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">215</int>
-						<reference key="object" ref="297493656"/>
-						<reference key="parent" ref="935020490"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">216</int>
-						<reference key="object" ref="729692979"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="278933381"/>
-						</object>
-						<reference key="parent" ref="1017822711"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">224</int>
-						<reference key="object" ref="176554930"/>
-						<reference key="parent" ref="0"/>
-						<string key="objectName">InfoController</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1964</int>
-						<reference key="object" ref="428850916"/>
-						<reference key="parent" ref="893552286"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1965</int>
-						<reference key="object" ref="327131725"/>
-						<reference key="parent" ref="210387551"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1966</int>
-						<reference key="object" ref="73578210"/>
-						<reference key="parent" ref="977607312"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1968</int>
-						<reference key="object" ref="934170338"/>
-						<reference key="parent" ref="788506691"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1969</int>
-						<reference key="object" ref="1045702831"/>
-						<reference key="parent" ref="537320483"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1970</int>
-						<reference key="object" ref="567447351"/>
-						<reference key="parent" ref="593598121"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1971</int>
-						<reference key="object" ref="497389328"/>
-						<reference key="parent" ref="530233415"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1972</int>
-						<reference key="object" ref="372630674"/>
-						<reference key="parent" ref="335179878"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1973</int>
-						<reference key="object" ref="269454663"/>
-						<reference key="parent" ref="1038382119"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1974</int>
-						<reference key="object" ref="579088625"/>
-						<reference key="parent" ref="747536303"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1993</int>
-						<reference key="object" ref="947523856"/>
-						<reference key="parent" ref="415603882"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1998</int>
-						<reference key="object" ref="999146642"/>
-						<reference key="parent" ref="1047946385"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1999</int>
-						<reference key="object" ref="278933381"/>
-						<reference key="parent" ref="729692979"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2000</int>
-						<reference key="object" ref="361287568"/>
-						<reference key="parent" ref="10567446"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2001</int>
-						<reference key="object" ref="345168793"/>
-						<reference key="parent" ref="145486834"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2002</int>
-						<reference key="object" ref="990091450"/>
-						<reference key="parent" ref="909348673"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2003</int>
-						<reference key="object" ref="884311606"/>
-						<reference key="parent" ref="440720679"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2004</int>
-						<reference key="object" ref="258996751"/>
-						<reference key="parent" ref="440720679"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2005</int>
-						<reference key="object" ref="1048519426"/>
-						<reference key="parent" ref="440720679"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2006</int>
-						<reference key="object" ref="177605134"/>
-						<reference key="parent" ref="96110784"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2007</int>
-						<reference key="object" ref="172641834"/>
-						<reference key="parent" ref="96110784"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2008</int>
-						<reference key="object" ref="993816125"/>
-						<reference key="parent" ref="96110784"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2009</int>
-						<reference key="object" ref="11642274"/>
-						<reference key="parent" ref="935020490"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2010</int>
-						<reference key="object" ref="574894181"/>
-						<reference key="parent" ref="935020490"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">340</int>
-						<reference key="object" ref="748314809"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1008754563"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1975</int>
-						<reference key="object" ref="1008754563"/>
-						<reference key="parent" ref="748314809"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">342</int>
-						<reference key="object" ref="411322031"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1051935415"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1976</int>
-						<reference key="object" ref="1051935415"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="455485314"/>
-						</object>
-						<reference key="parent" ref="411322031"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">741</int>
-						<reference key="object" ref="455485314"/>
-						<reference key="parent" ref="1051935415"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">344</int>
-						<reference key="object" ref="761947305"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="19899457"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1977</int>
-						<reference key="object" ref="19899457"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="248712560"/>
-						</object>
-						<reference key="parent" ref="761947305"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">742</int>
-						<reference key="object" ref="248712560"/>
-						<reference key="parent" ref="19899457"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">345</int>
-						<reference key="object" ref="560081349"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="628600719"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1978</int>
-						<reference key="object" ref="628600719"/>
-						<reference key="parent" ref="560081349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">348</int>
-						<reference key="object" ref="23658009"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="463621063"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1979</int>
-						<reference key="object" ref="463621063"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="833073507"/>
-						</object>
-						<reference key="parent" ref="23658009"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">417</int>
-						<reference key="object" ref="833073507"/>
-						<reference key="parent" ref="463621063"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">349</int>
-						<reference key="object" ref="217732195"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1057450635"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1980</int>
-						<reference key="object" ref="1057450635"/>
-						<reference key="parent" ref="217732195"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">352</int>
-						<reference key="object" ref="1070305297"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="474187509"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1981</int>
-						<reference key="object" ref="474187509"/>
-						<reference key="parent" ref="1070305297"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">402</int>
-						<reference key="object" ref="358834889"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="120617252"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1983</int>
-						<reference key="object" ref="120617252"/>
-						<reference key="parent" ref="358834889"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">404</int>
-						<reference key="object" ref="255735511"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="310838537"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1984</int>
-						<reference key="object" ref="310838537"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="547764719"/>
-						</object>
-						<reference key="parent" ref="255735511"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">411</int>
-						<reference key="object" ref="547764719"/>
-						<reference key="parent" ref="310838537"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">406</int>
-						<reference key="object" ref="640588663"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="35880329"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1985</int>
-						<reference key="object" ref="35880329"/>
-						<reference key="parent" ref="640588663"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">408</int>
-						<reference key="object" ref="850669444"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="456324371"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1986</int>
-						<reference key="object" ref="456324371"/>
-						<reference key="parent" ref="850669444"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">413</int>
-						<reference key="object" ref="972024631"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="383369569"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1987</int>
-						<reference key="object" ref="383369569"/>
-						<reference key="parent" ref="972024631"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">415</int>
-						<reference key="object" ref="627718334"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="756462877"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1988</int>
-						<reference key="object" ref="756462877"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="592804150"/>
-						</object>
-						<reference key="parent" ref="627718334"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">740</int>
-						<reference key="object" ref="592804150"/>
-						<reference key="parent" ref="756462877"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">425</int>
-						<reference key="object" ref="892096934"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="728535364"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1989</int>
-						<reference key="object" ref="728535364"/>
-						<reference key="parent" ref="892096934"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">475</int>
-						<reference key="object" ref="835771463"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="672812502"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1990</int>
-						<reference key="object" ref="672812502"/>
-						<reference key="parent" ref="835771463"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">400</int>
-						<reference key="object" ref="805322468"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="703486492"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1982</int>
-						<reference key="object" ref="703486492"/>
-						<reference key="parent" ref="805322468"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1902</int>
-						<reference key="object" ref="509563943"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="442311508"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1991</int>
-						<reference key="object" ref="442311508"/>
-						<reference key="parent" ref="509563943"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1960</int>
-						<reference key="object" ref="1064737768"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="533239018"/>
-						</object>
-						<reference key="parent" ref="1056952440"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1992</int>
-						<reference key="object" ref="533239018"/>
-						<reference key="parent" ref="1064737768"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1103</int>
-						<reference key="object" ref="709840556"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="675447498"/>
-						</object>
-						<reference key="parent" ref="748501112"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1994</int>
-						<reference key="object" ref="675447498"/>
-						<reference key="parent" ref="709840556"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1111</int>
-						<reference key="object" ref="871603218"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1009755861"/>
-						</object>
-						<reference key="parent" ref="748501112"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1995</int>
-						<reference key="object" ref="1009755861"/>
-						<reference key="parent" ref="871603218"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2013</int>
-						<reference key="object" ref="184192603"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="239701474"/>
-							<reference ref="478533800"/>
-							<reference ref="541208829"/>
-						</object>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1280</int>
-						<reference key="object" ref="478533800"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="989004902"/>
-						</object>
-						<reference key="parent" ref="184192603"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">1967</int>
-						<reference key="object" ref="989004902"/>
-						<reference key="parent" ref="478533800"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2011</int>
-						<reference key="object" ref="541208829"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="95048095"/>
-						</object>
-						<reference key="parent" ref="184192603"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2012</int>
-						<reference key="object" ref="95048095"/>
-						<reference key="parent" ref="541208829"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2022</int>
-						<reference key="object" ref="126070858"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="786994103"/>
-						</object>
-						<reference key="parent" ref="739317740"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2023</int>
-						<reference key="object" ref="786994103"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="284115188"/>
-							<reference ref="224507096"/>
-							<reference ref="642014996"/>
-							<reference ref="635503948"/>
-						</object>
-						<reference key="parent" ref="126070858"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2024</int>
-						<reference key="object" ref="284115188"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="497462431"/>
-							<reference ref="145484441"/>
-							<reference ref="1029505942"/>
-							<reference ref="209519573"/>
-						</object>
-						<reference key="parent" ref="786994103"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2025</int>
-						<reference key="object" ref="497462431"/>
-						<reference key="parent" ref="284115188"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2026</int>
-						<reference key="object" ref="145484441"/>
-						<reference key="parent" ref="284115188"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2027</int>
-						<reference key="object" ref="1029505942"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="604570943"/>
-							<reference ref="915858279"/>
-						</object>
-						<reference key="parent" ref="284115188"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2028</int>
-						<reference key="object" ref="209519573"/>
-						<reference key="parent" ref="284115188"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2029</int>
-						<reference key="object" ref="604570943"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="404459918"/>
-						</object>
-						<reference key="parent" ref="1029505942"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2030</int>
-						<reference key="object" ref="915858279"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="367407167"/>
-						</object>
-						<reference key="parent" ref="1029505942"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2031</int>
-						<reference key="object" ref="367407167"/>
-						<reference key="parent" ref="915858279"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2032</int>
-						<reference key="object" ref="404459918"/>
-						<reference key="parent" ref="604570943"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2033</int>
-						<reference key="object" ref="642014996"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="865151679"/>
-						</object>
-						<reference key="parent" ref="786994103"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2034</int>
-						<reference key="object" ref="865151679"/>
-						<reference key="parent" ref="642014996"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2035</int>
-						<reference key="object" ref="635503948"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="713243405"/>
-						</object>
-						<reference key="parent" ref="786994103"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2036</int>
-						<reference key="object" ref="713243405"/>
-						<reference key="parent" ref="635503948"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2037</int>
-						<reference key="object" ref="224507096"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="378183006"/>
-						</object>
-						<reference key="parent" ref="786994103"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2038</int>
-						<reference key="object" ref="378183006"/>
-						<reference key="parent" ref="224507096"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2049</int>
-						<reference key="object" ref="713307252"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="98390178"/>
-						</object>
-						<reference key="parent" ref="748501112"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2050</int>
-						<reference key="object" ref="98390178"/>
-						<reference key="parent" ref="713307252"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2054</int>
-						<reference key="object" ref="343070533"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="237101992"/>
-						</object>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2055</int>
-						<reference key="object" ref="237101992"/>
-						<reference key="parent" ref="343070533"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2018</int>
-						<reference key="object" ref="239701474"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="855912809"/>
-						</object>
-						<reference key="parent" ref="184192603"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2019</int>
-						<reference key="object" ref="855912809"/>
-						<reference key="parent" ref="239701474"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2064</int>
-						<reference key="object" ref="585584503"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="626243774"/>
-						</object>
-						<reference key="parent" ref="739317740"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2065</int>
-						<reference key="object" ref="626243774"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="731215349"/>
-						</object>
-						<reference key="parent" ref="585584503"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2086</int>
-						<reference key="object" ref="731215349"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="745195065"/>
-							<reference ref="40613678"/>
-							<reference ref="763432112"/>
-							<reference ref="716552409"/>
-							<reference ref="912875055"/>
-							<reference ref="628152029"/>
-							<reference ref="719182296"/>
-							<reference ref="724013147"/>
-							<reference ref="338319881"/>
-							<reference ref="791385502"/>
-							<reference ref="564887063"/>
-							<reference ref="826525177"/>
-							<reference ref="607193498"/>
-							<reference ref="704926497"/>
-							<reference ref="724827539"/>
-							<reference ref="681255345"/>
-							<reference ref="719264885"/>
-						</object>
-						<reference key="parent" ref="626243774"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2066</int>
-						<reference key="object" ref="628152029"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="733262466"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2067</int>
-						<reference key="object" ref="733262466"/>
-						<reference key="parent" ref="628152029"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2073</int>
-						<reference key="object" ref="716552409"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="583586222"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2074</int>
-						<reference key="object" ref="583586222"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="786136385"/>
-						</object>
-						<reference key="parent" ref="716552409"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2075</int>
-						<reference key="object" ref="786136385"/>
-						<reference key="parent" ref="583586222"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2071</int>
-						<reference key="object" ref="763432112"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="449287045"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2072</int>
-						<reference key="object" ref="449287045"/>
-						<reference key="parent" ref="763432112"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2076</int>
-						<reference key="object" ref="40613678"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="131938172"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2079</int>
-						<reference key="object" ref="131938172"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="230053326"/>
-						</object>
-						<reference key="parent" ref="40613678"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2080</int>
-						<reference key="object" ref="230053326"/>
-						<reference key="parent" ref="131938172"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2077</int>
-						<reference key="object" ref="745195065"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="27217273"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2078</int>
-						<reference key="object" ref="27217273"/>
-						<reference key="parent" ref="745195065"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2087</int>
-						<reference key="object" ref="912875055"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="488289338"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2088</int>
-						<reference key="object" ref="488289338"/>
-						<reference key="parent" ref="912875055"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2100</int>
-						<reference key="object" ref="719182296"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="119237369"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2101</int>
-						<reference key="object" ref="119237369"/>
-						<reference key="parent" ref="719182296"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2102</int>
-						<reference key="object" ref="724013147"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="16767965"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2103</int>
-						<reference key="object" ref="16767965"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="830532180"/>
-						</object>
-						<reference key="parent" ref="724013147"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2108</int>
-						<reference key="object" ref="830532180"/>
-						<reference key="parent" ref="16767965"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2109</int>
-						<reference key="object" ref="338319881"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="180280161"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2113</int>
-						<reference key="object" ref="180280161"/>
-						<reference key="parent" ref="338319881"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2110</int>
-						<reference key="object" ref="791385502"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="670432292"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2111</int>
-						<reference key="object" ref="670432292"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="68665996"/>
-						</object>
-						<reference key="parent" ref="791385502"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2112</int>
-						<reference key="object" ref="68665996"/>
-						<reference key="parent" ref="670432292"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2115</int>
-						<reference key="object" ref="564887063"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="529108778"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2119</int>
-						<reference key="object" ref="529108778"/>
-						<reference key="parent" ref="564887063"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2116</int>
-						<reference key="object" ref="826525177"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="136428454"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2117</int>
-						<reference key="object" ref="136428454"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="746851166"/>
-						</object>
-						<reference key="parent" ref="826525177"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2118</int>
-						<reference key="object" ref="746851166"/>
-						<reference key="parent" ref="136428454"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2121</int>
-						<reference key="object" ref="607193498"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="178986221"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2122</int>
-						<reference key="object" ref="178986221"/>
-						<reference key="parent" ref="607193498"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2123</int>
-						<reference key="object" ref="704926497"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1028068410"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2124</int>
-						<reference key="object" ref="1028068410"/>
-						<reference key="parent" ref="704926497"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2133</int>
-						<reference key="object" ref="724827539"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="426972560"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2134</int>
-						<reference key="object" ref="681255345"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="60716744"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2135</int>
-						<reference key="object" ref="719264885"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="989093559"/>
-						</object>
-						<reference key="parent" ref="731215349"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2136</int>
-						<reference key="object" ref="989093559"/>
-						<reference key="parent" ref="719264885"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2137</int>
-						<reference key="object" ref="60716744"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="67110106"/>
-						</object>
-						<reference key="parent" ref="681255345"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2138</int>
-						<reference key="object" ref="67110106"/>
-						<reference key="parent" ref="60716744"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2139</int>
-						<reference key="object" ref="426972560"/>
-						<reference key="parent" ref="724827539"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">2150</int>
-						<reference key="object" ref="802059200"/>
-						<reference key="parent" ref="1020318718"/>
-					</object>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="flattenedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>-1.IBPluginDependency</string>
-					<string>-2.IBPluginDependency</string>
-					<string>-3.IBPluginDependency</string>
-					<string>101.IBPluginDependency</string>
-					<string>104.IBPluginDependency</string>
-					<string>105.IBPluginDependency</string>
-					<string>1103.IBPluginDependency</string>
-					<string>1107.IBPluginDependency</string>
-					<string>1111.IBPluginDependency</string>
-					<string>1122.IBPluginDependency</string>
-					<string>1199.IBPluginDependency</string>
-					<string>12.IBPluginDependency</string>
-					<string>12.IBWindowTemplateEditedContentRect</string>
-					<string>1203.IBPluginDependency</string>
-					<string>1204.IBPluginDependency</string>
-					<string>1207.IBPluginDependency</string>
-					<string>1209.IBPluginDependency</string>
-					<string>1280.IBPluginDependency</string>
-					<string>1422.IBPluginDependency</string>
-					<string>1426.IBPluginDependency</string>
-					<string>1715.IBPluginDependency</string>
-					<string>177.IBPluginDependency</string>
-					<string>178.IBPluginDependency</string>
-					<string>1787.IBPluginDependency</string>
-					<string>1789.IBPluginDependency</string>
-					<string>179.IBPluginDependency</string>
-					<string>180.IBPluginDependency</string>
-					<string>181.IBPluginDependency</string>
-					<string>182.IBPluginDependency</string>
-					<string>183.IBPluginDependency</string>
-					<string>184.IBPluginDependency</string>
-					<string>1845.IBPluginDependency</string>
-					<string>185.IBPluginDependency</string>
-					<string>186.IBPluginDependency</string>
-					<string>1902.IBPluginDependency</string>
-					<string>1960.IBAttributePlaceholdersKey</string>
-					<string>1960.IBPluginDependency</string>
-					<string>1964.IBPluginDependency</string>
-					<string>1965.IBPluginDependency</string>
-					<string>1966.IBPluginDependency</string>
-					<string>1967.IBPluginDependency</string>
-					<string>1968.IBPluginDependency</string>
-					<string>1969.IBPluginDependency</string>
-					<string>1970.IBPluginDependency</string>
-					<string>1971.IBPluginDependency</string>
-					<string>1972.IBPluginDependency</string>
-					<string>1973.IBPluginDependency</string>
-					<string>1974.IBPluginDependency</string>
-					<string>1975.IBPluginDependency</string>
-					<string>1976.IBPluginDependency</string>
-					<string>1977.IBPluginDependency</string>
-					<string>1978.IBPluginDependency</string>
-					<string>1979.IBPluginDependency</string>
-					<string>1980.IBPluginDependency</string>
-					<string>1981.IBPluginDependency</string>
-					<string>1982.IBPluginDependency</string>
-					<string>1983.IBPluginDependency</string>
-					<string>1984.IBPluginDependency</string>
-					<string>1985.IBPluginDependency</string>
-					<string>1986.IBPluginDependency</string>
-					<string>1987.IBPluginDependency</string>
-					<string>1988.IBPluginDependency</string>
-					<string>1989.IBPluginDependency</string>
-					<string>1990.IBPluginDependency</string>
-					<string>1991.IBPluginDependency</string>
-					<string>1992.IBAttributePlaceholdersKey</string>
-					<string>1992.IBPluginDependency</string>
-					<string>1993.IBPluginDependency</string>
-					<string>1994.IBPluginDependency</string>
-					<string>1995.IBPluginDependency</string>
-					<string>1998.IBPluginDependency</string>
-					<string>1999.IBPluginDependency</string>
-					<string>200.IBPluginDependency</string>
-					<string>2000.IBPluginDependency</string>
-					<string>2000.IBShouldRemoveOnLegacySave</string>
-					<string>2001.IBPluginDependency</string>
-					<string>2001.IBShouldRemoveOnLegacySave</string>
-					<string>2002.IBPluginDependency</string>
-					<string>2002.IBShouldRemoveOnLegacySave</string>
-					<string>2003.IBPluginDependency</string>
-					<string>2003.IBShouldRemoveOnLegacySave</string>
-					<string>2004.IBPluginDependency</string>
-					<string>2004.IBShouldRemoveOnLegacySave</string>
-					<string>2005.IBPluginDependency</string>
-					<string>2005.IBShouldRemoveOnLegacySave</string>
-					<string>2006.IBPluginDependency</string>
-					<string>2006.IBShouldRemoveOnLegacySave</string>
-					<string>2007.IBPluginDependency</string>
-					<string>2007.IBShouldRemoveOnLegacySave</string>
-					<string>2008.IBPluginDependency</string>
-					<string>2008.IBShouldRemoveOnLegacySave</string>
-					<string>2009.IBPluginDependency</string>
-					<string>2009.IBShouldRemoveOnLegacySave</string>
-					<string>2010.IBPluginDependency</string>
-					<string>2010.IBShouldRemoveOnLegacySave</string>
-					<string>2011.IBPluginDependency</string>
-					<string>2012.IBPluginDependency</string>
-					<string>2013.IBPluginDependency</string>
-					<string>2018.IBPluginDependency</string>
-					<string>2019.IBPluginDependency</string>
-					<string>2022.IBPluginDependency</string>
-					<string>2023.IBPluginDependency</string>
-					<string>2024.IBPluginDependency</string>
-					<string>2025.IBPluginDependency</string>
-					<string>2026.IBPluginDependency</string>
-					<string>2027.IBPluginDependency</string>
-					<string>2028.IBPluginDependency</string>
-					<string>2029.IBPluginDependency</string>
-					<string>2030.IBPluginDependency</string>
-					<string>2031.IBPluginDependency</string>
-					<string>2032.IBPluginDependency</string>
-					<string>2033.IBPluginDependency</string>
-					<string>2034.IBPluginDependency</string>
-					<string>2035.IBPluginDependency</string>
-					<string>2036.IBPluginDependency</string>
-					<string>2037.IBPluginDependency</string>
-					<string>2038.IBPluginDependency</string>
-					<string>2049.IBPluginDependency</string>
-					<string>2050.IBPluginDependency</string>
-					<string>2054.IBPluginDependency</string>
-					<string>2055.IBPluginDependency</string>
-					<string>2064.IBPluginDependency</string>
-					<string>2065.IBPluginDependency</string>
-					<string>2066.IBPluginDependency</string>
-					<string>2067.IBPluginDependency</string>
-					<string>207.IBPluginDependency</string>
-					<string>2071.IBPluginDependency</string>
-					<string>2072.IBPluginDependency</string>
-					<string>2073.IBAttributePlaceholdersKey</string>
-					<string>2073.IBPluginDependency</string>
-					<string>2074.IBPluginDependency</string>
-					<string>2075.IBNumberFormatterBehaviorMetadataKey</string>
-					<string>2075.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>2075.IBPluginDependency</string>
-					<string>2076.IBAttributePlaceholdersKey</string>
-					<string>2076.IBPluginDependency</string>
-					<string>2077.IBPluginDependency</string>
-					<string>2078.IBPluginDependency</string>
-					<string>2079.IBPluginDependency</string>
-					<string>208.IBPluginDependency</string>
-					<string>208.IBWindowTemplateEditedContentRect</string>
-					<string>2080.IBNumberFormatterBehaviorMetadataKey</string>
-					<string>2080.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>2080.IBPluginDependency</string>
-					<string>2086.IBPluginDependency</string>
-					<string>2087.IBAttributePlaceholdersKey</string>
-					<string>2087.IBPluginDependency</string>
-					<string>2088.IBPluginDependency</string>
-					<string>209.IBPluginDependency</string>
-					<string>2100.IBPluginDependency</string>
-					<string>2101.IBPluginDependency</string>
-					<string>2102.IBAttributePlaceholdersKey</string>
-					<string>2102.IBPluginDependency</string>
-					<string>2103.IBPluginDependency</string>
-					<string>2108.IBNumberFormatterBehaviorMetadataKey</string>
-					<string>2108.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>2108.IBPluginDependency</string>
-					<string>2109.IBPluginDependency</string>
-					<string>2110.IBAttributePlaceholdersKey</string>
-					<string>2110.IBPluginDependency</string>
-					<string>2111.IBPluginDependency</string>
-					<string>2112.IBNumberFormatterBehaviorMetadataKey</string>
-					<string>2112.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>2112.IBPluginDependency</string>
-					<string>2113.IBPluginDependency</string>
-					<string>2115.IBPluginDependency</string>
-					<string>2116.IBAttributePlaceholdersKey</string>
-					<string>2116.IBPluginDependency</string>
-					<string>2117.IBPluginDependency</string>
-					<string>2118.IBNumberFormatterBehaviorMetadataKey</string>
-					<string>2118.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>2118.IBPluginDependency</string>
-					<string>2119.IBPluginDependency</string>
-					<string>2121.IBPluginDependency</string>
-					<string>2122.IBPluginDependency</string>
-					<string>2123.IBPluginDependency</string>
-					<string>2124.IBPluginDependency</string>
-					<string>2133.IBPluginDependency</string>
-					<string>2134.IBAttributePlaceholdersKey</string>
-					<string>2134.IBPluginDependency</string>
-					<string>2135.IBPluginDependency</string>
-					<string>2136.IBPluginDependency</string>
-					<string>2137.IBPluginDependency</string>
-					<string>2138.IBNumberFormatterBehaviorMetadataKey</string>
-					<string>2138.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>2138.IBPluginDependency</string>
-					<string>2139.IBPluginDependency</string>
-					<string>214.IBPluginDependency</string>
-					<string>215.IBPluginDependency</string>
-					<string>2150.IBPluginDependency</string>
-					<string>216.IBPluginDependency</string>
-					<string>224.IBPluginDependency</string>
-					<string>265.IBPluginDependency</string>
-					<string>337.IBPluginDependency</string>
-					<string>338.IBPluginDependency</string>
-					<string>339.IBPluginDependency</string>
-					<string>340.IBPluginDependency</string>
-					<string>342.IBPluginDependency</string>
-					<string>344.IBAttributePlaceholdersKey</string>
-					<string>344.IBPluginDependency</string>
-					<string>345.IBPluginDependency</string>
-					<string>348.IBAttributePlaceholdersKey</string>
-					<string>348.IBPluginDependency</string>
-					<string>349.IBPluginDependency</string>
-					<string>352.IBPluginDependency</string>
-					<string>400.IBPluginDependency</string>
-					<string>402.IBPluginDependency</string>
-					<string>404.IBAttributePlaceholdersKey</string>
-					<string>404.IBPluginDependency</string>
-					<string>406.IBPluginDependency</string>
-					<string>408.IBAttributePlaceholdersKey</string>
-					<string>408.IBPluginDependency</string>
-					<string>411.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>411.IBPluginDependency</string>
-					<string>413.IBPluginDependency</string>
-					<string>415.IBAttributePlaceholdersKey</string>
-					<string>415.IBPluginDependency</string>
-					<string>417.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>417.IBPluginDependency</string>
-					<string>425.IBPluginDependency</string>
-					<string>475.IBPluginDependency</string>
-					<string>6.IBPluginDependency</string>
-					<string>740.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>740.IBPluginDependency</string>
-					<string>741.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>741.IBPluginDependency</string>
-					<string>742.IBNumberFormatterLocalizesFormatMetadataKey</string>
-					<string>742.IBPluginDependency</string>
-				</object>
-				<object class="NSArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{208, 366}, {595, 486}}</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="1064737768"/>
-							<string key="toolTip">Enable the verbose mode or afsd</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="533239018"/>
-							<string type="base64-UTF8" key="toolTip">RW5hYmxlIGxvdCBvZiBkZWJ1Z2dpbmcgaW5mb3JtYXRpb24gZnJvbSBhZnNkLiAgT25seSB1c2VmdWwg
-Zm9yIGRlYnVnZ2luZyBhcyBpdCBwcmludHMgYSBMT1Qgb2YgaW5mb3JtYXRpb24uCg</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="716552409"/>
-							<string key="toolTip">Interval to check whether tickets require renewal, in seconds (min. 3600)</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1040"/>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="40613678"/>
-							<string key="toolTip">Maximum remaining ticket lifetime before renewal is attempted, in seconds (min. 3600)</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{0, 510}, {715, 485}}</string>
-					<integer value="1040"/>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="912875055"/>
-							<string key="toolTip">Enable/Disable automatic Kerberos ticket renewal</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="724013147"/>
-							<string key="toolTip">Days</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1041"/>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="791385502"/>
-							<string key="toolTip">Hours</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1041"/>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="826525177"/>
-							<string key="toolTip">Minutes</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1041"/>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="681255345"/>
-							<string key="toolTip">Seconds</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<integer value="1041"/>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="761947305"/>
-							<string key="toolTip">DCache entry used for store information about cache chunk</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="23658009"/>
-							<string key="toolTip">Number of daemons to use</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="255735511"/>
-							<string key="toolTip">Specifies the number of memory structures to allocate for storing volume location information</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="850669444"/>
-							<string key="toolTip">The directory on which the AFS is to be mounted.</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="627718334"/>
-							<string key="toolTip">Specifies the number of memory structures to allocate for storing volume location information</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<boolean value="YES"/>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="unlocalizedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<reference key="dict.sortedKeys" ref="0"/>
-				<reference key="dict.values" ref="0"/>
-			</object>
-			<nil key="activeLocalization"/>
-			<object class="NSMutableDictionary" key="localizations">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<reference key="dict.sortedKeys" ref="0"/>
-				<reference key="dict.values" ref="0"/>
-			</object>
-			<nil key="sourceID"/>
-			<int key="maxID">2151</int>
-		</object>
-		<object class="IBClassDescriber" key="IBDocument.Classes">
-			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSCommanderPref</string>
-					<string key="superclassName">NSPreferencePane</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addLink:</string>
-							<string>addRemoveCell:</string>
-							<string>afsMenuActivationEvent:</string>
-							<string>afsStartupSwitchEvent:</string>
-							<string>aklogSwitchEvent:</string>
-							<string>credentialAtLoginTimeEvent:</string>
-							<string>enableDisableKrb5RenewCheck:</string>
-							<string>enableLink:</string>
-							<string>getNewToken:</string>
-							<string>info:</string>
-							<string>krb5KredentialAtLoginTimeEvent:</string>
-							<string>krb5RenewParamChange:</string>
-							<string>manageBackgrounderActivation:</string>
-							<string>refreshConfiguration:</string>
-							<string>removeLink:</string>
-							<string>saveCacheManagerParam:</string>
-							<string>saveConfiguration:</string>
-							<string>searchCellTextEvent:</string>
-							<string>showCellIP:</string>
-							<string>startStopAfs:</string>
-							<string>tableDoubleAction:</string>
-							<string>tableViewLinkPerformClick:</string>
-							<string>unlog:</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="actionInfosByName">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addLink:</string>
-							<string>addRemoveCell:</string>
-							<string>afsMenuActivationEvent:</string>
-							<string>afsStartupSwitchEvent:</string>
-							<string>aklogSwitchEvent:</string>
-							<string>credentialAtLoginTimeEvent:</string>
-							<string>enableDisableKrb5RenewCheck:</string>
-							<string>enableLink:</string>
-							<string>getNewToken:</string>
-							<string>info:</string>
-							<string>krb5KredentialAtLoginTimeEvent:</string>
-							<string>krb5RenewParamChange:</string>
-							<string>manageBackgrounderActivation:</string>
-							<string>refreshConfiguration:</string>
-							<string>removeLink:</string>
-							<string>saveCacheManagerParam:</string>
-							<string>saveConfiguration:</string>
-							<string>searchCellTextEvent:</string>
-							<string>showCellIP:</string>
-							<string>startStopAfs:</string>
-							<string>tableDoubleAction:</string>
-							<string>tableViewLinkPerformClick:</string>
-							<string>unlog:</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<object class="IBActionInfo">
-								<string key="name">addLink:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">addRemoveCell:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">afsMenuActivationEvent:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">afsStartupSwitchEvent:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">aklogSwitchEvent:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">credentialAtLoginTimeEvent:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">enableDisableKrb5RenewCheck:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">enableLink:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">getNewToken:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">info:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">krb5KredentialAtLoginTimeEvent:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">krb5RenewParamChange:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">manageBackgrounderActivation:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">refreshConfiguration:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">removeLink:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">saveCacheManagerParam:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">saveConfiguration:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">searchCellTextEvent:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">showCellIP:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">startStopAfs:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">tableDoubleAction:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">tableViewLinkPerformClick:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">unlog:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addCellButton</string>
-							<string>afsCommanderView</string>
-							<string>afsDB</string>
-							<string>afsDefaultCellLabel</string>
-							<string>afsMenucheckBox</string>
-							<string>afsRootMountPoint</string>
-							<string>afsVersionLabel</string>
-							<string>aklogCredentialAtLoginTime</string>
-							<string>authView</string>
-							<string>backgrounderActivationCheck</string>
-							<string>buttonAddLink</string>
-							<string>buttonRemoveLink</string>
-							<string>cacheDimension</string>
-							<string>cellIpButton</string>
-							<string>cellList</string>
-							<string>checkButtonAfsAtBootTime</string>
-							<string>checkEnableLink</string>
-							<string>dCacheDim</string>
-							<string>daemonNumber</string>
-							<string>dynRoot</string>
-							<string>groupsBox</string>
-							<string>installKRB5AuthAtLoginButton</string>
-							<string>lynkCreationController</string>
-							<string>nVolEntry</string>
-							<string>nsButtonEnableDisableKrb5RenewCheck</string>
-							<string>nsStepperKrb5RenewTimeD</string>
-							<string>nsStepperKrb5RenewTimeH</string>
-							<string>nsStepperKrb5RenewTimeM</string>
-							<string>nsStepperKrb5RenewTimeS</string>
-							<string>nsTextFieldKrb5RenewCheckIntervall</string>
-							<string>nsTextFieldKrb5RenewTimeD</string>
-							<string>nsTextFieldKrb5RenewTimeH</string>
-							<string>nsTextFieldKrb5RenewTimeM</string>
-							<string>nsTextFieldKrb5RenewTimeS</string>
-							<string>nsTextFieldKrb5SecToExpireDateForRenew</string>
-							<string>removeCellButton</string>
-							<string>saveConfigurationButton</string>
-							<string>startStopButton</string>
-							<string>statCacheEntry</string>
-							<string>tableViewLink</string>
-							<string>textFieldDevInfoLabel</string>
-							<string>textSearchField</string>
-							<string>tokensButton</string>
-							<string>tokensTable</string>
-							<string>unlogButton</string>
-							<string>useAklogCheck</string>
-							<string>verbose</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSControl</string>
-							<string>NSView</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>NSControl</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>SFAuthorizationView</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>NSControl</string>
-							<string>NSTableView</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSBox</string>
-							<string>NSButton</string>
-							<string>LynkCreationController</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSStepper</string>
-							<string>NSStepper</string>
-							<string>NSStepper</string>
-							<string>NSStepper</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSControl</string>
-							<string>NSControl</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>NSTableView</string>
-							<string>NSTextField</string>
-							<string>NSSearchField</string>
-							<string>NSButton</string>
-							<string>NSTableView</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addCellButton</string>
-							<string>afsCommanderView</string>
-							<string>afsDB</string>
-							<string>afsDefaultCellLabel</string>
-							<string>afsMenucheckBox</string>
-							<string>afsRootMountPoint</string>
-							<string>afsVersionLabel</string>
-							<string>aklogCredentialAtLoginTime</string>
-							<string>authView</string>
-							<string>backgrounderActivationCheck</string>
-							<string>buttonAddLink</string>
-							<string>buttonRemoveLink</string>
-							<string>cacheDimension</string>
-							<string>cellIpButton</string>
-							<string>cellList</string>
-							<string>checkButtonAfsAtBootTime</string>
-							<string>checkEnableLink</string>
-							<string>dCacheDim</string>
-							<string>daemonNumber</string>
-							<string>dynRoot</string>
-							<string>groupsBox</string>
-							<string>installKRB5AuthAtLoginButton</string>
-							<string>lynkCreationController</string>
-							<string>nVolEntry</string>
-							<string>nsButtonEnableDisableKrb5RenewCheck</string>
-							<string>nsStepperKrb5RenewTimeD</string>
-							<string>nsStepperKrb5RenewTimeH</string>
-							<string>nsStepperKrb5RenewTimeM</string>
-							<string>nsStepperKrb5RenewTimeS</string>
-							<string>nsTextFieldKrb5RenewCheckIntervall</string>
-							<string>nsTextFieldKrb5RenewTimeD</string>
-							<string>nsTextFieldKrb5RenewTimeH</string>
-							<string>nsTextFieldKrb5RenewTimeM</string>
-							<string>nsTextFieldKrb5RenewTimeS</string>
-							<string>nsTextFieldKrb5SecToExpireDateForRenew</string>
-							<string>removeCellButton</string>
-							<string>saveConfigurationButton</string>
-							<string>startStopButton</string>
-							<string>statCacheEntry</string>
-							<string>tableViewLink</string>
-							<string>textFieldDevInfoLabel</string>
-							<string>textSearchField</string>
-							<string>tokensButton</string>
-							<string>tokensTable</string>
-							<string>unlogButton</string>
-							<string>useAklogCheck</string>
-							<string>verbose</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<object class="IBToOneOutletInfo">
-								<string key="name">addCellButton</string>
-								<string key="candidateClassName">NSControl</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">afsCommanderView</string>
-								<string key="candidateClassName">NSView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">afsDB</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">afsDefaultCellLabel</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">afsMenucheckBox</string>
-								<string key="candidateClassName">NSControl</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">afsRootMountPoint</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">afsVersionLabel</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">aklogCredentialAtLoginTime</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">authView</string>
-								<string key="candidateClassName">SFAuthorizationView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">backgrounderActivationCheck</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">buttonAddLink</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">buttonRemoveLink</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">cacheDimension</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">cellIpButton</string>
-								<string key="candidateClassName">NSControl</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">cellList</string>
-								<string key="candidateClassName">NSTableView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">checkButtonAfsAtBootTime</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">checkEnableLink</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">dCacheDim</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">daemonNumber</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">dynRoot</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">groupsBox</string>
-								<string key="candidateClassName">NSBox</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">installKRB5AuthAtLoginButton</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">lynkCreationController</string>
-								<string key="candidateClassName">LynkCreationController</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nVolEntry</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsButtonEnableDisableKrb5RenewCheck</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsStepperKrb5RenewTimeD</string>
-								<string key="candidateClassName">NSStepper</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsStepperKrb5RenewTimeH</string>
-								<string key="candidateClassName">NSStepper</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsStepperKrb5RenewTimeM</string>
-								<string key="candidateClassName">NSStepper</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsStepperKrb5RenewTimeS</string>
-								<string key="candidateClassName">NSStepper</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsTextFieldKrb5RenewCheckIntervall</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsTextFieldKrb5RenewTimeD</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsTextFieldKrb5RenewTimeH</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsTextFieldKrb5RenewTimeM</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsTextFieldKrb5RenewTimeS</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">nsTextFieldKrb5SecToExpireDateForRenew</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">removeCellButton</string>
-								<string key="candidateClassName">NSControl</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">saveConfigurationButton</string>
-								<string key="candidateClassName">NSControl</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">startStopButton</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">statCacheEntry</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">tableViewLink</string>
-								<string key="candidateClassName">NSTableView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">textFieldDevInfoLabel</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">textSearchField</string>
-								<string key="candidateClassName">NSSearchField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">tokensButton</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">tokensTable</string>
-								<string key="candidateClassName">NSTableView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">unlogButton</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">useAklogCheck</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">verbose</string>
-								<string key="candidateClassName">NSButton</string>
-							</object>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">./Classes/AFSCommanderPref.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">InfoController</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<string key="NS.key.0">closePanel:</string>
-						<string key="NS.object.0">id</string>
-					</object>
-					<object class="NSMutableDictionary" key="actionInfosByName">
-						<string key="NS.key.0">closePanel:</string>
-						<object class="IBActionInfo" key="NS.object.0">
-							<string key="name">closePanel:</string>
-							<string key="candidateClassName">id</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">./Classes/InfoController.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">LynkCreationController</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>cancell:</string>
-							<string>save:</string>
-							<string>selectLinkDest:</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="actionInfosByName">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>cancell:</string>
-							<string>save:</string>
-							<string>selectLinkDest:</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<object class="IBActionInfo">
-								<string key="name">cancell:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">save:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-							<object class="IBActionInfo">
-								<string key="name">selectLinkDest:</string>
-								<string key="candidateClassName">id</string>
-							</object>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>lynkCreationSheet</string>
-							<string>textFieldLinkDestPath</string>
-							<string>textfieldLinkName</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSPanel</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>lynkCreationSheet</string>
-							<string>textFieldLinkDestPath</string>
-							<string>textfieldLinkName</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<object class="IBToOneOutletInfo">
-								<string key="name">lynkCreationSheet</string>
-								<string key="candidateClassName">NSPanel</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">textFieldLinkDestPath</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">textfieldLinkName</string>
-								<string key="candidateClassName">NSTextField</string>
-							</object>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">./Classes/LynkCreationController.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">NSPreferencePane</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>_firstKeyView</string>
-							<string>_initialKeyView</string>
-							<string>_lastKeyView</string>
-							<string>_window</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSView</string>
-							<string>NSView</string>
-							<string>NSView</string>
-							<string>NSWindow</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>_firstKeyView</string>
-							<string>_initialKeyView</string>
-							<string>_lastKeyView</string>
-							<string>_window</string>
-						</object>
-						<object class="NSArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<object class="IBToOneOutletInfo">
-								<string key="name">_firstKeyView</string>
-								<string key="candidateClassName">NSView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">_initialKeyView</string>
-								<string key="candidateClassName">NSView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">_lastKeyView</string>
-								<string key="candidateClassName">NSView</string>
-							</object>
-							<object class="IBToOneOutletInfo">
-								<string key="name">_window</string>
-								<string key="candidateClassName">NSWindow</string>
-							</object>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">./Classes/NSPreferencePane.h</string>
-					</object>
-				</object>
-			</object>
-		</object>
-		<int key="IBDocument.localizationMode">0</int>
-		<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
-		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
-			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
-			<integer value="1050" key="NS.object.0"/>
-		</object>
-		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
-			<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
-			<integer value="3000" key="NS.object.0"/>
-		</object>
-		<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
-		<int key="IBDocument.defaultPropertyAccessControl">3</int>
-		<object class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
-			<string key="NS.key.0">NSSwitch</string>
-			<string key="NS.object.0">{15, 15}</string>
-		</object>
-	</data>
-</archive>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+	<deployment version="101400" identifier="macosx"/>
+	<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
+	<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+	<customObject id="-2" userLabel="File's Owner" customClass="AFSCommanderPref">
+	    <connections>
+		<outlet property="_window" destination="12" id="100"/>
+		<outlet property="addCellButton" destination="183" id="190"/>
+		<outlet property="afsCommanderView" destination="6" id="303"/>
+		<outlet property="afsDB" destination="1902" id="1904"/>
+		<outlet property="afsDefaultCellLabel" destination="1845" id="1847"/>
+		<outlet property="afsMenucheckBox" destination="1107" id="1110"/>
+		<outlet property="afsRootMountPoint" destination="408" id="421"/>
+		<outlet property="afsVersionLabel" destination="1715" id="1717"/>
+		<outlet property="aklogCredentialAtLoginTime" destination="2011" id="2014"/>
+		<outlet property="authView" destination="2150" id="2151"/>
+		<outlet property="backgrounderActivationCheck" destination="2054" id="2056"/>
+		<outlet property="buttonAddLink" destination="2033" id="2045"/>
+		<outlet property="buttonRemoveLink" destination="2035" id="2063"/>
+		<outlet property="cacheDimension" destination="415" id="423"/>
+		<outlet property="cellIpButton" destination="185" id="188"/>
+		<outlet property="cellList" destination="180" id="187"/>
+		<outlet property="checkButtonAfsAtBootTime" destination="2049" id="2051"/>
+		<outlet property="checkEnableLink" destination="2037" id="2042"/>
+		<outlet property="dCacheDim" destination="344" id="419"/>
+		<outlet property="daemonNumber" destination="348" id="420"/>
+		<outlet property="dynRoot" destination="400" id="424"/>
+		<outlet property="infoController" destination="224" id="225"/>
+		<outlet property="infoSheet" destination="208" id="217"/>
+		<outlet property="installKRB5AuthAtLoginButton" destination="2018" id="2020"/>
+		<outlet property="nVolEntry" destination="404" id="422"/>
+		<outlet property="nsButtonEnableDisableKrb5RenewCheck" destination="2087" id="2089"/>
+		<outlet property="nsStepperKrb5RenewTimeD" destination="2100" id="2146"/>
+		<outlet property="nsStepperKrb5RenewTimeH" destination="2109" id="2147"/>
+		<outlet property="nsStepperKrb5RenewTimeM" destination="2115" id="2148"/>
+		<outlet property="nsStepperKrb5RenewTimeS" destination="2133" id="2149"/>
+		<outlet property="nsTextFieldKrb5RenewCheckIntervall" destination="2073" id="2081"/>
+		<outlet property="nsTextFieldKrb5RenewTimeD" destination="2102" id="2142"/>
+		<outlet property="nsTextFieldKrb5RenewTimeH" destination="2110" id="2143"/>
+		<outlet property="nsTextFieldKrb5RenewTimeM" destination="2116" id="2144"/>
+		<outlet property="nsTextFieldKrb5RenewTimeS" destination="2134" id="2145"/>
+		<outlet property="nsTextFieldKrb5SecToExpireDateForRenew" destination="2076" id="2083"/>
+		<outlet property="removeCellButton" destination="184" id="189"/>
+		<outlet property="startStopButton" destination="1103" id="1106"/>
+		<outlet property="statCacheEntry" destination="342" id="418"/>
+		<outlet property="tableViewLink" destination="2027" id="2059"/>
+		<outlet property="textFieldDevInfoLabel" destination="207" id="2053"/>
+		<outlet property="textSearchField" destination="186" id="812"/>
+		<outlet property="tokensButton" destination="1209" id="1645"/>
+		<outlet property="tokensTable" destination="1203" id="1206"/>
+		<outlet property="unlogButton" destination="1207" id="1644"/>
+		<outlet property="useAklogCheck" destination="1280" id="1282"/>
+		<outlet property="verbose" destination="1960" id="1962"/>
+	    </connections>
+	</customObject>
+	<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+	<customObject id="-3" userLabel="Application"/>
+	<window title="&lt;&lt; do not localize &gt;&gt;" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" deferred="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="12" userLabel="PrefPane">
+	    <windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
+	    <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+	    <rect key="contentRect" x="423" y="652" width="595" height="486"/>
+	    <rect key="screenRect" x="0.0" y="0.0" width="1024" height="745"/>
+	    <view key="contentView" id="6">
+		<rect key="frame" x="0.0" y="0.0" width="595" height="486"/>
+		<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+		<subviews>
+		    <textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="300" translatesAutoresizingMaskIntoConstraints="NO" id="207">
+			<rect key="frame" x="17" y="1" width="304" height="14"/>
+			<autoresizingMask key="autoresizingMask"/>
+			<textFieldCell key="cell" sendsActionOnEndEditing="YES" id="1993">
+			    <font key="font" metaFont="miniSystem"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <box fixedFrame="YES" borderType="line" title="Box" titlePosition="noTitle" translatesAutoresizingMaskIntoConstraints="NO" id="1122">
+			<rect key="frame" x="17" y="423" width="564" height="45"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+			<view key="contentView" ambiguous="YES" id="MhF-zw-jIs">
+			    <rect key="frame" x="3" y="3" width="558" height="39"/>
+			    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+			    <subviews>
+				<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1103">
+				    <rect key="frame" x="13" y="3" width="109" height="28"/>
+				    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+				    <buttonCell key="cell" type="push" title="On" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="1994">
+					<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+					<font key="font" metaFont="controlContent" size="11"/>
+				    </buttonCell>
+				    <connections>
+					<action selector="startStopAfs:" target="-2" id="1105"/>
+				    </connections>
+				</button>
+				<button horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1111">
+				    <rect key="frame" x="522" y="5" width="21" height="23"/>
+				    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+				    <buttonCell key="cell" type="help" bezelStyle="helpButton" alignment="center" state="on" borderStyle="border" inset="2" id="1995">
+					<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+					<font key="font" metaFont="message"/>
+				    </buttonCell>
+				    <connections>
+					<action selector="info:" target="-2" id="1113"/>
+				    </connections>
+				</button>
+				<button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2049">
+				    <rect key="frame" x="138" y="9" width="117" height="18"/>
+				    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+				    <buttonCell key="cell" type="check" title="Start AFS at boot" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" imageScaling="proportionallyDown" inset="2" id="2050">
+					<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+					<font key="font" metaFont="controlContent" size="11"/>
+				    </buttonCell>
+				    <connections>
+					<action selector="afsStartupSwitchEvent:" target="-2" id="2052"/>
+				    </connections>
+				</button>
+			    </subviews>
+			</view>
+		    </box>
+		    <tabView fixedFrame="YES" controlSize="small" translatesAutoresizingMaskIntoConstraints="NO" id="101">
+			<rect key="frame" x="13" y="15" width="572" height="401"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+			<tabViewItems>
+			    <tabViewItem label="Tokens" identifier="1" id="104">
+				<view key="view" ambiguous="YES" id="105">
+				    <rect key="frame" x="10" y="25" width="552" height="363"/>
+				    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+				    <subviews>
+					<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="14" horizontalPageScroll="10" verticalLineScroll="14" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="1199">
+					    <rect key="frame" x="17" y="199" width="518" height="158"/>
+					    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+					    <clipView key="contentView" ambiguous="YES" id="WV5-0c-5O3">
+						<rect key="frame" x="1" y="0.0" width="516" height="157"/>
+						<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+						<subviews>
+						    <tableView verticalHuggingPriority="750" tag="1" allowsExpansionToolTips="YES" columnAutoresizingStyle="firstColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" multipleSelection="NO" autosaveColumns="NO" rowHeight="12" headerView="2005" id="1203">
+							<rect key="frame" x="0.0" y="0.0" width="516" height="132"/>
+							<autoresizingMask key="autoresizingMask"/>
+							<size key="intercellSpacing" width="3" height="2"/>
+							<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+							<tableViewGridLines key="gridStyleMask" horizontal="YES"/>
+							<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+							<tableColumns>
+							    <tableColumn editable="NO" width="513" minWidth="41.0966796875" maxWidth="1000" id="1204">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Token">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
+								</tableHeaderCell>
+								<textFieldCell key="dataCell" controlSize="mini" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="2000">
+								    <font key="font" metaFont="miniSystem"/>
+								    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+								</textFieldCell>
+								<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+							    </tableColumn>
+							</tableColumns>
+						    </tableView>
+						</subviews>
+					    </clipView>
+					    <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" controlSize="small" horizontal="YES" id="2004">
+						<rect key="frame" x="1" y="97" width="505" height="11"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </scroller>
+					    <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" controlSize="small" horizontal="NO" id="2003">
+						<rect key="frame" x="494" y="17" width="11" height="80"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </scroller>
+					    <tableHeaderView key="headerView" id="2005">
+						<rect key="frame" x="0.0" y="0.0" width="516" height="25"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </tableHeaderView>
+					</scrollView>
+					<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1207">
+					    <rect key="frame" x="329" y="164" width="80" height="28"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+					    <buttonCell key="cell" type="push" title="Unlog" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="1965">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="unlog:" target="-2" id="1211"/>
+					    </connections>
+					</button>
+					<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1209">
+					    <rect key="frame" x="407" y="164" width="133" height="28"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+					    <buttonCell key="cell" type="push" title="Get new Token" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="1966">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="getNewToken:" target="-2" id="1212"/>
+					    </connections>
+					</button>
+					<button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1107">
+					    <rect key="frame" x="14" y="172" width="86" height="18"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+					    <buttonCell key="cell" type="check" title="AFS Menu" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" inset="2" id="1964">
+						<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="afsMenuActivationEvent:" target="-2" id="1109"/>
+					    </connections>
+					</button>
+					<box autoresizesSubviews="NO" fixedFrame="YES" borderType="line" title="Kerberos Setting" translatesAutoresizingMaskIntoConstraints="NO" id="2013">
+					    <rect key="frame" x="113" y="97" width="195" height="94"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+					    <view key="contentView" id="qVs-iS-BQt">
+						<rect key="frame" x="3" y="3" width="189" height="76"/>
+						<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+						<subviews>
+						    <button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1280">
+							<rect key="frame" x="5" y="28" width="75" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<buttonCell key="cell" type="check" title="Use aklog" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" imageScaling="proportionallyDown" inset="2" id="1967">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							</buttonCell>
+							<connections>
+							    <action selector="aklogSwitchEvent:" target="-2" id="1353"/>
+							</connections>
+						    </button>
+						    <button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2011">
+							<rect key="frame" x="5" y="8" width="167" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<buttonCell key="cell" type="check" title="get credential at login time" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" imageScaling="proportionallyDown" inset="2" id="2012">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							</buttonCell>
+							<connections>
+							    <action selector="credentialAtLoginTimeEvent:" target="-2" id="2015"/>
+							</connections>
+						    </button>
+						    <button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2018">
+							<rect key="frame" x="5" y="48" width="170" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<buttonCell key="cell" type="check" title="Get Krb5 credential at login" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" imageScaling="proportionallyDown" inset="2" id="2019">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							    <connections>
+								<action selector="krb5KredentialAtLoginTimeEvent:" target="-2" id="2021"/>
+							    </connections>
+							</buttonCell>
+						    </button>
+						</subviews>
+					    </view>
+					</box>
+					<button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2054">
+					    <rect key="frame" x="14" y="152" width="96" height="18"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+					    <buttonCell key="cell" type="check" title="Backgrounder" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" imageScaling="proportionallyDown" inset="2" id="2055">
+						<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="manageBackgrounderActivation:" target="-2" id="2057"/>
+					    </connections>
+					</button>
+					<customView fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2150" customClass="SFAuthorizationView">
+					    <rect key="frame" x="3" y="3" width="400" height="40"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+					</customView>
+				    </subviews>
+				</view>
+			    </tabViewItem>
+			    <tabViewItem label="CellServDB Editor" identifier="2" id="177">
+				<view key="view" id="178">
+				    <rect key="frame" x="10" y="25" width="552" height="363"/>
+				    <autoresizingMask key="autoresizingMask"/>
+				    <subviews>
+					<searchField verticalHuggingPriority="750" fixedFrame="YES" textCompletion="NO" translatesAutoresizingMaskIntoConstraints="NO" id="186">
+					    <rect key="frame" x="337" y="335" width="198" height="19"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+					    <searchFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" borderStyle="bezel" alignment="center" placeholderString="CellServDB Search" bezelStyle="round" sendsSearchStringImmediately="YES" recentsAutosaveName="cell_searc" id="1971">
+						<font key="font" metaFont="message" size="11"/>
+						<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+						<color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+					    </searchFieldCell>
+					    <connections>
+						<action selector="searchCellTextEvent:" target="-2" id="817"/>
+						<outlet property="delegate" destination="-2" id="886"/>
+					    </connections>
+					</searchField>
+					<textField verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" preferredMaxLayoutWidth="72" translatesAutoresizingMaskIntoConstraints="NO" id="265">
+					    <rect key="frame" x="17" y="335" width="76" height="17"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+					    <textFieldCell key="cell" sendsActionOnEndEditing="YES" title="Default Cell:" id="1973">
+						<font key="font" metaFont="message" size="11"/>
+						<color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+						<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+					    </textFieldCell>
+					</textField>
+					<button verticalHuggingPriority="750" fixedFrame="YES" tag="1" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="183">
+					    <rect key="frame" x="17" y="7" width="30" height="25"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="roundTextured" title="+" bezelStyle="texturedRounded" alignment="center" controlSize="small" borderStyle="border" tag="1" inset="2" id="1968">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="addRemoveCell:" target="-2" id="191"/>
+					    </connections>
+					</button>
+					<button verticalHuggingPriority="750" fixedFrame="YES" tag="2" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="184">
+					    <rect key="frame" x="50" y="7" width="30" height="25"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="roundTextured" title="-" bezelStyle="texturedRounded" alignment="center" controlSize="small" enabled="NO" borderStyle="border" tag="2" inset="2" id="1969">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="addRemoveCell:" target="-2" id="192"/>
+					    </connections>
+					</button>
+					<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="185">
+					    <rect key="frame" x="82" y="7" width="72" height="25"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="roundTextured" title="Modify" bezelStyle="texturedRounded" alignment="center" controlSize="small" enabled="NO" borderStyle="border" inset="2" id="1970">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="showCellIP:" target="-2" id="193"/>
+					    </connections>
+					</button>
+					<button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="200">
+					    <rect key="frame" x="387" y="4" width="151" height="28"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="push" title="Save Cell Configuration" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="1972">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="saveConfiguration:" target="-2" id="202"/>
+					    </connections>
+					</button>
+					<scrollView fixedFrame="YES" autohidesScrollers="YES" horizontalLineScroll="17" horizontalPageScroll="10" verticalLineScroll="17" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="179">
+					    <rect key="frame" x="15" y="41" width="518" height="289"/>
+					    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+					    <clipView key="contentView" ambiguous="YES" id="XVU-qK-znO">
+						<rect key="frame" x="1" y="25" width="516" height="263"/>
+						<autoresizingMask key="autoresizingMask"/>
+						<subviews>
+						    <tableView verticalHuggingPriority="750" tag="2" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnReordering="NO" autosaveColumns="NO" rowHeight="15" headerView="2008" id="180">
+							<rect key="frame" x="0.0" y="0.0" width="516" height="263"/>
+							<autoresizingMask key="autoresizingMask"/>
+							<size key="intercellSpacing" width="3" height="2"/>
+							<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+							<tableViewGridLines key="gridStyleMask" vertical="YES"/>
+							<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+							<tableColumns>
+							    <tableColumn identifier="0" width="47" minWidth="10" maxWidth="3.4028230607370965e+38" id="1787">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Default">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
+								</tableHeaderCell>
+								<buttonCell key="dataCell" type="check" bezelStyle="regularSquare" imagePosition="only" alignment="center" controlSize="small" imageScaling="proportionallyDown" inset="2" id="1789">
+								    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+								    <font key="font" metaFont="message" size="11"/>
+								</buttonCell>
+								<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+							    </tableColumn>
+							    <tableColumn identifier="1" width="47" minWidth="10" maxWidth="3.4028230607370965e+38" id="1422">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Tokens">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
+								</tableHeaderCell>
+								<buttonCell key="dataCell" type="check" title="Check" bezelStyle="regularSquare" imagePosition="only" alignment="center" controlSize="small" imageScaling="proportionallyDown" inset="2" id="1426">
+								    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+								    <font key="font" metaFont="message" size="11"/>
+								</buttonCell>
+								<tableColumnResizingMask key="resizingMask" userResizable="YES"/>
+							    </tableColumn>
+							    <tableColumn identifier="2" editable="NO" width="167" minWidth="40" maxWidth="1000" id="182">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Name">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
+								</tableHeaderCell>
+								<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="2002">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+								</textFieldCell>
+								<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+							    </tableColumn>
+							    <tableColumn identifier="3" editable="NO" width="243" minWidth="65.0908203125" maxWidth="1000" id="181">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Description">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="headerColor" catalog="System" colorSpace="catalog"/>
+								</tableHeaderCell>
+								<textFieldCell key="dataCell" controlSize="small" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="2001">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+								</textFieldCell>
+								<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+							    </tableColumn>
+							</tableColumns>
+						    </tableView>
+						</subviews>
+					    </clipView>
+					    <scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" controlSize="small" horizontal="YES" id="2007">
+						<rect key="frame" x="1" y="215" width="516" height="11"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </scroller>
+					    <scroller key="verticalScroller" hidden="YES" verticalHuggingPriority="750" controlSize="small" horizontal="NO" id="2006">
+						<rect key="frame" x="506" y="17" width="11" height="198"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </scroller>
+					    <tableHeaderView key="headerView" id="2008">
+						<rect key="frame" x="0.0" y="0.0" width="516" height="25"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </tableHeaderView>
+					</scrollView>
+					<textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1845">
+					    <rect key="frame" x="95" y="338" width="237" height="14"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+					    <textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Default Cell" id="1974">
+						<font key="font" metaFont="message" size="11"/>
+						<color key="textColor" red="0.0" green="0.1098518372" blue="1" alpha="1" colorSpace="calibratedRGB"/>
+						<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+					    </textFieldCell>
+					</textField>
+				    </subviews>
+				</view>
+			    </tabViewItem>
+			    <tabViewItem label="Parameter" identifier="3" id="337">
+				<view key="view" id="338">
+				    <rect key="frame" x="10" y="25" width="552" height="363"/>
+				    <autoresizingMask key="autoresizingMask"/>
+				    <subviews>
+					<box fixedFrame="YES" borderType="line" title="Cache Manager" translatesAutoresizingMaskIntoConstraints="NO" id="339">
+					    <rect key="frame" x="14" y="202" width="524" height="155"/>
+					    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+					    <view key="contentView" id="COg-Rj-y4V">
+						<rect key="frame" x="3" y="3" width="518" height="137"/>
+						<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+						<subviews>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="340">
+							<rect key="frame" x="18" y="108" width="114" height="14"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="NÂ° stat chache entry" id="1975">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="342">
+							<rect key="frame" x="140" y="103" width="55" height="19"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="0000" drawsBackground="YES" id="1976">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="4" maximumIntegerDigits="2000000000" id="741">
+								<nil key="negativeInfinitySymbol"/>
+								<nil key="positiveInfinitySymbol"/>
+								<real key="minimum" value="1000"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="DCache entry used for store information about cache chunk" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="344">
+							<rect key="frame" x="140" y="77" width="55" height="19"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="0" drawsBackground="YES" id="1977">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="3" maximumIntegerDigits="2000000000" id="742">
+								<nil key="negativeInfinitySymbol"/>
+								<nil key="positiveInfinitySymbol"/>
+								<real key="minimum" value="100"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="345">
+							<rect key="frame" x="83" y="79" width="49" height="14"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="DCache" id="1978">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="Number of daemons to use" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="348">
+							<rect key="frame" x="140" y="48" width="25" height="19"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="0" drawsBackground="YES" id="1979">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="2" id="417">
+								<nil key="negativeInfinitySymbol"/>
+								<nil key="positiveInfinitySymbol"/>
+								<integer key="minimum" value="1"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="349">
+							<rect key="frame" x="47" y="50" width="85" height="14"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="NÂ° of daemons" id="1980">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="352">
+							<rect key="frame" x="405" y="105" width="93" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<buttonCell key="cell" type="check" title="Encryption" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" enabled="NO" inset="2" id="1981">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							</buttonCell>
+						    </button>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="402">
+							<rect key="frame" x="205" y="108" width="103" height="14"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="NÂ° Volume entries" id="1983">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="Specifies the number of memory structures to allocate for storing volume location information" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="404">
+							<rect key="frame" x="307" y="105" width="37" height="19"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" borderStyle="bezel" title="00" drawsBackground="YES" id="1984">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" numberStyle="decimal" allowsFloats="NO" usesGroupingSeparator="NO" groupingSize="0" minimumIntegerDigits="2" maximumIntegerDigits="3" id="411">
+								<nil key="negativeInfinitySymbol"/>
+								<nil key="positiveInfinitySymbol"/>
+								<real key="minimum" value="10"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="406">
+							<rect key="frame" x="46" y="19" width="86" height="14"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Afs Root Mount" id="1985">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="The directory on which the AFS is to be mounted." verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="408">
+							<rect key="frame" x="140" y="17" width="55" height="19"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="/" drawsBackground="YES" id="1986">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="413">
+							<rect key="frame" x="210" y="78" width="97" height="14"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Cache Dimension" id="1987">
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="Specifies the number of memory structures to allocate for storing volume location information" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="415">
+							<rect key="frame" x="307" y="76" width="52" height="19"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" title="00000" drawsBackground="YES" id="1988">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" positiveFormat="#" numberStyle="decimal" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="5" maximumIntegerDigits="2000000000" id="740">
+								<nil key="negativeInfinitySymbol"/>
+								<nil key="positiveInfinitySymbol"/>
+								<real key="minimum" value="10000"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message" size="11"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="425">
+							<rect key="frame" x="392" y="14" width="104" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<buttonCell key="cell" type="roundRect" title="Save Param" bezelStyle="roundedRect" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="1989">
+							    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							</buttonCell>
+							<connections>
+							    <action selector="saveCacheManagerParam:" target="-2" id="474"/>
+							</connections>
+						    </button>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="475">
+							<rect key="frame" x="380" y="3" width="126" height="13"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<textFieldCell key="cell" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="will force client restart" id="1990">
+							    <font key="font" metaFont="system" size="10"/>
+							    <color key="textColor" red="1" green="0.024058114740000001" blue="0.012268543240000001" alpha="1" colorSpace="calibratedRGB"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="400">
+							<rect key="frame" x="405" y="86" width="76" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<buttonCell key="cell" type="check" title="DynRoot" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" state="on" inset="2" id="1982">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							</buttonCell>
+						    </button>
+						    <button toolTip="Enable the verbose mode of afsd" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1960">
+							<rect key="frame" x="405" y="47" width="66" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<buttonCell key="cell" type="check" title="Verbose" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" state="on" imageScaling="proportionallyDown" inset="2" id="1992">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							    <string key="toolTip">Enable lot of debugging information from afsd.  Only useful for debugging as it prints a LOT of information.
+</string>
+							</buttonCell>
+						    </button>
+						    <button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1902">
+							<rect key="frame" x="405" y="66" width="63" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
+							<buttonCell key="cell" type="check" title="AfsDB" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" state="on" imageScaling="proportionallyDown" inset="2" id="1991">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="message" size="11"/>
+							</buttonCell>
+						    </button>
+						</subviews>
+					    </view>
+					</box>
+				    </subviews>
+				</view>
+			    </tabViewItem>
+			    <tabViewItem label="Mounts" identifier="4" id="2022">
+				<view key="view" id="2023">
+				    <rect key="frame" x="10" y="25" width="552" height="363"/>
+				    <autoresizingMask key="autoresizingMask"/>
+				    <subviews>
+					<scrollView fixedFrame="YES" horizontalLineScroll="19" horizontalPageScroll="10" verticalLineScroll="19" verticalPageScroll="10" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="2024">
+					    <rect key="frame" x="17" y="41" width="518" height="316"/>
+					    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+					    <clipView key="contentView" ambiguous="YES" id="ZsY-mV-j7U">
+						<rect key="frame" x="1" y="25" width="501" height="275"/>
+						<autoresizingMask key="autoresizingMask"/>
+						<subviews>
+						    <tableView verticalHuggingPriority="750" tag="3" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" alternatingRowBackgroundColors="YES" columnSelection="YES" autosaveColumns="NO" headerView="2028" id="2027">
+							<rect key="frame" x="0.0" y="0.0" width="501" height="275"/>
+							<autoresizingMask key="autoresizingMask"/>
+							<size key="intercellSpacing" width="3" height="2"/>
+							<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+							<tableViewGridLines key="gridStyleMask" horizontal="YES"/>
+							<color key="gridColor" name="gridColor" catalog="System" colorSpace="catalog"/>
+							<tableColumns>
+							    <tableColumn identifier="0" width="84" minWidth="40" maxWidth="1000" id="2029">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Mount Name">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
+								</tableHeaderCell>
+								<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="2032">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+								</textFieldCell>
+								<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+							    </tableColumn>
+							    <tableColumn identifier="1" width="411" minWidth="40" maxWidth="1000" id="2030">
+								<tableHeaderCell key="headerCell" lineBreakMode="truncatingTail" borderStyle="border" alignment="left" title="Mount Path">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="headerTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" white="0.33333298560000002" alpha="1" colorSpace="calibratedWhite"/>
+								</tableHeaderCell>
+								<textFieldCell key="dataCell" lineBreakMode="truncatingTail" selectable="YES" editable="YES" alignment="left" title="Text Cell" id="2031">
+								    <font key="font" metaFont="message" size="11"/>
+								    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+								    <color key="backgroundColor" name="controlBackgroundColor" catalog="System" colorSpace="catalog"/>
+								</textFieldCell>
+								<tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/>
+							    </tableColumn>
+							</tableColumns>
+							<connections>
+							    <outlet property="dataSource" destination="-2" id="2060"/>
+							    <outlet property="delegate" destination="-2" id="2061"/>
+							</connections>
+						    </tableView>
+						</subviews>
+					    </clipView>
+					    <scroller key="horizontalScroller" verticalHuggingPriority="750" horizontal="YES" id="2026">
+						<rect key="frame" x="1" y="300" width="501" height="15"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </scroller>
+					    <scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="37" horizontal="NO" id="2025">
+						<rect key="frame" x="502" y="25" width="15" height="275"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </scroller>
+					    <tableHeaderView key="headerView" id="2028">
+						<rect key="frame" x="0.0" y="0.0" width="501" height="25"/>
+						<autoresizingMask key="autoresizingMask"/>
+					    </tableHeaderView>
+					</scrollView>
+					<button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2033">
+					    <rect key="frame" x="17" y="16" width="81" height="18"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="squareTextured" title="Add New Path" bezelStyle="texturedSquare" imagePosition="overlaps" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="2034">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="addLink:" target="-2" id="2046"/>
+					    </connections>
+					</button>
+					<button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2035">
+					    <rect key="frame" x="106" y="16" width="78" height="18"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="squareTextured" title="Remove Path" bezelStyle="texturedSquare" imagePosition="overlaps" alignment="center" controlSize="small" enabled="NO" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="2036">
+						<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="removeLink:" target="-2" id="2047"/>
+					    </connections>
+					</button>
+					<button fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2037">
+					    <rect key="frame" x="400" y="17" width="137" height="18"/>
+					    <autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+					    <buttonCell key="cell" type="check" title="Enable Symbolic Link" bezelStyle="regularSquare" imagePosition="leading" alignment="left" controlSize="small" imageScaling="proportionallyDown" inset="2" id="2038">
+						<behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+						<font key="font" metaFont="message" size="11"/>
+					    </buttonCell>
+					    <connections>
+						<action selector="enableLink:" target="-2" id="2048"/>
+					    </connections>
+					</button>
+				    </subviews>
+				</view>
+			    </tabViewItem>
+			    <tabViewItem label="Option" identifier="Item 4" id="2064">
+				<view key="view" id="2065">
+				    <rect key="frame" x="10" y="25" width="552" height="363"/>
+				    <autoresizingMask key="autoresizingMask"/>
+				    <subviews>
+					<box autoresizesSubviews="NO" fixedFrame="YES" borderType="line" title="Kerberos Renew Ticket Option" translatesAutoresizingMaskIntoConstraints="NO" id="2086">
+					    <rect key="frame" x="19" y="179" width="519" height="178"/>
+					    <autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+					    <view key="contentView" id="HBP-1m-mJV">
+						<rect key="frame" x="3" y="3" width="513" height="160"/>
+						<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+						<subviews>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2066">
+							<rect key="frame" x="15" y="129" width="224" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Requested ticket lifetime(D:H:M:S):" id="2067">
+							    <font key="font" metaFont="cellTitle"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="Interval to check whether tickets require renewal, in seconds (min. 3600)" verticalHuggingPriority="750" fixedFrame="YES" tag="3" translatesAutoresizingMaskIntoConstraints="NO" id="2073">
+							<rect key="frame" x="237" y="66" width="96" height="22"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="3600" drawsBackground="YES" id="2074">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="2075">
+								<real key="minimum" value="60"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<connections>
+							    <action selector="krb5RenewParamChange:" target="-2" id="2092"/>
+							</connections>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2071">
+							<rect key="frame" x="15" y="68" width="207" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Ticket renewal check frequency:" id="2072">
+							    <font key="font" metaFont="cellTitle"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField toolTip="Maximum remaining ticket lifetime before renewal is attempted, in seconds (min. 3600)" verticalHuggingPriority="750" fixedFrame="YES" tag="2" translatesAutoresizingMaskIntoConstraints="NO" id="2076">
+							<rect key="frame" x="237" y="96" width="96" height="22"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="right" title="3600" drawsBackground="YES" id="2079">
+							    <numberFormatter key="formatter" formatterBehavior="custom10_4" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="0" maximumIntegerDigits="42" id="2080">
+								<real key="minimum" value="60"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<connections>
+							    <action selector="krb5RenewParamChange:" target="-2" id="2091"/>
+							</connections>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2077">
+							<rect key="frame" x="15" y="98" width="217" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Seconds before expire to renew:" id="2078">
+							    <font key="font" metaFont="cellTitle"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <button toolTip="Enable/Disable automatic Kerberos ticket renewal" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2087">
+							<rect key="frame" x="8" y="37" width="148" height="18"/>
+							<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+							<buttonCell key="cell" type="check" title="Enable auto-renew" bezelStyle="regularSquare" imagePosition="leading" alignment="left" inset="2" id="2088">
+							    <behavior key="behavior" changeContents="YES" doesNotDimImage="YES" lightByContents="YES"/>
+							    <font key="font" metaFont="cellTitle"/>
+							</buttonCell>
+							<connections>
+							    <action selector="enableDisableKrb5RenewCheck:" target="-2" id="2093"/>
+							</connections>
+						    </button>
+						    <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2100">
+							<rect key="frame" x="260" y="123" width="19" height="27"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<stepperCell key="cell" continuous="YES" alignment="left" maxValue="30" id="2101"/>
+							<connections>
+							    <action selector="takeIntegerValueFrom:" target="2102" id="2104"/>
+							</connections>
+						    </stepper>
+						    <textField toolTip="Days" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2102">
+							<rect key="frame" x="237" y="126" width="24" height="22"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="1" drawsBackground="YES" id="2103">
+							    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="42" id="2108">
+								<real key="minimum" value="0.0"/>
+								<real key="maximum" value="30"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<connections>
+							    <action selector="takeIntValueFrom:" target="2100" id="2128"/>
+							</connections>
+						    </textField>
+						    <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2109">
+							<rect key="frame" x="307" y="123" width="19" height="27"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<stepperCell key="cell" continuous="YES" alignment="left" maxValue="24" id="2113"/>
+							<connections>
+							    <action selector="takeIntegerValueFrom:" target="2110" id="2114"/>
+							</connections>
+						    </stepper>
+						    <textField toolTip="Hours" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2110">
+							<rect key="frame" x="284" y="126" width="24" height="22"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="0" drawsBackground="YES" id="2111">
+							    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="42" id="2112">
+								<real key="minimum" value="0.0"/>
+								<real key="maximum" value="24"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<connections>
+							    <action selector="takeIntegerValueFrom:" target="2109" id="2127"/>
+							</connections>
+						    </textField>
+						    <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2115">
+							<rect key="frame" x="355" y="123" width="19" height="27"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<stepperCell key="cell" continuous="YES" alignment="left" maxValue="60" id="2119"/>
+							<connections>
+							    <action selector="takeIntegerValueFrom:" target="2116" id="2120"/>
+							</connections>
+						    </stepper>
+						    <textField toolTip="Minutes" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2116">
+							<rect key="frame" x="332" y="126" width="24" height="22"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="0" drawsBackground="YES" id="2117">
+							    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="42" id="2118">
+								<real key="minimum" value="0.0"/>
+								<real key="maximum" value="60"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<connections>
+							    <action selector="takeIntValueFrom:" target="2115" id="2129"/>
+							</connections>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2121">
+							<rect key="frame" x="275" y="129" width="9" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title=":" id="2122">
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2123">
+							<rect key="frame" x="322" y="129" width="9" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title=":" id="2124">
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						    <stepper horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2133">
+							<rect key="frame" x="403" y="123" width="19" height="27"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<stepperCell key="cell" continuous="YES" alignment="left" maxValue="60" id="2139"/>
+							<connections>
+							    <action selector="takeIntegerValueFrom:" target="2134" id="2140"/>
+							</connections>
+						    </stepper>
+						    <textField toolTip="Seconds" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2134">
+							<rect key="frame" x="380" y="126" width="24" height="22"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" alignment="center" title="0" drawsBackground="YES" id="2137">
+							    <numberFormatter key="formatter" formatterBehavior="default10_4" usesGroupingSeparator="NO" formatWidth="-1" groupingSize="0" minimumIntegerDigits="1" maximumIntegerDigits="42" id="2138">
+								<real key="minimum" value="0.0"/>
+								<real key="maximum" value="60"/>
+							    </numberFormatter>
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+							<connections>
+							    <action selector="takeIntValueFrom:" target="2133" id="2141"/>
+							</connections>
+						    </textField>
+						    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="2135">
+							<rect key="frame" x="370" y="129" width="9" height="17"/>
+							<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+							<textFieldCell key="cell" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title=":" id="2136">
+							    <font key="font" metaFont="message"/>
+							    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+							    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+							</textFieldCell>
+						    </textField>
+						</subviews>
+					    </view>
+					</box>
+				    </subviews>
+				</view>
+			    </tabViewItem>
+			</tabViewItems>
+			<connections>
+			    <outlet property="delegate" destination="-2" id="669"/>
+			</connections>
+		    </tabView>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="1715">
+			<rect key="frame" x="323" y="3" width="258" height="11"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" alignment="right" title="afs version" id="1998">
+			    <font key="font" metaFont="miniSystem"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		</subviews>
+	    </view>
+	    <point key="canvasLocation" x="140" y="147"/>
+	</window>
+	<window title="Panel" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="208" userLabel="Info" customClass="NSPanel">
+	    <windowStyleMask key="styleMask" titled="YES" resizable="YES"/>
+	    <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
+	    <rect key="contentRect" x="1006" y="707" width="715" height="485"/>
+	    <rect key="screenRect" x="0.0" y="0.0" width="1024" height="745"/>
+	    <view key="contentView" id="209">
+		<rect key="frame" x="0.0" y="0.0" width="715" height="485"/>
+		<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+		<subviews>
+		    <scrollView fixedFrame="YES" horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" translatesAutoresizingMaskIntoConstraints="NO" id="214">
+			<rect key="frame" x="20" y="40" width="675" height="425"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+			<clipView key="contentView" ambiguous="YES" id="Und-GM-Qu7">
+			    <rect key="frame" x="1" y="1" width="662" height="423"/>
+			    <autoresizingMask key="autoresizingMask"/>
+			    <subviews>
+				<textView ambiguous="YES" editable="NO" importsGraphics="NO" richText="NO" verticallyResizable="YES" usesFontPanel="YES" usesRuler="YES" spellingCorrection="YES" smartInsertDelete="YES" id="215">
+				    <rect key="frame" x="0.0" y="0.0" width="662" height="423"/>
+				    <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
+				    <color key="textColor" name="textColor" catalog="System" colorSpace="catalog"/>
+				    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+				    <size key="minSize" width="662" height="423"/>
+				    <size key="maxSize" width="1337" height="10000000"/>
+				    <color key="insertionPointColor" name="textColor" catalog="System" colorSpace="catalog"/>
+				</textView>
+			    </subviews>
+			    <color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
+			</clipView>
+			<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" controlSize="small" horizontal="YES" id="2010">
+			    <rect key="frame" x="-100" y="-100" width="87" height="18"/>
+			    <autoresizingMask key="autoresizingMask"/>
+			</scroller>
+			<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" controlSize="small" horizontal="NO" id="2009">
+			    <rect key="frame" x="663" y="1" width="11" height="423"/>
+			    <autoresizingMask key="autoresizingMask"/>
+			</scroller>
+		    </scrollView>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="216">
+			<rect key="frame" x="318" y="8" width="80" height="28"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxX="YES" flexibleMaxY="YES"/>
+			<buttonCell key="cell" type="push" title="Close" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" inset="2" id="1999">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="message" size="11"/>
+			</buttonCell>
+			<connections>
+			    <action selector="closePanel:" target="224" id="228"/>
+			</connections>
+		    </button>
+		</subviews>
+	    </view>
+	</window>
+	<customObject id="224" userLabel="InfoController" customClass="InfoController">
+	    <connections>
+		<outlet property="infoPanel" destination="208" id="226"/>
+		<outlet property="texEditInfo" destination="215" id="227"/>
+	    </connections>
+	</customObject>
+    </objects>
+</document>
diff --git a/src/platform/DARWIN/AFSPreference/English.lproj/SymLinkEdit.xib b/src/platform/DARWIN/AFSPreference/English.lproj/SymLinkEdit.xib
index 975b10c4d..b0e0000e5 100644
--- a/src/platform/DARWIN/AFSPreference/English.lproj/SymLinkEdit.xib
+++ b/src/platform/DARWIN/AFSPreference/English.lproj/SymLinkEdit.xib
@@ -1,728 +1,116 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.02">
-	<data>
-		<int key="IBDocument.SystemTarget">1050</int>
-		<string key="IBDocument.SystemVersion">9D34</string>
-		<string key="IBDocument.InterfaceBuilderVersion">667</string>
-		<string key="IBDocument.AppKitVersion">949.33</string>
-		<string key="IBDocument.HIToolboxVersion">352.00</string>
-		<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<integer value="7"/>
-		</object>
-		<object class="NSArray" key="IBDocument.PluginDependencies">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<string>com.apple.InterfaceBuilderKit</string>
-			<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-		</object>
-		<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
-			<bool key="EncodedWithXMLCoder">YES</bool>
-			<object class="NSCustomObject" id="1001">
-				<string key="NSClassName">AFSCommanderPref</string>
-			</object>
-			<object class="NSCustomObject" id="1003">
-				<string key="NSClassName">FirstResponder</string>
-			</object>
-			<object class="NSCustomObject" id="1004">
-				<string key="NSClassName">NSApplication</string>
-			</object>
-			<object class="NSCustomObject" id="975034471">
-				<string key="NSClassName">LynkCreationController</string>
-			</object>
-			<object class="NSWindowTemplate" id="601928344">
-				<int key="NSWindowStyleMask">11</int>
-				<int key="NSWindowBacking">2</int>
-				<string key="NSWindowRect">{{196, 372}, {502, 138}}</string>
-				<int key="NSWTFlags">1946157056</int>
-				<string key="NSWindowTitle">Window</string>
-				<string key="NSWindowClass">NSPanel</string>
-				<nil key="NSViewClass"/>
-				<string key="NSWindowContentMaxSize">{800, 138}</string>
-				<string key="NSWindowContentMinSize">{502, 138}</string>
-				<object class="NSView" key="NSWindowView" id="460331704">
-					<reference key="NSNextResponder"/>
-					<int key="NSvFlags">266</int>
-					<object class="NSMutableArray" key="NSSubviews">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSTextField" id="490694985">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">268</int>
-							<string key="NSFrame">{{46, 116}, {67, 14}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="223588969">
-								<int key="NSCellFlags">68288064</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents">Link Name:</string>
-								<object class="NSFont" key="NSSupport" id="26">
-									<string key="NSName">LucidaGrande</string>
-									<double key="NSSize">1.100000e+01</double>
-									<int key="NSfFlags">3100</int>
-								</object>
-								<reference key="NSControlView" ref="490694985"/>
-								<object class="NSColor" key="NSBackgroundColor" id="459467427">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlColor</string>
-									<object class="NSColor" key="NSColor">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MC42NjY2NjY2OQA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor" id="580207658">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">controlTextColor</string>
-									<object class="NSColor" key="NSColor" id="213974819">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MAA</bytes>
-									</object>
-								</object>
-							</object>
-						</object>
-						<object class="NSTextField" id="216298488">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">266</int>
-							<string key="NSFrame">{{118, 114}, {364, 19}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="595483084">
-								<int key="NSCellFlags">-1804468671</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents"/>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="216298488"/>
-								<bool key="NSDrawsBackground">YES</bool>
-								<object class="NSColor" key="NSBackgroundColor" id="842446002">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textBackgroundColor</string>
-									<object class="NSColor" key="NSColor">
-										<int key="NSColorSpace">3</int>
-										<bytes key="NSWhite">MQA</bytes>
-									</object>
-								</object>
-								<object class="NSColor" key="NSTextColor" id="456929419">
-									<int key="NSColorSpace">6</int>
-									<string key="NSCatalogName">System</string>
-									<string key="NSColorName">textColor</string>
-									<reference key="NSColor" ref="213974819"/>
-								</object>
-							</object>
-						</object>
-						<object class="NSTextField" id="396325470">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">268</int>
-							<string key="NSFrame">{{17, 89}, {96, 14}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="606265604">
-								<int key="NSCellFlags">68288064</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents">Destination Path:</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="396325470"/>
-								<reference key="NSBackgroundColor" ref="459467427"/>
-								<reference key="NSTextColor" ref="580207658"/>
-							</object>
-						</object>
-						<object class="NSTextField" id="987609939">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">266</int>
-							<string key="NSFrame">{{118, 87}, {364, 19}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSTextFieldCell" key="NSCell" id="1031947755">
-								<int key="NSCellFlags">-1804468671</int>
-								<int key="NSCellFlags2">272761856</int>
-								<string key="NSContents"/>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="987609939"/>
-								<bool key="NSDrawsBackground">YES</bool>
-								<reference key="NSBackgroundColor" ref="842446002"/>
-								<reference key="NSTextColor" ref="456929419"/>
-							</object>
-						</object>
-						<object class="NSButton" id="852592336">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">265</int>
-							<string key="NSFrame">{{391, 55}, {96, 28}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="293618620">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Select Path</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="852592336"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">268435585</int>
-								<string key="NSAlternateContents"/>
-								<string key="NSKeyEquivalent">p</string>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-						<object class="NSButton" id="398365385">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">289</int>
-							<string key="NSFrame">{{391, 28}, {96, 28}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="1037460050">
-								<int key="NSCellFlags">-2080244224</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Save</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="398365385"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">129</int>
-								<string key="NSAlternateContents"/>
-								<string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-						<object class="NSButton" id="624416640">
-							<reference key="NSNextResponder" ref="460331704"/>
-							<int key="NSvFlags">289</int>
-							<string key="NSFrame">{{297, 28}, {96, 28}}</string>
-							<reference key="NSSuperview" ref="460331704"/>
-							<bool key="NSEnabled">YES</bool>
-							<object class="NSButtonCell" key="NSCell" id="204377612">
-								<int key="NSCellFlags">67239424</int>
-								<int key="NSCellFlags2">134348800</int>
-								<string key="NSContents">Cancel</string>
-								<reference key="NSSupport" ref="26"/>
-								<reference key="NSControlView" ref="624416640"/>
-								<int key="NSButtonFlags">-2038284033</int>
-								<int key="NSButtonFlags2">129</int>
-								<string key="NSAlternateContents"/>
-								<string type="base64-UTF8" key="NSKeyEquivalent">Gw</string>
-								<int key="NSPeriodicDelay">200</int>
-								<int key="NSPeriodicInterval">25</int>
-							</object>
-						</object>
-					</object>
-					<string key="NSFrameSize">{502, 138}</string>
-					<reference key="NSSuperview"/>
-				</object>
-				<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
-				<string key="NSMinSize">{502, 160}</string>
-				<string key="NSMaxSize">{800, 160}</string>
-			</object>
-		</object>
-		<object class="IBObjectContainer" key="IBDocument.Objects">
-			<object class="NSMutableArray" key="connectionRecords">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">save:</string>
-						<reference key="source" ref="975034471"/>
-						<reference key="destination" ref="398365385"/>
-					</object>
-					<int key="connectionID">23</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">cancell:</string>
-						<reference key="source" ref="975034471"/>
-						<reference key="destination" ref="624416640"/>
-					</object>
-					<int key="connectionID">24</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">lynkCreationSheet</string>
-						<reference key="source" ref="975034471"/>
-						<reference key="destination" ref="601928344"/>
-					</object>
-					<int key="connectionID">25</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">lyncCreationSheet</string>
-						<reference key="source" ref="1001"/>
-						<reference key="destination" ref="601928344"/>
-					</object>
-					<int key="connectionID">26</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">selectLinkDest:</string>
-						<reference key="source" ref="975034471"/>
-						<reference key="destination" ref="852592336"/>
-					</object>
-					<int key="connectionID">27</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textFieldLinkDestPath</string>
-						<reference key="source" ref="975034471"/>
-						<reference key="destination" ref="987609939"/>
-					</object>
-					<int key="connectionID">28</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBOutletConnection" key="connection">
-						<string key="label">textfieldLinkName</string>
-						<reference key="source" ref="975034471"/>
-						<reference key="destination" ref="216298488"/>
-					</object>
-					<int key="connectionID">29</int>
-				</object>
-			</object>
-			<object class="IBMutableOrderedSet" key="objectRecords">
-				<object class="NSArray" key="orderedObjects">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<object class="IBObjectRecord">
-						<int key="objectID">0</int>
-						<object class="NSArray" key="object" id="1002">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-						</object>
-						<reference key="children" ref="1000"/>
-						<nil key="parent"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-2</int>
-						<reference key="object" ref="1001"/>
-						<reference key="parent" ref="1002"/>
-						<string type="base64-UTF8" key="objectName">RmlsZSdzIE93bmVyA</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-1</int>
-						<reference key="object" ref="1003"/>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">First Responder</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">-3</int>
-						<reference key="object" ref="1004"/>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">Application</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">6</int>
-						<reference key="object" ref="601928344"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="460331704"/>
-						</object>
-						<reference key="parent" ref="1002"/>
-						<string key="objectName">LynkCreation</string>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">7</int>
-						<reference key="object" ref="460331704"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="490694985"/>
-							<reference ref="216298488"/>
-							<reference ref="987609939"/>
-							<reference ref="852592336"/>
-							<reference ref="398365385"/>
-							<reference ref="624416640"/>
-							<reference ref="396325470"/>
-						</object>
-						<reference key="parent" ref="601928344"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">8</int>
-						<reference key="object" ref="490694985"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="223588969"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">9</int>
-						<reference key="object" ref="223588969"/>
-						<reference key="parent" ref="490694985"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">10</int>
-						<reference key="object" ref="216298488"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="595483084"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">11</int>
-						<reference key="object" ref="595483084"/>
-						<reference key="parent" ref="216298488"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">12</int>
-						<reference key="object" ref="396325470"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="606265604"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">13</int>
-						<reference key="object" ref="987609939"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1031947755"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">14</int>
-						<reference key="object" ref="1031947755"/>
-						<reference key="parent" ref="987609939"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">15</int>
-						<reference key="object" ref="606265604"/>
-						<reference key="parent" ref="396325470"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">16</int>
-						<reference key="object" ref="852592336"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="293618620"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">17</int>
-						<reference key="object" ref="293618620"/>
-						<reference key="parent" ref="852592336"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">18</int>
-						<reference key="object" ref="398365385"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="1037460050"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">19</int>
-						<reference key="object" ref="1037460050"/>
-						<reference key="parent" ref="398365385"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">20</int>
-						<reference key="object" ref="624416640"/>
-						<object class="NSMutableArray" key="children">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<reference ref="204377612"/>
-						</object>
-						<reference key="parent" ref="460331704"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">21</int>
-						<reference key="object" ref="204377612"/>
-						<reference key="parent" ref="624416640"/>
-					</object>
-					<object class="IBObjectRecord">
-						<int key="objectID">22</int>
-						<reference key="object" ref="975034471"/>
-						<reference key="parent" ref="1002"/>
-					</object>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="flattenedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSMutableArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>-1.IBPluginDependency</string>
-					<string>-2.IBPluginDependency</string>
-					<string>-3.IBPluginDependency</string>
-					<string>10.IBAttributePlaceholdersKey</string>
-					<string>10.IBPluginDependency</string>
-					<string>11.IBPluginDependency</string>
-					<string>12.IBPluginDependency</string>
-					<string>13.IBAttributePlaceholdersKey</string>
-					<string>13.IBPluginDependency</string>
-					<string>14.IBPluginDependency</string>
-					<string>15.IBPluginDependency</string>
-					<string>16.IBPluginDependency</string>
-					<string>17.IBPluginDependency</string>
-					<string>18.IBPluginDependency</string>
-					<string>19.IBPluginDependency</string>
-					<string>20.IBPluginDependency</string>
-					<string>21.IBPluginDependency</string>
-					<string>22.IBPluginDependency</string>
-					<string>6.IBEditorWindowLastContentRect</string>
-					<string>6.IBPluginDependency</string>
-					<string>6.IBWindowTemplateEditedContentRect</string>
-					<string>6.NSWindowTemplate.visibleAtLaunch</string>
-					<string>6.windowTemplate.hasMaxSize</string>
-					<string>6.windowTemplate.hasMinSize</string>
-					<string>6.windowTemplate.maxSize</string>
-					<string>6.windowTemplate.minSize</string>
-					<string>7.IBPluginDependency</string>
-					<string>8.IBPluginDependency</string>
-					<string>9.IBPluginDependency</string>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilderKit</string>
-					<string>com.apple.InterfaceBuilderKit</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="216298488"/>
-							<string key="toolTip">Alias that describe the link. It will be used as mount name.</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<object class="NSMutableDictionary">
-						<string key="NS.key.0">ToolTip</string>
-						<object class="IBToolTipAttribute" key="NS.object.0">
-							<string key="name">ToolTip</string>
-							<reference key="object" ref="987609939"/>
-							<string key="toolTip">AFS path for the link destination</string>
-						</object>
-					</object>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{86, 409}, {502, 138}}</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>{{86, 409}, {502, 138}}</string>
-					<integer value="0"/>
-					<integer value="1" id="9"/>
-					<reference ref="9"/>
-					<string>{800, 138}</string>
-					<string>{502, 138}</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-					<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-				</object>
-			</object>
-			<object class="NSMutableDictionary" key="unlocalizedProperties">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="activeLocalization"/>
-			<object class="NSMutableDictionary" key="localizations">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="NSArray" key="dict.sortedKeys">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-				<object class="NSMutableArray" key="dict.values">
-					<bool key="EncodedWithXMLCoder">YES</bool>
-				</object>
-			</object>
-			<nil key="sourceID"/>
-			<int key="maxID">29</int>
-		</object>
-		<object class="IBClassDescriber" key="IBDocument.Classes">
-			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
-				<bool key="EncodedWithXMLCoder">YES</bool>
-				<object class="IBPartialClassDescription">
-					<string key="className">AFSCommanderPref</string>
-					<string key="superclassName">NSPreferencePane</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addLink:</string>
-							<string>addRemoveCell:</string>
-							<string>afsMenuActivationEvent:</string>
-							<string>aklogSwitchEvent:</string>
-							<string>credentialAtLoginTimeEvent:</string>
-							<string>enableLink:</string>
-							<string>getNewToken:</string>
-							<string>info:</string>
-							<string>krb5KredentialAtLoginTimeEvent:</string>
-							<string>refreshConfiguration:</string>
-							<string>removeLink:</string>
-							<string>saveCacheManagerParam:</string>
-							<string>saveConfiguration:</string>
-							<string>searchCellTextEvent:</string>
-							<string>showCellIP:</string>
-							<string>startStopAfs:</string>
-							<string>tableDoubleAction:</string>
-							<string>unlog:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>addCellButton</string>
-							<string>afsCommanderView</string>
-							<string>afsDB</string>
-							<string>afsDefaultCellLabel</string>
-							<string>afsMenucheckBox</string>
-							<string>afsRootMountPoint</string>
-							<string>afsVersionLabel</string>
-							<string>aklogCredentialAtLoginTime</string>
-							<string>buttonAddLink</string>
-							<string>buttonRemoveLink</string>
-							<string>cacheDimension</string>
-							<string>cellIpButton</string>
-							<string>cellList</string>
-							<string>checkEnableLink</string>
-							<string>credentialCommander</string>
-							<string>credentialSheet</string>
-							<string>dCacheDim</string>
-							<string>daemonNumber</string>
-							<string>dynRoot</string>
-							<string>groupsBox</string>
-							<string>infoController</string>
-							<string>infoSheet</string>
-							<string>installKRB5AuthAtLoginButton</string>
-							<string>installationPathTextField</string>
-							<string>ipConfControllerCommander</string>
-							<string>ipConfigurationSheet</string>
-							<string>labelSaveResult</string>
-							<string>lyncCreationSheet</string>
-							<string>lynkCreationController</string>
-							<string>nVolEntry</string>
-							<string>refreshConfigurationButton</string>
-							<string>removeCellButton</string>
-							<string>saveConfigurationButton</string>
-							<string>startStopButton</string>
-							<string>statCacheEntry</string>
-							<string>textSearchField</string>
-							<string>tokensButton</string>
-							<string>tokensTable</string>
-							<string>unlogButton</string>
-							<string>useAklogCheck</string>
-							<string>verbose</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>NSView</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-							<string>NSButton</string>
-							<string>NSBox</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>LynkCreationController</string>
-							<string>NSTextField</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-							<string>NSTextField</string>
-							<string>NSSearchField</string>
-							<string>NSButton</string>
-							<string>id</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-							<string>NSButton</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">AFSCommanderPref.h</string>
-					</object>
-				</object>
-				<object class="IBPartialClassDescription">
-					<string key="className">LynkCreationController</string>
-					<string key="superclassName">NSObject</string>
-					<object class="NSMutableDictionary" key="actions">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>cancell:</string>
-							<string>save:</string>
-							<string>selectLinkDest:</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>id</string>
-							<string>id</string>
-							<string>id</string>
-						</object>
-					</object>
-					<object class="NSMutableDictionary" key="outlets">
-						<bool key="EncodedWithXMLCoder">YES</bool>
-						<object class="NSMutableArray" key="dict.sortedKeys">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>lynkCreationSheet</string>
-							<string>textFieldLinkDestPath</string>
-							<string>textfieldLinkName</string>
-						</object>
-						<object class="NSMutableArray" key="dict.values">
-							<bool key="EncodedWithXMLCoder">YES</bool>
-							<string>NSPanel</string>
-							<string>NSTextField</string>
-							<string>NSTextField</string>
-						</object>
-					</object>
-					<object class="IBClassDescriptionSource" key="sourceIdentifier">
-						<string key="majorKey">IBProjectSource</string>
-						<string key="minorKey">LynkCreationController.h</string>
-					</object>
-				</object>
-			</object>
-		</object>
-		<int key="IBDocument.localizationMode">0</int>
-		<string key="IBDocument.LastKnownRelativeProjectPath">../OpenAFS.xcodeproj</string>
-		<int key="IBDocument.defaultPropertyAccessControl">3</int>
-	</data>
-</archive>
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14810.12" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
+    <dependencies>
+	<deployment version="101400" identifier="macosx"/>
+	<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14810.12"/>
+	<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
+    </dependencies>
+    <objects>
+	<customObject id="-2" userLabel="File's Owner" customClass="AFSCommanderPref">
+	    <connections>
+		<outlet property="lyncCreationSheet" destination="6" id="26"/>
+	    </connections>
+	</customObject>
+	<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
+	<customObject id="-3" userLabel="Application"/>
+	<customObject id="22" customClass="LynkCreationController">
+	    <connections>
+		<outlet property="lynkCreationSheet" destination="6" id="25"/>
+		<outlet property="textFieldLinkDestPath" destination="13" id="28"/>
+		<outlet property="textfieldLinkName" destination="10" id="29"/>
+	    </connections>
+	</customObject>
+	<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="6" userLabel="LynkCreation" customClass="NSPanel">
+	    <windowStyleMask key="styleMask" titled="YES" closable="YES" resizable="YES"/>
+	    <windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
+	    <rect key="contentRect" x="196" y="372" width="502" height="138"/>
+	    <rect key="screenRect" x="0.0" y="0.0" width="1024" height="745"/>
+	    <value key="minSize" type="size" width="502" height="138"/>
+	    <value key="maxSize" type="size" width="800" height="138"/>
+	    <view key="contentView" id="7">
+		<rect key="frame" x="0.0" y="0.0" width="502" height="138"/>
+		<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+		<subviews>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="8">
+			<rect key="frame" x="46" y="116" width="67" height="14"/>
+			<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Link Name:" id="9">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField toolTip="Alias that describe the link. It will be used as mount name." verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="10">
+			<rect key="frame" x="118" y="114" width="364" height="19"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="11">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="12">
+			<rect key="frame" x="17" y="89" width="96" height="14"/>
+			<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" sendsActionOnEndEditing="YES" title="Destination Path:" id="15">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <textField toolTip="AFS path for the link destination" verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="13">
+			<rect key="frame" x="118" y="87" width="364" height="19"/>
+			<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
+			<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" editable="YES" sendsActionOnEndEditing="YES" state="on" borderStyle="bezel" drawsBackground="YES" id="14">
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <color key="textColor" name="controlTextColor" catalog="System" colorSpace="catalog"/>
+			    <color key="backgroundColor" name="textBackgroundColor" catalog="System" colorSpace="catalog"/>
+			</textFieldCell>
+		    </textField>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="16">
+			<rect key="frame" x="391" y="55" width="96" height="28"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
+			<buttonCell key="cell" type="push" title="Select Path" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="17">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <string key="keyEquivalent">p</string>
+			    <modifierMask key="keyEquivalentModifierMask" command="YES"/>
+			</buttonCell>
+			<connections>
+			    <action selector="selectLinkDest:" target="22" id="27"/>
+			</connections>
+		    </button>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="18">
+			<rect key="frame" x="391" y="28" width="96" height="28"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+			<buttonCell key="cell" type="push" title="Save" bezelStyle="rounded" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="19">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <string key="keyEquivalent" base64-UTF8="YES">
+DQ
+</string>
+			</buttonCell>
+			<connections>
+			    <action selector="save:" target="22" id="23"/>
+			</connections>
+		    </button>
+		    <button verticalHuggingPriority="750" fixedFrame="YES" imageHugsTitle="YES" translatesAutoresizingMaskIntoConstraints="NO" id="20">
+			<rect key="frame" x="297" y="28" width="96" height="28"/>
+			<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMaxY="YES"/>
+			<buttonCell key="cell" type="push" title="Cancel" bezelStyle="rounded" alignment="center" controlSize="small" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="21">
+			    <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
+			    <font key="font" metaFont="controlContent" size="11"/>
+			    <string key="keyEquivalent" base64-UTF8="YES">
+Gw
+</string>
+			</buttonCell>
+			<connections>
+			    <action selector="cancell:" target="22" id="24"/>
+			</connections>
+		    </button>
+		</subviews>
+	    </view>
+	    <point key="canvasLocation" x="140" y="147"/>
+	</window>
+    </objects>
+</document>
diff --git a/src/platform/DARWIN/AFSPreference/Krb5Util.m b/src/platform/DARWIN/AFSPreference/Krb5Util.m
index b6050d0fd..d9cc88c45 100644
--- a/src/platform/DARWIN/AFSPreference/Krb5Util.m
+++ b/src/platform/DARWIN/AFSPreference/Krb5Util.m
@@ -176,13 +176,6 @@
 			KLPrincipal klprinc = nil;
 			kstatus = KLRenewInitialTickets ( klprinc, inLoginOptions, nil, nil);
 #endif
-
-#if 0
-			/* handoff to growl agent? */
-			kstatus = KLTicketExpirationTime (nil, kerberosVersion_All, &expireStartTime);
-			expirationDate = [NSDate dateWithTimeIntervalSince1970:expireStartTime];
-			BuildNotificationInfo(@"Ticket Renewed Unitl %@", expirationDate,  callbackInfo->dcref, callbackInfo->regref, callbackInfo->icon);
-#endif
 		}
 	}
 	@catch (NSException * e) {
diff --git a/src/platform/DARWIN/growlagent/main.m b/src/platform/DARWIN/growlagent/main.m
index a39f77a2b..89e848b79 100644
--- a/src/platform/DARWIN/growlagent/main.m
+++ b/src/platform/DARWIN/growlagent/main.m
@@ -118,10 +118,6 @@ BuildNotificationInfo(char *recvbuf, CFNotificationCenterRef dcref, CFDictionary
 	CFDictionarySetValue(notificationInfo, GROWL_NOTIFICATION_CLICK_CONTEXT, clickContext);
 	CFDictionarySetValue(notificationInfo, GROWL_NOTIFICATION_TITLE, CFSTR("OpenAFS")/*title*/);
 	//CFRelease(title);
-#if 0
-	/* if fetching ever provides more data we could use this */
-	CFDictionarySetValue(notificationInfo, GROWL_NOTIFICATION_PROGRESS, progressNumber);
-#endif
 	if (!strncmp(recvbuf, FETCHSTR, sizeof(FETCHSTR)-1)) {
 		CFDictionarySetValue(notificationInfo, GROWL_NOTIFICATION_DESCRIPTION, CFStringCreateWithCString(kCFAllocatorDefault, recvbuf+FETCHOFFT, kCFStringEncodingUTF8));
 		priority = -1;
diff --git a/src/platform/IRIX/rcmd.c b/src/platform/IRIX/rcmd.c
index 6e471da3b..37ad40f1c 100644
--- a/src/platform/IRIX/rcmd.c
+++ b/src/platform/IRIX/rcmd.c
@@ -145,11 +145,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 #endif /* !defined(AIX) */
 #endif
 	sin.sin_family = hp->h_addrtype;
-#ifdef	AFS_OSF_ENV
-	memcpy((caddr_t) & sin.sin_addr, hp->h_addr_list[0], hp->h_length);
-#else
 	memcpy((caddr_t) & sin.sin_addr, hp->h_addr, hp->h_length);
-#endif
 	sin.sin_port = rport;
 	/* attempt to remote authenticate first... */
 	sp = getservbyport((int)rport, "tcp");
@@ -290,16 +286,6 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 	goto bad2;
     }
     if (c != 0) {
-#ifdef	AFS_OSF_ENV
-	/*
-	 *   Two different protocols seem to be used;
-	 *   one prepends a "message" byte with a "small"
-	 *   number; the other one just sends the message
-	 */
-	if (isalnum(c))
-	    (void)write(2, &c, 1);
-
-#endif
 	while (read(s, &c, 1) == 1) {
 	    (void)write(2, &c, 1);
 	    if (c == '\n')
@@ -387,14 +373,6 @@ ruserok(rhost, superuser, ruser, luser)
     if (hostf) {
 	if (!_validuser(hostf, fhost, luser, ruser, baselen)) {
 	    (void)fclose(hostf);
-#ifdef	AFS_OSF_ENV
-	    if (first == 0) {
-		(void)seteuid(suid);
-		(void)setegid(sgid);
-		if (group_list_size >= 0)
-		    (void)setgroups(group_list_size, groups);
-	    }
-#endif
 	    return (0);
 	}
 	(void)fclose(hostf);
diff --git a/src/ptserver/liboafs_prot.la.sym b/src/ptserver/liboafs_prot.la.sym
index 2efa03c16..b56aa5f83 100644
--- a/src/ptserver/liboafs_prot.la.sym
+++ b/src/ptserver/liboafs_prot.la.sym
@@ -31,12 +31,25 @@ pr_SetMaxUserId
 pruclient
 string_PR_IDToName
 ubik_PR_AddToGroup
+ubik_PR_ChangeEntry
 ubik_PR_Delete
+ubik_PR_DumpEntry
 ubik_PR_GetCPS
+ubik_PR_GetCPS2
 ubik_PR_GetHostCPS
 ubik_PR_IDToName
+ubik_PR_INewEntry
+ubik_PR_IsAMemberOf
 ubik_PR_ListElements
+ubik_PR_ListEntries
+ubik_PR_ListEntry
+ubik_PR_ListMax
 ubik_PR_ListOwned
+ubik_PR_ListSuperGroups
 ubik_PR_NameToID
 ubik_PR_NewEntry
 ubik_PR_RemoveFromGroup
+ubik_PR_SetFieldsEntry
+ubik_PR_SetMax
+ubik_PR_UpdateEntry
+ubik_PR_WhereIsIt
diff --git a/src/ptserver/ptclient.c b/src/ptserver/ptclient.c
index 416e4c707..a368e6141 100644
--- a/src/ptserver/ptclient.c
+++ b/src/ptserver/ptclient.c
@@ -34,11 +34,9 @@ char confdir[AFSDIR_PATH_MAX];
 
 char *whoami;
 
-#ifndef AFS_PTHREAD_ENV
 extern struct ubik_client *pruclient;
 static void skip(char **);
 static void PrintHelp(void);
-#endif
 
 static int ignoreExist = 0;
 static char line[256];
@@ -46,7 +44,6 @@ static char *lineProgress;
 
 #define WHITESPACE " \t\n"
 
-#ifndef AFS_PTHREAD_ENV
 int
 osi_audit(void)
 {
@@ -56,7 +53,6 @@ osi_audit(void)
  */
     return 0;
 }
-#endif /* !AFS_PTHREAD_ENV */
 
 int
 GetToken(char *format, afs_int32 *l)
@@ -147,7 +143,6 @@ PrintEntry(afs_int32 ea, struct prentry *e, int indent)
     return pr_PrintEntry(stdout, /*host order */ 1, ea, e, indent);
 }
 
-#ifndef AFS_PTHREAD_ENV
 
 /* main program */
 
@@ -173,6 +168,7 @@ main(int argc, char **argv)
     char *foo;
     afs_int32 over;
     char *cell;
+    afs_int32 rxgk_level = 0;
 
 #ifdef	AFS_AIX32_ENV
     /*
@@ -206,15 +202,17 @@ main(int argc, char **argv)
 	    strncpy(confdir, AFSDIR_CLIENT_ETC_DIRPATH, sizeof(confdir));
 	else if (IsArg("server"))
 	    strncpy(confdir, AFSDIR_SERVER_ETC_DIRPATH, sizeof(confdir));
-	else if (IsArg("0") || IsArg("1") || IsArg("2"))
+	else if (IsArg("0") || IsArg("1") || IsArg("2") || IsArg("3"))
 	    security = atoi(argv[n]);
+	else if (IsArg("-rxgk"))
+	    rxgk_level = atoi(argv[++n]);
 	else if (IsArg("-ignoreexist"))
 	    ignoreExist++;
 	else if (IsArg("-cell"))
 	    cell = argv[++n];
 	else {
 	    printf
-		("Usage is: 'prclient [-testconfdir <dir> | server | client] [0 | 1 | 2] [-ignoreExist] [-cell <cellname>]\n");
+		("Usage is: 'prclient [-testconfdir <dir> | server | client] [0 | 1 | 2 | 3] [-rxgk 0 | 1 | 2] [-ignoreExist] [-cell <cellname>]\n");
 	    exit(1);
 	}
 	n++;
@@ -224,7 +222,7 @@ main(int argc, char **argv)
     if (security == 0)
 	printf("Making unauthenticated connection to prserver\n");
 
-    code = pr_Initialize(security, confdir, cell);
+    code = pr_Initialize2(security, confdir, cell, rxgk_level);
     if (code) {
 	afs_com_err(whoami, code, "Couldn't initialize protection library");
 	exit(1);
@@ -305,16 +303,6 @@ main(int argc, char **argv)
 		printf("%s\n", pr_ErrorMsg(code));
 	    if (code == PRSUCCESS) {
 		PrintEntry(pos, &entry, /*indent */ 0);
-#if 0
-		printf("The contents of the entry for %d are:\n", entry.id);
-		printf("flags %d next %d\n", entry.flags, entry.next);
-		printf("Groups (or members) \n");
-		for (i = 0; i < PRSIZE; i++)
-		    printf("%d\n", entry.entries[i]);
-		printf("nextID %d nextname %d name %s\n", entry.nextID,
-		       entry.nextName, entry.name);
-		printf("owner %d creator %d\n", entry.owner, entry.creator);
-#endif
 	    }
 	} else if (!strcmp(op, "add") || !strcmp(op, "au")) {
 	    /* scanf("%d %d",&id,&gid); */
@@ -740,4 +728,3 @@ skip(char **s)
     while (**s == ' ')
 	(*s)++;
 }
-#endif /* !AFS_PTHREAD_ENV */
diff --git a/src/ptserver/ptint.xg b/src/ptserver/ptint.xg
index 100231dc0..fba32ccf1 100644
--- a/src/ptserver/ptint.xg
+++ b/src/ptserver/ptint.xg
@@ -103,8 +103,8 @@ const	PRUPDATE_IDHASH =	0x0010;
 %#define PR_SF_NUSERS  (1u<<30)		/*  "  "  foreign users  "  */
 
 /* OpenAFS implementation limit.  This limit can be modified in future releases
- * and does not need to match the limis applied by other implementations. */
-const OPENAFS_MAXPRLIST=50000;
+ * and does not need to match the limits applied by other implementations. */
+const OPENAFS_MAXPRLIST=500000;
 
 typedef char prname[PR_MAXNAMELEN];
 typedef prname namelist<OPENAFS_MAXPRLIST>;
diff --git a/src/ptserver/ptprocs.c b/src/ptserver/ptprocs.c
index 039077ac2..5eb1ac7fe 100644
--- a/src/ptserver/ptprocs.c
+++ b/src/ptserver/ptprocs.c
@@ -62,6 +62,7 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rxkad.h>
+#include <rx/rx_identity.h>
 #include <afs/auth.h>
 #include <afs/cellconfig.h>
 
@@ -438,15 +439,6 @@ dumpEntry(struct rx_call *call, afs_int32 apos, struct prdebugentry *aentry,
     if (!AccessOK(tt, *cid, 0, PRP_STATUS_MEM, 0))
 	ABORT_WITH(tt, PRPERM);
 
-    /* Since prdebugentry is in the form of a prentry not a coentry, we will
-     * return the coentry slots in network order where the string is. */
-#if 0
-    if (aentry->flags & PRCONT) {	/* wrong type, get coentry instead */
-	code = pr_ReadCoEntry(tt, 0, apos, aentry);
-	if (code)
-	    ABORT_WITH(tt, code);
-    }
-#endif
     code = ubik_EndTrans(tt);
     if (code)
 	return code;
@@ -651,7 +643,7 @@ idToName(struct rx_call *call, idlist *aid, namelist *aname, afs_int32 *cid)
 	return 0;
     if (size < 0 || size > INT_MAX / PR_MAXNAMELEN)
 	return PRTOOMANY;
-    aname->namelist_val = malloc(size * PR_MAXNAMELEN);
+    aname->namelist_val = calloc(size, PR_MAXNAMELEN);
     aname->namelist_len = 0;
     if (aname->namelist_val == 0)
 	return PRNOMEM;
@@ -739,6 +731,10 @@ Delete(struct rx_call *call, afs_int32 aid, afs_int32 *cid)
 	&& !IsAMemberOf(tt, *cid, tentry.owner) && !pr_noAuth)
 	ABORT_WITH(tt, PRPERM);
 
+    if (restricted && !IsAMemberOf(tt, *cid, SYSADMINID)) {
+        ABORT_WITH(tt, PRPERM);
+    }
+
     /* Delete each continuation block as a separate transaction so that no one
      * transaction become to large to complete. */
     nptr = tentry.next;
@@ -1238,7 +1234,7 @@ SPR_GetHostCPS(struct rx_call *call, afs_int32 ahost, prlist *alist,
 
     code = getHostCPS(call, ahost, alist, over, &cid);
     osi_auditU(call, PTS_GetHCPSEvent, code, AUD_HOST, htonl(ahost), AUD_END);
-    ViceLog(125, ("PTS_GetHostCPS: code %d ahost %d\n", code, ahost));
+    ViceLog(125, ("PTS_GetHostCPS: code %d ahost %u (0x%x)\n", code, ahost, ahost));
     return code;
 }
 
@@ -1538,6 +1534,7 @@ put_prentries(struct prentry *tentry, prentries *bulkentries)
     entry = bulkentries->prentries_val;
     entry += bulkentries->prentries_len;
 
+    memset(entry, 0, sizeof(*entry));
     entry->flags = tentry->flags >> PRIVATE_SHIFT;
     if (entry->flags == 0) {
 	entry->flags =
@@ -1552,7 +1549,6 @@ put_prentries(struct prentry *tentry, prentries *bulkentries)
     entry->nusers = tentry->nusers;
     entry->count = tentry->count;
     strncpy(entry->name, tentry->name, PR_MAXNAMELEN);
-    memset(entry->reserved, 0, sizeof(entry->reserved));
     bulkentries->prentries_len++;
     return 0;
 }
@@ -1791,10 +1787,6 @@ listSuperGroups(struct rx_call *call, afs_int32 aid, prlist *alist,
     if (!pr_noAuth && restrict_anonymous && *cid == ANONYMOUSID)
 	ABORT_WITH(tt, PRPERM);
 
-    code = ubik_SetLock(tt, 1, 1, LOCKREAD);
-    if (code)
-	ABORT_WITH(tt, code);
-
     temp = FindByID(tt, aid);
     if (!temp)
 	ABORT_WITH(tt, PRNOENT);
@@ -2048,15 +2040,15 @@ WhoIsThisWithName(struct rx_call *acall, struct ubik_trans *at, afs_int32 *aid,
 	    strcat(vname, inst);
 	}
 	if (!islocal) {
-	     if (strlen(vname) + strlen(tcell) + 1  >= sizeof(vname))
+	    if (strlen(vname) + strlen(tcell) + 1  >= sizeof(vname))
 		goto done;
-	     strcat(vname, "@");
-	     strcat(vname, tcell);
-	     lcstring(vname, vname, sizeof(vname));
-	     NameToID(at, vname, aid);
-	     if (aname)
+	    strcat(vname, "@");
+	    strcat(vname, tcell);
+	    lcstring(vname, vname, sizeof(vname));
+	    NameToID(at, vname, aid);
+	    if (aname)
 		strcpy(aname, vname);
-	     return 2;
+	    return 2;
 	}
 
 	if (strcmp(AUTH_SUPERUSER, vname) == 0)
@@ -2065,6 +2057,25 @@ WhoIsThisWithName(struct rx_call *acall, struct ubik_trans *at, afs_int32 *aid,
 	    lcstring(vname, vname, sizeof(vname));
 	    code = NameToID(at, vname, aid);
 	}
+
+    } else {
+        /* If we reached here, we don't understand the security class of the
+         * given call. But if the calling user is RX_ID_SUPERUSER, we can check
+         * that without even needing to understand the security class. Remember
+         * to only check for RX_ID_SUPERUSER specifically; we do not use
+         * SYSADMINID for other admins. */
+        int is_super;
+        struct rx_identity *id = NULL;
+        is_super = afsconf_SuperIdentity(prdir, acall, &id);
+        if (is_super && id->kind == RX_ID_SUPERUSER) {
+            *aid = SYSADMINID;
+            code = 0;
+        } else {
+            code = -1;
+        }
+        if (id != NULL) {
+            rx_identity_free(&id);
+        }
     }
   done:
     if (code && !pr_noAuth)
diff --git a/src/ptserver/pts.c b/src/ptserver/pts.c
index 0b7742d70..e749714ce 100644
--- a/src/ptserver/pts.c
+++ b/src/ptserver/pts.c
@@ -25,6 +25,7 @@
 #include <afs/cmd.h>
 #include <rx/rx.h>
 #include <rx/xdr.h>
+#include <rx/rxgk_int.h>
 
 #include "ptclient.h"
 #include "ptuser.h"
@@ -49,6 +50,24 @@ struct authstate {
     char cell[MAXCELLCHARS];
 };
 
+/*
+ * Constants for add_std_args() global parameters. Start at offset 16, to try
+ * to avoid conflicting with any subcommand-specific parameters. If any
+ * subcommand uses more than 16 params, these constants will probably need to
+ * change.
+ */
+enum {
+    OPT_cell	    = 16,
+    OPT_noauth	    = 17,
+    OPT_test	    = 18,
+    OPT_force	    = 19,
+    OPT_localauth   = 20,
+    OPT_auth	    = 21,
+    OPT_encrypt	    = 22,
+    OPT_config	    = 23,
+    OPT_rxgk	    = 24,
+};
+
 static int CleanUp(struct cmd_syndesc *as, void *arock);
 
 static int
@@ -167,6 +186,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
     afs_int32 sec;
     int changed = 0;
     const char* confdir;
+    RXGK_Level rxgk_level = RXGK_LEVEL_BOGUS;
 
     whoami = as->a0name;
 
@@ -182,23 +202,23 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
 	changed = 1;
     }
 
-    if (as->parms[16].items) {
+    if (as->parms[OPT_cell].items) {
 	changed = 1;
-	cell = as->parms[16].items->data;
+	cell = as->parms[OPT_cell].items->data;
     }
-    if (as->parms[17].items) { /* -noauth */
+    if (as->parms[OPT_noauth].items) {
 	changed = 1;
 	sec = 0;
     }
-    if (as->parms[20].items) { /* -localauth */
+    if (as->parms[OPT_localauth].items) {
 	changed = 1;
 	sec = 2;
     }
-    if (as->parms[21].items) { /* -auth */
+    if (as->parms[OPT_auth].items) {
 	changed = 1;
 	sec = 1;
     }
-    if (as->parms[22].items    /* -encrypt */
+    if (as->parms[OPT_encrypt].items
 #ifdef AFS_NT40_ENV
         || win32_enableCrypt()
 #endif /* AFS_NT40_ENV */
@@ -206,7 +226,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
 	changed = 1;
 	sec = 3;
     }
-    if (as->parms[18].items || as->parms[20].items) { /* -test, -localauth */
+    if (as->parms[OPT_test].items || as->parms[OPT_localauth].items) {
 	changed = 1;
 	confdir = AFSDIR_SERVER_ETC_DIRPATH;
     } else {
@@ -216,14 +236,31 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
 	    confdir = AFSDIR_CLIENT_ETC_DIRPATH;
     }
 
-    if (as->parms[23].items) { /* -config */
+    if (as->parms[OPT_config].items) { /* -config */
+	changed = 1;
+	confdir = as->parms[OPT_config].items->data;
+    }
+
+    if (as->parms[OPT_rxgk].items) {
+	char *rxgk_seclevel_str = as->parms[OPT_rxgk].items->data;
 	changed = 1;
-	confdir = as->parms[23].items->data;
+
+	if (strcmp(rxgk_seclevel_str, "clear") == 0)
+	    rxgk_level = RXGK_LEVEL_CLEAR;
+	else if (strcmp(rxgk_seclevel_str, "auth") == 0)
+	    rxgk_level = RXGK_LEVEL_AUTH;
+	else if (strcmp(rxgk_seclevel_str, "crypt") == 0)
+	    rxgk_level = RXGK_LEVEL_CRYPT;
+	else {
+	    fprintf(stderr, "Invalid argument to -rxgk: %s\n", rxgk_seclevel_str);
+	    return 1;
+	}
+
     }
 
     if (changed) {
 	CleanUp(as, arock);
-	code = pr_Initialize(sec, confdir, cell);
+	code = pr_Initialize2(sec, confdir, cell, rxgk_level);
     } else {
 	code = 0;
     }
@@ -237,7 +274,7 @@ GetGlobals(struct cmd_syndesc *as, void *arock)
         strncpy(state->cell, cell, MAXCELLCHARS-1);
 
     force = 0;
-    if (as->parms[19].items)
+    if (as->parms[OPT_force].items)
 	force = 1;
 
     return code;
@@ -366,98 +403,6 @@ CreateUser(struct cmd_syndesc *as, void *arock)
 }
 
 
-#ifdef notdef
-static int
-GetNameOrId(struct cmd_syndesc *as, struct idlist *lids, struct namelist *lnames)
-{
-    afs_int32 code = 0;
-    int n = 0;
-    struct cmd_item *i;
-    int goodCount;
-
-    if (!(as->parms[0].items || as->parms[1].items)) {
-	afs_com_err(whoami, 0, "must specify either a name or an id.");
-	return -1;
-    }
-    if (as->parms[0].items && as->parms[1].items) {
-	afs_com_err(whoami, 0, "can't specify both a name and id.");
-	return -1;
-    }
-
-    goodCount = 0;
-    lids->idlist_len = 0;
-    lids->idlist_val = 0;
-
-    if (as->parms[0].items) {	/* name */
-	struct namelist names;	/* local copy, if not ret. names */
-	struct namelist *nl;
-
-	names.namelist_val = 0;	/* so it gets freed later if needed */
-	if (lnames)
-	    nl = lnames;
-	else
-	    nl = &names;
-
-	n = 0;			/* count names */
-	for (i = as->parms[0].items; i; i = i->next)
-	    n++;
-	nl->namelist_val = malloc(n * PR_MAXNAMELEN);
-	nl->namelist_len = n;
-	n = 0;
-	for (i = as->parms[0].items; i; i = i->next)
-	    strncpy(nl->namelist_val[n++], i->data, PR_MAXNAMELEN);
-
-	code = pr_NameToId(nl, lids);
-	if (code)
-	    afs_com_err(whoami, code, "so couldn't look up names");
-	else {
-	    for (n = 0; n < lids->idlist_len; n++) {
-		if ((lids->idlist_val[n] == ANONYMOUSID)) {
-		    afs_com_err(whoami, PRNOENT, "so couldn't look up id for %s",
-			    nl->namelist_val[n]);
-		} else
-		    goodCount++;
-	    }
-	    /* treat things as working if any of the lookups worked */
-	    if (goodCount == 0)
-		code = PRNOENT;
-	}
-
-	if (names.namelist_val)
-	    free(names.namelist_val);
-    } else if (as->parms[1].items) {	/* id */
-	n = 0;
-	for (i = as->parms[1].items; i; i = i->next)
-	    n++;
-	lids->idlist_val = malloc(n * sizeof(afs_int32));
-	lids->idlist_len = n;
-	n = 0;
-	for (i = as->parms[1].items; i; i = i->next) {
-	    code = util_GetInt32(i->data, &lids->idlist_val[n]);
-	    if (code)
-		afs_com_err(whoami, code =
-			PRNOENT, "because a bogus id '%s' was specified",
-			i->data);
-	    n++;
-	}
-	if (!code && lnames) {
-	    lnames->namelist_val = 0;
-	    lnames->namelist_len = 0;
-	    code = pr_IdToName(lids, lnames);
-	    if (code)
-		afs_com_err(whoami, code, "translating ids");
-	}
-    }
-    if (code) {
-	if (lids->idlist_val)
-	    free(lids->idlist_val);
-	return -1;
-    }
-    return 0;
-}
-#endif
-
-
 static int
 GetNameOrId(struct cmd_syndesc *as, struct idlist *lids,
 	    struct namelist *lnames)
@@ -1078,19 +1023,24 @@ add_std_args(struct cmd_syndesc *ts)
 	test_help = strdup("use server config file");
     }
 
-    cmd_Seek(ts, 16);
-    cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
-    cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL, "run unauthenticated");
-    cmd_AddParm(ts, "-test", CMD_FLAG, CMD_OPTIONAL | CMD_HIDE, test_help);
-    cmd_AddParm(ts, "-force", CMD_FLAG, CMD_OPTIONAL,
-		"Continue oper despite reasonable errors");
-    cmd_AddParm(ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
-		"use local authentication");
-    cmd_AddParm(ts, "-auth", CMD_FLAG, CMD_OPTIONAL,
-		"use user's authentication (default)");
-    cmd_AddParm(ts, "-encrypt", CMD_FLAG, CMD_OPTIONAL,
-		"encrypt commands");
-    cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL, "config location");
+    cmd_AddParmAtOffset(ts, OPT_cell, "-cell", CMD_SINGLE, CMD_OPTIONAL,
+			"cell name");
+    cmd_AddParmAtOffset(ts, OPT_noauth, "-noauth", CMD_FLAG, CMD_OPTIONAL,
+			"run unauthenticated");
+    cmd_AddParmAtOffset(ts, OPT_test, "-test", CMD_FLAG,
+			CMD_OPTIONAL | CMD_HIDE, test_help);
+    cmd_AddParmAtOffset(ts, OPT_force, "-force", CMD_FLAG, CMD_OPTIONAL,
+			"Continue oper despite reasonable errors");
+    cmd_AddParmAtOffset(ts, OPT_localauth, "-localauth", CMD_FLAG,
+			CMD_OPTIONAL, "use local authentication");
+    cmd_AddParmAtOffset(ts, OPT_auth, "-auth", CMD_FLAG, CMD_OPTIONAL,
+			"use user's authentication (default)");
+    cmd_AddParmAtOffset(ts, OPT_encrypt, "-encrypt", CMD_FLAG, CMD_OPTIONAL,
+			"encrypt commands");
+    cmd_AddParmAtOffset(ts, OPT_config, "-config", CMD_SINGLE, CMD_OPTIONAL,
+			"config location");
+    cmd_AddParmAtOffset(ts, OPT_rxgk, "-rxgk", CMD_SINGLE, CMD_OPTIONAL,
+			"rxgk security level to use");
     free(test_help);
 }
 
diff --git a/src/ptserver/ptserver.c b/src/ptserver/ptserver.c
index 2ab437de6..c718eceae 100644
--- a/src/ptserver/ptserver.c
+++ b/src/ptserver/ptserver.c
@@ -116,7 +116,6 @@
 #include <afs/opr.h>
 #ifdef AFS_PTHREAD_ENV
 # include <opr/softsig.h>
-# include <afs/procmgmt_softsig.h> /* must come after softsig.h */
 #endif
 
 #ifdef AFS_NT40_ENV
@@ -234,7 +233,8 @@ enum optionsList {
     OPT_rxbind,
     OPT_rxmaxmtu,
     OPT_dotted,
-    OPT_transarc_logs
+    OPT_transarc_logs,
+    OPT_s2s_crypt
 };
 
 int
@@ -249,9 +249,11 @@ main(int argc, char **argv)
     afs_int32 numClasses;
     int lwps = 3;
     char clones[MAXHOSTSPERCELL];
+    char hoststr[16];
     afs_uint32 host = htonl(INADDR_ANY);
     struct cmd_syndesc *opts;
     struct cmd_item *list;
+    int s2s_rxgk = 0;
 
     char *pr_dbaseName;
     char *configDir;
@@ -260,6 +262,7 @@ main(int argc, char **argv)
 
     char *auditFileName = NULL;
     char *interface = NULL;
+    char *s2s_crypt_behavior = NULL;
 
 #ifdef	AFS_AIX32_ENV
     /*
@@ -350,7 +353,7 @@ main(int argc, char **argv)
 
     /* rx options */
     cmd_AddParmAtOffset(opts, OPT_peer, "-enable_peer_stats", CMD_FLAG,
-		        CMD_OPTIONAL, "enable RX transport statistics");
+		        CMD_OPTIONAL, "enable RX RPC statistics by peer");
     cmd_AddParmAtOffset(opts, OPT_process, "-enable_process_stats", CMD_FLAG,
 		        CMD_OPTIONAL, "enable RX RPC statistics");
     cmd_AddParmAtOffset(opts, OPT_rxbind, "-rxbind", CMD_FLAG,
@@ -363,6 +366,11 @@ main(int argc, char **argv)
 		        CMD_FLAG, CMD_OPTIONAL,
 		        "permit Kerberos 5 principals with dots");
 
+    /* rxgk options */
+    cmd_AddParmAtOffset(opts, OPT_s2s_crypt, "-s2scrypt", CMD_SINGLE,
+			CMD_OPTIONAL,
+			"rxgk-crypt | never");
+
     code = cmd_Parse(argc, argv, &opts);
     if (code == CMD_HELP) {
 	PT_EXIT(0);
@@ -459,6 +467,20 @@ main(int argc, char **argv)
     /* rxkad options */
     cmd_OptionAsFlag(opts, OPT_dotted, &rxkadDisableDotCheck);
 
+    /* rxgk options */
+    if (cmd_OptionAsString(opts, OPT_s2s_crypt, &s2s_crypt_behavior) == 0) {
+	if (strcmp(s2s_crypt_behavior, "never") == 0) {
+	    /* noop; this is the default */
+	} else if (strcmp(s2s_crypt_behavior, "rxgk-crypt") == 0) {
+	    s2s_rxgk = 1;
+	} else {
+	    fprintf(stderr, "Invalid argument for -s2scrypt: %s\n", s2s_crypt_behavior);
+	    PT_EXIT(1);
+	}
+	free(s2s_crypt_behavior);
+	s2s_crypt_behavior = NULL;
+    }
+
     cmd_FreeOptions(&opts);
 
     if (auditFileName) {
@@ -512,7 +534,13 @@ main(int argc, char **argv)
     osi_audit_set_user_check(prdir, pr_IsLocalRealmMatch);
 
     /* initialize ubik */
-    ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, prdir);
+    if (s2s_rxgk) {
+	ubik_SetClientSecurityProcs(afsconf_ClientAuthRXGKCrypt,
+				    afsconf_UpToDate, prdir);
+    } else {
+	ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate,
+				    prdir);
+    }
     ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
 				afsconf_CheckAuth, prdir);
 
@@ -541,14 +569,17 @@ main(int argc, char **argv)
 	}
 	if (ccode == 1) {
 	    host = SHostAddrs[0];
-	    /* the following call is idempotent so if/when it gets called
-	     * again by the ubik init stuff, it doesn't really matter
-	     * -- klm
-	     */
-	    rx_InitHost(host, htons(AFSCONF_PROTPORT));
 	}
     }
 
+    ViceLog(0, ("ptserver binding rx to %s:%d\n",
+            afs_inet_ntoa_r(host, hoststr), AFSCONF_PROTPORT));
+    code = rx_InitHost(host, htons(AFSCONF_PROTPORT));
+    if (code < 0) {
+	ViceLog(0, ("ptserver: Rx init failed: %d\n", code));
+	PT_EXIT(1);
+    }
+
     /* Disable jumbograms */
     rx_SetNoJumbo();
 
@@ -583,8 +614,12 @@ main(int argc, char **argv)
     rx_SetMinProcs(tservice, 2);
     rx_SetMaxProcs(tservice, lwps);
     if (rxkadDisableDotCheck) {
-        rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
-                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	code = rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
+					   (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	if (code) {
+	    afs_com_err(whoami, code, "Failed to allow dotted principals");
+	    PT_EXIT(3);
+	}
     }
 
     tservice =
@@ -607,7 +642,11 @@ main(int argc, char **argv)
 		   "1.0",
 #endif
 		   "Starting AFS", FSLog);
-    if (afsconf_GetLatestKey(prdir, NULL, NULL) == 0) {
+    if (afsconf_CountKeys(prdir) == 0) {
+	ViceLog(0, ("WARNING: No encryption keys found! "
+		    "All authenticated accesses will fail. "
+		    "Run akeyconvert or asetkey to import encryption keys.\n"));
+    } else if (afsconf_GetLatestKey(prdir, NULL, NULL) == 0) {
 	LogDesWarning();
     }
 
diff --git a/src/ptserver/ptubik.c b/src/ptserver/ptubik.c
index 9d2d9169e..8e8dfe3fb 100644
--- a/src/ptserver/ptubik.c
+++ b/src/ptserver/ptubik.c
@@ -92,13 +92,6 @@ ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen,
     return (0);
 }
 
-int
-ubik_WaitVersion(struct ubik_dbase *adatabase,
-                 struct ubik_version *aversion)
-{
-    return (0);
-}
-
 int
 ubik_CheckCache(struct ubik_trans *atrans, ubik_updatecache_func cbf, void *rock)
 {
@@ -115,18 +108,10 @@ panic(char *format, ...)
     va_end(ap);
 
     abort();
-    printf("BACK FROM ABORT\n");	/* shouldn't come back from floating pt exception */
-    exit(1);			/* never know, though */
+    AFS_UNREACHED(printf("BACK FROM ABORT\n"));	/* shouldn't come back from floating pt exception */
+    AFS_UNREACHED(exit(1));			/* never know, though */
 }
 
-int
-ubik_GetVersion(struct ubik_trans *dummy, struct ubik_version *ver)
-{
-    memset(ver, 0, sizeof(struct ubik_version));
-    return (0);
-}
-
-
 int
 ubik_Seek(struct ubik_trans *tt, afs_int32 afd, afs_int32 pos)
 {
diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c
index 7df92916a..6e990576f 100644
--- a/src/ptserver/ptuser.c
+++ b/src/ptserver/ptuser.c
@@ -20,6 +20,7 @@
 #include <afs/cellconfig.h>
 #include <afs/afsutil.h>
 #include <afs/com_err.h>
+#include <rx/rxgk_int.h>
 
 #include "ptclient.h"
 #include "ptuser.h"
@@ -173,6 +174,13 @@ CreateIdList(struct idhash *idhash, idlist * alist, afs_int32 select)
 
 afs_int32
 pr_Initialize(IN afs_int32 secLevel, IN const char *confDir, IN char *cell)
+{
+    return pr_Initialize2(secLevel, confDir, cell, RXGK_LEVEL_BOGUS);
+}
+
+afs_int32
+pr_Initialize2(IN afs_int32 secLevel, IN const char *confDir, IN char *cell,
+	       int rxgk_level)
 {
     afs_int32 code;
     struct rx_connection *serverconns[MAXSERVERS];
@@ -187,6 +195,7 @@ pr_Initialize(IN afs_int32 secLevel, IN const char *confDir, IN char *cell)
     char cellstr[64];
     afs_int32 gottdir = 0;
     afs_int32 refresh = 0;
+    int use_rxgk = 0;
 
     initialize_PT_error_table();
     initialize_RXK_error_table();
@@ -250,8 +259,8 @@ pr_Initialize(IN afs_int32 secLevel, IN const char *confDir, IN char *cell)
 
 	code = afsconf_GetCellInfo(tdir, cell, "afsprot", &info);
 	if (code) {
-	    fprintf(stderr, "libprot: Could not locate cell %s in %s/%s\n",
-		    cell, confDir, AFSDIR_CELLSERVDB_FILE);
+	    fprintf(stderr, "libprot: Could not locate cell %s in %s\n",
+		    cell, tdir->cellservDB);
 	    return code;
 	}
     }
@@ -270,10 +279,31 @@ pr_Initialize(IN afs_int32 secLevel, IN const char *confDir, IN char *cell)
 	return code;
     }
 
+    switch (rxgk_level) {
+    case RXGK_LEVEL_CLEAR:
+    case RXGK_LEVEL_AUTH:
+    case RXGK_LEVEL_CRYPT:
+	use_rxgk = 1;
+	if (secLevel != 2) {
+	    fprintf(stderr, "libprot: Cannot use rxgk with non-localauth right now\n");
+	    return EINVAL;
+	}
+    }
+
     /* Most callers use secLevel==1, however, the fileserver uses secLevel==2
      * to force use of the KeyFile.  secLevel == 0 implies -noauth was
      * specified. */
-    if (secLevel == 2) {
+    if (use_rxgk) {
+	switch (rxgk_level) {
+	case RXGK_LEVEL_CLEAR: code = afsconf_ClientAuthRXGKClear(tdir, &sc, &scIndex);
+			       break;
+	case RXGK_LEVEL_AUTH:  code = afsconf_ClientAuthRXGKAuth(tdir, &sc, &scIndex);
+			       break;
+	case RXGK_LEVEL_CRYPT: code = afsconf_ClientAuthRXGKCrypt(tdir, &sc, &scIndex);
+	}
+	if (code)
+	    afs_com_err(whoami, code, "(calling client rxgk)");
+    } else if (secLevel == 2) {
 	/* If secLevel is two assume we're on a file server and use
 	 * ClientAuthSecure if possible. */
 	code = afsconf_ClientAuthSecure(tdir, &sc, &scIndex);
diff --git a/src/ptserver/ptuser.h b/src/ptserver/ptuser.h
index 6e1ebff34..80d89153f 100644
--- a/src/ptserver/ptuser.h
+++ b/src/ptserver/ptuser.h
@@ -15,6 +15,8 @@
 /* ptuser.c */
 extern afs_int32 pr_Initialize(afs_int32 secLevel, const char *confDir,
  			       char *cell);
+extern afs_int32 pr_Initialize2(afs_int32 secLevel, const char *confDir,
+				char *cell, int rxgk_level);
 extern int pr_End(void);
 extern int pr_CreateUser(prname name, afs_int32 *id) AFS_NONNULL();
 extern int pr_CreateGroup(prname name, prname owner,
diff --git a/src/ptserver/ptutils.c b/src/ptserver/ptutils.c
index 511f57af5..c551c62b9 100644
--- a/src/ptserver/ptutils.c
+++ b/src/ptserver/ptutils.c
@@ -286,8 +286,17 @@ AccessOK(struct ubik_trans *ut, afs_int32 cid,		/* caller id */
 	return 1;
     if (cid == SYSADMINID)
 	return 1;		/* special case fileserver */
-    if (restricted && ((mem == PRP_ADD_MEM) || (mem == PRP_REMOVE_MEM)) && (any == 0))
-	return 0;
+    if (restricted && !IsAMemberOf(ut, cid, SYSADMINID)) {
+        if (mem == PRP_ADD_MEM || mem == PRP_REMOVE_MEM) {
+            /* operation is for adding/removing members from a group */
+            return 0;
+        }
+        if (mem == 0 && any == 0) {
+            /* operation is for modifying an entry (or some administrative
+             * global operations) */
+            return 0;
+        }
+    }
     if (tentry) {
 	flags = tentry->flags;
 	oid = tentry->owner;
diff --git a/src/ptserver/testpt.c b/src/ptserver/testpt.c
index c9d60c200..eaaee48f1 100644
--- a/src/ptserver/testpt.c
+++ b/src/ptserver/testpt.c
@@ -255,7 +255,7 @@ void
 CreateGroup(int g)
 {
     afs_int32 code;
-    char name[16];
+    char name[PR_MAXNAMELEN + 1];
     afs_int32 id = 0;
     afs_int32 owner = 0;
     char *ownerName = NULL;
@@ -286,7 +286,12 @@ CreateGroup(int g)
 	break;
     }
 
-    sprintf(name, "%s:%s%d", ownerName, createPrefix, g);
+    code = snprintf(name, sizeof(name), "%s:%s%d", ownerName, createPrefix, g);
+    if (code >= sizeof(name)) {
+	fprintf(stderr, "%s: generated group name is too long: %s:%s%d\n",
+		whoami, ownerName, createPrefix, g);
+	exit(13);
+    }
     code = ubik_PR_NewEntry(pruclient, 0, name, PRGRP, owner, &id);
     if (code) {
 	if (code == PREXIST) {
@@ -440,18 +445,6 @@ TestManyMembers(struct cmd_syndesc *as, void *arock)
 	    if ((code == 0) && (callerId == ANONYMOUSID))
 		code = PRNOENT;
 	}
-#if 0				/* don't create user */
-	if (code == PRNOENT) {
-	    callerId = 0;
-	    code = pr_CreateUser(callerName, &callerId);
-	    if (code) {
-		afs_com_err(whoami, code, "can't create caller %s", callerName);
-		exit(5);
-	    }
-	    printf("Creating caller %s (%di)\n", callerName, callerId);
-	}
-	/* else */
-#endif
 	if (code) {
 	    afs_com_err(whoami, code, "can't find caller %s", callerName);
 	    exit(6);
@@ -981,7 +974,7 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
 	code = mkdir(tmp_conf_dir, 0777);
 	if ((code < 0) && (errno != EEXIST)) {
 	    afs_com_err(whoami, errno, "can't create temporary afsconf dir: %s",
-		    cdir);
+		    tmp_conf_dir);
 	    return errno;
 	}
 
diff --git a/src/roken/Makefile.in b/src/roken/Makefile.in
index 873746b12..0a36d1fe3 100644
--- a/src/roken/Makefile.in
+++ b/src/roken/Makefile.in
@@ -22,28 +22,31 @@ HEADERS = ${TOP_INCDIR}/base64.h \
 
 UPSTREAM = $(TOP_SRCDIR)/external/heimdal/roken
 
+@SHARED_ONLY@SHARED_LIBS = librokenafs.la
+@SHARED_ONLY@SHARED_SHLIBS_TOP = $(TOP_LIBDIR)/librokenafs.$(SHLIB_SUFFIX)
+
 # TOP_LIBDIR is a convenient place where we can ensure that both the shared
 # and static versions of the library will end up (I'm looking at you, AIX).
 # Otherwise we could just use .libs directly, since only openafs-internal
 # tools will be linking roken from that directory.
-all: $(ROKEN_HEADERS) $(HEADERS) $(TOP_LIBDIR)/librokenafs.$(SHLIB_SUFFIX) \
+all: $(ROKEN_HEADERS) $(HEADERS) $(SHARED_SHLIBS_TOP) \
 	$(TOP_LIBDIR)/librokenafs.a
 
 buildtools: $(ROKEN_HEADERS) $(HEADERS)
 
-install: librokenafs.la librokenafs.a
-	$(LT_INSTALL_DATA) librokenafs.la $(DESTDIR)$(libdir)/librokenafs.la
-	$(RM) $(DESTDIR)$(libdir)/librokenafs.la
+install: $(SHARED_LIBS) librokenafs.a
+	@SHARED_ONLY@$(LT_INSTALL_DATA) librokenafs.la $(DESTDIR)$(libdir)/librokenafs.la
+	@SHARED_ONLY@$(RM) $(DESTDIR)$(libdir)/librokenafs.la
 	$(INSTALL_DATA) librokenafs.a $(DESTDIR)$(libdir)/librokenafs.a
 
-dest: librokenafs.la librokenafs.a
-	$(LT_INSTALL_DATA) librokenafs.la $(DEST)/lib/librokenafs.la
-	$(RM) $(DEST)/lib/librokenafs.la
+dest: $(SHARED_LIBS) librokenafs.a
+	@SHARED_ONLY@$(LT_INSTALL_DATA) librokenafs.la $(DEST)/lib/librokenafs.la
+	@SHARED_ONLY@$(RM) $(DEST)/lib/librokenafs.la
 	$(INSTALL_DATA) librokenafs.a $(DEST)/lib/librokenafs.a
 
 clean:
 	$(LT_CLEAN)
-	$(RM) -f $(OBJECTS) librokenafs.a err.h
+	$(RM) -f $(OBJECTS) librokenafs.a err.h roken.h
 
 $(TOP_LIBDIR)/librokenafs.$(SHLIB_SUFFIX): librokenafs.la
 	$(LT_INSTALL_DATA) librokenafs.la $(TOP_LIBDIR)/librokenafs.la
@@ -65,7 +68,7 @@ $(TOP_INCDIR)/base64.h: ${UPSTREAM}/base64.h
 $(TOP_INCDIR)/err.h: ${UPSTREAM}/err.hin
 	$(INSTALL_DATA) $? $@
 
-$(TOP_INCDIR)/roken.h: $(UPSTREAM)/roken.h.in
+$(TOP_INCDIR)/roken.h: roken.h
 	$(INSTALL_DATA) $? $@
 
 $(TOP_INCDIR)/roken-common.h: $(UPSTREAM)/roken-common.h
@@ -74,6 +77,9 @@ $(TOP_INCDIR)/roken-common.h: $(UPSTREAM)/roken-common.h
 err.h: ${UPSTREAM}/err.hin
 	$(INSTALL_DATA) $? $@
 
+roken.h: $(UPSTREAM)/roken.h.in roken-post.h
+	cat $(UPSTREAM)/roken.h.in $(srcdir)/roken-post.h >$@
+
 # Here we have explicit rules for all the libtool objects we might need to
 # build.  The implicit rules don't work since the sources are in a different
 # castle.
diff --git a/src/roken/roken-post.h b/src/roken/roken-post.h
new file mode 100644
index 000000000..076eed327
--- /dev/null
+++ b/src/roken/roken-post.h
@@ -0,0 +1,8 @@
+/*
+ * roken defines an empty __attribute__() macro when the format
+ * attribute is not available.  Undefine this empty __attribute__() macro
+ * to to allow other types of attributes in code which includes roken.h.
+ */
+#ifdef __attribute__
+#undef __attribute__
+#endif
diff --git a/src/rx/AIX/rx_knet.c b/src/rx/AIX/rx_knet.c
index 6ac9cdffa..54a6c8583 100644
--- a/src/rx/AIX/rx_knet.c
+++ b/src/rx/AIX/rx_knet.c
@@ -200,21 +200,6 @@ rxk_RX_input(struct mbuf *am)
 	    m_freem(am);
 	    return;
 	}
-#else
-#ifdef notdef
-	{			/* in_cksum() doesn't work correctly or the length is wrong? */
-	    int cksum;
-	    int glockOwner = ISAFS_GLOCK();
-	    cksum = in_cksum(am, sizeof(struct ip) + tlen);
-	    if (!glockOwner)
-		AFS_GLOCK();
-	    afs_Trace3(afs_iclSetp, CM_TRACE_WASHERE, ICL_TYPE_STRING,
-		       __FILE__, ICL_TYPE_INT32, __LINE__, ICL_TYPE_INT32,
-		       cksum);
-	    if (!glockOwner)
-		AFS_GUNLOCK();
-	}
-#endif
 #endif
     }
 
diff --git a/src/rx/DARWIN/rx_knet.c b/src/rx/DARWIN/rx_knet.c
index 8cc24c8e9..9952957be 100644
--- a/src/rx/DARWIN/rx_knet.c
+++ b/src/rx/DARWIN/rx_knet.c
@@ -22,8 +22,6 @@
 #endif
 
 #ifdef RXK_UPCALL_ENV
-extern rx_atomic_t rxinit_status;
-
 void
 rx_upcall(socket_t so, void *arg, __unused int waitflag)
 {
@@ -41,7 +39,7 @@ rx_upcall(socket_t so, void *arg, __unused int waitflag)
     size_t nbytes, resid, noffset;
 
     /* we stopped rx but the socket isn't closed yet */
-    if (rx_atomic_test_bit(&rxinit_status, 0))
+    if (!rxi_IsRunning())
 	return;
 
     /* See if a check for additional packets was issued */
@@ -154,7 +152,6 @@ rx_upcall(socket_t so, void *arg, __unused int waitflag)
 void
 osi_StopNetIfPoller(void)
 {
-    shutdown_rx();
     soclose(rx_socket);
     if (afs_termState == AFSOP_STOP_NETIF) {
 	afs_termState = AFSOP_STOP_COMPLETE;
diff --git a/src/rx/FBSD/rx_kmutex.h b/src/rx/FBSD/rx_kmutex.h
index 660494c86..a10b469be 100644
--- a/src/rx/FBSD/rx_kmutex.h
+++ b/src/rx/FBSD/rx_kmutex.h
@@ -18,12 +18,8 @@
 
 #include <sys/systm.h>
 #include <sys/proc.h>
-#ifdef AFS_FBSD70_ENV
 #include <sys/lock.h>
 #include <sys/lockmgr.h>
-#else
-#include <sys/lock.h>
-#endif
 
 #define RX_ENABLE_LOCKS         1
 
@@ -58,11 +54,11 @@ typedef struct {
 
 #define MUTEX_ASSERT(a) osi_Assert(((afs_kmutex_t *)(a))->owner == curproc)
 
-#elif defined(AFS_FBSD70_ENV) /* dunno about 6.x */
+#else /* NULL_LOCKS */
 
 typedef struct mtx afs_kmutex_t;
 
-#if defined(AFS_FBSD80_ENV) && defined(WITNESS)
+#ifdef WITNESS
 #define WITCLEAR_MTX(a)					\
     do { memset((a), 0, sizeof(struct mtx)); } while(0)
 #else
@@ -96,42 +92,7 @@ typedef struct mtx afs_kmutex_t;
 #define MUTEX_ASSERT(a)				\
     osi_Assert(mtx_owned((a)))
 
-#else
-
-typedef struct {
-    struct lock lock;
-    struct thread *owner;
-} afs_kmutex_t;
-
-
-#define MUTEX_INIT(a,b,c,d) \
-    do { \
-	lockinit(&(a)->lock,PSOCK, "afs rx mutex", 0, 0); \
-	(a)->owner = 0; \
-    } while(0)
-#define MUTEX_DESTROY(a) \
-    do { \
-	(a)->owner = (struct proc *)-1; \
-    } while(0)
-#define MUTEX_ENTER(a) \
-    do { \
-	lockmgr(&(a)->lock, LK_EXCLUSIVE, 0, curthread); \
-	osi_Assert((a)->owner == 0); \
-	(a)->owner = curthread; \
-    } while(0)
-#define MUTEX_TRYENTER(a) \
-    ( lockmgr(&(a)->lock, LK_EXCLUSIVE|LK_NOWAIT, 0, curthread) ? 0 : ((a)->owner = curthread, 1) )
-#define xMUTEX_TRYENTER(a) \
-    ( osi_Assert((a)->owner == 0), (a)->owner = curthread, 1)
-#define MUTEX_EXIT(a) \
-    do { \
-	osi_Assert((a)->owner == curthread); \
-	(a)->owner = 0; \
-	lockmgr(&(a)->lock, LK_RELEASE, 0, curthread); \
-    } while(0)
-
-#define MUTEX_ASSERT(a) osi_Assert(((afs_kmutex_t *)(a))->owner == curthread)
-#endif
+#endif /* !NULL_LOCKS */
 
 /*
  * Condition variables
@@ -143,8 +104,6 @@ typedef struct {
 #define CV_INIT(cv,a,b,c)
 #define CV_DESTROY(cv)
 
-#if defined(AFS_FBSD70_ENV)
-
 #define CV_WAIT(cv, lck)    { \
     int isGlockOwner = ISAFS_GLOCK();					\
     if (isGlockOwner) AFS_GUNLOCK();					\
@@ -158,26 +117,6 @@ typedef struct {
 	                        msleep(cv, lck, PSOCK, "afs_rx_cv_timedwait", t); \
 	                        if (isGlockOwner) AFS_GLOCK();  \
 				}
-#else /* !AFS_FBSD70_ENV */
-#define CV_WAIT(cv, lck)    { \
-	                        int isGlockOwner = ISAFS_GLOCK(); \
-	                        if (isGlockOwner) AFS_GUNLOCK();  \
-	                        MUTEX_EXIT(lck);        \
-	                        tsleep(cv, PSOCK, "afs_rx_cv_wait", 0);  \
-	                        if (isGlockOwner) AFS_GLOCK();  \
-	                        MUTEX_ENTER(lck); \
-	                    }
-
-#define CV_TIMEDWAIT(cv,lck,t)  { \
-	                        int isGlockOwner = ISAFS_GLOCK(); \
-	                        if (isGlockOwner) AFS_GUNLOCK();  \
-	                        MUTEX_EXIT(lck);        \
-	                        tsleep(cv, PSOCK, "afs_rx_cv_timedwait", t); \
-	                        if (isGlockOwner) AFS_GLOCK();  \
-	                        MUTEX_ENTER(lck);       \
-				}
-#endif /* AFS_FBSD80_ENV */
-
 #define CV_SIGNAL(cv)           wakeup_one(cv)
 #define CV_BROADCAST(cv)        wakeup(cv)
 
diff --git a/src/rx/FBSD/rx_knet.c b/src/rx/FBSD/rx_knet.c
index 1e8a013c9..5d4b304a5 100644
--- a/src/rx/FBSD/rx_knet.c
+++ b/src/rx/FBSD/rx_knet.c
@@ -96,11 +96,7 @@ osi_StopListener(void)
     p = pfind(rxk_ListenerPid);
     if (p) {
 	afs_warn("osi_StopListener: rxk_ListenerPid %u\n", rxk_ListenerPid);
-#if (__FreeBSD_version >= 900044)
 	kern_psignal(p, SIGUSR1);
-#else
-	psignal(p, SIGUSR1);
-#endif
 	PROC_UNLOCK(p);
     } else
 	afs_warn("osi_StopListener: rxk_Listener not found (pid %u)\n",
@@ -197,11 +193,6 @@ rxk_init()
     last = inetdomain.dom_protoswNPROTOSW;
     for (tpro = inetdomain.dom_protosw; tpro < last; tpro++)
 	if (tpro->pr_protocol == IPPROTO_UDP) {
-#if 0				/* not exported */
-	    /* force UDP checksumming on for AFS    */
-	    extern int udpcksum;
-	    udpcksum = 1;
-#endif
 	    memcpy(&parent_proto, tpro, sizeof(parent_proto));
 	    tpro->pr_input = rxk_input;
 	    tpro->pr_fasttimo = rxk_fasttimo;
diff --git a/src/rx/HPUX/rx_kmutex.h b/src/rx/HPUX/rx_kmutex.h
index 89ebaf023..0eeb79e68 100644
--- a/src/rx/HPUX/rx_kmutex.h
+++ b/src/rx/HPUX/rx_kmutex.h
@@ -73,48 +73,6 @@ extern lock_t *rx_sleepLock;
 	} while(0)
 
 
-#if 0
-#define CV_WAIT(cv, lck) \
-    do { \
-        int code; \
-        ksleep_prepare(); \
-        MP_SPINLOCK(rx_sleepLock); \
-        if (!b_owns_sema(lck)) \
-            osi_Panic("mutex not held \n"); \
-        b_vsema(lck); \
-        code = ksleep_one(PCATCH | KERNEL_ADDRESS | KERN_SPINLOCK_OBJECT, \
-            (cv), rx_sleepLock, 0); \
-        if (code) { \
-            if (code == EINTR) { /* lock still held */ \
-                MP_SPINUNLOCK(rx_sleepLock); \
-            } else if (code != -EINTR) { \
-                osi_Panic("ksleep_one failed: code = %d \n", code); \
-            } \
-        } \
-        b_psema(lck); /* grab the mutex again */ \
-    } while(0)
-
-/* Wakes up a thread waiting on this condition */
-#define CV_SIGNAL(cv) \
-    do { \
-        int wo, code; \
-        MP_SPINLOCK(rx_sleepLock); \
-        if ((code = kwakeup_one(KERNEL_ADDRESS, (cv), WAKEUP_ONE, &wo)) < 0) \
-            osi_Panic("kwakeup_one failed: code = %d \n", code); \
-        MP_SPINUNLOCK(rx_sleepLock); \
-    } while (0)
-
-/* Wakes up all threads waiting on this condition */
-#define CV_BROADCAST(cv) \
-    do { \
-        int wo, code; \
-        MP_SPINLOCK(rx_sleepLock); \
-        if ((code = kwakeup_one(KERNEL_ADDRESS, (cv), WAKEUP_ALL, &wo)) < 0) \
-            osi_Panic("kwakeup_all failed: code = %d \n", code); \
-        MP_SPINUNLOCK(rx_sleepLock); \
-    } while (0)
-#endif /* 0 */
-
 #define CV_DESTROY(a)
 
 /* We now use beta semaphores for mutexes */
diff --git a/src/rx/LINUX/rx_knet.c b/src/rx/LINUX/rx_knet.c
index dea64fb38..50607c8f5 100644
--- a/src/rx/LINUX/rx_knet.c
+++ b/src/rx/LINUX/rx_knet.c
@@ -34,7 +34,6 @@
 #include <linux/errqueue.h>
 #include <linux/icmp.h>
 #endif
-
 #include "osi_compat.h"
 
 /* rxk_NewSocket
@@ -76,14 +75,10 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
 	return NULL;
     }
 
-    kernel_setsockopt(sockp, SOL_IP, IP_MTU_DISCOVER, (char *)&pmtu,
-		      sizeof(pmtu));
+    afs_linux_sock_set_mtu_discover(sockp, pmtu);
+
 #ifdef AFS_RXERRQ_ENV
-    {
-	int recverr = 1;
-	kernel_setsockopt(sockp, SOL_IP, IP_RECVERR, (char *)&recverr,
-	                  sizeof(recverr));
-    }
+    afs_linux_sock_set_recverr(sockp);
 #endif
     return (osi_socket *)sockp;
 }
@@ -272,7 +267,7 @@ osi_StopListener(void)
     while (rxk_ListenerTask) {
         if (rxk_ListenerTask) {
 	    flush_signals(rxk_ListenerTask);
-	    force_sig(SIGKILL, rxk_ListenerTask);
+	    send_sig(SIGKILL, rxk_ListenerTask, 1);
 	}
 	if (!rxk_ListenerTask)
 	    break;
diff --git a/src/rx/Makefile.in b/src/rx/Makefile.in
index abb54d487..1f5697540 100644
--- a/src/rx/Makefile.in
+++ b/src/rx/Makefile.in
@@ -10,7 +10,7 @@ include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.lwp
 include @TOP_OBJDIR@/src/config/Makefile.lwptool
 
-MODULE_CFLAGS=$(RXDEBUG)
+MODULE_CFLAGS=$(RXDEBUG) -DRX_REFCOUNT_CHECK
 
 LT_objs = xdr.lo xdr_array.lo xdr_rx.lo xdr_mem.lo xdr_len.lo xdr_afsuuid.lo \
 	  xdr_int32.lo xdr_int64.lo xdr_update.lo xdr_refernce.lo \
@@ -18,6 +18,7 @@ LT_objs = xdr.lo xdr_array.lo xdr_rx.lo xdr_mem.lo xdr_len.lo xdr_afsuuid.lo \
 	  rx_pthread.lo rx.lo rx_null.lo rx_globals.lo rx_getaddr.lo rx_misc.lo \
 	  rx_packet.lo rx_peer.lo rx_rdwr.lo rx_trace.lo rx_conncache.lo \
 	  rx_opaque.lo rx_identity.lo rx_stats.lo rx_multi.lo \
+	  rx_stubs.lo \
 	  AFS_component_version_number.lo
 LT_deps = $(top_builddir)/src/opr/liboafs_opr.la
 LT_libs = $(MT_LIBS)
@@ -47,7 +48,7 @@ librx.a: $(LT_objs)
 liboafs_rx.la: liboafs_rx.la.sym $(LT_objs) $(LT_deps)
 	$(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
 
-# Convenience libraries for libafsrpc and shlibafsrpc
+# Convenience libraries for libafsrpc
 librx_pic.la: $(LT_objs)
 	$(LT_LDLIB_pic) $(LT_objs)
 
diff --git a/src/rx/NBSD/rx_knet.c b/src/rx/NBSD/rx_knet.c
index 6ee14101b..4d6a20504 100644
--- a/src/rx/NBSD/rx_knet.c
+++ b/src/rx/NBSD/rx_knet.c
@@ -39,9 +39,6 @@ osi_NetReceive(osi_socket asocket, struct sockaddr_in *addr,
     u.uio_resid = *alength;
     UIO_SETUP_SYSSPACE(&u);
     u.uio_rw = UIO_READ;
-#if 0
-    u.uio_procp = NULL;
-#endif
     if (glocked)
 	AFS_GUNLOCK();
     code = soreceive(asocket, (addr ? &nam : NULL), &u, NULL, NULL, NULL);
@@ -113,9 +110,6 @@ osi_NetSend(osi_socket asocket, struct sockaddr_in *addr, struct iovec *dvec,
     u.uio_resid = alength;
     UIO_SETUP_SYSSPACE(&u);
     u.uio_rw = UIO_WRITE;
-#if 0
-    u.uio_procp = NULL;
-#endif
     nam = m_get(M_DONTWAIT, MT_SONAME);
     if (!nam)
 	return ENOBUFS;
diff --git a/src/rx/SUNOS/rx_kmutex.h b/src/rx/SUNOS/rx_kmutex.h
deleted file mode 100644
index 89b35272a..000000000
--- a/src/rx/SUNOS/rx_kmutex.h
+++ /dev/null
@@ -1 +0,0 @@
-#error kernel code not supported on SunOS 4
diff --git a/src/rx/SUNOS/rx_knet.c b/src/rx/SUNOS/rx_knet.c
deleted file mode 100644
index a55f44dba..000000000
--- a/src/rx/SUNOS/rx_knet.c
+++ /dev/null
@@ -1 +0,0 @@
-#error kernel code not supported on SunOS 4 
diff --git a/src/rx/liboafs_rx.la.sym b/src/rx/liboafs_rx.la.sym
index 6bf9f728b..90c2263b8 100644
--- a/src/rx/liboafs_rx.la.sym
+++ b/src/rx/liboafs_rx.la.sym
@@ -33,6 +33,7 @@ rx_FlushWrite
 rx_FreeStatistics
 rx_GetCachedConnection
 rx_GetCallAbortCode
+rx_GetCallStatus
 rx_GetConnection
 rx_GetConnectionEpoch
 rx_GetConnectionId
@@ -40,6 +41,7 @@ rx_GetIFInfo
 rx_GetNetworkError
 rx_GetSecurityData
 rx_GetSecurityHeaderSize
+rx_GetServiceSpecific
 rx_GetSpecific
 rx_GetStatistics
 rx_GetThreadNum
@@ -88,6 +90,7 @@ rx_SetSecurityConfiguration
 rx_SetSecurityData
 rx_SetSecurityHeaderSize
 rx_SetSecurityMaxTrailerSize
+rx_SetServiceSpecific
 rx_SetSpecific
 rx_SetThreadNum
 rx_SlowGetInt32
diff --git a/src/rx/rx.c b/src/rx/rx.c
index c7742fab1..0b548ff5b 100644
--- a/src/rx/rx.c
+++ b/src/rx/rx.c
@@ -152,7 +152,7 @@ static void rxi_ScheduleNatKeepAliveEvent(struct rx_connection *conn);
 static void rxi_ScheduleGrowMTUEvent(struct rx_call *call, int secs);
 static void rxi_KeepAliveOn(struct rx_call *call);
 static void rxi_GrowMTUOn(struct rx_call *call);
-static void rxi_ChallengeOn(struct rx_connection *conn);
+static int rxi_ChallengeOn(struct rx_connection *conn);
 static int rxi_CheckCall(struct rx_call *call, int haveCTLock);
 static void rxi_AckAllInTransmitQueue(struct rx_call *call);
 static void rxi_CancelKeepAliveEvent(struct rx_call *call);
@@ -160,6 +160,12 @@ static void rxi_CancelDelayedAbortEvent(struct rx_call *call);
 static void rxi_CancelGrowMTUEvent(struct rx_call *call);
 static void update_nextCid(void);
 
+#ifndef KERNEL
+static void rxi_Finalize_locked(void);
+#elif defined(UKERNEL)
+# define rxi_Finalize_locked() do { } while (0)
+#endif
+
 #ifdef RX_ENABLE_LOCKS
 struct rx_tq_debug {
     rx_atomic_t rxi_start_aborted; /* rxi_start awoke after rxi_Send in error.*/
@@ -215,12 +221,16 @@ struct opr_queue rx_incomingCallQueue;
  * calls to process */
 struct opr_queue rx_idleServerQueue;
 
+/* List of free rx_serverQueueEntry structs */
+struct opr_queue rx_freeServerQueue;
+
 #if !defined(offsetof)
 #include <stddef.h>		/* for definition of offsetof() */
 #endif
 
 #ifdef RX_ENABLE_LOCKS
 afs_kmutex_t rx_atomic_mutex;
+static afs_kmutex_t freeSQEList_lock;
 #endif
 
 /* Forward prototypes */
@@ -442,24 +452,40 @@ static int rxdb_fileID = RXDB_FILE_RX;
 #endif /* RX_ENABLE_LOCKS */
 struct rx_serverQueueEntry *rx_waitForPacket = 0;
 
+/*
+ * This mutex serializes calls to our initialization and shutdown routines
+ * (rx_InitHost, rx_Finalize and shutdown_rx). Only one thread can be running
+ * these at any time; all other threads must wait for it to finish running, and
+ * then examine the value of rxi_running afterwards.
+ */
+#ifdef AFS_PTHREAD_ENV
+# define LOCK_RX_INIT MUTEX_ENTER(&rx_init_mutex)
+# define UNLOCK_RX_INIT MUTEX_EXIT(&rx_init_mutex)
+#else
+# define LOCK_RX_INIT
+# define UNLOCK_RX_INIT
+#endif
+
 /* ------------Exported Interfaces------------- */
 
+static rx_atomic_t rxi_running = RX_ATOMIC_INIT(0);
+int
+rxi_IsRunning(void)
+{
+    return rx_atomic_read(&rxi_running);
+}
+
 /* Initialize rx.  A port number may be mentioned, in which case this
  * becomes the default port number for any service installed later.
  * If 0 is provided for the port number, a random port will be chosen
  * by the kernel.  Whether this will ever overlap anything in
  * /etc/services is anybody's guess...  Returns 0 on success, -1 on
  * error. */
-#if !(defined(AFS_NT40_ENV) || defined(RXK_UPCALL_ENV))
-static
-#endif
-rx_atomic_t rxinit_status = RX_ATOMIC_INIT(1);
-
 int
 rx_InitHost(u_int host, u_int port)
 {
 #ifdef KERNEL
-    osi_timeval_t tv;
+    osi_timeval32_t tv;
 #else /* KERNEL */
     struct timeval tv;
 #endif /* KERNEL */
@@ -468,15 +494,17 @@ rx_InitHost(u_int host, u_int port)
     SPLVAR;
 
     INIT_PTHREAD_LOCKS;
-    if (!rx_atomic_test_and_clear_bit(&rxinit_status, 0))
+    LOCK_RX_INIT;
+    if (rxi_IsRunning()) {
+	UNLOCK_RX_INIT;
 	return 0; /* already started */
-
+    }
 #ifdef RXDEBUG
     rxi_DebugInit();
 #endif
 #ifdef AFS_NT40_ENV
     if (afs_winsockInit() < 0)
-	return -1;
+	goto error;
 #endif
 
 #ifndef KERNEL
@@ -492,7 +520,7 @@ rx_InitHost(u_int host, u_int port)
 
     rx_socket = rxi_GetHostUDPSocket(host, (u_short) port);
     if (rx_socket == OSI_NULLSOCKET) {
-	return RX_ADDRINUSE;
+        goto addrinuse;
     }
 #if defined(RX_ENABLE_LOCKS) && defined(KERNEL)
 #ifdef RX_LOCKS_DB
@@ -580,19 +608,19 @@ rx_InitHost(u_int host, u_int port)
 	socklen_t addrlen = sizeof(addr);
 #endif
 	if (getsockname((intptr_t)rx_socket, (struct sockaddr *)&addr, &addrlen)) {
-	    rx_Finalize();
+	    rxi_Finalize_locked();
 	    osi_Free(htable, rx_hashTableSize * sizeof(struct rx_connection *));
-	    return -1;
+	    goto error;
 	}
 	rx_port = addr.sin_port;
 #endif
     }
     rx_stats.minRtt.sec = 9999999;
     if (RAND_bytes(&rx_epoch, sizeof(rx_epoch)) != 1)
-	return -1;
+	goto error;
     rx_epoch  = (rx_epoch & ~0x40000000) | 0x80000000;
     if (RAND_bytes(&rx_nextCid, sizeof(rx_nextCid)) != 1)
-	return -1;
+	goto error;
     rx_nextCid &= RX_CIDMASK;
     MUTEX_ENTER(&rx_quota_mutex);
     rxi_dataQuota += rx_extraQuota; /* + extra pkts caller asked to rsrv */
@@ -610,6 +638,7 @@ rx_InitHost(u_int host, u_int port)
 
     /* Initialize various global queues */
     opr_queue_Init(&rx_idleServerQueue);
+    opr_queue_Init(&rx_freeServerQueue);
     opr_queue_Init(&rx_incomingCallQueue);
     opr_queue_Init(&rx_freeCallQueue);
 
@@ -623,8 +652,19 @@ rx_InitHost(u_int host, u_int port)
     rxi_StartListener();
 
     USERPRI;
-    rx_atomic_clear_bit(&rxinit_status, 0);
+
+    rx_atomic_set(&rxi_running, 1);
+    UNLOCK_RX_INIT;
+
     return 0;
+
+ addrinuse:
+    UNLOCK_RX_INIT;
+    return RX_ADDRINUSE;
+
+ error:
+    UNLOCK_RX_INIT;
+    return -1;
 }
 
 int
@@ -1010,6 +1050,7 @@ rx_NewConnection(afs_uint32 shost, u_short sport, u_short sservice,
 {
     int hashindex, i;
     struct rx_connection *conn;
+    int code;
 
     SPLVAR;
 
@@ -1053,7 +1094,7 @@ rx_NewConnection(afs_uint32 shost, u_short sport, u_short sservice,
 	conn->lastBusy[i] = 0;
     }
 
-    RXS_NewConnection(securityObject, conn);
+    code = RXS_NewConnection(securityObject, conn);
     hashindex =
 	CONN_HASH(shost, sport, conn->cid, conn->epoch, RX_CLIENT_CONNECTION);
 
@@ -1064,6 +1105,9 @@ rx_NewConnection(afs_uint32 shost, u_short sport, u_short sservice,
 	rx_atomic_inc(&rx_stats.nClientConns);
     MUTEX_EXIT(&rx_connHashTable_lock);
     USERPRI;
+    if (code) {
+	rxi_ConnectionError(conn, code);
+    }
     return conn;
 }
 
@@ -1381,7 +1425,7 @@ static void
 rxi_WakeUpTransmitQueue(struct rx_call *call)
 {
     if (call->tqWaiters || (call->flags & RX_CALL_TQ_WAIT)) {
-	dpf(("call %"AFS_PTR_FMT" has %d waiters and flags %d\n",
+	dpf(("call %p has %d waiters and flags %d\n",
 	     call, call->tqWaiters, call->flags));
 #ifdef RX_ENABLE_LOCKS
 	MUTEX_ASSERT(&call->lock);
@@ -1411,7 +1455,7 @@ rx_NewCall(struct rx_connection *conn)
     SPLVAR;
 
     clock_NewTime();
-    dpf(("rx_NewCall(conn %"AFS_PTR_FMT")\n", conn));
+    dpf(("rx_NewCall(conn %p)\n", conn));
 
     NETPRI;
     clock_GetTime(&queueTime);
@@ -1625,7 +1669,7 @@ rx_NewCall(struct rx_connection *conn)
     MUTEX_EXIT(&call->lock);
     USERPRI;
 
-    dpf(("rx_NewCall(call %"AFS_PTR_FMT")\n", call));
+    dpf(("rx_NewCall(call %p)\n", call));
     return call;
 }
 
@@ -1801,10 +1845,14 @@ rx_SetSecurityConfiguration(struct rx_service *service,
 			    void *value)
 {
     int i;
+    int code;
     for (i = 0; i<service->nSecurityObjects; i++) {
 	if (service->securityObjects[i]) {
-	    RXS_SetConfiguration(service->securityObjects[i], NULL, type,
-				 value, NULL);
+	    code = RXS_SetConfiguration(service->securityObjects[i], NULL, type,
+					value, NULL);
+	    if (code) {
+		return code;
+	    }
 	}
     }
     return 0;
@@ -1901,7 +1949,7 @@ rxi_ServerProc(int threadID, struct rx_call *newcall, osi_socket * socketp)
 void
 rx_WakeupServerProcs(void)
 {
-    struct rx_serverQueueEntry *np, *tqp;
+    struct rx_serverQueueEntry *np;
     struct opr_queue *cursor;
     SPLVAR;
 
@@ -1916,8 +1964,8 @@ rx_WakeupServerProcs(void)
 	osi_rxWakeup(rx_waitForPacket);
 #endif /* RX_ENABLE_LOCKS */
     MUTEX_ENTER(&freeSQEList_lock);
-    for (np = rx_FreeSQEList; np; np = tqp) {
-	tqp = *(struct rx_serverQueueEntry **)np;
+    for (opr_queue_Scan(&rx_freeServerQueue, cursor)) {
+        np = opr_queue_Entry(cursor, struct rx_serverQueueEntry, entry);
 #ifdef RX_ENABLE_LOCKS
 	CV_BROADCAST(&np->cv);
 #else /* RX_ENABLE_LOCKS */
@@ -1977,8 +2025,10 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 
     MUTEX_ENTER(&freeSQEList_lock);
 
-    if ((sq = rx_FreeSQEList)) {
-	rx_FreeSQEList = *(struct rx_serverQueueEntry **)sq;
+    if (!opr_queue_IsEmpty(&rx_freeServerQueue)) {
+	sq = opr_queue_First(&rx_freeServerQueue, struct rx_serverQueueEntry,
+			     entry);
+	opr_queue_Remove(&sq->entry);
 	MUTEX_EXIT(&freeSQEList_lock);
     } else {			/* otherwise allocate a new one and return that */
 	MUTEX_EXIT(&freeSQEList_lock);
@@ -2012,7 +2062,7 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 		}
 		MUTEX_ENTER(&rx_pthread_mutex);
 		if (tno == rxi_fcfs_thread_num
-			|| opr_queue_IsEnd(&rx_incomingCallQueue, cursor)) {
+			|| opr_queue_IsLast(&rx_incomingCallQueue, cursor)) {
 		    MUTEX_EXIT(&rx_pthread_mutex);
 		    /* If we're the fcfs thread , then  we'll just use
 		     * this call. If we haven't been able to find an optimal
@@ -2051,6 +2101,7 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 	    opr_queue_Remove(&call->entry);
 	    MUTEX_EXIT(&rx_serverPool_lock);
 	    MUTEX_ENTER(&call->lock);
+	    CLEAR_CALL_QUEUE_LOCK(call);
 
 	    if (call->flags & RX_CALL_WAIT_PROC) {
 		call->flags &= ~RX_CALL_WAIT_PROC;
@@ -2069,7 +2120,6 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 		|| opr_queue_First(&call->rq, struct rx_packet, entry)->header.seq != 1)
 		rxi_SendAck(call, 0, 0, RX_ACK_DELAY, 0);
 
-	    CLEAR_CALL_QUEUE_LOCK(call);
 	    break;
 	} else {
 	    /* If there are no eligible incoming calls, add this process
@@ -2088,12 +2138,14 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 		CV_WAIT(&sq->cv, &rx_serverPool_lock);
 #ifdef	KERNEL
 		if (afs_termState == AFSOP_STOP_RXCALLBACK) {
-		    MUTEX_EXIT(&rx_serverPool_lock);
-		    return (struct rx_call *)0;
+		    break;
 		}
 #endif
 	    } while (!(call = sq->newcall)
 		     && !(socketp && *socketp != OSI_NULLSOCKET));
+	    if (opr_queue_IsOnQueue(&sq->entry)) {
+		opr_queue_Remove(&sq->entry);
+	    }
 	    MUTEX_EXIT(&rx_serverPool_lock);
 	    if (call) {
 		MUTEX_ENTER(&call->lock);
@@ -2103,8 +2155,7 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
     }
 
     MUTEX_ENTER(&freeSQEList_lock);
-    *(struct rx_serverQueueEntry **)sq = rx_FreeSQEList;
-    rx_FreeSQEList = sq;
+    opr_queue_Prepend(&rx_freeServerQueue, &sq->entry);
     MUTEX_EXIT(&freeSQEList_lock);
 
     if (call) {
@@ -2125,7 +2176,7 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 #endif
 
 	rxi_calltrace(RX_CALL_START, call);
-	dpf(("rx_GetCall(port=%d, service=%d) ==> call %"AFS_PTR_FMT"\n",
+	dpf(("rx_GetCall(port=%d, service=%d) ==> call %p\n",
 	     call->conn->service->servicePort, call->conn->service->serviceId,
 	     call));
 
@@ -2149,8 +2200,10 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
     NETPRI;
     MUTEX_ENTER(&freeSQEList_lock);
 
-    if ((sq = rx_FreeSQEList)) {
-	rx_FreeSQEList = *(struct rx_serverQueueEntry **)sq;
+    if (!opr_queue_IsEmpty(&rx_freeServerQueue)) {
+	sq = opr_queue_First(&rx_freeServerQueue, struct rx_serverQueueEntry,
+			     entry);
+	opr_queue_Remove(&sq->entry);
 	MUTEX_EXIT(&freeSQEList_lock);
     } else {			/* otherwise allocate a new one and return that */
 	MUTEX_EXIT(&freeSQEList_lock);
@@ -2184,9 +2237,8 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 	    service = tcall->conn->service;
 	    if (QuotaOK(service)) {
 		MUTEX_ENTER(&rx_pthread_mutex);
-		/* XXX - If tcall->entry.next is NULL, then we're no longer
-		 * on a queue at all. This shouldn't happen. */
-		if (tno == rxi_fcfs_thread_num || !tcall->entry.next) {
+		if (tno == rxi_fcfs_thread_num
+			|| opr_queue_IsLast(&rx_incomingCallQueue, cursor)) {
 		    MUTEX_EXIT(&rx_pthread_mutex);
 		    /* If we're the fcfs thread, then  we'll just use
 		     * this call. If we haven't been able to find an optimal
@@ -2220,6 +2272,7 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
 
     if (call) {
 	opr_queue_Remove(&call->entry);
+	CLEAR_CALL_QUEUE_LOCK(call);
 	/* we can't schedule a call if there's no data!!! */
 	/* send an ack if there's no data, if we're missing the
 	 * first packet, or we're missing something between first
@@ -2264,8 +2317,7 @@ rx_GetCall(int tno, struct rx_service *cur_service, osi_socket * socketp)
     MUTEX_EXIT(&sq->lock);
 
     MUTEX_ENTER(&freeSQEList_lock);
-    *(struct rx_serverQueueEntry **)sq = rx_FreeSQEList;
-    rx_FreeSQEList = sq;
+    opr_queue_Prepend(&rx_freeServerQueue, &sq->entry);
     MUTEX_EXIT(&freeSQEList_lock);
 
     if (call) {
@@ -2334,7 +2386,7 @@ rx_EndCall(struct rx_call *call, afs_int32 rc)
     afs_int32 error;
     SPLVAR;
 
-    dpf(("rx_EndCall(call %"AFS_PTR_FMT" rc %d error %d abortCode %d)\n",
+    dpf(("rx_EndCall(call %p rc %d error %d abortCode %d)\n",
           call, rc, call->error, call->abortCode));
 
     NETPRI;
@@ -2345,7 +2397,7 @@ rx_EndCall(struct rx_call *call, afs_int32 rc)
 	call->abortCount = 0;
     }
 
-    call->arrivalProc = (void (*)())0;
+    call->arrivalProc = NULL;
     if (rc && call->error == 0) {
 	rxi_CallError(call, rc);
         call->app.mode = RX_MODE_ERROR;
@@ -2492,12 +2544,21 @@ rx_EndCall(struct rx_call *call, afs_int32 rc)
 void
 rx_Finalize(void)
 {
-    struct rx_connection **conn_ptr, **conn_end;
-
     INIT_PTHREAD_LOCKS;
-    if (rx_atomic_test_and_set_bit(&rxinit_status, 0))
+    LOCK_RX_INIT;
+    if (!rxi_IsRunning()) {
+	UNLOCK_RX_INIT;
 	return;			/* Already shutdown. */
+    }
+    rxi_Finalize_locked();
+    UNLOCK_RX_INIT;
+}
 
+static void
+rxi_Finalize_locked(void)
+{
+    struct rx_connection **conn_ptr, **conn_end;
+    rx_atomic_set(&rxi_running, 0);
     rxi_DeleteCachedConnections();
     if (rx_connHashTable) {
 	MUTEX_ENTER(&rx_connHashTable_lock);
@@ -2534,7 +2595,6 @@ rx_Finalize(void)
 #ifdef AFS_NT40_ENV
     afs_winsockCleanup();
 #endif
-
 }
 #endif
 
@@ -2596,7 +2656,7 @@ rxi_NewCall(struct rx_connection *conn, int channel)
     struct opr_queue *cursor;
 #endif
 
-    dpf(("rxi_NewCall(conn %"AFS_PTR_FMT", channel %d)\n", conn, channel));
+    dpf(("rxi_NewCall(conn %p, channel %d)\n", conn, channel));
 
     /* Grab an existing call structure, or allocate a new one.
      * Existing call structures are assumed to have been left reset by
@@ -2794,7 +2854,7 @@ rxi_Alloc(size_t size)
     }
 
 p = (char *)
-#if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_FBSD80_ENV)
+#if defined(KERNEL) && !defined(UKERNEL) && defined(AFS_FBSD_ENV)
   afs_osi_Alloc_NoSleep(size);
 #else
   osi_Alloc(size);
@@ -2808,6 +2868,9 @@ p = (char *)
 void
 rxi_Free(void *addr, size_t size)
 {
+    if (!addr) {
+        return;
+    }
     if (rx_stats_active) {
 	rx_atomic_sub(&rxi_Allocsize, (int) size);
         rx_atomic_dec(&rxi_Alloccnt);
@@ -3067,6 +3130,7 @@ rxi_FindConnection(osi_socket socket, afs_uint32 host,
                    int *unknownService)
 {
     int hashindex, flag, i;
+    int code = 0;
     struct rx_connection *conn;
     *unknownService = 0;
     hashindex = CONN_HASH(host, port, cid, epoch, type);
@@ -3141,7 +3205,7 @@ rxi_FindConnection(osi_socket socket, afs_uint32 host,
 	    conn->rwind[i] = rx_initReceiveWindow;
 	}
 	/* Notify security object of the new connection */
-	RXS_NewConnection(conn->securityObject, conn);
+	code = RXS_NewConnection(conn->securityObject, conn);
 	/* XXXX Connection timeout? */
 	if (service->newConnProc)
 	    (*service->newConnProc) (conn);
@@ -3153,6 +3217,9 @@ rxi_FindConnection(osi_socket socket, afs_uint32 host,
 
     rxLastConn = conn;		/* store this connection as the last conn used */
     MUTEX_EXIT(&rx_connHashTable_lock);
+    if (code) {
+	rxi_ConnectionError(conn, code);
+    }
     return conn;
 }
 
@@ -3165,10 +3232,15 @@ static_inline int
 rxi_AbortIfServerBusy(osi_socket socket, struct rx_connection *conn,
 		      struct rx_packet *np)
 {
+    afs_uint32 serial;
+
     if ((rx_BusyThreshold > 0) &&
 	(rx_atomic_read(&rx_nWaiting) > rx_BusyThreshold)) {
+	MUTEX_ENTER(&conn->conn_data_lock);
+	serial = ++conn->serial;
+	MUTEX_EXIT(&conn->conn_data_lock);
 	rxi_SendRawAbort(socket, conn->peer->host, conn->peer->port,
-			 rx_BusyError, np, 0);
+			 serial, rx_BusyError, np, 0);
 	if (rx_stats_active)
 	    rx_atomic_inc(&rx_stats.nBusies);
 	return 1;
@@ -3345,7 +3417,7 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
  * this is the first time the packet has been seen */
     packetType = (np->header.type > 0 && np->header.type < RX_N_PACKET_TYPES)
 	? rx_packetTypes[np->header.type - 1] : "*UNKNOWN*";
-    dpf(("R %d %s: %x.%d.%d.%d.%d.%d.%d flags %d, packet %"AFS_PTR_FMT"\n",
+    dpf(("R %d %s: %x.%d.%d.%d.%d.%d.%d flags %d, packet %p\n",
 	 np->header.serial, packetType, ntohl(host), ntohs(port), np->header.serviceId,
 	 np->header.epoch, np->header.cid, np->header.callNumber,
 	 np->header.seq, np->header.flags, np));
@@ -3395,7 +3467,7 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
 	memset(&addr.sin_zero, 0, sizeof(addr.sin_zero));
 #ifdef STRUCT_SOCKADDR_HAS_SA_LEN
 	addr.sin_len = sizeof(addr);
-#endif /* AFS_OSF_ENV */
+#endif
 	drop = (*rx_justReceived) (np, &addr);
 	/* drop packet if return value is non-zero */
 	if (drop)
@@ -3420,7 +3492,7 @@ rxi_ReceivePacket(struct rx_packet *np, osi_socket socket,
        don't abort an abort. */
     if (!conn) {
         if (unknownService && (np->header.type != RX_PACKET_TYPE_ABORT))
-            rxi_SendRawAbort(socket, host, port, RX_INVALID_OPERATION,
+	    rxi_SendRawAbort(socket, host, port, 0, RX_INVALID_OPERATION,
                              np, 0);
         return np;
     }
@@ -3750,7 +3822,7 @@ rxi_CheckConnReach(struct rx_connection *conn, struct rx_call *call)
 static void
 TryAttach(struct rx_call *acall, osi_socket socket,
 	  int *tnop, struct rx_call **newcallp,
-	  int reachOverride)
+	  int reachOverride, int istack)
 {
     struct rx_connection *conn = acall->conn;
 
@@ -3764,7 +3836,19 @@ TryAttach(struct rx_call *acall, osi_socket socket,
 	     * may not any proc available
 	     */
 	} else {
-	    rxi_ChallengeOn(acall->conn);
+	    int code;
+	    code = rxi_ChallengeOn(acall->conn);
+	    if (code) {
+		/*
+		 * Ideally we would rxi_ConnectionError here, but doing that is
+		 * difficult, because some callers may have locked 'call',
+		 * _and_ another call on the same conn. So we cannot
+		 * rxi_ConnectionError, since that needs to lock every call on
+		 * the conn. But we can at least abort the call we have.
+		 */
+		rxi_CallError(acall, code);
+		rxi_SendCallAbort(acall, NULL, istack, 0);
+	    }
 	}
     }
 }
@@ -3801,7 +3885,7 @@ rxi_ReceiveDataPacket(struct rx_call *call,
         if (rx_stats_active)
             rx_atomic_inc(&rx_stats.noPacketBuffersOnRead);
 	rxi_calltrace(RX_TRACE_DROP, call);
-	dpf(("packet %"AFS_PTR_FMT" dropped on receipt - quota problems\n", np));
+	dpf(("packet %p dropped on receipt - quota problems\n", np));
         /* We used to clear the receive queue here, in an attempt to free
          * packets. However this is unsafe if the queue has received a
          * soft ACK for the final packet */
@@ -3855,7 +3939,7 @@ rxi_ReceiveDataPacket(struct rx_call *call,
 		&& opr_queue_First(&call->rq, struct rx_packet, entry)->header.seq == seq) {
                 if (rx_stats_active)
                     rx_atomic_inc(&rx_stats.dupPacketsRead);
-		dpf(("packet %"AFS_PTR_FMT" dropped on receipt - duplicate\n", np));
+		dpf(("packet %p dropped on receipt - duplicate\n", np));
 		rxi_CancelDelayedAckEvent(call);
 		np = rxi_SendAck(call, np, serial, RX_ACK_DUPLICATE, istack);
 		ackNeeded = 0;
@@ -3913,7 +3997,7 @@ rxi_ReceiveDataPacket(struct rx_call *call,
 	    if (call->arrivalProc) {
 		(*call->arrivalProc) (call, call->arrivalProcHandle,
 				      call->arrivalProcArg);
-		call->arrivalProc = (void (*)())0;
+		call->arrivalProc = NULL;
 	    }
 
 	    /* Update last packet received */
@@ -3924,7 +4008,7 @@ rxi_ReceiveDataPacket(struct rx_call *call,
 	     * server thread is available, this thread becomes a server
 	     * thread and the server thread becomes a listener thread. */
 	    if (isFirst) {
-		TryAttach(call, socket, tnop, newcallp, 0);
+		TryAttach(call, socket, tnop, newcallp, 0, istack);
 	    }
 	}
 	/* This is not the expected next packet. */
@@ -4105,7 +4189,8 @@ rxi_ReceiveDataPacket(struct rx_call *call,
 }
 
 static void
-rxi_UpdatePeerReach(struct rx_connection *conn, struct rx_call *acall)
+rxi_UpdatePeerReach(struct rx_connection *conn, struct rx_call *acall,
+		    int istack)
 {
     struct rx_peer *peer = conn->peer;
 
@@ -4126,7 +4211,7 @@ rxi_UpdatePeerReach(struct rx_connection *conn, struct rx_call *acall)
 		if (call != acall)
 		    MUTEX_ENTER(&call->lock);
 		/* tnop can be null if newcallp is null */
-		TryAttach(call, (osi_socket) - 1, NULL, NULL, 1);
+		TryAttach(call, (osi_socket) - 1, NULL, NULL, 1, istack);
 		if (call != acall)
 		    MUTEX_EXIT(&call->lock);
 	    }
@@ -4220,7 +4305,7 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
     }
 
     if (ap->reason == RX_ACK_PING_RESPONSE)
-	rxi_UpdatePeerReach(conn, call);
+	rxi_UpdatePeerReach(conn, call, istack);
 
     if (conn->lastPacketSizeSeq) {
 	MUTEX_ENTER(&conn->conn_data_lock);
@@ -4345,7 +4430,7 @@ rxi_ReceiveAckPacket(struct rx_call *call, struct rx_packet *np,
 
 #ifdef RX_ENABLE_LOCKS
 	/* XXX Hack. Because we have to release the global call lock when sending
-	 * packets (osi_NetSend) we drop all acks while we're traversing the tq
+	 * packets (rxi_NetSend) we drop all acks while we're traversing the tq
 	 * in rxi_Start sending packets out because packets may move to the
 	 * freePacketQueue as result of being here! So we drop these packets until
 	 * we're safely out of the traversing. Really ugly!
@@ -4764,7 +4849,7 @@ rxi_ReceiveResponsePacket(struct rx_connection *conn,
 	 * some calls went into attach-wait while we were waiting
 	 * for authentication..
 	 */
-	rxi_UpdatePeerReach(conn, NULL);
+	rxi_UpdatePeerReach(conn, NULL, istack);
     }
     return np;
 }
@@ -4872,6 +4957,7 @@ rxi_AttachServerProc(struct rx_call *call,
 	    if (opr_queue_IsOnQueue(&call->entry)) {
 		opr_queue_Remove(&call->entry);
 	    }
+	    CLEAR_CALL_QUEUE_LOCK(call);
 	}
 	call->state = RX_STATE_ACTIVE;
 	call->app.mode = RX_MODE_RECEIVING;
@@ -5062,7 +5148,7 @@ rxi_ClearReceiveQueue(struct rx_call *call)
 #ifdef RXDEBUG_PACKET
         call->rqc -= count;
         if ( call->rqc != 0 )
-            dpf(("rxi_ClearReceiveQueue call %"AFS_PTR_FMT" rqc %u != 0\n", call, call->rqc));
+	  dpf(("rxi_ClearReceiveQueue call %p rqc %u != 0\n", call, call->rqc));
 #endif
 	call->flags &= ~(RX_CALL_RECEIVE_DONE | RX_CALL_HAVE_LAST);
     }
@@ -5179,7 +5265,7 @@ rxi_ConnectionError(struct rx_connection *conn,
     if (error) {
 	int i;
 
-	dpf(("rxi_ConnectionError conn %"AFS_PTR_FMT" error %d\n", conn, error));
+	dpf(("rxi_ConnectionError conn %p error %d\n", conn, error));
 
 	MUTEX_ENTER(&conn->conn_data_lock);
 	if (rxevent_Cancel(&conn->challengeEvent))
@@ -5224,7 +5310,7 @@ void
 rxi_CallError(struct rx_call *call, afs_int32 error)
 {
     MUTEX_ASSERT(&call->lock);
-    dpf(("rxi_CallError call %"AFS_PTR_FMT" error %d call->error %d\n", call, error, call->error));
+    dpf(("rxi_CallError call %p error %d call->error %d\n", call, error, call->error));
     if (call->error)
 	error = call->error;
 
@@ -5253,13 +5339,13 @@ rxi_ResetCall(struct rx_call *call, int newcall)
     struct rx_packet *packet;
 
     MUTEX_ASSERT(&call->lock);
-    dpf(("rxi_ResetCall(call %"AFS_PTR_FMT", newcall %d)\n", call, newcall));
+    dpf(("rxi_ResetCall(call %p, newcall %d)\n", call, newcall));
 
     /* Notify anyone who is waiting for asynchronous packet arrival */
     if (call->arrivalProc) {
 	(*call->arrivalProc) (call, call->arrivalProcHandle,
 			      call->arrivalProcArg);
-	call->arrivalProc = (void (*)())0;
+	call->arrivalProc = NULL;
     }
 
 
@@ -5314,7 +5400,7 @@ rxi_ResetCall(struct rx_call *call, int newcall)
 
     rxi_ClearTransmitQueue(call, 1);
     if (call->tqWaiters || (flags & RX_CALL_TQ_WAIT)) {
-        dpf(("rcall %"AFS_PTR_FMT" has %d waiters and flags %d\n", call, call->tqWaiters, call->flags));
+	dpf(("rcall %p has %d waiters and flags %d\n", call, call->tqWaiters, call->flags));
     }
     call->flags = 0;
 
@@ -6106,7 +6192,7 @@ rxi_Start(struct rx_call *call, int istack)
 					     nXmitPackets, istack);
 			    goto restart;
 			}
-                        dpf(("call %d xmit packet %"AFS_PTR_FMT"\n",
+		       dpf(("call %d xmit packet %p\n",
                               *(call->callNumber), p));
 			call->xmitList[nXmitPackets++] = p;
 		    }
@@ -6185,6 +6271,7 @@ void
 rxi_Send(struct rx_call *call, struct rx_packet *p,
 	 int istack)
 {
+    int code;
     struct rx_connection *conn = call->conn;
 
     /* Stamp each packet with the user supplied status */
@@ -6192,7 +6279,15 @@ rxi_Send(struct rx_call *call, struct rx_packet *p,
 
     /* Allow the security object controlling this call's security to
      * make any last-minute changes to the packet */
-    RXS_SendPacket(conn->securityObject, call, p);
+    code = RXS_SendPacket(conn->securityObject, call, p);
+    if (code) {
+	MUTEX_EXIT(&call->lock);
+	CALL_HOLD(call, RX_CALL_REFCOUNT_SEND);
+	rxi_ConnectionError(conn, code);
+	CALL_RELE(call, RX_CALL_REFCOUNT_SEND);
+	MUTEX_ENTER(&call->lock);
+	return;
+    }
 
     /* Since we're about to send SOME sort of packet to the peer, it's
      * safe to nuke any scheduled end-of-packets ack */
@@ -6408,7 +6503,7 @@ rxi_NatKeepAliveEvent(struct rxevent *event, void *arg1,
     tmpiov[0].iov_base = tbuffer;
     tmpiov[0].iov_len = 1 + sizeof(struct rx_header);
 
-    osi_NetSend(socket, &taddr, tmpiov, 1, 1 + sizeof(struct rx_header), 1);
+    rxi_NetSend(socket, &taddr, tmpiov, 1, 1 + sizeof(struct rx_header), 1);
 
     MUTEX_ENTER(&conn->conn_data_lock);
     /* We ran, so the handle is no longer needed to try to cancel ourselves. */
@@ -6697,27 +6792,30 @@ rxi_SendDelayedCallAbort(struct rxevent *event, void *arg1, void *dummy,
  *
  * This routine is both an event handler and a function called directly;
  * when called directly the passed |event| is NULL and the
- * conn->conn->data>lock must must not be held.
+ * conn->conn->data>lock must must not be held.  Also, when called as an
+ * an event handler, we must putConnection before we exit; but when called
+ * directly (the first challenge), we must NOT putConnection.
  */
 static void
 rxi_ChallengeEvent(struct rxevent *event,
 		   void *arg0, void *arg1, int tries)
 {
     struct rx_connection *conn = arg0;
+    int event_raised = 0;	/* assume we were called directly */
 
     MUTEX_ENTER(&conn->conn_data_lock);
-    if (event != NULL && event == conn->challengeEvent)
+    if (event != NULL && event == conn->challengeEvent) {
+	event_raised = 1;	/* called as an event */
 	rxevent_Put(&conn->challengeEvent);
+    }
     MUTEX_EXIT(&conn->conn_data_lock);
 
     /* If there are no active calls it is not worth re-issuing the
      * challenge.  If the client issues another call on this connection
      * the challenge can be requested at that time.
      */
-    if (!rxi_HasActiveCalls(conn)) {
-	putConnection(conn);
-        return;
-    }
+    if (!rxi_HasActiveCalls(conn))
+	goto done;
 
     if (RXS_CheckAuthentication(conn->securityObject, conn) != 0) {
 	struct rx_packet *packet;
@@ -6743,18 +6841,33 @@ rxi_ChallengeEvent(struct rxevent *event,
 		}
 	    }
 	    MUTEX_EXIT(&conn->conn_call_lock);
-	    putConnection(conn);
-	    return;
+	    goto done;
 	}
 
 	packet = rxi_AllocPacket(RX_PACKET_CLASS_SPECIAL);
 	if (packet) {
-	    /* If there's no packet available, do this later. */
-	    RXS_GetChallenge(conn->securityObject, conn, packet);
-	    rxi_SendSpecial((struct rx_call *)0, conn, packet,
-			    RX_PACKET_TYPE_CHALLENGE, NULL, -1, 0);
+	    int code;
+	    code = RXS_GetChallenge(conn->securityObject, conn, packet);
+	    if (code && event_raised) {
+		/*
+		 * We can only rxi_ConnectionError the connection if we are
+		 * running as an event. Otherwise, the caller may have our call
+		 * locked, and so we cannot call rxi_ConnectionError (since it
+		 * tries to lock each call in the conn).
+		 */
+		rxi_FreePacket(packet);
+		rxi_ConnectionError(conn, code);
+		goto done;
+	    }
+	    if (code == 0) {
+		/* Only send a challenge packet if we were able to allocate a
+		 * packet, and the security layer successfully populated the
+		 * challenge. */
+		rxi_SendSpecial((struct rx_call *)0, conn, packet,
+				RX_PACKET_TYPE_CHALLENGE, NULL, -1, 0);
+		conn->securityChallengeSent = 1;
+	    }
 	    rxi_FreePacket(packet);
-	    conn->securityChallengeSent = 1;
 	}
 	clock_GetTime(&now);
 	when = now;
@@ -6769,7 +6882,9 @@ rxi_ChallengeEvent(struct rxevent *event,
 	}
 	MUTEX_EXIT(&conn->conn_data_lock);
     }
-    putConnection(conn);
+ done:
+    if (event_raised)
+	putConnection(conn);
 }
 
 /* Call this routine to start requesting the client to authenticate
@@ -6777,7 +6892,7 @@ rxi_ChallengeEvent(struct rxevent *event,
  * the call times out, or an invalid response is returned.  The
  * security object associated with the connection is asked to create
  * the challenge at this time. */
-static void
+static int
 rxi_ChallengeOn(struct rx_connection *conn)
 {
     int start = 0;
@@ -6786,9 +6901,14 @@ rxi_ChallengeOn(struct rx_connection *conn)
 	start = 1;
     MUTEX_EXIT(&conn->conn_data_lock);
     if (start) {
-	RXS_CreateChallenge(conn->securityObject, conn);
+	int code;
+	code = RXS_CreateChallenge(conn->securityObject, conn);
+	if (code) {
+	    return code;
+	}
 	rxi_ChallengeEvent(NULL, conn, 0, RX_CHALLENGE_MAXTRIES);
-    };
+    }
+    return 0;
 }
 
 
@@ -6844,7 +6964,7 @@ rxi_ComputeRoundTripTime(struct rx_packet *p,
 	return;			/* somebody set the clock back, don't count this time. */
 
     clock_Sub(&thisRtt, sentp);
-    dpf(("rxi_ComputeRoundTripTime(call=%d packet=%"AFS_PTR_FMT" rttp=%d.%06d sec)\n",
+    dpf(("rxi_ComputeRoundTripTime(call=%d packet=%p rttp=%d.%06d sec)\n",
           p->header.callNumber, p, thisRtt.sec, thisRtt.usec));
 
     if (clock_IsZero(&thisRtt)) {
@@ -6943,8 +7063,10 @@ rxi_ComputeRoundTripTime(struct rx_packet *p,
     peer->rtt_dev = call->rtt_dev;
     peer->rtt = call->rtt;
 
-    dpf(("rxi_ComputeRoundTripTime(call=%d packet=%"AFS_PTR_FMT" rtt=%d ms, srtt=%d ms, rtt_dev=%d ms, timeout=%d.%06d sec)\n",
-          p->header.callNumber, p, MSEC(&thisRtt), call->rtt >> 3, call->rtt_dev >> 2, (call->rto.sec), (call->rto.usec)));
+    dpf(("rxi_ComputeRoundTripTime(call=%d packet=%p rtt=%d ms, srtt=%d ms, "
+	 "rtt_dev=%d ms, timeout=%d.%06d sec)\n",
+	 p->header.callNumber, p, MSEC(&thisRtt), call->rtt >> 3,
+	 call->rtt_dev >> 2, (call->rto.sec), (call->rto.usec)));
 }
 
 
@@ -7834,9 +7956,12 @@ shutdown_rx(void)
     struct rx_serverQueueEntry *sq;
 #endif /* KERNEL */
 
-    if (rx_atomic_test_and_set_bit(&rxinit_status, 0))
+    LOCK_RX_INIT;
+    if (!rxi_IsRunning()) {
+	UNLOCK_RX_INIT;
 	return;			/* Already shutdown. */
-
+    }
+    rx_atomic_set(&rxi_running, 0);
 #ifndef KERNEL
     rx_port = 0;
 #ifndef AFS_PTHREAD_ENV
@@ -7933,8 +8058,10 @@ shutdown_rx(void)
 
     MUTEX_ENTER(&freeSQEList_lock);
 
-    while ((np = rx_FreeSQEList)) {
-	rx_FreeSQEList = *(struct rx_serverQueueEntry **)np;
+    while (!opr_queue_IsEmpty(&rx_freeServerQueue)) {
+	np = opr_queue_First(&rx_freeServerQueue, struct rx_serverQueueEntry,
+			     entry);
+	opr_queue_Remove(&np->entry);
 	MUTEX_DESTROY(&np->lock);
 	rxi_Free(np, sizeof(*np));
     }
@@ -7958,6 +8085,7 @@ shutdown_rx(void)
     rxi_dataQuota = RX_MAX_QUOTA;
     rxi_availProcs = rxi_totalMin = rxi_minDeficit = 0;
     MUTEX_EXIT(&rx_quota_mutex);
+    UNLOCK_RX_INIT;
 }
 
 #ifndef KERNEL
@@ -9288,3 +9416,17 @@ int rx_DumpCalls(FILE *outputFile, char *cookie)
     return 0;
 }
 #endif
+
+int
+rxi_NetSend(osi_socket socket, void *addr, struct iovec *dvec,
+	    int nvecs, int length, int istack)
+{
+    if (rxi_IsRunning()) {
+	return osi_NetSend(socket, addr, dvec, nvecs, length, istack);
+    }
+#ifdef AFS_NT40_ENV
+    return WSAESHUTDOWN;
+#else
+    return ESHUTDOWN;
+#endif
+}
diff --git a/src/rx/rx.h b/src/rx/rx.h
index 6bbf57499..3e1b77e46 100644
--- a/src/rx/rx.h
+++ b/src/rx/rx.h
@@ -102,6 +102,11 @@ extern void rx_RecordCallStatistics(struct rx_call *call,
 				    unsigned int totalFunc,
 				    int isServer);
 
+extern void rx_GetCallStatus(struct rx_call *call,
+			     afs_int32 *readNext,
+			     afs_int32 *transmitNext,
+			     int *lastSendTime,
+			     int *lastReceiveTime);
 /* Peer management */
 extern afs_uint32 rx_HostOf(struct rx_peer *peer);
 extern u_short rx_PortOf(struct rx_peer *peer);
@@ -360,7 +365,8 @@ struct rx_service {
 #define RX_CONN_BUSY               32	/* connection is busy; don't delete */
 #define RX_CONN_ATTACHWAIT	   64	/* attach waiting for peer->lastReach */
 #define RX_CONN_MAKECALL_ACTIVE   128   /* a thread is actively in rx_NewCall */
-#define RX_CONN_NAT_PING          256   /* nat ping requested */
+#define RX_CONN_NAT_PING          256   /* NAT ping requested but deferred during attachWait */
+#define RX_CONN_CACHED		  512   /* connection is managed by rxi_connectionCache */
 
 /* Type of connection, client or server */
 #define	RX_CLIENT_CONNECTION	0
@@ -518,6 +524,7 @@ enum {
     RX_SECTYPE_NULL = 1,
     RX_SECTYPE_VAB = 2,
     RX_SECTYPE_KAD = 3,
+    RX_SECTYPE_GK = 4,
 };
 struct rx_securityObjectStats {
     char type;			/* An RX_SECTYPE_* value */
@@ -583,8 +590,8 @@ struct rx_securityClass {
 	int (*op_CheckPacket) (struct rx_securityClass * aobj,
 			       struct rx_call * acall,
 			       struct rx_packet * apacket);
-	int (*op_DestroyConnection) (struct rx_securityClass * aobj,
-				     struct rx_connection * aconn);
+	void (*op_DestroyConnection) (struct rx_securityClass * aobj,
+				      struct rx_connection * aconn);
 	int (*op_GetStats) (struct rx_securityClass * aobj,
 			    struct rx_connection * aconn,
 			    struct rx_securityObjectStats * astats);
@@ -601,6 +608,10 @@ struct rx_securityClass {
 };
 
 #define RXS_OP(obj,op,args) ((obj && (obj->ops->op_ ## op)) ? (*(obj)->ops->op_ ## op)args : 0)
+#define RXS_OP_VOID(obj,op,args) do { \
+    if (obj && (obj->ops->op_ ## op)) \
+	(*(obj)->ops->op_ ## op)args; \
+} while (0)
 
 #define RXS_Close(obj) RXS_OP(obj,Close,(obj))
 #define RXS_NewConnection(obj,conn) RXS_OP(obj,NewConnection,(obj,conn))
@@ -612,7 +623,7 @@ struct rx_securityClass {
 #define RXS_GetResponse(obj,conn,packet) RXS_OP(obj,GetResponse,(obj,conn,packet))
 #define RXS_CheckResponse(obj,conn,packet) RXS_OP(obj,CheckResponse,(obj,conn,packet))
 #define RXS_CheckPacket(obj,call,packet) RXS_OP(obj,CheckPacket,(obj,call,packet))
-#define RXS_DestroyConnection(obj,conn) RXS_OP(obj,DestroyConnection,(obj,conn))
+#define RXS_DestroyConnection(obj,conn) RXS_OP_VOID(obj,DestroyConnection,(obj,conn))
 #define RXS_GetStats(obj,conn,stats) RXS_OP(obj,GetStats,(obj,conn,stats))
 #define RXS_SetConfiguration(obj, conn, type, value, currentValue) RXS_OP(obj, SetConfiguration,(obj,conn,type,value,currentValue))
 
diff --git a/src/rx/rx_atomic.h b/src/rx/rx_atomic.h
index 5bf35fee8..72ee054d4 100644
--- a/src/rx/rx_atomic.h
+++ b/src/rx/rx_atomic.h
@@ -77,34 +77,6 @@ rx_atomic_sub(rx_atomic_t *atomic, int change) {
     InterlockedExchangeAdd(&atomic->var, 0 - change);
 }
 
-static_inline int
-rx_atomic_test_bit(rx_atomic_t *atomic, int bit) {
-    return ((unsigned int) rx_atomic_read(atomic) & 1<<bit) != 0;
-}
-
-/* No InterlockedOr or InterlockedAnd on ix86, so just use the
- * BitTest functions */
-
-static_inline void
-rx_atomic_set_bit(rx_atomic_t *atomic, int bit) {
-    (void) InterlockedBitTestAndSet(&atomic->var, bit);
-}
-
-static_inline void
-rx_atomic_clear_bit(rx_atomic_t *atomic, int bit) {
-    (void) InterlockedBitTestAndReset(&atomic->var, bit);
-}
-
-static_inline int
-rx_atomic_test_and_set_bit(rx_atomic_t *atomic, int bit) {
-    return InterlockedBitTestAndSet(&atomic->var, bit);
-}
-
-static_inline int
-rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
-    return InterlockedBitTestAndReset(&atomic->var, bit);
-}
-
 #elif defined(AFS_AIX61_ENV) || defined(AFS_USR_AIX61_ENV)
 #include <sys/atomic_op.h>
 
@@ -157,48 +129,34 @@ rx_atomic_sub(rx_atomic_t *atomic, int change) {
     fetch_and_add(&atomic->var, -change);
 }
 
-static_inline int
-rx_atomic_test_bit(rx_atomic_t *atomic, int bit) {
-    return ((unsigned int) rx_atomic_read(atomic) & 1<<bit) != 0;
-}
+#elif defined(AFS_DARWIN80_ENV) || defined(AFS_USR_DARWIN80_ENV)
 
-static_inline void
-rx_atomic_set_bit(rx_atomic_t *atomic, int bit) {
-    fetch_and_or(&atomic->var, 1<<bit);
-}
+# if (defined(AFS_DARWIN160_ENV) || defined(AFS_USR_DARWIN160_ENV)) && !defined(KERNEL)
+#  define OSATOMIC_USE_INLINED 1
+# endif
 
-static_inline void
-rx_atomic_clear_bit(rx_atomic_t *atomic, int bit) {
-    fetch_and_and(&atomic->var, ~(1<<bit));
-}
+# include <libkern/OSAtomic.h>
 
+# if defined(KERNEL) && !defined(UKERNEL)
 static_inline int
-rx_atomic_test_and_set_bit(rx_atomic_t *atomic, int bit) {
-    return (fetch_and_or(&atomic->var, (1<<bit)) & 1<<bit) != 0;
+OSAtomicIncrement32(volatile int *value)
+{
+    return OSIncrementAtomic(value) + 1;
 }
 
 static_inline int
-rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
-    return (fetch_and_and(&atomic->var, ~(1<<bit)) & 1<<bit) != 0;
+OSAtomicAdd32(int amount, volatile int *value)
+{
+    return OSAddAtomic(amount, value) + amount;
 }
 
-#elif defined(AFS_DARWIN80_ENV) || defined(AFS_USR_DARWIN80_ENV)
-
-# if defined (AFS_DARWIN160_ENV) || defined(AFS_USR_DARWIN160_ENV)
-#  define OSATOMIC_USE_INLINED 1
-# else
-
-#  if defined(KERNEL) && !defined(UKERNEL)
-#   define OSAtomicIncrement32 OSIncrementAtomic
-#   define OSAtomicAdd32 OSAddAtomic
-#   define OSAtomicDecrement32 OSDecrementAtomic
-#   define OSAtomicOr32 OSBitOrAtomic
-#   define OSAtomicAnd32 OSBitAndAtomic
-#  endif
-
-# endif /* end defined DARWIN160 */
+static_inline int
+OSAtomicDecrement32(volatile int *value)
+{
+    return OSDecrementAtomic(value) - 1;
+}
 
-# include <libkern/OSAtomic.h>
+# endif
 
 typedef struct {
     volatile int var;
@@ -248,35 +206,6 @@ static_inline void
 rx_atomic_sub(rx_atomic_t *atomic, int change) {
     OSAtomicAdd32(0 - change, &atomic->var);
 }
-
-static_inline int
-rx_atomic_test_bit(rx_atomic_t *atomic, int bit) {
-    return ((unsigned int) rx_atomic_read(atomic) & 1<<bit) != 0;
-}
-
-static_inline void
-rx_atomic_set_bit(rx_atomic_t *atomic, int bit) {
-    OSAtomicOr32(1<<bit, (volatile uint32_t *)&atomic->var);
-}
-
-static_inline void
-rx_atomic_clear_bit(rx_atomic_t *atomic, int bit) {
-    OSAtomicAnd32(~(1<<bit), (volatile uint32_t *)&atomic->var);
-}
-
-static_inline int
-rx_atomic_test_and_set_bit(rx_atomic_t *atomic, int bit) {
-    return ((OSAtomicOr32Orig(1<<bit, (volatile uint32_t *)&atomic->var) & 1<<bit)
-	        != 0);
-}
-
-static_inline int
-rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
-    return ((OSAtomicAnd32Orig(~(1<<bit),
-			       (volatile uint32_t *)&atomic->var) & 1<<bit)
-	    != 0);
-}
-
 #elif defined(AFS_LINUX26_ENV) && defined(KERNEL)
 #include <asm/atomic.h>
 
@@ -291,11 +220,6 @@ typedef atomic_t rx_atomic_t;
 #define rx_atomic_dec(X)	  atomic_dec(X)
 #define rx_atomic_dec_and_read(X) atomic_dec_return(X)
 #define rx_atomic_sub(X, V)	  atomic_sub(V, X)
-#define rx_atomic_test_bit(X, B)  test_bit(B, (unsigned long *) &(X)->counter)
-#define rx_atomic_set_bit(X, B)   set_bit(B, (unsigned long *) &(X)->counter)
-#define rx_atomic_clear_bit(X, B) clear_bit(B, (unsigned long *) &(X)->counter)
-#define rx_atomic_test_and_set_bit(X, B)    test_and_set_bit(B, (unsigned long *) &(X)->counter)
-#define rx_atomic_test_and_clear_bit(X, B)  test_and_clear_bit(B, (unsigned long *) &(X)->counter)
 
 #elif defined(AFS_SUN510_ENV) || (defined(AFS_SUN5_ENV) && defined(KERNEL) && !defined(UKERNEL))
 
@@ -361,31 +285,6 @@ rx_atomic_sub(rx_atomic_t *atomic, int change) {
     atomic_add_32(&atomic->var, 0 - change);
 }
 
-static_inline int
-rx_atomic_test_bit(rx_atomic_t *atomic, int bit) {
-    return ((unsigned int) rx_atomic_read(atomic) & 1<<bit) != 0;
-}
-
-static_inline void
-rx_atomic_set_bit(rx_atomic_t *atomic, int bit) {
-    atomic_or_32(&atomic->var, 1<<bit);
-}
-
-static_inline void
-rx_atomic_clear_bit(rx_atomic_t *atomic, int bit) {
-    atomic_and_32(&atomic->var, ~(1<<bit));
-}
-
-static_inline int
-rx_atomic_test_and_set_bit(rx_atomic_t *atomic, int bit) {
-    return (atomic_set_long_excl(&atomic->var, bit) == -1);
-}
-
-static_inline int
-rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
-    return (atomic_clear_long_excl(&atomic->var, bit) == 0);
-}
-
 #elif defined(__GNUC__) && defined(HAVE_SYNC_FETCH_AND_ADD)
 
 typedef struct {
@@ -437,31 +336,6 @@ rx_atomic_sub(rx_atomic_t *atomic, int change) {
     (void)__sync_fetch_and_sub(&atomic->var, change);
 }
 
-static_inline int
-rx_atomic_test_bit(rx_atomic_t *atomic, int bit) {
-    return ((unsigned int) rx_atomic_read(atomic) & 1<<bit) != 0;
-}
-
-static_inline void
-rx_atomic_set_bit(rx_atomic_t *atomic, int bit) {
-    (void)__sync_fetch_and_or(&atomic->var, 1<<bit);
-}
-
-static_inline void
-rx_atomic_clear_bit(rx_atomic_t *atomic, int bit) {
-    (void)__sync_fetch_and_and(&atomic->var, ~(1<<bit));
-}
-
-static_inline int
-rx_atomic_test_and_set_bit(rx_atomic_t *atomic, int bit) {
-    return (__sync_fetch_and_or(&atomic->var, 1<<bit) & 1<<bit) != 0;
-}
-
-static_inline int
-rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
-    return (__sync_fetch_and_and(&atomic->var, ~(1<<bit)) & 1<<bit) != 0;
-}
-
 #else
 
 /* If we're on a platform where we have no idea how to do atomics,
@@ -556,48 +430,6 @@ rx_atomic_sub(rx_atomic_t *atomic, int change) {
     MUTEX_EXIT(&rx_atomic_mutex);
 }
 
-static_inline int
-rx_atomic_test_bit(rx_atomic_t *atomic, int bit) {
-    return ((unsigned int) rx_atomic_read(atomic) & 1<<bit) != 0;
-}
-
-static_inline void
-rx_atomic_set_bit(rx_atomic_t *atomic, int bit) {
-    MUTEX_ENTER(&rx_atomic_mutex);
-    atomic->var |= (1<<bit);
-    MUTEX_EXIT(&rx_atomic_mutex);
-}
-
-static_inline void
-rx_atomic_clear_bit(rx_atomic_t *atomic, int bit) {
-    MUTEX_ENTER(&rx_atomic_mutex);
-    atomic->var &= ~(1<<bit);
-    MUTEX_EXIT(&rx_atomic_mutex);
-}
-
-static_inline int
-rx_atomic_test_and_set_bit(rx_atomic_t *atomic, int bit) {
-    int val;
-
-    MUTEX_ENTER(&rx_atomic_mutex);
-    val = atomic->var;
-    atomic->var |= 1<<bit;
-    MUTEX_EXIT(&rx_atomic_mutex);
-
-    return (val & 1<<bit) == 1<<bit;
-}
-
-static_inline int
-rx_atomic_test_and_clear_bit(rx_atomic_t *atomic, int bit) {
-    int val;
-
-    MUTEX_ENTER(&rx_atomic_mutex);
-    val = atomic->var;
-    atomic->var &= ~(1<<bit);
-    MUTEX_EXIT(&rx_atomic_mutex);
-
-    return (val & 1<<bit) == 1<<bit;
-}
 #endif
 
 #endif
diff --git a/src/rx/rx_call.c b/src/rx/rx_call.c
index 43d6034fc..6f22ce072 100644
--- a/src/rx/rx_call.c
+++ b/src/rx/rx_call.c
@@ -72,3 +72,23 @@ rx_RecordCallStatistics(struct rx_call *call, unsigned int rxInterface,
 			     totalFunc, &queue, &exec, call->app.bytesSent,
 			     call->app.bytesRcvd, 1);
 }
+
+/*
+ * Accessor for VolMonitor 'vos status'
+ * note: the rx_call members are all unsigned, but our return targets
+ * in wire struct transDebugInfo are all signed.  Sigh.
+ */
+void
+rx_GetCallStatus(struct rx_call *call, afs_int32 *readNext,
+			afs_int32 *transmitNext, int *lastSendTime,
+			int *lastReceiveTime)
+{
+    if (readNext != NULL)
+	*readNext = call->rnext;
+    if (transmitNext != NULL)
+	*transmitNext = call->tnext;
+    if (lastSendTime != NULL)
+	*lastSendTime = call->lastSendTime;
+    if (lastReceiveTime != NULL)
+	*lastReceiveTime = call->lastReceiveTime;
+}
diff --git a/src/rx/rx_clock.h b/src/rx/rx_clock.h
index e3f20a281..c1184e935 100644
--- a/src/rx/rx_clock.h
+++ b/src/rx/rx_clock.h
@@ -94,21 +94,14 @@ extern void clock_UpdateTime(void);
 #endif /* AFS_USE_GETTIMEOFDAY || AFS_PTHREAD_ENV */
 #else /* KERNEL */
 #define clock_Init()
-#if defined(AFS_SGI61_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX_64BIT_KERNEL)
-#define clock_GetTime(cv) osi_GetTime((osi_timeval_t *)cv)
-#else
-#if (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL)) || (defined(AFS_DARWIN100_ENV) && defined(__amd64__)) || defined(AFS_XBSD_ENV)
-#define        clock_GetTime(cv)                               \
-    BEGIN                                              \
-       struct timeval tv;                              \
-       osi_GetTime(&tv);                        \
-       (cv)->sec = (afs_int32)tv.tv_sec;               \
-       (cv)->usec = (afs_int32)tv.tv_usec;             \
-    END
-#else /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
-#define clock_GetTime(cv) osi_GetTime((osi_timeval_t *)(cv))
-#endif /* defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL) */
-#endif
+static_inline void
+clock_GetTime(struct clock *cv)
+{
+    osi_timeval32_t now;
+    osi_GetTime(&now);
+    cv->sec = now.tv_sec;
+    cv->usec = now.tv_usec;
+}
 #define clock_Sec() osi_Time()
 #define	clock_NewTime()		/* don't do anything; clock is fast enough in kernel */
 #endif /* KERNEL */
diff --git a/src/rx/rx_conn.h b/src/rx/rx_conn.h
index 60ae9776e..90e4fcf40 100644
--- a/src/rx/rx_conn.h
+++ b/src/rx/rx_conn.h
@@ -54,10 +54,11 @@ struct rx_connection {
     struct rx_service *service;	/* used by servers only */
     u_short serviceId;		/* To stamp on requests (clients only) */
     afs_int32 refCount;	        /* Reference count (rx_refcnt_mutex) */
-    u_char flags;		/* Defined below - (conn_data_lock) */
+    u_char spare;		/* was flags - placeholder for alignment */
     u_char type;		/* Type of connection, defined below */
     u_char secondsUntilPing;	/* how often to ping for each active call */
     u_char securityIndex;	/* corresponds to the security class of the */
+    afs_uint32 flags;		/* Defined in rx.h RX_CONN_* */
     /* securityObject for this conn */
     struct rx_securityClass *securityObject;	/* Security object for this connection */
     void *securityData;		/* Private data for this conn's security class */
diff --git a/src/rx/rx_conncache.c b/src/rx/rx_conncache.c
index 89f8d5e5d..ced822c73 100644
--- a/src/rx/rx_conncache.c
+++ b/src/rx/rx_conncache.c
@@ -142,6 +142,7 @@ rxi_AddCachedConnection(rx_connParts_p parts, struct rx_connection **conn)
 	new_entry->hasError = 0;
 	opr_queue_Prepend(&rxi_connectionCache, &new_entry->queue);
     }
+    (*conn)->flags |= RX_CONN_CACHED;
 
     /*
      * if malloc fails, we fail silently
@@ -258,6 +259,19 @@ rx_ReleaseCachedConnection(struct rx_connection *conn)
     struct opr_queue *cursor, *store;
 
     LOCK_CONN_CACHE;
+
+    /* Check if the caller is asking us to release a conn that did NOT come
+     * from the connection cache.  If so, don't bother searching the cache
+     * because the connection won't be found or destroyed.  Since we return
+     * void, the caller must assume the connection _has_ been found and
+     * destroyed. So to avoid leaking the connection, just destroy it now and
+     * return.
+     */
+    if (!(conn->flags & RX_CONN_CACHED)) {
+	rxi_DestroyConnection(conn);
+	UNLOCK_CONN_CACHE;
+	return;
+    }
     for (opr_queue_ScanSafe(&rxi_connectionCache, cursor, store)) {
 	struct cache_entry *cacheConn
 	    = opr_queue_Entry(cursor, struct cache_entry, queue);
@@ -274,6 +288,7 @@ rx_ReleaseCachedConnection(struct rx_connection *conn)
 		cacheConn->hasError = 1;
 		if (cacheConn->inUse == 0) {
 		    opr_queue_Remove(&cacheConn->queue);
+		    cacheConn->conn->flags &= ~RX_CONN_CACHED;
 		    rxi_DestroyConnection(cacheConn->conn);
 		    free(cacheConn);
 		}
diff --git a/src/rx/rx_globals.h b/src/rx/rx_globals.h
index caf0d3bc9..a6695ea16 100644
--- a/src/rx/rx_globals.h
+++ b/src/rx/rx_globals.h
@@ -459,12 +459,6 @@ EXT afs_uint32 rx_maxJumboRecvSize GLOBALSINIT(RX_MAX_PACKET_SIZE);
 /* need this to permit progs to run on AIX systems */
 EXT int (*rxi_syscallp) (afs_uint32 a3, afs_uint32 a4, void *a5)GLOBALSINIT(0);
 
-/* List of free queue entries */
-EXT struct rx_serverQueueEntry *rx_FreeSQEList GLOBALSINIT(0);
-#ifdef	RX_ENABLE_LOCKS
-EXT afs_kmutex_t freeSQEList_lock;
-#endif
-
 /* List of free call structures */
 EXT struct opr_queue rx_freeCallQueue;
 #ifdef	RX_ENABLE_LOCKS
diff --git a/src/rx/rx_identity.c b/src/rx/rx_identity.c
index 3d87ec436..887924ff7 100644
--- a/src/rx/rx_identity.c
+++ b/src/rx/rx_identity.c
@@ -181,9 +181,13 @@ rx_identity_freeContents(struct rx_identity *identity)
  */
 
 void
-rx_identity_free(struct rx_identity **identity)
+rx_identity_free(struct rx_identity **a_identity)
 {
-    rx_identity_freeContents(*identity);
-    rxi_Free(*identity, sizeof(struct rx_identity));
-    *identity = NULL;
+    struct rx_identity *identity = *a_identity;
+    *a_identity = NULL;
+    if (identity == NULL) {
+	return;
+    }
+    rx_identity_freeContents(identity);
+    rxi_Free(identity, sizeof(*identity));
 }
diff --git a/src/rx/rx_internal.h b/src/rx/rx_internal.h
index 800732e50..8d5fd79c6 100644
--- a/src/rx/rx_internal.h
+++ b/src/rx/rx_internal.h
@@ -20,6 +20,7 @@ extern rx_atomic_t rx_nWaited;
 /* Prototypes for internal functions */
 
 /* rx.c */
+extern int rxi_IsRunning(void);
 extern void rxi_CancelDelayedAckEvent(struct rx_call *);
 extern void rxi_PacketsUnWait(void);
 extern void rxi_SetPeerMtu(struct rx_peer *peer, afs_uint32 host,
diff --git a/src/rx/rx_kcommon.c b/src/rx/rx_kcommon.c
index 3d2314f5a..181d479bb 100644
--- a/src/rx/rx_kcommon.c
+++ b/src/rx/rx_kcommon.c
@@ -589,7 +589,7 @@ rxi_Findcbi(afs_uint32 addr)
 
 #else /* AFS_USERSPACE_IP_ADDR */
 
-#if !defined(AFS_AIX41_ENV) && !defined(AFS_DUX40_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
+#if !defined(AFS_AIX41_ENV) && !defined(AFS_DARWIN_ENV) && !defined(AFS_XBSD_ENV)
 #define IFADDR2SA(f) (&((f)->ifa_addr))
 #else /* AFS_AIX41_ENV */
 #define IFADDR2SA(f) ((f)->ifa_addr)
@@ -658,7 +658,8 @@ rxi_GetIFInfo(void)
     }
 #else
 #if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
-#if defined(AFS_FBSD80_ENV)
+#if defined(AFS_FBSD_ENV)
+    CURVNET_SET(rx_socket->so_vnet);
     TAILQ_FOREACH(ifn, &V_ifnet, if_link) {
 #else
     TAILQ_FOREACH(ifn, &ifnet, if_link) {
@@ -720,6 +721,11 @@ rxi_GetIFInfo(void)
 	    myNetAddrs[l] = addrs[l];
 	}
     }
+
+#ifdef AFS_FBSD_ENV
+    CURVNET_RESTORE();
+#endif
+
     return different;
 }
 
@@ -730,6 +736,11 @@ rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp)
 {
     struct sockaddr_in s, sr;
     rx_ifaddr_t ifad;
+    rx_ifnet_t ret;
+
+#ifdef AFS_FBSD_ENV
+    CURVNET_SET(rx_socket->so_vnet);
+#endif
 
     s.sin_family = AF_INET;
     s.sin_addr.s_addr = addr;
@@ -739,7 +750,14 @@ rxi_FindIfnet(afs_uint32 addr, afs_uint32 * maskp)
 	rx_ifaddr_netmask(ifad, (struct sockaddr *)&sr, sizeof(sr));
 	*maskp = sr.sin_addr.s_addr;
     }
-    return (ifad ? rx_ifaddr_ifnet(ifad) : NULL);
+
+    ret = (ifad ? rx_ifaddr_ifnet(ifad) : NULL);
+
+#ifdef AFS_FBSD_ENV
+    CURVNET_RESTORE();
+#endif
+
+    return ret;
 }
 
 #else /* DARWIN || XBSD */
@@ -936,11 +954,7 @@ rxk_NewSocketHost(afs_uint32 ahost, short aport)
 	goto bad;
     }
 #else /* defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV) */
-#ifdef  AFS_OSF_ENV
-    nam = m_getclr(M_WAIT, MT_SONAME);
-#else /* AFS_OSF_ENV */
     nam = m_get(M_WAIT, MT_SONAME);
-#endif
     if (nam == NULL) {
 #if defined(KERNEL_HAVE_UERROR)
 	setuerror(ENOBUFS);
@@ -1201,6 +1215,7 @@ rxk_Listener(void)
 #ifdef AFS_LINUX20_ENV
     rxk_ListenerPid = current->pid;
     rxk_ListenerTask = current;
+    allow_signal(SIGKILL);    /* Allowed, but blocked until shutdown */
 #endif
 #ifdef AFS_SUN5_ENV
     rxk_ListenerPid = 1;	/* No PID, just a flag that we're alive */
diff --git a/src/rx/rx_kcommon.h b/src/rx/rx_kcommon.h
index b5b6a1087..c5e6a437b 100644
--- a/src/rx/rx_kcommon.h
+++ b/src/rx/rx_kcommon.h
@@ -26,12 +26,6 @@ struct coda_inode_info {
 };
 #endif
 #endif
-#ifdef AFS_DARWIN_ENV
-#ifndef _MACH_ETAP_H_
-#define _MACH_ETAP_H_
-typedef unsigned short etap_event_t;
-#endif
-#endif
 
 
 #include "h/types.h"
diff --git a/src/rx/rx_kernel.h b/src/rx/rx_kernel.h
index c6318f3e6..93d7f5c9c 100644
--- a/src/rx/rx_kernel.h
+++ b/src/rx/rx_kernel.h
@@ -80,7 +80,7 @@ extern void osi_Panic(char *fmt, ...)
 #define rx_ifnet_flags(x) (x?(x)->if_flags:0)
 #if defined(FBSD_IFA_IFWITHNET_THREE_ARGS)
 #define rx_ifaddr_withnet(x) ifa_ifwithnet(x, 0, RT_ALL_FIBS)
-#elif defined(AFS_OBSD46_ENV) || defined(AFS_FBSD81_ENV)
+#elif defined(AFS_OBSD46_ENV) || defined(AFS_FBSD_ENV)
 #define rx_ifaddr_withnet(x) ifa_ifwithnet(x, 0)
 #else
 #define rx_ifaddr_withnet(x) ifa_ifwithnet(x)
diff --git a/src/rx/rx_lwp.c b/src/rx/rx_lwp.c
index fa4ee6dc4..a64f3be44 100644
--- a/src/rx/rx_lwp.c
+++ b/src/rx/rx_lwp.c
@@ -334,8 +334,7 @@ rx_ListenerProc(void *dummy)
 	rxi_ServerProc(threadID, newcall, &sock);
 	/* osi_Assert(sock != OSI_NULLSOCKET); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /* This is the server process request loop. The server process loop
@@ -368,8 +367,7 @@ rx_ServerProc(void * unused)
 	/* osi_Assert(threadID != -1); */
 	/* osi_Assert(newcall != NULL); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*
diff --git a/src/rx/rx_opaque.c b/src/rx/rx_opaque.c
index 31eb8251a..a6353b1dc 100644
--- a/src/rx/rx_opaque.c
+++ b/src/rx/rx_opaque.c
@@ -54,7 +54,7 @@
 struct rx_opaque *
 rx_opaque_new(void *data, size_t datalen)
 {
-    struct rx_opaque *opaque = rxi_Alloc(sizeof(struct rx_opaque));
+    struct rx_opaque *opaque = rxi_Alloc(sizeof(*opaque));
     if (opaque != NULL)
 	rx_opaque_populate(opaque, data, datalen);
     return opaque;
@@ -147,7 +147,8 @@ rx_opaque_copy(struct rx_opaque *to, const struct rx_opaque *from)
  *
  */
 void
-rx_opaque_freeContents(struct rx_opaque *buf) {
+rx_opaque_freeContents(struct rx_opaque *buf)
+{
     if (buf->val) {
 	rxi_Free(buf->val, buf->len);
     }
@@ -159,7 +160,8 @@ rx_opaque_freeContents(struct rx_opaque *buf) {
  * Zero, then free, the contents of an opaque object
  */
 void
-rx_opaque_zeroFreeContents(struct rx_opaque *buf) {
+rx_opaque_zeroFreeContents(struct rx_opaque *buf)
+{
     if (buf->val)
 	memset(buf->val, 0, buf->len);
     rx_opaque_freeContents(buf);
@@ -172,10 +174,16 @@ rx_opaque_zeroFreeContents(struct rx_opaque *buf) {
  */
 
 void
-rx_opaque_free(struct rx_opaque **buf) {
-    rx_opaque_freeContents(*buf);
-    rxi_Free(*buf, sizeof(struct rx_opaque));
-    *buf = NULL;
+rx_opaque_free(struct rx_opaque **a_buf)
+{
+    struct rx_opaque *buf = *a_buf;
+    *a_buf = NULL;
+    if (buf == NULL) {
+	return;
+    }
+
+    rx_opaque_freeContents(buf);
+    rxi_Free(buf, sizeof(*buf));
 }
 
 /*!
@@ -186,8 +194,14 @@ rx_opaque_free(struct rx_opaque **buf) {
  */
 
 void
-rx_opaque_zeroFree(struct rx_opaque **buf) {
-    rx_opaque_zeroFreeContents(*buf);
-    rxi_Free(*buf, sizeof(struct rx_opaque));
-    *buf = NULL;
+rx_opaque_zeroFree(struct rx_opaque **a_buf)
+{
+    struct rx_opaque *buf = *a_buf;
+    *a_buf = NULL;
+    if (buf == NULL) {
+	return;
+    }
+
+    rx_opaque_zeroFreeContents(buf);
+    rxi_Free(buf, sizeof(*buf));
 }
diff --git a/src/rx/rx_packet.c b/src/rx/rx_packet.c
index 214f3079a..6cf997b96 100644
--- a/src/rx/rx_packet.c
+++ b/src/rx/rx_packet.c
@@ -31,7 +31,7 @@
 #  endif
 #  include "h/socket.h"
 #  if !defined(AFS_SUN5_ENV) &&  !defined(AFS_LINUX20_ENV) && !defined(AFS_HPUX110_ENV)
-#   if	!defined(AFS_OSF_ENV) && !defined(AFS_AIX41_ENV)
+#   if	!defined(AFS_AIX41_ENV)
 #    include "sys/mount.h"		/* it gets pulled in by something later anyway */
 #   endif
 #   include "h/mbuf.h"
@@ -871,7 +871,7 @@ rx_CheckPackets(void)
 static void
 rxi_FreePacketNoLock(struct rx_packet *p)
 {
-    dpf(("Free %"AFS_PTR_FMT"\n", p));
+    dpf(("Free %p\n", p));
 
     RX_FPQ_MARK_FREE(p);
     rx_nFreePackets++;
@@ -884,7 +884,7 @@ static void
 rxi_FreePacketTSFPQ(struct rx_packet *p, int flush_global)
 {
     struct rx_ts_info_t * rx_ts_info;
-    dpf(("Free %"AFS_PTR_FMT"\n", p));
+    dpf(("Free %p\n", p));
 
     RX_TS_INFO_GET(rx_ts_info);
     RX_TS_FPQ_CHECKIN(rx_ts_info,p);
@@ -1183,7 +1183,7 @@ rxi_AllocPacketNoLock(int class)
 
     RX_TS_FPQ_CHECKOUT(rx_ts_info,p);
 
-    dpf(("Alloc %"AFS_PTR_FMT", class %d\n", p, class));
+    dpf(("Alloc %p, class %d\n", p, class));
 
 
     /* have to do this here because rx_FlushWrite fiddles with the iovs in
@@ -1241,7 +1241,7 @@ rxi_AllocPacketNoLock(int class)
     opr_queue_Remove(&p->entry);
     RX_FPQ_MARK_USED(p);
 
-    dpf(("Alloc %"AFS_PTR_FMT", class %d\n", p, class));
+    dpf(("Alloc %p, class %d\n", p, class));
 
 
     /* have to do this here because rx_FlushWrite fiddles with the iovs in
@@ -1279,7 +1279,7 @@ rxi_AllocPacketTSFPQ(int class, int pull_global)
 
     RX_TS_FPQ_CHECKOUT(rx_ts_info,p);
 
-    dpf(("Alloc %"AFS_PTR_FMT", class %d\n", p, class));
+    dpf(("Alloc %p, class %d\n", p, class));
 
     /* have to do this here because rx_FlushWrite fiddles with the iovs in
      * order to truncate outbound packets.  In the near future, may need
@@ -1598,6 +1598,7 @@ rxi_SplitJumboPacket(struct rx_packet *p, afs_uint32 host, short port,
     np->header = p->header;
     np->header.serial = p->header.serial + 1;
     np->header.seq = p->header.seq + 1;
+    np->header.userStatus = 0;
     np->header.flags = jp->flags;
     np->header.spare = jp->cksum;
 
@@ -1873,6 +1874,7 @@ rxi_ReceiveDebugPacket(struct rx_packet *ap, osi_socket asocket,
 		for (tc = rx_connHashTable[i]; tc; tc = tc->next) {
 		    if ((all || rxi_IsConnInteresting(tc))
 			&& tin.index-- <= 0) {
+			int do_secstats = 0;
 			tconn.host = tc->peer->host;
 			tconn.port = tc->peer->port;
 			tconn.cid = htonl(tc->cid);
@@ -1894,12 +1896,18 @@ rxi_ReceiveDebugPacket(struct rx_packet *ap, osi_socket asocket,
 
 			tconn.natMTU = htonl(tc->peer->natMTU);
 			tconn.error = htonl(tc->error);
-			tconn.flags = tc->flags;
+			tconn.flags = (u_char) (tc->flags & 0xff);  /* compat. */
 			tconn.type = tc->type;
 			tconn.securityIndex = tc->securityIndex;
 			if (tc->securityObject) {
-			    RXS_GetStats(tc->securityObject, tc,
-					 &tconn.secStats);
+			    int code;
+			    code = RXS_GetStats(tc->securityObject, tc,
+						&tconn.secStats);
+			    if (code == 0) {
+				do_secstats = 1;
+			    }
+			}
+			if (do_secstats) {
 #define DOHTONL(a) (tconn.secStats.a = htonl(tconn.secStats.a))
 #define DOHTONS(a) (tconn.secStats.a = htons(tconn.secStats.a))
 			    DOHTONL(flags);
@@ -1918,6 +1926,8 @@ rxi_ReceiveDebugPacket(struct rx_packet *ap, osi_socket asocket,
 				 sizeof(tconn.secStats.sparel) /
 				 sizeof(afs_int32); i++)
 				DOHTONL(sparel[i]);
+			} else {
+			    memset(&tconn.secStats, 0, sizeof(tconn.secStats));
 			}
 
 			MUTEX_EXIT(&rx_connHashTable_lock);
@@ -2148,7 +2158,7 @@ rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
 	if (!waslocked)
 	    AFS_GLOCK();
 	afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
-		   "before osi_NetSend()");
+		   "before rxi_NetSend()");
 	AFS_GUNLOCK();
     }
 #else
@@ -2157,14 +2167,14 @@ rxi_SendDebugPacket(struct rx_packet *apacket, osi_socket asocket,
 #endif
 #endif
     /* debug packets are not reliably delivered, hence the cast below. */
-    (void)osi_NetSend(asocket, &taddr, apacket->wirevec, apacket->niovecs,
+    (void)rxi_NetSend(asocket, &taddr, apacket->wirevec, apacket->niovecs,
 		      apacket->length + RX_HEADER_SIZE, istack);
 #ifdef KERNEL
 #ifdef RX_KERNEL_TRACE
     if (ICL_SETACTIVE(afs_iclSetp)) {
 	AFS_GLOCK();
 	afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
-		   "after osi_NetSend()");
+		   "after rxi_NetSend()");
 	if (!waslocked)
 	    AFS_GUNLOCK();
     }
@@ -2301,7 +2311,7 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
 	    if (!waslocked)
 		AFS_GLOCK();
 	    afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
-		       "before osi_NetSend()");
+		       "before rxi_NetSend()");
 	    AFS_GUNLOCK();
 	}
 #else
@@ -2310,7 +2320,7 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
 #endif
 #endif
 	if ((code =
-	     osi_NetSend(socket, &addr, p->wirevec, p->niovecs,
+	     rxi_NetSend(socket, &addr, p->wirevec, p->niovecs,
 			 p->length + RX_HEADER_SIZE, istack)) != 0) {
 	    /* send failed, so let's hurry up the resend, eh? */
             if (rx_stats_active)
@@ -2331,7 +2341,7 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
 	if (ICL_SETACTIVE(afs_iclSetp)) {
 	    AFS_GLOCK();
 	    afs_Trace1(afs_iclSetp, CM_TRACE_TIMESTAMP, ICL_TYPE_STRING,
-		       "after osi_NetSend()");
+		       "after rxi_NetSend()");
 	    if (!waslocked)
 		AFS_GUNLOCK();
 	}
@@ -2342,7 +2352,7 @@ rxi_SendPacket(struct rx_call *call, struct rx_connection *conn,
 #endif
 #ifdef RXDEBUG
     }
-    dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %"AFS_PTR_FMT" len %d\n",
+    dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %p len %d\n",
           deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], ntohl(peer->host),
           ntohs(peer->port), p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber,
           p->header.seq, p->header.flags, p, p->length));
@@ -2508,7 +2518,7 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
 	    AFS_GUNLOCK();
 #endif
 	if ((code =
-	     osi_NetSend(socket, &addr, &wirevec[0], len + 1, length,
+	     rxi_NetSend(socket, &addr, &wirevec[0], len + 1, length,
 			 istack)) != 0) {
 	    /* send failed, so let's hurry up the resend, eh? */
             if (rx_stats_active)
@@ -2535,7 +2545,7 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
 
     osi_Assert(p != NULL);
 
-    dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %"AFS_PTR_FMT" len %d\n",
+    dpf(("%c %d %s: %x.%u.%u.%u.%u.%u.%u flags %d, packet %p len %d\n",
           deliveryType, p->header.serial, rx_packetTypes[p->header.type - 1], ntohl(peer->host),
           ntohs(peer->port), p->header.serial, p->header.epoch, p->header.cid, p->header.callNumber,
           p->header.seq, p->header.flags, p, p->length));
@@ -2552,7 +2562,8 @@ rxi_SendPacketList(struct rx_call *call, struct rx_connection *conn,
 /* Send a raw abort packet, without any call or connection structures */
 void
 rxi_SendRawAbort(osi_socket socket, afs_uint32 host, u_short port,
-		 afs_int32 error, struct rx_packet *source, int istack)
+		 afs_uint32 serial, afs_int32 error,
+		 struct rx_packet *source, int istack)
 {
     struct rx_header theader;
     struct sockaddr_in addr;
@@ -2561,7 +2572,7 @@ rxi_SendRawAbort(osi_socket socket, afs_uint32 host, u_short port,
     memset(&theader, 0, sizeof(theader));
     theader.epoch = htonl(source->header.epoch);
     theader.callNumber = htonl(source->header.callNumber);
-    theader.serial = htonl(1);
+    theader.serial = htonl(serial);
     theader.type = RX_PACKET_TYPE_ABORT;
     theader.serviceId = htons(source->header.serviceId);
     theader.securityIndex = source->header.securityIndex;
@@ -2590,7 +2601,7 @@ rxi_SendRawAbort(osi_socket socket, afs_uint32 host, u_short port,
     addr.sin_len = sizeof(struct sockaddr_in);
 #endif
 
-    osi_NetSend(socket, &addr, iov, 2,
+    rxi_NetSend(socket, &addr, iov, 2,
 		sizeof(struct rx_header) + sizeof(error), istack);
 }
 
@@ -2644,6 +2655,7 @@ rxi_SendSpecial(struct rx_call *call,
     p->header.seq = 0;
     p->header.epoch = conn->epoch;
     p->header.type = type;
+    p->header.userStatus = 0;
     p->header.flags = 0;
     if (conn->type == RX_CLIENT_CONNECTION)
 	p->header.flags |= RX_CLIENT_INITIATED;
@@ -2766,6 +2778,7 @@ rxi_PrepareSendPacket(struct rx_call *call,
     p->header.seq = seq;
     p->header.epoch = conn->epoch;
     p->header.type = RX_PACKET_TYPE_DATA;
+    p->header.userStatus = 0;
     p->header.flags = 0;
     p->header.spare = 0;
     if (conn->type == RX_CLIENT_CONNECTION)
diff --git a/src/rx/rx_packet.h b/src/rx/rx_packet.h
index c451f8087..94269df7a 100644
--- a/src/rx/rx_packet.h
+++ b/src/rx/rx_packet.h
@@ -72,7 +72,6 @@
  * the MAX packet size will be the maximum receive size, but the maximum send
  * size will be larger than that. */
 
-#ifdef notdef
 /*  some sample MTUs
            4352   what FDDI(RFC1188) uses... Larger?
            4096   VJ's recommendation for FDDI
@@ -85,23 +84,6 @@
 	   9180   Classical IP over ATM (RFC2225)
 */
 
-/* * * * these are the old defines
-*/
-#define	RX_MAX_PACKET_SIZE	(RX_MAX_DL_MTU -RX_IPUDP_SIZE)
-
-#define	RX_MAX_PACKET_DATA_SIZE	(RX_MAX_PACKET_SIZE-RX_HEADER_SIZE)
-#ifdef AFS_HPUX_ENV
-/* HPUX by default uses an 802.3 size, and it's not evident from SIOCGIFCONF */
-#define	RX_LOCAL_PACKET_SIZE	(1492 - RX_IPUDP_SIZE)
-#define	RX_REMOTE_PACKET_SIZE	(1492 - RX_IPUDP_SIZE)
-#else
-#define	RX_LOCAL_PACKET_SIZE	RX_MAX_PACKET_SIZE	/* For hosts on same net */
-#define	RX_REMOTE_PACKET_SIZE	RX_MAX_PACKET_SIZE	/* see note above */
-#endif
-#endif /* notdef */
-
-/* These are the new, streamlined ones.
- */
 #define	RX_HEADER_SIZE		sizeof (struct rx_header)
 
 /* The minimum MTU for an IP network is 576 bytes including headers */
diff --git a/src/rx/rx_prototypes.h b/src/rx/rx_prototypes.h
index 8af530865..314ba0a06 100644
--- a/src/rx/rx_prototypes.h
+++ b/src/rx/rx_prototypes.h
@@ -188,9 +188,6 @@ extern int clock_UnInit(void);
 #if !defined(clock_UpdateTime)
 extern void clock_UpdateTime(void);
 #endif
-#if defined(UKERNEL) && !defined(osi_GetTime)
-extern int osi_GetTime(struct timeval *tv);
-#endif
 
 /* rx_clock_nt.c */
 
@@ -412,6 +409,8 @@ extern struct rx_packet *rxi_SplitJumboPacket(struct rx_packet *p,
 extern int osi_NetSend(osi_socket socket, void *addr, struct iovec *dvec,
 		       int nvecs, int length, int istack);
 #endif
+extern int rxi_NetSend(osi_socket socket, void *addr, struct iovec *dvec,
+		       int nvecs, int length, int istack);
 extern struct rx_packet *rxi_ReceiveDebugPacket(struct rx_packet *ap,
 						osi_socket asocket,
 						afs_uint32 ahost, short aport,
@@ -426,8 +425,8 @@ extern void rxi_SendPacketList(struct rx_call *call,
 			       struct rx_connection *conn,
 			       struct rx_packet **list, int len, int istack);
 extern void rxi_SendRawAbort(osi_socket socket, afs_uint32 host, u_short port,
-			     afs_int32 error, struct rx_packet *source,
-			     int istack);
+			     afs_uint32 serial, afs_int32 error,
+			     struct rx_packet *source, int istack);
 extern struct rx_packet *rxi_SendSpecial(struct rx_call *call,
 					 struct rx_connection *conn,
 					 struct rx_packet *optionalPacket,
diff --git a/src/rx/rx_pthread.c b/src/rx/rx_pthread.c
index b4272bbce..388bca823 100644
--- a/src/rx/rx_pthread.c
+++ b/src/rx/rx_pthread.c
@@ -182,7 +182,7 @@ event_handler(void *argp)
 #endif
 	rx_pthread_event_rescheduled = 0;
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 
@@ -208,6 +208,12 @@ rxi_ListenerProc(osi_socket sock, int *tnop, struct rx_call **newcallp)
     u_short port;
     struct rx_packet *p = (struct rx_packet *)0;
 
+    if (!(rx_enable_hot_thread && newcallp)) {
+	/* Don't do this for hot threads, since we might stop being the
+	 * listener. */
+	opr_threadname_set("rx_Listener");
+    }
+
     MUTEX_ENTER(&listener_mutex);
     while (!listeners_started) {
 	CV_WAIT(&rx_listener_cond, &listener_mutex);
@@ -264,8 +270,7 @@ rx_ListenerProc(void *argp)
 	rxi_ServerProc(threadID, newcall, &sock);
 	/* osi_Assert(sock != OSI_NULLSOCKET); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /* This is the server process request loop. The server process loop
@@ -312,8 +317,7 @@ rx_ServerProc(void * dummy)
 	/* osi_Assert(threadID != -1); */
 	/* osi_Assert(newcall != NULL); */
     }
-    /* not reached */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*
diff --git a/src/rx/rx_rdwr.c b/src/rx/rx_rdwr.c
index 4124658e5..e2721d384 100644
--- a/src/rx/rx_rdwr.c
+++ b/src/rx/rx_rdwr.c
@@ -24,9 +24,6 @@
 #   if defined(AFS_AIX_ENV) || defined(AFS_AUX_ENV) || defined(AFS_SUN5_ENV)
 #    include "h/systm.h"
 #   endif
-#   ifdef	AFS_OSF_ENV
-#    include <net/net_globals.h>
-#   endif /* AFS_OSF_ENV */
 #   ifdef AFS_LINUX20_ENV
 #    include "h/socket.h"
 #   endif
@@ -772,7 +769,9 @@ rxi_WriteProc(struct rx_call *call, char *buf,
 	/* might be out of space now */
 	if (!nbytes) {
 	    return requestCount;
-	} else;			/* more data to send, so get another packet and keep going */
+	} else {
+	    /* more data to send, so get another packet and keep going */
+	}
     } while (nbytes);
 
     return requestCount - nbytes;
@@ -1015,7 +1014,7 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
 #ifdef RX_TRACK_PACKETS
     struct opr_queue *cursor;
 #endif
-    int nextio;
+    int nextio = 0;
     int requestCount;
     struct opr_queue tmpq;
 #ifdef RXDEBUG_PACKET
@@ -1023,7 +1022,6 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
 #endif
 
     requestCount = nbytes;
-    nextio = 0;
 
     MUTEX_ENTER(&call->lock);
     if (call->error) {
@@ -1060,7 +1058,6 @@ rxi_WritevProc(struct rx_call *call, struct iovec *iov, int nio, int nbytes)
      * to send. Set RX_PROTOCOL_ERROR if any problems are found in
      * the iovec. We put the loop condition at the end to ensure that
      * a zero length write will push a short packet. */
-    nextio = 0;
     opr_queue_Init(&tmpq);
 #ifdef RXDEBUG_PACKET
     tmpqc = 0;
diff --git a/src/rx/rx_stats.c b/src/rx/rx_stats.c
index 269313753..2daa54832 100644
--- a/src/rx/rx_stats.c
+++ b/src/rx/rx_stats.c
@@ -33,8 +33,8 @@
 
 #if !defined(KERNEL)
 #include <roken.h>
-#include <afs/opr.h>
 #endif
+#include <afs/opr.h>
 
 #ifdef KERNEL
 /* no kmutex, no atomic emulation...*/
@@ -67,7 +67,9 @@ struct rx_statisticsAtomic rx_stats;
 struct rx_statistics *
 rx_GetStatistics(void) {
     struct rx_statistics *stats = rxi_Alloc(sizeof(struct rx_statistics));
+
     MUTEX_ENTER(&rx_stats_mutex);
+    opr_StaticAssert(sizeof(*stats) == sizeof(rx_stats));
     memcpy(stats, &rx_stats, sizeof(struct rx_statistics));
     MUTEX_EXIT(&rx_stats_mutex);
 
diff --git a/src/rx/rx_stubs.c b/src/rx/rx_stubs.c
new file mode 100644
index 000000000..666801add
--- /dev/null
+++ b/src/rx/rx_stubs.c
@@ -0,0 +1,59 @@
+/* rx/rx_stubs.c - Stub functions for things not really implemented. */
+/*
+ * Copyright (C) 2017 by Benjamin Kaduk.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * Stub functions that don't have anyplace better to live.
+ * For example, libafsrpc is going to export an rxgk_GetServerInfo
+ * routine whether or not rxgk support is enabled at configure time.
+ * But src/rxgk is not compiled at all in that case, so we need a home
+ * for the stub function that will be exported in that case.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#ifndef ENABLE_RXGK
+
+#include <rx/rx.h>
+#include <rx/rxgk.h>
+#include <rx/rx_identity.h>
+
+#include <errno.h>
+
+afs_int32
+rxgk_GetServerInfo(struct rx_connection *conn, RXGK_Level *level,
+		   rxgkTime *expiry, struct rx_identity **identity)
+{
+    return EINVAL;
+}
+#endif	/* !ENABLE_RXGK */
diff --git a/src/rx/rx_trace.c b/src/rx/rx_trace.c
index 94dc11714..512491e7c 100644
--- a/src/rx/rx_trace.c
+++ b/src/rx/rx_trace.c
@@ -60,8 +60,9 @@ rxi_flushtrace(void)
     rxi_tracepos = 0;
     if (rxi_logfd < 0)
 	return;
-    if (write(rxi_logfd, rxi_tracebuf, len) < 0)
-	; /* don't care */
+    if (write(rxi_logfd, rxi_tracebuf, len) < 0) {
+	/* don't care */
+    }
 }
 
 void
@@ -121,6 +122,8 @@ rxi_calltrace(unsigned int event, struct rx_call *call)
 
     case RX_CALL_ARRIVAL:
 	call->traceWait = now;
+	break;
+
     default:
 	break;
     }
diff --git a/src/rx/rx_user.c b/src/rx/rx_user.c
index f135fac0e..0ba068b5a 100644
--- a/src/rx/rx_user.c
+++ b/src/rx/rx_user.c
@@ -352,7 +352,6 @@ rx_getAllAddrMaskMtu(afs_uint32 addrBuffer[], afs_uint32 maskBuffer[],
 #endif
 
 #ifdef AFS_NT40_ENV
-extern rx_atomic_t rxinit_status;
 void
 rxi_InitMorePackets(void) {
     int npackets, ncbufs;
@@ -373,7 +372,7 @@ rx_GetIFInfo(void)
 
     LOCK_IF_INIT;
     if (Inited) {
-	if (Inited < 2 && !rx_atomic_test_bit(&rxinit_status, 0)) {
+	if (Inited < 2 && rxi_IsRunning()) {
             /* We couldn't initialize more packets earlier.
              * Do it now. */
             rxi_InitMorePackets();
@@ -407,11 +406,11 @@ rx_GetIFInfo(void)
     UNLOCK_IF;
 
     /*
-     * If rxinit_status is still set, rx_InitHost() has yet to be called
+     * If rxi_IsRunning is false, rx_InitHost() has yet to be called
      * and we therefore do not have any mutex locks initialized.  As a
      * result we cannot call rxi_MorePackets() without crashing.
      */
-    if (rx_atomic_test_bit(&rxinit_status, 0))
+    if (!rxi_IsRunning())
         return;
 
     rxi_InitMorePackets();
@@ -448,8 +447,10 @@ rxi_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
 
 #if defined(AFS_SGI_ENV)
     rcode = afs_syscall(AFS_SYSCALL, 28, a3, a4, a5);
-#else
+#elif defined(AFS_SYSCALL)
     rcode = syscall(AFS_SYSCALL, 28 /* AFSCALL_CALL */ , a3, a4, a5);
+#else
+    rcode = -1;
 #endif /* AFS_SGI_ENV */
 
     signal(SIGSYS, old);
diff --git a/src/rx/xdr.c b/src/rx/xdr.c
index df6d179c5..7d23917ea 100644
--- a/src/rx/xdr.c
+++ b/src/rx/xdr.c
@@ -332,14 +332,11 @@ xdr_bool(XDR * xdrs, bool_t * bp)
 bool_t
 xdr_enum(XDR * xdrs, enum_t * ep)
 {
-    enum sizecheck { SIZEVAL };	/* used to find the size of an enum */
-
     /*
      * enums are treated as ints
      */
 
-    return (xdr_long(xdrs, (long *)ep));
-
+    return (xdr_int(xdrs, ep));
 }
 
 /*
@@ -427,7 +424,7 @@ xdr_bytes(XDR * xdrs, char **cpp, u_int * sizep,
 	if (sp == NULL) {
 	    return (FALSE);
 	}
-	/* fall into ... */
+	AFS_FALLTHROUGH;
 
     case XDR_ENCODE:
 	return (xdr_opaque(xdrs, sp, nodesize));
@@ -522,7 +519,7 @@ xdr_string(XDR * xdrs, char **cpp, u_int maxsize)
 	if (sp == NULL) {
 	    return (TRUE);	/* already free */
 	}
-	/* Fall through */
+	AFS_FALLTHROUGH;
     case XDR_ENCODE:
 	size = strlen(sp);
 	break;
@@ -550,7 +547,7 @@ xdr_string(XDR * xdrs, char **cpp, u_int maxsize)
 	    return (FALSE);
 	}
 	sp[size] = 0;
-	/* fall into ... */
+	AFS_FALLTHROUGH;
 
     case XDR_ENCODE:
 	return (xdr_opaque(xdrs, sp, size));
diff --git a/src/rxdebug/rxdebug.c b/src/rxdebug/rxdebug.c
index 3d4bf0a51..5cd30b2cf 100644
--- a/src/rxdebug/rxdebug.c
+++ b/src/rxdebug/rxdebug.c
@@ -22,6 +22,10 @@
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 
+#ifdef ENABLE_RXGK
+# include <rx/rxgk.h>
+#endif
+
 
 #define	TIMEOUT	    20
 
@@ -143,6 +147,10 @@ MainCommand(struct cmd_syndesc *as, void *arock)
 
     if (as->parms[9].items) {
 	char *name = as->parms[9].items->data;
+        /* Note that this assumes that the security levels for rxkad and rxgk
+         * use the same constants (0, 1, and 2). Perhaps a little ugly, but the
+         * constants being identical makes it really convenient to do it this
+         * way. */
 	if (strcmp(name, "clear") == 0)
 	    onlyAuth = 0;
 	else if (strcmp(name, "auth") == 0)
@@ -309,8 +317,8 @@ MainCommand(struct cmd_syndesc *as, void *arock)
 	    printf("Showing only client connections\n");
 	if (onlyAuth != 999) {
 	    static char *name[] =
-		{ "unauthenticated", "rxkad_clear", "rxkad_auth",
-		"rxkad_crypt"
+		{ "unauthenticated", "clear", "auth",
+		"crypt"
 	    };
 	    printf("Showing only %s connections\n", name[onlyAuth + 1]);
 	}
@@ -367,11 +375,20 @@ MainCommand(struct cmd_syndesc *as, void *arock)
 		    if (tconn.securityIndex != RX_SECIDX_NULL)
 			continue;
 		} else {
-		    if (tconn.securityIndex != RX_SECIDX_KAD)
-			continue;
+		    if (tconn.securityIndex != RX_SECIDX_KAD) {
+#ifdef ENABLE_RXGK
+                        if (tconn.securityIndex != RX_SECIDX_GK)
+#endif
+                            continue;
+                    }
 		    if (withSecStats && (tconn.secStats.type == RX_SECTYPE_KAD)
 			&& (tconn.secStats.level != onlyAuth))
 			continue;
+#ifdef ENABLE_RXGK
+		    if (withSecStats && (tconn.secStats.type == RX_SECTYPE_GK)
+			&& (tconn.secStats.level != onlyAuth))
+			continue;
+#endif
 		}
 	    }
 
@@ -469,6 +486,41 @@ MainCommand(struct cmd_syndesc *as, void *arock)
 			    printf("\n");
 			break;
 		    }
+#ifdef ENABLE_RXGK
+                case RX_SECTYPE_GK: {
+			char *level;
+			char flags = tconn.secStats.flags;
+			if (tconn.secStats.level == RXGK_LEVEL_CLEAR)
+			    level = "clear";
+			else if (tconn.secStats.level == RXGK_LEVEL_AUTH)
+			    level = "auth";
+			else if (tconn.secStats.level == RXGK_LEVEL_CRYPT)
+			    level = "crypt";
+			else
+			    level = "unknown";
+			printf("  rxgk: level %s", level);
+			if (flags)
+			    printf(", flags");
+			if ((flags & RXGK_STATS_UNALLOC))
+			    printf(" unalloc");
+			if ((flags & RXGK_STATS_AUTH))
+			    printf(" authenticated");
+			if (tconn.secStats.expires)
+			    printf(", expires in %.1f hours",
+				   ((afs_uint32) tconn.secStats.expires -
+				    time(0)) / 3600.0);
+			if (!(flags & RXGK_STATS_UNALLOC)) {
+			    printf("\n  Received %u bytes in %u packets\n",
+				   tconn.secStats.bytesReceived,
+				   tconn.secStats.packetsReceived);
+			    printf("  Sent %u bytes in %u packets\n",
+				   tconn.secStats.bytesSent,
+				   tconn.secStats.packetsSent);
+			} else
+			    printf("\n");
+			break;
+                    }
+#endif /* ENABLE_RXGK */
 
 		default:
 		    printf("  unknown\n");
diff --git a/src/rxgen/rpc_cout.c b/src/rxgen/rpc_cout.c
index 3ddb27aca..5c17a9041 100644
--- a/src/rxgen/rpc_cout.c
+++ b/src/rxgen/rpc_cout.c
@@ -122,14 +122,7 @@ print_header(definition * def)
     f_print(fout, "bool_t\n");
     f_print(fout, "xdr_%s(XDR *xdrs, ", def->def_name);
     f_print(fout, "%s ", def->def_name);
-#if 0
-    if (def->def_kind != DEF_TYPEDEF
-	|| !isvectordef(def->def.ty.old_type, def->def.ty.rel)) {
-	f_print(fout, "*");
-    }
-#else
     f_print(fout, "*");
-#endif
     f_print(fout, "objp)\n");
     f_print(fout, "{\n");
 }
@@ -375,7 +368,10 @@ emit_union(definition * def)
 	    object =
 		alloc(strlen(def->def_name) + strlen(format) +
 		      strlen(dflt->name) + 1);
-	    s_print(object, format, def->def_name, dflt->name);
+	    if (brief_flag)
+		s_print(object, briefformat, dflt->name);
+	    else
+		s_print(object, format, def->def_name, dflt->name);
 	    print_ifstat(2, dflt->prefix, dflt->type, dflt->rel,
 			 dflt->array_max, object, dflt->name);
 	    free(object);
diff --git a/src/rxgen/rpc_parse.c b/src/rxgen/rpc_parse.c
index ab26c954a..43510ea73 100644
--- a/src/rxgen/rpc_parse.c
+++ b/src/rxgen/rpc_parse.c
@@ -112,10 +112,6 @@ static void get1_param_type(definition * defp, declaration * dec,
 			    char **param_type);
 static void get_param_type(definition * defp, declaration * dec,
 			   char **param_type, char **typename);
-#ifdef undef
-static void hndle_param_tail(definition * defp, declaration * dec,
-			     token * tokp, char *typename);
-#endif
 static void cs_Proc_CodeGeneration(definition * defp, int split_flag,
 				   char *procheader);
 static void cs_ProcName_setup(definition * defp, char *procheader,
@@ -125,10 +121,12 @@ static void cs_ProcMarshallInParams_setup(definition * defp, int split_flag);
 static void cs_ProcSendPacket_setup(definition * defp, int split_flag);
 static void cs_ProcUnmarshallOutParams_setup(definition * defp);
 static void cs_ProcTail_setup(definition * defp, int split_flag);
+static void ucs_ProcCallback_setup(definition * defp, char *cbheader);
 static void ucs_ProcName_setup(definition * defp, char *procheader,
 			      int split_flag);
 static void ucs_ProcParams_setup(definition * defp, int split_flag);
-static void ucs_ProcTail_setup(definition * defp, int split_flag);
+static void ucs_ProcTail_setup(definition * defp, char *cbheader,
+			       int split_flag);
 static void ss_Proc_CodeGeneration(definition * defp);
 static void ss_ProcName_setup(definition * defp);
 static void ss_ProcParams_setup(definition * defp);
@@ -411,6 +409,9 @@ get_declaration(declaration * dec, defkind dkind)
 	}
 	dec->rel = REL_ARRAY;
 	if (peekscan(TOK_RANGLE, &tok)) {
+	    if ((dkind == DEF_INPARAM) || (dkind == DEF_INOUTPARAM)) {
+		error("input arrays must specify a max size");
+	    }
 	    dec->array_max = "~0u";	/* unspecified size, use max */
 	} else {
 	    scan_num(&tok);
@@ -953,7 +954,7 @@ hdle_param_tok(definition * defp, declaration * dec, token * tokp,
     Proc_list->component_kind = DEF_PARAM;
     Proc_list->code = alloc(250);
     Proc_list->scode = alloc(250);
-    get_declaration(dec, DEF_PARAM);
+    get_declaration(dec, par_kind);
     Proc_list->pl.param_name = dec->name;
     get1_param_type(defp, dec, &Proc_list->pl.param_type);
     print_param(dec);
@@ -1015,32 +1016,6 @@ get_param_type(definition * defp, declaration * dec, char **param_type,
 }
 
 
-#ifdef undef
-static void
-hndle_param_tail(definition * defp, declaration * dec, token * tokp,
-		 char *typename)
-{
-    char *amp;
-
-    if (dec->rel == REL_POINTER)
-	Proc_list->pl.param_flag |= INDIRECT_PARAM;
-    else
-	Proc_list->pl.param_flag &= ~INDIRECT_PARAM;
-    amp = "";
-    if (!(Proc_list->pl.param_flag & INDIRECT_PARAM))
-	amp = "&";
-
-    sprintf(Proc_list->code, "xdr_%s(&z_xdrs, %s%s)", typename, amp,
-	    Proc_list->pl.param_name);
-    sprintf(Proc_list->scode, "xdr_%s(z_xdrs, &%s)", typename,
-	    Proc_list->pl.param_name);
-    scan2(TOK_COMMA, TOK_RPAREN, tokp);
-    if (tokp->kind == TOK_COMMA)
-	peek(tokp);
-}
-#endif
-
-
 static void
 cs_Proc_CodeGeneration(definition * defp, int split_flag, char *procheader)
 {
@@ -1057,10 +1032,13 @@ cs_Proc_CodeGeneration(definition * defp, int split_flag, char *procheader)
     }
 
     if (!kflag && !split_flag && uflag) {
+	if (!cflag) {
+	    ucs_ProcCallback_setup(defp, "ubik_call_");
+	}
 	ucs_ProcName_setup(defp, "ubik_", split_flag);
 	if (!cflag) {
 	    ucs_ProcParams_setup(defp, split_flag);
-	    ucs_ProcTail_setup(defp, split_flag);
+	    ucs_ProcTail_setup(defp, "ubik_call_", split_flag);
 	}
     }
 }
@@ -1298,7 +1276,12 @@ cs_ProcTail_setup(definition * defp, int split_flag)
 static void
 ss_Proc_CodeGeneration(definition * defp)
 {
-    defp->can_fail = 0;
+    extern char zflag;
+
+    if (zflag)
+	defp->can_fail = 0;
+    else
+	defp->can_fail = 1;
     ss_ProcName_setup(defp);
     if (!cflag) {
 	ss_ProcParams_setup(defp);
@@ -1427,8 +1410,6 @@ ss_ProcSpecial_setup(definition * defp)
 		if (streq(string, structname(plist->pl.param_type))) {
 		    plist->pl.string_name = spec->sdef.string_name;
 		    plist->pl.param_flag |= FREETHIS_PARAM;
-		    fprintf(fout, "\n\t%s.%s = 0;", plist->pl.param_name,
-			    spec->sdef.string_name);
 		}
 	    }
 	}
@@ -1443,22 +1424,13 @@ ss_ProcSpecial_setup(definition * defp)
 		    case REL_ARRAY:
 			plist->pl.string_name = alloc(40);
 			if (brief_flag) {
-			    f_print(fout, "\n\t%s.val = 0;",
-				    plist->pl.param_name);
-			    f_print(fout, "\n\t%s.len = 0;",
-				    plist->pl.param_name);
 			    s_print(plist->pl.string_name, "val");
 			} else {
-			    f_print(fout, "\n\t%s.%s_val = 0;",
-				    plist->pl.param_name, defp1->def_name);
-			    f_print(fout, "\n\t%s.%s_len = 0;",
-				    plist->pl.param_name, defp1->def_name);
 			    s_print(plist->pl.string_name, "%s_val",
 				    defp1->def_name);
 			}
 			break;
 		    case REL_POINTER:
-			f_print(fout, "\n\t%s = 0;", plist->pl.param_name);
 			plist->pl.string_name = NULL;
 			break;
 		    default:
@@ -1474,13 +1446,19 @@ ss_ProcSpecial_setup(definition * defp)
 	    if (plist->component_kind == DEF_PARAM) {
 		if (streq(defp1->def_name, structname(plist->pl.param_type))) {
 		    plist->pl.param_flag |= FREETHIS_PARAM;
-		    fprintf(fout, "\n\tmemset(&%s, 0, sizeof(%s));",
-				 plist->pl.param_name, defp1->def_name);
 		}
 	    }
 	}
     }
 
+    for (plist = defp->pc.plists; plist; plist = plist->next) {
+	if (plist->component_kind == DEF_PARAM) {
+	    fprintf(fout, "\n\tmemset(&%s, 0, sizeof(%s));",
+		    plist->pl.param_name,
+		    plist->pl.param_name);
+	}
+    }
+
     f_print(fout, "\n");
 }
 
@@ -1543,6 +1521,8 @@ ss_ProcCallRealProc_setup(definition * defp)
     f_print(fout, ");\n");
     if (zflag) {
 	f_print(fout, "\tif (z_result)\n\t\treturn z_result;\n");
+    } else {
+	f_print(fout, "\tif (z_result)\n\t\tgoto fail;\n");
     }
 }
 
@@ -1667,6 +1647,68 @@ ss_ProcTail_setup(definition * defp)
     f_print(fout, "}\n\n");
 }
 
+static void
+ucs_ProcCallback_setup(definition * defp, char *cbheader)
+{
+    proc1_list *plist;
+    int any_params = 0;
+
+    for (plist = defp->pc.plists; plist; plist = plist->next) {
+	if (plist->component_kind == DEF_PARAM) {
+	    any_params = 1;
+	    break;
+	}
+    }
+
+    if (any_params) {
+	f_print(fout, "struct args_%s%s%s {\n", prefix,
+		      PackagePrefix[PackageIndex], defp->pc.proc_name);
+
+	for (plist = defp->pc.plists; plist; plist = plist->next) {
+	    if (plist->component_kind == DEF_PARAM) {
+		f_print(fout, "\t");
+		if (plist->pl.param_kind == DEF_INPARAM &&
+		    strcmp(plist->pl.param_type, "char *") == 0) {
+		    f_print(fout, "const ");
+		}
+		if ((plist->pl.param_flag & OUT_STRING) != 0) {
+		    f_print(fout, "%s *%s", plist->pl.param_type,
+			    plist->pl.param_name);
+		} else {
+		    f_print(fout, "%s %s", plist->pl.param_type,
+			    plist->pl.param_name);
+		}
+		f_print(fout, ";\n");
+	    }
+	}
+
+	f_print(fout, "};\n");
+    }
+
+    f_print(fout, "static int\n"
+		  "%s%s%s%s(struct ubik_callrock_info *info, void *z_rock)\n"
+		  "{\n",
+		  cbheader, prefix, PackagePrefix[PackageIndex],
+		  defp->pc.proc_name);
+
+    if (any_params) {
+	f_print(fout, "\tstruct args_%s%s%s *z_args = z_rock;\n", prefix,
+		      PackagePrefix[PackageIndex], defp->pc.proc_name);
+    }
+
+    f_print(fout, "\treturn %s%s%s(info->conn", prefix, PackagePrefix[PackageIndex],
+		  defp->pc.proc_name);
+
+    for (plist = defp->pc.plists; plist; plist = plist->next) {
+	if (plist->component_kind == DEF_PARAM) {
+	    f_print(fout, ",\n\t\t\tz_args->%s", plist->pl.param_name);
+	}
+    }
+
+    f_print(fout, ");\n"
+		  "}\n");
+
+}
 
 static void
 ucs_ProcName_setup(definition * defp, char *procheader, int split_flag)
@@ -1757,138 +1799,41 @@ ucs_ProcParams_setup(definition * defp, int split_flag)
 }
 
 static void
-ucs_ProcTail_setup(definition * defp, int split_flag)
+ucs_ProcTail_setup(definition * defp, char *cbheader, int split_flag)
 {
     proc1_list *plist;
+    int any_params = 0;
+
+    f_print(fout, "{\n");
 
-    f_print(fout, "{\tafs_int32 rcode, code, newHost, thisHost, i, _ucount;\n");
-    f_print(fout, "\tint chaseCount, pass, needsync;\n");
-#if 0 /* goes with block below */
-    f_print(fout, "\tint j, inlist;\n");
-#endif
-    f_print(fout, "\tstruct rx_connection *tc;\n");
-    f_print(fout, "\tstruct rx_peer *rxp;\n");
-    f_print(fout, "\tshort origLevel;\n\n");
-    f_print(fout, "\tif (!aclient)\n");
-    f_print(fout, "\t\treturn UNOENT;\n");
-    f_print(fout, "\tLOCK_UBIK_CLIENT(aclient);\n\n");
-    f_print(fout, "\t restart:\n");
-    f_print(fout, "\torigLevel = aclient->initializationState;\n");
-    f_print(fout, "\trcode = UNOSERVERS;\n");
-    f_print(fout, "\tchaseCount = needsync = 0;\n\n");
-#if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
-    f_print(fout, "\tinlist = 0;\n");
-    f_print(fout, "\tLOCK_UCLNT_CACHE;\n");
-    f_print(fout, "\tfor (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {\n");
-    f_print(fout, "\t\tif (calls_needsync[j] == (int *)%s%s%s) {\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
-    f_print(fout, "\t\t\tinlist = needsync = 1;\n");
-    f_print(fout, "\t\t\tbreak;\n");
-    f_print(fout, "\t\t}\n");
-    f_print(fout, "\t}\n");
-    f_print(fout, "\tUNLOCK_UCLNT_CACHE;\n");
-#endif
-    f_print(fout, "\t/* \n\t* First  pass, we try all servers that are up.\n\t* Second pass, we try all servers.\n\t*/\n");
-    f_print(fout, "\tfor (pass = 0; pass < 2; pass++) {  /*p */\n");
-    f_print(fout, "\t\t/* For each entry in our servers list */\n");
-    f_print(fout, "\t\tfor (_ucount = 0;; _ucount++) {     /*s */\n\n");
-    f_print(fout, "\t\tif (needsync) {\n");
-    f_print(fout, "\t\t\t/* Need a sync site. Lets try to quickly find it */\n");
-    f_print(fout, "\t\t\tif (aclient->syncSite) {\n");
-    f_print(fout, "\t\t\t\tnewHost = aclient->syncSite;        /* already in network order */\n");
-    f_print(fout, "\t\t\t\taclient->syncSite = 0;      /* Will reset if it works */\n");
-    f_print(fout, "\t\t\t} else if (aclient->conns[3]) {\n");
-    f_print(fout, "\t\t\t\t/* If there are fewer than four db servers in a cell,\n");
-    f_print(fout, "\t\t\t\t* there's no point in making the GetSyncSite call.\n");
-    f_print(fout, "\t\t\t\t* At best, it's a wash. At worst, it results in more\n");
-    f_print(fout, "\t\t\t\t* RPCs than you would otherwise make.\n");
-    f_print(fout, "\t\t\t\t*/\n");
-    f_print(fout, "\t\t\t\ttc = aclient->conns[_ucount];\n");
-    f_print(fout, "\t\t\t\tif (tc && rx_ConnError(tc)) {\n");
-    f_print(fout, "\t\t\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
-    f_print(fout, "\t\t\t\t}\n");
-    f_print(fout, "\t\t\t\tif (!tc)\n");
-    f_print(fout, "\t\t\t\t\tbreak;\n");
-    f_print(fout, "\t\t\t\tcode = VOTE_GetSyncSite(tc, &newHost);\n");
-    f_print(fout, "\t\t\t\tif (aclient->initializationState != origLevel)\n");
-    f_print(fout, "\t\t\t\t\tgoto restart;   /* somebody did a ubik_ClientInit */\n");
-    f_print(fout, "\t\t\t\tif (code)\n");
-    f_print(fout, "\t\t\t\t\tnewHost = 0;\n");
-    f_print(fout, "\t\t\t\tnewHost = htonl(newHost);   /* convert to network order */\n");
-    f_print(fout, "\t\t\t} else {\n");
-    f_print(fout, "\t\t\t\tnewHost = 0;\n");
-    f_print(fout, "\t\t\t}\n");
-    f_print(fout, "\t\t\tif (newHost) {\n");
-    f_print(fout, "\t\t\t\t/* position count at the appropriate slot in the client\n");
-    f_print(fout, "\t\t\t\t* structure and retry. If we can't find in slot, we'll\n");
-    f_print(fout, "\t\t\t\t* just continue through the whole list \n");
-    f_print(fout, "\t\t\t\t*/\n");
-    f_print(fout, "\t\t\t\tfor (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {\n");
-    f_print(fout, "\t\t\t\t\trxp = rx_PeerOf(aclient->conns[i]);\n");
-    f_print(fout, "\t\t\t\t\tthisHost = rx_HostOf(rxp);\n");
-    f_print(fout, "\t\t\t\t\tif (!thisHost)\n");
-    f_print(fout, "\t\t\t\t\t\tbreak;\n");
-    f_print(fout, "\t\t\t\t\tif (thisHost == newHost) {\n");
-    f_print(fout, "\t\t\t\t\t\tif (chaseCount++ > 2)\n");
-    f_print(fout, "\t\t\t\t\t\t\tbreak;  /* avoid loop asking */\n");
-    f_print(fout, "\t\t\t\t\t\t_ucount = i;  /* this index is the sync site */\n");
-    f_print(fout, "\t\t\t\t\t\tbreak;\n");
-    f_print(fout, "\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n");
-    f_print(fout, "\t\t/*needsync */\n");
-    f_print(fout, "\t\ttc = aclient->conns[_ucount];\n");
-    f_print(fout, "\t\tif (tc && rx_ConnError(tc)) {\n");
-    f_print(fout, "\t\t\taclient->conns[_ucount] = tc = ubik_RefreshConn(tc);\n");
-    f_print(fout, "\t\t}\n");
-    f_print(fout, "\t\tif (!tc)\n");
-    f_print(fout, "\t\t\tbreak;\n\n");
-    f_print(fout, "\t\tif ((pass == 0) && (aclient->states[_ucount] & CFLastFailed)) {\n");
-    f_print(fout, "\t\t\tcontinue;       /* this guy's down */\n");
-    f_print(fout, "\t\t}\n");
-
-    f_print(fout, "\t\trcode = %s%s%s(tc\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
     for (plist = defp->pc.plists; plist; plist = plist->next) {
 	if (plist->component_kind == DEF_PARAM) {
-	    plist->pl.param_flag &= ~PROCESSED_PARAM;
-	    f_print(fout, ", %s", plist->pl.param_name);
+	    any_params = 1;
+	    break;
 	}
     }
-    f_print(fout, ");\n");
-    f_print(fout, "\t\tif (aclient->initializationState != origLevel) {\n");
-    f_print(fout, "\t\t\t/* somebody did a ubik_ClientInit */\n");
-    f_print(fout, "\t\t\tif (rcode)\n");
-    f_print(fout, "\t\t\t\tgoto restart;       /* call failed */\n");
-    f_print(fout, "\t\t\telse\n");
-    f_print(fout, "\t\t\t\tgoto done;  /* call suceeded */\n");
-    f_print(fout, "\t\t}\n");
-    f_print(fout, "\t\tif (rcode < 0) {    /* network errors */\n");
-    f_print(fout, "\t\t\taclient->states[_ucount] |= CFLastFailed; /* Mark server down */\n");
-    f_print(fout, "\t\t} else if (rcode == UNOTSYNC) {\n");
-    f_print(fout, "\t\t\tneedsync = 1;\n");
-    f_print(fout, "\t\t} else if (rcode != UNOQUORUM) {\n");
-    f_print(fout, "\t\t\t/* either misc ubik code, or misc appl code, or success. */\n");
-    f_print(fout, "\t\t\taclient->states[_ucount] &= ~CFLastFailed;        /* mark server up*/\n");
-    f_print(fout, "\t\t\tgoto done;      /* all done */\n");
-    f_print(fout, "\t\t}\n");
-    f_print(fout, "\t\t}                       /*s */\n");
-    f_print(fout, "\t}                           /*p */\n\n");
-    f_print(fout, "\tdone:\n");
-    f_print(fout, "\tif (needsync) {\n");
-
-#if 0 /* We should do some sort of caching algorithm for this, but I need to think about it - shadow 26 jun 06 */
-    f_print(fout, "\t\tif (!inlist) {          /* Remember proc call that needs sync site */\n");
-    f_print(fout, "\t\t\tLOCK_UCLNT_CACHE;\n");
-    f_print(fout, "\t\t\tcalls_needsync[synccount % SYNCCOUNT] = (int *)%s%s%s;\n", prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
-    f_print(fout, "\t\t\tsynccount++;\n");
-    f_print(fout, "\t\t\tUNLOCK_UCLNT_CACHE;\n");
-    f_print(fout, "\t\t\tinlist = 1;\n");
-    f_print(fout, "\t\t}\n");
-#endif
-    f_print(fout, "\t\tif (!rcode) {           /* Remember the sync site - cmd successful */\n");
-    f_print(fout, "\t\t\trxp = rx_PeerOf(aclient->conns[_ucount]);\n");
-    f_print(fout, "\t\t\taclient->syncSite = rx_HostOf(rxp);\n");
-    f_print(fout, "\t\t}\n");
-    f_print(fout, "\t}\n");
-    f_print(fout, "\tUNLOCK_UBIK_CLIENT(aclient);\n");
-    f_print(fout, "\treturn rcode;\n}\n\n");
+
+    if (any_params) {
+	f_print(fout, "\tstruct args_%s%s%s args;\n", prefix,
+		      PackagePrefix[PackageIndex], defp->pc.proc_name);
+	f_print(fout, "\tmemset(&args, 0, sizeof(args));\n\n");
+
+	for (plist = defp->pc.plists; plist; plist = plist->next) {
+	    if (plist->component_kind == DEF_PARAM) {
+		plist->pl.param_flag &= ~PROCESSED_PARAM;
+		f_print(fout, "\targs.%s = %s;\n", plist->pl.param_name,
+			      plist->pl.param_name);
+	    }
+	}
+
+	f_print(fout, "\n\treturn ubik_CallRock(aclient, aflags, %s%s%s%s, &args);\n",
+		      cbheader, prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
+    } else {
+	f_print(fout, "\treturn ubik_CallRock(aclient, aflags, %s%s%s%s, NULL);\n",
+		      cbheader, prefix, PackagePrefix[PackageIndex], defp->pc.proc_name);
+    }
+
+    f_print(fout, "}\n\n");
 }
 
 
diff --git a/src/rxgk/.gitignore b/src/rxgk/.gitignore
new file mode 100644
index 000000000..ea1e59a00
--- /dev/null
+++ b/src/rxgk/.gitignore
@@ -0,0 +1,3 @@
+/rxgk_errs.h
+/rxgk_errs.c
+/rxgk_int.h
diff --git a/src/rxgk/Makefile.in b/src/rxgk/Makefile.in
new file mode 100644
index 000000000..16da77d22
--- /dev/null
+++ b/src/rxgk/Makefile.in
@@ -0,0 +1,105 @@
+srcdir=@srcdir@
+include @TOP_OBJDIR@/src/config/Makefile.config
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
+
+INCLS=	${TOP_INCDIR}/rx/rx.h ${TOP_INCDIR}/rx/rxgk.h ${TOP_INCDIR}/rx/rxgk_types.h \
+	${TOP_INCDIR}/rx/rxgk_errs.h ${TOP_INCDIR}/rx/rxgk_int.h
+
+LT_objs = rxgk_client.lo rxgk_server.lo rxgk_errs.lo rxgk_int.cs.lo \
+	rxgk_int.xdr.lo rxgk_int.ss.lo rxgk_procs.lo rxgk_token.lo \
+	rxgk_util.lo rxgk_packet.lo rxgk_crypto_rfc3961.lo
+
+LT_deps =   $(top_builddir)/src/opr/liboafs_opr.la \
+	    $(top_builddir)/src/comerr/liboafs_comerr.la \
+	    $(top_builddir)/src/rx/liboafs_rx.la \
+	    $(top_builddir)/src/crypto/rfc3961/liboafs_rfc3961.la
+
+LT_libs =   # gssapi will go here
+
+all: depinstall rxgk_int.cs.c rxgk_int.ss.c rxgk_int.xdr.c rxgk_int.h \
+	${LT_objs} liboafs_rxgk.la librxgk_pic.la
+
+generated: \
+	rxgk_errs.h rxgk_errs.c rxgk_int.h rxgk_int.cs.c rxgk_int.xdr.c \
+	rxgk_int.ss.c
+
+depinstall: \
+	${TOP_INCDIR}/rx/rxgk.h \
+	${TOP_INCDIR}/rx/rxgk_types.h \
+	${TOP_INCDIR}/rx/rxgk_errs.h \
+	${TOP_INCDIR}/rx/rxgk_int.h
+
+${TOP_INCDIR}/rx/rxgk.h: ${srcdir}/rxgk.h ${TOP_INCDIR}/rx/rxgk_errs.h \
+		${TOP_INCDIR}/rx/rxgk_int.h ${TOP_INCDIR}/rx/rxgk_types.h
+	${INSTALL_DATA} ${srcdir}/rxgk.h $@
+
+${TOP_INCDIR}/rx/rxgk_types.h: ${srcdir}/rxgk_types.h
+	${INSTALL_DATA} ${srcdir}/rxgk_types.h $@
+
+${TOP_INCDIR}/rx/rxgk_errs.h: rxgk_errs.h
+	${INSTALL_DATA} $? $@
+
+${TOP_INCDIR}/rx/rxgk_int.h: rxgk_int.h
+	${INSTALL_DATA} $? $@
+
+rxgk_int.cs.c: rxgk_int.xg
+	${RXGEN} -b -A -x -C -o $@ ${srcdir}/rxgk_int.xg
+
+rxgk_int.ss.c: rxgk_int.xg
+	${RXGEN} -b -A -x -S -o $@ ${srcdir}/rxgk_int.xg
+
+rxgk_int.xdr.c: rxgk_int.xg
+	${RXGEN} -b -A -x -c -o $@ ${srcdir}/rxgk_int.xg
+
+rxgk_int.h: rxgk_int.xg
+	${RXGEN} -b -A -x -h -o $@ ${srcdir}/rxgk_int.xg
+
+rxgk_int.ss.o: rxgk_int.ss.c rxgk_int.xdr.c rxgk_int.h
+rxgk_int.cs.o: rxgk_int.cs.c rxgk_int.xdr.c rxgk_int.h
+rxgk_int.xdr.o: rxgk_int.xdr.c rxgk_int.h
+
+liboafs_rxgk.la: liboafs_rxgk.la.sym ${LT_objs} ${LT_deps}
+	$(LT_LDLIB_shlib) $(LT_objs) $(LT_deps) $(LT_libs)
+
+librxgk_pic.la: $(LT_objs)
+	$(LT_LDLIB_pic) $(LT_objs)
+
+$(LT_objs): $(INCLS)
+
+rxgk_errs.h: rxgk_errs.c
+rxgk_errs.c: rxgk_errs.et
+	$(RM) -f rxgk_errs.h rxgk_errs.c
+	${COMPILE_ET} -p ${srcdir} rxgk_errs
+
+#
+# Installation targets
+#
+test: all
+
+install: liboafs_rxgk.la rxgk.h rxgk_types.h rxgk_errs.h rxgk_int.h
+	if [ "@ENABLE_RXGK@" = yes ]; then \
+		${INSTALL} -d ${DESTDIR}${includedir}/rx; \
+		${INSTALL_DATA} ${srcdir}/rxgk.h ${DESTDIR}${includedir}/rx/rxgk.h ; \
+		${INSTALL_DATA} ${srcdir}/rxgk_types.h ${DESTDIR}${includedir}/rx/rxgk_types.h ; \
+		${INSTALL_DATA} rxgk_errs.h ${DESTDIR}${includedir}/rx/rxgk_errs.h ; \
+		${INSTALL_DATA} rxgk_int.h ${DESTDIR}${includedir}/rx/rxgk_int.h ; \
+	fi
+
+dest: liboafs_rxgk.la rxgk.h rxgk_types.h rxgk_errs.h rxgk_int.h
+	if [ "@ENABLE_RXGK@" = yes ]; then \
+		${INSTALL} -d ${DEST}${includedir}/rx; \
+		${INSTALL_DATA} ${srcdir}/rxgk.h ${DEST}/include/rx/rxgk.h ; \
+		${INSTALL_DATA} ${srcdir}/rxgk_types.h ${DEST}/include/rx/rxgk_types.h ; \
+		${INSTALL_DATA} rxgk_errs.h ${DEST}/include/rx/rxgk_errs.h ; \
+		${INSTALL_DATA} rxgk_int.h ${DEST}/include/rx/rxgk_int.h ; \
+	fi
+
+#
+# Misc. targets
+#
+clean:
+	$(LT_CLEAN)
+	$(RM) -f *.o *.a *.cs.c *.ss.c *.xdr.c rxgk_int.h core
+
+include ../config/Makefile.version
diff --git a/src/rxgk/NTMakefile b/src/rxgk/NTMakefile
new file mode 100644
index 000000000..e421106c4
--- /dev/null
+++ b/src/rxgk/NTMakefile
@@ -0,0 +1,29 @@
+# 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
+
+RELDIR=rxgk
+!include ..\config\NTMakefile.$(SYS_NAME)
+
+INCFILEDIR = $(DESTDIR)\include\rx
+
+INCFILES  = \
+	$(INCFILEDIR)\rxgk_types.h \
+	$(INCFILEDIR)\rxgk_int.h
+
+$(INCFILEDIR)\rxgk_types.h: rxgk_types.h
+	$(COPY) rxgk_types.h $@
+
+$(INCFILEDIR)\rxgk_int.h: rxgk_int.h
+	$(COPY) rxgk_int.h $@
+
+rxgk_int.h: rxgk_int.xg
+	$(RXGEN) -b -A -x -h -o $@ rxgk_int.xg
+
+install_headers:  $(INCFILES)
+
+clean::
+	$(DEL) rxgk_int.h
diff --git a/src/rxgk/liboafs_rxgk.la.sym b/src/rxgk/liboafs_rxgk.la.sym
new file mode 100644
index 000000000..4c61ec97c
--- /dev/null
+++ b/src/rxgk/liboafs_rxgk.la.sym
@@ -0,0 +1,21 @@
+RXGK_CombineTokens
+RXGK_GSSNegotiate
+rxgk_GetServerInfo
+rxgk_NewClientSecurityObject
+rxgk_NewServerSecurityObject
+rxgk_check_mic_in_key
+rxgk_cipher_expansion
+rxgk_copy_key
+rxgk_decrypt_in_key
+rxgk_derive_tk
+rxgk_encrypt_in_key
+rxgk_enctype_better
+rxgk_make_key
+rxgk_make_token
+rxgk_mic_in_key
+rxgk_mic_length
+rxgk_nonce
+rxgk_print_token
+rxgk_print_token_and_key
+rxgk_random_key
+rxgk_release_key
diff --git a/src/rxgk/rxgk.h b/src/rxgk/rxgk.h
new file mode 100644
index 000000000..e68b9bc3b
--- /dev/null
+++ b/src/rxgk/rxgk.h
@@ -0,0 +1,125 @@
+/* rxgk.h - External interfaces for RXGK */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * External interfaces for RXGK.
+ */
+
+#ifndef OPENAFS_RXGK_H
+#define OPENAFS_RXGK_H
+
+/* Pull in the com_err table */
+#include <rx/rxgk_errs.h>
+
+/* Pull in the protocol description */
+#include <rx/rxgk_int.h>
+
+/* Pull in our basic type definitions */
+#include <rx/rxgk_types.h>
+
+/* RX-internal headers we depend on. */
+#include <rx/rx_opaque.h>
+#include <rx/rx_identity.h>
+
+/* rxgkTime is defined in rxgk_int.xg. rxgkTime values are unix timestamps, but
+ * in 100-nanosecond units. */
+
+/* Helpers to avoid having to count zeros. */
+static_inline rxgkTime secondsToRxgkTime(afs_uint64 seconds) {
+    return seconds * (rxgkTime)10000000;
+}
+static_inline afs_uint64 rxgkTimeToSeconds(rxgkTime atime) {
+    return (afs_uint64)atime / 10000000;
+}
+
+/** Get the current timestamp as an rxgkTime. */
+static_inline rxgkTime RXGK_NOW(void)
+{
+    struct timeval tv;
+    osi_GetTime(&tv);
+    return secondsToRxgkTime(tv.tv_sec) + (rxgkTime)tv.tv_usec * 10;
+}
+
+typedef afs_int32 (*rxgk_getkey_func)(void *rock, afs_int32 *kvno,
+				      afs_int32 *enctype, rxgk_key *key);
+
+/* Flags for our rx security stats */
+#define RXGK_STATS_UNALLOC 0x1
+#define RXGK_STATS_AUTH    0x2
+
+/* rxgk_server.c */
+struct rx_securityClass * rxgk_NewServerSecurityObject(void *getkey_rock,
+						       rxgk_getkey_func getkey);
+afs_int32 rxgk_GetServerInfo(struct rx_connection *conn, RXGK_Level *level,
+			     rxgkTime *expiry, struct rx_identity **identity);
+
+/* rxgk_client.c */
+struct rx_securityClass *rxgk_NewClientSecurityObject(RXGK_Level level,
+						      afs_int32 enctype,
+						      rxgk_key k0,
+						      RXGK_Data *token);
+
+/* rxgk_crypto_IMPL.c (currently rfc3961 is the only IMPL) */
+afs_int32 rxgk_make_key(rxgk_key *key_out, void *raw_key, afs_uint32 length,
+			afs_int32 enctype) AFS_NONNULL();
+afs_int32 rxgk_copy_key(rxgk_key key_in, rxgk_key *key_out) AFS_NONNULL();
+afs_int32 rxgk_random_key(afs_int32 *enctype, rxgk_key *key_out) AFS_NONNULL();
+void rxgk_release_key(rxgk_key *key) AFS_NONNULL();
+afs_int32 rxgk_mic_length(rxgk_key key, size_t *out) AFS_NONNULL();
+afs_int32 rxgk_mic_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+			  RXGK_Data *out) AFS_NONNULL();
+afs_int32 rxgk_check_mic_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+				RXGK_Data *mic) AFS_NONNULL();
+afs_int32 rxgk_encrypt_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+			      RXGK_Data *out) AFS_NONNULL();
+afs_int32 rxgk_decrypt_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+			      RXGK_Data *out) AFS_NONNULL();
+afs_int32 rxgk_derive_tk(rxgk_key *tk, rxgk_key k0, afs_uint32 epoch,
+			 afs_uint32 cid, rxgkTime start_time,
+			 afs_uint32 key_number) AFS_NONNULL();
+afs_int32 rxgk_cipher_expansion(rxgk_key k0, afs_uint32 *len_out) AFS_NONNULL();
+afs_int32 rxgk_nonce(RXGK_Data *nonce, afs_uint32 len) AFS_NONNULL();
+int rxgk_enctype_better(afs_int32 old_enctype, afs_int32 new_enctype);
+
+/* rxgk_token.c */
+afs_int32 rxgk_make_token(struct rx_opaque *out, RXGK_TokenInfo *info,
+			  struct rx_opaque *k0, PrAuthName *identities,
+			  int nids, rxgk_key key, afs_int32 kvno,
+			  afs_int32 enctype) AFS_NONNULL((1,2,3,6));
+afs_int32 rxgk_print_token(struct rx_opaque *out, RXGK_TokenInfo *input_info,
+			   struct rx_opaque *k0, rxgk_key key, afs_int32 kvno,
+			   afs_int32 enctype) AFS_NONNULL();
+afs_int32 rxgk_print_token_and_key(struct rx_opaque *out,
+                                   RXGK_TokenInfo *input_info, rxgk_key key,
+                                   afs_int32 kvno, afs_int32 enctype,
+                                   rxgk_key *k0_out) AFS_NONNULL();
+
+#endif /* OPENAFS_RXGK_H */
diff --git a/src/rxgk/rxgk_client.c b/src/rxgk/rxgk_client.c
new file mode 100644
index 000000000..a73783946
--- /dev/null
+++ b/src/rxgk/rxgk_client.c
@@ -0,0 +1,522 @@
+/* rxgk/rxgk_client.c - Client-only security object routines */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Client-only security object routines.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#include <afs/opr.h>
+
+/* OS-specific system headers go here */
+
+#include <rx/rx.h>
+#include <rx/rx_packet.h>
+#include <rx/rx_identity.h>
+#include <rx/rxgk.h>
+#include <rx/xdr.h>
+
+#include "rxgk_private.h"
+
+static void
+cprivate_destroy(struct rxgk_cprivate *cp)
+{
+    if (cp == NULL)
+        return;
+    rxgk_release_key(&cp->k0);
+    rx_opaque_freeContents(&cp->token);
+    rxi_Free(cp, sizeof(*cp));
+}
+
+/*
+ * Increment the reference count on the security object secobj.
+ */
+static_inline void
+obj_ref(struct rx_securityClass *secobj)
+{
+    secobj->refCount++;
+}
+
+/*
+ * Decrement the reference count on the security object secobj.
+ * If the reference count falls to zero, release the underlying storage.
+ */
+static void
+obj_rele(struct rx_securityClass *secobj)
+{
+    struct rxgk_cprivate *cp;
+
+    secobj->refCount--;
+    if (secobj->refCount > 0) {
+	/* still in use */
+	return;
+    }
+
+    cp = secobj->privateData;
+    cprivate_destroy(cp);
+    rxi_Free(secobj, sizeof(*secobj));
+    return;
+}
+
+static int
+rxgk_ClientClose(struct rx_securityClass *aobj)
+{
+    obj_rele(aobj);
+    return 0;
+}
+
+static int
+rxgk_NewClientConnection(struct rx_securityClass *aobj,
+			 struct rx_connection *aconn)
+{
+    struct rxgk_cconn *cc = NULL;
+    struct rxgk_cprivate *cp;
+
+    if (rx_GetSecurityData(aconn) != NULL)
+	goto error;
+    cp = aobj->privateData;
+
+    cc = rxi_Alloc(sizeof(*cc));
+    if (cc == NULL)
+	goto error;
+    cc->start_time = RXGK_NOW();
+    /* Set the header and trailer size to be reserved for the security
+     * class in each packet. */
+    if (rxgk_security_overhead(aconn, cp->level, cp->k0) != 0)
+	goto error;
+    rx_SetSecurityData(aconn, cc);
+    obj_ref(aobj);
+    return 0;
+
+ error:
+    rxi_Free(cc, sizeof(*cc));
+    return RXGK_INCONSISTENCY;
+}
+
+static int
+rxgk_ClientPreparePacket(struct rx_securityClass *aobj, struct rx_call *acall,
+			 struct rx_packet *apacket)
+{
+    struct rxgk_cconn *cc;
+    struct rxgk_cprivate *cp;
+    struct rx_connection *aconn;
+    rxgk_key tk;
+    afs_uint32 lkvno;
+    afs_uint16 wkvno, len;
+    int ret;
+
+    aconn = rx_ConnectionOf(acall);
+    cc = rx_GetSecurityData(aconn);
+    cp = aobj->privateData;
+
+    len = rx_GetDataSize(apacket);
+    lkvno = cc->key_number;
+    cc->stats.psent++;
+    cc->stats.bsent += len;
+    wkvno = (afs_uint16)lkvno;
+    rx_SetPacketCksum(apacket, wkvno);
+
+    if (cp->level == RXGK_LEVEL_CLEAR)
+        return 0;
+
+    ret = rxgk_derive_tk(&tk, cp->k0, rx_GetConnectionEpoch(aconn),
+			 rx_GetConnectionId(aconn), cc->start_time, lkvno);
+    if (ret != 0)
+	return ret;
+
+    switch(cp->level) {
+	case RXGK_LEVEL_AUTH:
+	    ret = rxgk_mic_packet(tk, RXGK_CLIENT_MIC_PACKET, aconn, apacket);
+	    break;
+	case RXGK_LEVEL_CRYPT:
+	    ret = rxgk_enc_packet(tk, RXGK_CLIENT_ENC_PACKET, aconn, apacket);
+	    break;
+	default:
+	    ret = RXGK_INCONSISTENCY;
+	    break;
+    }
+
+    rxgk_release_key(&tk);
+    return ret;
+}
+
+/*
+ * Helpers for GetResponse.
+ */
+
+/*
+ * Populate the RXGK_Authenticator structure.
+ * The caller is responsible for pre-zeroing the structure and freeing
+ * the resulting allocations, including partial allocations in the case
+ * of failure.
+ */
+static int
+fill_authenticator(RXGK_Authenticator *authenticator, RXGK_Challenge *challenge,
+		   struct rxgk_cprivate *cp, struct rx_connection *aconn)
+{
+    afs_int32 call_numbers[RX_MAXCALLS];
+    int ret, call_i;
+    opr_StaticAssert(sizeof(authenticator->nonce) == RXGK_CHALLENGE_NONCE_LEN);
+    opr_StaticAssert(sizeof(challenge->nonce) == RXGK_CHALLENGE_NONCE_LEN);
+
+    memset(&call_numbers, 0, sizeof(call_numbers));
+
+    memcpy(authenticator->nonce, challenge->nonce, sizeof(authenticator->nonce));
+
+    authenticator->level = cp->level;
+    authenticator->epoch = rx_GetConnectionEpoch(aconn);
+    authenticator->cid = rx_GetConnectionId(aconn);
+    /* Export the call numbers. */
+    ret = rxi_GetCallNumberVector(aconn, call_numbers);
+    if (ret != 0)
+	return ret;
+    authenticator->call_numbers.val = xdr_alloc(RX_MAXCALLS *
+						sizeof(afs_int32));
+    if (authenticator->call_numbers.val == NULL)
+	return RXGEN_CC_MARSHAL;
+    authenticator->call_numbers.len = RX_MAXCALLS;
+    for (call_i = 0; call_i < RX_MAXCALLS; call_i++)
+	authenticator->call_numbers.val[call_i] = (afs_uint32)call_numbers[call_i];
+    return 0;
+}
+
+/* XDR-encode an authenticator and encrypt it. */
+static int
+pack_wrap_authenticator(RXGK_Data *encdata, RXGK_Authenticator *authenticator,
+			struct rxgk_cprivate *cp, struct rxgk_cconn *cc)
+{
+    XDR xdrs;
+    struct rx_opaque data = RX_EMPTY_OPAQUE;
+    rxgk_key tk = NULL;
+    int ret;
+    u_int len;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+
+    xdrlen_create(&xdrs);
+    if (!xdr_RXGK_Authenticator(&xdrs, authenticator)) {
+	ret = RXGEN_CC_MARSHAL;
+	goto done;
+    }
+    len = xdr_getpos(&xdrs);
+    ret = rx_opaque_alloc(&data, len);
+    if (ret != 0)
+	goto done;
+    xdr_destroy(&xdrs);
+    xdrmem_create(&xdrs, data.val, len, XDR_ENCODE);
+    if (!xdr_RXGK_Authenticator(&xdrs, authenticator)) {
+	ret = RXGEN_CC_MARSHAL;
+	goto done;
+    }
+    ret = rxgk_derive_tk(&tk, cp->k0, authenticator->epoch, authenticator->cid,
+		         cc->start_time, cc->key_number);
+    if (ret != 0)
+	goto done;
+    ret = rxgk_encrypt_in_key(tk, RXGK_CLIENT_ENC_RESPONSE, &data, encdata);
+    if (ret != 0)
+	goto done;
+
+ done:
+    if (xdrs.x_ops) {
+        xdr_destroy(&xdrs);
+    }
+    rx_opaque_freeContents(&data);
+    rxgk_release_key(&tk);
+    return ret;
+}
+
+/* XDR-encode an RXGK_Response structure to put it on the wire.
+ * The caller must free the contents of the out parameter. */
+static int
+pack_response(RXGK_Data *out, RXGK_Response *response)
+{
+    XDR xdrs;
+    int ret;
+    u_int len;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+
+    xdrlen_create(&xdrs);
+    if (!xdr_RXGK_Response(&xdrs, response)) {
+	ret = RXGEN_CC_MARSHAL;
+	goto done;
+    }
+    len = xdr_getpos(&xdrs);
+    ret = rx_opaque_alloc(out, len);
+    if (ret != 0)
+	goto done;
+    xdr_destroy(&xdrs);
+    xdrmem_create(&xdrs, out->val, len, XDR_ENCODE);
+    if (!xdr_RXGK_Response(&xdrs, response)) {
+	rx_opaque_freeContents(out);
+	ret = RXGEN_CC_MARSHAL;
+	goto done;
+    }
+
+ done:
+    if (xdrs.x_ops) {
+        xdr_destroy(&xdrs);
+    }
+    return ret;
+}
+
+/*
+ * Respond to a challenge packet.
+ * The data of the packet on entry is the XDR-encoded RXGK_Challenge.
+ * We decode it and reuse the packet structure to prepare a response.
+ */
+static int
+rxgk_GetResponse(struct rx_securityClass *aobj, struct rx_connection *aconn,
+		 struct rx_packet *apacket)
+{
+    struct rxgk_cprivate *cp;
+    struct rxgk_cconn *cc;
+    XDR xdrs;
+    RXGK_Challenge challenge;
+    RXGK_Response response;
+    RXGK_Authenticator authenticator;
+    struct rx_opaque packed = RX_EMPTY_OPAQUE;
+    int ret;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+    memset(&challenge, 0, sizeof(challenge));
+    memset(&response, 0, sizeof(response));
+    memset(&authenticator, 0, sizeof(authenticator));
+
+    cp = aobj->privateData;
+    cc = rx_GetSecurityData(aconn);
+
+    /*
+     * Decode the challenge to get the nonce.
+     * This assumes that the entire challenge is in a contiguous data block in
+     * the packet. rx in general can store packet data in multiple different
+     * buffers (pointed to by apacket->wirevec[N]), but the payload when
+     * receiving a Challenge packet should all be in one buffer (so we can just
+     * reference it directly via rx_DataOf()). If this assumption turns out to
+     * be wrong, then we'll just see a truncated challenge blob and this
+     * function will likely return an error; there should be no danger of
+     * buffer overrun or anything scary like that.
+     */
+    if (rx_Contiguous(apacket) < RXGK_CHALLENGE_NONCE_LEN) {
+        ret = RXGK_PACKETSHORT;
+	goto done;
+    }
+    xdrmem_create(&xdrs, rx_DataOf(apacket), rx_Contiguous(apacket),
+		  XDR_DECODE);
+    if (!xdr_RXGK_Challenge(&xdrs, &challenge)) {
+	ret = RXGEN_CC_UNMARSHAL;
+	goto done;
+    }
+
+    /* Start filling the response. */
+    response.start_time = cc->start_time;
+    if (rx_opaque_copy(&response.token, &cp->token) != 0) {
+	ret = RXGEN_CC_MARSHAL;
+	goto done;
+    }
+
+    /* Fill up the authenticator */
+    ret = fill_authenticator(&authenticator, &challenge, cp, aconn);
+    if (ret != 0)
+	goto done;
+    /* Authenticator is full, now to pack and encrypt it. */
+    ret = pack_wrap_authenticator(&response.authenticator, &authenticator, cp, cc);
+    if (ret != 0)
+	goto done;
+    /* Put the kvno we used on the wire for the remote end. */
+    rx_SetPacketCksum(apacket, (afs_uint16)cc->key_number);
+
+    /* Response is ready, now to shove it in a packet. */
+    ret = pack_response(&packed, &response);
+    if (ret != 0)
+	goto done;
+    osi_Assert(packed.len <= 0xffffu);
+    rx_packetwrite(apacket, 0, packed.len, packed.val);
+    rx_SetDataSize(apacket, (afs_uint16)packed.len);
+
+ done:
+    if (xdrs.x_ops) {
+        xdr_destroy(&xdrs);
+    }
+    xdr_free((xdrproc_t)xdr_RXGK_Challenge, &challenge);
+    xdr_free((xdrproc_t)xdr_RXGK_Response, &response);
+    xdr_free((xdrproc_t)xdr_RXGK_Authenticator, &authenticator);
+    rx_opaque_freeContents(&packed);
+    return ret;
+}
+
+static void
+update_kvno(struct rxgk_cconn *cc, afs_uint32 kvno)
+{
+    cc->key_number = kvno;
+
+    /* XXX Our statistics for tracking when to re-key the conn should be reset
+     * here. */
+}
+
+static int
+rxgk_ClientCheckPacket(struct rx_securityClass *aobj, struct rx_call *acall,
+		       struct rx_packet *apacket)
+{
+    struct rxgk_cconn *cc;
+    struct rxgk_cprivate *cp;
+    struct rx_connection *aconn;
+    afs_uint32 lkvno, kvno;
+    afs_uint16 len;
+    int ret;
+
+    aconn = rx_ConnectionOf(acall);
+    cc = rx_GetSecurityData(aconn);
+    cp = aobj->privateData;
+
+    len = rx_GetDataSize(apacket);
+    cc->stats.precv++;
+    cc->stats.brecv += len;
+
+    lkvno = kvno = cc->key_number;
+    ret = rxgk_check_packet(0, aconn, apacket, cp->level, cc->start_time,
+                            &kvno, cp->k0);
+    if (ret != 0)
+	return ret;
+
+    if (kvno > lkvno)
+	update_kvno(cc, kvno);
+
+    return ret;
+}
+
+static void
+rxgk_DestroyClientConnection(struct rx_securityClass *aobj,
+			     struct rx_connection *aconn)
+{
+    struct rxgk_cconn *cc;
+
+    cc = rx_GetSecurityData(aconn);
+    if (cc == NULL) {
+        return;
+    }
+    rx_SetSecurityData(aconn, NULL);
+
+    rxi_Free(cc, sizeof(*cc));
+    obj_rele(aobj);
+}
+
+static int
+rxgk_ClientGetStats(struct rx_securityClass *aobj, struct rx_connection *aconn,
+		    struct rx_securityObjectStats *astats)
+{
+    struct rxgkStats *stats;
+    struct rxgk_cprivate *cp;
+    struct rxgk_cconn *cc;
+
+    astats->type = RX_SECTYPE_GK;
+    cc = rx_GetSecurityData(aconn);
+    if (cc == NULL) {
+	astats->flags |= RXGK_STATS_UNALLOC;
+	return 0;
+    }
+
+    stats = &cc->stats;
+    cp = aobj->privateData;
+    astats->level = cp->level;
+
+    astats->packetsReceived = stats->precv;
+    astats->packetsSent = stats->psent;
+    astats->bytesReceived = stats->brecv;
+    astats->bytesSent = stats->bsent;
+
+    return 0;
+}
+
+static struct rx_securityOps rxgk_client_ops = {
+    rxgk_ClientClose,
+    rxgk_NewClientConnection,		/* every new connection */
+    rxgk_ClientPreparePacket,		/* once per packet creation */
+    0,					/* send packet (once per retrans) */
+    0,
+    0,
+    0,
+    rxgk_GetResponse,			/* respond to challenge packet */
+    0,
+    rxgk_ClientCheckPacket,		/* check data packet */
+    rxgk_DestroyClientConnection,
+    rxgk_ClientGetStats,
+    0,
+    0,					/* spare 1 */
+    0,					/* spare 2 */
+};
+
+/*
+ * Create an rxgk client security object
+ *
+ * @param[in] level	The security level of the token; this must be the
+ *			level used for all connections using this security
+ *			object.
+ * @param[in] enctype	The RFC 3961 enctype of k0.
+ * @param[in] k0	The master key of the token.
+ * @param[in] token	The rxgk token used to authenticate the connection.
+ * @return NULL on failure, and a pointer to the security object on success.
+ */
+struct rx_securityClass *
+rxgk_NewClientSecurityObject(RXGK_Level level, afs_int32 enctype, rxgk_key k0,
+			     RXGK_Data *token)
+{
+    struct rx_securityClass *sc = NULL;
+    struct rxgk_cprivate *cp = NULL;
+
+    sc = rxi_Alloc(sizeof(*sc));
+    if (sc == NULL)
+	goto error;
+    cp = rxi_Alloc(sizeof(*cp));
+    if (cp == NULL)
+	goto error;
+    sc->ops = &rxgk_client_ops;
+    sc->refCount = 1;
+    sc->privateData = cp;
+
+    /* Now get the client-private data. */
+    if (rxgk_copy_key(k0, &cp->k0) != 0)
+	goto error;
+    cp->enctype = enctype;
+    cp->level = level;
+    if (rx_opaque_copy(&cp->token, token) != 0)
+	goto error;
+
+    return sc;
+
+ error:
+    rxi_Free(sc, sizeof(*sc));
+    cprivate_destroy(cp);
+    return NULL;
+}
diff --git a/src/rxgk/rxgk_crypto_rfc3961.c b/src/rxgk/rxgk_crypto_rfc3961.c
new file mode 100644
index 000000000..fc5eb8a41
--- /dev/null
+++ b/src/rxgk/rxgk_crypto_rfc3961.c
@@ -0,0 +1,857 @@
+/* rxgk/rxgk_crypto_rfc3961.c - Wrappers for RFC3961 crypto used in RXGK. */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * Wrappers for the RFC3961 crypto routines used by RXGK, and
+ * helpers.  This implementation uses the in-tree rfc3961 library, but
+ * we do not expose those types in our interface so as to be
+ * compatible with other backends in the future.  It should be possible
+ * to backend to an out-of-tree krb5 library or the kernel's crypto
+ * framework using this API.
+ *
+ * Public functions in this file should return RXGK error codes, because
+ * error codes from these functions can end up on the wire.  This will
+ * entail converting from any krb5 error codes that are used internally.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#ifdef KERNEL
+# include "afs/sysincludes.h"
+# include "afsincludes.h"
+#else
+# include <errno.h>
+#endif
+
+#include <rx/rx.h>
+#include <rx/rxgk.h>
+#include <afs/rfc3961.h>
+#include <afs/opr.h>
+
+#include "rxgk_private.h"
+
+/*
+ * This is what an rxgk_key really is, but it's a 'struct rxgk_key_s' to consumers:
+ * typedef struct rxgk_keyblock * rxgk_key;
+ */
+struct rxgk_keyblock {
+    /* A krb5 context for this key, only to be used for initialization and
+     * destruction of the key. Do not use this for actually using the key for
+     * crypto operations; we are supposed to avoid accessing it in multiple
+     * threads at the same time. */
+    krb5_context init_ctx;
+    krb5_keyblock key;
+};
+
+struct rxgk_key_s {
+    struct rxgk_keyblock keyblock;
+};
+
+/* Convenience macro; reduces the diff if an MIT krb5 backend is made. */
+#define deref_keyblock_enctype(k)	krb5_keyblock_get_enctype(k)
+
+/* Convenience functions to convert between the opaque rxgk_key type and our
+ * internal rxgk_keyblock struct. */
+static_inline struct rxgk_keyblock *
+key2keyblock(rxgk_key key)
+{
+    return &key->keyblock;
+}
+
+static_inline rxgk_key
+keyblock2key(struct rxgk_keyblock *keyblock)
+{
+    return (rxgk_key)keyblock;
+}
+
+/**
+ * Convert krb5 error code to RXGK error code.  Don't let the krb5 codes escape.
+ */
+static_inline afs_int32
+ktor(afs_int32 err)
+{
+
+    if (err >= ERROR_TABLE_BASE_RXGK && err < (ERROR_TABLE_BASE_RXGK + 256))
+	return err;
+    switch (err) {
+	case 0:
+	    return 0;
+	default:
+	    return RXGK_INCONSISTENCY;
+    }
+}
+
+/**
+ * Convert a krb5 enctype to a krb5 checksum type.
+ *
+ * Each enctype has a mandatory (to implement) checksum type, which can be
+ * chosen when computing a checksum by passing 0 for the type parameter.
+ * However, we must separately compute the length of a checksum on a message in
+ * order to extract the checksum from a packet at RXGK_LEVEL_AUTH, and Heimdal
+ * krb5 does not expose a way to get the mandatory checksum type for a given
+ * enctype.  So, we get to do it ourselves.
+ *
+ * @return -1 on failure, otherwise the checksum type.
+ */
+static_inline afs_int32
+etoc(afs_int32 etype)
+{
+    switch(etype) {
+	case ETYPE_DES_CBC_CRC:
+	    return CKSUMTYPE_RSA_MD5_DES;
+	case ETYPE_DES_CBC_MD4:
+	    return CKSUMTYPE_RSA_MD4_DES;
+	case ETYPE_DES_CBC_MD5:
+	    return CKSUMTYPE_RSA_MD5_DES;
+	case ETYPE_DES3_CBC_SHA1:
+	    return CKSUMTYPE_HMAC_SHA1_DES3;
+	case ETYPE_ARCFOUR_MD4:
+	    return CKSUMTYPE_HMAC_MD5_ENC;
+	case ETYPE_AES128_CTS_HMAC_SHA1_96:
+	    return CKSUMTYPE_HMAC_SHA1_96_AES_128;
+	case ETYPE_AES256_CTS_HMAC_SHA1_96:
+	    return CKSUMTYPE_HMAC_SHA1_96_AES_256;
+	default:
+	    return -1;
+    }
+}
+
+/**
+ * Get the number of octets of input needed for a key of the given etype,
+ *
+ * @return -1 on error, or the number of octets of input needed on success.
+ */
+ssize_t
+rxgk_etype_to_len(int etype)
+{
+    krb5_context ctx;
+    krb5_error_code code;
+    size_t bits;
+
+    code = krb5_init_context(&ctx);
+    if (code != 0)
+	return -1;
+    code = krb5_enctype_keybits(ctx, etype, &bits);
+    krb5_free_context(ctx);
+    if (code != 0)
+	return -1;
+    return (bits + 7) / 8;
+}
+
+/**
+ * Take a raw key from some external source and produce an rxgk_key from it.
+ *
+ * The raw_key and length are not an RXGK_Data because in some cases they will
+ * come from a gss_buffer and there's no real need to do the conversion.
+ * The caller must use rxgk_release_key to deallocate memory allocated for the
+ * new rxgk_key.
+ *
+ * This routine checks whether the length of the supplied key data matches the
+ * key generation seed length for the requested enctype, in which case the RFC
+ * 3961 random_to_key operation is performed, or if it is the actual (output)
+ * key length, in which case the key data is used as-is.
+ *
+ * @param key_out	the returned rxgk_key.
+ * @param raw_key	a pointer to the octet stream of the key input data.
+ * @param length	the length of raw_key (in octets).
+ * @param enctype	the RFC 3961 enctype of the key being constructed.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_make_key(rxgk_key *key_out, void *raw_key, afs_uint32 length,
+	      afs_int32 enctype)
+{
+    struct rxgk_keyblock *new_key = NULL;
+    krb5_error_code ret;
+    size_t full_length;
+    ssize_t input_length;
+
+    /* Must initialize before we return. */
+    *key_out = NULL;
+
+    new_key = rxi_Alloc(sizeof(*new_key));
+    if (new_key == NULL) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    ret = krb5_init_context(&new_key->init_ctx);
+    if (ret != 0)
+	goto done;
+    ret = krb5_enctype_keysize(new_key->init_ctx, enctype, &full_length);
+    if (ret != 0)
+	goto done;
+    input_length = rxgk_etype_to_len(enctype);
+    if (input_length < 0) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    if (length == full_length) {
+	/* free with krb5_free_keyblock_contents + rxi_Free */
+	ret = krb5_keyblock_init(new_key->init_ctx, enctype, raw_key, length,
+                                 &new_key->key);
+    } else if (length == input_length) {
+	/* free with krb5_free_keyblock_contents + rxi_Free */
+	ret = krb5_random_to_key(new_key->init_ctx, enctype, raw_key, length,
+                                 &new_key->key);
+    } else {
+	ret = RXGK_BADETYPE;
+    }
+    if (ret != 0)
+	goto done;
+    *key_out = keyblock2key(new_key);
+ done:
+    if (ret != 0 && new_key != NULL) {
+        if (new_key->init_ctx != NULL) {
+            krb5_free_context(new_key->init_ctx);
+        }
+	rxi_Free(new_key, sizeof(*new_key));
+    }
+    return ktor(ret);
+}
+
+/**
+ * Copy a given key.
+ *
+ * The caller must use rxgk_release_key to deallocate the memory allocated
+ * for the new rxgk_key.
+ *
+ * @param[in] key_in	The key to be copied.
+ * @param[out] key_out	A copy of key_in.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_copy_key(rxgk_key key_in, rxgk_key *key_out)
+{
+    struct rxgk_keyblock *keyblock;
+
+    keyblock = key2keyblock(key_in);
+    return rxgk_make_key(key_out, keyblock->key.keyvalue.data,
+			 keyblock->key.keyvalue.length, keyblock->key.keytype);
+}
+
+/**
+ * Generate a random key.
+ *
+ * The caller must use rxgk_release_key to deallocate the memory allocated
+ * for the new rxgk_key.
+ *
+ * @param[inout] enctype  The RFC 3961 enctype of the key to be generated. If
+ *                        0, set this to a default enctype, and use that
+ *                        enctype for the generated key.
+ * @param[out] key_out	The random rxgk key.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_random_key(afs_int32 *enctype, rxgk_key *key_out)
+{
+    void *buf;
+    krb5_error_code ret;
+    ssize_t len;
+
+    buf = NULL;
+    *key_out = NULL;
+
+    if (*enctype == 0)
+        *enctype = ETYPE_AES128_CTS_HMAC_SHA1_96;
+
+    len = rxgk_etype_to_len(*enctype);
+    if (len < 0)
+	return RXGK_INCONSISTENCY;
+    buf = rxi_Alloc(len);
+    if (buf == NULL)
+	return RXGK_INCONSISTENCY;
+    krb5_generate_random_block(buf, (size_t)len);
+    ret = rxgk_make_key(key_out, buf, len, *enctype);
+    rxi_Free(buf, len);
+    return ret;
+}
+
+/**
+ * Release the storage underlying an rxgk key
+ *
+ * Call into the underlying library to release any storage allocated for
+ * the rxgk_key, and null out the key pointer.
+ */
+void
+rxgk_release_key(rxgk_key *key)
+{
+    struct rxgk_keyblock *keyblock;
+
+    if (*key == NULL)
+	return;
+    keyblock = key2keyblock(*key);
+
+    krb5_free_keyblock_contents(keyblock->init_ctx, &keyblock->key);
+    if (keyblock->init_ctx != NULL) {
+        krb5_free_context(keyblock->init_ctx);
+    }
+    rxi_Free(keyblock, sizeof(*keyblock));
+    *key = NULL;
+}
+
+/**
+ * Determine the length of a checksum (MIC) using the specified key.
+ *
+ * @param[in] key	The rxgk_key being queried.
+ * @param[out] out	The length of a checksum made using key.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_mic_length(rxgk_key key, size_t *out)
+{
+    krb5_context ctx = NULL;
+    krb5_cksumtype cstype;
+    krb5_enctype enctype;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(key);
+    size_t len;
+
+    *out = 0;
+
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    cstype = etoc(enctype);
+    if (cstype == -1) {
+	ret = RXGK_BADETYPE;
+	goto done;
+    }
+    ret = krb5_checksumsize(ctx, cstype, &len);
+    if (ret != 0)
+	goto done;
+    *out = len;
+
+ done:
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    return ktor(ret);
+}
+
+/**
+ * Obtain the RFC 3961 Message Integrity Check of a buffer
+ *
+ * Call into the RFC 3961 encryption framework to obtain a Message Integrity
+ * Check of a buffer using the specified key and key usage.  It is assumed
+ * that the rxgk_key structure includes the enctype information needed to
+ * determine which crypto routine to call.
+ *
+ * The output buffer is allocated with rx_opaque_populate() and must be freed
+ * by the caller (with rx_opaque_freeContents()).
+ *
+ * @param[in] key	The key used to key the MIC.
+ * @param[in] usage	The key usage value to use (from rxgk_int.h).
+ * @param[in] in	The input buffer to be MICd.
+ * @param[out] out	The MIC.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_mic_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+		RXGK_Data *out)
+{
+    krb5_context ctx = NULL;
+    Checksum cksum;
+    krb5_cksumtype cstype;
+    krb5_crypto crypto = NULL;
+    krb5_enctype enctype;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(key);
+    size_t len;
+
+    memset(&cksum, 0, sizeof(cksum));
+    memset(out, 0, sizeof(*out));
+
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    cstype = etoc(enctype);
+    if (cstype == -1) {
+	ret = RXGK_BADETYPE;
+	goto done;
+    }
+    ret = krb5_checksumsize(ctx, cstype, &len);
+    if (ret != 0)
+	goto done;
+    ret = krb5_crypto_init(ctx, &keyblock->key, enctype, &crypto);
+    if (ret != 0)
+	goto done;
+    ret = krb5_create_checksum(ctx, crypto, usage, cstype, in->val,
+			       in->len, &cksum);
+    if (ret != 0)
+	goto done;
+    /* sanity check */
+    if (len != cksum.checksum.length) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    ret = rx_opaque_populate(out, cksum.checksum.data, len);
+
+ done:
+    free_Checksum(&cksum);
+    if (crypto != NULL)
+	krb5_crypto_destroy(ctx, crypto);
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    return ktor(ret);
+}
+
+/**
+ * Verify the RFC 3961 Message Integrity Check on a message
+ *
+ * Call into the RFC 3961 encryption framework to verify a message integrity
+ * check on a message, using the specified key with the specified key usage.
+ * It is assumed that the rxgk_key structure includes the enctype information
+ * needed to determine which particular crypto routine to call.
+ *
+ * @param[in] key	The key keying the checksum.
+ * @param[in] usage	The key usage for the checksum.
+ * @param[in] in	The buffer which was checksummed.
+ * @param[in] mic	The MIC to be verified.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_check_mic_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+		      RXGK_Data *mic)
+{
+    krb5_context ctx = NULL;
+    Checksum cksum;
+    krb5_crypto crypto = NULL;
+    krb5_enctype enctype;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(key);
+
+    memset(&cksum, 0, sizeof(cksum));
+
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    cksum.cksumtype = etoc(enctype);
+    ret = krb5_crypto_init(ctx, &keyblock->key, enctype, &crypto);
+    if (ret != 0)
+	goto done;
+    cksum.checksum.data = mic->val;
+    cksum.checksum.length = mic->len;
+    ret = krb5_verify_checksum(ctx, crypto, usage, in->val, in->len,
+			       &cksum);
+    /* Un-alias the storage to avoid a double-free. */
+    cksum.checksum.data = NULL;
+    cksum.checksum.length = 0;
+    if (ret != 0) {
+	ret = RXGK_SEALED_INCON;
+    }
+
+ done:
+    free_Checksum(&cksum);
+    if (crypto != NULL)
+	krb5_crypto_destroy(ctx, crypto);
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    return ktor(ret);
+}
+
+/**
+ * Encrypt a buffer in a key using the RFC 3961 framework
+ *
+ * Call into the RFC 3961 encryption framework to encrypt a buffer with
+ * specified key and key usage.  It is assumed that the rxgk_key structure
+ * includes the enctype information needed to determine which particular
+ * crypto routine to call.
+ *
+ * The output buffer is allocated with rx_opaque_populate() and must be freed
+ * by the caller (with rx_opaque_freeContents()).
+ *
+ * @param[in] key	The key used to encrypt the message.
+ * @param[in] usage	The key usage for the encryption.
+ * @param[in] in	The buffer being encrypted.
+ * @param[out] out	The encrypted form of the message.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_encrypt_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+		    RXGK_Data *out)
+{
+    krb5_context ctx = NULL;
+    krb5_crypto crypto = NULL;
+    krb5_data kd_out;
+    krb5_enctype enctype;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(key);
+
+    memset(&kd_out, 0, sizeof(kd_out));
+    memset(out, 0, sizeof(*out));
+
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    ret = krb5_crypto_init(ctx, &keyblock->key, enctype, &crypto);
+    if (ret != 0)
+	goto done;
+    ret = krb5_encrypt(ctx, crypto, usage, in->val, in->len, &kd_out);
+    if (ret != 0)
+	goto done;
+    ret = rx_opaque_populate(out, kd_out.data, kd_out.length);
+
+ done:
+    if (crypto != NULL)
+	krb5_crypto_destroy(ctx, crypto);
+    krb5_data_free(&kd_out);
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    return ktor(ret);
+}
+
+/**
+ * Decrypt a buffer using a given key in the RFC 3961 framework
+ *
+ * Call into the RFC 3961 encryption framework to decrypt a buffer with the
+ * specified key with the specified key usage.  It is assumed that the
+ * rxgk_key structure includes the enctype information needed to determine
+ * which particular crypto routine to call.
+ *
+ * The output buffer is allocated with rx_opaque_populate() and must be freed
+ * by the caller (with rx_opaque_freeContents()).
+ *
+ * @param[in] key	The key to use for the decryption.
+ * @param[in] usage	The key usage used for the encryption.
+ * @param[in] in	The encrypted message.
+ * @param[out] out	The decrypted message.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_decrypt_in_key(rxgk_key key, afs_int32 usage, RXGK_Data *in,
+		    RXGK_Data *out)
+{
+    krb5_context ctx = NULL;
+    krb5_crypto crypto = NULL;
+    krb5_data kd_out;
+    krb5_enctype enctype;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(key);
+
+    memset(out, 0, sizeof(*out));
+    memset(&kd_out, 0, sizeof(kd_out));
+
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    ret = krb5_crypto_init(ctx, &keyblock->key, enctype, &crypto);
+    if (ret != 0)
+	goto done;
+    ret = krb5_decrypt(ctx, crypto, usage, in->val, in->len, &kd_out);
+    if (ret != 0) {
+        ret = RXGK_SEALED_INCON;
+	goto done;
+    }
+    ret = rx_opaque_populate(out, kd_out.data, kd_out.length);
+
+ done:
+    if (crypto != NULL)
+	krb5_crypto_destroy(ctx, crypto);
+    krb5_data_free(&kd_out);
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    return ktor(ret);
+}
+
+/*
+ * Helper for derive_tk.
+ * Assumes the caller has already allocated space in 'out'.
+ */
+static afs_int32
+PRFplus(krb5_data *out, krb5_enctype enctype, rxgk_key k0,
+	void *seed, size_t seed_len)
+{
+    krb5_context ctx = NULL;
+    krb5_crypto crypto = NULL;
+    krb5_data prf_in, prf_out;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(k0);
+    unsigned char *pre_key = NULL;
+    size_t block_len;
+    size_t desired_len = out->length;
+    afs_uint32 n_iter, iterations, dummy;
+
+    memset(&prf_in, 0, sizeof(prf_in));
+    memset(&prf_out, 0, sizeof(prf_out));
+
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+
+    ret = krb5_crypto_init(ctx, &keyblock->key, enctype, &crypto);
+    if (ret != 0)
+	goto done;
+    prf_in.length = sizeof(n_iter) + seed_len;
+    prf_in.data = rxi_Alloc(prf_in.length);
+    if (prf_in.data == NULL) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    memcpy((unsigned char *)prf_in.data + sizeof(n_iter), seed, seed_len);
+    ret = krb5_crypto_prf_length(ctx, enctype, &block_len);
+    if (ret != 0)
+	goto done;
+    /* We need desired_len/block_len iterations, rounded up. */
+    iterations = (desired_len + block_len - 1) / block_len;
+    pre_key = rxi_Alloc(iterations * block_len);
+    if (pre_key == NULL) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+
+    for (n_iter = 1; n_iter <= iterations; ++n_iter) {
+	dummy = htonl(n_iter);
+	memcpy(prf_in.data, &dummy, sizeof(dummy));
+	krb5_data_free(&prf_out);
+	ret = krb5_crypto_prf(ctx, crypto, &prf_in, &prf_out);
+	if (ret != 0)
+	    goto done;
+	memcpy(pre_key + (n_iter - 1) * block_len, prf_out.data, block_len);
+    }
+    memcpy(out->data, pre_key, desired_len);
+    out->length = desired_len;
+
+ done:
+    if (crypto != NULL)
+	krb5_crypto_destroy(ctx, crypto);
+    krb5_data_free(&prf_out);
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    rxi_Free(prf_in.data, prf_in.length);
+    if (pre_key != NULL)
+	rxi_Free(pre_key, iterations * block_len);
+    return ktor(ret);
+}
+
+struct seed_data {
+    afs_uint32 epoch;
+    afs_uint32 cid;
+    afs_uint32 time_hi;
+    afs_uint32 time_lo;
+    afs_uint32 key_number;
+} __attribute__((packed));
+
+/* Our seed_data buffer that we feed into the PRF+ algorithm to generate our
+ * transport key had better be exactly 20 bytes large, to match the format of
+ * the seed data in the rxgk spec. */
+#define RXGK_SEED_DATA_SIZE 20
+
+/**
+ * Compute a transport key tk given a master key k0
+ *
+ * Given a connection master key k0, derive a transport key tk from the master
+ * key and connection parameters.
+ *
+ * TK = random-to-key(PRF+(K0, L, epoch || cid || start_time || key_number))
+ * using the RFC4402 PRF+, i.e., the ordinal of the application of the
+ * pseudo-random() function is stored in a 32-bit field, not an 8-bit field
+ * as in RFC6112.
+ *
+ * @param[out] tk		The derived transport key.
+ * @param[in] k0		The token master key.
+ * @param[in] epoch		The rx epoch of the connection.
+ * @param[in] cid		The rx connection id of the connection.
+ * @param[in] start_time	The start_time of the connection.
+ * @param[in] key_number	The current key number of the connection.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_derive_tk(rxgk_key *tk, rxgk_key k0, afs_uint32 epoch, afs_uint32 cid,
+	       rxgkTime start_time, afs_uint32 key_number)
+{
+    krb5_enctype enctype;
+    krb5_data pre_key;
+    struct rxgk_keyblock *keyblock = key2keyblock(k0);
+    struct seed_data seed;
+    ssize_t ell;
+    afs_int32 ret;
+
+    memset(&pre_key, 0, sizeof(pre_key));
+    memset(&seed, 0, sizeof(seed));
+
+    opr_StaticAssert(sizeof(seed) == RXGK_SEED_DATA_SIZE);
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    ell = rxgk_etype_to_len(enctype);
+    if (ell < 0)
+	return RXGK_INCONSISTENCY;
+
+    seed.epoch = htonl(epoch);
+    seed.cid = htonl(cid);
+    seed.time_hi = htonl((afs_int32)(start_time / ((afs_int64)1 << 32)));
+    seed.time_lo = htonl((afs_uint32)(start_time & (afs_uint64)0xffffffffu));
+    seed.key_number = htonl(key_number);
+
+    pre_key.data = rxi_Alloc(ell);
+    if (pre_key.data == NULL) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    pre_key.length = ell;
+    ret = PRFplus(&pre_key, enctype, k0, &seed, sizeof(seed));
+    if (ret != 0)
+	goto done;
+
+    ret = rxgk_make_key(tk, pre_key.data, ell, enctype);
+    if (ret != 0)
+	goto done;
+
+ done:
+    rxi_Free(pre_key.data, ell);
+    return ret;
+}
+
+/**
+ * Determine the maximum ciphertext expansion for a given enctype.
+ *
+ * @param[in] k0	The rxgk key to be used.
+ * @param[out] len_out	The maximum ciphertext expansion, in octets.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_cipher_expansion(rxgk_key k0, afs_uint32 *len_out)
+{
+    krb5_context ctx = NULL;
+    krb5_crypto crypto = NULL;
+    krb5_enctype enctype;
+    krb5_error_code ret;
+    struct rxgk_keyblock *keyblock = key2keyblock(k0);
+    size_t len;
+
+    *len_out = 0;
+
+    enctype = deref_keyblock_enctype(&keyblock->key);
+    ret = krb5_init_context(&ctx);
+    if (ret != 0)
+        goto done;
+    ret = krb5_crypto_init(ctx, &keyblock->key, enctype, &crypto);
+    if (ret != 0)
+	goto done;
+    len = krb5_crypto_overhead(ctx, crypto);
+    *len_out = len;
+
+ done:
+    if (crypto != NULL)
+	krb5_crypto_destroy(ctx, crypto);
+    if (ctx != NULL) {
+        krb5_free_context(ctx);
+    }
+    return ktor(ret);
+}
+
+/**
+ * Allocate and fill the buffer in nonce with len bytes of random data.
+ *
+ * @param[out] nonce	The buffer of random data.
+ * @param[in] len	The number of octets of random data to produce.
+ * @return rx error codes.
+ */
+afs_int32
+rxgk_nonce(RXGK_Data *nonce, afs_uint32 len)
+{
+    if (rx_opaque_alloc(nonce, len) != 0)
+	return RXGK_INCONSISTENCY;
+
+    krb5_generate_random_block(nonce->val, len);
+    return 0;
+}
+
+/* Returns the "score" of an enctype, giving a rough ordering of enctypes by
+ * strength. Higher scores are better. */
+static_inline int
+etype_score(afs_int32 etype)
+{
+    switch (etype) {
+	case ETYPE_ARCFOUR_HMAC_MD5_56: return 0;
+	case ETYPE_DES_CBC_MD4:         return 1;
+	case ETYPE_DES_CBC_CRC:         return 2;
+	case ETYPE_DES_CBC_MD5:         return 3;
+	case ETYPE_ARCFOUR_HMAC_MD5:    return 4;
+	case ETYPE_DES3_CBC_SHA1:       return 5;
+
+	case 25 /* camellia128 */:          return 6;
+	case ETYPE_AES128_CTS_HMAC_SHA1_96: return 7;
+
+	/* aes128-cts-hmac-sha256-128 */
+	case 19:                            return 8;
+
+	case 26 /* camellia256 */:          return 9;
+	case ETYPE_AES256_CTS_HMAC_SHA1_96: return 10;
+
+	/* aes256-cts-hmac-sha384-192 */
+	case 20:                            return 11;
+    }
+    return -1;
+}
+
+/**
+ * Determines which of the two given enctypes is "stronger".
+ *
+ * @param[in] old_enctype	An enctype to compare.
+ * @param[in] new_enctype	Another enctype to compare.
+ *
+ * @return 1 if new_enctype is better/stronger than old_enctype. 0 otherwise.
+ */
+int
+rxgk_enctype_better(afs_int32 old_enctype, afs_int32 new_enctype)
+{
+    int old_score, new_score;
+
+    /* Negative enctypes are reserved for local use. */
+    if (new_enctype < 0) return 1;
+    if (old_enctype < 0) return 0;
+
+    old_score = etype_score(old_enctype);
+    new_score = etype_score(new_enctype);
+
+    if (old_score < new_score) {
+	/* 'new' enctype is better */
+	return 1;
+    }
+    return 0;
+}
diff --git a/src/rxgk/rxgk_errs.et b/src/rxgk/rxgk_errs.et
new file mode 100644
index 000000000..0c76f190f
--- /dev/null
+++ b/src/rxgk/rxgk_errs.et
@@ -0,0 +1,14 @@
+error_table RXGK
+   ec RXGK_INCONSISTENCY, "Security module structure inconsistent"
+   ec RXGK_PACKETSHORT, "Packet too short for security challenge"
+   ec RXGK_BADCHALLENGE, "Invalid security challenge"
+   ec RXGK_BADETYPE, "Invalid or impermissible encryption type"
+   ec RXGK_BADLEVEL, "Invalid or impermissible security level"
+   ec RXGK_BADKEYNO, "Key version number not found"
+   ec RXGK_EXPIRED, "Token has expired"
+   ec RXGK_NOTAUTH, "Caller not authorized"
+   ec RXGK_BAD_TOKEN, "Security object was passed a bad token"
+   ec RXGK_SEALED_INCON, "Sealed data inconsistent"
+   ec RXGK_DATA_LEN, "User data too long"
+   ec RXGK_BAD_QOP, "Inadequate quality of protection available"
+end
diff --git a/src/rxgk/rxgk_int.xg b/src/rxgk/rxgk_int.xg
new file mode 100644
index 000000000..76effd66a
--- /dev/null
+++ b/src/rxgk/rxgk_int.xg
@@ -0,0 +1,177 @@
+/*
+ * Protocol descriptions for core RXGK structures and RPCs.
+ */
+
+package RXGK_
+prefix S
+
+/* constants for RXGK RPC numbers */
+#define	RXGK_GSSNEGOTIATE	1
+#define	RXGK_COMBINETOKENS	2
+#define	RXGK_AFSCOMBINETOKENS	3
+
+/* RPC-L from draft-wilkinson-afs3-rxgk */
+
+/* General values */
+
+typedef afs_int64 rxgkTime;
+
+/* key usage values */
+const RXGK_CLIENT_ENC_PACKET            = 1026;
+const RXGK_CLIENT_MIC_PACKET            = 1027;
+const RXGK_SERVER_ENC_PACKET            = 1028;
+const RXGK_SERVER_MIC_PACKET            = 1029;
+const RXGK_CLIENT_ENC_RESPONSE          = 1030;
+const RXGK_SERVER_ENC_TOKEN             = 1036;
+
+/* Security levels */
+enum RXGK_Level {
+    RXGK_LEVEL_CLEAR = 0,
+    RXGK_LEVEL_AUTH = 1,
+    RXGK_LEVEL_CRYPT = 2,
+
+    /* RXGK_LEVEL_BOGUS is an invalid level we only use internally for objects
+     * that are not yet initialized. This can be used to make sure we don't
+     * accidentally treat an uninitialized context as an RXGK_LEVEL_CLEAR
+     * connection. This level should never be used on the wire. */
+    RXGK_LEVEL_BOGUS = 71
+};
+
+/* limits for variable-length arrays */
+const RXGK_MAXENCTYPES = 255;
+const RXGK_MAXLEVELS = 255;
+const RXGK_MAXMIC = 1024;
+const RXGK_MAXNONCE = 1024;
+const RXGK_MAXDATA = 1048576;
+
+typedef afs_int32 RXGK_Enctypes<RXGK_MAXENCTYPES>;
+typedef opaque RXGK_Data<RXGK_MAXDATA>;
+
+/* Begin definitions for RXGK_GSSNegotiate. */
+
+struct RXGK_StartParams {
+   RXGK_Enctypes enctypes;
+   RXGK_Level levels<RXGK_MAXLEVELS>;
+   afs_uint32 lifetime;
+   afs_uint32 bytelife;
+   opaque client_nonce<RXGK_MAXNONCE>;
+};
+
+struct RXGK_ClientInfo {
+   afs_int32 errorcode;
+   afs_int32 enctype;
+   RXGK_Level level;
+   afs_uint32 lifetime;
+   afs_uint32 bytelife;
+   rxgkTime expiration;
+   opaque mic<RXGK_MAXMIC>;
+   RXGK_Data token;
+   opaque server_nonce<RXGK_MAXNONCE>;
+};
+
+GSSNegotiate(IN RXGK_StartParams *client_start,
+    IN RXGK_Data *input_token_buffer,
+    IN RXGK_Data *opaque_in,
+    OUT RXGK_Data *output_token_buffer,
+    OUT RXGK_Data *opaque_out,
+    OUT afs_uint32 *gss_major_status,
+    OUT afs_uint32 *gss_minor_status,
+    OUT RXGK_Data *rxgk_info) = RXGK_GSSNEGOTIATE;
+
+/* Begin definitions for RXGK_CombineTokens. */
+
+struct RXGK_CombineOptions {
+    RXGK_Enctypes enctypes;
+    RXGK_Level levels<RXGK_MAXLEVELS>;
+};
+
+struct RXGK_TokenInfo {
+    afs_int32 enctype;
+    RXGK_Level level;
+    afs_uint32 lifetime;
+    afs_uint32 bytelife;
+    rxgkTime expiration;
+};
+
+CombineTokens(IN RXGK_Data *token0, IN RXGK_Data *token1,
+	     IN RXGK_CombineOptions *options,
+	     OUT RXGK_Data *new_token,
+	     OUT RXGK_TokenInfo *info) = RXGK_COMBINETOKENS;
+
+/* Begin definitions for security class operation. */
+
+const RXGK_CHALLENGE_NONCE_LEN = 20;
+
+/* RX challenge and response structures */
+struct RXGK_Challenge {
+    opaque nonce[RXGK_CHALLENGE_NONCE_LEN];
+};
+const RXGK_MAXAUTHENTICATOR = 1416;	/* better fit in a packet! */
+struct RXGK_Response {
+    rxgkTime start_time;
+    RXGK_Data token;
+    opaque authenticator<RXGK_MAXAUTHENTICATOR>;
+};
+
+struct RXGK_Authenticator {
+    opaque nonce[RXGK_CHALLENGE_NONCE_LEN];
+    opaque appdata<>;
+    RXGK_Level level;
+    afs_uint32 epoch;
+    afs_uint32 cid;
+    afs_uint32 call_numbers<>;
+};
+
+/* RPC-L from draft-brashear-afs3-pts-extended-names-09 (final). */
+
+#define AUTHDATAMAX 2048
+#define AUTHPRINTABLEMAX 2048
+struct PrAuthName {
+    afs_int32 kind;
+    opaque data<AUTHDATAMAX>;
+    opaque display<AUTHPRINTABLEMAX>;
+};
+
+/* PrAuthName 'kind' values */
+const PRAUTHTYPE_KRB4 = 1;
+const PRAUTHTYPE_GSS = 2;
+
+/* RPC-L from draft-wilkinson-afs3-rxgk-afs. */
+
+const RXGK_NEVERDATE = 0;
+
+/* Begin authenticator appdata definition. */
+
+struct RXGK_Authenticator_AFSAppData {
+    afsUUID client_uuid;
+    RXGK_Data cb_tok;
+    RXGK_Data cb_key;
+    afs_int32 enctype;
+    afsUUID target_uuid;
+};
+
+/* Begin token definitions. */
+
+struct RXGK_TokenContainer {
+    afs_int32 kvno;
+    afs_int32 enctype;
+    opaque    encrypted_token<>;
+};
+struct RXGK_Token {
+    afs_int32 enctype;
+    opaque K0<>;
+    RXGK_Level level;
+    afs_uint32 lifetime;
+    afs_uint32 bytelife;
+    rxgkTime expirationtime;
+    struct PrAuthName identities<>;
+};
+
+/* Begin definitions for AFSCombineTokens. */
+
+AFSCombineTokens(IN RXGK_Data *user_tok,
+    IN RXGK_Data *cm_tok,
+    IN RXGK_CombineOptions *options,
+    IN afsUUID destination,
+    OUT RXGK_Data *new_token,
+    OUT RXGK_TokenInfo *token_info) = RXGK_AFSCOMBINETOKENS;
diff --git a/src/rxgk/rxgk_packet.c b/src/rxgk/rxgk_packet.c
new file mode 100644
index 000000000..498d38121
--- /dev/null
+++ b/src/rxgk/rxgk_packet.c
@@ -0,0 +1,419 @@
+/* rxgk/rxgk_packet.c - packet-manipulating routines for rxgk */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * Routines to encrypt or checksum packets, and perform the reverse
+ * decryption and checksum verification operations.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#include <roken.h>
+
+#include <rx/rx.h>
+#include <rx/rx_packet.h>
+#include <rx/rxgk.h>
+#ifdef KERNEL
+# include "afs/sysincludes.h"
+# include "afsincludes.h"
+#else
+# include <errno.h>
+#endif
+
+#include "rxgk_private.h"
+
+/**
+ * Fill in an rxgk_header structure from a packet
+ *
+ * Fill in the elements of the rxgk_header structure, in network byte order,
+ * using information from the packet structure and the supplied values for
+ * the security index and data length.
+ *
+ * @param[out] header	The header structure to be populated.
+ * @param[in] apacket	The packet from which to pull connection information.
+ * @param[in] index	The security index of the connection.
+ * @param[in] length	The (plaintext) data length of the packet.
+ */
+static void
+populate_header(struct rxgk_header *header, struct rx_packet *apacket,
+		afs_int32 index, afs_uint32 length)
+{
+    header->epoch = htonl(apacket->header.epoch);
+    header->cid = htonl(apacket->header.cid);
+    header->callNumber = htonl(apacket->header.callNumber);
+    header->seq = htonl(apacket->header.seq);
+    header->index = htonl(index);
+    header->length = htonl(length);
+}
+
+/**
+ * Verify the MIC on a packet
+ *
+ * Take a packet, extract the MIC and data payload, prefix the data with the
+ * rxgk pseudoheader, and verify the mic of that assembly.  The plaintext
+ * data remains at its present location in the packet.
+ *
+ * @param[in] tk	The transport key to be used.
+ * @param[in] keyusage	The key usage value used to generate the MIC.
+ * @param[in] aconn	The rx connection on which the packet was received.
+ * @param[in,out] apacket	The packet to be processed.
+ * @return rxgk error codes.  An error is returned if the MIC is invalid.
+ */
+static int
+rxgk_check_mic_packet(rxgk_key tk, afs_int32 keyusage,
+		      struct rx_connection *aconn, struct rx_packet *apacket)
+{
+    struct rx_opaque plain = RX_EMPTY_OPAQUE, mic = RX_EMPTY_OPAQUE;
+    struct rxgk_header *header;
+    afs_int32 ret;
+    afs_uint32 len;
+    size_t miclen;
+
+    miclen = rx_GetSecurityHeaderSize(aconn);
+    if (miclen == 0) {
+        ret = RXGK_INCONSISTENCY;
+        goto done;
+    }
+    if (rx_GetDataSize(apacket) < miclen) {
+	ret = RXGK_PACKETSHORT;
+        goto done;
+    }
+    len = rx_GetDataSize(apacket) - miclen;
+    ret = rx_opaque_alloc(&plain, sizeof(*header) + len);
+    if (ret != 0)
+	goto done;
+    header = plain.val;
+    ret = rx_opaque_alloc(&mic, miclen);
+    if (ret != 0)
+	goto done;
+    populate_header(header, apacket, rx_SecurityClassOf(aconn), len);
+    rx_packetread(apacket, 0, miclen, mic.val);
+    rx_packetread(apacket, miclen, len,
+		  (unsigned char *)plain.val + sizeof(*header));
+
+    /* The actual crypto call */
+    ret = rxgk_check_mic_in_key(tk, keyusage, &plain, &mic);
+
+    /*
+     * We need to tell Rx how many bytes of payload there are in the packet
+     * before returning. We haven't touched the payload, so the amount of
+     * payload is just the original data size of packet, minus our overhead for
+     * the mic. This is just 'len', calculated above.
+     */
+    rx_SetDataSize(apacket, len);
+
+ done:
+    rx_opaque_freeContents(&plain);
+    rx_opaque_freeContents(&mic);
+    return ret;
+}
+
+/**
+ * Decrypt a packet to plaintext
+ *
+ * Take an encrypted packet and decrypt it with the specified key and
+ * key usage.  Put the plaintext back in the packet.
+ *
+ * @param[in] tk	The transport key to use.
+ * @param[in] keyusage	The key usage used to encrypt the packet.
+ * @param[in] aconn	The rx connection on which the packet was received.
+ * @param[in,out] apacket	The packet being decrypted.
+ * @return rxgk and system error codes.
+ */
+static int
+rxgk_decrypt_packet(rxgk_key tk, afs_int32 keyusage,
+		    struct rx_connection *aconn, struct rx_packet *apacket)
+{
+    struct rx_opaque plain = RX_EMPTY_OPAQUE, crypt = RX_EMPTY_OPAQUE;
+    struct rxgk_header *header = NULL, *cryptheader;
+    afs_int32 ret;
+    afs_uint32 len;
+
+    len = rx_GetDataSize(apacket);
+
+    if (rx_GetSecurityHeaderSize(aconn) != sizeof(*header)) {
+        ret = RXGK_INCONSISTENCY;
+        goto done;
+    }
+
+    header = rxi_Alloc(sizeof(*header));
+    if (header == NULL) {
+	ret = ENOMEM;
+        goto done;
+    }
+    ret = rx_opaque_alloc(&crypt, len);
+    if (ret != 0)
+	goto done;
+    rx_packetread(apacket, 0, len, crypt.val);
+
+    /* The actual decryption */
+    ret = rxgk_decrypt_in_key(tk, keyusage, &crypt, &plain);
+    if (ret != 0)
+	goto done;
+
+    if (plain.len < sizeof(*cryptheader)) {
+        /*
+	 * Our decrypted contents must have an rxgk_header at the start. If we
+         * don't even have enough bytes for an rxgk_header, something is
+         * clearly wrong.
+	 */
+        ret = RXGK_DATA_LEN;
+        goto done;
+    }
+    cryptheader = plain.val;
+
+    /*
+     * cryptheader->length indicates the length of the decrypted plaintext of
+     * this packet. We must rely on this value, and we cannot calculate it
+     * ourselves from e.g. plain.len, since the encryption routines may have
+     * padded the plaintext. However, we also must not blindly trust the
+     * cryptheader->length value, since if it is set to larger than the actual
+     * plaintext length, we could read beyond the end of the buffer in
+     * plain.val. So check that cryptheader->length is not larger than the max
+     * size of the plaintext in our decrypted buffer.
+     */
+    if (ntohl(cryptheader->length) > plain.len - sizeof(*cryptheader)) {
+        ret = RXGK_DATA_LEN;
+        goto done;
+    }
+
+    populate_header(header, apacket, rx_SecurityClassOf(aconn),
+                    ntohl(cryptheader->length));
+
+    /* Verify the encrypted header. Note the constant-time memcmp here, since
+     * this is a security-sensitive comparison. */
+    ret = ct_memcmp(header, cryptheader, sizeof(*header));
+    if (ret != 0) {
+	ret = RXGK_SEALED_INCON;
+	goto done;
+    }
+
+    len = ntohl(cryptheader->length) + sizeof(*header);
+    if (len > 0xffffu) {
+	ret = RXGK_DATA_LEN;
+	goto done;
+    }
+
+    /*
+     * Now, write the plain data back to the packet. Note that we write back
+     * the decrypted packet payload, and the rxgk_header contents. We don't
+     * really need the rxgk_header in there anymore, but the Rx API does not
+     * let us skip it (Rx will skip the first N bytes when reading the packet
+     * payload, where N is our security header size).
+     */
+    rx_packetwrite(apacket, 0, len, plain.val);
+    rx_SetDataSize(apacket, ntohl(cryptheader->length));
+
+ done:
+    rx_opaque_freeContents(&plain);
+    rx_opaque_freeContents(&crypt);
+    rxi_Free(header, sizeof(*header));
+    return ret;
+}
+
+/**
+ * Compute the MIC of a packet using a given key and key usage
+ *
+ * Take a packet, prefix it with the rxgk pseudoheader, MIC the whole
+ * thing with specified key and key usage, then insert the mic into the
+ * packet payload before the actual data.
+ *
+ * @param[in] tk	The transport key to use.
+ * @param[in] keyusage	The key usage to use for the MIC.
+ * @param[in] aconn	The rx connection on which the packet will be sent.
+ * @param[in,out] apacket	The packet whose MIC is being calculated.
+ * @return rxgk error codes.
+ */
+int
+rxgk_mic_packet(rxgk_key tk, afs_int32 keyusage, struct rx_connection *aconn,
+		struct rx_packet *apacket)
+{
+    struct rx_opaque plain = RX_EMPTY_OPAQUE, mic = RX_EMPTY_OPAQUE;
+    struct rxgk_header *header;
+    afs_uint32 len, miclen;
+    int ret;
+
+    /* This 'len' does NOT include our overhead for the mic */
+    len = rx_GetDataSize(apacket);
+    miclen = rx_GetSecurityHeaderSize(aconn);
+    ret = rx_opaque_alloc(&plain, sizeof(*header) + len);
+    if (ret != 0)
+	goto done;
+    header = plain.val;
+    populate_header(header, apacket, rx_SecurityClassOf(aconn), len);
+    rx_packetread(apacket, miclen, len,
+		  (unsigned char *)plain.val + sizeof(*header));
+
+    /* The actual mic */
+    ret = rxgk_mic_in_key(tk, keyusage, &plain, &mic);
+    if (ret != 0)
+	goto done;
+
+    if (mic.len != miclen) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+
+    rx_packetwrite(apacket, 0, mic.len, mic.val);
+    rx_SetDataSize(apacket, mic.len + len);
+
+ done:
+    rx_opaque_freeContents(&plain);
+    rx_opaque_freeContents(&mic);
+    return ret;
+}
+
+/**
+ * Encrypt a packet using a given key and key usage
+ *
+ * Take a packet, prefix it with the rxgk pseudoheader, encrypt the whole
+ * thing with specified key and key usage, then rewrite the packet payload
+ * to be the encrypted version.
+ *
+ * @param[in] tk	The transport key to use.
+ * @param[in] keyusage	The key usage for the encryption.
+ * @param[in] aconn	The rx connection on which the packet will be sent.
+ * @param[in,out] apacket	The packet being encrypted.
+ * @return rxgk error codes.
+ */
+int
+rxgk_enc_packet(rxgk_key tk, afs_int32 keyusage, struct rx_connection *aconn,
+		struct rx_packet *apacket)
+{
+    struct rx_opaque plain = RX_EMPTY_OPAQUE, crypt = RX_EMPTY_OPAQUE;
+    struct rxgk_header *header;
+    afs_int32 ret;
+    afs_uint32 len;
+
+    len = rx_GetDataSize(apacket);
+    if (rx_GetSecurityHeaderSize(aconn) != sizeof(*header)) {
+        ret = RXGK_INCONSISTENCY;
+        goto done;
+    }
+    ret = rx_opaque_alloc(&plain, sizeof(*header) + len);
+    if (ret != 0)
+	goto done;
+    header = plain.val;
+    populate_header(header, apacket, rx_SecurityClassOf(aconn), len);
+    rx_packetread(apacket, sizeof(*header), len,
+		  (unsigned char *)plain.val + sizeof(*header));
+
+    /* The actual encryption */
+    ret = rxgk_encrypt_in_key(tk, keyusage, &plain, &crypt);
+    if (ret != 0)
+	goto done;
+    if (crypt.len > 0xffffu) {
+	ret = RXGK_DATA_LEN;
+	goto done;
+    }
+
+    /* Now, put the data back. */
+    if (crypt.len > plain.len)
+        rxi_RoundUpPacket(apacket, crypt.len - plain.len);
+    rx_packetwrite(apacket, 0, crypt.len, crypt.val);
+    rx_SetDataSize(apacket, crypt.len);
+
+ done:
+    rx_opaque_freeContents(&plain);
+    rx_opaque_freeContents(&crypt);
+    return ret;
+}
+
+/*
+ * Server/client common bits for the packet receipt routine.
+ * Wrap the appropriate check_mic/decrypt routines for the given level
+ * and client/server role, using the given start_time/kvno/k0 to generate
+ * the transport key needed.  Since the kvno may have been updated by the
+ * peer, 'a_kvno' is set to the new kvno on return, if it has changed.
+ */
+int
+rxgk_check_packet(int server, struct rx_connection *aconn,
+		  struct rx_packet *apacket, RXGK_Level level,
+		  rxgkTime start_time, afs_uint32 *a_kvno, rxgk_key k0)
+{
+    afs_uint16 wkvno;
+    afs_uint32 lkvno;
+    int ret;
+
+    wkvno = rx_GetPacketCksum(apacket);
+    lkvno = *a_kvno;
+    ret = rxgk_key_number(wkvno, lkvno, a_kvno);
+    if (ret != 0 && level == RXGK_LEVEL_CLEAR) {
+	/*
+	 * We ignore kvno errors for RXGK_LEVEL_CLEAR connections, since the
+	 * peer is not required to process kvno changes accurately for CLEAR
+	 * connections. We still call rxgk_key_number to try to track when then
+	 * kvno is updated properly, but if we got an error, just pretend
+	 * nothing happened and nobody tried to change the kvno.
+	 */
+	ret = 0;
+	*a_kvno = lkvno;
+    }
+    if (ret != 0)
+	return ret;
+
+    if (level != RXGK_LEVEL_CLEAR) {
+	/* We only need to deal with per-packet encryption stuff for non-CLEAR
+	 * connections. */
+	rxgk_key tk;
+	afs_uint32 keyusage;
+
+	ret = rxgk_derive_tk(&tk, k0, rx_GetConnectionEpoch(aconn),
+			     rx_GetConnectionId(aconn), start_time, *a_kvno);
+	if (ret != 0)
+	    return ret;
+
+	switch (level) {
+	    case RXGK_LEVEL_AUTH:
+		keyusage = server ? RXGK_CLIENT_MIC_PACKET :
+				    RXGK_SERVER_MIC_PACKET;
+
+		ret = rxgk_check_mic_packet(tk, keyusage, aconn, apacket);
+		break;
+
+	    case RXGK_LEVEL_CRYPT:
+		keyusage = server ? RXGK_CLIENT_ENC_PACKET :
+				    RXGK_SERVER_ENC_PACKET;
+
+		ret = rxgk_decrypt_packet(tk, keyusage, aconn, apacket);
+		break;
+
+	    default:
+		ret = RXGK_INCONSISTENCY;
+	}
+	rxgk_release_key(&tk);
+    }
+
+    return ret;
+}
diff --git a/src/rxgk/rxgk_private.h b/src/rxgk/rxgk_private.h
new file mode 100644
index 000000000..a5eef121d
--- /dev/null
+++ b/src/rxgk/rxgk_private.h
@@ -0,0 +1,147 @@
+/* src/rxgk/rxgk_private.h - Declarations of RXGK-internal routines */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Prototypes for routines internal to RXGK.
+ */
+
+#ifndef RXGK_PRIVATE_H
+#define RXGK_PRIVATE_H
+
+/** Statistics about a connection.  Bytes and packets sent/received. */
+struct rxgkStats {
+    afs_uint32 brecv;
+    afs_uint32 bsent;
+    afs_uint32 precv;
+    afs_uint32 psent;
+};
+
+/* The packet pseudoheader used for auth and crypt connections. */
+struct rxgk_header {
+    afs_uint32 epoch;
+    afs_uint32 cid;
+    afs_uint32 callNumber;
+    afs_uint32 seq;
+    afs_uint32 index;
+    afs_uint32 length;
+} __attribute__((packed));
+
+/*
+ * rgxk_server.c
+ */
+
+/**
+ * Security Object private data for the server.
+ *
+ * Per-connection flags, and a way to get a decryption key for what the client
+ * sends us.
+ */
+struct rxgk_sprivate {
+    void *rock;
+    rxgk_getkey_func getkey;
+};
+/**
+ * Per-connection security data for the server.
+ *
+ * Security level, authentication state, expiration, the current challenge
+ * nonce, status, the connection start time and current key derivation key
+ * number.  Cache both the user identity and callback identity presented
+ * in the token, for later use.
+ */
+struct rxgk_sconn {
+    RXGK_Level level;
+    unsigned char auth;
+    unsigned char challenge_valid;
+    rxgkTime expiration;
+    unsigned char challenge[RXGK_CHALLENGE_NONCE_LEN];
+    struct rxgkStats stats;
+    rxgkTime start_time;
+    struct rx_identity *client;
+    afs_uint32 key_number;
+    rxgk_key k0;
+};
+
+/*
+ * rxgk_client.c
+ */
+
+/**
+ * Security Object private data for client.
+ *
+ * The session key ("token master key"), plust the enctype of the
+ * token and the token itself.
+ * UUIDs for both the client (cache manager) and target server.  This is
+ * doable because the token is either a db server (the target has no UUID)
+ * or tied to a particular file server (which does have a UUID).
+ */
+struct rxgk_cprivate {
+    rxgk_key k0;
+    afs_int32 enctype;
+    RXGK_Level level;
+    RXGK_Data token;
+};
+/**
+ * Per-connection security data for client.
+ *
+ * The start time of the connection and connection key number are used
+ * for key derivation, information about the callback key to be presented in
+ * the authenticator for the connection, and the requisite connection
+ * statistics.
+ */
+struct rxgk_cconn {
+    rxgkTime start_time;
+    afs_uint32 key_number;
+    struct rxgkStats stats;
+};
+
+/* rxgk_crypto_IMPL.c (currently rfc3961 is the only IMPL) */
+ssize_t rxgk_etype_to_len(int etype);
+
+/* rxgk_token.c */
+afs_int32 rxgk_extract_token(RXGK_Data *tc, RXGK_Token *out,
+			     rxgk_getkey_func getkey, void *rock)
+			    AFS_NONNULL((1,2,3));
+
+/* rxgk_util.c */
+afs_int32 rxgk_security_overhead(struct rx_connection *aconn, RXGK_Level level,
+				 rxgk_key k0);
+afs_int32 rxgk_key_number(afs_uint16 wire, afs_uint32 local, afs_uint32 *real);
+
+/* rxgk_packet.c */
+int rxgk_mic_packet(rxgk_key tk, afs_int32 keyusage,
+		    struct rx_connection *aconn, struct rx_packet *apacket);
+int rxgk_enc_packet(rxgk_key tk, afs_int32 keyusage,
+		    struct rx_connection *aconn, struct rx_packet *apacket);
+int rxgk_check_packet(int server, struct rx_connection *aconn,
+                      struct rx_packet *apacket, RXGK_Level level,
+                      rxgkTime start_time, afs_uint32 *a_kvno, rxgk_key k0);
+
+#endif /* RXGK_PRIVATE_H */
diff --git a/src/rxgk/rxgk_procs.c b/src/rxgk/rxgk_procs.c
new file mode 100644
index 000000000..b35900a46
--- /dev/null
+++ b/src/rxgk/rxgk_procs.c
@@ -0,0 +1,76 @@
+/* rxgk/rxgk_procs.c - Server-side RPC procedures for RXGK */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Server-side RPC procedures for RXGK.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#ifdef AFS_RXGK_GSS_ENV
+
+#include <rx/rx.h>
+#include <rx/rx_identity.h>
+#include <rx/rxgk.h>
+
+#include "rxgk_private.h"
+
+afs_int32
+SRXGK_GSSNegotiate(struct rx_call *z_call, RXGK_StartParams *client_start,
+		   RXGK_Data *input_token_buffer, RXGK_Data *opaque_in,
+		   RXGK_Data *output_token_buffer, RXGK_Data *opaque_out,
+		   afs_uint32 *gss_major_status, afs_uint32 *gss_minor_status,
+		   RXGK_Data *rxgk_info)
+{
+    return RXGEN_OPCODE;
+}
+
+
+afs_int32
+SRXGK_CombineTokens(struct rx_call *z_call, RXGK_Data *token0,
+		    RXGK_Data *token1, RXGK_CombineOptions *options,
+		    RXGK_Data *new_token, RXGK_TokenInfo *info)
+{
+    return RXGEN_OPCODE;
+}
+
+afs_int32
+SRXGK_AFSCombineTokens(struct rx_call *z_call, RXGK_Data *user_tok,
+		       RXGK_Data *cm_tok, RXGK_CombineOptions *options,
+		       afsUUID destination, RXGK_Data *new_token,
+		       RXGK_TokenInfo *info)
+{
+    return RXGEN_OPCODE;
+}
+
+#endif /* AFS_RXGK_GSS_ENV */
diff --git a/src/rxgk/rxgk_server.c b/src/rxgk/rxgk_server.c
new file mode 100644
index 000000000..06bd46f8c
--- /dev/null
+++ b/src/rxgk/rxgk_server.c
@@ -0,0 +1,764 @@
+/* rxgk/rxgk_server.c - server-specific security object routines */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Server-specific security object routines.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#include <roken.h>
+
+#include <afs/opr.h>
+#include <rx/rx.h>
+#include <rx/xdr.h>
+#include <rx/rx_packet.h>
+#include <rx/rxgk.h>
+
+#include "rxgk_private.h"
+
+/*
+ * Increment the reference count on the security object secobj.
+ */
+static_inline void
+obj_ref(struct rx_securityClass *secobj)
+{
+    secobj->refCount++;
+}
+
+/*
+ * Decrement the reference count on the security object secobj.
+ * If the reference count falls to zero, release the underlying storage.
+ */
+static void
+obj_rele(struct rx_securityClass *secobj)
+{
+    struct rxgk_sprivate *sp;
+
+    secobj->refCount--;
+    if (secobj->refCount > 0) {
+	/* still in use */
+	return;
+    }
+
+    sp = secobj->privateData;
+    rxi_Free(secobj, sizeof(*secobj));
+    rxi_Free(sp, sizeof(*sp));
+    return;
+}
+
+/* Release a server security object. */
+static int
+rxgk_ServerClose(struct rx_securityClass *aobj)
+{
+    obj_rele(aobj);
+    return 0;
+}
+
+/* Set fields in 'sc' to invalid/uninitialized values, so we don't accidentally
+ * use blank/zeroed values later. */
+static void
+sconn_set_noauth(struct rxgk_sconn *sc)
+{
+    rxgk_release_key(&sc->k0);
+    if (sc->client != NULL)
+        rx_identity_free(&sc->client);
+    sc->start_time = 0;
+    sc->auth = 0;
+
+    /*
+     * The values here should never be seen; set some bogus values. For
+     * 'expiration' and 'level', values of 0 are not bogus, so we explicitly
+     * set some nonzero values that are sure to be invalid, just in case they
+     * get used.
+     */
+    sc->expiration = 1;
+    sc->level = RXGK_LEVEL_BOGUS;
+}
+
+/*
+ * Create a new rx connection on this given server security object.
+ */
+static int
+rxgk_NewServerConnection(struct rx_securityClass *aobj,
+			 struct rx_connection *aconn)
+{
+    struct rxgk_sconn *sc;
+
+    if (rx_GetSecurityData(aconn) != NULL)
+	goto error;
+
+    sc = rxi_Alloc(sizeof(*sc));
+    if (sc == NULL)
+	goto error;
+
+    sconn_set_noauth(sc);
+    rx_SetSecurityData(aconn, sc);
+    obj_ref(aobj);
+    return 0;
+
+ error:
+    return RXGK_INCONSISTENCY;
+}
+
+/*
+ * Server-specific packet preparation routine. All the interesting bits are in
+ * rxgk_packet.c; all we have to do here is extract data from the security data
+ * on the connection and use the proper key usage.
+ */
+static int
+rxgk_ServerPreparePacket(struct rx_securityClass *aobj, struct rx_call *acall,
+			 struct rx_packet *apacket)
+{
+    struct rxgk_sconn *sc;
+    struct rx_connection *aconn;
+    rxgk_key tk;
+    afs_uint32 lkvno;
+    afs_uint16 wkvno, len;
+    int ret;
+
+    aconn = rx_ConnectionOf(acall);
+    sc = rx_GetSecurityData(aconn);
+
+    if (sc->expiration < RXGK_NOW() && sc->expiration != RXGK_NEVERDATE)
+	return RXGK_EXPIRED;
+
+    len = rx_GetDataSize(apacket);
+    lkvno = sc->key_number;
+    sc->stats.psent++;
+    sc->stats.bsent += len;
+    wkvno = (afs_uint16)lkvno;
+    rx_SetPacketCksum(apacket, wkvno);
+
+    if (sc->level == RXGK_LEVEL_CLEAR)
+	return 0;
+
+    ret = rxgk_derive_tk(&tk, sc->k0, rx_GetConnectionEpoch(aconn),
+			 rx_GetConnectionId(aconn), sc->start_time, lkvno);
+    if (ret != 0)
+	return ret;
+
+    switch(sc->level) {
+	case RXGK_LEVEL_AUTH:
+	    ret = rxgk_mic_packet(tk, RXGK_SERVER_MIC_PACKET, aconn, apacket);
+	    break;
+	case RXGK_LEVEL_CRYPT:
+	    ret = rxgk_enc_packet(tk, RXGK_SERVER_ENC_PACKET, aconn, apacket);
+	    break;
+	default:
+	    ret = RXGK_INCONSISTENCY;
+	    break;
+    }
+
+    rxgk_release_key(&tk);
+    return ret;
+}
+
+/* Did a connection properly authenticate? */
+static int
+rxgk_CheckAuthentication(struct rx_securityClass *aobj,
+			 struct rx_connection *aconn)
+{
+    struct rxgk_sconn *sc;
+
+    sc = rx_GetSecurityData(aconn);
+    if (sc == NULL)
+	return RXGK_INCONSISTENCY;
+
+    if (sc->auth == 0)
+	return RXGK_NOTAUTH;
+
+    return 0;
+}
+
+/* Generate a challenge to be used later. */
+static int
+rxgk_CreateChallenge(struct rx_securityClass *aobj,
+		     struct rx_connection *aconn)
+{
+    struct rxgk_sconn *sc;
+    struct rx_opaque buf = RX_EMPTY_OPAQUE;
+    opr_StaticAssert(sizeof(sc->challenge) == RXGK_CHALLENGE_NONCE_LEN);
+
+    sc = rx_GetSecurityData(aconn);
+    if (sc == NULL)
+	return RXGK_INCONSISTENCY;
+    sc->auth = 0;
+
+    /* The challenge is a 20-byte random nonce. */
+    if (rxgk_nonce(&buf, RXGK_CHALLENGE_NONCE_LEN) != 0)
+	return RXGK_INCONSISTENCY;
+
+    opr_Assert(buf.len == RXGK_CHALLENGE_NONCE_LEN);
+    memcpy(&sc->challenge, buf.val, RXGK_CHALLENGE_NONCE_LEN);
+    rx_opaque_freeContents(&buf);
+    sc->challenge_valid = 1;
+    return 0;
+}
+
+/*
+ * Read the challenge stored in 'sc', performing some sanity checks. Always go
+ * through this function to access the challenge, and never read from
+ * sc->challenge directly.
+ */
+static int
+read_challenge(struct rxgk_sconn *sc, void *buf, int len)
+{
+    opr_StaticAssert(sizeof(sc->challenge) == RXGK_CHALLENGE_NONCE_LEN);
+
+    if (len != RXGK_CHALLENGE_NONCE_LEN) {
+	return RXGK_INCONSISTENCY;
+    }
+    if (!sc->challenge_valid) {
+	return RXGK_INCONSISTENCY;
+    }
+    memcpy(buf, sc->challenge, RXGK_CHALLENGE_NONCE_LEN);
+    return 0;
+}
+
+/* Incorporate a challenge into a packet */
+static int
+rxgk_GetChallenge(struct rx_securityClass *aobj, struct rx_connection *aconn,
+		  struct rx_packet *apacket)
+{
+    XDR xdrs;
+    struct rxgk_sconn *sc;
+    void *data = NULL;
+    RXGK_Challenge challenge;
+    int ret;
+    u_int len = 0;
+    opr_StaticAssert(sizeof(challenge.nonce) == RXGK_CHALLENGE_NONCE_LEN);
+
+    memset(&xdrs, 0, sizeof(xdrs));
+    memset(&challenge, 0, sizeof(challenge));
+
+    sc = rx_GetSecurityData(aconn);
+    if (sc == NULL) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    ret = read_challenge(sc, challenge.nonce, sizeof(challenge.nonce));
+    if (ret)
+	goto done;
+
+    xdrlen_create(&xdrs);
+    if (!xdr_RXGK_Challenge(&xdrs, &challenge)) {
+	ret = RXGEN_SS_MARSHAL;
+	goto done;
+    }
+    len = xdr_getpos(&xdrs);
+
+    data = rxi_Alloc(len);
+    if (data == NULL) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    xdr_destroy(&xdrs);
+    xdrmem_create(&xdrs, data, len, XDR_ENCODE);
+    if (!xdr_RXGK_Challenge(&xdrs, &challenge)) {
+	ret = RXGEN_SS_MARSHAL;
+	goto done;
+    }
+    opr_Assert(len <= 0xffffu);
+    rx_packetwrite(apacket, 0, len, data);
+    rx_SetDataSize(apacket, len);
+
+    /* Nothing should really pay attention to the checksum of a challenge
+     * packet, but just set it to 0 so it's always set to _something_. */
+    rx_SetPacketCksum(apacket, 0);
+
+    ret = 0;
+
+ done:
+    rxi_Free(data, len);
+    if (xdrs.x_ops)
+	xdr_destroy(&xdrs);
+    return ret;
+}
+
+/*
+ * Helper functions for CheckResponse.
+ */
+
+/**
+ * The XDR token format uses the XDR PrAuthName type to store identities.
+ * However, there is an existing rx_identity type used in libauth, so
+ * we convert from the wire type to the internal type as soon as possible
+ * in order to be able to use the most library code. 'a_identity' will contain
+ * a single identity on success, not an array.
+ *
+ * @return rxgk error codes
+ */
+static int
+prnames_to_identity(struct rx_identity **a_identity, PrAuthName *namelist,
+		    size_t nnames)
+{
+    rx_identity_kind kind;
+    size_t len;
+    char *display;
+
+    *a_identity = NULL;
+
+    /* Could grab the acceptor identity from ServiceSpecific if wanted. */
+    if (nnames == 0) {
+	*a_identity = rx_identity_new(RX_ID_SUPERUSER, "<printed token>", "",
+				      0);
+	return 0;
+
+    } else if (nnames > 1) {
+	/* Compound identities are not supported yet. */
+	return RXGK_INCONSISTENCY;
+    }
+
+    if (namelist[0].kind == PRAUTHTYPE_KRB4)
+	kind = RX_ID_KRB4;
+    else if (namelist[0].kind == PRAUTHTYPE_GSS)
+	kind = RX_ID_GSS;
+    else
+	return RXGK_INCONSISTENCY;
+    len = namelist[0].display.len;
+    display = rxi_Alloc(len + 1);
+    if (display == NULL)
+	return RXGK_INCONSISTENCY;
+    memcpy(display, namelist[0].display.val, len);
+    display[len] = '\0';
+    *a_identity = rx_identity_new(kind, display, namelist[0].data.val,
+				  namelist[0].data.len);
+    rxi_Free(display, len + 1);
+    return 0;
+}
+
+/*
+ * Unpack, decrypt, and extract information from a token.
+ * Store the relevant bits in the connection security data.
+ */
+static int
+process_token(RXGK_Data *tc, struct rxgk_sprivate *sp, struct rxgk_sconn *sc)
+{
+    RXGK_Token token;
+    int ret;
+
+    memset(&token, 0, sizeof(token));
+
+    ret = rxgk_extract_token(tc, &token, sp->getkey, sp->rock);
+    if (ret != 0)
+	goto done;
+
+    /* Stash the token master key in the per-connection data. */
+    rxgk_release_key(&sc->k0);
+    ret = rxgk_make_key(&sc->k0, token.K0.val, token.K0.len, token.enctype);
+    if (ret != 0)
+	goto done;
+
+    sc->level = token.level;
+    sc->expiration = token.expirationtime;
+    /*
+     * TODO: note that we currently ignore the bytelife and lifetime in
+     * 'token'. In the future, we should of course actually remember these and
+     * potentially alter our rekeying frequency according to them.
+     */
+
+    if (sc->client != NULL)
+	rx_identity_free(&sc->client);
+    ret = prnames_to_identity(&sc->client, token.identities.val,
+			      token.identities.len);
+    if (ret != 0)
+	goto done;
+
+ done:
+    xdr_free((xdrproc_t)xdr_RXGK_Token, &token);
+    return ret;
+}
+
+static void
+update_kvno(struct rxgk_sconn *sc, afs_uint32 kvno)
+{
+    sc->key_number = kvno;
+
+    /* XXX Our statistics for tracking when to re-key the conn should be reset
+     * here. */
+}
+
+/* Caller is responsible for freeing 'out'. */
+static int
+decrypt_authenticator(RXGK_Authenticator *out, struct rx_opaque *in,
+		      struct rx_connection *aconn, struct rxgk_sconn *sc,
+		      afs_uint16 wkvno)
+{
+    XDR xdrs;
+    struct rx_opaque packauth = RX_EMPTY_OPAQUE;
+    rxgk_key tk = NULL;
+    afs_uint32 lkvno, kvno = 0;
+    int ret;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+
+    lkvno = sc->key_number;
+    ret = rxgk_key_number(wkvno, lkvno, &kvno);
+    if (ret != 0)
+	goto done;
+    ret = rxgk_derive_tk(&tk, sc->k0, rx_GetConnectionEpoch(aconn),
+			 rx_GetConnectionId(aconn), sc->start_time, kvno);
+    if (ret != 0)
+	goto done;
+    ret = rxgk_decrypt_in_key(tk, RXGK_CLIENT_ENC_RESPONSE, in, &packauth);
+    if (ret != 0) {
+	goto done;
+    }
+    if (kvno > lkvno)
+	update_kvno(sc, kvno);
+
+    xdrmem_create(&xdrs, packauth.val, packauth.len, XDR_DECODE);
+    if (!xdr_RXGK_Authenticator(&xdrs, out)) {
+	ret = RXGEN_SS_UNMARSHAL;
+	goto done;
+    }
+    ret = 0;
+
+ done:
+    rx_opaque_freeContents(&packauth);
+    rxgk_release_key(&tk);
+    if (xdrs.x_ops)
+	xdr_destroy(&xdrs);
+    return ret;
+}
+
+/*
+ * Make the authenticator do its job with channel binding and nonce
+ * verification.
+ */
+static int
+check_authenticator(RXGK_Authenticator *authenticator,
+		    struct rx_connection *aconn, struct rxgk_sconn *sc)
+{
+    /*
+     * To check the data in the authenticator, we could simply check
+     * if (got_value == expected_value) for each field we care about. But since
+     * this is a security-sensitive check, we should try to do this check in
+     * constant time to avoid timing-based attacks. So to do that, we construct
+     * a small structure of the values we got and the expected values, and run
+     * ct_memcmp on the whole thing at the end.
+     */
+
+    int code;
+    struct {
+	unsigned char challenge[RXGK_CHALLENGE_NONCE_LEN];
+	RXGK_Level level;
+	afs_uint32 epoch;
+	afs_uint32 cid;
+	int calls_len;
+    } auth_got, auth_exp;
+
+    opr_StaticAssert(sizeof(auth_got.challenge) == RXGK_CHALLENGE_NONCE_LEN);
+    opr_StaticAssert(sizeof(auth_exp.challenge) == RXGK_CHALLENGE_NONCE_LEN);
+    opr_StaticAssert(sizeof(authenticator->nonce) == RXGK_CHALLENGE_NONCE_LEN);
+
+    memset(&auth_got, 0, sizeof(auth_got));
+    memset(&auth_exp, 0, sizeof(auth_exp));
+
+    memcpy(auth_got.challenge, authenticator->nonce, RXGK_CHALLENGE_NONCE_LEN);
+    code = read_challenge(sc, auth_exp.challenge, sizeof(auth_exp.challenge));
+    if (code)
+	return code;
+
+    auth_got.level = authenticator->level;
+    auth_exp.level = sc->level;
+
+    auth_got.epoch = authenticator->epoch;
+    auth_exp.epoch = rx_GetConnectionEpoch(aconn);
+
+    auth_got.cid = authenticator->cid;
+    auth_exp.cid = rx_GetConnectionId(aconn);
+
+    auth_got.calls_len = authenticator->call_numbers.len;
+    auth_exp.calls_len = RX_MAXCALLS;
+
+    /* XXX We do nothing with the appdata for now. */
+
+    if (ct_memcmp(&auth_got, &auth_exp, sizeof(auth_got)) != 0) {
+	return RXGK_BADCHALLENGE;
+    }
+    return 0;
+}
+
+/* Process the response packet to a challenge */
+static int
+rxgk_CheckResponse(struct rx_securityClass *aobj,
+		   struct rx_connection *aconn, struct rx_packet *apacket)
+{
+    struct rxgk_sprivate *sp;
+    struct rxgk_sconn *sc;
+    XDR xdrs;
+    RXGK_Response response;
+    RXGK_Authenticator authenticator;
+    int ret;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+    memset(&response, 0, sizeof(response));
+    memset(&authenticator, 0, sizeof(authenticator));
+
+    sp = aobj->privateData;
+    sc = rx_GetSecurityData(aconn);
+
+    /*
+     * This assumes that the entire response is in a contiguous data block in
+     * the packet. rx in general can store packet data in multiple different
+     * buffers (pointed to by apacket->wirevec[N]), but the payload when
+     * receiving a Response packet should all be in one buffer (so we can just
+     * reference it directly via rx_DataOf()). If this assumption turns out to
+     * be wrong, then we'll just see a truncated response blob and this
+     * function will likely return an error; there should be no danger of
+     * buffer overrun or anything scary like that.
+     */
+    xdrmem_create(&xdrs, rx_DataOf(apacket), rx_Contiguous(apacket),
+		  XDR_DECODE);
+    if (!xdr_RXGK_Response(&xdrs, &response)) {
+	ret = RXGEN_SS_UNMARSHAL;
+	goto done;
+    }
+
+    /* Stash useful bits from the token in sc. */
+    ret = process_token(&response.token, sp, sc);
+    if (ret != 0)
+	goto done;
+    if (sc->expiration < RXGK_NOW() && sc->expiration != RXGK_NEVERDATE) {
+	ret = RXGK_EXPIRED;
+	goto done;
+    }
+
+    /*
+     * Cache the client-provided start_time. If this is wrong, we cannot derive
+     * the correct transport key and the authenticator decryption will fail.
+     */
+    sc->start_time = response.start_time;
+
+    /* Try to decrypt the authenticator. */
+    ret = decrypt_authenticator(&authenticator, &response.authenticator, aconn,
+				sc, rx_GetPacketCksum(apacket));
+    if (ret != 0)
+	goto done;
+    ret = check_authenticator(&authenticator, aconn, sc);
+    if (ret != 0)
+	goto done;
+    ret = rxgk_security_overhead(aconn, sc->level, sc->k0);
+    if (ret != 0)
+	goto done;
+    if (rxi_SetCallNumberVector(aconn, (afs_int32 *)authenticator.call_numbers.val) != 0) {
+	ret = RXGK_INCONSISTENCY;
+	goto done;
+    }
+    /* Success! */
+    sc->auth = 1;
+    sc->challenge_valid = 0;
+
+ done:
+    if (ret != 0)
+	sconn_set_noauth(sc);
+    if (xdrs.x_ops)
+	xdr_destroy(&xdrs);
+    xdr_free((xdrproc_t)xdr_RXGK_Response, &response);
+    xdr_free((xdrproc_t)xdr_RXGK_Authenticator, &authenticator);
+    return ret;
+}
+
+/*
+ * Server-specific packet receipt routine.
+ * The interesting bits are in rxgk_packet.c, we just extract data from the
+ * connection security data.
+ */
+static int
+rxgk_ServerCheckPacket(struct rx_securityClass *aobj, struct rx_call *acall,
+		       struct rx_packet *apacket)
+{
+    struct rxgk_sconn *sc;
+    struct rx_connection *aconn;
+    afs_uint32 lkvno, kvno;
+    afs_uint16 len;
+    int ret;
+
+    aconn = rx_ConnectionOf(acall);
+    sc = rx_GetSecurityData(aconn);
+    if (sc == NULL)
+	return RXGK_INCONSISTENCY;
+
+    len = rx_GetDataSize(apacket);
+    sc->stats.precv++;
+    sc->stats.brecv += len;
+    if (sc->expiration < RXGK_NOW() && sc->expiration != RXGK_NEVERDATE)
+	return RXGK_EXPIRED;
+
+    lkvno = kvno = sc->key_number;
+    ret = rxgk_check_packet(1, aconn, apacket, sc->level, sc->start_time,
+			    &kvno, sc->k0);
+    if (ret != 0)
+	return ret;
+
+    if (kvno > lkvno)
+	update_kvno(sc, kvno);
+
+    return ret;
+}
+
+/*
+ * Perform server-side connection-specific teardown.
+ */
+static void
+rxgk_DestroyServerConnection(struct rx_securityClass *aobj,
+			     struct rx_connection *aconn)
+{
+    struct rxgk_sconn *sc;
+
+    sc = rx_GetSecurityData(aconn);
+    if (sc == NULL) {
+	return;
+    }
+    rx_SetSecurityData(aconn, NULL);
+
+    rxgk_release_key(&sc->k0);
+    if (sc->client != NULL)
+	rx_identity_free(&sc->client);
+    rxi_Free(sc, sizeof(*sc));
+    obj_rele(aobj);
+}
+
+/*
+ * Get statistics about this connection.
+ */
+static int
+rxgk_ServerGetStats(struct rx_securityClass *aobj, struct rx_connection *aconn,
+		    struct rx_securityObjectStats *astats)
+{
+    struct rxgkStats *stats;
+    struct rxgk_sconn *sc;
+
+    astats->type = RX_SECTYPE_GK;
+    sc = rx_GetSecurityData(aconn);
+    if (sc == NULL) {
+	astats->flags |= RXGK_STATS_UNALLOC;
+	return 0;
+    }
+
+    stats = &sc->stats;
+    astats->level = sc->level;
+    if (sc->auth)
+	astats->flags |= RXGK_STATS_AUTH;
+    astats->expires = (afs_uint32)rxgkTimeToSeconds(sc->expiration);
+
+    astats->packetsReceived = stats->precv;
+    astats->packetsSent = stats->psent;
+    astats->bytesReceived = stats->brecv;
+    astats->bytesSent = stats->bsent;
+
+    return 0;
+}
+
+/*
+ * Get some information about this connection, in particular the security
+ * level, expiry time, and the remote user's identity.
+ */
+afs_int32
+rxgk_GetServerInfo(struct rx_connection *conn, RXGK_Level *level,
+		   rxgkTime *expiry, struct rx_identity **identity)
+{
+    struct rxgk_sconn *sconn;
+
+    if (rx_SecurityClassOf(conn) != RX_SECIDX_GK) {
+	return EINVAL;
+    }
+
+    sconn = rx_GetSecurityData(conn);
+    if (sconn == NULL)
+	return RXGK_INCONSISTENCY;
+    if (identity != NULL) {
+	*identity = rx_identity_copy(sconn->client);
+	if (*identity == NULL)
+	    return RXGK_INCONSISTENCY;
+    }
+    if (level != NULL)
+	*level = sconn->level;
+    if (expiry != NULL)
+	*expiry = sconn->expiration;
+    return 0;
+}
+
+static struct rx_securityOps rxgk_server_ops = {
+    rxgk_ServerClose,
+    rxgk_NewServerConnection,
+    rxgk_ServerPreparePacket,		/* once per packet creation */
+    0,					/* send packet (once per retrans) */
+    rxgk_CheckAuthentication,
+    rxgk_CreateChallenge,
+    rxgk_GetChallenge,
+    0,
+    rxgk_CheckResponse,
+    rxgk_ServerCheckPacket,		/* check data packet */
+    rxgk_DestroyServerConnection,
+    rxgk_ServerGetStats,
+    0,
+    0,				/* spare 1 */
+    0,				/* spare 2 */
+};
+
+/**
+ * The low-level routine to generate a new server security object.
+ *
+ * Takes a getkey function and its rock.
+ *
+ * It is not expected that most callers will use this function, as
+ * we provide helpers that do other setup, setting service-specific
+ * data and such.
+ */
+struct rx_securityClass *
+rxgk_NewServerSecurityObject(void *getkey_rock, rxgk_getkey_func getkey)
+{
+    struct rx_securityClass *sc;
+    struct rxgk_sprivate *sp;
+
+    sc = rxi_Alloc(sizeof(*sc));
+    if (sc == NULL)
+	return NULL;
+    sp = rxi_Alloc(sizeof(*sp));
+    if (sp == NULL) {
+	rxi_Free(sc, sizeof(*sc));
+	return NULL;
+    }
+    sc->ops = &rxgk_server_ops;
+    sc->refCount = 1;
+    sc->privateData = sp;
+
+    /* Now set the server-private data. */
+    sp->rock = getkey_rock;
+    sp->getkey = getkey;
+
+    return sc;
+}
diff --git a/src/rxgk/rxgk_token.c b/src/rxgk/rxgk_token.c
new file mode 100644
index 000000000..a21704451
--- /dev/null
+++ b/src/rxgk/rxgk_token.c
@@ -0,0 +1,460 @@
+/* rxgk/rxgk_token.c - Token generation/manuipluation routines for RXGK */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * Routines to generate, encode, encrypt, decode, and decrypt rxgk tokens.
+ */
+
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#include <rx/rx.h>
+#include <rx/xdr.h>
+#include <rx/rx_opaque.h>
+#include <rx/rxgk.h>
+#include <errno.h>
+
+#include "rxgk_private.h"
+
+/*
+ * Copy the fields from a TokenInfo to a Token.
+ */
+static void
+tokeninfo_to_token(RXGK_TokenInfo *info, RXGK_Token *token)
+{
+
+    token->enctype = info->enctype;
+    token->level = info->level;
+    token->lifetime = info->lifetime;
+    token->bytelife = info->bytelife;
+    token->expirationtime = info->expiration;
+    return;
+}
+
+/*
+ * Take the input RXGK_Token and XDR-encode it, returning the result in 'out'.
+ * The caller is responsible for freeing the memory contained in 'out'.
+ *
+ * Returns RX errors.
+ */
+static afs_int32
+pack_token(RXGK_Token *token, struct rx_opaque *out)
+{
+    XDR xdrs;
+    afs_int32 ret;
+    u_int len;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+    memset(out, 0, sizeof(*out));
+    xdrlen_create(&xdrs);
+    if (!xdr_RXGK_Token(&xdrs, token)) {
+	ret = RXGEN_SS_MARSHAL;
+	goto done;
+    }
+    len = xdr_getpos(&xdrs);
+
+    ret = rx_opaque_alloc(out, len);
+    if (ret != 0)
+	goto done;
+
+    xdr_destroy(&xdrs);
+    xdrmem_create(&xdrs, out->val, len, XDR_ENCODE);
+    if (!xdr_RXGK_Token(&xdrs, token)) {
+	rx_opaque_freeContents(out);
+	ret = RXGEN_SS_MARSHAL;
+	goto done;
+    }
+    ret = 0;
+
+ done:
+    if (xdrs.x_ops) {
+        xdr_destroy(&xdrs);
+    }
+    return ret;
+}
+
+/*
+ * Take the input TokenContainer and XDR-encode it, returning the result
+ * in 'out'.  The caller is responsible for freeing the memory contained
+ * in 'out'.
+ *
+ * Returns RX errors.
+ */
+static afs_int32
+pack_container(RXGK_TokenContainer *container, struct rx_opaque *out)
+{
+    XDR xdrs;
+    afs_int32 ret;
+    u_int len;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+    xdrlen_create(&xdrs);
+    if (!xdr_RXGK_TokenContainer(&xdrs, container)) {
+	ret = RXGEN_SS_MARSHAL;
+	goto done;
+    }
+    len = xdr_getpos(&xdrs);
+
+    ret = rx_opaque_alloc(out, len);
+    if (ret != 0)
+	goto done;
+
+    xdr_destroy(&xdrs);
+    xdrmem_create(&xdrs, out->val, len, XDR_ENCODE);
+    if (!xdr_RXGK_TokenContainer(&xdrs, container)) {
+	rx_opaque_freeContents(out);
+	ret = RXGEN_SS_MARSHAL;
+	goto done;
+    }
+    ret = 0;
+
+ done:
+    if (xdrs.x_ops) {
+        xdr_destroy(&xdrs);
+    }
+    return ret;
+}
+
+/*
+ * Take the input token, encode it, encrypt that blob, populate a
+ * TokenContainer with the encrypted token, kvno, and enctype, and encode
+ * the resulting TokenContainer into 'out'.
+ *
+ * Returns RX errors.
+ */
+static afs_int32
+pack_wrap_token(rxgk_key server_key, afs_int32 kvno, afs_int32 enctype,
+		RXGK_Token *token, struct rx_opaque *out)
+{
+    struct rx_opaque packed_token = RX_EMPTY_OPAQUE;
+    struct rx_opaque encrypted_token = RX_EMPTY_OPAQUE;
+    RXGK_TokenContainer container;
+    afs_int32 ret;
+
+    memset(&container, 0, sizeof(container));
+
+    /* XDR-encode the token in to packed_token. */
+    ret = pack_token(token, &packed_token);
+    if (ret != 0)
+	goto done;
+
+    ret = rxgk_encrypt_in_key(server_key, RXGK_SERVER_ENC_TOKEN, &packed_token,
+			      &encrypted_token);
+    if (ret != 0)
+	goto done;
+    ret = rx_opaque_populate(&container.encrypted_token, encrypted_token.val,
+			     encrypted_token.len);
+    if (ret != 0)
+	goto done;
+    container.kvno = kvno;
+    container.enctype = enctype;
+
+    /* Now the token container is populated; time to encode it into 'out'. */
+    ret = pack_container(&container, out);
+
+ done:
+    rx_opaque_freeContents(&packed_token);
+    rx_opaque_freeContents(&encrypted_token);
+    rx_opaque_freeContents(&container.encrypted_token);
+    return ret;
+}
+
+/**
+ * Print an rxgk token with random key, returning key and token
+ *
+ * Print a token (with empty identity list) with a random master key,
+ * and encrypt it in the specified key/kvno/enctype.  Return the master
+ * key as well as the token, so that the token is usable.
+ *
+ * The caller must free k0 with release_key().
+ *
+ * @param[out] out	The printed token (RXGK_TokenContainer).
+ * @param[in] input_info	Parameters describing the token to be printed.
+ * @param[in] key	The token-encrypting key.
+ * @param[in] kvno	The kvno of key.
+ * @param[in] enctype	The enctype of key.
+ * @param[out] k0_out	The token master key.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_print_token_and_key(struct rx_opaque *out, RXGK_TokenInfo *input_info,
+                         rxgk_key key, afs_int32 kvno, afs_int32 enctype,
+                         rxgk_key *k0_out)
+{
+    struct rx_opaque k0_data = RX_EMPTY_OPAQUE;
+    rxgk_key k0 = NULL;
+    ssize_t len;
+    afs_int32 ret;
+
+    *k0_out = NULL;
+
+    len = rxgk_etype_to_len(input_info->enctype);
+    if (len < 0) {
+	ret = RXGK_BADETYPE;
+        goto done;
+    }
+
+    ret = rxgk_nonce(&k0_data, len);
+    if (ret != 0)
+	goto done;
+
+    ret = rxgk_make_key(&k0, k0_data.val, k0_data.len, input_info->enctype);
+    if (ret != 0)
+	goto done;
+
+    ret = rxgk_print_token(out, input_info, &k0_data, key, kvno, enctype);
+    if (ret != 0)
+	goto done;
+
+    *k0_out = k0;
+    k0 = NULL;
+
+ done:
+    rx_opaque_freeContents(&k0_data);
+    rxgk_release_key(&k0);
+    return ret;
+}
+
+/*
+ * Helper functions for rxgk_extract_token.
+ */
+static int
+unpack_container(RXGK_Data *in, RXGK_TokenContainer *container)
+{
+    XDR xdrs;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+
+    xdrmem_create(&xdrs, in->val, in->len, XDR_DECODE);
+    if (!xdr_RXGK_TokenContainer(&xdrs, container)) {
+	xdr_destroy(&xdrs);
+	return RXGEN_SS_UNMARSHAL;
+    }
+    xdr_destroy(&xdrs);
+    return 0;
+}
+
+static int
+decrypt_token(struct rx_opaque *enctoken, afs_int32 kvno, afs_int32 enctype,
+              rxgk_getkey_func getkey, void *rock, RXGK_Data *out)
+{
+    rxgk_key service_key = NULL;
+    afs_int32 ret;
+
+    if (kvno <= 0 || enctype <= 0) {
+	ret = RXGK_BAD_TOKEN;
+        goto done;
+    }
+
+    ret = getkey(rock, &kvno, &enctype, &service_key);
+    if (ret != 0)
+	goto done;
+    ret = rxgk_decrypt_in_key(service_key, RXGK_SERVER_ENC_TOKEN, enctoken,
+			      out);
+
+ done:
+    rxgk_release_key(&service_key);
+    return ret;
+}
+
+static int
+unpack_token(RXGK_Data *in, RXGK_Token *token)
+{
+    XDR xdrs;
+
+    memset(&xdrs, 0, sizeof(xdrs));
+
+    xdrmem_create(&xdrs, in->val, in->len, XDR_DECODE);
+    if (!xdr_RXGK_Token(&xdrs, token)) {
+	xdr_destroy(&xdrs);
+	return RXGEN_SS_UNMARSHAL;
+    }
+    xdr_destroy(&xdrs);
+    return 0;
+}
+
+/**
+ * Extract a cleartext RXGK_Token from a packed RXGK_TokenContainer
+ *
+ * Given an XDR-encoded RXGK_TokenContainer, extract/decrypt the contents
+ * into an RXGK_Token.
+ *
+ * The caller must free the returned token with xdr_free.
+ *
+ * @param[in] tc	The RXGK_TokenContainer to unpack.
+ * @param[out] out	The extracted RXGK_Token.
+ * @param[in] getkey	The getkey function used to decrypt the token.
+ * @param[in] rock	Data to pass to getkey.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_extract_token(RXGK_Data *tc, RXGK_Token *out, rxgk_getkey_func getkey,
+		   void *rock)
+{
+    RXGK_TokenContainer container;
+    struct rx_opaque packed_token = RX_EMPTY_OPAQUE;
+    afs_int32 ret;
+
+    memset(&container, 0, sizeof(container));
+
+    ret = unpack_container(tc, &container);
+    if (ret != 0)
+	goto done;
+    ret = decrypt_token(&container.encrypted_token, container.kvno,
+                        container.enctype, getkey, rock, &packed_token);
+    if (ret != 0)
+	goto done;
+    ret = unpack_token(&packed_token, out);
+
+ done:
+    xdr_free((xdrproc_t)xdr_RXGK_TokenContainer, &container);
+    xdr_free((xdrproc_t)xdr_RXGK_Data, &packed_token);
+    return ret;
+}
+
+/* NEVER call this function directly (except from rxgk_make_token or
+ * rxgk_print_token). Call rxgk_make_token or rxgk_print_token instead. See
+ * rxgk_make_token for info about our arguments. */
+static afs_int32
+make_token(struct rx_opaque *out, RXGK_TokenInfo *info,
+	   struct rx_opaque *k0, PrAuthName *identities,
+	   int nids, rxgk_key key, afs_int32 kvno, afs_int32 enctype)
+{
+    RXGK_Token token;
+    afs_int32 ret;
+
+    memset(&token, 0, sizeof(token));
+    memset(out, 0, sizeof(*out));
+
+    if (nids < 0) {
+        ret = RXGK_INCONSISTENCY;
+        goto done;
+    }
+
+    /* Get the tokeninfo values from the authoritative source. */
+    tokeninfo_to_token(info, &token);
+
+    /* Create the rest of the token. */
+    ret = rx_opaque_populate(&token.K0, k0->val, k0->len);
+    if (ret != 0)
+	goto done;
+    token.identities.len = (afs_uint32)nids;
+    token.identities.val = identities;
+    ret = pack_wrap_token(key, kvno, enctype, &token, out);
+    if (ret != 0)
+	goto done;
+
+ done:
+    /*
+     * We need to free the contents in 'token', but don't free
+     * token.identities. The pointer for that was given to us by our caller;
+     * they'll manage the memory for it.
+     */
+    memset(&token.identities, 0, sizeof(token.identities));
+    xdr_free((xdrproc_t)xdr_RXGK_Token, &token);
+    return ret;
+}
+
+/**
+ * Create an rxgk token
+ *
+ * Create a token from the specified TokenInfo, key, start time, and lists
+ * of identities.  Encrypts the token and stores it as an rx_opaque.
+ *
+ * Note that you cannot make printed tokens with this function ('nids' must be
+ * greater than 0). This is a deliberate restriction to try to avoid
+ * accidentally creating printed tokens.  Use rxgk_print_token() instead to
+ * make printed tokens.
+ *
+ * @param[out] out	The encoded rxgk token (RXGK_TokenContainer).
+ * @param[in] info	RXGK_Tokeninfo describing the token to be produced.
+ * @param[in] k0	The token master key.
+ * @param[in] identities The list of identities to be included in the token.
+ * @param[in] nids	The number of identities in the identities list (must
+ * 			be positive).
+ * @param[in] key	The token-encrypting key to use.
+ * @param[in] kvno	The kvno of key.
+ * @param[in] enctype	The enctype of key.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_make_token(struct rx_opaque *out, RXGK_TokenInfo *info,
+		struct rx_opaque *k0, PrAuthName *identities,
+		int nids, rxgk_key key, afs_int32 kvno, afs_int32 enctype)
+{
+    if (nids == 0 || identities == NULL) {
+	/* You cannot make printed tokens with this function; use
+	 * rxgk_print_token instead. */
+	memset(out, 0, sizeof(*out));
+	return RXGK_INCONSISTENCY;
+    }
+    return make_token(out, info, k0, identities, nids, key, kvno, enctype);
+}
+
+/* This lifetime is in seconds. */
+#define DEFAULT_LIFETIME	(60 * 60 * 10)
+/* The bytelife is log_2(bytes). */
+#define DEFAULT_BYTELIFE	30
+/**
+ * Create a printed rxgk token
+ *
+ * Print a token (with empty identity list) where the master key (k0)
+ * already exists, and encrypt it in the specified key/kvno/enctype.
+ *
+ * @param[out] out	The printed token (RXGK_TokenContainer).
+ * @param[in] input_info	Parameters describing the token to be printed.
+ * @param[in] k0	The master key to use for the token.
+ * @param[in] key	The token-encrypting key.
+ * @param[in] kvno	The kvno of key.
+ * @param[in] enctype	The enctype of key.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_print_token(struct rx_opaque *out, RXGK_TokenInfo *input_info,
+		 struct rx_opaque *k0, rxgk_key key, afs_int32 kvno,
+		 afs_int32 enctype)
+{
+    RXGK_TokenInfo info;
+
+    memset(&info, 0, sizeof(info));
+
+    info.enctype = input_info->enctype;
+    info.level = input_info->level;
+    info.lifetime = DEFAULT_LIFETIME;
+    info.bytelife = DEFAULT_BYTELIFE;
+    info.expiration = RXGK_NEVERDATE;
+
+    return make_token(out, &info, k0, NULL, 0, key, kvno, enctype);
+}
+
diff --git a/src/rxgk/rxgk_types.h b/src/rxgk/rxgk_types.h
new file mode 100644
index 000000000..70cae4493
--- /dev/null
+++ b/src/rxgk/rxgk_types.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Basic public type definitions for RXGK.
+ */
+
+#ifndef OPENAFS_RXGK_TYPES_H
+#define OPENAFS_RXGK_TYPES_H
+
+/* rxgk_key is an opaque type to wrap our RFC3961 implementation's concept
+ * of a key.  It has (at least) the keyblock and length, and enctype. */
+typedef struct rxgk_key_s * rxgk_key;
+
+#endif /* OPENAFS_RXGK_TYPES_H */
diff --git a/src/rxgk/rxgk_util.c b/src/rxgk/rxgk_util.c
new file mode 100644
index 000000000..059607031
--- /dev/null
+++ b/src/rxgk/rxgk_util.c
@@ -0,0 +1,146 @@
+/* rxgk/rxgk_util.c - utility functions for RXGK use */
+/*
+ * Copyright (C) 2013, 2014 by the Massachusetts Institute of Technology.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in
+ *   the documentation and/or other materials provided with the
+ *   distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/**
+ * @file
+ * Utility functions for RXGK use. Compute the security overhead for a
+ * connection at a given security level, and helpers for maintaining key
+ * version numbers for connections.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <afs/stds.h>
+
+#include <rx/rx.h>
+#include <rx/rx_identity.h>
+#include <rx/rxgk.h>
+#include <rx/rx_packet.h>
+#include <afs/rfc3961.h>
+#ifdef KERNEL
+# include "afs/sysincludes.h"
+# include "afsincludes.h"
+#else
+# include <errno.h>
+#endif
+
+#include "rxgk_private.h"
+
+/**
+ * Set the security header and trailer sizes on a connection
+ *
+ * Set the security header and trailer sizes on aconn to be consistent
+ * with the space needed for packet handling at the given security level
+ * using the given key (only its enctype/checksum type are relevant).
+ *
+ * @param[out] aconn	The connection being modified.
+ * @param[in] level	The security level of the connection.
+ * @param[in] k0	The master key for the connection.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_security_overhead(struct rx_connection *aconn, RXGK_Level level,
+		       rxgk_key k0)
+{
+    afs_int32 ret;
+    size_t mlen;
+    afs_uint32 elen;
+
+    switch (level) {
+	case RXGK_LEVEL_CLEAR:
+	    return 0;
+	case RXGK_LEVEL_AUTH:
+	    ret = rxgk_mic_length(k0, &mlen);
+	    if (ret != 0)
+		return ret;
+	    rx_SetSecurityHeaderSize(aconn, mlen);
+	    rx_SetSecurityMaxTrailerSize(aconn, 0);
+	    return 0;
+	case RXGK_LEVEL_CRYPT:
+	    ret = rxgk_cipher_expansion(k0, &elen);
+	    if (ret != 0)
+		return ret;
+	    rx_SetSecurityHeaderSize(aconn, sizeof(struct rxgk_header));
+	    rx_SetSecurityMaxTrailerSize(aconn, elen);
+	    return 0;
+	default:
+	    return RXGK_INCONSISTENCY;
+    }
+}
+
+/**
+ * Compute the full 32-bit kvno of a connection
+ *
+ * Given the 16-bit wire kvno and the local state, return the actual kvno which
+ * should be used for key derivation. All values are in host byte order.
+ * Understanding how we derive a 32-bit kvno from a 16-bit value requires some
+ * explanation:
+ *
+ * After an rxgk conn is set up, our peer informs us of kvno changes by sending
+ * the lowest 16 bits of its kvno. The real kvno being used is a 32-bit value,
+ * but the peer cannot change the kvno arbitrarily; the protocol spec only
+ * allows a peer to change the kvno by incrementing or decrementing it by 1. So
+ * if we know the current 32-bit kvno ('local'), and we know the advertised
+ * lower 16 bits of the new kvno ('wire'), we can calculate the new 32-bit kvno
+ * ('*real').
+ *
+ * @param[in] wire	The 16-bit kvno from the received packet.
+ * @param[in] local	The 32-bit kvno from the local connection state.
+ * @param[out] real	The kvno to be used to process this packet.
+ * @return rxgk error codes.
+ */
+afs_int32
+rxgk_key_number(afs_uint16 wire, afs_uint32 local, afs_uint32 *real)
+{
+    afs_uint16 lres, diff;
+
+    lres = local % (1u << 16);
+    diff = (afs_uint16)(wire - lres);
+
+    if (diff == 0) {
+	*real = local;
+    } else if (diff == 1) {
+	/* Our peer is using a kvno 1 higher than 'local' */
+	if (local == MAX_AFS_UINT32)
+	    return RXGK_INCONSISTENCY;
+	*real = local + 1;
+
+    } else if (diff == (afs_uint16)0xffffu) {
+	/* Our peer is using a kvno 1 lower than 'local' */
+	if (local == 0)
+	    return RXGK_INCONSISTENCY;
+	*real = local - 1;
+
+    } else {
+	return RXGK_BADKEYNO;
+    }
+    return 0;
+}
diff --git a/src/rxkad/README.v5 b/src/rxkad/README.v5
index c945fb3f6..7691f8dc9 100644
--- a/src/rxkad/README.v5
+++ b/src/rxkad/README.v5
@@ -17,7 +17,10 @@
 #
 #  All files are modified to build within OpenAFS environment without
 #  any external dependencies. Below is the shell script that is used to
-#  import the code into the four files.
+#  import the code into the four files. Before running this, you must first run
+#  a build from the heimdal tree like so:
+#
+# $ sh autogen.sh && COMPILE_ET=no ./configure && make
 #
 #  All internal symbols are rewritten to _rxkad_v5_.
 #
@@ -33,10 +36,9 @@ htree=/home/lha/src/cvs/heimdal
 hotree=/sources/obj/heimdal
 otree=/sources/afs/openafs-rxkad5
 
-export htree otree
+export htree hotree otree
 
 (cd $htree/lib/asn1 ; \
- echo '#include "asn1_err.h"'; \
  echo '#include <errno.h>'; \
  echo '#include <limits.h>'; \
  cat  timegm.c \
@@ -45,62 +47,55 @@ export htree otree
  der_free.c \
  der_length.c \
  der_copy.c \
-    )  \
+)  \
 | grep -v 'include "der_locl.h"' \
 | grep -v 'include <version.h>' \
 | sed 's!\(RCSID.*\)!/* \1 */!' \
 | sed 's!$Id: !Heimdal: !' \
-| cat > $otree/src/rxkad/v5der.c
+> $otree/src/rxkad/v5der.c
 
 grep -v 'struct units'  $hotree/lib/asn1/krb5_asn1.h \
  | sed s/uint16_t/afs_uint16/ \
  | sed s/uint32_t/afs_uint32/ \
    > $otree/src/rxkad/v5gen.h
 
-cp  $hotree/lib/asn1/der-protos.h \
+cat $hotree/lib/asn1/der-protos.h \
+ | sed 's:[*]/[*]:* /*:g' \
    > $otree/src/rxkad/der-protos.h
 
-cp  $hotree/lib/asn1/asn1_err.h \
-   > $otree/src/rxkad/asn1_err.h
+< $hotree/lib/asn1/asn1_err.h \
+ sed 's!#include <et/com_err[.]h>!struct et_list;!' \
+ > $otree/src/rxkad/asn1_err.h
 
 (cd $hotree/lib/asn1 ; \
- cat asn1_krb5int32.c \
-    asn1_Ticket.c \
-    asn1_AuthorizationDataElement.c \
-    asn1_EncryptedData.c \
-    asn1_PrincipalName.c \
-    asn1_HostAddresses.c \
-    asn1_HostAddress.c \
-    asn1_AuthorizationData.c \
-    asn1_EncTicketPart.c \
-    asn1_KerberosTime.c \
-    asn1_TransitedEncoding.c \
-    asn1_EncryptionKey.c \
-    asn1_TicketFlags.c \
-    asn1_Realm.c \
-    asn1_ENCTYPE.c \
-    asn1_NAME_TYPE.c \
-    ) \
+ echo '#define HEIMDAL_UNUSED_ATTRIBUTE AFS_UNUSED' ; \
+ cat krb5_asn1-priv.h ; \
+ cat asn1_krb5_asn1.x ) \
  | grep -v 'include <krb5-types.h>' \
- | grep -v 'include <krb5_asn1.h>' \
- | grep -v 'include <krb5_asn1-priv.h>' \
+ | grep -v 'include "krb5_asn1.h"' \
+ | grep -v 'include "krb5_asn1-priv.h"' \
  | grep -v 'include <der.h>' \
  | grep -v 'include <der-private.h>' \
  | grep -v 'include <parse_units.h>' \
  | grep -v 'include <asn1-template.h>' \
  | perl \
    -e '$f=0; while(<>){$f=1 if(/struct units/);print if($f eq 0);$f=0 if(/^}/);}' \
- | indent -npro -nbad -bap -nbc -br -ce -cd4 -brs -ncdb -di2 -ndj -nfc1 -i4 -lp -npcs -psl -sc -nsob \
- | cat > $otree/src/rxkad/v5gen.c
+ | sed -n '/^encode_Checksum[(]/q;p' \
+ | head -n -2 \
+ > $otree/src/rxkad/v5gen.c
 
 ( \
  perl -p -e 's/^(encode_|decode_|free_|copy_|length_)([^(]*)\([^)]*\)\n$/#define $1$2 _rxkad_v5_$1$2\n/' $otree/src/rxkad/v5gen.c ; \
-  perl -p -e 's/^(der_|copy_|encode_|decode_|len_|length_|free_|fix_dce|time2generalizedtime)([^(]*).*/#define $1$2 _rxkad_v5_$1$2/' /sources/afs/openafs-krb5/src/rxkad/v5der.c ; \
+  perl -p -e 's/^(der_|copy_|encode_|decode_|len_|length_|free_|fix_dce|time2generalizedtime)([^( ]*).*/#define $1$2 _rxkad_v5_$1$2/' $otree/src/rxkad/v5der.c ; \
   echo '#define TicketFlags2int _rxkad_v5_TicketFlags2int' ; \
   echo '#define int2TicketFlags _rxkad_v5_int2TicketFlags' ; \
   : ) | \
- (grep _rxkad_v5 ; \
-  echo '#ifndef HAVE_TIMEGM' ; \
-  echo '#define timegm	_rxkad_timegm' ; \
-  echo '#endif' ; \
-  :) > $otree/src/rxkad/v5gen-rewrite.h
+  grep _rxkad_v5 \
+  > $otree/src/rxkad/v5gen-rewrite.h
+
+( \
+  < $otree/src/rxkad/v5gen.c \
+  indent -npro -nbad -bap -nbc -br -ce -cd4 -brs -ncdb -di2 -ndj -nfc1 -i4 -lp -npcs -psl -sc -nsob \
+  > $otree/src/rxkad/v5gen.c.indent ; \
+  mv $otree/src/rxkad/v5gen.c.indent $otree/src/rxkad/v5gen.c \
+)
diff --git a/src/rxkad/bg-fcrypt.c b/src/rxkad/bg-fcrypt.c
index 9b69e58df..c88dbd003 100644
--- a/src/rxkad/bg-fcrypt.c
+++ b/src/rxkad/bg-fcrypt.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995 - 2000 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995 - 2000 Kungliga Tekniska HÃ¶gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -109,17 +109,6 @@
 
 #define EFF_NTOHL(x) ntohl(x)
 
-#if 0
-#if defined(__GNUC__) && (defined(i386) || defined(__i386__))
-static inline afs_uint32
-bswap(afs_uint32 x)
-{
-  asm("bswap %0": "=r"(x):"0"(x));
-    return x;
-}
-#endif
-#endif
-
 /*
  * Sboxes for Feistel network derived from
  * /afs/transarc.com/public/afsps/afs.rel31b.export-src/rxkad/sboxes.h
@@ -469,15 +458,8 @@ fc_cbc_dec(const afs_uint32 * in, afs_uint32 * out, afs_int32 length,
 	xor0 = in[0] ^ b8[0];
 	xor1 = in[1] ^ b8[1];
 
-#if 0
-	if (length >= 8)
-	    memcpy(out, b8, 8);
-	else
-	    memcpy(out, b8, length);	/* Don't write to much when length < 8 */
-#else
 	/* If length < 8 we write to much, this is not always ok */
 	memcpy(out, b8, 8);
-#endif
 	out += 2;
 	in += 2;
     }
diff --git a/src/rxkad/crc.c b/src/rxkad/crc.c
index ebed6f8f0..ca0e7db15 100644
--- a/src/rxkad/crc.c
+++ b/src/rxkad/crc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2000 Kungliga Tekniska HÃ¶gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
diff --git a/src/rxkad/der-protos.h b/src/rxkad/der-protos.h
index 6ca5494e8..1a5d3fa3b 100644
--- a/src/rxkad/der-protos.h
+++ b/src/rxkad/der-protos.h
@@ -1,6 +1,7 @@
 /* This is a generated file */
 #ifndef __der_protos_h__
 #define __der_protos_h__
+#ifndef DOXY
 
 #include <stdarg.h>
 
@@ -8,6 +9,18 @@
 extern "C" {
 #endif
 
+int
+asn1_fuzzer_done (void);
+
+int
+asn1_fuzzer_method (const char * /*mode*/);
+
+void
+asn1_fuzzer_next (void);
+
+void
+asn1_fuzzer_reset (void);
+
 int
 copy_heim_any (
 	const heim_any * /*from*/,
@@ -47,6 +60,11 @@ der_copy_general_string (
 	const heim_general_string * /*from*/,
 	heim_general_string * /*to*/);
 
+int
+der_copy_generalized_time (
+	const time_t * /*from*/,
+	time_t * /*to*/);
+
 int
 der_copy_heim_integer (
 	const heim_integer * /*from*/,
@@ -54,8 +72,18 @@ der_copy_heim_integer (
 
 int
 der_copy_ia5_string (
-	const heim_printable_string * /*from*/,
-	heim_printable_string * /*to*/);
+	const heim_ia5_string * /*from*/,
+	heim_ia5_string * /*to*/);
+
+int
+der_copy_integer (
+	const int * /*from*/,
+	int * /*to*/);
+
+int
+der_copy_integer64 (
+	const int64_t * /*from*/,
+	int64_t * /*to*/);
 
 int
 der_copy_octet_string (
@@ -77,6 +105,21 @@ der_copy_universal_string (
 	const heim_universal_string * /*from*/,
 	heim_universal_string * /*to*/);
 
+int
+der_copy_unsigned (
+	const unsigned * /*from*/,
+	unsigned * /*to*/);
+
+int
+der_copy_unsigned64 (
+	const uint64_t * /*from*/,
+	uint64_t * /*to*/);
+
+int
+der_copy_utctime (
+	const time_t * /*from*/,
+	time_t * /*to*/);
+
 int
 der_copy_utf8string (
 	const heim_utf8_string * /*from*/,
@@ -96,12 +139,21 @@ der_free_bmp_string (heim_bmp_string * /*k*/);
 void
 der_free_general_string (heim_general_string * /*str*/);
 
+void
+der_free_generalized_time (time_t * /*t*/);
+
 void
 der_free_heim_integer (heim_integer * /*k*/);
 
 void
 der_free_ia5_string (heim_ia5_string * /*str*/);
 
+void
+der_free_integer (int * /*i*/);
+
+void
+der_free_integer64 (int64_t * /*i*/);
+
 void
 der_free_octet_string (heim_octet_string * /*k*/);
 
@@ -114,6 +166,15 @@ der_free_printable_string (heim_printable_string * /*str*/);
 void
 der_free_universal_string (heim_universal_string * /*k*/);
 
+void
+der_free_unsigned (unsigned * /*u*/);
+
+void
+der_free_unsigned64 (uint64_t * /*u*/);
+
+void
+der_free_utctime (time_t * /*t*/);
+
 void
 der_free_utf8string (heim_utf8_string * /*str*/);
 
@@ -182,6 +243,13 @@ der_get_integer (
 	int * /*ret*/,
 	size_t * /*size*/);
 
+int
+der_get_integer64 (
+	const unsigned char * /*p*/,
+	size_t /*len*/,
+	int64_t * /*ret*/,
+	size_t * /*size*/);
+
 int
 der_get_length (
 	const unsigned char * /*p*/,
@@ -221,7 +289,7 @@ int
 der_get_tag (
 	const unsigned char * /*p*/,
 	size_t /*len*/,
-	Der_class * /*class*/,
+	Der_class * /*cls*/,
 	Der_type * /*type*/,
 	unsigned int * /*tag*/,
 	size_t * /*size*/);
@@ -252,6 +320,13 @@ der_get_unsigned (
 	unsigned * /*ret*/,
 	size_t * /*size*/);
 
+int
+der_get_unsigned64 (
+	const unsigned char * /*p*/,
+	size_t /*len*/,
+	uint64_t * /*ret*/,
+	size_t * /*size*/);
+
 int
 der_get_utctime (
 	const unsigned char * /*p*/,
@@ -303,6 +378,11 @@ der_heim_universal_string_cmp (
 	const heim_universal_string * /*p*/,
 	const heim_universal_string * /*q*/);
 
+int
+der_ia5_string_cmp (
+	const heim_ia5_string * /*p*/,
+	const heim_ia5_string * /*q*/);
+
 size_t
 der_length_bit_string (const heim_bit_string * /*k*/);
 
@@ -330,6 +410,9 @@ der_length_ia5_string (const heim_ia5_string * /*data*/);
 size_t
 der_length_integer (const int * /*data*/);
 
+size_t
+der_length_integer64 (const int64_t * /*data*/);
+
 size_t
 der_length_len (size_t /*len*/);
 
@@ -342,12 +425,18 @@ der_length_oid (const heim_oid * /*k*/);
 size_t
 der_length_printable_string (const heim_printable_string * /*data*/);
 
+size_t
+der_length_tag (unsigned int /*tag*/);
+
 size_t
 der_length_universal_string (const heim_universal_string * /*data*/);
 
 size_t
 der_length_unsigned (const unsigned * /*data*/);
 
+size_t
+der_length_unsigned64 (const uint64_t * /*data*/);
+
 size_t
 der_length_utctime (const time_t * /*t*/);
 
@@ -361,7 +450,7 @@ int
 der_match_tag (
 	const unsigned char * /*p*/,
 	size_t /*len*/,
-	Der_class /*class*/,
+	Der_class /*cls*/,
 	Der_type /*type*/,
 	unsigned int /*tag*/,
 	size_t * /*size*/);
@@ -370,7 +459,7 @@ int
 der_match_tag2 (
 	const unsigned char * /*p*/,
 	size_t /*len*/,
-	Der_class /*class*/,
+	Der_class /*cls*/,
 	Der_type * /*type*/,
 	unsigned int /*tag*/,
 	size_t * /*size*/);
@@ -379,7 +468,7 @@ int
 der_match_tag_and_length (
 	const unsigned char * /*p*/,
 	size_t /*len*/,
-	Der_class /*class*/,
+	Der_class /*cls*/,
 	Der_type * /*type*/,
 	unsigned int /*tag*/,
 	size_t * /*length_ret*/,
@@ -407,6 +496,11 @@ der_print_hex_heim_integer (
 	const heim_integer * /*data*/,
 	char ** /*p*/);
 
+int
+der_printable_string_cmp (
+	const heim_printable_string * /*p*/,
+	const heim_printable_string * /*q*/);
+
 int
 der_put_bit_string (
 	unsigned char * /*p*/,
@@ -463,6 +557,13 @@ der_put_integer (
 	const int * /*v*/,
 	size_t * /*size*/);
 
+int
+der_put_integer64 (
+	unsigned char * /*p*/,
+	size_t /*len*/,
+	const int64_t * /*v*/,
+	size_t * /*size*/);
+
 int
 der_put_length (
 	unsigned char * /*p*/,
@@ -524,6 +625,13 @@ der_put_unsigned (
 	const unsigned * /*v*/,
 	size_t * /*size*/);
 
+int
+der_put_unsigned64 (
+	unsigned char * /*p*/,
+	size_t /*len*/,
+	const uint64_t * /*v*/,
+	size_t * /*size*/);
+
 int
 der_put_utctime (
 	unsigned char * /*p*/,
@@ -580,4 +688,5 @@ length_heim_any_set (const heim_any * /*data*/);
 }
 #endif
 
+#endif /* DOXY */
 #endif /* __der_protos_h__ */
diff --git a/src/rxkad/fcrypt.c b/src/rxkad/fcrypt.c
index a8876aa5f..5488a0dd1 100644
--- a/src/rxkad/fcrypt.c
+++ b/src/rxkad/fcrypt.c
@@ -117,13 +117,8 @@ fc_ecb_encrypt(void * clear, void * cipher,
 #define Byte3 3
 #endif
 
-#if 0
-    memcpy(&L, clear, sizeof(afs_int32));
-    memcpy(&R, clear + 1, sizeof(afs_int32));
-#else
     L = ntohl(*((afs_uint32 *)clear));
     R = ntohl(*((afs_uint32 *)clear + 1));
-#endif
 
     if (encrypt) {
 	INC_RXKAD_STATS(fc_encrypts[ENCRYPT]);
@@ -163,13 +158,8 @@ fc_ecb_encrypt(void * clear, void * cipher,
 	    L ^= P;
 	}
     }
-#if 0
-    memcpy(cipher, &L, sizeof(afs_int32));
-    memcpy(cipher + 1, &R, sizeof(afs_int32));
-#else
     *((afs_int32 *)cipher) = htonl(L);
     *((afs_int32 *)cipher + 1) = htonl(R);
-#endif
     return 0;
 }
 
diff --git a/src/rxkad/rxkad_common.c b/src/rxkad/rxkad_common.c
index 091685420..5f6ba9b1e 100644
--- a/src/rxkad/rxkad_common.c
+++ b/src/rxkad/rxkad_common.c
@@ -364,7 +364,7 @@ rxkad_NewConnection(struct rx_securityClass *aobj,
 
 /* either: called to destroy a connection. */
 
-int
+void
 rxkad_DestroyConnection(struct rx_securityClass *aobj,
 			struct rx_connection *aconn)
 {
@@ -391,7 +391,7 @@ rxkad_DestroyConnection(struct rx_securityClass *aobj,
 	cconn = rx_GetSecurityData(aconn);
 	tcp = (struct rxkad_cprivate *)aobj->privateData;
 	if (!(tcp->type & rxkad_client))
-	    return RXKADINCONSISTENCY;
+	    return; /* something is weird; bail out */
 	if (cconn) {
 	    rx_SetSecurityData(aconn, NULL);
 	    rxi_Free(cconn, sizeof(struct rxkad_cconn));
@@ -400,12 +400,8 @@ rxkad_DestroyConnection(struct rx_securityClass *aobj,
     }
     aobj->refCount--;		/* decrement connection counter */
     if (aobj->refCount <= 0) {
-	afs_int32 code;
-	code = FreeObject(aobj);
-	if (code)
-	    return code;
+	(void)FreeObject(aobj);
     }
-    return 0;
 }
 
 /* either: decode packet */
diff --git a/src/rxkad/rxkad_convert.h b/src/rxkad/rxkad_convert.h
index 8fba9bfb4..cb45ab164 100644
--- a/src/rxkad/rxkad_convert.h
+++ b/src/rxkad/rxkad_convert.h
@@ -26,13 +26,6 @@ ktc_to_cblockptr(struct ktc_encryptionKey *key) {
     return (DES_cblock *)key;
 }
 
-#if 0
-static_inline unsigned char *
-cblockptr_to_cblock(DES_cblock *key) {
-    return (unsigned char *)key;
-}
-#endif
-
 static_inline DES_cblock *
 charptr_to_cblock(char *key) {
     return (DES_cblock *)key;
diff --git a/src/rxkad/rxkad_prototypes.h b/src/rxkad/rxkad_prototypes.h
index a13c9fe4b..e7774a8e8 100644
--- a/src/rxkad/rxkad_prototypes.h
+++ b/src/rxkad/rxkad_prototypes.h
@@ -66,8 +66,8 @@ extern void rxkad_SetLevel(struct rx_connection *conn, rxkad_level level);
 extern int rxkad_Close(struct rx_securityClass *aobj);
 extern int rxkad_NewConnection(struct rx_securityClass *aobj,
 			       struct rx_connection *aconn);
-extern int rxkad_DestroyConnection(struct rx_securityClass *aobj,
-				   struct rx_connection *aconn);
+extern void rxkad_DestroyConnection(struct rx_securityClass *aobj,
+				    struct rx_connection *aconn);
 extern int rxkad_CheckPacket(struct rx_securityClass *aobj,
 			     struct rx_call *acall,
 			     struct rx_packet *apacket);
diff --git a/src/rxkad/test/stress_c.c b/src/rxkad/test/stress_c.c
index e9d83b321..d8c9c0ed7 100644
--- a/src/rxkad/test/stress_c.c
+++ b/src/rxkad/test/stress_c.c
@@ -419,25 +419,9 @@ RunLoadTest(struct clientParms *parms, struct rx_connection *conn)
 	    int b;
 	    kbps = (double)(parms->copiousCalls * n) / (interval * 1000.0);
 	    b = kbps + 0.5;
-#if 0
-	    I just cannot get printing of floats to work on the pmax !
-		!!!printf("%g %d %d %d\n", (float)kbps, b);
-	    printf("%g %d %d %d\n", kbps, b);
-	    fprintf(stdout, "%g %d %d\n", kbps, b);
-	    {
-		char buf[100];
-		buf[sizeof(buf) - 1] = 0;
-		sprintf(buf, "%g %d %d\n", kbps, b);
-		assert(buf[sizeof(buf) - 1] == 0);
-		printf("%s", buf);
-	    }
-#endif
 	    printf
 		("For %lu copious calls, %lu send + %lu recv = %lu bytes each: %d kbytes/sec\n",
 		 parms->copiousCalls, parms->sendLen, parms->recvLen, n, b);
-#if 0
-	    printf("%g\n", kbps);
-#endif
 	}
     }
     return 0;
@@ -1296,10 +1280,6 @@ rxkst_StartClient(struct clientParms *parms)
 
     if (parms->printStats) {
 	rx_PrintStats(stdout);
-#if 0
-	/* use rxdebug style iteration here */
-	rx_PrintPeerStats(stdout, rx_PeerOf(conn));
-#endif
     }
 
     rxs_Release(sc);
diff --git a/src/rxkad/test/stress_s.c b/src/rxkad/test/stress_s.c
index 17939f2c4..2617b5cb3 100644
--- a/src/rxkad/test/stress_s.c
+++ b/src/rxkad/test/stress_s.c
@@ -277,13 +277,7 @@ SRXKST_Copious(struct rx_call *call, u_long inlen, u_long insum,
 	code = RXKST_BADINPUTSUM;
 	goto done;
     }
-#define BIG_PRIME 1257056893	/* 0x4AED2A7d */
-#if 0
-#define NextByte() ((b>24 ? ((seed = seed*BIG_PRIME + BIG_PRIME),b=0) : 0), \
-		    (b +=8), ((seed >> (b-8))&0xff))
-#else
 #define NextByte() (b+=3)
-#endif
     b = 32;
 
     mysum = 0;
diff --git a/src/rxkad/ticket5.c b/src/rxkad/ticket5.c
index 7b8eb5082..ea5ed3ef4 100644
--- a/src/rxkad/ticket5.c
+++ b/src/rxkad/ticket5.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 1996, 1997, 2002 Kungliga Tekniska Högskolan
+ * Copyright (c) 1995, 1996, 1997, 2002 Kungliga Tekniska HÃ¶gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -80,7 +80,17 @@
 #include "v5gen-rewrite.h"
 #include "v5gen.h"
 #include "der.h"
+#include <asn1_err.h>
+
+#if defined(IGNORE_SOME_GCC_WARNINGS) && !defined(__clang__) && __GNUC__ >= 7
+# pragma GCC diagnostic push
+# pragma GCC diagnostic warning "-Wformat-truncation"
+#endif
 #include "v5der.c"
+#if defined(IGNORE_SOME_GCC_WARNINGS) && !defined(__clang__) && __GNUC__ >= 7
+# pragma GCC diagnostic pop
+#endif
+
 #include "v5gen.c"
 
 #define RFC3961_NO_ENUMS
@@ -234,9 +244,9 @@ tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len,
 
     /* Check that the key type really fit into 8 bytes */
     switch (t5.enc_part.etype) {
-    case ETYPE_DES_CBC_CRC:
-    case ETYPE_DES_CBC_MD4:
-    case ETYPE_DES_CBC_MD5:
+    case KRB5_ENCTYPE_DES_CBC_CRC:
+    case KRB5_ENCTYPE_DES_CBC_MD4:
+    case KRB5_ENCTYPE_DES_CBC_MD5:
 	/* check ticket */
 	if (t5.enc_part.cipher.length > sizeof(plain)
 	    || t5.enc_part.cipher.length % 8 != 0)
@@ -263,12 +273,11 @@ tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len,
 	    krb5_free_context(context);
 	    goto unknown_key;
 	}
-	code = krb5_enctype_keybits(context,  t5.enc_part.etype, &keysize);
+	code = krb5_enctype_keysize(context,  t5.enc_part.etype, &keysize);
 	if (code != 0) {
 	    krb5_free_context(context);
 	    goto unknown_key;
 	}
-	keysize = keysize / 8;
 	allocsiz = keysize;
 	keybuf = rxi_Alloc(allocsiz);
 	/* this is not quite a hole for afsconf_GetKeyByTypes. A wrapper
@@ -385,13 +394,8 @@ tkt_DecodeTicket5(char *ticket, afs_int32 ticket_len,
 	*start = decr_part.authtime;
 	if (decr_part.starttime)
 	    *start = *decr_part.starttime;
-#if 0
-	if (*start - now > CLOCK_SKEW || decr_part.flags.invalid)
-	    goto no_auth;
-#else
 	if (decr_part.flags.invalid)
 	    goto no_auth;
-#endif
 	if (now > decr_part.endtime)
 	    goto tkt_expired;
 	*end = decr_part.endtime;
@@ -494,17 +498,17 @@ krb5_des_decrypt(struct ktc_encryptionKey *key, int etype, void *in,
 #define CONFOUNDERSZ 8
 
     switch (etype) {
-    case ETYPE_DES_CBC_CRC:
+    case KRB5_ENCTYPE_DES_CBC_CRC:
 	memcpy(&ivec, key, sizeof(ivec));
 	cksumsz = 4;
 	cksum_func = verify_checksum_crc;
 	break;
-    case ETYPE_DES_CBC_MD4:
+    case KRB5_ENCTYPE_DES_CBC_MD4:
 	memset(&ivec, 0, sizeof(ivec));
 	cksumsz = 16;
 	cksum_func = verify_checksum_md4;
 	break;
-    case ETYPE_DES_CBC_MD5:
+    case KRB5_ENCTYPE_DES_CBC_MD5:
 	memset(&ivec, 0, sizeof(ivec));
 	cksumsz = 16;
 	cksum_func = verify_checksum_md5;
@@ -554,7 +558,7 @@ tkt_MakeTicket5(char *ticket, int *ticketLen, int enctype, int *kvno,
     memset(&data, 0, sizeof(data));
 
     data.flags.transited_policy_checked = 1;
-    data.key.keytype=ETYPE_DES_CBC_CRC;
+    data.key.keytype=KRB5_ENCTYPE_DES_CBC_CRC;
     data.key.keyvalue.data=sessionKey->data;
     data.key.keyvalue.length=8;
     data.crealm=cell;
@@ -615,7 +619,9 @@ cleanup:
     if (cr != NULL)
 	krb5_crypto_destroy(context, cr);
     krb5_free_keyblock_contents(context, &kb);
-    krb5_free_context(context);
+    if (context != NULL) {
+        krb5_free_context(context);
+    }
     rxi_Free(buf, allocsiz);
     if ((code & 0xFFFFFF00) == ERROR_TABLE_BASE_asn1)
 	return RXKADINCONSISTENCY;
@@ -716,16 +722,16 @@ tkt_DeriveDesKey(int enctype, void *keydata, size_t keylen,
 		 struct ktc_encryptionKey *output)
 {
     switch (enctype) {
-    case ETYPE_DES_CBC_CRC:
-    case ETYPE_DES_CBC_MD4:
-    case ETYPE_DES_CBC_MD5:
+    case KRB5_ENCTYPE_DES_CBC_CRC:
+    case KRB5_ENCTYPE_DES_CBC_MD4:
+    case KRB5_ENCTYPE_DES_CBC_MD5:
 	if (keylen != 8)
 	    return 1;
 
 	/* Extract session key */
 	memcpy(output, keydata, 8);
 	break;
-    case ETYPE_NULL:
+    case KRB5_ENCTYPE_NULL:
     case 4:
     case 6:
     case 8:
@@ -739,12 +745,12 @@ tkt_DeriveDesKey(int enctype, void *keydata, size_t keylen,
 	return 1;
 	/*In order to become a "Cryptographic Key" as specified in
 	 * SP800-108, it must be indistinguishable from a random bitstring. */
-    case ETYPE_DES3_CBC_MD5:
-    case ETYPE_OLD_DES3_CBC_SHA1:
-    case ETYPE_DES3_CBC_SHA1:
+    case KRB5_ENCTYPE_DES3_CBC_MD5:
+    case KRB5_ENCTYPE_OLD_DES3_CBC_SHA1:
+    case KRB5_ENCTYPE_DES3_CBC_SHA1:
 	if (compress_parity_bits(keydata, &keylen))
 	    return 1;
-	/* FALLTHROUGH */
+	AFS_FALLTHROUGH;
     default:
 	if (enctype < 0)
 	    return 1;
diff --git a/src/rxkad/v5der.c b/src/rxkad/v5der.c
index 46ac9cedb..2f2ed6acb 100644
--- a/src/rxkad/v5der.c
+++ b/src/rxkad/v5der.c
@@ -1,4 +1,3 @@
-#include "asn1_err.h"
 #include <errno.h>
 #include <limits.h>
 /*
@@ -35,7 +34,7 @@
  */
 
 
-/* RCSID("$Id$"); */
+#define ASN1_MAX_YEAR	2000
 
 static int
 is_leap(unsigned y)
@@ -44,6 +43,10 @@ is_leap(unsigned y)
     return (y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0);
 }
 
+static const unsigned ndays[2][12] ={
+    {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
+    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
+
 /*
  * This is a simplifed version of timegm(3) that doesn't accept out of
  * bound values that timegm(3) normally accepts but those are not
@@ -53,17 +56,20 @@ is_leap(unsigned y)
 time_t
 _der_timegm (struct tm *tm)
 {
-  static const unsigned ndays[2][12] ={
-    {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31},
-    {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}};
   time_t res = 0;
-  unsigned i;
+  int i;
+
+  /*
+   * See comment in _der_gmtime
+   */
+  if (tm->tm_year > ASN1_MAX_YEAR)
+      return 0;
 
   if (tm->tm_year < 0)
       return -1;
   if (tm->tm_mon < 0 || tm->tm_mon > 11)
       return -1;
-  if (tm->tm_mday < 1 || tm->tm_mday > ndays[is_leap(tm->tm_year)][tm->tm_mon])
+  if (tm->tm_mday < 1 || tm->tm_mday > (int)ndays[is_leap(tm->tm_year)][tm->tm_mon])
       return -1;
   if (tm->tm_hour < 0 || tm->tm_hour > 23)
       return -1;
@@ -86,6 +92,49 @@ _der_timegm (struct tm *tm)
   res += tm->tm_sec;
   return res;
 }
+
+struct tm *
+_der_gmtime(time_t t, struct tm *tm)
+{
+    time_t secday = t % (3600 * 24);
+    time_t days = t / (3600 * 24);
+
+    memset(tm, 0, sizeof(*tm));
+
+    tm->tm_sec = secday % 60;
+    tm->tm_min = (secday % 3600) / 60;
+    tm->tm_hour = (int)(secday / 3600);
+
+    /*
+     * Refuse to calculate time ~ 2000 years into the future, this is
+     * not possible for systems where time_t is a int32_t, however,
+     * when time_t is a int64_t, that can happen, and this becomes a
+     * denial of sevice.
+     */
+    if (days > (ASN1_MAX_YEAR * 365))
+	return NULL;
+
+    tm->tm_year = 70;
+    while(1) {
+	unsigned dayinyear = (is_leap(tm->tm_year) ? 366 : 365);
+	if (days < dayinyear)
+	    break;
+	tm->tm_year += 1;
+	days -= dayinyear;
+    }
+    tm->tm_mon = 0;
+
+    while (1) {
+	unsigned daysinmonth = ndays[is_leap(tm->tm_year)][tm->tm_mon];
+	if (days < daysinmonth)
+	    break;
+	days -= daysinmonth;
+	tm->tm_mon++;
+    }
+    tm->tm_mday = (int)(days + 1);
+
+    return tm;
+}
 /*
  * Copyright (c) 1997 - 2007 Kungliga Tekniska HÃ¶gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
@@ -135,9 +184,28 @@ der_get_unsigned (const unsigned char *p, size_t len,
     unsigned val = 0;
     size_t oldlen = len;
 
-    if (len == sizeof(unsigned) + 1 && p[0] == 0)
+    if (len == sizeof(val) + 1 && p[0] == 0)
 	;
-    else if (len > sizeof(unsigned))
+    else if (len > sizeof(val))
+	return ASN1_OVERRUN;
+
+    while (len--)
+	val = val * 256 + *p++;
+    *ret = val;
+    if(size) *size = oldlen;
+    return 0;
+}
+
+int
+der_get_unsigned64 (const unsigned char *p, size_t len,
+                   uint64_t *ret, size_t *size)
+{
+    uint64_t val = 0;
+    size_t oldlen = len;
+
+    if (len == sizeof(val) + 1 && p[0] == 0)
+       ;
+    else if (len > sizeof(val))
 	return ASN1_OVERRUN;
 
     while (len--)
@@ -154,7 +222,7 @@ der_get_integer (const unsigned char *p, size_t len,
     int val = 0;
     size_t oldlen = len;
 
-    if (len > sizeof(int))
+    if (len > sizeof(val))
 	return ASN1_OVERRUN;
 
     if (len > 0) {
@@ -167,6 +235,27 @@ der_get_integer (const unsigned char *p, size_t len,
     return 0;
 }
 
+int
+der_get_integer64 (const unsigned char *p, size_t len,
+		   int64_t *ret, size_t *size)
+{
+    int64_t val = 0;
+    size_t oldlen = len;
+
+    if (len > sizeof(val))
+        return ASN1_OVERRUN;
+
+    if (len > 0) {
+       val = (signed char)*p++;
+       while (--len)
+           val = val * 256 + *p++;
+    }
+    *ret = val;
+    if(size) *size = oldlen;
+    return 0;
+}
+
+
 int
 der_get_length (const unsigned char *p, size_t len,
 		size_t *val, size_t *size)
@@ -228,20 +317,24 @@ der_get_general_string (const unsigned char *p, size_t len,
 	 * an strings in the NEED_PREAUTH case that includes a
 	 * trailing NUL.
 	 */
-	while (p1 - p < len && *p1 == '\0')
+	while ((size_t)(p1 - p) < len && *p1 == '\0')
 	    p1++;
-       if (p1 - p != len)
+	if ((size_t)(p1 - p) != len) {
+	    *str = NULL;
 	    return ASN1_BAD_CHARACTER;
+	}
     }
-    if (len > len + 1)
+    if (len == SIZE_MAX) {
+	*str = NULL;
 	return ASN1_BAD_LENGTH;
+    }
 
-    s = malloc (len + 1);
+    *str = s = malloc (len + 1);
     if (s == NULL)
 	return ENOMEM;
     memcpy (s, p, len);
     s[len] = '\0';
-    *str = s;
+
     if(size) *size = len;
     return 0;
 }
@@ -253,18 +346,34 @@ der_get_utf8string (const unsigned char *p, size_t len,
     return der_get_general_string(p, len, str, size);
 }
 
+#define gen_data_zero(_data) \
+	do { (_data)->length = 0; (_data)->data = NULL; } while(0)
+
 int
-der_get_printable_string (const unsigned char *p, size_t len,
-			  heim_printable_string *str, size_t *size)
+der_get_printable_string(const unsigned char *p, size_t len,
+			 heim_printable_string *str, size_t *size)
 {
-    return der_get_general_string(p, len, str, size);
+    if (len == SIZE_MAX) {
+	gen_data_zero(str);
+	return ASN1_BAD_LENGTH;
+    }
+    str->length = len;
+    str->data = malloc(len + 1);
+    if (str->data == NULL) {
+	gen_data_zero(str);
+	return ENOMEM;
+    }
+    memcpy(str->data, p, len);
+    ((char *)str->data)[len] = '\0';
+    if(size) *size = len;
+    return 0;
 }
 
 int
-der_get_ia5_string (const unsigned char *p, size_t len,
-		    heim_ia5_string *str, size_t *size)
+der_get_ia5_string(const unsigned char *p, size_t len,
+		   heim_ia5_string *str, size_t *size)
 {
-    return der_get_general_string(p, len, str, size);
+    return der_get_printable_string(p, len, str, size);
 }
 
 int
@@ -273,14 +382,20 @@ der_get_bmp_string (const unsigned char *p, size_t len,
 {
     size_t i;
 
-    if (len & 1)
+    if (len & 1) {
+	gen_data_zero(data);
 	return ASN1_BAD_FORMAT;
+    }
     data->length = len / 2;
-    if (data->length > UINT_MAX/sizeof(data->data[0]))
+    if (data->length > UINT_MAX/sizeof(data->data[0])) {
+	gen_data_zero(data);
 	return ERANGE;
+    }
     data->data = malloc(data->length * sizeof(data->data[0]));
-    if (data->data == NULL && data->length != 0)
+    if (data->data == NULL && data->length != 0) {
+	gen_data_zero(data);
 	return ENOMEM;
+    }
 
     for (i = 0; i < data->length; i++) {
 	data->data[i] = (p[0] << 8) | p[1];
@@ -288,8 +403,7 @@ der_get_bmp_string (const unsigned char *p, size_t len,
 	/* check for NUL in the middle of the string */
 	if (data->data[i] == 0 && i != (data->length - 1)) {
 	    free(data->data);
-	    data->data = NULL;
-	    data->length = 0;
+	    gen_data_zero(data);
 	    return ASN1_BAD_CHARACTER;
 	}
     }
@@ -304,14 +418,20 @@ der_get_universal_string (const unsigned char *p, size_t len,
 {
     size_t i;
 
-    if (len & 3)
+    if (len & 3) {
+	gen_data_zero(data);
 	return ASN1_BAD_FORMAT;
+    }
     data->length = len / 4;
-    if (data->length > UINT_MAX/sizeof(data->data[0]))
+    if (data->length > UINT_MAX/sizeof(data->data[0])) {
+	gen_data_zero(data);
 	return ERANGE;
+    }
     data->data = malloc(data->length * sizeof(data->data[0]));
-    if (data->data == NULL && data->length != 0)
+    if (data->data == NULL && data->length != 0) {
+	gen_data_zero(data);
 	return ENOMEM;
+    }
 
     for (i = 0; i < data->length; i++) {
 	data->data[i] = (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
@@ -319,8 +439,7 @@ der_get_universal_string (const unsigned char *p, size_t len,
 	/* check for NUL in the middle of the string */
 	if (data->data[i] == 0 && i != (data->length - 1)) {
 	    free(data->data);
-	    data->data = NULL;
-	    data->length = 0;
+	    gen_data_zero(data);
 	    return ASN1_BAD_CHARACTER;
 	}
     }
@@ -354,7 +473,7 @@ der_get_octet_string_ber (const unsigned char *p, size_t len,
 {
     int e;
     Der_type type;
-    Der_class class;
+    Der_class cls;
     unsigned int tag, depth = 0;
     size_t l, datalen, oldlen = len;
 
@@ -362,9 +481,9 @@ der_get_octet_string_ber (const unsigned char *p, size_t len,
     data->data = NULL;
 
     while (len) {
-	e = der_get_tag (p, len, &class, &type, &tag, &l);
+	e = der_get_tag (p, len, &cls, &type, &tag, &l);
 	if (e) goto out;
-	if (class != ASN1_C_UNIV) {
+	if (cls != ASN1_C_UNIV) {
 	    e = ASN1_BAD_ID;
 	    goto out;
 	}
@@ -510,7 +629,7 @@ der_get_time (const unsigned char *p, size_t len,
     char *times;
     int e;
 
-    if (len > len + 1 || len == 0)
+    if (len == SIZE_MAX || len == 0)
 	return ASN1_BAD_LENGTH;
 
     times = malloc(len + 1);
@@ -548,7 +667,7 @@ der_get_oid (const unsigned char *p, size_t len,
     if (len < 1)
 	return ASN1_OVERRUN;
 
-    if (len > len + 1)
+    if (len == SIZE_MAX)
 	return ASN1_BAD_LENGTH;
 
     if (len + 1 > UINT_MAX/sizeof(data->components[0]))
@@ -588,13 +707,13 @@ der_get_oid (const unsigned char *p, size_t len,
 
 int
 der_get_tag (const unsigned char *p, size_t len,
-	     Der_class *class, Der_type *type,
+	     Der_class *cls, Der_type *type,
 	     unsigned int *tag, size_t *size)
 {
     size_t ret = 0;
     if (len < 1)
 	return ASN1_OVERRUN;
-    *class = (Der_class)(((*p) >> 6) & 0x03);
+    *cls = (Der_class)(((*p) >> 6) & 0x03);
     *type = (Der_type)(((*p) >> 5) & 0x01);
     *tag = (*p) & 0x1f;
     p++; len--; ret++;
@@ -620,13 +739,13 @@ der_get_tag (const unsigned char *p, size_t len,
 
 int
 der_match_tag (const unsigned char *p, size_t len,
-	       Der_class class, Der_type type,
+	       Der_class cls, Der_type type,
 	       unsigned int tag, size_t *size)
 {
     Der_type thistype;
     int e;
 
-    e = der_match_tag2(p, len, class, &thistype, tag, size);
+    e = der_match_tag2(p, len, cls, &thistype, tag, size);
     if (e) return e;
     if (thistype != type) return ASN1_BAD_ID;
     return 0;
@@ -634,7 +753,7 @@ der_match_tag (const unsigned char *p, size_t len,
 
 int
 der_match_tag2 (const unsigned char *p, size_t len,
-		Der_class class, Der_type *type,
+		Der_class cls, Der_type *type,
 		unsigned int tag, size_t *size)
 {
     size_t l;
@@ -644,7 +763,7 @@ der_match_tag2 (const unsigned char *p, size_t len,
 
     e = der_get_tag (p, len, &thisclass, type, &thistag, &l);
     if (e) return e;
-    if (class != thisclass)
+    if (cls != thisclass)
 	return ASN1_BAD_ID;
     if(tag > thistag)
 	return ASN1_MISPLACED_FIELD;
@@ -656,13 +775,13 @@ der_match_tag2 (const unsigned char *p, size_t len,
 
 int
 der_match_tag_and_length (const unsigned char *p, size_t len,
-			  Der_class class, Der_type *type, unsigned int tag,
+			  Der_class cls, Der_type *type, unsigned int tag,
 			  size_t *length_ret, size_t *size)
 {
     size_t l, ret = 0;
     int e;
 
-    e = der_match_tag2 (p, len, class, type, tag, &l);
+    e = der_match_tag2 (p, len, cls, type, tag, &l);
     if (e) return e;
     p += l;
     len -= l;
@@ -713,14 +832,19 @@ der_get_bit_string (const unsigned char *p, size_t len,
      * any of them will cause a interger overrun */
     if ((len - 1) >> (sizeof(len) * 8 - 3))
 	return ASN1_OVERRUN;
-    data->length = (len - 1) * 8;
-    data->data = malloc(len - 1);
-    if (data->data == NULL && (len - 1) != 0)
-	return ENOMEM;
-    /* copy data is there is data to copy */
-    if (len - 1 != 0) {
-      memcpy (data->data, p + 1, len - 1);
-      data->length -= p[0];
+    /*
+     * If there is data to copy, do that now.
+     */
+    if (len - 1 > 0) {
+	data->length = (len - 1) * 8;
+	data->data = malloc(len - 1);
+	if (data->data == NULL)
+	    return ENOMEM;
+	memcpy (data->data, p + 1, len - 1);
+	data->length -= p[0];
+    } else {
+	data->data = NULL;
+	data->length = 0;
     }
     if(size) *size = len;
     return 0;
@@ -801,6 +925,38 @@ der_put_unsigned (unsigned char *p, size_t len, const unsigned *v, size_t *size)
     }
 }
 
+int
+der_put_unsigned64 (unsigned char *p, size_t len, const uint64_t *v, size_t *size)
+{
+    unsigned char *base = p;
+    uint64_t val = *v;
+
+    if (val) {
+       while (len > 0 && val) {
+           *p-- = val % 256;
+           val /= 256;
+           --len;
+       }
+       if (val != 0)
+           return ASN1_OVERFLOW;
+       else {
+           if(p[1] >= 128) {
+               if(len < 1)
+                   return ASN1_OVERFLOW;
+               *p-- = 0;
+           }
+           *size = base - p;
+           return 0;
+       }
+    } else if (len < 1)
+       return ASN1_OVERFLOW;
+    else {
+       *p    = 0;
+       *size = 1;
+       return 0;
+    }
+}
+
 int
 der_put_integer (unsigned char *p, size_t len, const int *v, size_t *size)
 {
@@ -841,6 +997,46 @@ der_put_integer (unsigned char *p, size_t len, const int *v, size_t *size)
     return 0;
 }
 
+int
+der_put_integer64 (unsigned char *p, size_t len, const int64_t *v, size_t *size)
+{
+    unsigned char *base = p;
+    int64_t val = *v;
+
+    if(val >= 0) {
+       do {
+           if(len < 1)
+               return ASN1_OVERFLOW;
+           *p-- = val % 256;
+           len--;
+           val /= 256;
+       } while(val);
+       if(p[1] >= 128) {
+           if(len < 1)
+               return ASN1_OVERFLOW;
+           *p-- = 0;
+           len--;
+       }
+    } else {
+       val = ~val;
+       do {
+           if(len < 1)
+               return ASN1_OVERFLOW;
+           *p-- = ~(val % 256);
+           len--;
+           val /= 256;
+       } while(val);
+       if(p[1] < 128) {
+           if(len < 1)
+               return ASN1_OVERFLOW;
+           *p-- = 0xff;
+           len--;
+       }
+    }
+    *size = base - p;
+    return 0;
+}
+
 
 int
 der_put_length (unsigned char *p, size_t len, size_t val, size_t *size)
@@ -907,14 +1103,14 @@ int
 der_put_printable_string (unsigned char *p, size_t len,
 			  const heim_printable_string *str, size_t *size)
 {
-    return der_put_general_string(p, len, str, size);
+    return der_put_octet_string(p, len, str, size);
 }
 
 int
 der_put_ia5_string (unsigned char *p, size_t len,
 		    const heim_ia5_string *str, size_t *size)
 {
-    return der_put_general_string(p, len, str, size);
+    return der_put_octet_string(p, len, str, size);
 }
 
 int
@@ -993,7 +1189,8 @@ der_put_heim_integer (unsigned char *p, size_t len,
     len -= data->length;
 
     if (data->negative) {
-	int i, carry;
+	ssize_t i;
+	int carry;
 	for (i = data->length - 1, carry = 1; i >= 0; i--) {
 	    *p = buf[i] ^ 0xff;
 	    if (carry)
@@ -1069,7 +1266,7 @@ der_put_oid (unsigned char *p, size_t len,
 	     const heim_oid *data, size_t *size)
 {
     unsigned char *base = p;
-    int n;
+    size_t n;
 
     for (n = data->length - 1; n >= 2; --n) {
 	unsigned u = data->components[n];
@@ -1152,22 +1349,25 @@ der_put_length_and_tag (unsigned char *p, size_t len, size_t len_val,
 int
 _heim_time2generalizedtime (time_t t, heim_octet_string *s, int gtimep)
 {
-     struct tm *tm;
+     struct tm tm;
      const size_t len = gtimep ? 15 : 13;
 
+     s->data = NULL;
+     s->length = 0;
+     if (_der_gmtime(t, &tm) == NULL)
+	 return ASN1_BAD_TIMEFORMAT;
      s->data = malloc(len + 1);
      if (s->data == NULL)
 	 return ENOMEM;
      s->length = len;
-     tm = gmtime (&t);
      if (gtimep)
 	 snprintf (s->data, len + 1, "%04d%02d%02d%02d%02d%02dZ",
-		   tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
-		   tm->tm_hour, tm->tm_min, tm->tm_sec);
+		   tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+		   tm.tm_hour, tm.tm_min, tm.tm_sec);
      else
 	 snprintf (s->data, len + 1, "%02d%02d%02d%02d%02d%02dZ",
-		   tm->tm_year % 100, tm->tm_mon + 1, tm->tm_mday,
-		   tm->tm_hour, tm->tm_min, tm->tm_sec);
+		   tm.tm_year % 100, tm.tm_mon + 1, tm.tm_mday,
+		   tm.tm_hour, tm.tm_min, tm.tm_sec);
 
      return 0;
 }
@@ -1193,14 +1393,14 @@ der_put_bit_string (unsigned char *p, size_t len,
 int
 _heim_der_set_sort(const void *a1, const void *a2)
 {
-    const struct heim_octet_string *s1 = a1, *s2 = a2;
+    const heim_octet_string *s1 = a1, *s2 = a2;
     int ret;
 
     ret = memcmp(s1->data, s2->data,
 		 s1->length < s2->length ? s1->length : s2->length);
     if(ret)
 	return ret;
-    return s1->length - s2->length;
+    return (int)(s1->length - s2->length);
 }
 /*
  * Copyright (c) 1997 - 2005 Kungliga Tekniska HÃ¶gskolan
@@ -1253,12 +1453,24 @@ der_free_integer (int *i)
     *i = 0;
 }
 
+void
+der_free_integer64 (int64_t *i)
+{
+    *i = 0;
+}
+
 void
 der_free_unsigned (unsigned *u)
 {
     *u = 0;
 }
 
+void
+der_free_unsigned64 (uint64_t *u)
+{
+    *u = 0;
+}
+
 void
 der_free_generalized_time(time_t *t)
 {
@@ -1282,15 +1494,13 @@ der_free_utf8string (heim_utf8_string *str)
 void
 der_free_printable_string (heim_printable_string *str)
 {
-    free(*str);
-    *str = NULL;
+    der_free_octet_string(str);
 }
 
 void
 der_free_ia5_string (heim_ia5_string *str)
 {
-    free(*str);
-    *str = NULL;
+    der_free_octet_string(str);
 }
 
 void
@@ -1403,6 +1613,24 @@ _heim_len_unsigned (unsigned val)
     return ret;
 }
 
+size_t
+_heim_len_unsigned64 (uint64_t val)
+{
+    size_t ret = 0;
+    int last_val_gt_128;
+
+    do {
+	++ret;
+	last_val_gt_128 = (val >= 128);
+	val /= 256;
+    } while (val);
+
+    if(last_val_gt_128)
+	ret++;
+
+    return ret;
+}
+
 size_t
 _heim_len_int (int val)
 {
@@ -1430,11 +1658,38 @@ _heim_len_int (int val)
     return ret;
 }
 
+size_t
+_heim_len_int64 (int64_t val)
+{
+    unsigned char q;
+    size_t ret = 0;
+
+    if (val >= 0) {
+	do {
+	    q = val % 256;
+	    ret++;
+	    val /= 256;
+	} while(val);
+	if(q >= 128)
+	    ret++;
+    } else {
+	val = ~val;
+	do {
+	    q = ~(val % 256);
+	    ret++;
+	    val /= 256;
+	} while(val);
+	if(q < 128)
+	    ret++;
+    }
+    return ret;
+}
+
 static size_t
 len_oid (const heim_oid *oid)
 {
     size_t ret = 1;
-    int n;
+    size_t n;
 
     for (n = 2; n < oid->length; ++n) {
 	unsigned u = oid->components[n];
@@ -1482,12 +1737,24 @@ der_length_integer (const int *data)
     return _heim_len_int (*data);
 }
 
+size_t
+der_length_integer64 (const int64_t *data)
+{
+    return _heim_len_int64 (*data);
+}
+
 size_t
 der_length_unsigned (const unsigned *data)
 {
     return _heim_len_unsigned(*data);
 }
 
+size_t
+der_length_unsigned64 (const uint64_t *data)
+{
+    return _heim_len_unsigned64(*data);
+}
+
 size_t
 der_length_enumerated (const unsigned *data)
 {
@@ -1509,13 +1776,13 @@ der_length_utf8string (const heim_utf8_string *data)
 size_t
 der_length_printable_string (const heim_printable_string *data)
 {
-    return strlen(*data);
+    return data->length;
 }
 
 size_t
 der_length_ia5_string (const heim_ia5_string *data)
 {
-    return strlen(*data);
+    return data->length;
 }
 
 size_t
@@ -1649,6 +1916,13 @@ der_copy_integer (const int *from, int *to)
     return 0;
 }
 
+int
+der_copy_integer64 (const int64_t *from, int64_t *to)
+{
+    *to = *from;
+    return 0;
+}
+
 int
 der_copy_unsigned (const unsigned *from, unsigned *to)
 {
@@ -1656,6 +1930,13 @@ der_copy_unsigned (const unsigned *from, unsigned *to)
     return 0;
 }
 
+int
+der_copy_unsigned64 (const uint64_t *from, uint64_t *to)
+{
+    *to = *from;
+    return 0;
+}
+
 int
 der_copy_generalized_time (const time_t *from, time_t *to)
 {
@@ -1680,14 +1961,20 @@ int
 der_copy_printable_string (const heim_printable_string *from,
 		       heim_printable_string *to)
 {
-    return der_copy_general_string(from, to);
+    to->length = from->length;
+    to->data   = malloc(to->length + 1);
+    if(to->data == NULL)
+	return ENOMEM;
+    memcpy(to->data, from->data, to->length);
+    ((char *)to->data)[to->length] = '\0';
+    return 0;
 }
 
 int
-der_copy_ia5_string (const heim_printable_string *from,
-		     heim_printable_string *to)
+der_copy_ia5_string (const heim_ia5_string *from,
+		     heim_ia5_string *to)
 {
-    return der_copy_general_string(from, to);
+    return der_copy_printable_string(from, to);
 }
 
 int
diff --git a/src/rxkad/v5gen-rewrite.h b/src/rxkad/v5gen-rewrite.h
index ce9220f08..36c7f9df4 100644
--- a/src/rxkad/v5gen-rewrite.h
+++ b/src/rxkad/v5gen-rewrite.h
@@ -1,219 +1,244 @@
+#define encode_NAME_TYPE _rxkad_v5_encode_NAME_TYPE
+#define decode_NAME_TYPE _rxkad_v5_decode_NAME_TYPE
+#define free_NAME_TYPE _rxkad_v5_free_NAME_TYPE
+#define length_NAME_TYPE _rxkad_v5_length_NAME_TYPE
+#define copy_NAME_TYPE _rxkad_v5_copy_NAME_TYPE
+#define encode_MESSAGE_TYPE _rxkad_v5_encode_MESSAGE_TYPE
+#define decode_MESSAGE_TYPE _rxkad_v5_decode_MESSAGE_TYPE
+#define free_MESSAGE_TYPE _rxkad_v5_free_MESSAGE_TYPE
+#define length_MESSAGE_TYPE _rxkad_v5_length_MESSAGE_TYPE
+#define copy_MESSAGE_TYPE _rxkad_v5_copy_MESSAGE_TYPE
+#define encode_PADATA_TYPE _rxkad_v5_encode_PADATA_TYPE
+#define decode_PADATA_TYPE _rxkad_v5_decode_PADATA_TYPE
+#define free_PADATA_TYPE _rxkad_v5_free_PADATA_TYPE
+#define length_PADATA_TYPE _rxkad_v5_length_PADATA_TYPE
+#define copy_PADATA_TYPE _rxkad_v5_copy_PADATA_TYPE
+#define encode_AUTHDATA_TYPE _rxkad_v5_encode_AUTHDATA_TYPE
+#define decode_AUTHDATA_TYPE _rxkad_v5_decode_AUTHDATA_TYPE
+#define free_AUTHDATA_TYPE _rxkad_v5_free_AUTHDATA_TYPE
+#define length_AUTHDATA_TYPE _rxkad_v5_length_AUTHDATA_TYPE
+#define copy_AUTHDATA_TYPE _rxkad_v5_copy_AUTHDATA_TYPE
+#define encode_CKSUMTYPE _rxkad_v5_encode_CKSUMTYPE
+#define decode_CKSUMTYPE _rxkad_v5_decode_CKSUMTYPE
+#define free_CKSUMTYPE _rxkad_v5_free_CKSUMTYPE
+#define length_CKSUMTYPE _rxkad_v5_length_CKSUMTYPE
+#define copy_CKSUMTYPE _rxkad_v5_copy_CKSUMTYPE
+#define encode_ENCTYPE _rxkad_v5_encode_ENCTYPE
+#define decode_ENCTYPE _rxkad_v5_decode_ENCTYPE
+#define free_ENCTYPE _rxkad_v5_free_ENCTYPE
+#define length_ENCTYPE _rxkad_v5_length_ENCTYPE
+#define copy_ENCTYPE _rxkad_v5_copy_ENCTYPE
+#define encode_krb5uint32 _rxkad_v5_encode_krb5uint32
+#define decode_krb5uint32 _rxkad_v5_decode_krb5uint32
+#define free_krb5uint32 _rxkad_v5_free_krb5uint32
+#define length_krb5uint32 _rxkad_v5_length_krb5uint32
+#define copy_krb5uint32 _rxkad_v5_copy_krb5uint32
 #define encode_krb5int32 _rxkad_v5_encode_krb5int32
 #define decode_krb5int32 _rxkad_v5_decode_krb5int32
 #define free_krb5int32 _rxkad_v5_free_krb5int32
 #define length_krb5int32 _rxkad_v5_length_krb5int32
 #define copy_krb5int32 _rxkad_v5_copy_krb5int32
-#define encode_AuthorizationDataElement _rxkad_v5_encode_AuthorizationDataElement
-#define decode_AuthorizationDataElement _rxkad_v5_decode_AuthorizationDataElement
-#define free_AuthorizationDataElement _rxkad_v5_free_AuthorizationDataElement
-#define length_AuthorizationDataElement _rxkad_v5_length_AuthorizationDataElement
-#define copy_AuthorizationDataElement _rxkad_v5_copy_AuthorizationDataElement
-#define encode_Ticket _rxkad_v5_encode_Ticket
-#define decode_Ticket _rxkad_v5_decode_Ticket
-#define free_Ticket _rxkad_v5_free_Ticket
-#define length_Ticket _rxkad_v5_length_Ticket
-#define copy_Ticket _rxkad_v5_copy_Ticket
-#define encode_EncryptedData _rxkad_v5_encode_EncryptedData
-#define decode_EncryptedData _rxkad_v5_decode_EncryptedData
-#define free_EncryptedData _rxkad_v5_free_EncryptedData
-#define length_EncryptedData _rxkad_v5_length_EncryptedData
-#define copy_EncryptedData _rxkad_v5_copy_EncryptedData
+#define encode_KerberosString _rxkad_v5_encode_KerberosString
+#define decode_KerberosString _rxkad_v5_decode_KerberosString
+#define free_KerberosString _rxkad_v5_free_KerberosString
+#define length_KerberosString _rxkad_v5_length_KerberosString
+#define copy_KerberosString _rxkad_v5_copy_KerberosString
+#define encode_Realm _rxkad_v5_encode_Realm
+#define decode_Realm _rxkad_v5_decode_Realm
+#define free_Realm _rxkad_v5_free_Realm
+#define length_Realm _rxkad_v5_length_Realm
+#define copy_Realm _rxkad_v5_copy_Realm
 #define encode_PrincipalName _rxkad_v5_encode_PrincipalName
 #define decode_PrincipalName _rxkad_v5_decode_PrincipalName
 #define free_PrincipalName _rxkad_v5_free_PrincipalName
 #define length_PrincipalName _rxkad_v5_length_PrincipalName
 #define copy_PrincipalName _rxkad_v5_copy_PrincipalName
-#define encode_HostAddresses _rxkad_v5_encode_HostAddresses
-#define decode_HostAddresses _rxkad_v5_decode_HostAddresses
-#define free_HostAddresses _rxkad_v5_free_HostAddresses
-#define length_HostAddresses _rxkad_v5_length_HostAddresses
-#define copy_HostAddresses _rxkad_v5_copy_HostAddresses
+#define encode_Principal _rxkad_v5_encode_Principal
+#define decode_Principal _rxkad_v5_decode_Principal
+#define free_Principal _rxkad_v5_free_Principal
+#define length_Principal _rxkad_v5_length_Principal
+#define copy_Principal _rxkad_v5_copy_Principal
+#define encode_Principals _rxkad_v5_encode_Principals
+#define decode_Principals _rxkad_v5_decode_Principals
+#define free_Principals _rxkad_v5_free_Principals
+#define length_Principals _rxkad_v5_length_Principals
+#define copy_Principals _rxkad_v5_copy_Principals
 #define encode_HostAddress _rxkad_v5_encode_HostAddress
 #define decode_HostAddress _rxkad_v5_decode_HostAddress
 #define free_HostAddress _rxkad_v5_free_HostAddress
 #define length_HostAddress _rxkad_v5_length_HostAddress
 #define copy_HostAddress _rxkad_v5_copy_HostAddress
-#define add_AuthorizationData _rxkad_v5_add_AuthorizationData
-#define remove_AuthorizationData _rxkad_v5_remove_AuthorizationData
-#define encode_AuthorizationData _rxkad_v5_encode_AuthorizationData
-#define decode_AuthorizationData _rxkad_v5_decode_AuthorizationData
-#define free_AuthorizationData _rxkad_v5_free_AuthorizationData
-#define length_AuthorizationData _rxkad_v5_length_AuthorizationData
-#define copy_AuthorizationData _rxkad_v5_copy_AuthorizationData
-#define encode_EncTicketPart _rxkad_v5_encode_EncTicketPart
-#define decode_EncTicketPart _rxkad_v5_decode_EncTicketPart
-#define free_EncTicketPart _rxkad_v5_free_EncTicketPart
-#define length_EncTicketPart _rxkad_v5_length_EncTicketPart
-#define copy_EncTicketPart _rxkad_v5_copy_EncTicketPart
+#define encode_HostAddresses _rxkad_v5_encode_HostAddresses
+#define decode_HostAddresses _rxkad_v5_decode_HostAddresses
+#define free_HostAddresses _rxkad_v5_free_HostAddresses
+#define length_HostAddresses _rxkad_v5_length_HostAddresses
+#define copy_HostAddresses _rxkad_v5_copy_HostAddresses
 #define encode_KerberosTime _rxkad_v5_encode_KerberosTime
 #define decode_KerberosTime _rxkad_v5_decode_KerberosTime
 #define free_KerberosTime _rxkad_v5_free_KerberosTime
 #define length_KerberosTime _rxkad_v5_length_KerberosTime
 #define copy_KerberosTime _rxkad_v5_copy_KerberosTime
-#define encode_TransitedEncoding _rxkad_v5_encode_TransitedEncoding
-#define decode_TransitedEncoding _rxkad_v5_decode_TransitedEncoding
-#define free_TransitedEncoding _rxkad_v5_free_TransitedEncoding
-#define length_TransitedEncoding _rxkad_v5_length_TransitedEncoding
-#define copy_TransitedEncoding _rxkad_v5_copy_TransitedEncoding
-#define encode_EncryptionKey _rxkad_v5_encode_EncryptionKey
-#define decode_EncryptionKey _rxkad_v5_decode_EncryptionKey
-#define free_EncryptionKey _rxkad_v5_free_EncryptionKey
-#define length_EncryptionKey _rxkad_v5_length_EncryptionKey
-#define copy_EncryptionKey _rxkad_v5_copy_EncryptionKey
+#define encode_AuthorizationDataElement _rxkad_v5_encode_AuthorizationDataElement
+#define decode_AuthorizationDataElement _rxkad_v5_decode_AuthorizationDataElement
+#define free_AuthorizationDataElement _rxkad_v5_free_AuthorizationDataElement
+#define length_AuthorizationDataElement _rxkad_v5_length_AuthorizationDataElement
+#define copy_AuthorizationDataElement _rxkad_v5_copy_AuthorizationDataElement
+#define encode_AuthorizationData _rxkad_v5_encode_AuthorizationData
+#define decode_AuthorizationData _rxkad_v5_decode_AuthorizationData
+#define free_AuthorizationData _rxkad_v5_free_AuthorizationData
+#define length_AuthorizationData _rxkad_v5_length_AuthorizationData
+#define copy_AuthorizationData _rxkad_v5_copy_AuthorizationData
+#define encode_APOptions _rxkad_v5_encode_APOptions
+#define decode_APOptions _rxkad_v5_decode_APOptions
+#define free_APOptions _rxkad_v5_free_APOptions
+#define length_APOptions _rxkad_v5_length_APOptions
+#define copy_APOptions _rxkad_v5_copy_APOptions
 #define encode_TicketFlags _rxkad_v5_encode_TicketFlags
 #define decode_TicketFlags _rxkad_v5_decode_TicketFlags
 #define free_TicketFlags _rxkad_v5_free_TicketFlags
 #define length_TicketFlags _rxkad_v5_length_TicketFlags
 #define copy_TicketFlags _rxkad_v5_copy_TicketFlags
-#define encode_Realm _rxkad_v5_encode_Realm
-#define decode_Realm _rxkad_v5_decode_Realm
-#define free_Realm _rxkad_v5_free_Realm
-#define length_Realm _rxkad_v5_length_Realm
-#define copy_Realm _rxkad_v5_copy_Realm
-#define encode_ENCTYPE _rxkad_v5_encode_ENCTYPE
-#define decode_ENCTYPE _rxkad_v5_decode_ENCTYPE
-#define free_ENCTYPE _rxkad_v5_free_ENCTYPE
-#define length_ENCTYPE _rxkad_v5_length_ENCTYPE
-#define copy_ENCTYPE _rxkad_v5_copy_ENCTYPE
-#define encode_NAME_TYPE _rxkad_v5_encode_NAME_TYPE
-#define decode_NAME_TYPE _rxkad_v5_decode_NAME_TYPE
-#define free_NAME_TYPE _rxkad_v5_free_NAME_TYPE
-#define length_NAME_TYPE _rxkad_v5_length_NAME_TYPE
-#define copy_NAME_TYPE _rxkad_v5_copy_NAME_TYPE
-#define der_copy_bit_string _rxkad_v5_der_copy_bit_string
-#define der_copy_bmp_string _rxkad_v5_der_copy_bmp_string
-#define der_copy_general_string _rxkad_v5_der_copy_general_string
-#define der_copy_generalized_time _rxkad_v5_der_copy_generalized_time
-#define der_copy_heim_integer _rxkad_v5_der_copy_heim_integer
-#define der_copy_ia5_string _rxkad_v5_der_copy_ia5_string
-#define der_copy_integer _rxkad_v5_der_copy_integer
-#define der_copy_octet_string _rxkad_v5_der_copy_octet_string
-#define der_copy_oid _rxkad_v5_der_copy_oid
-#define der_copy_printable_string _rxkad_v5_der_copy_printable_string
-#define der_copy_universal_string _rxkad_v5_der_copy_universal_string
-#define der_copy_unsigned _rxkad_v5_der_copy_unsigned
-#define der_copy_utctime _rxkad_v5_der_copy_utctime
-#define der_copy_utf8string _rxkad_v5_der_copy_utf8string
-#define der_copy_visible_string _rxkad_v5_der_copy_visible_string
-#define der_free_bit_string _rxkad_v5_der_free_bit_string
-#define der_free_bmp_string _rxkad_v5_der_free_bmp_string
+#define encode_KDCOptions _rxkad_v5_encode_KDCOptions
+#define decode_KDCOptions _rxkad_v5_decode_KDCOptions
+#define free_KDCOptions _rxkad_v5_free_KDCOptions
+#define length_KDCOptions _rxkad_v5_length_KDCOptions
+#define copy_KDCOptions _rxkad_v5_copy_KDCOptions
+#define encode_LR_TYPE _rxkad_v5_encode_LR_TYPE
+#define decode_LR_TYPE _rxkad_v5_decode_LR_TYPE
+#define free_LR_TYPE _rxkad_v5_free_LR_TYPE
+#define length_LR_TYPE _rxkad_v5_length_LR_TYPE
+#define copy_LR_TYPE _rxkad_v5_copy_LR_TYPE
+#define encode_LastReq _rxkad_v5_encode_LastReq
+#define decode_LastReq _rxkad_v5_decode_LastReq
+#define free_LastReq _rxkad_v5_free_LastReq
+#define length_LastReq _rxkad_v5_length_LastReq
+#define copy_LastReq _rxkad_v5_copy_LastReq
+#define encode_EncryptedData _rxkad_v5_encode_EncryptedData
+#define decode_EncryptedData _rxkad_v5_decode_EncryptedData
+#define free_EncryptedData _rxkad_v5_free_EncryptedData
+#define length_EncryptedData _rxkad_v5_length_EncryptedData
+#define copy_EncryptedData _rxkad_v5_copy_EncryptedData
+#define encode_EncryptionKey _rxkad_v5_encode_EncryptionKey
+#define decode_EncryptionKey _rxkad_v5_decode_EncryptionKey
+#define free_EncryptionKey _rxkad_v5_free_EncryptionKey
+#define length_EncryptionKey _rxkad_v5_length_EncryptionKey
+#define copy_EncryptionKey _rxkad_v5_copy_EncryptionKey
+#define encode_TransitedEncoding _rxkad_v5_encode_TransitedEncoding
+#define decode_TransitedEncoding _rxkad_v5_decode_TransitedEncoding
+#define free_TransitedEncoding _rxkad_v5_free_TransitedEncoding
+#define length_TransitedEncoding _rxkad_v5_length_TransitedEncoding
+#define copy_TransitedEncoding _rxkad_v5_copy_TransitedEncoding
+#define encode_Ticket _rxkad_v5_encode_Ticket
+#define decode_Ticket _rxkad_v5_decode_Ticket
+#define free_Ticket _rxkad_v5_free_Ticket
+#define length_Ticket _rxkad_v5_length_Ticket
+#define copy_Ticket _rxkad_v5_copy_Ticket
+#define encode_EncTicketPart _rxkad_v5_encode_EncTicketPart
+#define decode_EncTicketPart _rxkad_v5_decode_EncTicketPart
+#define free_EncTicketPart _rxkad_v5_free_EncTicketPart
+#define length_EncTicketPart _rxkad_v5_length_EncTicketPart
+#define copy_EncTicketPart _rxkad_v5_copy_EncTicketPart
+#define der_get_unsigned _rxkad_v5_der_get_unsigned
+#define der_get_unsigned64 _rxkad_v5_der_get_unsigned64
+#define der_get_integer _rxkad_v5_der_get_integer
+#define der_get_integer64 _rxkad_v5_der_get_integer64
+#define der_get_length _rxkad_v5_der_get_length
+#define der_get_boolean _rxkad_v5_der_get_boolean
+#define der_get_general_string _rxkad_v5_der_get_general_string
+#define der_get_utf8string _rxkad_v5_der_get_utf8string
+#define der_get_printable_string _rxkad_v5_der_get_printable_string
+#define der_get_ia5_string _rxkad_v5_der_get_ia5_string
+#define der_get_bmp_string _rxkad_v5_der_get_bmp_string
+#define der_get_universal_string _rxkad_v5_der_get_universal_string
+#define der_get_visible_string _rxkad_v5_der_get_visible_string
+#define der_get_octet_string _rxkad_v5_der_get_octet_string
+#define der_get_octet_string_ber _rxkad_v5_der_get_octet_string_ber
+#define der_get_heim_integer _rxkad_v5_der_get_heim_integer
+#define der_get_time _rxkad_v5_der_get_time
+#define der_get_generalized_time _rxkad_v5_der_get_generalized_time
+#define der_get_utctime _rxkad_v5_der_get_utctime
+#define der_get_oid _rxkad_v5_der_get_oid
+#define der_get_tag _rxkad_v5_der_get_tag
+#define der_match_tag _rxkad_v5_der_match_tag
+#define der_match_tag2 _rxkad_v5_der_match_tag2
+#define der_match_tag_and_length _rxkad_v5_der_match_tag_and_length
+#define der_get_bit_string _rxkad_v5_der_get_bit_string
+#define der_put_unsigned _rxkad_v5_der_put_unsigned
+#define der_put_unsigned64 _rxkad_v5_der_put_unsigned64
+#define der_put_integer _rxkad_v5_der_put_integer
+#define der_put_integer64 _rxkad_v5_der_put_integer64
+#define der_put_length _rxkad_v5_der_put_length
+#define der_put_boolean _rxkad_v5_der_put_boolean
+#define der_put_general_string _rxkad_v5_der_put_general_string
+#define der_put_utf8string _rxkad_v5_der_put_utf8string
+#define der_put_printable_string _rxkad_v5_der_put_printable_string
+#define der_put_ia5_string _rxkad_v5_der_put_ia5_string
+#define der_put_bmp_string _rxkad_v5_der_put_bmp_string
+#define der_put_universal_string _rxkad_v5_der_put_universal_string
+#define der_put_visible_string _rxkad_v5_der_put_visible_string
+#define der_put_octet_string _rxkad_v5_der_put_octet_string
+#define der_put_heim_integer _rxkad_v5_der_put_heim_integer
+#define der_put_generalized_time _rxkad_v5_der_put_generalized_time
+#define der_put_utctime _rxkad_v5_der_put_utctime
+#define der_put_oid _rxkad_v5_der_put_oid
+#define der_put_tag _rxkad_v5_der_put_tag
+#define der_put_length_and_tag _rxkad_v5_der_put_length_and_tag
+#define der_put_bit_string _rxkad_v5_der_put_bit_string
 #define der_free_general_string _rxkad_v5_der_free_general_string
-#define der_free_generalized_time _rxkad_v5_der_free_generalized_time
-#define der_free_heim_integer _rxkad_v5_der_free_heim_integer
-#define der_free_ia5_string _rxkad_v5_der_free_ia5_string
 #define der_free_integer _rxkad_v5_der_free_integer
-#define der_free_octet_string _rxkad_v5_der_free_octet_string
-#define der_free_oid _rxkad_v5_der_free_oid
-#define der_free_printable_string _rxkad_v5_der_free_printable_string
-#define der_free_universal_string _rxkad_v5_der_free_universal_string
+#define der_free_integer64 _rxkad_v5_der_free_integer64
 #define der_free_unsigned _rxkad_v5_der_free_unsigned
+#define der_free_unsigned64 _rxkad_v5_der_free_unsigned64
+#define der_free_generalized_time _rxkad_v5_der_free_generalized_time
 #define der_free_utctime _rxkad_v5_der_free_utctime
 #define der_free_utf8string _rxkad_v5_der_free_utf8string
+#define der_free_printable_string _rxkad_v5_der_free_printable_string
+#define der_free_ia5_string _rxkad_v5_der_free_ia5_string
+#define der_free_bmp_string _rxkad_v5_der_free_bmp_string
+#define der_free_universal_string _rxkad_v5_der_free_universal_string
 #define der_free_visible_string _rxkad_v5_der_free_visible_string
-#define der_get_bit_string _rxkad_v5_der_get_bit_string
-#define der_get_generalized_time _rxkad_v5_der_get_generalized_time
-#define der_get_heim_integer _rxkad_v5_der_get_heim_integer
-#define der_get_ia5_string _rxkad_v5_der_get_ia5_string
-#define der_get_octet_string_ber _rxkad_v5_der_get_octet_string_ber
-#define der_get_printable_string _rxkad_v5_der_get_printable_string
-#define der_get_time _rxkad_v5_der_get_time
-#define der_get_utf8string _rxkad_v5_der_get_utf8string
-#define der_get_visible_string _rxkad_v5_der_get_visible_string
-#define der_get_bmp_string _rxkad_v5_der_get_bmp_string
-#define der_get_boolean _rxkad_v5_der_get_boolean
-#define der_get_unsigned  _rxkad_v5_der_get_unsigned
-#define der_get_integer _rxkad_v5_der_get_integer
-#define der_get_int  _rxkad_v5_der_get_int
-#define der_get_length  _rxkad_v5_der_get_length
-#define der_get_general_string  _rxkad_v5_der_get_general_string
-#define der_get_octet_string  _rxkad_v5_der_get_octet_string
-#define der_get_oid  _rxkad_v5_der_get_oid
-#define der_get_tag  _rxkad_v5_der_get_tag
-#define der_get_universal_string _rxkad_v5_der_get_universal_string
-#define der_get_utctime _rxkad_v5_der_get_utctime
-#define der_length_bit_string _rxkad_v5_der_length_bit_string
-#define der_length_bmp_string _rxkad_v5_der_length_bmp_string
-#define der_length_boolean _rxkad_v5_der_length_boolean
+#define der_free_octet_string _rxkad_v5_der_free_octet_string
+#define der_free_heim_integer _rxkad_v5_der_free_heim_integer
+#define der_free_oid _rxkad_v5_der_free_oid
+#define der_free_bit_string _rxkad_v5_der_free_bit_string
+#define len_oid _rxkad_v5_len_oid
+#define der_length_len _rxkad_v5_der_length_len
+#define der_length_tag _rxkad_v5_der_length_tag
+#define der_length_integer _rxkad_v5_der_length_integer
+#define der_length_integer64 _rxkad_v5_der_length_integer64
+#define der_length_unsigned _rxkad_v5_der_length_unsigned
+#define der_length_unsigned64 _rxkad_v5_der_length_unsigned64
 #define der_length_enumerated _rxkad_v5_der_length_enumerated
 #define der_length_general_string _rxkad_v5_der_length_general_string
-#define der_length_generalized_time _rxkad_v5_der_length_generalized_time
-#define der_length_heim_integer _rxkad_v5_der_length_heim_integer
+#define der_length_utf8string _rxkad_v5_der_length_utf8string
+#define der_length_printable_string _rxkad_v5_der_length_printable_string
 #define der_length_ia5_string _rxkad_v5_der_length_ia5_string
-#define der_length_integer _rxkad_v5_der_length_integer
-#define der_length_len _rxkad_v5_der_length_len
+#define der_length_bmp_string _rxkad_v5_der_length_bmp_string
+#define der_length_universal_string _rxkad_v5_der_length_universal_string
+#define der_length_visible_string _rxkad_v5_der_length_visible_string
 #define der_length_octet_string _rxkad_v5_der_length_octet_string
+#define der_length_heim_integer _rxkad_v5_der_length_heim_integer
 #define der_length_oid _rxkad_v5_der_length_oid
-#define der_length_printable_string _rxkad_v5_der_length_printable_string
-#define der_length_tag _rxkad_v5_der_length_tag
-#define der_length_universal_string _rxkad_v5_der_length_universal_string
-#define der_length_unsigned _rxkad_v5_der_length_unsigned
+#define der_length_generalized_time _rxkad_v5_der_length_generalized_time
 #define der_length_utctime _rxkad_v5_der_length_utctime
-#define der_length_utf8string _rxkad_v5_der_length_utf8string
-#define der_length_visible_string _rxkad_v5_der_length_visible_string
-#define der_match_tag  _rxkad_v5_der_match_tag
-#define der_match_tag_and_length  _rxkad_v5_der_match_tag_and_length
-#define der_match_tag2 _rxkad_v5_der_match_tag2
-#define decode_integer  _rxkad_v5_decode_integer
-#define decode_unsigned  _rxkad_v5_decode_unsigned
-#define decode_enumerated  _rxkad_v5_decode_enumerated
-#define decode_general_string  _rxkad_v5_decode_general_string
-#define decode_octet_string  _rxkad_v5_decode_octet_string
-#define decode_oid  _rxkad_v5_decode_oid
-#define decode_generalized_time  _rxkad_v5_decode_generalized_time
-#define fix_dce _rxkad_v5_fix_dce
-#define der_put_bit_string _rxkad_v5_der_put_bit_string
-#define der_put_generalized_time _rxkad_v5_der_put_generalized_time
-#define der_put_heim_integer _rxkad_v5_der_put_heim_integer
-#define der_put_ia5_string _rxkad_v5_der_put_ia5_string
-#define der_put_printable_string _rxkad_v5_der_put_printable_string
-#define der_put_utf8string _rxkad_v5_der_put_utf8string
-#define der_put_visible_string _rxkad_v5_der_put_visible_string
-#define der_put_bmp_string _rxkad_v5_der_put_bmp_string
-#define der_put_boolean _rxkad_v5_der_put_boolean
-#define der_put_unsigned  _rxkad_v5_der_put_unsigned
-#define der_put_int  _rxkad_v5_der_put_int
-#define der_put_integer _rxkad_v5_der_put_integer
-#define der_put_length  _rxkad_v5_der_put_length
-#define der_put_general_string  _rxkad_v5_der_put_general_string
-#define der_put_octet_string  _rxkad_v5_der_put_octet_string
-#define der_put_oid  _rxkad_v5_der_put_oid
-#define der_put_tag  _rxkad_v5_der_put_tag
-#define der_put_length_and_tag  _rxkad_v5_der_put_length_and_tag
-#define der_put_universal_string _rxkad_v5_der_put_universal_string
-#define der_put_utctime _rxkad_v5_der_put_utctime
-#define encode_integer  _rxkad_v5_encode_integer
-#define encode_unsigned  _rxkad_v5_encode_unsigned
-#define encode_enumerated  _rxkad_v5_encode_enumerated
-#define encode_general_string  _rxkad_v5_encode_general_string
-#define encode_octet_string  _rxkad_v5_encode_octet_string
-#define encode_oid _rxkad_v5_encode_oid
-#define time2generalizedtime  _rxkad_v5_time2generalizedtime
-#define encode_generalized_time  _rxkad_v5_encode_generalized_time
-#define free_general_string  _rxkad_v5_free_general_string
-#define free_octet_string  _rxkad_v5_free_octet_string
-#define free_oid  _rxkad_v5_free_oid
-#define len_unsigned  _rxkad_v5_len_unsigned
-#define len_int  _rxkad_v5_len_int
-#define len_oid  _rxkad_v5_len_oid
-#define length_len  _rxkad_v5_length_len
-#define length_integer  _rxkad_v5_length_integer
-#define length_unsigned  _rxkad_v5_length_unsigned
-#define length_enumerated  _rxkad_v5_length_enumerated
-#define length_general_string  _rxkad_v5_length_general_string
-#define length_octet_string  _rxkad_v5_length_octet_string
-#define length_oid  _rxkad_v5_length_oid
-#define length_generalized_time  _rxkad_v5_length_generalized_time
-#define copy_general_string  _rxkad_v5_copy_general_string
-#define copy_octet_string  _rxkad_v5_copy_octet_string
-#define copy_oid  _rxkad_v5_copy_oid
+#define der_length_boolean _rxkad_v5_der_length_boolean
+#define der_length_bit_string _rxkad_v5_der_length_bit_string
+#define der_copy_general_string _rxkad_v5_der_copy_general_string
+#define der_copy_integer _rxkad_v5_der_copy_integer
+#define der_copy_integer64 _rxkad_v5_der_copy_integer64
+#define der_copy_unsigned _rxkad_v5_der_copy_unsigned
+#define der_copy_unsigned64 _rxkad_v5_der_copy_unsigned64
+#define der_copy_generalized_time _rxkad_v5_der_copy_generalized_time
+#define der_copy_utctime _rxkad_v5_der_copy_utctime
+#define der_copy_utf8string _rxkad_v5_der_copy_utf8string
+#define der_copy_printable_string _rxkad_v5_der_copy_printable_string
+#define der_copy_ia5_string _rxkad_v5_der_copy_ia5_string
+#define der_copy_bmp_string _rxkad_v5_der_copy_bmp_string
+#define der_copy_universal_string _rxkad_v5_der_copy_universal_string
+#define der_copy_visible_string _rxkad_v5_der_copy_visible_string
+#define der_copy_octet_string _rxkad_v5_der_copy_octet_string
+#define der_copy_heim_integer _rxkad_v5_der_copy_heim_integer
+#define der_copy_oid _rxkad_v5_der_copy_oid
+#define der_copy_bit_string _rxkad_v5_der_copy_bit_string
 #define TicketFlags2int _rxkad_v5_TicketFlags2int
 #define int2TicketFlags _rxkad_v5_int2TicketFlags
-#ifndef HAVE_TIMEGM
-#define timegm	_rxkad_timegm
-#endif
-#define _heim_fix_dce _rxkad_v5__heim_fix_dce
-#define _der_timegm _rxkad_v5__der_timegm
-#define _heim_der_set_sort _rxkad_v5__heim_der_set_sort
-#define _heim_len_int _rxkad_v5__heim_len_int
-#define _heim_len_unsigned _rxkad_v5__heim_len_unsigned
-#define _heim_time2generalizedtime _rxkad_v5__heim_time2generalizedtime
diff --git a/src/rxkad/v5gen.c b/src/rxkad/v5gen.c
index f1823256d..83a419bf0 100644
--- a/src/rxkad/v5gen.c
+++ b/src/rxkad/v5gen.c
@@ -1,6 +1,214 @@
+#define HEIMDAL_UNUSED_ATTRIBUTE AFS_UNUSED
+int ASN1CALL decode_MESSAGE_TYPE(const unsigned char *, size_t,
+				 MESSAGE_TYPE *, size_t *);
+int ASN1CALL encode_MESSAGE_TYPE(unsigned char *, size_t,
+				 const MESSAGE_TYPE *, size_t *);
+size_t ASN1CALL length_MESSAGE_TYPE(const MESSAGE_TYPE *);
+int ASN1CALL copy_MESSAGE_TYPE(const MESSAGE_TYPE *, MESSAGE_TYPE *);
+void ASN1CALL free_MESSAGE_TYPE(MESSAGE_TYPE *);
+
+
+int ASN1CALL decode_krb5uint32(const unsigned char *, size_t, krb5uint32 *,
+			       size_t *);
+int ASN1CALL encode_krb5uint32(unsigned char *, size_t, const krb5uint32 *,
+			       size_t *);
+size_t ASN1CALL length_krb5uint32(const krb5uint32 *);
+int ASN1CALL copy_krb5uint32(const krb5uint32 *, krb5uint32 *);
+void ASN1CALL free_krb5uint32(krb5uint32 *);
+
+
+int ASN1CALL decode_krb5int32(const unsigned char *, size_t, krb5int32 *,
+			      size_t *);
+int ASN1CALL encode_krb5int32(unsigned char *, size_t, const krb5int32 *,
+			      size_t *);
+size_t ASN1CALL length_krb5int32(const krb5int32 *);
+int ASN1CALL copy_krb5int32(const krb5int32 *, krb5int32 *);
+void ASN1CALL free_krb5int32(krb5int32 *);
+
+
+int ASN1CALL decode_APOptions(const unsigned char *, size_t, APOptions *,
+			      size_t *);
+int ASN1CALL encode_APOptions(unsigned char *, size_t, const APOptions *,
+			      size_t *);
+size_t ASN1CALL length_APOptions(const APOptions *);
+int ASN1CALL copy_APOptions(const APOptions *, APOptions *);
+void ASN1CALL free_APOptions(APOptions *);
+
+
+int ASN1CALL decode_TYPED_DATA(const unsigned char *, size_t, TYPED_DATA *,
+			       size_t *);
+int ASN1CALL encode_TYPED_DATA(unsigned char *, size_t, const TYPED_DATA *,
+			       size_t *);
+size_t ASN1CALL length_TYPED_DATA(const TYPED_DATA *);
+int ASN1CALL copy_TYPED_DATA(const TYPED_DATA *, TYPED_DATA *);
+void ASN1CALL free_TYPED_DATA(TYPED_DATA *);
+
+
+int ASN1CALL decode_KDC_REQ(const unsigned char *, size_t, KDC_REQ *,
+			    size_t *);
+int ASN1CALL encode_KDC_REQ(unsigned char *, size_t, const KDC_REQ *,
+			    size_t *);
+size_t ASN1CALL length_KDC_REQ(const KDC_REQ *);
+int ASN1CALL copy_KDC_REQ(const KDC_REQ *, KDC_REQ *);
+void ASN1CALL free_KDC_REQ(KDC_REQ *);
+
+
+int ASN1CALL decode_PROV_SRV_LOCATION(const unsigned char *, size_t,
+				      PROV_SRV_LOCATION *, size_t *);
+int ASN1CALL encode_PROV_SRV_LOCATION(unsigned char *, size_t,
+				      const PROV_SRV_LOCATION *, size_t *);
+size_t ASN1CALL length_PROV_SRV_LOCATION(const PROV_SRV_LOCATION *);
+int ASN1CALL copy_PROV_SRV_LOCATION(const PROV_SRV_LOCATION *,
+				    PROV_SRV_LOCATION *);
+void ASN1CALL free_PROV_SRV_LOCATION(PROV_SRV_LOCATION *);
+
+
+int ASN1CALL decode_AD_MANDATORY_FOR_KDC(const unsigned char *, size_t,
+					 AD_MANDATORY_FOR_KDC *, size_t *);
+int ASN1CALL encode_AD_MANDATORY_FOR_KDC(unsigned char *, size_t,
+					 const AD_MANDATORY_FOR_KDC *,
+					 size_t *);
+size_t ASN1CALL length_AD_MANDATORY_FOR_KDC(const AD_MANDATORY_FOR_KDC *);
+int ASN1CALL copy_AD_MANDATORY_FOR_KDC(const AD_MANDATORY_FOR_KDC *,
+				       AD_MANDATORY_FOR_KDC *);
+void ASN1CALL free_AD_MANDATORY_FOR_KDC(AD_MANDATORY_FOR_KDC *);
+
+
+int ASN1CALL decode_PA_SAM_TYPE(const unsigned char *, size_t, PA_SAM_TYPE *,
+				size_t *);
+int ASN1CALL encode_PA_SAM_TYPE(unsigned char *, size_t, const PA_SAM_TYPE *,
+				size_t *);
+size_t ASN1CALL length_PA_SAM_TYPE(const PA_SAM_TYPE *);
+int ASN1CALL copy_PA_SAM_TYPE(const PA_SAM_TYPE *, PA_SAM_TYPE *);
+void ASN1CALL free_PA_SAM_TYPE(PA_SAM_TYPE *);
+
+
+int ASN1CALL decode_PA_SAM_REDIRECT(const unsigned char *, size_t,
+				    PA_SAM_REDIRECT *, size_t *);
+int ASN1CALL encode_PA_SAM_REDIRECT(unsigned char *, size_t,
+				    const PA_SAM_REDIRECT *, size_t *);
+size_t ASN1CALL length_PA_SAM_REDIRECT(const PA_SAM_REDIRECT *);
+int ASN1CALL copy_PA_SAM_REDIRECT(const PA_SAM_REDIRECT *, PA_SAM_REDIRECT *);
+void ASN1CALL free_PA_SAM_REDIRECT(PA_SAM_REDIRECT *);
+
+
+int ASN1CALL decode_SAMFlags(const unsigned char *, size_t, SAMFlags *,
+			     size_t *);
+int ASN1CALL encode_SAMFlags(unsigned char *, size_t, const SAMFlags *,
+			     size_t *);
+size_t ASN1CALL length_SAMFlags(const SAMFlags *);
+int ASN1CALL copy_SAMFlags(const SAMFlags *, SAMFlags *);
+void ASN1CALL free_SAMFlags(SAMFlags *);
+
+
+int ASN1CALL decode_PA_SAM_CHALLENGE_2_BODY(const unsigned char *, size_t,
+					    PA_SAM_CHALLENGE_2_BODY *,
+					    size_t *);
+int ASN1CALL encode_PA_SAM_CHALLENGE_2_BODY(unsigned char *, size_t,
+					    const PA_SAM_CHALLENGE_2_BODY *,
+					    size_t *);
+size_t ASN1CALL length_PA_SAM_CHALLENGE_2_BODY(const PA_SAM_CHALLENGE_2_BODY
+					       *);
+int ASN1CALL copy_PA_SAM_CHALLENGE_2_BODY(const PA_SAM_CHALLENGE_2_BODY *,
+					  PA_SAM_CHALLENGE_2_BODY *);
+void ASN1CALL free_PA_SAM_CHALLENGE_2_BODY(PA_SAM_CHALLENGE_2_BODY *);
+
+
+int ASN1CALL decode_PA_SAM_CHALLENGE_2(const unsigned char *, size_t,
+				       PA_SAM_CHALLENGE_2 *, size_t *);
+int ASN1CALL encode_PA_SAM_CHALLENGE_2(unsigned char *, size_t,
+				       const PA_SAM_CHALLENGE_2 *, size_t *);
+size_t ASN1CALL length_PA_SAM_CHALLENGE_2(const PA_SAM_CHALLENGE_2 *);
+int ASN1CALL copy_PA_SAM_CHALLENGE_2(const PA_SAM_CHALLENGE_2 *,
+				     PA_SAM_CHALLENGE_2 *);
+void ASN1CALL free_PA_SAM_CHALLENGE_2(PA_SAM_CHALLENGE_2 *);
+
+
+int ASN1CALL decode_PA_SAM_RESPONSE_2(const unsigned char *, size_t,
+				      PA_SAM_RESPONSE_2 *, size_t *);
+int ASN1CALL encode_PA_SAM_RESPONSE_2(unsigned char *, size_t,
+				      const PA_SAM_RESPONSE_2 *, size_t *);
+size_t ASN1CALL length_PA_SAM_RESPONSE_2(const PA_SAM_RESPONSE_2 *);
+int ASN1CALL copy_PA_SAM_RESPONSE_2(const PA_SAM_RESPONSE_2 *,
+				    PA_SAM_RESPONSE_2 *);
+void ASN1CALL free_PA_SAM_RESPONSE_2(PA_SAM_RESPONSE_2 *);
+
+
+int ASN1CALL decode_PA_ENC_SAM_RESPONSE_ENC(const unsigned char *, size_t,
+					    PA_ENC_SAM_RESPONSE_ENC *,
+					    size_t *);
+int ASN1CALL encode_PA_ENC_SAM_RESPONSE_ENC(unsigned char *, size_t,
+					    const PA_ENC_SAM_RESPONSE_ENC *,
+					    size_t *);
+size_t ASN1CALL length_PA_ENC_SAM_RESPONSE_ENC(const PA_ENC_SAM_RESPONSE_ENC
+					       *);
+int ASN1CALL copy_PA_ENC_SAM_RESPONSE_ENC(const PA_ENC_SAM_RESPONSE_ENC *,
+					  PA_ENC_SAM_RESPONSE_ENC *);
+void ASN1CALL free_PA_ENC_SAM_RESPONSE_ENC(PA_ENC_SAM_RESPONSE_ENC *);
+
+
+int ASN1CALL decode_FastOptions(const unsigned char *, size_t, FastOptions *,
+				size_t *);
+int ASN1CALL encode_FastOptions(unsigned char *, size_t, const FastOptions *,
+				size_t *);
+size_t ASN1CALL length_FastOptions(const FastOptions *);
+int ASN1CALL copy_FastOptions(const FastOptions *, FastOptions *);
+void ASN1CALL free_FastOptions(FastOptions *);
+
+
+int ASN1CALL decode_KrbFastArmoredReq(const unsigned char *, size_t,
+				      KrbFastArmoredReq *, size_t *);
+int ASN1CALL encode_KrbFastArmoredReq(unsigned char *, size_t,
+				      const KrbFastArmoredReq *, size_t *);
+size_t ASN1CALL length_KrbFastArmoredReq(const KrbFastArmoredReq *);
+int ASN1CALL copy_KrbFastArmoredReq(const KrbFastArmoredReq *,
+				    KrbFastArmoredReq *);
+void ASN1CALL free_KrbFastArmoredReq(KrbFastArmoredReq *);
+
+
+int ASN1CALL decode_KrbFastArmoredRep(const unsigned char *, size_t,
+				      KrbFastArmoredRep *, size_t *);
+int ASN1CALL encode_KrbFastArmoredRep(unsigned char *, size_t,
+				      const KrbFastArmoredRep *, size_t *);
+size_t ASN1CALL length_KrbFastArmoredRep(const KrbFastArmoredRep *);
+int ASN1CALL copy_KrbFastArmoredRep(const KrbFastArmoredRep *,
+				    KrbFastArmoredRep *);
+void ASN1CALL free_KrbFastArmoredRep(KrbFastArmoredRep *);
+
+
+int ASN1CALL decode_KDCFastFlags(const unsigned char *, size_t,
+				 KDCFastFlags *, size_t *);
+int ASN1CALL encode_KDCFastFlags(unsigned char *, size_t,
+				 const KDCFastFlags *, size_t *);
+size_t ASN1CALL length_KDCFastFlags(const KDCFastFlags *);
+int ASN1CALL copy_KDCFastFlags(const KDCFastFlags *, KDCFastFlags *);
+void ASN1CALL free_KDCFastFlags(KDCFastFlags *);
+
+
+int ASN1CALL decode_KERB_TGS_REP_IN(const unsigned char *, size_t,
+				    KERB_TGS_REP_IN *, size_t *);
+int ASN1CALL encode_KERB_TGS_REP_IN(unsigned char *, size_t,
+				    const KERB_TGS_REP_IN *, size_t *);
+size_t ASN1CALL length_KERB_TGS_REP_IN(const KERB_TGS_REP_IN *);
+int ASN1CALL copy_KERB_TGS_REP_IN(const KERB_TGS_REP_IN *, KERB_TGS_REP_IN *);
+void ASN1CALL free_KERB_TGS_REP_IN(KERB_TGS_REP_IN *);
+
+
+int ASN1CALL decode_KERB_TGS_REP_OUT(const unsigned char *, size_t,
+				     KERB_TGS_REP_OUT *, size_t *);
+int ASN1CALL encode_KERB_TGS_REP_OUT(unsigned char *, size_t,
+				     const KERB_TGS_REP_OUT *, size_t *);
+size_t ASN1CALL length_KERB_TGS_REP_OUT(const KERB_TGS_REP_OUT *);
+int ASN1CALL copy_KERB_TGS_REP_OUT(const KERB_TGS_REP_OUT *,
+				   KERB_TGS_REP_OUT *);
+void ASN1CALL free_KERB_TGS_REP_OUT(KERB_TGS_REP_OUT *);
+
+
 /* Generated from ./krb5.asn1 */
 /* Do not edit */
 
+#define  ASN1_LIB
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <time.h>
@@ -9,22 +217,29 @@
 #include <limits.h>
 #include <asn1_err.h>
 
-int
-encode_krb5int32(unsigned char *p, size_t len, const krb5int32 * data, size_t * size)
+
+int ASN1CALL
+encode_NAME_TYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, const NAME_TYPE * data,
+		 size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
-    e = der_put_integer(p, len, data, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
+    {
+	int enumint = (int) *data;
+	e = der_put_integer(p, len, &enumint, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
 
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
+    }
+    ;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -35,18 +250,21 @@ encode_krb5int32(unsigned char *p, size_t len, const krb5int32 * data, size_t *
     return 0;
 }
 
-int
-decode_krb5int32(const unsigned char *p, size_t len, krb5int32 * data, size_t * size)
+int ASN1CALL
+decode_NAME_TYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, NAME_TYPE * data,
+		 size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Integer, &Top_datalen, &l);
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
 	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
@@ -61,153 +279,285 @@ decode_krb5int32(const unsigned char *p, size_t len, krb5int32 * data, size_t *
 	    goto fail;
 	}
 	len = Top_datalen;
-	e = der_get_integer(p, len, data, &l);
-	if (e)
-	    goto fail;
-	p += l;
-	len -= l;
-	ret += l;
+	{
+	    int enumint;
+	    e = der_get_integer(p, len, &enumint, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    *data = enumint;
+	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_krb5int32(data);
+  fail:
+    free_NAME_TYPE(data);
     return e;
 }
 
-void
-free_krb5int32(krb5int32 * data)
+void ASN1CALL
+free_NAME_TYPE(NAME_TYPE * data)
 {
 }
 
-size_t
-length_krb5int32(const krb5int32 * data)
+size_t ASN1CALL
+length_NAME_TYPE(const NAME_TYPE * data)
 {
     size_t ret = 0;
-    ret += der_length_integer(data);
+    {
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
+    }
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_krb5int32(const krb5int32 * from, krb5int32 * to)
+int ASN1CALL
+copy_NAME_TYPE(const NAME_TYPE * from, NAME_TYPE * to)
 {
     memset(to, 0, sizeof(*to));
     *(to) = *(from);
     return 0;
 }
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_Ticket(unsigned char *p, size_t len, const Ticket * data, size_t * size)
+int ASN1CALL
+encode_MESSAGE_TYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		    size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		    const MESSAGE_TYPE * data, size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
-/* enc-part */
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_EncryptedData(p, len, &(data)->enc_part, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
+	int enumint = (int) *data;
+	e = der_put_integer(p, len, &enumint, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
     }
-/* sname */
+    ;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_MESSAGE_TYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		    size_t len HEIMDAL_UNUSED_ATTRIBUTE, MESSAGE_TYPE * data,
+		    size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_PrincipalName(p, len, &(data)->sname, &l);
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
+	    e = ASN1_BAD_ID;
+	}
 	if (e)
-	    return e;
-	p -= l;
+	    goto fail;
+	p += l;
 	len -= l;
 	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    int enumint;
+	    e = der_get_integer(p, len, &enumint, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    *data = enumint;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_MESSAGE_TYPE(data);
+    return e;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+void ASN1CALL
+free_MESSAGE_TYPE(MESSAGE_TYPE * data)
+{
+}
 
-	ret += Top_tag_tag_oldret;
-    }
-/* realm */
+size_t ASN1CALL
+length_MESSAGE_TYPE(const MESSAGE_TYPE * data)
+{
+    size_t ret = 0;
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_Realm(p, len, &(data)->realm, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+int ASN1CALL
+copy_MESSAGE_TYPE(const MESSAGE_TYPE * from, MESSAGE_TYPE * to)
+{
+    memset(to, 0, sizeof(*to));
+    *(to) = *(from);
+    return 0;
+}
+
+int ASN1CALL
+encode_PADATA_TYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		   size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		   const PADATA_TYPE * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    {
+	int enumint = (int) *data;
+	e = der_put_integer(p, len, &enumint, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
     }
-/* tkt-vno */
+    ;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_PADATA_TYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		   size_t len HEIMDAL_UNUSED_ATTRIBUTE, PADATA_TYPE * data,
+		   size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_krb5int32(p, len, &(data)->tkt_vno, &l);
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
+	    e = ASN1_BAD_ID;
+	}
 	if (e)
-	    return e;
-	p -= l;
+	    goto fail;
+	p += l;
 	len -= l;
 	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    int enumint;
+	    e = der_get_integer(p, len, &enumint, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    *data = enumint;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_PADATA_TYPE(data);
+    return e;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+void ASN1CALL
+free_PADATA_TYPE(PADATA_TYPE * data)
+{
+}
+
+size_t ASN1CALL
+length_PADATA_TYPE(const PADATA_TYPE * data)
+{
+    size_t ret = 0;
+    {
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_PADATA_TYPE(const PADATA_TYPE * from, PADATA_TYPE * to)
+{
+    memset(to, 0, sizeof(*to));
+    *(to) = *(from);
+    return 0;
+}
+
+int ASN1CALL
+encode_AUTHDATA_TYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     const AUTHDATA_TYPE * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    {
+	int enumint = (int) *data;
+	e = der_put_integer(p, len, &enumint, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
-
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_APPL, CONS, 1, &l);
+    ;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -218,19 +568,22 @@ encode_Ticket(unsigned char *p, size_t len, const Ticket * data, size_t * size)
     return 0;
 }
 
-int
-decode_Ticket(const unsigned char *p, size_t len, Ticket * data, size_t * size)
+int ASN1CALL
+decode_AUTHDATA_TYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     AUTHDATA_TYPE * data, size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_APPL, &Top_type, 1, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -245,272 +598,72 @@ decode_Ticket(const unsigned char *p, size_t len, Ticket * data, size_t * size)
 	}
 	len = Top_datalen;
 	{
-	    size_t Top_Tag_datalen, Top_Tag_oldlen;
-	    Der_type Top_Tag_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_type, UT_Sequence, &Top_Tag_datalen, &l);
-	    if (e == 0 && Top_Tag_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
+	    int enumint;
+	    e = der_get_integer(p, len, &enumint, &l);
 	    if (e)
 		goto fail;
 	    p += l;
 	    len -= l;
 	    ret += l;
-	    Top_Tag_oldlen = len;
-	    if (Top_Tag_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = Top_Tag_datalen;
-	    {
-		size_t tkt_vno_datalen, tkt_vno_oldlen;
-		Der_type tkt_vno_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &tkt_vno_type, 0, &tkt_vno_datalen, &l);
-		if (e == 0 && tkt_vno_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		tkt_vno_oldlen = len;
-		if (tkt_vno_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = tkt_vno_datalen;
-		e = decode_krb5int32(p, len, &(data)->tkt_vno, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = tkt_vno_oldlen - tkt_vno_datalen;
-	    }
-	    {
-		size_t realm_datalen, realm_oldlen;
-		Der_type realm_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &realm_type, 1, &realm_datalen, &l);
-		if (e == 0 && realm_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		realm_oldlen = len;
-		if (realm_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = realm_datalen;
-		e = decode_Realm(p, len, &(data)->realm, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = realm_oldlen - realm_datalen;
-	    }
-	    {
-		size_t sname_datalen, sname_oldlen;
-		Der_type sname_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &sname_type, 2, &sname_datalen, &l);
-		if (e == 0 && sname_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		sname_oldlen = len;
-		if (sname_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = sname_datalen;
-		e = decode_PrincipalName(p, len, &(data)->sname, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = sname_oldlen - sname_datalen;
-	    }
-	    {
-		size_t enc_part_datalen, enc_part_oldlen;
-		Der_type enc_part_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &enc_part_type, 3, &enc_part_datalen, &l);
-		if (e == 0 && enc_part_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		enc_part_oldlen = len;
-		if (enc_part_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = enc_part_datalen;
-		e = decode_EncryptedData(p, len, &(data)->enc_part, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = enc_part_oldlen - enc_part_datalen;
-	    }
-	    len = Top_Tag_oldlen - Top_Tag_datalen;
+	    *data = enumint;
 	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_Ticket(data);
+  fail:
+    free_AUTHDATA_TYPE(data);
     return e;
 }
 
-void
-free_Ticket(Ticket * data)
+void ASN1CALL
+free_AUTHDATA_TYPE(AUTHDATA_TYPE * data)
 {
-    free_krb5int32(&(data)->tkt_vno);
-    free_Realm(&(data)->realm);
-    free_PrincipalName(&(data)->sname);
-    free_EncryptedData(&(data)->enc_part);
 }
 
-size_t
-length_Ticket(const Ticket * data)
+size_t ASN1CALL
+length_AUTHDATA_TYPE(const AUTHDATA_TYPE * data)
 {
     size_t ret = 0;
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_krb5int32(&(data)->tkt_vno);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_Realm(&(data)->realm);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_PrincipalName(&(data)->sname);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_EncryptedData(&(data)->enc_part);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
     }
     ret += 1 + der_length_len(ret);
-    ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_Ticket(const Ticket * from, Ticket * to)
+int ASN1CALL
+copy_AUTHDATA_TYPE(const AUTHDATA_TYPE * from, AUTHDATA_TYPE * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_krb5int32(&(from)->tkt_vno, &(to)->tkt_vno))
-	goto fail;
-    if (copy_Realm(&(from)->realm, &(to)->realm))
-	goto fail;
-    if (copy_PrincipalName(&(from)->sname, &(to)->sname))
-	goto fail;
-    if (copy_EncryptedData(&(from)->enc_part, &(to)->enc_part))
-	goto fail;
+    *(to) = *(from);
     return 0;
-fail:
-    free_Ticket(to);
-    return ENOMEM;
 }
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_AuthorizationDataElement(unsigned char *p, size_t len, const AuthorizationDataElement * data, size_t * size)
+int ASN1CALL
+encode_CKSUMTYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, const CKSUMTYPE * data,
+		 size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
-/* ad-data */
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = der_put_octet_string(p, len, &(data)->ad_data, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	ret += Top_tag_oldret;
-    }
-/* ad-type */
     {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = encode_krb5int32(p, len, &(data)->ad_type, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	int enumint = (int) *data;
+	e = der_put_integer(p, len, &enumint, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_oldret;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+    ;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -521,19 +674,22 @@ encode_AuthorizationDataElement(unsigned char *p, size_t len, const Authorizatio
     return 0;
 }
 
-int
-decode_AuthorizationDataElement(const unsigned char *p, size_t len, AuthorizationDataElement * data, size_t * size)
+int ASN1CALL
+decode_CKSUMTYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, CKSUMTYPE * data,
+		 size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -548,220 +704,72 @@ decode_AuthorizationDataElement(const unsigned char *p, size_t len, Authorizatio
 	}
 	len = Top_datalen;
 	{
-	    size_t ad_type_datalen, ad_type_oldlen;
-	    Der_type ad_type_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &ad_type_type, 0, &ad_type_datalen, &l);
-	    if (e == 0 && ad_type_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    ad_type_oldlen = len;
-	    if (ad_type_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = ad_type_datalen;
-	    e = decode_krb5int32(p, len, &(data)->ad_type, &l);
+	    int enumint;
+	    e = der_get_integer(p, len, &enumint, &l);
 	    if (e)
 		goto fail;
 	    p += l;
 	    len -= l;
 	    ret += l;
-	    len = ad_type_oldlen - ad_type_datalen;
-	}
-	{
-	    size_t ad_data_datalen, ad_data_oldlen;
-	    Der_type ad_data_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &ad_data_type, 1, &ad_data_datalen, &l);
-	    if (e == 0 && ad_data_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    ad_data_oldlen = len;
-	    if (ad_data_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = ad_data_datalen;
-	    {
-		size_t ad_data_Tag_datalen, ad_data_Tag_oldlen;
-		Der_type ad_data_Tag_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &ad_data_Tag_type, UT_OctetString, &ad_data_Tag_datalen, &l);
-		if (e == 0 && ad_data_Tag_type != PRIM) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		ad_data_Tag_oldlen = len;
-		if (ad_data_Tag_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = ad_data_Tag_datalen;
-		e = der_get_octet_string(p, len, &(data)->ad_data, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = ad_data_Tag_oldlen - ad_data_Tag_datalen;
-	    }
-	    len = ad_data_oldlen - ad_data_datalen;
+	    *data = enumint;
 	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_AuthorizationDataElement(data);
+  fail:
+    free_CKSUMTYPE(data);
     return e;
 }
 
-void
-free_AuthorizationDataElement(AuthorizationDataElement * data)
+void ASN1CALL
+free_CKSUMTYPE(CKSUMTYPE * data)
 {
-    free_krb5int32(&(data)->ad_type);
-    der_free_octet_string(&(data)->ad_data);
 }
 
-size_t
-length_AuthorizationDataElement(const AuthorizationDataElement * data)
+size_t ASN1CALL
+length_CKSUMTYPE(const CKSUMTYPE * data)
 {
     size_t ret = 0;
     {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += length_krb5int32(&(data)->ad_type);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += der_length_octet_string(&(data)->ad_data);
-	ret += 1 + der_length_len(ret);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
     }
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_AuthorizationDataElement(const AuthorizationDataElement * from, AuthorizationDataElement * to)
+int ASN1CALL
+copy_CKSUMTYPE(const CKSUMTYPE * from, CKSUMTYPE * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_krb5int32(&(from)->ad_type, &(to)->ad_type))
-	goto fail;
-    if (der_copy_octet_string(&(from)->ad_data, &(to)->ad_data))
-	goto fail;
+    *(to) = *(from);
     return 0;
-fail:
-    free_AuthorizationDataElement(to);
-    return ENOMEM;
 }
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_EncryptedData(unsigned char *p, size_t len, const EncryptedData * data, size_t * size)
+int ASN1CALL
+encode_ENCTYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	       size_t len HEIMDAL_UNUSED_ATTRIBUTE, const ENCTYPE * data,
+	       size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
-/* cipher */
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = der_put_octet_string(p, len, &(data)->cipher, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	ret += Top_tag_oldret;
-    }
-/* kvno */
-    if ((data)->kvno) {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = encode_krb5int32(p, len, (data)->kvno, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	ret += Top_tag_oldret;
-    }
-/* etype */
     {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = encode_ENCTYPE(p, len, &(data)->etype, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	int enumint = (int) *data;
+	e = der_put_integer(p, len, &enumint, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_oldret;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+    ;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -772,19 +780,22 @@ encode_EncryptedData(unsigned char *p, size_t len, const EncryptedData * data, s
     return 0;
 }
 
-int
-decode_EncryptedData(const unsigned char *p, size_t len, EncryptedData * data, size_t * size)
+int ASN1CALL
+decode_ENCTYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	       size_t len HEIMDAL_UNUSED_ATTRIBUTE, ENCTYPE * data,
+	       size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -799,264 +810,163 @@ decode_EncryptedData(const unsigned char *p, size_t len, EncryptedData * data, s
 	}
 	len = Top_datalen;
 	{
-	    size_t etype_datalen, etype_oldlen;
-	    Der_type etype_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &etype_type, 0, &etype_datalen, &l);
-	    if (e == 0 && etype_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    etype_oldlen = len;
-	    if (etype_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = etype_datalen;
-	    e = decode_ENCTYPE(p, len, &(data)->etype, &l);
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    len = etype_oldlen - etype_datalen;
-	}
-	{
-	    size_t kvno_datalen, kvno_oldlen;
-	    Der_type kvno_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &kvno_type, 1, &kvno_datalen, &l);
-	    if (e == 0 && kvno_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e) {
-		(data)->kvno = NULL;
-	    } else {
-		(data)->kvno = calloc(1, sizeof(*(data)->kvno));
-		if ((data)->kvno == NULL) {
-		    e = ENOMEM;
-		    goto fail;
-		}
-		p += l;
-		len -= l;
-		ret += l;
-		kvno_oldlen = len;
-		if (kvno_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = kvno_datalen;
-		e = decode_krb5int32(p, len, (data)->kvno, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = kvno_oldlen - kvno_datalen;
-	    }
-	}
-	{
-	    size_t cipher_datalen, cipher_oldlen;
-	    Der_type cipher_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &cipher_type, 2, &cipher_datalen, &l);
-	    if (e == 0 && cipher_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
+	    int enumint;
+	    e = der_get_integer(p, len, &enumint, &l);
 	    if (e)
 		goto fail;
 	    p += l;
 	    len -= l;
 	    ret += l;
-	    cipher_oldlen = len;
-	    if (cipher_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = cipher_datalen;
-	    {
-		size_t cipher_Tag_datalen, cipher_Tag_oldlen;
-		Der_type cipher_Tag_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &cipher_Tag_type, UT_OctetString, &cipher_Tag_datalen, &l);
-		if (e == 0 && cipher_Tag_type != PRIM) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		cipher_Tag_oldlen = len;
-		if (cipher_Tag_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = cipher_Tag_datalen;
-		e = der_get_octet_string(p, len, &(data)->cipher, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = cipher_Tag_oldlen - cipher_Tag_datalen;
-	    }
-	    len = cipher_oldlen - cipher_datalen;
+	    *data = enumint;
 	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_EncryptedData(data);
+  fail:
+    free_ENCTYPE(data);
     return e;
 }
 
-void
-free_EncryptedData(EncryptedData * data)
+void ASN1CALL
+free_ENCTYPE(ENCTYPE * data)
 {
-    free_ENCTYPE(&(data)->etype);
-    if ((data)->kvno) {
-	free_krb5int32((data)->kvno);
-	free((data)->kvno);
-	(data)->kvno = NULL;
-    }
-    der_free_octet_string(&(data)->cipher);
 }
 
-size_t
-length_EncryptedData(const EncryptedData * data)
+size_t ASN1CALL
+length_ENCTYPE(const ENCTYPE * data)
 {
     size_t ret = 0;
     {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += length_ENCTYPE(&(data)->etype);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
-    if ((data)->kvno) {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += length_krb5int32((data)->kvno);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    } {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += der_length_octet_string(&(data)->cipher);
-	ret += 1 + der_length_len(ret);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
     }
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_EncryptedData(const EncryptedData * from, EncryptedData * to)
+int ASN1CALL
+copy_ENCTYPE(const ENCTYPE * from, ENCTYPE * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_ENCTYPE(&(from)->etype, &(to)->etype))
-	goto fail;
-    if ((from)->kvno) {
-	(to)->kvno = malloc(sizeof(*(to)->kvno));
-	if ((to)->kvno == NULL)
-	    goto fail;
-	if (copy_krb5int32((from)->kvno, (to)->kvno))
-	    goto fail;
-    } else
-	(to)->kvno = NULL;
-    if (der_copy_octet_string(&(from)->cipher, &(to)->cipher))
-	goto fail;
+    *(to) = *(from);
     return 0;
-fail:
-    free_EncryptedData(to);
-    return ENOMEM;
 }
 
+int ASN1CALL
+encode_krb5uint32(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		  size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		  const krb5uint32 * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
+    e = der_put_unsigned(p, len, data, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
 
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
+    *size = ret;
+    return 0;
+}
 
-int
-encode_PrincipalName(unsigned char *p, size_t len, const PrincipalName * data, size_t * size)
+int ASN1CALL
+decode_krb5uint32(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		  size_t len HEIMDAL_UNUSED_ATTRIBUTE, krb5uint32 * data,
+		  size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int i, e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
-/* name-string */
+    memset(data, 0, sizeof(*data));
     {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	for (i = (&(data)->name_string)->len - 1; i >= 0; --i) {
-	    size_t name_string_tag_tag_for_oldret = ret;
-	    ret = 0;
-	    e = der_put_general_string(p, len, &(&(data)->name_string)->val[i], &l);
-	    if (e)
-		return e;
-	    p -= l;
-	    len -= l;
-	    ret += l;
-
-	    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_GeneralString, &l);
-	    if (e)
-		return e;
-	    p -= l;
-	    len -= l;
-	    ret += l;
-
-	    ret += name_string_tag_tag_for_oldret;
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
+	    e = ASN1_BAD_ID;
 	}
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
 	if (e)
-	    return e;
-	p -= l;
+	    goto fail;
+	p += l;
 	len -= l;
 	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	e = der_get_unsigned(p, len, data, &l);
 	if (e)
-	    return e;
-	p -= l;
+	    goto fail;
+	p += l;
 	len -= l;
 	ret += l;
-
-	ret += Top_tag_oldret;
+	len = Top_oldlen - Top_datalen;
     }
-/* name-type */
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = encode_NAME_TYPE(p, len, &(data)->name_type, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_krb5uint32(data);
+    return e;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+void ASN1CALL
+free_krb5uint32(krb5uint32 * data)
+{
+}
 
-	ret += Top_tag_oldret;
-    }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+size_t ASN1CALL
+length_krb5uint32(const krb5uint32 * data)
+{
+    size_t ret = 0;
+    ret += der_length_unsigned(data);
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_krb5uint32(const krb5uint32 * from, krb5uint32 * to)
+{
+    memset(to, 0, sizeof(*to));
+    *(to) = *(from);
+    return 0;
+}
+
+int ASN1CALL
+encode_krb5int32(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, const krb5int32 * data,
+		 size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    e = der_put_integer(p, len, data, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -1067,19 +977,22 @@ encode_PrincipalName(unsigned char *p, size_t len, const PrincipalName * data, s
     return 0;
 }
 
-int
-decode_PrincipalName(const unsigned char *p, size_t len, PrincipalName * data, size_t * size)
+int ASN1CALL
+decode_krb5int32(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, krb5int32 * data,
+		 size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -1093,233 +1006,162 @@ decode_PrincipalName(const unsigned char *p, size_t len, PrincipalName * data, s
 	    goto fail;
 	}
 	len = Top_datalen;
-	{
-	    size_t name_type_datalen, name_type_oldlen;
-	    Der_type name_type_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &name_type_type, 0, &name_type_datalen, &l);
-	    if (e == 0 && name_type_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    name_type_oldlen = len;
-	    if (name_type_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = name_type_datalen;
-	    e = decode_NAME_TYPE(p, len, &(data)->name_type, &l);
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    len = name_type_oldlen - name_type_datalen;
-	}
-	{
-	    size_t name_string_datalen, name_string_oldlen;
-	    Der_type name_string_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &name_string_type, 1, &name_string_datalen, &l);
-	    if (e == 0 && name_string_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    name_string_oldlen = len;
-	    if (name_string_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = name_string_datalen;
-	    {
-		size_t name_string_Tag_datalen, name_string_Tag_oldlen;
-		Der_type name_string_Tag_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &name_string_Tag_type, UT_Sequence, &name_string_Tag_datalen, &l);
-		if (e == 0 && name_string_Tag_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		name_string_Tag_oldlen = len;
-		if (name_string_Tag_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = name_string_Tag_datalen;
-		{
-		    size_t name_string_Tag_Tag_origlen = len;
-		    size_t name_string_Tag_Tag_oldret = ret;
-		    size_t name_string_Tag_Tag_olen = 0;
-		    void *name_string_Tag_Tag_tmp;
-		    ret = 0;
-		    (&(data)->name_string)->len = 0;
-		    (&(data)->name_string)->val = NULL;
-		    while (ret < name_string_Tag_Tag_origlen) {
-			size_t name_string_Tag_Tag_nlen = name_string_Tag_Tag_olen + sizeof(*((&(data)->name_string)->val));
-			if (name_string_Tag_Tag_olen > name_string_Tag_Tag_nlen) {
-			    e = ASN1_OVERFLOW;
-			    goto fail;
-			}
-			name_string_Tag_Tag_olen = name_string_Tag_Tag_nlen;
-			name_string_Tag_Tag_tmp = realloc((&(data)->name_string)->val, name_string_Tag_Tag_olen);
-			if (name_string_Tag_Tag_tmp == NULL) {
-			    e = ENOMEM;
-			    goto fail;
-			}
-			(&(data)->name_string)->val = name_string_Tag_Tag_tmp;
-			{
-			    size_t name_string_Tag_Tag_s_of_datalen, name_string_Tag_Tag_s_of_oldlen;
-			    Der_type name_string_Tag_Tag_s_of_type;
-			    e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &name_string_Tag_Tag_s_of_type, UT_GeneralString, &name_string_Tag_Tag_s_of_datalen, &l);
-			    if (e == 0 && name_string_Tag_Tag_s_of_type != PRIM) {
-				e = ASN1_BAD_ID;
-			    }
-			    if (e)
-				goto fail;
-			    p += l;
-			    len -= l;
-			    ret += l;
-			    name_string_Tag_Tag_s_of_oldlen = len;
-			    if (name_string_Tag_Tag_s_of_datalen > len) {
-				e = ASN1_OVERRUN;
-				goto fail;
-			    }
-			    len = name_string_Tag_Tag_s_of_datalen;
-			    e = der_get_general_string(p, len, &(&(data)->name_string)->val[(&(data)->name_string)->len], &l);
-			    if (e)
-				goto fail;
-			    p += l;
-			    len -= l;
-			    ret += l;
-			    len = name_string_Tag_Tag_s_of_oldlen - name_string_Tag_Tag_s_of_datalen;
-			}
-			(&(data)->name_string)->len++;
-			len = name_string_Tag_Tag_origlen - ret;
-		    }
-		    ret += name_string_Tag_Tag_oldret;
-		}
-		len = name_string_Tag_oldlen - name_string_Tag_datalen;
-	    }
-	    len = name_string_oldlen - name_string_datalen;
-	}
+	e = der_get_integer(p, len, data, &l);
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_PrincipalName(data);
+  fail:
+    free_krb5int32(data);
     return e;
 }
 
-void
-free_PrincipalName(PrincipalName * data)
+void ASN1CALL
+free_krb5int32(krb5int32 * data)
 {
-    free_NAME_TYPE(&(data)->name_type);
-    while ((&(data)->name_string)->len) {
-	der_free_general_string(&(&(data)->name_string)->val[(&(data)->name_string)->len - 1]);
-	(&(data)->name_string)->len--;
-    }
-    free((&(data)->name_string)->val);
-    (&(data)->name_string)->val = NULL;
 }
 
-size_t
-length_PrincipalName(const PrincipalName * data)
+size_t ASN1CALL
+length_krb5int32(const krb5int32 * data)
 {
     size_t ret = 0;
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += length_NAME_TYPE(&(data)->name_type);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	{
-	    int name_string_tag_tag_oldret = ret;
-	    int i;
-	    ret = 0;
-	    for (i = (&(data)->name_string)->len - 1; i >= 0; --i) {
-		int name_string_tag_tag_for_oldret = ret;
-		ret = 0;
-		ret += der_length_general_string(&(&(data)->name_string)->val[i]);
-		ret += 1 + der_length_len(ret);
-		ret += name_string_tag_tag_for_oldret;
-	    }
-	    ret += name_string_tag_tag_oldret;
-	}
-	ret += 1 + der_length_len(ret);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
+    ret += der_length_integer(data);
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_PrincipalName(const PrincipalName * from, PrincipalName * to)
+int ASN1CALL
+copy_krb5int32(const krb5int32 * from, krb5int32 * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_NAME_TYPE(&(from)->name_type, &(to)->name_type))
-	goto fail;
-    if (((&(to)->name_string)->val = malloc((&(from)->name_string)->len * sizeof(*(&(to)->name_string)->val))) == NULL && (&(from)->name_string)->len != 0)
-	goto fail;
-    for ((&(to)->name_string)->len = 0; (&(to)->name_string)->len < (&(from)->name_string)->len; (&(to)->name_string)->len++) {
-	if (der_copy_general_string(&(&(from)->name_string)->val[(&(to)->name_string)->len], &(&(to)->name_string)->val[(&(to)->name_string)->len]))
-	    goto fail;
-    }
+    *(to) = *(from);
     return 0;
-fail:
-    free_PrincipalName(to);
-    return ENOMEM;
 }
 
+int ASN1CALL
+encode_KerberosString(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		      size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		      const KerberosString * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
+    e = der_put_general_string(p, len, data, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
 
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+			       UT_GeneralString, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
+    *size = ret;
+    return 0;
+}
 
-int
-encode_HostAddresses(unsigned char *p, size_t len, const HostAddresses * data, size_t * size)
+int ASN1CALL
+decode_KerberosString(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		      size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		      KerberosString * data, size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int i, e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
-    for (i = (data)->len - 1; i >= 0; --i) {
-	size_t Top_tag_for_oldret = ret;
-	ret = 0;
-	e = encode_HostAddress(p, len, &(data)->val[i], &l);
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_GeneralString, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
+	    e = ASN1_BAD_ID;
+	}
 	if (e)
-	    return e;
-	p -= l;
+	    goto fail;
+	p += l;
 	len -= l;
 	ret += l;
-
-	ret += Top_tag_for_oldret;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	e = der_get_general_string(p, len, data, &l);
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	len = Top_oldlen - Top_datalen;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_KerberosString(data);
+    return e;
+}
+
+void ASN1CALL
+free_KerberosString(KerberosString * data)
+{
+    der_free_general_string(data);
+}
+
+size_t ASN1CALL
+length_KerberosString(const KerberosString * data)
+{
+    size_t ret = 0;
+    ret += der_length_general_string(data);
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_KerberosString(const KerberosString * from, KerberosString * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (der_copy_general_string(from, to))
+	goto fail;
+    return 0;
+  fail:
+    free_KerberosString(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_Realm(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	     size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Realm * data,
+	     size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    e = der_put_general_string(p, len, data, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+			       UT_GeneralString, &l);
     if (e)
 	return e;
     p -= l;
@@ -1330,19 +1172,21 @@ encode_HostAddresses(unsigned char *p, size_t len, const HostAddresses * data, s
     return 0;
 }
 
-int
-decode_HostAddresses(const unsigned char *p, size_t len, HostAddresses * data, size_t * size)
+int ASN1CALL
+decode_Realm(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	     size_t len HEIMDAL_UNUSED_ATTRIBUTE, Realm * data, size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_GeneralString, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -1356,128 +1200,85 @@ decode_HostAddresses(const unsigned char *p, size_t len, HostAddresses * data, s
 	    goto fail;
 	}
 	len = Top_datalen;
-	{
-	    size_t Top_Tag_origlen = len;
-	    size_t Top_Tag_oldret = ret;
-	    size_t Top_Tag_olen = 0;
-	    void *Top_Tag_tmp;
-	    ret = 0;
-	    (data)->len = 0;
-	    (data)->val = NULL;
-	    while (ret < Top_Tag_origlen) {
-		size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
-		if (Top_Tag_olen > Top_Tag_nlen) {
-		    e = ASN1_OVERFLOW;
-		    goto fail;
-		}
-		Top_Tag_olen = Top_Tag_nlen;
-		Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
-		if (Top_Tag_tmp == NULL) {
-		    e = ENOMEM;
-		    goto fail;
-		}
-		(data)->val = Top_Tag_tmp;
-		e = decode_HostAddress(p, len, &(data)->val[(data)->len], &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		(data)->len++;
-		len = Top_Tag_origlen - ret;
-	    }
-	    ret += Top_Tag_oldret;
-	}
+	e = der_get_general_string(p, len, data, &l);
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_HostAddresses(data);
+  fail:
+    free_Realm(data);
     return e;
 }
 
-void
-free_HostAddresses(HostAddresses * data)
+void ASN1CALL
+free_Realm(Realm * data)
 {
-    while ((data)->len) {
-	free_HostAddress(&(data)->val[(data)->len - 1]);
-	(data)->len--;
-    }
-    free((data)->val);
-    (data)->val = NULL;
+    der_free_general_string(data);
 }
 
-size_t
-length_HostAddresses(const HostAddresses * data)
+size_t ASN1CALL
+length_Realm(const Realm * data)
 {
     size_t ret = 0;
-    {
-	int Top_tag_oldret = ret;
-	int i;
-	ret = 0;
-	for (i = (data)->len - 1; i >= 0; --i) {
-	    int Top_tag_for_oldret = ret;
-	    ret = 0;
-	    ret += length_HostAddress(&(data)->val[i]);
-	    ret += Top_tag_for_oldret;
-	}
-	ret += Top_tag_oldret;
-    }
+    ret += der_length_general_string(data);
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_HostAddresses(const HostAddresses * from, HostAddresses * to)
+int ASN1CALL
+copy_Realm(const Realm * from, Realm * to)
 {
     memset(to, 0, sizeof(*to));
-    if (((to)->val = malloc((from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
+    if (der_copy_general_string(from, to))
 	goto fail;
-    for ((to)->len = 0; (to)->len < (from)->len; (to)->len++) {
-	if (copy_HostAddress(&(from)->val[(to)->len], &(to)->val[(to)->len]))
-	    goto fail;
-    }
     return 0;
-fail:
-    free_HostAddresses(to);
+  fail:
+    free_Realm(to);
     return ENOMEM;
 }
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_HostAddress(unsigned char *p, size_t len, const HostAddress * data, size_t * size)
+int ASN1CALL
+encode_PrincipalName(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     const PrincipalName * data, size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
-/* address */
+/* name-string */
     {
-	size_t Top_tag_oldret = ret;
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
 	ret = 0;
-	e = der_put_octet_string(p, len, &(data)->address, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+	for (i = (int) (&(data)->name_string)->len - 1; i >= 0; --i) {
+	    size_t name_string_tag_tag_for_oldret = ret;
+	    ret = 0;
+	    e = der_put_general_string(p, len,
+				       &(&(data)->name_string)->val[i], &l);
+	    if (e)
+		return e;
+	    p -= l;
+	    len -= l;
+	    ret += l;
+
+	    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+				       UT_GeneralString, &l);
+	    if (e)
+		return e;
+	    p -= l;
+	    len -= l;
+	    ret += l;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
+	    ret += name_string_tag_tag_for_oldret;
+	}
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS,
+				   UT_Sequence, &l);
 	if (e)
 	    return e;
 	p -= l;
@@ -1493,11 +1294,11 @@ encode_HostAddress(unsigned char *p, size_t len, const HostAddress * data, size_
 
 	ret += Top_tag_oldret;
     }
-/* addr-type */
+/* name-type */
     {
-	size_t Top_tag_oldret = ret;
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
 	ret = 0;
-	e = encode_krb5int32(p, len, &(data)->addr_type, &l);
+	e = encode_NAME_TYPE(p, len, &(data)->name_type, &l);
 	if (e)
 	    return e;
 	p -= l;
@@ -1513,7 +1314,8 @@ encode_HostAddress(unsigned char *p, size_t len, const HostAddress * data, size_
 
 	ret += Top_tag_oldret;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -1524,18 +1326,21 @@ encode_HostAddress(unsigned char *p, size_t len, const HostAddress * data, size_
     return 0;
 }
 
-int
-decode_HostAddress(const unsigned char *p, size_t len, HostAddress * data, size_t * size)
+int ASN1CALL
+decode_PrincipalName(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     PrincipalName * data, size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
 	if (e == 0 && Top_type != CONS) {
 	    e = ASN1_BAD_ID;
 	}
@@ -1551,10 +1356,12 @@ decode_HostAddress(const unsigned char *p, size_t len, HostAddress * data, size_
 	}
 	len = Top_datalen;
 	{
-	    size_t addr_type_datalen, addr_type_oldlen;
-	    Der_type addr_type_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &addr_type_type, 0, &addr_type_datalen, &l);
-	    if (e == 0 && addr_type_type != CONS) {
+	    size_t name_type_datalen, name_type_oldlen;
+	    Der_type name_type_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &name_type_type, 0,
+					 &name_type_datalen, &l);
+	    if (e == 0 && name_type_type != CONS) {
 		e = ASN1_BAD_ID;
 	    }
 	    if (e)
@@ -1562,25 +1369,27 @@ decode_HostAddress(const unsigned char *p, size_t len, HostAddress * data, size_
 	    p += l;
 	    len -= l;
 	    ret += l;
-	    addr_type_oldlen = len;
-	    if (addr_type_datalen > len) {
+	    name_type_oldlen = len;
+	    if (name_type_datalen > len) {
 		e = ASN1_OVERRUN;
 		goto fail;
 	    }
-	    len = addr_type_datalen;
-	    e = decode_krb5int32(p, len, &(data)->addr_type, &l);
+	    len = name_type_datalen;
+	    e = decode_NAME_TYPE(p, len, &(data)->name_type, &l);
 	    if (e)
 		goto fail;
 	    p += l;
 	    len -= l;
 	    ret += l;
-	    len = addr_type_oldlen - addr_type_datalen;
+	    len = name_type_oldlen - name_type_datalen;
 	}
 	{
-	    size_t address_datalen, address_oldlen;
-	    Der_type address_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &address_type, 1, &address_datalen, &l);
-	    if (e == 0 && address_type != CONS) {
+	    size_t name_string_datalen, name_string_oldlen;
+	    Der_type name_string_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &name_string_type, 1,
+					 &name_string_datalen, &l);
+	    if (e == 0 && name_string_type != CONS) {
 		e = ASN1_BAD_ID;
 	    }
 	    if (e)
@@ -1588,17 +1397,20 @@ decode_HostAddress(const unsigned char *p, size_t len, HostAddress * data, size_
 	    p += l;
 	    len -= l;
 	    ret += l;
-	    address_oldlen = len;
-	    if (address_datalen > len) {
+	    name_string_oldlen = len;
+	    if (name_string_datalen > len) {
 		e = ASN1_OVERRUN;
 		goto fail;
 	    }
-	    len = address_datalen;
+	    len = name_string_datalen;
 	    {
-		size_t address_Tag_datalen, address_Tag_oldlen;
-		Der_type address_Tag_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &address_Tag_type, UT_OctetString, &address_Tag_datalen, &l);
-		if (e == 0 && address_Tag_type != PRIM) {
+		size_t name_string_Tag_datalen, name_string_Tag_oldlen;
+		Der_type name_string_Tag_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+					     &name_string_Tag_type,
+					     UT_Sequence,
+					     &name_string_Tag_datalen, &l);
+		if (e == 0 && name_string_Tag_type != CONS) {
 		    e = ASN1_BAD_ID;
 		}
 		if (e)
@@ -1606,54 +1418,139 @@ decode_HostAddress(const unsigned char *p, size_t len, HostAddress * data, size_
 		p += l;
 		len -= l;
 		ret += l;
-		address_Tag_oldlen = len;
-		if (address_Tag_datalen > len) {
+		name_string_Tag_oldlen = len;
+		if (name_string_Tag_datalen > len) {
 		    e = ASN1_OVERRUN;
 		    goto fail;
 		}
-		len = address_Tag_datalen;
-		e = der_get_octet_string(p, len, &(data)->address, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = address_Tag_oldlen - address_Tag_datalen;
+		len = name_string_Tag_datalen;
+		{
+		    size_t name_string_Tag_Tag_origlen = len;
+		    size_t name_string_Tag_Tag_oldret = ret;
+		    size_t name_string_Tag_Tag_olen = 0;
+		    void *name_string_Tag_Tag_tmp;
+		    ret = 0;
+		    (&(data)->name_string)->len = 0;
+		    (&(data)->name_string)->val = NULL;
+		    while (ret < name_string_Tag_Tag_origlen) {
+			size_t name_string_Tag_Tag_nlen =
+			    name_string_Tag_Tag_olen +
+			    sizeof(*((&(data)->name_string)->val));
+			if (name_string_Tag_Tag_olen >
+			    name_string_Tag_Tag_nlen) {
+			    e = ASN1_OVERFLOW;
+			    goto fail;
+			}
+			name_string_Tag_Tag_olen = name_string_Tag_Tag_nlen;
+			name_string_Tag_Tag_tmp =
+			    realloc((&(data)->name_string)->val,
+				    name_string_Tag_Tag_olen);
+			if (name_string_Tag_Tag_tmp == NULL) {
+			    e = ENOMEM;
+			    goto fail;
+			}
+			(&(data)->name_string)->val = name_string_Tag_Tag_tmp;
+			{
+			    size_t name_string_Tag_Tag_s_of_datalen,
+				name_string_Tag_Tag_s_of_oldlen;
+			    Der_type name_string_Tag_Tag_s_of_type;
+			    e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+							 &name_string_Tag_Tag_s_of_type,
+							 UT_GeneralString,
+							 &name_string_Tag_Tag_s_of_datalen,
+							 &l);
+			    if (e == 0
+				&& name_string_Tag_Tag_s_of_type != PRIM) {
+				e = ASN1_BAD_ID;
+			    }
+			    if (e)
+				goto fail;
+			    p += l;
+			    len -= l;
+			    ret += l;
+			    name_string_Tag_Tag_s_of_oldlen = len;
+			    if (name_string_Tag_Tag_s_of_datalen > len) {
+				e = ASN1_OVERRUN;
+				goto fail;
+			    }
+			    len = name_string_Tag_Tag_s_of_datalen;
+			    e = der_get_general_string(p, len,
+						       &(&(data)->
+							 name_string)->
+						       val[(&(data)->
+							    name_string)->
+							   len], &l);
+			    if (e)
+				goto fail;
+			    p += l;
+			    len -= l;
+			    ret += l;
+			    len =
+				name_string_Tag_Tag_s_of_oldlen -
+				name_string_Tag_Tag_s_of_datalen;
+			}
+			(&(data)->name_string)->len++;
+			len = name_string_Tag_Tag_origlen - ret;
+		    }
+		    ret += name_string_Tag_Tag_oldret;
+		}
+		len = name_string_Tag_oldlen - name_string_Tag_datalen;
 	    }
-	    len = address_oldlen - address_datalen;
+	    len = name_string_oldlen - name_string_datalen;
 	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_HostAddress(data);
+  fail:
+    free_PrincipalName(data);
     return e;
 }
 
-void
-free_HostAddress(HostAddress * data)
+void ASN1CALL
+free_PrincipalName(PrincipalName * data)
 {
-    free_krb5int32(&(data)->addr_type);
-    der_free_octet_string(&(data)->address);
+    free_NAME_TYPE(&(data)->name_type);
+    while ((&(data)->name_string)->len) {
+	der_free_general_string(&(&(data)->name_string)->
+				val[(&(data)->name_string)->len - 1]);
+	(&(data)->name_string)->len--;
+    }
+    free((&(data)->name_string)->val);
+    (&(data)->name_string)->val = NULL;
 }
 
-size_t
-length_HostAddress(const HostAddress * data)
+size_t ASN1CALL
+length_PrincipalName(const PrincipalName * data)
 {
     size_t ret = 0;
     {
 	size_t Top_tag_oldret = ret;
 	ret = 0;
-	ret += length_krb5int32(&(data)->addr_type);
+	ret += length_NAME_TYPE(&(data)->name_type);
 	ret += 1 + der_length_len(ret);
 	ret += Top_tag_oldret;
     }
     {
 	size_t Top_tag_oldret = ret;
 	ret = 0;
-	ret += der_length_octet_string(&(data)->address);
+	{
+	    size_t name_string_tag_tag_oldret = ret;
+	    unsigned int n_name_string_tag_tag;
+	    ret = 0;
+	    for (n_name_string_tag_tag = (&(data)->name_string)->len;
+		 n_name_string_tag_tag > 0; --n_name_string_tag_tag) {
+		size_t name_string_tag_tag_for_oldret = ret;
+		ret = 0;
+		ret +=
+		    der_length_general_string(&(&(data)->name_string)->
+					      val[n_name_string_tag_tag - 1]);
+		ret += 1 + der_length_len(ret);
+		ret += name_string_tag_tag_for_oldret;
+	    }
+	    ret += name_string_tag_tag_oldret;
+	}
 	ret += 1 + der_length_len(ret);
 	ret += 1 + der_length_len(ret);
 	ret += Top_tag_oldret;
@@ -1662,54 +1559,82 @@ length_HostAddress(const HostAddress * data)
     return ret;
 }
 
-int
-copy_HostAddress(const HostAddress * from, HostAddress * to)
+int ASN1CALL
+copy_PrincipalName(const PrincipalName * from, PrincipalName * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_krb5int32(&(from)->addr_type, &(to)->addr_type))
+    if (copy_NAME_TYPE(&(from)->name_type, &(to)->name_type))
 	goto fail;
-    if (der_copy_octet_string(&(from)->address, &(to)->address))
+    if (((&(to)->name_string)->val =
+	 malloc((&(from)->name_string)->len *
+		sizeof(*(&(to)->name_string)->val))) == NULL
+	&& (&(from)->name_string)->len != 0)
 	goto fail;
+    for ((&(to)->name_string)->len = 0;
+	 (&(to)->name_string)->len < (&(from)->name_string)->len;
+	 (&(to)->name_string)->len++) {
+	if (der_copy_general_string
+	    (&(&(from)->name_string)->val[(&(to)->name_string)->len],
+	     &(&(to)->name_string)->val[(&(to)->name_string)->len]))
+	    goto fail;
+    }
     return 0;
-fail:
-    free_HostAddress(to);
+  fail:
+    free_PrincipalName(to);
     return ENOMEM;
 }
 
+int ASN1CALL
+encode_Principal(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Principal * data,
+		 size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
+/* realm */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_Realm(p, len, &(data)->realm, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
 
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_AuthorizationData(unsigned char *p, size_t len, const AuthorizationData * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int i, e;
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
 
-    i = 0;
-    for (i = (data)->len - 1; i >= 0; --i) {
-	size_t Top_tag_for_oldret = ret;
+	ret += Top_tag_oldret;
+    }
+/* name */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
 	ret = 0;
-	e = encode_AuthorizationDataElement(p, len, &(data)->val[i], &l);
+	e = encode_PrincipalName(p, len, &(data)->name, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_for_oldret;
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -1720,18 +1645,21 @@ encode_AuthorizationData(unsigned char *p, size_t len, const AuthorizationData *
     return 0;
 }
 
-int
-decode_AuthorizationData(const unsigned char *p, size_t len, AuthorizationData * data, size_t * size)
+int ASN1CALL
+decode_Principal(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, Principal * data,
+		 size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
 	if (e == 0 && Top_type != CONS) {
 	    e = ASN1_BAD_ID;
 	}
@@ -1747,380 +1675,554 @@ decode_AuthorizationData(const unsigned char *p, size_t len, AuthorizationData *
 	}
 	len = Top_datalen;
 	{
-	    size_t Top_Tag_origlen = len;
-	    size_t Top_Tag_oldret = ret;
-	    size_t Top_Tag_olen = 0;
-	    void *Top_Tag_tmp;
-	    ret = 0;
-	    (data)->len = 0;
-	    (data)->val = NULL;
-	    while (ret < Top_Tag_origlen) {
-		size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
-		if (Top_Tag_olen > Top_Tag_nlen) {
-		    e = ASN1_OVERFLOW;
-		    goto fail;
-		}
-		Top_Tag_olen = Top_Tag_nlen;
-		Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
-		if (Top_Tag_tmp == NULL) {
-		    e = ENOMEM;
-		    goto fail;
-		}
-		(data)->val = Top_Tag_tmp;
-		e = decode_AuthorizationDataElement(p, len, &(data)->val[(data)->len], &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		(data)->len++;
-		len = Top_Tag_origlen - ret;
+	    size_t name_datalen, name_oldlen;
+	    Der_type name_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &name_type,
+					 0, &name_datalen, &l);
+	    if (e == 0 && name_type != CONS) {
+		e = ASN1_BAD_ID;
 	    }
-	    ret += Top_Tag_oldret;
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    name_oldlen = len;
+	    if (name_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = name_datalen;
+	    e = decode_PrincipalName(p, len, &(data)->name, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = name_oldlen - name_datalen;
+	}
+	{
+	    size_t realm_datalen, realm_oldlen;
+	    Der_type realm_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &realm_type,
+					 1, &realm_datalen, &l);
+	    if (e == 0 && realm_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    realm_oldlen = len;
+	    if (realm_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = realm_datalen;
+	    e = decode_Realm(p, len, &(data)->realm, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = realm_oldlen - realm_datalen;
 	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_AuthorizationData(data);
+  fail:
+    free_Principal(data);
     return e;
 }
 
-void
-free_AuthorizationData(AuthorizationData * data)
+void ASN1CALL
+free_Principal(Principal * data)
 {
-    while ((data)->len) {
-	free_AuthorizationDataElement(&(data)->val[(data)->len - 1]);
-	(data)->len--;
-    }
-    free((data)->val);
-    (data)->val = NULL;
+    free_PrincipalName(&(data)->name);
+    free_Realm(&(data)->realm);
 }
 
-size_t
-length_AuthorizationData(const AuthorizationData * data)
+size_t ASN1CALL
+length_Principal(const Principal * data)
 {
     size_t ret = 0;
     {
-	int Top_tag_oldret = ret;
-	int i;
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += length_PrincipalName(&(data)->name);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    {
+	size_t Top_tag_oldret = ret;
 	ret = 0;
-	for (i = (data)->len - 1; i >= 0; --i) {
-	    int Top_tag_for_oldret = ret;
-	    ret = 0;
-	    ret += length_AuthorizationDataElement(&(data)->val[i]);
-	    ret += Top_tag_for_oldret;
-	}
+	ret += length_Realm(&(data)->realm);
+	ret += 1 + der_length_len(ret);
 	ret += Top_tag_oldret;
     }
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_AuthorizationData(const AuthorizationData * from, AuthorizationData * to)
+int ASN1CALL
+copy_Principal(const Principal * from, Principal * to)
 {
     memset(to, 0, sizeof(*to));
-    if (((to)->val = malloc((from)->len * sizeof(*(to)->val))) == NULL && (from)->len != 0)
+    if (copy_PrincipalName(&(from)->name, &(to)->name))
+	goto fail;
+    if (copy_Realm(&(from)->realm, &(to)->realm))
 	goto fail;
-    for ((to)->len = 0; (to)->len < (from)->len; (to)->len++) {
-	if (copy_AuthorizationDataElement(&(from)->val[(to)->len], &(to)->val[(to)->len]))
-	    goto fail;
-    }
     return 0;
-fail:
-    free_AuthorizationData(to);
+  fail:
+    free_Principal(to);
     return ENOMEM;
 }
 
-int
-add_AuthorizationData(AuthorizationData * data, const AuthorizationDataElement * element)
+int ASN1CALL
+encode_Principals(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		  size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		  const Principals * data, size_t * size)
 {
-    int ret;
-    void *ptr;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    ptr = realloc(data->val,
-		  (data->len + 1) * sizeof(data->val[0]));
-    if (ptr == NULL)
-	return ENOMEM;
-    data->val = ptr;
+    for (i = (int) (data)->len - 1; i >= 0; --i) {
+	size_t Top_tag_for_oldret = ret;
+	ret = 0;
+	e = encode_Principal(p, len, &(data)->val[i], &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
 
-    ret = copy_AuthorizationDataElement(element, &data->val[data->len]);
-    if (ret)
+	ret += Top_tag_for_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_Principals(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		  size_t len HEIMDAL_UNUSED_ATTRIBUTE, Principals * data,
+		  size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t Top_Tag_origlen = len;
+	    size_t Top_Tag_oldret = ret;
+	    size_t Top_Tag_olen = 0;
+	    void *Top_Tag_tmp;
+	    ret = 0;
+	    (data)->len = 0;
+	    (data)->val = NULL;
+	    while (ret < Top_Tag_origlen) {
+		size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
+		if (Top_Tag_olen > Top_Tag_nlen) {
+		    e = ASN1_OVERFLOW;
+		    goto fail;
+		}
+		Top_Tag_olen = Top_Tag_nlen;
+		Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
+		if (Top_Tag_tmp == NULL) {
+		    e = ENOMEM;
+		    goto fail;
+		}
+		(data)->val = Top_Tag_tmp;
+		e = decode_Principal(p, len, &(data)->val[(data)->len], &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		(data)->len++;
+		len = Top_Tag_origlen - ret;
+	    }
+	    ret += Top_Tag_oldret;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_Principals(data);
+    return e;
+}
+
+void ASN1CALL
+free_Principals(Principals * data)
+{
+    while ((data)->len) {
+	free_Principal(&(data)->val[(data)->len - 1]);
+	(data)->len--;
+    }
+    free((data)->val);
+    (data)->val = NULL;
+}
+
+size_t ASN1CALL
+length_Principals(const Principals * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_oldret = ret;
+	unsigned int n_Top_tag;
+	ret = 0;
+	for (n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag) {
+	    size_t Top_tag_for_oldret = ret;
+	    ret = 0;
+	    ret += length_Principal(&(data)->val[n_Top_tag - 1]);
+	    ret += Top_tag_for_oldret;
+	}
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_Principals(const Principals * from, Principals * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (((to)->val = malloc((from)->len * sizeof(*(to)->val))) == NULL
+	&& (from)->len != 0)
+	goto fail;
+    for ((to)->len = 0; (to)->len < (from)->len; (to)->len++) {
+	if (copy_Principal(&(from)->val[(to)->len], &(to)->val[(to)->len]))
+	    goto fail;
+    }
+    return 0;
+  fail:
+    free_Principals(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+add_Principals(Principals * data, const Principal * element)
+{
+    int ret;
+    void *ptr;
+
+    ptr = realloc(data->val, (data->len + 1) * sizeof(data->val[0]));
+    if (ptr == NULL)
+	return ENOMEM;
+    data->val = ptr;
+
+    ret = copy_Principal(element, &data->val[data->len]);
+    if (ret)
 	return ret;
     data->len++;
     return 0;
 }
 
-int
-remove_AuthorizationData(AuthorizationData * data, unsigned int element)
+int ASN1CALL
+remove_Principals(Principals * data, unsigned int element)
 {
     void *ptr;
 
     if (data->len == 0 || element >= data->len)
 	return ASN1_OVERRUN;
-    free_AuthorizationDataElement(&data->val[element]);
+    free_Principal(&data->val[element]);
     data->len--;
     if (element < data->len)
 	memmove(&data->val[element], &data->val[element + 1],
-		sizeof(data->val[0]) * data->len);
+		sizeof(data->val[0]) * (data->len - element));
     ptr = realloc(data->val, data->len * sizeof(data->val[0]));
     if (ptr != NULL || data->len == 0)
 	data->val = ptr;
     return 0;
 }
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_EncTicketPart(unsigned char *p, size_t len, const EncTicketPart * data, size_t * size)
+int ASN1CALL
+encode_HostAddress(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		   size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		   const HostAddress * data, size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
-/* authorization-data */
-    if ((data)->authorization_data) {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_AuthorizationData(p, len, (data)->authorization_data, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 10, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	ret += Top_tag_tag_oldret;
-    }
-/* caddr */
-    if ((data)->caddr) {
-	size_t Top_tag_tag_oldret = ret;
+/* address */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
 	ret = 0;
-	e = encode_HostAddresses(p, len, (data)->caddr, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 9, &l);
+	e = der_put_octet_string(p, len, &(data)->address, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
-    }
-/* renew-till */
-    if ((data)->renew_till) {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_KerberosTime(p, len, (data)->renew_till, &l);
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+				   UT_OctetString, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 8, &l);
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
+	ret += Top_tag_oldret;
     }
-/* endtime */
+/* addr-type */
     {
-	size_t Top_tag_tag_oldret = ret;
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
 	ret = 0;
-	e = encode_KerberosTime(p, len, &(data)->endtime, &l);
+	e = encode_krb5int32(p, len, &(data)->addr_type, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 7, &l);
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
+	ret += Top_tag_oldret;
     }
-/* starttime */
-    if ((data)->starttime) {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_KerberosTime(p, len, (data)->starttime, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 6, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
 
-	ret += Top_tag_tag_oldret;
-    }
-/* authtime */
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_KerberosTime(p, len, &(data)->authtime, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    *size = ret;
+    return 0;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 5, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+int ASN1CALL
+decode_HostAddress(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		   size_t len HEIMDAL_UNUSED_ATTRIBUTE, HostAddress * data,
+		   size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	ret += Top_tag_tag_oldret;
-    }
-/* transited */
+    memset(data, 0, sizeof(*data));
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_TransitedEncoding(p, len, &(data)->transited, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 4, &l);
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
 	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	ret += Top_tag_tag_oldret;
-    }
-/* cname */
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_PrincipalName(p, len, &(data)->cname, &l);
-	if (e)
-	    return e;
-	p -= l;
+	    goto fail;
+	p += l;
 	len -= l;
 	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t addr_type_datalen, addr_type_oldlen;
+	    Der_type addr_type_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &addr_type_type, 0,
+					 &addr_type_datalen, &l);
+	    if (e == 0 && addr_type_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    addr_type_oldlen = len;
+	    if (addr_type_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = addr_type_datalen;
+	    e = decode_krb5int32(p, len, &(data)->addr_type, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = addr_type_oldlen - addr_type_datalen;
+	}
+	{
+	    size_t address_datalen, address_oldlen;
+	    Der_type address_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &address_type, 1, &address_datalen,
+					 &l);
+	    if (e == 0 && address_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    address_oldlen = len;
+	    if (address_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = address_datalen;
+	    {
+		size_t address_Tag_datalen, address_Tag_oldlen;
+		Der_type address_Tag_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+					     &address_Tag_type,
+					     UT_OctetString,
+					     &address_Tag_datalen, &l);
+		if (e == 0 && address_Tag_type != PRIM) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		address_Tag_oldlen = len;
+		if (address_Tag_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = address_Tag_datalen;
+		e = der_get_octet_string(p, len, &(data)->address, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = address_Tag_oldlen - address_Tag_datalen;
+	    }
+	    len = address_oldlen - address_datalen;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_HostAddress(data);
+    return e;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+void ASN1CALL
+free_HostAddress(HostAddress * data)
+{
+    free_krb5int32(&(data)->addr_type);
+    der_free_octet_string(&(data)->address);
+}
 
-	ret += Top_tag_tag_oldret;
-    }
-/* crealm */
+size_t ASN1CALL
+length_HostAddress(const HostAddress * data)
+{
+    size_t ret = 0;
     {
-	size_t Top_tag_tag_oldret = ret;
+	size_t Top_tag_oldret = ret;
 	ret = 0;
-	e = encode_Realm(p, len, &(data)->crealm, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	ret += Top_tag_tag_oldret;
+	ret += length_krb5int32(&(data)->addr_type);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
     }
-/* key */
     {
-	size_t Top_tag_tag_oldret = ret;
+	size_t Top_tag_oldret = ret;
 	ret = 0;
-	e = encode_EncryptionKey(p, len, &(data)->key, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+	ret += der_length_octet_string(&(data)->address);
+	ret += 1 + der_length_len(ret);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+int ASN1CALL
+copy_HostAddress(const HostAddress * from, HostAddress * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (copy_krb5int32(&(from)->addr_type, &(to)->addr_type))
+	goto fail;
+    if (der_copy_octet_string(&(from)->address, &(to)->address))
+	goto fail;
+    return 0;
+  fail:
+    free_HostAddress(to);
+    return ENOMEM;
+}
 
-	ret += Top_tag_tag_oldret;
-    }
-/* flags */
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	e = encode_TicketFlags(p, len, &(data)->flags, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+int ASN1CALL
+encode_HostAddresses(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     const HostAddresses * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+    for (i = (int) (data)->len - 1; i >= 0; --i) {
+	size_t Top_tag_for_oldret = ret;
+	ret = 0;
+	e = encode_HostAddress(p, len, &(data)->val[i], &l);
 	if (e)
 	    return e;
 	p -= l;
 	len -= l;
 	ret += l;
 
-	ret += Top_tag_tag_oldret;
+	ret += Top_tag_for_oldret;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
-
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_APPL, CONS, 3, &l);
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -2131,18 +2233,21 @@ encode_EncTicketPart(unsigned char *p, size_t len, const EncTicketPart * data, s
     return 0;
 }
 
-int
-decode_EncTicketPart(const unsigned char *p, size_t len, EncTicketPart * data, size_t * size)
+int ASN1CALL
+decode_HostAddresses(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     HostAddresses * data, size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_APPL, &Top_type, 3, &Top_datalen, &l);
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
 	if (e == 0 && Top_type != CONS) {
 	    e = ASN1_BAD_ID;
 	}
@@ -2158,80 +2263,347 @@ decode_EncTicketPart(const unsigned char *p, size_t len, EncTicketPart * data, s
 	}
 	len = Top_datalen;
 	{
-	    size_t Top_Tag_datalen, Top_Tag_oldlen;
-	    Der_type Top_Tag_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_type, UT_Sequence, &Top_Tag_datalen, &l);
-	    if (e == 0 && Top_Tag_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    Top_Tag_oldlen = len;
-	    if (Top_Tag_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = Top_Tag_datalen;
-	    {
-		size_t flags_datalen, flags_oldlen;
-		Der_type flags_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &flags_type, 0, &flags_datalen, &l);
-		if (e == 0 && flags_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		flags_oldlen = len;
-		if (flags_datalen > len) {
-		    e = ASN1_OVERRUN;
+	    size_t Top_Tag_origlen = len;
+	    size_t Top_Tag_oldret = ret;
+	    size_t Top_Tag_olen = 0;
+	    void *Top_Tag_tmp;
+	    ret = 0;
+	    (data)->len = 0;
+	    (data)->val = NULL;
+	    while (ret < Top_Tag_origlen) {
+		size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
+		if (Top_Tag_olen > Top_Tag_nlen) {
+		    e = ASN1_OVERFLOW;
 		    goto fail;
 		}
-		len = flags_datalen;
-		e = decode_TicketFlags(p, len, &(data)->flags, &l);
-		if (e)
+		Top_Tag_olen = Top_Tag_nlen;
+		Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
+		if (Top_Tag_tmp == NULL) {
+		    e = ENOMEM;
 		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = flags_oldlen - flags_datalen;
-	    }
-	    {
-		size_t key_datalen, key_oldlen;
-		Der_type key_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &key_type, 1, &key_datalen, &l);
-		if (e == 0 && key_type != CONS) {
-		    e = ASN1_BAD_ID;
 		}
+		(data)->val = Top_Tag_tmp;
+		e = decode_HostAddress(p, len, &(data)->val[(data)->len], &l);
 		if (e)
 		    goto fail;
 		p += l;
 		len -= l;
 		ret += l;
-		key_oldlen = len;
-		if (key_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = key_datalen;
-		e = decode_EncryptionKey(p, len, &(data)->key, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = key_oldlen - key_datalen;
+		(data)->len++;
+		len = Top_Tag_origlen - ret;
+	    }
+	    ret += Top_Tag_oldret;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_HostAddresses(data);
+    return e;
+}
+
+void ASN1CALL
+free_HostAddresses(HostAddresses * data)
+{
+    while ((data)->len) {
+	free_HostAddress(&(data)->val[(data)->len - 1]);
+	(data)->len--;
+    }
+    free((data)->val);
+    (data)->val = NULL;
+}
+
+size_t ASN1CALL
+length_HostAddresses(const HostAddresses * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_oldret = ret;
+	unsigned int n_Top_tag;
+	ret = 0;
+	for (n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag) {
+	    size_t Top_tag_for_oldret = ret;
+	    ret = 0;
+	    ret += length_HostAddress(&(data)->val[n_Top_tag - 1]);
+	    ret += Top_tag_for_oldret;
+	}
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_HostAddresses(const HostAddresses * from, HostAddresses * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (((to)->val = malloc((from)->len * sizeof(*(to)->val))) == NULL
+	&& (from)->len != 0)
+	goto fail;
+    for ((to)->len = 0; (to)->len < (from)->len; (to)->len++) {
+	if (copy_HostAddress(&(from)->val[(to)->len], &(to)->val[(to)->len]))
+	    goto fail;
+    }
+    return 0;
+  fail:
+    free_HostAddresses(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_KerberosTime(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		    size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		    const KerberosTime * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    e = der_put_generalized_time(p, len, data, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+			       UT_GeneralizedTime, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_KerberosTime(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		    size_t len HEIMDAL_UNUSED_ATTRIBUTE, KerberosTime * data,
+		    size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_GeneralizedTime, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	e = der_get_generalized_time(p, len, data, &l);
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_KerberosTime(data);
+    return e;
+}
+
+void ASN1CALL
+free_KerberosTime(KerberosTime * data)
+{
+}
+
+size_t ASN1CALL
+length_KerberosTime(const KerberosTime * data)
+{
+    size_t ret = 0;
+    ret += der_length_generalized_time(data);
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_KerberosTime(const KerberosTime * from, KerberosTime * to)
+{
+    memset(to, 0, sizeof(*to));
+    *(to) = *(from);
+    return 0;
+}
+
+int ASN1CALL
+encode_AuthorizationDataElement(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+				size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+				const AuthorizationDataElement * data,
+				size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+/* ad-data */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = der_put_octet_string(p, len, &(data)->ad_data, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+				   UT_OctetString, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+/* ad-type */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_krb5int32(p, len, &(data)->ad_type, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_AuthorizationDataElement(const unsigned char *p
+				HEIMDAL_UNUSED_ATTRIBUTE,
+				size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+				AuthorizationDataElement * data,
+				size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t ad_type_datalen, ad_type_oldlen;
+	    Der_type ad_type_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &ad_type_type, 0, &ad_type_datalen,
+					 &l);
+	    if (e == 0 && ad_type_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    ad_type_oldlen = len;
+	    if (ad_type_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = ad_type_datalen;
+	    e = decode_krb5int32(p, len, &(data)->ad_type, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = ad_type_oldlen - ad_type_datalen;
+	}
+	{
+	    size_t ad_data_datalen, ad_data_oldlen;
+	    Der_type ad_data_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &ad_data_type, 1, &ad_data_datalen,
+					 &l);
+	    if (e == 0 && ad_data_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    ad_data_oldlen = len;
+	    if (ad_data_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
 	    }
+	    len = ad_data_datalen;
 	    {
-		size_t crealm_datalen, crealm_oldlen;
-		Der_type crealm_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &crealm_type, 2, &crealm_datalen, &l);
-		if (e == 0 && crealm_type != CONS) {
+		size_t ad_data_Tag_datalen, ad_data_Tag_oldlen;
+		Der_type ad_data_Tag_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+					     &ad_data_Tag_type,
+					     UT_OctetString,
+					     &ad_data_Tag_datalen, &l);
+		if (e == 0 && ad_data_Tag_type != PRIM) {
 		    e = ASN1_BAD_ID;
 		}
 		if (e)
@@ -2239,470 +2611,100 @@ decode_EncTicketPart(const unsigned char *p, size_t len, EncTicketPart * data, s
 		p += l;
 		len -= l;
 		ret += l;
-		crealm_oldlen = len;
-		if (crealm_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = crealm_datalen;
-		e = decode_Realm(p, len, &(data)->crealm, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = crealm_oldlen - crealm_datalen;
-	    }
-	    {
-		size_t cname_datalen, cname_oldlen;
-		Der_type cname_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &cname_type, 3, &cname_datalen, &l);
-		if (e == 0 && cname_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		cname_oldlen = len;
-		if (cname_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = cname_datalen;
-		e = decode_PrincipalName(p, len, &(data)->cname, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = cname_oldlen - cname_datalen;
-	    }
-	    {
-		size_t transited_datalen, transited_oldlen;
-		Der_type transited_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &transited_type, 4, &transited_datalen, &l);
-		if (e == 0 && transited_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		transited_oldlen = len;
-		if (transited_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = transited_datalen;
-		e = decode_TransitedEncoding(p, len, &(data)->transited, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = transited_oldlen - transited_datalen;
-	    }
-	    {
-		size_t authtime_datalen, authtime_oldlen;
-		Der_type authtime_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &authtime_type, 5, &authtime_datalen, &l);
-		if (e == 0 && authtime_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		authtime_oldlen = len;
-		if (authtime_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = authtime_datalen;
-		e = decode_KerberosTime(p, len, &(data)->authtime, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = authtime_oldlen - authtime_datalen;
-	    }
-	    {
-		size_t starttime_datalen, starttime_oldlen;
-		Der_type starttime_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &starttime_type, 6, &starttime_datalen, &l);
-		if (e == 0 && starttime_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e) {
-		    (data)->starttime = NULL;
-		} else {
-		    (data)->starttime = calloc(1, sizeof(*(data)->starttime));
-		    if ((data)->starttime == NULL) {
-			e = ENOMEM;
-			goto fail;
-		    }
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    starttime_oldlen = len;
-		    if (starttime_datalen > len) {
-			e = ASN1_OVERRUN;
-			goto fail;
-		    }
-		    len = starttime_datalen;
-		    e = decode_KerberosTime(p, len, (data)->starttime, &l);
-		    if (e)
-			goto fail;
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    len = starttime_oldlen - starttime_datalen;
-		}
-	    }
-	    {
-		size_t endtime_datalen, endtime_oldlen;
-		Der_type endtime_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &endtime_type, 7, &endtime_datalen, &l);
-		if (e == 0 && endtime_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		endtime_oldlen = len;
-		if (endtime_datalen > len) {
+		ad_data_Tag_oldlen = len;
+		if (ad_data_Tag_datalen > len) {
 		    e = ASN1_OVERRUN;
 		    goto fail;
 		}
-		len = endtime_datalen;
-		e = decode_KerberosTime(p, len, &(data)->endtime, &l);
+		len = ad_data_Tag_datalen;
+		e = der_get_octet_string(p, len, &(data)->ad_data, &l);
 		if (e)
 		    goto fail;
 		p += l;
 		len -= l;
 		ret += l;
-		len = endtime_oldlen - endtime_datalen;
-	    }
-	    {
-		size_t renew_till_datalen, renew_till_oldlen;
-		Der_type renew_till_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &renew_till_type, 8, &renew_till_datalen, &l);
-		if (e == 0 && renew_till_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e) {
-		    (data)->renew_till = NULL;
-		} else {
-		    (data)->renew_till = calloc(1, sizeof(*(data)->renew_till));
-		    if ((data)->renew_till == NULL) {
-			e = ENOMEM;
-			goto fail;
-		    }
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    renew_till_oldlen = len;
-		    if (renew_till_datalen > len) {
-			e = ASN1_OVERRUN;
-			goto fail;
-		    }
-		    len = renew_till_datalen;
-		    e = decode_KerberosTime(p, len, (data)->renew_till, &l);
-		    if (e)
-			goto fail;
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    len = renew_till_oldlen - renew_till_datalen;
-		}
-	    }
-	    {
-		size_t caddr_datalen, caddr_oldlen;
-		Der_type caddr_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &caddr_type, 9, &caddr_datalen, &l);
-		if (e == 0 && caddr_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e) {
-		    (data)->caddr = NULL;
-		} else {
-		    (data)->caddr = calloc(1, sizeof(*(data)->caddr));
-		    if ((data)->caddr == NULL) {
-			e = ENOMEM;
-			goto fail;
-		    }
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    caddr_oldlen = len;
-		    if (caddr_datalen > len) {
-			e = ASN1_OVERRUN;
-			goto fail;
-		    }
-		    len = caddr_datalen;
-		    e = decode_HostAddresses(p, len, (data)->caddr, &l);
-		    if (e)
-			goto fail;
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    len = caddr_oldlen - caddr_datalen;
-		}
-	    }
-	    {
-		size_t authorization_data_datalen, authorization_data_oldlen;
-		Der_type authorization_data_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &authorization_data_type, 10, &authorization_data_datalen, &l);
-		if (e == 0 && authorization_data_type != CONS) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e) {
-		    (data)->authorization_data = NULL;
-		} else {
-		    (data)->authorization_data = calloc(1, sizeof(*(data)->authorization_data));
-		    if ((data)->authorization_data == NULL) {
-			e = ENOMEM;
-			goto fail;
-		    }
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    authorization_data_oldlen = len;
-		    if (authorization_data_datalen > len) {
-			e = ASN1_OVERRUN;
-			goto fail;
-		    }
-		    len = authorization_data_datalen;
-		    e = decode_AuthorizationData(p, len, (data)->authorization_data, &l);
-		    if (e)
-			goto fail;
-		    p += l;
-		    len -= l;
-		    ret += l;
-		    len = authorization_data_oldlen - authorization_data_datalen;
-		}
+		len = ad_data_Tag_oldlen - ad_data_Tag_datalen;
 	    }
-	    len = Top_Tag_oldlen - Top_Tag_datalen;
+	    len = ad_data_oldlen - ad_data_datalen;
 	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_EncTicketPart(data);
+  fail:
+    free_AuthorizationDataElement(data);
     return e;
 }
 
-void
-free_EncTicketPart(EncTicketPart * data)
+void ASN1CALL
+free_AuthorizationDataElement(AuthorizationDataElement * data)
 {
-    free_TicketFlags(&(data)->flags);
-    free_EncryptionKey(&(data)->key);
-    free_Realm(&(data)->crealm);
-    free_PrincipalName(&(data)->cname);
-    free_TransitedEncoding(&(data)->transited);
-    free_KerberosTime(&(data)->authtime);
-    if ((data)->starttime) {
-	free_KerberosTime((data)->starttime);
-	free((data)->starttime);
-	(data)->starttime = NULL;
-    }
-    free_KerberosTime(&(data)->endtime);
-    if ((data)->renew_till) {
-	free_KerberosTime((data)->renew_till);
-	free((data)->renew_till);
-	(data)->renew_till = NULL;
-    }
-    if ((data)->caddr) {
-	free_HostAddresses((data)->caddr);
-	free((data)->caddr);
-	(data)->caddr = NULL;
-    }
-    if ((data)->authorization_data) {
-	free_AuthorizationData((data)->authorization_data);
-	free((data)->authorization_data);
-	(data)->authorization_data = NULL;
-    }
+    free_krb5int32(&(data)->ad_type);
+    der_free_octet_string(&(data)->ad_data);
 }
 
-size_t
-length_EncTicketPart(const EncTicketPart * data)
+size_t ASN1CALL
+length_AuthorizationDataElement(const AuthorizationDataElement * data)
 {
     size_t ret = 0;
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_TicketFlags(&(data)->flags);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_EncryptionKey(&(data)->key);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_Realm(&(data)->crealm);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_PrincipalName(&(data)->cname);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    {
-	size_t Top_tag_tag_oldret = ret;
+	size_t Top_tag_oldret = ret;
 	ret = 0;
-	ret += length_TransitedEncoding(&(data)->transited);
+	ret += length_krb5int32(&(data)->ad_type);
 	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
+	ret += Top_tag_oldret;
     }
     {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_KerberosTime(&(data)->authtime);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    if ((data)->starttime) {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_KerberosTime((data)->starttime);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    } {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_KerberosTime(&(data)->endtime);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    if ((data)->renew_till) {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_KerberosTime((data)->renew_till);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    if ((data)->caddr) {
-	size_t Top_tag_tag_oldret = ret;
+	size_t Top_tag_oldret = ret;
 	ret = 0;
-	ret += length_HostAddresses((data)->caddr);
+	ret += der_length_octet_string(&(data)->ad_data);
 	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
-    }
-    if ((data)->authorization_data) {
-	size_t Top_tag_tag_oldret = ret;
-	ret = 0;
-	ret += length_AuthorizationData((data)->authorization_data);
 	ret += 1 + der_length_len(ret);
-	ret += Top_tag_tag_oldret;
+	ret += Top_tag_oldret;
     }
     ret += 1 + der_length_len(ret);
-    ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_EncTicketPart(const EncTicketPart * from, EncTicketPart * to)
+int ASN1CALL
+copy_AuthorizationDataElement(const AuthorizationDataElement * from,
+			      AuthorizationDataElement * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_TicketFlags(&(from)->flags, &(to)->flags))
-	goto fail;
-    if (copy_EncryptionKey(&(from)->key, &(to)->key))
-	goto fail;
-    if (copy_Realm(&(from)->crealm, &(to)->crealm))
-	goto fail;
-    if (copy_PrincipalName(&(from)->cname, &(to)->cname))
-	goto fail;
-    if (copy_TransitedEncoding(&(from)->transited, &(to)->transited))
-	goto fail;
-    if (copy_KerberosTime(&(from)->authtime, &(to)->authtime))
+    if (copy_krb5int32(&(from)->ad_type, &(to)->ad_type))
 	goto fail;
-    if ((from)->starttime) {
-	(to)->starttime = malloc(sizeof(*(to)->starttime));
-	if ((to)->starttime == NULL)
-	    goto fail;
-	if (copy_KerberosTime((from)->starttime, (to)->starttime))
-	    goto fail;
-    } else
-	(to)->starttime = NULL;
-    if (copy_KerberosTime(&(from)->endtime, &(to)->endtime))
+    if (der_copy_octet_string(&(from)->ad_data, &(to)->ad_data))
 	goto fail;
-    if ((from)->renew_till) {
-	(to)->renew_till = malloc(sizeof(*(to)->renew_till));
-	if ((to)->renew_till == NULL)
-	    goto fail;
-	if (copy_KerberosTime((from)->renew_till, (to)->renew_till))
-	    goto fail;
-    } else
-	(to)->renew_till = NULL;
-    if ((from)->caddr) {
-	(to)->caddr = malloc(sizeof(*(to)->caddr));
-	if ((to)->caddr == NULL)
-	    goto fail;
-	if (copy_HostAddresses((from)->caddr, (to)->caddr))
-	    goto fail;
-    } else
-	(to)->caddr = NULL;
-    if ((from)->authorization_data) {
-	(to)->authorization_data = malloc(sizeof(*(to)->authorization_data));
-	if ((to)->authorization_data == NULL)
-	    goto fail;
-	if (copy_AuthorizationData((from)->authorization_data, (to)->authorization_data))
-	    goto fail;
-    } else
-	(to)->authorization_data = NULL;
     return 0;
-fail:
-    free_EncTicketPart(to);
+  fail:
+    free_AuthorizationDataElement(to);
     return ENOMEM;
 }
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_KerberosTime(unsigned char *p, size_t len, const KerberosTime * data, size_t * size)
+int ASN1CALL
+encode_AuthorizationData(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+			 size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+			 const AuthorizationData * data, size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
-    e = der_put_generalized_time(p, len, data, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
+    for (i = (int) (data)->len - 1; i >= 0; --i) {
+	size_t Top_tag_for_oldret = ret;
+	ret = 0;
+	e = encode_AuthorizationDataElement(p, len, &(data)->val[i], &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
 
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_GeneralizedTime, &l);
+	ret += Top_tag_for_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -2713,19 +2715,22 @@ encode_KerberosTime(unsigned char *p, size_t len, const KerberosTime * data, siz
     return 0;
 }
 
-int
-decode_KerberosTime(const unsigned char *p, size_t len, KerberosTime * data, size_t * size)
+int ASN1CALL
+decode_AuthorizationData(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+			 size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+			 AuthorizationData * data, size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_GeneralizedTime, &Top_datalen, &l);
-	if (e == 0 && Top_type != PRIM) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -2739,113 +2744,189 @@ decode_KerberosTime(const unsigned char *p, size_t len, KerberosTime * data, siz
 	    goto fail;
 	}
 	len = Top_datalen;
-	e = der_get_generalized_time(p, len, data, &l);
-	if (e)
-	    goto fail;
-	p += l;
-	len -= l;
-	ret += l;
+	{
+	    size_t Top_Tag_origlen = len;
+	    size_t Top_Tag_oldret = ret;
+	    size_t Top_Tag_olen = 0;
+	    void *Top_Tag_tmp;
+	    ret = 0;
+	    (data)->len = 0;
+	    (data)->val = NULL;
+	    while (ret < Top_Tag_origlen) {
+		size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
+		if (Top_Tag_olen > Top_Tag_nlen) {
+		    e = ASN1_OVERFLOW;
+		    goto fail;
+		}
+		Top_Tag_olen = Top_Tag_nlen;
+		Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
+		if (Top_Tag_tmp == NULL) {
+		    e = ENOMEM;
+		    goto fail;
+		}
+		(data)->val = Top_Tag_tmp;
+		e = decode_AuthorizationDataElement(p, len,
+						    &(data)->val[(data)->len],
+						    &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		(data)->len++;
+		len = Top_Tag_origlen - ret;
+	    }
+	    ret += Top_Tag_oldret;
+	}
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_KerberosTime(data);
+  fail:
+    free_AuthorizationData(data);
     return e;
 }
 
-void
-free_KerberosTime(KerberosTime * data)
+void ASN1CALL
+free_AuthorizationData(AuthorizationData * data)
 {
+    while ((data)->len) {
+	free_AuthorizationDataElement(&(data)->val[(data)->len - 1]);
+	(data)->len--;
+    }
+    free((data)->val);
+    (data)->val = NULL;
 }
 
-size_t
-length_KerberosTime(const KerberosTime * data)
+size_t ASN1CALL
+length_AuthorizationData(const AuthorizationData * data)
 {
     size_t ret = 0;
-    ret += der_length_generalized_time(data);
+    {
+	size_t Top_tag_oldret = ret;
+	unsigned int n_Top_tag;
+	ret = 0;
+	for (n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag) {
+	    size_t Top_tag_for_oldret = ret;
+	    ret = 0;
+	    ret +=
+		length_AuthorizationDataElement(&(data)->val[n_Top_tag - 1]);
+	    ret += Top_tag_for_oldret;
+	}
+	ret += Top_tag_oldret;
+    }
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_KerberosTime(const KerberosTime * from, KerberosTime * to)
+int ASN1CALL
+copy_AuthorizationData(const AuthorizationData * from, AuthorizationData * to)
 {
     memset(to, 0, sizeof(*to));
-    *(to) = *(from);
+    if (((to)->val = malloc((from)->len * sizeof(*(to)->val))) == NULL
+	&& (from)->len != 0)
+	goto fail;
+    for ((to)->len = 0; (to)->len < (from)->len; (to)->len++) {
+	if (copy_AuthorizationDataElement
+	    (&(from)->val[(to)->len], &(to)->val[(to)->len]))
+	    goto fail;
+    }
     return 0;
+  fail:
+    free_AuthorizationData(to);
+    return ENOMEM;
 }
 
+int ASN1CALL
+add_AuthorizationData(AuthorizationData * data,
+		      const AuthorizationDataElement * element)
+{
+    int ret;
+    void *ptr;
 
+    ptr = realloc(data->val, (data->len + 1) * sizeof(data->val[0]));
+    if (ptr == NULL)
+	return ENOMEM;
+    data->val = ptr;
 
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
+    ret = copy_AuthorizationDataElement(element, &data->val[data->len]);
+    if (ret)
+	return ret;
+    data->len++;
+    return 0;
+}
 
-int
-encode_TransitedEncoding(unsigned char *p, size_t len, const TransitedEncoding * data, size_t * size)
+int ASN1CALL
+remove_AuthorizationData(AuthorizationData * data, unsigned int element)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
-/* contents */
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = der_put_octet_string(p, len, &(data)->contents, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    void *ptr;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+    if (data->len == 0 || element >= data->len)
+	return ASN1_OVERRUN;
+    free_AuthorizationDataElement(&data->val[element]);
+    data->len--;
+    if (element < data->len)
+	memmove(&data->val[element], &data->val[element + 1],
+		sizeof(data->val[0]) * (data->len - element));
+    ptr = realloc(data->val, data->len * sizeof(data->val[0]));
+    if (ptr != NULL || data->len == 0)
+	data->val = ptr;
+    return 0;
+}
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+int ASN1CALL
+encode_APOptions(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, const APOptions * data,
+		 size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	ret += Top_tag_oldret;
-    }
-/* tr-type */
     {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = encode_krb5int32(p, len, &(data)->tr_type, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	ret += Top_tag_oldret;
+	unsigned char c = 0;
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	c = 0;
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	c = 0;
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	c = 0;
+	if ((data)->mutual_required) {
+	    c |= 1 << 5;
+	}
+	if ((data)->use_session_key) {
+	    c |= 1 << 6;
+	}
+	if ((data)->reserved) {
+	    c |= 1 << 7;
+	}
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = 0;
+	len -= 1;
+	ret += 1;
     }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -2856,19 +2937,22 @@ encode_TransitedEncoding(unsigned char *p, size_t len, const TransitedEncoding *
     return 0;
 }
 
-int
-decode_TransitedEncoding(const unsigned char *p, size_t len, TransitedEncoding * data, size_t * size)
+int ASN1CALL
+decode_APOptions(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		 size_t len HEIMDAL_UNUSED_ATTRIBUTE, APOptions * data,
+		 size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_BitString, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
 	if (e)
@@ -2882,384 +2966,89 @@ decode_TransitedEncoding(const unsigned char *p, size_t len, TransitedEncoding *
 	    goto fail;
 	}
 	len = Top_datalen;
-	{
-	    size_t tr_type_datalen, tr_type_oldlen;
-	    Der_type tr_type_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &tr_type_type, 0, &tr_type_datalen, &l);
-	    if (e == 0 && tr_type_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    tr_type_oldlen = len;
-	    if (tr_type_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = tr_type_datalen;
-	    e = decode_krb5int32(p, len, &(data)->tr_type, &l);
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    len = tr_type_oldlen - tr_type_datalen;
-	}
-	{
-	    size_t contents_datalen, contents_oldlen;
-	    Der_type contents_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &contents_type, 1, &contents_datalen, &l);
-	    if (e == 0 && contents_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    contents_oldlen = len;
-	    if (contents_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = contents_datalen;
-	    {
-		size_t contents_Tag_datalen, contents_Tag_oldlen;
-		Der_type contents_Tag_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &contents_Tag_type, UT_OctetString, &contents_Tag_datalen, &l);
-		if (e == 0 && contents_Tag_type != PRIM) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		contents_Tag_oldlen = len;
-		if (contents_Tag_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = contents_Tag_datalen;
-		e = der_get_octet_string(p, len, &(data)->contents, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = contents_Tag_oldlen - contents_Tag_datalen;
-	    }
-	    len = contents_oldlen - contents_datalen;
-	}
+	if (len < 1)
+	    return ASN1_OVERRUN;
+	p++;
+	len--;
+	ret++;
+	do {
+	    if (len < 1)
+		break;
+	    (data)->reserved = (*p >> 7) & 1;
+	    (data)->use_session_key = (*p >> 6) & 1;
+	    (data)->mutual_required = (*p >> 5) & 1;
+	} while (0);
+	p += len;
+	ret += len;
 	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_TransitedEncoding(data);
+  fail:
+    free_APOptions(data);
     return e;
 }
 
-void
-free_TransitedEncoding(TransitedEncoding * data)
+void ASN1CALL
+free_APOptions(APOptions * data)
 {
-    free_krb5int32(&(data)->tr_type);
-    der_free_octet_string(&(data)->contents);
 }
 
-size_t
-length_TransitedEncoding(const TransitedEncoding * data)
+size_t ASN1CALL
+length_APOptions(const APOptions * data)
 {
     size_t ret = 0;
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += length_krb5int32(&(data)->tr_type);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += der_length_octet_string(&(data)->contents);
-	ret += 1 + der_length_len(ret);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
+    ret += 5;
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_TransitedEncoding(const TransitedEncoding * from, TransitedEncoding * to)
+int ASN1CALL
+copy_APOptions(const APOptions * from, APOptions * to)
 {
     memset(to, 0, sizeof(*to));
-    if (copy_krb5int32(&(from)->tr_type, &(to)->tr_type))
-	goto fail;
-    if (der_copy_octet_string(&(from)->contents, &(to)->contents))
-	goto fail;
+    *(to) = *(from);
     return 0;
-fail:
-    free_TransitedEncoding(to);
-    return ENOMEM;
 }
 
+unsigned
+APOptions2int(APOptions f)
+{
+    unsigned r = 0;
+    if (f.reserved)
+	r |= (1U << 0);
+    if (f.use_session_key)
+	r |= (1U << 1);
+    if (f.mutual_required)
+	r |= (1U << 2);
+    return r;
+}
 
+APOptions
+int2APOptions(unsigned n)
+{
+    APOptions flags;
 
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
+    memset(&flags, 0, sizeof(flags));
 
-int
-encode_EncryptionKey(unsigned char *p, size_t len, const EncryptionKey * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
+    flags.reserved = (n >> 0) & 1;
+    flags.use_session_key = (n >> 1) & 1;
+    flags.mutual_required = (n >> 2) & 1;
+    return flags;
+}
 
-    i = 0;
-/* keyvalue */
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = der_put_octet_string(p, len, &(data)->keyvalue, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_OctetString, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
 
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
+int ASN1CALL
+encode_TicketFlags(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		   size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		   const TicketFlags * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-	ret += Top_tag_oldret;
-    }
-/* keytype */
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	e = encode_krb5int32(p, len, &(data)->keytype, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
-	ret += Top_tag_oldret;
-    }
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
-
-    *size = ret;
-    return 0;
-}
-
-int
-decode_EncryptionKey(const unsigned char *p, size_t len, EncryptionKey * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int e;
-
-    memset(data, 0, sizeof(*data));
-    {
-	size_t Top_datalen, Top_oldlen;
-	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Sequence, &Top_datalen, &l);
-	if (e == 0 && Top_type != CONS) {
-	    e = ASN1_BAD_ID;
-	}
-	if (e)
-	    goto fail;
-	p += l;
-	len -= l;
-	ret += l;
-	Top_oldlen = len;
-	if (Top_datalen > len) {
-	    e = ASN1_OVERRUN;
-	    goto fail;
-	}
-	len = Top_datalen;
-	{
-	    size_t keytype_datalen, keytype_oldlen;
-	    Der_type keytype_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &keytype_type, 0, &keytype_datalen, &l);
-	    if (e == 0 && keytype_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    keytype_oldlen = len;
-	    if (keytype_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = keytype_datalen;
-	    e = decode_krb5int32(p, len, &(data)->keytype, &l);
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    len = keytype_oldlen - keytype_datalen;
-	}
-	{
-	    size_t keyvalue_datalen, keyvalue_oldlen;
-	    Der_type keyvalue_type;
-	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &keyvalue_type, 1, &keyvalue_datalen, &l);
-	    if (e == 0 && keyvalue_type != CONS) {
-		e = ASN1_BAD_ID;
-	    }
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    keyvalue_oldlen = len;
-	    if (keyvalue_datalen > len) {
-		e = ASN1_OVERRUN;
-		goto fail;
-	    }
-	    len = keyvalue_datalen;
-	    {
-		size_t keyvalue_Tag_datalen, keyvalue_Tag_oldlen;
-		Der_type keyvalue_Tag_type;
-		e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &keyvalue_Tag_type, UT_OctetString, &keyvalue_Tag_datalen, &l);
-		if (e == 0 && keyvalue_Tag_type != PRIM) {
-		    e = ASN1_BAD_ID;
-		}
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		keyvalue_Tag_oldlen = len;
-		if (keyvalue_Tag_datalen > len) {
-		    e = ASN1_OVERRUN;
-		    goto fail;
-		}
-		len = keyvalue_Tag_datalen;
-		e = der_get_octet_string(p, len, &(data)->keyvalue, &l);
-		if (e)
-		    goto fail;
-		p += l;
-		len -= l;
-		ret += l;
-		len = keyvalue_Tag_oldlen - keyvalue_Tag_datalen;
-	    }
-	    len = keyvalue_oldlen - keyvalue_datalen;
-	}
-	len = Top_oldlen - Top_datalen;
-    }
-    if (size)
-	*size = ret;
-    return 0;
-fail:
-    free_EncryptionKey(data);
-    return e;
-}
-
-void
-free_EncryptionKey(EncryptionKey * data)
-{
-    free_krb5int32(&(data)->keytype);
-    der_free_octet_string(&(data)->keyvalue);
-}
-
-size_t
-length_EncryptionKey(const EncryptionKey * data)
-{
-    size_t ret = 0;
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += length_krb5int32(&(data)->keytype);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
-    {
-	size_t Top_tag_oldret = ret;
-	ret = 0;
-	ret += der_length_octet_string(&(data)->keyvalue);
-	ret += 1 + der_length_len(ret);
-	ret += 1 + der_length_len(ret);
-	ret += Top_tag_oldret;
-    }
-    ret += 1 + der_length_len(ret);
-    return ret;
-}
-
-int
-copy_EncryptionKey(const EncryptionKey * from, EncryptionKey * to)
-{
-    memset(to, 0, sizeof(*to));
-    if (copy_krb5int32(&(from)->keytype, &(to)->keytype))
-	goto fail;
-    if (der_copy_octet_string(&(from)->keyvalue, &(to)->keyvalue))
-	goto fail;
-    return 0;
-fail:
-    free_EncryptionKey(to);
-    return ENOMEM;
-}
-
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_TicketFlags(unsigned char *p, size_t len, const TicketFlags * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
     {
 	unsigned char c = 0;
 	if (len < 1)
@@ -3268,14 +3057,17 @@ encode_TicketFlags(unsigned char *p, size_t len, const TicketFlags * data, size_
 	len--;
 	ret++;
 	c = 0;
+	if ((data)->anonymous) {
+	    c |= 1 << 7;
+	}
 	if (len < 1)
 	    return ASN1_OVERFLOW;
 	*p-- = c;
 	len--;
 	ret++;
 	c = 0;
-	if ((data)->anonymous) {
-	    c |= 1 << 1;
+	if ((data)->enc_pa_rep) {
+	    c |= 1 << 0;
 	}
 	if ((data)->ok_as_delegate) {
 	    c |= 1 << 2;
@@ -3337,7 +3129,8 @@ encode_TicketFlags(unsigned char *p, size_t len, const TicketFlags * data, size_
 	ret += 1;
     }
 
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -3348,18 +3141,21 @@ encode_TicketFlags(unsigned char *p, size_t len, const TicketFlags * data, size_
     return 0;
 }
 
-int
-decode_TicketFlags(const unsigned char *p, size_t len, TicketFlags * data, size_t * size)
+int ASN1CALL
+decode_TicketFlags(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		   size_t len HEIMDAL_UNUSED_ATTRIBUTE, TicketFlags * data,
+		   size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_BitString, &Top_datalen, &l);
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_BitString, &Top_datalen, &l);
 	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
@@ -3401,7 +3197,13 @@ decode_TicketFlags(const unsigned char *p, size_t len, TicketFlags * data, size_
 	    (data)->hw_authent = (*p >> 4) & 1;
 	    (data)->transited_policy_checked = (*p >> 3) & 1;
 	    (data)->ok_as_delegate = (*p >> 2) & 1;
-	    (data)->anonymous = (*p >> 1) & 1;
+	    (data)->enc_pa_rep = (*p >> 0) & 1;
+	    p++;
+	    len--;
+	    ret++;
+	    if (len < 1)
+		break;
+	    (data)->anonymous = (*p >> 7) & 1;
 	} while (0);
 	p += len;
 	ret += len;
@@ -3410,17 +3212,17 @@ decode_TicketFlags(const unsigned char *p, size_t len, TicketFlags * data, size_
     if (size)
 	*size = ret;
     return 0;
-fail:
+  fail:
     free_TicketFlags(data);
     return e;
 }
 
-void
+void ASN1CALL
 free_TicketFlags(TicketFlags * data)
 {
 }
 
-size_t
+size_t ASN1CALL
 length_TicketFlags(const TicketFlags * data)
 {
     size_t ret = 0;
@@ -3429,7 +3231,7 @@ length_TicketFlags(const TicketFlags * data)
     return ret;
 }
 
-int
+int ASN1CALL
 copy_TicketFlags(const TicketFlags * from, TicketFlags * to)
 {
     memset(to, 0, sizeof(*to));
@@ -3469,8 +3271,10 @@ TicketFlags2int(TicketFlags f)
 	r |= (1U << 12);
     if (f.ok_as_delegate)
 	r |= (1U << 13);
+    if (f.enc_pa_rep)
+	r |= (1U << 15);
     if (f.anonymous)
-	r |= (1U << 14);
+	r |= (1U << 16);
     return r;
 }
 
@@ -3495,141 +3299,293 @@ int2TicketFlags(unsigned n)
     flags.hw_authent = (n >> 11) & 1;
     flags.transited_policy_checked = (n >> 12) & 1;
     flags.ok_as_delegate = (n >> 13) & 1;
-    flags.anonymous = (n >> 14) & 1;
+    flags.enc_pa_rep = (n >> 15) & 1;
+    flags.anonymous = (n >> 16) & 1;
     return flags;
 }
 
 
 
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_Realm(unsigned char *p, size_t len, const Realm * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
-    e = der_put_general_string(p, len, data, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
-
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_GeneralString, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
-
-    *size = ret;
-    return 0;
-}
-
-int
-decode_Realm(const unsigned char *p, size_t len, Realm * data, size_t * size)
+int ASN1CALL
+encode_KDCOptions(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		  size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		  const KDCOptions * data, size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int e;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    memset(data, 0, sizeof(*data));
     {
-	size_t Top_datalen, Top_oldlen;
-	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_GeneralString, &Top_datalen, &l);
-	if (e == 0 && Top_type != PRIM) {
-	    e = ASN1_BAD_ID;
+	unsigned char c = 0;
+	if ((data)->validate) {
+	    c |= 1 << 0;
 	}
-	if (e)
-	    goto fail;
-	p += l;
-	len -= l;
-	ret += l;
-	Top_oldlen = len;
-	if (Top_datalen > len) {
-	    e = ASN1_OVERRUN;
-	    goto fail;
+	if ((data)->renew) {
+	    c |= 1 << 1;
 	}
-	len = Top_datalen;
-	e = der_get_general_string(p, len, data, &l);
-	if (e)
-	    goto fail;
-	p += l;
-	len -= l;
-	ret += l;
-	len = Top_oldlen - Top_datalen;
+	if ((data)->enc_tkt_in_skey) {
+	    c |= 1 << 3;
+	}
+	if ((data)->renewable_ok) {
+	    c |= 1 << 4;
+	}
+	if ((data)->disable_transited_check) {
+	    c |= 1 << 5;
+	}
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	c = 0;
+	if ((data)->request_anonymous) {
+	    c |= 1 << 7;
+	}
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	c = 0;
+	if ((data)->canonicalize) {
+	    c |= 1 << 0;
+	}
+	if ((data)->cname_in_addl_tkt) {
+	    c |= 1 << 1;
+	}
+	if ((data)->renewable) {
+	    c |= 1 << 7;
+	}
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	c = 0;
+	if ((data)->postdated) {
+	    c |= 1 << 1;
+	}
+	if ((data)->allow_postdate) {
+	    c |= 1 << 2;
+	}
+	if ((data)->proxy) {
+	    c |= 1 << 3;
+	}
+	if ((data)->proxiable) {
+	    c |= 1 << 4;
+	}
+	if ((data)->forwarded) {
+	    c |= 1 << 5;
+	}
+	if ((data)->forwardable) {
+	    c |= 1 << 6;
+	}
+	if ((data)->reserved) {
+	    c |= 1 << 7;
+	}
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = c;
+	len--;
+	ret++;
+	if (len < 1)
+	    return ASN1_OVERFLOW;
+	*p-- = 0;
+	len -= 1;
+	ret += 1;
+    }
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_KDCOptions(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		  size_t len HEIMDAL_UNUSED_ATTRIBUTE, KDCOptions * data,
+		  size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_BitString, &Top_datalen, &l);
+	if (e == 0 && Top_type != PRIM) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	if (len < 1)
+	    return ASN1_OVERRUN;
+	p++;
+	len--;
+	ret++;
+	do {
+	    if (len < 1)
+		break;
+	    (data)->reserved = (*p >> 7) & 1;
+	    (data)->forwardable = (*p >> 6) & 1;
+	    (data)->forwarded = (*p >> 5) & 1;
+	    (data)->proxiable = (*p >> 4) & 1;
+	    (data)->proxy = (*p >> 3) & 1;
+	    (data)->allow_postdate = (*p >> 2) & 1;
+	    (data)->postdated = (*p >> 1) & 1;
+	    p++;
+	    len--;
+	    ret++;
+	    if (len < 1)
+		break;
+	    (data)->renewable = (*p >> 7) & 1;
+	    (data)->cname_in_addl_tkt = (*p >> 1) & 1;
+	    (data)->canonicalize = (*p >> 0) & 1;
+	    p++;
+	    len--;
+	    ret++;
+	    if (len < 1)
+		break;
+	    (data)->request_anonymous = (*p >> 7) & 1;
+	    p++;
+	    len--;
+	    ret++;
+	    if (len < 1)
+		break;
+	    (data)->disable_transited_check = (*p >> 5) & 1;
+	    (data)->renewable_ok = (*p >> 4) & 1;
+	    (data)->enc_tkt_in_skey = (*p >> 3) & 1;
+	    (data)->renew = (*p >> 1) & 1;
+	    (data)->validate = (*p >> 0) & 1;
+	} while (0);
+	p += len;
+	ret += len;
+	len = Top_oldlen - Top_datalen;
     }
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_Realm(data);
+  fail:
+    free_KDCOptions(data);
     return e;
 }
 
-void
-free_Realm(Realm * data)
+void ASN1CALL
+free_KDCOptions(KDCOptions * data)
 {
-    der_free_general_string(data);
 }
 
-size_t
-length_Realm(const Realm * data)
+size_t ASN1CALL
+length_KDCOptions(const KDCOptions * data)
 {
     size_t ret = 0;
-    ret += der_length_general_string(data);
+    ret += 5;
     ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_Realm(const Realm * from, Realm * to)
+int ASN1CALL
+copy_KDCOptions(const KDCOptions * from, KDCOptions * to)
 {
     memset(to, 0, sizeof(*to));
-    if (der_copy_general_string(from, to))
-	goto fail;
+    *(to) = *(from);
     return 0;
-fail:
-    free_Realm(to);
-    return ENOMEM;
 }
 
+unsigned
+KDCOptions2int(KDCOptions f)
+{
+    unsigned r = 0;
+    if (f.reserved)
+	r |= (1U << 0);
+    if (f.forwardable)
+	r |= (1U << 1);
+    if (f.forwarded)
+	r |= (1U << 2);
+    if (f.proxiable)
+	r |= (1U << 3);
+    if (f.proxy)
+	r |= (1U << 4);
+    if (f.allow_postdate)
+	r |= (1U << 5);
+    if (f.postdated)
+	r |= (1U << 6);
+    if (f.renewable)
+	r |= (1U << 8);
+    if (f.cname_in_addl_tkt)
+	r |= (1U << 14);
+    if (f.canonicalize)
+	r |= (1U << 15);
+    if (f.request_anonymous)
+	r |= (1U << 16);
+    if (f.disable_transited_check)
+	r |= (1U << 26);
+    if (f.renewable_ok)
+	r |= (1U << 27);
+    if (f.enc_tkt_in_skey)
+	r |= (1U << 28);
+    if (f.renew)
+	r |= (1U << 30);
+    if (f.validate)
+	r |= (1U << 31);
+    return r;
+}
+
+KDCOptions
+int2KDCOptions(unsigned n)
+{
+    KDCOptions flags;
 
+    memset(&flags, 0, sizeof(flags));
 
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
+    flags.reserved = (n >> 0) & 1;
+    flags.forwardable = (n >> 1) & 1;
+    flags.forwarded = (n >> 2) & 1;
+    flags.proxiable = (n >> 3) & 1;
+    flags.proxy = (n >> 4) & 1;
+    flags.allow_postdate = (n >> 5) & 1;
+    flags.postdated = (n >> 6) & 1;
+    flags.renewable = (n >> 8) & 1;
+    flags.cname_in_addl_tkt = (n >> 14) & 1;
+    flags.canonicalize = (n >> 15) & 1;
+    flags.request_anonymous = (n >> 16) & 1;
+    flags.disable_transited_check = (n >> 26) & 1;
+    flags.renewable_ok = (n >> 27) & 1;
+    flags.enc_tkt_in_skey = (n >> 28) & 1;
+    flags.renew = (n >> 30) & 1;
+    flags.validate = (n >> 31) & 1;
+    return flags;
+}
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
 
-int
-encode_ENCTYPE(unsigned char *p, size_t len, const ENCTYPE * data, size_t * size)
+
+int ASN1CALL
+encode_LR_TYPE(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	       size_t len HEIMDAL_UNUSED_ATTRIBUTE, const LR_TYPE * data,
+	       size_t * size)
 {
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
 
-    i = 0;
     {
 	int enumint = (int) *data;
 	e = der_put_integer(p, len, &enumint, &l);
@@ -3641,7 +3597,8 @@ encode_ENCTYPE(unsigned char *p, size_t len, const ENCTYPE * data, size_t * size
 
     }
     ;
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer,
+			       &l);
     if (e)
 	return e;
     p -= l;
@@ -3652,18 +3609,21 @@ encode_ENCTYPE(unsigned char *p, size_t len, const ENCTYPE * data, size_t * size
     return 0;
 }
 
-int
-decode_ENCTYPE(const unsigned char *p, size_t len, ENCTYPE * data, size_t * size)
+int ASN1CALL
+decode_LR_TYPE(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	       size_t len HEIMDAL_UNUSED_ATTRIBUTE, LR_TYPE * data,
+	       size_t * size)
 {
     size_t ret = 0;
-    size_t l;
-    int e;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
 
     memset(data, 0, sizeof(*data));
     {
 	size_t Top_datalen, Top_oldlen;
 	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Integer, &Top_datalen, &l);
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Integer, &Top_datalen, &l);
 	if (e == 0 && Top_type != PRIM) {
 	    e = ASN1_BAD_ID;
 	}
@@ -3693,146 +3653,2260 @@ decode_ENCTYPE(const unsigned char *p, size_t len, ENCTYPE * data, size_t * size
     if (size)
 	*size = ret;
     return 0;
-fail:
-    free_ENCTYPE(data);
+  fail:
+    free_LR_TYPE(data);
+    return e;
+}
+
+void ASN1CALL
+free_LR_TYPE(LR_TYPE * data)
+{
+}
+
+size_t ASN1CALL
+length_LR_TYPE(const LR_TYPE * data)
+{
+    size_t ret = 0;
+    {
+	int enumint = *data;
+	ret += der_length_integer(&enumint);
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_LR_TYPE(const LR_TYPE * from, LR_TYPE * to)
+{
+    memset(to, 0, sizeof(*to));
+    *(to) = *(from);
+    return 0;
+}
+
+int ASN1CALL
+encode_LastReq(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	       size_t len HEIMDAL_UNUSED_ATTRIBUTE, const LastReq * data,
+	       size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    for (i = (int) (data)->len - 1; i >= 0; --i) {
+	size_t Top_tag_for_oldret = ret;
+	ret = 0;
+/* lr-value */
+	{
+	    size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	    ret = 0;
+	    e = encode_KerberosTime(p, len, &(&(data)->val[i])->lr_value, &l);
+	    if (e)
+		return e;
+	    p -= l;
+	    len -= l;
+	    ret += l;
+
+	    e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1,
+				       &l);
+	    if (e)
+		return e;
+	    p -= l;
+	    len -= l;
+	    ret += l;
+
+	    ret += Top_tag_S_Of_tag_oldret;
+	}
+/* lr-type */
+	{
+	    size_t Top_tag_S_Of_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	    ret = 0;
+	    e = encode_LR_TYPE(p, len, &(&(data)->val[i])->lr_type, &l);
+	    if (e)
+		return e;
+	    p -= l;
+	    len -= l;
+	    ret += l;
+
+	    e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0,
+				       &l);
+	    if (e)
+		return e;
+	    p -= l;
+	    len -= l;
+	    ret += l;
+
+	    ret += Top_tag_S_Of_tag_oldret;
+	}
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS,
+				   UT_Sequence, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_for_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_LastReq(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	       size_t len HEIMDAL_UNUSED_ATTRIBUTE, LastReq * data,
+	       size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t Top_Tag_origlen = len;
+	    size_t Top_Tag_oldret = ret;
+	    size_t Top_Tag_olen = 0;
+	    void *Top_Tag_tmp;
+	    ret = 0;
+	    (data)->len = 0;
+	    (data)->val = NULL;
+	    while (ret < Top_Tag_origlen) {
+		size_t Top_Tag_nlen = Top_Tag_olen + sizeof(*((data)->val));
+		if (Top_Tag_olen > Top_Tag_nlen) {
+		    e = ASN1_OVERFLOW;
+		    goto fail;
+		}
+		Top_Tag_olen = Top_Tag_nlen;
+		Top_Tag_tmp = realloc((data)->val, Top_Tag_olen);
+		if (Top_Tag_tmp == NULL) {
+		    e = ENOMEM;
+		    goto fail;
+		}
+		(data)->val = Top_Tag_tmp;
+		{
+		    size_t Top_Tag_s_of_datalen, Top_Tag_s_of_oldlen;
+		    Der_type Top_Tag_s_of_type;
+		    e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+						 &Top_Tag_s_of_type,
+						 UT_Sequence,
+						 &Top_Tag_s_of_datalen, &l);
+		    if (e == 0 && Top_Tag_s_of_type != CONS) {
+			e = ASN1_BAD_ID;
+		    }
+		    if (e)
+			goto fail;
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    Top_Tag_s_of_oldlen = len;
+		    if (Top_Tag_s_of_datalen > len) {
+			e = ASN1_OVERRUN;
+			goto fail;
+		    }
+		    len = Top_Tag_s_of_datalen;
+		    {
+			size_t lr_type_datalen, lr_type_oldlen;
+			Der_type lr_type_type;
+			e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+						     &lr_type_type, 0,
+						     &lr_type_datalen, &l);
+			if (e == 0 && lr_type_type != CONS) {
+			    e = ASN1_BAD_ID;
+			}
+			if (e)
+			    goto fail;
+			p += l;
+			len -= l;
+			ret += l;
+			lr_type_oldlen = len;
+			if (lr_type_datalen > len) {
+			    e = ASN1_OVERRUN;
+			    goto fail;
+			}
+			len = lr_type_datalen;
+			e = decode_LR_TYPE(p, len,
+					   &(&(data)->val[(data)->len])->
+					   lr_type, &l);
+			if (e)
+			    goto fail;
+			p += l;
+			len -= l;
+			ret += l;
+			len = lr_type_oldlen - lr_type_datalen;
+		    }
+		    {
+			size_t lr_value_datalen, lr_value_oldlen;
+			Der_type lr_value_type;
+			e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+						     &lr_value_type, 1,
+						     &lr_value_datalen, &l);
+			if (e == 0 && lr_value_type != CONS) {
+			    e = ASN1_BAD_ID;
+			}
+			if (e)
+			    goto fail;
+			p += l;
+			len -= l;
+			ret += l;
+			lr_value_oldlen = len;
+			if (lr_value_datalen > len) {
+			    e = ASN1_OVERRUN;
+			    goto fail;
+			}
+			len = lr_value_datalen;
+			e = decode_KerberosTime(p, len,
+						&(&(data)->val[(data)->len])->
+						lr_value, &l);
+			if (e)
+			    goto fail;
+			p += l;
+			len -= l;
+			ret += l;
+			len = lr_value_oldlen - lr_value_datalen;
+		    }
+		    len = Top_Tag_s_of_oldlen - Top_Tag_s_of_datalen;
+		}
+		(data)->len++;
+		len = Top_Tag_origlen - ret;
+	    }
+	    ret += Top_Tag_oldret;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_LastReq(data);
+    return e;
+}
+
+void ASN1CALL
+free_LastReq(LastReq * data)
+{
+    while ((data)->len) {
+	free_LR_TYPE(&(&(data)->val[(data)->len - 1])->lr_type);
+	free_KerberosTime(&(&(data)->val[(data)->len - 1])->lr_value);
+	(data)->len--;
+    }
+    free((data)->val);
+    (data)->val = NULL;
+}
+
+size_t ASN1CALL
+length_LastReq(const LastReq * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_oldret = ret;
+	unsigned int n_Top_tag;
+	ret = 0;
+	for (n_Top_tag = (data)->len; n_Top_tag > 0; --n_Top_tag) {
+	    size_t Top_tag_for_oldret = ret;
+	    ret = 0;
+	    {
+		size_t Top_tag_S_Of_tag_oldret = ret;
+		ret = 0;
+		ret +=
+		    length_LR_TYPE(&(&(data)->val[n_Top_tag - 1])->lr_type);
+		ret += 1 + der_length_len(ret);
+		ret += Top_tag_S_Of_tag_oldret;
+	    }
+	    {
+		size_t Top_tag_S_Of_tag_oldret = ret;
+		ret = 0;
+		ret +=
+		    length_KerberosTime(&(&(data)->val[n_Top_tag - 1])->
+					lr_value);
+		ret += 1 + der_length_len(ret);
+		ret += Top_tag_S_Of_tag_oldret;
+	    }
+	    ret += 1 + der_length_len(ret);
+	    ret += Top_tag_for_oldret;
+	}
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_LastReq(const LastReq * from, LastReq * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (((to)->val = malloc((from)->len * sizeof(*(to)->val))) == NULL
+	&& (from)->len != 0)
+	goto fail;
+    for ((to)->len = 0; (to)->len < (from)->len; (to)->len++) {
+	if (copy_LR_TYPE
+	    (&(&(from)->val[(to)->len])->lr_type,
+	     &(&(to)->val[(to)->len])->lr_type))
+	    goto fail;
+	if (copy_KerberosTime
+	    (&(&(from)->val[(to)->len])->lr_value,
+	     &(&(to)->val[(to)->len])->lr_value))
+	    goto fail;
+    }
+    return 0;
+  fail:
+    free_LastReq(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_EncryptedData(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     const EncryptedData * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+/* cipher */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = der_put_octet_string(p, len, &(data)->cipher, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+				   UT_OctetString, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+/* kvno */
+    if ((data)->kvno) {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_krb5int32(p, len, (data)->kvno, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+/* etype */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_ENCTYPE(p, len, &(data)->etype, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_EncryptedData(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     EncryptedData * data, size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t etype_datalen, etype_oldlen;
+	    Der_type etype_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &etype_type,
+					 0, &etype_datalen, &l);
+	    if (e == 0 && etype_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    etype_oldlen = len;
+	    if (etype_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = etype_datalen;
+	    e = decode_ENCTYPE(p, len, &(data)->etype, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = etype_oldlen - etype_datalen;
+	}
+	{
+	    size_t kvno_datalen, kvno_oldlen;
+	    Der_type kvno_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &kvno_type,
+					 1, &kvno_datalen, &l);
+	    if (e == 0 && kvno_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e) {
+		(data)->kvno = NULL;
+	    } else {
+		(data)->kvno = calloc(1, sizeof(*(data)->kvno));
+		if ((data)->kvno == NULL) {
+		    e = ENOMEM;
+		    goto fail;
+		}
+		p += l;
+		len -= l;
+		ret += l;
+		kvno_oldlen = len;
+		if (kvno_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = kvno_datalen;
+		e = decode_krb5int32(p, len, (data)->kvno, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = kvno_oldlen - kvno_datalen;
+	    }
+	}
+	{
+	    size_t cipher_datalen, cipher_oldlen;
+	    Der_type cipher_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT, &cipher_type,
+					 2, &cipher_datalen, &l);
+	    if (e == 0 && cipher_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    cipher_oldlen = len;
+	    if (cipher_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = cipher_datalen;
+	    {
+		size_t cipher_Tag_datalen, cipher_Tag_oldlen;
+		Der_type cipher_Tag_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+					     &cipher_Tag_type, UT_OctetString,
+					     &cipher_Tag_datalen, &l);
+		if (e == 0 && cipher_Tag_type != PRIM) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		cipher_Tag_oldlen = len;
+		if (cipher_Tag_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = cipher_Tag_datalen;
+		e = der_get_octet_string(p, len, &(data)->cipher, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = cipher_Tag_oldlen - cipher_Tag_datalen;
+	    }
+	    len = cipher_oldlen - cipher_datalen;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_EncryptedData(data);
+    return e;
+}
+
+void ASN1CALL
+free_EncryptedData(EncryptedData * data)
+{
+    free_ENCTYPE(&(data)->etype);
+    if ((data)->kvno) {
+	free_krb5int32((data)->kvno);
+	free((data)->kvno);
+	(data)->kvno = NULL;
+    }
+    der_free_octet_string(&(data)->cipher);
+}
+
+size_t ASN1CALL
+length_EncryptedData(const EncryptedData * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += length_ENCTYPE(&(data)->etype);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    if ((data)->kvno) {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += length_krb5int32((data)->kvno);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += der_length_octet_string(&(data)->cipher);
+	ret += 1 + der_length_len(ret);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_EncryptedData(const EncryptedData * from, EncryptedData * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (copy_ENCTYPE(&(from)->etype, &(to)->etype))
+	goto fail;
+    if ((from)->kvno) {
+	(to)->kvno = malloc(sizeof(*(to)->kvno));
+	if ((to)->kvno == NULL)
+	    goto fail;
+	if (copy_krb5int32((from)->kvno, (to)->kvno))
+	    goto fail;
+    } else
+	(to)->kvno = NULL;
+    if (der_copy_octet_string(&(from)->cipher, &(to)->cipher))
+	goto fail;
+    return 0;
+  fail:
+    free_EncryptedData(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_EncryptionKey(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     const EncryptionKey * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+/* keyvalue */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = der_put_octet_string(p, len, &(data)->keyvalue, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+				   UT_OctetString, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+/* keytype */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_krb5int32(p, len, &(data)->keytype, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_EncryptionKey(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     EncryptionKey * data, size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t keytype_datalen, keytype_oldlen;
+	    Der_type keytype_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &keytype_type, 0, &keytype_datalen,
+					 &l);
+	    if (e == 0 && keytype_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    keytype_oldlen = len;
+	    if (keytype_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = keytype_datalen;
+	    e = decode_krb5int32(p, len, &(data)->keytype, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = keytype_oldlen - keytype_datalen;
+	}
+	{
+	    size_t keyvalue_datalen, keyvalue_oldlen;
+	    Der_type keyvalue_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &keyvalue_type, 1, &keyvalue_datalen,
+					 &l);
+	    if (e == 0 && keyvalue_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    keyvalue_oldlen = len;
+	    if (keyvalue_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = keyvalue_datalen;
+	    {
+		size_t keyvalue_Tag_datalen, keyvalue_Tag_oldlen;
+		Der_type keyvalue_Tag_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+					     &keyvalue_Tag_type,
+					     UT_OctetString,
+					     &keyvalue_Tag_datalen, &l);
+		if (e == 0 && keyvalue_Tag_type != PRIM) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		keyvalue_Tag_oldlen = len;
+		if (keyvalue_Tag_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = keyvalue_Tag_datalen;
+		e = der_get_octet_string(p, len, &(data)->keyvalue, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = keyvalue_Tag_oldlen - keyvalue_Tag_datalen;
+	    }
+	    len = keyvalue_oldlen - keyvalue_datalen;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_EncryptionKey(data);
+    return e;
+}
+
+void ASN1CALL
+free_EncryptionKey(EncryptionKey * data)
+{
+    free_krb5int32(&(data)->keytype);
+    der_free_octet_string(&(data)->keyvalue);
+}
+
+size_t ASN1CALL
+length_EncryptionKey(const EncryptionKey * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += length_krb5int32(&(data)->keytype);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += der_length_octet_string(&(data)->keyvalue);
+	ret += 1 + der_length_len(ret);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_EncryptionKey(const EncryptionKey * from, EncryptionKey * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (copy_krb5int32(&(from)->keytype, &(to)->keytype))
+	goto fail;
+    if (der_copy_octet_string(&(from)->keyvalue, &(to)->keyvalue))
+	goto fail;
+    return 0;
+  fail:
+    free_EncryptionKey(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_TransitedEncoding(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+			 size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+			 const TransitedEncoding * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+/* contents */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = der_put_octet_string(p, len, &(data)->contents, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM,
+				   UT_OctetString, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+/* tr-type */
+    {
+	size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_krb5int32(p, len, &(data)->tr_type, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_TransitedEncoding(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+			 size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+			 TransitedEncoding * data, size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type,
+				     UT_Sequence, &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t tr_type_datalen, tr_type_oldlen;
+	    Der_type tr_type_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &tr_type_type, 0, &tr_type_datalen,
+					 &l);
+	    if (e == 0 && tr_type_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    tr_type_oldlen = len;
+	    if (tr_type_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = tr_type_datalen;
+	    e = decode_krb5int32(p, len, &(data)->tr_type, &l);
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    len = tr_type_oldlen - tr_type_datalen;
+	}
+	{
+	    size_t contents_datalen, contents_oldlen;
+	    Der_type contents_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					 &contents_type, 1, &contents_datalen,
+					 &l);
+	    if (e == 0 && contents_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    contents_oldlen = len;
+	    if (contents_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = contents_datalen;
+	    {
+		size_t contents_Tag_datalen, contents_Tag_oldlen;
+		Der_type contents_Tag_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_UNIV,
+					     &contents_Tag_type,
+					     UT_OctetString,
+					     &contents_Tag_datalen, &l);
+		if (e == 0 && contents_Tag_type != PRIM) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		contents_Tag_oldlen = len;
+		if (contents_Tag_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = contents_Tag_datalen;
+		e = der_get_octet_string(p, len, &(data)->contents, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = contents_Tag_oldlen - contents_Tag_datalen;
+	    }
+	    len = contents_oldlen - contents_datalen;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_TransitedEncoding(data);
+    return e;
+}
+
+void ASN1CALL
+free_TransitedEncoding(TransitedEncoding * data)
+{
+    free_krb5int32(&(data)->tr_type);
+    der_free_octet_string(&(data)->contents);
+}
+
+size_t ASN1CALL
+length_TransitedEncoding(const TransitedEncoding * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += length_krb5int32(&(data)->tr_type);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    {
+	size_t Top_tag_oldret = ret;
+	ret = 0;
+	ret += der_length_octet_string(&(data)->contents);
+	ret += 1 + der_length_len(ret);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_TransitedEncoding(const TransitedEncoding * from, TransitedEncoding * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (copy_krb5int32(&(from)->tr_type, &(to)->tr_type))
+	goto fail;
+    if (der_copy_octet_string(&(from)->contents, &(to)->contents))
+	goto fail;
+    return 0;
+  fail:
+    free_TransitedEncoding(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_Ticket(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	      size_t len HEIMDAL_UNUSED_ATTRIBUTE, const Ticket * data,
+	      size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+/* enc-part */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_EncryptedData(p, len, &(data)->enc_part, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* sname */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_PrincipalName(p, len, &(data)->sname, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* realm */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_Realm(p, len, &(data)->realm, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* tkt-vno */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_krb5int32(p, len, &(data)->tkt_vno, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_APPL, CONS, 1, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_Ticket(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+	      size_t len HEIMDAL_UNUSED_ATTRIBUTE, Ticket * data,
+	      size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_APPL, &Top_type, 1,
+				     &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t Top_Tag_datalen, Top_Tag_oldlen;
+	    Der_type Top_Tag_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_type,
+					 UT_Sequence, &Top_Tag_datalen, &l);
+	    if (e == 0 && Top_Tag_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    Top_Tag_oldlen = len;
+	    if (Top_Tag_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = Top_Tag_datalen;
+	    {
+		size_t tkt_vno_datalen, tkt_vno_oldlen;
+		Der_type tkt_vno_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &tkt_vno_type, 0,
+					     &tkt_vno_datalen, &l);
+		if (e == 0 && tkt_vno_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		tkt_vno_oldlen = len;
+		if (tkt_vno_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = tkt_vno_datalen;
+		e = decode_krb5int32(p, len, &(data)->tkt_vno, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = tkt_vno_oldlen - tkt_vno_datalen;
+	    }
+	    {
+		size_t realm_datalen, realm_oldlen;
+		Der_type realm_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &realm_type, 1, &realm_datalen,
+					     &l);
+		if (e == 0 && realm_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		realm_oldlen = len;
+		if (realm_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = realm_datalen;
+		e = decode_Realm(p, len, &(data)->realm, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = realm_oldlen - realm_datalen;
+	    }
+	    {
+		size_t sname_datalen, sname_oldlen;
+		Der_type sname_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &sname_type, 2, &sname_datalen,
+					     &l);
+		if (e == 0 && sname_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		sname_oldlen = len;
+		if (sname_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = sname_datalen;
+		e = decode_PrincipalName(p, len, &(data)->sname, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = sname_oldlen - sname_datalen;
+	    }
+	    {
+		size_t enc_part_datalen, enc_part_oldlen;
+		Der_type enc_part_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &enc_part_type, 3,
+					     &enc_part_datalen, &l);
+		if (e == 0 && enc_part_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		enc_part_oldlen = len;
+		if (enc_part_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = enc_part_datalen;
+		e = decode_EncryptedData(p, len, &(data)->enc_part, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = enc_part_oldlen - enc_part_datalen;
+	    }
+	    len = Top_Tag_oldlen - Top_Tag_datalen;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_Ticket(data);
+    return e;
+}
+
+void ASN1CALL
+free_Ticket(Ticket * data)
+{
+    free_krb5int32(&(data)->tkt_vno);
+    free_Realm(&(data)->realm);
+    free_PrincipalName(&(data)->sname);
+    free_EncryptedData(&(data)->enc_part);
+}
+
+size_t ASN1CALL
+length_Ticket(const Ticket * data)
+{
+    size_t ret = 0;
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_krb5int32(&(data)->tkt_vno);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_Realm(&(data)->realm);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_PrincipalName(&(data)->sname);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_EncryptedData(&(data)->enc_part);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    ret += 1 + der_length_len(ret);
+    ret += 1 + der_length_len(ret);
+    return ret;
+}
+
+int ASN1CALL
+copy_Ticket(const Ticket * from, Ticket * to)
+{
+    memset(to, 0, sizeof(*to));
+    if (copy_krb5int32(&(from)->tkt_vno, &(to)->tkt_vno))
+	goto fail;
+    if (copy_Realm(&(from)->realm, &(to)->realm))
+	goto fail;
+    if (copy_PrincipalName(&(from)->sname, &(to)->sname))
+	goto fail;
+    if (copy_EncryptedData(&(from)->enc_part, &(to)->enc_part))
+	goto fail;
+    return 0;
+  fail:
+    free_Ticket(to);
+    return ENOMEM;
+}
+
+int ASN1CALL
+encode_EncTicketPart(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     const EncTicketPart * data, size_t * size)
+{
+    size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
+
+/* authorization-data */
+    if ((data)->authorization_data) {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_AuthorizationData(p, len, (data)->authorization_data, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 10, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* caddr */
+    if ((data)->caddr) {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_HostAddresses(p, len, (data)->caddr, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 9, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* renew-till */
+    if ((data)->renew_till) {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_KerberosTime(p, len, (data)->renew_till, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 8, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* endtime */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_KerberosTime(p, len, &(data)->endtime, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 7, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* starttime */
+    if ((data)->starttime) {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_KerberosTime(p, len, (data)->starttime, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 6, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* authtime */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_KerberosTime(p, len, &(data)->authtime, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 5, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* transited */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_TransitedEncoding(p, len, &(data)->transited, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 4, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* cname */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_PrincipalName(p, len, &(data)->cname, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 3, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* crealm */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_Realm(p, len, &(data)->crealm, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 2, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* key */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_EncryptionKey(p, len, &(data)->key, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 1, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+/* flags */
+    {
+	size_t Top_tag_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
+	ret = 0;
+	e = encode_TicketFlags(p, len, &(data)->flags, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	e = der_put_length_and_tag(p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
+	if (e)
+	    return e;
+	p -= l;
+	len -= l;
+	ret += l;
+
+	ret += Top_tag_tag_oldret;
+    }
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence,
+			       &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    e = der_put_length_and_tag(p, len, ret, ASN1_C_APPL, CONS, 3, &l);
+    if (e)
+	return e;
+    p -= l;
+    len -= l;
+    ret += l;
+
+    *size = ret;
+    return 0;
+}
+
+int ASN1CALL
+decode_EncTicketPart(const unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE,
+		     size_t len HEIMDAL_UNUSED_ATTRIBUTE,
+		     EncTicketPart * data, size_t * size)
+{
+    size_t ret = 0;
+    size_t l HEIMDAL_UNUSED_ATTRIBUTE;
+    int e HEIMDAL_UNUSED_ATTRIBUTE;
+
+    memset(data, 0, sizeof(*data));
+    {
+	size_t Top_datalen, Top_oldlen;
+	Der_type Top_type;
+	e = der_match_tag_and_length(p, len, ASN1_C_APPL, &Top_type, 3,
+				     &Top_datalen, &l);
+	if (e == 0 && Top_type != CONS) {
+	    e = ASN1_BAD_ID;
+	}
+	if (e)
+	    goto fail;
+	p += l;
+	len -= l;
+	ret += l;
+	Top_oldlen = len;
+	if (Top_datalen > len) {
+	    e = ASN1_OVERRUN;
+	    goto fail;
+	}
+	len = Top_datalen;
+	{
+	    size_t Top_Tag_datalen, Top_Tag_oldlen;
+	    Der_type Top_Tag_type;
+	    e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_Tag_type,
+					 UT_Sequence, &Top_Tag_datalen, &l);
+	    if (e == 0 && Top_Tag_type != CONS) {
+		e = ASN1_BAD_ID;
+	    }
+	    if (e)
+		goto fail;
+	    p += l;
+	    len -= l;
+	    ret += l;
+	    Top_Tag_oldlen = len;
+	    if (Top_Tag_datalen > len) {
+		e = ASN1_OVERRUN;
+		goto fail;
+	    }
+	    len = Top_Tag_datalen;
+	    {
+		size_t flags_datalen, flags_oldlen;
+		Der_type flags_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &flags_type, 0, &flags_datalen,
+					     &l);
+		if (e == 0 && flags_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		flags_oldlen = len;
+		if (flags_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = flags_datalen;
+		e = decode_TicketFlags(p, len, &(data)->flags, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = flags_oldlen - flags_datalen;
+	    }
+	    {
+		size_t key_datalen, key_oldlen;
+		Der_type key_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &key_type, 1, &key_datalen, &l);
+		if (e == 0 && key_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		key_oldlen = len;
+		if (key_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = key_datalen;
+		e = decode_EncryptionKey(p, len, &(data)->key, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = key_oldlen - key_datalen;
+	    }
+	    {
+		size_t crealm_datalen, crealm_oldlen;
+		Der_type crealm_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &crealm_type, 2, &crealm_datalen,
+					     &l);
+		if (e == 0 && crealm_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		crealm_oldlen = len;
+		if (crealm_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = crealm_datalen;
+		e = decode_Realm(p, len, &(data)->crealm, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = crealm_oldlen - crealm_datalen;
+	    }
+	    {
+		size_t cname_datalen, cname_oldlen;
+		Der_type cname_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &cname_type, 3, &cname_datalen,
+					     &l);
+		if (e == 0 && cname_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		cname_oldlen = len;
+		if (cname_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = cname_datalen;
+		e = decode_PrincipalName(p, len, &(data)->cname, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = cname_oldlen - cname_datalen;
+	    }
+	    {
+		size_t transited_datalen, transited_oldlen;
+		Der_type transited_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &transited_type, 4,
+					     &transited_datalen, &l);
+		if (e == 0 && transited_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		transited_oldlen = len;
+		if (transited_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = transited_datalen;
+		e = decode_TransitedEncoding(p, len, &(data)->transited, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = transited_oldlen - transited_datalen;
+	    }
+	    {
+		size_t authtime_datalen, authtime_oldlen;
+		Der_type authtime_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &authtime_type, 5,
+					     &authtime_datalen, &l);
+		if (e == 0 && authtime_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		authtime_oldlen = len;
+		if (authtime_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = authtime_datalen;
+		e = decode_KerberosTime(p, len, &(data)->authtime, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = authtime_oldlen - authtime_datalen;
+	    }
+	    {
+		size_t starttime_datalen, starttime_oldlen;
+		Der_type starttime_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &starttime_type, 6,
+					     &starttime_datalen, &l);
+		if (e == 0 && starttime_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e) {
+		    (data)->starttime = NULL;
+		} else {
+		    (data)->starttime = calloc(1, sizeof(*(data)->starttime));
+		    if ((data)->starttime == NULL) {
+			e = ENOMEM;
+			goto fail;
+		    }
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    starttime_oldlen = len;
+		    if (starttime_datalen > len) {
+			e = ASN1_OVERRUN;
+			goto fail;
+		    }
+		    len = starttime_datalen;
+		    e = decode_KerberosTime(p, len, (data)->starttime, &l);
+		    if (e)
+			goto fail;
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    len = starttime_oldlen - starttime_datalen;
+		}
+	    }
+	    {
+		size_t endtime_datalen, endtime_oldlen;
+		Der_type endtime_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &endtime_type, 7,
+					     &endtime_datalen, &l);
+		if (e == 0 && endtime_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		endtime_oldlen = len;
+		if (endtime_datalen > len) {
+		    e = ASN1_OVERRUN;
+		    goto fail;
+		}
+		len = endtime_datalen;
+		e = decode_KerberosTime(p, len, &(data)->endtime, &l);
+		if (e)
+		    goto fail;
+		p += l;
+		len -= l;
+		ret += l;
+		len = endtime_oldlen - endtime_datalen;
+	    }
+	    {
+		size_t renew_till_datalen, renew_till_oldlen;
+		Der_type renew_till_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &renew_till_type, 8,
+					     &renew_till_datalen, &l);
+		if (e == 0 && renew_till_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e) {
+		    (data)->renew_till = NULL;
+		} else {
+		    (data)->renew_till =
+			calloc(1, sizeof(*(data)->renew_till));
+		    if ((data)->renew_till == NULL) {
+			e = ENOMEM;
+			goto fail;
+		    }
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    renew_till_oldlen = len;
+		    if (renew_till_datalen > len) {
+			e = ASN1_OVERRUN;
+			goto fail;
+		    }
+		    len = renew_till_datalen;
+		    e = decode_KerberosTime(p, len, (data)->renew_till, &l);
+		    if (e)
+			goto fail;
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    len = renew_till_oldlen - renew_till_datalen;
+		}
+	    }
+	    {
+		size_t caddr_datalen, caddr_oldlen;
+		Der_type caddr_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &caddr_type, 9, &caddr_datalen,
+					     &l);
+		if (e == 0 && caddr_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e) {
+		    (data)->caddr = NULL;
+		} else {
+		    (data)->caddr = calloc(1, sizeof(*(data)->caddr));
+		    if ((data)->caddr == NULL) {
+			e = ENOMEM;
+			goto fail;
+		    }
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    caddr_oldlen = len;
+		    if (caddr_datalen > len) {
+			e = ASN1_OVERRUN;
+			goto fail;
+		    }
+		    len = caddr_datalen;
+		    e = decode_HostAddresses(p, len, (data)->caddr, &l);
+		    if (e)
+			goto fail;
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    len = caddr_oldlen - caddr_datalen;
+		}
+	    }
+	    {
+		size_t authorization_data_datalen, authorization_data_oldlen;
+		Der_type authorization_data_type;
+		e = der_match_tag_and_length(p, len, ASN1_C_CONTEXT,
+					     &authorization_data_type, 10,
+					     &authorization_data_datalen, &l);
+		if (e == 0 && authorization_data_type != CONS) {
+		    e = ASN1_BAD_ID;
+		}
+		if (e) {
+		    (data)->authorization_data = NULL;
+		} else {
+		    (data)->authorization_data =
+			calloc(1, sizeof(*(data)->authorization_data));
+		    if ((data)->authorization_data == NULL) {
+			e = ENOMEM;
+			goto fail;
+		    }
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    authorization_data_oldlen = len;
+		    if (authorization_data_datalen > len) {
+			e = ASN1_OVERRUN;
+			goto fail;
+		    }
+		    len = authorization_data_datalen;
+		    e = decode_AuthorizationData(p, len,
+						 (data)->authorization_data,
+						 &l);
+		    if (e)
+			goto fail;
+		    p += l;
+		    len -= l;
+		    ret += l;
+		    len =
+			authorization_data_oldlen -
+			authorization_data_datalen;
+		}
+	    }
+	    len = Top_Tag_oldlen - Top_Tag_datalen;
+	}
+	len = Top_oldlen - Top_datalen;
+    }
+    if (size)
+	*size = ret;
+    return 0;
+  fail:
+    free_EncTicketPart(data);
     return e;
 }
 
-void
-free_ENCTYPE(ENCTYPE * data)
+void ASN1CALL
+free_EncTicketPart(EncTicketPart * data)
 {
+    free_TicketFlags(&(data)->flags);
+    free_EncryptionKey(&(data)->key);
+    free_Realm(&(data)->crealm);
+    free_PrincipalName(&(data)->cname);
+    free_TransitedEncoding(&(data)->transited);
+    free_KerberosTime(&(data)->authtime);
+    if ((data)->starttime) {
+	free_KerberosTime((data)->starttime);
+	free((data)->starttime);
+	(data)->starttime = NULL;
+    }
+    free_KerberosTime(&(data)->endtime);
+    if ((data)->renew_till) {
+	free_KerberosTime((data)->renew_till);
+	free((data)->renew_till);
+	(data)->renew_till = NULL;
+    }
+    if ((data)->caddr) {
+	free_HostAddresses((data)->caddr);
+	free((data)->caddr);
+	(data)->caddr = NULL;
+    }
+    if ((data)->authorization_data) {
+	free_AuthorizationData((data)->authorization_data);
+	free((data)->authorization_data);
+	(data)->authorization_data = NULL;
+    }
 }
 
-size_t
-length_ENCTYPE(const ENCTYPE * data)
+size_t ASN1CALL
+length_EncTicketPart(const EncTicketPart * data)
 {
     size_t ret = 0;
     {
-	int enumint = *data;
-	ret += der_length_integer(&enumint);
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_TicketFlags(&(data)->flags);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
     }
-    ret += 1 + der_length_len(ret);
-    return ret;
-}
-
-int
-copy_ENCTYPE(const ENCTYPE * from, ENCTYPE * to)
-{
-    memset(to, 0, sizeof(*to));
-    *(to) = *(from);
-    return 0;
-}
-
-
-
-/* Generated from ./krb5.asn1 */
-/* Do not edit */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <time.h>
-#include <string.h>
-#include <errno.h>
-#include <limits.h>
-#include <asn1_err.h>
-
-int
-encode_NAME_TYPE(unsigned char *p, size_t len, const NAME_TYPE * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int i AFS_UNUSED, e;
-
-    i = 0;
     {
-	int enumint = (int) *data;
-	e = der_put_integer(p, len, &enumint, &l);
-	if (e)
-	    return e;
-	p -= l;
-	len -= l;
-	ret += l;
-
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_EncryptionKey(&(data)->key);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
     }
-    ;
-    e = der_put_length_and_tag(p, len, ret, ASN1_C_UNIV, PRIM, UT_Integer, &l);
-    if (e)
-	return e;
-    p -= l;
-    len -= l;
-    ret += l;
-
-    *size = ret;
-    return 0;
-}
-
-int
-decode_NAME_TYPE(const unsigned char *p, size_t len, NAME_TYPE * data, size_t * size)
-{
-    size_t ret = 0;
-    size_t l;
-    int e;
-
-    memset(data, 0, sizeof(*data));
     {
-	size_t Top_datalen, Top_oldlen;
-	Der_type Top_type;
-	e = der_match_tag_and_length(p, len, ASN1_C_UNIV, &Top_type, UT_Integer, &Top_datalen, &l);
-	if (e == 0 && Top_type != PRIM) {
-	    e = ASN1_BAD_ID;
-	}
-	if (e)
-	    goto fail;
-	p += l;
-	len -= l;
-	ret += l;
-	Top_oldlen = len;
-	if (Top_datalen > len) {
-	    e = ASN1_OVERRUN;
-	    goto fail;
-	}
-	len = Top_datalen;
-	{
-	    int enumint;
-	    e = der_get_integer(p, len, &enumint, &l);
-	    if (e)
-		goto fail;
-	    p += l;
-	    len -= l;
-	    ret += l;
-	    *data = enumint;
-	}
-	len = Top_oldlen - Top_datalen;
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_Realm(&(data)->crealm);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
     }
-    if (size)
-	*size = ret;
-    return 0;
-fail:
-    free_NAME_TYPE(data);
-    return e;
-}
-
-void
-free_NAME_TYPE(NAME_TYPE * data)
-{
-}
-
-size_t
-length_NAME_TYPE(const NAME_TYPE * data)
-{
-    size_t ret = 0;
     {
-	int enumint = *data;
-	ret += der_length_integer(&enumint);
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_PrincipalName(&(data)->cname);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_TransitedEncoding(&(data)->transited);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_KerberosTime(&(data)->authtime);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    if ((data)->starttime) {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_KerberosTime((data)->starttime);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_KerberosTime(&(data)->endtime);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    if ((data)->renew_till) {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_KerberosTime((data)->renew_till);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    if ((data)->caddr) {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_HostAddresses((data)->caddr);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
+    }
+    if ((data)->authorization_data) {
+	size_t Top_tag_tag_oldret = ret;
+	ret = 0;
+	ret += length_AuthorizationData((data)->authorization_data);
+	ret += 1 + der_length_len(ret);
+	ret += Top_tag_tag_oldret;
     }
     ret += 1 + der_length_len(ret);
+    ret += 1 + der_length_len(ret);
     return ret;
 }
 
-int
-copy_NAME_TYPE(const NAME_TYPE * from, NAME_TYPE * to)
+int ASN1CALL
+copy_EncTicketPart(const EncTicketPart * from, EncTicketPart * to)
 {
     memset(to, 0, sizeof(*to));
-    *(to) = *(from);
+    if (copy_TicketFlags(&(from)->flags, &(to)->flags))
+	goto fail;
+    if (copy_EncryptionKey(&(from)->key, &(to)->key))
+	goto fail;
+    if (copy_Realm(&(from)->crealm, &(to)->crealm))
+	goto fail;
+    if (copy_PrincipalName(&(from)->cname, &(to)->cname))
+	goto fail;
+    if (copy_TransitedEncoding(&(from)->transited, &(to)->transited))
+	goto fail;
+    if (copy_KerberosTime(&(from)->authtime, &(to)->authtime))
+	goto fail;
+    if ((from)->starttime) {
+	(to)->starttime = malloc(sizeof(*(to)->starttime));
+	if ((to)->starttime == NULL)
+	    goto fail;
+	if (copy_KerberosTime((from)->starttime, (to)->starttime))
+	    goto fail;
+    } else
+	(to)->starttime = NULL;
+    if (copy_KerberosTime(&(from)->endtime, &(to)->endtime))
+	goto fail;
+    if ((from)->renew_till) {
+	(to)->renew_till = malloc(sizeof(*(to)->renew_till));
+	if ((to)->renew_till == NULL)
+	    goto fail;
+	if (copy_KerberosTime((from)->renew_till, (to)->renew_till))
+	    goto fail;
+    } else
+	(to)->renew_till = NULL;
+    if ((from)->caddr) {
+	(to)->caddr = malloc(sizeof(*(to)->caddr));
+	if ((to)->caddr == NULL)
+	    goto fail;
+	if (copy_HostAddresses((from)->caddr, (to)->caddr))
+	    goto fail;
+    } else
+	(to)->caddr = NULL;
+    if ((from)->authorization_data) {
+	(to)->authorization_data = malloc(sizeof(*(to)->authorization_data));
+	if ((to)->authorization_data == NULL)
+	    goto fail;
+	if (copy_AuthorizationData
+	    ((from)->authorization_data, (to)->authorization_data))
+	    goto fail;
+    } else
+	(to)->authorization_data = NULL;
     return 0;
+  fail:
+    free_EncTicketPart(to);
+    return ENOMEM;
 }
diff --git a/src/rxkad/v5gen.h b/src/rxkad/v5gen.h
index 5ca4f9779..e0ec33e1c 100644
--- a/src/rxkad/v5gen.h
+++ b/src/rxkad/v5gen.h
@@ -10,24 +10,28 @@
 #ifndef __asn1_common_definitions__
 #define __asn1_common_definitions__
 
+#ifndef __HEIM_BASE_DATA__
+#define __HEIM_BASE_DATA__ 1
+struct heim_base_data {
+    size_t length;
+    void *data;
+};
+typedef struct heim_base_data heim_octet_string;
+#endif
+
 typedef struct heim_integer {
   size_t length;
   void *data;
   int negative;
 } heim_integer;
 
-typedef struct heim_octet_string {
-  size_t length;
-  void *data;
-} heim_octet_string;
-
 typedef char *heim_general_string;
 
 typedef char *heim_utf8_string;
 
-typedef char *heim_printable_string;
+typedef struct heim_base_data heim_printable_string;
 
-typedef char *heim_ia5_string;
+typedef struct heim_base_data heim_ia5_string;
 
 typedef struct heim_bmp_string {
   size_t length;
@@ -51,8 +55,8 @@ typedef struct heim_bit_string {
   void *data;
 } heim_bit_string;
 
-typedef struct heim_octet_string heim_any;
-typedef struct heim_octet_string heim_any_set;
+typedef struct heim_base_data heim_any;
+typedef struct heim_base_data heim_any_set;
 
 #define ASN1_MALLOC_ENCODE(T, B, BL, S, L, R)                  \
   do {                                                         \
@@ -70,6 +74,17 @@ typedef struct heim_octet_string heim_any_set;
     }                                                          \
   } while (0)
 
+#ifdef _WIN32
+#ifndef ASN1_LIB
+#define ASN1EXP  __declspec(dllimport)
+#else
+#define ASN1EXP
+#endif
+#define ASN1CALL __stdcall
+#else
+#define ASN1EXP
+#define ASN1CALL
+#endif
 
 #endif
 
@@ -85,10 +100,15 @@ NAME-TYPE ::= INTEGER {
   KRB5_NT_SMTP_NAME(7),
   KRB5_NT_ENTERPRISE_PRINCIPAL(10),
   KRB5_NT_WELLKNOWN(11),
+  KRB5_NT_SRV_HST_DOMAIN(12),
   KRB5_NT_ENT_PRINCIPAL_AND_ID(-130),
   KRB5_NT_MS_PRINCIPAL(-128),
   KRB5_NT_MS_PRINCIPAL_AND_ID(-129),
-  KRB5_NT_NTLM(-1200)
+  KRB5_NT_NTLM(-1200),
+  KRB5_NT_X509_GENERAL_NAME(-1201),
+  KRB5_NT_GSS_HOSTBASED_SERVICE(-1202),
+  KRB5_NT_CACHE_UUID(-1203),
+  KRB5_NT_SRV_HST_NEEDS_CANON(-195894762)
 }
 */
 
@@ -103,17 +123,22 @@ typedef enum NAME_TYPE {
   KRB5_NT_SMTP_NAME = 7,
   KRB5_NT_ENTERPRISE_PRINCIPAL = 10,
   KRB5_NT_WELLKNOWN = 11,
+  KRB5_NT_SRV_HST_DOMAIN = 12,
   KRB5_NT_ENT_PRINCIPAL_AND_ID = -130,
   KRB5_NT_MS_PRINCIPAL = -128,
   KRB5_NT_MS_PRINCIPAL_AND_ID = -129,
-  KRB5_NT_NTLM = -1200
+  KRB5_NT_NTLM = -1200,
+  KRB5_NT_X509_GENERAL_NAME = -1201,
+  KRB5_NT_GSS_HOSTBASED_SERVICE = -1202,
+  KRB5_NT_CACHE_UUID = -1203,
+  KRB5_NT_SRV_HST_NEEDS_CANON = -195894762
 } NAME_TYPE;
 
-int    decode_NAME_TYPE(const unsigned char *, size_t, NAME_TYPE *, size_t *);
-int    encode_NAME_TYPE(unsigned char *, size_t, const NAME_TYPE *, size_t *);
-size_t length_NAME_TYPE(const NAME_TYPE *);
-int    copy_NAME_TYPE  (const NAME_TYPE *, NAME_TYPE *);
-void   free_NAME_TYPE  (NAME_TYPE *);
+ASN1EXP int    ASN1CALL decode_NAME_TYPE(const unsigned char *, size_t, NAME_TYPE *, size_t *);
+ASN1EXP int    ASN1CALL encode_NAME_TYPE(unsigned char *, size_t, const NAME_TYPE *, size_t *);
+ASN1EXP size_t ASN1CALL length_NAME_TYPE(const NAME_TYPE *);
+ASN1EXP int    ASN1CALL copy_NAME_TYPE  (const NAME_TYPE *, NAME_TYPE *);
+ASN1EXP void   ASN1CALL free_NAME_TYPE  (NAME_TYPE *);
 
 
 /*
@@ -144,13 +169,6 @@ typedef enum MESSAGE_TYPE {
   krb_error = 30
 } MESSAGE_TYPE;
 
-int    decode_MESSAGE_TYPE(const unsigned char *, size_t, MESSAGE_TYPE *, size_t *);
-int    encode_MESSAGE_TYPE(unsigned char *, size_t, const MESSAGE_TYPE *, size_t *);
-size_t length_MESSAGE_TYPE(const MESSAGE_TYPE *);
-int    copy_MESSAGE_TYPE  (const MESSAGE_TYPE *, MESSAGE_TYPE *);
-void   free_MESSAGE_TYPE  (MESSAGE_TYPE *);
-
-
 /*
 PADATA-TYPE ::= INTEGER {
   KRB5_PADATA_NONE(0),
@@ -184,6 +202,7 @@ PADATA-TYPE ::= INTEGER {
   KRB5_PADATA_SAM_CHALLENGE2(30),
   KRB5_PADATA_SAM_RESPONSE2(31),
   KRB5_PA_EXTRA_TGT(41),
+  KRB5_PADATA_FX_FAST_ARMOR(71),
   KRB5_PADATA_TD_KRB_PRINCIPAL(102),
   KRB5_PADATA_PK_TD_TRUSTED_CERTIFIERS(104),
   KRB5_PADATA_PK_TD_CERTIFICATE_INDEX(105),
@@ -196,7 +215,6 @@ PADATA-TYPE ::= INTEGER {
   KRB5_PADATA_FOR_CHECK_DUPS(131),
   KRB5_PADATA_AS_CHECKSUM(132),
   KRB5_PADATA_PK_AS_09_BINDING(132),
-  KRB5_PADATA_CLIENT_CANONICALIZED(133),
   KRB5_PADATA_FX_COOKIE(133),
   KRB5_PADATA_AUTHENTICATION_SET(134),
   KRB5_PADATA_AUTH_SET_SELECTED(135),
@@ -211,6 +229,7 @@ PADATA-TYPE ::= INTEGER {
   KRB5_PADATA_EPAK_AS_REP(146),
   KRB5_PADATA_PKINIT_KX(147),
   KRB5_PADATA_PKU2U_NAME(148),
+  KRB5_PADATA_REQ_ENC_PA_REP(149),
   KRB5_PADATA_SUPPORTED_ETYPES(165)
 }
 */
@@ -247,6 +266,7 @@ typedef enum PADATA_TYPE {
   KRB5_PADATA_SAM_CHALLENGE2 = 30,
   KRB5_PADATA_SAM_RESPONSE2 = 31,
   KRB5_PA_EXTRA_TGT = 41,
+  KRB5_PADATA_FX_FAST_ARMOR = 71,
   KRB5_PADATA_TD_KRB_PRINCIPAL = 102,
   KRB5_PADATA_PK_TD_TRUSTED_CERTIFIERS = 104,
   KRB5_PADATA_PK_TD_CERTIFICATE_INDEX = 105,
@@ -259,7 +279,6 @@ typedef enum PADATA_TYPE {
   KRB5_PADATA_FOR_CHECK_DUPS = 131,
   KRB5_PADATA_AS_CHECKSUM = 132,
   KRB5_PADATA_PK_AS_09_BINDING = 132,
-  KRB5_PADATA_CLIENT_CANONICALIZED = 133,
   KRB5_PADATA_FX_COOKIE = 133,
   KRB5_PADATA_AUTHENTICATION_SET = 134,
   KRB5_PADATA_AUTH_SET_SELECTED = 135,
@@ -274,14 +293,15 @@ typedef enum PADATA_TYPE {
   KRB5_PADATA_EPAK_AS_REP = 146,
   KRB5_PADATA_PKINIT_KX = 147,
   KRB5_PADATA_PKU2U_NAME = 148,
+  KRB5_PADATA_REQ_ENC_PA_REP = 149,
   KRB5_PADATA_SUPPORTED_ETYPES = 165
 } PADATA_TYPE;
 
-int    decode_PADATA_TYPE(const unsigned char *, size_t, PADATA_TYPE *, size_t *);
-int    encode_PADATA_TYPE(unsigned char *, size_t, const PADATA_TYPE *, size_t *);
-size_t length_PADATA_TYPE(const PADATA_TYPE *);
-int    copy_PADATA_TYPE  (const PADATA_TYPE *, PADATA_TYPE *);
-void   free_PADATA_TYPE  (PADATA_TYPE *);
+ASN1EXP int    ASN1CALL decode_PADATA_TYPE(const unsigned char *, size_t, PADATA_TYPE *, size_t *);
+ASN1EXP int    ASN1CALL encode_PADATA_TYPE(unsigned char *, size_t, const PADATA_TYPE *, size_t *);
+ASN1EXP size_t ASN1CALL length_PADATA_TYPE(const PADATA_TYPE *);
+ASN1EXP int    ASN1CALL copy_PADATA_TYPE  (const PADATA_TYPE *, PADATA_TYPE *);
+ASN1EXP void   ASN1CALL free_PADATA_TYPE  (PADATA_TYPE *);
 
 
 /*
@@ -326,11 +346,11 @@ typedef enum AUTHDATA_TYPE {
   KRB5_AUTHDATA_SIGNTICKET = 512
 } AUTHDATA_TYPE;
 
-int    decode_AUTHDATA_TYPE(const unsigned char *, size_t, AUTHDATA_TYPE *, size_t *);
-int    encode_AUTHDATA_TYPE(unsigned char *, size_t, const AUTHDATA_TYPE *, size_t *);
-size_t length_AUTHDATA_TYPE(const AUTHDATA_TYPE *);
-int    copy_AUTHDATA_TYPE  (const AUTHDATA_TYPE *, AUTHDATA_TYPE *);
-void   free_AUTHDATA_TYPE  (AUTHDATA_TYPE *);
+ASN1EXP int    ASN1CALL decode_AUTHDATA_TYPE(const unsigned char *, size_t, AUTHDATA_TYPE *, size_t *);
+ASN1EXP int    ASN1CALL encode_AUTHDATA_TYPE(unsigned char *, size_t, const AUTHDATA_TYPE *, size_t *);
+ASN1EXP size_t ASN1CALL length_AUTHDATA_TYPE(const AUTHDATA_TYPE *);
+ASN1EXP int    ASN1CALL copy_AUTHDATA_TYPE  (const AUTHDATA_TYPE *, AUTHDATA_TYPE *);
+ASN1EXP void   ASN1CALL free_AUTHDATA_TYPE  (AUTHDATA_TYPE *);
 
 
 /*
@@ -350,6 +370,8 @@ CKSUMTYPE ::= INTEGER {
   CKSUMTYPE_SHA1(14),
   CKSUMTYPE_HMAC_SHA1_96_AES_128(15),
   CKSUMTYPE_HMAC_SHA1_96_AES_256(16),
+  CKSUMTYPE_HMAC_SHA256_128_AES128(19),
+  CKSUMTYPE_HMAC_SHA384_192_AES256(20),
   CKSUMTYPE_GSSAPI(32771),
   CKSUMTYPE_HMAC_MD5(-138),
   CKSUMTYPE_HMAC_MD5_ENC(-1138)
@@ -372,118 +394,110 @@ typedef enum CKSUMTYPE {
   CKSUMTYPE_SHA1 = 14,
   CKSUMTYPE_HMAC_SHA1_96_AES_128 = 15,
   CKSUMTYPE_HMAC_SHA1_96_AES_256 = 16,
+  CKSUMTYPE_HMAC_SHA256_128_AES128 = 19,
+  CKSUMTYPE_HMAC_SHA384_192_AES256 = 20,
   CKSUMTYPE_GSSAPI = 32771,
   CKSUMTYPE_HMAC_MD5 = -138,
   CKSUMTYPE_HMAC_MD5_ENC = -1138
 } CKSUMTYPE;
 
-int    decode_CKSUMTYPE(const unsigned char *, size_t, CKSUMTYPE *, size_t *);
-int    encode_CKSUMTYPE(unsigned char *, size_t, const CKSUMTYPE *, size_t *);
-size_t length_CKSUMTYPE(const CKSUMTYPE *);
-int    copy_CKSUMTYPE  (const CKSUMTYPE *, CKSUMTYPE *);
-void   free_CKSUMTYPE  (CKSUMTYPE *);
+ASN1EXP int    ASN1CALL decode_CKSUMTYPE(const unsigned char *, size_t, CKSUMTYPE *, size_t *);
+ASN1EXP int    ASN1CALL encode_CKSUMTYPE(unsigned char *, size_t, const CKSUMTYPE *, size_t *);
+ASN1EXP size_t ASN1CALL length_CKSUMTYPE(const CKSUMTYPE *);
+ASN1EXP int    ASN1CALL copy_CKSUMTYPE  (const CKSUMTYPE *, CKSUMTYPE *);
+ASN1EXP void   ASN1CALL free_CKSUMTYPE  (CKSUMTYPE *);
 
 
 /*
 ENCTYPE ::= INTEGER {
-  ETYPE_NULL(0),
-  ETYPE_DES_CBC_CRC(1),
-  ETYPE_DES_CBC_MD4(2),
-  ETYPE_DES_CBC_MD5(3),
-  ETYPE_DES3_CBC_MD5(5),
-  ETYPE_OLD_DES3_CBC_SHA1(7),
-  ETYPE_SIGN_DSA_GENERATE(8),
-  ETYPE_ENCRYPT_RSA_PRIV(9),
-  ETYPE_ENCRYPT_RSA_PUB(10),
-  ETYPE_DES3_CBC_SHA1(16),
-  ETYPE_AES128_CTS_HMAC_SHA1_96(17),
-  ETYPE_AES256_CTS_HMAC_SHA1_96(18),
-  ETYPE_ARCFOUR_HMAC_MD5(23),
-  ETYPE_ARCFOUR_HMAC_MD5_56(24),
-  ETYPE_ENCTYPE_PK_CROSS(48),
-  ETYPE_ARCFOUR_MD4(-128),
-  ETYPE_ARCFOUR_HMAC_OLD(-133),
-  ETYPE_ARCFOUR_HMAC_OLD_EXP(-135),
-  ETYPE_DES_CBC_NONE(-4096),
-  ETYPE_DES3_CBC_NONE(-4097),
-  ETYPE_DES_CFB64_NONE(-4098),
-  ETYPE_DES_PCBC_NONE(-4099),
-  ETYPE_DIGEST_MD5_NONE(-4100),
-  ETYPE_CRAM_MD5_NONE(-4101)
+  KRB5_ENCTYPE_NULL(0),
+  KRB5_ENCTYPE_DES_CBC_CRC(1),
+  KRB5_ENCTYPE_DES_CBC_MD4(2),
+  KRB5_ENCTYPE_DES_CBC_MD5(3),
+  KRB5_ENCTYPE_DES3_CBC_MD5(5),
+  KRB5_ENCTYPE_OLD_DES3_CBC_SHA1(7),
+  KRB5_ENCTYPE_SIGN_DSA_GENERATE(8),
+  KRB5_ENCTYPE_ENCRYPT_RSA_PRIV(9),
+  KRB5_ENCTYPE_ENCRYPT_RSA_PUB(10),
+  KRB5_ENCTYPE_DES3_CBC_SHA1(16),
+  KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96(17),
+  KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96(18),
+  KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128(19),
+  KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192(20),
+  KRB5_ENCTYPE_ARCFOUR_HMAC_MD5(23),
+  KRB5_ENCTYPE_ARCFOUR_HMAC_MD5_56(24),
+  KRB5_ENCTYPE_ENCTYPE_PK_CROSS(48),
+  KRB5_ENCTYPE_ARCFOUR_MD4(-128),
+  KRB5_ENCTYPE_ARCFOUR_HMAC_OLD(-133),
+  KRB5_ENCTYPE_ARCFOUR_HMAC_OLD_EXP(-135),
+  KRB5_ENCTYPE_DES_CBC_NONE(-4096),
+  KRB5_ENCTYPE_DES3_CBC_NONE(-4097),
+  KRB5_ENCTYPE_DES_CFB64_NONE(-4098),
+  KRB5_ENCTYPE_DES_PCBC_NONE(-4099),
+  KRB5_ENCTYPE_DIGEST_MD5_NONE(-4100),
+  KRB5_ENCTYPE_CRAM_MD5_NONE(-4101)
 }
 */
 
 typedef enum ENCTYPE {
-  ETYPE_NULL = 0,
-  ETYPE_DES_CBC_CRC = 1,
-  ETYPE_DES_CBC_MD4 = 2,
-  ETYPE_DES_CBC_MD5 = 3,
-  ETYPE_DES3_CBC_MD5 = 5,
-  ETYPE_OLD_DES3_CBC_SHA1 = 7,
-  ETYPE_SIGN_DSA_GENERATE = 8,
-  ETYPE_ENCRYPT_RSA_PRIV = 9,
-  ETYPE_ENCRYPT_RSA_PUB = 10,
-  ETYPE_DES3_CBC_SHA1 = 16,
-  ETYPE_AES128_CTS_HMAC_SHA1_96 = 17,
-  ETYPE_AES256_CTS_HMAC_SHA1_96 = 18,
-  ETYPE_ARCFOUR_HMAC_MD5 = 23,
-  ETYPE_ARCFOUR_HMAC_MD5_56 = 24,
-  ETYPE_ENCTYPE_PK_CROSS = 48,
-  ETYPE_ARCFOUR_MD4 = -128,
-  ETYPE_ARCFOUR_HMAC_OLD = -133,
-  ETYPE_ARCFOUR_HMAC_OLD_EXP = -135,
-  ETYPE_DES_CBC_NONE = -4096,
-  ETYPE_DES3_CBC_NONE = -4097,
-  ETYPE_DES_CFB64_NONE = -4098,
-  ETYPE_DES_PCBC_NONE = -4099,
-  ETYPE_DIGEST_MD5_NONE = -4100,
-  ETYPE_CRAM_MD5_NONE = -4101
+  KRB5_ENCTYPE_NULL = 0,
+  KRB5_ENCTYPE_DES_CBC_CRC = 1,
+  KRB5_ENCTYPE_DES_CBC_MD4 = 2,
+  KRB5_ENCTYPE_DES_CBC_MD5 = 3,
+  KRB5_ENCTYPE_DES3_CBC_MD5 = 5,
+  KRB5_ENCTYPE_OLD_DES3_CBC_SHA1 = 7,
+  KRB5_ENCTYPE_SIGN_DSA_GENERATE = 8,
+  KRB5_ENCTYPE_ENCRYPT_RSA_PRIV = 9,
+  KRB5_ENCTYPE_ENCRYPT_RSA_PUB = 10,
+  KRB5_ENCTYPE_DES3_CBC_SHA1 = 16,
+  KRB5_ENCTYPE_AES128_CTS_HMAC_SHA1_96 = 17,
+  KRB5_ENCTYPE_AES256_CTS_HMAC_SHA1_96 = 18,
+  KRB5_ENCTYPE_AES128_CTS_HMAC_SHA256_128 = 19,
+  KRB5_ENCTYPE_AES256_CTS_HMAC_SHA384_192 = 20,
+  KRB5_ENCTYPE_ARCFOUR_HMAC_MD5 = 23,
+  KRB5_ENCTYPE_ARCFOUR_HMAC_MD5_56 = 24,
+  KRB5_ENCTYPE_ENCTYPE_PK_CROSS = 48,
+  KRB5_ENCTYPE_ARCFOUR_MD4 = -128,
+  KRB5_ENCTYPE_ARCFOUR_HMAC_OLD = -133,
+  KRB5_ENCTYPE_ARCFOUR_HMAC_OLD_EXP = -135,
+  KRB5_ENCTYPE_DES_CBC_NONE = -4096,
+  KRB5_ENCTYPE_DES3_CBC_NONE = -4097,
+  KRB5_ENCTYPE_DES_CFB64_NONE = -4098,
+  KRB5_ENCTYPE_DES_PCBC_NONE = -4099,
+  KRB5_ENCTYPE_DIGEST_MD5_NONE = -4100,
+  KRB5_ENCTYPE_CRAM_MD5_NONE = -4101
 } ENCTYPE;
 
-int    decode_ENCTYPE(const unsigned char *, size_t, ENCTYPE *, size_t *);
-int    encode_ENCTYPE(unsigned char *, size_t, const ENCTYPE *, size_t *);
-size_t length_ENCTYPE(const ENCTYPE *);
-int    copy_ENCTYPE  (const ENCTYPE *, ENCTYPE *);
-void   free_ENCTYPE  (ENCTYPE *);
+ASN1EXP int    ASN1CALL decode_ENCTYPE(const unsigned char *, size_t, ENCTYPE *, size_t *);
+ASN1EXP int    ASN1CALL encode_ENCTYPE(unsigned char *, size_t, const ENCTYPE *, size_t *);
+ASN1EXP size_t ASN1CALL length_ENCTYPE(const ENCTYPE *);
+ASN1EXP int    ASN1CALL copy_ENCTYPE  (const ENCTYPE *, ENCTYPE *);
+ASN1EXP void   ASN1CALL free_ENCTYPE  (ENCTYPE *);
 
 
 /*
-krb5uint32 ::= INTEGER (0..-1)
+krb5uint32 ::= INTEGER (0..4294967295)
 */
 
 typedef unsigned int krb5uint32;
 
-int    decode_krb5uint32(const unsigned char *, size_t, krb5uint32 *, size_t *);
-int    encode_krb5uint32(unsigned char *, size_t, const krb5uint32 *, size_t *);
-size_t length_krb5uint32(const krb5uint32 *);
-int    copy_krb5uint32  (const krb5uint32 *, krb5uint32 *);
-void   free_krb5uint32  (krb5uint32 *);
-
-
 /*
 krb5int32 ::= INTEGER (-2147483648..2147483647)
 */
 
 typedef int krb5int32;
 
-int    decode_krb5int32(const unsigned char *, size_t, krb5int32 *, size_t *);
-int    encode_krb5int32(unsigned char *, size_t, const krb5int32 *, size_t *);
-size_t length_krb5int32(const krb5int32 *);
-int    copy_krb5int32  (const krb5int32 *, krb5int32 *);
-void   free_krb5int32  (krb5int32 *);
-
-
 /*
 KerberosString ::= GeneralString
 */
 
 typedef heim_general_string KerberosString;
 
-int    decode_KerberosString(const unsigned char *, size_t, KerberosString *, size_t *);
-int    encode_KerberosString(unsigned char *, size_t, const KerberosString *, size_t *);
-size_t length_KerberosString(const KerberosString *);
-int    copy_KerberosString  (const KerberosString *, KerberosString *);
-void   free_KerberosString  (KerberosString *);
+ASN1EXP int    ASN1CALL decode_KerberosString(const unsigned char *, size_t, KerberosString *, size_t *);
+ASN1EXP int    ASN1CALL encode_KerberosString(unsigned char *, size_t, const KerberosString *, size_t *);
+ASN1EXP size_t ASN1CALL length_KerberosString(const KerberosString *);
+ASN1EXP int    ASN1CALL copy_KerberosString  (const KerberosString *, KerberosString *);
+ASN1EXP void   ASN1CALL free_KerberosString  (KerberosString *);
 
 
 /*
@@ -492,11 +506,11 @@ Realm ::= GeneralString
 
 typedef heim_general_string Realm;
 
-int    decode_Realm(const unsigned char *, size_t, Realm *, size_t *);
-int    encode_Realm(unsigned char *, size_t, const Realm *, size_t *);
-size_t length_Realm(const Realm *);
-int    copy_Realm  (const Realm *, Realm *);
-void   free_Realm  (Realm *);
+ASN1EXP int    ASN1CALL decode_Realm(const unsigned char *, size_t, Realm *, size_t *);
+ASN1EXP int    ASN1CALL encode_Realm(unsigned char *, size_t, const Realm *, size_t *);
+ASN1EXP size_t ASN1CALL length_Realm(const Realm *);
+ASN1EXP int    ASN1CALL copy_Realm  (const Realm *, Realm *);
+ASN1EXP void   ASN1CALL free_Realm  (Realm *);
 
 
 /*
@@ -514,11 +528,11 @@ typedef struct PrincipalName {
   } name_string;
 } PrincipalName;
 
-int    decode_PrincipalName(const unsigned char *, size_t, PrincipalName *, size_t *);
-int    encode_PrincipalName(unsigned char *, size_t, const PrincipalName *, size_t *);
-size_t length_PrincipalName(const PrincipalName *);
-int    copy_PrincipalName  (const PrincipalName *, PrincipalName *);
-void   free_PrincipalName  (PrincipalName *);
+ASN1EXP int    ASN1CALL decode_PrincipalName(const unsigned char *, size_t, PrincipalName *, size_t *);
+ASN1EXP int    ASN1CALL encode_PrincipalName(unsigned char *, size_t, const PrincipalName *, size_t *);
+ASN1EXP size_t ASN1CALL length_PrincipalName(const PrincipalName *);
+ASN1EXP int    ASN1CALL copy_PrincipalName  (const PrincipalName *, PrincipalName *);
+ASN1EXP void   ASN1CALL free_PrincipalName  (PrincipalName *);
 
 
 /*
@@ -533,11 +547,11 @@ typedef struct Principal {
   Realm realm;
 } Principal;
 
-int    decode_Principal(const unsigned char *, size_t, Principal *, size_t *);
-int    encode_Principal(unsigned char *, size_t, const Principal *, size_t *);
-size_t length_Principal(const Principal *);
-int    copy_Principal  (const Principal *, Principal *);
-void   free_Principal  (Principal *);
+ASN1EXP int    ASN1CALL decode_Principal(const unsigned char *, size_t, Principal *, size_t *);
+ASN1EXP int    ASN1CALL encode_Principal(unsigned char *, size_t, const Principal *, size_t *);
+ASN1EXP size_t ASN1CALL length_Principal(const Principal *);
+ASN1EXP int    ASN1CALL copy_Principal  (const Principal *, Principal *);
+ASN1EXP void   ASN1CALL free_Principal  (Principal *);
 
 
 /*
@@ -549,13 +563,13 @@ typedef struct Principals {
   Principal *val;
 } Principals;
 
-int   add_Principals  (Principals *, const Principal *);
-int   remove_Principals  (Principals *, unsigned int);
-int    decode_Principals(const unsigned char *, size_t, Principals *, size_t *);
-int    encode_Principals(unsigned char *, size_t, const Principals *, size_t *);
-size_t length_Principals(const Principals *);
-int    copy_Principals  (const Principals *, Principals *);
-void   free_Principals  (Principals *);
+ASN1EXP int   ASN1CALL add_Principals  (Principals *, const Principal *);
+ASN1EXP int   ASN1CALL remove_Principals  (Principals *, unsigned int);
+ASN1EXP int    ASN1CALL decode_Principals(const unsigned char *, size_t, Principals *, size_t *);
+ASN1EXP int    ASN1CALL encode_Principals(unsigned char *, size_t, const Principals *, size_t *);
+ASN1EXP size_t ASN1CALL length_Principals(const Principals *);
+ASN1EXP int    ASN1CALL copy_Principals  (const Principals *, Principals *);
+ASN1EXP void   ASN1CALL free_Principals  (Principals *);
 
 
 /*
@@ -570,11 +584,11 @@ typedef struct HostAddress {
   heim_octet_string address;
 } HostAddress;
 
-int    decode_HostAddress(const unsigned char *, size_t, HostAddress *, size_t *);
-int    encode_HostAddress(unsigned char *, size_t, const HostAddress *, size_t *);
-size_t length_HostAddress(const HostAddress *);
-int    copy_HostAddress  (const HostAddress *, HostAddress *);
-void   free_HostAddress  (HostAddress *);
+ASN1EXP int    ASN1CALL decode_HostAddress(const unsigned char *, size_t, HostAddress *, size_t *);
+ASN1EXP int    ASN1CALL encode_HostAddress(unsigned char *, size_t, const HostAddress *, size_t *);
+ASN1EXP size_t ASN1CALL length_HostAddress(const HostAddress *);
+ASN1EXP int    ASN1CALL copy_HostAddress  (const HostAddress *, HostAddress *);
+ASN1EXP void   ASN1CALL free_HostAddress  (HostAddress *);
 
 
 /*
@@ -586,11 +600,11 @@ typedef struct HostAddresses {
   HostAddress *val;
 } HostAddresses;
 
-int    decode_HostAddresses(const unsigned char *, size_t, HostAddresses *, size_t *);
-int    encode_HostAddresses(unsigned char *, size_t, const HostAddresses *, size_t *);
-size_t length_HostAddresses(const HostAddresses *);
-int    copy_HostAddresses  (const HostAddresses *, HostAddresses *);
-void   free_HostAddresses  (HostAddresses *);
+ASN1EXP int    ASN1CALL decode_HostAddresses(const unsigned char *, size_t, HostAddresses *, size_t *);
+ASN1EXP int    ASN1CALL encode_HostAddresses(unsigned char *, size_t, const HostAddresses *, size_t *);
+ASN1EXP size_t ASN1CALL length_HostAddresses(const HostAddresses *);
+ASN1EXP int    ASN1CALL copy_HostAddresses  (const HostAddresses *, HostAddresses *);
+ASN1EXP void   ASN1CALL free_HostAddresses  (HostAddresses *);
 
 
 /*
@@ -599,11 +613,11 @@ KerberosTime ::= GeneralizedTime
 
 typedef time_t KerberosTime;
 
-int    decode_KerberosTime(const unsigned char *, size_t, KerberosTime *, size_t *);
-int    encode_KerberosTime(unsigned char *, size_t, const KerberosTime *, size_t *);
-size_t length_KerberosTime(const KerberosTime *);
-int    copy_KerberosTime  (const KerberosTime *, KerberosTime *);
-void   free_KerberosTime  (KerberosTime *);
+ASN1EXP int    ASN1CALL decode_KerberosTime(const unsigned char *, size_t, KerberosTime *, size_t *);
+ASN1EXP int    ASN1CALL encode_KerberosTime(unsigned char *, size_t, const KerberosTime *, size_t *);
+ASN1EXP size_t ASN1CALL length_KerberosTime(const KerberosTime *);
+ASN1EXP int    ASN1CALL copy_KerberosTime  (const KerberosTime *, KerberosTime *);
+ASN1EXP void   ASN1CALL free_KerberosTime  (KerberosTime *);
 
 
 /*
@@ -618,11 +632,11 @@ typedef struct AuthorizationDataElement {
   heim_octet_string ad_data;
 } AuthorizationDataElement;
 
-int    decode_AuthorizationDataElement(const unsigned char *, size_t, AuthorizationDataElement *, size_t *);
-int    encode_AuthorizationDataElement(unsigned char *, size_t, const AuthorizationDataElement *, size_t *);
-size_t length_AuthorizationDataElement(const AuthorizationDataElement *);
-int    copy_AuthorizationDataElement  (const AuthorizationDataElement *, AuthorizationDataElement *);
-void   free_AuthorizationDataElement  (AuthorizationDataElement *);
+ASN1EXP int    ASN1CALL decode_AuthorizationDataElement(const unsigned char *, size_t, AuthorizationDataElement *, size_t *);
+ASN1EXP int    ASN1CALL encode_AuthorizationDataElement(unsigned char *, size_t, const AuthorizationDataElement *, size_t *);
+ASN1EXP size_t ASN1CALL length_AuthorizationDataElement(const AuthorizationDataElement *);
+ASN1EXP int    ASN1CALL copy_AuthorizationDataElement  (const AuthorizationDataElement *, AuthorizationDataElement *);
+ASN1EXP void   ASN1CALL free_AuthorizationDataElement  (AuthorizationDataElement *);
 
 
 /*
@@ -634,13 +648,13 @@ typedef struct AuthorizationData {
   AuthorizationDataElement *val;
 } AuthorizationData;
 
-int   add_AuthorizationData  (AuthorizationData *, const AuthorizationDataElement *);
-int   remove_AuthorizationData  (AuthorizationData *, unsigned int);
-int    decode_AuthorizationData(const unsigned char *, size_t, AuthorizationData *, size_t *);
-int    encode_AuthorizationData(unsigned char *, size_t, const AuthorizationData *, size_t *);
-size_t length_AuthorizationData(const AuthorizationData *);
-int    copy_AuthorizationData  (const AuthorizationData *, AuthorizationData *);
-void   free_AuthorizationData  (AuthorizationData *);
+ASN1EXP int   ASN1CALL add_AuthorizationData  (AuthorizationData *, const AuthorizationDataElement *);
+ASN1EXP int   ASN1CALL remove_AuthorizationData  (AuthorizationData *, unsigned int);
+ASN1EXP int    ASN1CALL decode_AuthorizationData(const unsigned char *, size_t, AuthorizationData *, size_t *);
+ASN1EXP int    ASN1CALL encode_AuthorizationData(unsigned char *, size_t, const AuthorizationData *, size_t *);
+ASN1EXP size_t ASN1CALL length_AuthorizationData(const AuthorizationData *);
+ASN1EXP int    ASN1CALL copy_AuthorizationData  (const AuthorizationData *, AuthorizationData *);
+ASN1EXP void   ASN1CALL free_AuthorizationData  (AuthorizationData *);
 
 
 /*
@@ -689,13 +703,6 @@ typedef struct APOptions {
 
 unsigned APOptions2int(APOptions);
 APOptions int2APOptions(unsigned);
-int    decode_APOptions(const unsigned char *, size_t, APOptions *, size_t *);
-int    encode_APOptions(unsigned char *, size_t, const APOptions *, size_t *);
-size_t length_APOptions(const APOptions *);
-int    copy_APOptions  (const APOptions *, APOptions *);
-void   free_APOptions  (APOptions *);
-
-
 /*
 TicketFlags ::= BIT STRING {
   reserved(0),
@@ -712,7 +719,8 @@ TicketFlags ::= BIT STRING {
   hw-authent(11),
   transited-policy-checked(12),
   ok-as-delegate(13),
-  anonymous(14)
+  enc-pa-rep(15),
+  anonymous(16)
 }
 */
 
@@ -731,9 +739,9 @@ typedef struct TicketFlags {
   unsigned int hw_authent:1;
   unsigned int transited_policy_checked:1;
   unsigned int ok_as_delegate:1;
+  unsigned int _unused14:1;
+  unsigned int enc_pa_rep:1;
   unsigned int anonymous:1;
-  unsigned int _unused15:1;
-  unsigned int _unused16:1;
   unsigned int _unused17:1;
   unsigned int _unused18:1;
   unsigned int _unused19:1;
@@ -754,11 +762,11 @@ typedef struct TicketFlags {
 
 unsigned TicketFlags2int(TicketFlags);
 TicketFlags int2TicketFlags(unsigned);
-int    decode_TicketFlags(const unsigned char *, size_t, TicketFlags *, size_t *);
-int    encode_TicketFlags(unsigned char *, size_t, const TicketFlags *, size_t *);
-size_t length_TicketFlags(const TicketFlags *);
-int    copy_TicketFlags  (const TicketFlags *, TicketFlags *);
-void   free_TicketFlags  (TicketFlags *);
+ASN1EXP int    ASN1CALL decode_TicketFlags(const unsigned char *, size_t, TicketFlags *, size_t *);
+ASN1EXP int    ASN1CALL encode_TicketFlags(unsigned char *, size_t, const TicketFlags *, size_t *);
+ASN1EXP size_t ASN1CALL length_TicketFlags(const TicketFlags *);
+ASN1EXP int    ASN1CALL copy_TicketFlags  (const TicketFlags *, TicketFlags *);
+ASN1EXP void   ASN1CALL free_TicketFlags  (TicketFlags *);
 
 
 /*
@@ -771,9 +779,9 @@ KDCOptions ::= BIT STRING {
   allow-postdate(5),
   postdated(6),
   renewable(8),
-  request-anonymous(14),
+  cname-in-addl-tkt(14),
   canonicalize(15),
-  constrained-delegation(16),
+  request-anonymous(16),
   disable-transited-check(26),
   renewable-ok(27),
   enc-tkt-in-skey(28),
@@ -797,9 +805,9 @@ typedef struct KDCOptions {
   unsigned int _unused11:1;
   unsigned int _unused12:1;
   unsigned int _unused13:1;
-  unsigned int request_anonymous:1;
+  unsigned int cname_in_addl_tkt:1;
   unsigned int canonicalize:1;
-  unsigned int constrained_delegation:1;
+  unsigned int request_anonymous:1;
   unsigned int _unused17:1;
   unsigned int _unused18:1;
   unsigned int _unused19:1;
@@ -820,11 +828,11 @@ typedef struct KDCOptions {
 
 unsigned KDCOptions2int(KDCOptions);
 KDCOptions int2KDCOptions(unsigned);
-int    decode_KDCOptions(const unsigned char *, size_t, KDCOptions *, size_t *);
-int    encode_KDCOptions(unsigned char *, size_t, const KDCOptions *, size_t *);
-size_t length_KDCOptions(const KDCOptions *);
-int    copy_KDCOptions  (const KDCOptions *, KDCOptions *);
-void   free_KDCOptions  (KDCOptions *);
+ASN1EXP int    ASN1CALL decode_KDCOptions(const unsigned char *, size_t, KDCOptions *, size_t *);
+ASN1EXP int    ASN1CALL encode_KDCOptions(unsigned char *, size_t, const KDCOptions *, size_t *);
+ASN1EXP size_t ASN1CALL length_KDCOptions(const KDCOptions *);
+ASN1EXP int    ASN1CALL copy_KDCOptions  (const KDCOptions *, KDCOptions *);
+ASN1EXP void   ASN1CALL free_KDCOptions  (KDCOptions *);
 
 
 /*
@@ -851,11 +859,11 @@ typedef enum LR_TYPE {
   LR_ACCT_EXPTIME = 7
 } LR_TYPE;
 
-int    decode_LR_TYPE(const unsigned char *, size_t, LR_TYPE *, size_t *);
-int    encode_LR_TYPE(unsigned char *, size_t, const LR_TYPE *, size_t *);
-size_t length_LR_TYPE(const LR_TYPE *);
-int    copy_LR_TYPE  (const LR_TYPE *, LR_TYPE *);
-void   free_LR_TYPE  (LR_TYPE *);
+ASN1EXP int    ASN1CALL decode_LR_TYPE(const unsigned char *, size_t, LR_TYPE *, size_t *);
+ASN1EXP int    ASN1CALL encode_LR_TYPE(unsigned char *, size_t, const LR_TYPE *, size_t *);
+ASN1EXP size_t ASN1CALL length_LR_TYPE(const LR_TYPE *);
+ASN1EXP int    ASN1CALL copy_LR_TYPE  (const LR_TYPE *, LR_TYPE *);
+ASN1EXP void   ASN1CALL free_LR_TYPE  (LR_TYPE *);
 
 
 /*
@@ -873,11 +881,11 @@ typedef struct LastReq {
   } *val;
 } LastReq;
 
-int    decode_LastReq(const unsigned char *, size_t, LastReq *, size_t *);
-int    encode_LastReq(unsigned char *, size_t, const LastReq *, size_t *);
-size_t length_LastReq(const LastReq *);
-int    copy_LastReq  (const LastReq *, LastReq *);
-void   free_LastReq  (LastReq *);
+ASN1EXP int    ASN1CALL decode_LastReq(const unsigned char *, size_t, LastReq *, size_t *);
+ASN1EXP int    ASN1CALL encode_LastReq(unsigned char *, size_t, const LastReq *, size_t *);
+ASN1EXP size_t ASN1CALL length_LastReq(const LastReq *);
+ASN1EXP int    ASN1CALL copy_LastReq  (const LastReq *, LastReq *);
+ASN1EXP void   ASN1CALL free_LastReq  (LastReq *);
 
 
 /*
@@ -894,11 +902,11 @@ typedef struct EncryptedData {
   heim_octet_string cipher;
 } EncryptedData;
 
-int    decode_EncryptedData(const unsigned char *, size_t, EncryptedData *, size_t *);
-int    encode_EncryptedData(unsigned char *, size_t, const EncryptedData *, size_t *);
-size_t length_EncryptedData(const EncryptedData *);
-int    copy_EncryptedData  (const EncryptedData *, EncryptedData *);
-void   free_EncryptedData  (EncryptedData *);
+ASN1EXP int    ASN1CALL decode_EncryptedData(const unsigned char *, size_t, EncryptedData *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncryptedData(unsigned char *, size_t, const EncryptedData *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncryptedData(const EncryptedData *);
+ASN1EXP int    ASN1CALL copy_EncryptedData  (const EncryptedData *, EncryptedData *);
+ASN1EXP void   ASN1CALL free_EncryptedData  (EncryptedData *);
 
 
 /*
@@ -913,11 +921,11 @@ typedef struct EncryptionKey {
   heim_octet_string keyvalue;
 } EncryptionKey;
 
-int    decode_EncryptionKey(const unsigned char *, size_t, EncryptionKey *, size_t *);
-int    encode_EncryptionKey(unsigned char *, size_t, const EncryptionKey *, size_t *);
-size_t length_EncryptionKey(const EncryptionKey *);
-int    copy_EncryptionKey  (const EncryptionKey *, EncryptionKey *);
-void   free_EncryptionKey  (EncryptionKey *);
+ASN1EXP int    ASN1CALL decode_EncryptionKey(const unsigned char *, size_t, EncryptionKey *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncryptionKey(unsigned char *, size_t, const EncryptionKey *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncryptionKey(const EncryptionKey *);
+ASN1EXP int    ASN1CALL copy_EncryptionKey  (const EncryptionKey *, EncryptionKey *);
+ASN1EXP void   ASN1CALL free_EncryptionKey  (EncryptionKey *);
 
 
 /*
@@ -932,11 +940,11 @@ typedef struct TransitedEncoding {
   heim_octet_string contents;
 } TransitedEncoding;
 
-int    decode_TransitedEncoding(const unsigned char *, size_t, TransitedEncoding *, size_t *);
-int    encode_TransitedEncoding(unsigned char *, size_t, const TransitedEncoding *, size_t *);
-size_t length_TransitedEncoding(const TransitedEncoding *);
-int    copy_TransitedEncoding  (const TransitedEncoding *, TransitedEncoding *);
-void   free_TransitedEncoding  (TransitedEncoding *);
+ASN1EXP int    ASN1CALL decode_TransitedEncoding(const unsigned char *, size_t, TransitedEncoding *, size_t *);
+ASN1EXP int    ASN1CALL encode_TransitedEncoding(unsigned char *, size_t, const TransitedEncoding *, size_t *);
+ASN1EXP size_t ASN1CALL length_TransitedEncoding(const TransitedEncoding *);
+ASN1EXP int    ASN1CALL copy_TransitedEncoding  (const TransitedEncoding *, TransitedEncoding *);
+ASN1EXP void   ASN1CALL free_TransitedEncoding  (TransitedEncoding *);
 
 
 /*
@@ -955,11 +963,11 @@ typedef struct Ticket {
   EncryptedData enc_part;
 } Ticket;
 
-int    decode_Ticket(const unsigned char *, size_t, Ticket *, size_t *);
-int    encode_Ticket(unsigned char *, size_t, const Ticket *, size_t *);
-size_t length_Ticket(const Ticket *);
-int    copy_Ticket  (const Ticket *, Ticket *);
-void   free_Ticket  (Ticket *);
+ASN1EXP int    ASN1CALL decode_Ticket(const unsigned char *, size_t, Ticket *, size_t *);
+ASN1EXP int    ASN1CALL encode_Ticket(unsigned char *, size_t, const Ticket *, size_t *);
+ASN1EXP size_t ASN1CALL length_Ticket(const Ticket *);
+ASN1EXP int    ASN1CALL copy_Ticket  (const Ticket *, Ticket *);
+ASN1EXP void   ASN1CALL free_Ticket  (Ticket *);
 
 
 /*
@@ -992,11 +1000,11 @@ typedef struct EncTicketPart {
   AuthorizationData *authorization_data;
 } EncTicketPart;
 
-int    decode_EncTicketPart(const unsigned char *, size_t, EncTicketPart *, size_t *);
-int    encode_EncTicketPart(unsigned char *, size_t, const EncTicketPart *, size_t *);
-size_t length_EncTicketPart(const EncTicketPart *);
-int    copy_EncTicketPart  (const EncTicketPart *, EncTicketPart *);
-void   free_EncTicketPart  (EncTicketPart *);
+ASN1EXP int    ASN1CALL decode_EncTicketPart(const unsigned char *, size_t, EncTicketPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncTicketPart(unsigned char *, size_t, const EncTicketPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncTicketPart(const EncTicketPart *);
+ASN1EXP int    ASN1CALL copy_EncTicketPart  (const EncTicketPart *, EncTicketPart *);
+ASN1EXP void   ASN1CALL free_EncTicketPart  (EncTicketPart *);
 
 
 /*
@@ -1011,11 +1019,11 @@ typedef struct Checksum {
   heim_octet_string checksum;
 } Checksum;
 
-int    decode_Checksum(const unsigned char *, size_t, Checksum *, size_t *);
-int    encode_Checksum(unsigned char *, size_t, const Checksum *, size_t *);
-size_t length_Checksum(const Checksum *);
-int    copy_Checksum  (const Checksum *, Checksum *);
-void   free_Checksum  (Checksum *);
+ASN1EXP int    ASN1CALL decode_Checksum(const unsigned char *, size_t, Checksum *, size_t *);
+ASN1EXP int    ASN1CALL encode_Checksum(unsigned char *, size_t, const Checksum *, size_t *);
+ASN1EXP size_t ASN1CALL length_Checksum(const Checksum *);
+ASN1EXP int    ASN1CALL copy_Checksum  (const Checksum *, Checksum *);
+ASN1EXP void   ASN1CALL free_Checksum  (Checksum *);
 
 
 /*
@@ -1044,11 +1052,11 @@ typedef struct Authenticator {
   AuthorizationData *authorization_data;
 } Authenticator;
 
-int    decode_Authenticator(const unsigned char *, size_t, Authenticator *, size_t *);
-int    encode_Authenticator(unsigned char *, size_t, const Authenticator *, size_t *);
-size_t length_Authenticator(const Authenticator *);
-int    copy_Authenticator  (const Authenticator *, Authenticator *);
-void   free_Authenticator  (Authenticator *);
+ASN1EXP int    ASN1CALL decode_Authenticator(const unsigned char *, size_t, Authenticator *, size_t *);
+ASN1EXP int    ASN1CALL encode_Authenticator(unsigned char *, size_t, const Authenticator *, size_t *);
+ASN1EXP size_t ASN1CALL length_Authenticator(const Authenticator *);
+ASN1EXP int    ASN1CALL copy_Authenticator  (const Authenticator *, Authenticator *);
+ASN1EXP void   ASN1CALL free_Authenticator  (Authenticator *);
 
 
 /*
@@ -1063,11 +1071,11 @@ typedef struct PA_DATA {
   heim_octet_string padata_value;
 } PA_DATA;
 
-int    decode_PA_DATA(const unsigned char *, size_t, PA_DATA *, size_t *);
-int    encode_PA_DATA(unsigned char *, size_t, const PA_DATA *, size_t *);
-size_t length_PA_DATA(const PA_DATA *);
-int    copy_PA_DATA  (const PA_DATA *, PA_DATA *);
-void   free_PA_DATA  (PA_DATA *);
+ASN1EXP int    ASN1CALL decode_PA_DATA(const unsigned char *, size_t, PA_DATA *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_DATA(unsigned char *, size_t, const PA_DATA *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_DATA(const PA_DATA *);
+ASN1EXP int    ASN1CALL copy_PA_DATA  (const PA_DATA *, PA_DATA *);
+ASN1EXP void   ASN1CALL free_PA_DATA  (PA_DATA *);
 
 
 /*
@@ -1084,11 +1092,11 @@ typedef struct ETYPE_INFO_ENTRY {
   krb5int32 *salttype;
 } ETYPE_INFO_ENTRY;
 
-int    decode_ETYPE_INFO_ENTRY(const unsigned char *, size_t, ETYPE_INFO_ENTRY *, size_t *);
-int    encode_ETYPE_INFO_ENTRY(unsigned char *, size_t, const ETYPE_INFO_ENTRY *, size_t *);
-size_t length_ETYPE_INFO_ENTRY(const ETYPE_INFO_ENTRY *);
-int    copy_ETYPE_INFO_ENTRY  (const ETYPE_INFO_ENTRY *, ETYPE_INFO_ENTRY *);
-void   free_ETYPE_INFO_ENTRY  (ETYPE_INFO_ENTRY *);
+ASN1EXP int    ASN1CALL decode_ETYPE_INFO_ENTRY(const unsigned char *, size_t, ETYPE_INFO_ENTRY *, size_t *);
+ASN1EXP int    ASN1CALL encode_ETYPE_INFO_ENTRY(unsigned char *, size_t, const ETYPE_INFO_ENTRY *, size_t *);
+ASN1EXP size_t ASN1CALL length_ETYPE_INFO_ENTRY(const ETYPE_INFO_ENTRY *);
+ASN1EXP int    ASN1CALL copy_ETYPE_INFO_ENTRY  (const ETYPE_INFO_ENTRY *, ETYPE_INFO_ENTRY *);
+ASN1EXP void   ASN1CALL free_ETYPE_INFO_ENTRY  (ETYPE_INFO_ENTRY *);
 
 
 /*
@@ -1100,13 +1108,13 @@ typedef struct ETYPE_INFO {
   ETYPE_INFO_ENTRY *val;
 } ETYPE_INFO;
 
-int   add_ETYPE_INFO  (ETYPE_INFO *, const ETYPE_INFO_ENTRY *);
-int   remove_ETYPE_INFO  (ETYPE_INFO *, unsigned int);
-int    decode_ETYPE_INFO(const unsigned char *, size_t, ETYPE_INFO *, size_t *);
-int    encode_ETYPE_INFO(unsigned char *, size_t, const ETYPE_INFO *, size_t *);
-size_t length_ETYPE_INFO(const ETYPE_INFO *);
-int    copy_ETYPE_INFO  (const ETYPE_INFO *, ETYPE_INFO *);
-void   free_ETYPE_INFO  (ETYPE_INFO *);
+ASN1EXP int   ASN1CALL add_ETYPE_INFO  (ETYPE_INFO *, const ETYPE_INFO_ENTRY *);
+ASN1EXP int   ASN1CALL remove_ETYPE_INFO  (ETYPE_INFO *, unsigned int);
+ASN1EXP int    ASN1CALL decode_ETYPE_INFO(const unsigned char *, size_t, ETYPE_INFO *, size_t *);
+ASN1EXP int    ASN1CALL encode_ETYPE_INFO(unsigned char *, size_t, const ETYPE_INFO *, size_t *);
+ASN1EXP size_t ASN1CALL length_ETYPE_INFO(const ETYPE_INFO *);
+ASN1EXP int    ASN1CALL copy_ETYPE_INFO  (const ETYPE_INFO *, ETYPE_INFO *);
+ASN1EXP void   ASN1CALL free_ETYPE_INFO  (ETYPE_INFO *);
 
 
 /*
@@ -1123,11 +1131,11 @@ typedef struct ETYPE_INFO2_ENTRY {
   heim_octet_string *s2kparams;
 } ETYPE_INFO2_ENTRY;
 
-int    decode_ETYPE_INFO2_ENTRY(const unsigned char *, size_t, ETYPE_INFO2_ENTRY *, size_t *);
-int    encode_ETYPE_INFO2_ENTRY(unsigned char *, size_t, const ETYPE_INFO2_ENTRY *, size_t *);
-size_t length_ETYPE_INFO2_ENTRY(const ETYPE_INFO2_ENTRY *);
-int    copy_ETYPE_INFO2_ENTRY  (const ETYPE_INFO2_ENTRY *, ETYPE_INFO2_ENTRY *);
-void   free_ETYPE_INFO2_ENTRY  (ETYPE_INFO2_ENTRY *);
+ASN1EXP int    ASN1CALL decode_ETYPE_INFO2_ENTRY(const unsigned char *, size_t, ETYPE_INFO2_ENTRY *, size_t *);
+ASN1EXP int    ASN1CALL encode_ETYPE_INFO2_ENTRY(unsigned char *, size_t, const ETYPE_INFO2_ENTRY *, size_t *);
+ASN1EXP size_t ASN1CALL length_ETYPE_INFO2_ENTRY(const ETYPE_INFO2_ENTRY *);
+ASN1EXP int    ASN1CALL copy_ETYPE_INFO2_ENTRY  (const ETYPE_INFO2_ENTRY *, ETYPE_INFO2_ENTRY *);
+ASN1EXP void   ASN1CALL free_ETYPE_INFO2_ENTRY  (ETYPE_INFO2_ENTRY *);
 
 
 /*
@@ -1139,13 +1147,13 @@ typedef struct ETYPE_INFO2 {
   ETYPE_INFO2_ENTRY *val;
 } ETYPE_INFO2;
 
-int   add_ETYPE_INFO2  (ETYPE_INFO2 *, const ETYPE_INFO2_ENTRY *);
-int   remove_ETYPE_INFO2  (ETYPE_INFO2 *, unsigned int);
-int    decode_ETYPE_INFO2(const unsigned char *, size_t, ETYPE_INFO2 *, size_t *);
-int    encode_ETYPE_INFO2(unsigned char *, size_t, const ETYPE_INFO2 *, size_t *);
-size_t length_ETYPE_INFO2(const ETYPE_INFO2 *);
-int    copy_ETYPE_INFO2  (const ETYPE_INFO2 *, ETYPE_INFO2 *);
-void   free_ETYPE_INFO2  (ETYPE_INFO2 *);
+ASN1EXP int   ASN1CALL add_ETYPE_INFO2  (ETYPE_INFO2 *, const ETYPE_INFO2_ENTRY *);
+ASN1EXP int   ASN1CALL remove_ETYPE_INFO2  (ETYPE_INFO2 *, unsigned int);
+ASN1EXP int    ASN1CALL decode_ETYPE_INFO2(const unsigned char *, size_t, ETYPE_INFO2 *, size_t *);
+ASN1EXP int    ASN1CALL encode_ETYPE_INFO2(unsigned char *, size_t, const ETYPE_INFO2 *, size_t *);
+ASN1EXP size_t ASN1CALL length_ETYPE_INFO2(const ETYPE_INFO2 *);
+ASN1EXP int    ASN1CALL copy_ETYPE_INFO2  (const ETYPE_INFO2 *, ETYPE_INFO2 *);
+ASN1EXP void   ASN1CALL free_ETYPE_INFO2  (ETYPE_INFO2 *);
 
 
 /*
@@ -1157,13 +1165,13 @@ typedef struct METHOD_DATA {
   PA_DATA *val;
 } METHOD_DATA;
 
-int   add_METHOD_DATA  (METHOD_DATA *, const PA_DATA *);
-int   remove_METHOD_DATA  (METHOD_DATA *, unsigned int);
-int    decode_METHOD_DATA(const unsigned char *, size_t, METHOD_DATA *, size_t *);
-int    encode_METHOD_DATA(unsigned char *, size_t, const METHOD_DATA *, size_t *);
-size_t length_METHOD_DATA(const METHOD_DATA *);
-int    copy_METHOD_DATA  (const METHOD_DATA *, METHOD_DATA *);
-void   free_METHOD_DATA  (METHOD_DATA *);
+ASN1EXP int   ASN1CALL add_METHOD_DATA  (METHOD_DATA *, const PA_DATA *);
+ASN1EXP int   ASN1CALL remove_METHOD_DATA  (METHOD_DATA *, unsigned int);
+ASN1EXP int    ASN1CALL decode_METHOD_DATA(const unsigned char *, size_t, METHOD_DATA *, size_t *);
+ASN1EXP int    ASN1CALL encode_METHOD_DATA(unsigned char *, size_t, const METHOD_DATA *, size_t *);
+ASN1EXP size_t ASN1CALL length_METHOD_DATA(const METHOD_DATA *);
+ASN1EXP int    ASN1CALL copy_METHOD_DATA  (const METHOD_DATA *, METHOD_DATA *);
+ASN1EXP void   ASN1CALL free_METHOD_DATA  (METHOD_DATA *);
 
 
 /*
@@ -1178,11 +1186,11 @@ typedef struct TypedData {
   heim_octet_string *data_value;
 } TypedData;
 
-int    decode_TypedData(const unsigned char *, size_t, TypedData *, size_t *);
-int    encode_TypedData(unsigned char *, size_t, const TypedData *, size_t *);
-size_t length_TypedData(const TypedData *);
-int    copy_TypedData  (const TypedData *, TypedData *);
-void   free_TypedData  (TypedData *);
+ASN1EXP int    ASN1CALL decode_TypedData(const unsigned char *, size_t, TypedData *, size_t *);
+ASN1EXP int    ASN1CALL encode_TypedData(unsigned char *, size_t, const TypedData *, size_t *);
+ASN1EXP size_t ASN1CALL length_TypedData(const TypedData *);
+ASN1EXP int    ASN1CALL copy_TypedData  (const TypedData *, TypedData *);
+ASN1EXP void   ASN1CALL free_TypedData  (TypedData *);
 
 
 /*
@@ -1194,13 +1202,6 @@ typedef struct TYPED_DATA {
   TypedData *val;
 } TYPED_DATA;
 
-int    decode_TYPED_DATA(const unsigned char *, size_t, TYPED_DATA *, size_t *);
-int    encode_TYPED_DATA(unsigned char *, size_t, const TYPED_DATA *, size_t *);
-size_t length_TYPED_DATA(const TYPED_DATA *);
-int    copy_TYPED_DATA  (const TYPED_DATA *, TYPED_DATA *);
-void   free_TYPED_DATA  (TYPED_DATA *);
-
-
 /*
 KDC-REQ-BODY ::= SEQUENCE {
   kdc-options              [0] KDCOptions,
@@ -1239,11 +1240,11 @@ typedef struct KDC_REQ_BODY {
   } *additional_tickets;
 } KDC_REQ_BODY;
 
-int    decode_KDC_REQ_BODY(const unsigned char *, size_t, KDC_REQ_BODY *, size_t *);
-int    encode_KDC_REQ_BODY(unsigned char *, size_t, const KDC_REQ_BODY *, size_t *);
-size_t length_KDC_REQ_BODY(const KDC_REQ_BODY *);
-int    copy_KDC_REQ_BODY  (const KDC_REQ_BODY *, KDC_REQ_BODY *);
-void   free_KDC_REQ_BODY  (KDC_REQ_BODY *);
+ASN1EXP int    ASN1CALL decode_KDC_REQ_BODY(const unsigned char *, size_t, KDC_REQ_BODY *, size_t *);
+ASN1EXP int    ASN1CALL encode_KDC_REQ_BODY(unsigned char *, size_t, const KDC_REQ_BODY *, size_t *);
+ASN1EXP size_t ASN1CALL length_KDC_REQ_BODY(const KDC_REQ_BODY *);
+ASN1EXP int    ASN1CALL copy_KDC_REQ_BODY  (const KDC_REQ_BODY *, KDC_REQ_BODY *);
+ASN1EXP void   ASN1CALL free_KDC_REQ_BODY  (KDC_REQ_BODY *);
 
 
 /*
@@ -1262,24 +1263,17 @@ typedef struct KDC_REQ {
   KDC_REQ_BODY req_body;
 } KDC_REQ;
 
-int    decode_KDC_REQ(const unsigned char *, size_t, KDC_REQ *, size_t *);
-int    encode_KDC_REQ(unsigned char *, size_t, const KDC_REQ *, size_t *);
-size_t length_KDC_REQ(const KDC_REQ *);
-int    copy_KDC_REQ  (const KDC_REQ *, KDC_REQ *);
-void   free_KDC_REQ  (KDC_REQ *);
-
-
 /*
 AS-REQ ::= [APPLICATION 10] KDC-REQ
 */
 
 typedef KDC_REQ AS_REQ;
 
-int    decode_AS_REQ(const unsigned char *, size_t, AS_REQ *, size_t *);
-int    encode_AS_REQ(unsigned char *, size_t, const AS_REQ *, size_t *);
-size_t length_AS_REQ(const AS_REQ *);
-int    copy_AS_REQ  (const AS_REQ *, AS_REQ *);
-void   free_AS_REQ  (AS_REQ *);
+ASN1EXP int    ASN1CALL decode_AS_REQ(const unsigned char *, size_t, AS_REQ *, size_t *);
+ASN1EXP int    ASN1CALL encode_AS_REQ(unsigned char *, size_t, const AS_REQ *, size_t *);
+ASN1EXP size_t ASN1CALL length_AS_REQ(const AS_REQ *);
+ASN1EXP int    ASN1CALL copy_AS_REQ  (const AS_REQ *, AS_REQ *);
+ASN1EXP void   ASN1CALL free_AS_REQ  (AS_REQ *);
 
 
 /*
@@ -1288,11 +1282,11 @@ TGS-REQ ::= [APPLICATION 12] KDC-REQ
 
 typedef KDC_REQ TGS_REQ;
 
-int    decode_TGS_REQ(const unsigned char *, size_t, TGS_REQ *, size_t *);
-int    encode_TGS_REQ(unsigned char *, size_t, const TGS_REQ *, size_t *);
-size_t length_TGS_REQ(const TGS_REQ *);
-int    copy_TGS_REQ  (const TGS_REQ *, TGS_REQ *);
-void   free_TGS_REQ  (TGS_REQ *);
+ASN1EXP int    ASN1CALL decode_TGS_REQ(const unsigned char *, size_t, TGS_REQ *, size_t *);
+ASN1EXP int    ASN1CALL encode_TGS_REQ(unsigned char *, size_t, const TGS_REQ *, size_t *);
+ASN1EXP size_t ASN1CALL length_TGS_REQ(const TGS_REQ *);
+ASN1EXP int    ASN1CALL copy_TGS_REQ  (const TGS_REQ *, TGS_REQ *);
+ASN1EXP void   ASN1CALL free_TGS_REQ  (TGS_REQ *);
 
 
 /*
@@ -1307,11 +1301,11 @@ typedef struct PA_ENC_TS_ENC {
   krb5int32 *pausec;
 } PA_ENC_TS_ENC;
 
-int    decode_PA_ENC_TS_ENC(const unsigned char *, size_t, PA_ENC_TS_ENC *, size_t *);
-int    encode_PA_ENC_TS_ENC(unsigned char *, size_t, const PA_ENC_TS_ENC *, size_t *);
-size_t length_PA_ENC_TS_ENC(const PA_ENC_TS_ENC *);
-int    copy_PA_ENC_TS_ENC  (const PA_ENC_TS_ENC *, PA_ENC_TS_ENC *);
-void   free_PA_ENC_TS_ENC  (PA_ENC_TS_ENC *);
+ASN1EXP int    ASN1CALL decode_PA_ENC_TS_ENC(const unsigned char *, size_t, PA_ENC_TS_ENC *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_ENC_TS_ENC(unsigned char *, size_t, const PA_ENC_TS_ENC *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_ENC_TS_ENC(const PA_ENC_TS_ENC *);
+ASN1EXP int    ASN1CALL copy_PA_ENC_TS_ENC  (const PA_ENC_TS_ENC *, PA_ENC_TS_ENC *);
+ASN1EXP void   ASN1CALL free_PA_ENC_TS_ENC  (PA_ENC_TS_ENC *);
 
 
 /*
@@ -1324,11 +1318,11 @@ typedef struct PA_PAC_REQUEST {
   int include_pac;
 } PA_PAC_REQUEST;
 
-int    decode_PA_PAC_REQUEST(const unsigned char *, size_t, PA_PAC_REQUEST *, size_t *);
-int    encode_PA_PAC_REQUEST(unsigned char *, size_t, const PA_PAC_REQUEST *, size_t *);
-size_t length_PA_PAC_REQUEST(const PA_PAC_REQUEST *);
-int    copy_PA_PAC_REQUEST  (const PA_PAC_REQUEST *, PA_PAC_REQUEST *);
-void   free_PA_PAC_REQUEST  (PA_PAC_REQUEST *);
+ASN1EXP int    ASN1CALL decode_PA_PAC_REQUEST(const unsigned char *, size_t, PA_PAC_REQUEST *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_PAC_REQUEST(unsigned char *, size_t, const PA_PAC_REQUEST *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_PAC_REQUEST(const PA_PAC_REQUEST *);
+ASN1EXP int    ASN1CALL copy_PA_PAC_REQUEST  (const PA_PAC_REQUEST *, PA_PAC_REQUEST *);
+ASN1EXP void   ASN1CALL free_PA_PAC_REQUEST  (PA_PAC_REQUEST *);
 
 
 /*
@@ -1337,13 +1331,6 @@ PROV-SRV-LOCATION ::= GeneralString
 
 typedef heim_general_string PROV_SRV_LOCATION;
 
-int    decode_PROV_SRV_LOCATION(const unsigned char *, size_t, PROV_SRV_LOCATION *, size_t *);
-int    encode_PROV_SRV_LOCATION(unsigned char *, size_t, const PROV_SRV_LOCATION *, size_t *);
-size_t length_PROV_SRV_LOCATION(const PROV_SRV_LOCATION *);
-int    copy_PROV_SRV_LOCATION  (const PROV_SRV_LOCATION *, PROV_SRV_LOCATION *);
-void   free_PROV_SRV_LOCATION  (PROV_SRV_LOCATION *);
-
-
 /*
 KDC-REP ::= SEQUENCE {
   pvno            [0] krb5int32,
@@ -1366,11 +1353,11 @@ typedef struct KDC_REP {
   EncryptedData enc_part;
 } KDC_REP;
 
-int    decode_KDC_REP(const unsigned char *, size_t, KDC_REP *, size_t *);
-int    encode_KDC_REP(unsigned char *, size_t, const KDC_REP *, size_t *);
-size_t length_KDC_REP(const KDC_REP *);
-int    copy_KDC_REP  (const KDC_REP *, KDC_REP *);
-void   free_KDC_REP  (KDC_REP *);
+ASN1EXP int    ASN1CALL decode_KDC_REP(const unsigned char *, size_t, KDC_REP *, size_t *);
+ASN1EXP int    ASN1CALL encode_KDC_REP(unsigned char *, size_t, const KDC_REP *, size_t *);
+ASN1EXP size_t ASN1CALL length_KDC_REP(const KDC_REP *);
+ASN1EXP int    ASN1CALL copy_KDC_REP  (const KDC_REP *, KDC_REP *);
+ASN1EXP void   ASN1CALL free_KDC_REP  (KDC_REP *);
 
 
 /*
@@ -1379,11 +1366,11 @@ AS-REP ::= [APPLICATION 11] KDC-REP
 
 typedef KDC_REP AS_REP;
 
-int    decode_AS_REP(const unsigned char *, size_t, AS_REP *, size_t *);
-int    encode_AS_REP(unsigned char *, size_t, const AS_REP *, size_t *);
-size_t length_AS_REP(const AS_REP *);
-int    copy_AS_REP  (const AS_REP *, AS_REP *);
-void   free_AS_REP  (AS_REP *);
+ASN1EXP int    ASN1CALL decode_AS_REP(const unsigned char *, size_t, AS_REP *, size_t *);
+ASN1EXP int    ASN1CALL encode_AS_REP(unsigned char *, size_t, const AS_REP *, size_t *);
+ASN1EXP size_t ASN1CALL length_AS_REP(const AS_REP *);
+ASN1EXP int    ASN1CALL copy_AS_REP  (const AS_REP *, AS_REP *);
+ASN1EXP void   ASN1CALL free_AS_REP  (AS_REP *);
 
 
 /*
@@ -1392,11 +1379,11 @@ TGS-REP ::= [APPLICATION 13] KDC-REP
 
 typedef KDC_REP TGS_REP;
 
-int    decode_TGS_REP(const unsigned char *, size_t, TGS_REP *, size_t *);
-int    encode_TGS_REP(unsigned char *, size_t, const TGS_REP *, size_t *);
-size_t length_TGS_REP(const TGS_REP *);
-int    copy_TGS_REP  (const TGS_REP *, TGS_REP *);
-void   free_TGS_REP  (TGS_REP *);
+ASN1EXP int    ASN1CALL decode_TGS_REP(const unsigned char *, size_t, TGS_REP *, size_t *);
+ASN1EXP int    ASN1CALL encode_TGS_REP(unsigned char *, size_t, const TGS_REP *, size_t *);
+ASN1EXP size_t ASN1CALL length_TGS_REP(const TGS_REP *);
+ASN1EXP int    ASN1CALL copy_TGS_REP  (const TGS_REP *, TGS_REP *);
+ASN1EXP void   ASN1CALL free_TGS_REP  (TGS_REP *);
 
 
 /*
@@ -1433,11 +1420,11 @@ typedef struct EncKDCRepPart {
   METHOD_DATA *encrypted_pa_data;
 } EncKDCRepPart;
 
-int    decode_EncKDCRepPart(const unsigned char *, size_t, EncKDCRepPart *, size_t *);
-int    encode_EncKDCRepPart(unsigned char *, size_t, const EncKDCRepPart *, size_t *);
-size_t length_EncKDCRepPart(const EncKDCRepPart *);
-int    copy_EncKDCRepPart  (const EncKDCRepPart *, EncKDCRepPart *);
-void   free_EncKDCRepPart  (EncKDCRepPart *);
+ASN1EXP int    ASN1CALL decode_EncKDCRepPart(const unsigned char *, size_t, EncKDCRepPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncKDCRepPart(unsigned char *, size_t, const EncKDCRepPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncKDCRepPart(const EncKDCRepPart *);
+ASN1EXP int    ASN1CALL copy_EncKDCRepPart  (const EncKDCRepPart *, EncKDCRepPart *);
+ASN1EXP void   ASN1CALL free_EncKDCRepPart  (EncKDCRepPart *);
 
 
 /*
@@ -1446,11 +1433,11 @@ EncASRepPart ::= [APPLICATION 25] EncKDCRepPart
 
 typedef EncKDCRepPart EncASRepPart;
 
-int    decode_EncASRepPart(const unsigned char *, size_t, EncASRepPart *, size_t *);
-int    encode_EncASRepPart(unsigned char *, size_t, const EncASRepPart *, size_t *);
-size_t length_EncASRepPart(const EncASRepPart *);
-int    copy_EncASRepPart  (const EncASRepPart *, EncASRepPart *);
-void   free_EncASRepPart  (EncASRepPart *);
+ASN1EXP int    ASN1CALL decode_EncASRepPart(const unsigned char *, size_t, EncASRepPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncASRepPart(unsigned char *, size_t, const EncASRepPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncASRepPart(const EncASRepPart *);
+ASN1EXP int    ASN1CALL copy_EncASRepPart  (const EncASRepPart *, EncASRepPart *);
+ASN1EXP void   ASN1CALL free_EncASRepPart  (EncASRepPart *);
 
 
 /*
@@ -1459,11 +1446,11 @@ EncTGSRepPart ::= [APPLICATION 26] EncKDCRepPart
 
 typedef EncKDCRepPart EncTGSRepPart;
 
-int    decode_EncTGSRepPart(const unsigned char *, size_t, EncTGSRepPart *, size_t *);
-int    encode_EncTGSRepPart(unsigned char *, size_t, const EncTGSRepPart *, size_t *);
-size_t length_EncTGSRepPart(const EncTGSRepPart *);
-int    copy_EncTGSRepPart  (const EncTGSRepPart *, EncTGSRepPart *);
-void   free_EncTGSRepPart  (EncTGSRepPart *);
+ASN1EXP int    ASN1CALL decode_EncTGSRepPart(const unsigned char *, size_t, EncTGSRepPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncTGSRepPart(unsigned char *, size_t, const EncTGSRepPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncTGSRepPart(const EncTGSRepPart *);
+ASN1EXP int    ASN1CALL copy_EncTGSRepPart  (const EncTGSRepPart *, EncTGSRepPart *);
+ASN1EXP void   ASN1CALL free_EncTGSRepPart  (EncTGSRepPart *);
 
 
 /*
@@ -1484,11 +1471,11 @@ typedef struct AP_REQ {
   EncryptedData authenticator;
 } AP_REQ;
 
-int    decode_AP_REQ(const unsigned char *, size_t, AP_REQ *, size_t *);
-int    encode_AP_REQ(unsigned char *, size_t, const AP_REQ *, size_t *);
-size_t length_AP_REQ(const AP_REQ *);
-int    copy_AP_REQ  (const AP_REQ *, AP_REQ *);
-void   free_AP_REQ  (AP_REQ *);
+ASN1EXP int    ASN1CALL decode_AP_REQ(const unsigned char *, size_t, AP_REQ *, size_t *);
+ASN1EXP int    ASN1CALL encode_AP_REQ(unsigned char *, size_t, const AP_REQ *, size_t *);
+ASN1EXP size_t ASN1CALL length_AP_REQ(const AP_REQ *);
+ASN1EXP int    ASN1CALL copy_AP_REQ  (const AP_REQ *, AP_REQ *);
+ASN1EXP void   ASN1CALL free_AP_REQ  (AP_REQ *);
 
 
 /*
@@ -1505,11 +1492,11 @@ typedef struct AP_REP {
   EncryptedData enc_part;
 } AP_REP;
 
-int    decode_AP_REP(const unsigned char *, size_t, AP_REP *, size_t *);
-int    encode_AP_REP(unsigned char *, size_t, const AP_REP *, size_t *);
-size_t length_AP_REP(const AP_REP *);
-int    copy_AP_REP  (const AP_REP *, AP_REP *);
-void   free_AP_REP  (AP_REP *);
+ASN1EXP int    ASN1CALL decode_AP_REP(const unsigned char *, size_t, AP_REP *, size_t *);
+ASN1EXP int    ASN1CALL encode_AP_REP(unsigned char *, size_t, const AP_REP *, size_t *);
+ASN1EXP size_t ASN1CALL length_AP_REP(const AP_REP *);
+ASN1EXP int    ASN1CALL copy_AP_REP  (const AP_REP *, AP_REP *);
+ASN1EXP void   ASN1CALL free_AP_REP  (AP_REP *);
 
 
 /*
@@ -1528,11 +1515,11 @@ typedef struct EncAPRepPart {
   krb5uint32 *seq_number;
 } EncAPRepPart;
 
-int    decode_EncAPRepPart(const unsigned char *, size_t, EncAPRepPart *, size_t *);
-int    encode_EncAPRepPart(unsigned char *, size_t, const EncAPRepPart *, size_t *);
-size_t length_EncAPRepPart(const EncAPRepPart *);
-int    copy_EncAPRepPart  (const EncAPRepPart *, EncAPRepPart *);
-void   free_EncAPRepPart  (EncAPRepPart *);
+ASN1EXP int    ASN1CALL decode_EncAPRepPart(const unsigned char *, size_t, EncAPRepPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncAPRepPart(unsigned char *, size_t, const EncAPRepPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncAPRepPart(const EncAPRepPart *);
+ASN1EXP int    ASN1CALL copy_EncAPRepPart  (const EncAPRepPart *, EncAPRepPart *);
+ASN1EXP void   ASN1CALL free_EncAPRepPart  (EncAPRepPart *);
 
 
 /*
@@ -1555,11 +1542,11 @@ typedef struct KRB_SAFE_BODY {
   HostAddress *r_address;
 } KRB_SAFE_BODY;
 
-int    decode_KRB_SAFE_BODY(const unsigned char *, size_t, KRB_SAFE_BODY *, size_t *);
-int    encode_KRB_SAFE_BODY(unsigned char *, size_t, const KRB_SAFE_BODY *, size_t *);
-size_t length_KRB_SAFE_BODY(const KRB_SAFE_BODY *);
-int    copy_KRB_SAFE_BODY  (const KRB_SAFE_BODY *, KRB_SAFE_BODY *);
-void   free_KRB_SAFE_BODY  (KRB_SAFE_BODY *);
+ASN1EXP int    ASN1CALL decode_KRB_SAFE_BODY(const unsigned char *, size_t, KRB_SAFE_BODY *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB_SAFE_BODY(unsigned char *, size_t, const KRB_SAFE_BODY *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB_SAFE_BODY(const KRB_SAFE_BODY *);
+ASN1EXP int    ASN1CALL copy_KRB_SAFE_BODY  (const KRB_SAFE_BODY *, KRB_SAFE_BODY *);
+ASN1EXP void   ASN1CALL free_KRB_SAFE_BODY  (KRB_SAFE_BODY *);
 
 
 /*
@@ -1578,11 +1565,11 @@ typedef struct KRB_SAFE {
   Checksum cksum;
 } KRB_SAFE;
 
-int    decode_KRB_SAFE(const unsigned char *, size_t, KRB_SAFE *, size_t *);
-int    encode_KRB_SAFE(unsigned char *, size_t, const KRB_SAFE *, size_t *);
-size_t length_KRB_SAFE(const KRB_SAFE *);
-int    copy_KRB_SAFE  (const KRB_SAFE *, KRB_SAFE *);
-void   free_KRB_SAFE  (KRB_SAFE *);
+ASN1EXP int    ASN1CALL decode_KRB_SAFE(const unsigned char *, size_t, KRB_SAFE *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB_SAFE(unsigned char *, size_t, const KRB_SAFE *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB_SAFE(const KRB_SAFE *);
+ASN1EXP int    ASN1CALL copy_KRB_SAFE  (const KRB_SAFE *, KRB_SAFE *);
+ASN1EXP void   ASN1CALL free_KRB_SAFE  (KRB_SAFE *);
 
 
 /*
@@ -1599,11 +1586,11 @@ typedef struct KRB_PRIV {
   EncryptedData enc_part;
 } KRB_PRIV;
 
-int    decode_KRB_PRIV(const unsigned char *, size_t, KRB_PRIV *, size_t *);
-int    encode_KRB_PRIV(unsigned char *, size_t, const KRB_PRIV *, size_t *);
-size_t length_KRB_PRIV(const KRB_PRIV *);
-int    copy_KRB_PRIV  (const KRB_PRIV *, KRB_PRIV *);
-void   free_KRB_PRIV  (KRB_PRIV *);
+ASN1EXP int    ASN1CALL decode_KRB_PRIV(const unsigned char *, size_t, KRB_PRIV *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB_PRIV(unsigned char *, size_t, const KRB_PRIV *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB_PRIV(const KRB_PRIV *);
+ASN1EXP int    ASN1CALL copy_KRB_PRIV  (const KRB_PRIV *, KRB_PRIV *);
+ASN1EXP void   ASN1CALL free_KRB_PRIV  (KRB_PRIV *);
 
 
 /*
@@ -1626,11 +1613,11 @@ typedef struct EncKrbPrivPart {
   HostAddress *r_address;
 } EncKrbPrivPart;
 
-int    decode_EncKrbPrivPart(const unsigned char *, size_t, EncKrbPrivPart *, size_t *);
-int    encode_EncKrbPrivPart(unsigned char *, size_t, const EncKrbPrivPart *, size_t *);
-size_t length_EncKrbPrivPart(const EncKrbPrivPart *);
-int    copy_EncKrbPrivPart  (const EncKrbPrivPart *, EncKrbPrivPart *);
-void   free_EncKrbPrivPart  (EncKrbPrivPart *);
+ASN1EXP int    ASN1CALL decode_EncKrbPrivPart(const unsigned char *, size_t, EncKrbPrivPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncKrbPrivPart(unsigned char *, size_t, const EncKrbPrivPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncKrbPrivPart(const EncKrbPrivPart *);
+ASN1EXP int    ASN1CALL copy_EncKrbPrivPart  (const EncKrbPrivPart *, EncKrbPrivPart *);
+ASN1EXP void   ASN1CALL free_EncKrbPrivPart  (EncKrbPrivPart *);
 
 
 /*
@@ -1652,11 +1639,11 @@ typedef struct KRB_CRED {
   EncryptedData enc_part;
 } KRB_CRED;
 
-int    decode_KRB_CRED(const unsigned char *, size_t, KRB_CRED *, size_t *);
-int    encode_KRB_CRED(unsigned char *, size_t, const KRB_CRED *, size_t *);
-size_t length_KRB_CRED(const KRB_CRED *);
-int    copy_KRB_CRED  (const KRB_CRED *, KRB_CRED *);
-void   free_KRB_CRED  (KRB_CRED *);
+ASN1EXP int    ASN1CALL decode_KRB_CRED(const unsigned char *, size_t, KRB_CRED *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB_CRED(unsigned char *, size_t, const KRB_CRED *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB_CRED(const KRB_CRED *);
+ASN1EXP int    ASN1CALL copy_KRB_CRED  (const KRB_CRED *, KRB_CRED *);
+ASN1EXP void   ASN1CALL free_KRB_CRED  (KRB_CRED *);
 
 
 /*
@@ -1689,11 +1676,11 @@ typedef struct KrbCredInfo {
   HostAddresses *caddr;
 } KrbCredInfo;
 
-int    decode_KrbCredInfo(const unsigned char *, size_t, KrbCredInfo *, size_t *);
-int    encode_KrbCredInfo(unsigned char *, size_t, const KrbCredInfo *, size_t *);
-size_t length_KrbCredInfo(const KrbCredInfo *);
-int    copy_KrbCredInfo  (const KrbCredInfo *, KrbCredInfo *);
-void   free_KrbCredInfo  (KrbCredInfo *);
+ASN1EXP int    ASN1CALL decode_KrbCredInfo(const unsigned char *, size_t, KrbCredInfo *, size_t *);
+ASN1EXP int    ASN1CALL encode_KrbCredInfo(unsigned char *, size_t, const KrbCredInfo *, size_t *);
+ASN1EXP size_t ASN1CALL length_KrbCredInfo(const KrbCredInfo *);
+ASN1EXP int    ASN1CALL copy_KrbCredInfo  (const KrbCredInfo *, KrbCredInfo *);
+ASN1EXP void   ASN1CALL free_KrbCredInfo  (KrbCredInfo *);
 
 
 /*
@@ -1719,11 +1706,11 @@ typedef struct EncKrbCredPart {
   HostAddress *r_address;
 } EncKrbCredPart;
 
-int    decode_EncKrbCredPart(const unsigned char *, size_t, EncKrbCredPart *, size_t *);
-int    encode_EncKrbCredPart(unsigned char *, size_t, const EncKrbCredPart *, size_t *);
-size_t length_EncKrbCredPart(const EncKrbCredPart *);
-int    copy_EncKrbCredPart  (const EncKrbCredPart *, EncKrbCredPart *);
-void   free_EncKrbCredPart  (EncKrbCredPart *);
+ASN1EXP int    ASN1CALL decode_EncKrbCredPart(const unsigned char *, size_t, EncKrbCredPart *, size_t *);
+ASN1EXP int    ASN1CALL encode_EncKrbCredPart(unsigned char *, size_t, const EncKrbCredPart *, size_t *);
+ASN1EXP size_t ASN1CALL length_EncKrbCredPart(const EncKrbCredPart *);
+ASN1EXP int    ASN1CALL copy_EncKrbCredPart  (const EncKrbCredPart *, EncKrbCredPart *);
+ASN1EXP void   ASN1CALL free_EncKrbCredPart  (EncKrbCredPart *);
 
 
 /*
@@ -1760,11 +1747,11 @@ typedef struct KRB_ERROR {
   heim_octet_string *e_data;
 } KRB_ERROR;
 
-int    decode_KRB_ERROR(const unsigned char *, size_t, KRB_ERROR *, size_t *);
-int    encode_KRB_ERROR(unsigned char *, size_t, const KRB_ERROR *, size_t *);
-size_t length_KRB_ERROR(const KRB_ERROR *);
-int    copy_KRB_ERROR  (const KRB_ERROR *, KRB_ERROR *);
-void   free_KRB_ERROR  (KRB_ERROR *);
+ASN1EXP int    ASN1CALL decode_KRB_ERROR(const unsigned char *, size_t, KRB_ERROR *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB_ERROR(unsigned char *, size_t, const KRB_ERROR *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB_ERROR(const KRB_ERROR *);
+ASN1EXP int    ASN1CALL copy_KRB_ERROR  (const KRB_ERROR *, KRB_ERROR *);
+ASN1EXP void   ASN1CALL free_KRB_ERROR  (KRB_ERROR *);
 
 
 /*
@@ -1781,27 +1768,27 @@ typedef struct ChangePasswdDataMS {
   Realm *targrealm;
 } ChangePasswdDataMS;
 
-int    decode_ChangePasswdDataMS(const unsigned char *, size_t, ChangePasswdDataMS *, size_t *);
-int    encode_ChangePasswdDataMS(unsigned char *, size_t, const ChangePasswdDataMS *, size_t *);
-size_t length_ChangePasswdDataMS(const ChangePasswdDataMS *);
-int    copy_ChangePasswdDataMS  (const ChangePasswdDataMS *, ChangePasswdDataMS *);
-void   free_ChangePasswdDataMS  (ChangePasswdDataMS *);
+ASN1EXP int    ASN1CALL decode_ChangePasswdDataMS(const unsigned char *, size_t, ChangePasswdDataMS *, size_t *);
+ASN1EXP int    ASN1CALL encode_ChangePasswdDataMS(unsigned char *, size_t, const ChangePasswdDataMS *, size_t *);
+ASN1EXP size_t ASN1CALL length_ChangePasswdDataMS(const ChangePasswdDataMS *);
+ASN1EXP int    ASN1CALL copy_ChangePasswdDataMS  (const ChangePasswdDataMS *, ChangePasswdDataMS *);
+ASN1EXP void   ASN1CALL free_ChangePasswdDataMS  (ChangePasswdDataMS *);
 
 
 /*
-EtypeList ::= SEQUENCE OF krb5int32
+EtypeList ::= SEQUENCE OF ENCTYPE
 */
 
 typedef struct EtypeList {
   unsigned int len;
-  krb5int32 *val;
+  ENCTYPE *val;
 } EtypeList;
 
-int    decode_EtypeList(const unsigned char *, size_t, EtypeList *, size_t *);
-int    encode_EtypeList(unsigned char *, size_t, const EtypeList *, size_t *);
-size_t length_EtypeList(const EtypeList *);
-int    copy_EtypeList  (const EtypeList *, EtypeList *);
-void   free_EtypeList  (EtypeList *);
+ASN1EXP int    ASN1CALL decode_EtypeList(const unsigned char *, size_t, EtypeList *, size_t *);
+ASN1EXP int    ASN1CALL encode_EtypeList(unsigned char *, size_t, const EtypeList *, size_t *);
+ASN1EXP size_t ASN1CALL length_EtypeList(const EtypeList *);
+ASN1EXP int    ASN1CALL copy_EtypeList  (const EtypeList *, EtypeList *);
+ASN1EXP void   ASN1CALL free_EtypeList  (EtypeList *);
 
 
 enum { krb5_pvno = 5 };
@@ -1814,11 +1801,11 @@ AD-IF-RELEVANT ::= AuthorizationData
 
 typedef AuthorizationData AD_IF_RELEVANT;
 
-int    decode_AD_IF_RELEVANT(const unsigned char *, size_t, AD_IF_RELEVANT *, size_t *);
-int    encode_AD_IF_RELEVANT(unsigned char *, size_t, const AD_IF_RELEVANT *, size_t *);
-size_t length_AD_IF_RELEVANT(const AD_IF_RELEVANT *);
-int    copy_AD_IF_RELEVANT  (const AD_IF_RELEVANT *, AD_IF_RELEVANT *);
-void   free_AD_IF_RELEVANT  (AD_IF_RELEVANT *);
+ASN1EXP int    ASN1CALL decode_AD_IF_RELEVANT(const unsigned char *, size_t, AD_IF_RELEVANT *, size_t *);
+ASN1EXP int    ASN1CALL encode_AD_IF_RELEVANT(unsigned char *, size_t, const AD_IF_RELEVANT *, size_t *);
+ASN1EXP size_t ASN1CALL length_AD_IF_RELEVANT(const AD_IF_RELEVANT *);
+ASN1EXP int    ASN1CALL copy_AD_IF_RELEVANT  (const AD_IF_RELEVANT *, AD_IF_RELEVANT *);
+ASN1EXP void   ASN1CALL free_AD_IF_RELEVANT  (AD_IF_RELEVANT *);
 
 
 /*
@@ -1837,11 +1824,11 @@ typedef struct AD_KDCIssued {
   AuthorizationData elements;
 } AD_KDCIssued;
 
-int    decode_AD_KDCIssued(const unsigned char *, size_t, AD_KDCIssued *, size_t *);
-int    encode_AD_KDCIssued(unsigned char *, size_t, const AD_KDCIssued *, size_t *);
-size_t length_AD_KDCIssued(const AD_KDCIssued *);
-int    copy_AD_KDCIssued  (const AD_KDCIssued *, AD_KDCIssued *);
-void   free_AD_KDCIssued  (AD_KDCIssued *);
+ASN1EXP int    ASN1CALL decode_AD_KDCIssued(const unsigned char *, size_t, AD_KDCIssued *, size_t *);
+ASN1EXP int    ASN1CALL encode_AD_KDCIssued(unsigned char *, size_t, const AD_KDCIssued *, size_t *);
+ASN1EXP size_t ASN1CALL length_AD_KDCIssued(const AD_KDCIssued *);
+ASN1EXP int    ASN1CALL copy_AD_KDCIssued  (const AD_KDCIssued *, AD_KDCIssued *);
+ASN1EXP void   ASN1CALL free_AD_KDCIssued  (AD_KDCIssued *);
 
 
 /*
@@ -1856,11 +1843,11 @@ typedef struct AD_AND_OR {
   AuthorizationData elements;
 } AD_AND_OR;
 
-int    decode_AD_AND_OR(const unsigned char *, size_t, AD_AND_OR *, size_t *);
-int    encode_AD_AND_OR(unsigned char *, size_t, const AD_AND_OR *, size_t *);
-size_t length_AD_AND_OR(const AD_AND_OR *);
-int    copy_AD_AND_OR  (const AD_AND_OR *, AD_AND_OR *);
-void   free_AD_AND_OR  (AD_AND_OR *);
+ASN1EXP int    ASN1CALL decode_AD_AND_OR(const unsigned char *, size_t, AD_AND_OR *, size_t *);
+ASN1EXP int    ASN1CALL encode_AD_AND_OR(unsigned char *, size_t, const AD_AND_OR *, size_t *);
+ASN1EXP size_t ASN1CALL length_AD_AND_OR(const AD_AND_OR *);
+ASN1EXP int    ASN1CALL copy_AD_AND_OR  (const AD_AND_OR *, AD_AND_OR *);
+ASN1EXP void   ASN1CALL free_AD_AND_OR  (AD_AND_OR *);
 
 
 /*
@@ -1869,13 +1856,6 @@ AD-MANDATORY-FOR-KDC ::= AuthorizationData
 
 typedef AuthorizationData AD_MANDATORY_FOR_KDC;
 
-int    decode_AD_MANDATORY_FOR_KDC(const unsigned char *, size_t, AD_MANDATORY_FOR_KDC *, size_t *);
-int    encode_AD_MANDATORY_FOR_KDC(unsigned char *, size_t, const AD_MANDATORY_FOR_KDC *, size_t *);
-size_t length_AD_MANDATORY_FOR_KDC(const AD_MANDATORY_FOR_KDC *);
-int    copy_AD_MANDATORY_FOR_KDC  (const AD_MANDATORY_FOR_KDC *, AD_MANDATORY_FOR_KDC *);
-void   free_AD_MANDATORY_FOR_KDC  (AD_MANDATORY_FOR_KDC *);
-
-
 /*
 PA-SAM-TYPE ::= INTEGER {
   PA_SAM_TYPE_ENIGMA(1),
@@ -1896,26 +1876,12 @@ typedef enum PA_SAM_TYPE {
   PA_SAM_TYPE_CRYPTOCARD = 6
 } PA_SAM_TYPE;
 
-int    decode_PA_SAM_TYPE(const unsigned char *, size_t, PA_SAM_TYPE *, size_t *);
-int    encode_PA_SAM_TYPE(unsigned char *, size_t, const PA_SAM_TYPE *, size_t *);
-size_t length_PA_SAM_TYPE(const PA_SAM_TYPE *);
-int    copy_PA_SAM_TYPE  (const PA_SAM_TYPE *, PA_SAM_TYPE *);
-void   free_PA_SAM_TYPE  (PA_SAM_TYPE *);
-
-
 /*
 PA-SAM-REDIRECT ::= HostAddresses
 */
 
 typedef HostAddresses PA_SAM_REDIRECT;
 
-int    decode_PA_SAM_REDIRECT(const unsigned char *, size_t, PA_SAM_REDIRECT *, size_t *);
-int    encode_PA_SAM_REDIRECT(unsigned char *, size_t, const PA_SAM_REDIRECT *, size_t *);
-size_t length_PA_SAM_REDIRECT(const PA_SAM_REDIRECT *);
-int    copy_PA_SAM_REDIRECT  (const PA_SAM_REDIRECT *, PA_SAM_REDIRECT *);
-void   free_PA_SAM_REDIRECT  (PA_SAM_REDIRECT *);
-
-
 /*
 SAMFlags ::= BIT STRING {
   use-sad-as-key(0),
@@ -1962,13 +1928,6 @@ typedef struct SAMFlags {
 
 unsigned SAMFlags2int(SAMFlags);
 SAMFlags int2SAMFlags(unsigned);
-int    decode_SAMFlags(const unsigned char *, size_t, SAMFlags *, size_t *);
-int    encode_SAMFlags(unsigned char *, size_t, const SAMFlags *, size_t *);
-size_t length_SAMFlags(const SAMFlags *);
-int    copy_SAMFlags  (const SAMFlags *, SAMFlags *);
-void   free_SAMFlags  (SAMFlags *);
-
-
 /*
 PA-SAM-CHALLENGE-2-BODY ::= SEQUENCE {
   sam-type              [0] krb5int32,
@@ -1998,13 +1957,6 @@ typedef struct PA_SAM_CHALLENGE_2_BODY {
   krb5int32 sam_etype;
 } PA_SAM_CHALLENGE_2_BODY;
 
-int    decode_PA_SAM_CHALLENGE_2_BODY(const unsigned char *, size_t, PA_SAM_CHALLENGE_2_BODY *, size_t *);
-int    encode_PA_SAM_CHALLENGE_2_BODY(unsigned char *, size_t, const PA_SAM_CHALLENGE_2_BODY *, size_t *);
-size_t length_PA_SAM_CHALLENGE_2_BODY(const PA_SAM_CHALLENGE_2_BODY *);
-int    copy_PA_SAM_CHALLENGE_2_BODY  (const PA_SAM_CHALLENGE_2_BODY *, PA_SAM_CHALLENGE_2_BODY *);
-void   free_PA_SAM_CHALLENGE_2_BODY  (PA_SAM_CHALLENGE_2_BODY *);
-
-
 /*
 PA-SAM-CHALLENGE-2 ::= SEQUENCE {
   sam-body        [0] PA-SAM-CHALLENGE-2-BODY,
@@ -2021,13 +1973,6 @@ typedef struct PA_SAM_CHALLENGE_2 {
   } sam_cksum;
 } PA_SAM_CHALLENGE_2;
 
-int    decode_PA_SAM_CHALLENGE_2(const unsigned char *, size_t, PA_SAM_CHALLENGE_2 *, size_t *);
-int    encode_PA_SAM_CHALLENGE_2(unsigned char *, size_t, const PA_SAM_CHALLENGE_2 *, size_t *);
-size_t length_PA_SAM_CHALLENGE_2(const PA_SAM_CHALLENGE_2 *);
-int    copy_PA_SAM_CHALLENGE_2  (const PA_SAM_CHALLENGE_2 *, PA_SAM_CHALLENGE_2 *);
-void   free_PA_SAM_CHALLENGE_2  (PA_SAM_CHALLENGE_2 *);
-
-
 /*
 PA-SAM-RESPONSE-2 ::= SEQUENCE {
   sam-type               [0] krb5int32,
@@ -2047,13 +1992,6 @@ typedef struct PA_SAM_RESPONSE_2 {
   krb5int32 sam_nonce;
 } PA_SAM_RESPONSE_2;
 
-int    decode_PA_SAM_RESPONSE_2(const unsigned char *, size_t, PA_SAM_RESPONSE_2 *, size_t *);
-int    encode_PA_SAM_RESPONSE_2(unsigned char *, size_t, const PA_SAM_RESPONSE_2 *, size_t *);
-size_t length_PA_SAM_RESPONSE_2(const PA_SAM_RESPONSE_2 *);
-int    copy_PA_SAM_RESPONSE_2  (const PA_SAM_RESPONSE_2 *, PA_SAM_RESPONSE_2 *);
-void   free_PA_SAM_RESPONSE_2  (PA_SAM_RESPONSE_2 *);
-
-
 /*
 PA-ENC-SAM-RESPONSE-ENC ::= SEQUENCE {
   sam-nonce       [0] krb5int32,
@@ -2067,13 +2005,6 @@ typedef struct PA_ENC_SAM_RESPONSE_ENC {
   heim_general_string *sam_sad;
 } PA_ENC_SAM_RESPONSE_ENC;
 
-int    decode_PA_ENC_SAM_RESPONSE_ENC(const unsigned char *, size_t, PA_ENC_SAM_RESPONSE_ENC *, size_t *);
-int    encode_PA_ENC_SAM_RESPONSE_ENC(unsigned char *, size_t, const PA_ENC_SAM_RESPONSE_ENC *, size_t *);
-size_t length_PA_ENC_SAM_RESPONSE_ENC(const PA_ENC_SAM_RESPONSE_ENC *);
-int    copy_PA_ENC_SAM_RESPONSE_ENC  (const PA_ENC_SAM_RESPONSE_ENC *, PA_ENC_SAM_RESPONSE_ENC *);
-void   free_PA_ENC_SAM_RESPONSE_ENC  (PA_ENC_SAM_RESPONSE_ENC *);
-
-
 /*
 PA-S4U2Self ::= SEQUENCE {
   name            [0] PrincipalName,
@@ -2090,11 +2021,11 @@ typedef struct PA_S4U2Self {
   heim_general_string auth;
 } PA_S4U2Self;
 
-int    decode_PA_S4U2Self(const unsigned char *, size_t, PA_S4U2Self *, size_t *);
-int    encode_PA_S4U2Self(unsigned char *, size_t, const PA_S4U2Self *, size_t *);
-size_t length_PA_S4U2Self(const PA_S4U2Self *);
-int    copy_PA_S4U2Self  (const PA_S4U2Self *, PA_S4U2Self *);
-void   free_PA_S4U2Self  (PA_S4U2Self *);
+ASN1EXP int    ASN1CALL decode_PA_S4U2Self(const unsigned char *, size_t, PA_S4U2Self *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_S4U2Self(unsigned char *, size_t, const PA_S4U2Self *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_S4U2Self(const PA_S4U2Self *);
+ASN1EXP int    ASN1CALL copy_PA_S4U2Self  (const PA_S4U2Self *, PA_S4U2Self *);
+ASN1EXP void   ASN1CALL free_PA_S4U2Self  (PA_S4U2Self *);
 
 
 /*
@@ -2113,11 +2044,11 @@ typedef struct KRB5SignedPathData {
   METHOD_DATA *method_data;
 } KRB5SignedPathData;
 
-int    decode_KRB5SignedPathData(const unsigned char *, size_t, KRB5SignedPathData *, size_t *);
-int    encode_KRB5SignedPathData(unsigned char *, size_t, const KRB5SignedPathData *, size_t *);
-size_t length_KRB5SignedPathData(const KRB5SignedPathData *);
-int    copy_KRB5SignedPathData  (const KRB5SignedPathData *, KRB5SignedPathData *);
-void   free_KRB5SignedPathData  (KRB5SignedPathData *);
+ASN1EXP int    ASN1CALL decode_KRB5SignedPathData(const unsigned char *, size_t, KRB5SignedPathData *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB5SignedPathData(unsigned char *, size_t, const KRB5SignedPathData *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB5SignedPathData(const KRB5SignedPathData *);
+ASN1EXP int    ASN1CALL copy_KRB5SignedPathData  (const KRB5SignedPathData *, KRB5SignedPathData *);
+ASN1EXP void   ASN1CALL free_KRB5SignedPathData  (KRB5SignedPathData *);
 
 
 /*
@@ -2136,49 +2067,11 @@ typedef struct KRB5SignedPath {
   METHOD_DATA *method_data;
 } KRB5SignedPath;
 
-int    decode_KRB5SignedPath(const unsigned char *, size_t, KRB5SignedPath *, size_t *);
-int    encode_KRB5SignedPath(unsigned char *, size_t, const KRB5SignedPath *, size_t *);
-size_t length_KRB5SignedPath(const KRB5SignedPath *);
-int    copy_KRB5SignedPath  (const KRB5SignedPath *, KRB5SignedPath *);
-void   free_KRB5SignedPath  (KRB5SignedPath *);
-
-
-/*
-PA-ClientCanonicalizedNames ::= SEQUENCE {
-  requested-name   [0] PrincipalName,
-  mapped-name      [1] PrincipalName,
-}
-*/
-
-typedef struct PA_ClientCanonicalizedNames {
-  PrincipalName requested_name;
-  PrincipalName mapped_name;
-} PA_ClientCanonicalizedNames;
-
-int    decode_PA_ClientCanonicalizedNames(const unsigned char *, size_t, PA_ClientCanonicalizedNames *, size_t *);
-int    encode_PA_ClientCanonicalizedNames(unsigned char *, size_t, const PA_ClientCanonicalizedNames *, size_t *);
-size_t length_PA_ClientCanonicalizedNames(const PA_ClientCanonicalizedNames *);
-int    copy_PA_ClientCanonicalizedNames  (const PA_ClientCanonicalizedNames *, PA_ClientCanonicalizedNames *);
-void   free_PA_ClientCanonicalizedNames  (PA_ClientCanonicalizedNames *);
-
-
-/*
-PA-ClientCanonicalized ::= SEQUENCE {
-  names            [0] PA-ClientCanonicalizedNames,
-  canon-checksum   [1] Checksum,
-}
-*/
-
-typedef struct PA_ClientCanonicalized {
-  PA_ClientCanonicalizedNames names;
-  Checksum canon_checksum;
-} PA_ClientCanonicalized;
-
-int    decode_PA_ClientCanonicalized(const unsigned char *, size_t, PA_ClientCanonicalized *, size_t *);
-int    encode_PA_ClientCanonicalized(unsigned char *, size_t, const PA_ClientCanonicalized *, size_t *);
-size_t length_PA_ClientCanonicalized(const PA_ClientCanonicalized *);
-int    copy_PA_ClientCanonicalized  (const PA_ClientCanonicalized *, PA_ClientCanonicalized *);
-void   free_PA_ClientCanonicalized  (PA_ClientCanonicalized *);
+ASN1EXP int    ASN1CALL decode_KRB5SignedPath(const unsigned char *, size_t, KRB5SignedPath *, size_t *);
+ASN1EXP int    ASN1CALL encode_KRB5SignedPath(unsigned char *, size_t, const KRB5SignedPath *, size_t *);
+ASN1EXP size_t ASN1CALL length_KRB5SignedPath(const KRB5SignedPath *);
+ASN1EXP int    ASN1CALL copy_KRB5SignedPath  (const KRB5SignedPath *, KRB5SignedPath *);
+ASN1EXP void   ASN1CALL free_KRB5SignedPath  (KRB5SignedPath *);
 
 
 /*
@@ -2193,11 +2086,11 @@ typedef struct AD_LoginAlias {
   Checksum checksum;
 } AD_LoginAlias;
 
-int    decode_AD_LoginAlias(const unsigned char *, size_t, AD_LoginAlias *, size_t *);
-int    encode_AD_LoginAlias(unsigned char *, size_t, const AD_LoginAlias *, size_t *);
-size_t length_AD_LoginAlias(const AD_LoginAlias *);
-int    copy_AD_LoginAlias  (const AD_LoginAlias *, AD_LoginAlias *);
-void   free_AD_LoginAlias  (AD_LoginAlias *);
+ASN1EXP int    ASN1CALL decode_AD_LoginAlias(const unsigned char *, size_t, AD_LoginAlias *, size_t *);
+ASN1EXP int    ASN1CALL encode_AD_LoginAlias(unsigned char *, size_t, const AD_LoginAlias *, size_t *);
+ASN1EXP size_t ASN1CALL length_AD_LoginAlias(const AD_LoginAlias *);
+ASN1EXP int    ASN1CALL copy_AD_LoginAlias  (const AD_LoginAlias *, AD_LoginAlias *);
+ASN1EXP void   ASN1CALL free_AD_LoginAlias  (AD_LoginAlias *);
 
 
 /*
@@ -2212,11 +2105,11 @@ typedef struct PA_SvrReferralData {
   Realm referred_realm;
 } PA_SvrReferralData;
 
-int    decode_PA_SvrReferralData(const unsigned char *, size_t, PA_SvrReferralData *, size_t *);
-int    encode_PA_SvrReferralData(unsigned char *, size_t, const PA_SvrReferralData *, size_t *);
-size_t length_PA_SvrReferralData(const PA_SvrReferralData *);
-int    copy_PA_SvrReferralData  (const PA_SvrReferralData *, PA_SvrReferralData *);
-void   free_PA_SvrReferralData  (PA_SvrReferralData *);
+ASN1EXP int    ASN1CALL decode_PA_SvrReferralData(const unsigned char *, size_t, PA_SvrReferralData *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_SvrReferralData(unsigned char *, size_t, const PA_SvrReferralData *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_SvrReferralData(const PA_SvrReferralData *);
+ASN1EXP int    ASN1CALL copy_PA_SvrReferralData  (const PA_SvrReferralData *, PA_SvrReferralData *);
+ASN1EXP void   ASN1CALL free_PA_SvrReferralData  (PA_SvrReferralData *);
 
 
 /*
@@ -2225,11 +2118,11 @@ PA-SERVER-REFERRAL-DATA ::= EncryptedData
 
 typedef EncryptedData PA_SERVER_REFERRAL_DATA;
 
-int    decode_PA_SERVER_REFERRAL_DATA(const unsigned char *, size_t, PA_SERVER_REFERRAL_DATA *, size_t *);
-int    encode_PA_SERVER_REFERRAL_DATA(unsigned char *, size_t, const PA_SERVER_REFERRAL_DATA *, size_t *);
-size_t length_PA_SERVER_REFERRAL_DATA(const PA_SERVER_REFERRAL_DATA *);
-int    copy_PA_SERVER_REFERRAL_DATA  (const PA_SERVER_REFERRAL_DATA *, PA_SERVER_REFERRAL_DATA *);
-void   free_PA_SERVER_REFERRAL_DATA  (PA_SERVER_REFERRAL_DATA *);
+ASN1EXP int    ASN1CALL decode_PA_SERVER_REFERRAL_DATA(const unsigned char *, size_t, PA_SERVER_REFERRAL_DATA *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_SERVER_REFERRAL_DATA(unsigned char *, size_t, const PA_SERVER_REFERRAL_DATA *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_SERVER_REFERRAL_DATA(const PA_SERVER_REFERRAL_DATA *);
+ASN1EXP int    ASN1CALL copy_PA_SERVER_REFERRAL_DATA  (const PA_SERVER_REFERRAL_DATA *, PA_SERVER_REFERRAL_DATA *);
+ASN1EXP void   ASN1CALL free_PA_SERVER_REFERRAL_DATA  (PA_SERVER_REFERRAL_DATA *);
 
 
 /*
@@ -2249,18 +2142,18 @@ typedef struct PA_ServerReferralData {
   KerberosTime *referral_valid_until;
 } PA_ServerReferralData;
 
-int    decode_PA_ServerReferralData(const unsigned char *, size_t, PA_ServerReferralData *, size_t *);
-int    encode_PA_ServerReferralData(unsigned char *, size_t, const PA_ServerReferralData *, size_t *);
-size_t length_PA_ServerReferralData(const PA_ServerReferralData *);
-int    copy_PA_ServerReferralData  (const PA_ServerReferralData *, PA_ServerReferralData *);
-void   free_PA_ServerReferralData  (PA_ServerReferralData *);
+ASN1EXP int    ASN1CALL decode_PA_ServerReferralData(const unsigned char *, size_t, PA_ServerReferralData *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_ServerReferralData(unsigned char *, size_t, const PA_ServerReferralData *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_ServerReferralData(const PA_ServerReferralData *);
+ASN1EXP int    ASN1CALL copy_PA_ServerReferralData  (const PA_ServerReferralData *, PA_ServerReferralData *);
+ASN1EXP void   ASN1CALL free_PA_ServerReferralData  (PA_ServerReferralData *);
 
 
 /*
 FastOptions ::= BIT STRING {
   reserved(0),
   hide-client-names(1),
-  kdc-follow--referrals(16)
+  kdc-follow-referrals(16)
 }
 */
 
@@ -2281,7 +2174,7 @@ typedef struct FastOptions {
   unsigned int _unused13:1;
   unsigned int _unused14:1;
   unsigned int _unused15:1;
-  unsigned int kdc_follow__referrals:1;
+  unsigned int kdc_follow_referrals:1;
   unsigned int _unused17:1;
   unsigned int _unused18:1;
   unsigned int _unused19:1;
@@ -2302,17 +2195,10 @@ typedef struct FastOptions {
 
 unsigned FastOptions2int(FastOptions);
 FastOptions int2FastOptions(unsigned);
-int    decode_FastOptions(const unsigned char *, size_t, FastOptions *, size_t *);
-int    encode_FastOptions(unsigned char *, size_t, const FastOptions *, size_t *);
-size_t length_FastOptions(const FastOptions *);
-int    copy_FastOptions  (const FastOptions *, FastOptions *);
-void   free_FastOptions  (FastOptions *);
-
-
 /*
 KrbFastReq ::= SEQUENCE {
   fast-options    [0] FastOptions,
-  padata          [1] SEQUENCE OF PA-DATA,
+  padata          [1] METHOD-DATA,
   req-body        [2] KDC-REQ-BODY,
   ...,
 }
@@ -2320,18 +2206,15 @@ KrbFastReq ::= SEQUENCE {
 
 typedef struct KrbFastReq {
   FastOptions fast_options;
-  struct KrbFastReq_padata {
-    unsigned int len;
-    PA_DATA *val;
-  } padata;
+  METHOD_DATA padata;
   KDC_REQ_BODY req_body;
 } KrbFastReq;
 
-int    decode_KrbFastReq(const unsigned char *, size_t, KrbFastReq *, size_t *);
-int    encode_KrbFastReq(unsigned char *, size_t, const KrbFastReq *, size_t *);
-size_t length_KrbFastReq(const KrbFastReq *);
-int    copy_KrbFastReq  (const KrbFastReq *, KrbFastReq *);
-void   free_KrbFastReq  (KrbFastReq *);
+ASN1EXP int    ASN1CALL decode_KrbFastReq(const unsigned char *, size_t, KrbFastReq *, size_t *);
+ASN1EXP int    ASN1CALL encode_KrbFastReq(unsigned char *, size_t, const KrbFastReq *, size_t *);
+ASN1EXP size_t ASN1CALL length_KrbFastReq(const KrbFastReq *);
+ASN1EXP int    ASN1CALL copy_KrbFastReq  (const KrbFastReq *, KrbFastReq *);
+ASN1EXP void   ASN1CALL free_KrbFastReq  (KrbFastReq *);
 
 
 /*
@@ -2347,11 +2230,11 @@ typedef struct KrbFastArmor {
   heim_octet_string armor_value;
 } KrbFastArmor;
 
-int    decode_KrbFastArmor(const unsigned char *, size_t, KrbFastArmor *, size_t *);
-int    encode_KrbFastArmor(unsigned char *, size_t, const KrbFastArmor *, size_t *);
-size_t length_KrbFastArmor(const KrbFastArmor *);
-int    copy_KrbFastArmor  (const KrbFastArmor *, KrbFastArmor *);
-void   free_KrbFastArmor  (KrbFastArmor *);
+ASN1EXP int    ASN1CALL decode_KrbFastArmor(const unsigned char *, size_t, KrbFastArmor *, size_t *);
+ASN1EXP int    ASN1CALL encode_KrbFastArmor(unsigned char *, size_t, const KrbFastArmor *, size_t *);
+ASN1EXP size_t ASN1CALL length_KrbFastArmor(const KrbFastArmor *);
+ASN1EXP int    ASN1CALL copy_KrbFastArmor  (const KrbFastArmor *, KrbFastArmor *);
+ASN1EXP void   ASN1CALL free_KrbFastArmor  (KrbFastArmor *);
 
 
 /*
@@ -2368,13 +2251,6 @@ typedef struct KrbFastArmoredReq {
   EncryptedData enc_fast_req;
 } KrbFastArmoredReq;
 
-int    decode_KrbFastArmoredReq(const unsigned char *, size_t, KrbFastArmoredReq *, size_t *);
-int    encode_KrbFastArmoredReq(unsigned char *, size_t, const KrbFastArmoredReq *, size_t *);
-size_t length_KrbFastArmoredReq(const KrbFastArmoredReq *);
-int    copy_KrbFastArmoredReq  (const KrbFastArmoredReq *, KrbFastArmoredReq *);
-void   free_KrbFastArmoredReq  (KrbFastArmoredReq *);
-
-
 /*
 PA-FX-FAST-REQUEST ::= CHOICE {
   armored-data    [0] KrbFastArmoredReq,
@@ -2383,7 +2259,7 @@ PA-FX-FAST-REQUEST ::= CHOICE {
 */
 
 typedef struct PA_FX_FAST_REQUEST {
-  enum {
+  enum PA_FX_FAST_REQUEST_enum {
     choice_PA_FX_FAST_REQUEST_asn1_ellipsis = 0,
     choice_PA_FX_FAST_REQUEST_armored_data
     /* ... */
@@ -2394,11 +2270,11 @@ typedef struct PA_FX_FAST_REQUEST {
   } u;
 } PA_FX_FAST_REQUEST;
 
-int    decode_PA_FX_FAST_REQUEST(const unsigned char *, size_t, PA_FX_FAST_REQUEST *, size_t *);
-int    encode_PA_FX_FAST_REQUEST(unsigned char *, size_t, const PA_FX_FAST_REQUEST *, size_t *);
-size_t length_PA_FX_FAST_REQUEST(const PA_FX_FAST_REQUEST *);
-int    copy_PA_FX_FAST_REQUEST  (const PA_FX_FAST_REQUEST *, PA_FX_FAST_REQUEST *);
-void   free_PA_FX_FAST_REQUEST  (PA_FX_FAST_REQUEST *);
+ASN1EXP int    ASN1CALL decode_PA_FX_FAST_REQUEST(const unsigned char *, size_t, PA_FX_FAST_REQUEST *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_FX_FAST_REQUEST(unsigned char *, size_t, const PA_FX_FAST_REQUEST *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_FX_FAST_REQUEST(const PA_FX_FAST_REQUEST *);
+ASN1EXP int    ASN1CALL copy_PA_FX_FAST_REQUEST  (const PA_FX_FAST_REQUEST *, PA_FX_FAST_REQUEST *);
+ASN1EXP void   ASN1CALL free_PA_FX_FAST_REQUEST  (PA_FX_FAST_REQUEST *);
 
 
 /*
@@ -2407,8 +2283,7 @@ KrbFastFinished ::= SEQUENCE {
   usec              [1] krb5int32,
   crealm            [2] Realm,
   cname             [3] PrincipalName,
-  checksum          [4] Checksum,
-  ticket-checksum   [5] Checksum,
+  ticket-checksum   [4] Checksum,
   ...,
 }
 */
@@ -2418,40 +2293,38 @@ typedef struct KrbFastFinished {
   krb5int32 usec;
   Realm crealm;
   PrincipalName cname;
-  Checksum checksum;
   Checksum ticket_checksum;
 } KrbFastFinished;
 
-int    decode_KrbFastFinished(const unsigned char *, size_t, KrbFastFinished *, size_t *);
-int    encode_KrbFastFinished(unsigned char *, size_t, const KrbFastFinished *, size_t *);
-size_t length_KrbFastFinished(const KrbFastFinished *);
-int    copy_KrbFastFinished  (const KrbFastFinished *, KrbFastFinished *);
-void   free_KrbFastFinished  (KrbFastFinished *);
+ASN1EXP int    ASN1CALL decode_KrbFastFinished(const unsigned char *, size_t, KrbFastFinished *, size_t *);
+ASN1EXP int    ASN1CALL encode_KrbFastFinished(unsigned char *, size_t, const KrbFastFinished *, size_t *);
+ASN1EXP size_t ASN1CALL length_KrbFastFinished(const KrbFastFinished *);
+ASN1EXP int    ASN1CALL copy_KrbFastFinished  (const KrbFastFinished *, KrbFastFinished *);
+ASN1EXP void   ASN1CALL free_KrbFastFinished  (KrbFastFinished *);
 
 
 /*
 KrbFastResponse ::= SEQUENCE {
-  padata          [0] SEQUENCE OF PA-DATA,
-  rep-key         [1] EncryptionKey OPTIONAL,
-  finished        [2] KrbFastFinished OPTIONAL,
+  padata           [0] METHOD-DATA,
+  strengthen-key   [1] EncryptionKey OPTIONAL,
+  finished         [2] KrbFastFinished OPTIONAL,
+  nonce            [3] krb5uint32,
   ...,
 }
 */
 
 typedef struct KrbFastResponse {
-  struct KrbFastResponse_padata {
-    unsigned int len;
-    PA_DATA *val;
-  } padata;
-  EncryptionKey *rep_key;
+  METHOD_DATA padata;
+  EncryptionKey *strengthen_key;
   KrbFastFinished *finished;
+  krb5uint32 nonce;
 } KrbFastResponse;
 
-int    decode_KrbFastResponse(const unsigned char *, size_t, KrbFastResponse *, size_t *);
-int    encode_KrbFastResponse(unsigned char *, size_t, const KrbFastResponse *, size_t *);
-size_t length_KrbFastResponse(const KrbFastResponse *);
-int    copy_KrbFastResponse  (const KrbFastResponse *, KrbFastResponse *);
-void   free_KrbFastResponse  (KrbFastResponse *);
+ASN1EXP int    ASN1CALL decode_KrbFastResponse(const unsigned char *, size_t, KrbFastResponse *, size_t *);
+ASN1EXP int    ASN1CALL encode_KrbFastResponse(unsigned char *, size_t, const KrbFastResponse *, size_t *);
+ASN1EXP size_t ASN1CALL length_KrbFastResponse(const KrbFastResponse *);
+ASN1EXP int    ASN1CALL copy_KrbFastResponse  (const KrbFastResponse *, KrbFastResponse *);
+ASN1EXP void   ASN1CALL free_KrbFastResponse  (KrbFastResponse *);
 
 
 /*
@@ -2465,13 +2338,6 @@ typedef struct KrbFastArmoredRep {
   EncryptedData enc_fast_rep;
 } KrbFastArmoredRep;
 
-int    decode_KrbFastArmoredRep(const unsigned char *, size_t, KrbFastArmoredRep *, size_t *);
-int    encode_KrbFastArmoredRep(unsigned char *, size_t, const KrbFastArmoredRep *, size_t *);
-size_t length_KrbFastArmoredRep(const KrbFastArmoredRep *);
-int    copy_KrbFastArmoredRep  (const KrbFastArmoredRep *, KrbFastArmoredRep *);
-void   free_KrbFastArmoredRep  (KrbFastArmoredRep *);
-
-
 /*
 PA-FX-FAST-REPLY ::= CHOICE {
   armored-data    [0] KrbFastArmoredRep,
@@ -2480,7 +2346,7 @@ PA-FX-FAST-REPLY ::= CHOICE {
 */
 
 typedef struct PA_FX_FAST_REPLY {
-  enum {
+  enum PA_FX_FAST_REPLY_enum {
     choice_PA_FX_FAST_REPLY_asn1_ellipsis = 0,
     choice_PA_FX_FAST_REPLY_armored_data
     /* ... */
@@ -2491,11 +2357,277 @@ typedef struct PA_FX_FAST_REPLY {
   } u;
 } PA_FX_FAST_REPLY;
 
-int    decode_PA_FX_FAST_REPLY(const unsigned char *, size_t, PA_FX_FAST_REPLY *, size_t *);
-int    encode_PA_FX_FAST_REPLY(unsigned char *, size_t, const PA_FX_FAST_REPLY *, size_t *);
-size_t length_PA_FX_FAST_REPLY(const PA_FX_FAST_REPLY *);
-int    copy_PA_FX_FAST_REPLY  (const PA_FX_FAST_REPLY *, PA_FX_FAST_REPLY *);
-void   free_PA_FX_FAST_REPLY  (PA_FX_FAST_REPLY *);
+ASN1EXP int    ASN1CALL decode_PA_FX_FAST_REPLY(const unsigned char *, size_t, PA_FX_FAST_REPLY *, size_t *);
+ASN1EXP int    ASN1CALL encode_PA_FX_FAST_REPLY(unsigned char *, size_t, const PA_FX_FAST_REPLY *, size_t *);
+ASN1EXP size_t ASN1CALL length_PA_FX_FAST_REPLY(const PA_FX_FAST_REPLY *);
+ASN1EXP int    ASN1CALL copy_PA_FX_FAST_REPLY  (const PA_FX_FAST_REPLY *, PA_FX_FAST_REPLY *);
+ASN1EXP void   ASN1CALL free_PA_FX_FAST_REPLY  (PA_FX_FAST_REPLY *);
+
+
+/*
+KDCFastFlags ::= BIT STRING {
+  use_reply_key(0),
+  reply_key_used(1),
+  reply_key_replaced(2),
+  kdc_verfied(3)
+}
+*/
+
+typedef struct KDCFastFlags {
+  unsigned int use_reply_key:1;
+  unsigned int reply_key_used:1;
+  unsigned int reply_key_replaced:1;
+  unsigned int kdc_verfied:1;
+  unsigned int _unused4:1;
+  unsigned int _unused5:1;
+  unsigned int _unused6:1;
+  unsigned int _unused7:1;
+  unsigned int _unused8:1;
+  unsigned int _unused9:1;
+  unsigned int _unused10:1;
+  unsigned int _unused11:1;
+  unsigned int _unused12:1;
+  unsigned int _unused13:1;
+  unsigned int _unused14:1;
+  unsigned int _unused15:1;
+  unsigned int _unused16:1;
+  unsigned int _unused17:1;
+  unsigned int _unused18:1;
+  unsigned int _unused19:1;
+  unsigned int _unused20:1;
+  unsigned int _unused21:1;
+  unsigned int _unused22:1;
+  unsigned int _unused23:1;
+  unsigned int _unused24:1;
+  unsigned int _unused25:1;
+  unsigned int _unused26:1;
+  unsigned int _unused27:1;
+  unsigned int _unused28:1;
+  unsigned int _unused29:1;
+  unsigned int _unused30:1;
+  unsigned int _unused31:1;
+} KDCFastFlags;
+
+
+unsigned KDCFastFlags2int(KDCFastFlags);
+KDCFastFlags int2KDCFastFlags(unsigned);
+/*
+KDCFastState ::= SEQUENCE {
+  flags               [0] KDCFastFlags,
+  expiration          [1] GeneralizedTime,
+  fast-state          [2] METHOD-DATA,
+  expected-pa-types   [3] SEQUENCE OF PADATA-TYPE OPTIONAL,
+}
+*/
+
+typedef struct KDCFastState {
+  KDCFastFlags flags;
+  time_t expiration;
+  METHOD_DATA fast_state;
+  struct KDCFastState_expected_pa_types {
+    unsigned int len;
+    PADATA_TYPE *val;
+  } *expected_pa_types;
+} KDCFastState;
+
+ASN1EXP int    ASN1CALL decode_KDCFastState(const unsigned char *, size_t, KDCFastState *, size_t *);
+ASN1EXP int    ASN1CALL encode_KDCFastState(unsigned char *, size_t, const KDCFastState *, size_t *);
+ASN1EXP size_t ASN1CALL length_KDCFastState(const KDCFastState *);
+ASN1EXP int    ASN1CALL copy_KDCFastState  (const KDCFastState *, KDCFastState *);
+ASN1EXP void   ASN1CALL free_KDCFastState  (KDCFastState *);
+
+
+/*
+KDCFastCookie ::= SEQUENCE {
+  version         [0]   UTF8String,
+  cookie          [1] EncryptedData,
+}
+*/
+
+typedef struct KDCFastCookie {
+  heim_utf8_string version;
+  EncryptedData cookie;
+} KDCFastCookie;
+
+ASN1EXP int    ASN1CALL decode_KDCFastCookie(const unsigned char *, size_t, KDCFastCookie *, size_t *);
+ASN1EXP int    ASN1CALL encode_KDCFastCookie(unsigned char *, size_t, const KDCFastCookie *, size_t *);
+ASN1EXP size_t ASN1CALL length_KDCFastCookie(const KDCFastCookie *);
+ASN1EXP int    ASN1CALL copy_KDCFastCookie  (const KDCFastCookie *, KDCFastCookie *);
+ASN1EXP void   ASN1CALL free_KDCFastCookie  (KDCFastCookie *);
+
+
+/*
+KDC-PROXY-MESSAGE ::= SEQUENCE {
+  kerb-message     [0] OCTET STRING,
+  target-domain    [1] Realm OPTIONAL,
+  dclocator-hint   [2] INTEGER OPTIONAL,
+}
+*/
+
+typedef struct KDC_PROXY_MESSAGE {
+  heim_octet_string kerb_message;
+  Realm *target_domain;
+  heim_integer *dclocator_hint;
+} KDC_PROXY_MESSAGE;
+
+ASN1EXP int    ASN1CALL decode_KDC_PROXY_MESSAGE(const unsigned char *, size_t, KDC_PROXY_MESSAGE *, size_t *);
+ASN1EXP int    ASN1CALL encode_KDC_PROXY_MESSAGE(unsigned char *, size_t, const KDC_PROXY_MESSAGE *, size_t *);
+ASN1EXP size_t ASN1CALL length_KDC_PROXY_MESSAGE(const KDC_PROXY_MESSAGE *);
+ASN1EXP int    ASN1CALL copy_KDC_PROXY_MESSAGE  (const KDC_PROXY_MESSAGE *, KDC_PROXY_MESSAGE *);
+ASN1EXP void   ASN1CALL free_KDC_PROXY_MESSAGE  (KDC_PROXY_MESSAGE *);
+
+
+/*
+KERB-TIMES ::= SEQUENCE {
+  authtime        [0] KerberosTime,
+  starttime       [1] KerberosTime,
+  endtime         [2] KerberosTime,
+  renew_till      [3] KerberosTime,
+}
+*/
+
+typedef struct KERB_TIMES {
+  KerberosTime authtime;
+  KerberosTime starttime;
+  KerberosTime endtime;
+  KerberosTime renew_till;
+} KERB_TIMES;
+
+ASN1EXP int    ASN1CALL decode_KERB_TIMES(const unsigned char *, size_t, KERB_TIMES *, size_t *);
+ASN1EXP int    ASN1CALL encode_KERB_TIMES(unsigned char *, size_t, const KERB_TIMES *, size_t *);
+ASN1EXP size_t ASN1CALL length_KERB_TIMES(const KERB_TIMES *);
+ASN1EXP int    ASN1CALL copy_KERB_TIMES  (const KERB_TIMES *, KERB_TIMES *);
+ASN1EXP void   ASN1CALL free_KERB_TIMES  (KERB_TIMES *);
+
+
+/*
+KERB-CRED ::= SEQUENCE {
+  client          [0] Principal,
+  server          [1] Principal,
+  keyblock        [2] EncryptionKey,
+  times           [3] KERB-TIMES,
+  ticket          [4] OCTET STRING,
+  authdata        [5] OCTET STRING,
+  addresses       [6] HostAddresses,
+  flags           [7] TicketFlags,
+}
+*/
+
+typedef struct KERB_CRED {
+  Principal client;
+  Principal server;
+  EncryptionKey keyblock;
+  KERB_TIMES times;
+  heim_octet_string ticket;
+  heim_octet_string authdata;
+  HostAddresses addresses;
+  TicketFlags flags;
+} KERB_CRED;
+
+ASN1EXP int    ASN1CALL decode_KERB_CRED(const unsigned char *, size_t, KERB_CRED *, size_t *);
+ASN1EXP int    ASN1CALL encode_KERB_CRED(unsigned char *, size_t, const KERB_CRED *, size_t *);
+ASN1EXP size_t ASN1CALL length_KERB_CRED(const KERB_CRED *);
+ASN1EXP int    ASN1CALL copy_KERB_CRED  (const KERB_CRED *, KERB_CRED *);
+ASN1EXP void   ASN1CALL free_KERB_CRED  (KERB_CRED *);
+
+
+/*
+KERB-TGS-REQ-IN ::= SEQUENCE {
+  cache           [0] OCTET STRING,
+  addrs           [1] HostAddresses,
+  flags           [2] krb5uint32,
+  imp             [3] Principal OPTIONAL,
+  ticket          [4] OCTET STRING OPTIONAL,
+  in_cred         [5] KERB-CRED,
+  krbtgt          [6] KERB-CRED,
+  padata          [7] METHOD-DATA,
+}
+*/
+
+typedef struct KERB_TGS_REQ_IN {
+  heim_octet_string cache;
+  HostAddresses addrs;
+  krb5uint32 flags;
+  Principal *imp;
+  heim_octet_string *ticket;
+  KERB_CRED in_cred;
+  KERB_CRED krbtgt;
+  METHOD_DATA padata;
+} KERB_TGS_REQ_IN;
+
+ASN1EXP int    ASN1CALL decode_KERB_TGS_REQ_IN(const unsigned char *, size_t, KERB_TGS_REQ_IN *, size_t *);
+ASN1EXP int    ASN1CALL encode_KERB_TGS_REQ_IN(unsigned char *, size_t, const KERB_TGS_REQ_IN *, size_t *);
+ASN1EXP size_t ASN1CALL length_KERB_TGS_REQ_IN(const KERB_TGS_REQ_IN *);
+ASN1EXP int    ASN1CALL copy_KERB_TGS_REQ_IN  (const KERB_TGS_REQ_IN *, KERB_TGS_REQ_IN *);
+ASN1EXP void   ASN1CALL free_KERB_TGS_REQ_IN  (KERB_TGS_REQ_IN *);
+
+
+/*
+KERB-TGS-REQ-OUT ::= SEQUENCE {
+  subkey          [0] EncryptionKey OPTIONAL,
+  t               [1] TGS-REQ,
+}
+*/
+
+typedef struct KERB_TGS_REQ_OUT {
+  EncryptionKey *subkey;
+  TGS_REQ t;
+} KERB_TGS_REQ_OUT;
+
+ASN1EXP int    ASN1CALL decode_KERB_TGS_REQ_OUT(const unsigned char *, size_t, KERB_TGS_REQ_OUT *, size_t *);
+ASN1EXP int    ASN1CALL encode_KERB_TGS_REQ_OUT(unsigned char *, size_t, const KERB_TGS_REQ_OUT *, size_t *);
+ASN1EXP size_t ASN1CALL length_KERB_TGS_REQ_OUT(const KERB_TGS_REQ_OUT *);
+ASN1EXP int    ASN1CALL copy_KERB_TGS_REQ_OUT  (const KERB_TGS_REQ_OUT *, KERB_TGS_REQ_OUT *);
+ASN1EXP void   ASN1CALL free_KERB_TGS_REQ_OUT  (KERB_TGS_REQ_OUT *);
+
+
+/*
+KERB-TGS-REP-IN ::= SEQUENCE {
+  cache           [0] OCTET STRING,
+  subkey          [1] EncryptionKey OPTIONAL,
+  in_cred         [2] KERB-CRED,
+  t               [3] TGS-REP,
+}
+*/
+
+typedef struct KERB_TGS_REP_IN {
+  heim_octet_string cache;
+  EncryptionKey *subkey;
+  KERB_CRED in_cred;
+  TGS_REP t;
+} KERB_TGS_REP_IN;
+
+/*
+KERB-TGS-REP-OUT ::= SEQUENCE {
+  cache           [0] OCTET STRING,
+  cred            [1] KERB-CRED,
+  subkey          [2] EncryptionKey,
+}
+*/
+
+typedef struct KERB_TGS_REP_OUT {
+  heim_octet_string cache;
+  KERB_CRED cred;
+  EncryptionKey subkey;
+} KERB_TGS_REP_OUT;
+
+/*
+KERB-ARMOR-SERVICE-REPLY ::= SEQUENCE {
+  armor           [0] KrbFastArmor,
+  armor-key       [1] EncryptionKey,
+}
+*/
+
+typedef struct KERB_ARMOR_SERVICE_REPLY {
+  KrbFastArmor armor;
+  EncryptionKey armor_key;
+} KERB_ARMOR_SERVICE_REPLY;
+
+ASN1EXP int    ASN1CALL decode_KERB_ARMOR_SERVICE_REPLY(const unsigned char *, size_t, KERB_ARMOR_SERVICE_REPLY *, size_t *);
+ASN1EXP int    ASN1CALL encode_KERB_ARMOR_SERVICE_REPLY(unsigned char *, size_t, const KERB_ARMOR_SERVICE_REPLY *, size_t *);
+ASN1EXP size_t ASN1CALL length_KERB_ARMOR_SERVICE_REPLY(const KERB_ARMOR_SERVICE_REPLY *);
+ASN1EXP int    ASN1CALL copy_KERB_ARMOR_SERVICE_REPLY  (const KERB_ARMOR_SERVICE_REPLY *, KERB_ARMOR_SERVICE_REPLY *);
+ASN1EXP void   ASN1CALL free_KERB_ARMOR_SERVICE_REPLY  (KERB_ARMOR_SERVICE_REPLY *);
 
 
 #endif /* __krb5_asn1_h__ */
diff --git a/src/rxosd/Makefile.in b/src/rxosd/Makefile.in
index 83249b329..180c363e2 100644
--- a/src/rxosd/Makefile.in
+++ b/src/rxosd/Makefile.in
@@ -133,9 +133,6 @@ osddb.xdr.c: ${OSDDBSRC}/osddb.xg osddb.h
 osddbuser.o: ${OSDDBSRC}/osddbuser.c
 	${AFS_CCRULE} ${OSDDBSRC}/osddbuser.c
 
-afsaux.o: ${FSINT}/afsaux.c
-	${AFS_CCRULE} ${FSINT}/afsaux.c
-
 rxosd.ss.c: rxosd.xg rxosd.h
 	${RXGEN} -x -S -o $@ ${srcdir}/rxosd.xg
 
diff --git a/src/scout/Makefile.in b/src/scout/Makefile.in
index db0f1613a..47d18754b 100644
--- a/src/scout/Makefile.in
+++ b/src/scout/Makefile.in
@@ -7,7 +7,7 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
 
 
 INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
@@ -23,28 +23,16 @@ INCLS=${TOP_INCDIR}/afs/gtxobjects.h \
 	${TOP_INCDIR}/afs/cellconfig.h \
 	${TOP_INCDIR}/afs/cmd.h
 
-LIBS=${TOP_LIBDIR}/libgtx.a \
-	${TOP_LIBDIR}/libfsprobe.a \
-	${TOP_LIBDIR}/libvolser.a \
-        ${TOP_LIBDIR}/libubik.a \
-	${TOP_LIBDIR}/libkauth.a \
-	${TOP_LIBDIR}/libauth.a \
-	${TOP_LIBDIR}/librxkad.a \
-	${TOP_LIBDIR}/libcmd.a \
-	${TOP_LIBDIR}/vlib.a \
-	${TOP_LIBDIR}/libacl.a \
-        ${TOP_LIBDIR}/libvldb.a \
-	${TOP_LIBDIR}/libafsint.a \
-	${TOP_LIBDIR}/libsys.a \
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/libsys.a \
-	${TOP_LIBDIR}/libaudit.a \
-	${TOP_LIBDIR}/libafscom_err.a \
-	${TOP_LIBDIR}/liblwp.a \
-	${TOP_LIBDIR}/util.a \
-	${TOP_LIBDIR}/libopr.a \
-	${TOP_LIBDIR}/libafsrfc3961.a \
-	${TOP_LIBDIR}/libafshcrypto_lwp.a
+LIBS=\
+	$(top_builddir)/src/fsprobe/liboafs_fsprobe.la \
+	$(top_builddir)/src/gtx/liboafs_gtx.la \
+	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
+	$(top_builddir)/src/fsint/liboafs_fsint.la \
+	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/opr/liboafs_opr.la \
+	$(top_builddir)/src/lwp/liboafs_lwpcompat.la \
+	$(top_builddir)/src/volser/liboafs_volser.la \
 
 all: scout
 
@@ -54,7 +42,7 @@ all: scout
 scout.o: scout.c ${INCLS} AFS_component_version_number.c
 
 scout: scout.o $(LIBS)
-	$(AFS_LDRULE) scout.o $(LIBS) $(LIB_roken) ${LIB_curses} ${XLIBS}
+	$(LT_LDRULE_static) scout.o $(LIBS) $(LIB_roken) ${LIB_curses} ${XLIBS}
 
 #
 # Installation targets
diff --git a/src/scout/scout.c b/src/scout/scout.c
index 9396c50b7..132c872bb 100644
--- a/src/scout/scout.c
+++ b/src/scout/scout.c
@@ -15,6 +15,7 @@
 #include <afs/param.h>
 
 #include <roken.h>
+#include <opr/softsig.h>
 
 #undef	IN
 #include <afs/gtxwindows.h>		/*Generic window package */
@@ -35,9 +36,6 @@
  */
 #define P_SERVER    0
 #define P_BASE	    1
-#if 0
-#define	P_PACKAGE   2
-#endif /* 0 */
 #define P_FREQ	    2
 #define P_HOST	    3
 #define P_ATTENTION 4
@@ -1635,12 +1633,7 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
     struct mini_line *curr_line;	/*Ptr to current line */
     int i;			/*Generic loop variable */
     int mini_line_bytes;	/*Num bytes in mini_lines */
-    struct timeval tv;		/*Time structure */
     int linenum;		/*Current mini-line number */
-#if 0
-    PROCESS pid;		/*Main LWP process ID */
-    PROCESS gxlistener_ID;	/*Input Server LWP process ID */
-#endif /* 0 */
     struct gator_lightobj *lightdata;	/*Private light data */
 
     if (scout_debug) {
@@ -1649,23 +1642,14 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
     }
 
     /*
-     * We have to initialize LWP support before we start up any of
+     * We have to initialize thread support before we start up any of
      * our packages.
      */
-#if 0
-    code = LWP_InitializeProcessSupport(LWP_NORMAL_PRIORITY, &pid);
-    if (code) {
-	fprintf(stderr, "[%s:%s] Can't initialize LWP\n", pn, rn);
-	scout_CleanExit(code);
-    }
-#endif /* 0 */
+    opr_softsig_Init();
 
     /*
      * Initialize the gtx package.
      */
-#if 0
-    fprintf(stderr, "[%s:%s] Starting up gtx package\n", pn, rn);
-#endif /* 0 */
     scout_gwin = gtx_Init(0,	/*Don't start up InputServer yet */
 			  -1);	/*Type of window package */
     if (scout_gwin == NULL) {
@@ -1801,14 +1785,18 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
 	    snprintf(attn_label, sizeof(attn_label), "%s: < %d blocks free",
 		     scout_label[5], scout_attn_disk_minfree);
 	}
-	snprintf(scout_Banner, sizeof(scout_Banner),
-		 "%*s %*s %*s %*s %*s %s",
-		 scout_col_width[0], scout_label[0],
-		 scout_col_width[1], scout_label[1],
-		 scout_col_width[2], scout_label[2],
-		 scout_col_width[3], scout_label[3],
-		 scout_col_width[4], scout_label[4],
-		 attn_label);
+	code = snprintf(scout_Banner, sizeof(scout_Banner),
+		        "%*s %*s %*s %*s %*s %s",
+		        scout_col_width[0], scout_label[0],
+		        scout_col_width[1], scout_label[1],
+		        scout_col_width[2], scout_label[2],
+		        scout_col_width[3], scout_label[3],
+		        scout_col_width[4], scout_label[4],
+		        attn_label);
+	if (code < 0 || code >= sizeof(scout_Banner)) {
+	    fprintf(stderr, "[%s] Truncation while generating banner\n", rn);
+	    return -1;
+	}
 
 	lightdata = (struct gator_lightobj *)(scout_banner1_lp->o_data);
 	mini_justify(scout_Banner, lightdata->label, scout_frameDims.maxx,
@@ -1903,21 +1891,6 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
 
     }				/*Add lights in server records to display list */
 
-#if 0
-    /*
-     * Set up the minimal keymap.
-     */
-    code = keymap_BindToString(scout_frame->keymap,	/*Ptr to keymap */
-			       "e",	/*Key to bind */
-			       ExitCmd,	/*Cmd to execute */
-			       NULL,	/*Name */
-			       NULL);	/*Ptr to rock */
-    if (code) {
-	fprintf(stderr, "[%s] Can't bind key `e', code is %d\n", rn, code);
-	return (code);
-    }
-#endif /* 0 */
-
     /*
      * Finish setting up the overall mini_screen structure.
      */
@@ -1936,28 +1909,12 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
 			scout_probefreq,	/*Probe frequency */
 			FS_Handler,	/*Handler routine */
 			0);	/*Turn debugging output off */
-#if 0
-    scout_debug);		/*Turn debugging output off */
-#endif /* 0 */
     if (code) {
 	fprintf(stderr, "[%s] Error returned by fsprobe_Init: %d\n", rn,
 		code);
 	return (-1);
     }
 
-
-    /*
-     * Start up the input server LWP for our window.
-     */
-#if 0
-    code = LWP_CreateProcess(gtx_InputServer,	/*Fcn to start up */
-			     8192,	/*Stack size in bytes */
-			     LWP_NORMAL_PRIORITY,	/*Priority */
-			     (void *)scout_gwin,	/*Params: Ptr to window */
-			     "gx-listener",	/*Name to use */
-			     &gxlistener_ID);	/*Returned LWP process ID */
-#endif /* 0 */
-
     code = (int)(intptr_t)gtx_InputServer(scout_gwin);
     if (code) {
 	fprintf(stderr,
@@ -1966,28 +1923,8 @@ execute_scout(int a_numservers, struct cmd_item *a_srvname, int a_pkg)
 	scout_CleanExit(code);
     }
 
-    /*
-     * We fall into a loop, sleeping forever.
-     */
-    while (1) {
-	tv.tv_sec = 60 * 60;	/*Sleep for an hour at a time */
-	tv.tv_usec = 0;
-	select(0,	/*Num fds */
-	       0,	/*Descriptors ready for reading */
-	       0,	/*Descriptors ready for writing */
-	       0,	/*Descriptors with exceptional conditions */
-	       &tv);	/*Timeout structure */
-    }				/*Sleep forever */
-
-#if 0
-    /*
-     * How did we get here?  Oh, well, clean up our windows and
-     * return sweetness and light anyway.
-     */
-    WOP_CLEANUP(&scout_gwin);
-    return (0);
-#endif /* 0 */
-
+    fsprobe_Wait(0); /* sleep forever */
+    return 0;
 }				/*execute_scout */
 
 /*------------------------------------------------------------------------
@@ -2244,29 +2181,7 @@ static int scoutInit(struct cmd_syndesc *as, void *arock)
 	fprintf(scout_debugfd, "[%s] Writing to Scout debugging file '%s'\n",
 		rn, debug_filename);
     }
-#if 0
-    wpkg_to_use = atoi(as->parms[P_PACKAGE].items->data);
-#endif /* 0 */
     wpkg_to_use = 2;		/*Always use curses for now */
-#if 0
-    fprintf(stderr, "[%s:%s] Using graphics package %d: ", pn, rn,
-	    wpkg_to_use);
-    switch (wpkg_to_use) {
-    case GATOR_WIN_CURSES:
-	fprintf(stderr, "curses\n");
-	break;
-    case GATOR_WIN_DUMB:
-	fprintf(stderr, "dumb terminal\n");
-	break;
-    case GATOR_WIN_X11:
-	fprintf(stderr, "X11\n");
-	break;
-    default:
-	fprintf(stderr, "Illegal graphics package: %d\n", wpkg_to_use);
-	scout_CleanExit(-1);
-    }				/*end switch (wpkg_to_use) */
-#endif /* 0 */
-
     if (as->parms[P_FREQ].items != 0)
 	scout_probefreq = atoi(as->parms[P_FREQ].items->data);
     else
@@ -2361,10 +2276,6 @@ main(int argc, char **argv)
 		"FileServer name(s) to monitor");
     cmd_AddParm(ts, "-basename", CMD_SINGLE, CMD_OPTIONAL,
 		"base server name");
-#if 0
-    cmd_AddParm(ts, "-package", CMD_SINGLE, CMD_REQUIRED,
-		"Graphics package to use");
-#endif /* 0 */
     cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL,
 		"poll frequency, in seconds");
     cmd_AddParm(ts, "-host", CMD_FLAG, CMD_OPTIONAL,
@@ -2382,10 +2293,6 @@ main(int argc, char **argv)
      */
     code = cmd_Dispatch(argc, argv);
     if (code) {
-#if 0
-	fprintf(stderr, "[%s:%s] Call to cmd_Dispatch() failed; code is %d\n",
-		pn, rn, code);
-#endif /* 0 */
 	scout_CleanExit(1);
     } else
 	scout_CleanExit(0);
diff --git a/src/shlibafsrpc/.gitignore b/src/shlibafsrpc/.gitignore
deleted file mode 100644
index f1c80078c..000000000
--- a/src/shlibafsrpc/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-# After changing this file, please run
-#     git ls-files -i --exclude-standard
-# to check that you haven't inadvertently ignored any tracked files.
-
-/libafsrpc.exp
-
diff --git a/src/sys/afssyscalls.c b/src/sys/afssyscalls.c
index 712e68c89..8291a46c5 100644
--- a/src/sys/afssyscalls.c
+++ b/src/sys/afssyscalls.c
@@ -43,10 +43,6 @@ static void check_iops(int index, char *fun, char *file, int line);
 #pragma weak xiinc = iinc
 #pragma weak xidec = idec
 #pragma weak xiopen = iopen
-#ifdef notdef
-#pragma weak xiread = iread
-#pragma weak xiwrite = iwrite
-#endif
 
 int
 icreate(int dev, int near_inode, int param1, int param2, int param3,
@@ -170,23 +166,6 @@ afs_init_kernel_config(int flag)
 }
 #endif
 
-#ifdef notdef
-/* iread and iwrite are deprecated interfaces. Use inode_read and inode_write instead. */
-int
-iread(int dev, int inode, int inode_p1, unsigned int offset, char *cbuf,
-      unsigned int count)
-{
-    return (syscall(AFS_IREAD, dev, inode, inode_p1, offset, cbuf, count));
-}
-
-int
-iwrite(int dev, int inode, int inode_p1, unsigned int offset, char *cbuf,
-       unsigned int count)
-{
-    return (syscall(AFS_IWRITE, dev, inode, inode_p1, offset, cbuf, count));
-}
-#endif /* notdef */
-
 #else /* AFS_SGI_ENV */
 
 #ifndef AFS_NAMEI_ENV
@@ -250,39 +229,6 @@ idec(int dev, int inode, int inode_p1)
 }
 
 
-#ifdef notdef
-int
-iread(int dev, int inode, int inode_p1, unsigned int offset, char *cbuf,
-      unsigned int count)
-{
-    int errcode;
-    struct iparam iparams;
-
-    iparams.param1 = inode_p1;
-    iparams.param2 = offset;
-    iparams.param3 = (long)cbuf;
-    iparams.param4 = count;
-    errcode = syscall(AFS_SYSCALL, AFSCALL_IREAD, dev, inode, &iparams);
-    return (errcode);
-}
-
-
-iwrite(int dev, int inode, int inode_p1, unsigned int offset, char *cbuf,
-       unsigned int count)
-{
-    int errcode;
-    struct iparam iparams;
-
-    iparams.param1 = inode_p1;
-    iparams.param2 = offset;
-    iparams.param3 = (long)cbuf;
-    iparams.param4 = count;
-
-    errcode = syscall(AFS_SYSCALL, AFSCALL_IWRITE, dev, inode, &iparams);
-    return (errcode);
-}
-#endif
-
 #endif /* AFS_NAMEI_ENV */
 
 #endif /* !AFS_SGI_ENV */
diff --git a/src/sys/pioctl.c b/src/sys/pioctl.c
index 031def228..f2f9138de 100644
--- a/src/sys/pioctl.c
+++ b/src/sys/pioctl.c
@@ -51,9 +51,14 @@ lpioctl(char *path, int cmd, void *cmarg, int follow)
     rval = proc_afs_syscall(AFSCALL_PIOCTL, (long)path, cmd, (long)cmarg,
 			    follow, &errcode);
 
-    if(rval)
+    if(rval) {
+# ifdef AFS_SYSCALL
 	errcode = syscall(AFS_SYSCALL, AFSCALL_PIOCTL, path, cmd, cmarg,
 			  follow);
+# else
+	errcode = -1;
+# endif
+    }
 
     return (errcode);
 }
diff --git a/src/sys/rmtsysc.c b/src/sys/rmtsysc.c
index a66eb8801..cf16afcea 100644
--- a/src/sys/rmtsysc.c
+++ b/src/sys/rmtsysc.c
@@ -135,14 +135,8 @@ rx_connection(afs_int32 * errorcode, char *syscall)
 
 /* WARNING: The calling program (i.e. klog) MUST be suid-root since we need to
  * do a setgroups(2) call with the new pag.... */
-#ifdef AFS_DUX40_ENV
-#pragma weak setpag = afs_setpag
-int
-afs_setpag(void)
-#else
 int
 setpag(void)
-#endif
 {
     struct rx_connection *conn;
     clientcred creds;
@@ -152,7 +146,10 @@ setpag(void)
     if (!(conn = rx_connection(&errorcode, "setpag"))) {
 	/* Remote call can't be performed for some reason.
 	 * Try the local 'setpag' system call ... */
-	errorcode = lsetpag();
+	do {
+	    errorcode = lsetpag();
+	} while (errorcode && errno == EINTR);
+
 	return errorcode;
     }
     ngroups = SetClientCreds(&creds, groups);
@@ -192,15 +189,8 @@ setpag(void)
 
 
 /* Remote pioctl(2) client routine */
-#ifdef AFS_DUX40_ENV
-#pragma weak pioctl = afs_pioctl
-int
-afs_pioctl(char *path, afs_int32 cmd, struct ViceIoctl *data,
-	   afs_int32 follow)
-#else
 int
 pioctl(char *path, afs_int32 cmd, struct ViceIoctl *data, afs_int32 follow)
-#endif
 {
     struct rx_connection *conn;
     clientcred creds;
@@ -215,10 +205,6 @@ pioctl(char *path, afs_int32 cmd, struct ViceIoctl *data, afs_int32 follow)
 	return errorcode;
     }
     (void)SetClientCreds(&creds, groups);
-#ifdef	AFS_OSF_ENV
-    if (!ins)
-	ins = 1;
-#endif
     if (!(inbuffer = malloc(ins)))
 	return (-1);		/* helpless here */
     if (data->in_size)
diff --git a/src/sys/setpag.c b/src/sys/setpag.c
index 3c90279ee..48570bf78 100644
--- a/src/sys/setpag.c
+++ b/src/sys/setpag.c
@@ -55,8 +55,14 @@ lsetpag(void)
 
     rval = proc_afs_syscall(AFSCALL_SETPAG,0,0,0,0,&errcode);
 
-    if(rval)
+    if(rval) {
+# ifdef AFS_SYSCALL
       errcode = syscall(AFS_SYSCALL, AFSCALL_SETPAG);
+# else
+      errcode = -1;
+# endif
+    }
+
 #elif defined(AFS_DARWIN80_ENV)
     int rval;
 
diff --git a/src/sys/sys_prototypes.h b/src/sys/sys_prototypes.h
index b4a5a275c..beb28f617 100644
--- a/src/sys/sys_prototypes.h
+++ b/src/sys/sys_prototypes.h
@@ -29,11 +29,7 @@ extern int lpioctl(char *, int, void *, int);
 struct ViceIoctl;
 extern int pioctl(char *path, afs_int32 cmd, struct ViceIoctl *data,
 		  afs_int32 follow);
-#ifdef AFS_DUX40_ENV
-extern int afs_setpag(void);
-#else
 extern int setpag(void);
-#endif
 
 /* rmtsysnet.c */
 extern void inparam_conversion(afs_int32, char *, afs_int32);
diff --git a/src/tbutc/NTMakefile b/src/tbutc/NTMakefile
index 3c991f342..19b2f5cde 100644
--- a/src/tbutc/NTMakefile
+++ b/src/tbutc/NTMakefile
@@ -70,7 +70,8 @@ BUTCLIBS=$(DESTDIR)\lib\afs\afsbudb.lib  \
 	     $(DESTDIR)\lib\afsrpc.lib \
              $(DESTDIR)\lib\afsrxkad.lib \
 	     $(DESTDIR)\lib\afs\mtafsubik.lib \
-             $(DESTDIR)\lib\afs\afsutil.lib \
+             $(DESTDIR)\lib\afs\mtafsutil.lib \
+             $(DESTDIR)\lib\afs\afsaudit.lib \
              $(DESTDIR)\lib\afs\afsusd.lib \
 	     $(DESTDIR)\lib\afs\afspioctl.lib \
              $(DESTDIR)\lib\afs\afscmd.lib \
diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in
index 5d0feca89..6abe1f604 100644
--- a/src/tests/Makefile.in
+++ b/src/tests/Makefile.in
@@ -11,7 +11,7 @@ SYS_LIBS	= ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a $
 
 AUTH_LIBS	= ${TOP_LIBDIR}/libauth.a ${SYS_LIBS}
 
-INT_LIBS	= ${TOP_LIBDIR}/libafsint.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libafsrfc3961.a
+INT_LIBS	= ${TOP_LIBDIR}/libafsint.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/librxkad.a ${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libafscom_err.a ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libafsrfc3961.a ${TOP_LIBDIR}/libopr.a $(LIB_roken) $(LIB_hcrypto)
 
 TEST_PROGRAMS = write-ro-file hello-world read-vs-mmap read-vs-mmap2	 \
 		mmap-and-read large-dir large-dir2 large-dir3 mountpoint \
diff --git a/src/tests/afscp.c b/src/tests/afscp.c
index 5175e1ba1..7e24bee2d 100644
--- a/src/tests/afscp.c
+++ b/src/tests/afscp.c
@@ -164,29 +164,14 @@ do_rx_Init(void)
 struct rx_securityClass *
 get_sc(char *cellname)
 {
-#if 0
-    char realm[REALM_SZ];
-    CREDENTIALS c;
-#endif
-
     return rxnull_NewClientSecurityObject();
-#if 0
-
-    ucstring(realm, cellname, REALM_SZ);
-
-    if (krb_get_cred("afs", "", realm, &c)) {
-	if (get_ad_tkt("afs", "", realm, DEFAULT_TKT_LIFE)) {
-	    return NULL;
-	} else {
-	    if (krb_get_cred("afs", "", realm, &c)) {
-		return NULL;
-	    }
-	}
-    }
+}
 
-    return rxkad_NewClientSecurityObject(rxkad_clear, c.session, c.kvno,
-					 c.ticket_st.length, c.ticket_st.dat);
-#endif
+static volatile int loop_stop = 1;
+static void
+int_handler(int sig)
+{
+    loop_stop = 1;
 }
 
 #define scindex_NULL 0
@@ -208,16 +193,21 @@ main(int argc, char **argv)
     struct AFSFid sf, dd, df;
 
     int filesz = 0;
+    unsigned long total_xfer = 0;
     int ch, blksize, bytesremaining, bytes;
     struct timeval start, finish;
     struct rx_securityClass *ssc = 0, *dsc = 0;
     int sscindex, dscindex;
     struct rx_connection *sconn = NULL, *dconn = NULL;
     struct rx_call *scall = NULL, *dcall = NULL;
+    struct rx_call *scall_2 = NULL, *dcall_2 = NULL;
     int code = 0, fetchcode, storecode, printcallerrs = 0;
     int slcl = 0, dlcl = 0, unlock = 0;
     int sfd = 0, dfd = 0, unauth = 0;
     int sleeptime = 0;
+    int did_start = 0;
+    int loop_seconds = 0;
+    int first;
 
     struct AFSCBFids theFids;
     struct AFSCBs theCBs;
@@ -225,7 +215,7 @@ main(int argc, char **argv)
 
     blksize = 8 * 1024;
 
-    while ((ch = getopt(argc, argv, "iouUb:s:")) != -1) {
+    while ((ch = getopt(argc, argv, "iouUb:s:l:")) != -1) {
 	switch (ch) {
 	case 'b':
 	    blksize = atoi(optarg);
@@ -245,6 +235,15 @@ main(int argc, char **argv)
 	case 'U':
 	    unlock = 1;
 	    break;
+	case 'l': {
+	    struct sigaction sa;
+	    loop_stop = 0;
+	    loop_seconds = atoi(optarg);
+	    memset(&sa, 0, sizeof(sa));
+	    sa.sa_handler = int_handler;
+	    sigaction(SIGINT, &sa, NULL);
+	    break;
+	}
 	default:
 	    printf("Unknown option '%c'\n", ch);
 	    exit(1);
@@ -254,13 +253,14 @@ main(int argc, char **argv)
 
     if (argc - optind + unlock < 2) {
 	fprintf(stderr,
-		"Usage: afscp [-i|-o]] [-b xfersz] [-s time] [-u] [-U] source [dest]\n");
+		"Usage: afscp [-i|-o]] [-b xfersz] [-s time] [-l n] [-u] [-U] source [dest]\n");
 	fprintf(stderr, "  -b   Set block size\n");
 	fprintf(stderr, "  -i   Source is local (copy into AFS)\n");
 	fprintf(stderr, "  -o   Dest is local (copy out of AFS)\n");
 	fprintf(stderr, "  -s   Set the seconds to sleep before reading/writing data\n");
 	fprintf(stderr, "  -u   Run unauthenticated\n");
 	fprintf(stderr, "  -U   Send an unlock request for source. (dest path not required)\n");
+	fprintf(stderr, "  -l   repeat request for N seconds (0 for forever)\n");
 	fprintf(stderr, "source and dest can be paths or specified as:\n");
 	fprintf(stderr, "     @afs:cellname:servername:volume:vnode:uniq\n");
 	exit(1);
@@ -358,13 +358,22 @@ main(int argc, char **argv)
 	}
     }
 
+    first = 2;
+ repeat:
+    if (first == 2) {
+	first = 1;
+    } else if (first == 1) {
+	first = 0;
+    }
 
     memset(&sst, 0, sizeof(struct AFSStoreStatus));
 
     if (dlcl && !unlock) {
 	dfd = open(destpath, O_RDWR | O_CREAT | O_EXCL, 0666);
 	if (dfd < 0 && errno == EEXIST) {
-	    printf("%s already exists, overwriting\n", destpath);
+	    if (first) {
+		printf("%s already exists, overwriting\n", destpath);
+	    }
 	    dfd = open(destpath, O_RDWR | O_TRUNC, 0666);
 	    if (dfd < 0) {
 		fprintf(stderr, "Cannot open %s (%s)\n", destpath,
@@ -381,7 +390,9 @@ main(int argc, char **argv)
 	     RXAFS_CreateFile(dconn, &dd, destf, &sst, &df, &fst, &dfst, &dcb,
 			      &vs))) {
 	    if (code == EEXIST) {
-		printf("%s already exits, overwriting\n", destpath);
+		if (first) {
+		    printf("%s already exits, overwriting\n", destpath);
+		}
 		if (statfile(destpath, dcell, &dsrv, &df))
 		    fprintf(stderr, "Cannot get attributes of %s\n",
 			    destpath);
@@ -424,15 +435,31 @@ main(int argc, char **argv)
     } else {
 	filesz = fst.Length;
     }
+    total_xfer += filesz;
 
     printcallerrs = 0;
     fetchcode = 0;
     storecode = 0;
-    if (!slcl && !unlock)
-	scall = rx_NewCall(sconn);
-    if (!dlcl && !unlock)
-	dcall = rx_NewCall(dconn);
-    gettimeofday(&start, NULL);
+    if (!slcl && !unlock) {
+	if (first) {
+	    scall = rx_NewCall(sconn);
+	} else {
+	    scall = scall_2;
+	}
+	scall_2 = rx_NewCall(sconn);
+    }
+    if (!dlcl && !unlock) {
+	if (first) {
+	    dcall = rx_NewCall(dconn);
+	} else {
+	    dcall = dcall_2;
+	}
+	dcall_2 = rx_NewCall(dconn);
+    }
+    if (!did_start) {
+	gettimeofday(&start, NULL);
+	did_start = 1;
+    }
     if (unlock) {
 	if (fst.lockCount) {
 	    printf("Sending 1 unlock for %s (%d locks)\n", srcf, fst.lockCount);
@@ -551,6 +578,19 @@ main(int argc, char **argv)
     }
     if (storecode)
 	printf("Error returned from store: %s\n", afs_error_message(storecode));
+
+    if (!loop_stop) {
+	struct timeval cur;
+	double elapsed;
+	if (loop_seconds == 0) {
+	    goto repeat;
+	}
+	gettimeofday(&cur, NULL);
+	elapsed = cur.tv_sec - start.tv_sec + (cur.tv_usec - start.tv_usec) / 1e+06;
+	if (elapsed < loop_seconds) {
+	    goto repeat;
+	}
+    }
 Finish:
     gettimeofday(&finish, NULL);
 
@@ -599,19 +639,19 @@ Finish:
     if (printcallerrs && !unlock) {
 	double rate, size, time;
 	if (finish.tv_sec == start.tv_sec) {
-	    printf("Copied %d bytes in %d microseconds\n", filesz,
+	    printf("Copied %lu bytes in %d microseconds\n", total_xfer,
 		   (int)(finish.tv_usec - start.tv_usec));
 	} else {
-	    printf("Copied %d bytes in %d seconds\n", filesz,
+	    printf("Copied %lu bytes in %d seconds\n", total_xfer,
 		   (int)(finish.tv_sec - start.tv_sec));
 	}
 
-	size = filesz / 1024.0;
+	size = total_xfer / 1024.0;
 	time =
 	    finish.tv_sec - start.tv_sec + (finish.tv_usec -
 					    start.tv_usec) / 1e+06;
 	rate = size / time;
-	printf("Transfer rate %g Kbytes/sec\n", rate);
+	printf("Transfer rate %.4g Kbytes/sec\n", rate);
 
     }
 
diff --git a/src/tests/asu.c b/src/tests/asu.c
index 6112100e9..ddd532dda 100644
--- a/src/tests/asu.c
+++ b/src/tests/asu.c
@@ -86,13 +86,6 @@ main(int argc, char **argv)
 	setegid(gid);
 	seteuid(uid);
     }
-#if 0
-    if (k_hasafs()) {
-	int ret = k_setpag();
-	if (ret < 0)
-	    warn("k_setpag");
-    }
-#endif
 
     execvp(prog, &argv[2]);
 
diff --git a/src/tests/ga-test.c b/src/tests/ga-test.c
index 03865fba9..f0b909902 100644
--- a/src/tests/ga-test.c
+++ b/src/tests/ga-test.c
@@ -130,9 +130,6 @@ test_simple_strings(void)
 			    "--strings=foo", "--strings=bar", NULL}},
 	{AARG_GNUSTYLE, 5, {"strings", "-s", "foo", "-s", "bar", NULL}},
 	{AARG_AFSSTYLE, 4, {"strings", "-string", "foo", "bar", NULL}}
-#if 0
-	{AARG_AFSSTYLE, 3, {"strings", "foo", "bar", NULL}}
-#endif
     };
 
     struct agetargs args[] = {
@@ -243,10 +240,6 @@ test_simple_flag(void)
 	{AARG_GNUSTYLE, 2, {"flag", "-g", NULL}, GA_SUCCESS},
 	{AARG_AFSSTYLE, 2, {"flag", "--flag"}, GA_FAILURE},
 	{AARG_AFSSTYLE, 2, {"flag", "-flag", NULL}, GA_SUCCESS},
-#if 0
-	/* XXX */
-	{AARG_AFSSTYLE, 2, {"flag", "yes", NULL}, GA_SUCCESS},
-#endif
 	{AARG_GNUSTYLE, 2, {"flag", "--no-flag", NULL}, GA_SUCCESS}
     };
 
diff --git a/src/tests/intr-read.c b/src/tests/intr-read.c
index 344c2abfd..99a08f6eb 100644
--- a/src/tests/intr-read.c
+++ b/src/tests/intr-read.c
@@ -50,7 +50,6 @@
 
 #include <err.h>
 
-#define RETSIGTYPE void
 #ifndef MAXPATHLEN
 #ifdef PATH_MAX
 #define MAXPATHLEN PATH_MAX
@@ -61,7 +60,7 @@
 
 static sig_atomic_t set_alarm = 1;
 
-static RETSIGTYPE
+static void
 sigalrm(int foo)
 {
     signal(SIGALRM, sigalrm);
diff --git a/src/tests/large-dir.c b/src/tests/large-dir.c
index 04b215fc1..98a59eef2 100644
--- a/src/tests/large-dir.c
+++ b/src/tests/large-dir.c
@@ -121,10 +121,6 @@ creat_files(const char *dirname, int count)
     closedir(d);
     if (stat(".", &sb) < 0)
 	err(1, "stat .");
-#if 0
-    if (sb.st_size != 2048)
-	errx(1, "size != 2048");
-#endif
     return 0;
 }
 
diff --git a/src/tests/large-dir2.c b/src/tests/large-dir2.c
index 6f53b85cd..d2c2c8418 100644
--- a/src/tests/large-dir2.c
+++ b/src/tests/large-dir2.c
@@ -64,10 +64,6 @@ creat_files(const char *dirname, int count)
 	err(1, "chdir %s", dirname);
     if (stat(".", &sb) < 0)
 	err(1, "stat .");
-#if 0
-    if (sb.st_size != 2048)
-	errx(1, "size != 2048");
-#endif
     for (i = 0; i < count; ++i) {
 	char fname[256];
 	int len;
diff --git a/src/tests/mmap-and-read.c b/src/tests/mmap-and-read.c
index 39c7258c1..8508625ee 100644
--- a/src/tests/mmap-and-read.c
+++ b/src/tests/mmap-and-read.c
@@ -89,11 +89,6 @@ generate_random_file(const char *filename, unsigned npages, unsigned pagesize,
 
     memcpy(fbuf, buf, sz);
 
-#if 0
-    if (msync(fbuf, sz, MS_SYNC))
-	err(1, "msync");
-#endif
-
     if (munmap(fbuf, sz) != 0)
 	err(1, "munmap");
 
diff --git a/src/tests/rename-under-feet.c b/src/tests/rename-under-feet.c
index ad12e6cf6..3b4d74268 100644
--- a/src/tests/rename-under-feet.c
+++ b/src/tests/rename-under-feet.c
@@ -49,8 +49,6 @@
 
 #include <err.h>
 
-#define RETSIGTYPE void
-
 static void
 emkdir(const char *path, mode_t mode)
 {
@@ -63,7 +61,7 @@ static pid_t child_pid;
 
 static sig_atomic_t term_sig = 0;
 
-static RETSIGTYPE
+static void
 child_sigterm(int signo)
 {
     term_sig = 1;
@@ -104,10 +102,6 @@ child_chdir(const char *path)
 	    err(1, "write");
 	while (!term_sig)
 	    pause();
-#if 0
-	if (getcwd(buf, sizeof(buf)) == NULL)
-	    err(1, "getcwd");
-#endif
 	fp = fdopen(4, "w");
 	if (fp != NULL)
 	    fprintf(fp, "child: cwd = %s\n", buf);
diff --git a/src/tests/run-tests.in b/src/tests/run-tests.in
index d0fc73d70..1ab12ad14 100755
--- a/src/tests/run-tests.in
+++ b/src/tests/run-tests.in
@@ -28,8 +28,8 @@ srcdir=@srcdir@
 objdir=`pwd`
 SHELL=/bin/sh
 SHELLVERBOSE=
-VERSION=@VERSION@
-PACKAGE=@PACKAGE@
+VERSION=@PACKAGE_VERSION@
+PACKAGE=@PACKAGE_TARNAME@
 host=@host@
 RUNAS=
 FS=${AFSSRVBINDIR}/fs
diff --git a/src/tests/snprintf.c b/src/tests/snprintf.c
index aaed1a7e5..a8eeb19ed 100644
--- a/src/tests/snprintf.c
+++ b/src/tests/snprintf.c
@@ -442,7 +442,7 @@ xyzprintf(struct state *state, const char *char_format, va_list ap)
 		}
 	    case '\0':
 		--format;
-		/* FALLTHROUGH */
+		AFS_FALLTHROUGH;
 	    case '%':
 		if ((*state->append_char) (state, c))
 		    return -1;
diff --git a/src/tools/dumpscan/afsdump_dirlist.c b/src/tools/dumpscan/afsdump_dirlist.c
index 0af2ed7d1..811ddd45c 100644
--- a/src/tools/dumpscan/afsdump_dirlist.c
+++ b/src/tools/dumpscan/afsdump_dirlist.c
@@ -56,7 +56,7 @@ static dump_parser dp;
 
 
 /* Print a usage message and exit */
-static void
+static void AFS_NORETURN
 usage(int status, char *msg)
 {
     if (msg)
diff --git a/src/tools/dumpscan/afsdump_extract.c b/src/tools/dumpscan/afsdump_extract.c
index 98f3a0c27..dfe0369fb 100644
--- a/src/tools/dumpscan/afsdump_extract.c
+++ b/src/tools/dumpscan/afsdump_extract.c
@@ -62,7 +62,7 @@ static path_hashinfo phi;
 static dump_parser dp;
 
 /* Print a usage message and exit */
-static void
+static void AFS_NORETURN
 usage(int status, char *msg)
 {
     if (msg)
@@ -237,7 +237,7 @@ static char *month[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun",
 static char *
 datestr(time_t date)
 {
-    static char str[13];
+    static char str[20];
     time_t clock = time(0);
     struct tm *now, *then;
     int diff;
diff --git a/src/tools/dumpscan/afsdump_scan.c b/src/tools/dumpscan/afsdump_scan.c
index dafae676b..787172d45 100644
--- a/src/tools/dumpscan/afsdump_scan.c
+++ b/src/tools/dumpscan/afsdump_scan.c
@@ -63,7 +63,7 @@ static dump_parser dp;
 
 
 /* Print a usage message and exit */
-static void
+static void AFS_NORETURN
 usage(int status, char *msg)
 {
     if (msg)
diff --git a/src/tools/dumpscan/directory.c b/src/tools/dumpscan/directory.c
index a3b9d3e0b..6aa043ade 100644
--- a/src/tools/dumpscan/directory.c
+++ b/src/tools/dumpscan/directory.c
@@ -74,19 +74,6 @@ static int namehash(char *name, int buckets, int seed)
   return tval ? hval < 0 ? buckets - tval : tval : 0;
 }
 
-#if 0
-static void fixup(char *name, int l)
-{
-  name += 16;
-  l -= 15;
-
-  while (l-- > 0) {
-    name[0] = name[4];
-    name++;
-  }
-}
-#endif
-
 afs_uint32 parse_directory(XFILE *X, dump_parser *p, afs_vnode *v,
                         afs_uint32 size, int toeof)
 {
@@ -140,9 +127,6 @@ afs_uint32 parse_directory(XFILE *X, dump_parser *p, afs_vnode *v,
       de.uniq  = ntohl(page.entry[i].vunique);
       if (p->print_flags & DSPRINT_DIR)
         printf("  %10d %10d  %s\n", de.vnode, de.uniq, de.name);
-      if (p->cb_dirent) {
-        r = (p->cb_dirent)(v, &de, X, p->refcon);
-      }
       if (p->cb_dirent && (r = (p->cb_dirent)(v, &de, X, p->refcon)))
         return r;
       i += ((l + 16) >> 5);
diff --git a/src/tools/dumpscan/dumptool.c b/src/tools/dumpscan/dumptool.c
index 70b2ec708..61dc0e6b6 100644
--- a/src/tools/dumpscan/dumptool.c
+++ b/src/tools/dumpscan/dumptool.c
@@ -1028,9 +1028,6 @@ ScanVnodes(FILE * f, VolumeDiskData * vol, int sizescan)
 		    fprintf(stderr, "failed readbystring for 'A'\n");
 		    return -1;
 		}
-#if 0
-		acl_NtohACL(VVnodeDiskACL(vnode));
-#endif
 		break;
 #ifdef RESIDENCY
 	    case 'h':
@@ -1303,6 +1300,7 @@ DirectoryList(int argc, char **argv, struct vnodeData *vdata,
 	    break;
 	case 'R':
 	    Rflag++;
+	    break;
 	case 's':
 	    sflag++;
 	    break;
diff --git a/src/tools/dumpscan/intNN.h b/src/tools/dumpscan/intNN.h
index b344a3552..7163ee91d 100644
--- a/src/tools/dumpscan/intNN.h
+++ b/src/tools/dumpscan/intNN.h
@@ -31,13 +31,6 @@
 
 /* intNN.h - Sized integer types */
 #include <afs/stds.h>
-#if 0
-typedef short afs_int16;
-typedef unsigned short afs_uint16;
-
-typedef long afs_int32;
-typedef unsigned long afs_uint32;
-#endif
 
 
 /* Support for 64-bit integers.
diff --git a/src/tools/dumpscan/parsevnode.c b/src/tools/dumpscan/parsevnode.c
index 0e18e498e..f4e5e4b7d 100644
--- a/src/tools/dumpscan/parsevnode.c
+++ b/src/tools/dumpscan/parsevnode.c
@@ -27,7 +27,7 @@
  */
 
 /* parsevnode.c - Parse a VNode */
-
+#include <afsconfig.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <errno.h>
@@ -480,7 +480,7 @@ parse_vdata(XFILE * X, unsigned char *tag, tagged_field * field,
 		    return r;
 		break;
 	    }
-
+	    AFS_FALLTHROUGH;
 	default:
 	    if ((r = xfskip(X, v->size)))
 		return r;
diff --git a/src/tools/rxperf/rxperf.c b/src/tools/rxperf/rxperf.c
index 8d90b1bc5..bcefe9a2b 100644
--- a/src/tools/rxperf/rxperf.c
+++ b/src/tools/rxperf/rxperf.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000 - 2001 Kungliga Tekniska Högskolan
+ * Copyright (c) 2000 - 2001 Kungliga Tekniska HÃ¶gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -671,9 +671,10 @@ client_thread( void *vparams)
 
 #ifdef AFS_PTHREAD_ENV
     pthread_exit(NULL);
-#endif
-
+    AFS_UNREACHED(return NULL);
+#else
     return NULL;
+#endif
 }
 
 /*
diff --git a/src/tptserver/.gitignore b/src/tptserver/.gitignore
index e993f8443..7f6420549 100644
--- a/src/tptserver/.gitignore
+++ b/src/tptserver/.gitignore
@@ -4,6 +4,7 @@
 
 /db_verify
 /pt_util
+/ptclient
 /pterror.c
 /pterror.h
 /ptint.h
diff --git a/src/tsalvaged/Makefile.in b/src/tsalvaged/Makefile.in
index c0c337c77..cd69b86af 100644
--- a/src/tsalvaged/Makefile.in
+++ b/src/tsalvaged/Makefile.in
@@ -20,7 +20,7 @@ MODULE_CFLAGS = -DRXDEBUG -DFSSYNC_BUILD_CLIENT \
 SCFLAGS=$(COMMON_CFLAGS) -I.. -DRXDEBUG -DFSSYNC_BUILD_CLIENT \
 	-DAFS_DEMAND_ATTACH_FS $(PTH_CFLAGS)
 
-SCCRULE=$(RUN_CC) ${MT_CC} ${SCFLAGS} -c $? -o $@
+SCCRULE=$(RUN_CC) $(CC_WRAPPER) ${MT_CC} ${SCFLAGS} -c $? -o $@
 
 DIR=$(srcdir)/../dir
 VOL=$(srcdir)/../vol
diff --git a/src/tsalvaged/salvsync-debug.c b/src/tsalvaged/salvsync-debug.c
index 3c0681d49..b26355b71 100644
--- a/src/tsalvaged/salvsync-debug.c
+++ b/src/tsalvaged/salvsync-debug.c
@@ -355,25 +355,6 @@ reason_code_to_string(afs_int32 reason)
     }
 }
 
-#if 0
-static char *
-program_type_to_string(afs_int32 type)
-{
-    switch ((ProgramType)type) {
-    case fileServer:
-	return "fileServer";
-    case volumeUtility:
-	return "volumeUtility";
-    case salvager:
-	return "salvager";
-    case salvageServer:
-	return "salvageServer";
-    default:
-	return "**UNKNOWN**";
-    }
-}
-#endif
-
 static char *
 state_code_to_string(afs_int32 state)
 {
diff --git a/src/tsm41/aix_aklog.c b/src/tsm41/aix_aklog.c
index 49d677afc..5486af517 100644
--- a/src/tsm41/aix_aklog.c
+++ b/src/tsm41/aix_aklog.c
@@ -179,39 +179,6 @@ aklog_authenticate(char *userName, char *response, int *reenter, char **message)
 		    str);
 	return AUTH_FAILURE; /* NOTFOUND? */
     }
-
-#if 0
-    /*
-     * Local hack - if the person has a file in their home
-     * directory called ".xlog", read that for a list of
-     * extra cells to authenticate to
-     */
-
-    if ((pwd = getpwuid(getuid())) != NULL) {
-	struct stat sbuf;
-	FILE *f;
-	char fcell[100], xlog_path[512];
-
-	strcpy(xlog_path, pwd->pw_dir);
-	strcat(xlog_path, "/.xlog");
-
-	if ((stat(xlog_path, &sbuf) == 0) &&
-	    ((f = fopen(xlog_path, "r")) != NULL)) {
-
-	    while (fgets(fcell, 100, f) != NULL) {
-		int auth_status;
-
-		fcell[strlen(fcell) - 1] = '\0';
-
-		auth_status = auth_to_cell(context, userName, fcell, NULL);
-		if (status == AKLOG_SUCCESS)
-		    status = auth_status;
-		else
-		    status = AKLOG_SOMETHINGSWRONG;
-	    }
-	}
-    }
-#endif
     return AUTH_SUCCESS;
 }
 
diff --git a/src/tvlserver/Makefile.in b/src/tvlserver/Makefile.in
index d35fc676b..a9dc356c0 100644
--- a/src/tvlserver/Makefile.in
+++ b/src/tvlserver/Makefile.in
@@ -66,13 +66,6 @@ cnvldb: cnvldb.o $(LIBS_client)
 cnvldb.o: ${VLSERVER}/cnvldb.c
 	$(AFS_CCRULE) $(VLSERVER)/cnvldb.c
 
-sascnvldb: sascnvldb.o $(LIBS_client)
-	$(LT_LDRULE_static) sascnvldb.o \
-		$(LIBS_client) $(LIB_hcrypto) $(LIB_roken) ${MT_LIBS}
-
-sascnvldb.o: ${VLSERVER}/sascnvldb.c
-	$(AFS_CCRULE) $(VLSERVER)/sascnvldb.c
-
 vlserver: vlserver.o vlutils.o vlprocs.o vldbint.ss.o vldbint.xdr.o $(LIBS_server)
 	$(LT_LDRULE_static) vlserver.o vlutils.o vlprocs.o vldbint.ss.o \
 		vldbint.xdr.o \
diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c
index 01844ae7d..305a118cd 100644
--- a/src/ubik/beacon.c
+++ b/src/ubik/beacon.c
@@ -24,9 +24,7 @@
 #include <rx/rxkad.h>
 #include <rx/rx_multi.h>
 #include <afs/cellconfig.h>
-#ifndef AFS_NT40_ENV
 #include <afs/afsutil.h>
-#endif
 
 #define UBIK_INTERNALS
 #include "ubik.h"
@@ -117,7 +115,7 @@ amSyncSite(void)
 	now = FT_ApproxTime();
 	if (beacon_globals.syncSiteUntil <= now) {	/* if my votes have expired, say so */
 	    if (beacon_globals.ubik_amSyncSite)
-		ubik_dprint("Ubik: I am no longer the sync site\n");
+		ViceLog(0, ("Ubik: I am no longer the sync site - my votes expired\n"));
 	    beacon_globals.ubik_amSyncSite = 0;
 	    beacon_globals.ubik_syncSiteAdvertised = 0;
 	    rcode = 0;
@@ -126,7 +124,7 @@ amSyncSite(void)
 	}
     }
     UBIK_BEACON_UNLOCK;
-    ubik_dprint("beacon: amSyncSite is %d\n", rcode);
+    ViceLog(5, ("beacon: amSyncSite is %d\n", rcode));
     return rcode;
 }
 
@@ -412,7 +410,7 @@ ubeacon_InitServerListCommon(afs_uint32 ame, struct afsconf_cell *info,
 
     if (ubik_singleServer) {
 	if (!beacon_globals.ubik_amSyncSite) {
-	    ubik_dprint("Ubik: I am the sync site - 1 server\n");
+	    ViceLog(0, ("Ubik: I am the sync site - 1 server\n"));
 	    DBHOLD(ubik_dbase);
 	    UBIK_VERSION_LOCK;
 	    version_globals.ubik_epochTime = FT_ApproxTime();
@@ -447,7 +445,7 @@ ubeacon_Interact(void *dummy)
     struct ubik_version tversion;
     afs_int32 startTime;
 
-    afs_pthread_setname_self("beacon");
+    opr_threadname_set("beacon");
 
     /* loop forever getting votes */
     lastWakeupTime = 0;		/* keep track of time we last started a vote collection */
@@ -500,7 +498,7 @@ ubeacon_Interact(void *dummy)
 
 	UBIK_VERSION_LOCK;
 	ttid.epoch = version_globals.ubik_epochTime;
-	if (ubik_dbase->flags & DBWRITING) {
+	if (ubik_dbase->dbFlags & DBWRITING) {
 	    /*
 	     * if a write is in progress, we have to send the writeTidCounter
 	     * which holds the tid counter of the write transaction , and not
@@ -549,14 +547,14 @@ ubeacon_Interact(void *dummy)
 		     * happen due to errors with the rx security class in play
 		     * (rxkad, rxgk, etc). treat the host as if we got a
 		     * timeout, since this is not a valid vote. */
-		    ubik_print("assuming distant vote time %d from %s is an error; marking host down\n",
-		               (int)code, afs_inet_ntoa_r(ts->addr[0], hoststr));
+		    ViceLog(0, ("assuming distant vote time %d from %s is an error; marking host down\n",
+		               (int)code, afs_inet_ntoa_r(ts->addr[0], hoststr)));
 		    code = -1;
 		}
 		if (code > 0 && rx_ConnError(connections[multi_i])) {
-		    ubik_print("assuming vote from %s is invalid due to conn error %d; marking host down\n",
+		    ViceLog(0, ("assuming vote from %s is invalid due to conn error %d; marking host down\n",
 		               afs_inet_ntoa_r(ts->addr[0], hoststr),
-		               (int)rx_ConnError(connections[multi_i]));
+		               (int)rx_ConnError(connections[multi_i])));
 		    code = -1;
 		}
 
@@ -565,8 +563,8 @@ ubeacon_Interact(void *dummy)
 		 * the latter down below if we got enough votes to go with */
 		if (code > 0) {
 		    if ((code & ~0xff) == ERROR_TABLE_BASE_RXK) {
-			ubik_dprint("token error %d from host %s\n",
-				    code, afs_inet_ntoa_r(ts->addr[0], hoststr));
+			ViceLog(0, ("Server %s is marked down due to token error %d\n",
+				    afs_inet_ntoa_r(ts->addr[0], hoststr), code));
 			ts->up = 0;
 			ts->beaconSinceDown = 0;
 			urecovery_LostServer(ts);
@@ -581,21 +579,21 @@ ubeacon_Interact(void *dummy)
 			    yesVotes++;	/* the extra epsilon */
 			ts->up = 1;	/* server is up (not really necessary: recovery does this for real) */
 			ts->beaconSinceDown = 1;
-			ubik_dprint("yes vote from host %s\n",
-				    afs_inet_ntoa_r(ts->addr[0], hoststr));
+			ViceLog(5, ("yes vote from host %s\n",
+				    afs_inet_ntoa_r(ts->addr[0], hoststr)));
 		    }
 		} else if (code == 0) {
 		    ts->lastVoteTime = temp;
 		    ts->lastVote = 0;
 		    ts->beaconSinceDown = 1;
-		    ubik_dprint("no vote from %s\n",
-				afs_inet_ntoa_r(ts->addr[0], hoststr));
+		    ViceLog(5, ("no vote from %s\n",
+				afs_inet_ntoa_r(ts->addr[0], hoststr)));
 		} else if (code < 0) {
 		    ts->up = 0;
 		    ts->beaconSinceDown = 0;
 		    urecovery_LostServer(ts);
-		    ubik_dprint("time out from %s\n",
-				afs_inet_ntoa_r(ts->addr[0], hoststr));
+		    ViceLog(0, ("Server %s is marked down due to VOTE_Beacon time out (%d)\n",
+				afs_inet_ntoa_r(ts->addr[0], hoststr), code));
 		}
 		UBIK_BEACON_UNLOCK;
 	    }
@@ -620,7 +618,7 @@ ubeacon_Interact(void *dummy)
 	if (yesVotes > nServers) {	/* yesVotes is bumped by 2 or 3 for each site */
 	    UBIK_BEACON_LOCK;
 	    if (!beacon_globals.ubik_amSyncSite) {
-		ubik_dprint("Ubik: I am the sync site\n");
+		ViceLog(0, ("Ubik: I am the sync site\n"));
 		/* Defer actually changing any variables until we can take the
 		 * DB lock (which is before the beacon lock in the lock order). */
 		becameSyncSite = 1;
@@ -634,7 +632,7 @@ ubeacon_Interact(void *dummy)
 	} else {
 	    UBIK_BEACON_LOCK;
 	    if (beacon_globals.ubik_amSyncSite)
-		ubik_dprint("Ubik: I am no longer the sync site\n");
+		ViceLog(0, ("Ubik: I am no longer the sync site - I lost the election\n"));
 	    beacon_globals.ubik_amSyncSite = 0;
 	    beacon_globals.ubik_syncSiteAdvertised = 0;
 	    UBIK_BEACON_UNLOCK;
@@ -663,7 +661,7 @@ ubeacon_Interact(void *dummy)
 	}
 
     }				/* while loop */
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*!
@@ -711,9 +709,9 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
 				      AFSDIR_SERVER_NETINFO_FILEPATH,
 				      AFSDIR_SERVER_NETRESTRICT_FILEPATH);
 	if (count < 0) {
-	    ubik_print("ubik: Can't register any valid addresses:%s\n",
-		       reason);
-	    ubik_print("Aborting..\n");
+	    ViceLog(0, ("ubik: Can't register any valid addresses:%s\n",
+		       reason));
+	    ViceLog(0, ("Aborting..\n"));
 	    return UBADHOST;
 	}
 	usednetfiles++;
@@ -723,7 +721,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
     }
 
     if (count <= 0) {		/* no address found */
-	ubik_print("ubik: No network addresses found, aborting..\n");
+	ViceLog(0, ("ubik: No network addresses found, aborting..\n"));
 	return UBADHOST;
     }
 
@@ -736,8 +734,8 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
     }
 
     if (!found) {
-	ubik_print("ubik: primary address %s does not exist\n",
-		   afs_inet_ntoa_r(*ame, hoststr));
+	ViceLog(0, ("ubik: primary address %s does not exist\n",
+		   afs_inet_ntoa_r(*ame, hoststr)));
 	/* if we had the result of rx_getAllAddr already, avoid subverting
 	 * the "is gethostbyname(gethostname()) us" check. If we're
 	 * using NetInfo/NetRestrict, we assume they have enough clue
@@ -747,7 +745,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
 	    *ame = myAddr[0];
 	    tcount = rx_getAllAddr(myAddr2, UBIK_MAX_INTERFACE_ADDR);
 	    if (tcount <= 0) {	/* no address found */
-		ubik_print("ubik: No network addresses found, aborting..\n");
+		ViceLog(0, ("ubik: No network addresses found, aborting..\n"));
 		return UBADHOST;
 	    }
 
@@ -782,7 +780,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
 	}
     }
     if (found)
-	ubik_print("Using %s as my primary address\n", afs_inet_ntoa_r(*ame, hoststr));
+	ViceLog(0, ("Using %s as my primary address\n", afs_inet_ntoa_r(*ame, hoststr)));
 
     if (!info) {
 	/* get rid of servers which were purged because all
@@ -864,9 +862,9 @@ ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])
 		if (ts->addr[0] != htonl(outAddr.hostAddr[0])) {
 		    code = UBADHOST;
 		    strcpy(buffer, afs_inet_ntoa_r(ts->addr[0], hoststr));
-		    ubik_print("ubik:Two primary addresses for same server \
+		    ViceLog(0, ("ubik:Two primary addresses for same server \
                     %s %s\n", buffer,
-		    afs_inet_ntoa_r(htonl(outAddr.hostAddr[0]), hoststr));
+		    afs_inet_ntoa_r(htonl(outAddr.hostAddr[0]), hoststr)));
 		} else {
 		    for (j = 1; j < UBIK_MAX_INTERFACE_ADDR; j++)
 			ts->addr[j] = htonl(outAddr.hostAddr[j]);
@@ -874,21 +872,23 @@ ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])
 		UBIK_ADDR_UNLOCK;
 	    } else if (multi_error == RXGEN_OPCODE) {	/* pre 3.5 remote server */
 		UBIK_ADDR_LOCK;
-		ubik_print
-		    ("ubik server %s does not support UpdateInterfaceAddr RPC\n",
-		     afs_inet_ntoa_r(ts->addr[0], hoststr));
+		ViceLog(0, ("ubik server %s does not support UpdateInterfaceAddr RPC\n",
+		     afs_inet_ntoa_r(ts->addr[0], hoststr)));
 		UBIK_ADDR_UNLOCK;
 	    } else if (multi_error == UBADHOST) {
 		code = UBADHOST;	/* remote CellServDB inconsistency */
-		ubik_print("Inconsistent Cell Info on server:\n");
+		ViceLog(0, ("Inconsistent Cell Info on server:\n"));
 		UBIK_ADDR_LOCK;
 		for (j = 0; j < UBIK_MAX_INTERFACE_ADDR && ts->addr[j]; j++)
-		    ubik_print("... %s\n", afs_inet_ntoa_r(ts->addr[j], hoststr));
+		    ViceLog(0, ("... %s\n", afs_inet_ntoa_r(ts->addr[j], hoststr)));
 		UBIK_ADDR_UNLOCK;
 	    } else {
 		UBIK_BEACON_LOCK;
 		ts->up = 0;	/* mark the remote server as down */
 		UBIK_BEACON_UNLOCK;
+		ViceLog(0, ("Server %s is marked down due to DISK_UpdateInterfaceAddr code %d\n",
+			    afs_inet_ntoa_r(ts->addr[0], hoststr), multi_error));
+
 	    }
 	}
 	multi_End;
diff --git a/src/ubik/disk.c b/src/ubik/disk.c
index 6f96efcea..5b743691c 100644
--- a/src/ubik/disk.c
+++ b/src/ubik/disk.c
@@ -18,6 +18,7 @@
 #else
 # include <opr/lockstub.h>
 #endif
+#include <afs/afsutil.h>
 
 #define UBIK_INTERNALS
 #include "ubik.h"
@@ -109,22 +110,14 @@ udisk_Debug(struct ubik_debug *aparm)
  * Abort transaction: opcode \n
  * Write data: opcode, file, position, length, <length> data bytes \n
  */
-int
+static int
 udisk_LogOpcode(struct ubik_dbase *adbase, afs_int32 aopcode, int async)
 {
-    struct ubik_stat ustat;
     afs_int32 code;
 
-    /* figure out where to write */
-    code = (*adbase->stat) (adbase, LOGFILE, &ustat);
-    if (code < 0)
-	return code;
-
     /* setup data and do write */
     aopcode = htonl(aopcode);
-    code =
-	(*adbase->write) (adbase, LOGFILE, (char *)&aopcode, ustat.size,
-			  sizeof(afs_int32));
+    code = (*adbase->buffered_append)(adbase, LOGFILE, &aopcode, sizeof(afs_int32));
     if (code != sizeof(afs_int32))
 	return UIOERROR;
 
@@ -139,17 +132,11 @@ udisk_LogOpcode(struct ubik_dbase *adbase, afs_int32 aopcode, int async)
 /*!
  * \brief Log a commit, never syncing.
  */
-int
+static int
 udisk_LogEnd(struct ubik_dbase *adbase, struct ubik_version *aversion)
 {
     afs_int32 code;
     afs_int32 data[3];
-    struct ubik_stat ustat;
-
-    /* figure out where to write */
-    code = (*adbase->stat) (adbase, LOGFILE, &ustat);
-    if (code)
-	return code;
 
     /* setup data */
     data[0] = htonl(LOGEND);
@@ -158,8 +145,7 @@ udisk_LogEnd(struct ubik_dbase *adbase, struct ubik_version *aversion)
 
     /* do write */
     code =
-	(*adbase->write) (adbase, LOGFILE, (char *)data, ustat.size,
-			  3 * sizeof(afs_int32));
+	(*adbase->buffered_append)(adbase, LOGFILE, data, 3 * sizeof(afs_int32));
     if (code != 3 * sizeof(afs_int32))
 	return UIOERROR;
 
@@ -171,18 +157,12 @@ udisk_LogEnd(struct ubik_dbase *adbase, struct ubik_version *aversion)
 /*!
  * \brief Log a truncate operation, never syncing.
  */
-int
+static int
 udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
 		  afs_int32 alength)
 {
     afs_int32 code;
     afs_int32 data[3];
-    struct ubik_stat ustat;
-
-    /* figure out where to write */
-    code = (*adbase->stat) (adbase, LOGFILE, &ustat);
-    if (code < 0)
-	return code;
 
     /* setup data */
     data[0] = htonl(LOGTRUNCATE);
@@ -191,8 +171,7 @@ udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
 
     /* do write */
     code =
-	(*adbase->write) (adbase, LOGFILE, (char *)data, ustat.size,
-			  3 * sizeof(afs_int32));
+	(*adbase->buffered_append)(adbase, LOGFILE, data, 3 * sizeof(afs_int32));
     if (code != 3 * sizeof(afs_int32))
 	return UIOERROR;
     return 0;
@@ -201,20 +180,12 @@ udisk_LogTruncate(struct ubik_dbase *adbase, afs_int32 afile,
 /*!
  * \brief Write some data to the log, never syncing.
  */
-int
+static int
 udisk_LogWriteData(struct ubik_dbase *adbase, afs_int32 afile, void *abuffer,
 		   afs_int32 apos, afs_int32 alen)
 {
-    struct ubik_stat ustat;
     afs_int32 code;
     afs_int32 data[4];
-    afs_int32 lpos;
-
-    /* find end of log */
-    code = (*adbase->stat) (adbase, LOGFILE, &ustat);
-    lpos = ustat.size;
-    if (code < 0)
-	return code;
 
     /* setup header */
     data[0] = htonl(LOGDATA);
@@ -224,13 +195,12 @@ udisk_LogWriteData(struct ubik_dbase *adbase, afs_int32 afile, void *abuffer,
 
     /* write header */
     code =
-	(*adbase->write) (adbase, LOGFILE, (char *)data, lpos, 4 * sizeof(afs_int32));
+	(*adbase->buffered_append)(adbase, LOGFILE, data, 4 * sizeof(afs_int32));
     if (code != 4 * sizeof(afs_int32))
 	return UIOERROR;
-    lpos += 4 * sizeof(afs_int32);
 
     /* write data */
-    code = (*adbase->write) (adbase, LOGFILE, abuffer, lpos, alen);
+    code = (*adbase->buffered_append)(adbase, LOGFILE, abuffer, alen);
     if (code != alen)
 	return UIOERROR;
     return 0;
@@ -380,7 +350,7 @@ DRead(struct ubik_trans *atrans, afs_int32 fid, int page)
 	tb->file = BADFID;
 	Dlru(tb);
 	tb->lockers--;
-	ubik_print("Ubik: Error reading database file: errno=%d\n", errno);
+	ViceLog(0, ("Ubik: Error reading database file: errno=%d\n", errno));
 	return 0;
     }
     ios++;
@@ -545,8 +515,7 @@ newslot(struct ubik_dbase *adbase, afs_int32 afid, afs_int32 apage)
 
     if (pp == 0) {
 	/* There are no unlocked buffers that don't need to be written to the disk. */
-	ubik_print
-	    ("Ubik: Internal Error: Unable to find free buffer in ubik cache\n");
+	ViceLog(0, ("Ubik: Internal Error: Unable to find free buffer in ubik cache\n"));
 	return NULL;
     }
 
@@ -807,7 +776,6 @@ udisk_write(struct ubik_trans *atrans, afs_int32 afile, void *abuffer,
 	    bp = DNew(atrans, afile, apos >> UBIK_LOGPAGESIZE);
 	    if (!bp)
 		return UIOERROR;
-	    memset(bp, 0, UBIK_PAGESIZE);
 	}
 	/* otherwise, min of remaining bytes and end of buffer to user mode */
 	offset = apos & (UBIK_PAGESIZE - 1);
@@ -835,7 +803,7 @@ udisk_begin(struct ubik_dbase *adbase, int atype, struct ubik_trans **atrans)
 
     *atrans = NULL;
     if (atype == UBIK_WRITETRANS) {
-	if (adbase->flags & DBWRITING)
+	if (adbase->dbFlags & DBWRITING)
 	    return USYNC;
 	code = udisk_LogOpcode(adbase, LOGNEW, 0);
 	if (code)
@@ -850,7 +818,7 @@ udisk_begin(struct ubik_dbase *adbase, int atype, struct ubik_trans **atrans)
 	adbase->readers++;
     else if (atype == UBIK_WRITETRANS) {
 	UBIK_VERSION_LOCK;
-	adbase->flags |= DBWRITING;
+	adbase->dbFlags |= DBWRITING;
 	UBIK_VERSION_UNLOCK;
     }
     *atrans = tt;
@@ -879,9 +847,9 @@ udisk_commit(struct ubik_trans *atrans)
 	    UBIK_VERSION_LOCK;
 	    if (version_globals.ubik_epochTime < UBIK_MILESTONE
 		|| version_globals.ubik_epochTime > now) {
-		ubik_print
+		ViceLog(0,
 		    ("Ubik: New database label %d is out of the valid range (%d - %d)\n",
-		     version_globals.ubik_epochTime, UBIK_MILESTONE, now);
+		     version_globals.ubik_epochTime, UBIK_MILESTONE, now));
 		panic("Writing Ubik DB label\n");
 	    }
 	    oldversion = dbase->version;
@@ -909,11 +877,6 @@ udisk_commit(struct ubik_trans *atrans)
 
 	UBIK_VERSION_LOCK;
 	dbase->version.counter++;	/* bump commit count */
-#ifdef AFS_PTHREAD_ENV
-	opr_cv_broadcast(&dbase->version_cond);
-#else
-	LWP_NoYieldSignal(&dbase->version);
-#endif
 	code = udisk_LogEnd(dbase, &dbase->version);
 	if (code) {
 	    dbase->version.counter--;
@@ -974,7 +937,7 @@ udisk_abort(struct ubik_trans *atrans)
      * will do nothing because the abort is there or no LogEnd opcode.
      */
     dbase = atrans->dbase;
-    if (atrans->type == UBIK_WRITETRANS && dbase->flags & DBWRITING) {
+    if (atrans->type == UBIK_WRITETRANS && dbase->dbFlags & DBWRITING) {
 	udisk_LogOpcode(dbase, LOGABORT, 1);
 	code = (*dbase->truncate) (dbase, LOGFILE, 0);
 	if (code)
@@ -1010,9 +973,9 @@ udisk_end(struct ubik_trans *atrans)
     /* check if we are the write trans before unsetting the DBWRITING bit, else
      * we could be unsetting someone else's bit.
      */
-    if (atrans->type == UBIK_WRITETRANS && dbase->flags & DBWRITING) {
+    if (atrans->type == UBIK_WRITETRANS && dbase->dbFlags & DBWRITING) {
 	UBIK_VERSION_LOCK;
-	dbase->flags &= ~DBWRITING;
+	dbase->dbFlags &= ~DBWRITING;
 	UBIK_VERSION_UNLOCK;
     } else {
 	dbase->readers--;
@@ -1027,7 +990,7 @@ udisk_end(struct ubik_trans *atrans)
 #ifdef AFS_PTHREAD_ENV
     opr_cv_broadcast(&dbase->flags_cond);
 #else
-    LWP_NoYieldSignal(&dbase->flags);
+    LWP_NoYieldSignal(&dbase->dbFlags);
 #endif
     return 0;
 }
diff --git a/src/ubik/liboafs_ubik.la.sym b/src/ubik/liboafs_ubik.la.sym
index 679bad64a..4ca62db9f 100644
--- a/src/ubik/liboafs_ubik.la.sym
+++ b/src/ubik/liboafs_ubik.la.sym
@@ -2,7 +2,6 @@ EndDISK_GetFile
 StartDISK_GetFile
 VOTE_Debug
 VOTE_DebugOld
-VOTE_GetSyncSite
 VOTE_SDebug
 VOTE_SDebugOld
 VOTE_XDebug
diff --git a/src/ubik/lock.c b/src/ubik/lock.c
index ba368937f..c13837522 100644
--- a/src/ubik/lock.c
+++ b/src/ubik/lock.c
@@ -17,6 +17,7 @@
 # include <opr/lock.h>
 #endif
 #include <lock.h>
+#include <afs/afsutil.h>
 
 #define UBIK_INTERNALS 1
 #include "ubik.h"
@@ -83,13 +84,13 @@ ulock_getLock(struct ubik_trans *atrans, int atype, int await)
     }
 
     if (atrans->locktype != 0) {
-	ubik_print("Ubik: Internal Error: attempted to take lock twice\n");
+	ViceLog(0, ("Ubik: Internal Error: attempted to take lock twice\n"));
 	abort();
     }
 
 /*
- *ubik_print("Ubik: DEBUG: Thread 0x%x request %s lock\n", lwp_cpptr,
- *	     ((atype == LOCKREAD) ? "READ" : "WRITE"));
+ *ViceLog(0, ("Ubik: DEBUG: Thread 0x%x request %s lock\n", lwp_cpptr,
+ *	     ((atype == LOCKREAD) ? "READ" : "WRITE")));
  */
 
     /* Check if the lock would would block */
@@ -120,8 +121,8 @@ ulock_getLock(struct ubik_trans *atrans, int atype, int await)
     atrans->locktype = atype;
 
 /*
- *ubik_print("Ubik: DEBUG: Thread 0x%x took %s lock\n", lwp_cpptr,
- *	     ((atype == LOCKREAD) ? "READ" : "WRITE"));
+ *ViceLog(0, ("Ubik: DEBUG: Thread 0x%x took %s lock\n", lwp_cpptr,
+ *	     ((atype == LOCKREAD) ? "READ" : "WRITE")));
  */
     return 0;
 }
@@ -133,8 +134,8 @@ void
 ulock_relLock(struct ubik_trans *atrans)
 {
     if (atrans->locktype == LOCKWRITE && (atrans->flags & TRREADWRITE)) {
-	ubik_print("Ubik: Internal Error: unlocking write lock with "
-	           "TRREADWRITE?\n");
+	ViceLog(0, ("Ubik: Internal Error: unlocking write lock with "
+	           "TRREADWRITE?\n"));
 	abort();
     }
 
@@ -147,8 +148,8 @@ ulock_relLock(struct ubik_trans *atrans)
     }
 
 /*
- *ubik_print("Ubik: DEBUG: Thread 0x%x %s unlock\n", lwp_cpptr,
- *	     ((atrans->locktype == LOCKREAD) ? "READ" : "WRITE"));
+ *ViceLog(0, ("Ubik: DEBUG: Thread 0x%x %s unlock\n", lwp_cpptr,
+ *	     ((atrans->locktype == LOCKREAD) ? "READ" : "WRITE")));
  */
 
     atrans->locktype = 0;
diff --git a/src/ubik/phys.c b/src/ubik/phys.c
index 4ce6a226d..b35ae4af2 100644
--- a/src/ubik/phys.c
+++ b/src/ubik/phys.c
@@ -34,8 +34,41 @@ static struct fdcache {
     int refCount;
 } fdcache[MAXFDCACHE];
 
+/* Cache a stdio handle for a given database file, for uphys_buf_append
+ * operations. We only use buf_append for one file at a time, so only try to
+ * cache a single file handle, since that's all we should need. */
+static struct buf_fdcache {
+    int fileID;
+    FILE *stream;
+} buf_fdcache;
+
 static char pbuffer[1024];
 
+static int uphys_buf_flush(struct ubik_dbase *adbase, afs_int32 afid);
+
+#ifdef HAVE_PIO
+# define uphys_pread  pread
+# define uphys_pwrite pwrite
+#else /* HAVE_PIO */
+static_inline ssize_t
+uphys_pread(int fd, void *buf, size_t nbyte, off_t offset)
+{
+    if (lseek(fd, offset, 0) < 0) {
+	return -1;
+    }
+    return read(fd, buf, nbyte);
+}
+
+static_inline ssize_t
+uphys_pwrite(int fd, void *buf, size_t nbyte, off_t offset)
+{
+    if (lseek(fd, offset, 0) < 0) {
+	return -1;
+    }
+    return write(fd, buf, nbyte);
+}
+#endif /* !HAVE_PIO */
+
 /*!
  * \warning Beware, when using this function, of the header in front of most files.
  */
@@ -62,7 +95,6 @@ uphys_open(struct ubik_dbase *adbase, afs_int32 afid)
     /* scan file descr cache */
     for (tfd = fdcache, i = 0; i < MAXFDCACHE; i++, tfd++) {
 	if (afid == tfd->fileID && tfd->refCount == 0) {	/* don't use open fd */
-	    lseek(tfd->fd, 0, 0);	/* reset ptr just like open would have */
 	    tfd->refCount++;
 	    return tfd->fd;
 	}
@@ -159,7 +191,6 @@ uphys_stat(struct ubik_dbase *adbase, afs_int32 afid, struct ubik_stat *astat)
     if (code < 0) {
 	return code;
     }
-    astat->mtime = tstat.st_mtime;
     code = tstat.st_size - HDRSIZE;
     if (code < 0)
 	astat->size = 0;
@@ -178,12 +209,7 @@ uphys_read(struct ubik_dbase *adbase, afs_int32 afile,
     fd = uphys_open(adbase, afile);
     if (fd < 0)
 	return -1;
-    code = lseek(fd, apos + HDRSIZE, 0);
-    if (code < 0) {
-	uphys_close(fd);
-	return -1;
-    }
-    code = read(fd, abuffer, alength);
+    code = uphys_pread(fd, abuffer, alength, apos + HDRSIZE);
     uphys_close(fd);
     return code;
 }
@@ -199,12 +225,7 @@ uphys_write(struct ubik_dbase *adbase, afs_int32 afile,
     fd = uphys_open(adbase, afile);
     if (fd < 0)
 	return -1;
-    code = lseek(fd, apos + HDRSIZE, 0);
-    if (code < 0) {
-	uphys_close(fd);
-	return -1;
-    }
-    length = write(fd, abuffer, alength);
+    length = uphys_pwrite(fd, abuffer, alength, apos + HDRSIZE);
     code = uphys_close(fd);
     if (code)
 	return -1;
@@ -217,6 +238,13 @@ uphys_truncate(struct ubik_dbase *adbase, afs_int32 afile,
 	       afs_int32 asize)
 {
     afs_int32 code, fd;
+
+    /* Just in case there's memory-buffered data for this file, flush it before
+     * truncating. */
+    if (uphys_buf_flush(adbase, afile) < 0) {
+        return UIOERROR;
+    }
+
     fd = uphys_open(adbase, afile);
     if (fd < 0)
 	return UNOENT;
@@ -250,7 +278,7 @@ uphys_getlabel(struct ubik_dbase *adbase, afs_int32 afile,
     fd = uphys_open(adbase, afile);
     if (fd < 0)
 	return UNOENT;
-    code = read(fd, &thdr, sizeof(thdr));
+    code = uphys_pread(fd, &thdr, sizeof(thdr), 0);
     if (code != sizeof(thdr)) {
 	uphys_close(fd);
 	return EIO;
@@ -281,7 +309,7 @@ uphys_setlabel(struct ubik_dbase *adbase, afs_int32 afile,
     thdr.version.counter = htonl(aversion->counter);
     thdr.magic = htonl(UBIK_MAGIC);
     thdr.size = htons(HDRSIZE);
-    code = write(fd, &thdr, sizeof(thdr));
+    code = uphys_pwrite(fd, &thdr, sizeof(thdr), 0);
     fsync(fd);			/* preserve over crash */
     uphys_close(fd);
     if (code != sizeof(thdr)) {
@@ -294,6 +322,12 @@ int
 uphys_sync(struct ubik_dbase *adbase, afs_int32 afile)
 {
     afs_int32 code, fd;
+
+    /* Flush any in-memory data, so we can sync it. */
+    if (uphys_buf_flush(adbase, afile) < 0) {
+        return -1;
+    }
+
     fd = uphys_open(adbase, afile);
     code = fsync(fd);
     uphys_close(fd);
@@ -318,3 +352,58 @@ uphys_invalidate(struct ubik_dbase *adbase, afs_int32 afid)
 	}
     }
 }
+
+static FILE *
+uphys_buf_append_open(struct ubik_dbase *adbase, afs_int32 afid)
+{
+    /* If we have a cached handle open for this file, just return it. */
+    if (buf_fdcache.stream && buf_fdcache.fileID == afid) {
+        return buf_fdcache.stream;
+    }
+
+    /* Otherwise, close the existing handle, and open a new handle for the
+     * given file. */
+
+    if (buf_fdcache.stream) {
+        fclose(buf_fdcache.stream);
+    }
+
+    snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d", adbase->pathName,
+	     (afid<0)?"SYS":"", (afid<0)?-afid:afid);
+    buf_fdcache.stream = fopen(pbuffer, "a");
+    buf_fdcache.fileID = afid;
+    return buf_fdcache.stream;
+}
+
+static int
+uphys_buf_flush(struct ubik_dbase *adbase, afs_int32 afid)
+{
+    if (buf_fdcache.stream && buf_fdcache.fileID == afid) {
+        int code = fflush(buf_fdcache.stream);
+        if (code) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
+/* Append the given data to the given database file, allowing the data to be
+ * buffered in memory. */
+int
+uphys_buf_append(struct ubik_dbase *adbase, afs_int32 afid, void *adata,
+                 afs_int32 alength)
+{
+    FILE *stream;
+    size_t code;
+
+    stream = uphys_buf_append_open(adbase, afid);
+    if (!stream) {
+        return -1;
+    }
+
+    code = fwrite(adata, alength, 1, stream);
+    if (code != 1) {
+        return -1;
+    }
+    return alength;
+}
diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c
index 0f3e714a7..a53aa596a 100644
--- a/src/ubik/recovery.c
+++ b/src/ubik/recovery.c
@@ -66,10 +66,6 @@ int
 urecovery_ResetState(void)
 {
     urecovery_state = 0;
-#if !defined(AFS_PTHREAD_ENV)
-    /*  No corresponding LWP_WaitProcess found anywhere for this -- klm */
-    LWP_NoYieldSignal(&urecovery_state);
-#endif
     return 0;
 }
 
@@ -86,10 +82,6 @@ int
 urecovery_LostServer(struct ubik_server *ts)
 {
     ubeacon_ReinitServer(ts);
-#if !defined(AFS_PTHREAD_ENV)
-    /*  No corresponding LWP_WaitProcess found anywhere for this -- klm */
-    LWP_NoYieldSignal(&urecovery_state);
-#endif
     return 0;
 }
 
@@ -107,7 +99,7 @@ urecovery_AllBetter(struct ubik_dbase *adbase, int areadAny)
 {
     afs_int32 rcode;
 
-    ubik_dprint_25("allbetter checking\n");
+    ViceLog(25, ("allbetter checking\n"));
     rcode = 0;
 
 
@@ -130,7 +122,7 @@ urecovery_AllBetter(struct ubik_dbase *adbase, int areadAny)
 	rcode = 1;
     }
 
-    ubik_dprint_25("allbetter: returning %d\n", rcode);
+    ViceLog(25, ("allbetter: returning %d\n", rcode));
     return rcode;
 }
 
@@ -141,9 +133,17 @@ int
 urecovery_AbortAll(struct ubik_dbase *adbase)
 {
     struct ubik_trans *tt;
+    int reads = 0, writes = 0;
+
     for (tt = adbase->activeTrans; tt; tt = tt->next) {
+	if (tt->type == UBIK_WRITETRANS)
+	    writes++;
+	else
+	    reads++;
 	udisk_abort(tt);
     }
+    ViceLog(0, ("urecovery_AbortAll: just aborted %d read and %d write transactions\n",
+		    reads, writes));
     return 0;
 }
 
@@ -159,8 +159,20 @@ urecovery_CheckTid(struct ubik_tid *atid, int abortalways)
 	if (atid->epoch != ubik_currentTrans->tid.epoch
 	    || atid->counter > ubik_currentTrans->tid.counter || abortalways) {
 	    /* don't match, abort it */
+	    int endit = 0;
 	    /* If the thread is not waiting for lock - ok to end it */
 	    if (ubik_currentTrans->locktype != LOCKWAIT) {
+		endit = 1;
+	    }
+
+	    ViceLog(0, ("urecovery_CheckTid: Aborting/ending bad remote "
+			"transaction. (tx %d.%d, atid %d.%d, abortalways %d, "
+			"endit %d)\n",
+			ubik_currentTrans->tid.epoch,
+			ubik_currentTrans->tid.counter,
+			atid->epoch, atid->counter,
+			abortalways, endit));
+	    if (endit) {
 		udisk_end(ubik_currentTrans);
 	    }
 	    ubik_currentTrans = (struct ubik_trans *)0;
@@ -244,8 +256,8 @@ ReplayLog(struct ubik_dbase *adbase)
 	    /* otherwise, skip over the data bytes, too */
 	    tpos += ntohl(buffer[2]) + 3 * sizeof(afs_int32);
 	} else {
-	    ubik_print("corrupt log opcode (%d) at position %d\n", opcode,
-		       tpos);
+	    ViceLog(0, ("corrupt log opcode (%d) at position %d\n", opcode,
+		       tpos));
 	    break;		/* corrupt log! */
 	}
     }
@@ -280,9 +292,9 @@ ReplayLog(struct ubik_dbase *adbase)
 		code = (*adbase->setlabel) (adbase, 0, &version);
 		if (code)
 		    return code;
-		ubik_print("Successfully replayed log for interrupted "
+		ViceLog(0, ("Successfully replayed log for interrupted "
 		           "transaction; db version is now %ld.%ld\n",
-		           (long) version.epoch, (long) version.counter);
+		           (long) version.epoch, (long) version.counter));
 		logIsGood = 1;
 		break;		/* all done now */
 	    } else if (opcode == LOGTRUNCATE) {
@@ -338,8 +350,8 @@ ReplayLog(struct ubik_dbase *adbase)
 		    len -= thisSize;
 		}
 	    } else {
-		ubik_print("corrupt log opcode (%d) at position %d\n",
-			   opcode, tpos);
+		ViceLog(0, ("corrupt log opcode (%d) at position %d\n",
+			   opcode, tpos));
 		break;		/* corrupt log! */
 	    }
 	}
@@ -349,7 +361,7 @@ ReplayLog(struct ubik_dbase *adbase)
 	    if (code)
 		return code;
 	} else {
-	    ubik_print("Log read error on pass 2\n");
+	    ViceLog(0, ("Log read error on pass 2\n"));
 	    return UBADLOG;
 	}
     }
@@ -382,11 +394,6 @@ InitializeDB(struct ubik_dbase *adbase)
 	    adbase->version.counter = 0;
 	    (*adbase->setlabel) (adbase, 0, &adbase->version);
 	}
-#ifdef AFS_PTHREAD_ENV
-	opr_cv_broadcast(&adbase->version_cond);
-#else
-	LWP_NoYieldSignal(&adbase->version);
-#endif
 	UBIK_VERSION_UNLOCK;
     }
     return 0;
@@ -465,7 +472,9 @@ urecovery_Interact(void *dummy)
     int fd = -1;
     afs_int32 pass;
 
-    afs_pthread_setname_self("recovery");
+    memset(pbuffer, 0, sizeof(pbuffer));
+
+    opr_threadname_set("recovery");
 
     /* otherwise, begin interaction */
     urecovery_state = 0;
@@ -480,7 +489,7 @@ urecovery_Interact(void *dummy)
 	IOMGR_Select(0, 0, 0, 0, &tv);
 #endif
 
-	ubik_dprint("recovery running in state %x\n", urecovery_state);
+	ViceLog(5, ("recovery running in state %x\n", urecovery_state));
 
 	/* Every 30 seconds, check all the down servers and mark them
 	 * as up if they respond. When a server comes up or found to
@@ -601,25 +610,28 @@ urecovery_Interact(void *dummy)
 	    /* we don't have the best version; we should fetch it. */
 	    urecovery_AbortAll(ubik_dbase);
 
+	    pbuffer[0] = '\0';
+
 	    /* Rx code to do the Bulk fetch */
 	    file = 0;
 	    offset = 0;
 	    UBIK_ADDR_LOCK;
 	    rxcall = rx_NewCall(bestServer->disk_rxcid);
 
-	    ubik_print("Ubik: Synchronize database with server %s\n",
-		       afs_inet_ntoa_r(bestServer->addr[0], hoststr));
+	    ViceLog(0, ("Ubik: Synchronize database: receive (via GetFile) "
+			"from server %s begin\n",
+		       afs_inet_ntoa_r(bestServer->addr[0], hoststr)));
 	    UBIK_ADDR_UNLOCK;
 
 	    code = StartDISK_GetFile(rxcall, file);
 	    if (code) {
-		ubik_dprint("StartDiskGetFile failed=%d\n", code);
+		ViceLog(0, ("StartDiskGetFile failed=%d\n", code));
 		goto FetchEndCall;
 	    }
 	    nbytes = rx_Read(rxcall, (char *)&length, sizeof(afs_int32));
 	    length = ntohl(length);
 	    if (nbytes != sizeof(afs_int32)) {
-		ubik_dprint("Rx-read length error=%d\n", code = BULK_ERROR);
+		ViceLog(0, ("Rx-read length error=%d\n", BULK_ERROR));
 		code = EIO;
 		goto FetchEndCall;
 	    }
@@ -630,7 +642,7 @@ urecovery_Interact(void *dummy)
 	    code = (*ubik_dbase->setlabel) (ubik_dbase, file, &tversion);
 	    UBIK_VERSION_UNLOCK;
 	    if (code) {
-		ubik_dprint("setlabel io error=%d\n", code);
+		ViceLog(0, ("setlabel io error=%d\n", code));
 		goto FetchEndCall;
 	    }
 	    snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP",
@@ -656,7 +668,7 @@ urecovery_Interact(void *dummy)
 #endif
 		nbytes = rx_Read(rxcall, tbuffer, tlen);
 		if (nbytes != tlen) {
-		    ubik_dprint("Rx-read bulk error=%d\n", code = BULK_ERROR);
+		    ViceLog(0, ("Rx-read bulk error=%d\n", BULK_ERROR));
 		    code = EIO;
 		    close(fd);
 		    goto FetchEndCall;
@@ -715,7 +727,9 @@ urecovery_Interact(void *dummy)
 #endif
 	    }
 	    if (code) {
-		unlink(pbuffer);
+		if (pbuffer[0] != '\0') {
+		    unlink(pbuffer);
+		}
 		/*
 		 * We will effectively invalidate the old data forever now.
 		 * Unclear if we *should* but we do.
@@ -724,18 +738,20 @@ urecovery_Interact(void *dummy)
 		ubik_dbase->version.epoch = 0;
 		ubik_dbase->version.counter = 0;
 		UBIK_VERSION_UNLOCK;
-		ubik_print("Ubik: Synchronize database failed (error = %d)\n",
-			   code);
+		ViceLog(0,
+		    ("Ubik: Synchronize database: receive (via GetFile) "
+		    "from server %s failed (error = %d)\n",
+		    afs_inet_ntoa_r(bestServer->addr[0], hoststr), code));
 	    } else {
-		ubik_print("Ubik: Synchronize database completed\n");
+		ViceLog(0,
+		    ("Ubik: Synchronize database: receive (via GetFile) "
+		    "from server %s complete, version: %d.%d\n",
+		    afs_inet_ntoa_r(bestServer->addr[0], hoststr),
+		    ubik_dbase->version.epoch, ubik_dbase->version.counter));
+
 		urecovery_state |= UBIK_RECHAVEDB;
 	    }
 	    udisk_Invalidate(ubik_dbase, 0);	/* data has changed */
-#ifdef AFS_PTHREAD_ENV
-	    opr_cv_broadcast(&ubik_dbase->version_cond);
-#else
-	    LWP_NoYieldSignal(&ubik_dbase->version);
-#endif
 	}
 	if (!(urecovery_state & UBIK_RECHAVEDB)) {
 	    DBRELE(ubik_dbase);
@@ -756,11 +772,6 @@ urecovery_Interact(void *dummy)
 		(*ubik_dbase->setlabel) (ubik_dbase, 0, &ubik_dbase->version);
 	    UBIK_VERSION_UNLOCK;
 	    udisk_Invalidate(ubik_dbase, 0);	/* data may have changed */
-#ifdef AFS_PTHREAD_ENV
-	    opr_cv_broadcast(&ubik_dbase->version_cond);
-#else
-	    LWP_NoYieldSignal(&ubik_dbase->version);
-#endif
 	}
 
 	/* Check the other sites and send the database to them if they
@@ -779,11 +790,11 @@ urecovery_Interact(void *dummy)
 	     * the write-lock above if there is a write transaction in progress,
 	     * but then, it won't hurt to check, will it?
 	     */
-	    if (ubik_dbase->flags & DBWRITING) {
+	    if (ubik_dbase->dbFlags & DBWRITING) {
 		struct timeval tv;
 		int safety = 0;
 		long cur_usec = 50000;
-		while ((ubik_dbase->flags & DBWRITING) && (safety < 500)) {
+		while ((ubik_dbase->dbFlags & DBWRITING) && (safety < 500)) {
 		    DBRELE(ubik_dbase);
 		    /* sleep for a little while */
 		    tv.tv_sec = 0;
@@ -806,16 +817,23 @@ urecovery_Interact(void *dummy)
 		UBIK_BEACON_LOCK;
 		if (!ts->up) {
 		    UBIK_BEACON_UNLOCK;
-		    ubik_dprint("recovery cannot send version to %s\n",
-				afs_inet_ntoa_r(inAddr.s_addr, hoststr));
+		    /* It would be nice to have this message at loglevel
+		     * 0 as well, but it will log once every 4s for each
+		     * down server while in this recovery state.  This
+		     * should only be changed to loglevel 0 if it is
+		     * also rate-limited.
+		     */
+		    ViceLog(5, ("recovery cannot send version to %s\n",
+				afs_inet_ntoa_r(inAddr.s_addr, hoststr)));
 		    dbok = 0;
 		    continue;
 		}
 		UBIK_BEACON_UNLOCK;
-		ubik_dprint("recovery sending version to %s\n",
-			    afs_inet_ntoa_r(inAddr.s_addr, hoststr));
+
 		if (vcmp(ts->version, ubik_dbase->version) != 0) {
-		    ubik_dprint("recovery stating local database\n");
+		    ViceLog(0, ("Synchronize database: send (via SendFile) "
+				"to server %s begin\n",
+			    afs_inet_ntoa_r(inAddr.s_addr, hoststr)));
 
 		    /* Rx code to do the Bulk Store */
 		    code = (*ubik_dbase->stat) (ubik_dbase, 0, &ubikstat);
@@ -829,8 +847,8 @@ urecovery_Interact(void *dummy)
 			    StartDISK_SendFile(rxcall, file, length,
 					       &ubik_dbase->version);
 			if (code) {
-			    ubik_dprint("StartDiskSendFile failed=%d\n",
-					code);
+			    ViceLog(0, ("StartDiskSendFile failed=%d\n",
+					code));
 			    goto StoreEndCall;
 			}
 			while (length > 0) {
@@ -841,14 +859,14 @@ urecovery_Interact(void *dummy)
 				(*ubik_dbase->read) (ubik_dbase, file,
 						     tbuffer, offset, tlen);
 			    if (nbytes != tlen) {
-				ubik_dprint("Local disk read error=%d\n",
-					    code = UIOERROR);
+				code = UIOERROR;
+				ViceLog(0, ("Local disk read error=%d\n", code));
 				goto StoreEndCall;
 			    }
 			    nbytes = rx_Write(rxcall, tbuffer, tlen);
 			    if (nbytes != tlen) {
-				ubik_dprint("Rx-write bulk error=%d\n", code =
-					    BULK_ERROR);
+				code = BULK_ERROR;
+				ViceLog(0, ("Rx-write bulk error=%d\n", code));
 				goto StoreEndCall;
 			    }
 			    offset += tlen;
@@ -858,12 +876,24 @@ urecovery_Interact(void *dummy)
 		      StoreEndCall:
 			code = rx_EndCall(rxcall, code);
 		    }
+
 		    if (code == 0) {
 			/* we set a new file, process its header */
 			ts->version = ubik_dbase->version;
 			ts->currentDB = 1;
-		    } else
+			ViceLog(0,
+			    ("Ubik: Synchronize database: send (via SendFile) "
+			    "to server %s complete, version: %d.%d\n",
+			    afs_inet_ntoa_r(inAddr.s_addr, hoststr),
+			    ts->version.epoch, ts->version.counter));
+
+		    } else {
 			dbok = 0;
+			ViceLog(0,
+			    ("Ubik: Synchronize database: send (via SendFile) "
+			     "to server %s failed (error = %d)\n",
+			    afs_inet_ntoa_r(inAddr.s_addr, hoststr), code));
+		    }
 		} else {
 		    /* mark file up to date */
 		    ts->currentDB = 1;
@@ -874,7 +904,7 @@ urecovery_Interact(void *dummy)
 	}
 	DBRELE(ubik_dbase);
     }
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 /*!
@@ -936,8 +966,8 @@ DoProbe(struct ubik_server *server)
 	connSuccess = conns[success_i];
 	strcpy(buffer, afs_inet_ntoa_r(server->addr[0], hoststr));
 
-	ubik_print("ubik:server %s is back up: will be contacted through %s\n",
-	     buffer, afs_inet_ntoa_r(addr, hoststr));
+	ViceLog(0, ("ubik:server %s is back up: will be contacted through %s\n",
+	     buffer, afs_inet_ntoa_r(addr, hoststr)));
 	UBIK_ADDR_UNLOCK;
     }
 
@@ -947,8 +977,8 @@ DoProbe(struct ubik_server *server)
 	    rx_DestroyConnection(conns[i]);
 
     if (!connSuccess)
-	ubik_dprint("ubik:server %s still down\n",
-		    afs_inet_ntoa_r(server->addr[0], hoststr));
+	ViceLog(5, ("ubik:server %s still down\n",
+		    afs_inet_ntoa_r(server->addr[0], hoststr)));
 
     if (connSuccess)
 	return 0;		/* success */
diff --git a/src/ubik/remote.c b/src/ubik/remote.c
index d3d0f138a..6874c6a75 100644
--- a/src/ubik/remote.c
+++ b/src/ubik/remote.c
@@ -396,45 +396,72 @@ SDISK_GetFile(struct rx_call *rxcall, afs_int32 file,
     char tbuffer[256];
     afs_int32 tlen;
     afs_int32 length;
+    struct rx_peer *tpeer;
+    struct rx_connection *tconn;
+    afs_uint32 otherHost = 0;
+    char hoststr[16];
 
     if ((code = ubik_CheckAuth(rxcall))) {
 	return code;
     }
+
+    tconn = rx_ConnectionOf(rxcall);
+    tpeer = rx_PeerOf(tconn);
+    otherHost = ubikGetPrimaryInterfaceAddr(rx_HostOf(tpeer));
+    ViceLog(0, ("Ubik: Synchronize database: send (via GetFile) "
+		"to server %s begin\n",
+	       afs_inet_ntoa_r(otherHost, hoststr)));
+
     dbase = ubik_dbase;
     DBHOLD(dbase);
     code = (*dbase->stat) (dbase, file, &ubikstat);
     if (code < 0) {
-	DBRELE(dbase);
-	return code;
+	ViceLog(0, ("database stat() error:%d\n", code));
+	goto failed;
     }
     length = ubikstat.size;
     tlen = htonl(length);
     code = rx_Write(rxcall, (char *)&tlen, sizeof(afs_int32));
     if (code != sizeof(afs_int32)) {
-	DBRELE(dbase);
-	ubik_dprint("Rx-write length error=%d\n", code);
-	return BULK_ERROR;
+	ViceLog(0, ("Rx-write length error=%d\n", code));
+	code = BULK_ERROR;
+	goto failed;
     }
     offset = 0;
     while (length > 0) {
 	tlen = (length > sizeof(tbuffer) ? sizeof(tbuffer) : length);
 	code = (*dbase->read) (dbase, file, tbuffer, offset, tlen);
 	if (code != tlen) {
-	    DBRELE(dbase);
-	    ubik_dprint("read failed error=%d\n", code);
-	    return UIOERROR;
+	    ViceLog(0, ("read failed error=%d\n", code));
+	    code = UIOERROR;
+	    goto failed;
 	}
 	code = rx_Write(rxcall, tbuffer, tlen);
 	if (code != tlen) {
-	    DBRELE(dbase);
-	    ubik_dprint("Rx-write length error=%d\n", code);
-	    return BULK_ERROR;
+	    ViceLog(0, ("Rx-write data error=%d\n", code));
+	    code = BULK_ERROR;
+	    goto failed;
 	}
 	length -= tlen;
 	offset += tlen;
     }
     code = (*dbase->getlabel) (dbase, file, version);	/* return the dbase, too */
+    if (code)
+	ViceLog(0, ("getlabel error=%d\n", code));
+
+ failed:
     DBRELE(dbase);
+    if (code) {
+	ViceLog(0,
+	    ("Ubik: Synchronize database: send (via GetFile) to "
+	     "server %s failed (error = %d)\n",
+	     afs_inet_ntoa_r(otherHost, hoststr), code));
+    } else {
+	ViceLog(0,
+	    ("Ubik: Synchronize database: send (via GetFile) to "
+	     "server %s complete, version: %d.%d\n",
+	    afs_inet_ntoa_r(otherHost, hoststr), version->epoch, version->counter));
+    }
     return code;
 }
 
@@ -450,6 +477,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     int tlen;
     struct rx_peer *tpeer;
     struct rx_connection *tconn;
+    afs_uint32 syncHost = 0;
     afs_uint32 otherHost = 0;
     char hoststr[16];
     char pbuffer[1028];
@@ -463,8 +491,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     pbuffer[0] = '\0';
 
     if ((code = ubik_CheckAuth(rxcall))) {
-	DBHOLD(dbase);
-	goto failed;
+	return code;
     }
 
     /* next, we do a sanity check to see if the guy sending us the database is
@@ -477,15 +504,18 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
      * screwup.  Thus, we only object if we're sure we know who the sync site
      * is, and it ain't the guy talking to us.
      */
-    offset = uvote_GetSyncSite();
+    syncHost = uvote_GetSyncSite();
     tconn = rx_ConnectionOf(rxcall);
     tpeer = rx_PeerOf(tconn);
     otherHost = ubikGetPrimaryInterfaceAddr(rx_HostOf(tpeer));
-    if (offset && offset != otherHost) {
+    if (syncHost && syncHost != otherHost) {
 	/* we *know* this is the wrong guy */
-	code = USYNC;
-	DBHOLD(dbase);
-	goto failed;
+        char sync_hoststr[16];
+	ViceLog(0,
+	    ("Ubik: Refusing synchronization with server %s since it is not the sync-site (%s).\n",
+	     afs_inet_ntoa_r(otherHost, hoststr),
+	     afs_inet_ntoa_r(syncHost, sync_hoststr)));
+	return USYNC;
     }
 
     DBHOLD(dbase);
@@ -493,8 +523,8 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     /* abort any active trans that may scribble over the database */
     urecovery_AbortAll(dbase);
 
-    ubik_print("Ubik: Synchronize database with server %s\n",
-	       afs_inet_ntoa_r(otherHost, hoststr));
+    ViceLog(0, ("Ubik: Synchronize database: receive (via SendFile) from server %s begin\n",
+	       afs_inet_ntoa_r(otherHost, hoststr)));
 
     offset = 0;
     UBIK_VERSION_LOCK;
@@ -506,10 +536,12 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
     fd = open(pbuffer, O_CREAT | O_RDWR | O_TRUNC, 0600);
     if (fd < 0) {
 	code = errno;
+	ViceLog(0, ("Open error=%d\n", code));
 	goto failed_locked;
     }
     code = lseek(fd, HDRSIZE, 0);
     if (code != HDRSIZE) {
+	ViceLog(0, ("lseek error=%d\n", code));
 	close(fd);
 	goto failed_locked;
     }
@@ -524,7 +556,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 #endif
 	code = rx_Read(rxcall, tbuffer, tlen);
 	if (code != tlen) {
-	    ubik_dprint("Rx-read length error=%d\n", code);
+	    ViceLog(0, ("Rx-read length error=%d\n", code));
 	    code = BULK_ERROR;
 	    close(fd);
 	    goto failed;
@@ -532,7 +564,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 	code = write(fd, tbuffer, tlen);
 	pass++;
 	if (code != tlen) {
-	    ubik_dprint("write failed error=%d\n", code);
+	    ViceLog(0, ("write failed tlen=%d, error=%d\n", tlen, code));
 	    code = UIOERROR;
 	    close(fd);
 	    goto failed;
@@ -541,8 +573,10 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 	length -= tlen;
     }
     code = close(fd);
-    if (code)
+    if (code) {
+	ViceLog(0, ("close failed error=%d\n", code));
 	goto failed;
+    }
 
     /* sync data first, then write label and resync (resync done by setlabel call).
      * This way, good label is only on good database. */
@@ -571,11 +605,6 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file,
 #endif
     memcpy(&ubik_dbase->version, avers, sizeof(struct ubik_version));
     udisk_Invalidate(dbase, file);	/* new dbase, flush disk buffers */
-#ifdef AFS_PTHREAD_ENV
-    opr_Assert(pthread_cond_broadcast(&dbase->version_cond) == 0);
-#else
-    LWP_NoYieldSignal(&dbase->version);
-#endif
 
 failed_locked:
     UBIK_VERSION_UNLOCK;
@@ -592,12 +621,16 @@ failed:
 	    (*dbase->setlabel) (dbase, file, &tversion);
 	    UBIK_VERSION_UNLOCK;
 	}
-	ubik_print
-	    ("Ubik: Synchronize database with server %s failed (error = %d)\n",
-	     afs_inet_ntoa_r(otherHost, hoststr), code);
+	ViceLog(0,
+	    ("Ubik: Synchronize database: receive (via SendFile) from "
+	     "server %s failed (error = %d)\n",
+	    afs_inet_ntoa_r(otherHost, hoststr), code));
     } else {
 	uvote_set_dbVersion(*avers);
-	ubik_print("Ubik: Synchronize database completed\n");
+	ViceLog(0,
+	    ("Ubik: Synchronize database: receive (via SendFile) from "
+	     "server %s complete, version: %d.%d\n",
+	    afs_inet_ntoa_r(otherHost, hoststr), avers->epoch, avers->counter));
     }
     DBRELE(dbase);
     return code;
@@ -661,9 +694,9 @@ SDISK_UpdateInterfaceAddr(struct rx_call *rxcall,
     /* if (probableMatch) */
     /* inconsistent addresses in CellServDB */
     if (!probableMatch || found) {
-	ubik_print("Inconsistent Cell Info from server:\n");
+	ViceLog(0, ("Inconsistent Cell Info from server:\n"));
 	for (i = 0; i < UBIK_MAX_INTERFACE_ADDR && inAddr->hostAddr[i]; i++)
-	    ubik_print("... %s\n", afs_inet_ntoa_r(htonl(inAddr->hostAddr[i]), hoststr));
+	    ViceLog(0, ("... %s\n", afs_inet_ntoa_r(htonl(inAddr->hostAddr[i]), hoststr)));
 	fflush(stdout);
 	fflush(stderr);
 	printServerInfo();
@@ -675,9 +708,9 @@ SDISK_UpdateInterfaceAddr(struct rx_call *rxcall,
     for (i = 1; i < UBIK_MAX_INTERFACE_ADDR; i++)
 	ts->addr[i] = htonl(inAddr->hostAddr[i]);
 
-    ubik_print("ubik: A Remote Server has addresses:\n");
+    ViceLog(0, ("ubik: A Remote Server has addresses:\n"));
     for (i = 0; i < UBIK_MAX_INTERFACE_ADDR && ts->addr[i]; i++)
-	ubik_print("... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr));
+	ViceLog(0, ("... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr)));
 
     UBIK_ADDR_UNLOCK;
 
@@ -702,11 +735,11 @@ printServerInfo(void)
     int i, j = 1;
     char hoststr[16];
 
-    ubik_print("Local CellServDB:\n");
+    ViceLog(0, ("Local CellServDB:\n"));
     for (ts = ubik_servers; ts; ts = ts->next, j++) {
-	ubik_print("  Server %d:\n", j);
+	ViceLog(0, ("  Server %d:\n", j));
 	for (i = 0; (i < UBIK_MAX_INTERFACE_ADDR) && ts->addr[i]; i++)
-	    ubik_print("  ... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr));
+	    ViceLog(0, ("  ... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr)));
     }
 }
 
diff --git a/src/ubik/ubik.c b/src/ubik/ubik.c
index bc04f9972..6adf9dd3f 100644
--- a/src/ubik/ubik.c
+++ b/src/ubik/ubik.c
@@ -23,6 +23,7 @@
 #include <lock.h>
 #include <rx/rx.h>
 #include <afs/cellconfig.h>
+#include <afs/afsutil.h>
 
 
 #define UBIK_INTERNALS
@@ -149,7 +150,7 @@ Quorum_EndIO(struct ubik_trans *atrans, struct rx_connection *aconn)
 static int
 ContactQuorum_iterate(struct ubik_trans *atrans, int aflags, struct ubik_server **ts,
 			 struct rx_connection **conn, afs_int32 *rcode,
-			 afs_int32 *okcalls, afs_int32 code)
+			 afs_int32 *okcalls, afs_int32 code, const char *procname)
 {
     if (!*ts) {
 	/* Initial call - start iterating over servers */
@@ -162,6 +163,8 @@ ContactQuorum_iterate(struct ubik_trans *atrans, int aflags, struct ubik_server
 	    Quorum_EndIO(atrans, *conn);
 	    *conn = NULL;
 	    if (code) {		/* failure */
+		char hoststr[16];
+
 		*rcode = code;
 		UBIK_BEACON_LOCK;
 		(*ts)->up = 0;		/* mark as down now; beacons will no longer be sent */
@@ -169,6 +172,8 @@ ContactQuorum_iterate(struct ubik_trans *atrans, int aflags, struct ubik_server
 		UBIK_BEACON_UNLOCK;
 		(*ts)->currentDB = 0;
 		urecovery_LostServer(*ts);	/* tell recovery to try to resend dbase later */
+		ViceLog(0, ("Server %s is marked down due to %s code %d\n",
+			    afs_inet_ntoa_r((*ts)->addr[0], hoststr), procname, *rcode));
 	    } else {		/* success */
 		if (!(*ts)->isClone)
 		    (*okcalls)++;	/* count up how many worked */
@@ -222,26 +227,26 @@ ContactQuorum_rcode(int okcalls, afs_int32 rcode)
  * because it is sent the sync count along with the beacon message that
  * marks it as \b really up (\p beaconSinceDown).
  */
-afs_int32
+static afs_int32
 ContactQuorum_NoArguments(afs_int32 (*proc)(struct rx_connection *, ubik_tid *),
-	       		  struct ubik_trans *atrans, int aflags)
+			  struct ubik_trans *atrans, int aflags, const char *procname)
 {
     struct ubik_server *ts = NULL;
     afs_int32 code = 0, rcode, okcalls;
     struct rx_connection *conn;
     int done;
 
-    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     while (!done) {
 	if (conn)
 	    code = (*proc)(conn, &atrans->tid);
-	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     }
     return ContactQuorum_rcode(okcalls, rcode);
 }
 
 
-afs_int32
+static afs_int32
 ContactQuorum_DISK_Lock(struct ubik_trans *atrans, int aflags,afs_int32 file,
 			afs_int32 position, afs_int32 length, afs_int32 type)
 {
@@ -249,37 +254,18 @@ ContactQuorum_DISK_Lock(struct ubik_trans *atrans, int aflags,afs_int32 file,
     afs_int32 code = 0, rcode, okcalls;
     struct rx_connection *conn;
     int done;
+    char *procname = "DISK_Lock";
 
-    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     while (!done) {
 	if (conn)
 	    code = DISK_Lock(conn, &atrans->tid, file, position, length, type);
-	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     }
     return ContactQuorum_rcode(okcalls, rcode);
 }
 
-
-afs_int32
-ContactQuorum_DISK_Write(struct ubik_trans *atrans, int aflags,
-			 afs_int32 file, afs_int32 position, bulkdata *data)
-{
-    struct ubik_server *ts = NULL;
-    afs_int32 code = 0, rcode, okcalls;
-    struct rx_connection *conn;
-    int done;
-
-    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
-    while (!done) {
-	if (conn)
-	    code = DISK_Write(conn, &atrans->tid, file, position, data);
-	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
-    }
-    return ContactQuorum_rcode(okcalls, rcode);
-}
-
-
-afs_int32
+static afs_int32
 ContactQuorum_DISK_Truncate(struct ubik_trans *atrans, int aflags,
 			    afs_int32 file, afs_int32 length)
 {
@@ -287,18 +273,19 @@ ContactQuorum_DISK_Truncate(struct ubik_trans *atrans, int aflags,
     afs_int32 code = 0, rcode, okcalls;
     struct rx_connection *conn;
     int done;
+    char *procname = "DISK_Truncate";
 
-    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     while (!done) {
 	if (conn)
 	    code = DISK_Truncate(conn, &atrans->tid, file, length);
-	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     }
     return ContactQuorum_rcode(okcalls, rcode);
 }
 
 
-afs_int32
+static afs_int32
 ContactQuorum_DISK_WriteV(struct ubik_trans *atrans, int aflags,
 			  iovec_wrt * io_vector, iovec_buf *io_buffer)
 {
@@ -306,10 +293,12 @@ ContactQuorum_DISK_WriteV(struct ubik_trans *atrans, int aflags,
     afs_int32 code = 0, rcode, okcalls;
     struct rx_connection *conn;
     int done;
+    char *procname = "DISK_WriteV";
 
-    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     while (!done) {
 	if (conn) {
+	    procname = "DISK_WriteV";	/* in case previous fallback to DISK_Write */
 	    code = DISK_WriteV(conn, &atrans->tid, io_vector, io_buffer);
 	    if ((code <= -450) && (code > -500)) {
 		/* An RPC interface mismatch (as defined in comerr/error_msg.c).
@@ -322,6 +311,7 @@ ContactQuorum_DISK_WriteV(struct ubik_trans *atrans, int aflags,
 		bulkdata tcbs;
 		afs_int32 i, offset;
 
+		procname = "DISK_Write";	/* for accurate error msg, if any */
 		for (i = 0, offset = 0; i < io_vector->iovec_wrt_len; i++) {
 		    /* Sanity check for going off end of buffer */
 		    if ((offset + iovec[i].length) > io_buffer->iovec_buf_len) {
@@ -338,7 +328,7 @@ ContactQuorum_DISK_WriteV(struct ubik_trans *atrans, int aflags,
 		}
 	    }
 	}
-	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     }
     return ContactQuorum_rcode(okcalls, rcode);
 }
@@ -353,12 +343,13 @@ ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans, int aflags,
     afs_int32 code = 0, rcode, okcalls;
     struct rx_connection *conn;
     int done;
+    char *procname = "DISK_SetVersion";
 
-    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+    done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     while (!done) {
 	if (conn)
 	    code = DISK_SetVersion(conn, &atrans->tid, OldVersion, NewVersion);
-	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+	done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
     }
     return ContactQuorum_rcode(okcalls, rcode);
 }
@@ -415,11 +406,8 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
 
     initialize_U_error_table();
 
-    tdb = malloc(sizeof(struct ubik_dbase));
+    tdb = calloc(1, sizeof(*tdb));
     tdb->pathName = strdup(pathName);
-    tdb->activeTrans = (struct ubik_trans *)0;
-    memset(&tdb->version, 0, sizeof(struct ubik_version));
-    memset(&tdb->cachedVersion, 0, sizeof(struct ubik_version));
 #ifdef AFS_PTHREAD_ENV
     opr_mutex_init(&tdb->versionLock);
     opr_mutex_init(&beacon_globals.beacon_lock);
@@ -430,7 +418,6 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
     Lock_Init(&tdb->versionLock);
 #endif
     Lock_Init(&tdb->cache_lock);
-    tdb->flags = 0;
     tdb->read = uphys_read;
     tdb->write = uphys_write;
     tdb->truncate = uphys_truncate;
@@ -440,13 +427,11 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
     tdb->getlabel = uphys_getlabel;
     tdb->setlabel = uphys_setlabel;
     tdb->getnfiles = uphys_getnfiles;
-    tdb->readers = 0;
-    tdb->tidCounter = tdb->writeTidCounter = 0;
+    tdb->buffered_append = uphys_buf_append;
     *dbase = tdb;
     ubik_dbase = tdb;		/* for now, only one db per server; can fix later when we have names for the other dbases */
 
 #ifdef AFS_PTHREAD_ENV
-    opr_cv_init(&tdb->version_cond);
     opr_cv_init(&tdb->flags_cond);
 #endif /* AFS_PTHREAD_ENV */
 
@@ -499,7 +484,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
 	rx_NewService(0, VOTE_SERVICE_ID, "VOTE", ubik_sc, numClasses,
 		      VOTE_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
-	ubik_dprint("Could not create VOTE rx service!\n");
+	ViceLog(0, ("Could not create VOTE rx service!\n"));
 	return -1;
     }
     rx_SetMinProcs(tservice, 2);
@@ -509,7 +494,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort,
 	rx_NewService(0, DISK_SERVICE_ID, "DISK", ubik_sc, numClasses,
 		      DISK_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
-	ubik_dprint("Could not create DISK rx service!\n");
+	ViceLog(0, ("Could not create DISK rx service!\n"));
 	return -1;
     }
     rx_SetMinProcs(tservice, 2);
@@ -612,9 +597,9 @@ BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode,
 	/* it's not safe to use ubik_BeginTransReadAnyWrite without a
 	 * cache-syncing function; fall back to ubik_BeginTransReadAny,
 	 * which is safe but slower */
-	ubik_print("ubik_BeginTransReadAnyWrite called, but "
+	ViceLog(0, ("ubik_BeginTransReadAnyWrite called, but "
 	           "ubik_SyncWriterCacheProc not set; pretending "
-	           "ubik_BeginTransReadAny was called instead\n");
+	           "ubik_BeginTransReadAny was called instead\n"));
 	readAny = 1;
     }
 
@@ -633,12 +618,12 @@ BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode,
      * don't know how to restore one without possibly picking up some data from the other. */
     if (transMode == UBIK_WRITETRANS) {
 	/* if we're writing already, wait */
-	while (dbase->flags & DBWRITING) {
+	while (dbase->dbFlags & DBWRITING) {
 #ifdef AFS_PTHREAD_ENV
 	    opr_cv_wait(&dbase->flags_cond, &dbase->versionLock);
 #else
 	    DBRELE(dbase);
-	    LWP_WaitProcess(&dbase->flags);
+	    LWP_WaitProcess(&dbase->dbFlags);
 	    DBHOLD(dbase);
 #endif
 	}
@@ -682,11 +667,12 @@ BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode,
 
     if (transMode == UBIK_WRITETRANS) {
 	/* next try to start transaction on appropriate number of machines */
-	code = ContactQuorum_NoArguments(DISK_Begin, tt, CCheckSyncAdvertised);
+	code = ContactQuorum_NoArguments(DISK_Begin, tt, CCheckSyncAdvertised, "DISK_Begin");
 	if (code) {
 	    /* we must abort the operation */
 	    udisk_abort(tt);
-	    ContactQuorum_NoArguments(DISK_Abort, tt, 0); /* force aborts to the others */
+	    /* force aborts to the others */
+	    ContactQuorum_NoArguments(DISK_Abort, tt, 0, "DISK_Abort");
 	    udisk_end(tt);
 	    DBRELE(dbase);
 	    return code;
@@ -776,7 +762,7 @@ ubik_AbortTrans(struct ubik_trans *transPtr)
     }
 
     /* now it is safe to try remote abort */
-    code = ContactQuorum_NoArguments(DISK_Abort, transPtr, 0);
+    code = ContactQuorum_NoArguments(DISK_Abort, transPtr, 0, "DISK_Abort");
     code2 = udisk_abort(transPtr);
     udisk_end(transPtr);
     DBRELE(dbase);
@@ -873,7 +859,7 @@ ubik_EndTrans(struct ubik_trans *transPtr)
 
 	ReleaseWriteLock(&dbase->cache_lock);
 
-	code = ContactQuorum_NoArguments(DISK_Commit, transPtr, CStampVersion);
+	code = ContactQuorum_NoArguments(DISK_Commit, transPtr, CStampVersion, "DISK_Commit");
 
     } else {
 	memset(&dbase->cachedVersion, 0, sizeof(struct ubik_version));
@@ -887,7 +873,7 @@ ubik_EndTrans(struct ubik_trans *transPtr)
 	 * we lose.  If we contact a majority of sites, then we won't be here: contacting
 	 * a majority guarantees commit, since it guarantees that one dude will be a
 	 * member of the next quorum. */
-	ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0);
+	ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0, "DISK_ReleaseLocks");
 	udisk_end(transPtr);
 	DBRELE(dbase);
 	goto error;
@@ -905,7 +891,7 @@ ubik_EndTrans(struct ubik_trans *transPtr)
 	 * to us, or timeout.  Put safety check in anyway */
 	if (now - realStart > 10 * BIGTIME) {
 	    ubik_stats.escapes++;
-	    ubik_print("ubik escaping from commit wait\n");
+	    ViceLog(0, ("ubik escaping from commit wait\n"));
 	    break;
 	}
 	for (ts = ubik_servers; ts; ts = ts->next) {
@@ -942,7 +928,7 @@ ubik_EndTrans(struct ubik_trans *transPtr)
      * The transaction is committed anyway, since we succeeded in contacting a quorum
      * at the start (when invoking the DiskCommit function).
      */
-    ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0);
+    ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0, "DISK_ReleaseLocks");
 
   success:
     udisk_end(transPtr);
@@ -1025,7 +1011,8 @@ ubik_Flush(struct ubik_trans *transPtr)
 				  &transPtr->iovec_data);
     if (code) {
 	udisk_abort(transPtr);
-	ContactQuorum_NoArguments(DISK_Abort, transPtr, 0); /* force aborts to the others */
+	/* force aborts to the others */
+	ContactQuorum_NoArguments(DISK_Abort, transPtr, 0, "DISK_Abort");
 	transPtr->iovec_info.iovec_wrt_len = 0;
 	transPtr->iovec_data.iovec_buf_len = 0;
 	ERROR_EXIT(code);
@@ -1201,7 +1188,8 @@ ubik_Truncate(struct ubik_trans *transPtr, afs_int32 length)
     if (code) {
 	/* we must abort the operation */
 	udisk_abort(transPtr);
-	ContactQuorum_NoArguments(DISK_Abort, transPtr, 0); /* force aborts to the others */
+	/* force aborts to the others */
+	ContactQuorum_NoArguments(DISK_Abort, transPtr, 0, "DISK_Abort");
 	ERROR_EXIT(code);
     }
 
@@ -1248,7 +1236,8 @@ ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen,
 	if (code) {
 	    /* we must abort the operation */
 	    udisk_abort(atrans);
-	    ContactQuorum_NoArguments(DISK_Abort, atrans, 0); /* force aborts to the others */
+	    /* force aborts to the others */
+	    ContactQuorum_NoArguments(DISK_Abort, atrans, 0, "DISK_Abort");
 	    ERROR_EXIT(code);
 	}
     }
@@ -1258,43 +1247,6 @@ ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen,
     return error;
 }
 
-/*!
- * \brief utility to wait for a version # to change
- */
-int
-ubik_WaitVersion(struct ubik_dbase *adatabase,
-		 struct ubik_version *aversion)
-{
-    DBHOLD(adatabase);
-    while (1) {
-	/* wait until version # changes, and then return */
-	if (vcmp(*aversion, adatabase->version) != 0) {
-	    DBRELE(adatabase);
-	    return 0;
-	}
-#ifdef AFS_PTHREAD_ENV
-	opr_cv_wait(&adatabase->version_cond, &adatabase->versionLock);
-#else
-	DBRELE(adatabase);
-	LWP_WaitProcess(&adatabase->version);	/* same vers, just wait */
-	DBHOLD(adatabase);
-#endif
-    }
-}
-
-/*!
- * \brief utility to get the version of the dbase a transaction is dealing with
- */
-int
-ubik_GetVersion(struct ubik_trans *atrans,
-		struct ubik_version *avers)
-{
-    DBHOLD(atrans->dbase);
-    *avers = atrans->dbase->version;
-    DBRELE(atrans->dbase);
-    return 0;
-}
-
 /*!
  * \brief Facility to simplify database caching.
  * \return zero if last trans was done on the local server and was successful.
@@ -1392,13 +1344,13 @@ panic(char *format, ...)
     va_list ap;
 
     va_start(ap, format);
-    ubik_print("Ubik PANIC:\n");
-    ubik_vprint(format, ap);
+    ViceLog(0, ("Ubik PANIC:\n"));
+    vViceLog(0, (format, ap));
     va_end(ap);
 
     abort();
-    ubik_print("BACK FROM ABORT\n");	/* shouldn't come back */
-    exit(1);			/* never know, though  */
+    AFS_UNREACHED(ViceLog(0, ("BACK FROM ABORT\n")));
+    AFS_UNREACHED(exit(1));
 }
 
 /*!
diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h
index 9454cacb4..cfd12f790 100644
--- a/src/ubik/ubik.p.h
+++ b/src/ubik/ubik.p.h
@@ -123,7 +123,6 @@ struct ubik_trunc {
 
 struct ubik_stat {
     afs_int32 size;
-    afs_int32 mtime;
 };
 
 #include <lock.h>		/* just to make sure we've got this */
@@ -145,7 +144,7 @@ struct ubik_dbase {
 #endif
     afs_int32 tidCounter;	/*!< last RW or RO trans tid counter */
     afs_int32 writeTidCounter;	/*!< last write trans tid counter */
-    afs_int32 flags;		/*!< flags */
+    afs_int32 dbFlags;		/*!< flags */
     /* physio procedures */
     int (*read) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
 		 afs_int32 apos, afs_int32 alength);
@@ -160,11 +159,11 @@ struct ubik_dbase {
     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 */
+    int (*buffered_append)(struct ubik_dbase *adbase, afs_int32 afid, void *adata, afs_int32 alength);
     short readers;		/*!< number of current read transactions */
     struct ubik_version cachedVersion;	/*!< version of caller's cached data */
     struct Lock cache_lock; /*!< protects cached application data */
 #ifdef AFS_PTHREAD_ENV
-    pthread_cond_t version_cond;    /*!< condition variable to manage changes to version */
     pthread_cond_t flags_cond;      /*!< condition variable to manage changes to flags */
 #endif
 };
@@ -418,7 +417,9 @@ struct addr_data {
 
 /*!
  * \brief The version lock protects the structure member, as well as
- * the database version, flags, tidCounter, writeTidCounter
+ * the database version, dbFlags, tidCounter, writeTidCounter. Reading these
+ * values can be done while holding either UBIK_VERSION_LOCK or DBHOLD. Writing
+ * these requires holding both locks.
  */
 struct version_data {
 #ifdef AFS_PTHREAD_ENV
@@ -449,6 +450,8 @@ extern int uphys_setlabel(struct ubik_dbase *adbase, afs_int32 afile,
 extern int uphys_sync(struct ubik_dbase *adbase, afs_int32 afile);
 extern void uphys_invalidate(struct ubik_dbase *adbase,
 			     afs_int32 afid);
+extern int uphys_buf_append(struct ubik_dbase *adbase, afs_int32 afid,
+                            void *buf, afs_int32 alength);
 
 /*! \name recovery.c */
 extern int urecovery_ResetState(void);
@@ -463,31 +466,6 @@ extern int DoProbe(struct ubik_server *server);
 /*\}*/
 
 /*! \name ubik.c */
-extern afs_int32 ContactQuorum_NoArguments(afs_int32 (*proc)
-						       (struct rx_connection *,
-							ubik_tid *),
-					   struct ubik_trans *atrans,
-					   int aflags);
-
-extern afs_int32 ContactQuorum_DISK_Lock(struct ubik_trans *atrans,
-					 int aflags,
-					 afs_int32 file, afs_int32 position,
-					 afs_int32 length, afs_int32 type);
-
-extern afs_int32 ContactQuorum_DISK_Write(struct ubik_trans *atrans,
-					  int aflags,
-					  afs_int32 file, afs_int32 position,
-					  bulkdata *data);
-
-extern afs_int32 ContactQuorum_DISK_Truncate(struct ubik_trans *atrans,
-					     int aflags,
-					     afs_int32 file, afs_int32 length);
-
-extern afs_int32 ContactQuorum_DISK_WriteV(struct ubik_trans *atrans,
-					   int aflags,
-					   iovec_wrt * io_vector,
-					   iovec_buf *io_buffer);
-
 extern afs_int32 ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans,
 					       int aflags,
 					       ubik_version *OldVersion,
@@ -548,17 +526,6 @@ extern void ulock_Debug(struct ubik_debug *aparm);
 extern int uvote_ShouldIRun(void);
 extern afs_int32 uvote_GetSyncSite(void);
 extern int uvote_Init(void);
-extern void ubik_vprint(const char *format, va_list ap)
-    AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0);
-
-extern void ubik_print(const char *format, ...)
-    AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
-
-extern void ubik_dprint(const char *format, ...)
-    AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
-
-extern void ubik_dprint_25(const char *format, ...)
-    AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
 extern struct vote_data vote_globals;
 extern void uvote_set_dbVersion(struct ubik_version);
 extern int uvote_eq_dbVersion(struct ubik_version);
@@ -606,10 +573,6 @@ extern int ubik_Truncate(struct ubik_trans *transPtr,
 			 afs_int32 length);
 extern int ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos,
 			afs_int32 alen, int atype);
-extern int ubik_WaitVersion(struct ubik_dbase *adatabase,
-			    struct ubik_version *aversion);
-extern int ubik_GetVersion(struct ubik_trans *atrans,
-			   struct ubik_version *avers);
 extern int ubik_CheckCache(struct ubik_trans *atrans,
                            ubik_updatecache_func check,
                            void *rock);
@@ -624,6 +587,15 @@ extern int ubik_ClientInit(struct rx_connection **serverconns,
 			   struct ubik_client **aclient);
 extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient);
 extern struct rx_connection *ubik_RefreshConn(struct rx_connection *tc);
+
+struct ubik_callrock_info {
+    struct rx_connection *conn;
+};
+typedef afs_int32 (*ubik_callrock_func)(struct ubik_callrock_info *info, void *rock);
+extern afs_int32 ubik_CallRock(struct ubik_client *aclient, afs_int32 aflags,
+			       ubik_callrock_func proc, void *rock)
+			       AFS_NONNULL((3));
+
 #ifdef UBIK_LEGACY_CALLITER
 extern afs_int32 ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
 			       afs_int32 aflags, int *apos, long p1, long p2,
@@ -647,6 +619,7 @@ extern int ubik_ParseServerList(int argc, char **argv, afs_uint32 *ahost,
 
 struct rx_securityClass;
 struct afsconf_dir;
+typedef int (*ugen_secproc_func)(struct rx_securityClass *, afs_int32);
 extern int ugen_ClientInitCell(struct afsconf_dir *dir,
 			       struct afsconf_cell *info,
 			       int secFlags,
@@ -660,15 +633,13 @@ extern int ugen_ClientInitServer(const char *confDir, char *cellName,
 			         afs_uint32 port);
 extern int ugen_ClientInitFlags(const char *confDir, char *cellName,
 				int secFlags, struct ubik_client **uclientp,
-				int (*secproc) (struct rx_securityClass *,
-						afs_int32),
+				ugen_secproc_func secproc,
 				int maxservers, char *serviceid,
 				int deadtime);
 extern afs_int32 ugen_ClientInit(int noAuthFlag, const char *confDir,
 				 char *cellName, afs_int32 sauth,
 				 struct ubik_client **uclientp,
-				 int (*secproc) (struct rx_securityClass *sc,
-					 	 afs_int32 scIndex),
+				 ugen_secproc_func secproc,
 				 char *funcName,
 				 afs_int32 gen_rxkad_level,
 				 afs_int32 maxservers, char *serviceid,
diff --git a/src/ubik/ubik_int.xg b/src/ubik/ubik_int.xg
index 0d6e202e4..78b2517d0 100644
--- a/src/ubik/ubik_int.xg
+++ b/src/ubik/ubik_int.xg
@@ -181,7 +181,12 @@ DebugOld	(OUT ubik_debug_old *db) = VOTE_DEBUG_OLD;
 SDebugOld	(IN afs_int32 which,
 		OUT ubik_sdebug_old *db) = VOTE_SDEBUG_OLD;
 
-GetSyncSite	(IN afs_int32 *site) = VOTE_GETSYNCSITE;
+/*
+ * The output of GetSyncSite (site) is mistakenly marked as an input argument.
+ * As a result, this RPC can't be used to find the current sync-site.
+ */
+
+/* GetSyncSite	(IN afs_int32 *site) = VOTE_GETSYNCSITE; */
 
 Debug		(OUT ubik_debug *db) = VOTE_DEBUG;
 
diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c
index 450b1531e..2e6f672f4 100644
--- a/src/ubik/ubikclient.c
+++ b/src/ubik/ubikclient.c
@@ -345,62 +345,6 @@ static int synccount = 0;
 
 
 
-/*!
- * \brief Call this after getting back a #UNOTSYNC.
- *
- * \note Getting a #UNOTSYNC error code back does \b not guarantee
- * that there is a sync site yet elected.  However, if there is a sync
- * site out there somewhere, and you're trying an operation that
- * requires a sync site, ubik will return #UNOTSYNC, indicating the
- * operation won't work until you find a sync site
- */
-static int
-try_GetSyncSite(struct ubik_client *aclient, afs_int32 apos)
-{
-    struct rx_peer *rxp;
-    afs_int32 code;
-    int i;
-    afs_int32 thisHost, newHost;
-    struct rx_connection *tc;
-    short origLevel;
-
-    origLevel = aclient->initializationState;
-
-    /* get this conn */
-    tc = aclient->conns[apos];
-    if (tc && rx_ConnError(tc)) {
-	aclient->conns[apos] = (tc = ubik_RefreshConn(tc));
-    }
-    if (!tc) {
-	return -1;
-    }
-
-    /* now see if we can find the sync site host */
-    code = VOTE_GetSyncSite(tc, &newHost);
-    if (aclient->initializationState != origLevel) {
-	return -1;		/* somebody did a ubik_ClientInit */
-    }
-
-    if (!code && newHost) {
-	newHost = htonl(newHost);	/* convert back to network order */
-
-	/*
-	 * position count at the appropriate slot in the client
-	 * structure and retry. If we can't find in slot, we'll just
-	 * continue through the whole list
-	 */
-	for (i = 0; i < MAXSERVERS; i++) {
-	    rxp = rx_PeerOf(aclient->conns[i]);
-	    thisHost = rx_HostOf(rxp);
-	    if (!thisHost) {
-		return -1;
-	    } else if (thisHost == newHost) {
-		return i;	/* we were told to use this one */
-	    }
-	}
-    }
-    return -1;
-}
 
 #define NEED_LOCK 1
 #define NO_LOCK 0
@@ -497,9 +441,7 @@ ubik_Call_New(int (*aproc) (), struct ubik_client *aclient,
 {
     afs_int32 code, rcode;
     afs_int32 count;
-    afs_int32 temp;
     int pass;
-    int stepBack;
     short origLevel;
 
     LOCK_UBIK_CLIENT(aclient);
@@ -510,7 +452,6 @@ ubik_Call_New(int (*aproc) (), struct ubik_client *aclient,
     /* Do two passes. First pass only checks servers known running */
     for (aflags |= UPUBIKONLY, pass = 0; pass < 2;
 	 pass++, aflags &= ~UPUBIKONLY) {
-	stepBack = 0;
 	count = 0;
 	while (1) {
 	    code =
@@ -525,17 +466,7 @@ ubik_Call_New(int (*aproc) (), struct ubik_client *aclient,
 	    }
 	    rcode = code;	/* remember code from last good call */
 
-	    if (code == UNOTSYNC) {	/* means this requires a sync site */
-		if (aclient->conns[3]) {	/* don't bother unless 4 or more srv */
-		    temp = try_GetSyncSite(aclient, count);
-		    if (aclient->initializationState != origLevel) {
-			goto restart;	/* somebody did a ubik_ClientInit */
-		    }
-		    if ((temp >= 0) && ((temp > count) || (stepBack++ <= 2))) {
-			count = temp;	/* generally try to make progress */
-		    }
-		}
-	    } else if ((code >= 0) && (code != UNOQUORUM)) {
+	    if ((code >= 0) && (code != UNOQUORUM) && (code != UNOTSYNC)) {
 		UNLOCK_UBIK_CLIENT(aclient);
 		return code;	/* success or global error condition */
 	    }
@@ -556,8 +487,8 @@ ubik_Call(int (*aproc) (), struct ubik_client *aclient,
 	  long p5, long p6, long p7, long p8, long p9, long p10,
 	  long p11, long p12, long p13, long p14, long p15, long p16)
 {
-    afs_int32 rcode, code, newHost, thisHost, i, count;
-    int chaseCount, pass, needsync, inlist, j;
+    afs_int32 rcode, newHost, thisHost, i, count;
+    int pass, needsync, inlist, j;
     struct rx_connection *tc;
     struct rx_peer *rxp;
     short origLevel;
@@ -574,7 +505,7 @@ ubik_Call(int (*aproc) (), struct ubik_client *aclient,
   restart:
     origLevel = aclient->initializationState;
     rcode = UNOSERVERS;
-    chaseCount = inlist = needsync = 0;
+    inlist = needsync = 0;
 
     LOCK_UCLNT_CACHE;
     for (j = 0; ((j < SYNCCOUNT) && calls_needsync[j]); j++) {
@@ -597,24 +528,6 @@ ubik_Call(int (*aproc) (), struct ubik_client *aclient,
 		if (aclient->syncSite) {
 		    newHost = aclient->syncSite;	/* already in network order */
 		    aclient->syncSite = 0;	/* Will reset if it works */
-		} else if (aclient->conns[3]) {
-		    /* If there are fewer than four db servers in a cell,
-		     * there's no point in making the GetSyncSite call.
-		     * At best, it's a wash. At worst, it results in more
-		     * RPCs than you would otherwise make.
-		     */
-		    tc = aclient->conns[count];
-		    if (tc && rx_ConnError(tc)) {
-			aclient->conns[count] = tc = ubik_RefreshConn(tc);
-		    }
-		    if (!tc)
-			break;
-		    code = VOTE_GetSyncSite(tc, &newHost);
-		    if (aclient->initializationState != origLevel)
-			goto restart;	/* somebody did a ubik_ClientInit */
-		    if (code)
-			newHost = 0;
-		    newHost = htonl(newHost);	/* convert to network order */
 		} else {
 		    newHost = 0;
 		}
@@ -629,8 +542,6 @@ ubik_Call(int (*aproc) (), struct ubik_client *aclient,
 			if (!thisHost)
 			    break;
 			if (thisHost == newHost) {
-			    if (chaseCount++ > 2)
-				break;	/* avoid loop asking */
 			    count = i;	/* this index is the sync site */
 			    break;
 			}
@@ -688,3 +599,102 @@ ubik_Call(int (*aproc) (), struct ubik_client *aclient,
     UNLOCK_UBIK_CLIENT(aclient);
     return rcode;
 }
+
+afs_int32
+ubik_CallRock(struct ubik_client *aclient, afs_int32 aflags,
+	      ubik_callrock_func proc, void *rock)
+{
+    afs_int32 rcode, newHost, thisHost, i, _ucount;
+    int pass, needsync;
+    struct rx_connection *tc;
+    struct rx_peer *rxp;
+    short origLevel;
+
+    if (!aclient)
+	return UNOENT;
+    LOCK_UBIK_CLIENT(aclient);
+
+ restart:
+    origLevel = aclient->initializationState;
+    rcode = UNOSERVERS;
+    needsync = 0;
+
+    /*
+     * First  pass, we try all servers that are up.
+     * Second pass, we try all servers.
+     */
+    for (pass = 0; pass < 2; pass++) {
+	/* For each entry in our servers list */
+	for (_ucount = 0;; _ucount++) {
+	    struct ubik_callrock_info info;
+	    if (needsync) {
+		/* Need a sync site. Lets try to quickly find it */
+		if (aclient->syncSite) {
+		    newHost = aclient->syncSite;	/* already in network order */
+		    aclient->syncSite = 0;      /* Will reset if it works */
+		} else {
+		    newHost = 0;
+		}
+		if (newHost) {
+		    /*
+		     * position count at the appropriate slot in the client
+		     * structure and retry. If we can't find in slot, we'll
+		     * just continue through the whole list
+		     */
+		    for (i = 0; i < MAXSERVERS && aclient->conns[i]; i++) {
+			rxp = rx_PeerOf(aclient->conns[i]);
+			thisHost = rx_HostOf(rxp);
+			if (!thisHost)
+			    break;
+			if (thisHost == newHost) {
+			    _ucount = i;  /* this index is the sync site */
+			    break;
+			}
+		    }
+		}
+	    }
+	    /*needsync */
+	    tc = aclient->conns[_ucount];
+	    if (tc && rx_ConnError(tc)) {
+		aclient->conns[_ucount] = tc = ubik_RefreshConn(tc);
+	    }
+	    if (!tc)
+		break;
+
+	    if ((pass == 0) && (aclient->states[_ucount] & CFLastFailed)) {
+		continue;       /* this guy's down */
+	    }
+
+	    memset(&info, 0, sizeof(info));
+	    info.conn = tc;
+	    rcode = (*proc)(&info, rock);
+
+	    if (aclient->initializationState != origLevel) {
+		/* somebody did a ubik_ClientInit */
+		if (rcode)
+		    goto restart;       /* call failed */
+		else
+		    goto done;  /* call suceeded */
+	    }
+	    if (rcode < 0) {    /* network errors */
+		aclient->states[_ucount] |= CFLastFailed; /* Mark server down */
+	    } else if (rcode == UNOTSYNC) {
+		needsync = 1;
+	    } else if (rcode != UNOQUORUM) {
+		/* either misc ubik code, or misc appl code, or success. */
+		aclient->states[_ucount] &= ~CFLastFailed;	/* mark server up*/
+		goto done;      /* all done */
+	    }
+	}
+    }
+
+ done:
+    if (needsync) {
+	if (!rcode) {		/* Remember the sync site - cmd successful */
+	    rxp = rx_PeerOf(aclient->conns[_ucount]);
+	    aclient->syncSite = rx_HostOf(rxp);
+	}
+    }
+    UNLOCK_UBIK_CLIENT(aclient);
+    return rcode;
+}
diff --git a/src/ubik/uinit.c b/src/ubik/uinit.c
index 3a1997d9e..1467cfb06 100644
--- a/src/ubik/uinit.c
+++ b/src/ubik/uinit.c
@@ -32,7 +32,7 @@
 static int
 internal_client_init(struct afsconf_dir *dir, struct afsconf_cell *info,
 		     int secFlags, struct ubik_client **uclientp,
-		     int (*secproc) (struct rx_securityClass *, afs_int32),
+		     ugen_secproc_func secproc,
 		     int maxservers, const char *serviceid, int deadtime,
 		     afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
 {
@@ -115,7 +115,7 @@ ugen_ClientInitCell(struct afsconf_dir *dir, struct afsconf_cell *info,
 static int
 internal_client_init_dir(const char *confDir, char *cellName, int secFlags,
 		      struct ubik_client **uclientp,
-		      int (*secproc) (struct rx_securityClass *, afs_int32),
+		      ugen_secproc_func secproc,
 		      afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
 		      afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
 {
@@ -144,9 +144,8 @@ internal_client_init_dir(const char *confDir, char *cellName, int secFlags,
 
     code = afsconf_GetCellInfo(dir, cellName, serviceid, &info);
     if (code) {
-	fprintf(stderr, "%s: can't find cell %s's hosts in %s/%s\n",
-		progname?progname:"<unknown>", cellName, confDir,
-		AFSDIR_CELLSERVDB_FILE);
+	fprintf(stderr, "%s: can't find cell %s's hosts in %s\n",
+		progname?progname:"<unknown>", cellName, dir->cellservDB);
 	afsconf_Close(dir);
 	return code;
     }
@@ -175,7 +174,7 @@ ugen_ClientInitServer(const char *confDir, char *cellName, int secFlags,
 int
 ugen_ClientInitFlags(const char *confDir, char *cellName, int secFlags,
 		     struct ubik_client **uclientp,
-	             int (*secproc) (struct rx_securityClass *, afs_int32),
+	             ugen_secproc_func secproc,
 		     int maxservers, char *serviceid, int deadtime)
 {
     return internal_client_init_dir(confDir, cellName, secFlags, uclientp,
@@ -189,7 +188,7 @@ ugen_ClientInitFlags(const char *confDir, char *cellName, int secFlags,
 afs_int32
 ugen_ClientInit(int noAuthFlag, const char *confDir, char *cellName, afs_int32 sauth,
 	       struct ubik_client **uclientp,
-	       int (*secproc) (struct rx_securityClass *, afs_int32),
+	       ugen_secproc_func secproc,
 	       char *funcName, afs_int32 gen_rxkad_level,
 	       afs_int32 maxservers, char *serviceid, afs_int32 deadtime,
 	       afs_uint32 server, afs_uint32 port, afs_int32 usrvid)
diff --git a/src/ubik/utst_server.c b/src/ubik/utst_server.c
index fda298b80..7a1ae4db2 100644
--- a/src/ubik/utst_server.c
+++ b/src/ubik/utst_server.c
@@ -318,9 +318,6 @@ main(int argc, char **argv)
     }
 
     sc[0] = rxnull_NewServerSecurityObject();
-#if 0
-    sc[1] = rxvab_NewServerSecurityObject("applexx", 0);
-#endif
     tservice = rx_NewService(0, USER_SERVICE_ID, "Sample", sc, 1 /*2 */ ,
 			     SAMPLE_ExecuteRequest);
     if (tservice == (struct rx_service *)0) {
diff --git a/src/ubik/vote.c b/src/ubik/vote.c
index 51b9220a7..daa1dc5a5 100644
--- a/src/ubik/vote.c
+++ b/src/ubik/vote.c
@@ -112,6 +112,10 @@ uvote_ShouldIRun(void)
     afs_int32 now;
     int code = 1; /* default to yes */
 
+    if (amIClone) {
+	return 0;		/* if we cannot be the sync-site, do not ask for votes */
+    }
+
     UBIK_VOTE_LOCK;
     now = FT_ApproxTime();
     if (BIGTIME + vote_globals.ubik_lastYesTime < now)
@@ -197,8 +201,8 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate,
 	/* This is the identifier that ubik uses. */
 	otherHost = ubikGetPrimaryInterfaceAddr(otherHost);
 	if (!otherHost) {
-	    ubik_dprint("Received beacon from unknown host %s\n",
-			afs_inet_ntoa_r(rx_HostOf(rxp), hoststr));
+	    ViceLog(5, ("Received beacon from unknown host %s\n",
+			afs_inet_ntoa_r(rx_HostOf(rxp), hoststr)));
 	    return 0;		/* I don't know about you: vote no */
 	}
 	for (ts = ubik_servers; ts; ts = ts->next) {
@@ -206,7 +210,7 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate,
 		break;
 	}
 	if (!ts)
-	    ubik_dprint("Unknown host %x has sent a beacon\n", otherHost);
+	    ViceLog(0, ("Unknown host %x has sent a beacon\n", otherHost));
 	if (ts && ts->isClone)
 	    isClone = 1;
     } else {
@@ -214,8 +218,8 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate,
 	isClone = amIClone;
     }
 
-    ubik_dprint("Received beacon type %d from host %s\n", astate,
-		afs_inet_ntoa_r(otherHost, hoststr));
+    ViceLog(5, ("Received beacon type %d from host %s\n", astate,
+		afs_inet_ntoa_r(otherHost, hoststr)));
 
     /* compute the lowest server we've heard from.  We'll try to only vote for
      * this dude if we don't already have a synchronization site.  Also, don't
@@ -265,9 +269,8 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate,
 	vote_globals.syncTime = now;
     } else if (vote_globals.syncTime + BIGTIME < now) {
 	if (vote_globals.syncHost) {
-	    ubik_dprint
-		("Ubik: Lost contact with sync-site %s (NOT in quorum)\n",
-		 afs_inet_ntoa_r(vote_globals.syncHost, hoststr));
+	    ViceLog(0, ("Ubik: Lost contact with sync-site %s (NOT in quorum)\n",
+		 afs_inet_ntoa_r(vote_globals.syncHost, hoststr)));
 	}
 	vote_globals.syncHost = 0;
     }
@@ -312,9 +315,12 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate,
 	if ((vote_globals.ubik_lastYesTime + BIGTIME < now) || (otherHost != vote_globals.lastYesHost)
 	    || (vote_globals.lastYesState != astate)) {
 	    /* A new vote or a change in the vote or changed quorum */
-	    ubik_dprint("Ubik: vote 'yes' for %s %s\n",
+	    /* XXX This should be at loglevel 0, but the conditionals
+	     * ought to be reworked first to prevent excessive logging.
+	     */
+	    ViceLog(5, ("Ubik: vote 'yes' for %s %s\n",
 			afs_inet_ntoa_r(otherHost, hoststr),
-			(astate ? "(in quorum)" : "(NOT in quorum)"));
+			(astate ? "(in quorum)" : "(NOT in quorum)")));
 	}
 
 	vote = now;		/* vote yes */
@@ -399,6 +405,7 @@ SVOTE_Debug(struct rx_call * rxcall, struct ubik_debug * aparm)
     /* fill in the basic debug structure.  Note the the RPC protocol transfers,
      * integers in host order. */
 
+    memset(aparm, 0, sizeof(*aparm));
     aparm->now = FT_ApproxTime();
     aparm->lastYesTime = vote_globals.ubik_lastYesTime;
     aparm->lastYesHost = ntohl(vote_globals.lastYesHost);
@@ -432,15 +439,12 @@ SVOTE_Debug(struct rx_call * rxcall, struct ubik_debug * aparm)
 	&& (urecovery_state & UBIK_RECHAVEDB)) {
 	aparm->recoveryState |= UBIK_RECLABELDB;
     }
-    aparm->activeWrite = (ubik_dbase->flags & DBWRITING);
+    aparm->activeWrite = (ubik_dbase->dbFlags & DBWRITING);
     aparm->tidCounter = ubik_dbase->tidCounter;
 
     if (ubik_currentTrans) {
 	aparm->currentTrans = 1;
-	if (ubik_currentTrans->type == UBIK_WRITETRANS)
-	    aparm->writeTrans = 1;
-	else
-	    aparm->writeTrans = 0;
+	aparm->writeTrans = 1;
     } else {
 	aparm->currentTrans = 0;
     }
@@ -515,15 +519,12 @@ SVOTE_DebugOld(struct rx_call * rxcall,
 	&& (urecovery_state & UBIK_RECHAVEDB)) {
 	aparm->recoveryState |= UBIK_RECLABELDB;
     }
-    aparm->activeWrite = (ubik_dbase->flags & DBWRITING);
+    aparm->activeWrite = (ubik_dbase->dbFlags & DBWRITING);
     aparm->tidCounter = ubik_dbase->tidCounter;
 
     if (ubik_currentTrans) {
 	aparm->currentTrans = 1;
-	if (ubik_currentTrans->type == UBIK_WRITETRANS)
-	    aparm->writeTrans = 1;
-	else
-	    aparm->writeTrans = 0;
+	aparm->writeTrans = 1;
     } else {
 	aparm->currentTrans = 0;
     }
@@ -534,56 +535,6 @@ SVOTE_DebugOld(struct rx_call * rxcall,
 }
 
 
-/*!
- * \brief Get the sync site; called by remote servers to find where they should go.
- */
-afs_int32
-SVOTE_GetSyncSite(struct rx_call * rxcall,
-		  afs_int32 * ahost)
-{
-    afs_int32 temp;
-
-    temp = uvote_GetSyncSite();
-    *ahost = ntohl(temp);
-    return 0;
-}
-
-void
-ubik_dprint_25(const char *format, ...)
-{
-    va_list ap;
-
-    va_start(ap, format);
-    vViceLog(25, (format, ap));
-    va_end(ap);
-}
-
-void
-ubik_dprint(const char *format, ...)
-{
-    va_list ap;
-
-    va_start(ap, format);
-    vViceLog(5, (format, ap));
-    va_end(ap);
-}
-
-void
-ubik_vprint(const char *format, va_list ap)
-{
-    vViceLog(0, (format, ap));
-}
-
-void
-ubik_print(const char *format, ...)
-{
-    va_list ap;
-
-    va_start(ap, format);
-    ubik_vprint(format, ap);
-    va_end(ap);
-}
-
 /*!
  * \brief Called once/run to init the vote module
  */
diff --git a/src/update/Makefile.in b/src/update/Makefile.in
index 917bf766c..e8a0518ab 100644
--- a/src/update/Makefile.in
+++ b/src/update/Makefile.in
@@ -7,20 +7,15 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-
-LIBS=${TOP_LIBDIR}/libauth.a \
-	${TOP_LIBDIR}/librxkad.a \
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/libsys.a \
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/liblwp.a \
-	${TOP_LIBDIR}/libafscom_err.a \
-	${TOP_LIBDIR}/util.a \
-	${TOP_LIBDIR}/libopr.a \
-	${TOP_LIBDIR}/libafsrfc3961.a \
-	${TOP_LIBDIR}/libafshcrypto_lwp.a
+LIBS= \
+	$(top_builddir)/src/auth/liboafs_auth.la \
+	$(top_builddir)/src/rx/liboafs_rx.la \
+	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
+	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/opr/liboafs_opr.la
 
 all: upserver upclient
 
@@ -30,11 +25,11 @@ generated: update.cs.c update.ss.c update.xdr.c update.h
 # Build targets
 #
 upclient: client.o update.cs.o utils.o ${LIBS}
-	$(AFS_LDRULE) client.o update.cs.o utils.o \
+	$(LT_LDRULE_static) client.o update.cs.o utils.o \
 		${LIBS} $(LIB_roken) ${XLIBS}
 
 upserver: server.o utils.o update.ss.o ${LIBS}
-	$(AFS_LDRULE) server.o utils.o update.ss.o \
+	$(LT_LDRULE_static) server.o utils.o update.ss.o \
 		${LIBS} $(LIB_roken) ${XLIBS}
 
 utils.o: utils.c update.h global.h
diff --git a/src/update/client.c b/src/update/client.c
index 742c7f9a2..5bc0ec014 100644
--- a/src/update/client.c
+++ b/src/update/client.c
@@ -375,14 +375,14 @@ main(int argc, char **argv)
 	    free(curDir);
 	}			/* end for each dir loop */
 	/*delete the file with info on files in directory df->name */
-	IOMGR_Sleep(interval);
+	sleep(interval);
 	continue;
 
       fail_dirbuf:
 	fclose(stream);
 	unlink(dirbuf);
       fail:
-	IOMGR_Sleep(retrytime);
+	sleep(retrytime);
 	if (cnt > 10) {
 	    rx_DestroyConnection(conn);
 	    goto again;
diff --git a/src/update/server.c b/src/update/server.c
index c2985d375..7a5e33bf4 100644
--- a/src/update/server.c
+++ b/src/update/server.c
@@ -198,6 +198,7 @@ main(int argc, char *argv[])
     struct rx_securityClass **securityClasses;
     afs_int32 numClasses;
     struct rx_service *service;
+    char hoststr[16];
     afs_uint32 host = htonl(INADDR_ANY);
 
     int a = 0;
@@ -289,6 +290,12 @@ main(int argc, char *argv[])
 	exit(1);
     }
 
+    if (afsconf_CountKeys(cdir) == 0) {
+	fprintf(stderr, "WARNING: No encryption keys found! "
+			"All authenticated accesses will fail."
+			"Run akeyconvert or asetkey to import encryption keys.\n");
+    }
+
     if (rxBind) {
 	afs_int32 ccode;
         if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
@@ -308,6 +315,8 @@ main(int argc, char *argv[])
 
     /* Initialize Rx, telling it port number this server will use for its
      * single service */
+    fprintf(stderr, "upserver binding rx to %s:%d\n",
+            afs_inet_ntoa_r(host, hoststr), AFSCONF_UPDATEPORT);
     if (rx_InitHost(host, htons(AFSCONF_UPDATEPORT)) < 0)
 	Quit("rx_init");
 
diff --git a/src/uss/Makefile.in b/src/uss/Makefile.in
index 7a5fe4f98..aa1ddb71b 100644
--- a/src/uss/Makefile.in
+++ b/src/uss/Makefile.in
@@ -48,7 +48,7 @@ uss: uss.o ${OBJS} $(LIBS)
 
 uss.o:  uss.c AFS_component_version_number.c
 
-CFLAGS_lex.yy.o = @CFLAGS_NOUNUSED@ @CFLAGS_NOOLDSTYLE@
+CFLAGS_lex.yy.o = @CFLAGS_NOUNUSED@ @CFLAGS_NOOLDSTYLE@ @CFLAGS_NOIMPLICIT_FALLTHROUGH@
 lex.yy.o : lex.yy.c y.tab.c
 
 lex.yy.c : lex.l
diff --git a/src/uss/uss_common.c b/src/uss/uss_common.c
index d547b47b7..adb6badad 100644
--- a/src/uss/uss_common.c
+++ b/src/uss/uss_common.c
@@ -218,14 +218,8 @@ uss_common_FieldCp(char *a_to, char *a_from, char a_separator,
 	     */
 	    *a_overflowP = 1;
 	    a_to--;
-#if 0
-	    printf("*** Skipping overflow char '%c'\n", *(a_from - 1));
-#endif /* 0 */
 	    while (*a_from != a_separator && *a_from != '\0'
 		   && *a_from != '\n') {
-#if 0
-		printf("*** Skipping overflow char '%c'\n", *a_from);
-#endif /* 0 */
 		a_from++;
 	    }			/*Skip over excess chars */
 	    break;
diff --git a/src/uss/uss_fs.c b/src/uss/uss_fs.c
index 06937d5c1..11cda30db 100644
--- a/src/uss/uss_fs.c
+++ b/src/uss/uss_fs.c
@@ -579,7 +579,7 @@ uss_fs_UnlogToken(char *celln)
 	       code);
 	exit(1);
     }
-    for (code = index = 0; index < count; index++) {
+    for (index = 0; index < count; index++) {
 	tp = tokenInfoP + index;
 	if (!(tp->deleted)) {
 	    code = ktc_SetToken(&tp->service, &tp->token, &tp->client, 0);
diff --git a/src/uss/uss_kauth.c b/src/uss/uss_kauth.c
index da956bd94..11cbe6cdb 100644
--- a/src/uss/uss_kauth.c
+++ b/src/uss/uss_kauth.c
@@ -641,7 +641,7 @@ uss_kauth_SetFields(char *username, char *expirestring, char *reuse,
 	fprintf(stderr, "Zero represents unlimited login attempts.\n");
 	fprintf(stderr, "Continuing with limit == 254 for user %s.\n",
 		username);
-	misc_auth_bytes[2] = 255;
+	misc_auth_bytes[2] = 0xff;
     } else
 	misc_auth_bytes[2] = nfailures + 1;
 
diff --git a/src/uss/uss_procs.c b/src/uss/uss_procs.c
index 4e4807171..ff5619f74 100644
--- a/src/uss/uss_procs.c
+++ b/src/uss/uss_procs.c
@@ -659,12 +659,12 @@ afs_int32
 uss_procs_PickADir(char *path, char *cp)
 {				/*uss_procs_PickADir */
 
-    char cd[300];		/*Current  directory for search */
+    char cd[uss_DirPoolLen];		/*Current  directory for search */
 
     int i, count, MinIndex = 0, mina = 10000;
     struct dirent *dp;
     DIR *dirp;
-    char dirname[300];
+    char dirname[uss_DirPoolLen*2];
 
     if (uss_NumGroups == 0) {
 	fprintf(stderr, "%s: No choice yet given to replace $AUTO\n",
@@ -698,7 +698,7 @@ uss_procs_PickADir(char *path, char *cp)
      * each and pick the minimum.
      */
     for (i = 0; i < uss_NumGroups; i++) {
-	sprintf(dirname, "%s/%s", cd, uss_DirPool[i]);
+	snprintf(dirname, sizeof(dirname), "%s/%s", cd, uss_DirPool[i]);
 	if ((dirp = opendir(dirname)) == NULL) {
 	    if (errno != ENOTDIR)
 		fprintf(stderr,
@@ -771,7 +771,9 @@ uss_procs_FindAndOpen(char *a_fileToOpen)
 
     FILE *rv;			/*Template file descriptor */
     int i;			/*Loop counter */
-    char tmp_str[uss_MAX_SIZE];	/*Tmp string */
+    char *tmp_str;		/*Points to the name of the file */
+				/* -> a_fileToOpen or -> buffer @tmp_str_free */
+    char *tmp_str_free = NULL;  /*Dynamically built filename */
     static char
       TemplatePath[NUM_TPL_PATHS][1024];	/*Template directories */
     int cant_read;		/*Can't read the file? */
@@ -780,13 +782,14 @@ uss_procs_FindAndOpen(char *a_fileToOpen)
      * If a full pathname was given, just take it as is.
      */
     if (strchr(a_fileToOpen, '/')) {
-	strcpy(tmp_str, a_fileToOpen);
+	tmp_str = a_fileToOpen;
 	rv = fopen(a_fileToOpen, "r");
     } else {
 	/*
 	 * A relative pathname was given.  Try to find the file in each of
 	 * the default template directories.
 	 */
+	int mem_error = 0;
 	cant_read = 0;
 
 	sprintf(TemplatePath[0], "%s", ".");
@@ -794,7 +797,19 @@ uss_procs_FindAndOpen(char *a_fileToOpen)
 	sprintf(TemplatePath[2], "%s", "/etc");
 
 	for (i = 0; i < NUM_TPL_PATHS; i++) {
-	    sprintf(tmp_str, "%s/%s", TemplatePath[i], a_fileToOpen);
+	    int code;
+	    free(tmp_str_free);
+	    tmp_str_free = NULL;
+	    code = asprintf(&tmp_str_free, "%s/%s",
+			    TemplatePath[i], a_fileToOpen);
+	    if (code == -1) {
+		tmp_str_free = NULL;
+		mem_error = 1;
+		rv = NULL;
+		break;
+	    }
+	    tmp_str = tmp_str_free;
+
 	    if ((rv = fopen(tmp_str, "r")) != NULL)
 		break;
 
@@ -821,7 +836,11 @@ uss_procs_FindAndOpen(char *a_fileToOpen)
 	     * Check to see if we specifically found the file but
 	     * couldn't read it.
 	     */
-	    if (cant_read)
+	    if (mem_error) {
+		fprintf(stderr, "%s: Error allocating memory\n",
+			uss_whoami);
+	    }
+	    else if (cant_read)
 		fprintf(stderr, "%s: Can't open template '%s': %s\n",
 			uss_whoami, tmp_str, strerror(errno));
 	    else {
@@ -837,6 +856,7 @@ uss_procs_FindAndOpen(char *a_fileToOpen)
     /*
      * Whatever happened, return what we got.
      */
+    free(tmp_str_free);
     return (rv);
 
 }				/*uss_procs_FindAndOpen */
diff --git a/src/uss/uss_vol.c b/src/uss/uss_vol.c
index c9c13941d..5bbdebe9b 100644
--- a/src/uss/uss_vol.c
+++ b/src/uss/uss_vol.c
@@ -61,7 +61,7 @@ extern int line;
  * will work and we can avoid nasty little core dumps.
  */
 struct ubik_client *uconn_vldbP;	/*Ubik connection struct */
-struct ubik_client *cstruct;	/*Required name for above */
+extern struct ubik_client *cstruct;	/*Required name for above */
 
 /*
  * ------------------------ Private globals -----------------------
@@ -355,44 +355,6 @@ uss_vol_GetServer(char *a_name)
 
 }				/*uss_vol_GetServer */
 
-/* XXX - This function is unused, and could be deleted */
-#if 0
-/*------------------------------------------------------------------------
- * static GetVolumeType
- *
- * Description:
- *	Translate the given char string representing a volume type to the
- *	numeric representation.
- *
- * Arguments:
- *	a_type : Char string volume type.
- *
- * Returns:
- *	One of ROVOL, RWVOL, BACKVOL, or -1 on failure.
- *
- * Environment:
- *	Nothing interesting.
- *
- * Side Effects:
- *	As advertised.
- *------------------------------------------------------------------------*/
-
-static afs_int32
-GetVolumeType(char *a_type)
-{				/*GetVolumeType */
-
-    if (!strcmp(a_type, "ro"))
-	return (ROVOL);
-    else if (!strcmp(a_type, "rw"))
-	return (RWVOL);
-    else if (!strcmp(a_type, "bk"))
-	return (BACKVOL);
-    else
-	return (-1);
-
-}				/*GetVolumeType */
-#endif
-
 /*------------------------------------------------------------------------
  * EXPORTED uss_Vol_GetPartitionID
  *
diff --git a/src/uss/uss_vol.h b/src/uss/uss_vol.h
index 83b0f707b..08cf5a124 100644
--- a/src/uss/uss_vol.h
+++ b/src/uss/uss_vol.h
@@ -103,19 +103,4 @@ extern afs_int32 uss_vol_GetVolInfoFromMountPoint(char *a_mountpoint);
      *    Other error code if problem occurred in lower-level call.
      */
 
-#if 0
-extern afs_int32 uss_vol_DeleteMountPoint();
-    /*
-     * Summary:
-     *    Given a mountpoint, nuke it.
-     *
-     * Args:
-     *    char *a_mountpoint : Name of the mountpoint.
-     *
-     * Returns:
-     *    0 if everything went well,
-     *    1 if there was a problem in the routine itself, or
-     *    Other error code if problem occurred in lower-level call.
-     */
-#endif
 #endif /* _USS_VOL_H_ */
diff --git a/src/util/Makefile.in b/src/util/Makefile.in
index f0dfcc8ee..d1fcbaebb 100644
--- a/src/util/Makefile.in
+++ b/src/util/Makefile.in
@@ -19,7 +19,7 @@ LT_objs =$(LT_rpc_objs) \
 	 hputil.lo kreltime.lo uuid.lo serverLog.lo \
 	 dirpath.lo fileutil.lo flipbase64.lo fstab.lo \
 	 afs_atomlist.lo afs_lhash.lo pthread_glock.lo tabular_output.lo \
-	 pthread_threadname.lo ${REGEX_OBJ}
+	 ${REGEX_OBJ}
 
 LT_deps = $(top_builddir)/src/opr/liboafs_opr.la
 LT_libs = $(LIB_roken) $(MT_LIBS)
@@ -212,8 +212,9 @@ clean:
 	$(RM) -f sys dirpath.h
 	$(RM) -f util.a *.o core AFS_component_version_number.c
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 include ../config/Makefile.version
 
diff --git a/src/util/afs_lhash.c b/src/util/afs_lhash.c
index 176fd246a..90e39a089 100644
--- a/src/util/afs_lhash.c
+++ b/src/util/afs_lhash.c
@@ -455,9 +455,6 @@ afs_lhash_enter(afs_lhash * lh, unsigned key, void *data)
      */
     if (lh->ndata > LOAD_FACTOR * lh->ltable) {
 	afs_lhash_expand(lh);
-#if 0
-	printf("lh->p = %d; lh->maxp = %d\n", lh->p, lh->maxp);
-#endif
     }
 #ifdef CHECK_INVARIANTS
     assert(lh->ndata <= LOAD_FACTOR * lh->ltable);
diff --git a/src/util/afs_lhash.h b/src/util/afs_lhash.h
index a1f19451a..0da8db105 100644
--- a/src/util/afs_lhash.h
+++ b/src/util/afs_lhash.h
@@ -20,7 +20,7 @@
  * For more information on the algorithm, see
  *
  *	Dynamic Hash Tables
- *	Per-Åke Larson (Per-Ake Larson)
+ *	Per-Ã…ke Larson (Per-Ake Larson)
  *	Communications of the ACM
  *	Vol. 31, No. 4 (April 1988), Pages 446-457
  */
diff --git a/src/util/afsutil.h b/src/util/afsutil.h
index bd78946b4..bbebcc16d 100644
--- a/src/util/afsutil.h
+++ b/src/util/afsutil.h
@@ -121,6 +121,11 @@ extern int re_exec(const char *p1);
 /* b64_string_t is 8 bytes, in stds.h */
      typedef char lb64_string_t[12];
 
+/* A simple macro to help show the value of #define'd constants. e.g. If 'FOO'
+ * is defined as 5, then AFS_STRINGIZE(FOO) expands to "5" */
+#define AFS_STRINGIZE_(s) #s
+#define AFS_STRINGIZE(s) AFS_STRINGIZE_(s)
+
 #include <afs/ktime.h>
 #include "afsutil_prototypes.h"
 
diff --git a/src/util/afsutil_prototypes.h b/src/util/afsutil_prototypes.h
index b91e6fb7f..21f8378dd 100644
--- a/src/util/afsutil_prototypes.h
+++ b/src/util/afsutil_prototypes.h
@@ -29,7 +29,7 @@ extern int base64_to_int(char *s);
 
 /* dirpath.c */
 extern unsigned int initAFSDirPath(void);
-extern const char *getDirPath(afsdir_id_t string_id);
+extern const char *afs_getDirPath(afsdir_id_t string_id);
 extern int ConstructLocalPath(const char *cpath, const char *relativeTo,
 			      char **fullPathBufp);
 extern int ConstructLocalBinPath(const char *cpath, char **fullPathBufp);
@@ -105,16 +105,6 @@ extern afs_int32 ktime_InterpretDate(struct ktime_date *akdate);
 /* pthread_glock.c */
 
 
-/* pthread_threadname.c */
-#if defined(AFS_PTHREAD_ENV) && !defined(AFS_NT40_ENV)
-extern void afs_pthread_setname_self(const char *threadname);
-#else
-/* Allow unconditional references to afs_pthread_setname_self to
- * reduce #ifdef spaghetti.
- */
-#define afs_pthread_setname_self(threadname) (void)0
-#endif
-
 /* readdir_nt.c */
 
 
@@ -172,7 +162,11 @@ extern afs_int32 afs_uuid_create(afsUUID * uuid);
 extern u_short afs_uuid_hash(afsUUID * uuid);
 #if !defined(KERNEL) && !defined(UKERNEL)
 extern int afsUUID_from_string(const char *str, afsUUID * uuid);
-extern int afsUUID_to_string(const afsUUID * uuid, char *str, size_t strsz);
+
+struct uuid_fmtbuf {
+    char buffer[38];
+};
+extern char *afsUUID_to_string(const afsUUID * uuid, struct uuid_fmtbuf *buf);
 #endif
 
 /* volparse.c */
diff --git a/src/util/dirpath.c b/src/util/dirpath.c
index 90f053de5..830ac2631 100644
--- a/src/util/dirpath.c
+++ b/src/util/dirpath.c
@@ -428,12 +428,12 @@ initDirPathArray(void)
     return;
 }
 
-/* getDirPath - returns a const char pointer to the requested string
+/* afs_getDirPath - returns a const char pointer to the requested string
  * from the internal path array.
  * string_id - index into the path array
  */
 const char *
-getDirPath(afsdir_id_t string_id)
+afs_getDirPath(afsdir_id_t string_id)
 {
     /* check if the array has been initialized */
     if (initFlag == 0) {	/* no it's not, so initialize */
@@ -446,6 +446,16 @@ getDirPath(afsdir_id_t string_id)
     return (const char *)dirPathArray[string_id];
 }
 
+#ifdef AFS_NT40_ENV
+/* getDirPath - present for ABI compatibility on Windows systems;
+ * Unix systems should not use it. */
+const char *
+getDirPath(afsdir_id_t string_id)
+{
+    return afs_getDirPath(string_id);
+}
+#endif
+
 /*
  * LocalizePathHead() -- Make path relative to local part
  *
@@ -550,6 +560,9 @@ ConstructLocalPath(const char *cpath, const char *relativeTo,
 
     *fullPathBufp = NULL;
 
+    if (cpath == NULL)
+	return ENOENT;
+
     while (isspace(*cpath)) {
 	cpath++;
     }
@@ -644,6 +657,9 @@ ConstructLocalPath(const char *cpath, const char *relativeTo,
 
     *fullPathBufp = NULL;
 
+    if (cpath == NULL)
+	return ENOENT;
+
     while (isspace(*cpath)) {
 	cpath++;
     }
diff --git a/src/util/dirpath.hin b/src/util/dirpath.hin
index 165e6975c..7d8c1e742 100644
--- a/src/util/dirpath.hin
+++ b/src/util/dirpath.hin
@@ -298,86 +298,86 @@ typedef enum afsdir_id {
       AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH_ID,
       AFSDIR_PATHSTRING_MAX } afsdir_id_t;
 
-/* getDirPath() returns a pointer to a string from an internal array of path strings 
+/* afs_getDirPath() returns a pointer to a string from an internal array of path strings 
  */
-const char *getDirPath(afsdir_id_t string_id);
+const char *afs_getDirPath(afsdir_id_t string_id);
 
 /* Top level usr dir */
-#define AFSDIR_USR_DIRPATH getDirPath(AFSDIR_USR_DIRPATH_ID)
+#define AFSDIR_USR_DIRPATH afs_getDirPath(AFSDIR_USR_DIRPATH_ID)
 
 /* server subdir paths */
-#define AFSDIR_SERVER_AFS_DIRPATH getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID)
-#define AFSDIR_SERVER_ETC_DIRPATH getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID)
-#define AFSDIR_SERVER_BIN_DIRPATH getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID)
-#define AFSDIR_SERVER_CORES_DIRPATH getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID)
-#define AFSDIR_SERVER_DB_DIRPATH getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID)
-#define AFSDIR_SERVER_LOGS_DIRPATH getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID)
-#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
-#define AFSDIR_SERVER_BACKUP_DIRPATH getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID)
-#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
-#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
-#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
+#define AFSDIR_SERVER_AFS_DIRPATH afs_getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID)
+#define AFSDIR_SERVER_ETC_DIRPATH afs_getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID)
+#define AFSDIR_SERVER_BIN_DIRPATH afs_getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID)
+#define AFSDIR_SERVER_CORES_DIRPATH afs_getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID)
+#define AFSDIR_SERVER_DB_DIRPATH afs_getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID)
+#define AFSDIR_SERVER_LOGS_DIRPATH afs_getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID)
+#define AFSDIR_SERVER_LOCAL_DIRPATH afs_getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
+#define AFSDIR_SERVER_BACKUP_DIRPATH afs_getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID)
+#define AFSDIR_SERVER_LOCAL_DIRPATH afs_getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
+#define AFSDIR_SERVER_MIGRATE_DIRPATH afs_getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
+#define AFSDIR_SERVER_MIGRATE_DIRPATH afs_getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
 
 /* client subdir paths */
-#define AFSDIR_CLIENT_VICE_DIRPATH getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID)
-#define AFSDIR_CLIENT_ETC_DIRPATH getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID)
-#define AFSDIR_CLIENT_DATA_DIRPATH getDirPath(AFSDIR_CLIENT_DATA_DIRPATH_ID)
-#define AFSDIR_SERVER_BIN_FILE_DIRPATH getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID)
+#define AFSDIR_CLIENT_VICE_DIRPATH afs_getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID)
+#define AFSDIR_CLIENT_ETC_DIRPATH afs_getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID)
+#define AFSDIR_CLIENT_DATA_DIRPATH afs_getDirPath(AFSDIR_CLIENT_DATA_DIRPATH_ID)
+#define AFSDIR_SERVER_BIN_FILE_DIRPATH afs_getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID)
 
 /* server file paths */
-#define AFSDIR_SERVER_THISCELL_FILEPATH getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID)
-#define AFSDIR_SERVER_CELLSERVDB_FILEPATH getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID)
-#define AFSDIR_SERVER_NOAUTH_FILEPATH getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID)
-#define AFSDIR_SERVER_KEY_FILEPATH getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID)
-#define AFSDIR_SERVER_ULIST_FILEPATH getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID)
-#define AFSDIR_SERVER_BUDBLOG_FILEPATH getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_TAPECONFIG_FILEPATH getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID)
-#define AFSDIR_SERVER_KALOGDB_FILEPATH getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID)
-#define AFSDIR_SERVER_KALOG_FILEPATH getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID)
-#define AFSDIR_SERVER_KADB_FILEPATH getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID)
-#define AFSDIR_SERVER_NTPD_FILEPATH getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID)
-#define AFSDIR_SERVER_PRDB_FILEPATH getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID)
-#define AFSDIR_SERVER_PTLOG_FILEPATH getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_KCONF_FILEPATH getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID)
-#define AFSDIR_SERVER_VLDB_FILEPATH getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID)
-#define AFSDIR_SERVER_VLOG_FILEPATH getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_CORELOG_FILEPATH getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID)
-#define AFSDIR_SERVER_SLVGLOG_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_SALSRVLOG_FILEPATH getDirPath(AFSDIR_SERVER_SALSRVLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_SALVAGER_FILEPATH getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID)
-#define AFSDIR_SERVER_SALSRV_FILEPATH getDirPath(AFSDIR_SERVER_SALSRV_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZCONF_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZRXBIND_FILEPATH getDirPath(AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID)
-#define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
-#define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
-#define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_ROOTVOL_FILEPATH getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID)
-#define AFSDIR_SERVER_HOSTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID)
-#define AFSDIR_SERVER_CLNTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID)
-#define AFSDIR_SERVER_CBKDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID)
-#define AFSDIR_SERVER_OLDSYSID_FILEPATH getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID)
-#define AFSDIR_SERVER_SYSID_FILEPATH getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID)
-#define AFSDIR_SERVER_FILELOG_FILEPATH getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID)
-#define AFSDIR_SERVER_AUDIT_FILEPATH getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID)
-#define AFSDIR_SERVER_NETINFO_FILEPATH getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID)
-#define AFSDIR_SERVER_NETRESTRICT_FILEPATH getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID)
-#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)
-#define AFSDIR_SERVER_FSSTATE_FILEPATH getDirPath(AFSDIR_SERVER_FSSTATE_FILEPATH_ID)
-#define AFSDIR_SERVER_CONFIG_FILE_FILEPATH getDirPath(AFSDIR_SERVER_CONFIG_FILE_FILEPATH_ID)
-#define AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH getDirPath(AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH_ID)
+#define AFSDIR_SERVER_THISCELL_FILEPATH afs_getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID)
+#define AFSDIR_SERVER_CELLSERVDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID)
+#define AFSDIR_SERVER_NOAUTH_FILEPATH afs_getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID)
+#define AFSDIR_SERVER_KEY_FILEPATH afs_getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID)
+#define AFSDIR_SERVER_ULIST_FILEPATH afs_getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID)
+#define AFSDIR_SERVER_BUDBLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_TAPECONFIG_FILEPATH afs_getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID)
+#define AFSDIR_SERVER_KALOGDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID)
+#define AFSDIR_SERVER_KALOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KADB_FILEPATH afs_getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID)
+#define AFSDIR_SERVER_NTPD_FILEPATH afs_getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID)
+#define AFSDIR_SERVER_PRDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID)
+#define AFSDIR_SERVER_PTLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KCONF_FILEPATH afs_getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID)
+#define AFSDIR_SERVER_VLDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID)
+#define AFSDIR_SERVER_VLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_CORELOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_SLVGLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_SALSRVLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_SALSRVLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_SALVAGER_FILEPATH afs_getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID)
+#define AFSDIR_SERVER_SALSRV_FILEPATH afs_getDirPath(AFSDIR_SERVER_SALSRV_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZCONF_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZCONFNEW_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZINIT_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZRXBIND_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID)
+#define AFSDIR_SERVER_BOSVR_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
+#define AFSDIR_SERVER_SLVGLOCK_FILEPATH afs_getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
+#define AFSDIR_SERVER_VOLSERLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_ROOTVOL_FILEPATH afs_getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID)
+#define AFSDIR_SERVER_HOSTDUMP_FILEPATH afs_getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID)
+#define AFSDIR_SERVER_CLNTDUMP_FILEPATH afs_getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID)
+#define AFSDIR_SERVER_CBKDUMP_FILEPATH afs_getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID)
+#define AFSDIR_SERVER_OLDSYSID_FILEPATH afs_getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID)
+#define AFSDIR_SERVER_SYSID_FILEPATH afs_getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID)
+#define AFSDIR_SERVER_FILELOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_AUDIT_FILEPATH afs_getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID)
+#define AFSDIR_SERVER_NETINFO_FILEPATH afs_getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID)
+#define AFSDIR_SERVER_NETRESTRICT_FILEPATH afs_getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID)
+#define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH afs_getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID)
+#define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH afs_getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID)
+#define AFSDIR_SERVER_MIGRATELOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KRB_EXCL_FILEPATH afs_getDirPath(AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID)
+#define AFSDIR_SERVER_FSSTATE_FILEPATH afs_getDirPath(AFSDIR_SERVER_FSSTATE_FILEPATH_ID)
+#define AFSDIR_SERVER_CONFIG_FILE_FILEPATH afs_getDirPath(AFSDIR_SERVER_CONFIG_FILE_FILEPATH_ID)
+#define AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH afs_getDirPath(AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH_ID)
 
 /* client file paths */
-#define AFSDIR_CLIENT_CONFIG_FILE_FILEPATH getDirPath(AFSDIR_CLIENT_CONFIG_FILE_FILEPATH_ID)
-#define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
-#define AFSDIR_CLIENT_CELLSERVDB_FILEPATH getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID)  
-#define AFSDIR_CLIENT_CELLALIAS_FILEPATH getDirPath(AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID)  
-#define AFSDIR_CLIENT_NETINFO_FILEPATH getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID)
-#define AFSDIR_CLIENT_NETRESTRICT_FILEPATH getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID)
+#define AFSDIR_CLIENT_CONFIG_FILE_FILEPATH afs_getDirPath(AFSDIR_CLIENT_CONFIG_FILE_FILEPATH_ID)
+#define AFSDIR_CLIENT_THISCELL_FILEPATH afs_getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
+#define AFSDIR_CLIENT_CELLSERVDB_FILEPATH afs_getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID)  
+#define AFSDIR_CLIENT_CELLALIAS_FILEPATH afs_getDirPath(AFSDIR_CLIENT_CELLALIAS_FILEPATH_ID)  
+#define AFSDIR_CLIENT_NETINFO_FILEPATH afs_getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID)
+#define AFSDIR_CLIENT_NETRESTRICT_FILEPATH afs_getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID)
 
 #endif /* _DIRPATH_H */
diff --git a/src/util/dirpath_nt.h b/src/util/dirpath_nt.h
index e08932d77..5a978821c 100644
--- a/src/util/dirpath_nt.h
+++ b/src/util/dirpath_nt.h
@@ -284,84 +284,86 @@ typedef enum afsdir_id {
     AFSDIR_PATHSTRING_MAX
 } afsdir_id_t;
 
-/* getDirPath() returns a pointer to a string from an internal array of path strings
+/* afs_getDirPath() returns a pointer to a string from an internal array of path strings
  */
+const char *afs_getDirPath(afsdir_id_t string_id);
+/* For ABI compatibility with historical versions. */
 const char *getDirPath(afsdir_id_t string_id);
 
 /* Top level usr dir */
-#define AFSDIR_USR_DIRPATH getDirPath(AFSDIR_USR_DIRPATH_ID)
+#define AFSDIR_USR_DIRPATH afs_getDirPath(AFSDIR_USR_DIRPATH_ID)
 
 /* server subdir paths */
-#define AFSDIR_SERVER_AFS_DIRPATH getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID)
-#define AFSDIR_SERVER_ETC_DIRPATH getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID)
-#define AFSDIR_SERVER_BIN_DIRPATH getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID)
-#define AFSDIR_SERVER_CORES_DIRPATH getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID)
-#define AFSDIR_SERVER_DB_DIRPATH getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID)
-#define AFSDIR_SERVER_LOGS_DIRPATH getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID)
-#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
-#define AFSDIR_SERVER_BACKUP_DIRPATH getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID)
-#define AFSDIR_SERVER_LOCAL_DIRPATH getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
-#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
-#define AFSDIR_SERVER_MIGRATE_DIRPATH getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
+#define AFSDIR_SERVER_AFS_DIRPATH afs_getDirPath(AFSDIR_SERVER_AFS_DIRPATH_ID)
+#define AFSDIR_SERVER_ETC_DIRPATH afs_getDirPath(AFSDIR_SERVER_ETC_DIRPATH_ID)
+#define AFSDIR_SERVER_BIN_DIRPATH afs_getDirPath(AFSDIR_SERVER_BIN_DIRPATH_ID)
+#define AFSDIR_SERVER_CORES_DIRPATH afs_getDirPath(AFSDIR_SERVER_CORES_DIRPATH_ID)
+#define AFSDIR_SERVER_DB_DIRPATH afs_getDirPath(AFSDIR_SERVER_DB_DIRPATH_ID)
+#define AFSDIR_SERVER_LOGS_DIRPATH afs_getDirPath(AFSDIR_SERVER_LOGS_DIRPATH_ID)
+#define AFSDIR_SERVER_LOCAL_DIRPATH afs_getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
+#define AFSDIR_SERVER_BACKUP_DIRPATH afs_getDirPath(AFSDIR_SERVER_BACKUP_DIRPATH_ID)
+#define AFSDIR_SERVER_LOCAL_DIRPATH afs_getDirPath(AFSDIR_SERVER_LOCAL_DIRPATH_ID)
+#define AFSDIR_SERVER_MIGRATE_DIRPATH afs_getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
+#define AFSDIR_SERVER_MIGRATE_DIRPATH afs_getDirPath(AFSDIR_SERVER_MIGRATE_DIRPATH_ID)
 
 /* client subdir paths */
-#define AFSDIR_CLIENT_VICE_DIRPATH getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID)
-#define AFSDIR_CLIENT_ETC_DIRPATH getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID)
-#define AFSDIR_SERVER_BIN_FILE_DIRPATH getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID)
+#define AFSDIR_CLIENT_VICE_DIRPATH afs_getDirPath(AFSDIR_CLIENT_VICE_DIRPATH_ID)
+#define AFSDIR_CLIENT_ETC_DIRPATH afs_getDirPath(AFSDIR_CLIENT_ETC_DIRPATH_ID)
+#define AFSDIR_SERVER_BIN_FILE_DIRPATH afs_getDirPath(AFSDIR_SERVER_BIN_FILE_DIRPATH_ID)
 
 /* server file paths */
-#define AFSDIR_SERVER_THISCELL_FILEPATH getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID)
-#define AFSDIR_SERVER_CELLSERVDB_FILEPATH getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID)
-#define AFSDIR_SERVER_NOAUTH_FILEPATH getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID)
-#define AFSDIR_SERVER_KEY_FILEPATH getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID)
-#define AFSDIR_SERVER_ULIST_FILEPATH getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID)
-#define AFSDIR_SERVER_BUDBLOG_FILEPATH getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_TAPECONFIG_FILEPATH getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID)
-#define AFSDIR_SERVER_KALOGDB_FILEPATH getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID)
-#define AFSDIR_SERVER_KALOG_FILEPATH getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID)
-#define AFSDIR_SERVER_KADB_FILEPATH getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID)
-#define AFSDIR_SERVER_NTPD_FILEPATH getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID)
-#define AFSDIR_SERVER_PRDB_FILEPATH getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID)
-#define AFSDIR_SERVER_PTLOG_FILEPATH getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_KCONF_FILEPATH getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID)
-#define AFSDIR_SERVER_VLDB_FILEPATH getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID)
-#define AFSDIR_SERVER_VLOG_FILEPATH getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_CORELOG_FILEPATH getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID)
-#define AFSDIR_SERVER_SLVGLOG_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_SALSRVLOG_FILEPATH getDirPath(AFSDIR_SERVER_SALSRVLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_SALVAGER_FILEPATH getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID)
-#define AFSDIR_SERVER_SALSRV_FILEPATH getDirPath(AFSDIR_SERVER_SALSRV_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZCONF_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZCONFNEW_FILEPATH getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZINIT_FILEPATH getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZLOG_FILEPATH getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_BOZRXBIND_FILEPATH getDirPath(AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID)
-#define AFSDIR_SERVER_BOSVR_FILEPATH getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
-#define AFSDIR_SERVER_SLVGLOCK_FILEPATH getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
-#define AFSDIR_SERVER_VOLSERLOG_FILEPATH getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)
-#define AFSDIR_SERVER_ROOTVOL_FILEPATH getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID)
-#define AFSDIR_SERVER_HOSTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID)
-#define AFSDIR_SERVER_CLNTDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID)
-#define AFSDIR_SERVER_CBKDUMP_FILEPATH getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID)
-#define AFSDIR_SERVER_OLDSYSID_FILEPATH getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID)
-#define AFSDIR_SERVER_SYSID_FILEPATH getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID)
-#define AFSDIR_SERVER_FILELOG_FILEPATH getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID)
-#define AFSDIR_SERVER_AUDIT_FILEPATH getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID)
-#define AFSDIR_SERVER_NETINFO_FILEPATH getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID)
-#define AFSDIR_SERVER_NETRESTRICT_FILEPATH getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID)
-#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)
-#define AFSDIR_SERVER_FSSTATE_FILEPATH getDirPath(AFSDIR_SERVER_FSSTATE_FILEPATH_ID)
-#define AFSDIR_SERVER_CONFIG_FILE_FILEPATH getDirPath(AFSDIR_SERVER_CONFIG_FILE_FILEPATH_ID)
-#define AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH getDirPath(AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH_ID)
+#define AFSDIR_SERVER_THISCELL_FILEPATH afs_getDirPath(AFSDIR_SERVER_THISCELL_FILEPATH_ID)
+#define AFSDIR_SERVER_CELLSERVDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_CELLSERVDB_FILEPATH_ID)
+#define AFSDIR_SERVER_NOAUTH_FILEPATH afs_getDirPath(AFSDIR_SERVER_NOAUTH_FILEPATH_ID)
+#define AFSDIR_SERVER_KEY_FILEPATH afs_getDirPath(AFSDIR_SERVER_KEY_FILEPATH_ID)
+#define AFSDIR_SERVER_ULIST_FILEPATH afs_getDirPath(AFSDIR_SERVER_ULIST_FILEPATH_ID)
+#define AFSDIR_SERVER_BUDBLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_BUDBLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_TAPECONFIG_FILEPATH afs_getDirPath(AFSDIR_SERVER_TAPECONFIG_FILEPATH_ID)
+#define AFSDIR_SERVER_KALOGDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_KALOGDB_FILEPATH_ID)
+#define AFSDIR_SERVER_KALOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_KALOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KADB_FILEPATH afs_getDirPath(AFSDIR_SERVER_KADB_FILEPATH_ID)
+#define AFSDIR_SERVER_NTPD_FILEPATH afs_getDirPath(AFSDIR_SERVER_NTPD_FILEPATH_ID)
+#define AFSDIR_SERVER_PRDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_PRDB_FILEPATH_ID)
+#define AFSDIR_SERVER_PTLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_PTLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KCONF_FILEPATH afs_getDirPath(AFSDIR_SERVER_KCONF_FILEPATH_ID)
+#define AFSDIR_SERVER_VLDB_FILEPATH afs_getDirPath(AFSDIR_SERVER_VLDB_FILEPATH_ID)
+#define AFSDIR_SERVER_VLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_VLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_CORELOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_CORELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_SLVGLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_SLVGLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_SALSRVLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_SALSRVLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_SALVAGER_FILEPATH afs_getDirPath(AFSDIR_SERVER_SALVAGER_FILEPATH_ID)
+#define AFSDIR_SERVER_SALSRV_FILEPATH afs_getDirPath(AFSDIR_SERVER_SALSRV_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZCONF_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZCONF_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZCONFNEW_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZCONFNEW_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZINIT_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZINIT_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_BOZRXBIND_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOZRXBIND_FILEPATH_ID)
+#define AFSDIR_SERVER_BOSVR_FILEPATH afs_getDirPath(AFSDIR_SERVER_BOSVR_FILEPATH_ID)
+#define AFSDIR_SERVER_SLVGLOCK_FILEPATH afs_getDirPath(AFSDIR_SERVER_SLVGLOCK_FILEPATH_ID)
+#define AFSDIR_SERVER_VOLSERLOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_VOLSERLOG_FILEPATH_ID)
+#define AFSDIR_SERVER_ROOTVOL_FILEPATH afs_getDirPath(AFSDIR_SERVER_ROOTVOL_FILEPATH_ID)
+#define AFSDIR_SERVER_HOSTDUMP_FILEPATH afs_getDirPath(AFSDIR_SERVER_HOSTDUMP_FILEPATH_ID)
+#define AFSDIR_SERVER_CLNTDUMP_FILEPATH afs_getDirPath(AFSDIR_SERVER_CLNTDUMP_FILEPATH_ID)
+#define AFSDIR_SERVER_CBKDUMP_FILEPATH afs_getDirPath(AFSDIR_SERVER_CBKDUMP_FILEPATH_ID)
+#define AFSDIR_SERVER_OLDSYSID_FILEPATH afs_getDirPath(AFSDIR_SERVER_OLDSYSID_FILEPATH_ID)
+#define AFSDIR_SERVER_SYSID_FILEPATH afs_getDirPath(AFSDIR_SERVER_SYSID_FILEPATH_ID)
+#define AFSDIR_SERVER_FILELOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_FILELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_AUDIT_FILEPATH afs_getDirPath(AFSDIR_SERVER_AUDIT_FILEPATH_ID)
+#define AFSDIR_SERVER_NETINFO_FILEPATH afs_getDirPath(AFSDIR_SERVER_NETINFO_FILEPATH_ID)
+#define AFSDIR_SERVER_NETRESTRICT_FILEPATH afs_getDirPath(AFSDIR_SERVER_NETRESTRICT_FILEPATH_ID)
+#define AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH afs_getDirPath(AFSDIR_SERVER_WEIGHTING_CONSTANTS_FILEPATH_ID)
+#define AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH afs_getDirPath(AFSDIR_SERVER_THRESHOLD_CONSTANTS_FILEPATH_ID)
+#define AFSDIR_SERVER_MIGRATELOG_FILEPATH afs_getDirPath(AFSDIR_SERVER_MIGRATELOG_FILEPATH_ID)
+#define AFSDIR_SERVER_KRB_EXCL_FILEPATH afs_getDirPath(AFSDIR_SERVER_KRB_EXCL_FILEPATH_ID)
+#define AFSDIR_SERVER_FSSTATE_FILEPATH afs_getDirPath(AFSDIR_SERVER_FSSTATE_FILEPATH_ID)
+#define AFSDIR_SERVER_CONFIG_FILE_FILEPATH afs_getDirPath(AFSDIR_SERVER_CONFIG_FILE_FILEPATH_ID)
+#define AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH afs_getDirPath(AFSDIR_SERVER_RXKAD_KEYTAB_FILEPATH_ID)
 
 /* client file paths */
-#define AFSDIR_CLIENT_CONFIG_FILE_FILEPATH getDirPath(AFSDIR_CLIENT_CONFIG_FILE_FILEPATH_ID)
-#define AFSDIR_CLIENT_THISCELL_FILEPATH getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
-#define AFSDIR_CLIENT_CELLSERVDB_FILEPATH getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID)
-#define AFSDIR_CLIENT_NETINFO_FILEPATH getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID)
-#define AFSDIR_CLIENT_NETRESTRICT_FILEPATH getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID)
+#define AFSDIR_CLIENT_CONFIG_FILE_FILEPATH afs_getDirPath(AFSDIR_CLIENT_CONFIG_FILE_FILEPATH_ID)
+#define AFSDIR_CLIENT_THISCELL_FILEPATH afs_getDirPath(AFSDIR_CLIENT_THISCELL_FILEPATH_ID)
+#define AFSDIR_CLIENT_CELLSERVDB_FILEPATH afs_getDirPath(AFSDIR_CLIENT_CELLSERVDB_FILEPATH_ID)
+#define AFSDIR_CLIENT_NETINFO_FILEPATH afs_getDirPath(AFSDIR_CLIENT_NETINFO_FILEPATH_ID)
+#define AFSDIR_CLIENT_NETRESTRICT_FILEPATH afs_getDirPath(AFSDIR_CLIENT_NETRESTRICT_FILEPATH_ID)
 
 #endif /* _DIRPATH_H */
diff --git a/src/util/ktime.c b/src/util/ktime.c
index 20f9de8a7..4df420df3 100644
--- a/src/util/ktime.c
+++ b/src/util/ktime.c
@@ -381,9 +381,9 @@ ktime_next(struct ktime * aktime, afs_int32 afrom)
 
     /* handle some special cases */
     if (tmask & KTIME_NEVER)
-	return 0x7fffffff;
+	return KTIME_NEVERTIME;
     if (tmask & KTIME_NOW)
-	return 0;
+	return KTIME_NOWTIME;
 
     /* Use probe to fill in members of *tsp. Add 23 hours each iteration until
      * time_next is correct. Only add 23 hrs to avoid skipping spring
@@ -638,12 +638,6 @@ ktime_InterpretDate(struct ktime_date * akdate)
 	temp = tresult + tbit;	/* see if adding this bit keeps us < akdate */
 	tsp = localtime(&temp);
 	tsp->tm_mon++;
-#ifdef notdef
-	if (tsp->tm_mon == 0) {
-	    tsp->tm_mon = 12;
-	    tsp->tm_year--;
-	}
-#endif
 	if (KDateCmp(akdate, tsp) >= 0) {
 	    /* if temp still represents earlier than date than we're searching
 	     * for, add in bit as increment, otherwise use old value and look
diff --git a/src/util/ktime.h b/src/util/ktime.h
index 15e44fd0b..ace4b83a0 100644
--- a/src/util/ktime.h
+++ b/src/util/ktime.h
@@ -43,6 +43,7 @@ struct ktime {
     short day;			/* 0 is sunday */
 };
 
+/* ktime masks */
 #define	KTIME_HOUR	1	/* hour should match */
 #define	KTIME_MIN	2
 #define	KTIME_SEC	4
@@ -51,6 +52,10 @@ struct ktime {
 #define	KTIME_NEVER	0x10	/* special case: never */
 #define	KTIME_NOW	0x20	/* special case: right now */
 
+/* ktime special values */
+#define KTIME_NEVERTIME  0x7fffffff  /* never */
+#define KTIME_NOWTIME    0           /* right now */
+
 #define	ktime_DateToLong	ktime_DateToInt32	/* XXX */
 #define	ktimeRelDate_ToLong	ktimeRelDate_ToInt32	/* XXX */
 #define	LongTo_ktimeRelDate     Int32To_ktimeRelDate	/* XXX */
diff --git a/src/util/liboafs_util.la.sym b/src/util/liboafs_util.la.sym
index 98fad699d..1d2de7cd4 100644
--- a/src/util/liboafs_util.la.sym
+++ b/src/util/liboafs_util.la.sym
@@ -19,25 +19,20 @@ afsUUID_to_string
 afs_htonuuid
 afs_inet_ntoa_r
 afs_ntohuuid
-afs_pthread_setname_self
 afs_uuid_create
 afs_uuid_equal
 afs_uuid_hash
 afs_uuid_is_nil
 flipbase64_to_int64
-getDirPath
-getDirPath
+afs_getDirPath
 gettmpdir
 grmutex
-grmutex
 hostutil_GetHostByName
 hostutil_GetNameByINet
 initAFSDirPath
 int64_to_flipbase64
 ktime_DateToInt32
 pthread_recursive_mutex_lock
-pthread_recursive_mutex_lock
-pthread_recursive_mutex_unlock
 pthread_recursive_mutex_unlock
 util_GetHumanInt32
 util_GetInt32
diff --git a/src/util/serverLog.c b/src/util/serverLog.c
index 41a07f5de..60e8517f7 100644
--- a/src/util/serverLog.c
+++ b/src/util/serverLog.c
@@ -25,7 +25,6 @@
 #include <roken.h>		/* Must come after procmgmt.h */
 #ifdef AFS_PTHREAD_ENV
  #include <opr/softsig.h>
- #include <afs/procmgmt_softsig.h>	/* Must come after softsig.h */
 #endif
 #include <afs/opr.h>
 #include "afsutil.h"
@@ -149,8 +148,9 @@ WriteLogBuffer(char *buf, afs_uint32 len)
 {
     LOCK_SERVERLOG();
     if (serverLogFD >= 0) {
-	if (write(serverLogFD, buf, len) < 0)
-	    ; /* don't care */
+	if (write(serverLogFD, buf, len) < 0) {
+	    /* don't care */
+        }
     }
     UNLOCK_SERVERLOG();
 }
@@ -204,8 +204,9 @@ vFSLog(const char *format, va_list args)
     } else
 #endif
     if (serverLogFD >= 0) {
-	if (write(serverLogFD, tbuffer, len) < 0)
-	    ; /* don't care */
+	if (write(serverLogFD, tbuffer, len) < 0) {
+	    /* don't care */
+        }
     }
     UNLOCK_SERVERLOG();
 
@@ -506,10 +507,25 @@ SetupLogSignals(void)
 }
 
 #if defined(AFS_PTHREAD_ENV)
+static void
+LockServerLog(void)
+{
+    LOCK_SERVERLOG();
+}
+
+static void
+UnlockServerLog(void)
+{
+    UNLOCK_SERVERLOG();
+}
+
 static void
 InitServerLogMutex(void)
 {
     opr_Verify(pthread_mutex_init(&serverLogMutex, NULL) == 0);
+# ifndef AFS_NT40_ENV
+    opr_Verify(pthread_atfork(LockServerLog, UnlockServerLog, UnlockServerLog) == 0);
+# endif
 }
 #endif /* AFS_PTHREAD_ENV */
 
@@ -523,8 +539,9 @@ InitServerLogMutex(void)
 static void
 RedirectStdStreams(const char *fileName)
 {
-    if (freopen(fileName, "a", stdout) == NULL)
-	; /* don't care */
+    if (freopen(fileName, "a", stdout) == NULL) {
+	/* don't care */
+    }
     if (freopen(fileName, "a", stderr) != NULL) {
 #ifdef HAVE_SETVBUF
 	setvbuf(stderr, NULL, _IONBF, 0);
@@ -572,9 +589,12 @@ OpenLogFile(const char *fileName)
     RedirectStdStreams(fileName);
 
     /* Save our name for reopening. */
-    free(ourName);
-    ourName = strdup(fileName);
-    opr_Assert(ourName != NULL);
+    if (ourName != fileName) {
+	/* Make a copy if needed */
+	free(ourName);
+	ourName = strdup(fileName);
+	opr_Assert(ourName != NULL);
+    }
 
     serverLogFD = tempfd;
 
diff --git a/src/util/tabular_output.c b/src/util/tabular_output.c
index 7c883a81b..dd45fd2ff 100644
--- a/src/util/tabular_output.c
+++ b/src/util/tabular_output.c
@@ -509,5 +509,5 @@ findRowIndex(struct util_Table* Table, struct util_TableRow *aRow){
                 return lower;
         }
     }  while(1);
-    return 0;
+    AFS_UNREACHED(return(0));
 }
diff --git a/src/util/uuid.c b/src/util/uuid.c
index dbf77d062..af6dfa018 100644
--- a/src/util/uuid.c
+++ b/src/util/uuid.c
@@ -10,7 +10,7 @@
 /* String conversion routines have the following copyright */
 
 /*
- * Copyright (c) 2002 Kungliga Tekniska Högskolan
+ * Copyright (c) 2002 Kungliga Tekniska HÃ¶gskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -198,14 +198,21 @@ afsUUID_from_string(const char *str, afsUUID * uuid)
     return 0;
 }
 
-/*
+/**
  *    Converts a UUID from binary representation to a string representation.
+ *
+ *    @param[in]  uuid pointer to a afsUUID
+ *    @param[out] buf  format work buffer
+ *
+ *    @returns pointer to buffer containing string representation of "uuid"
  */
 
-int
-afsUUID_to_string(const afsUUID * uuid, char *str, size_t strsz)
+char *
+afsUUID_to_string(const afsUUID * uuid, struct uuid_fmtbuf *buf)
 {
-    snprintf(str, strsz, "%08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x",
+    memset(buf, 0, sizeof(*buf));
+    snprintf(buf->buffer, sizeof(buf->buffer),
+	     "%08x-%04x-%04x-%02x-%02x-%02x%02x%02x%02x%02x%02x",
 	     uuid->time_low, uuid->time_mid, uuid->time_hi_and_version,
 	     (unsigned char)uuid->clock_seq_hi_and_reserved,
 	     (unsigned char)uuid->clock_seq_low, (unsigned char)uuid->node[0],
@@ -213,7 +220,7 @@ afsUUID_to_string(const afsUUID * uuid, char *str, size_t strsz)
 	     (unsigned char)uuid->node[3], (unsigned char)uuid->node[4],
 	     (unsigned char)uuid->node[5]);
 
-    return 0;
+    return buf->buffer;
 }
 #endif
 
@@ -393,7 +400,7 @@ uuid_get_address(uuid_address_p_t addr)
 void
 uuid__get_os_time(uuid_time_t * os_time)
 {
-    osi_timeval_t tp;
+    osi_timeval32_t tp;
 
     osi_GetTime(&tp);
     os_time->hi = tp.tv_sec;
diff --git a/src/util/vice.h b/src/util/vice.h
index 1920a352c..5342be78f 100644
--- a/src/util/vice.h
+++ b/src/util/vice.h
@@ -12,7 +12,7 @@
 
 #include <sys/types.h>
 #if !defined(AFS_NT40_ENV)
-# if (!defined(AFS_FBSD80_ENV) && !defined(AFS_LINUX26_ENV)) || !defined(KERNEL) || defined(UKERNEL)
+# if (!defined(AFS_FBSD_ENV) && !defined(AFS_LINUX26_ENV)) || !defined(KERNEL) || defined(UKERNEL)
 #  include <sys/ioctl.h>
 # endif
 #endif /* AFS_NT40_ENV */
diff --git a/src/util/volparse.c b/src/util/volparse.c
index c4cb1f877..79004fe87 100644
--- a/src/util/volparse.c
+++ b/src/util/volparse.c
@@ -57,9 +57,11 @@ volutil_GetPartitionID(char *aname)
     if (strlen(aname) <= 2) {
 	strcpy(ascii, aname);
     } else if (!strncmp(aname, "/vicep", 6)) {
-	strncpy(ascii, aname + 6, 2);
+	if(strlcpy(ascii, aname + 6, sizeof(ascii)) >= sizeof(ascii))
+	    return -1;  /* bad partition name: trailing characters */
     } else if (!strncmp(aname, "vicep", 5)) {
-	strncpy(ascii, aname + 5, 2);
+	if(strlcpy(ascii, aname + 5, sizeof(ascii)) >= sizeof(ascii))
+	    return -1;  /* bad partition name: trailing characters */
     } else
 	return -1;		/* bad partition name */
     /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab, .../vicepzz,
diff --git a/src/venus/Makefile.in b/src/venus/Makefile.in
index 78645b7d6..d778579e6 100644
--- a/src/venus/Makefile.in
+++ b/src/venus/Makefile.in
@@ -172,8 +172,6 @@ kdump: kdump.o
 		$(MAKE) kdump-alpha_linux-@LINUX_VERSION@ ;; \
 	*linux* ) \
 		$(MAKE) kdump-linux-@LINUX_VERSION@ ;; \
-	alpha_osf1 | alpha_osf20 |  alpha_osf30 | alpha_osf32 | alpha_osf32c | alpha_dux??) \
-		${CC} -o kdump kdump.o ${TOP_LIBDIR}/libcmd.a  ${TOP_LIBDIR}/util.a ${XLIBS} -ll -lmld;; \
 	ncrx86_* ) ${CC} -o kdump kdump.o ${TOP_LIBDIR}/libcmd.a  ${TOP_LIBDIR}/util.a -lelf ${XLIBS} ;; \
 	*bsd*) touch kdump ;; \
 	* )     ${CC} -o kdump kdump.o ${TOP_LIBDIR}/libcmd.a  ${TOP_LIBDIR}/util.a ${XLIBS} ;; \
@@ -197,8 +195,6 @@ kdump.o: kdump.c ${INCLS} AFS_component_version_number.c
 			$(MAKE) kdump-alpha_linux-${LINUX_VERSION}.o ;; \
 		*linux* ) \
 			$(MAKE) kdump-linux-${LINUX_VERSION}.o ;; \
-		alpha_osf1 | alpha_osf20 |  alpha_osf30 | alpha_osf32 | alpha_osf32c| alpha_dux?? ) \
-			${CC} ${AFS_CFLAGS} -I/usr/sys/include -I/usr/sys/BINARY -I/usr/sys/AFS -DDEBUGGER -c ${srcdir}/kdump.c ;;\
 		sgi_6? ) \
 			for f in ../libafs/STATIC.IP*/CPU_KDEFS; \
 			do	IP=`expr "$$f" : '../libafs/STATIC.\(IP..\)'`; \
@@ -366,7 +362,8 @@ clean:
 		AFS_component_version_number.c fstrace gcpags livesys dedebug \
 		cacheout afsio
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 include ../config/Makefile.version
diff --git a/src/venus/cmdebug.c b/src/venus/cmdebug.c
index a5596e7b4..2f16274de 100644
--- a/src/venus/cmdebug.c
+++ b/src/venus/cmdebug.c
@@ -82,7 +82,7 @@ PrintInterfaces(struct rx_connection *aconn)
 #ifdef AFS_NT40_ENV
     char * p;
 #else
-    char uuidstr[128];
+    struct uuid_fmtbuf uuidstr;
 #endif
     int i, code;
     char hoststr[16];
@@ -104,8 +104,8 @@ PrintInterfaces(struct rx_connection *aconn)
     printf("UUID: %s\n",p);
     RpcStringFree(&p);
 #else
-    afsUUID_to_string(&addr.uuid, uuidstr, sizeof(uuidstr));
-    printf("UUID: %s\n",uuidstr);
+    afsUUID_to_string(&addr.uuid, &uuidstr);
+    printf("UUID: %s\n", uuidstr.buffer);
 #endif
 
     printf("Host interfaces:\n");
@@ -569,8 +569,8 @@ CommandProc(struct cmd_syndesc *as, void *arock)
 
     if (int32p == 0 || int32p == 1)
         PrintLocks(conn, int32p);
-    if (int32p >= 0 || int32p <= 4)
-        PrintCacheEntries(conn, int32p);
+
+    PrintCacheEntries(conn, int32p);
     return 0;
 }
 
diff --git a/src/venus/fs.c b/src/venus/fs.c
index a0dfa9a26..630f44c66 100644
--- a/src/venus/fs.c
+++ b/src/venus/fs.c
@@ -761,23 +761,23 @@ QuickPrintSpace(VolumeStatus * status, char *name, int human)
 static char *
 AclToString(struct Acl *acl)
 {
-    static char mydata[AFS_PIOCTL_MAXSIZE];
+    static char mydata[AFS_PIOCTL_MAXSIZE + 24];
     char tstring[AFS_PIOCTL_MAXSIZE];
-    char dfsstring[30];
+    char dfsstring[AFS_PIOCTL_MAXSIZE];
     struct AclEntry *tp;
 
     if (acl->dfs)
-	sprintf(dfsstring, " dfs:%d %s", acl->dfs, acl->cell);
+	snprintf(dfsstring, sizeof(dfsstring), " dfs:%d %s", acl->dfs, acl->cell);
     else
 	dfsstring[0] = '\0';
-    sprintf(mydata, "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
+    snprintf(mydata, sizeof(mydata), "%d%s\n%d\n", acl->nplus, dfsstring, acl->nminus);
     for (tp = acl->pluslist; tp; tp = tp->next) {
-	sprintf(tstring, "%s %d\n", tp->name, tp->rights);
-	strcat(mydata, tstring);
+	snprintf(tstring, sizeof(tstring), "%s %d\n", tp->name, tp->rights);
+	strlcat(mydata, tstring, sizeof(mydata));
     }
     for (tp = acl->minuslist; tp; tp = tp->next) {
-	sprintf(tstring, "%s %d\n", tp->name, tp->rights);
-	strcat(mydata, tstring);
+	snprintf(tstring, sizeof(tstring), "%s %d\n", tp->name, tp->rights);
+	strlcat(mydata, tstring, sizeof(mydata));
     }
     return mydata;
 }
@@ -2402,7 +2402,7 @@ ListCellsCmd(struct cmd_syndesc *as, void *arock)
 		name = hostutil_GetNameByINet(addr);
 	    } else {
 		addr = ntohl(addr);
-		sprintf(tbuffer, "%d.%d.%d.%d", (addr >> 24) & 0xff,
+		snprintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr >> 24) & 0xff,
 			(addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
 		name = tbuffer;
 	    }
@@ -2988,10 +2988,6 @@ GetCellCmd(struct cmd_syndesc *as, void *arock)
 	    continue;
 	}
 	printf("Cell %s status: ", info.name);
-#ifdef notdef
-	if (args.stat & 1)
-	    printf("primary ");
-#endif
 	if (args.stat & 2)
 	    printf("no setuid allowed");
 	else
@@ -3326,6 +3322,9 @@ GetPrefCmd(struct cmd_syndesc *as, void *arock)
 	    if (code) {
 		if ((errno != E2BIG) || (2 * blob.out_size > 0x7FFF)) {
 		    perror("getserverprefs pioctl");
+		    if (blob.out != space) {
+			free(blob.out);
+		    }
 		    return 1;
 		}
 		blob.out_size *= 2;
@@ -3343,7 +3342,7 @@ GetPrefCmd(struct cmd_syndesc *as, void *arock)
 		name = hostutil_GetNameByINet(out->servers[i].server.s_addr);
 	    } else {
 		addr = ntohl(out->servers[i].server.s_addr);
-		sprintf(tbuffer, "%d.%d.%d.%d", (addr >> 24) & 0xff,
+		snprintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr >> 24) & 0xff,
 			(addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
 		name = tbuffer;
 	    }
@@ -3733,11 +3732,6 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-path", CMD_LIST, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, CMD_OPTIONAL,
 		"disk space quota in 1K units");
-#ifdef notdef
-    cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL,
-		"disk space guaranteed");
-    cmd_AddParm(ts, "-motd", CMD_SINGLE, CMD_OPTIONAL, "message of the day");
-#endif
     cmd_AddParm(ts, "-offlinemsg", CMD_SINGLE, CMD_OPTIONAL,
 		"offline message");
     cmd_CreateAlias(ts, "sv");
@@ -3832,9 +3826,6 @@ defect 3069
     ts = cmd_CreateSyntax("setquota", SetQuotaCmd, NULL, 0, "set volume quota");
     cmd_AddParm(ts, "-path", CMD_SINGLE, CMD_OPTIONAL, "dir/file path");
     cmd_AddParm(ts, "-max", CMD_SINGLE, 0, "max quota in kbytes");
-#ifdef notdef
-    cmd_AddParm(ts, "-min", CMD_SINGLE, CMD_OPTIONAL, "min quota in kbytes");
-#endif
     cmd_CreateAlias(ts, "sq");
 
     ts = cmd_CreateSyntax("newcell", NewCellCmd, NULL, 0, "configure new cell");
@@ -4054,9 +4045,9 @@ GetClientAddrsCmd(struct cmd_syndesc *as, void *arock)
 	    out = (struct sprefinfo *)blob.out;
 	    for (i = 0; i < out->num_servers; i++) {
 		afs_int32 addr;
-		char tbuffer[32];
+		char tbuffer[20];
 		addr = ntohl(out->servers[i].server.s_addr);
-		sprintf(tbuffer, "%d.%d.%d.%d", (addr >> 24) & 0xff,
+		snprintf(tbuffer, sizeof(tbuffer), "%d.%d.%d.%d", (addr >> 24) & 0xff,
 			(addr >> 16) & 0xff, (addr >> 8) & 0xff, addr & 0xff);
 		printf("%-50s\n", tbuffer);
 	    }
diff --git a/src/venus/fstrace.c b/src/venus/fstrace.c
index 12a594972..38c1cc087 100644
--- a/src/venus/fstrace.c
+++ b/src/venus/fstrace.c
@@ -24,7 +24,7 @@
 #include <afs/vice.h>
 #include <afs/sys_prototypes.h>
 
-#if defined(AFS_OSF_ENV) || defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
+#if defined(AFS_SGI61_ENV) || (defined(AFS_AIX51_ENV) && defined(AFS_64BIT_KERNEL))
 /* For SGI 6.2, this is changed to 1 if it's a 32 bit kernel. */
 int afs_icl_sizeofLong = 2;
 #else
@@ -296,10 +296,7 @@ DisplayRecord(FILE *outFilep, afs_int32 *alp, afs_int32 rsize)
 		printfParms[pfpix] <<= 32;
 		printfParms[pfpix] |= alp[pix + 1];
 	    }
-#elif defined(AFS_OSF_ENV)
-	    printfParms[pfpix] = alp[pix + 1];
-	    printfParms[pfpix] |= (alp[pix] <<= 32);
-#else /* !AFS_OSF_ENV && !AFS_SGI61_ENV */
+#else /* !AFS_SGI61_ENV */
 	    printfParms[pfpix] = alp[pix];
 #endif
 	    pfpix++;
@@ -510,9 +507,6 @@ DisplayRecord(FILE *outFilep, afs_int32 *alp, afs_int32 rsize)
 
 
 #include <locale.h>
-#ifdef	AFS_OSF_ENV
-#include <limits.h>
-#endif
 #include <nl_types.h>
 
 #define FACILITY_CODE_MASK          0xF0000000
@@ -759,10 +753,6 @@ icl_DumpKernel(FILE *outFilep, char *setname)
 	    /* print the record */
 	    DisplayRecord(outFilep, &bufferp[ix], rlength);
 	    ix += rlength;
-#ifdef notdef
-	    /* obsolete: read entire buffer first */
-	    i += rlength;	/* update cookie value, too */
-#endif
 	}			/* for loop displaying buffer */
     }				/* for loop over all logs */
 
@@ -1120,12 +1110,22 @@ afs_syscall(long call, long parm0, long parm1, long parm2, long parm3,
     /* Linux can only handle 5 arguments in the actual syscall. */
     if (call == AFSCALL_ICL) {
 	rval = proc_afs_syscall(call, parm0, parm1, parm2, (long)eparm, &code);
-	if (rval)
+	if (rval) {
+#ifdef AFS_SYSCALL
 	    code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, eparm);
+#else
+	    code = -1;
+#endif
+	}
     } else {
 	rval = proc_afs_syscall(call, parm0, parm1, parm2, parm3, &code);
-	if (rval)
+	if (rval) {
+#ifdef AFS_SYSCALL
 	    code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3);
+#else
+	    code = -1;
+#endif
+	}
     }
 #if defined(AFS_SPARC64_LINUX20_ENV) || defined(AFS_SPARC_LINUX20_ENV)
     /* on sparc this function returns none value, so do it myself */
@@ -1137,7 +1137,11 @@ afs_syscall(long call, long parm0, long parm1, long parm2, long parm3,
     if (!code) code = rval;
 #else
 #if !defined(AFS_SGI_ENV) && !defined(AFS_AIX32_ENV)
+# if defined(AFS_SYSCALL)
     code = syscall(AFS_SYSCALL, call, parm0, parm1, parm2, parm3, parm4);
+# else
+    code = -1;
+# endif
 #else
 #if defined(AFS_SGI_ENV)
     code = syscall(AFS_ICL, call, parm0, parm1, parm2, parm3, parm4);	/* XXX */
diff --git a/src/venus/kdump.c b/src/venus/kdump.c
index 4ed65c4d0..c5d0384e7 100644
--- a/src/venus/kdump.c
+++ b/src/venus/kdump.c
@@ -116,45 +116,6 @@ struct ncp_sb_info {
 
 #include <afs/stds.h>
 
-#if defined(AFS_OSF_ENV)
-#define	KERNEL
-#define	UNIX_LOCKS
-#define	_KERNEL	1
-#ifdef	_KERN_LOCK_H_
-#include FFFFF
-#endif
-#include <kern/lock.h>
-#include <sys/vnode.h>
-#include <arch/alpha/pmap.h>
-
-/*
- * beginning with DUX 4.0A, the system header files define the macros
- *
- * KSEG_TO_PHYS()
- * IS_KSEG_VA()
- * IS_SEG1_VA()
- *
- * to be calls to the kernel functions
- *
- * kseg_to_phys()
- * is_kseg_va()
- * is_seg1_va()
- *
- * when _KERNEL is defined, and expressions otherwise.  Since need
- * to define _KERNEL, we redefine these kernel functions as macros
- * for the expressions that we would have gotten if _KERNEL had not
- * been defined.  Yes, this duplicates code from the header files, but
- * there's no simple way around it.
- */
-
-#define kseg_to_phys(addr) ((vm_offset_t)(addr) - UNITY_BASE)
-#define is_kseg_va(x)   (((unsigned long)(x) & SEG1_BASE) == UNITY_BASE)
-#define is_seg1_va(x)   (((unsigned long)(x) & SEG1_BASE) == SEG1_BASE)
-
-#undef	KERNEL
-#undef  _KERNEL
-#endif
-
 #ifdef	AFS_SUN5_ENV /*XXXXX*/
 #include <sys/t_lock.h>
 struct vnode foo;
@@ -203,7 +164,7 @@ struct vnode foo;
 # include <netinet/in.h>	/* struct in_addr */
 #endif
 
-#if defined(AFS_SGI_ENV) || defined(AFS_OSF_ENV)
+#if defined(AFS_SGI_ENV)
 #ifdef       AFS_SGI_ENV
 #include <sys/vnode.h>
 #endif /* AFS_SGI_ENV */
@@ -258,12 +219,6 @@ struct vnode foo;
 struct timezone {
     int a, b;
 };
-#if 0				/*ndef AFS_ALPHA_LINUX20_ENV */
-typedef struct timeval {
-    int tv_sec;
-    int tv_usec;
-} timeval_t;			/* Needed here since KERNEL defined. */
-#endif /*AFS_ALPHA_LINUX20_ENV */
 #if defined(WORDS_BIGENDIAN)
 #define _LINUX_BYTEORDER_BIG_ENDIAN_H
 #else
@@ -355,15 +310,6 @@ typedef kmutex_t afs_kmutex_t;
 typedef kcondvar_t afs_kcondvar_t;
 #endif /* AFS_SUN5_ENV */
 
-#ifdef AFS_DUX40_ENV
-#define RX_ENABLE_LOCKS
-typedef struct {
-    unsigned long lock;
-    void *owner;
-} afs_kmutex_t;
-typedef int afs_kcondvar_t;
-#endif /* AFS_DUX40_ENV */
-
 #ifdef AFS_HPUX110_ENV
 #define RX_ENABLE_LOCKS
 typedef struct {
@@ -409,7 +355,7 @@ typedef void *afs_kcondvar_t;
 typedef struct {
     int tv_sec;
     int tv_usec;
-} osi_timeval_t;		/* Needed here since KERNEL defined. */
+} osi_timeval32_t;		/* Needed here since KERNEL defined. */
 
 /*#include "afs/volerrors.h"*/
 #ifdef AFS_LINUX20_ENV
@@ -449,15 +395,6 @@ extern off64_t lseek64();
 
 #undef	KERNEL
 
-#if defined(AFS_OSF_ENV) && !defined(v_count)
-#define v_count         v_usecount
-#endif
-
-#ifdef	AFS_OSF_ENV
-#define	KERNELBASE	0x80000000
-#define	coreadj(x)	((int)x - KERNELBASE)
-#endif
-
 #if defined(AFS_SGI_ENV)
 #define UNIX "/unix"
 #else
@@ -1043,15 +980,6 @@ findsym(char *sname, off_t * offset)
 		    errno, strerror(errno));
 	    exit(1);
 	}
-#if	defined(AFS_OSF_ENV)
-	if (mem) {
-	    long X;
-
-	    X = coreadj(request[0].n_value);
-	    request[0].n_value = X;
-	}
-#endif /* defined(AFS_OSF_ENV) */
-
 	*offset = request[0].n_value;
 	if (!request[0].n_value) {
 	    printf("(WARNING) Couldn't find %s in %s. Proceeding..\n", sname,
@@ -2197,79 +2125,6 @@ readmem(kmem, buf, vad, len)
 }
 #endif
 
-#ifdef	AFS_OSF_ENV
-static
-read_addr(int fd, unsigned long addr, unsigned long *val)
-{
-    if (lseek(fd, addr, SEEK_SET) == -1)
-	return (0);
-    if (read(fd, val, sizeof(long)) != sizeof(long))
-	return (0);
-    return (1);
-}
-
-static pt_entry_t *ptes = NULL;
-static
-addr_to_offset(unsigned long addr, unsigned long *ret, int fd)
-{
-    off_t symoff;
-    pt_entry_t pte, *val;
-    char *str, *ptr;
-
-    if (IS_SEG1_VA(addr)) {
-	if (ptes == NULL) {
-	    int i, loc;
-	    unsigned long loc1, loc2[2];
-	    findsym("kernel_pmap", &symoff);
-	    loc1 = coreadj(symoff);
-	    /*printf("ptes=%lx -> %lx\n", symoff, loc1); */
-	    if (lseek(fd, loc1, L_SET /*0 */ ) != loc1) {
-		perror("lseek");
-		exit(1);
-	    }
-	    if ((i = read(fd, (char *)&loc1, sizeof(long))) != sizeof(long)) {
-		printf("Read of kerne_map failed\n");
-		return;		/*exit(1); */
-	    }
-	    loc = loc1;
-	    /*printf("loc1 %lx -> %lx\n",  loc1, loc); */
-	    if (lseek(fd, loc, L_SET /*0 */ ) != loc) {
-		perror("lseek");
-		exit(1);
-	    }
-	    if ((i =
-		 read(fd, (char *)loc2,
-		      2 * sizeof(long))) != 2 * sizeof(long)) {
-		printf("Read of kerne_map failed\n");
-		return;		/*exit(1); */
-	    }
-	    ptes = (pt_entry_t *) loc2[1];
-	    /*printf("ptes=%lx\n", ptes); */
-
-	}
-	if (!addr_to_offset
-	    ((unsigned long)(ptes + LEVEL1_PT_OFFSET(addr)),
-	     (unsigned long *)&val, fd))
-	    return (0);
-	if (!read_addr(fd, (unsigned long)val, (unsigned long *)&pte))
-	    return (0);
-	val = ((pt_entry_t *) PTETOPHYS(&pte)) + LEVEL2_PT_OFFSET(addr);
-	if (!read_addr(fd, (unsigned long)val, (unsigned long *)&pte))
-	    return (0);
-	val = ((pt_entry_t *) PTETOPHYS(&pte)) + LEVEL3_PT_OFFSET(addr);
-	if (!read_addr(fd, (unsigned long)val, (unsigned long *)&pte))
-	    return (0);
-	*ret = PTETOPHYS(&pte) + (addr & ((1 << PGSHIFT) - 1));
-	return (1);
-    } else if (IS_KSEG_VA(addr)) {
-	*ret = KSEG_TO_PHYS(addr);
-	return (1);
-    } else {
-	return (0);
-    }
-}
-#endif
-
 #ifndef AFS_KDUMP_LIB
 void
 kread(int kmem, off_t loc, void *buf, KDUMP_SIZE_T len)
@@ -2278,19 +2133,6 @@ kread(int kmem, off_t loc, void *buf, KDUMP_SIZE_T len)
 
     memset(buf, 0, len);
 
-#ifdef	AFS_OSF_ENV
-    if (mem) {
-	unsigned long ret;
-	i = addr_to_offset(loc, &ret, kmem);
-	if (i == 1)
-	    loc = ret;
-	else {
-	    unsigned long loc1;
-	    loc1 = coreadj(loc);
-	    loc = loc1;
-	}
-    }
-#else
 #if	defined(sparc) && !defined(__linux__)
 #ifndef AFS_SUN5_ENV
     if (mem) {
@@ -2301,7 +2143,6 @@ kread(int kmem, off_t loc, void *buf, KDUMP_SIZE_T len)
     }
 #endif
 #endif
-#endif
 #if	! defined(AFS_SUN5_ENV)
 #if defined(AFS_SGI61_ENV) && !defined(AFS_32BIT_KERNEL_ENV)
     if (lseek64(kmem, loc, L_SET /*0 */ ) != loc)
@@ -2997,17 +2838,6 @@ print_vlru(int kmem)
     printf("\n\nPrinting vcache VLRU info (oldest first)...\n\n");
     findsym("afs_cacheStats", &symoff);
     kread(kmem, symoff, (char *)&maxvcount, sizeof maxvcount);
-#ifdef	AFS_OSF_ENV
-    findsym("afs_maxvcount", &symoff);
-    kread(kmem, symoff, (char *)&maxvcount, sizeof maxvcount);
-    findsym("afs_vcount", &symoff);
-    kread(kmem, symoff, (char *)&vcount, sizeof vcount);
-    findsym("max_vnodes", &symoff);
-    kread(kmem, symoff, (char *)&nvnode, sizeof nvnode);
-    printf("max number of vcache entries = %d\n", maxvcount);
-    printf("number of vcaches in use = %d\n", vcount);
-    printf("total number of system vnode entries = %d\n", nvnode);
-#endif
     findsym("VLRU", &symoff);
     kread(kmem, symoff, (char *)&VLRU, sizeof VLRU);
     vlru_addr = (u_long) symoff;
@@ -3234,11 +3064,9 @@ print_global_afs_cache(int kmem)
     findsym("afs_mariner", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
     printf("\tafs_mariner = 0x%x\n", count);
-#ifndef	AFS_OSF_ENV
     findsym("freeVCList", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
     printf("\tafs_freeVCList = 0x%x XXX\n", count);
-#endif
     findsym("afs_freeDCList", &symoff);
     kread(kmem, symoff, (char *)&count, sizeof count);
     printf("\tfreeDCList = 0x%x\n", count);
@@ -4350,7 +4178,6 @@ print_cmstats(struct afs_CMStats *cmp)
     printf("\t%10d afs_ConnByHost\n", cmp->callInfo.C_afs_ConnByHost);
     printf("\t%10d afs_ConnByMHosts\n", cmp->callInfo.C_afs_ConnByMHosts);
     printf("\t%10d afs_Analyze\n", cmp->callInfo.C_afs_Analyze);
-    printf("\t%10d afs_CheckLocks\n", cmp->callInfo.C_afs_CheckLocks);
     printf("\t%10d CheckVLServer\n", cmp->callInfo.C_CheckVLServer);
     printf("\t%10d afs_CheckCacheResets\n",
 	   cmp->callInfo.C_afs_CheckCacheResets);
@@ -4464,162 +4291,3 @@ print_cmstats(struct afs_CMStats *cmp)
 }
 
 #endif
-#if 0
-#define OffsetOf(s,mem)	((long)(&(((s *)0)->mem)))
-#define SizeOf(s,mem)	((long)sizeof(((s *)0)->mem))
-#define values(s,mem)	OffsetOf(s,mem), SizeOf(s,mem)
-
-print_struct_vcache_offsets()
-{
-    printf("struct vcache.v              offset = %ld, size = %ld\n",
-	   values(struct vcache, v));
-    printf("struct vcache.vlruq          offset = %ld, size = %ld\n",
-	   values(struct vcache, vlruq));
-    printf("struct vcache.nextfree       offset = %ld, size = %ld\n",
-	   values(struct vcache, nextfree));
-    printf("struct vcache.hnext          offset = %ld, size = %ld\n",
-	   values(struct vcache, hnext));
-    printf("struct vcache.fid            offset = %ld, size = %ld\n",
-	   values(struct vcache, fid));
-    printf("struct vcache.m              offset = %ld, size = %ld\n",
-	   values(struct vcache, m));
-    printf("struct vcache.lock           offset = %ld, size = %ld\n",
-	   values(struct vcache, lock));
-    printf("struct vcache.parentVnode    offset = %ld, size = %ld\n",
-	   values(struct vcache, parentVnode));
-    printf("struct vcache.parentUnique   offset = %ld, size = %ld\n",
-	   values(struct vcache, parentUnique));
-    printf("struct vcache.mvid           offset = %ld, size = %ld\n",
-	   values(struct vcache, mvid));
-    printf("struct vcache.linkData       offset = %ld, size = %ld\n",
-	   values(struct vcache, linkData));
-    printf("struct vcache.flushDV        offset = %ld, size = %ld\n",
-	   values(struct vcache, flushDV));
-    printf("struct vcache.mapDV          offset = %ld, size = %ld\n",
-	   values(struct vcache, mapDV));
-    printf("struct vcache.truncPos       offset = %ld, size = %ld\n",
-	   values(struct vcache, truncPos));
-    printf("struct vcache.callback       offset = %ld, size = %ld\n",
-	   values(struct vcache, callback));
-    printf("struct vcache.cbExpires      offset = %ld, size = %ld\n",
-	   values(struct vcache, cbExpires));
-    printf("struct vcache.callsort       offset = %ld, size = %ld\n",
-	   values(struct vcache, callsort));
-    printf("struct vcache.Access         offset = %ld, size = %ld\n",
-	   values(struct vcache, Access));
-    printf("struct vcache.anyAccess      offset = %ld, size = %ld\n",
-	   values(struct vcache, anyAccess));
-    printf("struct vcache.last_looker    offset = %ld, size = %ld\n",
-	   values(struct vcache, last_looker));
-    printf("struct vcache.activeV        offset = %ld, size = %ld\n",
-	   values(struct vcache, activeV));
-    printf("struct vcache.slocks         offset = %ld, size = %ld\n",
-	   values(struct vcache, slocks));
-    printf("struct vcache.opens          offset = %ld, size = %ld\n",
-	   values(struct vcache, opens));
-    printf("struct vcache.execsOrWriters offset = %ld, size = %ld\n",
-	   values(struct vcache, execsOrWriters));
-    printf("struct vcache.flockCount     offset = %ld, size = %ld\n",
-	   values(struct vcache, flockCount));
-    printf("struct vcache.mvstat         offset = %ld, size = %ld\n",
-	   values(struct vcache, mvstat));
-    printf("struct vcache.states         offset = %ld, size = %ld\n",
-	   values(struct vcache, states));
-    printf("struct vcache.quick          offset = %ld, size = %ld\n",
-	   values(struct vcache, quick));
-    printf("struct vcache.symhintstamp   offset = %ld, size = %ld\n",
-	   values(struct vcache, symhintstamp));
-    printf("struct vcache.h1             offset = %ld, size = %ld\n",
-	   values(struct vcache, h1));
-    printf("struct vcache.lastr          offset = %ld, size = %ld\n",
-	   values(struct vcache, lastr));
-    printf("struct vcache.vc_rwlockid    offset = %ld, size = %ld\n",
-	   values(struct vcache, vc_rwlockid));
-    printf("struct vcache.vc_locktrips   offset = %ld, size = %ld\n",
-	   values(struct vcache, vc_locktrips));
-    printf("struct vcache.vc_rwlock      offset = %ld, size = %ld\n",
-	   values(struct vcache, vc_rwlock));
-    printf("struct vcache.mapcnt         offset = %ld, size = %ld\n",
-	   values(struct vcache, mapcnt));
-    printf("struct vcache.cred           offset = %ld, size = %ld\n",
-	   values(struct vcache, cred));
-    printf("struct vcache.vc_bhv_desc    offset = %ld, size = %ld\n",
-	   values(struct vcache, vc_bhv_desc));
-    printf("struct vcache.vc_error       offset = %ld, size = %ld\n",
-	   values(struct vcache, vc_error));
-    printf("struct vcache.xlatordv       offset = %ld, size = %ld\n",
-	   values(struct vcache, xlatordv));
-    printf("struct vcache.uncred         offset = %ld, size = %ld\n",
-	   values(struct vcache, uncred));
-    printf("struct vcache.asynchrony     offset = %ld, size = %ld\n",
-	   values(struct vcache, asynchrony));
-}
-
-print_struct_vnode_offsets()
-{
-    printf("struct vnode.v_list           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_list));
-    printf("struct vnode.v_flag           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_flag));
-    printf("struct vnode.v_count          offset = %ld, size = %ld\n",
-	   values(struct vnode, v_count));
-    printf("struct vnode.v_listid         offset = %ld, size = %ld\n",
-	   values(struct vnode, v_listid));
-    printf("struct vnode.v_intpcount      offset = %ld, size = %ld\n",
-	   values(struct vnode, v_intpcount));
-    printf("struct vnode.v_type           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_type));
-    printf("struct vnode.v_rdev           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_rdev));
-    printf("struct vnode.v_vfsmountedhere offset = %ld, size = %ld\n",
-	   values(struct vnode, v_vfsmountedhere));
-    printf("struct vnode.v_vfsp           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_vfsp));
-    printf("struct vnode.v_stream         offset = %ld, size = %ld\n",
-	   values(struct vnode, v_stream));
-    printf("struct vnode.v_filocks        offset = %ld, size = %ld\n",
-	   values(struct vnode, v_filocks));
-    printf("struct vnode.v_filocksem      offset = %ld, size = %ld\n",
-	   values(struct vnode, v_filocksem));
-    printf("struct vnode.v_number         offset = %ld, size = %ld\n",
-	   values(struct vnode, v_number));
-    printf("struct vnode.v_bh             offset = %ld, size = %ld\n",
-	   values(struct vnode, v_bh));
-    printf("struct vnode.v_namecap        offset = %ld, size = %ld\n",
-	   values(struct vnode, v_namecap));
-    printf("struct vnode.v_hashp          offset = %ld, size = %ld\n",
-	   values(struct vnode, v_hashp));
-    printf("struct vnode.v_hashn          offset = %ld, size = %ld\n",
-	   values(struct vnode, v_hashn));
-    printf("struct vnode.v_mreg           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_mreg));
-    printf("struct vnode.v_mregb          offset = %ld, size = %ld\n",
-	   values(struct vnode, v_mregb));
-    printf("struct vnode.v_pgcnt          offset = %ld, size = %ld\n",
-	   values(struct vnode, v_pgcnt));
-    printf("struct vnode.v_dpages         offset = %ld, size = %ld\n",
-	   values(struct vnode, v_dpages));
-    printf("struct vnode.v_dpages_gen     offset = %ld, size = %ld\n",
-	   values(struct vnode, v_dpages_gen));
-    printf("struct vnode.v_dbuf           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_dbuf));
-    printf("struct vnode.v_buf            offset = %ld, size = %ld\n",
-	   values(struct vnode, v_buf));
-    printf("struct vnode.v_bufgen         offset = %ld, size = %ld\n",
-	   values(struct vnode, v_bufgen));
-    printf("struct vnode.v_traceix        offset = %ld, size = %ld\n",
-	   values(struct vnode, v_traceix));
-    printf("struct vnode.v_buf_lock       offset = %ld, size = %ld\n",
-	   values(struct vnode, v_buf_lock));
-    printf("struct vnode.v_pc             offset = %ld, size = %ld\n",
-	   values(struct vnode, v_pc));
-#ifdef VNODE_TRACING
-    printf("struct vnode.v_trace          offset = %ld, size = %ld\n",
-	   values(struct vnode, v_trace));
-#endif
-#ifdef CKPT
-    printf("struct vnode.v_ckpt           offset = %ld, size = %ld\n",
-	   values(struct vnode, v_ckpt));
-#endif
-}
-#endif
diff --git a/src/venus/test/fulltest.c b/src/venus/test/fulltest.c
index e3b6d9beb..9018dcdf7 100644
--- a/src/venus/test/fulltest.c
+++ b/src/venus/test/fulltest.c
@@ -89,14 +89,6 @@ main(int argc, char **argv)
 	printf("fchmod failed to set mode properly\n");
 	return -1;
     }
-#if 0
-    /* These appear to be defunct routines;
-     * I don't know what, if anything, replaced them */
-    if (osi_ExclusiveLockNoBlock(fd1) < 0)
-	{perror("flock1");return -1;}
-    if (osi_UnLock(fd1) < 0)
-	{perror("flock/unlock");return -1;}
-#endif
 
 /* How about shared lock portability? */
     {
diff --git a/src/vfsck/Makefile.in b/src/vfsck/Makefile.in
index 542700f42..c5e7452cb 100644
--- a/src/vfsck/Makefile.in
+++ b/src/vfsck/Makefile.in
@@ -25,10 +25,10 @@ MODULE_CFLAGS=${VFSCK_CFLAGS}
 
 SRCS= dir.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c \
 	pass4.c pass5.c setup.c utilities.c ufs_subr.c \
-	ufs_tables.c dirutils.c vprintf.c proplist.c
+	ufs_tables.c dirutils.c vprintf.c
 
 OBJS= dir.o inode.o main.o pass1.o pass1b.o pass2.o pass3.o pass4.o \
-	pass5.o setup.o utilities.o dirutils.o vprintf.o proplist.o \
+	pass5.o setup.o utilities.o dirutils.o vprintf.o \
 	ufs_subr.o ufs_tables.o
 
 all: vfsck
diff --git a/src/vfsck/dir.c b/src/vfsck/dir.c
index fb657445c..5cfe0ef37 100644
--- a/src/vfsck/dir.c
+++ b/src/vfsck/dir.c
@@ -40,17 +40,6 @@
 
 #define VICE			/* allow us to put our changes in at will */
 
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #include <sys/vnode.h>
@@ -77,7 +66,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #ifdef AFS_SUN_ENV
 #ifdef	AFS_SUN5_ENV
diff --git a/src/vfsck/fsck.h b/src/vfsck/fsck.h
index 8483e640b..597932924 100644
--- a/src/vfsck/fsck.h
+++ b/src/vfsck/fsck.h
@@ -114,13 +114,6 @@ struct bufarea *getdatablk();
 #define	sblock		(*sblk.b_un.b_fs)
 #define	cgrp		(*cgblk.b_un.b_cg)
 
-#ifdef	AFS_OSF_ENV
-/*
- * struct direct -> struct dirent
-*/
-#define	direct	dirent
-#endif /* AFS_OSF_ENV */
-
 enum fixstate { DONTKNOW, NOFIX, FIX };
 
 struct inodesc {
@@ -250,12 +243,7 @@ int rflag;			/* check raw file systems */
 #include <sys/sysmacros.h>
 FILE *logfile;			/* additional place for log message, for non-root file systems */
 #else /* AFS_SUN5_ENV */
-#ifdef	AFS_OSF_ENV
-FILE *logfile;			/* additional place for log message, for non-root file systems */
-char fflag;			/* force fsck to check a mounted fs */
-#else /* AFS_OSF_ENV */
 struct _iobuf *logfile;		/* additional place for log message, for non-root file systems */
-#endif /* AFS_OSF_ENV */
 #endif /* AFS_SUN5_ENV */
 #endif /* VICE */
 
diff --git a/src/vfsck/inode.c b/src/vfsck/inode.c
index 58fc980e4..f49446112 100644
--- a/src/vfsck/inode.c
+++ b/src/vfsck/inode.c
@@ -40,17 +40,6 @@
 
 #define VICE			/* control whether AFS changes are present */
 
-#ifdef	AFS_OSF_ENV
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #include <sys/vnode.h>
@@ -74,7 +63,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include <afs/osi_inode.h>
 #include "fsck.h"
@@ -109,24 +97,9 @@ ckinode(dp, idesc)
     idesc->id_filesize = dp->di_size;
     if ((dp->di_mode & IFMT) == IFBLK || (dp->di_mode & IFMT) == IFCHR)
 	return (KEEPON);
-#ifdef	AFS_OSF_ENV
-    if ((dp->di_flags & IC_FASTLINK) != 0) {
-	return (KEEPON);
-    }
-#endif /* AFS_OSF_ENV */
     dino = *dp;
     ndb = howmany(dino.di_size, (UOFF_T) sblock.fs_bsize);
     ap = &dino.di_db[0];
-#ifdef AFS_OSF_ENV
-    /*
-     * Check property lists on pass1
-     */
-    if (idesc->id_func == pass1check && dino.di_flags & IC_PROPLIST && *ap) {
-	ret = proplist_scan(dp, idesc);
-	if (ret & STOP)
-	    return (ret);
-    }
-#endif /* AFS_OSF_ENV */
     for (; ap < &dino.di_db[NDADDR]; ap++) {
 	if (--ndb == 0 && (offset = blkoff(&sblock, dino.di_size)) != 0)
 	    idesc->id_numfrags =
diff --git a/src/vfsck/main.c b/src/vfsck/main.c
index dc466033c..679c5419d 100644
--- a/src/vfsck/main.c
+++ b/src/vfsck/main.c
@@ -52,12 +52,6 @@
 #undef KERNEL
 #endif
 
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #include <sys/vnode.h>
@@ -85,7 +79,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include <sys/wait.h>
 #ifdef	XAFS_SUN_ENV
@@ -178,7 +171,7 @@ main(argc, argv)
 #if	defined(AFS_HPUX_ENV)
     pclean = 0;
 #endif
-#if	defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV) || defined(AFS_OSF_ENV)
+#if	defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV)
     fflag = 0;
 #endif
 #ifdef	AFS_SUN5_ENV
@@ -334,11 +327,6 @@ main(argc, argv)
 	    break;
 #endif /* AFS_HPUX100_ENV */
 #endif /* AFS_SUN5_ENV */
-#ifdef	AFS_OSF_ENV
-	case 'o':
-	    fflag++;
-	    break;
-#endif /* AFS_OSF_ENV */
 	case 'n':
 	case 'N':
 	    nflag++;
@@ -435,11 +423,6 @@ main(argc, argv)
 		&& strcmp(fsp->fs_type, FSTAB_RO)
 		&& strcmp(fsp->fs_type, FSTAB_RQ))
 		continue;
-#ifdef	AFS_OSF_ENV
-	    if (strcmp(fsp->fs_vfstype, "ufs") || fsp->fs_passno == 0) {
-		continue;
-	    }
-#endif /* AFS_OSF_ENV */
 	    if (preen == 0 || passno == 1 && fsp->fs_passno == 1) {
 		if (passno == 1) {
 		    name = blockcheck(fsp->fs_spec);
@@ -618,10 +601,6 @@ checkfilesys(filesys, parname)
     char devbuffer[128];
     int ret_val;
 
-#ifdef	AFS_OSF_ENV
-    int temp;
-#endif /* AFS_OSF_ENV */
-
 #ifdef	AFS_SUN_ENV
     iscorrupt = 1;
 #endif
@@ -659,10 +638,6 @@ checkfilesys(filesys, parname)
 #ifdef	AFS_HPUX_ENV
 	} else if (ret_val == -1) {	/* pclean && FS_CLEAN */
 	    return (1);
-#endif
-#if	defined(AFS_OSF_ENV)
-	} else if (ret_val == FS_CLEAN) {	/* pclean && FS_CLEAN */
-	    return (1);
 #endif
 	}
 #if	defined(AFS_HPUX100_ENV)
@@ -874,21 +849,10 @@ checkfilesys(filesys, parname)
 	sbdirty();
     }
 #else
-#ifdef	AFS_OSF_ENV
-    if (!nflag && !bflag && !hotroot) {
-	temp = fsmodified;
-	sblock.fs_clean = FS_CLEAN;
-	(void)time(&sblock.fs_time);
-	sbdirty();
-	flush(fswritefd, &sblk);
-	fsmodified = temp;
-    }
-#else /* AFS_OSF_ENV */
     if (fsmodified) {
 	(void)time(&sblock.fs_time);
 	sbdirty();
     }
-#endif
 #endif
     ckfini();
     free(blockmap);
@@ -957,18 +921,6 @@ checkfilesys(filesys, parname)
 		failed = 1;
 	    }
 	}
-#endif
-#ifdef	AFS_OSF_ENV
-	/* if system mounted / as read-only, we'll try to fix now */
-	if (access("/", W_OK) < 0 && errno == EROFS) {
-	    printf("Can't RW acceess /; %d\n", errno);
-	    code = system("/sbin/mount -u /");
-	    if (code) {
-		printf("Couldn't remount / R/W; continuing anyway (%d).\n",
-		       errno);
-		failed = 1;
-	    }
-	}
 #endif
 	rmdir(pname);
 	unlink(pname);
@@ -1010,14 +962,10 @@ checkfilesys(filesys, parname)
 		fstat(fd, &tstat);
 		close(fd);
 	    }
-#if !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV) && !defined(AFS_OSF_ENV)
+#if !defined(AFS_HPUX_ENV) && !defined(AFS_SUN5_ENV)
 	    unmount(pname);
 #else
-#if	defined(AFS_OSF_ENV)
-	    umount(pname, MNT_NOFORCE);
-#else /* AFS_OSF_ENV */
 	    umount(devname);
-#endif
 #endif
 	}
 	rmdir(pname);
@@ -1054,9 +1002,7 @@ blockcheck(name)
     if ((stblock.st_mode & S_IFMT) == S_IFBLK) {
 	if (stslash.st_dev == stblock.st_rdev) {
 	    hotroot++;
-#if	!defined(AFS_OSF_ENV)	/*  OSF/1 always uses the raw device, even for / */
 	    return (name);
-#endif /* AFS_OSF_ENV */
 	}
 	raw = rawname(name);
 	if (raw) {
diff --git a/src/vfsck/pass1.c b/src/vfsck/pass1.c
index cbcfabd4e..262abad50 100644
--- a/src/vfsck/pass1.c
+++ b/src/vfsck/pass1.c
@@ -23,17 +23,6 @@
 #include <ctype.h>
 
 #define VICE
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -58,7 +47,6 @@ extern int ge_danger;
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include <afs/osi_inode.h>
 #include "fsck.h"
@@ -247,9 +235,6 @@ pass1()
 	    if ((dp->di_mode & IFMT) == IFBLK
 		|| (dp->di_mode & IFMT) == IFCHR)
 		ndb++;
-#ifdef	AFS_OSF_ENV
-	    if ((dp->di_flags & IC_FASTLINK) == 0) {
-#endif /* AFS_OSF_ENV */
 		for (j = ndb; j < NDADDR; j++) {
 #if defined(AFS_HPUX_ENV) && (defined(DUX) || defined(CNODE_DEV))
 		    /*
@@ -284,9 +269,6 @@ pass1()
 #if	defined(AFS_HPUX_ENV)
 	      ignore_direct_block_check:
 #endif
-#ifdef	AFS_OSF_ENV
-	    }
-#endif /* AFS_OSF_ENV */
 	    if (ftypeok(dp) == 0)
 		goto unknown;
 	    n_files++;
diff --git a/src/vfsck/pass1b.c b/src/vfsck/pass1b.c
index 69d2941f2..92f0f1698 100644
--- a/src/vfsck/pass1b.c
+++ b/src/vfsck/pass1b.c
@@ -23,17 +23,6 @@
 #include <ctype.h>
 
 #define VICE
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -56,7 +45,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include "fsck.h"
 
diff --git a/src/vfsck/pass2.c b/src/vfsck/pass2.c
index 2858c92e7..9d0b7456c 100644
--- a/src/vfsck/pass2.c
+++ b/src/vfsck/pass2.c
@@ -39,17 +39,6 @@
 #include <ctype.h>
 
 #define VICE
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -72,7 +61,6 @@
 #include <sys/fs.h>
 
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #include <afs/osi_inode.h>
 
 #include "fsck.h"
@@ -152,7 +140,7 @@ pass2()
 #else /* no ACLS */
 	statemap[ROOTINO] = DSTATE;
 #endif /* ACLS */
-	/* fall into ... */
+	AFS_FALLTHROUGH;
 
     case DSTATE:
 	descend(&rootdesc, ROOTINO);
@@ -359,7 +347,7 @@ pass2check(idesc)
 		else if ((n = reply("REMOVE")) == 1)
 		    break;
 	    }
-	    /* fall through */
+	    AFS_FALLTHROUGH;
 
 	case FSTATE:
 #ifdef VICE
diff --git a/src/vfsck/pass3.c b/src/vfsck/pass3.c
index 655deb40e..808d64d0c 100644
--- a/src/vfsck/pass3.c
+++ b/src/vfsck/pass3.c
@@ -24,17 +24,6 @@
 
 #define VICE
 
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -57,7 +46,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include <afs/osi_inode.h>
 #include "fsck.h"
diff --git a/src/vfsck/pass4.c b/src/vfsck/pass4.c
index 86c8a214c..3d73dacb3 100644
--- a/src/vfsck/pass4.c
+++ b/src/vfsck/pass4.c
@@ -23,17 +23,6 @@
 #include <ctype.h>
 
 #define VICE
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -56,7 +45,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #include <afs/osi_inode.h>
 
 #include "fsck.h"
diff --git a/src/vfsck/pass5.c b/src/vfsck/pass5.c
index 2632e247e..4ac84feee 100644
--- a/src/vfsck/pass5.c
+++ b/src/vfsck/pass5.c
@@ -23,17 +23,6 @@
 #include <ctype.h>
 
 #define VICE
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -56,12 +45,11 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #include <afs/osi_inode.h>
 
 #include "fsck.h"
 
-#if	defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
+#if	defined(AFS_SUN_ENV)
 #define AFS_NEWCG_ENV
 #else
 #undef AFS_NEWCG_ENV
@@ -156,20 +144,8 @@ pass5()
 	idesc[i].id_type = ADDR;
     memset(&cstotal, 0, sizeof(struct csum));
     (void)time(&now);
-#ifdef notdef
-    /* this is the original from UCB/McKusick, but it is clearly wrong.  It is
-     * rounding the # of fragments to the next 1024 (in our case, with a 1K/8K file system),
-     * while instead it should be rounding to the next block.
-     *
-     * In addition, we should be sure that we allocate enough space, but that seems to be
-     * ensured by the fact that the bitmap is rounded up to the nearest short, and that there
-     * are never more than 16 frags per block.
-     */
-    for (i = fs->fs_size; i < fragroundup(fs, fs->fs_size); i++)
-#else
     c = 1 << fs->fs_fragshift;	/* unit to which we want to round */
     for (i = fs->fs_size; i < roundup(fs->fs_size, c); i++)
-#endif
 	setbmap(i);
     for (c = 0; c < fs->fs_ncg; c++) {
 	getblk(&cgblk, cgtod(fs, c), fs->fs_cgsize);
@@ -237,7 +213,7 @@ pass5()
 	    case DCLEAR:
 	    case DFOUND:
 		newcg->cg_cs.cs_ndir++;
-		/* fall through */
+		AFS_FALLTHROUGH;
 
 #ifdef VICE
 	    case VSTATE:
diff --git a/src/vfsck/proplist.c b/src/vfsck/proplist.c
deleted file mode 100644
index a7068497e..000000000
--- a/src/vfsck/proplist.c
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
- * 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>
-
-#include <roken.h>
-
-#define VICE			/* control whether AFS changes are present */
-
-#ifdef   AFS_OSF_ENV
-
-#include <sys/mount.h>
-#include <sys/vnode.h>
-#include <ufs/inode.h>
-#include <ufs/dinode.h>
-#include <sys/proplist.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-
-#include <afs/osi_inode.h>
-#include "fsck.h"
-
-struct prop_entry_desc {
-    struct prop_entry_desc *next;
-    int flags;
-#define PROP_ENTRY_BAD	0x1
-#define PROP_ENTRY_DUP	0x2
-    daddr_t blkno;
-    int blksize;
-    long offset;
-    long size;
-    char name[PROPLIST_NAME_MAX];
-};
-
-int
-proplist_scan(dp, idesc)
-     struct dinode *dp;
-     struct inodesc *idesc;
-{
-    struct proplist_desc1 *pl_descp;
-    struct bufarea *bp;
-    struct dinode *ndp;
-    long code;
-    int offsetinbuf, blksize;
-    struct prop_entry_desc *entry_list, *next;
-
-    code = proplist_blkscan(dp, idesc, &entry_list);
-    if (code & STOP)
-	goto out;
-
-    proplist_markdup(entry_list);
-
-    code = proplist_updateblks(dp, idesc, entry_list);
-    if (code & STOP)
-	goto out;
-
-    ndp = ginode(idesc->id_number);
-    if ((ndp->di_flags & IC_PROPLIST) == 0) {
-	code = 0;
-	goto out;
-    }
-    if ((ndp->di_flags & (IC_PROPLIST_BLOCK | IC_PROPLIST_FRAG)) ==
-	(IC_PROPLIST_BLOCK | IC_PROPLIST_FRAG)) {
-	code = 0;
-	goto out;
-    }
-    if (ndp->di_flags & IC_PROPLIST_FRAG) {
-	idesc->id_numfrags = 1;
-	blksize = sblock.fs_fsize;
-    } else {
-	idesc->id_numfrags = sblock.fs_frag;
-	blksize = sblock.fs_bsize;
-    }
-    idesc->id_blkno = ndp->di_proplb;
-    for (;;) {
-	code = (*idesc->id_func) (idesc);
-	if (code & STOP)
-	    goto out;
-
-	bp = getdatablk(idesc->id_blkno, blksize);
-	for (offsetinbuf = 0; offsetinbuf < blksize;) {
-	    pl_descp =
-		(struct proplist_desc1 *)(bp->b_un.b_buf + offsetinbuf);
-	    offsetinbuf += pl_descp->pl_nextentry;
-	}
-	if (pl_descp->pl_nextfsb > 0) {
-	    daddr_t save_blkno;
-
-	    save_blkno = pl_descp->pl_nextfsb;
-	    bp->b_flags &= ~B_INUSE;
-	    idesc->id_blkno = save_blkno;
-	    blksize = sblock.fs_bsize;
-	    idesc->id_numfrags = sblock.fs_frag;
-	    continue;
-	}
-	bp->b_flags &= ~B_INUSE;
-	break;
-    }
-  out:
-    for (next = entry_list; entry_list != NULL;) {
-	next = entry_list->next;
-	free(entry_list);
-	entry_list = next;
-    }
-    return (code);
-}
-
-int
-proplist_blkscan(dp, idesc, entry_list)
-     struct dinode *dp;
-     struct inodesc *idesc;
-     struct prop_entry_desc **entry_list;
-{
-    struct proplist_desc1 *pl_descp;
-    struct bufarea *bp;
-    struct prop_entry_desc *entry, *lastentry;
-    int blksize;
-    long code, valueresid;
-
-    *entry_list = NULL;
-    idesc->id_blkno = dp->di_proplb;
-    if (dp->di_flags & IC_PROPLIST_FRAG) {
-	blksize = sblock.fs_fsize;
-	idesc->id_numfrags = 1;
-    } else {
-	blksize = sblock.fs_bsize;
-	idesc->id_numfrags = sblock.fs_frag;
-    }
-    idesc->id_loc = 0;
-    valueresid = 0;
-    for (;;) {
-	if (idesc->id_loc == 0) {
-	    if (chkrange(idesc->id_blkno, idesc->id_numfrags)) {
-		code = proplist_blkdel(dp, idesc, 0);
-		return (code);
-	    }
-	    bp = getdatablk(idesc->id_blkno, blksize);
-	    if (proplist_chkblock(bp, blksize)) {
-		bp->b_flags &= ~B_INUSE;
-		pwarn("PROPERTY LIST BLOCK CORRUPTED I=%u", idesc->id_number);
-		if (preen)
-		    printf(" (CLEARED)\n");
-		else if (reply("CLEAR") == 0)
-		    return (SKIP);
-		code = proplist_blkdel(dp, idesc, 0);
-		return (code);
-	    }
-	}
-	pl_descp = (struct proplist_desc1 *)(bp->b_un.b_buf + idesc->id_loc);
-	if (pl_descp->pl_entrysize) {
-	    if (valueresid < 0
-		|| (valueresid
-		    && strcmp((char *)&pl_descp[1], entry->name))) {
-		entry->flags |= PROP_ENTRY_BAD;
-		valueresid = 0;
-	    }
-	    if (valueresid == 0) {
-		entry = malloc(sizeof(struct prop_entry_desc));
-		if (entry == NULL)
-		    return (SKIP);
-		entry->next = NULL;
-		entry->flags = 0;
-		memcpy(entry->name, (char *)&pl_descp[1],
-		       pl_descp->pl_namelen);
-		entry->blkno = idesc->id_blkno;
-		entry->blksize = blksize;
-		entry->offset = idesc->id_loc;
-		entry->size = 0;
-		if (*entry_list != NULL)
-		    lastentry->next = entry;
-		else
-		    *entry_list = entry;
-		lastentry = entry;
-		valueresid = pl_descp->pl_valuelen;
-	    }
-	    entry->size += pl_descp->pl_entrysize;
-	    valueresid -= pl_descp->pl_valuelen_entry;
-	}
-	if (pl_descp->pl_nextfsb > 0) {
-	    daddr_t save_blkno;
-
-	    save_blkno = pl_descp->pl_nextfsb;
-	    bp->b_flags &= ~B_INUSE;
-	    idesc->id_blkno = save_blkno;
-	    idesc->id_numfrags = sblock.fs_frag;
-	    blksize = sblock.fs_bsize;
-	    idesc->id_loc = 0;
-	    continue;
-	}
-	idesc->id_loc += pl_descp->pl_nextentry;
-	if (idesc->id_loc == blksize) {
-	    bp->b_flags &= ~B_INUSE;
-	    if (valueresid) {
-		entry->flags |= PROP_ENTRY_BAD;
-	    }
-	    break;
-	}
-    }
-    return (0);
-}
-
-int
-proplist_markdup(entry_list)
-     struct prop_entry_desc *entry_list;
-{
-    struct prop_entry_desc *start, *cur;
-    int bad_entries, dup_entries;
-
-    for (start = entry_list; start != NULL; start = start->next) {
-	if (start->flags & (PROP_ENTRY_BAD | PROP_ENTRY_DUP))
-	    continue;
-	for (cur = start->next; cur != NULL; cur = cur->next) {
-	    if (!strcmp(start->name, cur->name))
-		cur->flags |= PROP_ENTRY_DUP;
-	}
-    }
-    return (0);
-}
-
-int
-proplist_updateblks(dp, idesc, entry_list)
-     struct dinode *dp;
-     struct inodesc *idesc;
-     struct prop_entry_desc *entry_list;
-{
-    struct proplist_desc1 *pl_descp, *prev_pl_descp;
-    struct bufarea *bp;
-    struct prop_entry_desc *cur;
-    long code;
-    daddr_t next_blkno;
-    int resid, offset, free, blksize;
-
-    for (cur = entry_list; cur != NULL; cur = cur->next) {
-	if (cur->flags == 0)
-	    continue;
-	idesc->id_blkno = cur->blkno;
-	idesc->id_loc = cur->offset;
-	blksize = cur->blksize;
-
-	if (cur->flags & PROP_ENTRY_BAD)
-	    pwarn("BAD PROPERTY LIST ENTRY FOUND I=%u NAME %0.10s",
-		  idesc->id_number, cur->name);
-	else
-	    pwarn("DUP PROPERTY LIST ENTRY FOUND I=%u NAME %0.10s",
-		  idesc->id_number, cur->name);
-	if (preen)
-	    printf(" (FIXED)\n");
-	else if (reply("FIX") == 0)
-	    continue;
-	for (resid = cur->size; resid > 0;) {
-	    bp = getdatablk(idesc->id_blkno, blksize);
-	    pl_descp =
-		(struct proplist_desc1 *)(bp->b_un.b_buf + idesc->id_loc);
-	    if (strcmp((char *)&pl_descp[1], cur->name)) {
-		bp->b_flags &= ~B_INUSE;
-		break;
-	    }
-	    if (idesc->id_loc) {
-		prev_pl_descp = (struct proplist_desc1 *)bp->b_un.b_buf;
-		for (offset = 0; offset < cur->offset;) {
-		    prev_pl_descp =
-			(struct proplist_desc1 *)(bp->b_un.b_buf + offset);
-		    offset += prev_pl_descp->pl_nextentry;
-		}
-		/*
-		 * prev_pl_descp now points to the entry
-		 * before the one we need to delete
-		 *
-		 * Coalesce into previous entry
-		 */
-		prev_pl_descp->pl_nextentry += pl_descp->pl_nextentry;
-		prev_pl_descp->pl_nextfsb = pl_descp->pl_nextfsb;
-	    }
-	    resid -= pl_descp->pl_entrysize;
-	    pl_descp->pl_entrysize = 0;
-	    pl_descp->pl_namelen = 0;
-	    pl_descp->pl_valuelen = 0;
-
-	    next_blkno = pl_descp->pl_nextfsb;
-	    free = prop_avail(bp, blksize);
-	    dirty(bp);
-	    if (free == blksize)
-		proplist_blkdel(dp, idesc, next_blkno);
-
-	    if (next_blkno && resid > 0) {
-		idesc->id_blkno = next_blkno;
-		blksize = sblock.fs_bsize;
-		idesc->id_loc = 0;
-		continue;
-	    }
-	    break;
-	}
-    }
-    return (0);
-}
-
-int
-prop_avail(bp, blksize)
-     struct bufarea *bp;
-     int blksize;
-{
-    struct proplist_desc1 *pl_descp;
-    int offsetinbuf, total_avail;
-
-    total_avail = 0;
-    for (offsetinbuf = 0; offsetinbuf < blksize;) {
-	pl_descp = (struct proplist_desc1 *)(bp->b_un.b_buf + offsetinbuf);
-	total_avail += (pl_descp->pl_nextentry - pl_descp->pl_entrysize);
-	offsetinbuf += pl_descp->pl_nextentry;
-    }
-    return (total_avail);
-}
-
-int
-proplist_chkblock(bp, blksize)
-     struct bufarea *bp;
-     int blksize;
-{
-    struct proplist_desc1 *pl_descp;
-    int offsetinbuf;
-
-    for (offsetinbuf = 0; offsetinbuf < blksize;) {
-	pl_descp = (struct proplist_desc1 *)(bp->b_un.b_buf + offsetinbuf);
-	if (pl_descp->pl_magic != PROP_LIST_MAGIC_VERS1) {
-	    return (1);
-	}
-	if (pl_descp->pl_entrysize % 8 || pl_descp->pl_nextentry % 8
-	    || pl_descp->pl_nextentry < UFSPROPLIST_STRUCT
-	    || pl_descp->pl_nextentry + offsetinbuf > blksize) {
-	    return (1);
-	}
-	if (pl_descp->pl_entrysize
-	    && (pl_descp->pl_namelen > PROPLIST_NAME_MAX
-		|| pl_descp->pl_valuelen_entry > pl_descp->pl_valuelen
-		|| pl_descp->pl_entrysize > pl_descp->pl_nextentry
-		|| pl_descp->pl_entrysize !=
-		UFSPROPLIST_SIZE(pl_descp->pl_namelen,
-				 pl_descp->pl_valuelen_entry)
-		|| strlen((char *)&pl_descp[1]) > pl_descp->pl_namelen)) {
-	    return (1);
-	}
-	offsetinbuf += pl_descp->pl_nextentry;
-	if (offsetinbuf == blksize) {
-	    bp->b_flags &= ~B_INUSE;
-	    break;
-	}
-    }
-    if (offsetinbuf != blksize) {
-	return (1);
-    }
-    return (0);
-}
-
-
-int
-proplist_blkdel(dp, idesc, nextblk)
-     struct dinode *dp;
-     struct inodesc *idesc;
-     daddr_t nextblk;
-{
-    struct proplist_desc1 *pl_descp;
-    struct bufarea *bp;
-    int blksize;
-    daddr_t badblkno;
-
-    badblkno = idesc->id_blkno;
-    if (dp->di_proplb == badblkno) {
-	dp = ginode(idesc->id_number);
-	dp->di_proplb = nextblk;
-	dp->di_flags &= ~IC_PROPLIST;
-	if (nextblk)
-	    dp->di_flags |= IC_PROPLIST_BLOCK;
-	inodirty();
-	return (ALTERED);
-    }
-    idesc->id_blkno = dp->di_proplb;
-    if (dp->di_flags & IC_PROPLIST_FRAG) {
-	blksize = sblock.fs_fsize;
-	idesc->id_numfrags = 1;
-    } else {
-	blksize = sblock.fs_bsize;
-	idesc->id_numfrags = sblock.fs_frag;
-    }
-    bp = getdatablk(idesc->id_blkno, blksize);
-    idesc->id_loc = 0;
-    for (;;) {
-	pl_descp = (struct proplist_desc1 *)(bp->b_un.b_buf + idesc->id_loc);
-	if (pl_descp->pl_nextfsb > 0) {
-	    daddr_t save_blkno;
-
-	    if (pl_descp->pl_nextfsb == badblkno) {
-		pl_descp->pl_nextfsb = nextblk;
-		dirty(bp);
-		return (ALTERED);
-	    }
-	    save_blkno = pl_descp->pl_nextfsb;
-	    bp->b_flags &= ~B_INUSE;
-	    idesc->id_blkno = save_blkno;
-	    idesc->id_numfrags = sblock.fs_frag;
-	    blksize = sblock.fs_bsize;
-	    bp = getdatablk(save_blkno, blksize);
-	    idesc->id_loc = 0;
-	    continue;
-	}
-	idesc->id_loc += pl_descp->pl_nextentry;
-	if (idesc->id_loc == blksize) {
-	    bp->b_flags &= ~B_INUSE;
-	    break;
-	}
-    }
-    return (SKIP);
-}
-
-#endif /* AFS_OSF_ENV */
diff --git a/src/vfsck/setup.c b/src/vfsck/setup.c
index 39dcc74b2..2c994a9f8 100644
--- a/src/vfsck/setup.c
+++ b/src/vfsck/setup.c
@@ -24,7 +24,7 @@
 
 #define VICE
 
-#if	defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
+#if	defined(AFS_SUN_ENV)
 #define AFS_NEWCG_ENV
 #else
 #undef AFS_NEWCG_ENV
@@ -37,17 +37,6 @@ extern vfscklogprintf();
 
 #define DKTYPENAMES
 
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -70,7 +59,6 @@ extern vfscklogprintf();
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include <sys/file.h>
 #ifdef	AFS_SUN5_ENV
@@ -552,13 +540,6 @@ setup(dev)
 	return (0);
     }
 #endif
-#ifdef	AFS_OSF_ENV
-    if (!fflag && !bflag && !nflag && !hotroot && sblock.fs_clean == FS_CLEAN
-	&& !sblk.b_dirty) {
-	pwarn("Clean file system - skipping fsck\n");
-	return (FS_CLEAN);
-    }
-#endif /* AFS_OSF_ENV */
 
     /*
      * allocate and initialize the necessary maps
diff --git a/src/vfsck/ufs_subr.c b/src/vfsck/ufs_subr.c
index 7bd3c77b0..78bcd8f9e 100644
--- a/src/vfsck/ufs_subr.c
+++ b/src/vfsck/ufs_subr.c
@@ -24,9 +24,6 @@
 
 #define VICE
 
-#ifdef	AFS_OSF_ENV
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #ifdef	AFS_SUN5_ENV
 #include <sys/fs/ufs_fs.h>
@@ -36,7 +33,6 @@
 #else /* AFS_VFSINCL_ENV */
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 extern int around[9];
 extern int inside[9];
diff --git a/src/vfsck/utilities.c b/src/vfsck/utilities.c
index 680c41d7c..ad5072ff9 100644
--- a/src/vfsck/utilities.c
+++ b/src/vfsck/utilities.c
@@ -40,18 +40,6 @@
 #include <ctype.h>
 
 #define VICE			/* allow us to put our changes in at will */
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#define	AFS_NEWCG_ENV
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -73,11 +61,10 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include "fsck.h"
 
-#if	defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV)
+#if	defined(AFS_SUN_ENV)
 #define AFS_NEWCG_ENV
 #else
 #undef AFS_NEWCG_ENV
diff --git a/src/vfsck/vprintf.c b/src/vfsck/vprintf.c
index f339f09e9..18f1a9c3a 100644
--- a/src/vfsck/vprintf.c
+++ b/src/vfsck/vprintf.c
@@ -45,17 +45,6 @@
 
 #include <sys/file.h>
 
-#ifdef	AFS_OSF_ENV
-#include <sys/vnode.h>
-#include <sys/mount.h>
-#include <ufs/inode.h>
-#include <ufs/fs.h>
-#define	_BSD
-#define	_KERNEL
-#include <ufs/dir.h>
-#undef	_KERNEL
-#undef	_BSD
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #include <sys/vnode.h>
@@ -83,7 +72,6 @@
 #endif
 #include <sys/fs.h>
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 
 #include <sys/wait.h>
 #include "fsck.h"
diff --git a/src/viced/NTMakefile b/src/viced/NTMakefile
index 078574391..43e5c2bab 100644
--- a/src/viced/NTMakefile
+++ b/src/viced/NTMakefile
@@ -41,7 +41,7 @@ LWPOBJS = $(OUT)\lock.obj $(OUT)\fasttime.obj $(OUT)\threadname.obj
 
 LIBACLOBJS = $(OUT)\aclprocs.obj $(OUT)\netprocs.obj
 
-FSINTOBJS = $(OUT)\afsaux.obj $(OUT)\afscbint.cs.obj $(OUT)\afsint.ss.obj $(OUT)\afsint.xdr.obj
+FSINTOBJS = $(OUT)\afscbint.cs.obj $(OUT)\afsint.ss.obj $(OUT)\afsint.xdr.obj
 
 EXEOBJS = $(EXERES) $(VICEDOBJS) $(LWPOBJS) $(LIBACLOBJS) \
 	  $(FSINTOBJS) $(RXOBJS)
diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c
index ea1164092..b608734fd 100644
--- a/src/viced/afsfileprocs.c
+++ b/src/viced/afsfileprocs.c
@@ -179,6 +179,7 @@ afs_int32 BlocksSpare = 1024;	/* allow 1 MB overruns */
 afs_int32 PctSpare;
 extern afs_int32 implicitAdminRights;
 extern afs_int32 readonlyServer;
+extern afs_int32 adminwriteServer;
 extern int CopyOnWrite_calls, CopyOnWrite_off0, CopyOnWrite_size0;
 extern afs_fsize_t CopyOnWrite_maxsize;
 
@@ -1007,6 +1008,30 @@ VolumeRootVnode(Vnode * targetptr)
 
 }				/*VolumeRootVnode */
 
+/**
+ * Check if server can perform writes.
+ *
+ * This functions checks if the fileserver is read-only for the client received
+ * as an argument. Read-only fileservers allow write requests for members of
+ * system:administrators when started with both -readonly and -admin-write.
+ *
+ * @param[in]  client  calling user
+ *
+ * @return 1 if not read-only for this user; 0 otherwise
+ */
+static int
+IsWriteAllowed(struct client *client)
+{
+    if (readonlyServer) {
+	if (adminwriteServer && !VanillaUser(client)) {
+	    /* admins can write */
+	    return 1;
+	}
+	return 0;
+    }
+    return 1;
+}
+
 /*
  * Check if target file has the proper access permissions for the Fetch
  * (FetchData, FetchACL, FetchStatus) and Store (StoreData, StoreACL,
@@ -1077,6 +1102,9 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 		      AUD_END);
 	}
     } else {			/* a store operation */
+	if (!IsWriteAllowed(client)) {
+	    return (VREADONLY);
+	}
 	if ((rights & PRSFS_INSERT) && OWNSp(client, targetptr)
 	    && (CallingRoutine != CHK_STOREACL)
 	    && (targetptr->disk.type == vFile)) {
@@ -1085,9 +1113,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 	     * unless you are a system administrator */
 	  /******  InStatus->Owner && UnixModeBits better be SET!! */
 	    if (CHOWN(InStatus, targetptr) || CHGRP(InStatus, targetptr)) {
-		if (readonlyServer)
-		    return (VREADONLY);
-		else if (VanillaUser(client))
+		if (VanillaUser(client))
 		    return (EPERM);	/* Was EACCES */
 		else
 		    osi_audit(PrivilegeEvent, 0, AUD_ID,
@@ -1100,9 +1126,6 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 			  (client ? client->z.ViceId : 0), AUD_INT,
 			  CallingRoutine, AUD_END);
 	    } else {
-		if (readonlyServer) {
-		    return (VREADONLY);
-		}
 		if (CallingRoutine == CHK_STOREACL) {
 		    if (!(rights & PRSFS_ADMINISTER)
 			&& !VolumeOwner(client, targetptr))
@@ -1111,9 +1134,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 		    /* watch for chowns and chgrps */
 		    if (CHOWN(InStatus, targetptr)
 			|| CHGRP(InStatus, targetptr)) {
-			if (readonlyServer)
-			    return (VREADONLY);
-			else if (VanillaUser(client))
+			if (VanillaUser(client))
 			    return (EPERM);	/* Was EACCES */
 			else
 			    osi_audit(PrivilegeEvent, 0, AUD_ID,
@@ -1127,8 +1148,6 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 #else
 			(InStatus->UnixModeBits & (S_ISUID | S_ISGID)) != 0) {
 #endif
-			if (readonlyServer)
-			    return (VREADONLY);
 			if (VanillaUser(client))
 			    return (EACCES);
 			else
@@ -1137,8 +1156,6 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 				      CallingRoutine, AUD_END);
 		    }
 		    if (CallingRoutine == CHK_STOREDATA) {
-			if (readonlyServer)
-			    return (VREADONLY);
 			if (!(rights & PRSFS_WRITE))
 			    return (EACCES);
 			/* Next thing is tricky.  We want to prevent people
@@ -1166,8 +1183,6 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 #endif
 			    if ((targetptr->disk.type != vDirectory)
 				&& (!(targetptr->disk.modeBits & OWNERWRITE))) {
-			    if (readonlyServer)
-				return (VREADONLY);
 			    if (VanillaUser(client))
 				return (EACCES);
 			    else
@@ -1176,8 +1191,6 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 					  AUD_INT, CallingRoutine, AUD_END);
 			}
 		    } else {	/* a status store */
-			if (readonlyServer)
-			    return (VREADONLY);
 			if (targetptr->disk.type == vDirectory) {
 			    if (!(rights & PRSFS_DELETE)
 				&& !(rights & PRSFS_INSERT))
@@ -1483,8 +1496,13 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
 
     /* check that the file is in the directory */
     SetDirHandle(dir, parentptr);
-    if (afs_dir_Lookup(dir, Name, fileFid))
-	return (ENOENT);
+    errorCode = afs_dir_Lookup(dir, Name, fileFid);
+    if (errorCode && errorCode != ENOENT) {
+        errorCode = EIO;
+    }
+    if (errorCode) {
+	return errorCode;
+    }
     fileFid->Volume = V_id(volptr);
 
     /* just-in-case check for something causing deadlock */
@@ -2020,9 +2038,10 @@ HandleLocking(Vnode * targetptr, struct client *client, afs_int32 rights, ViceLo
 /* Checks if caller has the proper AFS and Unix (WRITE) access permission to the target directory; Prfs_Mode refers to the AFS Mode operation while rights contains the caller's access permissions to the directory. */
 
 static afs_int32
-CheckWriteMode(Vnode * targetptr, afs_int32 rights, int Prfs_Mode)
+CheckWriteMode(Vnode * targetptr, afs_int32 rights, int Prfs_Mode,
+	       struct client *client)
 {
-    if (readonlyServer)
+    if (!IsWriteAllowed(client))
 	return (VREADONLY);
     if (!(rights & Prfs_Mode))
 	return (EACCES);
@@ -2753,6 +2772,7 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 			      &rights, &anyrights))) {
 	    tstatus = &OutStats->AFSBulkStats_val[i];
 
+	    tstatus->InterfaceVersion = 1;
 	    if (thost->z.hostFlags & HERRORTRANS) {
 		tstatus->errorCode = sys_error_to_et(errorCode);
 	    } else {
@@ -2781,6 +2801,7 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 					CHK_FETCHSTATUS, 0))) {
 		tstatus = &OutStats->AFSBulkStats_val[i];
 
+		tstatus->InterfaceVersion = 1;
 		if (thost->z.hostFlags & HERRORTRANS) {
 		    tstatus->errorCode = sys_error_to_et(errorCode);
 		} else {
@@ -3286,7 +3307,7 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     SetVolumeSync(Sync, volptr);
 
     /* Does the caller has delete (& write) access to the parent directory? */
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_DELETE))) {
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_DELETE, client))) {
 	goto Bad_RemoveFile;
     }
 
@@ -3425,7 +3446,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     SetVolumeSync(Sync, volptr);
 
     /* Can we write (and insert) onto the parent directory? */
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT))) {
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT, client))) {
 	goto Bad_CreateFile;
     }
 
@@ -3619,10 +3640,11 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     /* set volume synchronization information */
     SetVolumeSync(Sync, volptr);
 
-    if ((errorCode = CheckWriteMode(oldvptr, rights, PRSFS_DELETE))) {
+    if ((errorCode = CheckWriteMode(oldvptr, rights, PRSFS_DELETE, client))) {
 	goto Bad_Rename;
     }
-    if ((errorCode = CheckWriteMode(newvptr, newrights, PRSFS_INSERT))) {
+    if ((errorCode = CheckWriteMode(newvptr, newrights, PRSFS_INSERT,
+				    client))) {
 	goto Bad_Rename;
     }
 
@@ -3653,8 +3675,11 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     SetDirHandle(&newdir, newvptr);
 
     /* Lookup the file to delete its vnode */
-    if (afs_dir_Lookup(&olddir, OldName, &fileFid)) {
-	errorCode = ENOENT;
+    errorCode = afs_dir_Lookup(&olddir, OldName, &fileFid);
+    if (errorCode && errorCode != ENOENT) {
+        errorCode = EIO;
+    }
+    if (errorCode) {
 	goto Bad_Rename;
     }
     if (fileFid.Vnode == oldvptr->vnodeNumber
@@ -3693,8 +3718,13 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     }
 
     /* Lookup the new file  */
-    if (!(afs_dir_Lookup(&newdir, NewName, &newFileFid))) {
-	if (readonlyServer) {
+    code = afs_dir_Lookup(&newdir, NewName, &newFileFid);
+    if (code && code != ENOENT) {
+        errorCode = EIO;
+        goto Bad_Rename;
+    }
+    if (!code) {
+	if (!IsWriteAllowed(client)) {
 	    errorCode = VREADONLY;
 	    goto Bad_Rename;
 	}
@@ -3802,6 +3832,10 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
 	    struct AFSFid unused;
 
 	    code = afs_dir_Lookup(&filedir, "..", &unused);
+            if (code && code != ENOENT) {
+                errorCode = EIO;
+                goto Bad_Rename;
+            }
 	    if (code == ENOENT) {
 		/* only update .. if it doesn't already exist */
 		updatefile = 1;
@@ -4066,7 +4100,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     SetVolumeSync(Sync, volptr);
 
     /* Does the caller has insert (and write) access to the parent directory? */
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT)))
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT, client)))
 	goto Bad_SymLink;
 
     /*
@@ -4075,7 +4109,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
      * to do this.
      */
     if ((InStatus->Mask & AFS_SETMODE) && !(InStatus->UnixModeBits & 0111)) {
-	if (readonlyServer) {
+	if (!IsWriteAllowed(client)) {
 	    errorCode = VREADONLY;
 	    goto Bad_SymLink;
 	}
@@ -4246,7 +4280,7 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     SetVolumeSync(Sync, volptr);
 
     /* Can the caller insert into the parent directory? */
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT))) {
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT, client))) {
 	goto Bad_Link;
     }
 
@@ -4430,10 +4464,11 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
      * implcit a access that goes with dir ownership, and proceed to
      * subvert quota in the volume.
      */
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT))
-	|| (errorCode = CheckWriteMode(parentptr, rights, PRSFS_WRITE))) {
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT, client))
+	|| (errorCode = CheckWriteMode(parentptr, rights, PRSFS_WRITE,
+				       client))) {
 #else
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT))) {
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_INSERT, client))) {
 #endif /* DIRCREATE_NEED_WRITE */
 	goto Bad_MakeDir;
     }
@@ -4579,7 +4614,7 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     SetVolumeSync(Sync, volptr);
 
     /* Does the caller has delete (&write) access to the parent dir? */
-    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_DELETE))) {
+    if ((errorCode = CheckWriteMode(parentptr, rights, PRSFS_DELETE, client))) {
 	goto Bad_RemoveDir;
     }
 
@@ -5358,18 +5393,19 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
     afs_int32 dataBytes;	/*Bytes in data buffer */
     struct fsstats fsstats;
 
+    /*
+     * Note: This function intentionally omits CallPreamble()
+     *       to avoid issuing TellMeAboutYourself() calls to
+     *       simple clients which are only gathering stats.
+     */
+
     fsstats_StartOp(&fsstats, FS_STATS_RPCIDX_GETXSTATS);
 
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    /*
-     * Record the time of day and the server version number.
-     */
+
+    /* Return the server's time of day and xstat version number. */
     *a_srvVersionNumP = AFS_XSTAT_VERSION;
     *a_timeP = (afs_int32) time(NULL);
-
-    /*
-     * Stuff the appropriate data in there (assume victory)
-     */
     code = 0;
 
     osi_auditU(a_call, GetXStatsEvent,
@@ -5377,60 +5413,27 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 	       AUD_INT, a_clientVersionNum,
 	       AUD_INT, a_collectionNumber, AUD_END);
 
-#if 0
-    /*
-     * We're not keeping stats, so just return successfully with
-     * no data.
-     */
-    a_dataP->AFS_CollData_len = 0;
-    a_dataP->AFS_CollData_val = NULL;
-#endif /* 0 */
-
     switch (a_collectionNumber) {
     case AFS_XSTATSCOLL_CALL_INFO:
-	/*
-	 * Pass back all the call-count-related data.
-	 *
-	 * >>> We are forced to allocate a separate area in which to
-	 * >>> put this stuff in by the RPC stub generator, since it
-	 * >>> will be freed at the tail end of the server stub code.
-	 */
-#if 0
-	/*
-	 * I don't think call-level stats are being collected yet
-	 * for the File Server.
-	 */
-	dataBytes = sizeof(struct afs_Stats);
-	dataBuffP = malloc(dataBytes);
-	memcpy(dataBuffP, &afs_cmstats, dataBytes);
-	a_dataP->AFS_CollData_len = dataBytes >> 2;
-	a_dataP->AFS_CollData_val = dataBuffP;
-#else
+	/*  The call info collection type is not implemented. */
 	a_dataP->AFS_CollData_len = 0;
 	a_dataP->AFS_CollData_val = NULL;
-#endif /* 0 */
 	break;
 
     case AFS_XSTATSCOLL_PERF_INFO:
 	/*
 	 * Pass back all the regular performance-related data.
 	 *
-	 * >>> We are forced to allocate a separate area in which to
-	 * >>> put this stuff in by the RPC stub generator, since it
-	 * >>> will be freed at the tail end of the server stub code.
+	 * Allocate a separate area in which to put this stuff in
+	 * by the RPC stub generator, since it will be freed at the
+	 * tail end of the server stub code.
 	 */
-
 	afs_perfstats.numPerfCalls++;
 	FillPerfValues(&afs_perfstats);
-
-	/*
-	 * Don't overwrite the spares at the end.
-	 */
-
 	dataBytes = sizeof(struct afs_PerfStats);
-	dataBuffP = malloc(dataBytes);
+	dataBuffP = calloc(1, dataBytes);
 	memcpy(dataBuffP, &afs_perfstats, dataBytes);
-	a_dataP->AFS_CollData_len = dataBytes >> 2;
+	a_dataP->AFS_CollData_len = dataBytes / sizeof(afs_int32);
 	a_dataP->AFS_CollData_val = dataBuffP;
 	break;
 
@@ -5440,23 +5443,17 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 	 * We have to stuff the basic, overall numbers in, but the
 	 * detailed numbers are kept in the structure already.
 	 *
-	 * >>> We are forced to allocate a separate area in which to
-	 * >>> put this stuff in by the RPC stub generator, since it
-	 * >>> will be freed at the tail end of the server stub code.
+	 * Allocate a separate area in which to put this stuff in
+	 * by the RPC stub generator, since it will be freed at the
+	 * tail end of the server stub code.
 	 */
-
 	afs_perfstats.numPerfCalls++;
 	afs_FullPerfStats.overall.numPerfCalls = afs_perfstats.numPerfCalls;
 	FillPerfValues(&afs_FullPerfStats.overall);
-
-	/*
-	 * Don't overwrite the spares at the end.
-	 */
-
 	dataBytes = sizeof(struct fs_stats_FullPerfStats);
-	dataBuffP = malloc(dataBytes);
+	dataBuffP = calloc(1, dataBytes);
 	memcpy(dataBuffP, &afs_FullPerfStats, dataBytes);
-	a_dataP->AFS_CollData_len = dataBytes >> 2;
+	a_dataP->AFS_CollData_len = dataBytes / sizeof(afs_int32);
 	a_dataP->AFS_CollData_val = dataBuffP;
 	break;
 
@@ -5464,7 +5461,7 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 	afs_perfstats.numPerfCalls++;
 
 	dataBytes = sizeof(struct cbcounters);
-	dataBuffP = malloc(dataBytes);
+	dataBuffP = calloc(1, dataBytes);
 	{
 	    extern struct cbcounters cbstuff;
 	    dataBuffP[0]=cbstuff.DeleteFiles;
@@ -5485,15 +5482,12 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 	    dataBuffP[15]=cbstuff.GSS5;
 	}
 
-	a_dataP->AFS_CollData_len = dataBytes >> 2;
+	a_dataP->AFS_CollData_len = dataBytes / sizeof(afs_int32);
 	a_dataP->AFS_CollData_val = dataBuffP;
 	break;
 
-
     default:
-	/*
-	 * Illegal collection number.
-	 */
+	/* Illegal collection number. */
 	a_dataP->AFS_CollData_len = 0;
 	a_dataP->AFS_CollData_val = NULL;
 	code = 1;
@@ -5978,7 +5972,7 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 			  &rights, &anyrights)))
 	goto Bad_SetVolumeStatus;
 
-    if (readonlyServer) {
+    if (!IsWriteAllowed(client)) {
 	errorCode = VREADONLY;
 	goto Bad_SetVolumeStatus;
     }
@@ -6011,14 +6005,6 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 afs_int32
 SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
 {
-#ifdef notdef
-    int fd;
-    int len;
-    char *temp;
-    struct rx_connection *tcon;
-    struct host *thost;
-    Error errorCode = 0;
-#endif
     struct fsstats fsstats;
 
     fsstats_StartOp(&fsstats, FS_STATS_RPCIDX_GETROOTVOLUME);
@@ -6065,7 +6051,6 @@ SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
 }				/*SRXAFS_GetRootVolume */
 
 
-/* still works because a struct CBS is the same as a struct AFSOpaque */
 afs_int32
 SRXAFS_CheckToken(struct rx_call * acall, afs_int32 AfsId,
 		  struct AFSOpaque * Token)
@@ -6770,6 +6755,13 @@ init_sys_error_to_et(void)
     sys2et[EDQUOT] = UAEDQUOT;
     sys2et[ENOMEDIUM] = UAENOMEDIUM;
     sys2et[EMEDIUMTYPE] = UAEMEDIUMTYPE;
+    sys2et[ECANCELED] = UAECANCELED;
+    sys2et[ENOTRECOVERABLE] = UAENOTRECOVERABLE;
+    sys2et[ENOTSUP] = UAENOTSUP;
+    sys2et[EOTHER] = UAEOTHER;
+    sys2et[EOWNERDEAD] = UAEOWNERDEAD;
+    sys2et[EPROCLIM] = UAEPROCLIM;
+    sys2et[EDISCON] = UAEDISCON;
 
     sys2et[EIO] = UAEIO;
 }
diff --git a/src/viced/callback.c b/src/viced/callback.c
index 0b3fc35b2..0e38a9508 100644
--- a/src/viced/callback.c
+++ b/src/viced/callback.c
@@ -1035,6 +1035,7 @@ BreakDelayedCallBacks_r(struct host *host)
     cbstuff.nbreakers++;
     if (!(host->z.hostFlags & RESETDONE) && !(host->z.hostFlags & HOSTDELETED)) {
 	host->z.hostFlags &= ~ALTADDR;	/* alternate addresses are invalid */
+	host->z.hostFlags |= HWHO_INPROGRESS; /* ICBS(3) invokes thread quota */
 	cb_conn = host->z.callback_rxcon;
 	rx_GetConnection(cb_conn);
 	if (host->z.interface) {
@@ -1049,6 +1050,7 @@ BreakDelayedCallBacks_r(struct host *host)
 	cb_conn = NULL;
 	H_LOCK;
 	host->z.hostFlags |= ALTADDR;	/* alternate addresses are valid */
+	host->z.hostFlags &= ~HWHO_INPROGRESS;
 	if (code) {
 	    if (ShowProblems) {
 		ViceLog(0,
@@ -1121,7 +1123,6 @@ BreakDelayedCallBacks_r(struct host *host)
 		}
 		host->z.hostFlags |= VENUSDOWN;	/* Failed */
 		ClearHostCallbacks_r(host, 1 /* locked */ );
-		nfids = 0;
 		break;
 	    }
 	    if (nfids < AFSCBMAX)
@@ -1370,10 +1371,12 @@ BreakLaterCallBacks(void)
 int
 CleanupTimedOutCallBacks(void)
 {
+    int code;
+
     H_LOCK;
-    CleanupTimedOutCallBacks_r();
+    code = CleanupTimedOutCallBacks_r();
     H_UNLOCK;
-    return 0;
+    return code;
 }
 
 int
@@ -1643,6 +1646,7 @@ ClearHostCallbacks_r(struct host *hp, int locked)
     } else if (!(hp->z.hostFlags & HOSTDELETED)) {
 	/* host is up, try a call */
 	hp->z.hostFlags &= ~ALTADDR;	/* alternate addresses are invalid */
+	hp->z.hostFlags |= HWHO_INPROGRESS;   /* enable host thread quota enforcement */
 	cb_conn = hp->z.callback_rxcon;
 	rx_GetConnection(hp->z.callback_rxcon);
 	if (hp->z.interface) {
@@ -1657,6 +1661,7 @@ ClearHostCallbacks_r(struct host *hp, int locked)
 	cb_conn = NULL;
 	H_LOCK;
 	hp->z.hostFlags |= ALTADDR;	/* alternate addresses are valid */
+	hp->z.hostFlags &= ~HWHO_INPROGRESS;
 	if (code) {
 	    /* failed, mark host down and need reset */
 	    hp->z.hostFlags |= VENUSDOWN;
diff --git a/src/viced/fsprobe.c b/src/viced/fsprobe.c
index a72727444..a3a7afb65 100644
--- a/src/viced/fsprobe.c
+++ b/src/viced/fsprobe.c
@@ -95,121 +95,6 @@ main(int argc, char **argv)
     else
 	printf("return code is %d\n", code);
 
-#ifdef notdef
-    while (1) {
-	char line[500];
-	int nargs;
-
-	printf("fs> ");
-	if (fgets(line, 499, stdin) != NULL) {
-	    char *oper;
-	    char **argp = args;
-	    GetArgs(line, argp, &nargs);
-	    oper = &argp[0][0];
-	    ++argp, --nargs;
-	    if (!strcmp(oper, "probe")) {
-		code =
-		    ubik_Call(RXAFS_GetTime, cstruct, 0, &tv.tv_sec,
-			      &tv.tv_usec);
-		printf("return code is %d\n", code);
-		if (!code)
-		    printf("sec=%d\n", tv.tv_sec);
-	    } else if (!strcmp(oper, "fsstats")) {
-		struct afsStatistics stats;
-
-		code = ubik_AFS_GetStatistics(cstruct, 0, &stats);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "fd")) {
-		code = FetchData(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "fs")) {
-		code = FetchStatus(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "fa")) {
-		code = FetchACL(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "sd")) {
-		code = StoreData(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "ss")) {
-		code = StoreStatus(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "sa")) {
-		code = StoreACL(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "cf")) {
-		code = CreateFile(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "rf")) {
-		code = RemoveFile(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "rn")) {
-		code = Rename(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "sl")) {
-		code = Symlink(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "hl")) {
-		code = HardLink(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "md")) {
-		code = MakeDir(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "rd")) {
-		code = RemoveDir(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "rdd")) {
-		code = Readdir(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "mm")) {
-		code = MakeMountPoint(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "rt")) {
-		code = ReleaseTokens(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "bs")) {
-		code = BulkStatus(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "lk")) {
-		code = Lookup(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "gt")) {
-		code = GetToken(argp);
-		printf("return code is %d\n", code);
-	    } else if (!strcmp(oper, "ka")) {
-		code = KeepAlive(argp);
-		printf("return code is %d\n", code);
-	    } else if ((!strcmp(oper, "q")) || !strcmp(oper, "quit"))
-		exit(0);
-	    else {
-		printf("Unknown oper! Available operations: \n\n");
-		printf("fd <vnode> <unique> <pos> <len>\n");
-		printf("fs <vnode> <unique>\n");
-		printf("fa <vnode> <unique>\n");
-		printf
-		    ("sd <vnode> <unique> <pos> <len> <flen> [<mode>|-1] [<owner>|-1] [<length>|-1] <string>\n");
-		printf
-		    ("ss <vnode> <unique> [<mode>|-1] [<owner>|-1] [<length>|-1]\n");
-		printf("sa <vnode> <unique> <string>\n");
-		printf("rf <vnode> <unique> <name>\n");
-		printf
-		    ("cf <vnode> <unique> <name> [<mode>|-1] [<owner>|-1] [<length>|-1]\n");
-		printf
-		    ("rn <ovnode> <ounique> <oname> <nvnode> <nunique> <nname>\n");
-		printf
-		    ("sl <vnode> <unique> <name> <contents> [<mode>|-1] [<owner>|-1] [<length>|-1]\n");
-		printf("hl <dvnode> <dunique> <name> <evnode> <eunique>\n");
-		printf
-		    ("md <vnode> <unique> <name> [<mode>|-1] [<owner>|-1] [<length>|-1]\n");
-		printf("rd <vnode> <unique> <name>\n");
-		printf("rdd <vnode> <unique> <pos> <len>\n");
-		printf("lk <vnode> <unique> <name>\n");
-		printf("gt <vnode> <unique> <tokenID>\n");
-		printf("ka <vol.l> <vnode> <unique> <isExec> <kaTime>\n");
-	    }
-	}
-    }
-#endif
     return 0;
 }
 
@@ -231,730 +116,3 @@ GetArgs(char *line, char **args, int *nargs)
 	    line++;
     }
 }
-
-#ifdef notdef
-afs_int32
-FetchData(char **argp)
-{
-    struct afsFetchStatus OutStatus;
-    struct afsToken Token;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    int vnode, unique, position, length;
-    int code;
-    struct rx_call *tcall;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    sscanf(&(*argp)[0], "%d", &position);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    tcall = rx_NewCall(cstruct->conns[0]);
-    code = StartAFS_FetchData(tcall, &fid, &hyp0, position, length, 0);
-    if (!code) {
-	code = FetchProc(tcall);
-    }
-    if (!code) {
-	code = EndAFS_FetchData(tcall, &OutStatus, &Token, &tsync);
-    }
-    code = rx_EndCall(tcall, code);
-    return code;
-}
-
-
-static afs_int32
-FetchProc(struct rx_call *acall)
-{
-    char *tbuffer;
-    afs_int32 tlen, length, code;
-
-    code = rx_Read(acall, &length, sizeof(afs_int32));
-    length = ntohl(length);
-    if (code != sizeof(afs_int32))
-	return -1;
-    tbuffer = malloc(256);
-    while (length > 0) {
-	tlen = (length > 256 ? 256 : length);
-	code = rx_Read(acall, tbuffer, tlen);
-	if (code != tlen) {
-	    free(tbuffer);
-	    return -1;
-	}
-	length -= tlen;
-    }
-    free(tbuffer);
-    return 0;
-}
-
-
-afs_int32
-FetchStatus(char **argp)
-{
-    struct afsFetchStatus OutStatus;
-    struct afsToken Token;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    code =
-	ubik_AFS_FetchStatus(cstruct, 0, &fid, &hyp0, 0, &OutStatus,
-		  &Token, &tsync);
-    return (code);
-}
-
-
-afs_int32
-FetchACL(char **argp)
-{
-    struct afsFetchStatus OutStatus;
-    struct afsACL AccessList;
-    struct afsToken Token;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    code =
-	ubik_AFS_FetchACL(cstruct, 0, &fid, &hyp0, 0, &AccessList,
-		  &OutStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-StoreData(char **argp)
-{
-    struct afsStoreStatus InStatus;
-    struct afsFetchStatus OutStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    int vnode, unique, position, length, filelength;
-    int mode, owner, len;
-    int code;
-    char *string;
-    struct rx_call *tcall;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    sscanf(&(*argp)[0], "%d", &position);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &filelength);
-    ++argp;
-    memset(&InStatus, 0, sizeof(struct afsStoreStatus));
-    sscanf(&(*argp)[0], "%d", &mode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &owner);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &len);
-    ++argp;
-    if (mode != -1) {
-	InStatus.mode = mode;
-	InStatus.mask |= AFS_SETMODE;
-    }
-    if (owner != -1) {
-	InStatus.owner = owner;
-	InStatus.mask |= AFS_SETOWNER;
-    }
-    if (length != -1) {
-	InStatus.length = length;
-	InStatus.mask |= AFS_SETLENGTH;
-    }
-    string = &argp[0][0];
-    ++argp;
-
-    tcall = rx_NewCall(cstruct->conns[0]);
-    code =
-	StartAFS_StoreData(tcall, &fid, &InStatus, position, length,
-			   filelength, &hyp0, 0);
-    if (!code) {
-	code = StoreProc(tcall, string, length);
-    }
-    if (!code) {
-	code = EndAFS_StoreData(tcall, &OutStatus, &tsync);
-    }
-    code = rx_EndCall(tcall, code);
-    return (code);
-}
-
-
-static afs_int32
-StoreProc(struct rx_call *acall, char *string, int length)
-{
-    afs_int32 tlen, code;
-
-    while (length > 0) {
-	tlen = (length > 256 ? 256 : length);
-	code = rx_Write(acall, string, tlen);
-	if (code != tlen) {
-	    return -1;
-	}
-	length -= tlen;
-    }
-    return 0;
-}
-
-
-afs_int32
-StoreStatus(char **argp)
-{
-    struct afsStoreStatus InStatus;
-    struct afsFetchStatus OutStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    int vnode, unique, mode, owner, length;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    memset(&InStatus, 0, sizeof(struct afsStoreStatus));
-    sscanf(&(*argp)[0], "%d", &mode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &owner);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    if (mode != -1) {
-	InStatus.mode = mode;
-	InStatus.mask |= AFS_SETMODE;
-    }
-    if (owner != -1) {
-	InStatus.owner = owner;
-	InStatus.mask |= AFS_SETOWNER;
-    }
-    if (length != -1) {
-	InStatus.length = length;
-	InStatus.mask |= AFS_SETLENGTH;
-    }
-    code =
-	ubik_AFS_StoreStatus(cstruct, 0, &fid, &InStatus, &hyp0, 0,
-		  &OutStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-StoreACL(char **argp)
-{
-    struct afsFetchStatus OutStatus;
-    struct afsACL AccessList;
-    struct afsToken Token;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    char *string;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    string = &argp[0][0];
-    ++argp;
-    AccessList.afsACL_len = strlen(string) + 1;
-    AccessList.afsACL_val = string;
-    code =
-	ubik_AFS_StoreACL(cstruct, 0, &fid, &AccessList, &hyp0, 0,
-		  &OutStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-RemoveFile(char **argp)
-{
-    struct afsFetchStatus OutDirStatus, OutFidStatus;
-    struct afsVolSync tsync;
-    struct afsFidName nameFid;
-    struct afsFid fid, outFid;
-    char *name;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    memset(&nameFid, 0, sizeof(struct afsFidName));
-    strcpy(nameFid.name, name);
-    code =
-	ubik_AFS_RemoveFile(cstruct, 0, &fid, &nameFid, &hyp0, 0,
-		  &OutDirStatus, &OutFidStatus, &outFid, &tsync);
-    return (code);
-}
-
-
-afs_int32
-CreateFile(char **argp)
-{
-    struct afsFetchStatus OutDirStatus, OutFidStatus;
-    struct afsStoreStatus InStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid, outFid;
-    struct afsToken Token;
-    char *name;
-    int vnode, unique, mode, owner, length;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    memset(&InStatus, 0, sizeof(struct afsStoreStatus));
-    sscanf(&(*argp)[0], "%d", &mode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &owner);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    if (mode != -1) {
-	InStatus.mode = mode;
-	InStatus.mask |= AFS_SETMODE;
-    }
-    if (owner != -1) {
-	InStatus.owner = owner;
-	InStatus.mask |= AFS_SETOWNER;
-    }
-    if (length != -1) {
-	InStatus.length = length;
-	InStatus.mask |= AFS_SETLENGTH;
-    }
-    code =
-	ubik_AFS_CreateFile(cstruct, 0, &fid, name, &InStatus, &hyp0, 0,
-		  &outFid, &OutFidStatus, &OutDirStatus, &Token, &tsync);
-    return (code);
-}
-
-
-afs_int32
-Rename(char **argp)
-{
-    struct afsFetchStatus OutOldDirStatus, OutNewDirStatus;
-    struct afsFetchStatus OutOldFileStatus, OutNewFileStatus;
-    struct afsVolSync tsync;
-    struct afsFid OldDirFid, NewDirFid, OutOldFileFid, OutNewFileFid;
-    struct afsFidName OldName, NewName;
-    char *oname, *nname;
-    int ovnode, ounique, nvnode, nunique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &ovnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &ounique);
-    ++argp;
-    memset(&OldDirFid, 0, sizeof(struct afsFid));
-    OldDirFid.Volume.low = 10;	/* XXX */
-    OldDirFid.Vnode = ovnode;
-    OldDirFid.Unique = ounique;
-    oname = &argp[0][0];
-    ++argp;
-    memset(&OldName, 0, sizeof(struct afsFidName));
-    strcpy(OldName.name, oname);
-    sscanf(&(*argp)[0], "%d", &nvnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &nunique);
-    ++argp;
-    memset(&NewDirFid, 0, sizeof(struct afsFid));
-    NewDirFid.Volume.low = 10;	/* XXX */
-    NewDirFid.Vnode = nvnode;
-    NewDirFid.Unique = nunique;
-    nname = &argp[0][0];
-    ++argp;
-    memset(&NewName, 0, sizeof(struct afsFidName));
-    strcpy(NewName.name, nname);
-    code =
-	ubik_AFS_Rename(cstruct, 0, &OldDirFid, &OldName, &NewDirFid,
-		  &NewName, &hyp0, 0, &OutOldDirStatus, &OutNewDirStatus,
-		  &OutOldFileFid, &OutOldFileStatus, &OutNewFileFid,
-		  &OutNewFileStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-Symlink(char **argp)
-{
-    struct afsFetchStatus OutDirStatus, OutFidStatus;
-    struct afsStoreStatus InStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid, outFid;
-    struct afsToken Token;
-    char *name, *linkcontents;
-    int vnode, unique, mode, owner, length;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    linkcontents = &argp[0][0];
-    ++argp;
-    memset(&InStatus, 0, sizeof(struct afsStoreStatus));
-    sscanf(&(*argp)[0], "%d", &mode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &owner);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    if (mode != -1) {
-	InStatus.mode = mode;
-	InStatus.mask |= AFS_SETMODE;
-    }
-    if (owner != -1) {
-	InStatus.owner = owner;
-	InStatus.mask |= AFS_SETOWNER;
-    }
-    if (length != -1) {
-	InStatus.length = length;
-	InStatus.mask |= AFS_SETLENGTH;
-    }
-    code =
-	ubik_AFS_Symlink(cstruct, 0, &fid, name, linkcontents,
-		  &InStatus, &hyp0, 0, &outFid, &OutFidStatus, &OutDirStatus,
-		  &Token, &tsync);
-    return (code);
-}
-
-
-afs_int32
-HardLink(char **argp)
-{
-    struct afsFetchStatus OutDirStatus, OutFidStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid, existingFid;
-    char *name;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&existingFid, 0, sizeof(struct afsFid));
-    existingFid.Volume.low = 10;	/* XXX */
-    existingFid.Vnode = vnode;
-    existingFid.Unique = unique;
-    code =
-	ubik_AFS_HardLink(cstruct, 0, &fid, name, &existingFid, &hyp0,
-		  0, &OutFidStatus, &OutDirStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-MakeDir(char **argp)
-{
-    struct afsFetchStatus OutDirStatus, OutFidStatus;
-    struct afsStoreStatus InStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid, outFid;
-    struct afsToken Token;
-    char *name;
-    int vnode, unique, mode, owner, length;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    memset(&InStatus, 0, sizeof(struct afsStoreStatus));
-    sscanf(&(*argp)[0], "%d", &mode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &owner);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    if (mode != -1) {
-	InStatus.mode = mode;
-	InStatus.mask |= AFS_SETMODE;
-    }
-    if (owner != -1) {
-	InStatus.owner = owner;
-	InStatus.mask |= AFS_SETOWNER;
-    }
-    if (length != -1) {
-	InStatus.length = length;
-	InStatus.mask |= AFS_SETLENGTH;
-    }
-    code =
-	ubik_AFS_MakeDir(cstruct, 0, &fid, name, &InStatus, &hyp0, 0,
-		  &outFid, &OutFidStatus, &OutDirStatus, &Token, &tsync);
-    return (code);
-}
-
-
-afs_int32
-RemoveDir(char **argp)
-{
-    struct afsFetchStatus OutDirStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid, outFid;
-    struct afsFidName nameFid;
-    char *name;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    memset(&nameFid, 0, sizeof(struct afsFidName));
-    strcpy(nameFid.name, name);
-    code =
-	ubik_AFS_RemoveDir(cstruct, 0, &fid, &nameFid, &hyp0, 0,
-		  &OutDirStatus, &outFid, &tsync);
-    return (code);
-}
-
-
-afs_int32
-Readdir(char **argp)
-{
-    struct afsFetchStatus OutDirStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid;
-    struct afsToken Token;
-    char *name;
-    struct rx_call *tcall;
-    int vnode, unique, offset, length, NextOffset;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &offset);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &length);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    tcall = rx_NewCall(cstruct->conns[0]);
-    code = StartAFS_Readdir(tcall, &fid, offset, length, &hyp0, 0);
-    if (!code) {
-	code = FetchDir(tcall);
-    }
-    if (!code) {
-	code =
-	    EndAFS_FetchData(tcall, &NextOffset, &OutDirStatus, &Token,
-			     &tsync);
-    }
-    code = rx_EndCall(tcall, code);
-    return (code);
-}
-
-
-static afs_int32
-FetchDir(struct rx_call *acall)
-{
-    char *tbuffer;
-    afs_int32 tlen, length, code;
-    struct dirent *dp;
-
-
-    tbuffer = malloc(256);
-    while (1) {
-	code = rx_Read(acall, &length, sizeof(afs_int32));
-	length = ntohl(length);
-	if (code != sizeof(afs_int32))
-	    return -1;
-	if (length == 0)
-	    break;
-	tlen = (length > 8192 ? 8192 : length);
-	code = rx_Read(acall, tbuffer, tlen);
-	if (code != tlen) {
-	    free(tbuffer);
-	    return -1;
-	}
-	length -= tlen;
-    }
-    dp = (struct dirent *)dp;
-    free(tbuffer);
-    return 0;
-}
-
-
-afs_int32
-Lookup(char **argp)
-{
-    struct afsFetchStatus OutDirStatus, OutFidStatus;
-    struct afsVolSync tsync;
-    struct afsFid fid, outFid;
-    char *name;
-    int vnode, unique;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    name = &argp[0][0];
-    ++argp;
-    code =
-	ubik_AFS_Lookup(cstruct, 0, &fid, name, &hyp0, 0, &outFid,
-		  &OutFidStatus, &OutDirStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-GetToken(char **argp)
-{
-    struct afsFetchStatus OutStatus;
-    struct afsVolSync tsync;
-    struct afsToken MinToken, RealToken;
-    struct afsFid fid;
-    int vnode, unique, tokenId;
-    int code;
-
-    sscanf(&(*argp)[0], "%d", &vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &unique);
-    ++argp;
-    memset(&fid, 0, sizeof(struct afsFid));
-    fid.Volume.low = 10;	/* XXX */
-    fid.Vnode = vnode;
-    fid.Unique = unique;
-    sscanf(&(*argp)[0], "%d", &tokenId);
-    ++argp;
-    memset(&MinToken, 0, sizeof(struct afsToken));
-    MinToken.tokenID.low = tokenId;	/* XXX */
-    code =
-	ubik_AFS_GetToken(cstruct, 0, &fid, &MinToken, &hyp0, 0,
-		  &RealToken, &OutStatus, &tsync);
-    return (code);
-}
-
-
-afs_int32
-MakeMountPoint(char **argp)
-{
-}
-
-
-afs_int32
-ReleaseTokens(char **argp)
-{
-}
-
-
-afs_int32
-BulkStatus(char **argp)
-{
-}
-
-/*  printf("ka <vol.l> <vnode> <unique> <isExec> <kaTime>\n"); */
-afs_int32
-KeepAlive(char **argp)
-{
-    struct afsBulkFEX fex;
-    afs_uint32 numExec, spare4;
-    struct afsFidExp fx;
-    int code;
-
-    memset(&fx, 0, sizeof(struct afsFidExp));
-    sscanf(&(*argp)[0], "%d", &fx.fid.Volume.low);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &fx.fid.Vnode);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &fx.fid.Unique);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &numExec);
-    ++argp;
-    sscanf(&(*argp)[0], "%d", &fx.keepAliveTime);
-    memset(&fex, 0, sizeof(struct afsBulkFEX));
-    fex.afsBulkFEX_val = &fx;
-    fex.afsBulkFEX_len = 1;
-    code =
-	ubik_AFS_BulkKeepAlive(cstruct, 0, &fex, numExec, 0, 0, 0,
-		  &spare4);
-    return (code);
-}
-#endif /* notdef */
diff --git a/src/viced/host.c b/src/viced/host.c
index 36f9e88c0..363b342fd 100644
--- a/src/viced/host.c
+++ b/src/viced/host.c
@@ -67,6 +67,8 @@ int hostCount = 0;		/* number of hosts in hostList */
 int rxcon_ident_key;
 int rxcon_client_key;
 
+struct host *(hosttableptrs[h_MAXHOSTTABLES]);
+
 static struct rx_securityClass *sc = NULL;
 static int h_quota_limit;
 
@@ -284,8 +286,8 @@ hpr_Initialize(struct ubik_client **uclient)
 
     code = afsconf_GetCellInfo(tdir, cellstr, "afsprot", &info);
     if (code) {
-	ViceLog(0, ("hpr_Initialize: Could not locate cell %s in %s/%s\n",
-		    cellstr, tdir->name, AFSDIR_CELLSERVDB_FILE));
+	ViceLog(0, ("hpr_Initialize: Could not locate cell %s in %s\n",
+		    cellstr, tdir->cellservDB));
 	afsconf_Close(tdir);
 	return code;
     }
@@ -675,11 +677,7 @@ h_Alloc_r(struct rx_connection *r_con)
     h_AddHostToAddrHashTable_r(host->z.host, host->z.port, host);
 
     if (consolePort == 0) {	/* find the portal number for console */
-#if	defined(AFS_OSF_ENV)
-	serverentry = getservbyname("ropcons", "");
-#else
 	serverentry = getservbyname("ropcons", 0);
-#endif
 	if (serverentry)
 	    consolePort = serverentry->s_port;
 	else
@@ -831,7 +829,7 @@ h_TossStuff_r(struct host *host)
 	char hoststr[16];
 	if (wasdeleted) {
 	    /* someone locked the host while HOSTDELETED was set; that is bad */
-	    ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %" AFS_PTR_FMT
+	    ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %p"
 			" (%s:%d flags 0x%x) was locked.\n",
 			host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port),
 			(unsigned)host->z.hostFlags));
@@ -848,7 +846,7 @@ h_TossStuff_r(struct host *host)
 	char hoststr[16];
 	if (wasdeleted) {
 	    /* someone grabbed a ref while HOSTDELETED was set; that is bad */
-	    ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %" AFS_PTR_FMT
+	    ViceLog(0, ("Warning:  h_TossStuff_r failed; Host %p"
 			" (%s:%d flags 0x%x) was held.\n",
 			host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port),
 			(unsigned)host->z.hostFlags));
@@ -1117,7 +1115,7 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host)
 {
     int index;
     struct h_UuidHashChain *chain;
-    char uuid1[128], uuid2[128];
+    struct uuid_fmtbuf uuid1, uuid2;
     char hoststr[16];
 
     /* hash into proper bucket */
@@ -1131,13 +1129,12 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host)
 	if (chain->hostPtr->z.interface &&
 	    afs_uuid_equal(&chain->hostPtr->z.interface->uuid, uuid)) {
 	    if (GetLogLevel() >= 125) {
-		afsUUID_to_string(&chain->hostPtr->z.interface->uuid, uuid1,
-				  127);
-		afsUUID_to_string(uuid, uuid2, 127);
-		ViceLog(125, ("h_AddHostToUuidHashTable_r: host %" AFS_PTR_FMT " (uuid %s) exists as %s:%d (uuid %s)\n",
-			      host, uuid1,
+		afsUUID_to_string(&chain->hostPtr->z.interface->uuid, &uuid1);
+		afsUUID_to_string(uuid, &uuid2);
+		ViceLog(125, ("h_AddHostToUuidHashTable_r: host %p (uuid %s) exists as %s:%d (uuid %s)\n",
+			      host, uuid1.buffer,
 			      afs_inet_ntoa_r(chain->hostPtr->z.host, hoststr),
-			      ntohs(chain->hostPtr->z.port), uuid2));
+			      ntohs(chain->hostPtr->z.port), uuid2.buffer));
 	    }
 	    return;
 	}
@@ -1153,11 +1150,11 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host)
     hostUuidHashTable[index] = chain;
          if (GetLogLevel() < 125)
 	       return;
-     afsUUID_to_string(uuid, uuid2, 127);
+     afsUUID_to_string(uuid, &uuid2);
      ViceLog(125,
 	     ("h_AddHostToUuidHashTable_r: host %p (%s:%d) added as uuid %s\n",
 	      host, afs_inet_ntoa_r(chain->hostPtr->z.host, hoststr),
-	      ntohs(chain->hostPtr->z.port), uuid2));
+	      ntohs(chain->hostPtr->z.port), uuid2.buffer));
 }
 
 /* deletes a HashChain structure corresponding to this host */
@@ -1166,7 +1163,7 @@ h_DeleteHostFromUuidHashTable_r(struct host *host)
 {
      int index;
      struct h_UuidHashChain **uhp, *uth;
-     char uuid1[128];
+     struct uuid_fmtbuf uuid1;
      char hoststr[16];
 
      if (!host->z.interface)
@@ -1176,13 +1173,13 @@ h_DeleteHostFromUuidHashTable_r(struct host *host)
      index = h_UuidHashIndex(&host->z.interface->uuid);
 
      if (GetLogLevel() >= 125)
-	 afsUUID_to_string(&host->z.interface->uuid, uuid1, 127);
+	 afsUUID_to_string(&host->z.interface->uuid, &uuid1);
      for (uhp = &hostUuidHashTable[index]; (uth = *uhp); uhp = &uth->next) {
          opr_Assert(uth->hostPtr);
 	 if (uth->hostPtr == host) {
 	     ViceLog(125,
-		     ("h_DeleteHostFromUuidHashTable_r: host %" AFS_PTR_FMT " (uuid %s %s:%d)\n",
-		      host, uuid1, afs_inet_ntoa_r(host->z.host, hoststr),
+		     ("h_DeleteHostFromUuidHashTable_r: host %p (uuid %s %s:%d)\n",
+		      host, uuid1.buffer, afs_inet_ntoa_r(host->z.host, hoststr),
 		      ntohs(host->z.port)));
 	     *uhp = uth->next;
 	     free(uth);
@@ -1190,8 +1187,8 @@ h_DeleteHostFromUuidHashTable_r(struct host *host)
 	 }
      }
      ViceLog(125,
-	     ("h_DeleteHostFromUuidHashTable_r: host %" AFS_PTR_FMT " (uuid %s %s:%d) not found\n",
-	      host, uuid1, afs_inet_ntoa_r(host->z.host, hoststr),
+	     ("h_DeleteHostFromUuidHashTable_r: host %p (uuid %s %s:%d) not found\n",
+	      host, uuid1.buffer, afs_inet_ntoa_r(host->z.host, hoststr),
 	      ntohs(host->z.port)));
      return 0;
 }
@@ -1212,7 +1209,7 @@ invalidateInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
     opr_Assert(host);
     opr_Assert(host->z.interface);
 
-    ViceLog(125, ("invalidateInterfaceAddr : host %" AFS_PTR_FMT " (%s:%d) addr %s:%d\n",
+    ViceLog(125, ("invalidateInterfaceAddr : host %p (%s:%d) addr %s:%d\n",
 		  host, afs_inet_ntoa_r(host->z.host, hoststr),
 		  ntohs(host->z.port), afs_inet_ntoa_r(addr, hoststr2),
 		  ntohs(port)));
@@ -1257,7 +1254,7 @@ removeAddress_r(struct host *host, afs_uint32 addr, afs_uint16 port)
     if (!host->z.interface || host->z.interface->numberOfInterfaces == 1) {
 	if (host->z.host == addr && host->z.port == port) {
 	    ViceLog(25,
-		    ("Removing only address for host %" AFS_PTR_FMT " (%s:%d), deleting host.\n",
+		    ("Removing only address for host %p (%s:%d), deleting host.\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port)));
 	    host->z.hostFlags |= HOSTDELETED;
             /*
@@ -1269,7 +1266,7 @@ removeAddress_r(struct host *host, afs_uint32 addr, afs_uint16 port)
              */
         } else {
 	    ViceLog(0,
-		    ("Removing address that does not belong to host %" AFS_PTR_FMT " (%s:%d).\n",
+		    ("Removing address that does not belong to host %p (%s:%d).\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port)));
         }
     } else {
@@ -1279,7 +1276,7 @@ removeAddress_r(struct host *host, afs_uint32 addr, afs_uint16 port)
 	    for (i=0; i < host->z.interface->numberOfInterfaces; i++) {
 		if (host->z.interface->interface[i].valid) {
 		    ViceLog(25,
-			     ("Removed address for host %" AFS_PTR_FMT " (%s:%d), new primary interface %s:%d.\n",
+			     ("Removed address for host %p (%s:%d), new primary interface %s:%d.\n",
 			       host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port),
 			       afs_inet_ntoa_r(host->z.interface->interface[i].addr, hoststr2),
 			       ntohs(host->z.interface->interface[i].port)));
@@ -1292,7 +1289,7 @@ removeAddress_r(struct host *host, afs_uint32 addr, afs_uint16 port)
 
 	    if (i == host->z.interface->numberOfInterfaces) {
                 ViceLog(25,
-                         ("Removed only address for host %" AFS_PTR_FMT " (%s:%d), no valid alternate interfaces, deleting host.\n",
+			 ("Removed only address for host %p (%s:%d), no valid alternate interfaces, deleting host.\n",
 			   host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port)));
 		host->z.hostFlags |= HOSTDELETED;
                 /* addr/port was removed from the hash table */
@@ -1334,7 +1331,7 @@ createHostAddrHashChain_r(int index, afs_uint32 addr, afs_uint16 port, struct ho
     chain->addr = addr;
     chain->port = port;
     hostAddrHashTable[index] = chain;
-    ViceLog(125, ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " added as %s:%d\n",
+    ViceLog(125, ("h_AddHostToAddrHashTable_r: host %p added as %s:%d\n",
 		  host, afs_inet_ntoa_r(addr, hoststr), ntohs(port)));
 }
 
@@ -1359,8 +1356,8 @@ reconcileHosts_r(afs_uint32 addr, afs_uint16 port, struct host *newHost,
     char hoststr[16];
 
     ViceLog(125,
-	    ("reconcileHosts_r: addr %s:%d newHost %" AFS_PTR_FMT " oldHost %"
-	     AFS_PTR_FMT "\n", afs_inet_ntoa_r(addr, hoststr), ntohs(port),
+	    ("reconcileHosts_r: addr %s:%d newHost %p oldHost %p\n",
+	     afs_inet_ntoa_r(addr, hoststr), ntohs(port),
 	     newHost, oldHost));
 
     opr_Assert(oldHost != newHost);
@@ -1483,7 +1480,7 @@ h_AddHostToAddrHashTable_r(afs_uint32 addr, afs_uint16 port, struct host *host)
 	if (chain->addr == addr && chain->port == port) {
 	    if (chain->hostPtr == host) {
 	        ViceLog(125,
-	                ("h_AddHostToAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d) already hashed\n",
+			("h_AddHostToAddrHashTable_r: host %p (%s:%d) already hashed\n",
 	                  host, afs_inet_ntoa_r(chain->addr, hoststr),
 	                  ntohs(chain->port)));
 	        return;
@@ -1525,7 +1522,7 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
 	if (host->z.interface->interface[i].addr == addr &&
 	     host->z.interface->interface[i].port == port) {
 	    ViceLog(125,
-		    ("addInterfaceAddr : found host %" AFS_PTR_FMT " (%s:%d) adding %s:%d%s\n",
+		    ("addInterfaceAddr : found host %p (%s:%d) adding %s:%d%s\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr),
 		     ntohs(host->z.port), afs_inet_ntoa_r(addr, hoststr2),
 		     ntohs(port), host->z.interface->interface[i].valid ? "" :
@@ -1539,7 +1536,7 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
         }
     }
 
-    ViceLog(125, ("addInterfaceAddr : host %" AFS_PTR_FMT " (%s:%d) adding %s:%d\n",
+    ViceLog(125, ("addInterfaceAddr : host %p (%s:%d) adding %s:%d\n",
 		  host, afs_inet_ntoa_r(host->z.host, hoststr),
 		  ntohs(host->z.port), afs_inet_ntoa_r(addr, hoststr2),
 		  ntohs(port)));
@@ -1582,7 +1579,7 @@ removeInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port)
     opr_Assert(host);
     opr_Assert(host->z.interface);
 
-    ViceLog(125, ("removeInterfaceAddr : host %" AFS_PTR_FMT " (%s:%d) addr %s:%d\n",
+    ViceLog(125, ("removeInterfaceAddr : host %p (%s:%d) addr %s:%d\n",
 		  host, afs_inet_ntoa_r(host->z.host, hoststr),
 		  ntohs(host->z.port), afs_inet_ntoa_r(addr, hoststr2),
 		  ntohs(port)));
@@ -1890,7 +1887,7 @@ h_GetHost_r(struct rx_connection *tcon)
              * waited for the lock. */
 	    h_Unlock_r(host);
 	    ViceLog(125,
-		    ("Host %" AFS_PTR_FMT " (%s:%d) starting h_Lookup again\n",
+		    ("Host %p (%s:%d) starting h_Lookup again\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr),
 		     ntohs(host->z.port)));
 	    h_Release_r(host);
@@ -1972,7 +1969,7 @@ h_GetHost_r(struct rx_connection *tcon)
 		 * that we maintain some extra callback state information */
 		if (host->z.interface) {
 		    ViceLog(0,
-			    ("Host %" AFS_PTR_FMT " (%s:%d) used to support WhoAreYou, deleting.\n",
+			    ("Host %p (%s:%d) used to support WhoAreYou, deleting.\n",
 			     host,
 			     afs_inet_ntoa_r(host->z.host, hoststr),
 			     ntohs(host->z.port)));
@@ -2019,7 +2016,7 @@ h_GetHost_r(struct rx_connection *tcon)
 			removeAddress_r(host, haddr, hport);
 		} else {
 		    ViceLog(25,
-			    ("Uuid doesn't match host %" AFS_PTR_FMT " (%s:%d).\n",
+			    ("Uuid doesn't match host %p (%s:%d).\n",
 			     host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port)));
 
 		    removeAddress_r(host, host->z.host, host->z.port);
@@ -2056,7 +2053,7 @@ h_GetHost_r(struct rx_connection *tcon)
                      * callback connection, and destroy the old one.
                      */
                     struct rx_connection *rxconn;
-                    ViceLog(0,("CB: ProbeUuid for host %" AFS_PTR_FMT " (%s:%d) failed %d\n",
+		    ViceLog(0,("CB: ProbeUuid for host %p (%s:%d) failed %d\n",
 			       host,
 			       afs_inet_ntoa_r(host->z.host, hoststr),
 			       ntohs(host->z.port),code2));
@@ -2106,7 +2103,7 @@ h_GetHost_r(struct rx_connection *tcon)
 		goto gethost_out;
 	    } else {
 		ViceLog(0,
-			("CB: WhoAreYou failed for host %" AFS_PTR_FMT " (%s:%d), error %d\n",
+			("CB: WhoAreYou failed for host %p (%s:%d), error %d\n",
 			 host, afs_inet_ntoa_r(host->z.host, hoststr),
 			 ntohs(host->z.port), code));
 		host->z.hostFlags |= VENUSDOWN;
@@ -2124,13 +2121,13 @@ h_GetHost_r(struct rx_connection *tcon)
 	if (!(host->z.hostFlags & ALTADDR)) {
 	    /* another thread is doing the initialisation */
 	    ViceLog(125,
-		    ("Host %" AFS_PTR_FMT " (%s:%d) waiting for host-init to complete\n",
+		    ("Host %p (%s:%d) waiting for host-init to complete\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr),
 		     ntohs(host->z.port)));
 	    h_Lock_r(host);
 	    h_Unlock_r(host);
 	    ViceLog(125,
-		    ("Host %" AFS_PTR_FMT " (%s:%d) starting h_Lookup again\n",
+		    ("Host %p (%s:%d) starting h_Lookup again\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr),
 		     ntohs(host->z.port)));
 	    h_Release_r(host);
@@ -2145,18 +2142,20 @@ h_GetHost_r(struct rx_connection *tcon)
 		|| (identP->valid
 		    && !afs_uuid_equal(&identP->uuid,
 				       &host->z.interface->uuid)))) {
-	    char uuid1[128], uuid2[128];
+
+	    struct uuid_fmtbuf uuid1, uuid2;
+
 	    if (identP->valid)
-		afsUUID_to_string(&identP->uuid, uuid1, 127);
+		afsUUID_to_string(&identP->uuid, &uuid1);
 	    if (host->z.interface)
-		afsUUID_to_string(&host->z.interface->uuid, uuid2, 127);
+		afsUUID_to_string(&host->z.interface->uuid, &uuid2);
 	    ViceLog(0,
 		    ("CB: new identity for host %p (%s:%d), "
 		     "deleting(%x %p %s %s)\n",
 		     host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port),
 		     identP->valid, host->z.interface,
-		     identP->valid ? uuid1 : "no_uuid",
-		     host->z.interface ? uuid2 : "no_uuid"));
+		     identP->valid ? uuid1.buffer : "no_uuid",
+		     host->z.interface ? uuid2.buffer : "no_uuid"));
 
 	    /* The host in the cache is not the host for this connection */
             h_Lock_r(host);
@@ -2197,7 +2196,7 @@ h_GetHost_r(struct rx_connection *tcon)
 		if (!pident)
 		    rx_SetSpecific(tcon, rxcon_ident_key, identP);
 		ViceLog(25,
-			("Host %" AFS_PTR_FMT " (%s:%d) does not support WhoAreYou.\n",
+			("Host %p (%s:%d) does not support WhoAreYou.\n",
 			 host, afs_inet_ntoa_r(host->z.host, hoststr),
 			 ntohs(host->z.port)));
 		code = 0;
@@ -2216,7 +2215,7 @@ h_GetHost_r(struct rx_connection *tcon)
 		if (!pident)
 		    rx_SetSpecific(tcon, rxcon_ident_key, identP);
 		ViceLog(25,
-			("WhoAreYou success on host %" AFS_PTR_FMT " (%s:%d)\n",
+			("WhoAreYou success on host %p (%s:%d)\n",
 			 host, afs_inet_ntoa_r(host->z.host, hoststr),
 			 ntohs(host->z.port)));
 	    }
@@ -2277,7 +2276,7 @@ h_GetHost_r(struct rx_connection *tcon)
 			     * MultiProbeAlternateAddress_r() will remove the
 			     * alternate interfaces that do not have the same
 			     * Uuid. */
-			    ViceLog(0,("CB: ProbeUuid for host %" AFS_PTR_FMT " (%s:%d) failed %d\n",
+			    ViceLog(0,("CB: ProbeUuid for host %p (%s:%d) failed %d\n",
 					 oldHost,
 					 afs_inet_ntoa_r(oldHost->z.host, hoststr),
 					 ntohs(oldHost->z.port),code2));
@@ -2301,7 +2300,7 @@ h_GetHost_r(struct rx_connection *tcon)
 			struct rx_connection *rxconn;
 
 			ViceLog(25,
-				 ("CB: Host %" AFS_PTR_FMT " (%s:%d) has new addr %s:%d\n",
+				 ("CB: Host %p (%s:%d) has new addr %s:%d\n",
 				   oldHost,
 				   afs_inet_ntoa_r(oldHost->z.host, hoststr2),
 				   ntohs(oldHost->z.port),
@@ -2371,7 +2370,7 @@ h_GetHost_r(struct rx_connection *tcon)
 		    H_LOCK;
 		    if (code == 0) {
 			ViceLog(25,
-				("InitCallBackState3 success on host %" AFS_PTR_FMT " (%s:%d)\n",
+				("InitCallBackState3 success on host %p (%s:%d)\n",
 				 host, afs_inet_ntoa_r(host->z.host, hoststr),
 				 ntohs(host->z.port)));
 		    }
@@ -2379,12 +2378,12 @@ h_GetHost_r(struct rx_connection *tcon)
 	    }
 	    if (code) {
 		ViceLog(0,
-			("CB: RCallBackConnectBack failed for %" AFS_PTR_FMT " (%s:%d)\n",
+			("CB: RCallBackConnectBack failed for %p (%s:%d)\n",
 			 host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port)));
 		host->z.hostFlags |= VENUSDOWN;
 	    } else {
 		ViceLog(125,
-			("CB: RCallBackConnectBack succeeded for %" AFS_PTR_FMT " (%s:%d)\n",
+			("CB: RCallBackConnectBack succeeded for %p (%s:%d)\n",
 			 host, afs_inet_ntoa_r(host->z.host, hoststr), ntohs(host->z.port)));
 		host->z.hostFlags |= RESETDONE;
 	    }
@@ -2736,7 +2735,7 @@ h_FindClient_r(struct rx_connection *tcon, afs_int32 *a_viceid)
 	    if (code) {
 		char hoststr[16];
 		ViceLog(0,
-			("pr_GetCPS failed(%d) for user %d, host %" AFS_PTR_FMT " (%s:%d)\n",
+			("pr_GetCPS failed(%d) for user %d, host %p (%s:%d)\n",
 			 code, viceid, client->z.host,
 			 afs_inet_ntoa_r(client->z.host->z.host,hoststr),
 			 ntohs(client->z.host->z.port)));
@@ -3409,14 +3408,15 @@ h_stateVerifyUuidHash(struct fs_dump_state * state, struct host * h)
     struct h_UuidHashChain *chain;
     afsUUID * uuidp = &h->z.interface->uuid;
     int index = h_UuidHashIndex(uuidp);
-    char tmp[40];
+    struct uuid_fmtbuf tmp;
     int chain_len = 0;
 
     for (chain = hostUuidHashTable[index]; chain; chain = chain->next) {
 	host = chain->hostPtr;
 	if (host == NULL) {
-	    afsUUID_to_string(uuidp, tmp, sizeof(tmp));
-	    ViceLog(0, ("h_stateVerifyUuidHash: error: uuid hash chain has NULL host ptr (lookup uuid %s)\n", tmp));
+	    afsUUID_to_string(uuidp, &tmp);
+	    ViceLog(0, ("h_stateVerifyUuidHash: error: uuid hash chain has NULL host ptr (lookup uuid %s)\n",
+			tmp.buffer));
 	    ret = 1;
 	    goto done;
 	}
@@ -3440,13 +3440,15 @@ h_stateVerifyUuidHash(struct fs_dump_state * state, struct host * h)
 
     /* Fall through, so host not found */
 
-    afsUUID_to_string(uuidp, tmp, sizeof(tmp));
+    afsUUID_to_string(uuidp, &tmp);
     if (state->mode == FS_STATE_LOAD_MODE) {
-	ViceLog(0, ("h_stateVerifyUuidHash: error: uuid %s not found in hash\n", tmp));
+	ViceLog(0, ("h_stateVerifyUuidHash: error: uuid %s not found in hash\n",
+		    tmp.buffer));
 	ret = 1;
 	goto done;
     } else {
-	ViceLog(0, ("h_stateVerifyUuidHash: warning: uuid %s not found in hash\n", tmp));
+	ViceLog(0, ("h_stateVerifyUuidHash: warning: uuid %s not found in hash\n",
+		    tmp.buffer));
 	state->flags.warnings_generated = 1;
     }
 
@@ -4145,7 +4147,7 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf)
     int found;
     struct Interface *interface;
     char hoststr[16];
-    char uuidstr[128];
+    struct uuid_fmtbuf uuidstr;
     afs_uint16 port7001 = htons(7001);
 
     opr_Assert(host);
@@ -4261,9 +4263,9 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf)
     h_AddHostToUuidHashTable_r(&interface->uuid, host);
 
     if (GetLogLevel() >= 125) {
-	afsUUID_to_string(&interface->uuid, uuidstr, 127);
+	afsUUID_to_string(&interface->uuid, &uuidstr);
 
-	ViceLog(125, ("--- uuid %s\n", uuidstr));
+	ViceLog(125, ("--- uuid %s\n", uuidstr.buffer));
 	for (i = 0; i < host->z.interface->numberOfInterfaces; i++) {
 	    ViceLog(125, ("--- alt address %s:%d\n",
 			  afs_inet_ntoa_r(host->z.interface->interface[i].addr, hoststr),
@@ -4290,7 +4292,7 @@ h_DeleteHostFromAddrHashTable_r(afs_uint32 addr, afs_uint16 port,
 	 hp = &th->next) {
         opr_Assert(th->hostPtr);
         if (th->hostPtr == host && th->addr == addr && th->port == port) {
-	    ViceLog(125, ("h_DeleteHostFromAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d)\n",
+	    ViceLog(125, ("h_DeleteHostFromAddrHashTable_r: host %p (%s:%d)\n",
 			  host, afs_inet_ntoa_r(host->z.host, hoststr),
 			  ntohs(host->z.port)));
             *hp = th->next;
@@ -4299,7 +4301,7 @@ h_DeleteHostFromAddrHashTable_r(afs_uint32 addr, afs_uint16 port,
         }
     }
     ViceLog(125,
-	    ("h_DeleteHostFromAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d) not found\n",
+	    ("h_DeleteHostFromAddrHashTable_r: host %p (%s:%d) not found\n",
 	     host, afs_inet_ntoa_r(host->z.host, hoststr),
 	     ntohs(host->z.port)));
     return 0;
diff --git a/src/viced/host.h b/src/viced/host.h
index fead948f6..272dcdbe7 100644
--- a/src/viced/host.h
+++ b/src/viced/host.h
@@ -254,7 +254,7 @@ extern int h_RestoreState(void);
 #define H_ENUMERATE_BAIL(flags)        ((flags)|0x80000000)
 #define H_ENUMERATE_ISSET_BAIL(flags)  ((flags)&0x80000000)
 
-struct host *(hosttableptrs[h_MAXHOSTTABLES]);	/* Used by h_itoh */
+extern struct host *(hosttableptrs[h_MAXHOSTTABLES]);	/* Used by h_itoh */
 #define h_htoi(host) ((host)->index)	/* index isn't zeroed, no need to lock */
 #define h_itoh(hostindex) (hosttableptrs[(hostindex)>>h_HTSHIFT]+((hostindex)&(h_HTSPERBLOCK-1)))
 
diff --git a/src/viced/state_analyzer.c b/src/viced/state_analyzer.c
index 6d8b2098a..b46c4ca81 100644
--- a/src/viced/state_analyzer.c
+++ b/src/viced/state_analyzer.c
@@ -259,7 +259,7 @@ openFile(char * path)
 	goto done;
     }
 
-    printf("mapped %lu bytes at %"AFS_PTR_FMT"\n", (unsigned long)map_len, map);
+    printf("mapped %lu bytes at %p\n", (unsigned long)map_len, map);
 
  done:
     if (ret) {
@@ -700,7 +700,7 @@ print_cb_help(void)
     do { \
         char * _p = (char *)addr; \
         char * _m = (char *)map; \
-        printf("loading structure from address %"AFS_PTR_FMT" (offset %ld)\n", \
+	printf("loading structure from address %p (offset %ld)\n", \
                addr, (long)(_p-_m)); \
     } while (0)
 
@@ -751,7 +751,7 @@ print_cb_help(void)
 static void
 dump_hdr(void)
 {
-    char uuid_str[40];
+    struct uuid_fmtbuf uuid_str;
     afs_uint32 hi, lo;
 
     if (get_hdr())
@@ -766,8 +766,8 @@ dump_hdr(void)
     DPFT1("timestamp", hdrs.hdr.timestamp);
     DPFV1("sys_name", "u", hdrs.hdr.sys_name);
 
-    afsUUID_to_string(&hdrs.hdr.server_uuid, uuid_str, sizeof(uuid_str));
-    DPFS1("server_uuid", uuid_str);
+    afsUUID_to_string(&hdrs.hdr.server_uuid, &uuid_str);
+    DPFS1("server_uuid", uuid_str.buffer);
     DPFV1("valid", "d", hdrs.hdr.valid);
     DPFV1("endianness", "d", hdrs.hdr.endianness);
     DPFV1("stats_detailed", "d", hdrs.hdr.stats_detailed);
@@ -1265,6 +1265,7 @@ static void
 dump_he_interfaces(void)
 {
     char temp_str[40];
+    struct uuid_fmtbuf uuidstr;
     struct Interface * ifp;
     int len, i;
     char hoststr[16];
@@ -1281,8 +1282,8 @@ dump_he_interfaces(void)
     DPFSO0("Interface");
     DPFV1("numberOfInterfaces", "u", ifp->numberOfInterfaces);
 
-    afsUUID_to_string(&ifp->uuid, temp_str, sizeof(temp_str));
-    DPFS1("uuid", temp_str);
+    afsUUID_to_string(&ifp->uuid, &uuidstr);
+    DPFS1("uuid", uuidstr.buffer);
     for (i = 0; i < he_cursor.hdr.interfaces; i++) {
 	snprintf(temp_str, sizeof(temp_str), "interface[%d]", i);
 	DPFSO1(temp_str);
@@ -1844,33 +1845,6 @@ get_cb_entry(void)
     return 0;
 }
 
-#if 0
-static int
-find_he_by_index(afs_uint32 idx)
-{
-    int i;
-
-    if (get_h_hdr()) {
-	return 1;
-    }
-
-    for (i = 0; i < hdrs.h_hdr.records; i++) {
-	if (get_he(i)) {
-	    fprintf(stderr, "error getting he %d\n", i);
-	    return 1;
-	}
-	if (he_cursor.he.index == idx)
-	    break;
-    }
-
-    if (i < hdrs.h_hdr.records) {
-	dump_this_he();
-	return 0;
-    }
-    return 1;
-}
-#endif
-
 static int
 find_fe_by_index(afs_uint32 idx)
 {
diff --git a/src/viced/viced.c b/src/viced/viced.c
index a8b6e337c..6d2912928 100644
--- a/src/viced/viced.c
+++ b/src/viced/viced.c
@@ -47,7 +47,6 @@
 #include <opr/lock.h>
 #include <opr/proc.h>
 #include <opr/softsig.h>
-#include <afs/procmgmt_softsig.h> /* must come after softsig.h */
 #include <afs/cmd.h>
 #include <afs/ptclient.h>
 #include <afs/afsint.h>
@@ -128,6 +127,7 @@ int rxMaxMTU = -1;
 afs_int32 implicitAdminRights = PRSFS_LOOKUP;	/* The ADMINISTER right is
 						 * already implied */
 afs_int32 readonlyServer = 0;
+afs_int32 adminwriteServer = 0;
 
 int stackSize = 24000;
 int fiveminutes = 300;		/* 5 minutes.  Change this for debugging only */
@@ -312,7 +312,18 @@ fs_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
     return islocal;
 }
 
-#if !defined(AFS_NT40_ENV) && !defined(AFS_DARWIN160_ENV)
+#if defined(AFS_NT40_ENV)
+/* no viced_syscall */
+#elif defined(AFS_DARWIN160_ENV)
+/* no viced_syscall */
+#elif !defined(AFS_SYSCALL)
+int
+viced_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
+{
+    errno = ENOSYS;
+    return -1;
+}
+#else
 int
 viced_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
 {
@@ -366,7 +377,7 @@ setThreadId(char *s)
 
     /* set our 'thread-id' so that the host hold table works */
     threadId = rx_SetThreadNum();
-    afs_pthread_setname_self(s);
+    opr_threadname_set(s);
     ViceLog(0, ("Set thread id 0x%x for '%s'\n", threadId, s));
 #endif
 }
@@ -429,8 +440,10 @@ FiveMinuteCheckLWP(void *unused)
     opr_cv_broadcast(&fs_state.worker_done_cv);
     FS_UNLOCK;
     FS_STATE_UNLOCK;
-#endif
     return NULL;
+#else
+    AFS_UNREACHED(return(NULL));
+#endif
 }				/*FiveMinuteCheckLWP */
 
 
@@ -477,8 +490,10 @@ HostCheckLWP(void *unused)
     opr_cv_broadcast(&fs_state.worker_done_cv);
     FS_UNLOCK;
     FS_STATE_UNLOCK;
-#endif
     return NULL;
+#else
+    AFS_UNREACHED(return(NULL));
+#endif
 }				/*HostCheckLWP */
 
 /* This LWP does fsync checks every 5 minutes:  it should not be used for
@@ -536,8 +551,10 @@ FsyncCheckLWP(void *unused)
     opr_cv_broadcast(&fs_state.worker_done_cv);
     FS_UNLOCK;
     FS_STATE_UNLOCK;
-#endif /* AFS_DEMAND_ATTACH_FS */
     return NULL;
+#else
+    AFS_UNREACHED(return(NULL));
+#endif /* !AFS_DEMAND_ATTACH_FS */
 }
 
 /*------------------------------------------------------------------------
@@ -665,7 +682,7 @@ PrintCounters(void)
 static void *
 ShutdownWatchdogLWP(void *unused)
 {
-    afs_pthread_setname_self("ShutdownWatchdog");
+    opr_threadname_set("ShutdownWatchdog");
     sleep(panic_timeout);
     ViceLogThenPanic(0, ("ShutdownWatchdogLWP: Failed to shutdown and panic "
                          "within %d seconds; forcing panic\n",
@@ -847,7 +864,6 @@ ParseRights(char *arights)
  * AIX:         sysconf() limit is real
  * HP-UX:       sysconf() limit is real
  * IRIX:        sysconf() limit is apparently NOT real -- too small
- * DUX:         sysconf() limit is apparently NOT real -- too big
  * Linux:       sysconf() limit is apparently NOT real -- too big
  * Solaris:     no sysconf() limit
  */
@@ -874,6 +890,7 @@ enum optionsList {
     OPT_implicit,
     OPT_lock,
     OPT_readonly,
+    OPT_adminwrite,
     OPT_saneacls,
     OPT_buffers,
     OPT_callbacks,
@@ -967,6 +984,9 @@ ParseArgs(int argc, char *argv[])
 #endif
     cmd_AddParmAtOffset(opts, OPT_readonly, "-readonly", CMD_FLAG,
 			CMD_OPTIONAL, "be a readonly fileserver");
+    cmd_AddParmAtOffset(opts, OPT_adminwrite, "-admin-write", CMD_FLAG,
+			CMD_OPTIONAL, "if read-only, allow writes for users "
+			"from system:administrators");
     cmd_AddParmAtOffset(opts, OPT_saneacls, "-saneacls", CMD_FLAG,
 		        CMD_OPTIONAL, "set the saneacls capability bit");
 
@@ -1040,21 +1060,21 @@ ParseArgs(int argc, char *argv[])
     cmd_AddParmAtOffset(opts, OPT_vlrudisable, "-vlrudisable",
 			CMD_FLAG, CMD_OPTIONAL, "disable VLRU functionality");
     cmd_AddParmAtOffset(opts, OPT_vlruthresh, "-vlruthresh",
-			CMD_FLAG, CMD_OPTIONAL,
+			CMD_SINGLE, CMD_OPTIONAL,
 			"mins before unused vols become eligible for detach");
     cmd_AddParmAtOffset(opts, OPT_vlruinterval, "-vlruinterval",
-			CMD_FLAG, CMD_OPTIONAL, "secs between VLRU scans");
-    cmd_AddParmAtOffset(opts, OPT_vlrumax, "-vlrumax", CMD_FLAG, CMD_OPTIONAL,
+			CMD_SINGLE, CMD_OPTIONAL, "secs between VLRU scans");
+    cmd_AddParmAtOffset(opts, OPT_vlrumax, "-vlrumax", CMD_SINGLE, CMD_OPTIONAL,
 		        "max volumes to detach in one scan");
     cmd_AddParmAtOffset(opts, OPT_unsafe_nosalvage, "-unsafe-nosalvage",
 			CMD_FLAG, CMD_OPTIONAL,
-			"bybass safety checks on volume attach");
+			"bypass safety checks on volume attach");
 #endif
 
     /* unrecommend options - should perhaps be CMD_HIDE */
     cmd_AddParmAtOffset(opts, OPT_cbwait, "-w", CMD_SINGLE, CMD_OPTIONAL,
 			"callback wait interval");
-    cmd_AddParmAtOffset(opts, OPT_novbc, "-novbc", CMD_SINGLE, CMD_FLAG,
+    cmd_AddParmAtOffset(opts, OPT_novbc, "-novbc", CMD_FLAG, CMD_OPTIONAL,
 			"disable callback breaks on reattach");
 
     /* general options */
@@ -1077,7 +1097,7 @@ ParseArgs(int argc, char *argv[])
 
     /* rx options */
     cmd_AddParmAtOffset(opts, OPT_peer, "-enable_peer_stats", CMD_FLAG,
-			CMD_OPTIONAL, "enable RX transport statistics");
+			CMD_OPTIONAL, "enable RX RPC statistics by peer");
     cmd_AddParmAtOffset(opts, OPT_process, "-enable_process_stats", CMD_FLAG,
 			CMD_OPTIONAL, "enable RX RPC statistics");
     cmd_AddParmAtOffset(opts, OPT_nojumbo, "-nojumbo", CMD_FLAG,
@@ -1168,6 +1188,7 @@ ParseArgs(int argc, char *argv[])
     cmd_OptionAsFlag(opts, OPT_lock, &SawLock);
 #endif
     cmd_OptionAsFlag(opts, OPT_readonly, &readonlyServer);
+    cmd_OptionAsFlag(opts, OPT_adminwrite, &adminwriteServer);
     cmd_OptionAsFlag(opts, OPT_saneacls, &saneacls);
     cmd_OptionAsInt(opts, OPT_buffers, &buffs);
 
@@ -1820,6 +1841,7 @@ main(int argc, char *argv[])
     int curLimit;
     time_t t;
     struct tm tm;
+    char hoststr[16];
     afs_uint32 rx_bindhost;
     VolumePackageOptions opts;
 
@@ -1878,7 +1900,12 @@ main(int argc, char *argv[])
     OpenLog(&logopts);
 
     LogCommandLine(argc, argv, "starting", "", "File server", FSLog);
-    if (afsconf_GetLatestKey(confDir, NULL, NULL) == 0) {
+
+    if (afsconf_CountKeys(confDir) == 0) {
+	ViceLog(0, ("WARNING: No encryption keys found! "
+		    "All authenticated accesses will fail. "
+		    "Run akeyconvert or asetkey to import encryption keys.\n"));
+    } else if (afsconf_GetLatestKey(confDir, NULL, NULL) == 0) {
 	LogDesWarning();
     }
 
@@ -1896,8 +1923,9 @@ main(int argc, char *argv[])
     if (SawLock)
 	plock(PROCLOCK);
 #elif !defined(AFS_NT40_ENV)
-    if (nice(-5) < 0)
-	; /* don't care */
+    if (nice(-5) < 0) {
+	/* don't care */
+    }
 #endif
     DInit(buffs);
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -1987,6 +2015,8 @@ main(int argc, char *argv[])
 	rx_SetUdpBufSize(udpBufSize);	/* set the UDP buffer size for receive */
     rx_bindhost = SetupVL();
 
+    ViceLog(0, ("File server binding rx to %s:%d\n",
+            afs_inet_ntoa_r(rx_bindhost, hoststr), 7000));
     if (rx_InitHost(rx_bindhost, (int)htons(7000)) < 0) {
 	ViceLog(0, ("Cannot initialize RX\n"));
 	exit(1);
@@ -2017,8 +2047,12 @@ main(int argc, char *argv[])
 	exit(-1);
     }
     if (rxkadDisableDotCheck) {
-        rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
-                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	code = rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
+					   (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	if (code) {
+	    ViceLog(0, ("Failed to allow dotted principals: code %d\n", code));
+	    exit(-1);
+	}
     }
     rx_SetMinProcs(tservice, 3);
     rx_SetMaxProcs(tservice, lwps);
@@ -2185,7 +2219,6 @@ main(int argc, char *argv[])
     if (!he) {
 	ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
     } else {
-	char hoststr[16];
 	memcpy(&FS_HostAddr_NBO, he->h_addr, 4);
 	(void)afs_inet_ntoa_r(FS_HostAddr_NBO, hoststr);
 	FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
@@ -2202,5 +2235,5 @@ main(int argc, char *argv[])
     while (1) {
 	sleep(1000);		/* long time */
     }
-    return 0;
+    AFS_UNREACHED(return(0));
 }
diff --git a/src/vlserver/Makefile.in b/src/vlserver/Makefile.in
index 8a09bc50d..08fd55615 100644
--- a/src/vlserver/Makefile.in
+++ b/src/vlserver/Makefile.in
@@ -87,11 +87,6 @@ cnvldb: cnvldb.o ${LIBS}
 
 cnvldb.o: cnvldb.c cnvldb.h AFS_component_version_number.o
 
-sascnvldb: sascnvldb.o ${LIBS}
-	$(AFS_LDRULE) sascnvldb.o ${LIBS} $(LIB_roken) ${XLIBS}
-
-sascnvldb.o: sascnvldb.c cnvldb.h AFS_component_version_number.o
-
 vlserver: vlserver.o vlutils.o vlprocs.o vldbint.ss.o vldbint.xdr.lo $(LIBS)
 	$(AFS_LDRULE) vlserver.o vlutils.o vlprocs.o vldbint.ss.o \
 		.lwp/vldbint.xdr.o \
diff --git a/src/vlserver/sascnvldb.c b/src/vlserver/sascnvldb.c
deleted file mode 100644
index b046e8273..000000000
--- a/src/vlserver/sascnvldb.c
+++ /dev/null
@@ -1,418 +0,0 @@
-/*
- * 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>
-#include <afs/stds.h>
-
-#include <sys/file.h>
-#include <afs/venus.h>
-#include <afs/cmd.h>
-#include <afs/afs_consts.h>
-
-#include "cnvldb.h"		/* CHANGEME! */
-
-static char pn[] = "cnvldb";
-static char tempname[] = "XXnewvldb";
-static char space[AFS_PIOCTL_MAXSIZE];
-static int MaxServers[2] = { 30, 254 };	/* max server # permitted in this version */
-
-#ifdef notdef			/* postpone this... */
-static int
-saferead(fd, addr, osize)
-     int fd, osize;
-     char *addr;
-{
-    int rc, size;
-    char *ptr;
-
-    if (size == EOF)
-	return (EOF);
-
-    ptr = addr;
-    rc = osize = size;
-
-    while (rc != EOF) {
-	rc = read(fd, ptr, size)) {
-	    if (rc == size)
-		return osize;
-	    else {
-		if (errno != EINTR) {
-		    perror(pn);
-		    exit(-1);
-		}
-	    }
-	}
-    }
-
-
-    static int
-      saferead(fd, addr, osize)
-    int fd, osize;
-    char *addr;
-    {
-	int rc;
-
-	rc = read(fd, addr, osize);
-	if (rc != osize && rc != EOF) {
-	    perror(pn);
-	    exit(-1);
-	}
-	return (rc);
-    }
-#else
-#define saferead(fd,addr,siz) read((fd),(addr),(siz))
-#endif
-
-static char tspace[1024];	/* chdir can't handle anything bigger, anyway */
-/* return a static pointer to a buffer */
-static char *
-Parent(apath)
-     char *apath;
-{
-    char *tp;
-    strcpy(tspace, apath);
-    tp = strrchr(tspace, '/');
-    if (tp) {
-	*tp = 0;
-    } else
-	strcpy(tspace, ".");
-    return tspace;
-}
-
-#ifdef notdef
-
-/* this function returns TRUE (1) if the file is in AFS, otherwise false (0) */
-static int
-InAFS(apath)
-     char *apath;
-{
-    struct ViceIoctl blob;
-    afs_int32 code;
-
-    blob.in_size = 0;
-    blob.out_size = AFS_PIOCTL_MAXSIZE;
-    blob.out = space;
-
-    code = pioctl(apath, VIOC_FILE_CELL_NAME, &blob, 1);
-    if (code) {
-	if ((errno == EINVAL) || (errno == ENOENT))
-	    return 0;
-    }
-    return 1;
-}
-
-QuickPrintStatus(status, name)
-     struct VolumeStatus *status;
-     char *name;
-{
-    double QuotaUsed = 0.0;
-    double PartUsed = 0.0;
-    int WARN = 0;
-
-    if (status->MaxQuota != 0) {
-	QuotaUsed =
-	    ((((double)status->BlocksInUse) / status->MaxQuota) * 100.0);
-    } else {
-	/* no limit */
-    }
-    PartUsed =
-	(100.0 -
-	 ((((double)status->PartBlocksAvail) / status->PartMaxBlocks) *
-	  100.0));
-}
-
-
-static int
-ListQuotaCmd(struct cmd_syndesc *as, void *arock)
-{
-    afs_int32 code;
-    struct ViceIoctl blob;
-    struct cmd_item *ti;
-    struct VolumeStatus *status;
-    char *name;
-
-    for (ti = as->parms[0].items; ti; ti = ti->next) {
-	/* once per file */
-	blob.out_size = AFS_PIOCTL_MAXSIZE;
-	blob.in_size = 0;
-	blob.out = space;
-	code = pioctl(ti->data, VIOCGETVOLSTAT, &blob, 1);
-	if (code) {
-	    Die(code, ti->data);
-	    continue;
-	}
-	status = (struct VolumeStatus *)space;
-	name = (char *)status + sizeof(*status);
-	QuickPrintStatus(status, name);
-    }
-    return 0;
-}
-#endif /* notdef */
-
-int gc = 1, fromvers = 1, tovers = 2;
-char *pathname = NULL, *defaultpath = "/usr/afs/db/vl.DB0";
-
-usage()
-{
-    fprintf(stderr, "usage: %s ", pn);
-    fprintf(stderr, "[-name <pathname>] [-help]\n");
-}
-
-getargs(argc, argv)
-     int argc;
-     char **argv;
-{
-    int pos, i;
-    pos = 0;
-
-    for (i = 1; i < argc; i++) {
-	if (!argv[i])
-	    break;
-	else if (*(argv[i]) != '-') {	/* positional params */
-	    if (!pathname)
-		pathname = argv[i];
-	    else {
-		fprintf(stderr, "%s: Too many parameters!\n");
-		usage();
-		exit(-1);
-	    }
-	} else			/* keyword params */
-	    switch (argv[i][1]) {
-
-	    case 't':		/* -to */
-		fprintf(stderr, "%s: can't specify version with this tool!\n",
-			pn);
-		exit(-1);
-		break;
-
-	    case 'f':		/* -from */
-		fprintf(stderr, "%s: can't specify version with this tool!\n",
-			pn);
-		break;
-
-	    case 'n':		/* -name */
-		if (pathname) {
-		    fprintf(stderr,
-			    "%s: -name specified (or implied) twice!\n", pn);
-		    exit(-1);
-		}
-		pathname = argv[++i];
-		break;
-
-	    case 'h':		/* -help */
-		usage();
-		exit(0);
-		break;
-
-	    case 'g':		/* -gc == No GC */
-		gc = 0;
-		break;
-
-	    default:
-		usage();
-		exit(EINVAL);
-	    }
-    }
-
-    if (!pathname)
-	pathname = defaultpath;
-}
-
-#include "AFS_component_version_number.c"
-
-main(argc, argv)
-     int argc;
-     char **argv;
-{
-    afs_int32 code;
-    int old, new, rc;
-    short uvers;
-    char ubik[80];		/* space for some ubik header */
-
-    union {
-	struct vlheader_1 header1;
-	struct vlheader_2 header2;
-    } oldheader, newheader;	/* large enough for either */
-
-    union {
-	struct vlentry_1 entry1;
-	struct vlentry_2 entry2;
-    } vlentry;
-
-
-    getargs(argc, argv);
-
-    /* should stat() the old vldb, get its size, and see if there's */
-    /* room for another.  It might be in AFS, so check the quota, too */
-    if (!(old = open(pathname, O_RDONLY))) {
-	perror(pn);
-	exit(-1);
-    }
-
-    if (chdir(Parent(pathname))) {
-	perror(pn);
-	exit(-1);
-    }
-
-    if (!(new = open(tempname, O_WRONLY | O_CREAT | O_TRUNC, 0600))) {
-	perror(pn);
-	exit(-1);
-    }
-
-    if (fromvers == 0) {	/* not set */
-	lseek(old, 64, L_SET);
-	read(old, &fromvers, sizeof(int));
-	fromvers = ntohl(fromvers);
-	lseek(old, 0, L_SET);	/* go back to beginning */
-    }
-
-    /* skip the UBIK data */
-    read(old, ubik, 64);
-#ifdef notdef
-    uvers = ntohs(uvers);
-    uvers += 10;		/* hey, if you screw with the VLDB, you lose */
-    uvers = htons(uvers);
-#endif
-    write(new, ubik, 64);
-
-    readheader(old, fromvers, &oldheader);
-    convert_header(new, fromvers, tovers, &oldheader, &newheader);
-    while ((rc = read(old, &vlentry, sizeof(struct vlentry_1))) && rc != EOF) {
-	convert_vlentry(new, fromvers, tovers, &oldheader, &newheader,
-			&vlentry);
-    }
-
-
-    if (gc)
-	rewrite_header(new, tovers, &newheader);
-
-    close(old);
-    if (fsync(new)) {
-	perror(pn);
-	exit(-1);
-    }
-
-    close(new);
-    rename(tempname, pathname);
-    exit(0);
-}
-
-readheader(fd, version, addr)
-     int fd;
-     int version;
-     char *addr;
-{
-    if (version == 1) {
-	read(fd, addr, sizeof(struct vlheader_2));	/* it's not a bug, it's SAS */
-    } else if (version == 2) {
-	read(fd, addr, sizeof(struct vlheader_2));
-    } else
-	return EINVAL;
-
-    return 0;
-}
-
-/* SAS special */
-convert_header(fd, fromv, tov, fromaddr, toaddr)
-     int fd, fromv, tov;
-     char *fromaddr, *toaddr;
-{
-    struct vlheader_2 *tvp1;
-    struct vlheader_2 *tvp2;
-    int i, j, diff;
-
-    memcpy(toaddr, fromaddr, sizeof(struct vlheader_2));
-    tvp2 = (struct vlheader_2 *)toaddr;
-    tvp2->vital_header.vldbversion = htonl(2);
-
-    write(fd, tvp2, sizeof(struct vlheader_2));
-
-    /* for garbage-collecting... */
-    if (gc)
-	for (i = 0; i < 254; i++)
-	    tvp2->IpMappedAddr[i] = 0;
-
-    return 0;
-}
-
-static int
-convert_vlentry(new, fromvers, tovers, oldheader, newheader, vlentry)
-     int new, fromvers, tovers;
-     struct vlheader_1 *oldheader, *newheader;	/* close enough */
-     struct vlentry_1 *vlentry;	/* 1 and 2 are identical */
-{
-    int diff, i, s;
-
-#ifndef DEBUG
-    if (fromvers != tovers) {	/* only supports 1 and 2 currently */
-#endif
-
-	diff =
-	    (tovers ==
-	     1 ? sizeof(struct vlheader_1) : sizeof(struct vlheader_2))
-	    - (fromvers ==
-	       1 ? sizeof(struct vlheader_1) : sizeof(struct vlheader_2));
-
-	for (i = 0; i < 3; i++)
-	    vlentry->nextIdHash[i] =
-		htonl(ntohl(vlentry->nextIdHash[i]) + diff);
-
-	vlentry->nextNameHash = htonl(ntohl(vlentry->nextNameHash) + diff);
-
-#ifndef DEBUG
-    } else {
-	;			/* no change, we're just in it for the GC */
-    }
-#endif
-
-    for (i = 0; i < 8; i++) {
-	s = vlentry->serverNumber[i];
-	if (s != 255) {
-	    if (s > 254) {
-		fprintf(stderr,
-			"%s: Too Many Servers (%d) for this version!\n", pn,
-			s + 1);
-		exit(-1);
-	    } else {
-		newheader->IpMappedAddr[s] = oldheader->IpMappedAddr[s];
-	    }
-	}
-    }
-    write(new, vlentry, sizeof(struct vlentry_2));
-
-    return;
-}
-
-static int
-rewrite_header(new, tovers, newheader)
-     int new, tovers;
-     char *newheader;
-{
-    int pos;
-
-    pos = lseek(new, 64, L_SET);	/* leave room for ubik */
-
-    if (pos == -1) {
-	perror(pn);
-	fprintf(stderr, "%s: no garbage collection\n", pn);
-	return;
-    } else if (pos != 64) {
-	fprintf(stderr, "%s: Can't rewind: no garbage collection\n", pn);
-	return;
-    }
-
-    if (tovers = 1) {
-	write(new, newheader, sizeof(struct vlheader_1));
-    } else {
-	write(new, newheader, sizeof(struct vlheader_2));
-    }
-
-    return;
-}
diff --git a/src/vlserver/vlclient.c b/src/vlserver/vlclient.c
index e22af50e0..8c5044c50 100644
--- a/src/vlserver/vlclient.c
+++ b/src/vlserver/vlclient.c
@@ -687,7 +687,7 @@ handleit(struct cmd_syndesc *as, void *arock)
 		sscanf(&(*argp)[0], "%d", &id);
 		++argp, --nargs;
 		sscanf(&(*argp)[0], "%d", &voltype);
-		if (voltype < 0 && voltype > 2) {
+		if (voltype < 0 || voltype > 2) {
 		    printf("Illegal voltype; must be 0, 1 or 2\n");
 		    continue;
 		}
diff --git a/src/vlserver/vldb_check.c b/src/vlserver/vldb_check.c
index ed857f9ee..5e454d205 100644
--- a/src/vlserver/vldb_check.c
+++ b/src/vlserver/vldb_check.c
@@ -479,9 +479,13 @@ writeMH(afs_int32 addr, int block, struct extentaddr *mhblockP)
     if (verbose) {
 	quiet_println("Writing back MH block % at addr %u\n", block,  addr);
     }
+    mhblockP->ex_hdrflags = htonl(mhblockP->ex_hdrflags);
     if (block == 0) {
+	/*
+	 * These header fields are only used in the first mh block, so were
+	 * converted to host byte order only when the first mh block was read.
+	 */
 	mhblockP->ex_count = htonl(mhblockP->ex_count);
-	mhblockP->ex_hdrflags = htonl(mhblockP->ex_hdrflags);
 	for (i = 0; i < VL_MAX_ADDREXTBLKS; i++) {
 	    mhblockP->ex_contaddrs[i] = htonl(mhblockP->ex_contaddrs[i]);
 	}
diff --git a/src/vlserver/vldbint.xg b/src/vlserver/vldbint.xg
index ff34d12d4..523fe801e 100644
--- a/src/vlserver/vldbint.xg
+++ b/src/vlserver/vldbint.xg
@@ -208,7 +208,12 @@ const VLOP_DUMP        = 0x100;
 typedef	vldbentry bulkentries<>;
 typedef	nvldbentry nbulkentries<>;
 typedef	uvldbentry ubulkentries<>;
-typedef afs_uint32 bulkaddrs<>;
+/*
+ * 500 is an arbitrary implementation limit, larger than what we support storing.
+ * It lets the XDR decoder detect an attack (excessively large input) and reject
+ * it without incurring excessive resource usage.
+ */
+typedef afs_uint32 bulkaddrs<500>;
 
 struct VLCallBack {
     afs_uint32 CallBackVersion;
diff --git a/src/vlserver/vlprocs.c b/src/vlserver/vlprocs.c
index 016ff513f..89f8760a4 100644
--- a/src/vlserver/vlprocs.c
+++ b/src/vlserver/vlprocs.c
@@ -146,7 +146,7 @@ multiHomedExtent(struct vl_ctx *ctx, int srvidx, struct extentaddr **exp)
     return multiHomedExtentBase(ctx, srvidx, exp, &base);
 }
 
-#define AFS_RXINFO_LEN 128
+#define AFS_RXINFO_LEN 217
 static char *
 rxkadInfo(char *str, struct rx_connection *conn, struct in_addr hostAddr)
 {
@@ -1841,7 +1841,7 @@ ListAttributesN2(struct rx_call *rxcall,
 		 * pick up entries marked NEWREPSITEs and DONTUSE.
 		 */
 		else {
-		    if (tentry.flags & VLF_ROEXISTS) {
+		    if ((tentry.serverFlags[k] & VLSF_ROVOL) != 0) {
 			if (findname) {
 			    if (namematchRO) {
 				thismatch =
@@ -3054,7 +3054,7 @@ vldbentry_to_vlentry(struct vl_ctx *ctx,
 	VlEntry->serverPartition[i] = VldbEntry->serverPartition[i];
 	VlEntry->serverFlags[i] = VldbEntry->serverFlags[i];
     }
-    for (; i < OMAXNSERVERS; i++)
+    for (; i < NMAXNSERVERS; i++)
 	VlEntry->serverNumber[i] = VlEntry->serverPartition[i] =
 	    VlEntry->serverFlags[i] = BADSERVERID;
     for (i = 0; i < MAXTYPES; i++)
diff --git a/src/vlserver/vlserver.c b/src/vlserver/vlserver.c
index 08ecab93c..36e02a8c5 100644
--- a/src/vlserver/vlserver.c
+++ b/src/vlserver/vlserver.c
@@ -14,7 +14,6 @@
 #include <roken.h>
 #ifdef AFS_PTHREAD_ENV
 # include <opr/softsig.h>
-# include <afs/procmgmt_softsig.h> /* must come after softsig.h */
 #endif
 
 #ifdef AFS_NT40_ENV
@@ -158,7 +157,8 @@ enum optionsList {
     OPT_trace,
     OPT_dotted,
     OPT_restricted_query,
-    OPT_transarc_logs
+    OPT_transarc_logs,
+    OPT_s2s_crypt
 };
 
 int
@@ -176,9 +176,11 @@ main(int argc, char **argv)
     char hostname[VL_MAXNAMELEN];
     int noAuth = 0;
     char clones[MAXHOSTSPERCELL];
+    char hoststr[16];
     afs_uint32 host = ntohl(INADDR_ANY);
     struct cmd_syndesc *opts;
     struct logOptions logopts;
+    int s2s_rxgk = 0;
 
     char *vl_dbaseName;
     char *configDir;
@@ -186,6 +188,7 @@ main(int argc, char **argv)
     char *auditFileName = NULL;
     char *interface = NULL;
     char *optstring = NULL;
+    char *s2s_crypt_behavior = NULL;
 
     char *restricted_query_parameter = NULL;
 
@@ -257,7 +260,7 @@ main(int argc, char **argv)
 
     /* rx options */
     cmd_AddParmAtOffset(opts, OPT_peer, "-enable_peer_stats", CMD_FLAG,
-		        CMD_OPTIONAL, "enable RX transport statistics");
+		        CMD_OPTIONAL, "enable RX RPC statistics by peer");
     cmd_AddParmAtOffset(opts, OPT_process, "-enable_process_stats", CMD_FLAG,
 		        CMD_OPTIONAL, "enable RX RPC statistics");
     cmd_AddParmAtOffset(opts, OPT_nojumbo, "-nojumbo", CMD_FLAG,
@@ -279,6 +282,11 @@ main(int argc, char **argv)
 		        CMD_FLAG, CMD_OPTIONAL,
 		        "permit Kerberos 5 principals with dots");
 
+    /* rxgk options */
+    cmd_AddParmAtOffset(opts, OPT_s2s_crypt, "-s2scrypt", CMD_SINGLE,
+			CMD_OPTIONAL,
+			"rxgk-crypt | never");
+
     code = cmd_Parse(argc, argv, &opts);
     if (code == CMD_HELP) {
 	exit(0);
@@ -386,6 +394,20 @@ main(int argc, char **argv)
 	free(restricted_query_parameter);
     }
 
+    /* rxgk options */
+    if (cmd_OptionAsString(opts, OPT_s2s_crypt, &s2s_crypt_behavior) == 0) {
+	if (strcmp(s2s_crypt_behavior, "never") == 0) {
+	    /* noop; this is the default */
+	} else if (strcmp(s2s_crypt_behavior, "rxgk-crypt") == 0) {
+	    s2s_rxgk = 1;
+	} else {
+	    printf("Invalid argument for -s2scrypt: %s\n", s2s_crypt_behavior);
+	    return -1;
+	}
+	free(s2s_crypt_behavior);
+	s2s_crypt_behavior = NULL;
+    }
+
     if (auditFileName) {
 	osi_audit_file(auditFileName);
     }
@@ -463,7 +485,6 @@ main(int argc, char **argv)
         }
         if (ccode == 1) {
             host = SHostAddrs[0];
-	    rx_InitHost(host, htons(AFSCONF_VLDBPORT));
 	}
     }
 
@@ -477,7 +498,9 @@ main(int argc, char **argv)
 	}
     }
 
-    code = rx_Init(htons(AFSCONF_VLDBPORT));
+    VLog(0, ("vlserver binding rx to %s:%d\n",
+         afs_inet_ntoa_r(host, hoststr), AFSCONF_VLDBPORT));
+    code = rx_InitHost(host, htons(AFSCONF_VLDBPORT));
     if (code < 0) {
         VLog(0, ("vlserver: Rx init failed: %d\n", code));
         exit(1);
@@ -485,7 +508,12 @@ main(int argc, char **argv)
     rx_SetRxDeadTime(50);
 
     ubik_nBuffers = 512;
-    ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, tdir);
+    if (s2s_rxgk) {
+	ubik_SetClientSecurityProcs(afsconf_ClientAuthRXGKCrypt,
+				    afsconf_UpToDate, tdir);
+    } else {
+	ubik_SetClientSecurityProcs(afsconf_ClientAuth, afsconf_UpToDate, tdir);
+    }
     ubik_SetServerSecurityProcs(afsconf_BuildServerSecurityObjects,
 				afsconf_CheckAuth, tdir);
 
@@ -518,8 +546,13 @@ main(int argc, char **argv)
     rx_SetMaxProcs(tservice, lwps);
 
     if (rxkadDisableDotCheck) {
-        rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
-                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	code = rx_SetSecurityConfiguration(tservice, RXS_CONFIG_FLAGS,
+					   (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	if (code) {
+	    VLog(0, ("vlserver: failed to allow dotted principals: %s\n",
+		 afs_error_message(code)));
+	    exit(2);
+	}
     }
 
     tservice =
@@ -534,7 +567,11 @@ main(int argc, char **argv)
     rx_SetMaxProcs(tservice, 4);
 
     LogCommandLine(argc, argv, "vlserver", VldbVersion, "Starting AFS", FSLog);
-    if (afsconf_GetLatestKey(tdir, NULL, NULL) == 0) {
+    if (afsconf_CountKeys(tdir) == 0) {
+	VLog(0, ("WARNING: No encryption keys found! "
+		 "All authenticated accesses will fail."
+		 "Run akeyconvert or asetkey to import encryption keys.\n"));
+    } else if (afsconf_GetLatestKey(tdir, NULL, NULL) == 0) {
 	LogDesWarning();
     }
     VLog(0, ("%s\n", cml_version_number));
diff --git a/src/vlserver/vlutils.c b/src/vlserver/vlutils.c
index 06ad04b67..d11917fae 100644
--- a/src/vlserver/vlutils.c
+++ b/src/vlserver/vlutils.c
@@ -178,9 +178,15 @@ vlentryread(struct ubik_trans *trans, afs_int32 offset, char *buffer,
 	    nbufp->nextIdHash[i] = ntohl(oep->nextIdHash[i]);
 	nbufp->nextNameHash = ntohl(oep->nextNameHash);
 	memcpy(nbufp->name, oep->name, VL_MAXNAMELEN);
-	memcpy(nbufp->serverNumber, oep->serverNumber, NMAXNSERVERS);
-	memcpy(nbufp->serverPartition, oep->serverPartition, NMAXNSERVERS);
-	memcpy(nbufp->serverFlags, oep->serverFlags, NMAXNSERVERS);
+	memcpy(nbufp->serverNumber, oep->serverNumber, OMAXNSERVERS);
+	memcpy(nbufp->serverPartition, oep->serverPartition, OMAXNSERVERS);
+	memcpy(nbufp->serverFlags, oep->serverFlags, OMAXNSERVERS);
+	/* initilize the last elements to BADSERVERID */
+	for (i = OMAXNSERVERS; i < NMAXNSERVERS; i++) {
+	    nbufp->serverNumber[i] = BADSERVERID;
+	    nbufp->serverPartition[i] = BADSERVERID;
+	    nbufp->serverFlags[i] = BADSERVERID;
+	}
     }
     return 0;
 }
@@ -391,9 +397,34 @@ CheckInit(struct ubik_trans *trans, int builddb)
     return 0;
 }
 
+/**
+ * Grow the eofPtr in the header by 'bump' bytes.
+ *
+ * @param[inout] cheader    VL header
+ * @param[in] bump	    How many bytes to add to eofPtr
+ * @param[out] a_blockindex On success, set to the original eofPtr before we
+ *			    bumped it
+ * @return VL error codes
+ */
+static afs_int32
+grow_eofPtr(struct vlheader *cheader, afs_int32 bump, afs_int32 *a_blockindex)
+{
+    afs_int32 blockindex = ntohl(cheader->vital_header.eofPtr);
+
+    if (blockindex < 0 || blockindex >= MAX_AFS_INT32 - bump) {
+	VLog(0, ("Error: Tried to grow the VLDB beyond the 2GiB limit. Either "
+		 "find a way to trim down your VLDB, or upgrade to a release "
+		 "and database format that supports a larger VLDB.\n"));
+	return VL_IO;
+    }
+
+    *a_blockindex = blockindex;
+    cheader->vital_header.eofPtr = htonl(blockindex + bump);
+    return 0;
+}
 
 afs_int32
-GetExtentBlock(struct vl_ctx *ctx, register afs_int32 base)
+GetExtentBlock(struct vl_ctx *ctx, afs_int32 base)
 {
     afs_int32 blockindex, code, error = 0;
 
@@ -412,16 +443,17 @@ GetExtentBlock(struct vl_ctx *ctx, register afs_int32 base)
 
 	/* Write the full extension block at end of vldb */
 	ctx->ex_addr[base]->ex_hdrflags = htonl(VLCONTBLOCK);
-	blockindex = ntohl(ctx->cheader->vital_header.eofPtr);
+	code = grow_eofPtr(ctx->cheader, VL_ADDREXTBLK_SIZE, &blockindex);
+	if (code)
+	    ERROR_EXIT(VL_IO);
+
 	code =
 	    vlwrite(ctx->trans, blockindex, (char *)ctx->ex_addr[base],
 		    VL_ADDREXTBLK_SIZE);
 	if (code)
 	    ERROR_EXIT(VL_IO);
 
-	/* Update the cheader.vitalheader structure on disk */
-	ctx->cheader->vital_header.eofPtr = blockindex + VL_ADDREXTBLK_SIZE;
-	ctx->cheader->vital_header.eofPtr = htonl(ctx->cheader->vital_header.eofPtr);
+
 	code = write_vital_vlheader(ctx);
 	if (code)
 	    ERROR_EXIT(VL_IO);
@@ -566,9 +598,11 @@ AllocBlock(struct vl_ctx *ctx, struct nvlentry *tentry)
 	    return 0;
 	ctx->cheader->vital_header.freePtr = htonl(tentry->nextIdHash[0]);
     } else {
+	afs_int32 code;
 	/* hosed, nothing on free list, grow file */
-	blockindex = ntohl(ctx->cheader->vital_header.eofPtr);	/* remember this guy */
-	ctx->cheader->vital_header.eofPtr = htonl(blockindex + sizeof(vlentry));
+	code = grow_eofPtr(ctx->cheader, sizeof(vlentry), &blockindex);
+	if (code)
+	    return 0;
     }
     ctx->cheader->vital_header.allocs++;
     if (write_vital_vlheader(ctx))
diff --git a/src/vol/Makefile.in b/src/vol/Makefile.in
index cb37d77e3..f6b85e6a9 100644
--- a/src/vol/Makefile.in
+++ b/src/vol/Makefile.in
@@ -245,8 +245,9 @@ clean:
 	$(RM) -f *.o *.a AFS_component_version_number.c
 	$(RM) -f ${SCMPROGS} ${STAGEPROGS} core salvager volinfo volscan gi fssync-debug
 
+.PHONY: test
 test:
-	cd test; $(MAKE)
+	cd test && $(MAKE)
 
 include ../config/Makefile.version
 
diff --git a/src/vol/clone.c b/src/vol/clone.c
index dfe67cad2..deaa079c5 100644
--- a/src/vol/clone.c
+++ b/src/vol/clone.c
@@ -256,7 +256,7 @@ DoCloneIndex(Volume * rwvp, Volume * clvp, VnodeClass class, int reclone)
 	    } else if (rwinode) {
 		if (IH_INC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) ==
 		    -1) {
-		    Log("IH_INC failed: %"AFS_PTR_FMT", %s, %" AFS_VOLID_FMT " errno %d\n",
+		    Log("IH_INC failed: %p, %s, %" AFS_VOLID_FMT " errno %d\n",
 			V_linkHandle(rwvp), PrintInode(stmp, rwinode),
 			afs_printable_VolumeId_lu(V_parentId(rwvp)), errno);
 		    VForceOffline(rwvp);
@@ -309,7 +309,7 @@ DoCloneIndex(Volume * rwvp, Volume * clvp, VnodeClass class, int reclone)
 	    if (inodeinced) {
 		if (IH_DEC(V_linkHandle(rwvp), rwinode, V_parentId(rwvp)) ==
 		    -1) {
-		    Log("IH_DEC failed: %"AFS_PTR_FMT", %s, %" AFS_VOLID_FMT " errno %d\n",
+		    Log("IH_DEC failed: %p, %s, %" AFS_VOLID_FMT " errno %d\n",
 			V_linkHandle(rwvp), PrintInode(stmp, rwinode),
 			afs_printable_VolumeId_lu(V_parentId(rwvp)), errno);
 		    VForceOffline(rwvp);
diff --git a/src/vol/devname.c b/src/vol/devname.c
index de5852595..eddd60c33 100644
--- a/src/vol/devname.c
+++ b/src/vol/devname.c
@@ -10,6 +10,8 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
+#ifndef AFS_NAMEI_ENV
+
 #include <roken.h>
 
 #include <ctype.h>
@@ -19,55 +21,45 @@
 #include <afs/afsint.h>
 
 #if !defined(AFS_SGI_ENV)
-#ifdef	AFS_OSF_ENV
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
-#ifdef AFS_VFSINCL_ENV
-#define VFS
-#ifdef	AFS_SUN5_ENV
-#include <sys/fs/ufs_fs.h>
-#else
-#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
-#include <ufs/ufs/dinode.h>
-#include <ufs/ffs/fs.h>
-#else
-#include <ufs/fs.h>
-#endif
-#endif
-#else /* AFS_VFSINCL_ENV */
-#if !defined(AFS_AIX_ENV) && !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_DARWIN_ENV)
-#include <sys/fs.h>
-#endif
-#endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
+# ifdef AFS_VFSINCL_ENV
+#  define VFS
+#  ifdef	AFS_SUN5_ENV
+#   include <sys/fs/ufs_fs.h>
+#  else
+#   include <ufs/fs.h>
+#  endif
+# else /* AFS_VFSINCL_ENV */
+#  if !defined(AFS_AIX_ENV)
+#   include <sys/fs.h>
+#  endif
+# endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_SGI_ENV */
+
 #include <sys/file.h>
+
 #ifdef	AFS_AIX_ENV
-#include <sys/vfs.h>
-#else
-#ifdef	AFS_HPUX_ENV
-#include <mntent.h>
-#else
-#if	defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
-#ifdef	AFS_SUN5_ENV
-#include <sys/mnttab.h>
-#include <sys/mntent.h>
-#else
-#include <mntent.h>
-#endif
-#else
-#if defined(AFS_SGI_ENV)
-#include <mntent.h>
-#else
-#ifdef AFS_LINUX22_ENV
-#include <mntent.h>
-#else
-#include <fstab.h>
-#endif
-#endif
-#endif /* AFS_SGI_ENV */
-#endif /* AFS_HPUX_ENV */
+# include <sys/vfs.h>
+#else
+# ifdef	AFS_HPUX_ENV
+#  include <mntent.h>
+# else
+#  if	defined(AFS_SUN_ENV) || defined(AFS_SUN5_ENV)
+#   ifdef	AFS_SUN5_ENV
+#    include <sys/mnttab.h>
+#    include <sys/mntent.h>
+#   else
+#    include <mntent.h>
+#   endif
+#  else
+#   if defined(AFS_SGI_ENV)
+#    include <mntent.h>
+#   else
+#    include <fstab.h>
+#   endif
+#  endif /* AFS_SGI_ENV */
+# endif /* AFS_HPUX_ENV */
 #endif
+
 #include <sys/wait.h>
 #include <setjmp.h>
 
@@ -86,13 +78,14 @@ vol_DevName(dev_t adev, char *wpath)
     struct mnttab mnt;
     FILE *mntfile;
 #else
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
+# if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
     struct mntent *mntent;
     FILE *mfd;
-#else
+# else
     struct fstab *fsent;
-#endif
-#endif
+# endif
+#endif /* AFS_SUN5_ENV */
+
 #ifdef	AFS_AIX_ENV
     int nmounts;
     struct vmount *vmountp;
@@ -107,58 +100,45 @@ vol_DevName(dev_t adev, char *wpath)
 	 (struct vmount *)((int)vmountp + vmountp->vmt_length)) {
 	char *part = vmt2dataptr(vmountp, VMT_STUB);
 #else
-#ifdef	AFS_SUN5_ENV
+# ifdef	AFS_SUN5_ENV
     if (!(mntfile = fopen(MNTTAB, "r"))) {
 	return NULL;
     }
     while (!getmntent(mntfile, &mnt)) {
 	char *part = mnt.mnt_mountp;
-#else
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
-#ifdef AFS_LINUX22_ENV
-    if ((mfd = setmntent("/proc/mounts", "r")) == NULL) {
-	if ((mfd = setmntent("/etc/mtab", "r")) == NULL) {
-	    return NULL;
-	}
-    }
-#else
+# else
+#  if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
     if ((mfd = setmntent(MOUNTED /*MNTTAB*/, "r")) == NULL) {
 	return NULL;
     }
-#endif
     while ((mntent = getmntent(mfd))) {
 	char *part = mntent->mnt_dir;
-#else
+#  else
     setfsent();
     while ((fsent = getfsent())) {
 	char *part = fsent->fs_file;
-#endif
-#endif /* AFS_SGI_ENV */
+#  endif
+# endif /* AFS_SGI_ENV */
 #endif
 	struct stat status;
 #ifdef	AFS_AIX_ENV
 	if (vmountp->vmt_flags & (MNT_READONLY | MNT_REMOVABLE | MNT_REMOTE))
 	    continue;		/* Ignore any "special" partitions */
 #else
-#ifdef	AFS_SUN5_ENV
+# ifdef	AFS_SUN5_ENV
 	/* Ignore non ufs or non read/write partitions */
 	if ((strcmp(mnt.mnt_fstype, "ufs") != 0)
 	    || (strncmp(mnt.mnt_mntopts, "ro,ignore", 9) == 0))
 	    continue;
-#else
-#if defined(AFS_LINUX22_ENV)
-	if (strcmp(mntent->mnt_type, "ext2"))
-	    continue;
-#else
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
+# else
+#  if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
 	if (!hasmntopt(mntent, MNTOPT_RW))
 	    continue;
-#else
+#  else
 	if (strcmp(fsent->fs_type, "rw") != 0)
 	    continue;		/* Ignore non read/write partitions */
-#endif /* AFS_LINUX22_ENV */
-#endif /* AFS_SGI_ENV */
-#endif
+#  endif /* AFS_SGI_ENV */
+# endif
 #endif
 	/* Only keep track of "/vicepx" partitions since it can get hairy when NFS mounts are involved.. */
 	if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
@@ -167,7 +147,7 @@ vol_DevName(dev_t adev, char *wpath)
 	if (stat(part, &status) == -1) {
 	    continue;
 	}
-#if !defined(AFS_SGI_XFS_IOPS_ENV) && !defined(AFS_LINUX22_ENV) && !defined(AFS_DARWIN_ENV)
+#if !defined(AFS_SGI_XFS_IOPS_ENV)
 	if ((status.st_ino !=
 	     ROOTINO) /*|| ((status.st_mode & S_IFMT) != S_IFBLK) */ ) {
 	    continue;
@@ -177,15 +157,15 @@ vol_DevName(dev_t adev, char *wpath)
 #ifdef	AFS_AIX_ENV
 	    strcpy(pbuffer, vmt2dataptr(vmountp, VMT_OBJECT));
 #else
-#ifdef	AFS_SUN5_ENV
+# ifdef	AFS_SUN5_ENV
 	    strcpy(pbuffer, mnt.mnt_special);
-#else
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
+# else
+#  if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
 	    strcpy(pbuffer, mntent->mnt_fsname);
-#else
+#  else
 	    strcpy(pbuffer, fsent->fs_spec);
-#endif
-#endif /* AFS_SGI_ENV */
+#  endif
+# endif /* AFS_SGI_ENV */
 #endif
 	    if (wpath) {
 		strcpy(pbuf, pbuffer);
@@ -207,13 +187,13 @@ vol_DevName(dev_t adev, char *wpath)
 #ifdef	AFS_SUN5_ENV
     (void)fclose(mntfile);
 #else
-#if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_LINUX22_ENV)
+# if defined(AFS_SGI_ENV) || defined(AFS_SUN_ENV) || defined(AFS_HPUX_ENV)
     endmntent(mfd);
-#else
-#ifndef	AFS_AIX_ENV
+# else
+#  ifndef	AFS_AIX_ENV
     endfsent();
-#endif
-#endif
+#  endif
+# endif
 #endif /* AFS_SGI_ENV */
     return NULL;
 }
@@ -247,3 +227,5 @@ afs_rawname(char *devfile)
 
     return NULL;
 }
+
+#endif /* AFS_NAMEI_ENV */
diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c
index cd15e2d7c..720e6ef1c 100644
--- a/src/vol/fssync-server.c
+++ b/src/vol/fssync-server.c
@@ -79,9 +79,6 @@
 #endif /* USE_UNIX_SOCKETS */
 
 #ifdef FSSYNC_BUILD_SERVER
-
-int (*V_BreakVolumeCallbacks) (VolumeId volume);
-
 #define MAXHANDLERS	4	/* Up to 4 clients; must be at least 2, so that
 				 * move = dump+restore can run on single server */
 #define MAXOFFLINEVOLUMES 128	/* This needs to be as big as the maximum
@@ -261,7 +258,7 @@ FSYNC_sync(void * args)
     /* set our 'thread-id' so that the host hold table works */
     tid = rx_SetThreadNum();
     Log("Set thread id %d for FSYNC_sync\n", tid);
-    afs_pthread_setname_self("FSYNC_sync");
+    opr_threadname_set("FSYNC_sync");
 #endif /* AFS_PTHREAD_ENV */
 
     VOL_LOCK;
@@ -331,7 +328,7 @@ FSYNC_sync(void * args)
 	    CallHandler(&FSYNC_readfds);
 #endif
     }
-    return NULL; /* hush now, little gcc */
+    AFS_UNREACHED(return(NULL)); /* hush now, little gcc */
 }
 
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -376,9 +373,8 @@ FSYNC_salvageThread(void * args)
 	VCancelReservation_r(vp);
     }
 
-    VOL_UNLOCK;
-
-    return NULL;
+    AFS_UNREACHED(VOL_UNLOCK);
+    AFS_UNREACHED(return(NULL));
 }
 
 /**
@@ -958,6 +954,7 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res)
 
 		VOL_CV_WAIT(&V_attachCV(vp));
 	    }
+	    break;
 
 	case debugUtility:
 	    break;
@@ -1000,7 +997,7 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res)
 	     * attaching the volume would be safe */
 	    VRegisterVolOp_r(vp, &info);
 	    vp->pending_vol_op->vol_op_state = FSSYNC_VolOpRunningUnknown;
-	    /* fall through */
+	    goto done;
 
 	case VOL_STATE_DELETED:
 	    goto done;
@@ -1030,7 +1027,7 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res)
                  * attaching the volume would be safe */
                 VRegisterVolOp_r(vp, &info);
                 vp->pending_vol_op->vol_op_state = FSSYNC_VolOpRunningUnknown;
-		/* fall through */
+		goto done;
 
             case VOL_STATE_DELETED:
                 goto done;
@@ -2128,7 +2125,7 @@ FindHandler(osi_socket afd)
 	}
     ReleaseReadLock(&FSYNC_handler_lock);	/* just in case */
     opr_abort();
-    return -1;			/* satisfy compiler */
+    AFS_UNREACHED(return(-1));			/* satisfy compiler */
 }
 
 static int
@@ -2140,7 +2137,7 @@ FindHandler_r(osi_socket afd)
 	    return i;
 	}
     opr_abort();
-    return -1;			/* satisfy compiler */
+    AFS_UNREACHED(return(-1));			/* satisfy compiler */
 }
 
 static int
diff --git a/src/vol/ihandle.c b/src/vol/ihandle.c
index 3144b702f..c32ae758c 100644
--- a/src/vol/ihandle.c
+++ b/src/vol/ihandle.c
@@ -433,7 +433,7 @@ ih_open(IHandle_t * ihP)
 	     * cannot reuse it; it will be closed soon. */
 	    continue;
 	}
-#ifndef HAVE_PIO
+#ifndef AFS_IHANDLE_PIO_ENV
 	/*
 	 * If we don't have positional i/o, don't try to share fds, since
 	 * we can't do so in a threadsafe way.
@@ -442,9 +442,9 @@ ih_open(IHandle_t * ihP)
 	    continue;
 	}
 	opr_Assert(fdP->fd_status == FD_HANDLE_OPEN);
-#else /* HAVE_PIO */
+#else /* AFS_IHANDLE_PIO_ENV */
 	opr_Assert(fdP->fd_status != FD_HANDLE_AVAIL);
-#endif /* HAVE_PIO */
+#endif /* AFS_IHANDLE_PIO_ENV */
 
 	fdP->fd_refcnt++;
 	if (fdP->fd_status == FD_HANDLE_OPEN) {
@@ -1092,7 +1092,7 @@ ih_size(FD_t fd)
 #endif
 }
 
-#ifndef HAVE_PIO
+#ifndef AFS_IHANDLE_PIO_ENV
 ssize_t
 ih_pread(int fd, void * buf, size_t count, afs_foff_t offset)
 {
@@ -1112,7 +1112,7 @@ ih_pwrite(int fd, const void * buf, size_t count, afs_foff_t offset)
 	    return code;
 	return OS_WRITE(fd, buf, count);
 }
-#endif /* !HAVE_PIO */
+#endif /* !AFS_IHANDLE_PIO_ENV */
 
 #ifndef AFS_NT40_ENV
 int
diff --git a/src/vol/ihandle.h b/src/vol/ihandle.h
index a37898e4e..0bc0203d5 100644
--- a/src/vol/ihandle.h
+++ b/src/vol/ihandle.h
@@ -391,24 +391,24 @@ extern FdHandle_t *ih_attachfd(IHandle_t * ihP, FD_t fd);
 #define IH_CONDSYNC(H) ih_condsync(H)
 
 #ifdef HAVE_PIO
-# ifdef AFS_NT40_ENV
-#  define OS_PREAD(FD, B, S, O) nt_pread(FD, B, S, O)
-#  define OS_PWRITE(FD, B, S, O) nt_pwrite(FD, B, S, O)
-# else
-#  ifdef O_LARGEFILE
-#   define OS_PREAD(FD, B, S, O) pread64(FD, B, S, O)
-#   define OS_PWRITE(FD, B, S, O) pwrite64(FD, B, S, O)
-#  else /* !O_LARGEFILE */
-#   define OS_PREAD(FD, B, S, O) pread(FD, B, S, O)
-#   define OS_PWRITE(FD, B, S, O) pwrite(FD, B, S, O)
-#  endif /* !O_LARGEFILE */
-# endif /* AFS_NT40_ENV */
-#else /* !HAVE_PIO */
+# define AFS_IHANDLE_PIO_ENV 1
+# ifdef O_LARGEFILE
+#  define OS_PREAD(FD, B, S, O) pread64(FD, B, S, O)
+#  define OS_PWRITE(FD, B, S, O) pwrite64(FD, B, S, O)
+# else /* !O_LARGEFILE */
+#  define OS_PREAD(FD, B, S, O) pread(FD, B, S, O)
+#  define OS_PWRITE(FD, B, S, O) pwrite(FD, B, S, O)
+# endif /* !O_LARGEFILE */
+#elif defined(AFS_NT40_ENV)
+# define AFS_IHANDLE_PIO_ENV 1
+# define OS_PREAD(FD, B, S, O) nt_pread(FD, B, S, O)
+# define OS_PWRITE(FD, B, S, O) nt_pwrite(FD, B, S, O)
+#else
 extern ssize_t ih_pread(FD_t fd, void * buf, size_t count, afs_foff_t offset);
 extern ssize_t ih_pwrite(FD_t fd, const void * buf, size_t count, afs_foff_t offset);
 # define OS_PREAD(FD, B, S, O) ih_pread(FD, B, S, O)
 # define OS_PWRITE(FD, B, S, O) ih_pwrite(FD, B, S, O)
-#endif /* !HAVE_PIO */
+#endif
 
 #ifdef AFS_NT40_ENV
 # define OS_LOCKFILE(FD, O) (!LockFile(FD, (DWORD)((O) & 0xFFFFFFFF), (DWORD)((O) >> 32), 2, 0))
diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c
index 9deb66b4d..75bf9362c 100644
--- a/src/vol/listinodes.c
+++ b/src/vol/listinodes.c
@@ -44,9 +44,6 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 }
 #else
 #if !defined(AFS_SGI_ENV)
-#ifdef	AFS_OSF_ENV
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #ifdef	  AFS_SUN5_ENV
@@ -67,7 +64,6 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 #include <sys/fs.h>
 #endif
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #include <sys/vnode.h>
 #ifdef	  AFS_SUN5_ENV
@@ -78,11 +74,7 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 #endif
 #endif
 #else /* AFS_VFSINCL_ENV */
-#ifdef	AFS_OSF_ENV
-#include <ufs/inode.h>
-#else /* AFS_OSF_ENV */
 #include <sys/inode.h>
-#endif
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_SGI_ENV */
 #include <afs/osi_inode.h>
@@ -1001,7 +993,7 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 #else
     if ((super.fs.fs_magic != FS_MAGIC)
 	|| (super.fs.fs_ncg < 1)
-#if	defined(AFS_SUN_ENV) || defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if	defined(AFS_SUN_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 	|| (super.fs.fs_cpg < 1)
 #else
 	|| (super.fs.fs_cpg < 1 || super.fs.fs_cpg > MAXCPG)
@@ -1050,10 +1042,6 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 #endif /* AFS_SUN5_ENV */
 	i = c * super.fs.fs_ipg;
 	e = i + super.fs.fs_ipg;
-#ifdef	AFS_OSF_ENV
-	dblk1 = fsbtodb(&super.fs, itod(&super.fs, i));
-	if (OS_SEEK(pfd, (off_t) ((off_t) dblk1 * DEV_BSIZE), L_SET) == -1) {
-#else
 #if defined(AFS_SUN5_ENV) || defined(AFS_DARWIN_ENV)
 	f1 = fsbtodb(&super.fs, itod(&super.fs, i));
 	off = (offset_t) f1 << DEV_BSHIFT;
@@ -1062,7 +1050,6 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 	if (OS_SEEK(pfd, dbtob(fsbtodb(&super.fs, itod(&super.fs, i))), L_SET)
 	    == -1) {
 #endif /* AFS_SUN5_ENV */
-#endif /* AFS_OSF_ENV */
 #endif /* AFS_HPUX_ENV */
 	    Log("Error reading inodes for partition %s; run vfsck\n",
 		partition);
@@ -1098,27 +1085,6 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 		}
 	    }
 	    for (p = inodes; p < einodes && i < e; i++, p++) {
-#ifdef notdef
-		Log("Ino=%d, v1=%x, v2=%x, v3=%x, mode=%x size=%d, lcnt=%d\n",
-		    i, p->di_vicep1, p->di_vicep2, p->di_vicep3, p->di_mode,
-		    p->di_size, p->di_nlink);
-		printf
-		    ("Ino=%d, v1=%x, v2=%x, v3=%x, mode=%x size=%d, lcnt=%d\n",
-		     i, p->di_vicep1, p->di_vicep2, p->di_vicep3, p->di_mode,
-		     p->di_size, p->di_nlink);
-#endif
-#ifdef AFS_OSF_ENV
-#ifdef AFS_3DISPARES
-		/* Check to see if this inode is a pre-"OSF1 4.0D" inode */
-		if ((p->di_uid || p->di_gid)
-		    && !(p->di_flags & (IC_XUID | IC_XGID))) {
-		    Log("Found unconverted inode %d: Use 'fs_conv_dux40D convert' on partition %s\n", i, partition);
-		    goto out;
-		}
-#else
-		osi_Panic("Tru64 needs AFS_3DISPARES\n");
-#endif
-#endif
 #if	defined(AFS_SUN5_ENV)
 		/* if this is a pre-sol2.6 unconverted inode, bail out */
 		{
diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c
index aee57a3c3..7704fcd74 100644
--- a/src/vol/namei_ops.c
+++ b/src/vol/namei_ops.c
@@ -2605,8 +2605,14 @@ namei_ListAFSSubDirs(IHandle_t * dirIH,
 
 #ifndef AFS_NT40_ENV /* This level missing on Windows */
 	    /* Now we've got a next level subdir. */
-	    snprintf(path2, sizeof(path2), "%s" OS_DIRSEP "%s",
-		     path1, dp1->d_name);
+	    code = snprintf(path2, sizeof(path2), "%s" OS_DIRSEP "%s",
+			    path1, dp1->d_name);
+	    if (code < 0 || code >= sizeof(path2)) {
+		/* error, or truncated */
+		closedir(dirp1);
+		ret = -1;
+		goto error;
+	    }
 	    dirp2 = opendir(path2);
 	    if (dirp2) {
 		while ((dp2 = readdir(dirp2))) {
@@ -2614,13 +2620,22 @@ namei_ListAFSSubDirs(IHandle_t * dirIH,
 			continue;
 
 		    /* Now we've got to the actual data */
-		    snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s",
-			     path2, dp2->d_name);
+		    code = snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s",
+				    path2, dp2->d_name);
 #else
 		    /* Now we've got to the actual data */
-		    snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s",
-			     path1, dp1->d_name);
+		    code = snprintf(path3, sizeof(path3), "%s" OS_DIRSEP "%s",
+				    path1, dp1->d_name);
 #endif
+		    if (code < 0 || code >= sizeof(path3)) {
+			/* error, or truncated */
+#ifndef AFS_NT40_ENV
+			closedir(dirp2);
+#endif
+			closedir(dirp1);
+			ret = -1;
+			goto error;
+		    }
 		    dirp3 = opendir(path3);
 		    if (dirp3) {
 			while ((dp3 = readdir(dirp3))) {
@@ -3128,8 +3143,13 @@ namei_ConvertROtoRWvolume(char *pname, VolumeId volumeId)
     t_ih.ih_dev = ih->ih_dev;
     t_ih.ih_vid = ih->ih_vid;
 
-    snprintf(oldpath, sizeof oldpath, "%s" OS_DIRSEP "%s", dir_name,
-	     infoName);
+    code = snprintf(oldpath, sizeof oldpath, "%s" OS_DIRSEP "%s", dir_name,
+		    infoName);
+    if (code < 0 || code >= sizeof(oldpath)) {
+	/* error, or truncated */
+	code = -1;
+	goto done;
+    }
     fd = OS_OPEN(oldpath, O_RDWR, 0);
     if (fd == INVALID_FD) {
 	Log("1 namei_ConvertROtoRWvolume: could not open RO info file: %s\n",
@@ -3159,8 +3179,13 @@ namei_ConvertROtoRWvolume(char *pname, VolumeId volumeId)
 
     t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_SMALLINDEX);
     namei_HandleToName(&n, &t_ih);
-    snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
-	     smallName);
+    code = snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
+		    smallName);
+    if (code < 0 || code >= sizeof(newpath)) {
+	/* error, or truncated */
+	code = -1;
+	goto done;
+    }
     fd = OS_OPEN(newpath, O_RDWR, 0);
     if (fd == INVALID_FD) {
 	Log("1 namei_ConvertROtoRWvolume: could not open SmallIndex file: %s\n", newpath);
@@ -3182,8 +3207,13 @@ namei_ConvertROtoRWvolume(char *pname, VolumeId volumeId)
 
     t_ih.ih_ino = namei_MakeSpecIno(ih->ih_vid, VI_LARGEINDEX);
     namei_HandleToName(&n, &t_ih);
-    snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
-	     largeName);
+    code = snprintf(newpath, sizeof newpath, "%s" OS_DIRSEP "%s", dir_name,
+		    largeName);
+    if (code < 0 || code >= sizeof(newpath)) {
+	/* error, or truncated */
+	code = -1;
+	goto done;
+    }
     fd = OS_OPEN(newpath, O_RDWR, 0);
     if (fd == INVALID_FD) {
 	Log("1 namei_ConvertROtoRWvolume: could not open LargeIndex file: %s\n", newpath);
@@ -3226,6 +3256,7 @@ namei_ConvertROtoRWvolume(char *pname, VolumeId volumeId)
     FSYNC_VolOp(volumeId, pname, FSYNC_VOL_DONE, 0, NULL);
     FSYNC_VolOp(h.id, pname, FSYNC_VOL_ON, 0, NULL);
 
+    code = 0;
  done:
 # ifdef AFS_DEMAND_ATTACH_FS
     if (locktype) {
@@ -3337,4 +3368,37 @@ FreeZLCList(void)
 }
 #endif
 
+/**
+ * Remove empty directories associated with the volume received
+ * as an argument.
+ *
+ * @param[in] pname    vice partition path
+ * @param[in] vid      volume id
+ *
+ * @return 0 on success
+ */
+int
+namei_RemoveDirectories(char *pname, afs_int32 vid)
+{
+    IHandle_t dirIH;
+    namei_t name;
+
+    memset(&dirIH, 0, sizeof(dirIH));
+
+    dirIH.ih_vid = vid;
+
+#ifdef AFS_NT40_ENV
+    dirIH.ih_dev = nt_DriveToDev(pname);
+#else
+    dirIH.ih_dev = volutil_GetPartitionID(pname);
+#endif
+    if (dirIH.ih_dev == -1) {
+	return -1;
+    }
+
+    namei_HandleToVolDir(&name, &dirIH);
+
+    return namei_RemoveDataDirectories(&name);
+}
+
 #endif /* AFS_NAMEI_ENV */
diff --git a/src/vol/namei_ops.h b/src/vol/namei_ops.h
index cacb42fd6..f3de43299 100644
--- a/src/vol/namei_ops.h
+++ b/src/vol/namei_ops.h
@@ -88,6 +88,8 @@ int namei_replace_file_by_hardlink(IHandle_t *hLink, IHandle_t *hTarget);
 extern void namei_SetWorkQueue(struct afs_work_queue *wq);
 # endif
 
+int namei_RemoveDirectories(char *pname, afs_int32 vid);
+
 #endif /* AFS_NAMEI_ENV */
 
 #endif /* _AFS_NAMEI_OPS_H_H_ */
diff --git a/src/vol/nuke.c b/src/vol/nuke.c
index 3d520ff63..6b35db826 100644
--- a/src/vol/nuke.c
+++ b/src/vol/nuke.c
@@ -205,6 +205,13 @@ nuke(char *aname, VolumeId avolid)
 
 	allInodes = NULL;
 
+#ifdef AFS_NAMEI_ENV
+	if (namei_RemoveDirectories(aname, avolid)) {
+	    Log("Nuke: Could not remove some empty directories associated with "
+		"volume %u\n", avolid);
+	}
+#endif
+
 	/* at this point, we should try to remove the volume header file itself.
 	 * the volume header file is the file named VNNNNN.vol in the UFS file
 	 * system, and is a normal file.  As such, it is not stamped with the
diff --git a/src/vol/partition.c b/src/vol/partition.c
index 272ada35d..628de3394 100644
--- a/src/vol/partition.c
+++ b/src/vol/partition.c
@@ -39,10 +39,6 @@
 #endif
 
 #if !defined(AFS_SGI_ENV)
-#ifdef	AFS_OSF_ENV
-#include <sys/mount.h>
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #ifdef	AFS_SUN5_ENV
@@ -60,7 +56,6 @@
 #include <sys/fs.h>
 #endif
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #include <sys/file.h>
 #ifdef	AFS_AIX_ENV
 #include <sys/vfs.h>
@@ -289,6 +284,10 @@ VCheckPartition(char *part, char *devname, int logging)
     if (strncmp(part, VICE_PARTITION_PREFIX, VICE_PREFIX_SIZE)) {
 	return 0;
     }
+    if (volutil_GetPartitionID(part) == -1) {
+	Log("Warning: %s is a bad partition name; ignored.\n", part);
+	return 0;
+    }
     if (afs_stat(part, &status) < 0) {
 	Log("VInitVnodes: Couldn't find file system %s; ignored\n", part);
 	return 0;
@@ -346,13 +345,6 @@ VCheckPartition(char *part, char *devname, int logging)
 #endif /* AFS_NAMEI_ENV */
 #endif /* !AFS_LINUX20_ENV && !AFS_NT40_ENV */
 
-#if defined(AFS_DUX40_ENV) && !defined(AFS_NAMEI_ENV)
-    if (status.st_ino != ROOTINO) {
-	Log("%s is not a mounted file system; ignored.\n", part);
-	return 0;
-    }
-#endif
-
     VInitPartition(part, devname, status.st_dev);
 
     return 0;
@@ -671,7 +663,7 @@ VAttachPartitions(void)
     return errors;
 }
 #endif
-#if defined(AFS_DUX40_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
+#if defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 int
 VAttachPartitions(void)
 {
@@ -1457,12 +1449,4 @@ AddPartitionToTable_r(struct DiskPartition64 *dp)
     DiskPartitionTable[dp->index] = dp;
 }
 
-#if 0
-static void
-DeletePartitionFromTable_r(struct DiskPartition64 *dp)
-{
-    opr_Assert(dp->index >= 0 && dp->index <= VOLMAXPARTS);
-    DiskPartitionTable[dp->index] = NULL;
-}
-#endif
 #endif /* AFS_DEMAND_ATTACH_FS */
diff --git a/src/vol/purge.c b/src/vol/purge.c
index 77fe59ed4..16157b0de 100644
--- a/src/vol/purge.c
+++ b/src/vol/purge.c
@@ -46,10 +46,6 @@
 /* forward declarations */
 static int ObliterateRegion(Volume * avp, VnodeClass aclass, StreamHandle_t * afile,
 			    afs_foff_t * aoffset);
-#if 0
-static void PurgeIndex(Volume * vp, VnodeClass class);
-static void PurgeHeader(Volume * vp);
-#endif
 
 static void PurgeIndex_r(Volume * vp, VnodeClass class);
 static void PurgeHeader_r(Volume * vp);
@@ -164,16 +160,6 @@ ObliterateRegion(Volume * avp, VnodeClass aclass, StreamHandle_t * afile,
     return -1;
 }
 
-#if 0
-static void
-PurgeIndex(Volume * vp, VnodeClass class)
-{
-    VOL_LOCK;
-    PurgeIndex_r(vp, class);
-    VOL_UNLOCK;
-}
-#endif
-
 static void
 PurgeIndex_r(Volume * vp, VnodeClass class)
 {
@@ -204,16 +190,6 @@ PurgeIndex_r(Volume * vp, VnodeClass class)
     FDH_CLOSE(fdP);
 }
 
-#if 0
-static void
-PurgeHeader(Volume * vp)
-{
-    VOL_LOCK;
-    PurgeHeader_r(vp);
-    VOL_UNLOCK;
-}
-#endif
-
 static void
 PurgeHeader_r(Volume * vp)
 {
diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c
index 23239d731..1e522c931 100644
--- a/src/vol/salvaged.c
+++ b/src/vol/salvaged.c
@@ -51,13 +51,9 @@
 #endif
 #endif
 #else /* AFS_VFSINCL_ENV */
-#ifdef	AFS_OSF_ENV
-#include <ufs/inode.h>
-#else /* AFS_OSF_ENV */
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_DARWIN_ENV)
 #include <sys/inode.h>
 #endif
-#endif
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_SGI_ENV */
 #ifdef	AFS_AIX_ENV
@@ -215,11 +211,13 @@ handleit(struct cmd_syndesc *opts, void *arock)
     cmd_OptionAsFlag(opts, OPT_salvagedirs, &RebuildDirs);
     cmd_OptionAsFlag(opts, OPT_blockreads, &forceR);
     if (cmd_OptionAsString(opts, OPT_parallel, &optstring) == 0) {
+	char *input = optstring;
 	if (strncmp(optstring, "all", 3) == 0) {
 	    PartsPerDisk = 1;
+	    input += 3;
 	}
-	if (strlen(optstring) != 0) {
-	    Parallel = atoi(optstring);
+	if (strlen(input) != 0) {
+	    Parallel = atoi(input);
 	    if (Parallel < 1)
 		Parallel = 1;
 	    if (Parallel > MAXPARALLEL) {
@@ -438,7 +436,7 @@ main(int argc, char **argv)
 
     err = cmd_Dispatch(argc, argv);
     Exit(err);
-    return 0; /* not reached */
+    AFS_UNREACHED(return 0);
 }
 
 static void
@@ -480,6 +478,7 @@ SalvageClient(VolumeId vid, char * pname)
 	switch (sres.state) {
 	case SALVSYNC_STATE_ERROR:
 	    printf("salvageserver reports salvage ended in an error; check log files for more details\n");
+	    AFS_FALLTHROUGH;
 	case SALVSYNC_STATE_DONE:
 	case SALVSYNC_STATE_UNKNOWN:
 	    done = 1;
@@ -708,7 +707,7 @@ SalvageChildReaperThread(void * args)
 	opr_cv_broadcast(&worker_cv);
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static int
@@ -757,8 +756,8 @@ SalvageLogCleanupThread(void * arg)
 	}
     }
 
-    opr_mutex_exit(&worker_lock);
-    return NULL;
+    AFS_UNREACHED(opr_mutex_exit(&worker_lock));
+    AFS_UNREACHED(return(NULL));
 }
 
 #define LOG_XFER_BUF_SIZE 65536
diff --git a/src/vol/salvager.c b/src/vol/salvager.c
index 297ea3dc7..b61abf19f 100644
--- a/src/vol/salvager.c
+++ b/src/vol/salvager.c
@@ -51,13 +51,9 @@
 #endif
 #endif
 #else /* AFS_VFSINCL_ENV */
-#ifdef	AFS_OSF_ENV
-#include <ufs/inode.h>
-#else /* AFS_OSF_ENV */
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_DARWIN_ENV)
 #include <sys/inode.h>
 #endif
-#endif
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_SGI_ENV */
 #ifdef	AFS_AIX_ENV
@@ -546,6 +542,6 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-f", CMD_FLAG, CMD_OPTIONAL, "Alias for -force");
     err = cmd_Dispatch(argc, argv);
     Exit(err);
-    return 0; /* not reached */
+    AFS_UNREACHED(return 0);
 }
 
diff --git a/src/vol/salvsync-server.c b/src/vol/salvsync-server.c
index b399d8164..fbbc70ba1 100644
--- a/src/vol/salvsync-server.c
+++ b/src/vol/salvsync-server.c
@@ -232,21 +232,6 @@ AddNodeToHash(struct SalvageQueueNode * node)
     SalvageHashTable[idx].len++;
 }
 
-#if 0
-static void
-DeleteNodeFromHash(struct SalvageQueueNode * node)
-{
-    int idx = VSHASH(node->command.sop.volume);
-
-    if (queue_IsNotOnQueue(&node->hash_chain)) {
-	return;
-    }
-
-    queue_Remove(&node->hash_chain);
-    SalvageHashTable[idx].len--;
-}
-#endif
-
 void
 SALVSYNC_salvInit(void)
 {
@@ -336,7 +321,7 @@ SALVSYNC_syncThread(void * args)
 	    CallHandler(&SALVSYNC_readfds);
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 static void
@@ -832,7 +817,7 @@ FindHandler(osi_socket afd)
 	}
     ReleaseReadLock(&SALVSYNC_handler_lock);	/* just in case */
     osi_Panic("Failed to find handler\n");
-    return -1;			/* satisfy compiler */
+    AFS_UNREACHED(return -1);
 }
 
 static int
@@ -844,7 +829,7 @@ FindHandler_r(osi_socket afd)
 	    return i;
 	}
     osi_Panic("Failed to find handler\n");
-    return -1;			/* satisfy compiler */
+    AFS_UNREACHED(return -1);
 }
 
 static int
@@ -955,7 +940,7 @@ LinkNode(struct SalvageQueueNode * parent,
     switch (clone->state) {
     case SALVSYNC_STATE_QUEUED:
 	DeleteFromSalvageQueue(clone);
-
+	AFS_FALLTHROUGH;
     case SALVSYNC_STATE_SALVAGING:
 	switch (parent->state) {
 	case SALVSYNC_STATE_UNKNOWN:
@@ -1085,25 +1070,6 @@ DeleteFromPendingQueue(struct SalvageQueueNode * node)
     }
 }
 
-#if 0
-static struct SalvageQueueNode *
-LookupPendingCommand(SALVSYNC_command_hdr * qry)
-{
-    struct SalvageQueueNode * np, * nnp;
-
-    for (queue_Scan(&pendingQueue, np, nnp, SalvageQueueNode)) {
-	if ((np->command.sop.volume == qry->volume) &&
-	    !strncmp(np->command.sop.partName, qry->partName,
-		     sizeof(qry->partName)))
-	    break;
-    }
-
-    if (queue_IsEnd(&pendingQueue, np))
-	np = NULL;
-    return np;
-}
-#endif
-
 static struct SalvageQueueNode *
 LookupPendingCommandByPid(int pid)
 {
diff --git a/src/vol/test/listVicepx.c b/src/vol/test/listVicepx.c
index b715c5fbd..c4f535f41 100644
--- a/src/vol/test/listVicepx.c
+++ b/src/vol/test/listVicepx.c
@@ -23,9 +23,6 @@
 #include <ctype.h>
 #include <sys/param.h>
 #if !defined(AFS_SGI_ENV)
-#ifdef	AFS_OSF_ENV
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #ifdef	AFS_SUN5_ENV
@@ -38,7 +35,6 @@
 #include <sys/fs.h>
 #endif
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #endif /* AFS_SGI_ENV */
 #include <sys/errno.h>
 #include <sys/stat.h>
@@ -105,9 +101,6 @@
 #include <afs/dir.h>
 #include <unistd.h>
 
-#ifdef	AFS_OSF_ENV
-extern void *calloc(), *realloc();
-#endif
 #include "salvage.h"
 int volumeId;
 int VolumeChanged;		/* to satisfy library libdir use */
diff --git a/src/vol/test/updateDirInode.c b/src/vol/test/updateDirInode.c
index 0853c1f5b..3e216ed08 100644
--- a/src/vol/test/updateDirInode.c
+++ b/src/vol/test/updateDirInode.c
@@ -23,9 +23,6 @@
 #include <ctype.h>
 #include <sys/param.h>
 #if !defined(AFS_SGI_ENV)
-#ifdef	AFS_OSF_ENV
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #ifdef	AFS_SUN5_ENV
@@ -38,7 +35,6 @@
 #include <sys/fs.h>
 #endif
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #endif /* AFS_SGI_ENV */
 #include <sys/errno.h>
 #include <sys/stat.h>
@@ -106,9 +102,6 @@
 #include <afs/dir.h>
 #include <unistd.h>
 
-#ifdef	AFS_OSF_ENV
-extern void *calloc(), *realloc();
-#endif
 #include "salvage.h"
 int volumeId;
 int VolumeChanged;		/* to satisfy library libdir use */
diff --git a/src/vol/vg_cache.c b/src/vol/vg_cache.c
index 307b358b2..5e8ca75fa 100644
--- a/src/vol/vg_cache.c
+++ b/src/vol/vg_cache.c
@@ -508,7 +508,7 @@ _VVGC_hash_entry_add(struct DiskPartition64 * dp,
 	if (ent != nent) {
 	    ViceLog(0, ("_VVGC_hash_entry_add: tried to add a duplicate "
 	                " nonmatching entry for vol %lu: original "
-	                "(%"AFS_PTR_FMT",%lu) new (%"AFS_PTR_FMT",%lu)\n",
+			"(%p,%lu) new (%p,%lu)\n",
 	                afs_printable_uint32_lu(volid),
 	                nent, afs_printable_uint32_lu(nent->rw),
 	                ent, afs_printable_uint32_lu(ent->rw)));
@@ -869,32 +869,37 @@ _VVGC_entry_purge_r(struct DiskPartition64 * dp,
                     VolumeId parent, VolumeId child)
 {
     int code = 0, res;
-    VVGCache_entry_t * parent_ent, * child_ent;
+    VVGCache_entry_t * child_ent;
     VVGCache_hash_entry_t * child_hent;
 
-    /* check mappings for each volid */
-    res = _VVGC_lookup(dp, parent, &parent_ent, NULL);
-    if (res) {
-	code = res;
-	goto done;
-    }
     res = _VVGC_lookup(dp, child, &child_ent, &child_hent);
     if (res) {
 	code = res;
 	goto done;
     }
 
-    /* if the mappings don't match, we have a serious error */
-    if (parent_ent != child_ent) {
-	ViceLog(0, ("VVGCache_entry_del: trying to delete vol %lu from VG %lu, "
-	    "but vol %lu points to VGC entry %"AFS_PTR_FMT" and VG %lu "
-	    "points to VGC entry %"AFS_PTR_FMT"\n",
-	    afs_printable_uint32_lu(child),
-	    afs_printable_uint32_lu(parent),
-	    afs_printable_uint32_lu(child),
-	    child_ent, afs_printable_uint32_lu(parent), parent_ent));
-	code = -1;
-	goto done;
+    if (parent != 0) {
+	VVGCache_entry_t * parent_ent;
+
+	res = _VVGC_lookup(dp, parent, &parent_ent, NULL);
+	if (res) {
+	    code = res;
+	    goto done;
+	}
+
+	/* if the mappings don't match, we have a serious error */
+	if (parent_ent != child_ent) {
+	    ViceLog(0,
+		    ("VVGCache_entry_del: trying to delete vol %lu from VG %lu, "
+		     "but vol %lu points to VGC entry %p"
+		     " and VG %lu " "points to VGC entry %p\n",
+		     afs_printable_uint32_lu(child),
+		     afs_printable_uint32_lu(parent),
+		     afs_printable_uint32_lu(child), child_ent,
+		     afs_printable_uint32_lu(parent), parent_ent));
+	    code = -1;
+	    goto done;
+	}
     }
 
     code = _VVGC_hash_entry_del(child_hent);
diff --git a/src/vol/vg_scan.c b/src/vol/vg_scan.c
index 509eadefc..5fb0c698c 100644
--- a/src/vol/vg_scan.c
+++ b/src/vol/vg_scan.c
@@ -452,8 +452,8 @@ _VVGC_dlist_lookup_r(struct DiskPartition64 *dp, VolumeId parent,
     for (queue_Scan(&VVGCache.part[dp->index].dlist_hash_buckets[bucket],
                     ent, nent,
 		    VVGCache_dlist_entry)) {
-
-	if (ent->child == child && ent->parent == parent) {
+	if (ent->child == child
+	    && (ent->parent == 0 || ent->parent == parent)) {
 	    return ent;
 	}
     }
@@ -501,7 +501,7 @@ _VVGC_flush_dlist(struct DiskPartition64 *dp)
  * back onto the VGC.
  *
  * @param[in] dp      the partition to whose dlist we are adding
- * @param[in] parent  the parent volumeID of the VGC entry
+ * @param[in] parent  the parent volumeID of the VGC entry, or 0 for any
  * @param[in] child   the child volumeID of the VGC entry
  *
  * @return operation status
@@ -525,7 +525,7 @@ _VVGC_dlist_add_r(struct DiskPartition64 *dp, VolumeId parent,
     }
 
     entry->child = child;
-    entry->parent = parent;
+    entry->parent = parent; /* May be zero to match any child. */
 
     queue_Append(&VVGCache.part[dp->index].dlist_hash_buckets[bucket],
                  entry);
diff --git a/src/vol/vnode.c b/src/vol/vnode.c
index 472e2e428..dd50c5f38 100644
--- a/src/vol/vnode.c
+++ b/src/vol/vnode.c
@@ -1376,7 +1376,7 @@ VPutVnode_r(Error * ec, Vnode * vnp)
 						changed_oldTime) << 1) | vnp->
 	      delete, 0, 0);
 	if (thisProcess != vnp->writer)
-	    Abort("VPutVnode: Vnode at %"AFS_PTR_FMT" locked by another process!\n",
+	    Abort("VPutVnode: Vnode at %p locked by another process!\n",
 		  vnp);
 
 
@@ -1434,7 +1434,7 @@ VPutVnode_r(Error * ec, Vnode * vnp)
 	if (vnp->changed_newTime || vnp->changed_oldTime || vnp->delete)
 	    Abort
 		("VPutVnode: Change or delete flag for vnode "
-		 "%"AFS_PTR_FMT" is set but vnode is not write locked!\n",
+		 "%p is set but vnode is not write locked!\n",
 		 vnp);
 #ifdef AFS_DEMAND_ATTACH_FS
 	VnEndRead_r(vnp);
@@ -1521,8 +1521,7 @@ VVnodeWriteToRead_r(Error * ec, Vnode * vnp)
     LWP_CurrentProcess(&thisProcess);
 #endif /* AFS_PTHREAD_ENV */
     if (thisProcess != vnp->writer)
-	Abort("VPutVnode: Vnode at %"AFS_PTR_FMT
-	      " locked by another process!\n", vnp);
+	Abort("VPutVnode: Vnode at %p locked by another process!\n", vnp);
 
     if (vnp->delete) {
 	return 0;
diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c
index acde64b88..6643968cc 100644
--- a/src/vol/vol-salvage.c
+++ b/src/vol/vol-salvage.c
@@ -119,13 +119,9 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 #endif
 #endif
 #else /* AFS_VFSINCL_ENV */
-#ifdef	AFS_OSF_ENV
-#include <ufs/inode.h>
-#else /* AFS_OSF_ENV */
 #if !defined(AFS_LINUX20_ENV) && !defined(AFS_XBSD_ENV) && !defined(AFS_DARWIN_ENV)
 #include <sys/inode.h>
 #endif
-#endif
 #endif /* AFS_VFSINCL_ENV */
 #endif /* AFS_SGI_ENV */
 #ifdef	AFS_AIX_ENV
@@ -192,9 +188,6 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 
 #define SALV_BUFFER_SIZE 1024
 
-#ifdef	AFS_OSF_ENV
-extern void *calloc();
-#endif
 static char *TimeStamp(char *buffer, size_t size, time_t clock, int precision);
 
 
@@ -701,7 +694,7 @@ void
 SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
 {
     char *name, *tdir;
-    char inodeListPath[256];
+    char *inodeListPath = NULL;
     FD_t inodeFile = INVALID_FD;
     static char tmpDevName[100];
     static char wpath[100];
@@ -811,10 +804,16 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
     tdir = (tmpdir ? tmpdir : salvinfo->fileSysPath);
 #ifdef AFS_NT40_ENV
     (void)_putenv("TMP=");	/* If "TMP" is set, then that overrides tdir. */
-    (void)strncpy(inodeListPath, _tempnam(tdir, "salvage.inodes."), 255);
+    inodeListPath = strdup(_tempnam(tdir, "salvage.inodes."));
+    if (inodeListPath == NULL) {
+	Abort("Error allocating memory for inodeListPath\n");
+    }
 #else
-    snprintf(inodeListPath, 255, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name,
+    code = asprintf(&inodeListPath, "%s" OS_DIRSEP "salvage.inodes.%s.%d", tdir, name,
 	     getpid());
+    if (code == -1) {
+	Abort("Error allocating memory for inodeListPath\n");
+    }
 #endif
 
     inodeFile = OS_OPEN(inodeListPath, O_RDWR|O_TRUNC|O_CREAT, 0666);
@@ -843,11 +842,16 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
 
     if (GetInodeSummary(salvinfo, inodeFile, singleVolumeNumber) < 0) {
 	OS_CLOSE(inodeFile);
+	free(inodeListPath);
 	return;
     }
     salvinfo->inodeFd = inodeFile;
     if (salvinfo->inodeFd == INVALID_FD)
 	Abort("Temporary file %s is missing...\n", inodeListPath);
+
+    free(inodeListPath);
+    inodeListPath = NULL;
+
     OS_SEEK(salvinfo->inodeFd, 0L, SEEK_SET);
     if (ListInodeOption) {
 	PrintInodeList(salvinfo);
@@ -979,7 +983,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber)
 void
 DeleteExtraVolumeHeaderFile(struct SalvInfo *salvinfo, struct VolumeSummary *vsp)
 {
-    char path[64];
+    char path[VMAXPATHLEN + 10];
     char filename[VMAXPATHLEN];
 
     if (vsp->deleted) {
@@ -2436,7 +2440,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp,
     }
 
     if (isp->volSummary == NULL) {
-	char path[64];
+	char path[VMAXPATHLEN];
 	char headerName[64];
 	snprintf(headerName, sizeof headerName, VFORMAT,
 		 afs_printable_VolumeId_lu(isp->volumeId));
@@ -2454,7 +2458,7 @@ SalvageVolumeHeaderFile(struct SalvInfo *salvinfo, struct InodeSummary *isp,
 
 	writefunc = VCreateVolumeDiskHeader;
     } else {
-	char path[64];
+	char path[VMAXPATHLEN];
 	char headerName[64];
 	/* hack: these two fields are obsolete... */
 	isp->volSummary->header.volumeAcl = 0;
@@ -4374,7 +4378,7 @@ MaybeZapVolume(struct SalvInfo *salvinfo, struct InodeSummary *isp,
 	    }
 	    if (!Testing) {
 		afs_int32 code;
-		char path[64];
+		char path[VMAXPATHLEN + 10];
 		char filename[VMAXPATHLEN];
 		VolumeExternalName_r(isp->volumeId, filename, sizeof(filename));
 		sprintf(path, "%s" OS_DIRSEP "%s", salvinfo->fileSysPath, filename);
diff --git a/src/vol/voldefs.h b/src/vol/voldefs.h
index 57bebe633..813740450 100644
--- a/src/vol/voldefs.h
+++ b/src/vol/voldefs.h
@@ -69,7 +69,7 @@
 #define	VHDRNAMELEN (VFORMATDIGITS + 1 + sizeof(VHDREXT) - 1) /* must match VFORMAT */
 
 /* Maximum length (including trailing NUL) of a volume external path name. */
-#define VMAXPATHLEN 64
+#define VMAXPATHLEN 512
 
 #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
 
diff --git a/src/vol/volume.c b/src/vol/volume.c
index f1ff10a7b..f52a560a4 100644
--- a/src/vol/volume.c
+++ b/src/vol/volume.c
@@ -45,9 +45,6 @@
 
 #ifndef AFS_NT40_ENV
 #if !defined(AFS_SGI_ENV)
-#ifdef	AFS_OSF_ENV
-#include <ufs/fs.h>
-#else /* AFS_OSF_ENV */
 #ifdef AFS_VFSINCL_ENV
 #define VFS
 #ifdef	AFS_SUN5_ENV
@@ -65,7 +62,6 @@
 #include <sys/fs.h>
 #endif
 #endif /* AFS_VFSINCL_ENV */
-#endif /* AFS_OSF_ENV */
 #endif /* AFS_SGI_ENV */
 #endif /* !AFS_NT40_ENV */
 
@@ -124,9 +120,6 @@ pthread_cond_t vol_vinit_cond;
 int vol_attach_threads = 1;
 #endif /* AFS_PTHREAD_ENV */
 
-/* start-time configurable I/O parameters */
-ih_init_params vol_io_params;
-
 #ifdef AFS_DEMAND_ATTACH_FS
 pthread_mutex_t vol_salvsync_mutex;
 
@@ -142,10 +135,6 @@ static volatile sig_atomic_t vol_disallow_salvsync = 0;
  */
 static int vol_shutting_down = 0;
 
-#ifdef	AFS_OSF_ENV
-extern void *calloc(), *realloc();
-#endif
-
 /* Forward declarations */
 static Volume *attach2(Error * ec, VolumeId volumeId, char *path,
 		       struct DiskPartition64 *partp, Volume * vp,
@@ -163,9 +152,6 @@ static void ReleaseVolumeHeader(struct volHeader *hd);
 static void FreeVolumeHeader(Volume * vp);
 static void AddVolumeToHashTable(Volume * vp, VolumeId hashid);
 static void DeleteVolumeFromHashTable(Volume * vp);
-#if 0
-static int VHold(Volume * vp);
-#endif
 static int VHold_r(Volume * vp);
 static void VGetBitmap_r(Error * ec, Volume * vp, VnodeClass class);
 static void VReleaseVolumeHandles_r(Volume * vp);
@@ -470,14 +456,10 @@ bit32 VolumeCacheCheck;		/* Incremented everytime a volume goes on line--
 void
 VOptDefaults(ProgramType pt, VolumePackageOptions *opts)
 {
-    opts->nLargeVnodes = opts->nSmallVnodes = 5;
-    opts->volcache = 0;
+    memset(opts, 0, sizeof(*opts));
 
-    opts->canScheduleSalvage = 0;
-    opts->canUseFSSYNC = 0;
-    opts->canUseSALVSYNC = 0;
+    opts->nLargeVnodes = opts->nSmallVnodes = 5;
 
-    opts->interrupt_rxcall = NULL;
     opts->offline_timeout = -1;
     opts->offline_shutdown_timeout = -1;
     opts->usage_threshold = 128;
@@ -485,9 +467,7 @@ VOptDefaults(ProgramType pt, VolumePackageOptions *opts)
 
 #ifdef FAST_RESTART
     opts->unsafe_attach = 1;
-#else /* !FAST_RESTART */
-    opts->unsafe_attach = 0;
-#endif /* !FAST_RESTART */
+#endif
 
     switch (pt) {
     case fileServer:
@@ -1810,15 +1790,18 @@ ShutdownVolumeWalk_r(struct DiskPartition64 * dp, int pass,
 		(V_attachState(vp) != VOL_STATE_PREATTACHED)) {
 		break;
 	    }
+	    AFS_FALLTHROUGH;
 	case 1:
 	    if ((V_attachState(vp) == VOL_STATE_ATTACHED) &&
 		(vp->header == NULL)) {
 		break;
 	    }
+	    AFS_FALLTHROUGH;
 	case 2:
 	    if (VIsExclusiveState(V_attachState(vp))) {
 		break;
 	    }
+	    AFS_FALLTHROUGH;
 	case 3:
 	    *idx = nqp;
 	    DeleteVolumeFromVByPList_r(vp);
@@ -1862,6 +1845,7 @@ VShutdownVolume_r(Volume * vp)
     case VOL_STATE_PREATTACHED:
     case VOL_STATE_ERROR:
 	VChangeState_r(vp, VOL_STATE_UNATTACHED);
+	break;
     case VOL_STATE_UNATTACHED:
     case VOL_STATE_DELETED:
 	break;
@@ -3757,18 +3741,6 @@ VOfflineTimeout(struct timespec *ats)
 
 #endif /* !AFS_PTHREAD_ENV */
 
-#if 0
-static int
-VHold(Volume * vp)
-{
-    int retVal;
-    VOL_LOCK;
-    retVal = VHold_r(vp);
-    VOL_UNLOCK;
-    return retVal;
-}
-#endif
-
 static afs_int32
 VIsGoingOffline_r(struct Volume *vp)
 {
@@ -4024,15 +3996,6 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
           const struct timespec *timeout)
 {
     Volume *vp = hint;
-    /* pull this profiling/debugging code out of regular builds */
-#ifdef notdef
-#define VGET_CTR_INC(x) x++
-    unsigned short V0 = 0, V1 = 0, V2 = 0, V3 = 0, V5 = 0, V6 =
-	0, V7 = 0, V8 = 0, V9 = 0;
-    unsigned short V10 = 0, V11 = 0, V12 = 0, V13 = 0, V14 = 0, V15 = 0;
-#else
-#define VGET_CTR_INC(x)
-#endif
 #ifdef AFS_DEMAND_ATTACH_FS
     Volume *avp, * rvp = hint;
 #endif
@@ -4061,7 +4024,6 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
 	*ec = 0;
 	if (client_ec)
 	    *client_ec = 0;
-	VGET_CTR_INC(V0);
 
 	vp = VLookupVolume_r(ec, volumeId, vp);
 	if (*ec) {
@@ -4078,9 +4040,7 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
 #endif /* AFS_DEMAND_ATTACH_FS */
 
 	if (!vp) {
-	    VGET_CTR_INC(V1);
 	    if (VInit < 2) {
-		VGET_CTR_INC(V2);
 		/* Until we have reached an initialization level of 2
 		 * we don't know whether this volume exists or not.
 		 * We can't sleep and retry later because before a volume
@@ -4095,7 +4055,6 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
 	    break;
 	}
 
-	VGET_CTR_INC(V3);
 	IncUInt64(&VStats.hdr_gets);
 
 #ifdef AFS_DEMAND_ATTACH_FS
@@ -4231,7 +4190,6 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
 
 	LoadVolumeHeader(ec, vp);
 	if (*ec) {
-	    VGET_CTR_INC(V6);
 	    /* Only log the error if it was a totally unexpected error.  Simply
 	     * a missing inode is likely to be caused by the volume being deleted */
 	    if (errno != ENXIO || GetLogLevel() != 0)
@@ -4251,21 +4209,17 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
 	    break;
 	}
 
-	VGET_CTR_INC(V7);
 	if (vp->shuttingDown) {
-	    VGET_CTR_INC(V8);
 	    *ec = VNOVOL;
 	    vp = NULL;
 	    break;
 	}
 
 	if (programType == fileServer) {
-	    VGET_CTR_INC(V9);
 	    if (vp->goingOffline) {
 		if (timeout && VTimedOut(timeout)) {
 		    /* we've timed out; don't wait for the vol */
 		} else {
-		    VGET_CTR_INC(V10);
 #ifdef AFS_DEMAND_ATTACH_FS
 		    /* wait for the volume to go offline */
 		    if (V_attachState(vp) == VOL_STATE_GOING_OFFLINE) {
@@ -4283,21 +4237,15 @@ GetVolume(Error * ec, Error * client_ec, VolumeId volumeId, Volume * hint,
 		}
 	    }
 	    if (vp->specialStatus) {
-		VGET_CTR_INC(V11);
 		*ec = vp->specialStatus;
 	    } else if (V_inService(vp) == 0 || V_blessed(vp) == 0) {
-		VGET_CTR_INC(V12);
 		*ec = VNOVOL;
 	    } else if (V_inUse(vp) == 0 || vp->goingOffline) {
-		VGET_CTR_INC(V13);
 		*ec = VOFFLINE;
-	    } else {
-		VGET_CTR_INC(V14);
 	    }
 	}
 	break;
     }
-    VGET_CTR_INC(V15);
 
 #ifdef AFS_DEMAND_ATTACH_FS
     /* if no error, bump nUsers */
@@ -4776,16 +4724,6 @@ VDetachVolume_r(Error * ec, Volume * vp)
 	 * which the file server would attempt to put on line
 	 */
 	FSYNC_VolOp(volume, tpartp->name, useDone, 0, NULL);
-	/* XXX this code path is only hit by volume utilities, thus
-	 * V_BreakVolumeCallbacks will always be NULL.  if we really
-	 * want to break callbacks in this path we need to use FSYNC_VolOp() */
-#ifdef notdef
-	/* Dettaching it so break all callbacks on it */
-	if (V_BreakVolumeCallbacks) {
-	    Log("volume %u detached; breaking all call backs\n", volume);
-	    (*V_BreakVolumeCallbacks) (volume);
-	}
-#endif
     }
 #endif /* FSSYNC_BUILD_CLIENT */
 }
diff --git a/src/vol/volume.h b/src/vol/volume.h
index e600237b3..d8d25a98e 100644
--- a/src/vol/volume.h
+++ b/src/vol/volume.h
@@ -29,10 +29,7 @@ typedef bit32 FileOffset;	/* Offset in this file */
 #include "daemon_com.h"
 #include "fssync.h"
 
-#if 0
-/** turn this on if you suspect a volume package locking bug */
-#define VOL_LOCK_DEBUG 1
-#endif
+/** turn on VOL_LOCK_DEBUG if you suspect a volume package locking bug */
 
 #ifdef VOL_LOCK_DEBUG
 #define VOL_LOCK_ASSERT_HELD \
@@ -413,11 +410,7 @@ typedef struct VolumeDiskData {
 				 * this volume; it is bogus (left over from an aborted  volume move,
 				 * for example).  Note:  if this flag is on, then inService should
 				 * be OFF--only the salvager checks this flag */
-#ifdef ALPHA_DUX40_ENV
-#define DONT_SALVAGE	0xE6
-#else				/* ALPHA_DUX40_ENV */
 #define DONT_SALVAGE	0xE5
-#endif				/* ALPHA_DUX40_ENV */
     byte dontSalvage;		/* If this is on, then don't bother salvaging this volume */
     byte reserveb3;
 
diff --git a/src/vol/vutil.c b/src/vol/vutil.c
index cafed4de6..d5b8d8d73 100644
--- a/src/vol/vutil.c
+++ b/src/vol/vutil.c
@@ -115,7 +115,7 @@ VCreateVolume_r(Error * ec, char *partname, VolumeId volumeId, VolumeId parentId
 				 * no parent */
     VolumeDiskData vol;
     int i, rc;
-    char headerName[VMAXPATHLEN], volumePath[VMAXPATHLEN];
+    char headerName[VMAXPATHLEN], volumePath[VMAXPATHLEN + 1];
     Device device;
     struct DiskPartition64 *partition;
     struct VolumeDiskHeader diskHeader;
@@ -670,9 +670,6 @@ VCreateVolumeDiskHeader(VolumeDiskHeader_t * hdr,
  * @return operation status
  *    @retval 0 success
  *
- * @note if parent is 0, the parent volume ID will be looked up from the
- * fileserver
- *
  * @note for non-DAFS, parent is currently ignored
  */
 afs_int32
@@ -695,22 +692,8 @@ VDestroyVolumeDiskHeader(struct DiskPartition64 * dp,
     }
 
 #ifdef AFS_DEMAND_ATTACH_FS
+    /* Remove the volume entry from the fileserver's volume group cache, if found. */
     memset(&res, 0, sizeof(res));
-    if (!parent) {
-	FSSYNC_VGQry_response_t q_res;
-
-	code = FSYNC_VGCQuery(dp->name, volid, &q_res, &res);
-	if (code) {
-	    Log("VDestroyVolumeDiskHeader: FSYNC_VGCQuery(%s, %lu) failed "
-	        "with code %ld, reason %ld\n", dp->name,
-	        afs_printable_uint32_lu(volid), afs_printable_int32_ld(code),
-		afs_printable_int32_ld(res.hdr.reason));
-	    goto done;
-	}
-
-	parent = q_res.rw;
-
-    }
     code = FSYNC_VGCDel(dp->name, parent, volid, FSYNC_WHATEVER, &res);
     if (code) {
 	Log("VDestroyVolumeDiskHeader: FSYNC_VGCDel(%s, %" AFS_VOLID_FMT ", %" AFS_VOLID_FMT ") failed "
diff --git a/src/volser/Makefile.in b/src/volser/Makefile.in
index 7e9cc78af..62b1e0bff 100644
--- a/src/volser/Makefile.in
+++ b/src/volser/Makefile.in
@@ -198,7 +198,7 @@ install: restorevol voldump volser.h volint.h vos volserver libvolser.a
 	${INSTALL_PROGRAM} vos ${DESTDIR}${afssrvsbindir}/vos
 	${INSTALL_DATA} libvolser.a ${DESTDIR}${libdir}/afs/libvolser.a
 	@case ${SYS_NAME} in \
-	alpha_dux4*|*linux*|rs_aix*|sgi_6*|sun4x*|sunx86*) \
+	*linux*|rs_aix*|sgi_6*|sun4x*|sunx86*) \
 		echo "Don't install volserver for ${SYS_NAME}" ;; \
 	*_darwin_[1-6][0-9]) \
 		echo ${INSTALL} volserver \
@@ -228,7 +228,7 @@ dest: restorevol voldump volser.h volint.h vos volserver libvolser.a
 	${INSTALL_PROGRAM} vos ${DEST}/root.server/usr/afs/bin/vos
 	${INSTALL_DATA} libvolser.a ${DEST}/lib/afs/libvolser.a
 	@case ${SYS_NAME} in \
-	alpha_dux4*|*linux*|rs_aix*|sgi_6*|sun4x*|sunx86*) \
+	*linux*|rs_aix*|sgi_6*|sun4x*|sunx86*) \
 		echo "Don't install volserver for ${SYS_NAME}" ;; \
 	*_darwin_[1-6][0-9]) \
 		echo ${INSTALL} volserver \
diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c
index 63bf061c4..3a7c85e27 100644
--- a/src/volser/dumpstuff.c
+++ b/src/volser/dumpstuff.c
@@ -64,9 +64,9 @@ static int DumpVnodeIndex(struct iod *iodp, Volume * vp,
 static int DumpVnode(struct iod *iodp, struct VnodeDiskObject *v,
 		     VolumeId volid, int vnodeNumber, int dumpEverything);
 static int ReadDumpHeader(struct iod *iodp, struct DumpHeader *hp);
-static int ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
-		      afs_foff_t * Lbuf, afs_int32 s1, afs_foff_t * Sbuf,
-		      afs_int32 s2, afs_int32 delo);
+static int ReadVnodes(struct iod *iodp, Volume * vp, afs_foff_t * Lbuf,
+                      afs_int32 s1, afs_foff_t * Sbuf, afs_int32 s2,
+                      afs_int32 delo);
 static afs_fsize_t volser_WriteFile(int vn, struct iod *iodp,
 				    FdHandle_t * handleP, int tag,
 				    Error * status);
@@ -704,10 +704,8 @@ static int
 DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
 {
     int code = 0, error = 0;
-    afs_int32 pad = 0;
-    afs_foff_t offset = 0;
     afs_sfsize_t nbytes, howBig;
-    ssize_t n;
+    ssize_t n = 0;
     size_t howMany;
     afs_foff_t howFar = 0;
     byte *p;
@@ -776,62 +774,38 @@ DumpFile(struct iod *iodp, int vnode, FdHandle_t * handleP)
 	return VOLSERDUMPERROR;
     }
 
-    for (nbytes = howBig; (nbytes && !error); nbytes -= howMany) {
+    for (nbytes = howBig; (nbytes && !error); ) {
 	if (nbytes < howMany)
 	    howMany = nbytes;
 
 	/* Read the data */
 	n = FDH_PREAD(handleP, p, howMany, howFar);
-	howFar += n;
+	if (n < 0) {
+	    Log("1 Volser: DumpFile: Error reading inode %s for vnode %d: %s\n",
+		PrintInode(stmp, handleP->fd_ih->ih_ino), vnode,
+		afs_error_message(errno));
+	    error = VOLSERDUMPERROR;
 
-	/* If read any good data and we null padded previously, log the
-	 * amount that we had null padded.
-	 */
-	if ((n > 0) && pad) {
-	    Log("1 Volser: DumpFile: Null padding file %d bytes at offset %lld\n", pad, (long long)offset);
-	    pad = 0;
+	} else if (n == 0) {
+	    Log("1 Volser: DumpFile: Premature EOF reading inode %s for vnode %d\n",
+		PrintInode(stmp, handleP->fd_ih->ih_ino), vnode);
+	    error = VOLSERDUMPERROR;
 	}
-
-	/* If didn't read enough data, null padd the rest of the buffer. This
-	 * can happen if, for instance, the media has some bad spots. We don't
-	 * want to quit the dump, so we start null padding.
-	 */
-	if (n < howMany) {
-	    /* Record the read error */
-	    if (n < 0) {
-		n = 0;
-		Log("1 Volser: DumpFile: Error reading inode %s for vnode %d: %s\n", PrintInode(stmp, handleP->fd_ih->ih_ino), vnode, afs_error_message(errno));
-	    } else if (!pad) {
-		Log("1 Volser: DumpFile: Error reading inode %s for vnode %d\n", PrintInode(stmp, handleP->fd_ih->ih_ino), vnode);
-	    }
-
-	    /* Pad the rest of the buffer with zeros. Remember offset we started
-	     * padding. Keep total tally of padding.
-	     */
-	    memset(p + n, 0, howMany - n);
-	    if (!pad)
-		offset = (howBig - nbytes) + n;
-	    pad += (howMany - n);
-
-	    /* Now seek over the data we could not get. An error here means we
-	     * can't do the next read.
-	     */
-	    howFar = (size_t)((howBig - nbytes) + howMany);
+	if (error != 0) {
+	    break;
 	}
 
+	howFar += n;
+	nbytes -= n;
+
 	/* Now write the data out */
-	if (iod_Write(iodp, (char *)p, howMany) != howMany)
+	if (iod_Write(iodp, (char *)p, n) != n)
 	    error = VOLSERDUMPERROR;
 #ifndef AFS_PTHREAD_ENV
 	IOMGR_Poll();
 #endif
     }
 
-    if (pad) {			/* Any padding we hadn't reported yet */
-	Log("1 Volser: DumpFile: Null padding file: %d bytes at offset %lld\n",
-	    pad, (long long)offset);
-    }
-
     free(p);
     return error;
 }
@@ -1233,8 +1207,7 @@ ProcessIndex(Volume * vp, VnodeClass class, afs_foff_t ** Bufp, int *sizep,
 
 
 int
-RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
-	      struct restoreCookie *cookie)
+RestoreVolume(struct rx_call *call, Volume * avp, struct restoreCookie *cookie)
 {
     VolumeDiskData vol;
     struct DumpHeader header;
@@ -1247,6 +1220,7 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
     int s1 = 0, s2 = 0, delo = 0, tdelo;
     int tag;
     VolumeDiskData saved_header;
+    afs_uint32 uptime, crtime;
 
     iod_Init(iodp, call);
 
@@ -1264,8 +1238,11 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 	Log("1 Volser: RestoreVolume: Volume header missing from dump; not restored\n");
 	return VOLSERREAD_DUMPERROR;
     }
-    if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR)
+    if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR) {
+	Log("1 Volser: RestoreVolume: Error reading volume header (id: %u); aborted\n",
+	    V_id(vp));
 	return VOLSERREAD_DUMPERROR;
+    }
 
     if (!delo)
 	delo = ProcessIndex(vp, vLarge, &b1, &s1, 0);
@@ -1286,7 +1263,9 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 
     tdelo = delo;
     while (1) {
-	if (ReadVnodes(iodp, vp, 0, b1, s1, b2, s2, tdelo)) {
+	if (ReadVnodes(iodp, vp, b1, s1, b2, s2, tdelo)) {
+	    Log("1 Volser: RestoreVolume: Error reading vnodes (id: %u); aborted\n",
+		V_id(vp));
 	    error = VOLSERREAD_DUMPERROR;
 	    goto clean;
 	}
@@ -1295,6 +1274,8 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 	    break;
 
 	if (ReadVolumeHeader(iodp, &vol) == VOLSERREAD_DUMPERROR) {
+	    Log("1 Volser: RestoreVolume: Error reading volume header (id: %u); aborted\n",
+		V_id(vp));
 	    error = VOLSERREAD_DUMPERROR;
 	    goto out;
 	}
@@ -1334,6 +1315,8 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 	 * prevent it from getting overwritten. */
 	vol.needsSalvaged = V_needsSalvaged(vp);
     }
+    crtime = V_creationDate(vp);
+    uptime = V_updateDate(vp);
     CopyVolumeHeader(&vol, &V_disk(vp));
     V_destroyMe(vp) = 0;
     VUpdateVolume(&vupdate, vp);
@@ -1341,6 +1324,20 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 	Log("1 Volser: RestoreVolume: Unable to rewrite volume header; restore aborted\n");
 	error = VOLSERREAD_DUMPERROR;
 	goto out;
+    } else {
+	/*
+	 * If the volume was not a new empty volume and the restored dump was
+	 * older than the volume in question, this is probably a mistake, and
+	 * may mean the resulting volume is corrupted. Log the following message
+	 * to give a clue as to why this volume suddenly looks strange or corrupt.
+	 */
+	if ((crtime != uptime) && (uptime > V_updateDate(vp))) {
+	    Log("1 Volser: RestoreVolume: volume %s (%u) appears to have been partially or "
+		"completely restored to an earlier version (updateDate went from %u to %u). "
+		"This is allowed, but may indicate a mistake in whatever tool is restoring "
+		"this volume. If this volume appears corrupted, this is probably why.\n",
+		V_name(vp), V_id(vp), uptime, V_updateDate(vp));
+	}
     }
   out:
     /* Free the malloced space above */
@@ -1352,9 +1349,8 @@ RestoreVolume(struct rx_call *call, Volume * avp, int incremental,
 }
 
 static int
-ReadVnodes(struct iod *iodp, Volume * vp, int incremental,
-	   afs_foff_t * Lbuf, afs_int32 s1, afs_foff_t * Sbuf, afs_int32 s2,
-	   afs_int32 delo)
+ReadVnodes(struct iod *iodp, Volume * vp, afs_foff_t * Lbuf, afs_int32 s1,
+           afs_foff_t * Sbuf, afs_int32 s2, afs_int32 delo)
 {
     afs_int32 vnodeNumber;
     char buf[SIZEOF_LARGEDISKVNODE];
diff --git a/src/volser/dumpstuff.h b/src/volser/dumpstuff.h
index e949f3c65..b456f88fc 100644
--- a/src/volser/dumpstuff.h
+++ b/src/volser/dumpstuff.h
@@ -34,8 +34,7 @@ struct iod {
 extern int DumpVolume(struct rx_call *call, Volume *vp, afs_int32, int);
 extern int DumpVolMulti(struct rx_call **, int, Volume *, afs_int32, int,
 		        int *);
-extern int RestoreVolume(struct rx_call *, Volume *, int,
-			 struct restoreCookie *);
+extern int RestoreVolume(struct rx_call *, Volume *, struct restoreCookie *);
 extern int SizeDumpVolume(struct rx_call *, Volume *, afs_int32, int,
 			  struct volintSize *);
 
diff --git a/src/volser/restorevol.c b/src/volser/restorevol.c
index 0f2887513..376255875 100644
--- a/src/volser/restorevol.c
+++ b/src/volser/restorevol.c
@@ -362,33 +362,22 @@ struct vNode {
     afs_int32 modebits;
     afs_int32 parent;
     char acl[192];
-#ifdef notdef
-    struct acl_accessList {
-	int size;		/*size of this access list in bytes, including MySize itself */
-	int version;		/*to deal with upward compatibility ; <= ACL_ACLVERSION */
-	int total;
-	int positive;		/* number of positive entries */
-	int negative;		/* number of minus entries */
-	struct acl_accessEntry {
-	    int id;		/*internally-used ID of user or group */
-	    int rights;		/*mask */
-	} entries[100];
-    } acl;
-#endif
     afs_sfsize_t dataSize;
 };
 
 #define MAXNAMELEN 256
 
-afs_int32
-ReadVNode(afs_int32 count)
+static int
+ReadVNode(afs_int32 count, afs_int32 *return_tag)
 {
     struct vNode vn;
     int code, i, done;
     char tag;
-    char dirname[MAXNAMELEN], linkname[MAXNAMELEN], lname[MAXNAMELEN];
-    char parentdir[MAXNAMELEN], vflink[MAXNAMELEN];
-    char filename[MAXNAMELEN], fname[MAXNAMELEN];
+    char *dirname = NULL, *lname = NULL, *slinkname = NULL;
+    char linkname[MAXNAMELEN+1];
+    char *parentdir = NULL, *vflink = NULL;
+    char *filename = NULL;
+    char fname[MAXNAMELEN+1];
     int len;
     afs_int32 vnode;
     afs_int32 mode = 0;
@@ -467,35 +456,57 @@ ReadVNode(afs_int32 count)
 	     * The parent dir and symbolic link to it must exist.
 	     */
 	    vnode = ((vn.type == 2) ? vn.vnode : vn.parent);
-	    if (vnode == 1)
-		strncpy(parentdir, rootdir, sizeof parentdir);
-	    else {
-		snprintf(parentdir, sizeof parentdir,
-			 "%s" OS_DIRSEP "%s%d", rootdir, ADIR, vnode);
+	    if (vnode == 1) {
+		free(parentdir);
+		parentdir = strdup(rootdir);
+		if (!parentdir) {
+		    code = ENOMEM;
+		    goto common_exit;
+		}
+	    } else {
+		free(parentdir);
+		if (asprintf(&parentdir,
+			 "%s" OS_DIRSEP "%s%d", rootdir, ADIR, vnode) < 0) {
+		    parentdir = NULL;
+		    code = ENOMEM;
+		    goto common_exit;
+		}
 
 		len = readlink(parentdir, linkname, MAXNAMELEN);
 		if (len < 0) {
 		    /* parentdir does not exist. So create an orphan dir.
 		     * and then link the parentdir to the orphaned dir.
 		     */
-		    snprintf(linkname, sizeof linkname, "%s" OS_DIRSEP "%s%d",
-			     rootdir, ODIR, vnode);
-		    code = mkdir(linkname, 0777);
+		    if (asprintf(&lname, "%s" OS_DIRSEP "%s%d",
+			     rootdir, ODIR, vnode) < 0) {
+			lname = NULL;
+			code = ENOMEM;
+			goto common_exit;
+		    }
+
+		    code = mkdir(lname, 0777);
 		    if ((code < 0) && (errno != EEXIST)) {
 			fprintf(stderr,
 				"Error creating directory %s  code=%d;%d\n",
-				linkname, code, errno);
+				lname, code, errno);
 		    }
-
+		    free(lname);
 		    /* Link the parentdir to it - now parentdir exists */
-		    snprintf(linkname, sizeof linkname, "%s%d/", ODIR,
-			     vnode);
-		    code = symlink(linkname, parentdir);
+		    if (asprintf(&lname, "%s%d/", ODIR,
+			     vnode) < 0) {
+			lname = NULL;
+			code = ENOMEM;
+			goto common_exit;
+		    }
+
+		    code = symlink(lname, parentdir);
 		    if (code) {
 			fprintf(stderr,
 				"Error creating symlink %s -> %s  code=%d;%d\n",
-				parentdir, linkname, code, errno);
+				parentdir, lname, code, errno);
 		    }
+		    free(lname);
+		    lname = NULL;
 		}
 	    }
 
@@ -543,7 +554,11 @@ ReadVNode(afs_int32 count)
 
 
 		buffer = NULL;
-		buffer = malloc(vn.dataSize);
+		buffer = calloc(1, vn.dataSize);
+		if (!buffer) {
+		    code = ENOMEM;
+		    goto common_exit;
+		}
 
 		readdata(buffer, vn.dataSize);
 		page0 = (struct Page0 *)buffer;
@@ -571,12 +586,22 @@ ReadVNode(afs_int32 count)
 				/* dirname is the directory to create.
 				 * vflink is what will link to it.
 				 */
-			    snprintf(dirname, sizeof dirname,
+			    if (asprintf(&dirname,
 				     "%s" OS_DIRSEP "%s",
-				     parentdir, this_name);
-			    snprintf(vflink, sizeof vflink,
+				     parentdir, this_name) < 0) {
+				free(buffer);
+				code = ENOMEM;
+				goto common_exit;
+			    }
+
+			    if (asprintf(&vflink,
 				     "%s" OS_DIRSEP "%s%d",
-				     rootdir, ADIR, this_vn);
+				     rootdir, ADIR, this_vn) < 0) {
+				free(buffer);
+				free(dirname);
+				code = ENOMEM;
+				goto common_exit;
+			    }
 
 			    /* The link and directory may already exist */
 			    len = readlink(vflink, linkname, MAXNAMELEN);
@@ -595,24 +620,48 @@ ReadVNode(afs_int32 count)
 				 * It was created originally as orphaned.
 				 */
 				linkname[len - 1] = '\0';	/* remove '/' at end */
-				snprintf(lname, sizeof lname,
+				if (asprintf(&lname,
 				         "%s" OS_DIRSEP "%s",
-					 rootdir, linkname);
+					 rootdir, linkname) < 0) {
+				    free(buffer);
+				    free(dirname);
+				    free(vflink);
+				    lname = NULL;
+				    code = ENOMEM;
+				    goto common_exit;
+				}
+
 				code = rename(lname, dirname);
 				if (code) {
 				    fprintf(stderr,
 					    "Error renaming %s to %s  code=%d;%d\n",
 					    lname, dirname, code, errno);
 				}
+				free(lname);
+				lname = NULL;
 			    }
+			    free(dirname);
+			    dirname = NULL;
 
 			    /* Now create/update the link to the new/moved directory */
-			    if (vn.vnode == 1)
-				snprintf(dirname, sizeof dirname, "%s/",
-					 this_name);
-			    else
-				snprintf(dirname, sizeof dirname, "%s%d/%s/",
-					 ADIR, vn.vnode, this_name);
+			    if (vn.vnode == 1) {
+				if (asprintf(&dirname, "%s/",
+					 this_name) < 0) {
+				    free(buffer);
+				    free(vflink);
+				    code = ENOMEM;
+				    goto common_exit;
+				}
+			    } else {
+				if (asprintf(&dirname, "%s%d/%s/",
+					 ADIR, vn.vnode, this_name) < 0) {
+				    free(buffer);
+				    free(vflink);
+				    code = ENOMEM;
+				    goto common_exit;
+				}
+			    }
+
 			    unlink(vflink);
 			    code = symlink(dirname, vflink);
 			    if (code) {
@@ -620,6 +669,10 @@ ReadVNode(afs_int32 count)
 					"Error creating symlink %s -> %s  code=%d;%d\n",
 					vflink, dirname, code, errno);
 			    }
+			    free(dirname);
+			    free(vflink);
+			    dirname = NULL;
+			    vflink = NULL;
 			}
 			/*ADIRENTRY*/
 			    /* For a file entry, we remember the name of the file
@@ -628,9 +681,13 @@ ReadVNode(afs_int32 count)
 			     */
 			else {
 			     /*AFILEENTRY*/
-			    snprintf(vflink, sizeof vflink,
+			    if (asprintf(&vflink,
 				     "%s" OS_DIRSEP "%s%d", parentdir,
-				     AFILE, this_vn);
+				     AFILE, this_vn) < 0) {
+				free(buffer);
+				code = ENOMEM;
+				goto common_exit;
+			    }
 
 			    code = symlink(this_name, vflink);
 			    if ((code < 0) && (errno != EEXIST)) {
@@ -639,10 +696,13 @@ ReadVNode(afs_int32 count)
 					vflink, page0->entry[j].name, code,
 					errno);
 			    }
+			    free(vflink);
+			    vflink = NULL;
 			}
 		     /*AFILEENTRY*/}
 		}
 		free(buffer);
+		buffer = NULL;
 	    }
 	    /*ITSADIR*/
 	    else if (vn.type == 1) {
@@ -659,12 +719,19 @@ ReadVNode(afs_int32 count)
 		 * then the file will be an orphaned file.
 		 */
 		lfile = 1;
-		snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s%d",
-			 parentdir, AFILE, vn.vnode);
+		if (asprintf(&filename, "%s" OS_DIRSEP "%s%d",
+			 parentdir, AFILE, vn.vnode) < 0) {
+		    code = ENOMEM;
+		    goto common_exit;
+		}
 		len = readlink(filename, fname, MAXNAMELEN);
 		if (len < 0) {
-		    snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s%d",
-			     rootdir, OFILE, vn.vnode);
+		    free(filename);
+		    if (asprintf(&filename, "%s" OS_DIRSEP "%s%d",
+			     rootdir, OFILE, vn.vnode) < 0) {
+			code = ENOMEM;
+			goto common_exit;
+		    }
 		    lfile = 0;	/* no longer a linked file; a direct path */
 		}
 
@@ -690,12 +757,9 @@ ReadVNode(afs_int32 count)
 			    fprintf(stderr, "Code = %d; Errno = %d\n", code,
 				    errno);
 			else {
-			    char tmp[100];
-			    snprintf(tmp, sizeof tmp,
-				     "Read %llu bytes out of %llu",
+			    fprintf(stderr, "Read %llu bytes out of %llu\n",
 				     (afs_uintmax_t) (vn.dataSize - size),
 				     (afs_uintmax_t) vn.dataSize);
-			    fprintf(stderr, "%s\n", tmp);
 			}
 			break;
 		    }
@@ -725,6 +789,8 @@ open_fail:
 		if (lfile) {
 		    unlink(filename);
 		}
+		free(filename);
+		filename = NULL;
 	    }
 	    /*ITSAFILE*/
 	    else if (vn.type == 3) {
@@ -739,16 +805,28 @@ open_fail:
 		 * of the symbolic link. If it doesn't exist,
 		 * then the link will be an orphaned link.
 		 */
-		snprintf(linkname, sizeof linkname, "%s" OS_DIRSEP "%s%d",
-			 parentdir, AFILE, vn.vnode);
-		len = readlink(linkname, fname, MAXNAMELEN - 1);
+		if (asprintf(&slinkname, "%s" OS_DIRSEP "%s%d",
+			 parentdir, AFILE, vn.vnode) < 0) {
+		    code = ENOMEM;
+		    goto common_exit;
+		}
+
+		len = readlink(slinkname, fname, MAXNAMELEN);
 		if (len < 0) {
-		    snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s%d",
-			     rootdir, OFILE, vn.vnode);
+		    if (asprintf(&filename, "%s" OS_DIRSEP "%s%d",
+			     rootdir, OFILE, vn.vnode) < 0) {
+			free(slinkname);
+			code = ENOMEM;
+			goto common_exit;
+		    }
 		} else {
 		    fname[len] = '\0';
-		    snprintf(filename, sizeof filename, "%s" OS_DIRSEP "%s",
-			     parentdir, fname);
+		    if (asprintf(&filename, "%s" OS_DIRSEP "%s",
+			     parentdir, fname) < 0) {
+			free(slinkname);
+			code = ENOMEM;
+			goto common_exit;
+		    }
 		}
 
 		/* Read the link in, delete it, and then create it */
@@ -760,9 +838,27 @@ open_fail:
 		    && (buf[s - 1] == '.')) {
 		    /* This is a symbolic link */
 		    buf[s - 1] = 0;	/* Remove prefix '.' */
-		    strcpy(lname, &buf[1]);	/* Remove postfix '#' or '%' */
-		    strcpy(buf, mntroot);
-		    strcat(buf, lname);
+		    lname = strdup(&buf[1]);	/* Remove postfix '#' or '%' */
+		    if (!lname) {
+			free(filename);
+			free(slinkname);
+			code = ENOMEM;
+			goto common_exit;
+		    }
+		    if (strlcpy(buf, mntroot, BUFSIZE) >= BUFSIZE) {
+			free(filename);
+			free(slinkname);
+			code = EMSGSIZE;
+			goto common_exit;
+		    }
+		    if (strlcat(buf, lname, BUFSIZE) >= BUFSIZE) {
+			free(filename);
+			free(slinkname);
+			code = EMSGSIZE;
+			goto common_exit;
+		    }
+		    free(lname);
+		    lname = NULL;
 		}
 
 		unlink(filename);
@@ -774,7 +870,12 @@ open_fail:
 		}
 
 		/* Remove the symbolic link */
-		unlink(linkname);
+		unlink(slinkname);
+		free(slinkname);
+		free(filename);
+		slinkname = NULL;
+		filename = NULL;
+
 	    }
 	    /*ITSASYMLINK*/
 	    else {
@@ -790,7 +891,13 @@ open_fail:
     if (vn.type == 0)
 	inc_dump = 1;
 
-    return ((afs_int32) tag);
+
+    *return_tag  = (afs_int32)tag;
+    code = 0;
+  common_exit:
+    free(parentdir);
+    free(lname);
+    return code;
 }
 
 static int
@@ -800,13 +907,12 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
     afs_int32 type, count, vcount;
     DIR *dirP, *dirQ;
     struct dirent *dirE, *dirF;
-    char name[MAXNAMELEN];
-    char thisdir[MAXPATHLEN], *t;
+    char *name = NULL;
+    char *thisdir, *t;
     struct DumpHeader dh;	/* Defined in dump.h */
-#if 0/*ndef HAVE_GETCWD*/	/* XXX enable when autoconf happens */
-    extern char *getwd();
-#define getcwd(x,y) getwd(x)
-#endif
+    thisdir = calloc(1, MAXPATHLEN+4);
+    if (!thisdir)
+	goto mem_error_exit;
 
     if (as->parms[0].items) {	/* -file <dumpfile> */
 	dumpfile = fopen(as->parms[0].items->data, "r");
@@ -830,14 +936,17 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     /* Get the root directory we restore to */
     if (as->parms[1].items) {	/* -dir <rootdir> */
-	strcpy(rootdir, as->parms[1].items->data);
+	if (strlcpy(rootdir, as->parms[1].items->data, sizeof(rootdir)) >= sizeof(rootdir))
+	    goto str_error_exit;
     } else {
 	strcpy(rootdir, ".");
     }
-    strcat(rootdir, "/");
+    if (strlcat(rootdir, "/", sizeof(rootdir)) >= sizeof(rootdir))
+	goto str_error_exit;
 
     /* Append the RW volume name to the root directory */
-    strcat(rootdir, dh.volumeName);
+    if (strlcat(rootdir, dh.volumeName, sizeof(rootdir)) >= sizeof(rootdir))
+	goto str_error_exit;
     len = strlen(rootdir);
     if (strcmp(".backup", rootdir + len - 7) == 0) {
 	rootdir[len - 7] = 0;
@@ -847,7 +956,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     /* Append the extension we asked for */
     if (as->parms[2].items) {
-	strcat(rootdir, as->parms[2].items->data);	/* -extension <ext> */
+	if (strlcat(rootdir, as->parms[2].items->data, sizeof(rootdir)) >= sizeof(rootdir))    /* -extension <ext> */
+	    goto str_error_exit;
     }
 
     /* The mountpoint root is either specifid in -mountpoint
@@ -879,7 +989,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 	    code = -1;
 	    goto cleanup;
 	}
-	strcat(mntroot, "/");	/* append '/' to end of it */
+	if (strlcat(mntroot, "/", sizeof(mntroot)) >= sizeof(mntroot))	/* append '/' to end of it */
+	    goto str_error_exit;
 	code = chdir(thisdir);	/* return to original working dir */
 	if (code) {
 	    fprintf(stderr, "Cannot find working directory: Error = %d\n",
@@ -896,7 +1007,8 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 	    goto cleanup;
 	}
     }
-    strcat(mntroot, "/");	/* append '/' to end of it */
+    if (strlcat(mntroot, "/", sizeof(mntroot)) >= sizeof(mntroot))	/* append '/' to end of it */
+	goto str_error_exit;
 
     /* Set the umask for the restore */
     if (as->parms[4].items) {	/* -umask */
@@ -916,8 +1028,13 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 
     for (count = 1; type == 2; count++) {
 	type = ReadVolumeHeader(count);
-	for (vcount = 1; type == 3; vcount++)
-	    type = ReadVNode(vcount);
+	for (vcount = 1; type == 3; vcount++) {
+	    code = ReadVNode(vcount, &type);
+	    if (code == ENOMEM)
+		goto mem_error_exit;
+	    if (code == EMSGSIZE)
+		goto str_error_exit;
+	}
     }
 
     if (type != 4) {
@@ -935,38 +1052,70 @@ WorkerBee(struct cmd_syndesc *as, void *arock)
 	dirP = opendir(rootdir);
 	while (dirP && (dirE = readdir(dirP))) {
 	    if (strncmp(dirE->d_name, ADIR, strlen(ADIR)) == 0) {
-		snprintf(name, sizeof name, "%s" OS_DIRSEP "%s", rootdir,
-			 dirE->d_name);
+		if (asprintf(&name, "%s" OS_DIRSEP "%s", rootdir,
+			 dirE->d_name) < 0)
+		    goto mem_error_exit;
+
 		dirQ = opendir(name);
+		free(name);
+		name = NULL;
 		while (dirQ && (dirF = readdir(dirQ))) {
 		    if (strncmp(dirF->d_name, AFILE, strlen(AFILE)) == 0) {
-			snprintf(name, sizeof name, "%s" OS_DIRSEP "%s/%s",
-				 rootdir, dirE->d_name, dirF->d_name);
+			if (asprintf(&name, "%s" OS_DIRSEP "%s/%s",
+				 rootdir, dirE->d_name, dirF->d_name) < 0)
+			    goto mem_error_exit;
+
 			unlink(name);
+			free(name);
+			name = NULL;
 		    }
 		}
-		closedir(dirQ);
+		if (dirQ)
+		    closedir(dirQ);
 	    } else if (strncmp(dirE->d_name, AFILE, strlen(AFILE)) == 0) {
-		snprintf(name, sizeof name, "%s" OS_DIRSEP "%s", rootdir,
-			 dirE->d_name);
+		if (asprintf(&name, "%s" OS_DIRSEP "%s", rootdir,
+			 dirE->d_name) < 0)
+		    goto mem_error_exit;
+
 		unlink(name);
+		free(name);
+		name = NULL;
 	    }
 	}
-	closedir(dirP);
+	if (dirP)
+	    closedir(dirP);
     }
 
     /* Now go through and remove all the directory links */
     dirP = opendir(rootdir);
     while (dirP && (dirE = readdir(dirP))) {
 	if (strncmp(dirE->d_name, ADIR, strlen(ADIR)) == 0) {
-	    snprintf(name, sizeof name, "%s" OS_DIRSEP "%s", rootdir,
-		     dirE->d_name);
+	    if (asprintf(&name, "%s" OS_DIRSEP "%s", rootdir,
+		     dirE->d_name) < 0)
+		goto mem_error_exit;
+
 	    unlink(name);
+	    free(name);
+	    name = NULL;
 	}
     }
-    closedir(dirP);
+    if (dirP)
+	closedir(dirP);
 
+    free(thisdir);
     return (code);
+
+  mem_error_exit:
+    /* Error allocating memory -- quick exit */
+    fprintf(stderr, "Memory allocation error!\n");
+    free(thisdir);
+    return -1;
+
+  str_error_exit:
+    /* Str length error */
+    fprintf(stderr, "String exceeded buffer size\n");
+    free(thisdir);
+    return -1;
 }
 
 int
diff --git a/src/volser/vol-dump.c b/src/volser/vol-dump.c
index 1efbbaf0a..9a077a4cd 100644
--- a/src/volser/vol-dump.c
+++ b/src/volser/vol-dump.c
@@ -53,6 +53,7 @@
 
 int VolumeChanged;		/* needed by physio - leave alone */
 int verbose = 0;
+static int enable_padding; /* Pad errors with NUL bytes */
 
 /* Forward Declarations */
 static void HandleVolume(struct DiskPartition64 *partP, char *name,
@@ -145,15 +146,6 @@ handleit(struct cmd_syndesc *as, void *arock)
     afs_int32 code;
 
 
-#ifndef AFS_NT40_ENV
-#if 0
-    if (geteuid() != 0) {
-	fprintf(stderr, "voldump must be run as root; sorry\n");
-	exit(1);
-    }
-#endif
-#endif
-
     if ((ti = as->parms[0].items))
 	partName = ti->data;
     if ((ti = as->parms[1].items))
@@ -170,6 +162,9 @@ handleit(struct cmd_syndesc *as, void *arock)
 		return code;
 	}
     }
+    if (as->parms[5].items != NULL) { /* -pad-errors */
+	enable_padding = 1;
+    }
 
     DInit(10);
 
@@ -280,6 +275,8 @@ main(int argc, char **argv)
     cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL,
 		"Trace dump progress (very verbose)");
     cmd_AddParm(ts, "-time", CMD_SINGLE, CMD_OPTIONAL, "dump from time");
+    cmd_AddParm(ts, "-pad-errors", CMD_FLAG, CMD_OPTIONAL,
+		"pad i/o errors with NUL bytes");
     code = cmd_Dispatch(argc, argv);
     return code;
 }
@@ -536,11 +533,11 @@ DumpByteString(int dumpfd, char tag, byte * bs, int nbytes)
 static int
 DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v)
 {
-    int code = 0, failed_seek = 0, failed_write = 0;
+    int code = 0;
     afs_int32 pad = 0;
     afs_foff_t offset = 0;
     afs_sfsize_t nbytes, howBig;
-    ssize_t n;
+    ssize_t n = 0;
     size_t howMany;
     afs_foff_t howFar = 0;
     byte *p;
@@ -609,13 +606,11 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
     }
 
     /* loop through whole file, while we still have bytes left, and no errors, in chunks of howMany bytes */
-    for (nbytes = size; (nbytes && !failed_write); nbytes -= howMany) {
+    for (nbytes = size; (nbytes && !code); ) {
 	if (nbytes < howMany)
 	    howMany = nbytes;
 
-	/* Read the data - unless we know we can't */
-	n = (failed_seek ? 0 : FDH_PREAD(handleP, p, howMany, howFar));
-	howFar += n;
+	n = FDH_PREAD(handleP, p, howMany, howFar);
 
 	/* If read any good data and we null padded previously, log the
 	 * amount that we had null padded.
@@ -626,42 +621,48 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
 	    pad = 0;
 	}
 
-	/* If didn't read enough data, null padd the rest of the buffer. This
-	 * can happen if, for instance, the media has some bad spots. We don't
-	 * want to quit the dump, so we start null padding.
-	 */
-	if (n < howMany) {
-
-		if (verbose) fprintf(stderr, "  read %u instead of %u bytes.\n", (unsigned)n, (unsigned)howMany);
-
-	    /* Record the read error */
-	    if (n < 0) {
-		n = 0;
-		fprintf(stderr, "Error %d reading inode %s for vnode %d\n",
-			errno, PrintInode(stmp, handleP->fd_ih->ih_ino),
-			vnode);
-	    } else if (!pad) {
-		fprintf(stderr, "Error reading inode %s for vnode %d\n",
+	if (n < 0) {
+	    fprintf(stderr, "Error %d reading inode %s for vnode %d\n",
+		    errno, PrintInode(stmp, handleP->fd_ih->ih_ino),
+		    vnode);
+	    code = VOLSERDUMPERROR;
+	}
+	if (n == 0) {
+	    if (pad == 0) {
+		fprintf(stderr, "Unexpected EOF reading inode %s for vnode %d\n",
 			PrintInode(stmp, handleP->fd_ih->ih_ino), vnode);
 	    }
+	    code = VOLSERDUMPERROR;
+	}
 
-	    /* Pad the rest of the buffer with zeros. Remember offset we started
-	     * padding. Keep total tally of padding.
+	if (code != 0 && enable_padding) {
+	    /*
+	     * If our read failed, NUL-pad the rest of the buffer. This can
+	     * happen if, for instance, the media has some bad spots. We don't
+	     * want to quit the dump, so we start NUL padding.
 	     */
-	    memset(p + n, 0, howMany - n);
+	    memset(p, 0, howMany);
+
+	    /* Remember the offset where we started padding, and keep a total
+	     * tally of how much padding we've done. */
 	    if (!pad)
-		offset = (howBig - nbytes) + n;
-	    pad += (howMany - n);
+		offset = howFar;
+	    pad += howMany;
 
-	    /* Now seek over the data we could not get. An error here means we
-	     * can't do the next read.
-	     */
-	    howFar = ((size - nbytes) + howMany);
+	    /* Pretend we read 'howMany' bytes. */
+	    n = howMany;
+	    code = 0;
 	}
+	if (code != 0) {
+	    break;
+	}
+
+	howFar += n;
+	nbytes -= n;
 
 	/* Now write the data out */
-	if (write(dumpfd, (char *)p, howMany) != howMany)
-	    failed_write = VOLSERDUMPERROR;
+	if (write(dumpfd, (char *)p, n) != n)
+	    code = VOLSERDUMPERROR;
     }
 
     if (pad) {			/* Any padding we hadn't reported yet */
@@ -670,7 +671,7 @@ DumpFile(int dumpfd, int vnode, FdHandle_t * handleP,  struct VnodeDiskObject *v
     }
 
     free(p);
-    return failed_write;
+    return code;
 }
 
 
diff --git a/src/volser/volint.xg b/src/volser/volint.xg
index 5febc6330..3c982e5cd 100644
--- a/src/volser/volint.xg
+++ b/src/volser/volint.xg
@@ -65,6 +65,7 @@ statindex 16
 %#define     VOLDUMPV2_OMITDIRS 1
 
 const SIZE = 1024;
+const NMAXNSERVERS = 13;
 
 struct volser_status {
 	afs_uint32 volID;		/* Volume id--unique over all systems */
@@ -247,7 +248,7 @@ struct volintSize {
     afs_uint64 dump_size;
 };
 
-typedef  replica manyDests<>;
+typedef  replica manyDests<NMAXNSERVERS>;
 typedef  afs_int32 manyResults<>;
 typedef  transDebugInfo transDebugEntries<>;
 typedef  volintInfo volEntries<>;
@@ -256,7 +257,7 @@ typedef  volintXInfo volXEntries<>;
 
 proc CreateVolume(
   IN afs_int32 partition,
-  string name<>,
+  string name<VNAMESIZE>,
   IN afs_int32 type,
   IN afs_uint32 parent,
   INOUT afs_uint32 *volid,
@@ -290,7 +291,7 @@ proc Clone(
   IN afs_int32 trans,
   IN afs_uint32 purgeVol,
   IN afs_int32 newType,
-  IN string newName<>,
+  IN string newName<VNAMESIZE>,
   INOUT afs_uint32 *newVol
 ) = VOLCLONE;
 
@@ -338,7 +339,7 @@ proc GetStatus(
 ) = VOLGETSTATUS;
 
 proc SignalRestore(
-  IN string name<>,
+  IN string name<VNAMESIZE>,
   int type,
   afs_uint32 pid,
   afs_uint32 cloneid
@@ -356,7 +357,7 @@ proc ListVolumes(
 
 proc SetIdsTypes(
   IN afs_int32 tId,
-  string name<>,
+  string name<VNAMESIZE>,
   afs_int32 type,
   afs_uint32 pId,
   afs_uint32 cloneId,
@@ -368,7 +369,7 @@ proc Monitor(
 ) = VOLMONITOR;
 
 proc PartitionInfo(
-  IN string name<>,
+  IN string name<4096>,
   OUT struct diskPartition *partition
 ) = VOLDISKPART;
 
@@ -441,7 +442,7 @@ proc DumpV2(
 ) split = VOLDUMPV2;
 
 proc PartitionInfo64(
-    IN string name<>,
+    IN string name<4096>,
     OUT struct diskPartition64 *partition
 ) = VOLDISKPART64;
 
diff --git a/src/volser/volmain.c b/src/volser/volmain.c
index 430510f4f..a56f657dc 100644
--- a/src/volser/volmain.c
+++ b/src/volser/volmain.c
@@ -15,7 +15,6 @@
 #ifdef AFS_PTHREAD_ENV
 # include <opr/lock.h>
 # include <opr/softsig.h>
-# include <afs/procmgmt_softsig.h> /* must come after softsig */
 #endif
 
 #ifdef AFS_NT40_ENV
@@ -134,7 +133,7 @@ BKGLoop(void *unused)
     struct timeval tv;
     int loop = 0;
 
-    afs_pthread_setname_self("vol bkg");
+    opr_threadname_set("vol bkg");
     while (1) {
 	tv.tv_sec = GCWAKEUP;
 	tv.tv_usec = 0;
@@ -156,7 +155,7 @@ BKGLoop(void *unused)
 	}
     }
 
-    return NULL;
+    AFS_UNREACHED(return(NULL));
 }
 
 #if defined(AFS_NT40_ENV) || defined(AFS_DARWIN160_ENV)
@@ -173,6 +172,13 @@ volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
     }
     return err;
 }
+#elif !defined(AFS_SYSCALL)
+int
+volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
+{
+    errno = ENOSYS;
+    return -1;
+}
 #else
 int
 volser_syscall(afs_uint32 a3, afs_uint32 a4, void *a5)
@@ -286,7 +292,7 @@ ParseArgs(int argc, char **argv) {
     cmd_AddParmAtOffset(opts, OPT_sleep, "-sleep", CMD_SINGLE,
 	    CMD_OPTIONAL, "make background daemon sleep (LWP only)");
     cmd_AddParmAtOffset(opts, OPT_peer, "-enable_peer_stats", CMD_FLAG,
-	    CMD_OPTIONAL, "enable RX transport statistics");
+	    CMD_OPTIONAL, "enable RX RPC statistics by peer");
     cmd_AddParmAtOffset(opts, OPT_process, "-enable_process_stats", CMD_FLAG,
 	    CMD_OPTIONAL, "enable RX RPC statistics");
     /* -preserve-vol-stats on by default now. */
@@ -435,6 +441,7 @@ main(int argc, char **argv)
     afs_int32 numClasses;
     struct rx_service *service;
     int rxpackets = 100;
+    char hoststr[16];
     afs_uint32 host = ntohl(INADDR_ANY);
     VolumePackageOptions opts;
 
@@ -533,6 +540,8 @@ main(int argc, char **argv)
             host = SHostAddrs[0];
     }
 
+    Log("Volserver binding rx to %s:%d\n",
+        afs_inet_ntoa_r(host, hoststr), AFSCONF_VOLUMEPORT);
     code = rx_InitHost(host, (int)htons(AFSCONF_VOLUMEPORT));
     if (code) {
 	fprintf(stderr, "rx init failed on socket AFSCONF_VOLUMEPORT %u\n",
@@ -580,7 +589,7 @@ main(int argc, char **argv)
     if (!tdir) {
 	Abort("volser: could not open conf files in %s\n",
 	      configDir);
-	VS_EXIT(1);
+	AFS_UNREACHED(VS_EXIT(1));
     }
 
     /* initialize audit user check */
@@ -609,8 +618,14 @@ main(int argc, char **argv)
 #endif
 
     if (rxkadDisableDotCheck) {
-        rx_SetSecurityConfiguration(service, RXS_CONFIG_FLAGS,
-                                    (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	code = rx_SetSecurityConfiguration(service, RXS_CONFIG_FLAGS,
+					   (void *)RXS_CONFIG_FLAGS_DISABLE_DOTCHECK);
+	if (code) {
+	    fprintf(stderr,
+		    "volser: failed to allow dotted principals: code %d\n",
+		    code);
+	    VS_EXIT(1);
+	}
     }
 
     service =
@@ -623,7 +638,11 @@ main(int argc, char **argv)
 
     LogCommandLine(argc, argv, "Volserver", VolserVersion, "Starting AFS",
 		   Log);
-    if (afsconf_GetLatestKey(tdir, NULL, NULL) == 0) {
+    if (afsconf_CountKeys(tdir) == 0) {
+	Log("WARNING: No encryption keys found! "
+	    "All authenticated accesses will fail. "
+	    "Run akeyconvert or asetkey to import encryption keys.\n");
+    } else if (afsconf_GetLatestKey(tdir, NULL, NULL) == 0) {
 	LogDesWarning();
     }
 
@@ -634,5 +653,5 @@ main(int argc, char **argv)
 
     osi_audit(VS_FinishEvent, (-1), AUD_END);
     Abort("StartServer returned?");
-    return 0; /* not reached */
+    AFS_UNREACHED(return 0);
 }
diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c
index 2c9c3001c..13bba3818 100644
--- a/src/volser/volprocs.c
+++ b/src/volser/volprocs.c
@@ -96,8 +96,7 @@ static afs_int32 VolForward(struct rx_call *, afs_int32, afs_int32,
 			    struct destServer *destination, afs_int32,
 			    struct restoreCookie *cookie);
 static afs_int32 VolDump(struct rx_call *, afs_int32, afs_int32, afs_int32);
-static afs_int32 VolRestore(struct rx_call *, afs_int32, afs_int32,
-			    struct restoreCookie *);
+static afs_int32 VolRestore(struct rx_call *, afs_int32, struct restoreCookie *);
 static afs_int32 VolEndTrans(struct rx_call *, afs_int32, afs_int32 *);
 static afs_int32 VolSetForwarding(struct rx_call *, afs_int32, afs_int32);
 static afs_int32 VolGetStatus(struct rx_call *, afs_int32,
@@ -159,44 +158,6 @@ VPFullUnlock(void)
     return code;
 }
 
-/* get partition id from a name */
-afs_int32
-PartitionID(char *aname)
-{
-    char tc;
-    int code = 0;
-    char ascii[3];
-
-    tc = *aname;
-    if (tc == 0)
-	return -1;		/* unknown */
-
-    /* otherwise check for vicepa or /vicepa, or just plain "a" */
-    ascii[2] = 0;
-    if (!strncmp(aname, "/vicep", 6)) {
-	strncpy(ascii, aname + 6, 2);
-    } else
-	return -1;		/* bad partition name */
-    /* now partitions are named /vicepa ... /vicepz, /vicepaa, /vicepab, .../vicepzz, and are numbered
-     * from 0.  Do the appropriate conversion */
-    if (ascii[1] == 0) {
-	/* one char name, 0..25 */
-	if (ascii[0] < 'a' || ascii[0] > 'z')
-	    return -1;		/* wrongo */
-	return ascii[0] - 'a';
-    } else {
-	/* two char name, 26 .. <whatever> */
-	if (ascii[0] < 'a' || ascii[0] > 'z')
-	    return -1;		/* wrongo */
-	if (ascii[1] < 'a' || ascii[1] > 'z')
-	    return -1;		/* just as bad */
-	code = (ascii[0] - 'a') * 26 + (ascii[1] - 'a') + 26;
-	if (code > VOLMAXPARTS)
-	    return -1;
-	return code;
-    }
-}
-
 static int
 ConvertVolume(VolumeId avol, char *aname, afs_int32 asize)
 {
@@ -420,6 +381,7 @@ SAFSVolPartitionInfo(struct rx_call *acid, char *pname, struct diskPartition
     afs_int32 code;
     struct diskPartition64 *dp = malloc(sizeof(struct diskPartition64));
 
+    memset(partition, 0, sizeof(*partition));
     code = VolPartitionInfo(acid, pname, dp);
     if (!code) {
 	strncpy(partition->name, dp->name, 32);
@@ -439,6 +401,7 @@ SAFSVolPartitionInfo64(struct rx_call *acid, char *pname, struct diskPartition64
 {
     afs_int32 code;
 
+    memset(partition, 0, sizeof(*partition));
     code = VolPartitionInfo(acid, pname, partition);
     osi_auditU(acid, VS_ParInfEvent, code, AUD_STR, pname, AUD_END);
     return code;
@@ -1570,14 +1533,13 @@ SAFSVolRestore(struct rx_call *acid, afs_int32 atrans, afs_int32 aflags,
 {
     afs_int32 code;
 
-    code = VolRestore(acid, atrans, aflags, cookie);
+    code = VolRestore(acid, atrans, cookie);
     osi_auditU(acid, VS_RestoreEvent, code, AUD_LONG, atrans, AUD_END);
     return code;
 }
 
 static afs_int32
-VolRestore(struct rx_call *acid, afs_int32 atrans, afs_int32 aflags,
-	   struct restoreCookie *cookie)
+VolRestore(struct rx_call *acid, afs_int32 atrans, struct restoreCookie *cookie)
 {
     struct volser_trans *tt;
     afs_int32 code, tcode;
@@ -1602,7 +1564,7 @@ VolRestore(struct rx_call *acid, afs_int32 atrans, afs_int32 aflags,
 
     DFlushVolume(V_parentId(tt->volume)); /* Ensure dir buffers get dropped */
 
-    code = RestoreVolume(acid, tt->volume, (aflags & 1), cookie);	/* last is incrementalp */
+    code = RestoreVolume(acid, tt->volume, cookie);
     FSYNC_VolOp(tt->volid, NULL, FSYNC_VOL_BREAKCBKS, 0l, NULL);
     TClearRxCall(tt);
     tcode = TRELE(tt);
@@ -2314,6 +2276,7 @@ GetVolInfo(afs_uint32 partId,
 	case VOL_INFO_LIST_SINGLE:
 	    Log("1 Volser: GetVolInfo: Volume %" AFS_VOLID_FMT " (%s:%s) will be destroyed on next salvage\n",
 		afs_printable_VolumeId_lu(volumeId), pname, volname);
+	    goto drop;
 
 	default:
 	    goto drop;
@@ -2844,6 +2807,7 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo)
 	goto done;		/*no active transactions */
     for (tt = allTrans; tt; tt = nt) {	/*copy relevant info into pntr */
 	nt = tt->next;
+	memset(pntr, 0, sizeof(*pntr));
         VTRANS_OBJ_LOCK(tt);
 	pntr->tid = tt->tid;
 	pntr->time = tt->time;
@@ -2858,12 +2822,8 @@ VolMonitor(struct rx_call *acid, transDebugEntries *transInfo)
 	pntr->callValid = 0;
 	if (tt->rxCallPtr) {	/*record call related info */
 	    pntr->callValid = 1;
-#if 0
-	    pntr->readNext = tt->rxCallPtr->rnext;
-	    pntr->transmitNext = tt->rxCallPtr->tnext;
-	    pntr->lastSendTime = tt->rxCallPtr->lastSendTime;
-	    pntr->lastReceiveTime = tt->rxCallPtr->lastReceiveTime;
-#endif
+	    rx_GetCallStatus(tt->rxCallPtr, &(pntr->readNext), &(pntr->transmitNext),
+				&(pntr->lastSendTime), &(pntr->lastReceiveTime));
 	}
         VTRANS_OBJ_UNLOCK(tt);
 	pntr++;
diff --git a/src/volser/volser.p.h b/src/volser/volser.p.h
index 6d7f129ec..79c331e0e 100644
--- a/src/volser/volser.p.h
+++ b/src/volser/volser.p.h
@@ -15,6 +15,7 @@
 #endif
 
 #include <afs/voldefs.h>
+#include <ubik.h>
 
 /* vflags, representing state of the volume */
 #define	VTDeleteOnSalvage	1	/* delete on next salvage */
@@ -183,8 +184,7 @@ extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, a
 extern int vsu_ExtractName(char rname[], char name[]);
 extern afs_int32 vsu_ClientInit(const char *confDir, char *cellName,
 				int secFlags,
-				int (*secproc)(struct rx_securityClass *,
-					       afs_int32),
+				ugen_secproc_func secproc,
 				struct ubik_client **uclientp);
 enum vol_s2s_crypt {
     VS2SC_NEVER = 0,
diff --git a/src/volser/voltrans.c b/src/volser/voltrans.c
index 18811b1b1..7a7af3e3d 100644
--- a/src/volser/voltrans.c
+++ b/src/volser/voltrans.c
@@ -180,16 +180,13 @@ GCTrans(void)
 
     VTRANS_LOCK;
     for (tt = allTrans; tt; tt = nt) {
-	nt = tt->next;		/* remember in case we zap it */
 	if (tt->time + OLDTRANSWARN < now) {
 	    Log("trans %u on volume %" AFS_VOLID_FMT " %s than %d seconds\n", tt->tid,
 		afs_printable_VolumeId_lu(tt->volid),
 		((tt->refCount > 0) ? "is older" : "has been idle for more"),
 		(((now - tt->time) / GCWAKEUP) * GCWAKEUP));
 	}
-	if (tt->refCount > 0)
-	    continue;
-	if (tt->time + OLDTRANSTIME < now) {
+	if ((tt->refCount <= 0) && (tt->time + OLDTRANSTIME < now)) {
 	    Log("trans %u on volume %" AFS_VOLID_FMT " has timed out\n", tt->tid, afs_printable_VolumeId_lu(tt->volid));
 
 	    tt->refCount++;	/* we're using it now */
@@ -208,12 +205,27 @@ GCTrans(void)
 
 		VTRANS_UNLOCK;
 		VPurgeVolume(&error, tt->volume);
+		/*
+		 * While the lock was dropped, tt->next may have changed.
+		 * Therefore, defer reading tt->next until _after_ we regain the lock.
+		 */
 		VTRANS_LOCK;
 	    }
-
-	    DeleteTrans(tt, 0);	/* drops refCount or deletes it */
+	    nt = tt->next;
+	    /*
+	     * DeleteTrans() will decrement tt->refCount; if it falls to 0, it will
+	     * also delete tt itself.  Therefore, we must read tt->next _before_
+	     * calling DeleteTrans().
+	     */
+	    DeleteTrans(tt, 0);
 	    GCDeletes++;
+	    continue;
 	}
+	/*
+	 * This path never dropped VTRANS_LOCK or modified the allTrans list.
+	 * Therefore, no special care is required to determine the next trans in the chain.
+	 */
+	nt = tt->next;
     }
     VTRANS_UNLOCK;
     return 0;
diff --git a/src/volser/vos.c b/src/volser/vos.c
index 6d4dbc68f..be487b200 100644
--- a/src/volser/vos.c
+++ b/src/volser/vos.c
@@ -80,6 +80,7 @@ enum {
     COMMONPARM_OFFSET_ENCRYPT   = 29,
     COMMONPARM_OFFSET_NORESOLVE = 30,
     COMMONPARM_OFFSET_CONFIG    = 31,
+    COMMONPARM_OFFSET_RXGK      = 32,
 };
 
 #define COMMONPARMS \
@@ -98,6 +99,8 @@ cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_NORESOLVE, \
     "-noresolve", CMD_FLAG, CMD_OPTIONAL, "don't resolve addresses"); \
 cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_CONFIG, \
     "-config", CMD_SINGLE, CMD_OPTIONAL, "config location"); \
+cmd_AddParmAtOffset(ts, COMMONPARM_OFFSET_RXGK, \
+    "-rxgk", CMD_SINGLE, CMD_OPTIONAL, "rxgk security level to use"); \
 
 #define ERROR_EXIT(code) do { \
     error = (code); \
@@ -2068,32 +2071,6 @@ CreateVolume(struct cmd_syndesc *as, void *arock)
     return 0;
 }
 
-#if 0
-static afs_int32
-DeleteAll(struct nvldbentry *entry)
-{
-    int i;
-    afs_int32 error, code, curserver, curpart;
-    afs_uint32 volid;
-
-    MapHostToNetwork(entry);
-    error = 0;
-    for (i = 0; i < entry->nServers; i++) {
-	curserver = entry->serverNumber[i];
-	curpart = entry->serverPartition[i];
-	if (entry->serverFlags[i] & VLSF_ROVOL) {
-	    volid = entry->volumeId[ROVOL];
-	} else {
-	    volid = entry->volumeId[RWVOL];
-	}
-	code = UV_DeleteVolume(curserver, curpart, volid);
-	if (code && !error)
-	    error = code;
-    }
-    return error;
-}
-#endif
-
 static int
 DeleteVolume(struct cmd_syndesc *as, void *arock)
 {
@@ -2752,18 +2729,6 @@ CloneVolume(struct cmd_syndesc *as, void *arock)
 		volname, VOLSER_OLDMAXVOLNAME - 1);
 	    return E2BIG;
 	}
-#if 0
-	/*
-	 * In order that you be able to make clones of RO or BK, this
-	 * check must be omitted.
-	 */
-	if (!VolNameOK(volname)) {
-	    fprintf(STDERR,
-		"Illegal volume name %s, should not end in .readonly or .backup\n",
-		volname);
-	    return EINVAL;
-	}
-#endif
 	if (IsNumeric(volname)) {
 	    fprintf(STDERR,
 		"Illegal volume name %s, should not be a number\n",
@@ -4130,33 +4095,32 @@ VolserStatus(struct cmd_syndesc *as, void *arock)
 	}
 	if (pntr->iflags) {
 	    fprintf(STDOUT, "attachFlags:  ");
-	    switch (pntr->iflags) {
-	    case ITOffline:
+	    if ((pntr->iflags & ITOffline) != 0) {
 		fprintf(STDOUT, "offline ");
-		break;
-	    case ITBusy:
+	    }
+	    if ((pntr->iflags & ITBusy) != 0) {
 		fprintf(STDOUT, "busy ");
-		break;
-	    case ITReadOnly:
+	    }
+	    if ((pntr->iflags & ITReadOnly) != 0) {
 		fprintf(STDOUT, "readonly ");
-		break;
-	    case ITCreate:
+	    }
+	    if ((pntr->iflags & ITCreate) != 0) {
 		fprintf(STDOUT, "create ");
-		break;
-	    case ITCreateVolID:
+	    }
+	    if ((pntr->iflags & ITCreateVolID) != 0) {
 		fprintf(STDOUT, "create volid ");
-		break;
 	    }
 	    fprintf(STDOUT, "\n");
 	}
 	if (pntr->vflags) {
 	    fprintf(STDOUT, "volumeStatus: ");
-	    switch (pntr->vflags) {
-	    case VTDeleteOnSalvage:
+	    if ((pntr->vflags & VTDeleteOnSalvage) != 0) {
 		fprintf(STDOUT, "deleteOnSalvage ");
-	    case VTOutOfService:
+	    }
+	    if ((pntr->vflags & VTOutOfService) != 0) {
 		fprintf(STDOUT, "outOfService ");
-	    case VTDeleted:
+	    }
+	    if ((pntr->vflags & VTDeleted) != 0) {
 		fprintf(STDOUT, "deleted ");
 	    }
 	    fprintf(STDOUT, "\n");
@@ -4188,25 +4152,39 @@ VolserStatus(struct cmd_syndesc *as, void *arock)
 static int
 RenameVolume(struct cmd_syndesc *as, void *arock)
 {
-    afs_int32 code1, code2, code;
+    afs_int32 code;
     struct nvldbentry entry;
+    struct nvldbentry entry2;
 
-    code1 = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
-    if (code1) {
+    /* Get the entry of the volume to be renamed (-oldname), by name or id. */
+    code = VLDB_GetEntryByName(as->parms[0].items->data, &entry);
+    if (code) {
 	fprintf(STDERR, "vos: Could not find entry for volume %s\n",
 		as->parms[0].items->data);
+	PrintError("", code);
 	exit(1);
     }
-    code2 = VLDB_GetEntryByName(as->parms[1].items->data, &entry);
-    if ((!code1) && (!code2)) {	/*the newname already exists */
-	fprintf(STDERR, "vos: volume %s already exists\n",
+
+    /*
+     * Verify the new name is available before attempting to rename.
+     * Allow renaming of the same volume in order to complete a
+     * previously interrupted rename.
+     */
+    code = VLDB_GetEntryByName(as->parms[1].items->data, &entry2);
+    if (code != 0 && code != VL_NOENT) {
+	fprintf(STDERR, "vos: Could not check entry for volume %s\n",
 		as->parms[1].items->data);
+	PrintError("", code);
 	exit(1);
     }
-
-    if (code1 && code2) {
-	fprintf(STDERR, "vos: Could not find entry for volume %s or %s\n",
-		as->parms[0].items->data, as->parms[1].items->data);
+    if (code == 0 && entry.volumeId[RWVOL] != entry2.volumeId[RWVOL]) {
+	fprintf(STDERR, "vos: Cannot rename volume %s (%lu) to %s;"
+			" volume %s (%lu) already exists\n",
+			as->parms[0].items->data,
+			(unsigned long)entry.volumeId[RWVOL],
+			as->parms[1].items->data,
+			as->parms[1].items->data,
+			(unsigned long)entry2.volumeId[RWVOL]);
 	exit(1);
     }
     if (!VolNameOK(as->parms[0].items->data)) {
@@ -5296,12 +5274,11 @@ ChangeAddr(struct cmd_syndesc *as, void *arock)
 	afs_int32 m_uniq = 0;
 	afsUUID m_uuid;
 	ListAddrByAttributes m_attrs;
-	char buffer[128];
+	struct uuid_fmtbuf buffer;
 
 	memset(&m_attrs, 0, sizeof(m_attrs));
 	memset(&m_uuid, 0, sizeof(m_uuid));
 	memset(&m_addrs, 0, sizeof(m_addrs));
-	memset(buffer, 0, sizeof(buffer));
 
 	m_attrs.Mask = VLADDR_IPADDR;
 	m_attrs.ipaddr = ntohl(ip1);	/* -oldaddr */
@@ -5312,9 +5289,10 @@ ChangeAddr(struct cmd_syndesc *as, void *arock)
 	xdr_free((xdrproc_t) xdr_bulkaddrs, &m_addrs);
 	switch (vcode) {
 	case 0:		/* mh entry detected */
-	    afsUUID_to_string(&m_uuid, buffer, sizeof(buffer) - 1);
+	    afsUUID_to_string(&m_uuid, &buffer);
 	    fprintf(STDERR, "vos: Refusing to change address in multi-homed server entry.\n");
-	    fprintf(STDERR, "     -oldaddr address is registered to file server UUID %s\n", buffer);
+	    fprintf(STDERR, "     -oldaddr address is registered to file server UUID %s\n",
+			    buffer.buffer);
 	    fprintf(STDERR, "     Please restart the file server or use vos setaddrs.\n");
 	    return EINVAL;
 	case VL_NOENT:
@@ -5363,11 +5341,11 @@ print_addrs(const bulkaddrs * addrs, afsUUID * m_uuid, int nentries,
 {
     int i;
     afs_uint32 addr;
-    char buf[1024];
+    struct uuid_fmtbuf buf;
 
     if (print) {
-	afsUUID_to_string(m_uuid, buf, sizeof(buf));
-	printf("UUID: %s\n", buf);
+	afsUUID_to_string(m_uuid, &buf);
+	printf("UUID: %s\n", buf.buffer);
     }
 
     /* print out the list of all the server */
@@ -5930,6 +5908,7 @@ static int
 MyBeforeProc(struct cmd_syndesc *as, void *arock)
 {
     char *tcell;
+    char *rxgk_seclevel_str = NULL;
     afs_int32 code;
     int secFlags;
 
@@ -5960,6 +5939,23 @@ MyBeforeProc(struct cmd_syndesc *as, void *arock)
     if (as->parms[COMMONPARM_OFFSET_CONFIG].items)   /* -config flag set */
 	confdir = as->parms[COMMONPARM_OFFSET_CONFIG].items->data;
 
+    if (cmd_OptionAsString(as, COMMONPARM_OFFSET_RXGK, &rxgk_seclevel_str) == 0) {
+	if (strcmp(rxgk_seclevel_str, "clear") == 0)
+	    secFlags |= AFSCONF_SECOPTS_ALWAYSCLEAR;
+	else if (strcmp(rxgk_seclevel_str, "auth") == 0)
+	    secFlags |= AFSCONF_SECOPTS_NEVERENCRYPT;
+	else if (strcmp(rxgk_seclevel_str, "crypt") == 0) {
+	    /* don't need to set any flags; this is the default for rxgk */
+	} else {
+	    fprintf(STDERR, "Invalid argument to -rxgk: %s\n", rxgk_seclevel_str);
+	    exit(1);
+	}
+	secFlags |= AFSCONF_SECOPTS_RXGK;
+
+	free(rxgk_seclevel_str);
+	rxgk_seclevel_str = NULL;
+    }
+
     if ((code = vsu_ClientInit(confdir, tcell, secFlags, UV_SetSecurity,
 			       &cstruct))) {
 	fprintf(STDERR, "could not initialize VLDB library (code=%lu) \n",
@@ -6023,9 +6019,6 @@ main(int argc, char **argv)
 		"initial quota (KB)");
     cmd_AddParm(ts, "-id", CMD_SINGLE, CMD_OPTIONAL, "volume ID");
     cmd_AddParm(ts, "-roid", CMD_SINGLE, CMD_OPTIONAL, "readonly volume ID");
-#ifdef notdef
-    cmd_AddParm(ts, "-minquota", CMD_SINGLE, CMD_OPTIONAL, "");
-#endif
     COMMONPARMS;
 
     ts = cmd_CreateSyntax("remove", DeleteVolume, NULL, 0, "delete a volume");
diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c
index cd0e6b389..ffbabddd4 100644
--- a/src/volser/vsprocs.c
+++ b/src/volser/vsprocs.c
@@ -159,11 +159,6 @@ do { \
 
 
 /* Protos for static routines */
-#if 0
-static afs_int32 CheckAndDeleteVolume(struct rx_connection *aconn,
-				      afs_int32 apart, afs_uint32 okvol,
-				      afs_uint32 delvol);
-#endif
 static int GetTrans(struct nvldbentry *vldbEntryPtr, afs_int32 index,
 		    struct rx_connection **connPtr, afs_int32 * transPtr,
 		    afs_uint32 * crtimePtr, afs_uint32 * uptimePtr,
@@ -485,57 +480,6 @@ AFSVolTransCreate_retry(struct rx_connection *z_conn,
     return code;
 }
 
-#if 0
-/* if <okvol> is allright(indicated by beibg able to
- * start a transaction, delete the <delvol> */
-static afs_int32
-CheckAndDeleteVolume(struct rx_connection *aconn, afs_int32 apart,
-		     afs_uint32 okvol, afs_uint32 delvol)
-{
-    afs_int32 error, code, tid, rcode;
-    error = 0;
-    code = 0;
-
-    if (okvol == 0) {
-	code = AFSVolTransCreate_retry(aconn, delvol, apart, ITOffline, &tid);
-	if (!error && code)
-	    error = code;
-	code = AFSVolDeleteVolume(aconn, tid);
-	if (!error && code)
-	    error = code;
-	code = AFSVolEndTrans(aconn, tid, &rcode);
-	if (!code)
-	    code = rcode;
-	if (!error && code)
-	    error = code;
-	return error;
-    } else {
-	code = AFSVolTransCreate_retry(aconn, okvol, apart, ITOffline, &tid);
-	if (!code) {
-	    code = AFSVolEndTrans(aconn, tid, &rcode);
-	    if (!code)
-		code = rcode;
-	    if (!error && code)
-		error = code;
-	    code = AFSVolTransCreate_retry(aconn, delvol, apart, ITOffline, &tid);
-	    if (!error && code)
-		error = code;
-	    code = AFSVolDeleteVolume(aconn, tid);
-	    if (!error && code)
-		error = code;
-	    code = AFSVolEndTrans(aconn, tid, &rcode);
-	    if (!code)
-		code = rcode;
-	    if (!error && code)
-		error = code;
-	} else
-	    error = code;
-	return error;
-    }
-}
-
-#endif
-
 /* called by EmuerateEntry, show vldb entry in a reasonable format */
 void
 SubEnumerateEntry(struct nvldbentry *entry)
@@ -545,25 +489,6 @@ SubEnumerateEntry(struct nvldbentry *entry)
     int isMixed = 0;
     char hoststr[16];
 
-#ifdef notdef
-    fprintf(STDOUT, "	readWriteID %-10u ", entry->volumeId[RWVOL]);
-    if (entry->flags & VLF_RWEXISTS)
-	fprintf(STDOUT, " valid \n");
-    else
-	fprintf(STDOUT, " invalid \n");
-    fprintf(STDOUT, "	readOnlyID  %-10u ", entry->volumeId[ROVOL]);
-    if (entry->flags & VLF_ROEXISTS)
-	fprintf(STDOUT, " valid \n");
-    else
-	fprintf(STDOUT, " invalid \n");
-    fprintf(STDOUT, "	backUpID    %-10u ", entry->volumeId[BACKVOL]);
-    if (entry->flags & VLF_BACKEXISTS)
-	fprintf(STDOUT, " valid \n");
-    else
-	fprintf(STDOUT, " invalid \n");
-    if ((entry->cloneId != 0) && (entry->flags & VLF_ROEXISTS))
-	fprintf(STDOUT, "    releaseClone %-10u \n", entry->cloneId);
-#else
     if (entry->flags & VLF_RWEXISTS)
 	fprintf(STDOUT, "    RWrite: %-10u", entry->volumeId[RWVOL]);
     if (entry->flags & VLF_ROEXISTS)
@@ -573,7 +498,6 @@ SubEnumerateEntry(struct nvldbentry *entry)
     if ((entry->cloneId != 0) && (entry->flags & VLF_ROEXISTS))
 	fprintf(STDOUT, "    RClone: %-10lu", (unsigned long)entry->cloneId);
     fprintf(STDOUT, "\n");
-#endif
     fprintf(STDOUT, "    number of sites -> %lu\n",
 	    (unsigned long)entry->nServers);
     for (i = 0; i < entry->nServers; i++) {
@@ -868,13 +792,8 @@ UV_AddVLDBEntry(afs_uint32 aserver, afs_int32 apart, char *aname,
     entry.flags = VLF_RWEXISTS;	/* this records that rw volume exists */
     entry.serverFlags[0] = VLSF_RWVOL;	/*this rep site has rw  vol */
     entry.volumeId[RWVOL] = aid;
-#ifdef notdef
-    entry.volumeId[ROVOL] = anewid + 1;	/* rw,ro, bk id are related in the default case */
-    entry.volumeId[BACKVOL] = *anewid + 2;
-#else
     entry.volumeId[ROVOL] = 0;
     entry.volumeId[BACKVOL] = 0;
-#endif
     entry.cloneId = 0;
     /*map into right byte order, before passing to xdr, the stuff has to be in host
      * byte order. Xdr converts it into network order */
@@ -1570,8 +1489,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
 	fflush(STDOUT);
 	if (fscanf(stdin, "%c", &in) < 1)
 	    in = 0;
-	if (fscanf(stdin, "%c", &lf) < 0)	/* toss away */
-	    ; /* don't care */
+	if (fscanf(stdin, "%c", &lf) < 0) {
+	    /* toss away; don't care */
+	}
 	if (in == 'y') {
 	    fprintf(STDOUT, "type control-c\n");
 	    while (1) {
@@ -1928,8 +1848,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
 	fflush(STDOUT);
 	if (fscanf(stdin, "%c", &in) < 1)
 	    in = 0;
-	if (fscanf(stdin, "%c", &lf) < 0)	/* toss away */
-	    ; /* don't care */
+	if (fscanf(stdin, "%c", &lf) < 0) {
+ 	    /* toss away, don't care */
+	}
 	if (in == 'y') {
 	    fprintf(STDOUT, "type control-c\n");
 	    while (1) {
@@ -1963,8 +1884,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
 	fflush(STDOUT);
 	if (fscanf(stdin, "%c", &in) < 1)
 	    in = 0;
-	if (fscanf(stdin, "%c", &lf) < 0)	/* toss away */
-	    ; /* don't care */
+	if (fscanf(stdin, "%c", &lf) < 0) {
+	    /* toss away; don't care */
+	}
 	if (in == 'y') {
 	    fprintf(STDOUT, "type control-c\n");
 	    while (1) {
@@ -1975,21 +1897,6 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
 	}
 	/* or drop through */
     }
-#ifdef notdef
-    /* This is tricky.  File server is very stupid, and if you mark the volume
-     * as VTOutOfService, it may mark the *good* instance (if you're moving
-     * between partitions on the same machine) as out of service.  Since
-     * we're cleaning this code up in DEcorum, we're just going to kludge around
-     * it for now by removing this call. */
-    /* already out of service, just zap it now */
-    code =
-	AFSVolSetFlags(fromconn, fromtid, VTDeleteOnSalvage | VTOutOfService);
-    if (code) {
-	fprintf(STDERR,
-		"Failed to set the flags to make the old source volume offline\n");
-	goto mfail;
-    }
-#endif
     if (atoserver != afromserver) {
 	/* set forwarding pointer for moved volumes */
 	VPRINT1("Setting forwarding pointer for volume %u ...", afromvol);
@@ -2030,13 +1937,12 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
     if (!(flags & RV_NOCLONE)) {
 	code = DoVolDelete(fromconn, newVol, afrompart,
 			   "cloned", 0, NULL, NULL);
-	if (code) {
-	    if (code == VNOVOL) {
-		EPRINT1(code, "Failed to start transaction on %u\n", newVol);
-	    }
+	if (code && code != VNOVOL) {
 	    error = code;
 	    goto mfail;
 	}
+
+	code = 0;	/* clone missing? that's okay */
     }
 
     /* fall through */
@@ -2048,8 +1954,9 @@ UV_MoveVolume2(afs_uint32 afromvol, afs_uint32 afromserver, afs_int32 afrompart,
 	fflush(STDOUT);
 	if (fscanf(stdin, "%c", &in) < 1)
 	    in = 0;
-	if (fscanf(stdin, "%c", &lf) < 0)	/* toss away */
-	    ; /* don't care */
+	if (fscanf(stdin, "%c", &lf) < 0) {	/* toss away */
+	    /* don't care */
+	}
 	if (in == 'y') {
 	    fprintf(STDOUT, "type control-c\n");
 	    while (1) {
@@ -2641,13 +2548,12 @@ cpincr:
     if (!(flags & RV_NOCLONE)) {
 	code = DoVolDelete(fromconn, cloneVol, afrompart,
 			   "cloned", 0, NULL, NULL);
-	if (code) {
-	    if (code == VNOVOL) {
-		EPRINT1(code, "Failed to start transaction on %u\n", cloneVol);
-	    }
+	if (code && code != VNOVOL) {
 	    error = code;
 	    goto mfail;
 	}
+
+	code = 0;		/* clone missing? that's ok */
     }
 
     if (!(flags & RV_NOVLDB)) {
@@ -2771,11 +2677,8 @@ cpincr:
 
     /* common cleanup - delete local clone */
     if (cloneVol) {
-	code = DoVolDelete(fromconn, cloneVol, afrompart,
-		           "clone", 0, NULL, "Recovery:");
-	if (code == VNOVOL) {
-	    EPRINT1(code, "Recovery: Failed to start transaction on %u\n", cloneVol);
-	}
+	DoVolDelete(fromconn, cloneVol, afrompart, "clone", 0, NULL,
+		    "Recovery:");
     }
 
   done:			/* routine cleanup */
@@ -4215,7 +4118,8 @@ UV_ReleaseVolume(afs_uint32 afromvol, afs_uint32 afromserver,
 	}
 	code = DoVolDelete(fromconn, cloneVolId, afrompart, NULL, 0, NULL,
 			   NULL);
-	ONERROR(code, cloneVolId, "Failed to delete volume %u.\n");
+	if (code && code != VNOVOL)
+	    ONERROR(code, cloneVolId, "Failed to delete volume %u.\n");
 	VDONE;
     }
 
@@ -4677,41 +4581,40 @@ UV_RestoreVolume2(afs_uint32 toserver, afs_int32 topart, afs_uint32 tovolid,
             noresolve ? afs_inet_ntoa_r(toserver, hoststr) :
 	    hostutil_GetNameByINet(toserver), partName);
     fflush(STDOUT);
-    code =
-	AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid, &pvolid,
-			   &totid);
-    if (code) {
-	if (flags & RV_FULLRST) {	/* full restore: delete then create anew */
-	    code = DoVolDelete(toconn, pvolid, topart, "the previous", 0,
-			       &tstatus, NULL);
-	    if (code && code != VNOVOL) {
-		error = code;
-		goto refail;
-	    }
 
-	    code =
-		AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid,
-				   &pvolid, &totid);
+    /*
+     * Obtain a transaction and get the status of the target volume. Create a new
+     * volume if the target volume does not already exist.
+     */
+    memset(&tstatus, 0, sizeof(tstatus));
+    if ((flags & RV_FULLRST) != 0) {
+	/* Full restore: Delete existing volume then create anew. */
+	code = DoVolDelete(toconn, pvolid, topart, "the previous", 0, &tstatus, NULL);
+	if (code && code != VNOVOL) {
+	    error = code;
+	    goto refail;
+	}
+	code = AFSVolCreateVolume(toconn, topart, tovolreal, volsertype, pparentid,
+			          &pvolid, &totid);
+	EGOTO1(refail, code, "Could not create new volume %u\n", pvolid);
+    } else {
+	/* Incremental restore: Obtain a transaction on the existing volume. */
+	code = AFSVolTransCreate_retry(toconn, pvolid, topart, ITOffline, &totid);
+	if (code == 0) {
+	    code = AFSVolGetStatus(toconn, totid, &tstatus);
+	    EGOTO1(refail, code, "Could not get timestamp from volume %u\n", pvolid);
+	} else if (code == VNOVOL) {
+	    code = AFSVolCreateVolume(toconn, topart, tovolreal, volsertype,
+				      pparentid, &pvolid, &totid);
 	    EGOTO1(refail, code, "Could not create new volume %u\n", pvolid);
 	} else {
-	    code =
-		AFSVolTransCreate_retry(toconn, pvolid, topart, ITOffline, &totid);
-	    EGOTO1(refail, code, "Failed to start transaction on %u\n",
-		   pvolid);
-
-	    code = AFSVolGetStatus(toconn, totid, &tstatus);
-	    EGOTO1(refail, code, "Could not get timestamp from volume %u\n",
-		   pvolid);
-
+	    EGOTO1(refail, code, "Failed to start transaction on %u\n", pvolid);
 	}
-	oldCreateDate = tstatus.creationDate;
-	oldUpdateDate = tstatus.updateDate;
-	oldCloneId = tstatus.cloneID;
-	oldBackupId = tstatus.backupID;
-    } else {
-	oldCreateDate = 0;
-	oldUpdateDate = 0;
     }
+    oldCreateDate = tstatus.creationDate;
+    oldUpdateDate = tstatus.updateDate;
+    oldCloneId = tstatus.cloneID;
+    oldBackupId = tstatus.backupID;
 
     cookie.parent = pparentid;
     cookie.type = voltype;
@@ -5248,7 +5151,8 @@ UV_RemoveSite(afs_uint32 server, afs_int32 part, afs_uint32 volid)
 		      LOCKREL_OPCODE | LOCKREL_AFSID | LOCKREL_TIMESTAMP);
 	    return (vcode);
 	}
-	VDONE;
+	fprintf(STDOUT, " done\n");
+	fflush(STDOUT);
     }
     return 0;
 }
@@ -5508,7 +5412,6 @@ UV_ListVolumes(afs_uint32 aserver, afs_int32 apart, int all,
     afs_int32 code = 0;
     volEntries volumeInfo;
 
-    code = 0;
     *size = 0;
     *resultPtr = (volintInfo *) 0;
     volumeInfo.volEntries_val = (volintInfo *) 0;	/*this hints the stub to allocate space */
@@ -7070,7 +6973,39 @@ UV_RenameVolume(struct nvldbentry *entry, char oldname[], char newname[])
 	goto rvfail;
     }
     islocked = 1;
+
+    /*
+     * Match the flags we just set via SetLock,
+     * so we don't invalidate our compare below.
+     */
+    entry->flags &= ~VLOP_ALLOPERS;
+    entry->flags |= VLOP_ADDSITE;
+
+    /*
+     * Now get the entry again (under lock) and
+     * verify the volume hasn't otherwise changed.
+     */
+    vcode = VLDB_GetEntryByID(entry->volumeId[RWVOL], RWVOL, &storeEntry);
+    if (vcode) {
+	fprintf(STDERR,
+		"Could not obtain the VLDB entry for the volume %u\n",
+		entry->volumeId[RWVOL]);
+	error = vcode;
+	goto rvfail;
+    }
+    /* Convert to net order to match entry, which was passed in net order. */
+    MapHostToNetwork(&storeEntry);
+    if (memcmp(entry, &storeEntry, sizeof(*entry)) != 0) {
+	fprintf(STDERR,
+		"VLDB entry for volume %u has changed; "
+		"please reissue the command.\n",
+		entry->volumeId[RWVOL]);
+	error = VL_BADENTRY;	/* an arbitrary choice, but closest to the truth */
+	goto rvfail;
+    }
+
     strncpy(entry->name, newname, VOLSER_OLDMAXVOLNAME);
+    /* Note that we are reusing storeEntry. */
     MapNetworkToHost(entry, &storeEntry);
     vcode = VLDB_ReplaceEntry(entry->volumeId[RWVOL], RWVOL, &storeEntry, 0);
     if (vcode) {
diff --git a/src/volser/vsutils.c b/src/volser/vsutils.c
index 51b24651b..642d273e7 100644
--- a/src/volser/vsutils.c
+++ b/src/volser/vsutils.c
@@ -136,6 +136,7 @@ VLDB_GetEntryByID(afs_uint32 volid, afs_int32 voltype, struct nvldbentry *entryp
 	    ovlentry_to_nvlentry(&oentry, entryp);
 	return code;
     }
+    memset(entryp, 0, sizeof(*entryp));	    /* ensure padding is cleared */
     code = ubik_VL_GetEntryByIDN(cstruct, 0, volid, voltype, entryp);
     if (newvlserver == vltype_unknown) {
 	if (code == RXGEN_OPCODE) {
@@ -161,6 +162,7 @@ VLDB_GetEntryByName(char *namep, struct nvldbentry *entryp)
 	    ovlentry_to_nvlentry(&oentry, entryp);
 	return code;
     }
+    memset(entryp, 0, sizeof(*entryp));	    /* ensure padding is cleared */
     code = ubik_VL_GetEntryByNameN(cstruct, 0, namep, entryp);
     if (newvlserver == vltype_unknown) {
 	if (code == RXGEN_OPCODE) {
@@ -396,7 +398,7 @@ VLDB_IsSameAddrs(afs_uint32 serv1, afs_uint32 serv2, afs_int32 *errorp)
 */
 int
 vsu_ClientInit(const char *confDir, char *cellName, int secFlags,
-	       int (*secproc)(struct rx_securityClass *, afs_int32),
+	       ugen_secproc_func secproc,
 	       struct ubik_client **uclientp)
 {
     return ugen_ClientInitFlags(confDir, cellName, secFlags, uclientp,
diff --git a/src/xstat/.gitignore b/src/xstat/.gitignore
index 9688fc37b..be40652e3 100644
--- a/src/xstat/.gitignore
+++ b/src/xstat/.gitignore
@@ -2,5 +2,7 @@
 #     git ls-files -i --exclude-standard
 # to check that you haven't inadvertently ignored any tracked files.
 
+/afscbint.h
+/afscbint.ss.c
 /xstat_cm_test
 /xstat_fs_test
diff --git a/src/xstat/Makefile.in b/src/xstat/Makefile.in
index fcd0a426a..596807b75 100644
--- a/src/xstat/Makefile.in
+++ b/src/xstat/Makefile.in
@@ -10,21 +10,19 @@
 
 srcdir=@srcdir@
 include @TOP_OBJDIR@/src/config/Makefile.config
-include @TOP_OBJDIR@/src/config/Makefile.lwp
+include @TOP_OBJDIR@/src/config/Makefile.pthread
+include @TOP_OBJDIR@/src/config/Makefile.libtool
 
-
-RPCINCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/rx/rx.h
-
-LIBS=${TOP_LIBDIR}/libafsint.a \
-	${TOP_LIBDIR}/libcmd.a \
-	${TOP_LIBDIR}/librx.a \
-	${TOP_LIBDIR}/libafshcrypto_lwp.a \
-	${TOP_LIBDIR}/liblwp.a \
-	${TOP_LIBDIR}/libsys.a \
-	${TOP_LIBDIR}/libopr.a \
-	${TOP_LIBDIR}/util.a
+LT_deps = \
+	$(top_builddir)/src/rxkad/liboafs_rxkad.la \
+	$(top_builddir)/src/fsint/liboafs_fsint.la \
+	$(top_builddir)/src/cmd/liboafs_cmd.la \
+	$(top_builddir)/src/util/liboafs_util.la \
+	$(top_builddir)/src/opr/liboafs_opr.la
 
 all: \
+	liboafs_xstat_fs.la \
+	liboafs_xstat_cm.la \
 	${TOP_INCDIR}/afs/xstat_fs.h \
 	${TOP_INCDIR}/afs/xstat_cm.h \
 	${TOP_LIBDIR}/libxstat_fs.a \
@@ -47,40 +45,61 @@ ${TOP_LIBDIR}/libxstat_cm.a: libxstat_cm.a
 #
 # File Server data collection
 #
-FSINCLS=xstat_fs.h ${RPCINCLS}
+FSINCLS = \
+    xstat_fs.h \
+    ${TOP_INCDIR}/rx/rx.h
 
-libxstat_fs.a: xstat_fs.o xstat_fs_callback.o AFS_component_version_number.o
-	-$(RM) -f $@
-	$(AR) crv $@ xstat_fs.o xstat_fs_callback.o AFS_component_version_number.o
-	$(RANLIB) $@
+LT_objs_fs = \
+    xstat_fs.lo \
+    xstat_fs_callback.lo \
+    afscbint.ss.lo \
+    AFS_component_version_number.lo
 
-xstat_fs.o: xstat_fs.c ${FSINCLS}
+liboafs_xstat_fs.la: liboafs_xstat_fs.la.sym $(LT_objs_fs) $(LT_deps)
+	$(LT_LDLIB_shlib) $(LT_objs_fs) $(LT_deps) $(LT_libs)
 
-xstat_fs_callback.o: xstat_fs_callback.c ${FSINCLS}
+libxstat_fs.a: $(LT_objs_fs)
+	$(LT_LDLIB_static) $(LT_objs_fs)
 
-xstat_fs_test.o: xstat_fs_test.c ${FSINCLS} AFS_component_version_number.c
+# afscbint.ss.c is required for RXAFSCB_ExecuteRequest.
+afscbint.h: $(top_builddir)/src/fsint/afscbint.h
+	${INSTALL_DATA} $? $@
 
-xstat_fs_test: xstat_fs_test.o libxstat_fs.a ${LIBS}
-	$(AFS_LDRULE) xstat_fs_test.o libxstat_fs.a \
-		${LIBS} $(LIB_roken) ${XLIBS}
+afscbint.ss.c: $(top_builddir)/src/fsint/afscbint.ss.c
+	${INSTALL_DATA} $? $@
+
+xstat_fs.lo: xstat_fs.c ${FSINCLS}
+xstat_fs_callback.lo: xstat_fs_callback.c ${FSINCLS}
+xstat_fs_test.lo: xstat_fs_test.c ${FSINCLS} AFS_component_version_number.c
+afscbint.ss.lo: afscbint.ss.c afscbint.h
+
+xstat_fs_test: xstat_fs_test.o liboafs_xstat_fs.la $(LT_deps)
+	$(LT_LDRULE_static) xstat_fs_test.o liboafs_xstat_fs.la \
+		$(LT_deps) $(LIB_roken) ${XLIBS}
 
 #
 # Cache Manager data collection
 #
-CMINCLS=xstat_cm.h ${RPCINCLS}
+CMINCLS = \
+    xstat_cm.h \
+    ${TOP_INCDIR}/rx/rx.h
+
+LT_objs_cm = \
+    xstat_cm.lo \
+    AFS_component_version_number.lo
 
-libxstat_cm.a: xstat_cm.o AFS_component_version_number.o
-	-$(RM) -f libxstat_cm.a
-	$(AR) crv libxstat_cm.a xstat_cm.o AFS_component_version_number.o
-	$(RANLIB) libxstat_cm.a
+liboafs_xstat_cm.la: liboafs_xstat_cm.la.sym $(LT_objs_cm) $(LT_deps)
+	$(LT_LDLIB_shlib) $(LT_objs_cm) $(LT_deps) $(LT_libs)
 
-xstat_cm.o: xstat_cm.c ${CMINCLS}
+libxstat_cm.a: $(LT_objs_cm)
+	$(LT_LDLIB_static) $(LT_objs_cm)
 
+xstat_cm.lo: xstat_cm.c ${CMINCLS}
 xstat_cm_test.o: xstat_cm_test.c ${CMINCLS} AFS_component_version_number.c
 
-xstat_cm_test: xstat_cm_test.o libxstat_cm.a ${LIBS}
-	$(AFS_LDRULE) xstat_cm_test.o libxstat_cm.a \
-		${LIBS} $(LIB_roken) ${XLIBS}
+xstat_cm_test: xstat_cm_test.o liboafs_xstat_cm.la $(LT_deps)
+	$(LT_LDRULE_static) xstat_cm_test.o liboafs_xstat_cm.la \
+		$(LT_deps) $(LIB_roken) ${XLIBS}
 
 #
 # Installation targets
@@ -113,6 +132,8 @@ dest: xstat_fs.h xstat_cm.h libxstat_fs.a libxstat_cm.a xstat_fs_test \
 # Misc targets
 #
 clean:
-	$(RM) -f *.o *.a xstat_fs_test xstat_cm_test core AFS_component_version_number.c
+	$(LT_CLEAN)
+	$(RM) -f *.o *.a afscbint.ss.c afscbint.h xstat_fs_test xstat_cm_test \
+              core AFS_component_version_number.c
 
 include ../config/Makefile.version
diff --git a/src/xstat/NTMakefile b/src/xstat/NTMakefile
index a0c4cd523..444e9ea7c 100644
--- a/src/xstat/NTMakefile
+++ b/src/xstat/NTMakefile
@@ -16,21 +16,21 @@ LIBDIR = $(DESTDIR)\lib
 INCDIR = $(DESTDIR)\include
 BINDIR = $(DESTDIR)\bin
 
-RPCINCLS=$(INCDIR)\lwp.h $(INCDIR)\rx\rx.h
+RPCINCLS=$(INCDIR)\rx\rx.h
 
 LIBS= \
-	$(LIBDIR)\afs\afsint.lib \
+	$(LIBDIR)\afs\mtafsint.lib \
 	$(LIBDIR)\afs\afscmd.lib \
-	$(LIBDIR)\afsrx.lib \
+	$(LIBDIR)\afsrpc.lib \
 	$(LIBDIR)\afshcrypto.lib \
-	$(LIBDIR)\afslwp.lib \
+	$(LIBDIR)\afspthread.lib \
 	$(LIBDIR)\afs\afspioctl.lib \
-	$(LIBDIR)\afs\afsutil.lib \
+	$(LIBDIR)\afs\afsprocmgmt.lib \
+	$(LIBDIR)\afs\mtafsutil.lib \
 	$(LIBDIR)\afs\afsreg.lib \
 	$(LIBDIR)\afsroken.lib \
 	$(LIBDIR)\opr.lib
 
-
 install: \
 	$(INCDIR)\afs\xstat_fs.h \
 	$(INCDIR)\afs\xstat_cm.h \
@@ -45,7 +45,7 @@ install: \
 FSINCLS= $(INCDIR)\xstat_fs.h $(RPCINCLS)
 
 {.}.c{$(OUT)}.obj:
-    $(C2OBJ) $<
+    $(C2OBJ) $< -DAFS_PTHREAD_ENV
 
 $(LIBDIR)\afs_xstat_fs.lib: $(OUT)\xstat_fs.obj $(OUT)\xstat_fs_callback.obj $(OUT)\AFS_component_version_number.obj
 	$(LIBARCH)
diff --git a/src/xstat/liboafs_xstat_cm.la.sym b/src/xstat/liboafs_xstat_cm.la.sym
new file mode 100644
index 000000000..00acbd817
--- /dev/null
+++ b/src/xstat/liboafs_xstat_cm.la.sym
@@ -0,0 +1,5 @@
+xstat_cm_Cleanup
+xstat_cm_ForceProbeNow
+xstat_cm_Init
+xstat_cm_Results
+xstat_cm_Wait
diff --git a/src/xstat/liboafs_xstat_fs.la.sym b/src/xstat/liboafs_xstat_fs.la.sym
new file mode 100644
index 000000000..8f5fef69e
--- /dev/null
+++ b/src/xstat/liboafs_xstat_fs.la.sym
@@ -0,0 +1,5 @@
+xstat_fs_Cleanup
+xstat_fs_DecodeFullPerfStats
+xstat_fs_ForceProbeNow
+xstat_fs_Init
+xstat_fs_Wait
diff --git a/src/xstat/xstat_cm.c b/src/xstat/xstat_cm.c
index d8600c124..a7d0a033f 100644
--- a/src/xstat/xstat_cm.c
+++ b/src/xstat/xstat_cm.c
@@ -18,23 +18,20 @@
 #include <afs/param.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #include "xstat_cm.h"		/*Interface for this module */
-#include <lwp.h>		/*Lightweight process package */
+#include <pthread.h>
 
 #include <afs/afsutil.h>
 
-#define LWP_STACK_SIZE	(16 * 1024)
-
 /*
  * Exported variables.
  */
 int xstat_cm_numServers;	/*Num connected servers */
 struct xstat_cm_ConnectionInfo
  *xstat_cm_ConnInfo;		/*Ptr to connection array */
-int numCollections;		/*Number of data collections */
 struct xstat_cm_ProbeResults xstat_cm_Results;	/*Latest probe results */
-char terminationEvent;		/*One-shot termination event */
 
 afs_int32 xstat_cmData[AFSCB_MAX_XSTAT_LONGS];	/*Buffer for collected data */
 
@@ -46,9 +43,11 @@ static int xstat_cm_initflag = 0;	/*Was init routine called? */
 static int xstat_cm_debug = 0;	/*Debugging output enabled? */
 static int xstat_cm_oneShot = 0;	/*One-shot operation? */
 static int (*xstat_cm_Handler) (void);	/*Probe handler routine */
-static PROCESS probeLWP_ID;	/*Probe LWP process ID */
+static pthread_t xstat_cm_thread;	/*Probe thread */
 static int xstat_cm_numCollections;	/*Number of desired collections */
 static afs_int32 *xstat_cm_collIDP;	/*Ptr to collection IDs desired */
+static opr_mutex_t xstat_cm_force_lock;	/*Lock to wakeup probe */
+static opr_cv_t xstat_cm_force_cv;	/*Condvar to wakeup probe */
 
 
 /*------------------------------------------------------------------------
@@ -173,7 +172,7 @@ xstat_cm_Cleanup(int a_releaseMem)
  * [private] xstat_cm_LWP
  *
  * Description:
- *	This LWP iterates over the server connections and gathers up
+ *	This thread iterates over the server connections and gathers up
  *	the desired statistics from each one on a regular basis, for
  *	all known data collections.  The associated handler function
  *	is called each time a new data collection is received.
@@ -196,8 +195,8 @@ xstat_cm_LWP(void *unused)
 {
     static char rn[] = "xstat_cm_LWP";	/*Routine name */
     afs_int32 code;	/*Results of calls */
-    int oneShotCode;		/*Result of one-shot signal */
     struct timeval tv;		/*Time structure */
+    struct timespec wait;	/*Time to wait */
     int conn_idx;		/*Connection index */
     struct xstat_cm_ConnectionInfo *curr_conn;	/*Current connection */
     afs_int32 srvVersionNumber;	/*Xstat version # */
@@ -257,12 +256,12 @@ xstat_cm_LWP(void *unused)
 
 		    if (xstat_cm_debug) {
 			printf
-			    ("%s: Calling RXAFSCB_GetXStats, conn=%" AFS_PTR_FMT ", clientVersionNumber=%d, collectionNumber=%d, srvVersionNumberP=%" AFS_PTR_FMT ", timeP=%" AFS_PTR_FMT ", dataP=%" AFS_PTR_FMT "\n",
+			    ("%s: Calling RXAFSCB_GetXStats, conn=%p, clientVersionNumber=%d, collectionNumber=%d, srvVersionNumberP=%p, timeP=%p, dataP=%p\n",
 			     rn, curr_conn->rxconn, clientVersionNumber,
 			     *currCollIDP, &srvVersionNumber,
 			     &(xstat_cm_Results.probeTime),
 			     &(xstat_cm_Results.data));
-			printf("%s: [bufflen=%d, buffer at %" AFS_PTR_FMT "]\n", rn,
+			printf("%s: [bufflen=%d, buffer at %p]\n", rn,
 			       xstat_cm_Results.data.AFSCB_CollData_len,
 			       xstat_cm_Results.data.AFSCB_CollData_val);
 		    }
@@ -310,36 +309,25 @@ xstat_cm_LWP(void *unused)
 
 	if (xstat_cm_oneShot) {
 	    /*
-	     * One-shot execution desired.  Signal our main procedure
-	     * that we've finished our collection round.
+	     * One-shot execution desired.
 	     */
-	    if (xstat_cm_debug)
-		printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn,
-		       &terminationEvent);
-	    oneShotCode = LWP_SignalProcess(&terminationEvent);
-	    if (oneShotCode)
-		fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn,
-			oneShotCode);
 	    break;		/*from the perpetual while loop */
 	} /*One-shot execution */
 	else {
 	    /*
 	     * Continuous execution desired.  Sleep for the required
-	     * number of seconds.
+	     * number of seconds or wakeup sooner if forced.
 	     */
-	    tv.tv_sec = xstat_cm_ProbeFreqInSecs;
-	    tv.tv_usec = 0;
 	    if (xstat_cm_debug)
 		printf("[%s] Falling asleep for %d seconds\n", rn,
 		       xstat_cm_ProbeFreqInSecs);
-	    code = IOMGR_Select(0,	/*Num fids */
-				0,	/*Descs ready for reading */
-				0,	/*Descs ready for writing */
-				0,	/*Descs w/exceptional conditions */
-				&tv);	/*Ptr to timeout structure */
-	    if (code)
-		fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn,
-			code);
+	    gettimeofday(&tv, NULL);
+	    wait.tv_sec = tv.tv_sec + xstat_cm_ProbeFreqInSecs;
+	    wait.tv_nsec = tv.tv_usec * 1000;
+	    opr_mutex_enter(&xstat_cm_force_lock);
+	    code = opr_cv_timedwait(&xstat_cm_force_cv, &xstat_cm_force_lock, &wait);
+	    opr_Assert(code == 0 || code == ETIMEDOUT);
+	    opr_mutex_exit(&xstat_cm_force_lock);
 	}			/*Continuous execution */
     }				/*Service loop */
     return NULL;
@@ -351,7 +339,7 @@ xstat_cm_LWP(void *unused)
  *
  * Description:
  *	Initialize the xstat_cm module: set up Rx connections to the
- *	given set of Cache Managers, start up the probe LWP, and
+ *	given set of Cache Managers, start up the probe thread, and
  *	associate the routine to be called when a probe completes.
  *	Also, let it know which collections you're interested in.
  *
@@ -367,7 +355,7 @@ xstat_cm_LWP(void *unused)
  * Returns:
  *	0 on success,
  *	-2 for (at least one) connection error,
- *	LWP process creation code, if it failed,
+ *	thread process creation code, if it failed,
  *	-1 for other fatal errors.
  *
  * Environment:
@@ -404,6 +392,9 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     } else
 	xstat_cm_initflag = 1;
 
+    opr_mutex_init(&xstat_cm_force_lock);
+    opr_cv_init(&xstat_cm_force_cv);
+
     /*
      * Check the parameters for bogosities.
      */
@@ -497,17 +488,17 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 
     /*
      * Create a null Rx client security object, to be used by the
-     * probe LWP.
+     * probe thread.
      */
     secobj = rxnull_NewClientSecurityObject();
     if (secobj == (struct rx_securityClass *)0) {
 	fprintf(stderr,
-		"[%s] Can't create probe LWP client security object.\n", rn);
+		"[%s] Can't create probe thread client security object.\n", rn);
 	xstat_cm_Cleanup(1);	/*Delete already-malloc'ed areas */
 	return (-1);
     }
     if (xstat_cm_debug)
-	printf("[%s] Probe LWP client security object created\n", rn);
+	printf("[%s] Probe thread client security object created\n", rn);
 
     curr_conn = xstat_cm_ConnInfo;
     conn_err = 0;
@@ -559,7 +550,7 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 	    conn_err = 1;
 	}
 	if (xstat_cm_debug)
-	    printf("[%s] New connection at %" AFS_PTR_FMT "\n", rn, curr_conn->rxconn);
+	    printf("[%s] New connection at %p\n", rn, curr_conn->rxconn);
 
 	/*
 	 * Bump the current xstat_cm connection to set up.
@@ -569,25 +560,17 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     }				/*for curr_srv */
 
     /*
-     * Start up the probe LWP.
+     * Start up the probe thread.
      */
     if (xstat_cm_debug)
-	printf("[%s] Creating the probe LWP\n", rn);
-    code = LWP_CreateProcess(xstat_cm_LWP,	/*Function to start up */
-			     LWP_STACK_SIZE,	/*Stack size in bytes */
-			     1,	/*Priority */
-			     (void *)0,	/*Parameters */
-			     "xstat_cm Worker",	/*Name to use */
-			     &probeLWP_ID);	/*Returned LWP process ID */
+	printf("[%s] Creating the probe thread\n", rn);
+    code = pthread_create(&xstat_cm_thread, NULL, xstat_cm_LWP, NULL);
     if (code) {
-	fprintf(stderr, "[%s] Can't create xstat_cm LWP!  Error is %d\n", rn,
+	fprintf(stderr, "[%s] Can't create xstat_cm thread!  Error is %d\n", rn,
 		code);
 	xstat_cm_Cleanup(1);	/*Delete already-malloc'ed areas */
 	return (code);
     }
-    if (xstat_cm_debug)
-	printf("[%s] Probe LWP process structure located at %" AFS_PTR_FMT "\n", rn,
-	       probeLWP_ID);
 
     /*
      * Return the final results.
@@ -603,7 +586,7 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray,
  * [exported] xstat_cm_ForceProbeNow
  *
  * Description:
- *	Wake up the probe LWP, forcing it to execute a probe immediately.
+ *	Wake up the probe thread, forcing it to execute a probe immediately.
  *
  * Arguments:
  *	None.
@@ -635,10 +618,80 @@ xstat_cm_ForceProbeNow(void)
     /*
      * Kick the sucker in the side.
      */
-    IOMGR_Cancel(probeLWP_ID);
+    opr_mutex_enter(&xstat_cm_force_lock);
+    opr_cv_signal(&xstat_cm_force_cv);
+    opr_mutex_exit(&xstat_cm_force_lock);
 
     /*
      * We did it, so report the happy news.
      */
     return (0);
 }
+
+/*
+ * Wait for the collection to complete. Returns after one cycle if running in
+ * one-shot mode, otherwise wait for a given amount of time.
+ *
+ * Args:
+ *    int sleep_secs : time to wait in seconds when running
+ *                     in continuous mode. 0 means wait forever.
+ *
+ * Returns:
+ *    0 on success
+ */
+int
+xstat_cm_Wait(int sleep_secs)
+{
+    static char rn[] = "xstat_cm_Wait";	/*Routine name */
+    int code;
+    struct timeval tv;		/*Time structure */
+
+    if (xstat_cm_oneShot) {
+	/*
+	 * One-shot operation; just wait for the collection to be done.
+	 */
+	if (xstat_cm_debug)
+	    printf("[%s] Calling pthread_join()\n", rn);
+	code = pthread_join(xstat_cm_thread, NULL);
+	if (xstat_cm_debug)
+	    printf("[%s] Returned from pthread_join()\n", rn);
+	if (code) {
+	    fprintf(stderr,
+		    "[%s] Error %d encountered by pthread_join()\n",
+		    rn, code);
+	}
+    } else if (sleep_secs == 0) {
+	/* Sleep forever. */
+	tv.tv_sec = 24 * 60;
+	tv.tv_usec = 0;
+	if (xstat_cm_debug)
+	    fprintf(stderr, "[%s] going to sleep ...\n", rn);
+	while (1) {
+	    code = select(0,	/*Num fds */
+			  0,	/*Descriptors ready for reading */
+			  0,	/*Descriptors ready for writing */
+			  0,	/*Descriptors with exceptional conditions */
+			  &tv);	/*Timeout structure */
+	    if (code < 0) {
+		fprintf(stderr, "[%s] select() error %d\n", rn, errno);
+		break;
+	    }
+	}
+    } else {
+	/* Let's just fall asleep while.  */
+	if (xstat_cm_debug)
+	    printf
+		("xstat_cm service started, main thread sleeping for %d secs.\n",
+		 sleep_secs);
+	tv.tv_sec = sleep_secs;
+	tv.tv_usec = 0;
+	code = select(0,	/*Num fds */
+		      0,	/*Descriptors ready for reading */
+		      0,	/*Descriptors ready for writing */
+		      0,	/*Descriptors with exceptional conditions */
+		      &tv);	/*Timeout structure */
+	if (code < 0)
+	    fprintf(stderr, "[%s] select() error: %d\n", rn, errno);
+    }
+    return code;
+}
diff --git a/src/xstat/xstat_cm.h b/src/xstat/xstat_cm.h
index efbba531c..85d8388ac 100644
--- a/src/xstat/xstat_cm.h
+++ b/src/xstat/xstat_cm.h
@@ -86,10 +86,8 @@ struct xstat_cm_ProbeResults {
 extern int xstat_cm_numServers;	/*# connected servers */
 extern struct xstat_cm_ConnectionInfo
  *xstat_cm_ConnInfo;		/*Ptr to connections */
-extern int numCollections;	/*Num data collections */
 extern struct xstat_cm_ProbeResults
   xstat_cm_Results;		/*Latest probe results */
-extern char terminationEvent;	/*One-shot termination event */
 
 /*
  * ------------------------ Exported functions ------------------------
@@ -145,4 +143,17 @@ extern int xstat_cm_Cleanup(int);
      *          with the xstat_cm connection array.
      */
 
+extern int xstat_cm_Wait(int sleep_secs);
+    /*
+     * Summary:
+     *    Wait for the collection to complete.
+     *
+     * Args:
+     *    int sleep_secs : time to wait in seconds when running
+     *                     in continuous mode. 0 means wait forever.
+     *
+     * Returns:
+     *    0 on success
+     */
+
 #endif /* _xstat_cm_h_ */
diff --git a/src/xstat/xstat_cm_test.c b/src/xstat/xstat_cm_test.c
index b284237aa..e65177c55 100644
--- a/src/xstat/xstat_cm_test.c
+++ b/src/xstat/xstat_cm_test.c
@@ -21,6 +21,7 @@
 #include "xstat_cm.h"		/*Interface for xstat_cm module */
 #include <afs/cmd.h>		/*Command line interpreter */
 #include <afs/afsutil.h>
+#include <opr/softsig.h>
 
 /*
  * Command line parameter indices.
@@ -747,13 +748,12 @@ RunTheTest(struct cmd_syndesc *a_s, void *arock)
     struct cmd_item *curr_item;	/*Current CM cmd line record */
     struct sockaddr_in *CMSktArray;	/*Cache Manager socket array */
     struct hostent *he;		/*Host entry */
-    struct timeval tv;		/*Time structure */
-    int sleep_secs;		/*Number of seconds to sleep */
     int initFlags;		/*Flags passed to the init fcn */
-    int waitCode;		/*Result of LWP_WaitProcess() */
     int freq;			/*Frequency of polls */
     int period;			/*Time in minutes of data collection */
 
+    opr_softsig_Init();
+
     /*
      * Are we doing one-shot measurements?
      */
@@ -875,47 +875,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *arock)
 	exit(-1);
     }
 
-    if (one_shot) {
-	/*
-	 * One-shot operation; just wait for the collection to be done.
-	 */
-	if (debugging_on)
-	    printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT
-		   "\n", rn, &terminationEvent);
-	waitCode = LWP_WaitProcess(&terminationEvent);
-	if (debugging_on)
-	    printf("[%s] Returned from LWP_WaitProcess()\n", rn);
-	if (waitCode) {
-	    if (debugging_on)
-		fprintf(stderr,
-			"[%s] Error %d encountered by LWP_WaitProcess()\n",
-			rn, waitCode);
-	}
-    } else {
-	/*
-	 * Continuous operation.
-	 */
-	sleep_secs = 60 * period;	/*length of data collection */
-	printf
-	    ("xstat_cm service started, main thread sleeping for %d secs.\n",
-	     sleep_secs);
-
-	/*
-	 * Let's just fall asleep for a while, then we'll clean up.
-	 */
-	tv.tv_sec = sleep_secs;
-	tv.tv_usec = 0;
-	code = IOMGR_Select(0,	/*Num fds */
-			    0,	/*Descriptors ready for reading */
-			    0,	/*Descriptors ready for writing */
-			    0,	/*Descriptors with exceptional conditions */
-			    &tv);	/*Timeout structure */
-	if (code) {
-	    fprintf(stderr,
-		    "[%s] IOMGR_Select() returned non-zero value: %d\n", rn,
-		    code);
-	}
-    }
+    /* Wait for the collection complete. */
+    xstat_cm_Wait(60 * period);
 
     /*
      * We're all done.  Clean up, put the last nail in Rx, then
diff --git a/src/xstat/xstat_fs.c b/src/xstat/xstat_fs.c
index f588d0f8c..3ebf97f59 100644
--- a/src/xstat/xstat_fs.c
+++ b/src/xstat/xstat_fs.c
@@ -18,24 +18,21 @@
 #include <afs/param.h>
 
 #include <roken.h>
+#include <afs/opr.h>
 
 #include "xstat_fs.h"		/*Interface for this module */
-#include <lwp.h>		/*Lightweight process package */
+#include <pthread.h>
 
 #include <afs/afsutil.h>
 #include <afs/afscbint.h>
 
-#define LWP_STACK_SIZE	(16 * 1024)
-
 /*
  * Exported variables.
  */
 int xstat_fs_numServers;	/*Num connected servers */
 struct xstat_fs_ConnectionInfo
  *xstat_fs_ConnInfo;		/*Ptr to connection array */
-int numCollections;		/*Number of data collections */
 struct xstat_fs_ProbeResults xstat_fs_Results;	/*Latest probe results */
-char terminationEvent;		/*One-shot termination event */
 
 afs_int32 xstat_fsData[AFS_MAX_XSTAT_LONGS];	/*Buffer for collected data */
 
@@ -47,9 +44,11 @@ static int xstat_fs_initflag = 0;	/*Was init routine called? */
 static int xstat_fs_debug = 0;	/*Debugging output enabled? */
 static int xstat_fs_oneShot = 0;	/*One-shot operation? */
 static int (*xstat_fs_Handler) (void);	/*Probe handler routine */
-static PROCESS probeLWP_ID;	/*Probe LWP process ID */
+static pthread_t xstat_fs_thread;	/*Probe thread */
 static int xstat_fs_numCollections;	/*Number of desired collections */
 static afs_int32 *xstat_fs_collIDP;	/*Ptr to collection IDs desired */
+static opr_mutex_t xstat_fs_force_lock;	/*Lock to wakeup probe */
+static opr_cv_t xstat_fs_force_cv;	/*Condvar to wakeup probe */
 
 
 /*------------------------------------------------------------------------
@@ -194,7 +193,7 @@ xstat_fs_Cleanup(int a_releaseMem)
  * [private] xstat_fs_LWP
  *
  * Description:
- *	This LWP iterates over the server connections and gathers up
+ *	This thread iterates over the server connections and gathers up
  *	the desired statistics from each one on a regular basis.  When
  *	the sweep is done, the associated handler function is called
  *	to process the new data.
@@ -216,10 +215,10 @@ xstat_fs_Cleanup(int a_releaseMem)
 static void *
 xstat_fs_LWP(void *unused)
 {
-    static char rn[] = "xstat_fs_LWP";	/*Routine name */
+    static char rn[] = "xstat_fs_thread";	/*Routine name */
     afs_int32 code;	/*Results of calls */
-    int oneShotCode;		/*Result of one-shot signal */
     struct timeval tv;		/*Time structure */
+    struct timespec wait;	/*Time to wait */
     int conn_idx;		/*Connection index */
     struct xstat_fs_ConnectionInfo *curr_conn;	/*Current connection */
     afs_int32 srvVersionNumber;	/*Xstat version # */
@@ -276,12 +275,12 @@ xstat_fs_LWP(void *unused)
 
 		    if (xstat_fs_debug) {
 			printf
-			    ("%s: Calling RXAFS_GetXStats, conn=%" AFS_PTR_FMT ", clientVersionNumber=%d, collectionNumber=%d, srvVersionNumberP=%" AFS_PTR_FMT ", timeP=%" AFS_PTR_FMT ", dataP=%" AFS_PTR_FMT "\n",
+			    ("%s: Calling RXAFS_GetXStats, conn=%p, clientVersionNumber=%d, collectionNumber=%d, srvVersionNumberP=%p, timeP=%p, dataP=%p\n",
 			     rn, curr_conn->rxconn, clientVersionNumber,
 			     *currCollIDP, &srvVersionNumber,
 			     &(xstat_fs_Results.probeTime),
 			     &(xstat_fs_Results.data));
-			printf("%s: [bufflen=%d, buffer at %" AFS_PTR_FMT "]\n", rn,
+			printf("%s: [bufflen=%d, buffer at %p]\n", rn,
 			       xstat_fs_Results.data.AFS_CollData_len,
 			       xstat_fs_Results.data.AFS_CollData_val);
 		    }
@@ -329,36 +328,21 @@ xstat_fs_LWP(void *unused)
 
 	if (xstat_fs_oneShot) {
 	    /*
-	     * One-shot execution desired.  Signal our main procedure
-	     * that we've finished our collection round.
+	     * One-shot execution desired.
 	     */
-	    if (xstat_fs_debug)
-		printf("[%s] Signalling main process at %" AFS_PTR_FMT "\n", rn,
-		       &terminationEvent);
-	    oneShotCode = LWP_SignalProcess(&terminationEvent);
-	    if (oneShotCode)
-		fprintf(stderr, "[%s] Error %d from LWP_SignalProcess()", rn,
-			oneShotCode);
-	    break;		/*from the perpetual while loop */
-	} /*One-shot execution */
-	else {
+	    break;
+	} else {
 	    /*
 	     * Continuous execution desired.  Sleep for the required
-	     * number of seconds.
+	     * number of seconds or wakeup sooner if forced.
 	     */
-	    tv.tv_sec = xstat_fs_ProbeFreqInSecs;
-	    tv.tv_usec = 0;
-	    if (xstat_fs_debug)
-		printf("[%s] Falling asleep for %d seconds\n", rn,
-		       xstat_fs_ProbeFreqInSecs);
-	    code = IOMGR_Select(0,	/*Num fids */
-				0,	/*Descs ready for reading */
-				0,	/*Descs ready for writing */
-				0,	/*Descs w/exceptional conditions */
-				&tv);	/*Ptr to timeout structure */
-	    if (code)
-		fprintf(stderr, "[%s] IOMGR_Select returned code %d\n", rn,
-			code);
+	    gettimeofday(&tv, NULL);
+	    wait.tv_sec = tv.tv_sec + xstat_fs_ProbeFreqInSecs;
+	    wait.tv_nsec = tv.tv_usec * 1000;
+	    opr_mutex_enter(&xstat_fs_force_lock);
+	    code = opr_cv_timedwait(&xstat_fs_force_cv, &xstat_fs_force_lock, &wait);
+	    opr_Verify(code == 0 || code == ETIMEDOUT);
+	    opr_mutex_exit(&xstat_fs_force_lock);
 	}			/*Continuous execution */
     }				/*Service loop */
     return NULL;
@@ -369,7 +353,7 @@ xstat_fs_LWP(void *unused)
  *
  * Description:
  *	Initialize the xstat_fs module: set up Rx connections to the
- *	given set of File Servers, start up the probe and callback LWPs,
+ *	given set of File Servers, start up the probe and callback threads,
  *	and associate the routine to be called when a probe completes.
  *	Also, let it know which collections you're interested in.
  *
@@ -425,6 +409,9 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
     } else
 	xstat_fs_initflag = 1;
 
+    opr_mutex_init(&xstat_fs_force_lock);
+    opr_cv_init(&xstat_fs_force_cv);
+
     /*
      * Check the parameters for bogosities.
      */
@@ -443,7 +430,7 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 		a_ProbeFreqInSecs);
 	arg_errfound = 1;
     }
-    if (a_ProbeHandler == (int (*)())0) {
+    if (a_ProbeHandler == NULL) {
 	fprintf(stderr, "[%s] Null probe handler function argument\n", rn);
 	arg_errfound = 1;
     }
@@ -532,17 +519,17 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 
     /*
      * Create a null Rx client security object, to be used by the
-     * probe LWP.
+     * probe thread.
      */
     secobj = rxnull_NewClientSecurityObject();
     if (secobj == (struct rx_securityClass *)0) {
 	fprintf(stderr,
-		"[%s] Can't create probe LWP client security object.\n", rn);
+		"[%s] Can't create probe thread client security object.\n", rn);
 	xstat_fs_Cleanup(1);	/*Delete already-malloc'ed areas */
 	return (-1);
     }
     if (xstat_fs_debug)
-	printf("[%s] Probe LWP client security object created\n", rn);
+	printf("[%s] Probe thread client security object created\n", rn);
 
     curr_conn = xstat_fs_ConnInfo;
     conn_err = 0;
@@ -596,7 +583,7 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
 	    conn_err = 1;
 	}
 	if (xstat_fs_debug)
-	    printf("[%s] New connection at %" AFS_PTR_FMT "\n", rn, curr_conn->rxconn);
+	    printf("[%s] New connection at %p\n", rn, curr_conn->rxconn);
 
 	/*
 	 * Bump the current xstat_fs connection to set up.
@@ -636,22 +623,14 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
      * Start up the probe LWP.
      */
     if (xstat_fs_debug)
-	printf("[%s] Creating the probe LWP\n", rn);
-    code = LWP_CreateProcess(xstat_fs_LWP,	/*Function to start up */
-			     LWP_STACK_SIZE,	/*Stack size in bytes */
-			     1,	/*Priority */
-			     (void *)0,	/*Parameters */
-			     "xstat_fs Worker",	/*Name to use */
-			     &probeLWP_ID);	/*Returned LWP process ID */
+	printf("[%s] Creating the probe thread\n", rn);
+    code = pthread_create(&xstat_fs_thread, NULL, xstat_fs_LWP, NULL);
     if (code) {
-	fprintf(stderr, "[%s] Can't create xstat_fs LWP!  Error is %d\n", rn,
+	fprintf(stderr, "[%s] Can't create xstat_fs thread!  Error is %d\n", rn,
 		code);
 	xstat_fs_Cleanup(1);	/*Delete already-malloc'ed areas */
 	return (code);
     }
-    if (xstat_fs_debug)
-	printf("[%s] Probe LWP process structure located at %" AFS_PTR_FMT "\n", rn,
-	       probeLWP_ID);
 
     /*
      * Return the final results.
@@ -667,7 +646,7 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray,
  * [exported] xstat_fs_ForceProbeNow
  *
  * Description:
- *	Wake up the probe LWP, forcing it to execute a probe immediately.
+ *	Wake up the probe thread, forcing it to execute a probe immediately.
  *
  * Arguments:
  *	None.
@@ -699,7 +678,9 @@ xstat_fs_ForceProbeNow(void)
     /*
      * Kick the sucker in the side.
      */
-    IOMGR_Cancel(probeLWP_ID);
+    opr_mutex_enter(&xstat_fs_force_lock);
+    opr_cv_signal(&xstat_fs_force_cv);
+    opr_mutex_exit(&xstat_fs_force_lock);
 
     /*
      * We did it, so report the happy news.
@@ -840,3 +821,71 @@ xstat_fs_DecodeFullPerfStats(struct fs_stats_FullPerfStats **aout,
     return 0;
 #undef DECODE_TV
 }
+
+/*
+ * Wait for the collection to complete. Returns after one cycle if running in
+ * one-shot mode, otherwise wait for a given amount of time.
+ *
+ * Args:
+ *    int sleep_secs : time to wait in seconds when running
+ *                     in continuous mode. 0 means wait forever.
+ *
+ * Returns:
+ *    0 on success
+ */
+int
+xstat_fs_Wait(int sleep_secs)
+{
+    static char rn[] = "xstat_fs_Wait";	/*Routine name */
+    int code;
+    struct timeval tv;		/*Time structure */
+
+    if (xstat_fs_oneShot) {
+	/*
+	 * One-shot operation; just wait for the collection to be done.
+	 */
+	if (xstat_fs_debug)
+	    printf("[%s] Calling pthread_join\n", rn);
+	code = pthread_join(xstat_fs_thread, NULL);
+	if (xstat_fs_debug)
+	    printf("[%s] Returned from pthread_join()\n", rn);
+	if (code) {
+	    fprintf(stderr,
+		    "[%s] Error %d encountered by pthread_join()\n",
+		    rn, code);
+	}
+    } else if (sleep_secs == 0) {
+	/* Sleep forever. */
+	tv.tv_sec = 24 * 60;
+	tv.tv_usec = 0;
+	if (xstat_fs_debug)
+	    fprintf(stderr, "[ %s ] going to sleep ...\n", rn);
+	while (1) {
+	    code = select(0,	/*Num fds */
+			  0,	/*Descriptors ready for reading */
+			  0,	/*Descriptors ready for writing */
+			  0,	/*Descriptors with exceptional conditions */
+			  &tv);	/*Timeout structure */
+	    if (code < 0) {
+		fprintf(stderr, "[%s] select() error %d\n", rn, errno);
+		break;
+	    }
+	}
+    } else {
+	/* Let's just fall asleep while.  */
+	if (xstat_fs_debug)
+	    printf
+		("xstat_fs service started, main thread sleeping for %d secs.\n",
+		 sleep_secs);
+	tv.tv_sec = sleep_secs;
+	tv.tv_usec = 0;
+	code = select(0,	/*Num fds */
+		      0,	/*Descriptors ready for reading */
+		      0,	/*Descriptors ready for writing */
+		      0,	/*Descriptors with exceptional conditions */
+		      &tv);	/*Timeout structure */
+	if (code < 0)
+	    fprintf(stderr, "[%s] select() error %d\n", rn, errno);
+    }
+    return code;
+}
diff --git a/src/xstat/xstat_fs.h b/src/xstat/xstat_fs.h
index 6e2b77b85..839a06556 100644
--- a/src/xstat/xstat_fs.h
+++ b/src/xstat/xstat_fs.h
@@ -87,10 +87,8 @@ struct xstat_fs_ProbeResults {
 extern int xstat_fs_numServers;	/*# connected servers */
 extern struct xstat_fs_ConnectionInfo
  *xstat_fs_ConnInfo;		/*Ptr to connections */
-extern int numCollections;	/*Num data collections */
 extern struct xstat_fs_ProbeResults
   xstat_fs_Results;		/*Latest probe results */
-extern char terminationEvent;	/*One-shot termination event */
 
 /*
  * ------------------------ Exported functions ------------------------
@@ -145,6 +143,19 @@ extern int xstat_fs_Cleanup(int);
      *          with the xstat_fs connection array.
      */
 
+extern int xstat_fs_Wait(int sleep_secs);
+    /*
+     * Summary:
+     *    Wait for the collection to complete.
+     *
+     * Args:
+     *    int sleep_secs : time to wait in seconds when running
+     *                     in continuous mode. 0 means wait forever.
+     *
+     * Returns:
+     *    0 on success
+     */
+
 /*
  * Decode the full performance statistics collection data.
  */
diff --git a/src/xstat/xstat_fs_test.c b/src/xstat/xstat_fs_test.c
index 853c2121e..7f9f822cd 100644
--- a/src/xstat/xstat_fs_test.c
+++ b/src/xstat/xstat_fs_test.c
@@ -21,6 +21,7 @@
 #include "xstat_fs.h"		/*Interface for xstat_fs module */
 #include <afs/cmd.h>		/*Command line interpreter */
 #include <afs/afsutil.h>
+#include <opr/softsig.h>
 
 /*
  * Command line parameter indices.
@@ -122,7 +123,7 @@ PrintCallInfo(void)
 	   printableTime);
 
     if (debugging_on)
-	printf("\n[%u entries returned at %" AFS_PTR_FMT "]\n\n", numInt32s, currInt32);
+	printf("\n[%u entries returned at %p]\n\n", numInt32s, currInt32);
 
     for (i = 0; i < numInt32s; i++)
 	printf("%u ", *currInt32++);
@@ -660,13 +661,12 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
     struct cmd_item *curr_item;	/*Current FS cmd line record */
     struct sockaddr_in FSSktArray[20];	/*File Server socket array - FIX! */
     struct hostent *he;		/*Host entry */
-    struct timeval tv;		/*Time structure */
-    int sleep_secs;		/*Number of seconds to sleep */
     int initFlags;		/*Flags passed to the init fcn */
-    int waitCode;		/*Result of LWP_WaitProcess() */
     int freq;			/*Frequency of polls */
     int period;			/*Time in minutes of data collection */
 
+    opr_softsig_Init();
+
     /*
      * Are we doing one-shot measurements?
      */
@@ -772,47 +772,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *dummy)
 	exit(-1);
     }
 
-    if (one_shot) {
-	/*
-	 * One-shot operation; just wait for the collection to be done.
-	 */
-	if (debugging_on)
-	    printf("[%s] Calling LWP_WaitProcess() on event %" AFS_PTR_FMT "\n", rn,
-		   &terminationEvent);
-	waitCode = LWP_WaitProcess(&terminationEvent);
-	if (debugging_on)
-	    printf("[%s] Returned from LWP_WaitProcess()\n", rn);
-	if (waitCode) {
-	    if (debugging_on)
-		fprintf(stderr,
-			"[%s] Error %d encountered by LWP_WaitProcess()\n",
-			rn, waitCode);
-	}
-    } else {
-	/*
-	 * Continuous operation.
-	 */
-	sleep_secs = 60 * period;	/*length of data collection */
-	printf
-	    ("xstat_fs service started, main thread sleeping for %d secs.\n",
-	     sleep_secs);
-
-	/*
-	 * Let's just fall asleep for a while, then we'll clean up.
-	 */
-	tv.tv_sec = sleep_secs;
-	tv.tv_usec = 0;
-	code = IOMGR_Select(0,	/*Num fds */
-			    0,	/*Descriptors ready for reading */
-			    0,	/*Descriptors ready for writing */
-			    0,	/*Descriptors with exceptional conditions */
-			    &tv);	/*Timeout structure */
-	if (code) {
-	    fprintf(stderr,
-		    "[%s] IOMGR_Select() returned non-zero value: %d\n", rn,
-		    code);
-	}
-    }
+    /* Wait for the collection complete. */
+    xstat_fs_Wait(60 * period);
 
     /*
      * We're all done.  Clean up, put the last nail in Rx, then
diff --git a/tests/.gitignore b/tests/.gitignore
index e01a35423..830a67690 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -3,3 +3,4 @@
 # to check that you haven't inadvertently ignored any tracked files.
 
 /runtests
+/core
diff --git a/tests/Makefile.in b/tests/Makefile.in
index 23f1fa096..29559ba30 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -6,8 +6,8 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-MODULE_CFLAGS = -DSOURCE='"$(abs_top_srcdir)/tests"' \
-	-DBUILD='"$(abs_top_builddir)/tests"'
+MODULE_CFLAGS = -DC_TAP_SOURCE='"$(abs_top_srcdir)/tests"' \
+	-DC_TAP_BUILD='"$(abs_top_builddir)/tests"'
 
 SUBDIRS = tap common auth util cmd volser opr rx
 
@@ -22,8 +22,8 @@ runtests.o: $(srcdir)/runtests.c
 
 check test tests: runtests
 	@for A in $(SUBDIRS); do cd $$A && $(MAKE) $@ && cd .. || exit 1; done
-	MAKECHECK=1 ./libwrap @TOP_OBJDIR@/lib \
-	    ./runtests $(abs_top_srcdir)/tests/TESTS
+	MAKECHECK=1 $(abs_top_srcdir)/tests/libwrap @TOP_OBJDIR@/lib \
+	    ./runtests -v -l $(abs_top_srcdir)/tests/TESTS
 
 install:
 
diff --git a/tests/TESTS b/tests/TESTS
index e59014e1d..72f11589c 100644
--- a/tests/TESTS
+++ b/tests/TESTS
@@ -1,10 +1,13 @@
 util/ktime
 util/exec-alt
+util/volutil
 auth/keys
 auth/superuser
 auth/authcon
 auth/realms
+auth/writeoldkey
 cmd/command
+opr/cache
 opr/dict
 opr/fmt
 opr/jhash
@@ -21,3 +24,5 @@ volser/vos-man
 volser/vos
 bucoord/backup-man
 kauth/kas-man
+bozo/bos-man
+venus/fs-man
diff --git a/tests/auth/KeyFile.short b/tests/auth/KeyFile.short
new file mode 100644
index 000000000..6e5801e02
Binary files /dev/null and b/tests/auth/KeyFile.short differ
diff --git a/tests/auth/Makefile.in b/tests/auth/Makefile.in
index ed4ed27ae..aa89f7589 100644
--- a/tests/auth/Makefile.in
+++ b/tests/auth/Makefile.in
@@ -4,9 +4,9 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-TESTS = authcon-t superuser-t keys-t realms-t
+TESTS = authcon-t superuser-t keys-t realms-t writekeyfile
 
-MODULE_CFLAGS=-I$(srcdir)/../.. -I$(srcdir)/../common/
+MODULE_CFLAGS=-I$(TOP_OBJDIR) -I$(srcdir)/../common/
 
 all check test tests: $(TESTS)
 
@@ -20,11 +20,12 @@ authcon-t: authcon-t.o ../common/config.o ../common/network.o
 		$(MODULE_LIBS)
 
 superuser-t: superuser-t.o ../common/config.o ../common/rxkad.o \
-	     test.cs.o test.ss.o test.xdr.o ../common/network.o
+	     test.cs.o test.ss.o test.xdr.o ../common/network.o \
+	     ../common/misc.o
 	$(LT_LDRULE_static) superuser-t.o ../common/config.o \
 		../common/rxkad.o ../common/servers.o \
 		test.cs.o test.ss.o test.xdr.o ../common/network.o \
-		$(MODULE_LIBS)
+		../common/misc.o $(MODULE_LIBS)
 
 keys-t: keys-t.o ../common/config.o ../common/network.o
 	$(LT_LDRULE_static) keys-t.o ../common/config.o ../common/network.o $(MODULE_LIBS)
@@ -32,8 +33,8 @@ keys-t: keys-t.o ../common/config.o ../common/network.o
 realms-t: realms-t.o ../common/config.o ../common/network.o
 	$(LT_LDRULE_static) realms-t.o ../common/config.o ../common/network.o $(MODULE_LIBS)
 
-writekeyfile: writekeyfile.o
-	$(LT_LDRULE_static) writekeyfile.o $(MODULE_LIBS)
+writekeyfile: writekeyfile.o ../common/config.o
+	$(LT_LDRULE_static) writekeyfile.o ../common/config.o $(MODULE_LIBS)
 
 test.cs.c: test.xg
 	$(RXGEN) -A -x -C -o $@ $(srcdir)/test.xg
@@ -52,4 +53,4 @@ superuser-t.o: test.h
 clean:
 	$(LT_CLEAN)
 	rm -f *.o *.cs.c *.ss.c *.xdr.c test.h \
-		writekeyfile $(TESTS)
+		$(TESTS)
diff --git a/tests/auth/authcon-t.c b/tests/auth/authcon-t.c
index e029774f3..5bcd74c00 100644
--- a/tests/auth/authcon-t.c
+++ b/tests/auth/authcon-t.c
@@ -53,7 +53,7 @@ main(int argc, char **argv)
 
     afstest_SkipTestsIfBadHostname();
 
-    plan(9);
+    plan(8);
     dirname = afstest_BuildTestConfig();
 
     dir = afsconf_Open(dirname);
@@ -68,15 +68,10 @@ main(int argc, char **argv)
     /* Server Security objects */
 
     afsconf_BuildServerSecurityObjects(dir, &classes, &numClasses);
-    is_int(3, numClasses, "3 security classes are returned, as expected");
+    is_int(5, numClasses, "5 security classes are returned, as expected");
     ok(classes[1] == NULL, "The rxvab class is undefined, as requested");
     free(classes);
 
-    afsconf_SetSecurityFlags(dir, AFSCONF_SECOPTS_ALWAYSENCRYPT);
-
-    afsconf_BuildServerSecurityObjects(dir, &classes, &numClasses);
-    is_int(4, numClasses, "When encryption is enabled, 4 classes are returned");
-
     /* Up to date checks */
 
     ok(afsconf_UpToDate(dir), "Newly opened directory is up to date");
diff --git a/tests/auth/keys-t.c b/tests/auth/keys-t.c
index 789b49bc2..f0556ceea 100644
--- a/tests/auth/keys-t.c
+++ b/tests/auth/keys-t.c
@@ -128,11 +128,11 @@ int main(int argc, char **argv)
 	goto out;
 
     /* Work out the path to our KeyFile. If the test harness hasn't set
-     * the SOURCE environment variable, then assume it is in our CWD */
-    if (getenv("SOURCE") == NULL) {
+     * the C_TAP_SOURCE environment variable, then assume it is in our CWD */
+    if (getenv("C_TAP_SOURCE") == NULL) {
 	keyfilesrc = strdup("KeyFile");
     } else {
-	if (asprintf(&keyfilesrc, "%s/auth/KeyFile", getenv("SOURCE")) == -1)
+	if (asprintf(&keyfilesrc, "%s/auth/KeyFile", getenv("C_TAP_SOURCE")) == -1)
 	    goto out;
     }
 
diff --git a/tests/auth/superuser-t.c b/tests/auth/superuser-t.c
index bdba611f5..718572230 100644
--- a/tests/auth/superuser-t.c
+++ b/tests/auth/superuser-t.c
@@ -29,6 +29,8 @@
 #ifdef HAVE_SYS_WAIT_H
 #include <sys/wait.h>
 #endif
+#include <signal.h>
+#include <time.h>
 
 #ifdef IGNORE_SOME_GCC_WARNINGS
 # pragma GCC diagnostic warning "-Wdeprecated-declarations"
@@ -365,6 +367,33 @@ STEST_NewWhoAmI(struct rx_call *call, char **result)
    return 0;
 }
 
+/*
+ * Primitive replacement for using sigtimedwait(). Just see if 'signo' is
+ * pending, and if it's not, wait 100ms and try again. Try this for
+ * approximately as many times as it takes to wait for 'nsecs' seconds.
+ */
+static int
+waitforsig(int signo, int nsecs)
+{
+    int nsleeps;
+
+    for (nsleeps = 0; nsleeps < nsecs * 10; nsleeps++) {
+	sigset_t set;
+	int code;
+
+	opr_Verify(sigpending(&set) == 0);
+	if (sigismember(&set, signo)) {
+	    return 0;
+	}
+
+	/* Sleep for 100ms */
+	code = usleep(100000);
+	opr_Assert(code == 0 || errno == EINTR);
+    }
+
+    return -1;
+}
+
 int main(int argc, char **argv)
 {
     struct afsconf_dir *dir;
@@ -372,6 +401,8 @@ int main(int argc, char **argv)
     int serverPid, clientPid, waited, stat;
     int code;
     int ret = 0;
+    sigset_t set;
+    char *argv0 = afstest_GetProgname(argv);
 
     afstest_SkipTestsIfBadHostname();
 
@@ -380,8 +411,8 @@ int main(int argc, char **argv)
     if (argc == 3 ) {
         if (strcmp(argv[1], "-server") == 0) {
 	    globalDir = afsconf_Open(argv[2]);
-	    afstest_StartTestRPCService(argv[2], TEST_PORT, TEST_SERVICE_ID,
-					TEST_ExecuteRequest);
+	    afstest_StartTestRPCService(argv[2], getppid(), TEST_PORT,
+					TEST_SERVICE_ID, TEST_ExecuteRequest);
             exit(0);
         } else if (strcmp(argv[1], "-client") == 0) {
             startClient(argv[2]);
@@ -395,6 +426,10 @@ int main(int argc, char **argv)
     /* Otherwise, do the basic configuration, then start the client and
      * server */
 
+    sigemptyset(&set);
+    sigaddset(&set, SIGUSR1);
+    opr_Verify(sigprocmask(SIG_BLOCK, &set, NULL) == 0);
+
     dirname = afstest_BuildTestConfig();
 
     dir = afsconf_Open(dirname);
@@ -406,7 +441,7 @@ int main(int argc, char **argv)
 
     code = afstest_AddDESKeyFile(dir);
     if (code) {
-	afs_com_err("superuser-t", code, "while adding new key\n");
+	afs_com_err(argv0, code, "while adding new key\n");
 	ret = 1;
 	goto out;
     }
@@ -420,6 +455,17 @@ int main(int argc, char **argv)
 	ret = 1;
 	goto out;
     }
+
+    /* Our server child pid will send us a SIGUSR1 when it's started listening
+     * on its port. Wait for up to 5 seconds to get the USR1. */
+    if (waitforsig(SIGUSR1, 5) != 0) {
+	fprintf(stderr, "%s: Timed out waiting for SIGUSR1 from server child\n",
+		argv0);
+	kill(serverPid, SIGTERM);
+	ret = 1;
+	goto out;
+    }
+
     clientPid = fork();
     if (clientPid == -1) {
         kill(serverPid, SIGTERM);
diff --git a/tests/auth/writekeyfile.c b/tests/auth/writekeyfile.c
index 2387da062..4a07e61cb 100644
--- a/tests/auth/writekeyfile.c
+++ b/tests/auth/writekeyfile.c
@@ -8,40 +8,29 @@
 #include <afs/param.h>
 #include <afs/cellconfig.h>
 #include <afs/afsutil.h>
+#include <afs/opr.h>
 
 #include <roken.h>
 
+#include "common.h"
+
 int
 main(int argc, char **argv)
 {
     struct afsconf_dir *dir;
-    char buffer[1024];
+    char *dirname;
     char *block;
-    char *dirEnd;
-    FILE *file;
+    char *keyfile = NULL;
     int in, out;
     size_t len;
-    int code;
-
-    snprintf(buffer, sizeof(buffer), "%s/afs_XXXXXX", gettmpdir());
-    mkdtemp(buffer);
-    dirEnd = buffer + strlen(buffer);
-
-    /* Create a CellServDB file */
-    strcpy(dirEnd, "/CellServDB");
-    file = fopen(buffer, "w");
-    fprintf(file, ">example.org # An example cell\n");
-    fprintf(file, "127.0.0.1 #test.example.org\n");
-    fclose(file);
 
-    /* Create a ThisCell file */
-    strcpy(dirEnd, "/ThisCell");
-    file = fopen(buffer, "w");
-    fprintf(file, "example.org\n");
-    fclose(file);
+    dirname = afstest_BuildTestConfig();
+    if (dirname == NULL) {
+	fprintf(stderr, "Unable to create tmp config dir\n");
+	exit(1);
+    }
 
-    *dirEnd='\0';
-    dir = afsconf_Open(strdup(buffer));
+    dir = afsconf_Open(dirname);
     if (dir == NULL) {
 	fprintf(stderr, "Unable to open configuration directory\n");
 	exit(1);
@@ -54,15 +43,18 @@ main(int argc, char **argv)
     afsconf_Close(dir);
 
     /* Copy out the resulting keyfile into our homedirectory */
-    strcpy(dirEnd, "/KeyFile");
-    in = open(buffer, O_RDONLY);
+    opr_Verify(asprintf(&keyfile, "%s/KeyFile", dirname) > 0);
+    in = open(keyfile, O_RDONLY);
     out = open("KeyFile", O_WRONLY | O_CREAT, 0644);
 
     block = malloc(1024);
     do {
 	len = read(in, block, 1024);
-	if (len > 0)
-	    write(out, block, len);
+	if (len > 0) {
+	    if (write(out, block, len) != len) {
+		len = -1;
+	    }
+	}
     } while (len > 0);
 
     if (len == -1) {
@@ -73,14 +65,7 @@ main(int argc, char **argv)
     close(in);
     close(out);
 
-    strcpy(dirEnd, "/KeyFile");
-    unlink(buffer);
-    strcpy(dirEnd, "/CellServDB");
-    unlink(buffer);
-    strcpy(dirEnd, "/ThisCell");
-    unlink(buffer);
-    strcpy(dirEnd, "/UserList");
-    unlink(buffer);
-    *dirEnd='\0';
-    rmdir(buffer);
+    afstest_UnlinkTestConfig(dirname);
+
+    return 0;
 }
diff --git a/tests/auth/writeoldkey-t b/tests/auth/writeoldkey-t
new file mode 100755
index 000000000..324021294
--- /dev/null
+++ b/tests/auth/writeoldkey-t
@@ -0,0 +1,47 @@
+#!/usr/bin/env perl
+
+use strict;
+use warnings;
+use Test::More;
+use File::Temp qw/tempdir/;
+use FindBin qw($Bin);
+use Cwd qw/abs_path/;
+use File::Compare;
+use Sys::Hostname;
+use Socket;
+
+# Run tests/auth/writekeyfile, and check that the KeyFile that it generates
+# matches what we expect.
+
+if (!defined(gethostbyname(hostname()))) {
+    # writekeyfile needs a hostname to generate a config dir
+    plan skip_all => 'Cannot resolve hostname';
+}
+plan tests => 1;
+
+my $cmd;
+if (defined($ENV{C_TAP_BUILD})) {
+    $cmd = $ENV{C_TAP_BUILD} . "/auth/writekeyfile";
+} else {
+    $cmd = $Bin . "/writekeyfile";
+}
+$cmd = abs_path($cmd);
+
+my $keyfile;
+if (defined($ENV{C_TAP_SOURCE})) {
+    $keyfile = $ENV{C_TAP_SOURCE} . "/auth/KeyFile.short";
+} else {
+    $keyfile = $Bin . "/KeyFile.short";
+}
+$keyfile = abs_path($keyfile);
+
+my $dir = tempdir('afs_XXXXXX', CLEANUP => 1);
+
+chdir($dir)
+    or die("chdir $dir failed: $?");
+
+system($cmd) == 0
+    or die("$cmd failed: $?");
+
+ok(compare("KeyFile", $keyfile) == 0,
+   "writekeyfile generates expected KeyFile");
diff --git a/tests/bozo/bos-man-t b/tests/bozo/bos-man-t
index fedcf5863..40758e803 100755
--- a/tests/bozo/bos-man-t
+++ b/tests/bozo/bos-man-t
@@ -1,25 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
-use File::Basename;
-use lib "./tests-lib/perl5";
+use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
 use mancheck_utils;
 
-# Set this to the bare command to test
-my $command = 'bos';
-my $builddir = $ENV{BUILD};
-if (!$builddir) {
-    $builddir = dirname($0) . "/..";
-}
-$builddir .= "/..";
-# Set this to the directory holding $command
-my $srcdir = "$builddir/src/bozo";
-
-#---------------------------------------------------------------------
-
-my @sub_commands = lookup_sub_commands($srcdir, $command);
-plan tests => scalar @sub_commands;
-
-test_command_man_pages($builddir, $command, @sub_commands);
-
+run_manpage_tests("src/bozo", "bos");
diff --git a/tests/bucoord/backup-man-t b/tests/bucoord/backup-man-t
index d8df2c823..95343d758 100755
--- a/tests/bucoord/backup-man-t
+++ b/tests/bucoord/backup-man-t
@@ -1,25 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
-use File::Basename;
-use lib "./tests-lib/perl5";
+use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
 use mancheck_utils;
 
-# Set this to the bare command to test
-my $command = 'backup';
-my $builddir = $ENV{BUILD};
-if (!$builddir) {
-    $builddir = dirname($0) . "/..";
-}
-$builddir .= "/..";
-# Set this to the directory holding $command
-my $srcdir = "$builddir/src/bucoord";
-
-#---------------------------------------------------------------------
-
-my @sub_commands = lookup_sub_commands($srcdir, $command);
-plan tests => scalar @sub_commands;
-
-test_command_man_pages($builddir, $command, @sub_commands);
-
+run_manpage_tests("src/bucoord", "backup");
diff --git a/tests/cmd/Makefile.in b/tests/cmd/Makefile.in
index 57dfe8fe2..9c042ffeb 100644
--- a/tests/cmd/Makefile.in
+++ b/tests/cmd/Makefile.in
@@ -5,7 +5,7 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-MODULE_CFLAGS = -I$(srcdir)/../..
+MODULE_CFLAGS = -I$(TOP_OBJDIR)
 
 LIBS = ../tap/libtap.a \
        $(abs_top_builddir)/src/cmd/liboafs_cmd.la \
diff --git a/tests/cmd/command-t.c b/tests/cmd/command-t.c
index 796ff22c7..71efd398c 100644
--- a/tests/cmd/command-t.c
+++ b/tests/cmd/command-t.c
@@ -360,10 +360,10 @@ main(int argc, char **argv)
     cmd_FreeArgv(tv);
 
     /* Now, try adding a configuration file into the mix */
-    if (getenv("SOURCE") == NULL)
+    if (getenv("C_TAP_SOURCE") == NULL)
 	path = strdup("test1.conf");
     else {
-	if (asprintf(&path, "%s/cmd/test1.conf", getenv("SOURCE")) < 0)
+	if (asprintf(&path, "%s/cmd/test1.conf", getenv("C_TAP_SOURCE")) < 0)
 	    path = NULL;
     }
     if (path != NULL) {
diff --git a/tests/common/Makefile.in b/tests/common/Makefile.in
index f71d9d37f..3bc609697 100644
--- a/tests/common/Makefile.in
+++ b/tests/common/Makefile.in
@@ -4,7 +4,7 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-MODULE_CFLAGS=-I$(srcdir)/.. -I$(srcdir)/../..
+MODULE_CFLAGS=-I$(TOP_OBJDIR)
 
 all check test tests:	config.o servers.o ubik.o rxkad.o network.o
 
diff --git a/tests/common/common.h b/tests/common/common.h
index c9f734970..88bd745aa 100644
--- a/tests/common/common.h
+++ b/tests/common/common.h
@@ -25,6 +25,7 @@
 /* config.c */
 extern char *afstest_BuildTestConfig(void);
 extern void afstest_UnlinkTestConfig(char *);
+extern char *afstest_mkdtemp(char *template);
 
 struct afsconf_dir;
 extern int afstest_AddDESKeyFile(struct afsconf_dir *dir);
@@ -40,7 +41,7 @@ extern struct rx_securityClass
 struct rx_call;
 extern int afstest_StartVLServer(char *dirname, pid_t *serverPid);
 extern int afstest_StopServer(pid_t serverPid);
-extern int afstest_StartTestRPCService(const char *, u_short, u_short,
+extern int afstest_StartTestRPCService(const char *, pid_t, u_short, u_short,
 				       afs_int32 (*proc)(struct rx_call *));
 
 /* ubik.c */
@@ -55,3 +56,7 @@ extern int afstest_GetUbikClient(struct afsconf_dir *dir, char *service,
 extern int afstest_IsLoopbackNetworkDefault(void);
 extern int afstest_SkipTestsIfLoopbackNetIsDefault(void);
 extern void afstest_SkipTestsIfBadHostname(void);
+extern void afstest_SkipTestsIfServerRunning(char *name);
+
+/* misc.c */
+extern char *afstest_GetProgname(char **argv);
diff --git a/tests/common/config.c b/tests/common/config.c
index 6a0e3e1ef..debd71e39 100644
--- a/tests/common/config.c
+++ b/tests/common/config.c
@@ -61,6 +61,30 @@ unlinkConfigFile(char *dirname, char *filename) {
     }
 }
 
+/*!
+ *  Wrapper for mkdtemp
+ */
+
+char *
+afstest_mkdtemp(char *template)
+{
+#if defined(HAVE_MKDTEMP)
+    return mkdtemp(template);
+#else
+    /*
+     * Note that using the following is not a robust replacement
+     * for mkdtemp as there is a possible race condition between
+     * creating the name and creating the directory itself.  The
+     * use of this routine is limited to running tests.
+     */
+    if (mktemp(template) == NULL)
+	return NULL;
+    if (mkdir(template, 0700))
+	return NULL;
+    return template;
+#endif
+}
+
 /*!
  * Build a test configuration directory, containing a CellServDB and ThisCell
  * file for the "example.org" cell
@@ -82,7 +106,7 @@ afstest_BuildTestConfig(void) {
     if (asprintf(&dir, "%s/afs_XXXXXX", gettmpdir()) == -1)
 	goto fail;
 
-    if (mkdtemp(dir) == NULL)
+    if (afstest_mkdtemp(dir) == NULL)
 	goto fail;
 
     /* Work out which IP address to use in our CellServDB. We figure this out
diff --git a/tests/common/misc.c b/tests/common/misc.c
new file mode 100644
index 000000000..b2703d091
--- /dev/null
+++ b/tests/common/misc.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2019 Sine Nomine Associates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*!
+ * Common misc functions for testing programs
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+#include <roken.h>
+
+#include "common.h"
+
+char *
+afstest_GetProgname(char **argv)
+{
+    char *argv0;
+
+    /* For invocations like ./foo/bar/prog, strip out everything but the
+     * trailing 'prog'. */
+    argv0 = strrchr(argv[0], '/');
+    if (argv0 != NULL) {
+        argv0++;
+        return argv0;
+    }
+    return argv[0];
+}
diff --git a/tests/common/network.c b/tests/common/network.c
index 474fc6155..c664505c1 100644
--- a/tests/common/network.c
+++ b/tests/common/network.c
@@ -61,3 +61,44 @@ afstest_SkipTestsIfBadHostname(void)
     if (!host)
 	skip_all("Can't resolve hostname %s\n", hostname);
 }
+
+/*!
+ * Skips all TAP tests if a server is already running on this system.
+ *
+ * \param name[in]  IANA service name, e.g. "afs3-vlserver"
+ */
+void
+afstest_SkipTestsIfServerRunning(char *name)
+{
+    afs_int32 code;
+    osi_socket sock;
+    struct sockaddr_in addr;
+    afs_int32 service;
+
+    service = afsconf_FindService(name);
+    if (service == -1) {
+	fprintf(stderr, "Unknown service name: %s\n", name);
+	exit(1);
+    }
+    sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+    if (sock == OSI_NULLSOCKET) {
+	fprintf(stderr, "Failed to get socket file descriptor.\n");
+	exit(1);
+    }
+    addr.sin_family = AF_INET;
+    addr.sin_addr.s_addr = htonl(INADDR_ANY);
+    addr.sin_port = service; /* Already in network byte order. */
+#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
+    addr.sin_len = sizeof(addr);
+#endif
+    code = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
+    if (code < 0) {
+	if (errno == EADDRINUSE) {
+	    skip_all("Service %s is already running.\n", name);
+	} else {
+	    perror("bind");
+	    exit(1);
+	}
+    }
+    close(sock);
+}
diff --git a/tests/common/servers.c b/tests/common/servers.c
index 4380e57c3..716b0ca1a 100644
--- a/tests/common/servers.c
+++ b/tests/common/servers.c
@@ -11,6 +11,8 @@
 
 #include <afs/cellconfig.h>
 
+#include <tests/tap/basic.h>
+
 #include "common.h"
 
 /* Start up the VLserver, using the configuration in dirname, and putting our
@@ -21,6 +23,7 @@ int
 afstest_StartVLServer(char *dirname, pid_t *serverPid)
 {
     pid_t pid;
+    int status;
 
     pid = fork();
     if (pid == -1) {
@@ -30,7 +33,7 @@ afstest_StartVLServer(char *dirname, pid_t *serverPid)
 	char *binPath, *logPath, *dbPath, *build;
 
 	/* Child */
-	build = getenv("BUILD");
+	build = getenv("C_TAP_BUILD");
 
 	if (build == NULL)
 	    build = "..";
@@ -46,6 +49,20 @@ afstest_StartVLServer(char *dirname, pid_t *serverPid)
 	fprintf(stderr, "Running %s failed\n", binPath);
 	exit(1);
     }
+
+    if (waitpid(pid, &status, WNOHANG) != 0) {
+	fprintf(stderr, "Error starting vlserver\n");
+	return -1;
+    }
+
+    diag("Sleeping for a few seconds to let the vlserver startup");
+    sleep(5);
+
+    if (waitpid(pid, &status, WNOHANG) != 0) {
+	fprintf(stderr, "vlserver died during startup\n");
+	return -1;
+    }
+
     *serverPid = pid;
 
     return 0;
@@ -73,6 +90,7 @@ afstest_StopServer(pid_t serverPid)
 
 int
 afstest_StartTestRPCService(const char *configPath,
+			    pid_t signal_pid,
 			    u_short port,
 			    u_short serviceId,
 			    afs_int32 (*proc) (struct rx_call *))
@@ -95,6 +113,10 @@ afstest_StartTestRPCService(const char *configPath,
 	return -1;
     }
 
+    if (signal_pid != 0) {
+	kill(signal_pid, SIGUSR1);
+    }
+
     afsconf_BuildServerSecurityObjects(dir, &classes, &numClasses);
     service = rx_NewService(0, serviceId, "test", classes, numClasses,
                             proc);
diff --git a/tests/kauth/kas-man-t b/tests/kauth/kas-man-t
index 162958896..bb783024f 100755
--- a/tests/kauth/kas-man-t
+++ b/tests/kauth/kas-man-t
@@ -1,25 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
-use File::Basename;
-use lib "./tests-lib/perl5";
+use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
 use mancheck_utils;
 
-# Set this to the bare command to test
-my $command = 'kas';
-my $builddir = $ENV{BUILD};
-if (!$builddir) {
-    $builddir = dirname($0) . "/..";
-}
-$builddir .= "/..";
-# Set this to the directory holding $command
-my $srcdir = "$builddir/src/kauth";
-
-#---------------------------------------------------------------------
-
-my @sub_commands = lookup_sub_commands($srcdir, $command);
-plan tests => scalar @sub_commands;
-
-test_command_man_pages($builddir, $command, @sub_commands);
-
+run_manpage_tests("src/kauth", "kas");
diff --git a/tests/opr/.gitignore b/tests/opr/.gitignore
index 1941a9368..f7b33fe39 100644
--- a/tests/opr/.gitignore
+++ b/tests/opr/.gitignore
@@ -10,3 +10,4 @@
 /time-t
 /uuid-t
 /softsig-helper
+/cache-t
diff --git a/tests/opr/Makefile.in b/tests/opr/Makefile.in
index 96601775a..52916fb96 100644
--- a/tests/opr/Makefile.in
+++ b/tests/opr/Makefile.in
@@ -3,14 +3,18 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-MODULE_CFLAGS = -I$(srcdir)/../..
+MODULE_CFLAGS = -I$(TOP_OBJDIR)
 
 LIBS=../tap/libtap.a $(abs_top_builddir)/src/opr/liboafs_opr.la
 
-tests = dict-t fmt-t jhash-t queues-t rbtree-t softsig-helper time-t uuid-t
+tests = cache-t dict-t fmt-t jhash-t queues-t rbtree-t softsig-helper time-t \
+	uuid-t
 
 all check test tests: $(tests)
 
+cache-t: cache-t.o
+	$(LT_LDRULE_static) cache-t.o $(LIBS) $(XLIBS)
+
 dict-t: dict-t.o
 	$(LT_LDRULE_static) dict-t.o $(LIBS) $(XLIBS)
 
diff --git a/tests/opr/cache-t.c b/tests/opr/cache-t.c
new file mode 100644
index 000000000..2d97b2fc7
--- /dev/null
+++ b/tests/opr/cache-t.c
@@ -0,0 +1,265 @@
+/*
+ * Copyright (c) 2019 Sine Nomine Associates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <tests/tap/basic.h>
+#include <afs/opr.h>
+
+#include <stdlib.h>
+#include <time.h>
+
+struct {
+    char *key;
+    int key_len;
+
+    char *val;
+    int val_len;
+} items[] = {
+
+#define TCASE(key, len, val) { (key), (len), (val), sizeof(val)-1 }
+
+    TCASE("foo\0\0", 6, "one"),
+    TCASE("bar\0\0", 6, "two"),
+    TCASE("baz\0\0", 6, "three"),
+    TCASE("quux\0",  6, "four"),
+    TCASE("pants",   6, "five"),
+
+    TCASE("foo\0\0", 4, "six"),
+    TCASE("bar\0\0", 4, "seven"),
+    TCASE("baz\0\0", 4, "eight"),
+    TCASE("quux\0",  5, "nine"),
+
+    TCASE("foo1\0", 6, "ten"),
+    TCASE("bar1\0", 6, "eleven"),
+    TCASE("baz1\0", 6, "twelve"),
+    TCASE("quux1",  6, "thirteen"),
+
+    TCASE("f\xf3\x0a", 5, "value \x01"),
+    TCASE("ba\xffr", 5, "\x01\x02\x03"),
+    TCASE("ba\xffz", 5, "\0\0\0\0"),
+
+#undef TCASE
+
+};
+static const int n_items = sizeof(items)/sizeof(items[0]);
+
+static void
+run_seed(int seed)
+{
+    struct opr_cache_opts opts;
+    struct opr_cache *cache = NULL;
+    int item_i;
+    int missing;
+    int code;
+    char val[1024];
+    size_t val_len;
+
+    srand(seed);
+
+    val_len = sizeof(val);
+    code = opr_cache_get(cache, NULL, 0, val, &val_len);
+    is_int(ENOENT, code,
+       "Looking up in a NULL cache fails with ENOENT");
+
+    opr_cache_put(cache, NULL, 0, NULL, 0);
+    ok(1,
+       "Storing in a NULL cache does nothing");
+
+    memset(&opts, 0, sizeof(opts));
+
+    opts.n_buckets = 2;
+    opts.max_entries = 100;
+    ok(opr_cache_init(&opts, &cache) != 0,
+       "Initializing a cache with a tiny n_buckets fails");
+
+    opts.n_buckets = 0x40000000;
+    ok(opr_cache_init(&opts, &cache) != 0,
+       "Initializing a cache with a huge n_buckets fails");
+
+    opts.n_buckets = 1024*1024 + 1;
+    ok(opr_cache_init(&opts, &cache) != 0,
+       "Initializing a cache with 1024*1024+1 n_buckets fails");
+
+    opts.n_buckets = 1024*1024;
+    code = opr_cache_init(&opts, &cache);
+    is_int(0, code,
+       "Initializing a cache with 1024*1024 n_buckets succeeds");
+    opr_cache_free(&cache);
+
+    opts.n_buckets = 1024*1024 - 1;
+    code = opr_cache_init(&opts, &cache);
+    is_int(0, code,
+       "Initializing a cache with 1024*1024-1 n_buckets succeeds");
+    opr_cache_free(&cache);
+
+    opts.n_buckets = 23;
+    code = opr_cache_init(&opts, &cache);
+    is_int(0, code,
+       "Initializing a cache with non-power-of-2 n_buckets succeeds");
+    opr_cache_free(&cache);
+
+    opts.n_buckets = 64;
+    opts.max_entries = 1;
+    ok(opr_cache_init(&opts, &cache) != 0,
+       "Initializing a cache with a tiny max_entries fails");
+
+    opts.max_entries = 0x7fffffff;
+    ok(opr_cache_init(&opts, &cache) != 0,
+       "Initializing a cache with a huge max_entries fails");
+
+    opts.n_buckets = 8;
+    opts.max_entries = 12;
+
+    code = opr_cache_init(&opts, &cache);
+    is_int(0, code,
+       "Initializing a reasonably-sized cache succeeds");
+
+    ok(cache != NULL,
+       "Initializing a cache gives us a cache");
+
+    for (item_i = 0; item_i < n_items; item_i++) {
+	val_len = sizeof(val);
+	code = opr_cache_get(cache, items[item_i].key,
+			     items[item_i].key_len,
+			     val, &val_len);
+	is_int(ENOENT, code,
+	   "[item %d] Looking up in an empty cache fails with ENOENT", item_i);
+    }
+
+    for (item_i = 0; item_i < 12; item_i++) {
+	opr_cache_put(cache, items[item_i].key, items[item_i].key_len,
+		      items[item_i].val, items[item_i].val_len);
+    }
+    ok(1, "Cache filled successfully");
+
+    for (item_i = 0; item_i < 12; item_i++) {
+	val_len = sizeof(val);
+	code = opr_cache_get(cache, items[item_i].key, items[item_i].key_len,
+			     val, &val_len);
+	is_int(0, code, "[item %d] Lookup succeeds", item_i);
+	is_int(items[item_i].val_len, val_len,
+	   "[item %d] Lookup returns correct val_len %d",
+	   item_i, items[item_i].val_len);
+
+	ok(memcmp(val, items[item_i].val, val_len) == 0,
+	   "[item %d] Lookup returns correct val", item_i);
+    }
+
+    val_len = sizeof(val);
+    code = opr_cache_get(cache, NULL, 5, val, &val_len);
+    is_int(ENOENT, code,
+	"Looking up NULL key fails with ENOENT");
+
+    code = opr_cache_get(cache, val, 0, val, &val_len);
+    is_int(ENOENT, code,
+	"Looking up 0-length key fails with ENOENT");
+
+    opr_cache_put(cache, NULL, 0, val, val_len);
+    opr_cache_put(cache, NULL, 5, val, val_len);
+    opr_cache_put(cache, val, 0, val, val_len);
+    opr_cache_put(cache, val, val_len, NULL, 0);
+    opr_cache_put(cache, val, val_len, NULL, 5);
+    opr_cache_put(cache, val, val_len, val, 0);
+    opr_cache_put(cache, NULL, 0, NULL, 0);
+    opr_cache_put(cache, NULL, 5, NULL, 5);
+    opr_cache_put(cache, val, 0, val, 0);
+    ok(1, "Storing NULL/0-length entries does nothing");
+
+    code = opr_cache_get(cache, "123", 3, val, &val_len);
+    is_int(ENOENT, code, "Cache lookup fails for nonexistent item");
+
+    memcpy(val, "replace", 7);
+    val_len = 7;
+    opr_cache_put(cache, items[0].key, items[0].key_len, val, val_len);
+    ok(1, "Replacement store succeeds");
+
+    val_len = 1;
+    code = opr_cache_get(cache, items[0].key, items[0].key_len, val, &val_len);
+    is_int(ENOSPC, code, "Small lookup returns ENOSPC");
+
+    val_len = sizeof(val);
+    code = opr_cache_get(cache, items[0].key, items[0].key_len, val, &val_len);
+    is_int(0, code, "Replacement lookup succeeds");
+    is_int(7, val_len, "Lookup trims val_len");
+    ok(memcmp(val, "replace", 7) == 0,
+	"Replacement lookup returns correct value");
+
+    /* Set items[0] back to the original value. */
+    opr_cache_put(cache, items[0].key, items[0].key_len, items[0].val,
+		  items[0].val_len);
+
+    for (item_i = 12; item_i < n_items; item_i++) {
+	opr_cache_put(cache, items[item_i].key, items[item_i].key_len,
+		      items[item_i].val, items[item_i].val_len);
+    }
+    ok(1, "[seed %d] Cache over-filled successfully", seed);
+
+    missing = 0;
+    for (item_i = 0; item_i < n_items; item_i++) {
+	val_len = sizeof(val);
+	code = opr_cache_get(cache, items[item_i].key, items[item_i].key_len,
+			     val, &val_len);
+	if (code == ENOENT) {
+	    missing++;
+	    continue;
+	}
+	is_int(0, code, "[item %d] Lookup succeeds", item_i);
+	is_int(items[item_i].val_len, val_len,
+	   "[item %d] Lookup returns correct val_len %d",
+	   item_i, items[item_i].val_len);
+
+	ok(memcmp(val, items[item_i].val, val_len) == 0,
+	    "[item %d] Lookup returns correct val", item_i);
+    }
+
+    is_int(4, missing,
+	"[seed %d] Cache lookup fails for %d items", seed, missing);
+
+    opr_cache_free(&cache);
+    ok(1, "Cache free succeeds");
+    ok(cache == NULL, "Cache free NULLs arg");
+
+    opr_cache_free(&cache);
+    ok(1, "Double-free is noop");
+    ok(cache == NULL, "Cache is still NULL after double-free");
+}
+
+int
+main(void)
+{
+    int seed;
+
+    plan(116 * 32);
+
+    for (seed = 0; seed < 32; seed++) {
+	run_seed(seed);
+    }
+
+    return 0;
+}
diff --git a/tests/opr/softsig-t b/tests/opr/softsig-t
index 533feb4fd..d750d98dd 100755
--- a/tests/opr/softsig-t
+++ b/tests/opr/softsig-t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 #
 # Copyright (c) 2010 Your File System Inc. All rights reserved.
 #
@@ -32,7 +32,17 @@ use FindBin qw($Bin);
 
 # Start up our test process, and send it various signals. Check that these
 # signals make it to it correctly, and are reported on the command line.
-my $softsig_helper = $Bin . "/softsig-helper";
+
+my $softsig_helper;
+
+# Our softsig helper should be in $TOP_OBJDIR/tests/opr. To calculate that
+# path, use the C_TAP_BUILD env var if the test harness has set it; otherwise,
+# our next best guess is that it's in the same dir as this script.
+if (defined($ENV{C_TAP_BUILD})) {
+    $softsig_helper = $ENV{C_TAP_BUILD} . "/opr/softsig-helper";
+} else {
+    $softsig_helper = $Bin . "/softsig-helper";
+}
 
 # This -dummy argument prevents Perl from putting an intermediate sh
 # -c between us and softsig-helper in the case where the build
@@ -88,6 +98,7 @@ is($? & 0x7f, SIGSEGV, "Helper exited on SEGV signal.");
 SKIP: {
     my $sigbus = eval "SIGBUS";
     skip("Skipping buserror test; SIGBUS constant is not defined.", 1) unless $sigbus;
+    skip("Skipping buserror test; test unreliable on FreeBSD.", 1) if ($^O eq 'freebsd');
 
     my ($fh, $path) = mkstemp("/tmp/softsig-t_XXXXXX");
     $pid = open(HELPER, "-|", $softsig_helper, "-buserror", $path)
diff --git a/tests/ptserver/pt_util-t b/tests/ptserver/pt_util-t
index 8d3cdcb87..553b2be43 100755
--- a/tests/ptserver/pt_util-t
+++ b/tests/ptserver/pt_util-t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
@@ -6,7 +6,7 @@ use warnings;
 use File::Basename;
 use Test::More tests=>2;
 
-my $builddir = $ENV{BUILD};
+my $builddir = $ENV{C_TAP_BUILD};
 if (!$builddir) {
   $builddir = dirname($0)."/..";
 }
diff --git a/tests/ptserver/pts-man-t b/tests/ptserver/pts-man-t
index 60645ea2b..0376f02a5 100755
--- a/tests/ptserver/pts-man-t
+++ b/tests/ptserver/pts-man-t
@@ -1,25 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
-use File::Basename;
-use lib "./tests-lib/perl5";
+use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
 use mancheck_utils;
 
-# Set this to the bare command to test
-my $command = 'pts';
-my $builddir = $ENV{BUILD};
-if (!$builddir) {
-    $builddir = dirname($0) . "/..";
-}
-$builddir .= "/..";
-# Set this to the directory holding $command
-my $srcdir = "$builddir/src/ptserver";
-
-#---------------------------------------------------------------------
-
-my @sub_commands = lookup_sub_commands($srcdir, $command);
-plan tests => scalar @sub_commands;
-
-test_command_man_pages($builddir, $command, @sub_commands);
-
+run_manpage_tests("src/ptserver", "pts");
diff --git a/tests/rpctestlib/Makefile.in b/tests/rpctestlib/Makefile.in
index f88349cf9..df82732a1 100644
--- a/tests/rpctestlib/Makefile.in
+++ b/tests/rpctestlib/Makefile.in
@@ -25,7 +25,7 @@ headers= ${RTL}/rpc_test_procs.h
 
 RTLOBJS= rpc_test_procs.o rpc_test_cb_procs.o
 
-FSINTOBJS= afsaux.o afscbint.ss.o afsint.cs.o afscbint.xdr.o \
+FSINTOBJS= afscbint.ss.o afsint.cs.o afscbint.xdr.o \
 	afsint.xdr.o
 
 RXOBJS = rx_pthread.o
@@ -46,9 +46,6 @@ rpc_test_main.o: ${RTL}/rpc_test_main.c ${headers}
 rpc_test_procs.o: ${RTL}/rpc_test_procs.c ${headers}
 rpc_test_cb_procs.o: ${RTL}/rpc_test_cb_procs.c ${headers}
 
-CFLAGS_afsaux.o = -I{FSINT}
-afsaux.o: ${FSINT}/afsaux.c
-	$(AFS_CCRULE) ${FSINT}/afsaux.c
 afscbint.ss.o: ${FSINT}/afscbint.ss.c
 	$(AFS_CCRULE) ${FSINT}/afscbint.ss.c
 afsint.cs.o: ${FSINT}/afsint.cs.c
diff --git a/tests/rpctestlib/NTMakefile b/tests/rpctestlib/NTMakefile
index 0d929bfba..7f5dde0fd 100644
--- a/tests/rpctestlib/NTMakefile
+++ b/tests/rpctestlib/NTMakefile
@@ -32,7 +32,7 @@ RXOBJS = $(OUT)\xdr_int64.obj \
 
 RTLOBJS= $(OUT)\rpc_test_procs.obj $(OUT)\rpc_test_cb_procs.obj
 
-FSINTOBJS = $(OUT)\afsaux.obj $(OUT)\afscbint.ss.obj $(OUT)\afsint.cs.obj \
+FSINTOBJS = $(OUT)\afscbint.ss.obj $(OUT)\afsint.cs.obj \
 	$(OUT)\afscbint.xdr.obj $(OUT)\afsint.xdr.obj
 
 LIBOBJS = $(RTLOBJS) $(FSINTOBJS) $(RXOBJS)
diff --git a/tests/rpctestlib/rpc_test_procs.c b/tests/rpctestlib/rpc_test_procs.c
index 7b70a861c..586324207 100644
--- a/tests/rpctestlib/rpc_test_procs.c
+++ b/tests/rpctestlib/rpc_test_procs.c
@@ -179,12 +179,7 @@ afs_int32 init_callback_service(rpc_test_request_ctx *ctx)
     afs_uuid_create(&(ctx->cb_listen_addr.uuid));
 
 #if !defined(RPC_TEST_GLOBAL_RX_INIT)
-#if 0
-    code = rx_InitHost(ctx->cb_listen_addr.addr_in[0],
-                       (int) htons(ctx->cb_port));
-#else
     code = rx_Init((int) htons(ctx->cb_port));
-#endif
 #endif /* RPC_TEST_GLOBAL_RX_INIT */
 
     assert(pthread_attr_init(&tattr) == 0);
diff --git a/tests/rx/Makefile.in b/tests/rx/Makefile.in
index f5b4cf924..373aac6ef 100644
--- a/tests/rx/Makefile.in
+++ b/tests/rx/Makefile.in
@@ -5,7 +5,7 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.pthread
 
-MODULE_CFLAGS = -I$(srcdir)/../..
+MODULE_CFLAGS = -I$(TOP_OBJDIR)
 
 LIBS = ../tap/libtap.a \
        $(abs_top_builddir)/src/rx/liboafs_rx.la
diff --git a/tests/rx/event-t.c b/tests/rx/event-t.c
index 9c2b8e15e..008cadb2f 100644
--- a/tests/rx/event-t.c
+++ b/tests/rx/event-t.c
@@ -179,7 +179,7 @@ main(void)
 
     ok(1, "Added %d events", NUMEVENTS);
 
-    sleep(3);
+    sleep(4);
 
     fired = 0;
     cancelled = 0;
@@ -193,7 +193,9 @@ main(void)
 	    fail = 1;
     }
     ok(!fail, "Didn't fire any cancelled events");
-    ok(fired+cancelled == NUMEVENTS,
+    diag("fired %d/%d events", fired, NUMEVENTS);
+    diag("cancelled %d/%d events", cancelled, NUMEVENTS);
+    is_int(NUMEVENTS, fired+cancelled,
 	"Number of fired and cancelled events sum to correct total");
 
     return 0;
diff --git a/tests/rx/perf-t b/tests/rx/perf-t
index 025d6b5e3..a6ce38749 100755
--- a/tests/rx/perf-t
+++ b/tests/rx/perf-t
@@ -1,4 +1,4 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
@@ -7,7 +7,7 @@ use Test::More tests=>4;
 use POSIX qw(:sys_wait_h :signal_h);
 
 my $port = 4000;
-my $build = $ENV{BUILD};
+my $build = $ENV{C_TAP_BUILD};
 $build = ".." if (!defined($build));
 my $rxperf = $build."/../src/tools/rxperf/rxperf";
 
diff --git a/tests/tests-lib/perl5/mancheck_utils.pm b/tests/tests-lib/perl5/mancheck_utils.pm
index edfa8fc3d..62e1693cf 100644
--- a/tests/tests-lib/perl5/mancheck_utils.pm
+++ b/tests/tests-lib/perl5/mancheck_utils.pm
@@ -52,7 +52,7 @@ sub lookup_sub_commands {
 #
 # Arguments:
 #
-#                builddir : A path to the OpenAFS build directory,
+#                  srcdir : A path to the OpenAFS source directory,
 #                           such as /tmp/1.4.14
 #
 #                 command : the name of the command (e.g. vos)
@@ -60,7 +60,7 @@ sub lookup_sub_commands {
 #             subcommlist : a list of sub-commands for command
 #
 sub test_command_man_pages {
-    my ($builddir, $command, @subcommlist) = @_;
+    my ($srcdir, $command, @subcommlist) = @_;
 
     # The following is because File::Find makes no sense to me
     # for this purpose, and actually seems totally misnamed
@@ -69,9 +69,9 @@ sub test_command_man_pages {
     my $frex = "";
     # Since we don't know what man section it might be in,
     # search all existing man page files for a filename match
-    my @mandirglob = glob("$builddir/doc/man-pages/man[1-8]/*");
+    my @mandirglob = glob("$srcdir/doc/man-pages/man[1-8]/*");
     # For every subcommand, see if command_subcommand.[1-8] exists
-    # in our man page build dir.
+    # in our man page source dir.
     foreach (@subcommlist) {
         my $subcommand = $_;
         $found = 0;
@@ -89,4 +89,28 @@ sub test_command_man_pages {
 	ok($found eq 1, "existence of man page for $command" . "_$subcommand");
     }
 }
+
+#
+# Setup the test plan and run all of the tests for the given command suite.
+#
+# Call like so:
+# run_manpage_tests("src/ptserver", "pts");
+#
+sub run_manpage_tests($$) {
+    my ($subdir, $command) = @_;
+
+    # When run from 'runtests', our cwd will be TOP_OBJDIR/tests. $C_TAP_SOURCE
+    # is set to TOP_SRCDIR/tests, and $C_TAP_BUILD is set to TOP_OBJDIR/tests.
+    # We want the top-level src and obj dirs, in order to find the relevant
+    # binaries and manpages.
+    my $srcdir = $ENV{C_TAP_SOURCE} . "/..";
+    my $objdir = $ENV{C_TAP_BUILD} . "/..";
+
+    my @sub_commands = lookup_sub_commands("$objdir/$subdir", $command);
+    die("No subcommands found in $objdir/$subdir/$command?") unless(@sub_commands);
+
+    plan tests => scalar @sub_commands;
+
+    test_command_man_pages($srcdir, $command, @sub_commands);
+}
 1;
diff --git a/tests/util/.gitignore b/tests/util/.gitignore
index 02663aec9..b44d7d666 100644
--- a/tests/util/.gitignore
+++ b/tests/util/.gitignore
@@ -5,3 +5,4 @@
 /exec-alt-t
 /ktime-t
 /queues-t
+/volutil-t
diff --git a/tests/util/Makefile.in b/tests/util/Makefile.in
index 763ac89c9..28debc01d 100644
--- a/tests/util/Makefile.in
+++ b/tests/util/Makefile.in
@@ -5,13 +5,13 @@ abs_top_builddir=@abs_top_builddir@
 include @TOP_OBJDIR@/src/config/Makefile.config
 include @TOP_OBJDIR@/src/config/Makefile.lwp
 
-MODULE_CFLAGS = -I$(srcdir)/../..
+MODULE_CFLAGS = -I$(TOP_OBJDIR)
 
 LIBS = ../tap/libtap.a \
        $(abs_top_builddir)/lib/util.a \
        $(abs_top_builddir)/lib/libopr.a
 
-tests = ktime-t exec-alt-t
+tests = ktime-t exec-alt-t volutil-t
 
 all check test tests: $(tests)
 
@@ -21,6 +21,9 @@ ktime-t: ktime-t.o $(LIBS)
 exec-alt-t: exec-alt-t.o $(LIBS)
 	$(AFS_LDRULE) exec-alt-t.o $(LIBS) $(XLIBS)
 
+volutil-t: volutil-t.o $(LIBS)
+	$(AFS_LDRULE) volutil-t.o $(LIBS) $(LIB_roken) $(XLIBS)
+
 install:
 
 clean distclean:
diff --git a/tests/util/volutil-t.c b/tests/util/volutil-t.c
new file mode 100644
index 000000000..c598071ab
--- /dev/null
+++ b/tests/util/volutil-t.c
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2018, Sine Nomine Associates and others.
+ * All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <afsconfig.h>
+#include <afs/param.h>
+
+#include <afs/afsutil.h>
+#include <tests/tap/basic.h>
+
+char *out_of_range_names[] = {
+    "/vicepiv",
+    "/vicepzz",
+    "iv",
+    "zz",
+    "255",
+    "256",
+    NULL,
+};
+
+char *invalid_names[] = {
+    "",
+    "/vice",
+    "/vicep",
+    "/vicepbogus",
+    "/vicep0",
+    "foo",
+    "!?",
+    "-1",
+    NULL,
+};
+
+void
+test_partition_name_to_id(void)
+{
+    char x, y;
+    int id;
+    char part[32];
+    char **t;
+
+    /*
+     * Test conversion of XX to partition id,
+     * where XX is "a".."z", "aa"..."iu"
+     */
+    id = 0;
+    for (x = 'a'; x <= 'z'; x++, id++) {
+        sprintf(part, "%c", x);
+        is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+    }
+    for (x = 'a'; x <= 'i'; x++) {
+        for (y = 'a'; y <= 'z'; y++, id++) {
+            sprintf(part, "%c%c", x, y);
+            is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+            if (x == 'i' && y == 'u')
+                break;
+        }
+    }
+
+    /*
+     * Test conversion of /vicepXX to partition id,
+     * where XX is "a".."z", "aa"..."iu".
+     */
+    id = 0;
+    for (x = 'a'; x <= 'z'; x++, id++) {
+        sprintf(part, "/vicep%c", x);
+        is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+    }
+    for (x = 'a'; x <= 'i'; x++) {
+        for (y = 'a'; y <= 'z'; y++, id++) {
+            sprintf(part, "/vicep%c%c", x,y );
+            is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+            if (x == 'i' && y == 'u')
+                break;
+        }
+    }
+
+    /*
+     * Test conversion of vicepXX to partition id,
+     * where XX is "a".."z", "aa"..."iu".
+     */
+    id = 0;
+    for (x = 'a'; x <= 'z'; x++, id++) {
+        sprintf(part, "vicep%c", x);
+        is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+    }
+    for (x = 'a'; x <= 'i'; x++) {
+        for (y = 'a'; y <= 'z'; y++, id++) {
+            sprintf(part, "vicep%c%c", x,y );
+            is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+            if (x == 'i' && y == 'u')
+                break;
+        }
+    }
+
+    /*
+     * Test numeric names in the range "0".."254" are passed through.
+     */
+    for (id = 0; id <= 254; id++) {
+        sprintf(part, "%d", id);
+        is_int(id, volutil_GetPartitionID(part), "\"%s\" is %d", part, id);
+    }
+
+    /*
+     * Test out of range names.
+     */
+    for (t = out_of_range_names; *t != NULL; t++) {
+        is_int(-1, volutil_GetPartitionID(*t), "\"%s\" is out of range", *t);
+    }
+
+    /*
+     * Test invalid names.
+     */
+    for (t = invalid_names; *t != NULL; t++) {
+        is_int(-1, volutil_GetPartitionID(*t), "\"%s\" is invalid", *t);
+    }
+}
+
+void
+test_partition_id_to_name(void)
+{
+    char x, y;
+    int id;
+    char part[32];
+
+    /*
+     * Test conversion of ids to partition names,
+     * for ids of 0 to 254.
+     */
+    id = 0;
+    for (x = 'a'; x <= 'z'; x++, id++) {
+        sprintf(part, "/vicep%c", x);
+        is_string(part, volutil_PartitionName(id), "%d is \"%s\"", id, part);
+    }
+    for (x = 'a'; x <= 'i'; x++) {
+        for (y = 'a'; y <= 'z'; y++, id++) {
+            sprintf(part, "/vicep%c%c", x,y );
+            is_string(part, volutil_PartitionName(id), "%d is \"%s\"", id, part);
+            if (x == 'i' && y == 'u')
+                break;
+        }
+    }
+
+    /* Test out of range values. */
+    is_string("BAD VOLUME ID", volutil_PartitionName(-1), "-1 is invalid");
+    is_string("BAD VOLUME ID", volutil_PartitionName(255), "255 is invalid");
+    is_string("BAD VOLUME ID", volutil_PartitionName(256), "256 is invalid");
+
+    /* Test buffer too short (thread safe variant of volutil_PartitionName). */
+    is_string("SPC", volutil_PartitionName_r(0, part, 4), "buffer too short");
+}
+
+int
+main(int argc, char **argv)
+{
+    plan(1293);
+    test_partition_name_to_id();
+    test_partition_id_to_name();
+    return 0;
+}
diff --git a/tests/venus/fs-man-t b/tests/venus/fs-man-t
index 3267b5ddd..219a33a32 100755
--- a/tests/venus/fs-man-t
+++ b/tests/venus/fs-man-t
@@ -1,25 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
-use File::Basename;
-use lib "./tests-lib/perl5";
+use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
 use mancheck_utils;
 
-# Set this to the bare command to test
-my $command = 'fs';
-my $builddir = $ENV{BUILD};
-if (!$builddir) {
-    $builddir = dirname($0) . "/..";
-}
-$builddir .= "/..";
-# Set this to the directory holding $command
-my $srcdir = "$builddir/src/venus";
-
-#---------------------------------------------------------------------
-
-my @sub_commands = lookup_sub_commands($srcdir, $command);
-plan tests => scalar @sub_commands;
-
-test_command_man_pages($builddir, $command, @sub_commands);
-
+run_manpage_tests("src/venus", "fs");
diff --git a/tests/volser/Makefile.in b/tests/volser/Makefile.in
index 6ba9d46d6..041480b7d 100644
--- a/tests/volser/Makefile.in
+++ b/tests/volser/Makefile.in
@@ -6,7 +6,7 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread
 
 TESTS = vos-t
 
-MODULE_CFLAGS=-I$(srcdir)/../.. -I$(srcdir)/../common/
+MODULE_CFLAGS=-I$(TOP_OBJDIR) -I$(srcdir)/../common/
 
 all check test tests: $(TESTS)
 
@@ -15,9 +15,10 @@ MODULE_LIBS = 	../tap/libtap.a \
 		$(XLIBS)
 
 vos-t: vos-t.o ../common/config.o ../common/servers.o ../common/ubik.o \
-		../common/network.o
+		../common/network.o ../common/misc.o
 	$(LT_LDRULE_static) vos-t.o ../common/config.o ../common/servers.o \
-		../common/ubik.o ../common/network.o $(MODULE_LIBS)
+		../common/ubik.o ../common/network.o ../common/misc.o \
+		$(MODULE_LIBS)
 
 clean:
 	$(LT_CLEAN)
diff --git a/tests/volser/vos-man-t b/tests/volser/vos-man-t
index 2e2cc3560..af0fb3081 100755
--- a/tests/volser/vos-man-t
+++ b/tests/volser/vos-man-t
@@ -1,25 +1,9 @@
-#!/usr/bin/perl
+#!/usr/bin/env perl
 
 use strict;
 use warnings;
-use File::Basename;
-use lib "./tests-lib/perl5";
+use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5";
 use mancheck_utils;
 
-# Set this to the bare command to test
-my $command = 'vos';
-my $builddir = $ENV{BUILD};
-if (!$builddir) {
-    $builddir = dirname($0) . "/..";
-}
-$builddir .= "/..";
-# Set this to the directory holding $command
-my $srcdir = "$builddir/src/volser";
-
-#---------------------------------------------------------------------
-
-my @sub_commands = lookup_sub_commands($srcdir, $command);
-plan tests => scalar @sub_commands;
-
-test_command_man_pages($builddir, $command, @sub_commands);
+run_manpage_tests("src/volser", "vos");
 
diff --git a/tests/volser/vos-t.c b/tests/volser/vos-t.c
index 57161f477..05ec8fd75 100644
--- a/tests/volser/vos-t.c
+++ b/tests/volser/vos-t.c
@@ -69,7 +69,7 @@ TestListAddrs(struct ubik_client *client, char *dirname)
 	close(outpipe[0]);
 	close(outpipe[1]);
 
-	build = getenv("BUILD");
+	build = getenv("C_TAP_BUILD");
 	if (build == NULL)
 	    build = "..";
 
@@ -78,7 +78,7 @@ TestListAddrs(struct ubik_client *client, char *dirname)
 	    exit(1);
 	}
 	execl(binPath, "vos",
-	      "listaddrs", "-config", dirname, "-noauth", NULL);
+	      "listaddrs", "-config", dirname, "-noauth", "-noresolve", NULL);
 	exit(1);
     }
     close(outpipe[1]);
@@ -96,15 +96,18 @@ main(int argc, char **argv)
     char *dirname;
     struct afsconf_dir *dir;
     int code, secIndex;
-    pid_t serverPid;
+    pid_t serverPid = 0;
     struct rx_securityClass *secClass;
     struct ubik_client *ubikClient = NULL;
     int ret = 0;
+    char *argv0 = afstest_GetProgname(argv);
 
     /* Skip all tests if the current hostname can't be resolved */
     afstest_SkipTestsIfBadHostname();
     /* Skip all tests if the current hostname is on the loopback network */
     afstest_SkipTestsIfLoopbackNetIsDefault();
+    /* Skip all tests if a vlserver is already running on this system. */
+    afstest_SkipTestsIfServerRunning("afs3-vlserver");
 
     plan(6);
 
@@ -116,24 +119,22 @@ main(int argc, char **argv)
 
     code = afstest_AddDESKeyFile(dir);
     if (code) {
-	afs_com_err("vos-t", code, "while adding test DES keyfile");
+	afs_com_err(argv0, code, "while adding test DES keyfile");
 	ret = 1;
 	goto out;
     }
 
     code = afstest_StartVLServer(dirname, &serverPid);
     if (code) {
-	afs_com_err("vos-t", code, "while starting the vlserver");
+	afs_com_err(argv0, code, "while starting the vlserver");
 	ret = 1;
 	goto out;
     }
 
-    /* Let it figure itself out ... */
-    sleep(5);
     code = afsconf_ClientAuthSecure(dir, &secClass, &secIndex);
     is_int(code, 0, "Successfully got security class");
     if (code) {
-	afs_com_err("authname-t", code, "while getting anonymous secClass");
+	afs_com_err(argv0, code, "while getting anonymous secClass");
 	ret = 1;
 	goto out;
     }
@@ -142,17 +143,19 @@ main(int argc, char **argv)
 				 secClass, secIndex, &ubikClient);
     is_int(code, 0, "Successfully built ubik client structure");
     if (code) {
-	afs_com_err("vos-t", code, "while building ubik client");
+	afs_com_err(argv0, code, "while building ubik client");
 	ret = 1;
 	goto out;
     }
 
     TestListAddrs(ubikClient, dirname);
 
-    code = afstest_StopServer(serverPid);
-    is_int(0, code, "Server exited cleanly");
-
 out:
+    if (serverPid != 0) {
+	code = afstest_StopServer(serverPid);
+	is_int(0, code, "Server exited cleanly");
+    }
+
     afstest_UnlinkTestConfig(dirname);
     return ret;
 }
