diff --git a/NEWS b/NEWS
index 952a20bd16..af8ad39f85 100644
--- a/NEWS
+++ b/NEWS
@@ -1,5 +1,66 @@
                        User-Visible OpenAFS Changes
 
+OpenAFS 1.8.15pre1
+
+  All platforms
+
+    * The generically named lock.h header file has been renamed to
+      afs/afs_lock.h to avoid conflicts with other software.  For
+      backward compatibility, a wrapper lock.h is still provided, ensuring
+      that older software built against OpenAFS will continue to compile. Any
+      users of lock.h should update to using afs/afs_lock.h as soon as
+      possible; the lock.h wrapper will be removed in the future.
+      (16605, 16610, 16611)
+
+  All server platforms
+
+    * A fileserver bug has been fixed where uninitialized data from the
+      stack could be sent over the network when handling certain
+      protection-related RPCs. This change prevents a potential information
+      leak. (16207)
+
+    * A potential race condition has been fixed in the fileserver that was
+      only triggerable by the obsolete RXAFS_GetVolumeInfo RPC. (16206)
+
+    * A fileserver bug has been fixed where the SRXAFS_GetStatistics64 RPC
+      could send 4 bytes of uninitialized memory over the network. This change
+      prevents a potential information leak from the fileserver. (16205)
+
+  All UNIX clients
+
+    * A long-standing bug has been fixed in the afs_create() operation where
+      callback expiration was processed incorrectly.  This could lead
+      to processes reading stale data for newly-created files under certain
+      conditions. (16612)
+
+    * A memory leak during error conditions in the PGetVolumeStatus pioctl
+      has been fixed. (16262)
+
+    * A race condition has been fixed where the client asserts during startup
+      when the client was started with `afsd -fakestat` or `afsd -fakestat-all`
+      and a user attempts to set a token early in the startup. (16653)
+
+  Linux client
+
+    * Support for Linux kernel 6.17 has been added. (16603, 16604)
+
+    * A potential race condition on Linux clients has been fixed that could
+      cause a spurious SIGBUS error when reading memory-mapped files from AFS.
+      This bug was introduced in OpenAFS 1.6.0. (16616)
+
+  MacOS client
+
+    * A bug has been fixed where the privhelper component of the prefpane was
+      not honoring the configured compiler flags.  This caused the prefpane
+      operations to not work on x86 for universal packages built on arm. (16662)
+
+  AIX
+
+    * Build support for AIX has been improved. (16125, 16126, 16127, 16128,
+      16129, 16633, 16634)
+
+    * Installation instructions for AIX have been reinstated. (16635)
+
 OpenAFS 1.8.14
 
   All platforms
diff --git a/configure-libafs.ac b/configure-libafs.ac
index ce579ec42d..326239fce8 100644
--- a/configure-libafs.ac
+++ b/configure-libafs.ac
@@ -4,7 +4,7 @@ AC_CONFIG_AUX_DIR([build-tools])
 AC_CONFIG_SRCDIR([src/libafs/Makefile.common.in])
 
 AC_CONFIG_HEADERS([src/config/afsconfig.h])
-MACOS_VERSION=1.8.14
+MACOS_VERSION=1.8.15fc1
 
 AC_SUBST([MACOS_VERSION])
 
diff --git a/configure.ac b/configure.ac
index 2481997fae..0a4f578098 100644
--- a/configure.ac
+++ b/configure.ac
@@ -5,7 +5,7 @@ AC_CONFIG_MACRO_DIR([src/cf])
 AC_CONFIG_SRCDIR([src/config/stds.h])
 
 AC_CONFIG_HEADERS([src/config/afsconfig.h])
-MACOS_VERSION=1.8.14
+MACOS_VERSION=1.8.15fc1
 
 AC_SUBST([MACOS_VERSION])
 
diff --git a/doc/protocol/rx-spec.h b/doc/protocol/rx-spec.h
index d3ad9b05d9..1677d5b233 100644
--- a/doc/protocol/rx-spec.h
+++ b/doc/protocol/rx-spec.h
@@ -457,7 +457,7 @@
  * here will be fully defined later, in Section 2.3.2. 
  * 
  * \code
- * #include <afs/lock.h> 
+ * #include <afs/afs_lock.h>
  * 
  * struct Vnode { 
  * 	... 
diff --git a/doc/txt/ubik.txt b/doc/txt/ubik.txt
index 547654fe86..89aab65f5d 100644
--- a/doc/txt/ubik.txt
+++ b/doc/txt/ubik.txt
@@ -1314,7 +1314,7 @@ THREAD SAFETY
 
       + ulock_Debug should use LOCK_LOCK/LOCK_UNLOCK when examining the
         internals of struct Lock.  Ideally, knowledge of these internals
-        should be abstracted to src/lwp/lock.h.
+        should be abstracted to src/lwp/afs_lock.h.
 
       + ubeacon_Debug() should hold the beacon lock while accessing the
         value of 'syncSiteUntil' and, if the access is moved here from
diff --git a/doc/xml/QuickStartUnix/appendix.xml b/doc/xml/QuickStartUnix/appendix.xml
index ded9d23215..dee969e913 100644
--- a/doc/xml/QuickStartUnix/appendix.xml
+++ b/doc/xml/QuickStartUnix/appendix.xml
@@ -622,6 +622,11 @@ ll name</replaceable>&gt; <emphasis
         <para>For convenience, the following sections group this procedure by
         system type. Proceed to the appropriate section.
           <itemizedlist>
+            <listitem>
+              <para>
+                <link linkend="KAS012">Enabling AFS Login on AIX Systems</link>
+              </para>
+            </listitem>
             <listitem>
               <para>
                 <link linkend="KAS015">Enabling AFS Login on Linux Systems</link>
@@ -635,6 +640,145 @@ ll name</replaceable>&gt; <emphasis
           </itemizedlist>
         </para>
       </sect2>
+      <sect2 id="KAS012">
+        <title>Enabling kaserver based AFS login</title>
+                
+        <para>Now incorporate AFS into the AIX secondary authentication system. 
+          <orderedlist>
+            <listitem>
+              <para>Issue the <emphasis role="bold">ls</emphasis> command to 
+              verify that the <emphasis role="bold">afs_dynamic_auth</emphasis> 
+              and <emphasis role="bold">afs_dynamic_kerbauth</emphasis> 
+              programs are installed in the local 
+              <emphasis role="bold">/usr/vice/etc</emphasis> directory. 
+<programlisting>
+   # <emphasis role="bold">ls /usr/vice/etc</emphasis>   
+</programlisting>
+              </para>
+
+              <para>If the files do not exist, unpack the 
+              OpenAFS Binary Distribution for AIX (if it is not already), 
+              change directory as indicated, and copy them.</para>
+
+<programlisting>
+   # <emphasis role="bold">cd /tmp/afsdist/rs_aix42/dest/root.client/usr/vice/etc</emphasis>
+   # <emphasis role="bold">cp  -p  afs_dynamic*  /usr/vice/etc</emphasis>
+</programlisting>
+            </listitem>
+
+            <listitem>
+              <para>Edit the local 
+              <emphasis role="bold">/etc/security/user</emphasis> file, making 
+              changes to the indicated stanzas:
+                <itemizedlist>
+                  <listitem>
+                    <para>In the default stanza, set the 
+                    <computeroutput>registry</computeroutput> attribute to 
+                    <emphasis role="bold">DCE</emphasis> (not to 
+                    <emphasis role="bold">AFS</emphasis>), as follows: 
+<programlisting>
+   registry = DCE
+</programlisting>
+                    </para>
+                  </listitem>
+
+                  <listitem>
+                    <para>In the default stanza, set the 
+                    <computeroutput>SYSTEM</computeroutput> attribute as 
+                    indicated.</para>
+
+                    <para>If the machine is an AFS client only, set the 
+                    following value:</para>
+<programlisting>
+   SYSTEM = "AFS OR (AFS[UNAVAIL] AND compat[SUCCESS])"   
+</programlisting>
+
+                    <para>If the machine is both an AFS and a DCE client, 
+                    set the following value (it must appear on a single line in
+                    the file):</para>
+<programlisting>
+   SYSTEM = "DCE OR DCE[UNAVAIL] OR AFS OR (AFS[UNAVAIL]  \
+       AND compat[SUCCESS])"
+</programlisting>
+                  </listitem>
+
+                  <listitem>
+                    <para>In the <computeroutput>root</computeroutput> 
+                    stanza, set the <computeroutput>registry</computeroutput>
+                    attribute as follows. It enables the local superuser 
+                    <emphasis role="bold">root</emphasis> to log into the local
+                    file system only, based on the password listed in the 
+                    local password file. 
+<programlisting>
+   root:
+         registry = files
+</programlisting>
+                    </para>
+                  </listitem>
+                </itemizedlist>
+              </para>
+            </listitem>
+
+            <listitem>
+              <para>Edit the local 
+              <emphasis role="bold">/etc/security/login.cfg</emphasis> file, 
+              creating or editing the indicated stanzas: 
+                <itemizedlist>
+                  <listitem>
+                    <para>In the <computeroutput>DCE</computeroutput> stanza, 
+                    set the <computeroutput>program</computeroutput>
+                    attribute as follows.</para>
+
+                    <para>If you use the AFS Authentication Server 
+                    (<emphasis role="bold">kaserver</emphasis> process):</para>
+<programlisting>
+   DCE:
+        program = /usr/vice/etc/afs_dynamic_auth   
+</programlisting>
+
+                    <para>If you use a Kerberos v4 implementation of AFS 
+                    authentication:</para>
+
+<programlisting>
+   DCE:
+        program = /usr/vice/etc/afs_dynamic_kerbauth
+</programlisting>
+                  </listitem>
+
+                  <listitem>
+                    <para>In the <computeroutput>AFS</computeroutput> stanza, 
+                    set the <computeroutput>program</computeroutput>
+                    attribute as follows.</para>
+
+                    <para>If you use the AFS Authentication Server 
+                    (<emphasis role="bold">kaserver</emphasis> process):</para>
+<programlisting>
+   AFS:
+        program = /usr/vice/etc/afs_dynamic_auth   
+</programlisting>
+
+                    <para>If you use a Kerberos v4 implementation of AFS 
+                    authentication:</para>
+<programlisting>
+   AFS:
+        program = /usr/vice/etc/afs_dynamic_kerbauth
+</programlisting>
+                </listitem>
+                </itemizedlist>
+              </para>
+            </listitem>
+            <listitem>
+              <para>Proceed to 
+              <link linkend="HDRWQ50">Starting the BOS Server</link>,
+              if you are installing your first file server machine;
+              <link linkend="HDRWQ108">Starting Server Programs</link>, 
+              if you are installing an additional file server machine; or
+              <link linkend="HDRWQ145">Loading and Creating Client Files</link>
+              if you are installating a client</para>
+            </listitem>
+          </orderedlist>
+        </para>
+      </sect2>
       <sect2 id="KAS015">
         <title>Enabling kaserver based AFS Login on Linux Systems</title>
         
diff --git a/doc/xml/QuickStartUnix/auqbg005.xml b/doc/xml/QuickStartUnix/auqbg005.xml
index c4d706d55a..ac6ade597a 100644
--- a/doc/xml/QuickStartUnix/auqbg005.xml
+++ b/doc/xml/QuickStartUnix/auqbg005.xml
@@ -438,6 +438,10 @@
         <listitem>
           <para><link linkend="HDRWQ45">Getting Started on Solaris Systems</link></para>
         </listitem>
+
+        <listitem>
+          <para><link linkend="HDRWQ21">Getting Started on AIX Systems</link></para>
+        </listitem>
       </itemizedlist></para>
   </sect1>
 
@@ -1445,6 +1449,316 @@ auth  required                pam_unix.so try_first_pass</literallayout>
     </sect2>
   </sect1>
 
+  <sect1 id="HDRWQ21">
+    <title>Getting Started on AIX Systems</title>
+
+    <para>Begin by running the AFS initialization script to call the AIX kernel extension facility, which dynamically loads AFS
+    modifications into the kernel. Then use the <emphasis role="bold">SMIT</emphasis> program to configure partitions for storing
+    AFS volumes, and replace the AIX <emphasis role="bold">fsck</emphasis> program helper with a version that correctly handles AFS
+    volumes. If the machine is to remain an AFS client machine, incorporate AFS into the AIX secondary authentication system.
+    <indexterm>
+        <primary>incorporating AFS kernel extensions</primary>
+
+        <secondary>first AFS machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm> <indexterm>
+        <primary>AFS kernel extensions</primary>
+
+        <secondary>on first AFS machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm> <indexterm>
+        <primary>first AFS machine</primary>
+
+        <secondary>AFS kernel extensions</secondary>
+
+        <tertiary>on AIX</tertiary>
+      </indexterm> <indexterm>
+        <primary>AIX</primary>
+
+        <secondary>AFS kernel extensions</secondary>
+
+        <tertiary>on first AFS machine</tertiary>
+      </indexterm></para>
+
+    <sect2 id="HDRWQ22">
+      <title>Loading AFS into the AIX Kernel</title>
+
+      <para>The AIX kernel extension facility is the dynamic kernel loader
+      provided by IBM Corporation.  AIX does not support incorporation of
+      AFS modifications during a kernel build.</para>
+
+      <para>For AFS to function correctly, the kernel extension facility must run each time the machine reboots, so the AFS
+      initialization script (included in the AFS distribution) invokes it automatically. In this section you copy the script to the
+      conventional location and edit it to select the appropriate options depending on whether NFS is also to run.</para>
+
+      <para>After editing the script, you run it to incorporate AFS into the kernel. In later sections you verify that the script
+      correctly initializes all AFS components, then configure the AIX <emphasis role="bold">inittab</emphasis> file so that the
+      script runs automatically at reboot. <orderedlist>
+          <listitem>
+            <para>Unpack the distribution tarball. The examples below assume 
+            that you have unpacked the files into the 
+            <emphasis role="bold">/tmp/afsdist</emphasis> directory. If you 
+            pick a different location, substitute this in all of the following 
+            examples. Once you have unpacked the distribution, 
+            change directory as indicated.
+<programlisting>
+   # <emphasis role="bold">cd /tmp/afsdist/rs_aix42/dest/root.client/usr/vice/etc</emphasis>
+</programlisting></para>
+          </listitem>
+
+          <listitem>
+            <para>Copy the AFS kernel library files to the local <emphasis role="bold">/usr/vice/etc/dkload</emphasis> directory,
+            and the AFS initialization script to the <emphasis role="bold">/etc</emphasis> directory. <programlisting>
+   # <emphasis role="bold">cp -rp  dkload  /usr/vice/etc</emphasis>
+   # <emphasis role="bold">cp -p  rc.afs  /etc/rc.afs</emphasis>
+</programlisting></para>
+          </listitem>
+
+          <listitem>
+            <para>Edit the <emphasis role="bold">/etc/rc.afs</emphasis> script, setting the <computeroutput>NFS</computeroutput>
+            variable as indicated.</para>
+
+            <para>If the machine is not to function as an NFS/AFS Translator, set the <computeroutput>NFS</computeroutput> variable
+            as follows.</para>
+
+            <programlisting>
+   NFS=$NFS_NONE
+</programlisting>
+
+            <para>If the machine is to function as an NFS/AFS Translator and is running AIX 4.2.1 or higher, set the
+            <computeroutput>NFS</computeroutput> variable as follows. Note that NFS must already be loaded into the kernel, which
+            happens automatically on systems running AIX 4.1.1 and later, as long as the file <emphasis
+            role="bold">/etc/exports</emphasis> exists.</para>
+
+            <programlisting>
+   NFS=$NFS_IAUTH
+</programlisting>
+          </listitem>
+
+          <listitem>
+            <para>Invoke the <emphasis role="bold">/etc/rc.afs</emphasis> script to load AFS modifications into the kernel. You can
+            ignore any error messages about the inability to start the BOS Server or the Cache Manager or AFS client.
+            <programlisting>
+   # <emphasis role="bold">/etc/rc.afs</emphasis>
+</programlisting></para>
+          </listitem>
+        </orderedlist></para>
+
+      <indexterm>
+        <primary>configuring</primary>
+
+        <secondary>AFS server partition on first AFS machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>AFS server partition</primary>
+
+        <secondary>configuring on first AFS machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>first AFS machine</primary>
+
+        <secondary>AFS server partition</secondary>
+
+        <tertiary>on AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>AIX</primary>
+
+        <secondary>AFS server partition</secondary>
+
+        <tertiary>on first AFS machine</tertiary>
+      </indexterm>
+    </sect2>
+
+    <sect2 id="HDRWQ23">
+      <title>Configuring Server Partitions on AIX Systems</title>
+
+      <para>Every AFS file server machine must have at least one partition or logical volume dedicated to storing AFS volumes. Each
+      server partition is mounted at a directory named <emphasis role="bold">/vicep</emphasis><replaceable>xx</replaceable>, where
+      <replaceable>xx</replaceable> is one or two lowercase letters. The <emphasis
+      role="bold">/vicep</emphasis><replaceable>xx</replaceable> directories must reside in the file server machine's root
+      directory, not in one of its subdirectories (for example, <emphasis role="bold">/usr/vicepa</emphasis> is not an acceptable
+      directory location). For additional information, see <link linkend="HDRWQ20">Performing Platform-Specific
+      Procedures</link>.</para>
+
+      <para>To configure server partitions on an AIX system, perform the following procedures: <orderedlist>
+          <listitem>
+            <para>Create a directory called <emphasis role="bold">/vicep</emphasis><replaceable>xx</replaceable> for each AFS server
+            partition you are configuring (there must be at least one). Repeat the command for each partition. <programlisting>
+   # <emphasis role="bold">mkdir /vicep</emphasis><replaceable>xx</replaceable>
+</programlisting></para>
+          </listitem>
+
+          <listitem>
+            <para>Use the <emphasis role="bold">SMIT</emphasis> program to create a journaling file system on each partition to be
+            configured as an AFS server partition.</para>
+          </listitem>
+
+          <listitem>
+            <para>Mount each partition at one of the <emphasis role="bold">/vicep</emphasis><replaceable>xx</replaceable>
+            directories. Choose one of the following three methods: <itemizedlist>
+                <listitem>
+                  <para>Use the <emphasis role="bold">SMIT</emphasis> program</para>
+                </listitem>
+
+                <listitem>
+                  <para>Use the <emphasis role="bold">mount -a</emphasis> command to mount all partitions at once</para>
+                </listitem>
+
+                <listitem>
+                  <para>Use the <emphasis role="bold">mount</emphasis> command on each partition in turn</para>
+                </listitem>
+              </itemizedlist></para>
+
+            <para>Also configure the partitions so that they are mounted automatically at each reboot. For more information, refer
+            to the AIX documentation.</para>
+          </listitem>
+        </orderedlist></para>
+
+      <indexterm>
+        <primary>replacing fsck program</primary>
+
+        <secondary>first AFS machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>fsck program</primary>
+
+        <secondary>on first AFS machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>first AFS machine</primary>
+
+        <secondary>fsck program</secondary>
+
+        <tertiary>on AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>AIX</primary>
+
+        <secondary>fsck program</secondary>
+
+        <tertiary>on first AFS machine</tertiary>
+      </indexterm>
+    </sect2>
+
+    <sect2 id="HDRWQ24">
+      <title>Replacing the fsck Program Helper on AIX Systems</title>
+
+      <note><para>The AFS modified fsck program is not required on AIX 5.1 
+      systems, and the <emphasis role="bold">v3fshelper</emphasis> program
+      refered to below is not shipped for these systems.</para></note>
+      
+      <para>In this section, you make modifications to guarantee that the appropriate <emphasis role="bold">fsck</emphasis> program
+      runs on AFS server partitions. The <emphasis role="bold">fsck</emphasis> program provided with the operating system must never
+      run on AFS server partitions. Because it does not recognize the structures that the File Server uses to organize volume data,
+      it removes all of the data. To repeat:</para>
+
+      <para><emphasis role="bold">Never run the standard fsck program on AFS server partitions. It discards AFS
+      volumes.</emphasis></para>
+
+      <para>On AIX systems, you do not replace the <emphasis role="bold">fsck</emphasis> binary itself, but rather the
+      <emphasis>program helper</emphasis> file included in the AIX distribution as <emphasis
+      role="bold">/sbin/helpers/v3fshelper</emphasis>. <orderedlist>
+          <listitem>
+            <para>Move the AIX <emphasis role="bold">fsck</emphasis> program helper to a safe location and install the version from
+            the AFS distribution in its place. 
+<programlisting>
+   # <emphasis role="bold">cd /sbin/helpers</emphasis>
+   # <emphasis role="bold">mv v3fshelper v3fshelper.noafs</emphasis>
+   # <emphasis role="bold">cp -p /tmp/afsdist/rs_aix42/dest/root.server/etc/v3fshelper v3fshelper</emphasis>
+</programlisting></para>
+          </listitem>
+
+          <listitem>
+            <para>If you plan to retain client functionality on this machine after completing the installation, proceed to <link
+            linkend="HDRWQ25">Enabling AFS Login on AIX Systems</link>. Otherwise, proceed to <link linkend="HDRWQ50">Starting the
+            BOS Server</link>.</para>
+          </listitem>
+        </orderedlist></para>
+
+      <indexterm>
+        <primary>enabling AFS login</primary>
+
+        <secondary>file server machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>AFS login</primary>
+
+        <secondary>on file server machine</secondary>
+
+        <tertiary>AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>first AFS machine</primary>
+
+        <secondary>AFS login</secondary>
+
+        <tertiary>on AIX</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>AIX</primary>
+
+        <secondary>AFS login</secondary>
+
+        <tertiary>on file server machine</tertiary>
+      </indexterm>
+
+      <indexterm>
+        <primary>secondary authentication system (AIX)</primary>
+
+        <secondary>server machine</secondary>
+      </indexterm>
+    </sect2>
+
+    <sect2 id="HDRWQ25">
+      <title>Enabling AFS Login on AIX Systems</title>
+
+      <note>
+        <para>If you plan to remove client functionality from this machine after completing the installation, skip this section and
+        proceed to <link linkend="HDRWQ50">Starting the BOS Server</link>.</para>
+      </note>
+
+      <para>In modern AFS installations, you should be using Kerberos v5
+      for user login, and obtaining AFS tokens following this authentication
+      step.</para>
+      
+      <para>There are currently no instructions available on configuring AIX to
+      automatically obtain AFS tokens at login. Following login, users can 
+      obtain tokens by running the <emphasis role="bold">aklog</emphasis> 
+      command</para>
+     
+      <para>Sites which still require <emphasis role="bold">kaserver</emphasis>
+      or external Kerberos v4 authentication should consult 
+      <link linkend="KAS012">Enabling kaserver based AFS login on AIX systems</link>
+      for details of how to enable AIX login.</para>
+      
+      <para>Proceed to <link linkend="HDRWQ50">Starting the BOS Server</link> 
+      (or if referring to these instructions while installing an additional 
+      file server machine, return to <link linkend="HDRWQ108">Starting Server
+      Programs</link>).</para>
+    </sect2>
+  </sect1>
   <sect1 id="HDRWQ50">
     <title>Starting the BOS Server</title>
 
@@ -3150,7 +3464,7 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
           <para>For a disk cache, you cannot specify a value in the third field that exceeds 95% of the space available on the
           partition mounted at the directory named in the second field. If you violate this restriction, the <emphasis
           role="bold">afsd</emphasis> program exits without starting the Cache Manager and prints an appropriate message on the
-          standard output stream. A value of 90% is more appropriate on most machines. Some operating systems do not
+          standard output stream. A value of 90% is more appropriate on most machines. Some operating systems (such as AIX) do not
           automatically reserve some space to prevent the partition from filling completely; for them, a smaller value (say, 80% to
           85% of the space available) is more appropriate.</para>
         </listitem>
@@ -3375,6 +3689,13 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
 </programlisting></para>
         </listitem>
 
+        <listitem>
+          <para>On AIX systems, add the following line to the <emphasis role="bold">/etc/vfs</emphasis> file. It enables AIX to
+          unmount AFS correctly during shutdown. <programlisting>
+   afs     4     none     none
+</programlisting></para>
+        </listitem>
+
         <listitem>
           <para>On non-package based Linux systems, copy the <emphasis role="bold">afsd</emphasis> options file from the <emphasis
           role="bold">/usr/vice/etc</emphasis> directory to the <emphasis role="bold">/etc/sysconfig</emphasis> directory, removing
@@ -3387,6 +3708,10 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
           <para>Edit the machine's AFS initialization script or <emphasis role="bold">afsd</emphasis> options file to set
           appropriate values for <emphasis role="bold">afsd</emphasis> command parameters. The script resides in the indicated
           location on each system type: <itemizedlist>
+              <listitem>
+                <para>On AIX systems, <emphasis role="bold">/etc/rc.afs</emphasis></para>
+              </listitem>
+
 	          <listitem>
                 <para>On Fedora and RHEL systems, <emphasis role="bold">/etc/sysconfg/openafs</emphasis></para>
               </listitem>
@@ -3566,6 +3891,32 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
         <listitem>
           <para>Issue the appropriate commands to run the AFS initialization script for this system type.</para>
 
+          <indexterm>
+            <primary>AIX</primary>
+
+            <secondary>AFS initialization script</secondary>
+
+            <tertiary>on first AFS machine</tertiary>
+          </indexterm>
+
+          <para><emphasis role="bold">On AIX systems:</emphasis> <orderedlist>
+              <listitem>
+                <para>Reboot the machine and log in again as the local superuser <emphasis role="bold">root</emphasis>.
+                <programlisting>
+   # <emphasis role="bold">cd /</emphasis>
+   # <emphasis role="bold">shutdown -r now</emphasis>
+   login: <emphasis role="bold">root</emphasis>
+   Password: <replaceable>root_password</replaceable>
+</programlisting></para>
+              </listitem>
+
+              <listitem>
+                <para>Run the AFS initialization script. <programlisting>
+   # <emphasis role="bold">/etc/rc.afs</emphasis>
+</programlisting></para>
+              </listitem>
+            </orderedlist></para>
+
           <para><emphasis role="bold">On Linux systems:</emphasis> <orderedlist>
               <listitem>
                 <para>Reboot the machine and log in again as the local superuser <emphasis role="bold">root</emphasis>.
@@ -3738,6 +4089,10 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
 
     <para>Now that you have confirmed that the AFS initialization script works correctly, take the action necessary to have it run
     automatically at each reboot. Proceed to the instructions for your system type: <itemizedlist>
+        <listitem>
+          <para><link linkend="HDRWQ74">Activating the Script on AIX Systems</link></para>
+        </listitem>
+
         <listitem>
           <para><link linkend="HDRWQ78">Activating the Script on Linux Systems</link></para>
         </listitem>
@@ -3746,6 +4101,42 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
           <para><link linkend="HDRWQ79">Activating the Script on Solaris Systems</link></para>
         </listitem>
       </itemizedlist></para>
+
+    <indexterm>
+      <primary>AIX</primary>
+
+      <secondary>AFS initialization script</secondary>
+
+      <tertiary>on first AFS machine</tertiary>
+    </indexterm>
+
+    <sect2 id="HDRWQ74">
+      <title>Activating the Script on AIX Systems</title>
+
+      <orderedlist>
+        <listitem>
+          <para>Edit the AIX initialization file, <emphasis role="bold">/etc/inittab</emphasis>, adding the following line to invoke
+          the AFS initialization script. Place it just after the line that starts NFS daemons. <programlisting>
+   rcafs:2:wait:/etc/rc.afs &gt; /dev/console 2&gt;&amp;1 # Start AFS services
+</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para><emphasis role="bold">(Optional)</emphasis> There are now copies of the AFS initialization file in both the
+          <emphasis role="bold">/usr/vice/etc</emphasis> and <emphasis role="bold">/etc</emphasis> directories. If you want to avoid
+          potential confusion by guaranteeing that they are always the same, create a link between them. You can always retrieve the
+          original script from the AFS CD-ROM if necessary. <programlisting>
+   # <emphasis role="bold">cd  /usr/vice/etc</emphasis>
+   # <emphasis role="bold">rm  rc.afs</emphasis>
+   # <emphasis role="bold">ln -s  /etc/rc.afs</emphasis>
+</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para>Proceed to <link linkend="HDRWQ80">Configuring the Top Levels of the AFS Filespace</link>.</para>
+        </listitem>
+      </orderedlist>
+
       <indexterm>
         <primary>Linux</primary>
 
@@ -3753,6 +4144,7 @@ Password for <replaceable>you/admin@REALM</replaceable>: <replaceable>your_passw
 
         <tertiary>on first AFS machine</tertiary>
       </indexterm>
+    </sect2>
 
     <sect2 id="HDRWQ78">
       <title>Activating the Script on Linux Systems</title>
diff --git a/doc/xml/QuickStartUnix/auqbg006.xml b/doc/xml/QuickStartUnix/auqbg006.xml
index eccbb10a0a..cf079905bd 100644
--- a/doc/xml/QuickStartUnix/auqbg006.xml
+++ b/doc/xml/QuickStartUnix/auqbg006.xml
@@ -235,6 +235,10 @@
         </itemizedlist></para>
 
       <para>To continue, proceed to the section for this system type: <itemizedlist>
+          <listitem>
+            <para><link linkend="HDRWQ101">Getting Started on AIX Systems</link></para>
+          </listitem>
+
           <listitem>
             <para><link linkend="HDRWQ106">Getting Started on Linux Systems</link></para>
           </listitem>
@@ -244,6 +248,202 @@
           </listitem>
         </itemizedlist></para>
 
+      <sect3 id="HDRWQ101">
+        <title>Getting Started on AIX Systems</title>
+
+        <para>Begin by running the AFS initialization script to call the AIX kernel extension facility, which dynamically loads AFS
+        modifications into the kernel. Then configure partitions and replace the AIX <emphasis role="bold">fsck</emphasis> program
+        with a version that correctly handles AFS volumes. <orderedlist>
+            <indexterm>
+              <primary>incorporating AFS kernel extensions</primary>
+
+              <secondary>server machine after first</secondary>
+
+              <tertiary>AIX</tertiary>
+            </indexterm>
+
+            <indexterm>
+              <primary>AFS kernel extensions</primary>
+
+              <secondary>on server machine after first</secondary>
+
+              <tertiary>AIX</tertiary>
+            </indexterm>
+
+            <indexterm>
+              <primary>file server machine, additional</primary>
+
+              <secondary>AFS kernel extensions</secondary>
+
+              <tertiary>on AIX</tertiary>
+            </indexterm>
+
+            <indexterm>
+              <primary>AIX</primary>
+
+              <secondary>AFS kernel extensions</secondary>
+
+              <tertiary>on add'l server machine</tertiary>
+            </indexterm>
+
+            <listitem>
+              <para>Unpack the distribution tarball. The examples below assume 
+              that you have unpacked the files into the 
+              <emphasis role="bold">/tmp/afsdist</emphasis> directory. If you 
+              pick a different location, substitute this in all of the following 
+              examples. Once you have unpacked the distribution, 
+              change directory as indicated.
+<programlisting>
+   # <emphasis role="bold">cd /tmp/afsdist/rs_aix42/dest/root.client/usr/vice/etc</emphasis>
+</programlisting></para>
+            </listitem>
+
+            <listitem>
+              <para>Copy the AFS kernel library files to the local <emphasis role="bold">/usr/vice/etc/dkload</emphasis> directory,
+              and the AFS initialization script to the <emphasis role="bold">/etc</emphasis> directory. <programlisting>
+   # <emphasis role="bold">cp -rp  dkload  /usr/vice/etc</emphasis>
+   # <emphasis role="bold">cp -p  rc.afs  /etc/rc.afs</emphasis>
+</programlisting></para>
+            </listitem>
+
+            <listitem>
+              <para>Edit the <emphasis role="bold">/etc/rc.afs</emphasis> script, setting the <computeroutput>NFS</computeroutput>
+              variable as indicated.</para>
+
+              <para>If the machine is not to function as an NFS/AFS Translator, set the <computeroutput>NFS</computeroutput>
+              variable as follows.</para>
+
+              <programlisting>
+   NFS=$NFS_NONE
+</programlisting>
+
+              <para>If the machine is to function as an NFS/AFS Translator and is running AIX 4.2.1 or higher, set the
+              <computeroutput>NFS</computeroutput> variable as follows. Note that NFS must already be loaded into the kernel, which
+              happens automatically on systems running AIX 4.1.1 and later, as long as the file <emphasis
+              role="bold">/etc/exports</emphasis> exists.</para>
+
+              <programlisting>
+   NFS=$NFS_IAUTH
+</programlisting>
+            </listitem>
+
+            <listitem>
+              <para>Invoke the <emphasis role="bold">/etc/rc.afs</emphasis> script to load AFS modifications into the kernel. You
+              can ignore any error messages about the inability to start the BOS Server or the Cache Manager or AFS client.
+              <programlisting>
+   # <emphasis role="bold">/etc/rc.afs</emphasis>
+</programlisting> <indexterm>
+                  <primary>configuring</primary>
+
+                  <secondary>AFS server partition on server machine after first</secondary>
+
+                  <tertiary>AIX</tertiary>
+                </indexterm> <indexterm>
+                  <primary>AFS server partition</primary>
+
+                  <secondary>configuring on server machine after first</secondary>
+
+                  <tertiary>AIX</tertiary>
+                </indexterm> <indexterm>
+                  <primary>file server machine, additional</primary>
+
+                  <secondary>AFS server partition</secondary>
+
+                  <tertiary>on AIX</tertiary>
+                </indexterm> <indexterm>
+                  <primary>AIX</primary>
+
+                  <secondary>AFS server partition</secondary>
+
+                  <tertiary>on add'l server machine</tertiary>
+                </indexterm></para>
+            </listitem>
+
+            <listitem>
+              <para>Create a directory called <emphasis role="bold">/vicep</emphasis><replaceable>xx</replaceable> for each AFS
+              server partition you are configuring (there must be at least one). Repeat the command for each partition.
+              <programlisting>
+   # <emphasis role="bold">mkdir /vicep</emphasis><replaceable>xx</replaceable>
+</programlisting></para>
+            </listitem>
+
+            <listitem>
+              <para>Use the <emphasis role="bold">SMIT</emphasis> program to create a journaling file system on each partition to be
+              configured as an AFS server partition.</para>
+            </listitem>
+
+            <listitem>
+              <para>Mount each partition at one of the <emphasis role="bold">/vicep</emphasis><replaceable>xx</replaceable>
+              directories. Choose one of the following three methods: <itemizedlist>
+                  <listitem>
+                    <para>Use the <emphasis role="bold">SMIT</emphasis> program</para>
+                  </listitem>
+
+                  <listitem>
+                    <para>Use the <emphasis role="bold">mount -a</emphasis> command to mount all partitions at once</para>
+                  </listitem>
+
+                  <listitem>
+                    <para>Use the <emphasis role="bold">mount</emphasis> command on each partition in turn</para>
+                  </listitem>
+                </itemizedlist></para>
+
+              <para>Also configure the partitions so that they are mounted automatically at each reboot. For more information, refer
+              to the AIX documentation. <indexterm>
+                  <primary>replacing fsck program</primary>
+
+                  <secondary>server machine after first</secondary>
+
+                  <tertiary>AIX</tertiary>
+                </indexterm> <indexterm>
+                  <primary>fsck program</primary>
+
+                  <secondary>on server machine after first</secondary>
+
+                  <tertiary>AIX</tertiary>
+                </indexterm> <indexterm>
+                  <primary>file server machine, additional</primary>
+
+                  <secondary>fsck program</secondary>
+
+                  <tertiary>on AIX</tertiary>
+                </indexterm> <indexterm>
+                  <primary>AIX</primary>
+
+                  <secondary>fsck program</secondary>
+
+                  <tertiary>on add'l server machine</tertiary>
+                </indexterm></para>
+            </listitem>
+
+            <listitem>
+              <para>On systems prior to AIX 5.1, move the AIX 
+              <emphasis role="bold">fsck</emphasis> program helper to a safe 
+              location and install the version from the AFS distribution in 
+              its place. Note that on AIX 5.1, and later, systems this step is
+              not required, and the <emphasis role="bold">v3fshelper</emphasis>
+              program is not shipped for these systems.</para>
+              
+              <para>The AFS binary distribution must still be available in the
+              <emphasis role="bold">/tmp/afsdist</emphasis> directory. 
+<programlisting>
+   # <emphasis role="bold">cd /sbin/helpers</emphasis>
+   # <emphasis role="bold">mv v3fshelper v3fshelper.noafs</emphasis>
+   # <emphasis role="bold">cp -p /tmp/afsdist/rs_aix42/dest/root.server/etc/v3fshelper v3fshelper</emphasis>
+</programlisting></para>
+            </listitem>
+
+            <listitem>
+              <para>If the machine is to remain an AFS client, incorporate AFS into its authentication system, following the
+              instructions in <link linkend="HDRWQ25">Enabling AFS Login on AIX Systems</link>.</para>
+            </listitem>
+
+            <listitem>
+              <para>Proceed to <link linkend="HDRWQ108">Starting Server Programs</link>.</para>
+            </listitem>
+          </orderedlist></para>
+      </sect3>
+
       <sect3 id="HDRWQ106">
         <title>Getting Started on Linux Systems</title>
 
@@ -1524,6 +1724,13 @@
 </programlisting></para>
           </listitem>
 
+          <listitem>
+            <para>On AIX systems, add the following line to the <emphasis role="bold">/etc/vfs</emphasis> file. It enables AIX to
+            unmount AFS correctly during shutdown. <programlisting>
+   afs     4     none     none
+</programlisting></para>
+          </listitem>
+
           <listitem>
             <para>On non-packaged Linux systems, copy the <emphasis role="bold">afsd</emphasis> options file from the <emphasis
             role="bold">/usr/vice/etc</emphasis> directory to the <emphasis role="bold">/etc/sysconfig</emphasis> directory,
@@ -1536,6 +1743,10 @@
             <para>Edit the machine's AFS initialization script or <emphasis role="bold">afsd</emphasis> options file to set
             appropriate values for <emphasis role="bold">afsd</emphasis> command parameters. The script resides in the indicated
             location on each system type: <itemizedlist>
+                <listitem>
+                  <para>On AIX systems, <emphasis role="bold">/etc/rc.afs</emphasis></para>
+                </listitem>
+
                 <listitem>
                   <para>On Fedora and RHEL systems, 
                   <emphasis role="bold">/etc/sysconfig/openafs</emphasis>. 
@@ -1642,7 +1853,58 @@
                 <secondary>AFS initialization script</secondary>
 
                 <tertiary>server machine after first</tertiary>
-              </indexterm>
+              </indexterm> <indexterm>
+                <primary>AIX</primary>
+
+                <secondary>AFS initialization script</secondary>
+
+                <tertiary>on add'l server machine</tertiary>
+              </indexterm></para>
+          </listitem>
+
+          <listitem>
+            <para>Run the AFS initialization script by issuing the appropriate commands for this system type.</para>
+
+            <para><emphasis role="bold">On AIX systems:</emphasis> <orderedlist>
+                <listitem>
+                  <para>Reboot the machine and log in again as the local superuser <emphasis role="bold">root</emphasis>.
+                  <programlisting>
+   # <emphasis role="bold">cd /</emphasis>
+   # <emphasis role="bold">shutdown -r now</emphasis>
+   login: <emphasis role="bold">root</emphasis>
+   Password: <replaceable>root_password</replaceable>
+</programlisting></para>
+                </listitem>
+
+                <listitem>
+                  <para>Run the AFS initialization script. <programlisting>
+   # <emphasis role="bold">/etc/rc.afs</emphasis>
+</programlisting></para>
+                </listitem>
+
+                <listitem>
+                  <para>Edit the AIX initialization file, <emphasis role="bold">/etc/inittab</emphasis>, adding the following line
+                  to invoke the AFS initialization script. Place it just after the line that starts NFS daemons. <programlisting>
+   rcafs:2:wait:/etc/rc.afs &gt; /dev/console 2&gt;&amp;1 # Start AFS services
+</programlisting></para>
+                </listitem>
+
+                <listitem>
+                  <para><emphasis role="bold">(Optional)</emphasis> There are now copies of the AFS initialization file in both the
+                  <emphasis role="bold">/usr/vice/etc</emphasis> and <emphasis role="bold">/etc</emphasis> directories. If you want
+                  to avoid potential confusion by guaranteeing that they are always the same, create a link between them. You can
+                  always retrieve the original script from the AFS CD-ROM if necessary. <programlisting>
+   # <emphasis role="bold">cd  /usr/vice/etc</emphasis>
+   # <emphasis role="bold">rm  rc.afs</emphasis>
+   # <emphasis role="bold">ln -s  /etc/rc.afs</emphasis>
+</programlisting></para>
+                </listitem>
+
+                <listitem>
+                  <para>Proceed to Step <link linkend="LIWQ113">4</link>.</para>
+                </listitem>
+              </orderedlist></para>
+
             <indexterm>
               <primary>Linux</primary>
 
@@ -1650,11 +1912,6 @@
 
               <tertiary>on add'l server machine</tertiary>
             </indexterm>
-              </para>
-          </listitem>
-
-          <listitem>
-            <para>Run the AFS initialization script by issuing the appropriate commands for this system type.</para>
 
             <para><emphasis role="bold">On Fedora or RHEL Linux systems:</emphasis> 
               <orderedlist>
diff --git a/doc/xml/QuickStartUnix/auqbg007.xml b/doc/xml/QuickStartUnix/auqbg007.xml
index 040468609e..5c2b8fa040 100644
--- a/doc/xml/QuickStartUnix/auqbg007.xml
+++ b/doc/xml/QuickStartUnix/auqbg007.xml
@@ -142,6 +142,10 @@
 
     <para>For convenience, the following sections group the two procedures by system type. Proceed to the appropriate section.
     <itemizedlist>
+        <listitem>
+          <para><link linkend="HDRWQ136">Getting Started on AIX Systems</link></para>
+        </listitem>
+
         <listitem>
           <para><link linkend="HDRWQ143">Getting Started on Linux Systems</link></para>
         </listitem>
@@ -149,7 +153,170 @@
         <listitem>
           <para><link linkend="HDRWQ144">Getting Started on Solaris Systems</link></para>
         </listitem>
-      </itemizedlist>
+      </itemizedlist></para>
+
+    <indexterm>
+      <primary>incorporating AFS kernel extensions</primary>
+
+      <secondary>client machine</secondary>
+
+      <tertiary>AIX</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>AFS kernel extensions</primary>
+
+      <secondary>on client machine</secondary>
+
+      <tertiary>AIX</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>client machine</primary>
+
+      <secondary>AFS kernel extensions</secondary>
+
+      <tertiary>on AIX</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>AIX</primary>
+
+      <secondary>AFS kernel extensions</secondary>
+
+      <tertiary>on client machine</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>enabling AFS login</primary>
+
+      <secondary>client machine</secondary>
+
+      <tertiary>AIX</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>AFS login</primary>
+
+      <secondary>on client machine</secondary>
+
+      <tertiary>AIX</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>client machine</primary>
+
+      <secondary>AFS login</secondary>
+
+      <tertiary>on AIX</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>AIX</primary>
+
+      <secondary>AFS login</secondary>
+
+      <tertiary>on client machine</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>secondary authentication system (AIX)</primary>
+
+      <secondary>client machine</secondary>
+    </indexterm>
+  </sect1>
+
+  <sect1 id="HDRWQ136">
+    <title>Getting Started on AIX Systems</title>
+
+    <para>In this section you load AFS into the AIX kernel. Then incorporate AFS modifications into the machine's secondary
+    authentication system, if you wish to enable AFS login.</para>
+
+    <sect2 id="Header_120">
+      <title>Loading AFS into the AIX Kernel</title>
+
+      <para>The AIX kernel extension facility is the dynamic kernel loader provided by IBM Corporation. AIX does not support
+      incorporation of AFS modifications during a kernel build.</para>
+
+      <para>For AFS to function correctly, the kernel extension facility must run each time the machine reboots, so the AFS
+      initialization script (included in the AFS distribution) invokes it automatically. In this section you copy the script to the
+      conventional location and edit it to select the appropriate options depending on whether NFS is also to run.</para>
+
+      <para>After editing the script, you run it to incorporate AFS into the kernel. In a later section you verify that the script
+      correctly initializes the Cache Manager, then configure the AIX <emphasis role="bold">inittab</emphasis> file so that the
+      script runs automatically at reboot. <orderedlist>
+          <listitem>
+            <para>Unpack the distribution tarball. The examples below assume 
+            that you have unpacked the files into the 
+            <emphasis role="bold">/tmp/afsdist</emphasis> directory. If you 
+            pick a different location, substitute this in all of the following 
+            examples. Once you have unpacked the distribution, 
+            change directory as indicated.
+<programlisting>
+   # <emphasis role="bold">cd /tmp/afsdist/rs_aix42/dest/root.client/usr/vice/etc</emphasis>
+</programlisting></para>
+          </listitem>
+          <listitem>
+            <para>Copy the AFS kernel library files to the local <emphasis role="bold">/usr/vice/etc/dkload</emphasis> directory,
+            and the AFS initialization script to the <emphasis role="bold">/etc</emphasis> directory. <programlisting>
+   # <emphasis role="bold">cp -rp  dkload  /usr/vice/etc</emphasis>
+   # <emphasis role="bold">cp -p  rc.afs  /etc/rc.afs</emphasis>
+</programlisting></para>
+          </listitem>
+
+          <listitem>
+            <para>Edit the <emphasis role="bold">/etc/rc.afs</emphasis> script, setting the <computeroutput>NFS</computeroutput>
+            variable as indicated.</para>
+
+            <para>If the machine is not to function as an NFS/AFS Translator, set the <computeroutput>NFS</computeroutput> variable
+            as follows.</para>
+
+            <programlisting>
+   NFS=$NFS_NONE
+</programlisting>
+
+            <para>If the machine is to function as an NFS/AFS Translator and is running AIX 4.2.1 or higher, set the
+            <computeroutput>NFS</computeroutput> variable as follows. Note that NFS must already be loaded into the kernel, which
+            happens automatically on systems running AIX 4.1.1 and later, as long as the file <emphasis
+            role="bold">/etc/exports</emphasis> exists.</para>
+
+            <programlisting>
+   NFS=$NFS_IAUTH
+</programlisting>
+          </listitem>
+
+          <listitem>
+            <para>Invoke the <emphasis role="bold">/etc/rc.afs</emphasis> script to load AFS modifications into the kernel. You can
+            ignore any error messages about the inability to start the BOS Server or the Cache Manager or AFS client.
+            <programlisting>
+   # <emphasis role="bold">/etc/rc.afs</emphasis>
+</programlisting></para>
+          </listitem>
+        </orderedlist></para>
+    </sect2>
+
+    <sect2 id="Header_121">
+      <title>Enabling AFS Login on AIX Systems</title>
+
+      <para>In modern AFS installations, you should be using Kerberos v5
+      for user login, and obtaining AFS tokens following this authentication
+      step.</para>
+      
+      <para>There are currently no instructions available on configuring AIX to
+      automatically obtain AFS tokens at login. Following login, users can 
+      obtain tokens by running the <emphasis role="bold">aklog</emphasis> 
+      command</para>
+
+      <para>Sites which still require <emphasis role="bold">kaserver</emphasis>
+      or external Kerberos v4 authentication should consult 
+      <link linkend="KAS012">Enabling kaserver based AFS Login on AIX Systems</link>
+      for details of how to enable AIX login.</para>
+
+      <para><orderedlist>
+          <listitem>
+            <para>Proceed to <link linkend="HDRWQ145">Loading and Creating Client Files</link>.</para>
+          </listitem>
+        </orderedlist>
 
       <indexterm>
           <primary>incorporating AFS kernel extensions</primary>
@@ -207,6 +374,7 @@
           <tertiary>client machine</tertiary>
         </indexterm>
       </para>
+    </sect2>
   </sect1>
 
   <sect1 id="HDRWQ143">
@@ -946,7 +1114,7 @@
           <para>For a disk cache, you cannot specify a value in the third field that exceeds 95% of the space available on the
           partition mounted at the directory named in the second field. If you violate this restriction, the <emphasis
           role="bold">afsd</emphasis> program exits without starting the Cache Manager and prints an appropriate message on the
-          standard output stream. A value of 90% is more appropriate on most machines. Some operating systems do not
+          standard output stream. A value of 90% is more appropriate on most machines. Some operating systems (such as AIX) do not
           automatically reserve some space to prevent the partition from filling completely; for them, a smaller value (say, 80% to
           85% of the space available) is more appropriate.</para>
         </listitem>
@@ -1176,6 +1344,31 @@
         <secondary>Cache Manager</secondary>
       </indexterm>
 
+      <indexterm>
+        <primary>files</primary>
+
+        <secondary>vfs (AIX)</secondary>
+      </indexterm>
+
+      <indexterm>
+        <primary>vfs file</primary>
+      </indexterm>
+
+      <indexterm>
+        <primary>etc/vfs file</primary>
+      </indexterm>
+
+      <indexterm>
+        <primary>AIX</primary>
+
+        <secondary>editing /etc/vfs file</secondary>
+      </indexterm>
+
+      <indexterm>
+        <primary>client machine</primary>
+
+        <secondary>vfs file (AIX)</secondary>
+      </indexterm>
     </sect2>
   </sect1>
 
@@ -1286,6 +1479,13 @@
 </programlisting></para>
         </listitem>
 
+        <listitem>
+          <para>On AIX systems, add the following line to the <emphasis role="bold">/etc/vfs</emphasis> file. It enables AIX to
+          unmount AFS correctly during shutdown. <programlisting>
+   afs     4     none     none
+</programlisting></para>
+        </listitem>
+
         <listitem>
           <para>On non-package based Linux systems, copy the <emphasis role="bold">afsd</emphasis> options file from the <emphasis
           role="bold">/usr/vice/etc</emphasis> directory to the <emphasis role="bold">/etc/sysconfig</emphasis> directory, removing
@@ -1298,6 +1498,10 @@
           <para>Edit the machine's AFS initialization script or <emphasis role="bold">afsd</emphasis> options file to set
           appropriate values for <emphasis role="bold">afsd</emphasis> command parameters. The appropriate file for each system type
           is as follows: <itemizedlist>
+              <listitem>
+                <para>On AIX systems, <emphasis role="bold">/etc/rc.afs</emphasis></para>
+              </listitem>
+
               <listitem>
                 <para>On Fedora and RHEL systems, <emphasis role="bold">/etc/sysconfig/openafs</emphasis></para>
               </listitem>
@@ -1381,6 +1585,10 @@
     <para>Proceed to the instructions for your system type:</para>
 
     <itemizedlist>
+      <listitem>
+        <para><link linkend="HDRWQ151">Running the Script on AIX Systems</link></para>
+      </listitem>
+
       <listitem>
         <para><link linkend="HDRWQ155">Running the Script on Linux Systems</link></para>
       </listitem>
@@ -1390,6 +1598,74 @@
       </listitem>
     </itemizedlist>
 
+    <indexterm>
+      <primary>AIX</primary>
+
+      <secondary>AFS initialization script</secondary>
+
+      <tertiary>on client machine</tertiary>
+    </indexterm>
+
+    <indexterm>
+      <primary>rc.afs file (AFS init. file for AIX)</primary>
+    </indexterm>
+
+    <indexterm>
+      <primary>files</primary>
+
+      <secondary>rc.afs</secondary>
+    </indexterm>
+
+    <indexterm>
+      <primary>etc/rc.afs</primary>
+
+      <see>rc.afs file</see>
+    </indexterm>
+
+    <sect2 id="HDRWQ151">
+      <title>Running the Script on AIX Systems</title>
+
+      <orderedlist>
+        <listitem>
+          <para>Reboot the machine and log in again as the local superuser <emphasis role="bold">root</emphasis>. <programlisting>
+   # <emphasis role="bold">cd /</emphasis>
+   # <emphasis role="bold">shutdown -r now</emphasis>
+   login: <emphasis role="bold">root</emphasis>
+   Password: <replaceable>root_password</replaceable>
+</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para>Run the AFS initialization script. <programlisting>
+   # <emphasis role="bold">/etc/rc.afs</emphasis>
+</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para>Edit the AIX initialization file, <emphasis role="bold">/etc/inittab</emphasis>, adding the following line to invoke
+          the AFS initialization script. Place it just after the line that starts NFS daemons. <programlisting>
+   rcafs:2:wait:/etc/rc.afs &gt; /dev/console 2&gt;&amp;1 # Start AFS services
+</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para><emphasis role="bold">(Optional)</emphasis> There are now copies of the AFS initialization file in both the
+          <emphasis role="bold">/usr/vice/etc</emphasis> and <emphasis role="bold">/etc</emphasis> directories. If you want to avoid
+          potential confusion by guaranteeing that they are always the same, create a link between them. You can always retrieve the
+          original script from the AFS CD-ROM if necessary. <programlisting>
+   # <emphasis role="bold">cd  /usr/vice/etc</emphasis>
+   # <emphasis role="bold">rm  rc.afs</emphasis>
+   # <emphasis role="bold">ln -s  /etc/rc.afs</emphasis>
+</programlisting></para>
+        </listitem>
+
+        <listitem>
+          <para>If a volume for housing AFS binaries for this machine's system type does not already exist, proceed to <link
+          linkend="HDRWQ157">Setting Up Volumes and Loading Binaries into AFS</link>. Otherwise, the installation is
+          complete.</para>
+        </listitem>
+      </orderedlist>
+
       <indexterm>
         <primary>afs file</primary>
 
@@ -1417,6 +1693,7 @@
 
         <tertiary>on client machine</tertiary>
       </indexterm>
+    </sect2>
 
     <sect2>
       <title>Running the Script on Fedora / RHEL Systems</title>
diff --git a/src/WINNT/afsd/cm_ioctl.c b/src/WINNT/afsd/cm_ioctl.c
index ffe5f70ae8..d0f2bba5d0 100644
--- a/src/WINNT/afsd/cm_ioctl.c
+++ b/src/WINNT/afsd/cm_ioctl.c
@@ -2518,7 +2518,7 @@ cm_UsernameToId(char *uname, cm_ucell_t * ucellp, afs_uint32* uid)
     lids.idlist_len = 0;
     lids.idlist_val = 0;
     lnames.namelist_len = 1;
-    lnames.namelist_val = (prname *) malloc(PR_MAXNAMELEN);
+    lnames.namelist_val = calloc(1, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[0], uname, PR_MAXNAMELEN);
     lnames.namelist_val[0][PR_MAXNAMELEN-1] = '\0';
     for ( p=lnames.namelist_val[0], r=NULL; *p; p++ ) {
diff --git a/src/WINNT/install/wix/files.wxi b/src/WINNT/install/wix/files.wxi
index fa3ac11be6..4105666cbf 100644
--- a/src/WINNT/install/wix/files.wxi
+++ b/src/WINNT/install/wix/files.wxi
@@ -1466,7 +1466,6 @@
                             <File Id="filedirent_H" Name="dirent.h" LongName="dirent.h" DiskId="1" src="$(var.IncDir)dirent.h" />
                             <File Id="fileerr_H" Name="err.h" LongName="err.h" DiskId="1" src="$(var.IncDir)err.h" />
                             <File Id="filelargeint_H" Name="largeint.h" LongName="largeint.h" DiskId="1" src="$(var.IncDir)largeint.h" /> 
-                            <File Id="filelock_H" Name="lock.h" LongName="lock.h" DiskId="1" src="$(var.IncDir)lock.h" /> 
                             <File Id="filelwp_H" Name="lwp.h" LongName="lwp.h" DiskId="1" src="$(var.IncDir)lwp.h" /> 
                             <File Id="filemain_H" Name="main.h" LongName="main.h" DiskId="1" src="$(var.IncDir)main.h" /> 
                             <File Id="fileosi_H" Name="osi.h" LongName="osi.h" DiskId="1" src="$(var.IncDir)osi.h" /> 
@@ -1524,6 +1523,7 @@
                                 <File Id="fileafs_cfgAdmin_H" Name="AFS_CFG1.h" LongName="afs_cfgAdmin.h" DiskId="1" src="$(var.IncDir)afs\afs_cfgAdmin.h" />
                                 <File Id="fileafs_clientAdmin_H" Name="AFS_CLI1.h" LongName="afs_clientAdmin.h" DiskId="1" src="$(var.IncDir)afs\afs_clientAdmin.h" />
                                 <File Id="fileafs_kasAdmin_H" Name="AFS_KAS1.h" LongName="afs_kasAdmin.h" DiskId="1" src="$(var.IncDir)afs\afs_kasAdmin.h" />
+                                <File Id="fileafs_lock_H" Name="afs_lock.h" LongName="afs_lock.h" DiskId="1" src="$(var.IncDir)afs\afs_lock.h" />
                                 <File Id="fileafs_ptsAdmin_H" Name="AFS_PTS1.h" LongName="afs_ptsAdmin.h" DiskId="1" src="$(var.IncDir)afs\afs_ptsAdmin.h" />
                                 <File Id="fileafs_sysnames_H" Name="AFS_SYS1.h" LongName="afs_sysnames.h" DiskId="1" src="$(var.IncDir)afs\afs_sysnames.h" />
                                 <File Id="fileafs_utilAdmin_H" Name="AFS_UTI1.h" LongName="afs_utilAdmin.h" DiskId="1" src="$(var.IncDir)afs\afs_utilAdmin.h" />
diff --git a/src/afs/DARWIN/osi_vnodeops.c b/src/afs/DARWIN/osi_vnodeops.c
index 494b3628b3..aef06bcbcb 100644
--- a/src/afs/DARWIN/osi_vnodeops.c
+++ b/src/afs/DARWIN/osi_vnodeops.c
@@ -580,7 +580,7 @@ afs_vop_access(ap)
         code = afs_CheckCode(code, &treq, 56);
         goto out;
     }
-    if (afs_fakestat_enable && tvc->mvstat != AFS_MVSTAT_FILE && !(tvc->f.states & CStatd)) {
+    if (fakestate.fakestat_enable && tvc->mvstat != AFS_MVSTAT_FILE && !(tvc->f.states & CStatd)) {
         code = 0;
         goto out;
     }
diff --git a/src/afs/LINUX/osi_export.c b/src/afs/LINUX/osi_export.c
index 3a40eaec15..bb76704ad7 100644
--- a/src/afs/LINUX/osi_export.c
+++ b/src/afs/LINUX/osi_export.c
@@ -404,9 +404,11 @@ static int UnEvalFakeStat(struct vrequest *areq, struct vcache **vcpp)
     struct volume *tvp;
     struct vcache *tvc;
     int code;
+    int fakestat_enable = afs_fakestat_enable;
 
-    if (!afs_fakestat_enable)
+    if (!fakestat_enable) {
 	return 0;
+    }
 
     if (*vcpp == afs_globalVp || vType(*vcpp) != VDIR || (*vcpp)->mvstat != AFS_MVSTAT_ROOT)
 	return 0;
@@ -436,7 +438,7 @@ static int UnEvalFakeStat(struct vrequest *areq, struct vcache **vcpp)
 	return ENOENT;
     }
 
-    if (afs_fakestat_enable == 2) {
+    if (fakestat_enable == 2) {
 	ObtainWriteLock(&tvc->lock, 806);
 	code = afs_HandleLink(tvc, areq);
 	if (code) {
diff --git a/src/afs/LINUX/osi_vnodeops.c b/src/afs/LINUX/osi_vnodeops.c
index 9508b11d27..b525126c20 100644
--- a/src/afs/LINUX/osi_vnodeops.c
+++ b/src/afs/LINUX/osi_vnodeops.c
@@ -2476,8 +2476,10 @@ afs_linux_read_cache(struct file *cachefp, struct page *page,
 	    } else {
 		put_page(newpage);
 		newpage = NULL;
-		if (code != -EEXIST)
+		if (code != -EEXIST) {
 		    goto out;
+		}
+		code = 0;
 	    }
         } else {
 	    lock_page(cachepage);
@@ -3794,15 +3796,33 @@ afs_linux_prepare_write(struct file *file, struct page *page, unsigned from,
     return 0;
 }
 
+#if defined(HAVE_LINUX_WRITE_BEGIN_END_KIOCB)
+/*
+ * When aops write_begin and write_end are passed a kiocb, it is implied that
+ * write_begin and write_end take a folio.
+ */
+# define HAVE_LINUX_WRITE_BEGIN_END_FOLIO
+#endif
+
 #if defined(HAVE_LINUX_WRITE_BEGIN_END_FOLIO)
+# if defined(HAVE_LINUX_WRITE_BEGIN_END_KIOCB)
+static int
+afs_linux_write_end(const struct kiocb *iocb, struct address_space *mapping,
+		    loff_t pos, unsigned len, unsigned copied,
+		    struct folio *folio, void *fsdata)
+# else
 static int
 afs_linux_write_end(struct file *file, struct address_space *mapping,
 		    loff_t pos, unsigned len, unsigned copied,
 		    struct folio *folio, void *fsdata)
+# endif
 {
     int code;
     unsigned int from = pos & (PAGE_SIZE - 1);
     struct page *page = folio_page(folio, 0);
+# if defined(HAVE_LINUX_WRITE_BEGIN_END_KIOCB)
+    struct file *file = iocb->ki_filp;
+# endif
 
     code = afs_linux_commit_write(file, page, from, from + copied);
 
@@ -3812,15 +3832,25 @@ afs_linux_write_end(struct file *file, struct address_space *mapping,
 }
 
 # if defined(HAVE_LINUX_FILEMAP_GET_FOLIO)
+#  if defined(HAVE_LINUX_WRITE_BEGIN_END_KIOCB)
+static int
+afs_linux_write_begin(const struct kiocb *iocb, struct address_space *mapping,
+		      loff_t pos, unsigned len,
+		      struct folio **foliop, void **fsdata)
+#  else
 static int
 afs_linux_write_begin(struct file *file, struct address_space *mapping,
 		      loff_t pos, unsigned len,
 		      struct folio **foliop, void **fsdata)
+#  endif
 {
     struct page *page;
     pgoff_t index = pos >> PAGE_SHIFT;
     unsigned int from = pos & (PAGE_SIZE - 1);
     int code;
+#  if defined(HAVE_LINUX_WRITE_BEGIN_END_KIOCB)
+    struct file *file = iocb->ki_filp;
+#  endif
 
     *foliop = __filemap_get_folio(mapping, index, FGP_WRITEBEGIN, mapping_gfp_mask(mapping));
     if (IS_ERR(*foliop)) {
diff --git a/src/afs/VNOPS/afs_vnop_access.c b/src/afs/VNOPS/afs_vnop_access.c
index 042d781fb1..d3db68cb0c 100644
--- a/src/afs/VNOPS/afs_vnop_access.c
+++ b/src/afs/VNOPS/afs_vnop_access.c
@@ -214,7 +214,7 @@ afs_access(OSI_VC_DECL(avc), afs_int32 amode,
 
     AFS_DISCON_LOCK();
 
-    if (afs_fakestat_enable && avc->mvstat == AFS_MVSTAT_MTPT) {
+    if (fakestate.fakestat_enable && avc->mvstat == AFS_MVSTAT_MTPT) {
 	code = afs_TryEvalFakeStat(&avc, &fakestate, treq);
         if (code == 0 && avc->mvstat == AFS_MVSTAT_MTPT) {
 	    afs_PutFakeStat(&fakestate);
diff --git a/src/afs/VNOPS/afs_vnop_create.c b/src/afs/VNOPS/afs_vnop_create.c
index 9a17c70c0a..444ad916a0 100644
--- a/src/afs/VNOPS/afs_vnop_create.c
+++ b/src/afs/VNOPS/afs_vnop_create.c
@@ -308,6 +308,8 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 	}
     }
 
+    now = osi_Time();
+
     if (!AFS_IS_DISCONNECTED) {
 	/* If not disconnected, connect to the server.*/
 
@@ -326,7 +328,6 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 				 &CallBack, &tsync);
 	    	RX_AFS_GLOCK();
 	    	XSTATS_END_TIME;
-	    	CallBack.ExpirationTime += now;
 	    } else
 	    	code = -1;
     	} while (afs_Analyze
@@ -450,7 +451,7 @@ afs_create(OSI_VC_DECL(adp), char *aname, struct vattr *attrs,
 		tvc->f.states |= CStatd;	/* we've fake entire thing, so don't stat */
 		tvc->f.states &= ~CBulkFetching;
 		if (!AFS_IS_DISCON_RW) {
-		    tvc->cbExpires = CallBack.ExpirationTime;
+		    tvc->cbExpires = CallBack.ExpirationTime + now;
 		    afs_QueueCallback(tvc, CBHash(CallBack.ExpirationTime), volp);
 		}
 	    } else {
diff --git a/src/afs/VNOPS/afs_vnop_lookup.c b/src/afs/VNOPS/afs_vnop_lookup.c
index db60c9c68d..6d3de0e709 100644
--- a/src/afs/VNOPS/afs_vnop_lookup.c
+++ b/src/afs/VNOPS/afs_vnop_lookup.c
@@ -319,12 +319,9 @@ EvalMountPoint(struct vcache *avc, struct vcache *advc,
 void
 afs_InitFakeStat(struct afs_fakestat_state *state)
 {
-    if (!afs_fakestat_enable)
-	return;
-
+    memset(state, 0, sizeof(*state));
     state->valid = 1;
-    state->did_eval = 0;
-    state->need_release = 0;
+    state->fakestat_enable = afs_fakestat_enable;
 }
 
 #ifdef AFS_DARWIN80_ENV
@@ -449,10 +446,12 @@ afs_EvalFakeStat_int(struct vcache **avcp, struct afs_fakestat_state *state,
     struct volume *tvolp = NULL;
     int code = 0;
 
-    if (!afs_fakestat_enable)
+    osi_Assert(state->valid == 1);
+
+    if (!state->fakestat_enable) {
 	return 0;
+    }
 
-    osi_Assert(state->valid == 1);
     osi_Assert(state->did_eval == 0);
     state->did_eval = 1;
 
@@ -567,10 +566,12 @@ afs_TryEvalFakeStat(struct vcache **avcp, struct afs_fakestat_state *state,
 void
 afs_PutFakeStat(struct afs_fakestat_state *state)
 {
-    if (!afs_fakestat_enable)
+    osi_Assert(state->valid == 1);
+
+    if (!state->fakestat_enable) {
 	return;
+    }
 
-    osi_Assert(state->valid == 1);
     if (state->need_release)
 	afs_PutVCache(state->root_vp);
     state->valid = 0;
@@ -1531,7 +1532,8 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     afs_int32 code;
     afs_int32 bulkcode = 0;
     int pass = 0, hit = 0;
-    int force_eval = afs_fakestat_enable ? 0 : 1;
+    int fakestat_enable = afs_fakestat_enable;
+    int force_eval = fakestat_enable ? 0 : 1;
     long dirCookie;
     afs_hyper_t versionNo;
     int no_read_access = 0;
@@ -1554,7 +1556,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     if ((code = afs_CreateReq(&treq, acred)))
 	goto done;
 
-    if (afs_fakestat_enable && adp->mvstat == AFS_MVSTAT_MTPT) {
+    if (fakestat_enable && adp->mvstat == AFS_MVSTAT_MTPT) {
        if (strcmp(aname, ".directory") == 0)
            tryEvalOnly = 1;
     }
@@ -1563,13 +1565,13 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
     /* Workaround for MacOSX Finder, which tries to look for
      * .DS_Store and Contents under every directory.
      */
-    if (afs_fakestat_enable && adp->mvstat == AFS_MVSTAT_MTPT) {
+    if (fakestat_enable && adp->mvstat == AFS_MVSTAT_MTPT) {
 	if (strcmp(aname, ".DS_Store") == 0)
 	    tryEvalOnly = 1;
 	if (strcmp(aname, "Contents") == 0)
 	    tryEvalOnly = 1;
     }
-    if (afs_fakestat_enable && adp->mvstat == AFS_MVSTAT_ROOT) {
+    if (fakestat_enable && adp->mvstat == AFS_MVSTAT_ROOT) {
 	if (strncmp(aname, "._", 2) == 0)
 	    tryEvalOnly = 1;
     }
@@ -1949,7 +1951,7 @@ afs_lookup(OSI_VC_DECL(adp), char *aname, struct vcache **avcp, afs_ucred_t *acr
 	tvc->f.parent.unique = adp->f.fid.Fid.Unique;
 	tvc->f.states &= ~CBulkStat;
 
-	if (afs_fakestat_enable == 2 && tvc->mvstat == AFS_MVSTAT_MTPT) {
+	if (fakestat_enable == 2 && tvc->mvstat == AFS_MVSTAT_MTPT) {
 	    ObtainSharedLock(&tvc->lock, 680);
 	    if (!tvc->linkData) {
 		UpgradeSToWLock(&tvc->lock, 681);
diff --git a/src/afs/afs.h b/src/afs/afs.h
index 345cecb91c..569dde1773 100644
--- a/src/afs/afs.h
+++ b/src/afs/afs.h
@@ -1595,6 +1595,7 @@ struct fetchOps {
  */
 struct afs_fakestat_state {
     char valid;
+    char fakestat_enable;
     char did_eval;
     char need_release;
     struct vcache *root_vp;
diff --git a/src/afs/afs_pioctl.c b/src/afs/afs_pioctl.c
index f6049f0f29..857da8aae1 100644
--- a/src/afs/afs_pioctl.c
+++ b/src/afs/afs_pioctl.c
@@ -2033,15 +2033,27 @@ DECL_PIOCTL(PGetVolumeStatus)
 
     if (code)
 	goto out;
-    /* Copy all this junk into msg->im_data, keeping track of the lengths. */
-    if (afs_pd_putBytes(aout, &volstat, sizeof(VolumeStatus)) != 0)
-	return E2BIG;
-    if (afs_pd_putString(aout, volName) != 0)
-	return E2BIG;
-    if (afs_pd_putString(aout, offLineMsg) != 0)
-	return E2BIG;
-    if (afs_pd_putString(aout, motd) != 0)
-	return E2BIG;
+
+    if (afs_pd_putBytes(aout, &volstat, sizeof(volstat)) != 0) {
+	code = E2BIG;
+	goto out;
+    }
+
+    if (afs_pd_putString(aout, volName) != 0) {
+	code = E2BIG;
+	goto out;
+    }
+
+    if (afs_pd_putString(aout, offLineMsg) != 0) {
+	code = E2BIG;
+	goto out;
+    }
+
+    if (afs_pd_putString(aout, motd) != 0) {
+	code = E2BIG;
+	goto out;
+    }
+
   out:
     xdr_free((xdrproc_t) xdr_string, &volName);
     xdr_free((xdrproc_t) xdr_string, &offLineMsg);
diff --git a/src/aklog/klog.c b/src/aklog/klog.c
index 6a75399c77..9da05ac2b1 100644
--- a/src/aklog/klog.c
+++ b/src/aklog/klog.c
@@ -14,7 +14,7 @@
 #include <roken.h>
 
 #include <rx/xdr.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/com_err.h>
 #include <afs/auth.h>
diff --git a/src/audit/audit.c b/src/audit/audit.c
index 1f641f0c52..631f93d08e 100644
--- a/src/audit/audit.c
+++ b/src/audit/audit.c
@@ -29,7 +29,7 @@
 #include <rx/rxkad.h>
 #include "audit.h"
 #include "audit-api.h"
-#include "lock.h"
+#include "afs/afs_lock.h"
 
 #include <afs/afsutil.h>
 
diff --git a/src/bucoord/bc_status.c b/src/bucoord/bc_status.c
index 04b2ba9d8c..120814d00b 100644
--- a/src/bucoord/bc_status.c
+++ b/src/bucoord/bc_status.c
@@ -14,7 +14,7 @@
 
 #include <afs/com_err.h>
 #include <afs/bubasics.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/tcdata.h>
 #include <afs/cmd.h>
 
diff --git a/src/bucoord/commands.c b/src/bucoord/commands.c
index dc7847fd14..9ddbf6a6a2 100644
--- a/src/bucoord/commands.c
+++ b/src/bucoord/commands.c
@@ -30,7 +30,7 @@
 #include <afs/vldbint.h>	/* PA */
 #include <afs/ktime.h>		/* PA */
 #include <ubik.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/tcdata.h>
 #include <afs/butx.h>
 #include <afs/vsutils_prototypes.h>
diff --git a/src/bucoord/dump.c b/src/bucoord/dump.c
index a85484d242..dd36435cdf 100644
--- a/src/bucoord/dump.c
+++ b/src/bucoord/dump.c
@@ -23,7 +23,6 @@
 #include <afs/bubasics.h>
 #include <afs/butc.h>
 #include <afs/com_err.h>
-#include <lock.h>		/* for checking TC_ABORTFAILED. PA */
 #include <afs/tcdata.h>		/* for checking TC_ABORTFAILED. PA */
 #include <afs/butc.h>
 
diff --git a/src/bucoord/main.c b/src/bucoord/main.c
index 1ed0997b5c..b54d9a7c8c 100644
--- a/src/bucoord/main.c
+++ b/src/bucoord/main.c
@@ -29,7 +29,7 @@
 #include <afs/afsint.h>
 #include <afs/volser.h>		/*VLDB_MAXSERVERS */
 #include <afs/com_err.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/budb.h>
 #include <afs/kautils.h>
 #include <afs/vlserver.h>
diff --git a/src/bucoord/ubik_db_if.c b/src/bucoord/ubik_db_if.c
index d88233e85d..f9fbc93b5f 100644
--- a/src/bucoord/ubik_db_if.c
+++ b/src/bucoord/ubik_db_if.c
@@ -966,7 +966,7 @@ udbClientInit(int noAuthFlag, int localauth, char *cellName)
 
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 
 /* notes
  *	1) first call with SINGLESERVER set, record the server to be used.
diff --git a/src/budb/Makefile.in b/src/budb/Makefile.in
index d20344d853..eae64b7a36 100644
--- a/src/budb/Makefile.in
+++ b/src/budb/Makefile.in
@@ -12,7 +12,7 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp
 
 
 INCLS=\
-	${TOP_INCDIR}/lock.h \
+	${TOP_INCDIR}/afs/afs_lock.h \
 	${TOP_INCDIR}/ubik.h \
 	${TOP_INCDIR}/lwp.h \
 	${TOP_INCDIR}/rx/rx.h \
diff --git a/src/budb/database.h b/src/budb/database.h
index 222ecd62db..9382004ec9 100644
--- a/src/budb/database.h
+++ b/src/budb/database.h
@@ -9,7 +9,7 @@
 
 #include <afs/auth.h>
 #include <afs/bubasics.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include "budb.h"
 
 #if !defined(offsetof)
diff --git a/src/budb/ol_verify.c b/src/budb/ol_verify.c
index 8baeccca9b..18d68581b2 100644
--- a/src/budb/ol_verify.c
+++ b/src/budb/ol_verify.c
@@ -15,7 +15,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/cellconfig.h>
 #include <afs/audit.h>
diff --git a/src/budb/procs.c b/src/budb/procs.c
index a0879b12f3..75e35f2a14 100644
--- a/src/budb/procs.c
+++ b/src/budb/procs.c
@@ -20,7 +20,7 @@
 
 #include <afs/stds.h>
 #include <afs/bubasics.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <lwp.h>
 #include <rx/xdr.h>
diff --git a/src/butc/dbentries.c b/src/butc/dbentries.c
index 867a225225..3ca4f30e63 100644
--- a/src/butc/dbentries.c
+++ b/src/butc/dbentries.c
@@ -16,7 +16,7 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/tcdata.h>
 #include <afs/bubasics.h>
 #include <afs/budb_client.h>
diff --git a/src/butc/dump.c b/src/butc/dump.c
index 365544ec7b..9278ee93f6 100644
--- a/src/butc/dump.c
+++ b/src/butc/dump.c
@@ -16,7 +16,7 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/tcdata.h>
 #include <afs/bubasics.h>
 #include <afs/budb_client.h>
diff --git a/src/butc/list.c b/src/butc/list.c
index fac79aeb24..62c16445be 100644
--- a/src/butc/list.c
+++ b/src/butc/list.c
@@ -14,7 +14,7 @@
 
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <lwp.h>
 #include <afs/tcdata.h>
 
diff --git a/src/butc/lwps.c b/src/butc/lwps.c
index 3078d73823..51ece82d19 100644
--- a/src/butc/lwps.c
+++ b/src/butc/lwps.c
@@ -20,7 +20,7 @@
 #include <afs/opr.h>
 #include <rx/rx.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/tcdata.h>
 #include <afs/bubasics.h>	/* PA */
 #include <afs/budb_client.h>
diff --git a/src/butc/read_tape.c b/src/butc/read_tape.c
index 569a740698..a256c8d913 100644
--- a/src/butc/read_tape.c
+++ b/src/butc/read_tape.c
@@ -13,7 +13,7 @@
 #include <roken.h>
 
 #include <afs/cmd.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/tcdata.h>
 #include <afs/usd.h>
 
diff --git a/src/butc/recoverDb.c b/src/butc/recoverDb.c
index 36abc56166..0430540192 100644
--- a/src/butc/recoverDb.c
+++ b/src/butc/recoverDb.c
@@ -16,7 +16,7 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <afs/tcdata.h>
 #include <afs/bubasics.h>
diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c
index 6a5daa21bc..750679aba5 100644
--- a/src/butc/tcmain.c
+++ b/src/butc/tcmain.c
@@ -35,7 +35,7 @@
 #include <afs/nfs.h>
 #include <afs/vlserver.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <afs/authcon.h>
 #include <afs/cellconfig.h>
diff --git a/src/butc/tcprocs.c b/src/butc/tcprocs.c
index c51b1f14d2..e5c61e3e4d 100644
--- a/src/butc/tcprocs.c
+++ b/src/butc/tcprocs.c
@@ -21,7 +21,7 @@
 #include <afs/prs_fs.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 #include <ubik.h>
diff --git a/src/butc/tcstatus.c b/src/butc/tcstatus.c
index b67ae1eee4..48773d7094 100644
--- a/src/butc/tcstatus.c
+++ b/src/butc/tcstatus.c
@@ -13,7 +13,7 @@
 #include <roken.h>
 
 #include <afs/com_err.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/bubasics.h>
 #include <afs/tcdata.h>
 #include <afs/butc.h>
diff --git a/src/butc/tcudbprocs.c b/src/butc/tcudbprocs.c
index ed953c1965..d543582571 100644
--- a/src/butc/tcudbprocs.c
+++ b/src/butc/tcudbprocs.c
@@ -19,7 +19,7 @@
 #include <afs/prs_fs.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 #include <ubik.h>
diff --git a/src/cf/afs-libtool.m4 b/src/cf/afs-libtool.m4
index 63ec5c18fc..76d7f94477 100644
--- a/src/cf/afs-libtool.m4
+++ b/src/cf/afs-libtool.m4
@@ -18,7 +18,14 @@ dnl libtool.
 AC_DEFUN([AFS_LT_INIT],
   [AC_REQUIRE([AFS_LT_PATH_NM])
 
-   LT_INIT
+dnl For AIX, change the --with-aix-soname default to be 'svr4' (builds a static
+dnl libfoo.a and a shared libfoo.so) instead of 'aix' (builds the static and
+dnl shared objects together in libfoo.a).
+dnl
+dnl Also specify 'shared' and 'static' to enable shared and static libraries by
+dnl default. These are already turned on by default, but we specify them
+dnl explicitly here to workaround libtool bug #111161.
+   LT_INIT([shared static aix-soname=svr4])
 
 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
diff --git a/src/cf/linux-kernel-func.m4 b/src/cf/linux-kernel-func.m4
index 175db00eaf..0784262d70 100644
--- a/src/cf/linux-kernel-func.m4
+++ b/src/cf/linux-kernel-func.m4
@@ -367,6 +367,18 @@ AC_CHECK_LINUX_FUNC([readahead_folio],
 		      static struct folio *folio;]],
 		    [[folio = __readahead_folio(NULL);]])
 
+dnl Linux 6.17 changed aops->write_begin/write_end to take a struct kiocp *
+dnl instead of a struct file *.
+AC_CHECK_LINUX_FUNC([write_begin_end_kiocb],
+		    [[#include <linux/fs.h>
+		      static const struct kiocb *kiocb;
+		      static struct address_space *mapping;
+		      static struct folio *foliop;
+		      static void *fsdata;
+		      static struct address_space_operations *aops;]],
+		    [[aops->write_begin(kiocb, mapping, 0, 0, &foliop, fsdata);
+		      aops->write_end(kiocb, mapping, 0, 0, 0, foliop, fsdata);]])
+
 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/config/NTMakefile.amd64_w2k b/src/config/NTMakefile.amd64_w2k
index 1bbcd75e60..5ce54d3b1a 100644
--- a/src/config/NTMakefile.amd64_w2k
+++ b/src/config/NTMakefile.amd64_w2k
@@ -88,7 +88,7 @@ AFSPRODUCT_VER_MAJOR=1
 AFSPRODUCT_VER_MINOR=8
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
-AFSPRODUCT_VER_PATCH=1401
+AFSPRODUCT_VER_PATCH=1500
 !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 f89c5dd1e6..6586968a6d 100644
--- a/src/config/NTMakefile.i386_nt40
+++ b/src/config/NTMakefile.i386_nt40
@@ -88,7 +88,7 @@ AFSPRODUCT_VER_MAJOR=1
 AFSPRODUCT_VER_MINOR=8
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
-AFSPRODUCT_VER_PATCH=1401
+AFSPRODUCT_VER_PATCH=1500
 !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 24d6feba0f..d38df4a48a 100644
--- a/src/config/NTMakefile.i386_w2k
+++ b/src/config/NTMakefile.i386_w2k
@@ -92,7 +92,7 @@ AFSPRODUCT_VER_MAJOR=1
 AFSPRODUCT_VER_MINOR=8
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_PATCH)
-AFSPRODUCT_VER_PATCH=1401
+AFSPRODUCT_VER_PATCH=1500
 !ENDIF
 !IF !DEFINED(AFSPRODUCT_VER_BUILD)
 AFSPRODUCT_VER_BUILD=0
diff --git a/src/config/icl.h b/src/config/icl.h
index ec912ac649..bdee33eda8 100644
--- a/src/config/icl.h
+++ b/src/config/icl.h
@@ -19,7 +19,7 @@
 #include "lock.h"
 #include "afs_trace.h"
 #else
-#include <lock.h>
+#include <afs/afs_lock.h>
 typedef struct Lock afs_lock_t;
 #endif
 
diff --git a/src/dir/buffer.c b/src/dir/buffer.c
index d522d92cd9..56404441f4 100644
--- a/src/dir/buffer.c
+++ b/src/dir/buffer.c
@@ -13,7 +13,7 @@
 #include <roken.h>
 #include <afs/opr.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 
 #include "dir.h"
 
diff --git a/src/export/cfgafs.c b/src/export/cfgafs.c
index fdc8c4d0b2..ca4d5a293e 100644
--- a/src/export/cfgafs.c
+++ b/src/export/cfgafs.c
@@ -17,6 +17,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/device.h>
 #include <sys/sysconfig.h>
@@ -25,14 +27,28 @@
 #include <setjmp.h>
 #include <signal.h>
 
-extern char *malloc(), *optarg;
+extern char *optarg;
 
 extern int sysconfig(int cmd, void *arg, int len);
 
 #include "AFS_component_version_number.c"
 
-main(argc, argv)
-     char **argv;
+#if defined(AFS_AIX42_ENV)
+static const char *execerror = "/usr/sbin/execerror";
+#else
+static const char *execerror = "/etc/execerror";
+#endif
+
+static void
+usage(void)
+{
+
+    fprintf(stderr, "usage: cfgafs [-a mod_file] [-d mod_file]\n");
+    exit(1);
+}
+
+int
+main(int argc, char **argv)
 {
     int add, del;
     int c;
@@ -95,7 +111,7 @@ main(argc, argv)
 	if (res != 0) {
 	    perror("SYS_KLOAD");
 	    loadquery(L_GETMESSAGES, &buf[2], sizeof buf - 8);
-	    execvp("/etc/execerror", buf);
+	    execvp(execerror, buf);
 	    exit(1);
 	}
 
@@ -154,10 +170,3 @@ main(argc, argv)
 	exit(0);
     }
 }
-
-usage()
-{
-
-    fprintf(stderr, "usage: cfgafs [-a mod_file] [-d mod_file]\n");
-    exit(1);
-}
diff --git a/src/export/cfgexport.c b/src/export/cfgexport.c
index f4ab5d5a25..f8f3df20ce 100644
--- a/src/export/cfgexport.c
+++ b/src/export/cfgexport.c
@@ -17,6 +17,8 @@
 #include <errno.h>
 #include <stdio.h>
 #include <fcntl.h>
+#include <stdlib.h>
+#include <string.h>
 #include <sys/types.h>
 #include <sys/device.h>
 #include <sys/sysconfig.h>
@@ -28,17 +30,38 @@
 #include "export.h"
 #include "sym.h"
 
-extern char *malloc(), *optarg;
+extern char *optarg;
 extern int sysconfig(int cmd, void *arg, int len);
 
-int debug = 0;
-char *syms = "/unix";
-char *xstrings;
+static int debug = 0;
+static char *syms = "/unix";
+static char *xstrings;
 
 #include "AFS_component_version_number.c"
 
-main(argc, argv)
-     char **argv;
+static void get_syms(struct k_conf *conf, char *syms);
+static void xlate_xtok(struct syment *xp, sym_t *kp, char **strp, uint *szp);
+static int find_suffix(char *p, char *strings, int max, uint *offp);
+static int xsym_compar(struct syment *xp, struct syment *xq);
+static void dump_xsym(struct syment *xsp);
+static void dump_ksym(sym_t *ksp, char *strings);
+static void error();
+static void sys_error();
+
+#if defined(AFS_AIX42_ENV)
+static const char *execerror = "/usr/sbin/execerror";
+#else
+static const char *execerror = "/etc/execerror";
+#endif
+
+static void
+usage(void)
+{
+    error("usage: cfgexport [-a mod_file [-s symbols]] [-d mod_file]\n");
+}
+
+int
+main(int argc, char **argv)
 {
     int add, del, opts;
     int c;
@@ -109,7 +132,7 @@ main(argc, argv)
 	cload.path = file;
 	if (sysconfig(SYS_KLOAD, &cload, sizeof(cload)) == -1) {
 	    loadquery(L_GETMESSAGES, &buf[2], sizeof buf - 8);
-	    execvp("/etc/execerror", buf);
+	    execvp(execerror, buf);
 	    perror("SYS_KLOAD");
 	    exit(1);
 	}
@@ -170,12 +193,9 @@ main(argc, argv)
 	}
 	exit(0);
     }
-}
-
-usage()
-{
 
-    error("usage: cfgexport [-a mod_file [-s symbols]] [-d mod_file]\n");
+    /* unreached */
+    return -1;
 }
 
 /*
@@ -185,9 +205,8 @@ usage()
  *	conf	-	^ to EXPORT extension configuration struct
  *	syms	-	^ to name of file containing XCOFF symbols
  */
-get_syms(conf, syms)
-     struct k_conf *conf;
-     char *syms;
+static void
+get_syms(struct k_conf *conf, char *syms)
 {
     sym_t *k_symtab, *ksp;
     struct syment *x_symtab, *xsp, *xsq;
@@ -198,7 +217,6 @@ get_syms(conf, syms)
     int i, nsyms, nksyms, nxsyms = 0;
     int xstr_size, kstr_size;
     FILE *fp;
-    int xsym_compar();
 
     if (syms == NULL)
       sys_error("syms is NULL");
@@ -365,7 +383,6 @@ get_syms(conf, syms)
     conf->strtab = kstrings;
 }
 
-
 /*
  * xlate_xtok	-	xlate XCOFF to EXPORT format
  *
@@ -376,15 +393,12 @@ get_syms(conf, syms)
  *	szp	-	^ to EXPORT string table size
  */
 #define SYMBUFSIZE 1048576
-xlate_xtok(xp, kp, strp, szp)
-     struct syment *xp;
-     sym_t *kp;
-     char **strp;
-     uint *szp;
+static void
+xlate_xtok(struct syment *xp, sym_t *kp, char **strp, uint *szp)
 {
     int len;
     static char *export_strings = NULL, *prev = "";
-    static left, offset, sz;
+    static int left, offset, sz;
 
     if (!export_strings) {
 	export_strings = malloc(sz = SYMBUFSIZE);
@@ -488,9 +502,8 @@ xlate_xtok(xp, kp, strp, szp)
  * NOTE:
  *	This is rather inefficient.
  */
-find_suffix(p, strings, max, offp)
-     char *p, *strings;
-     uint *offp;
+static int
+find_suffix(char *p, char *strings, int max, uint *offp)
 {
     char *q, *e;
     int len = strlen(p) - 1;
@@ -530,8 +543,8 @@ find_suffix(p, strings, max, offp)
  * If the names are the same, sort by descending storage class, so that
  * C_EXT < C_HIDEXT;
  */
-xsym_compar(xp, xq)
-     struct syment *xp, *xq;
+static int
+xsym_compar(struct syment *xp, struct syment *xq)
 {
     char *p, *q;
     int compar;
@@ -558,8 +571,8 @@ xsym_compar(xp, xq)
 /*
  * dump_xsym -	print to XCOFF symbol
  */
-dump_xsym(xsp)
-     struct syment *xsp;
+static void
+dump_xsym(struct syment *xsp)
 {
 
 #ifndef __XCOFF64__
@@ -581,9 +594,8 @@ dump_xsym(xsp)
 	     xsp->n_sclass, xsp->n_numaux);
 }
 
-dump_ksym(ksp, strings)
-     sym_t *ksp;
-     char *strings;
+static void
+dump_ksym(sym_t *ksp, char *strings)
 {
 
 #ifndef __XCOFF64__
@@ -594,28 +606,18 @@ dump_ksym(ksp, strings)
 	printf("%8.8x %s\n", ksp->n_value, ksp->n_offset + strings);
 }
 
-error(p, a, b, c, d, e)
-     char *p;
+static void
+error(char *p, long a, long b, long c, long d, long e)
 {
-
     fprintf(stderr, p, a, b, c, d, e);
     fprintf(stderr, "\n");
     exit(1);
 }
 
-sys_error(p, a, b, c, d, e)
-     char *p;
+static void
+sys_error(char *p, long a, long b, long c, long d, long e)
 {
-
     fprintf(stderr, p, a, b, c, d, e);
     perror(": ");
     exit(1);
 }
-
-warn(p, a, b, c, d, e)
-     char *p;
-{
-
-    fprintf(stderr, p, a, b, c, d, e);
-    fprintf(stderr, "\n");
-}
diff --git a/src/export/export.c b/src/export/export.c
index 5aacec725c..973e731009 100644
--- a/src/export/export.c
+++ b/src/export/export.c
@@ -31,8 +31,11 @@
 
 sym_t *toc_syms;		/* symbol table                 */
 int toc_nsyms;			/* # of symbols                 */
-caddr_t toc_strs;		/* string table                 */
-int toc_size;			/* size of toc_syms             */
+static caddr_t toc_strs;		/* string table                 */
+static int toc_size;			/* size of toc_syms             */
+
+static int config(struct uio *uiop);
+static int export_cleanup(void);
 
 /*
  * export	-	entry point to EXPORT kernel extension
@@ -41,11 +44,10 @@ int toc_size;			/* size of toc_syms             */
  *	cmd	-	add/delete command
  *	uiop	-	uio vector describing any config params
  */
-export(cmd, uiop)
-     struct uio *uiop;
+int
+export(int cmd, struct uio *uiop)
 {
     int err, monster;
-    static once;
 
     err = 0;
     monster = lockl(&kernel_lock, LOCK_SHORT);
@@ -75,8 +77,8 @@ export(cmd, uiop)
 /*
  * config -	process configuration data
  */
-config(uiop)
-     struct uio *uiop;
+static int
+config(struct uio *uiop)
 {
     struct k_conf conf;
     struct export_nl *np;
@@ -129,7 +131,8 @@ config(uiop)
 /*
  * export_cleanup -	cleanup EXPORT prior to removing kernel extension
  */
-export_cleanup()
+static int
+export_cleanup(void)
 {
 
     /*
@@ -156,11 +159,11 @@ export_cleanup()
  *	the /unix symbol table) we are in trouble.
  */
 #ifdef __XCOFF64__
-u_int64 *myg_toc;
+static u_int64 *myg_toc;
 #else
-u_int32 *myg_toc;
+static u_int32 *myg_toc;
 #endif
-
+int
 import_kfunc(struct k_func * kfp)
 {
     sym_t *sym;
@@ -202,6 +205,7 @@ import_kfunc(struct k_func * kfp)
  * import_kvar -	import a kernel variable that was mistakenly left
  *			off the exports list
  */
+int
 import_kvar(struct k_var * kvp, caddr_t * toc)
 {
     sym_t *sym;
@@ -249,6 +253,7 @@ import_kvar(struct k_var * kvp, caddr_t * toc)
  * Call vanilla syscalls
  */
 #ifndef AFS_AIX51_ENV
+int
 osetgroups(ngroups, gidset)
      int ngroups;
      gid_t *gidset;
@@ -262,13 +267,16 @@ osetgroups(ngroups, gidset)
 
 #ifdef AFS_AIX51_ENV
 #ifdef AFS_64BIT_KERNEL
-okioctl(fdes, cmd, arg, ext, arg2, arg3)
+int
+okioctl(int fdes, int cmd, caddr_t arg, caddr_t ext, caddr_t arg2,
+	caddr_t arg3)
 #else /* AFS_64BIT_KERNEL */
-okioctl32(fdes, cmd, arg, ext, arg2, arg3)
+int
+okioctl32(int fdes, int cmd, caddr_t arg, caddr_t ext, caddr_t arg2,
+	  caddr_t arg3)
 #endif /* AFS_64BIT_KERNEL */
-     int fdes, cmd;
-     caddr_t ext, arg, arg2, arg3;
 #else
+int
 okioctl(fdes, cmd, arg, ext)
      int fdes, cmd, arg;
      caddr_t ext;
@@ -278,6 +286,7 @@ okioctl(fdes, cmd, arg, ext)
 
 #ifdef AFS_AIX51_ENV
 #ifdef AFS_64BIT_KERNEL
+    extern int kioctl(int, int, caddr_t, caddr_t, caddr_t, caddr_t);
     error = kioctl(fdes, cmd, arg, ext, arg2, arg3);
 #else /* AFS_64BIT_KERNEL */
     error = kioctl32(fdes, cmd, arg, ext, arg2, arg3);
@@ -287,16 +296,3 @@ okioctl(fdes, cmd, arg, ext)
 #endif
     return (error);
 }
-
-#ifdef	notdef
-ocore(signo, sigctx)
-     char signo;
-     struct sigcontext *sigctx;
-{
-    int error;
-#include <sys/user.h>
-    u.u_sigflags[signo] |= SA_FULLDUMP;	/* XXX */
-    error = core(signo, sigctx);
-    return (error);
-}
-#endif
diff --git a/src/export/sym.h b/src/export/sym.h
index 8cb8d7997b..e199e74942 100644
--- a/src/export/sym.h
+++ b/src/export/sym.h
@@ -44,7 +44,5 @@ struct toc_syment {
 typedef struct toc_syment sym_t;
 
 extern struct toc_syment *toc_syms;	/* symbol table         */
-extern caddr_t toc_strs;	/* string table         */
-extern toc_nsyms;		/* # symbols            */
-extern sym_t *sym_flex();
-extern sym_t *sym_lookup();
+extern int toc_nsyms;		/* # symbols            */
+extern sym_t *sym_lookup(char *name, int value);
diff --git a/src/export/symtab.c b/src/export/symtab.c
index 74942bc3cf..7d620380c0 100644
--- a/src/export/symtab.c
+++ b/src/export/symtab.c
@@ -14,6 +14,7 @@
 #include <afs/param.h>
 
 
+#include <string.h>
 #include "sys/types.h"
 #include "sym.h"
 
@@ -29,11 +30,13 @@
 	((sym)->n_zeroes == 0 ? (char *) sym_off(sym) : (sym)->n_name)
 #endif
 
+static sym_t * search(unsigned addr);
+static sym_t * symsrch(char *s);
+static sym_t * sym_flex(sym_t *sym);
+
 sym_t *
-sym_lookup(name, value)
-     char *name;
+sym_lookup(char *name, int value)
 {
-    static sym_t *symsrch(), *search();
     char buf[64];
     sym_t *sym;
 
@@ -59,8 +62,7 @@ sym_lookup(name, value)
 }
 
 static sym_t *
-search(addr)
-     unsigned addr;
+search(unsigned addr)
 {
     sym_t *sp;
     sym_t *save;
@@ -81,8 +83,7 @@ search(addr)
 }
 
 static sym_t *
-symsrch(s)
-     char *s;
+symsrch(char *s)
 {
     sym_t *sp;
     sym_t *found;
@@ -126,9 +127,8 @@ symsrch(s)
  * Returns:
  *	^ to static location containing modified symbol.
  */
-sym_t *
-sym_flex(sym)
-     sym_t *sym;
+static sym_t *
+sym_flex(sym_t *sym)
 {
     static sym_t symbol;
     static char name[48];
diff --git a/src/finale/Makefile.in b/src/finale/Makefile.in
index 606f7c970a..fb417e4c71 100644
--- a/src/finale/Makefile.in
+++ b/src/finale/Makefile.in
@@ -12,7 +12,7 @@ include @TOP_OBJDIR@/src/config/Makefile.lwp
 
 INCLS=${TOP_INCDIR}/ubik.h \
 	${TOP_INCDIR}/lwp.h \
-	${TOP_INCDIR}/lock.h  \
+	${TOP_INCDIR}/afs/afs_lock.h  \
 	${TOP_INCDIR}/rx/rx.h \
 	${TOP_INCDIR}/rx/xdr.h \
 	${TOP_INCDIR}/rx/rxkad.h \
diff --git a/src/gtx/gtxtextcb.h b/src/gtx/gtxtextcb.h
index e379f63bbd..9d3b51c529 100644
--- a/src/gtx/gtxtextcb.h
+++ b/src/gtx/gtxtextcb.h
@@ -18,7 +18,7 @@
  *
  *------------------------------------------------------------------------*/
 
-#include <lock.h>		/*AFS locks */
+#include <afs/afs_lock.h>		/*AFS locks */
 
 #define GATOR_TEXTCB_MAXINVERSIONS 10	/*Max highlight inversions */
 
diff --git a/src/kauth/Makefile.in b/src/kauth/Makefile.in
index cffe8ea792..7181f99f2e 100644
--- a/src/kauth/Makefile.in
+++ b/src/kauth/Makefile.in
@@ -28,7 +28,7 @@ INSTALL_KAUTH = @INSTALL_KAUTH@
 
 INCLS=${TOP_INCDIR}/ubik.h \
              ${TOP_INCDIR}/lwp.h \
-             ${TOP_INCDIR}/lock.h  \
+             ${TOP_INCDIR}/afs/afs_lock.h  \
              ${TOP_INCDIR}/rx/rx.h \
              ${TOP_INCDIR}/rx/xdr.h \
 	     ${TOP_INCDIR}/rx/rxkad.h \
diff --git a/src/kauth/admin_tools.c b/src/kauth/admin_tools.c
index a260341e06..fbd2b33420 100644
--- a/src/kauth/admin_tools.c
+++ b/src/kauth/admin_tools.c
@@ -29,7 +29,7 @@
 #include <rx/rx.h>
 #include <rx/rxkad.h>
 #include <rx/rxkad_convert.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #define UBIK_LEGACY_CALLITER 1
 #include <ubik.h>
 #include <afs/auth.h>
diff --git a/src/kauth/ka_util.c b/src/kauth/ka_util.c
index a3e0b8b574..dd131ce60c 100644
--- a/src/kauth/ka_util.c
+++ b/src/kauth/ka_util.c
@@ -15,7 +15,7 @@
 
 #include <ctype.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #define UBIK_INTERNALS
 #include <ubik.h>
 #include <rx/xdr.h>
diff --git a/src/kauth/kaprocs.c b/src/kauth/kaprocs.c
index f7c639eb4e..4cce7aa075 100644
--- a/src/kauth/kaprocs.c
+++ b/src/kauth/kaprocs.c
@@ -27,7 +27,7 @@
 #define HC_DEPRECATED
 #include <hcrypto/des.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <lwp.h>
 #include <rx/xdr.h>
diff --git a/src/kauth/kas.c b/src/kauth/kas.c
index 027b44883c..10bf5c736b 100644
--- a/src/kauth/kas.c
+++ b/src/kauth/kas.c
@@ -19,7 +19,7 @@
 #endif
 
 #include <rx/xdr.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/cellconfig.h>
 #include <afs/com_err.h>
diff --git a/src/kauth/kaserver.c b/src/kauth/kaserver.c
index 5524bb3a5b..37f6aecb00 100644
--- a/src/kauth/kaserver.c
+++ b/src/kauth/kaserver.c
@@ -26,7 +26,7 @@
 #include <rx/rxkad.h>
 #include <rx/rx_globals.h>
 #include <afs/cellconfig.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <afs/com_err.h>
 #include <afs/audit.h>
diff --git a/src/kauth/katoken.c b/src/kauth/katoken.c
index 9d9bfd34df..bca2f7b8b1 100644
--- a/src/kauth/katoken.c
+++ b/src/kauth/katoken.c
@@ -22,7 +22,7 @@
 #include <afs/pthread_glock.h>
 #include <afs/cellconfig.h>
 #include <afs/auth.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 
 #include "kauth.h"
diff --git a/src/kauth/klog.c b/src/kauth/klog.c
index 9116a88207..8c415418ac 100644
--- a/src/kauth/klog.c
+++ b/src/kauth/klog.c
@@ -14,7 +14,7 @@
 #include <roken.h>
 
 #include <rx/xdr.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/com_err.h>
 #include <afs/cellconfig.h>
diff --git a/src/kauth/kpasswd.c b/src/kauth/kpasswd.c
index f83e799d7d..f345fcfb36 100644
--- a/src/kauth/kpasswd.c
+++ b/src/kauth/kpasswd.c
@@ -22,7 +22,7 @@
 
 #include <rx/xdr.h>
 #include <rx/rxkad_convert.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/com_err.h>
 #include <afs/auth.h>
diff --git a/src/kauth/manyklog.c b/src/kauth/manyklog.c
index 760ffe813f..b2ed0b577a 100644
--- a/src/kauth/manyklog.c
+++ b/src/kauth/manyklog.c
@@ -14,7 +14,7 @@
 #include <roken.h>
 
 #include <rx/xdr.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/com_err.h>
 #include <afs/cellconfig.h>
diff --git a/src/kauth/test/multiklog.c b/src/kauth/test/multiklog.c
index da48608ed2..56b05bbe07 100644
--- a/src/kauth/test/multiklog.c
+++ b/src/kauth/test/multiklog.c
@@ -22,7 +22,7 @@
 #include <sys/types.h>
 #include <rx/xdr.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 
 #include <stdio.h>
diff --git a/src/kauth/test/test_badtix.c b/src/kauth/test/test_badtix.c
index a157d89b2d..8f78be495f 100644
--- a/src/kauth/test/test_badtix.c
+++ b/src/kauth/test/test_badtix.c
@@ -18,7 +18,7 @@
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rxkad.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <lwp.h>
 #include "kauth.h"
diff --git a/src/libacl/test/acltest.c b/src/libacl/test/acltest.c
index dbaa8b49f1..b9af1c5d0f 100644
--- a/src/libacl/test/acltest.c
+++ b/src/libacl/test/acltest.c
@@ -235,7 +235,7 @@ main()
 		continue;
 	    }
 	    names.namelist_len = 1;
-	    names.namelist_val = malloc(strlen(name) + 1);
+	    names.namelist_val = calloc(1, PR_MAXNAMELEN);
 	    strncpy(names.namelist_val, name, PR_MAXNAMELEN);
 	    code = pr_NameToId(&names, &ids);
 	    if (code) {
diff --git a/src/libadmin/pts/afs_ptsAdmin.c b/src/libadmin/pts/afs_ptsAdmin.c
index 97c44ce09d..2cede105a7 100644
--- a/src/libadmin/pts/afs_ptsAdmin.c
+++ b/src/libadmin/pts/afs_ptsAdmin.c
@@ -191,6 +191,8 @@ TranslateTwoNames(const afs_cell_handle_p c_handle, const char *id1,
     namelist names;
     char tmp_array[2 * PTS_MAX_NAME_LEN];
 
+    memset(tmp_array, 0, sizeof(tmp_array));
+
     /*
      * Copy the group and user names in order to translate them
      */
@@ -271,6 +273,8 @@ TranslateOneName(const afs_cell_handle_p c_handle, const char *ptsName,
     char tmp_array[PTS_MAX_NAME_LEN];
     idlist ids;
 
+    memset(tmp_array, 0, sizeof(tmp_array));
+
     /*
      * Copy the name in order to translate it
      */
@@ -1489,6 +1493,7 @@ pts_GroupMemberRemove(const void *cellHandle, const char *userName,
     idlist ids;
 
     ids.idlist_val = NULL;
+    ids.idlist_len = 0;
 
     /*
      * Validate arguments
diff --git a/src/libadmin/vos/vsprocs.h b/src/libadmin/vos/vsprocs.h
index 74a1dcaab3..b410b198b5 100644
--- a/src/libadmin/vos/vsprocs.h
+++ b/src/libadmin/vos/vsprocs.h
@@ -20,7 +20,7 @@
 #include <sys/file.h>
 #include <netinet/in.h>
 #endif
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/voldefs.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
diff --git a/src/lwp/.gitignore b/src/lwp/.gitignore
new file mode 100644
index 0000000000..fde87e7343
--- /dev/null
+++ b/src/lwp/.gitignore
@@ -0,0 +1,5 @@
+# After changing this file, please run
+#     git ls-files -i --exclude-standard
+# to check that you haven't inadvertently ignored any tracked files.
+
+/rw
diff --git a/src/lwp/Makefile.in b/src/lwp/Makefile.in
index 7a5419602c..72f31f77a9 100644
--- a/src/lwp/Makefile.in
+++ b/src/lwp/Makefile.in
@@ -25,12 +25,12 @@ LT_libs = $(MT_LIBS)
 all: liboafs_lwpcompat.la liblwpcompat_pic.la \
 	${TOP_LIBDIR}/liblwp.a depinstall
 
-depinstall: ${TOP_INCDIR}/lock.h ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/timer.h
+depinstall: ${TOP_INCDIR}/afs/afs_lock.h ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/timer.h
 
 ${TOP_LIBDIR}/liblwp.a: liblwp.a
 	${INSTALL_DATA} $? $@
 
-${TOP_INCDIR}/lock.h: lock.h
+${TOP_INCDIR}/afs/afs_lock.h: afs_lock.h
 	${INSTALL_DATA} $? $@
 
 ${TOP_INCDIR}/lwp.h: lwp.h
@@ -185,7 +185,7 @@ lwp.o		: lwp.c lwp.h
 		*)  \
 			$(AFS_CCRULE_NOQ) ${srcdir}/lwp.c;; \
 		esac
-lock.lo		: lock.c lock.h lwp.h
+lock.lo		: lock.c afs_lock.h lwp.h
 timer.o		: timer.c
 fasttime.lo	: fasttime.c
 threadname.o    : threadname.c
@@ -201,19 +201,22 @@ rw: rw.o liblwp.a $(TOP_LIBDIR)/util.a $(TOP_LIBDIR)/libopr.a
 #
 # Install targets
 #
-install: liblwp.a lock.h lwp.h timer.h
+install: liblwp.a afs_lock.h lwp.h timer.h
 	${INSTALL} -d ${DESTDIR}${libdir}
 	${INSTALL} -d ${DESTDIR}${includedir}
+	${INSTALL} -d ${DESTDIR}${includedir}/afs
 	${INSTALL_DATA} liblwp.a ${DESTDIR}${libdir}/liblwp.a
-	${INSTALL_DATA} ${srcdir}/lock.h ${DESTDIR}${includedir}/lock.h
+	${INSTALL_DATA} ${srcdir}/afs_lock.h ${DESTDIR}${includedir}/afs/afs_lock.h
+	${INSTALL_DATA} ${srcdir}/old_lock_compat.h ${DESTDIR}${includedir}/lock.h
 	${INSTALL_DATA} ${srcdir}/lwp.h ${DESTDIR}${includedir}/lwp.h
 	${INSTALL_DATA} ${srcdir}/timer.h ${DESTDIR}${includedir}/timer.h
 
-dest: liblwp.a lock.h lwp.h timer.h
+dest: liblwp.a afs_lock.h lwp.h timer.h
 	${INSTALL} -d ${DEST}/lib
 	${INSTALL} -d ${DEST}/include
 	${INSTALL_DATA} liblwp.a ${DEST}/lib/liblwp.a
-	${INSTALL_DATA} ${srcdir}/lock.h ${DEST}/include/lock.h
+	${INSTALL_DATA} ${srcdir}/afs_lock.h ${DEST}/include/afs/afs_lock.h
+	${INSTALL_DATA} ${srcdir}/old_lock_compat.h ${DEST}/include/lock.h
 	${INSTALL_DATA} ${srcdir}/lwp.h ${DEST}/include/lwp.h
 	${INSTALL_DATA} ${srcdir}/timer.h ${DEST}/include/timer.h
 
@@ -224,6 +227,6 @@ buildtools: ${TOP_LIBDIR}/liblwp.a depinstall
 #
 clean:
 	$(LT_CLEAN)
-	$(RM) -f *.o *.a core AFS_component_version_number.c
+	$(RM) -f *.o *.a core rw AFS_component_version_number.c
 
 include ../config/Makefile.version
diff --git a/src/lwp/NTMakefile b/src/lwp/NTMakefile
index 816089eea8..c6e2f8ad69 100644
--- a/src/lwp/NTMakefile
+++ b/src/lwp/NTMakefile
@@ -26,7 +26,7 @@ $(LIBOBJS): $$(@B).c
 LIBFILE = $(DESTDIR)\lib\afslwp.lib
 
 INCFILES = \
-	$(DESTDIR)\include\lock.h \
+	$(DESTDIR)\include\afs\afs_lock.h \
 	$(DESTDIR)\include\lwp.h \
 	$(DESTDIR)\include\timer.h
 
diff --git a/src/lwp/lock.h b/src/lwp/afs_lock.h
similarity index 97%
rename from src/lwp/lock.h
rename to src/lwp/afs_lock.h
index f0f0efc18b..a3600b22fa 100644
--- a/src/lwp/lock.h
+++ b/src/lwp/afs_lock.h
@@ -20,11 +20,11 @@
 	Include file for using Vice locking routines.
 */
 
-#ifndef LOCK_H
-#define LOCK_H
+#ifndef OPENAFS_AFS_LOCK_H
+#define OPENAFS_AFS_LOCK_H
 
 #ifdef KERNEL
-#error Do not include lwp/lock.h for kernel code. Use afs/lock.h instead.
+#error Do not include afs/afs_lock.h for kernel code. Use afs/lock.h instead.
 #endif
 
 
@@ -217,4 +217,4 @@ void Lock_Destroy(struct Lock *lock);
 #define SharedLocked(lock)\
 	((lock)->excl_locked & SHARED_LOCK)
 
-#endif /* LOCK_H */
+#endif /* OPENAFS_AFS_LOCK_H */
diff --git a/src/lwp/lock.c b/src/lwp/lock.c
index 824ed170e1..0dc0467045 100644
--- a/src/lwp/lock.c
+++ b/src/lwp/lock.c
@@ -29,7 +29,7 @@
 #include <afs/opr.h>
 
 #include "lwp.h"
-#include "lock.h"
+#include "afs/afs_lock.h"
 
 #define FALSE	0
 #define TRUE	1
diff --git a/src/lwp/old_lock_compat.h b/src/lwp/old_lock_compat.h
new file mode 100644
index 0000000000..d36683ddb7
--- /dev/null
+++ b/src/lwp/old_lock_compat.h
@@ -0,0 +1,7 @@
+/*
+ * This is a compatibility header for <afs/afs_lock.h> in OpenAFS. OpenAFS used
+ * to include a header <lock.h>, but it was renamed to <afs/afs_lock.h>. This
+ * header exists just to allow older source code built against <lock.h> to
+ * still compile, and should be removed when possible.
+ */
+#include <afs/afs_lock.h>
diff --git a/src/lwp/rw.c b/src/lwp/rw.c
index d0ca13a006..b455205cdc 100644
--- a/src/lwp/rw.c
+++ b/src/lwp/rw.c
@@ -20,7 +20,7 @@ Created: 11/1/83, J. Rosenberg
 #include <roken.h>
 
 #include "lwp.h"
-#include "lock.h"
+#include "afs/afs_lock.h"
 
 #define DEFAULT_READERS	5
 
diff --git a/src/packaging/RedHat/openafs.spec.in b/src/packaging/RedHat/openafs.spec.in
index f1dce8fb16..03ab61e603 100644
--- a/src/packaging/RedHat/openafs.spec.in
+++ b/src/packaging/RedHat/openafs.spec.in
@@ -1329,6 +1329,8 @@ dkms remove -m %{name} -v %{dkms_version} --rpm_safe_upgrade --all ||:
 %{_bindir}/afs_compile_et
 %{_bindir}/rxgen
 %{_includedir}/afs
+%{_includedir}/afs/afs_lock.h
+# Note lock.h is a compat header, and should be removed when possible.
 %{_includedir}/lock.h
 %{_includedir}/lwp.h
 %{_includedir}/rx
diff --git a/src/platform/DARWIN/PrivilegedHelper/Makefile.in b/src/platform/DARWIN/PrivilegedHelper/Makefile.in
index 134f064486..9bbf3a04ec 100644
--- a/src/platform/DARWIN/PrivilegedHelper/Makefile.in
+++ b/src/platform/DARWIN/PrivilegedHelper/Makefile.in
@@ -5,10 +5,10 @@ include @TOP_OBJDIR@/src/config/Makefile.pthread
 all: org.openafs.privhelper
 
 org.openafs.privhelper: privhelper.c
-	$(CC) -O2 -mmacosx-version-min=10.6 \
+	$(AFS_LDRULE) privhelper.c -mmacosx-version-min=10.6 \
 		-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __info_plist -Xlinker privhelper-info.plist \
 		-Xlinker -sectcreate -Xlinker __TEXT -Xlinker __launchd_plist -Xlinker privhelper-launchd.plist \
-		-o org.openafs.privhelper privhelper.c -framework Security -framework CoreFoundation
+		-framework Security -framework CoreFoundation
 
 clean:
 	$(RM) -f *.o org.openafs.privhelper
diff --git a/src/ptserver/Makefile.in b/src/ptserver/Makefile.in
index 946da08cac..fd82db71c3 100644
--- a/src/ptserver/Makefile.in
+++ b/src/ptserver/Makefile.in
@@ -12,7 +12,7 @@ include @TOP_OBJDIR@/src/config/Makefile.lwptool
 ENABLE_PTHREADED_UBIK=@ENABLE_PTHREADED_UBIK@
 
 INCLS=${TOP_INCDIR}/ubik.h \
-	${TOP_INCDIR}/lock.h  \
+	${TOP_INCDIR}/afs/afs_lock.h  \
 	${TOP_INCDIR}/lwp.h \
 	${TOP_INCDIR}/rx/rx.h \
 	${TOP_INCDIR}/rx/xdr.h \
@@ -21,7 +21,7 @@ INCLS=${TOP_INCDIR}/ubik.h \
 	ptserver.h ptclient.h ptuser.h ptint.h pterror.h map.h ptprototypes.h
 
 LINCLS=${TOP_INCDIR}/ubik.h \
-	${TOP_INCDIR}/lock.h \
+	${TOP_INCDIR}/afs/afs_lock.h \
 	${TOP_INCDIR}/rx/rx.h \
 	${TOP_INCDIR}/rx/xdr.h  \
 	${TOP_INCDIR}/rx/rxkad.h \
diff --git a/src/ptserver/pt_util.c b/src/ptserver/pt_util.c
index 00b7deae6a..c8499c8dec 100644
--- a/src/ptserver/pt_util.c
+++ b/src/ptserver/pt_util.c
@@ -26,7 +26,7 @@
 #include <afs/com_err.h>
 #include <afs/cmd.h>		/*Command line parsing */
 #include <afs/afsutil.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #define UBIK_INTERNALS
 #include <ubik.h>
 #include <rx/xdr.h>
diff --git a/src/ptserver/ptclient.c b/src/ptserver/ptclient.c
index d765191e96..994a087dbd 100644
--- a/src/ptserver/ptclient.c
+++ b/src/ptserver/ptclient.c
@@ -344,7 +344,7 @@ main(int argc, char **argv)
 	    lid.idlist_val = 0;
 	    lid.idlist_len = 0;
 	} else if (!strcmp(op, "ntoi")) {
-	    lnames.namelist_val = malloc(PR_MAXLIST * PR_MAXNAMELEN);
+	    lnames.namelist_val = calloc(PR_MAXLIST, PR_MAXNAMELEN);
 	    lnames.namelist_len = 0;
 	    foo = line;
 	    skip(&foo);
diff --git a/src/ptserver/ptclient.h b/src/ptserver/ptclient.h
index abb487da7b..ea9af044a9 100644
--- a/src/ptserver/ptclient.h
+++ b/src/ptserver/ptclient.h
@@ -7,7 +7,7 @@
  * directory or online at http://www.openafs.org/dl/license10.html
  */
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include "ptint.h"
 #include "ptserver.h"
diff --git a/src/ptserver/ptprocs.c b/src/ptserver/ptprocs.c
index 617eb7cc5d..4b3b280442 100644
--- a/src/ptserver/ptprocs.c
+++ b/src/ptserver/ptprocs.c
@@ -56,7 +56,7 @@
 
 #include <ctype.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <ubik.h>
 #include <rx/xdr.h>
diff --git a/src/ptserver/pts.c b/src/ptserver/pts.c
index 05508a70df..076989ce32 100644
--- a/src/ptserver/pts.c
+++ b/src/ptserver/pts.c
@@ -422,14 +422,14 @@ GetNameOrId(struct cmd_syndesc *as, struct idlist *lids,
     lids->idlist_len = n;
     ids.idlist_val = malloc(n * sizeof(afs_int32));
     ids.idlist_len = n;
-    names.namelist_val = malloc(n * PR_MAXNAMELEN);
+    names.namelist_val = calloc(n, PR_MAXNAMELEN);
     names.namelist_len = n;
     if (lnames) {
 	lnames->namelist_val = malloc(n * PR_MAXNAMELEN);
 	lnames->namelist_len = 0;
     }
     for (i = as->parms[0].items; i; i = i->next) {
-	tnames.namelist_val = malloc(PR_MAXNAMELEN);
+	tnames.namelist_val = calloc(1, PR_MAXNAMELEN);
 	strncpy(tnames.namelist_val[0], i->data, PR_MAXNAMELEN);
 	tnames.namelist_len = 1;
 	tids.idlist_len = 0;
diff --git a/src/ptserver/ptserver.c b/src/ptserver/ptserver.c
index a133ec8088..be535a0515 100644
--- a/src/ptserver/ptserver.c
+++ b/src/ptserver/ptserver.c
@@ -127,7 +127,7 @@
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 #include <rx/rxstat.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/authcon.h>
 #include <afs/cmd.h>
diff --git a/src/ptserver/ptubik.c b/src/ptserver/ptubik.c
index 9d2d9169ed..4484fa15bd 100644
--- a/src/ptserver/ptubik.c
+++ b/src/ptserver/ptubik.c
@@ -6,7 +6,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/cellconfig.h>
 #define UBIK_INTERNALS
 #include <ubik.h>
diff --git a/src/ptserver/ptuser.c b/src/ptserver/ptuser.c
index 1eb7c5c500..13431e66d3 100644
--- a/src/ptserver/ptuser.c
+++ b/src/ptserver/ptuser.c
@@ -435,7 +435,7 @@ pr_AddToGroup(prname user, prname group)
     if (code)
 	return code;
     lnames.namelist_len = 2;
-    lnames.namelist_val = malloc(2 * PR_MAXNAMELEN);
+    lnames.namelist_val = calloc(2, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[0], user, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[1], group, PR_MAXNAMELEN);
     lids.idlist_val = 0;
@@ -478,7 +478,7 @@ pr_RemoveUserFromGroup(prname user, prname group)
     if (code)
 	return code;
     lnames.namelist_len = 2;
-    lnames.namelist_val = malloc(2 * PR_MAXNAMELEN);
+    lnames.namelist_val = calloc(2, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[0], user, PR_MAXNAMELEN);
     strncpy(lnames.namelist_val[1], group, PR_MAXNAMELEN);
     lids.idlist_val = 0;
@@ -540,7 +540,7 @@ pr_SNameToId(prname name, afs_int32 *id)
     lids.idlist_len = 0;
     lids.idlist_val = 0;
     lnames.namelist_len = 1;
-    lnames.namelist_val = malloc(PR_MAXNAMELEN);
+    lnames.namelist_val = calloc(1, PR_MAXNAMELEN);
     stolower(name);
     strncpy(lnames.namelist_val[0], name, PR_MAXNAMELEN);
     code = ubik_PR_NameToID(pruclient, 0, &lnames, &lids);
diff --git a/src/ptserver/ptutils.c b/src/ptserver/ptutils.c
index 1a343feaa7..c0b76fb29c 100644
--- a/src/ptserver/ptutils.c
+++ b/src/ptserver/ptutils.c
@@ -26,7 +26,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <rx/xdr.h>
 #include <afs/com_err.h>
diff --git a/src/ptserver/utils.c b/src/ptserver/utils.c
index abc37c12c0..0918cac93f 100644
--- a/src/ptserver/utils.c
+++ b/src/ptserver/utils.c
@@ -13,7 +13,7 @@
 #include <roken.h>
 
 #include <afs/opr.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 
 #include "ptserver.h"
diff --git a/src/rx/rx_atomic.h b/src/rx/rx_atomic.h
index 789f7bb8e9..b42db5136f 100644
--- a/src/rx/rx_atomic.h
+++ b/src/rx/rx_atomic.h
@@ -33,99 +33,117 @@ typedef struct {
 } rx_atomic_t;
 
 static_inline void
-rx_atomic_set(rx_atomic_t *atomic, int val) {
+rx_atomic_set(rx_atomic_t *atomic, int val)
+{
     atomic->var = val;
 }
 
 static_inline int
-rx_atomic_read(rx_atomic_t *atomic) {
+rx_atomic_read(rx_atomic_t *atomic)
+{
     return atomic->var;
 }
 
 static_inline void
-rx_atomic_inc(rx_atomic_t *atomic) {
+rx_atomic_inc(rx_atomic_t *atomic)
+{
     InterlockedIncrement(&atomic->var);
 }
 
 static_inline int
-rx_atomic_inc_and_read(rx_atomic_t *atomic) {
+rx_atomic_inc_and_read(rx_atomic_t *atomic)
+{
     return InterlockedIncrement(&atomic->var);
 }
 
 static_inline void
-rx_atomic_add(rx_atomic_t *atomic, int change) {
+rx_atomic_add(rx_atomic_t *atomic, int change)
+{
     InterlockedExchangeAdd(&atomic->var, change);
 }
 
 static_inline int
-rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
+rx_atomic_add_and_read(rx_atomic_t *atomic, int change)
+{
     return InterlockedExchangeAdd(&atomic->var, change) + change;
 }
 
 static_inline void
-rx_atomic_dec(rx_atomic_t *atomic) {
+rx_atomic_dec(rx_atomic_t *atomic)
+{
     InterlockedDecrement(&atomic->var);
 }
 
 static_inline int
-rx_atomic_dec_and_read(rx_atomic_t *atomic) {
+rx_atomic_dec_and_read(rx_atomic_t *atomic)
+{
     return InterlockedDecrement(&atomic->var);
 }
 
 static_inline void
-rx_atomic_sub(rx_atomic_t *atomic, int change) {
+rx_atomic_sub(rx_atomic_t *atomic, int change)
+{
     InterlockedExchangeAdd(&atomic->var, 0 - change);
 }
 
-#elif defined(AFS_AIX61_ENV) || defined(AFS_USR_AIX61_ENV)
-#include <sys/atomic_op.h>
+#elif defined(AFS_AIX41_ENV) || defined(AFS_USR_AIX41_ENV)
+# include <sys/atomic_op.h>
 
 typedef struct {
    volatile int var;
 } rx_atomic_t;
 
 static_inline void
-rx_atomic_set(rx_atomic_t *atomic, int val) {
+rx_atomic_set(rx_atomic_t *atomic, int val)
+{
     atomic->var = val;
 }
 
 static_inline int
-rx_atomic_read(rx_atomic_t *atomic) {
+rx_atomic_read(rx_atomic_t *atomic)
+{
     return atomic->var;
 }
 
 static_inline void
-rx_atomic_inc(rx_atomic_t *atomic) {
+rx_atomic_inc(rx_atomic_t *atomic)
+{
     fetch_and_add(&atomic->var, 1);
 }
 
 static_inline int
-rx_atomic_inc_and_read(rx_atomic_t *atomic) {
+rx_atomic_inc_and_read(rx_atomic_t *atomic)
+{
     return (fetch_and_add(&atomic->var, 1) + 1);
 }
 
 static_inline void
-rx_atomic_add(rx_atomic_t *atomic, int change) {
+rx_atomic_add(rx_atomic_t *atomic, int change)
+{
     fetch_and_add(&atomic->var, change);
 }
 
 static_inline int
-rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
+rx_atomic_add_and_read(rx_atomic_t *atomic, int change)
+{
     return (fetch_and_add(&atomic->var, change) + change);
 }
 
 static_inline void
-rx_atomic_dec(rx_atomic_t *atomic) {
+rx_atomic_dec(rx_atomic_t *atomic)
+{
     fetch_and_add(&atomic->var, -1);
 }
 
 static_inline int
-rx_atomic_dec_and_read(rx_atomic_t *atomic) {
+rx_atomic_dec_and_read(rx_atomic_t *atomic)
+{
     return (fetch_and_add(&atomic->var, -1) - 1);
 }
 
 static_inline void
-rx_atomic_sub(rx_atomic_t *atomic, int change) {
+rx_atomic_sub(rx_atomic_t *atomic, int change)
+{
     fetch_and_add(&atomic->var, -change);
 }
 
@@ -155,71 +173,79 @@ OSAtomicDecrement32(volatile int *value)
 {
     return OSDecrementAtomic(value) - 1;
 }
-
-# endif
+# endif /* KERNEL && !UKERNEL */
 
 typedef struct {
     volatile int var;
 } rx_atomic_t;
 
 static_inline void
-rx_atomic_set(rx_atomic_t *atomic, int val) {
+rx_atomic_set(rx_atomic_t *atomic, int val)
+{
     atomic->var = val;
 }
 
 static_inline int
-rx_atomic_read(rx_atomic_t *atomic) {
+rx_atomic_read(rx_atomic_t *atomic)
+{
     return atomic->var;
 }
 
 static_inline void
-rx_atomic_inc(rx_atomic_t *atomic) {
+rx_atomic_inc(rx_atomic_t *atomic)
+{
     OSAtomicIncrement32(&atomic->var);
 }
 
 static_inline int
-rx_atomic_inc_and_read(rx_atomic_t *atomic) {
+rx_atomic_inc_and_read(rx_atomic_t *atomic)
+{
     return OSAtomicIncrement32(&atomic->var);
 }
 
 static_inline void
-rx_atomic_add(rx_atomic_t *atomic, int change) {
+rx_atomic_add(rx_atomic_t *atomic, int change)
+{
     OSAtomicAdd32(change, &atomic->var);
 }
 
 static_inline int
-rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
+rx_atomic_add_and_read(rx_atomic_t *atomic, int change)
+{
     return OSAtomicAdd32(change, &atomic->var);
 }
 
 static_inline void
-rx_atomic_dec(rx_atomic_t *atomic) {
+rx_atomic_dec(rx_atomic_t *atomic)
+{
     OSAtomicDecrement32(&atomic->var);
 }
 
 static_inline int
-rx_atomic_dec_and_read(rx_atomic_t *atomic) {
+rx_atomic_dec_and_read(rx_atomic_t *atomic)
+{
     return OSAtomicDecrement32(&atomic->var);
 }
 
 static_inline void
-rx_atomic_sub(rx_atomic_t *atomic, int change) {
+rx_atomic_sub(rx_atomic_t *atomic, int change)
+{
     OSAtomicAdd32(0 - change, &atomic->var);
 }
 #elif defined(AFS_LINUX_ENV) && defined(KERNEL)
-#include <asm/atomic.h>
+# include <asm/atomic.h>
 
 typedef atomic_t rx_atomic_t;
 
-#define rx_atomic_set(X, V)	  atomic_set(X, V)
-#define rx_atomic_read(X)	  atomic_read(X)
-#define rx_atomic_inc(X)	  atomic_inc(X)
-#define rx_atomic_inc_and_read(X) atomic_inc_return(X)
-#define rx_atomic_add(X, V)	  atomic_add(V, X)
-#define rx_atomic_add_and_read(X, V) atomic_add_return(V, X)
-#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_set(X, V)	  atomic_set(X, V)
+# define rx_atomic_read(X)	  atomic_read(X)
+# define rx_atomic_inc(X)	  atomic_inc(X)
+# define rx_atomic_inc_and_read(X) atomic_inc_return(X)
+# define rx_atomic_add(X, V)	  atomic_add(V, X)
+# define rx_atomic_add_and_read(X, V) atomic_add_return(V, X)
+# 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)
 
 #elif defined(AFS_SUN510_ENV) || (defined(AFS_SUN5_ENV) && defined(KERNEL) && !defined(UKERNEL))
 
@@ -229,59 +255,68 @@ typedef atomic_t rx_atomic_t;
 #  include <atomic.h>
 # endif
 
-#ifndef AFS_SUN510_ENV
-# define atomic_inc_32(X)    atomic_add_32((X), 1)
-# define atomic_inc_32_nv(X) atomic_add_32_nv((X), 1)
-# define atomic_dec_32(X)    atomic_add_32((X), -1)
-# define atomic_dec_32_nv(X) atomic_add_32_nv((X), -1)
-#endif
+# ifndef AFS_SUN510_ENV
+#  define atomic_inc_32(X)    atomic_add_32((X), 1)
+#  define atomic_inc_32_nv(X) atomic_add_32_nv((X), 1)
+#  define atomic_dec_32(X)    atomic_add_32((X), -1)
+#  define atomic_dec_32_nv(X) atomic_add_32_nv((X), -1)
+# endif
 
 typedef struct {
     volatile unsigned int var;
 } rx_atomic_t;
 
 static_inline void
-rx_atomic_set(rx_atomic_t *atomic, int val) {
+rx_atomic_set(rx_atomic_t *atomic, int val)
+{
     atomic->var = val;
 }
 
 static_inline int
-rx_atomic_read(rx_atomic_t *atomic) {
+rx_atomic_read(rx_atomic_t *atomic)
+{
     return atomic->var;
 }
 
 static_inline void
-rx_atomic_inc(rx_atomic_t *atomic) {
+rx_atomic_inc(rx_atomic_t *atomic)
+{
     atomic_inc_32(&atomic->var);
 }
 
 static_inline int
-rx_atomic_inc_and_read(rx_atomic_t *atomic) {
+rx_atomic_inc_and_read(rx_atomic_t *atomic)
+{
     return atomic_inc_32_nv(&atomic->var);
 }
 
 static_inline void
-rx_atomic_add(rx_atomic_t *atomic, int change) {
+rx_atomic_add(rx_atomic_t *atomic, int change)
+{
     atomic_add_32(&atomic->var, change);
 }
 
 static_inline int
-rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
+rx_atomic_add_and_read(rx_atomic_t *atomic, int change)
+{
     return atomic_add_32_nv(&atomic->var, change);
 }
 
 static_inline void
-rx_atomic_dec(rx_atomic_t *atomic) {
+rx_atomic_dec(rx_atomic_t *atomic)
+{
     atomic_dec_32(&atomic->var);
 }
 
 static_inline int
-rx_atomic_dec_and_read(rx_atomic_t *atomic) {
+rx_atomic_dec_and_read(rx_atomic_t *atomic)
+{
     return atomic_dec_32_nv(&atomic->var);
 }
 
 static_inline void
-rx_atomic_sub(rx_atomic_t *atomic, int change) {
+rx_atomic_sub(rx_atomic_t *atomic, int change)
+{
     atomic_add_32(&atomic->var, 0 - change);
 }
 
@@ -292,74 +327,94 @@ typedef struct {
 } rx_atomic_t;
 
 static_inline void
-rx_atomic_set(rx_atomic_t *atomic, int val) {
+rx_atomic_set(rx_atomic_t *atomic, int val)
+{
     atomic->var = val;
 }
 
 static_inline int
-rx_atomic_read(rx_atomic_t *atomic) {
+rx_atomic_read(rx_atomic_t *atomic)
+{
     return atomic->var;
 }
 
 static_inline void
-rx_atomic_inc(rx_atomic_t *atomic) {
+rx_atomic_inc(rx_atomic_t *atomic)
+{
     (void)__sync_fetch_and_add(&atomic->var, 1);
 }
 
 static_inline int
-rx_atomic_inc_and_read(rx_atomic_t *atomic) {
+rx_atomic_inc_and_read(rx_atomic_t *atomic)
+{
     return __sync_add_and_fetch(&atomic->var, 1);
 }
 
 static_inline void
-rx_atomic_add(rx_atomic_t *atomic, int change) {
+rx_atomic_add(rx_atomic_t *atomic, int change)
+{
     (void)__sync_fetch_and_add(&atomic->var, change);
 }
 
 static_inline int
-rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
+rx_atomic_add_and_read(rx_atomic_t *atomic, int change)
+{
     return __sync_add_and_fetch(&atomic->var, change);
 }
 
 static_inline void
-rx_atomic_dec(rx_atomic_t *atomic) {
+rx_atomic_dec(rx_atomic_t *atomic)
+{
     (void)__sync_fetch_and_sub(&atomic->var, 1);
 }
 
 static_inline int
-rx_atomic_dec_and_read(rx_atomic_t *atomic) {
+rx_atomic_dec_and_read(rx_atomic_t *atomic)
+{
     return __sync_sub_and_fetch(&atomic->var, 1);
 }
 
 static_inline void
-rx_atomic_sub(rx_atomic_t *atomic, int change) {
+rx_atomic_sub(rx_atomic_t *atomic, int change)
+{
     (void)__sync_fetch_and_sub(&atomic->var, change);
 }
 
-#else
+#else /* AFS_NT40_ENV */
 
-/* If we're on a platform where we have no idea how to do atomics,
- * then we fall back to using a single process wide mutex to protect
- * all atomic variables. This won't be the quickest thing ever.
+/*
+ * If we're on a platform where we have no idea how to do atomics, then we fall
+ * back to using a single process wide mutex to protect all atomic variables.
+ * This won't be the quickest thing ever.
  */
 
-#ifdef RX_ENABLE_LOCKS
+# if defined(KERNEL)
+#  include "rx_kmutex.h"
+# elif defined(AFS_PTHREAD_ENV)
+#  include "rx_pthread.h"
+# else
+#  include "rx_lwp.h"
+# endif
+
+# ifdef RX_ENABLE_LOCKS
 extern afs_kmutex_t rx_atomic_mutex;
-#endif
+# endif
 
 typedef struct {
     int var;
 } rx_atomic_t;
 
 static_inline void
-rx_atomic_set(rx_atomic_t *atomic, int val) {
+rx_atomic_set(rx_atomic_t *atomic, int val)
+{
     MUTEX_ENTER(&rx_atomic_mutex);
     atomic->var = val;
     MUTEX_EXIT(&rx_atomic_mutex);
 }
 
 static_inline int
-rx_atomic_read(rx_atomic_t *atomic) {
+rx_atomic_read(rx_atomic_t *atomic)
+{
     int out;
 
     MUTEX_ENTER(&rx_atomic_mutex);
@@ -370,14 +425,16 @@ rx_atomic_read(rx_atomic_t *atomic) {
 }
 
 static_inline void
-rx_atomic_inc(rx_atomic_t *atomic) {
+rx_atomic_inc(rx_atomic_t *atomic)
+{
    MUTEX_ENTER(&rx_atomic_mutex);
    atomic->var++;
    MUTEX_EXIT(&rx_atomic_mutex);
 }
 
 static_inline int
-rx_atomic_inc_and_read(rx_atomic_t *atomic) {
+rx_atomic_inc_and_read(rx_atomic_t *atomic)
+{
     int retval;
     MUTEX_ENTER(&rx_atomic_mutex);
     atomic->var++;
@@ -387,14 +444,16 @@ rx_atomic_inc_and_read(rx_atomic_t *atomic) {
 }
 
 static_inline void
-rx_atomic_add(rx_atomic_t *atomic, int change) {
+rx_atomic_add(rx_atomic_t *atomic, int change)
+{
     MUTEX_ENTER(&rx_atomic_mutex);
     atomic->var += change;
     MUTEX_EXIT(&rx_atomic_mutex);
 }
 
 static_inline int
-rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
+rx_atomic_add_and_read(rx_atomic_t *atomic, int change)
+{
     int retval;
 
     MUTEX_ENTER(&rx_atomic_mutex);
@@ -406,14 +465,16 @@ rx_atomic_add_and_read(rx_atomic_t *atomic, int change) {
 }
 
 static_inline void
-rx_atomic_dec(rx_atomic_t *atomic) {
+rx_atomic_dec(rx_atomic_t *atomic)
+{
     MUTEX_ENTER(&rx_atomic_mutex);
     atomic->var--;
     MUTEX_EXIT(&rx_atomic_mutex);
 }
 
 static_inline int
-rx_atomic_dec_and_read(rx_atomic_t *atomic) {
+rx_atomic_dec_and_read(rx_atomic_t *atomic)
+{
     int retval;
     MUTEX_ENTER(&rx_atomic_mutex);
     atomic->var--;
@@ -424,12 +485,13 @@ rx_atomic_dec_and_read(rx_atomic_t *atomic) {
 
 
 static_inline void
-rx_atomic_sub(rx_atomic_t *atomic, int change) {
+rx_atomic_sub(rx_atomic_t *atomic, int change)
+{
     MUTEX_ENTER(&rx_atomic_mutex);
     atomic->var -= change;
     MUTEX_EXIT(&rx_atomic_mutex);
 }
 
-#endif
+#endif /* AFS_NT40_ENV */
 
-#endif
+#endif /* OPENAFS_RX_ATOMIC_H */
diff --git a/src/tbudb/Makefile.in b/src/tbudb/Makefile.in
index e5634d7998..f32c6e4bdd 100644
--- a/src/tbudb/Makefile.in
+++ b/src/tbudb/Makefile.in
@@ -16,7 +16,7 @@ RX=$(srcdir)/../rx
 BUDB=$(srcdir)/../budb
 
 INCLS=\
-	${TOP_INCDIR}/lock.h \
+	${TOP_INCDIR}/afs/afs_lock.h \
 	${TOP_INCDIR}/ubik.h \
 	${TOP_INCDIR}/lwp.h \
 	${TOP_INCDIR}/rx/rx.h \
diff --git a/src/tools/dumpscan/dumpscan.h b/src/tools/dumpscan/dumpscan.h
index 7fd53ee831..3e697f23e0 100644
--- a/src/tools/dumpscan/dumpscan.h
+++ b/src/tools/dumpscan/dumpscan.h
@@ -35,7 +35,7 @@
 #include "xfiles.h"
 
 #include <rx/rx_queue.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <afs/ihandle.h>
diff --git a/src/tools/dumpscan/dumptool.c b/src/tools/dumpscan/dumptool.c
index 95f75fa4c0..9dc8fd2e5a 100644
--- a/src/tools/dumpscan/dumptool.c
+++ b/src/tools/dumpscan/dumptool.c
@@ -78,7 +78,7 @@
 #include <sys/ioctl.h>
 
 #include <rx/rx_queue.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <afs/acl.h>
diff --git a/src/tptserver/Makefile.in b/src/tptserver/Makefile.in
index cbde711e2d..c28300cf62 100644
--- a/src/tptserver/Makefile.in
+++ b/src/tptserver/Makefile.in
@@ -15,7 +15,7 @@ ENABLE_PTHREADED_UBIK=@ENABLE_PTHREADED_UBIK@
 PTSERVER=$(srcdir)/../ptserver
 
 INCLS=${TOP_INCDIR}/ubik.h \
-	${TOP_INCDIR}/lock.h  \
+	${TOP_INCDIR}/afs/afs_lock.h  \
 	${TOP_INCDIR}/lwp.h \
 	${TOP_INCDIR}/rx/rx.h \
 	${TOP_INCDIR}/rx/xdr.h \
diff --git a/src/tsalvaged/salvsync-debug.c b/src/tsalvaged/salvsync-debug.c
index b26355b71e..811470e83b 100644
--- a/src/tsalvaged/salvsync-debug.c
+++ b/src/tsalvaged/salvsync-debug.c
@@ -40,7 +40,7 @@
 
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
 #include <afs/volume.h>
diff --git a/src/tubik/Makefile.in b/src/tubik/Makefile.in
index ac95399682..3a3030b6ae 100644
--- a/src/tubik/Makefile.in
+++ b/src/tubik/Makefile.in
@@ -14,9 +14,9 @@ ENABLE_PTHREADED_UBIK=@ENABLE_PTHREADED_UBIK@
 
 UBIK=$(srcdir)/../ubik
 
-INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/lock.h \
+INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/afs/afs_lock.h \
 	${TOP_INCDIR}/rx/rx.h ${TOP_INCDIR}/rx/xdr.h \
-	${TOP_INCDIR}/lock.h ubik.h ubik_int.h utst_int.h
+	${TOP_INCDIR}/afs/afs_lock.h ubik.h ubik_int.h utst_int.h
 
 LTLIBS=@TOP_OBJDIR@/src/util/liboafs_util.la \
        @TOP_OBJDIR@/src/ubik/liboafs_ubik.la \
diff --git a/src/tvlserver/Makefile.in b/src/tvlserver/Makefile.in
index d35fc676be..981d093e3c 100644
--- a/src/tvlserver/Makefile.in
+++ b/src/tvlserver/Makefile.in
@@ -16,7 +16,7 @@ VLSERVER=$(srcdir)/../vlserver
 
 INCLS=${TOP_INCDIR}/ubik.h \
              ${TOP_INCDIR}/lwp.h \
-             ${TOP_INCDIR}/lock.h  \
+             ${TOP_INCDIR}/afs/afs_lock.h  \
              ${TOP_INCDIR}/rx/rx.h \
              ${TOP_INCDIR}/rx/xdr.h \
              ${TOP_INCDIR}/afs/keys.h \
diff --git a/src/ubik/Makefile.in b/src/ubik/Makefile.in
index 4beac5067c..57a1b793ac 100644
--- a/src/ubik/Makefile.in
+++ b/src/ubik/Makefile.in
@@ -24,9 +24,9 @@ LT_deps =   $(top_builddir)/src/auth/liboafs_auth.la \
 	    $(top_builddir)/src/rx/liboafs_rx.la \
 	    $(top_builddir)/src/util/liboafs_util.la
 
-INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/lock.h \
+INCLS=${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/afs/afs_lock.h \
 	${TOP_INCDIR}/rx/rx.h ${TOP_INCDIR}/rx/xdr.h \
-	${TOP_INCDIR}/lock.h ubik.h ubik_int.h
+	${TOP_INCDIR}/afs/afs_lock.h ubik.h ubik_int.h
 
 LIBS=${TOP_LIBDIR}/librx.a ${TOP_LIBDIR}/libafshcrypto_lwp.a \
 	${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libauth.a \
diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c
index 94381233eb..f921d3f4f3 100644
--- a/src/ubik/beacon.c
+++ b/src/ubik/beacon.c
@@ -19,7 +19,7 @@
 # include <opr/lockstub.h>
 #endif
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/rx.h>
 #include <rx/rxkad.h>
 #include <rx/rx_multi.h>
diff --git a/src/ubik/lock.c b/src/ubik/lock.c
index c138375225..4798fa40f2 100644
--- a/src/ubik/lock.c
+++ b/src/ubik/lock.c
@@ -16,7 +16,7 @@
 #ifdef AFS_PTHREAD_ENV
 # include <opr/lock.h>
 #endif
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 
 #define UBIK_INTERNALS 1
diff --git a/src/ubik/phys.c b/src/ubik/phys.c
index b35ae4af27..1f372f1ac9 100644
--- a/src/ubik/phys.c
+++ b/src/ubik/phys.c
@@ -14,7 +14,7 @@
 
 #include <lwp.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 
 #define	UBIK_INTERNALS 1
diff --git a/src/ubik/remote.c b/src/ubik/remote.c
index b63a32325a..b36c66e110 100644
--- a/src/ubik/remote.c
+++ b/src/ubik/remote.c
@@ -21,7 +21,7 @@
 # include <opr/lockstub.h>
 #endif
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <afs/afsutil.h>
diff --git a/src/ubik/ubik.c b/src/ubik/ubik.c
index 4061d058cc..3e9b4630c0 100644
--- a/src/ubik/ubik.c
+++ b/src/ubik/ubik.c
@@ -20,7 +20,7 @@
 # include <opr/lockstub.h>
 #endif
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/rx.h>
 #include <afs/cellconfig.h>
 #include <afs/afsutil.h>
diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h
index 60032884bd..c681fa8be9 100644
--- a/src/ubik/ubik.p.h
+++ b/src/ubik/ubik.p.h
@@ -125,7 +125,7 @@ struct ubik_stat {
     afs_int32 size;
 };
 
-#include <lock.h>		/* just to make sure we've got this */
+#include <afs/afs_lock.h>		/* just to make sure we've got this */
 
 /*!
  * \brief representation of a ubik database.
diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c
index 31ed5f991d..db37d6a75b 100644
--- a/src/ubik/ubikclient.c
+++ b/src/ubik/ubikclient.c
@@ -20,7 +20,7 @@
 #include <afs/pthread_glock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/rxgen_consts.h>
 #define UBIK_LEGACY_CALLITER
 #include "ubik.h"
diff --git a/src/ubik/ubikcmd.c b/src/ubik/ubikcmd.c
index 7611fc2739..c90e961c9e 100644
--- a/src/ubik/ubikcmd.c
+++ b/src/ubik/ubikcmd.c
@@ -12,7 +12,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 
diff --git a/src/ubik/udebug.c b/src/ubik/udebug.c
index a36e4b29d6..bebf7562b5 100644
--- a/src/ubik/udebug.c
+++ b/src/ubik/udebug.c
@@ -12,7 +12,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <afs/cmd.h>
diff --git a/src/ubik/uinit.c b/src/ubik/uinit.c
index 3a1997d9ef..12a62b3c1e 100644
--- a/src/ubik/uinit.c
+++ b/src/ubik/uinit.c
@@ -18,7 +18,7 @@
 #endif
 
 #include <afs/dirpath.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
diff --git a/src/ubik/utst_client.c b/src/ubik/utst_client.c
index 1f1ff51219..ceec664397 100644
--- a/src/ubik/utst_client.c
+++ b/src/ubik/utst_client.c
@@ -15,7 +15,7 @@
 
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 
 #include "ubik.h"
 #include "utst_int.h"
diff --git a/src/ubik/utst_server.c b/src/ubik/utst_server.c
index 7a1ae4db2e..1d34f5449b 100644
--- a/src/ubik/utst_server.c
+++ b/src/ubik/utst_server.c
@@ -15,7 +15,7 @@
 
 #include <rx/xdr.h>
 #include <rx/rx.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 
 #include "ubik.h"
diff --git a/src/ubik/vote.c b/src/ubik/vote.c
index 1ae7456435..1ff058995f 100644
--- a/src/ubik/vote.c
+++ b/src/ubik/vote.c
@@ -18,7 +18,7 @@
 #else
 # include <opr/lockstub.h>
 #endif
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/rx.h>
 #include <afs/afsutil.h>
 
diff --git a/src/venus/cmdebug.c b/src/venus/cmdebug.c
index 9e335850f7..e1832015fa 100644
--- a/src/venus/cmdebug.c
+++ b/src/venus/cmdebug.c
@@ -19,7 +19,7 @@
 #include <afs/afscbint.h>
 #include <afs/cmd.h>
 #include <rx/rx.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afs_args.h>
 #include <afs/afsutil.h>
 #include <afs/com_err.h>
diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c
index 8a91a7308b..6d8cffdad6 100644
--- a/src/viced/afsfileprocs.c
+++ b/src/viced/afsfileprocs.c
@@ -5237,7 +5237,7 @@ SRXAFS_GetStatistics64(struct rx_call *acall, afs_int32 statsVersion, ViceStatis
 
     ViceLog(1, ("SAFS_GetStatistics64 Received\n"));
     Statistics->ViceStatistics64_val =
-	malloc(statsVersion*sizeof(afs_uint64));
+	calloc(statsVersion, sizeof(afs_uint64));
     Statistics->ViceStatistics64_len = statsVersion;
     FS_LOCK;
     AFSCallStats.GetStatistics++, AFSCallStats.TotalCalls++;
@@ -5945,12 +5945,14 @@ TryLocalVLServer(char *avolid, struct VolumeInfo *avolinfo)
     struct rx_securityClass *vlSec;
     afs_int32 code;
 
+    FS_LOCK;
     if (!vlConn) {
 	vlSec = rxnull_NewClientSecurityObject();
 	vlConn =
 	    rx_NewConnection(htonl(0x7f000001), htons(7003), 52, vlSec, 0);
 	rx_SetConnDeadTime(vlConn, 15);	/* don't wait long */
     }
+    FS_UNLOCK;
     if (down && (time(NULL) < lastDownTime + 180)) {
 	return 1;		/* failure */
     }
diff --git a/src/viced/host.c b/src/viced/host.c
index 62a1b2ac33..03e0fbbefb 100644
--- a/src/viced/host.c
+++ b/src/viced/host.c
@@ -1367,6 +1367,7 @@ reconcileHosts_r(afs_uint32 addr, afs_uint16 port, struct host *newHost,
 
     opr_Assert(oldHost != newHost);
     caps.Capabilities_val = NULL;
+    caps.Capabilities_len = 0;
 
     if (!sc) {
 	sc = rxnull_NewClientSecurityObject();
@@ -2434,9 +2435,17 @@ MapName_r(char *uname, afs_int32 * aval)
     namelist lnames;
     idlist lids;
     afs_int32 code;
+    prname namebuf;
+
+    memset(&namebuf, 0, sizeof(namebuf));
+
+    if (strlcpy(namebuf, uname, sizeof(namebuf)) >= sizeof(namebuf)) {
+	ViceLog(0, ("MapName: name %s is too long\n", uname));
+	return -1;
+    }
 
     lnames.namelist_len = 1;
-    lnames.namelist_val = (prname *) uname;
+    lnames.namelist_val = &namebuf;
     lids.idlist_len = 0;
     lids.idlist_val = NULL;
 
diff --git a/src/viced/physio.c b/src/viced/physio.c
index 4f0dfe2d62..2d6f8d1aa6 100644
--- a/src/viced/physio.c
+++ b/src/viced/physio.c
@@ -25,7 +25,7 @@
 #include <rx/rx_queue.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsint.h>
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
diff --git a/src/viced/state_analyzer.c b/src/viced/state_analyzer.c
index d5b8dbbaaf..7a9a07e5d5 100644
--- a/src/viced/state_analyzer.c
+++ b/src/viced/state_analyzer.c
@@ -25,7 +25,7 @@
 #include <rx/xdr.h>
 #include <afs/opr_assert.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/opr.h>
 #include <rx/rx.h>
 #include <rx/rx_queue.h>
diff --git a/src/vlserver/Makefile.in b/src/vlserver/Makefile.in
index 8a09bc50d5..1fa6d41e82 100644
--- a/src/vlserver/Makefile.in
+++ b/src/vlserver/Makefile.in
@@ -14,7 +14,7 @@ ENABLE_PTHREADED_UBIK = @ENABLE_PTHREADED_UBIK@
 
 INCLS=${TOP_INCDIR}/ubik.h \
              ${TOP_INCDIR}/lwp.h \
-             ${TOP_INCDIR}/lock.h  \
+             ${TOP_INCDIR}/afs/afs_lock.h  \
              ${TOP_INCDIR}/rx/rx.h \
              ${TOP_INCDIR}/rx/xdr.h \
              ${TOP_INCDIR}/afs/keys.h \
diff --git a/src/vlserver/vlclient.c b/src/vlserver/vlclient.c
index 8426e7f680..67f5ef3b41 100644
--- a/src/vlserver/vlclient.c
+++ b/src/vlserver/vlclient.c
@@ -29,7 +29,7 @@
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 #include <afs/cmd.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 
 #include "vlserver.h"
diff --git a/src/vlserver/vlprocs.c b/src/vlserver/vlprocs.c
index 89f8760a4f..5e24c27e51 100644
--- a/src/vlserver/vlprocs.c
+++ b/src/vlserver/vlprocs.c
@@ -12,7 +12,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <ubik.h>
 #include <rx/xdr.h>
diff --git a/src/vlserver/vlserver.c b/src/vlserver/vlserver.c
index 2685fd93a1..e883b756f4 100644
--- a/src/vlserver/vlserver.c
+++ b/src/vlserver/vlserver.c
@@ -36,7 +36,7 @@
 #include <afs/auth.h>
 #include <afs/audit.h>
 #include <afs/com_err.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <ubik.h>
 #include <afs/afsutil.h>
 
diff --git a/src/vlserver/vlutils.c b/src/vlserver/vlutils.c
index c47bcb78db..c994eb73d4 100644
--- a/src/vlserver/vlutils.c
+++ b/src/vlserver/vlutils.c
@@ -12,7 +12,7 @@
 
 #include <roken.h>
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/xdr.h>
 #include <ubik.h>
 
diff --git a/src/vol/Makefile.in b/src/vol/Makefile.in
index 320be75fc1..e7390cf1e6 100644
--- a/src/vol/Makefile.in
+++ b/src/vol/Makefile.in
@@ -173,7 +173,7 @@ dest: vlib.a salvager volinfo volscan fssync-debug
 #
 # Build targets
 #
-${OBJECTS}: ${PUBLICHEADERS} ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/lock.h ${TOP_INCDIR}/afs/afsint.h vutils.h salvage.h AFS_component_version_number.c
+${OBJECTS}: ${PUBLICHEADERS} ${TOP_INCDIR}/lwp.h ${TOP_INCDIR}/afs/afs_lock.h ${TOP_INCDIR}/afs/afsint.h vutils.h salvage.h AFS_component_version_number.c
 
 vol-salvage.o vutil.o: volinodes.h
 vol-salvage.o salvager.o: vol-salvage.h
diff --git a/src/vol/clone.c b/src/vol/clone.c
index deaa079c51..5874f8e085 100644
--- a/src/vol/clone.c
+++ b/src/vol/clone.c
@@ -32,7 +32,7 @@
 
 #include "nfs.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
diff --git a/src/vol/daemon_com.c b/src/vol/daemon_com.c
index 4256a20d0f..0d3292df38 100644
--- a/src/vol/daemon_com.c
+++ b/src/vol/daemon_com.c
@@ -32,7 +32,7 @@
 #include "nfs.h"
 #include "daemon_com.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/fssync-client.c b/src/vol/fssync-client.c
index 02559222e7..75edf2d56a 100644
--- a/src/vol/fssync-client.c
+++ b/src/vol/fssync-client.c
@@ -51,7 +51,7 @@
 #include "daemon_com.h"
 #include "fssync.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
diff --git a/src/vol/fssync-debug.c b/src/vol/fssync-debug.c
index 47562dff13..a853b08640 100644
--- a/src/vol/fssync-debug.c
+++ b/src/vol/fssync-debug.c
@@ -39,7 +39,7 @@
 #include <rx/rx_queue.h>
 
 #include "nfs.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c
index 720e6ef1c4..e545e780ce 100644
--- a/src/vol/fssync-server.c
+++ b/src/vol/fssync-server.c
@@ -59,7 +59,7 @@
 #include "fssync_inline.h"
 #include "salvsync.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c
index 3e8cac7486..71737767f9 100644
--- a/src/vol/listinodes.c
+++ b/src/vol/listinodes.c
@@ -90,7 +90,7 @@ ListViceInodes(char *devname, char *mountedOn, FD_t inodeFile,
 
 #include <rx/rx_queue.h>
 
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c
index 7488aa113f..2671d0e039 100644
--- a/src/vol/namei_ops.c
+++ b/src/vol/namei_ops.c
@@ -34,7 +34,7 @@
 #ifdef AFS_PTHREAD_ENV
 # include <opr/lock.h>
 #endif
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <lwp.h>
 #include "nfs.h"
diff --git a/src/vol/ntops.c b/src/vol/ntops.c
index 3cb0c5e723..433f475dcb 100644
--- a/src/vol/ntops.c
+++ b/src/vol/ntops.c
@@ -19,7 +19,7 @@
 #include <windows.h>
 #include <winnt.h>
 #include <winbase.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include <rx/rx_queue.h>
 #include "nfs.h"
diff --git a/src/vol/nuke.c b/src/vol/nuke.c
index 6b35db826d..e99a203587 100644
--- a/src/vol/nuke.c
+++ b/src/vol/nuke.c
@@ -20,7 +20,7 @@
 
 #include "nfs.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/partition.c b/src/vol/partition.c
index 8d37a07ac5..f624935f8c 100644
--- a/src/vol/partition.c
+++ b/src/vol/partition.c
@@ -99,7 +99,7 @@
 #include <rx/rx_queue.h>
 #include "nfs.h"
 #include <afs/errors.h>
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "lwp.h"
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
diff --git a/src/vol/partition.h b/src/vol/partition.h
index 5fcecb0eb3..d62f64f485 100644
--- a/src/vol/partition.h
+++ b/src/vol/partition.h
@@ -32,7 +32,7 @@
 #define	AFS_RDSKDEV	"/dev/r"
 #endif
 
-#include "lock.h"
+#include <afs/afs_lock.h>
 #ifdef AFS_DEMAND_ATTACH_FS
 # include <pthread.h>
 #endif
diff --git a/src/vol/purge.c b/src/vol/purge.c
index 16157b0de4..ee6e8ac63e 100644
--- a/src/vol/purge.c
+++ b/src/vol/purge.c
@@ -29,7 +29,7 @@
 #include "afs/afsint.h"
 #include "nfs.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #ifdef AFS_NT40_ENV
diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c
index c4df218b1b..c84ead1894 100644
--- a/src/vol/salvaged.c
+++ b/src/vol/salvaged.c
@@ -89,7 +89,7 @@
 
 #include "nfs.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/salvager.c b/src/vol/salvager.c
index 7e307e4ce9..26ac82af87 100644
--- a/src/vol/salvager.c
+++ b/src/vol/salvager.c
@@ -89,7 +89,7 @@
 
 #include "nfs.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/salvsync-client.c b/src/vol/salvsync-client.c
index 3e0b1398c1..cf57897fe7 100644
--- a/src/vol/salvsync-client.c
+++ b/src/vol/salvsync-client.c
@@ -26,7 +26,7 @@
 #include "nfs.h"
 #include <afs/errors.h>
 #include "salvsync.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/salvsync-server.c b/src/vol/salvsync-server.c
index dd32d8d493..a46d37ef9c 100644
--- a/src/vol/salvsync-server.c
+++ b/src/vol/salvsync-server.c
@@ -39,7 +39,7 @@
 #include "nfs.h"
 #include <afs/errors.h>
 #include "salvsync.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/vg_cache.c b/src/vol/vg_cache.c
index 5e8ca75fa7..508be4bd75 100644
--- a/src/vol/vg_cache.c
+++ b/src/vol/vg_cache.c
@@ -26,7 +26,7 @@
 #include <afs/opr.h>
 #include <rx/rx_queue.h>
 #include <opr/lock.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include "nfs.h"
 #include <afs/afsint.h>
diff --git a/src/vol/vg_scan.c b/src/vol/vg_scan.c
index 5fb0c698c3..0ae5177aa9 100644
--- a/src/vol/vg_scan.c
+++ b/src/vol/vg_scan.c
@@ -27,7 +27,7 @@
 #include <afs/opr.h>
 #include <rx/rx_queue.h>
 #include <opr/lock.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afsutil.h>
 #include "nfs.h"
 #include <afs/afsint.h>
diff --git a/src/vol/vnode.c b/src/vol/vnode.c
index dd50c5f38d..3eb800513a 100644
--- a/src/vol/vnode.c
+++ b/src/vol/vnode.c
@@ -35,7 +35,7 @@
 #include <afs/afsint.h>
 #include "nfs.h"
 #include <afs/errors.h>
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "lwp.h"
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
@@ -1127,7 +1127,7 @@ VnStore(Error * ec, Volume * vp, Vnode * vnp,
  */
 Vnode *
 VGetVnode(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
-{				/* READ_LOCK or WRITE_LOCK, as defined in lock.h */
+{				/* READ_LOCK or WRITE_LOCK, as defined in afs_lock.h */
     Vnode *retVal;
     VOL_LOCK;
     retVal = VGetVnode_r(ec, vp, vnodeNumber, locktype);
@@ -1152,7 +1152,7 @@ VGetVnode(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
  */
 Vnode *
 VGetVnode_r(Error * ec, Volume * vp, VnodeId vnodeNumber, int locktype)
-{				/* READ_LOCK or WRITE_LOCK, as defined in lock.h */
+{				/* READ_LOCK or WRITE_LOCK, as defined in afs_lock.h */
     Vnode *vnp;
     VnodeClass class;
     struct VnodeClassInfo *vcp;
diff --git a/src/vol/vol-bless.c b/src/vol/vol-bless.c
index 6a2e4af4d4..5683806e9b 100644
--- a/src/vol/vol-bless.c
+++ b/src/vol/vol-bless.c
@@ -18,7 +18,7 @@
 #include <rx/rx_queue.h>
 #include <afs/afsint.h>
 #include "nfs.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
diff --git a/src/vol/vol-info.c b/src/vol/vol-info.c
index 6423fa8e96..ffd476932d 100644
--- a/src/vol/vol-info.c
+++ b/src/vol/vol-info.c
@@ -34,7 +34,7 @@
 #include <rx/rx_queue.h>
 
 #include "nfs.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "ihandle.h"
 #include "vnode.h"
 #include "volume.h"
diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c
index 6a8a948a89..232530e9e9 100644
--- a/src/vol/vol-salvage.c
+++ b/src/vol/vol-salvage.c
@@ -157,7 +157,7 @@ Vnodes with 0 inode pointers in RW volumes are now deleted.
 
 #include "nfs.h"
 #include "lwp.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
 #include "vnode.h"
diff --git a/src/vol/volinfo-main.c b/src/vol/volinfo-main.c
index 4b2ae986f1..f91df70b0b 100644
--- a/src/vol/volinfo-main.c
+++ b/src/vol/volinfo-main.c
@@ -17,7 +17,7 @@
 #include <rx/rx_queue.h>
 #include "nfs.h"
 #include "ihandle.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "vnode.h"  /* for vSmall, vLarge */
 #include "vol-info.h"
 
diff --git a/src/vol/volscan-main.c b/src/vol/volscan-main.c
index 85ab03ddc2..0643f196ac 100644
--- a/src/vol/volscan-main.c
+++ b/src/vol/volscan-main.c
@@ -36,7 +36,7 @@
 #include <rx/rx_queue.h>
 #include "nfs.h"
 #include "ihandle.h"
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "vnode.h"  /* for vSmall, vLarge */
 #include "vol-info.h"
 
diff --git a/src/vol/volume.c b/src/vol/volume.c
index 9bbf9fedfe..7189fffecf 100644
--- a/src/vol/volume.c
+++ b/src/vol/volume.c
@@ -94,7 +94,7 @@
 
 #include "nfs.h"
 #include <afs/errors.h>
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "lwp.h"
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
diff --git a/src/vol/volume_inline.h b/src/vol/volume_inline.h
index 0d4a6a7e65..be62b84fa7 100644
--- a/src/vol/volume_inline.h
+++ b/src/vol/volume_inline.h
@@ -14,7 +14,7 @@
 #include "partition.h"
 
 #ifdef AFS_DEMAND_ATTACH_FS
-# include "lock.h"
+# include "afs/afs_lock.h"
 #endif
 
 #ifdef AFS_PTHREAD_ENV
diff --git a/src/vol/vutil.c b/src/vol/vutil.c
index d5b8d8d73d..2986d39f17 100644
--- a/src/vol/vutil.c
+++ b/src/vol/vutil.c
@@ -39,7 +39,7 @@
 #include <afs/afsint.h>
 #include "nfs.h"
 #include <afs/errors.h>
-#include "lock.h"
+#include <afs/afs_lock.h>
 #include "lwp.h"
 #include <afs/afssyscalls.h>
 #include "ihandle.h"
diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c
index 2db0d0db8a..d2737bdd08 100644
--- a/src/volser/dumpstuff.c
+++ b/src/volser/dumpstuff.c
@@ -20,7 +20,7 @@
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <afs/errors.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <lwp.h>
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
diff --git a/src/volser/restorevol.c b/src/volser/restorevol.c
index 376255875c..206e4fe564 100644
--- a/src/volser/restorevol.c
+++ b/src/volser/restorevol.c
@@ -47,7 +47,7 @@
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <rx/rx_queue.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
 #include <afs/volume.h>
diff --git a/src/volser/vol-dump.c b/src/volser/vol-dump.c
index 4b035b0253..fd1c567ca6 100644
--- a/src/volser/vol-dump.c
+++ b/src/volser/vol-dump.c
@@ -31,7 +31,7 @@
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <afs/errors.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <lwp.h>
 #include <afs/afssyscalls.h>
 #include <afs/ihandle.h>
diff --git a/src/volser/vol_split.c b/src/volser/vol_split.c
index fa42a7ca23..82cf23cbc8 100644
--- a/src/volser/vol_split.c
+++ b/src/volser/vol_split.c
@@ -21,7 +21,7 @@
 #include <afs/afsint.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
diff --git a/src/volser/volmain.c b/src/volser/volmain.c
index 9ffc62996b..900ad1d8ba 100644
--- a/src/volser/volmain.c
+++ b/src/volser/volmain.c
@@ -28,7 +28,7 @@
 #include <afs/prs_fs.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/afssyscalls.h>
 #include <afs/ihandle.h>
 #ifdef AFS_NT40_ENV
diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c
index 710d4befa6..b42e031f1b 100644
--- a/src/volser/volprocs.c
+++ b/src/volser/volprocs.c
@@ -26,7 +26,7 @@
 #include <afs/prs_fs.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 #include <ubik.h>
diff --git a/src/volser/voltrans.c b/src/volser/voltrans.c
index 7a7af3e3dd..817ca06723 100644
--- a/src/volser/voltrans.c
+++ b/src/volser/voltrans.c
@@ -33,7 +33,7 @@
 #include <afs/prs_fs.h>
 #include <afs/nfs.h>
 #include <lwp.h>
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 #include <rx/rx.h>
diff --git a/src/volser/vos.c b/src/volser/vos.c
index 6efc1c73fd..3201ec53cc 100644
--- a/src/volser/vos.c
+++ b/src/volser/vos.c
@@ -24,7 +24,7 @@
 #include <sys/statfs.h>
 #endif
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/stds.h>
 #include <rx/rx_queue.h>
 #include <rx/xdr.h>
diff --git a/src/volser/vsprocs.c b/src/volser/vsprocs.c
index e20749fb81..9c36a46d3c 100644
--- a/src/volser/vsprocs.c
+++ b/src/volser/vsprocs.c
@@ -17,7 +17,7 @@
 #include <sys/statfs.h>
 #endif
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <afs/voldefs.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
diff --git a/src/volser/vsutils.c b/src/volser/vsutils.c
index fca2283e7a..ed35179807 100644
--- a/src/volser/vsutils.c
+++ b/src/volser/vsutils.c
@@ -18,7 +18,7 @@
 #include <sys/statfs.h>
 #endif
 
-#include <lock.h>
+#include <afs/afs_lock.h>
 #include <rx/xdr.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
