Do not leak information on partial success in RXAFS_InlineBulkStatus
[openafs.git] / src / viced / afsfileprocs.c
index 3e33d4c..ec9eea6 100644 (file)
@@ -28,8 +28,6 @@
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -42,18 +40,12 @@ RCSID
 #else
 #include <sys/param.h>
 #include <sys/file.h>
-#include <netinet/in.h>
-#include <netdb.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-
-#ifdef HAVE_STRING_H
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <netdb.h>
 #include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
 
 #ifndef AFS_LINUX20_ENV
 #include <net/if.h>
@@ -79,9 +71,10 @@ RCSID
 #include <afs/ihandle.h>
 #include <afs/vnode.h>
 #include <afs/volume.h>
-#include <afs/acl.h>
 #include <afs/ptclient.h>
+#include <afs/ptuser.h>
 #include <afs/prs_fs.h>
+#include <afs/acl.h>
 #include <rx/rx.h>
 #include <rx/rx_globals.h>
 #include <sys/stat.h>
@@ -104,20 +97,35 @@ RCSID
 #include <afs/cellconfig.h>
 #include <afs/keys.h>
 
-#include <afs/auth.h>
 #include <signal.h>
 #include <afs/partition.h>
 #include "viced_prototypes.h"
 #include "viced.h"
 #include "host.h"
+#include "callback.h"
 #include <afs/unified_afs.h>
 #include <afs/audit.h>
 #include <afs/afsutil.h>
+#include <afs/dir.h>
+
+extern void SetDirHandle(register DirHandle * dir, register Vnode * vnode);
+extern void FidZap(DirHandle * file);
+extern void FidZero(DirHandle * file);
 
 #ifdef AFS_PTHREAD_ENV
 pthread_mutex_t fileproc_glock_mutex;
 #endif /* AFS_PTHREAD_ENV */
 
+#ifdef O_LARGEFILE
+#define afs_stat       stat64
+#define afs_fstat      fstat64
+#define afs_open       open64
+#else /* !O_LARGEFILE */
+#define afs_stat       stat
+#define afs_fstat      fstat
+#define afs_open       open
+#endif /* !O_LARGEFILE */
+
 
 /* Useful local defines used by this module */
 
@@ -179,8 +187,6 @@ struct afs_FSStats {
 
 struct afs_FSStats afs_fsstats;
 
-void ResetDebug(), SetDebug(), Terminate();
-
 int LogLevel = 0;
 int supported = 1;
 int Console = 0;
@@ -188,32 +194,34 @@ afs_int32 BlocksSpare = 1024;     /* allow 1 MB overruns */
 afs_int32 PctSpare;
 extern afs_int32 implicitAdminRights;
 extern afs_int32 readonlyServer;
+extern int CopyOnWrite_calls, CopyOnWrite_off0, CopyOnWrite_size0;
+extern afs_fsize_t CopyOnWrite_maxsize;
 
 /*
  * Externals used by the xstat code.
  */
-extern int VolumeCacheSize, VolumeGets, VolumeReplacements;
+extern VolPkgStats VStats;
 extern int CEs, CEBlocks;
 
 extern int HTs, HTBlocks;
 
 afs_int32 FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
-                           register struct rx_call *Call, afs_int32 Pos,
-                           afs_int32 Len, afs_int32 Int64Mode,
+                           register struct rx_call *Call, afs_sfsize_t Pos,
+                           afs_sfsize_t Len, afs_int32 Int64Mode,
 #if FS_STATS_DETAILED
-                           afs_int32 * a_bytesToFetchP,
-                           afs_int32 * a_bytesFetchedP
+                           afs_sfsize_t * a_bytesToFetchP,
+                           afs_sfsize_t * a_bytesFetchedP
 #endif                         /* FS_STATS_DETAILED */
     );
 
 afs_int32 StoreData_RXStyle(Volume * volptr, Vnode * targetptr,
                            struct AFSFid *Fid, struct client *client,
-                           register struct rx_call *Call, afs_uint32 Pos,
-                           afs_uint32 Length, afs_uint32 FileLength,
+                           register struct rx_call *Call, afs_fsize_t Pos,
+                           afs_fsize_t Length, afs_fsize_t FileLength,
                            int sync,
 #if FS_STATS_DETAILED
-                           afs_int32 * a_bytesToStoreP,
-                           afs_int32 * a_bytesStoredP
+                           afs_sfsize_t * a_bytesToStoreP,
+                           afs_sfsize_t * a_bytesStoredP
 #endif                         /* FS_STATS_DETAILED */
     );
 
@@ -236,16 +244,20 @@ SpareComp(Volume * avolp)
 {
     register afs_int32 temp;
 
-    FS_LOCK if (PctSpare) {
+    FS_LOCK;
+    if (PctSpare) {
        temp = V_maxquota(avolp);
        if (temp == 0) {
            /* no matter; doesn't check in this case */
-           FS_UNLOCK return 0;
+           FS_UNLOCK;
+           return 0;
        }
        temp = (temp * PctSpare) / 100;
-       FS_UNLOCK return temp;
+       FS_UNLOCK;
+       return temp;
     } else {
-       FS_UNLOCK return BlocksSpare;
+       FS_UNLOCK;
+       return BlocksSpare;
     }
 
 }                              /*SpareComp */
@@ -257,9 +269,9 @@ SpareComp(Volume * avolp)
 static void
 SetVolumeSync(register struct AFSVolSync *async, register Volume * avol)
 {
-    FS_LOCK
-       /* date volume instance was created */
-       if (async) {
+    FS_LOCK;
+    /* date volume instance was created */
+    if (async) {
        if (avol)
            async->spare1 = avol->header->diskstuff.creationDate;
        else
@@ -270,7 +282,8 @@ SetVolumeSync(register struct AFSVolSync *async, register Volume * avol)
        async->spare5 = 0;
        async->spare6 = 0;
     }
-FS_UNLOCK}                     /*SetVolumeSync */
+    FS_UNLOCK;
+}                              /*SetVolumeSync */
 
 /*
  * Note that this function always returns a held host, so
@@ -279,61 +292,94 @@ FS_UNLOCK}                        /*SetVolumeSync */
  */
 static int
 CallPreamble(register struct rx_call *acall, int activecall,
-            struct rx_connection **tconn)
+            struct rx_connection **tconn, struct host **ahostp)
 {
     struct host *thost;
     struct client *tclient;
     int retry_flag = 1;
     int code = 0;
-    char hoststr[16];
+    char hoststr[16], hoststr2[16];
+#ifdef AFS_PTHREAD_ENV
+    struct ubik_client *uclient;
+#endif
+    *ahostp = NULL;
+
     if (!tconn) {
        ViceLog(0, ("CallPreamble: unexpected null tconn!\n"));
        return -1;
     }
     *tconn = rx_ConnectionOf(acall);
 
-    H_LOCK retry:tclient = h_FindClient_r(*tconn);
+    H_LOCK;
+  retry:
+    tclient = h_FindClient_r(*tconn);
+    if (!tclient) {
+       ViceLog(0, ("CallPreamble: Couldn't get CPS. Too many lockers\n"));
+       H_UNLOCK;
+       return VBUSY;
+    }
+    thost = tclient->host;
     if (tclient->prfail == 1) {        /* couldn't get the CPS */
        if (!retry_flag) {
            h_ReleaseClient_r(tclient);
+           h_Release_r(thost);
            ViceLog(0, ("CallPreamble: Couldn't get CPS. Fail\n"));
-           H_UNLOCK return -1001;
+           H_UNLOCK;
+           return -1001;
        }
        retry_flag = 0;         /* Retry once */
 
        /* Take down the old connection and re-read the key file */
        ViceLog(0,
                ("CallPreamble: Couldn't get CPS. Reconnect to ptserver\n"));
-       H_UNLOCK code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
-       H_LOCK if (code) {
+#ifdef AFS_PTHREAD_ENV
+       uclient = (struct ubik_client *)pthread_getspecific(viced_uclient_key);
+
+       /* Is it still necessary to drop this? We hit the net, we should... */
+       H_UNLOCK;
+       if (uclient) {
+           hpr_End(uclient);
+           uclient = NULL;
+       }
+       code = hpr_Initialize(&uclient);
+
+       if (!code)
+           assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0);
+       H_LOCK;
+#else
+       code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0);
+#endif
+       if (code) {
            h_ReleaseClient_r(tclient);
-           H_UNLOCK ViceLog(0,
-                            ("CallPreamble: couldn't reconnect to ptserver\n"));
+           h_Release_r(thost);
+           H_UNLOCK;
+           ViceLog(0, ("CallPreamble: couldn't reconnect to ptserver\n"));
            return -1001;
        }
 
        tclient->prfail = 2;    /* Means re-eval client's cps */
        h_ReleaseClient_r(tclient);
+       h_Release_r(thost);
        goto retry;
     }
 
-    thost = tclient->host;
     tclient->LastCall = thost->LastCall = FT_ApproxTime();
-    if (activecall)            /* For all but "GetTime" calls */
+    if (activecall)            /* For all but "GetTime", "GetStats", and "GetCaps" calls */
        thost->ActiveCall = thost->LastCall;
 
     h_Lock_r(thost);
     if (thost->hostFlags & HOSTDELETED) {
        ViceLog(3,
-               ("Discarded a packet for deleted host %s\n",
-                afs_inet_ntoa_r(thost->host, hoststr)));
+               ("Discarded a packet for deleted host %s:%d\n",
+                afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port)));
        code = VBUSY;           /* raced, so retry */
     } else if ((thost->hostFlags & VENUSDOWN)
               || (thost->hostFlags & HFE_LATER)) {
        if (BreakDelayedCallBacks_r(thost)) {
            ViceLog(0,
-                   ("BreakDelayedCallbacks FAILED for host %s which IS UP.  Possible network or routing failure.\n",
-                    afs_inet_ntoa_r(thost->host, hoststr)));
+                   ("BreakDelayedCallbacks FAILED for host %s:%d which IS UP.  Connection from %s:%d.  Possible network or routing failure.\n",
+                    afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2), 
+                    ntohs(rxr_PortOf(*tconn))));
            if (MultiProbeAlternateAddress_r(thost)) {
                ViceLog(0,
                        ("MultiProbe failed to find new address for host %s:%d\n",
@@ -347,8 +393,9 @@ CallPreamble(register struct rx_call *acall, int activecall,
                         ntohs(thost->port)));
                if (BreakDelayedCallBacks_r(thost)) {
                    ViceLog(0,
-                           ("BreakDelayedCallbacks FAILED AGAIN for host %s which IS UP.  Possible network or routing failure.\n",
-                            afs_inet_ntoa_r(thost->host, hoststr)));
+                           ("BreakDelayedCallbacks FAILED AGAIN for host %s:%d which IS UP.  Connection from %s:%d.  Possible network or routing failure.\n",
+                             afs_inet_ntoa_r(thost->host, hoststr), ntohs(thost->port), afs_inet_ntoa_r(rxr_HostOf(*tconn), hoststr2), 
+                             ntohs(rxr_PortOf(*tconn))));
                    code = -1;
                }
            }
@@ -359,25 +406,60 @@ CallPreamble(register struct rx_call *acall, int activecall,
 
     h_ReleaseClient_r(tclient);
     h_Unlock_r(thost);
-    H_UNLOCK return code;
+    H_UNLOCK;
+    *ahostp = thost;
+    return code;
 
 }                              /*CallPreamble */
 
 
 static afs_int32
-CallPostamble(register struct rx_connection *aconn, afs_int32 ret)
+CallPostamble(register struct rx_connection *aconn, afs_int32 ret,
+             struct host *ahost)
 {
     struct host *thost;
     struct client *tclient;
     int translate = 0;
 
-    H_LOCK tclient = h_FindClient_r(aconn);
+    H_LOCK;
+    tclient = h_FindClient_r(aconn);
+    if (!tclient) 
+       goto busyout;
     thost = tclient->host;
     if (thost->hostFlags & HERRORTRANS)
        translate = 1;
     h_ReleaseClient_r(tclient);
+
+    if (ahost) {
+           if (ahost != thost) {
+                   /* host/client recycle */
+                   char hoststr[16], hoststr2[16];
+                   ViceLog(0, ("CallPostamble: ahost %s:%d (%p) != thost "
+                               "%s:%d (%p)\n",
+                               afs_inet_ntoa_r(ahost->host, hoststr),
+                               ntohs(ahost->port),
+                               ahost,
+                               afs_inet_ntoa_r(thost->host, hoststr2),
+                               ntohs(thost->port),
+                               thost));
+           }
+           /* return the reference taken in CallPreamble */
+           h_Release_r(ahost);
+    } else {
+           char hoststr[16];
+           ViceLog(0, ("CallPostamble: null ahost for thost %s:%d (%p)\n",
+                       afs_inet_ntoa_r(thost->host, hoststr),
+                       ntohs(thost->port),
+                       thost));
+    }
+
+    /* return the reference taken in local h_FindClient_r--h_ReleaseClient_r
+     * does not decrement refcount on client->host */
     h_Release_r(thost);
-    H_UNLOCK return (translate ? sys_error_to_et(ret) : ret);
+
+ busyout:
+    H_UNLOCK;
+    return (translate ? sys_error_to_et(ret) : ret);
 }                              /*CallPostamble */
 
 /*
@@ -388,8 +470,8 @@ CallPostamble(register struct rx_connection *aconn, afs_int32 ret)
 static afs_int32
 CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
 {
-    int fileCode = 0;
-    int errorCode = -1;
+    Error fileCode = 0;
+    Error local_errorCode, errorCode = -1;
     static struct timeval restartedat = { 0, 0 };
 
     if (fid->Volume == 0 || fid->Vnode == 0)   /* not: || fid->Unique == 0) */
@@ -398,8 +480,16 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
        extern int VInit;
 
        while (1) {
+           int restarting = 
+#ifdef AFS_DEMAND_ATTACH_FS
+               VSALVAGE
+#else
+               VRESTARTING
+#endif
+               ;
+
            errorCode = 0;
-           *volptr = VGetVolume(&errorCode, (afs_int32) fid->Volume);
+           *volptr = VGetVolume(&local_errorCode, &errorCode, (afs_int32) fid->Volume);
            if (!errorCode) {
                assert(*volptr);
                break;
@@ -454,20 +544,40 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock)
                if (restartedat.tv_sec == 0) {
                    /* I'm not really worried about when we restarted, I'm   */
                    /* just worried about when the first VBUSY was returned. */
-                   TM_GetTimeOfDay(&restartedat, 0);
-                   return (busyonrst ? VBUSY : VRESTARTING);
+                   FT_GetTimeOfDay(&restartedat, 0);
+                   if (busyonrst) {
+                       FS_LOCK;
+                       afs_perfstats.fs_nBusies++;
+                       FS_UNLOCK;
+                   }
+                   return (busyonrst ? VBUSY : restarting);
                } else {
                    struct timeval now;
-                   TM_GetTimeOfDay(&now, 0);
+                   FT_GetTimeOfDay(&now, 0);
                    if ((now.tv_sec - restartedat.tv_sec) < (11 * 60)) {
-                       return (busyonrst ? VBUSY : VRESTARTING);
+                       if (busyonrst) {
+                           FS_LOCK;
+                           afs_perfstats.fs_nBusies++;
+                           FS_UNLOCK;
+                       }
+                       return (busyonrst ? VBUSY : restarting);
                    } else {
-                       return (VRESTARTING);
+                       return (restarting);
                    }
                }
            }
-           /* allow read operations on busy volume */
-           else if (errorCode == VBUSY && lock == READ_LOCK) {
+           /* allow read operations on busy volume. 
+            * must check local_errorCode because demand attach fs
+            * can have local_errorCode == VSALVAGING, errorCode == VBUSY */
+           else if (local_errorCode == VBUSY && lock == READ_LOCK) {
+#ifdef AFS_DEMAND_ATTACH_FS
+               /* DAFS case is complicated by the fact that local_errorCode can
+                * be VBUSY in cases where the volume is truly offline */
+               if (!*volptr) {
+                   /* volume is in VOL_STATE_UNATTACHED */
+                   return (errorCode);
+               }
+#endif /* AFS_DEMAND_ATTACH_FS */
                errorCode = 0;
                break;
            } else if (errorCode)
@@ -509,7 +619,7 @@ SetAccessList(Vnode ** targetptr, Volume ** volume,
        assert(Fid != 0);
        while (1) {
            VnodeId parentvnode;
-           int errorCode = 0;
+           Error errorCode = 0;
 
            parentvnode = (*targetptr)->disk.parent;
            VPutVnode(&errorCode, *targetptr);
@@ -535,6 +645,33 @@ SetAccessList(Vnode ** targetptr, Volume ** volume,
 
 }                              /*SetAccessList */
 
+/* Must not be called with H_LOCK held */
+static void
+client_CheckRights(struct client *client, struct acl_accessList *ACL, 
+                  afs_int32 *rights)
+{
+    *rights = 0;
+    ObtainReadLock(&client->lock);
+    if (client->CPS.prlist_len > 0 && !client->deleted &&
+       client->host && !(client->host->hostFlags & HOSTDELETED))
+       acl_CheckRights(ACL, &client->CPS, rights);
+    ReleaseReadLock(&client->lock);
+}
+
+/* Must not be called with H_LOCK held */
+static afs_int32
+client_HasAsMember(struct client *client, afs_int32 id)
+{
+    afs_int32 code = 0;
+
+    ObtainReadLock(&client->lock);
+    if (client->CPS.prlist_len > 0 && !client->deleted && 
+       client->host && !(client->host->hostFlags & HOSTDELETED))
+       code = acl_IsAMember(id, &client->CPS);
+    ReleaseReadLock(&client->lock);
+    return code;
+}
+
 /*
  * Compare the directory's ACL with the user's access rights in the client
  * connection and return the user's and everybody else's access permissions
@@ -546,18 +683,21 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 {
     extern prlist SystemAnyUserCPS;
     afs_int32 hrights = 0;
+#ifndef AFS_PTHREAD_ENV
     int code;
+#endif
 
     if (acl_CheckRights(ACL, &SystemAnyUserCPS, anyrights) != 0) {
-
        ViceLog(0, ("CheckRights failed\n"));
        *anyrights = 0;
     }
     *rights = 0;
-    acl_CheckRights(ACL, &client->CPS, rights);
+
+    client_CheckRights(client, ACL, rights);
 
     /* wait if somebody else is already doing the getCPS call */
-    H_LOCK while (client->host->hostFlags & HCPS_INPROGRESS) {
+    H_LOCK;
+    while (client->host->hostFlags & HCPS_INPROGRESS) {
        client->host->hostFlags |= HCPS_WAITING;        /* I am waiting */
 #ifdef AFS_PTHREAD_ENV
        pthread_cond_wait(&client->host->cond, &host_glock_mutex);
@@ -568,16 +708,20 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 #endif /* AFS_PTHREAD_ENV */
     }
 
-    if (client->host->hcps.prlist_len && !client->host->hcps.prlist_val) {
-       ViceLog(0,
-               ("CheckRights: len=%d, for host=0x%x\n",
-                client->host->hcps.prlist_len, client->host->host));
+    if (!client->host->hcps.prlist_len || !client->host->hcps.prlist_val) {
+       char hoststr[16];
+       ViceLog(5,
+               ("CheckRights: len=%u, for host=%s:%d\n",
+                client->host->hcps.prlist_len, 
+                afs_inet_ntoa_r(client->host->host, hoststr),
+                ntohs(client->host->port)));
     } else
        acl_CheckRights(ACL, &client->host->hcps, &hrights);
-    H_UNLOCK
-       /* Allow system:admin the rights given with the -implicit option */
-       if (acl_IsAMember(SystemId, &client->CPS))
+    H_UNLOCK;
+    /* Allow system:admin the rights given with the -implicit option */
+    if (client_HasAsMember(client, SystemId))
        *rights |= implicitAdminRights;
+
     *rights |= hrights;
     *anyrights |= hrights;
 
@@ -592,7 +736,7 @@ GetRights(struct client *client, struct acl_accessList *ACL,
 static afs_int32
 VanillaUser(struct client *client)
 {
-    if (acl_IsAMember(SystemId, &client->CPS))
+    if (client_HasAsMember(client, SystemId))
        return (0);             /* not a system administrator, then you're "vanilla" */
     return (1);
 
@@ -612,7 +756,7 @@ GetVolumePackage(struct rx_connection *tcon, AFSFid * Fid, Volume ** volptr,
 {
     struct acl_accessList *aCL;        /* Internal access List */
     int aCLSize;               /* size of the access list */
-    int errorCode = 0;         /* return code to caller */
+    Error errorCode = 0;               /* return code to caller */
 
     if ((errorCode = CheckVnode(Fid, volptr, targetptr, locktype)))
        return (errorCode);
@@ -631,11 +775,13 @@ GetVolumePackage(struct rx_connection *tcon, AFSFid * Fid, Volume ** volptr,
        return (errorCode);
     if (chkforDir == MustBeDIR)
        assert((*parent) == 0);
-    if ((errorCode = GetClient(tcon, client)) != 0)
-       return (errorCode);
-    if (!(*client))
-       return (EINVAL);
-    assert(GetRights(*client, aCL, rights, anyrights) == 0);
+    if (!(*client)) {
+       if ((errorCode = GetClient(tcon, client)) != 0)
+           return (errorCode);
+       if (!(*client))
+           return (EINVAL);
+    }
+    GetRights(*client, aCL, rights, anyrights);
     /* ok, if this is not a dir, set the PRSFS_ADMINISTER bit iff we're the owner */
     if ((*targetptr)->disk.type != vDirectory) {
        /* anyuser can't be owner, so only have to worry about rights, not anyrights */
@@ -660,9 +806,9 @@ GetVolumePackage(struct rx_connection *tcon, AFSFid * Fid, Volume ** volptr,
  */
 static void
 PutVolumePackage(Vnode * parentwhentargetnotdir, Vnode * targetptr,
-                Vnode * parentptr, Volume * volptr)
+                Vnode * parentptr, Volume * volptr, struct client **client)
 {
-    int fileCode = 0;          /* Error code returned by the volume package */
+    Error fileCode = 0;                /* Error code returned by the volume package */
 
     if (parentwhentargetnotdir) {
        VPutVnode(&fileCode, parentwhentargetnotdir);
@@ -679,6 +825,9 @@ PutVolumePackage(Vnode * parentwhentargetnotdir, Vnode * targetptr,
     if (volptr) {
        VPutVolume(volptr);
     }
+    if (*client) {
+       PutClient(client);
+    }
 }                              /*PutVolumePackage */
 
 static int
@@ -693,7 +842,7 @@ VolumeOwner(register struct client *client, register Vnode * targetptr)
         * We don't have to check for host's cps since only regular
         * viceid are volume owners.
         */
-       return (acl_IsAMember(owner, &client->CPS));
+       return (client_HasAsMember(client, owner));
     }
 
 }                              /*VolumeOwner */
@@ -721,7 +870,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                       afs_int32 rights, int CallingRoutine,
                       AFSStoreStatus * InStatus)
 {
-    int errorCode = 0;
+    Error errorCode = 0;
 #define OWNSp(client, target) ((client)->ViceId == (target)->disk.owner)
 #define CHOWN(i,t) (((i)->Mask & AFS_SETOWNER) &&((i)->Owner != (t)->disk.owner))
 #define CHGRP(i,t) (((i)->Mask & AFS_SETGROUP) &&((i)->Group != (t)->disk.group))
@@ -747,7 +896,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                && targetptr->disk.type == vFile)
 #ifdef USE_GROUP_PERMS
                if (!OWNSp(client, targetptr)
-                   && !acl_IsAMember(targetptr->disk.owner, &client->CPS)) {
+                   && !client_HasAsMember(client, targetptr->disk.owner)) {
                    errorCode =
                        (((GROUPREAD | GROUPEXEC) & targetptr->disk.modeBits)
                         ? 0 : EACCES);
@@ -770,7 +919,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
 #endif
        } else {                /*  !VanillaUser(client) && !FetchData */
 
-           osi_audit(PrivilegeEvent, 0, AUD_INT,
+           osi_audit(PrivilegeEvent, 0, AUD_ID,
                      (client ? client->ViceId : 0), AUD_INT, CallingRoutine,
                      AUD_END);
        }
@@ -788,13 +937,13 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                else if (VanillaUser(client))
                    return (EPERM);     /* Was EACCES */
                else
-                   osi_audit(PrivilegeEvent, 0, AUD_INT,
+                   osi_audit(PrivilegeEvent, 0, AUD_ID,
                              (client ? client->ViceId : 0), AUD_INT,
                              CallingRoutine, AUD_END);
            }
        } else {
            if (CallingRoutine != CHK_STOREDATA && !VanillaUser(client)) {
-               osi_audit(PrivilegeEvent, 0, AUD_INT,
+               osi_audit(PrivilegeEvent, 0, AUD_ID,
                          (client ? client->ViceId : 0), AUD_INT,
                          CallingRoutine, AUD_END);
            } else {
@@ -814,7 +963,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                        else if (VanillaUser(client))
                            return (EPERM);     /* Was EACCES */
                        else
-                           osi_audit(PrivilegeEvent, 0, AUD_INT,
+                           osi_audit(PrivilegeEvent, 0, AUD_ID,
                                      (client ? client->ViceId : 0), AUD_INT,
                                      CallingRoutine, AUD_END);
                    }
@@ -830,7 +979,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                        if (VanillaUser(client))
                            return (EACCES);
                        else
-                           osi_audit(PrivSetID, 0, AUD_INT,
+                           osi_audit(PrivSetID, 0, AUD_ID,
                                      (client ? client->ViceId : 0), AUD_INT,
                                      CallingRoutine, AUD_END);
                    }
@@ -851,8 +1000,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                        if ((targetptr->disk.type == vFile)
                            && VanillaUser(client)) {
                            if (!OWNSp(client, targetptr)
-                               && !acl_IsAMember(targetptr->disk.owner,
-                                                 &client->CPS)) {
+                               && !client_HasAsMember(client, targetptr->disk.owner)) {
                                errorCode =
                                    ((GROUPWRITE & targetptr->disk.modeBits)
                                     ? 0 : EACCES);
@@ -870,7 +1018,7 @@ Check_PermissionRights(Vnode * targetptr, struct client *client,
                            if (VanillaUser(client))
                                return (EACCES);
                            else
-                               osi_audit(PrivilegeEvent, 0, AUD_INT,
+                               osi_audit(PrivilegeEvent, 0, AUD_ID,
                                          (client ? client->ViceId : 0),
                                          AUD_INT, CallingRoutine, AUD_END);
                        }
@@ -907,8 +1055,8 @@ RXFetch_AccessList(Vnode * targetptr, Vnode * parentwhentargetnotdir,
 {
     char *eACL;                        /* External access list placeholder */
 
-    if (acl_Externalize
-       ((targetptr->disk.type ==
+    if (acl_Externalize_pr
+       (hpr_IdToName, (targetptr->disk.type ==
          vDirectory ? VVnodeACL(targetptr) :
          VVnodeACL(parentwhentargetnotdir)), &eACL) != 0) {
        return EIO;
@@ -936,7 +1084,8 @@ RXStore_AccessList(Vnode * targetptr, struct AFSOpaque *AccessList)
 {
     struct acl_accessList *newACL;     /* PlaceHolder for new access list */
 
-    if (acl_Internalize(AccessList->AFSOpaque_val, &newACL) != 0)
+    if (acl_Internalize_pr(hpr_NameToId, AccessList->AFSOpaque_val, &newACL)
+       != 0)
        return (EINVAL);
     if ((newACL->size + 4) > VAclSize(targetptr))
        return (E2BIG);
@@ -947,49 +1096,6 @@ RXStore_AccessList(Vnode * targetptr, struct AFSOpaque *AccessList)
 }                              /*RXStore_AccessList */
 
 
-static afs_int32
-Fetch_AccessList(Vnode * targetptr, Vnode * parentwhentargetnotdir,
-                struct AFSAccessList *AccessList)
-{
-    char *eACL;                        /* External access list placeholder */
-
-    assert(acl_Externalize
-          ((targetptr->disk.type ==
-            vDirectory ? VVnodeACL(targetptr) :
-            VVnodeACL(parentwhentargetnotdir)), &eACL) == 0);
-    if ((strlen(eACL) + 1) > AccessList->MaxSeqLen) {
-       acl_FreeExternalACL(&eACL);
-       return (E2BIG);
-    } else {
-       strcpy((char *)(AccessList->SeqBody), (char *)eACL);
-       AccessList->SeqLen = strlen(eACL) + 1;
-    }
-    acl_FreeExternalACL(&eACL);
-    return (0);
-
-}                              /*Fetch_AccessList */
-
-/*
- * The Access List information is converted from its external form in the
- * input AccessList structure to the internal representation and copied into
- * the target dir's vnode storage.
- */
-static afs_int32
-Store_AccessList(Vnode * targetptr, struct AFSAccessList *AccessList)
-{
-    struct acl_accessList *newACL;     /* PlaceHolder for new access list */
-
-    if (acl_Internalize(AccessList->SeqBody, &newACL) != 0)
-       return (EINVAL);
-    if ((newACL->size + 4) > VAclSize(targetptr))
-       return (E2BIG);
-    memcpy((char *)VVnodeACL(targetptr), (char *)newACL, (int)(newACL->size));
-    acl_FreeACL(&newACL);
-    return (0);
-
-}                              /*Store_AccessList */
-
-
 /* In our current implementation, each successive data store (new file
  * data version) creates a new inode. This function creates the new
  * inode, copies the old inode's contents to the new one, remove the old
@@ -998,14 +1104,15 @@ Store_AccessList(Vnode * targetptr, struct AFSAccessList *AccessList)
  * disk.inodeNumber and cloned)
  */
 #define        COPYBUFFSIZE    8192
+#define MAXFSIZE (~(afs_fsize_t) 0)
 static int
-CopyOnWrite(Vnode * targetptr, Volume * volptr)
+CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_fsize_t off, afs_fsize_t len)
 {
     Inode ino, nearInode;
     int rdlen;
     int wrlen;
-    register int size, length;
-    int ifd, ofd;
+    register afs_fsize_t size;
+    register int length;
     char *buff;
     int rc;                    /* return code */
     IHandle_t *newH;           /* Use until finished copying, then cp to vnode. */
@@ -1016,13 +1123,26 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
        DFlush();               /* just in case? */
 
     VN_GET_LEN(size, targetptr);
+    if (size > off) 
+       size -= off;
+    else 
+       size = 0;
+    if (size > len)
+       size = len;
+
     buff = (char *)malloc(COPYBUFFSIZE);
     if (buff == NULL) {
        return EIO;
     }
 
     ino = VN_GET_INO(targetptr);
-    assert(VALID_INO(ino));
+    if (!VALID_INO(ino)) {
+       free(buff);
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
+       return EIO;
+    }    
     targFdP = IH_OPEN(targetptr->handle);
     if (targFdP == NULL) {
        rc = errno;
@@ -1053,12 +1173,14 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
     newFdP = IH_OPEN(newH);
     assert(newFdP != NULL);
 
+    FDH_SEEK(targFdP, off, SEEK_SET);
+    FDH_SEEK(newFdP, off, SEEK_SET);
     while (size > 0) {
        if (size > COPYBUFFSIZE) {      /* more than a buffer */
            length = COPYBUFFSIZE;
            size -= COPYBUFFSIZE;
        } else {
-           length = size;
+           length = (int)size;
            size = 0;
        }
        rdlen = FDH_READ(targFdP, buff, length);
@@ -1075,7 +1197,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
         *  error code indicates that the disk is full, we roll-back to
         *  the initial state.
         */
-       if ((rdlen != length) || (wrlen != length))
+       if ((rdlen != length) || (wrlen != length)) {
            if ((wrlen < 0) && (errno == ENOSPC)) {     /* disk full */
                ViceLog(0,
                        ("CopyOnWrite failed: Partition %s containing volume %u is full\n",
@@ -1098,10 +1220,10 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
                        ("CopyOnWrite failed: volume %u in partition %s  (tried reading %u, read %u, wrote %u, errno %u) volume needs salvage\n",
                         V_id(volptr), volptr->partition->name, length, rdlen,
                         wrlen, errno));
-#ifdef FAST_RESTART            /* if running in no-salvage, don't core the server */
+#if defined(AFS_DEMAND_ATTACH_FS)
+               ViceLog(0, ("CopyOnWrite failed: requesting salvage\n"));
+#else
                ViceLog(0, ("CopyOnWrite failed: taking volume offline\n"));
-#else /* Avoid further corruption and try to get a core. */
-               assert(0);
 #endif
                /* Decrement this inode so salvager doesn't find it. */
                FDH_REALLYCLOSE(newFdP);
@@ -1112,6 +1234,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
                VTakeOffline(volptr);
                return EIO;
            }
+       }
 #ifndef AFS_PTHREAD_ENV
        IOMGR_Poll();
 #endif /* !AFS_PTHREAD_ENV */
@@ -1134,6 +1257,42 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr)
     return 0;                  /* success */
 }                              /*CopyOnWrite */
 
+static int
+CopyOnWrite2(FdHandle_t *targFdP, FdHandle_t *newFdP, afs_fsize_t off, afs_fsize_t size) {
+    char *buff = (char *)malloc(COPYBUFFSIZE);
+    register int length;
+    int rdlen;
+    int wrlen;
+    int rc;
+
+    FDH_SEEK(targFdP, off, SEEK_SET);
+    FDH_SEEK(newFdP, off, SEEK_SET);
+
+    if (size > FDH_SIZE(targFdP) - off) size = FDH_SIZE(targFdP) - off;
+    while (size > 0) {
+       if (size > COPYBUFFSIZE) {      /* more than a buffer */
+           length = COPYBUFFSIZE;
+           size -= COPYBUFFSIZE;
+       } else {
+           length = (int)size;
+           size = 0;
+       }
+       rdlen = FDH_READ(targFdP, buff, length);
+       if (rdlen == length)
+           wrlen = FDH_WRITE(newFdP, buff, length);
+       else
+           wrlen = 0;
+
+       if ((rdlen != length) || (wrlen != length)) {
+           /* no error recovery, at the worst we'll have a "hole" in the file */
+           rc = 1;
+           break;
+       }
+    }
+    free(buff);
+    return rc;
+}
+
 
 /*
  * Common code to handle with removing the Name (file when it's called from
@@ -1146,7 +1305,7 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
             DirHandle * dir, AFSFid * fileFid, char *Name, int ChkForDir)
 {
     DirHandle childdir;                /* Handle for dir package I/O */
-    int errorCode = 0;
+    Error errorCode = 0;
     int code;
 
     /* watch for invalid names */
@@ -1154,7 +1313,7 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
        return (EINVAL);
     if (parentptr->disk.cloned) {
        ViceLog(25, ("DeleteTarget : CopyOnWrite called\n"));
-       if ((errorCode = CopyOnWrite(parentptr, volptr))) {
+       if ((errorCode = CopyOnWrite(parentptr, volptr, 0, MAXFSIZE))) {
            ViceLog(20,
                    ("DeleteTarget %s: CopyOnWrite failed %d\n", Name,
                     errorCode));
@@ -1189,6 +1348,9 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
       */
     if ((*targetptr)->disk.uniquifier != fileFid->Unique) {
        VTakeOffline(volptr);
+       ViceLog(0,
+               ("Volume %u now offline, must be salvaged.\n",
+                volptr->hashid));
        errorCode = VSALVAGE;
        return errorCode;
     }
@@ -1197,7 +1359,8 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
        SetDirHandle(&childdir, *targetptr);
        if (IsEmpty(&childdir) != 0)
            return (EEXIST);
-       DZap(&childdir);
+       DZap((afs_int32 *) &childdir);
+       FidZap(&childdir);
        (*targetptr)->delete = 1;
     } else if ((--(*targetptr)->disk.linkCount) == 0)
        (*targetptr)->delete = 1;
@@ -1214,16 +1377,12 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
                        ("DT: inode=%s, name=%s, errno=%d\n",
                         PrintInode(NULL, VN_GET_INO(*targetptr)), Name,
                         errno));
-#ifdef AFS_DEC_ENV
-               if ((errno != ENOENT) && (errno != EIO) && (errno != ENXIO))
-#else
                if (errno != ENOENT)
-#endif
                {
+                   VTakeOffline(volptr);
                    ViceLog(0,
                            ("Volume %u now offline, must be salvaged.\n",
                             volptr->hashid));
-                   VTakeOffline(volptr);
                    return (EIO);
                }
                DT1++;
@@ -1246,10 +1405,10 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr,
                ("Error %d deleting %s\n", code,
                 (((*targetptr)->disk.type ==
                   Directory) ? "directory" : "file")));
+       VTakeOffline(volptr);
        ViceLog(0,
                ("Volume %u now offline, must be salvaged.\n",
                 volptr->hashid));
-       VTakeOffline(volptr);
        if (!errorCode)
            errorCode = code;
     }
@@ -1276,7 +1435,7 @@ Update_ParentVnodeStatus(Vnode * parentptr, Volume * volptr, DirHandle * dir,
 {
     afs_fsize_t newlength;     /* Holds new directory length */
     afs_fsize_t parentLength;
-    int errorCode;
+    Error errorCode;
 #if FS_STATS_DETAILED
     Date currDate;             /*Current date */
     int writeIdx;              /*Write index to bump */
@@ -1284,7 +1443,7 @@ Update_ParentVnodeStatus(Vnode * parentptr, Volume * volptr, DirHandle * dir,
 #endif /* FS_STATS_DETAILED */
 
     parentptr->disk.dataVersion++;
-    newlength = Length(dir);
+    newlength = (afs_fsize_t) Length(dir);
     /* 
      * This is a called on both dir removals (i.e. remove, removedir, rename) but also in dir additions
      * (create, symlink, link, makedir) so we need to check if we have enough space
@@ -1462,12 +1621,12 @@ Update_TargetVnodeStatus(Vnode * targetptr, afs_uint32 Caller,
            targetptr->disk.modeBits = modebits;
            switch (Caller) {
            case TVS_SDATA:
-               osi_audit(PrivSetID, 0, AUD_INT, client->ViceId, AUD_INT,
+               osi_audit(PrivSetID, 0, AUD_ID, client->ViceId, AUD_INT,
                          CHK_STOREDATA, AUD_END);
                break;
            case TVS_CFILE:
            case TVS_SSTATUS:
-               osi_audit(PrivSetID, 0, AUD_INT, client->ViceId, AUD_INT,
+               osi_audit(PrivSetID, 0, AUD_ID, client->ViceId, AUD_INT,
                          CHK_STORESTATUS, AUD_END);
                break;
            default:
@@ -1511,10 +1670,11 @@ SetCallBackStruct(afs_uint32 CallBackTime, struct AFSCallBack *CallBack)
  * enough space before consuming some.
  */
 static afs_int32
-AdjustDiskUsage(Volume * volptr, afs_int32 length, afs_int32 checkLength)
+AdjustDiskUsage(Volume * volptr, afs_sfsize_t length,
+               afs_sfsize_t checkLength)
 {
-    int rc;
-    int nc;
+    Error rc;
+    Error nc;
 
     VAdjustDiskUsage(&rc, volptr, length, checkLength);
     if (rc) {
@@ -1545,10 +1705,10 @@ AdjustDiskUsage(Volume * volptr, afs_int32 length, afs_int32 checkLength)
 static afs_int32
 Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
               Vnode ** targetptr, char *Name, struct AFSFid *OutFid,
-              int FileType, int BlocksPreallocatedForVnode)
+              int FileType, afs_sfsize_t BlocksPreallocatedForVnode)
 {
-    int errorCode = 0;         /* Error code returned back */
-    int temp;
+    Error errorCode = 0;               /* Error code returned back */
+    Error temp;
     Inode inode = 0;
     Inode nearInode;           /* hint for inode allocation in solaris */
 
@@ -1556,8 +1716,8 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
         AdjustDiskUsage(volptr, BlocksPreallocatedForVnode,
                         BlocksPreallocatedForVnode))) {
        ViceLog(25,
-               ("Insufficient space to allocate %d blocks\n",
-                BlocksPreallocatedForVnode));
+               ("Insufficient space to allocate %" AFS_INT64_FMT " blocks\n",
+                (afs_intmax_t) BlocksPreallocatedForVnode));
        return (errorCode);
     }
 
@@ -1597,7 +1757,7 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
 
     if (parentptr->disk.cloned) {
        ViceLog(25, ("Alloc_NewVnode : CopyOnWrite called\n"));
-       if ((errorCode = CopyOnWrite(parentptr, volptr))) {     /* disk full */
+       if ((errorCode = CopyOnWrite(parentptr, volptr, 0, MAXFSIZE))) {        /* disk full */
            ViceLog(25, ("Alloc_NewVnode : CopyOnWrite failed\n"));
            /* delete the vnode previously allocated */
            (*targetptr)->delete = 1;
@@ -1637,14 +1797,11 @@ Alloc_NewVnode(Vnode * parentptr, DirHandle * dir, Volume * volptr,
  * SAFS_ReleaseLock)
  */
 static afs_int32
-HandleLocking(Vnode * targetptr, afs_int32 rights, ViceLockType LockingType)
+HandleLocking(Vnode * targetptr, struct client *client, afs_int32 rights, ViceLockType LockingType)
 {
     int Time;                  /* Used for time */
     int writeVnode = targetptr->changed_oldTime;       /* save original status */
 
-    /* Does the caller has Lock priviledges; root extends locks, however */
-    if (LockingType != LockExtend && !(rights & PRSFS_LOCK))
-       return (EACCES);
     targetptr->changed_oldTime = 1;    /* locking doesn't affect any time stamp */
     Time = FT_ApproxTime();
     switch (LockingType) {
@@ -1655,12 +1812,21 @@ HandleLocking(Vnode * targetptr, afs_int32 rights, ViceLockType LockingType)
                0;
        Time += AFS_LOCKWAIT;
        if (LockingType == LockRead) {
+           if ( !(rights & PRSFS_LOCK) && 
+                 !(rights & PRSFS_WRITE) &&
+                 !(OWNSp(client, targetptr) && (rights & PRSFS_INSERT)) )
+                    return(EACCES);
+
            if (targetptr->disk.lock.lockCount >= 0) {
                ++(targetptr->disk.lock.lockCount);
                targetptr->disk.lock.lockTime = Time;
            } else
                return (EAGAIN);
-       } else {
+       } else if (LockingType == LockWrite) {
+           if ( !(rights & PRSFS_WRITE) && 
+                !(OWNSp(client, targetptr) && (rights & PRSFS_INSERT)) )
+               return(EACCES);
+
            if (targetptr->disk.lock.lockCount == 0) {
                targetptr->disk.lock.lockCount = -1;
                targetptr->disk.lock.lockTime = Time;
@@ -1739,80 +1905,6 @@ RXUpdate_VolumeStatus(Volume * volptr, AFSStoreVolumeStatus * StoreVolStatus,
 }                              /*RXUpdate_VolumeStatus */
 
 
-/* old interface */
-static afs_int32
-Update_VolumeStatus(Volume * volptr, VolumeStatus * StoreVolStatus,
-                   struct BBS *Name, struct BBS *OfflineMsg,
-                   struct BBS *Motd)
-{
-    Error errorCode = 0;
-
-    if (StoreVolStatus->MinQuota > -1)
-       V_minquota(volptr) = StoreVolStatus->MinQuota;
-    if (StoreVolStatus->MaxQuota > -1)
-       V_maxquota(volptr) = StoreVolStatus->MaxQuota;
-    if (OfflineMsg->SeqLen > 1)
-       strcpy(V_offlineMessage(volptr), OfflineMsg->SeqBody);
-    if (Name->SeqLen > 1)
-       strcpy(V_name(volptr), Name->SeqBody);
-#if OPENAFS_VOL_STATS
-    /*
-     * We don't overwrite the motd field, since it's now being used
-     * for stats
-     */
-#else
-    if (Motd->SeqLen > 1)
-       strcpy(V_motd(volptr), Motd->SeqBody);
-#endif /* FS_STATS_DETAILED */
-    VUpdateVolume(&errorCode, volptr);
-    return (errorCode);
-
-}                              /*Update_VolumeStatus */
-
-
-/*
- * Get internal volume-related statistics from the Volume disk label
- * structure and put it into the VolumeStatus structure, status; it's
- * used by both SAFS_GetVolumeStatus and SAFS_SetVolumeStatus to return
- * the volume status to the caller.
- */
-static afs_int32
-GetVolumeStatus(VolumeStatus * status, struct BBS *name, struct BBS *offMsg,
-               struct BBS *motd, Volume * volptr)
-{
-    status->Vid = V_id(volptr);
-    status->ParentId = V_parentId(volptr);
-    status->Online = V_inUse(volptr);
-    status->InService = V_inService(volptr);
-    status->Blessed = V_blessed(volptr);
-    status->NeedsSalvage = V_needsSalvaged(volptr);
-    if (VolumeWriteable(volptr))
-       status->Type = ReadWrite;
-    else
-       status->Type = ReadOnly;
-    status->MinQuota = V_minquota(volptr);
-    status->MaxQuota = V_maxquota(volptr);
-    status->BlocksInUse = V_diskused(volptr);
-    status->PartBlocksAvail = volptr->partition->free;
-    status->PartMaxBlocks = volptr->partition->totalUsable;
-    strncpy(name->SeqBody, V_name(volptr), (int)name->MaxSeqLen);
-    name->SeqLen = strlen(V_name(volptr)) + 1;
-    if (name->SeqLen > name->MaxSeqLen)
-       name->SeqLen = name->MaxSeqLen;
-    strncpy(offMsg->SeqBody, V_offlineMessage(volptr), (int)name->MaxSeqLen);
-    offMsg->SeqLen = strlen(V_offlineMessage(volptr)) + 1;
-    if (offMsg->SeqLen > offMsg->MaxSeqLen)
-       offMsg->SeqLen = offMsg->MaxSeqLen;
-#ifdef notdef
-    /*Don't do anything with the motd field */
-    strncpy(motd->SeqBody, nullString, (int)offMsg->MaxSeqLen);
-    motd->SeqLen = strlen(nullString) + 1;
-#endif
-    if (motd->SeqLen > motd->MaxSeqLen)
-       motd->SeqLen = motd->MaxSeqLen;
-
-}                              /*GetVolumeStatus */
-
 static afs_int32
 RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
                  char **motd, Volume * volptr)
@@ -1832,8 +1924,8 @@ RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
     status->MinQuota = V_minquota(volptr);
     status->MaxQuota = V_maxquota(volptr);
     status->BlocksInUse = V_diskused(volptr);
-    status->PartBlocksAvail = volptr->partition->free;
-    status->PartMaxBlocks = volptr->partition->totalUsable;
+    status->PartBlocksAvail = RoundInt64ToInt32(volptr->partition->free);
+    status->PartMaxBlocks = RoundInt64ToInt32(volptr->partition->totalUsable);
 
     /* now allocate and copy these things; they're freed by the RXGEN stub */
     temp = strlen(V_name(volptr)) + 1;
@@ -1866,7 +1958,7 @@ RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg,
     }
     strcpy(*motd, V_motd(volptr));
 #endif /* FS_STATS_DETAILED */
-
+    return 0;
 }                              /*RXGetVolumeStatus */
 
 
@@ -1889,26 +1981,6 @@ FileNameOK(register char *aname)
 }                              /*FileNameOK */
 
 
-/* Debugging tool to print Volume Statu's contents */
-static void
-PrintVolumeStatus(VolumeStatus * status)
-{
-    ViceLog(5, ("Volume header contains:\n"));
-    ViceLog(5,
-           ("Vid = %u, Parent = %u, Online = %d, InService = %d, Blessed = %d, NeedsSalvage = %d\n",
-            status->Vid, status->ParentId, status->Online, status->InService,
-            status->Blessed, status->NeedsSalvage));
-    ViceLog(5,
-           ("MinQuota = %d, MaxQuota = %d\n", status->MinQuota,
-            status->MaxQuota));
-    ViceLog(5,
-           ("Type = %d, BlocksInUse = %d, PartBlocksAvail = %d, PartMaxBlocks = %d\n",
-            status->Type, status->BlocksInUse, status->PartBlocksAvail,
-            status->PartMaxBlocks));
-
-}                              /*PrintVolumeStatus */
-
-
 /*
  * This variant of symlink is expressly to support the AFS/DFS translator
  * and is not supported by the AFS fileserver. We just return EINVAL.
@@ -1925,13 +1997,22 @@ SRXAFS_DFSSymlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 }
 
 afs_int32
-SRXAFS_ResidencyCmd(struct rx_call * acall, struct AFSFid * Fid,
-                   struct ResidencyCmdInputs * Inputs,
-                   struct ResidencyCmdOutputs * Outputs)
+SRXAFS_FsCmd(struct rx_call * acall, struct AFSFid * Fid,
+                   struct FsCmdInputs * Inputs,
+                   struct FsCmdOutputs * Outputs)
 {
-    return EINVAL;
+    afs_int32 code = 0;
+
+    switch (Inputs->command) {
+    default:
+        code = EINVAL;
+    }
+    ViceLog(1,("FsCmd: cmd = %d, code=%d\n", 
+                       Inputs->command, Outputs->code));
+    return code;
 }
 
+#ifdef AFS_NT40_ENV
 static struct afs_buffer {
     struct afs_buffer *next;
 } *freeBufferList = 0;
@@ -1940,10 +2021,12 @@ static int afs_buffersAlloced = 0;
 static
 FreeSendBuffer(register struct afs_buffer *adata)
 {
-    FS_LOCK afs_buffersAlloced--;
+    FS_LOCK;
+    afs_buffersAlloced--;
     adata->next = freeBufferList;
     freeBufferList = adata;
-    FS_UNLOCK return 0;
+    FS_UNLOCK;
+    return 0;
 
 }                              /*FreeSendBuffer */
 
@@ -1953,10 +2036,12 @@ AllocSendBuffer()
 {
     register struct afs_buffer *tp;
 
-    FS_LOCK afs_buffersAlloced++;
+    FS_LOCK;
+    afs_buffersAlloced++;
     if (!freeBufferList) {
        char *tmp;
-       FS_UNLOCK tmp = malloc(sendBufSize);
+       FS_UNLOCK;
+       tmp = malloc(sendBufSize);
        if (!tmp) {
            ViceLog(0, ("Failed malloc in AllocSendBuffer\n"));
            assert(0);
@@ -1965,9 +2050,11 @@ AllocSendBuffer()
     }
     tp = freeBufferList;
     freeBufferList = tp->next;
-    FS_UNLOCK return (char *)tp;
+    FS_UNLOCK;
+    return (char *)tp;
 
 }                              /*AllocSendBuffer */
+#endif /* AFS_NT40_ENV */
 
 /*
  * This routine returns the status info associated with the targetptr vnode
@@ -2020,21 +2107,23 @@ GetStatus(Vnode * targetptr, AFSFetchStatus * status, afs_int32 rights,
 
 static
   afs_int32
-common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
-                  afs_int32 Len, struct AFSFetchStatus *OutStatus,
+common_FetchData64(struct rx_call *acall, struct AFSFid *Fid,
+                  afs_sfsize_t Pos, afs_sfsize_t Len,
+                  struct AFSFetchStatus *OutStatus,
                   struct AFSCallBack *CallBack, struct AFSVolSync *Sync,
                   int type)
 {
     Vnode *targetptr = 0;      /* pointer to vnode to fetch */
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if vptr is a file */
     Vnode tparentwhentargetnotdir;     /* parent vnode for GetStatus */
-    int errorCode = 0;         /* return code to caller */
-    int fileCode = 0;          /* return code from vol package */
+    Error errorCode = 0;               /* return code to caller */
+    Error fileCode = 0;                /* return code from vol package */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     struct rx_connection *tcon;        /* the connection we're part of */
+    struct host *thost;
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -2042,8 +2131,8 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
     struct timeval xferStartTime, xferStopTime;        /* Start/stop times for xfer portion */
     struct timeval elapsedTime;        /* Transfer time */
-    afs_int32 bytesToXfer;     /* # bytes to xfer */
-    afs_int32 bytesXferred;    /* # bytes actually xferred */
+    afs_sfsize_t bytesToXfer;  /* # bytes to xfer */
+    afs_sfsize_t bytesXferred; /* # bytes actually xferred */
     int readIdx;               /* Index of read stats array to bump */
     static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
 
@@ -2053,24 +2142,28 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_FETCHDATA]);
     xferP = &(afs_FullPerfStats.det.xferOpTimes[FS_STATS_XFERIDX_FETCHDATA]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1,
            ("SRXAFS_FetchData, Fid = %u.%u.%u\n", Fid->Volume, Fid->Vnode,
             Fid->Unique));
-    FS_LOCK AFSCallStats.FetchData++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    FS_LOCK;
+    AFSCallStats.FetchData++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_FetchData;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(5,
-           ("SRXAFS_FetchData, Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SRXAFS_FetchData, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
     /*
      * Get volume/vnode for the fetched file; caller's access rights to
      * it are also returned
@@ -2087,20 +2180,20 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     /*
      * Remember that another read operation was performed.
      */
-    FS_LOCK if (client->InSameNetwork)
-         readIdx = VOL_STATS_SAME_NET;
+    FS_LOCK;
+    if (client->InSameNetwork)
+       readIdx = VOL_STATS_SAME_NET;
     else
        readIdx = VOL_STATS_DIFF_NET;
     V_stat_reads(volptr, readIdx)++;
     if (client->ViceId != AnonymousID) {
        V_stat_reads(volptr, readIdx + 1)++;
     }
-    FS_UNLOCK
+    FS_UNLOCK;
 #endif /* FS_STATS_DETAILED */
-       /* Check whether the caller has permission access to fetch the data */
-       if ((errorCode =
-            Check_PermissionRights(targetptr, client, rights, CHK_FETCHDATA,
-                                   0)))
+    /* Check whether the caller has permission access to fetch the data */
+    if ((errorCode =
+        Check_PermissionRights(targetptr, client, rights, CHK_FETCHDATA, 0)))
        goto Bad_FetchData;
 
     /*
@@ -2117,7 +2210,7 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
     /*
      * Remember when the data transfer started.
      */
-    TM_GetTimeOfDay(&xferStartTime, 0);
+    FT_GetTimeOfDay(&xferStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     /* actually do the data transfer */
@@ -2138,8 +2231,9 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
      * integrate the transfer size and elapsed time into the stats.  If the
      * operation failed, we jump to the appropriate point.
      */
-    TM_GetTimeOfDay(&xferStopTime, 0);
-    FS_LOCK(xferP->numXfers)++;
+    FT_GetTimeOfDay(&xferStopTime, 0);
+    FS_LOCK;
+    (xferP->numXfers)++;
     if (!errorCode) {
        (xferP->numSuccesses)++;
 
@@ -2188,12 +2282,12 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
            fs_stats_TimeAssign((xferP->maxTime), elapsedTime);
        }
     }
-    FS_UNLOCK
-       /*
-        * Finally, go off to tell our caller the bad news in case the
-        * fetch failed.
-        */
-       if (errorCode)
+    FS_UNLOCK;
+    /*
+     * Finally, go off to tell our caller the bad news in case the
+     * fetch failed.
+     */
+    if (errorCode)
        goto Bad_FetchData;
 #endif /* FS_STATS_DETAILED */
 
@@ -2214,14 +2308,15 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
   Bad_FetchData:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SRXAFS_FetchData returns %d\n", errorCode));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -2231,10 +2326,13 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, afs_int32 Pos,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, FetchDataEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, FetchDataEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return (errorCode);
 
 }                              /*SRXAFS_FetchData */
@@ -2244,12 +2342,8 @@ SRXAFS_FetchData(struct rx_call * acall, struct AFSFid * Fid, afs_int32 Pos,
                 afs_int32 Len, struct AFSFetchStatus * OutStatus,
                 struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
 {
-    int code;
-
-    code =
-       common_FetchData64(acall, Fid, Pos, Len, OutStatus, CallBack, Sync,
-                          0);
-    return code;
+    return common_FetchData64(acall, Fid, Pos, Len, OutStatus, CallBack, 
+                              Sync, 0);
 }
 
 afs_int32
@@ -2258,16 +2352,14 @@ SRXAFS_FetchData64(struct rx_call * acall, struct AFSFid * Fid, afs_int64 Pos,
                   struct AFSCallBack * CallBack, struct AFSVolSync * Sync)
 {
     int code;
-    afs_int32 tPos, tLen;
+    afs_sfsize_t tPos, tLen;
 
 #ifdef AFS_64BIT_ENV
-    if (Pos + Len > 0x7fffffff)
-       return E2BIG;
-    tPos = Pos;
-    tLen = Len;
+    tPos = (afs_sfsize_t) Pos;
+    tLen = (afs_sfsize_t) Len;
 #else /* AFS_64BIT_ENV */
     if (Pos.high || Len.high)
-       return E2BIG;
+       return EFBIG;
     tPos = Pos.low;
     tLen = Len.low;
 #endif /* AFS_64BIT_ENV */
@@ -2285,12 +2377,13 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
 {
     Vnode *targetptr = 0;      /* pointer to vnode to fetch */
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
-    int errorCode = 0;         /* return error code to caller */
+    Error errorCode = 0;               /* return error code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
-    struct client *t_client;   /* tmp ptr to client data */
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -2302,24 +2395,28 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_FETCHACL]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1,
            ("SAFS_FetchACL, Fid = %u.%u.%u\n", Fid->Volume, Fid->Vnode,
             Fid->Unique));
-    FS_LOCK AFSCallStats.FetchACL++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    FS_LOCK;
+    AFSCallStats.FetchACL++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_FetchACL;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(5,
-           ("SAFS_FetchACL, Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("SAFS_FetchACL, Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
 
     AccessList->AFSOpaque_len = 0;
     AccessList->AFSOpaque_val = malloc(AFSOPAQUEMAX);
@@ -2357,16 +2454,17 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
   Bad_FetchACL:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2,
            ("SAFS_FetchACL returns %d (ACL=%s)\n", errorCode,
             AccessList->AFSOpaque_val));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -2376,10 +2474,14 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, FetchACLEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, FetchACLEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, 
+               AUD_ACL, AccessList->AFSOpaque_val, AUD_END);
     return errorCode;
 }                              /*SRXAFS_FetchACL */
 
@@ -2396,31 +2498,32 @@ SAFSS_FetchStatus(struct rx_call *acall, struct AFSFid *Fid,
 {
     Vnode *targetptr = 0;      /* pointer to vnode to fetch */
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
-    int errorCode = 0;         /* return code to caller */
+    Error errorCode = 0;               /* return code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_FetchStatus,  Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_FetchStatus,  Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
-    FS_LOCK AFSCallStats.FetchStatus++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get volume/vnode for the fetched file; caller's rights to it are
-        * also returned
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
-                             &parentwhentargetnotdir, &client, READ_LOCK,
-                             &rights, &anyrights)))
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.FetchStatus++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get volume/vnode for the fetched file; caller's rights to it are
+     * also returned
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
+                         &parentwhentargetnotdir, &client, READ_LOCK,
+                         &rights, &anyrights)))
        goto Bad_FetchStatus;
 
     /* set volume synchronization information */
@@ -2454,7 +2557,7 @@ SAFSS_FetchStatus(struct rx_call *acall, struct AFSFid *Fid,
   Bad_FetchStatus:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SAFS_FetchStatus returns %d\n", errorCode));
     return errorCode;
 
@@ -2470,12 +2573,14 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     afs_int32 nfiles;
     Vnode *targetptr = 0;      /* pointer to vnode to fetch */
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
-    int errorCode = 0;         /* return code to caller */
+    Error errorCode = 0;               /* return code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     register struct AFSFid *tfid;      /* file id we're dealing with now */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;     /* tmp pointer to the client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -2486,13 +2591,17 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_BULKSTATUS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1, ("SAFS_BulkStatus\n"));
-    FS_LOCK AFSCallStats.TotalCalls++;
-    FS_UNLOCK nfiles = Fids->AFSCBFids_len;    /* # of files in here */
+    FS_LOCK;
+    AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    nfiles = Fids->AFSCBFids_len;      /* # of files in here */
     if (nfiles <= 0) {         /* Sanity check */
        errorCode = EINVAL;
        goto Audit_and_Return;
@@ -2514,7 +2623,7 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     }
     CallBacks->AFSCBs_len = nfiles;
 
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_BulkStatus;
 
     tfid = Fids->AFSCBFids_val;
@@ -2529,7 +2638,7 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                              &rights, &anyrights)))
            goto Bad_BulkStatus;
        /* set volume synchronization information, but only once per call */
-       if (i == nfiles)
+       if (i == 0)
            SetVolumeSync(Sync, volptr);
 
        /* Are we allowed to fetch Fid's status? */
@@ -2561,22 +2670,26 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 
        /* put back the file ID and volume */
        (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                              volptr);
+                              volptr, &client);
        parentwhentargetnotdir = (Vnode *) 0;
        targetptr = (Vnode *) 0;
        volptr = (Volume *) 0;
+       client = (struct client *)0;
     }
 
   Bad_BulkStatus:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
-    errorCode = CallPostamble(tcon, errorCode);
+                          volptr, &client);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -2586,13 +2699,15 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
   Audit_and_Return:
     ViceLog(2, ("SAFS_BulkStatus       returns %d\n", errorCode));
-    osi_auditU(acall, BulkFetchStatusEvent, errorCode, AUD_FIDS, Fids,
-              AUD_END);
+    osi_auditU(acall, BulkFetchStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FIDS, Fids, AUD_END);
     return errorCode;
 
 }                              /*SRXAFS_BulkStatus */
@@ -2607,13 +2722,16 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     afs_int32 nfiles;
     Vnode *targetptr = 0;      /* pointer to vnode to fetch */
     Vnode *parentwhentargetnotdir = 0; /* parent vnode if targetptr is a file */
-    int errorCode = 0;         /* return code to caller */
+    Error errorCode = 0;               /* return code to caller */
     Volume *volptr = 0;                /* pointer to the volume */
-    struct client *client;     /* pointer to the client data */
+    struct client *client = 0; /* pointer to the client data */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     register struct AFSFid *tfid;      /* file id we're dealing with now */
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     AFSFetchStatus *tstatus;
+    int VolSync_set = 0;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -2624,13 +2742,17 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_BULKSTATUS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1, ("SAFS_InlineBulkStatus\n"));
-    FS_LOCK AFSCallStats.TotalCalls++;
-    FS_UNLOCK nfiles = Fids->AFSCBFids_len;    /* # of files in here */
+    FS_LOCK;
+    AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    nfiles = Fids->AFSCBFids_len;      /* # of files in here */
     if (nfiles <= 0) {         /* Sanity check */
        errorCode = EINVAL;
        goto Audit_and_Return;
@@ -2652,7 +2774,12 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
     }
     CallBacks->AFSCBs_len = nfiles;
 
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon))) {
+    /* Zero out return values to avoid leaking information on partial succes */
+    memset(OutStats->AFSBulkStats_val, 0, nfiles * sizeof(struct AFSFetchStatus));
+    memset(CallBacks->AFSCBs_val, 0, nfiles * sizeof(struct AFSCallBack));
+    memset(Sync, 0, sizeof(*Sync));
+
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))) {
        goto Bad_InlineBulkStatus;
     }
 
@@ -2668,15 +2795,20 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                              &rights, &anyrights))) {
            tstatus = &OutStats->AFSBulkStats_val[i];
            tstatus->errorCode = errorCode;
+           PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                            volptr, &client);
            parentwhentargetnotdir = (Vnode *) 0;
            targetptr = (Vnode *) 0;
            volptr = (Volume *) 0;
+           client = (struct client *)0;
            continue;
        }
 
        /* set volume synchronization information, but only once per call */
-       if (i == nfiles)
+       if (!VolSync_set) {
            SetVolumeSync(Sync, volptr);
+           VolSync_set = 1;
+       }
 
        /* Are we allowed to fetch Fid's status? */
        if (targetptr->disk.type != vDirectory) {
@@ -2686,10 +2818,11 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
                tstatus = &OutStats->AFSBulkStats_val[i];
                tstatus->errorCode = errorCode;
                (void)PutVolumePackage(parentwhentargetnotdir, targetptr,
-                                      (Vnode *) 0, volptr);
+                                      (Vnode *) 0, volptr, &client);
                parentwhentargetnotdir = (Vnode *) 0;
                targetptr = (Vnode *) 0;
                volptr = (Volume *) 0;
+               client = (struct client *)0;
                continue;
            }
        }
@@ -2713,22 +2846,26 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
 
        /* put back the file ID and volume */
        (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                              volptr);
+                              volptr, &client);
        parentwhentargetnotdir = (Vnode *) 0;
        targetptr = (Vnode *) 0;
        volptr = (Volume *) 0;
+       client = (struct client *)0;
     }
 
   Bad_InlineBulkStatus:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
-    errorCode = CallPostamble(tcon, errorCode);
+                          volptr, &client);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -2738,13 +2875,15 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
   Audit_and_Return:
     ViceLog(2, ("SAFS_InlineBulkStatus returns %d\n", errorCode));
-    osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode, AUD_FIDS, Fids,
-              AUD_END);
+    osi_auditU(acall, InlineBulkFetchStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FIDS, Fids, AUD_END);
     return 0;
 
 }                              /*SRXAFS_InlineBulkStatus */
@@ -2757,6 +2896,8 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -2767,22 +2908,27 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_FETCHSTATUS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_FetchStatus;
 
     code = SAFSS_FetchStatus(acall, Fid, OutStatus, CallBack, Sync);
 
   Bad_FetchStatus:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -2792,10 +2938,13 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, FetchStatusEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, FetchStatusEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_FetchStatus */
@@ -2803,29 +2952,30 @@ SRXAFS_FetchStatus(struct rx_call * acall, struct AFSFid * Fid,
 static
   afs_int32
 common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
-                  struct AFSStoreStatus *InStatus, afs_uint32 Pos,
-                  afs_uint32 Length, afs_uint32 FileLength,
+                  struct AFSStoreStatus *InStatus, afs_fsize_t Pos,
+                  afs_fsize_t Length, afs_fsize_t FileLength,
                   struct AFSFetchStatus *OutStatus, struct AFSVolSync *Sync)
 {
     Vnode *targetptr = 0;      /* pointer to input fid */
     Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
     Vnode tparentwhentargetnotdir;     /* parent vnode for GetStatus */
-    int errorCode = 0;         /* return code for caller */
-    int fileCode = 0;          /* return code from vol package */
+    Error errorCode = 0;               /* return code for caller */
+    Error fileCode = 0;                /* return code from vol package */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct fs_stats_xferData *xferP;   /* Ptr to this op's byte size struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
     struct timeval xferStartTime, xferStopTime;        /* Start/stop times for xfer portion */
     struct timeval elapsedTime;        /* Transfer time */
-    afs_int32 bytesToXfer;     /* # bytes to xfer */
-    afs_int32 bytesXferred;    /* # bytes actually xfer */
+    afs_sfsize_t bytesToXfer;  /* # bytes to xfer */
+    afs_sfsize_t bytesXferred; /* # bytes actually xfer */
     static afs_int32 tot_bytesXferred; /* shared access protected by FS_LOCK */
 
     /*
@@ -2834,24 +2984,28 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_STOREDATA]);
     xferP = &(afs_FullPerfStats.det.xferOpTimes[FS_STATS_XFERIDX_STOREDATA]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK ViceLog(1,
-                     ("StoreData: Fid = %u.%u.%u\n", Fid->Volume, Fid->Vnode,
-                      Fid->Unique));
-    TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    ViceLog(1,
+           ("StoreData: Fid = %u.%u.%u\n", Fid->Volume, Fid->Vnode,
+            Fid->Unique));
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    FS_LOCK AFSCallStats.StoreData++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    FS_LOCK;
+    AFSCallStats.StoreData++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_StoreData;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(5,
-           ("StoreData: Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("StoreData: Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
 
     /*
      * Get associated volume/vnode for the stored file; caller's rights
@@ -2890,12 +3044,11 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
        assert(!fileCode || (fileCode == VSALVAGE));
        parentwhentargetnotdir = NULL;
     }
-
 #if FS_STATS_DETAILED
     /*
      * Remember when the data transfer started.
      */
-    TM_GetTimeOfDay(&xferStartTime, 0);
+    FT_GetTimeOfDay(&xferStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     /* Do the actual storing of the data */
@@ -2918,8 +3071,9 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
      * integrate the transfer size and elapsed time into the stats.  If the
      * operation failed, we jump to the appropriate point.
      */
-    TM_GetTimeOfDay(&xferStopTime, 0);
-    FS_LOCK(xferP->numXfers)++;
+    FT_GetTimeOfDay(&xferStopTime, 0);
+    FS_LOCK;
+    (xferP->numXfers)++;
     if (!errorCode) {
        (xferP->numSuccesses)++;
 
@@ -2968,12 +3122,12 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
            fs_stats_TimeAssign((xferP->maxTime), elapsedTime);
        }
     }
-    FS_UNLOCK
-       /*
-        * Finally, go off to tell our caller the bad news in case the
-        * store failed.
-        */
-       if (errorCode && (!targetptr->changed_newTime))
+    FS_UNLOCK;
+    /*
+     * Finally, go off to tell our caller the bad news in case the
+     * store failed.
+     */
+    if (errorCode && (!targetptr->changed_newTime))
        goto Bad_StoreData;
 #endif /* FS_STATS_DETAILED */
 
@@ -2988,15 +3142,16 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
   Bad_StoreData:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SAFS_StoreData        returns %d\n", errorCode));
 
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -3006,12 +3161,13 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
-
-    osi_auditU(acall, StoreDataEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, StoreDataEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return (errorCode);
-
 }                              /*common_StoreData64 */
 
 afs_int32
@@ -3020,13 +3176,12 @@ SRXAFS_StoreData(struct rx_call * acall, struct AFSFid * Fid,
                 afs_uint32 Length, afs_uint32 FileLength,
                 struct AFSFetchStatus * OutStatus, struct AFSVolSync * Sync)
 {
-    int code;
-
-    code =
-       common_StoreData64(acall, Fid, InStatus, Pos, Length, FileLength,
-                          OutStatus, Sync);
-    return code;
+    if (FileLength > 0x7fffffff || Pos > 0x7fffffff || 
+       (0x7fffffff - Pos) < Length)
+        return EFBIG;
 
+    return common_StoreData64(acall, Fid, InStatus, Pos, Length, FileLength,
+                             OutStatus, Sync);
 }                              /*SRXAFS_StoreData */
 
 afs_int32
@@ -3037,19 +3192,17 @@ SRXAFS_StoreData64(struct rx_call * acall, struct AFSFid * Fid,
                   struct AFSVolSync * Sync)
 {
     int code;
-    afs_int32 tPos;
-    afs_int32 tLength;
-    afs_int32 tFileLength;
+    afs_fsize_t tPos;
+    afs_fsize_t tLength;
+    afs_fsize_t tFileLength;
 
 #ifdef AFS_64BIT_ENV
-    if (FileLength > 0x7fffffff)
-       return E2BIG;
-    tPos = Pos;
-    tLength = Length;
-    tFileLength = FileLength;
+    tPos = (afs_fsize_t) Pos;
+    tLength = (afs_fsize_t) Length;
+    tFileLength = (afs_fsize_t) FileLength;
 #else /* AFS_64BIT_ENV */
     if (FileLength.high)
-       return E2BIG;
+       return EFBIG;
     tPos = Pos.low;
     tLength = Length.low;
     tFileLength = FileLength.low;
@@ -3068,13 +3221,14 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
 {
     Vnode *targetptr = 0;      /* pointer to input fid */
     Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
-    int errorCode = 0;         /* return code for caller */
+    Error errorCode = 0;               /* return code for caller */
     struct AFSStoreStatus InStatus;    /* Input status for fid */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct rx_connection *tcon;
-    struct client *t_client;   /* tmp ptr to client data */
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -3086,21 +3240,25 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_STOREACL]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_StoreACL;
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_StoreACL, Fid = %u.%u.%u, ACL=%s, Host %s, Id %d\n",
+           ("SAFS_StoreACL, Fid = %u.%u.%u, ACL=%s, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, AccessList->AFSOpaque_val,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.StoreACL++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK InStatus.Mask = 0;       /* not storing any status */
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.StoreACL++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    InStatus.Mask = 0;         /* not storing any status */
 
     /*
      * Get associated volume/vnode for the target dir; caller's rights
@@ -3142,14 +3300,16 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
 
   Bad_StoreACL:
     /* Update and store volume/vnode and parent vnodes back */
-    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                    volptr, &client);
     ViceLog(2, ("SAFS_StoreACL returns %d\n", errorCode));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -3159,10 +3319,13 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, StoreACLEvent, errorCode, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, StoreACLEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_ACL, AccessList->AFSOpaque_val, AUD_END);
     return errorCode;
 
 }                              /*SRXAFS_StoreACL */
@@ -3179,31 +3342,32 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
 {
     Vnode *targetptr = 0;      /* pointer to input fid */
     Vnode *parentwhentargetnotdir = 0; /* parent of Fid to get ACL */
-    int errorCode = 0;         /* return code for caller */
+    Error errorCode = 0;               /* return code for caller */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
-    struct client *t_client;   /* tmp ptr to client data */
+    struct client *t_client = NULL;    /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_StoreStatus,  Fid    = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_StoreStatus,  Fid    = %u.%u.%u, Host %s:%d, Id %d\n",
             Fid->Volume, Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
-    FS_LOCK AFSCallStats.StoreStatus++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get volume/vnode for the target file; caller's rights to it are
-        * also returned
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
-                             &parentwhentargetnotdir, &client, WRITE_LOCK,
-                             &rights, &anyrights))) {
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.StoreStatus++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get volume/vnode for the target file; caller's rights to it are
+     * also returned
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
+                         &parentwhentargetnotdir, &client, WRITE_LOCK,
+                         &rights, &anyrights))) {
        goto Bad_StoreStatus;
     }
 
@@ -3243,7 +3407,8 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid,
 
   Bad_StoreStatus:
     /* Update and store volume/vnode and parent vnodes back */
-    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                    volptr, &client);
     ViceLog(2, ("SAFS_StoreStatus returns %d\n", errorCode));
     return errorCode;
 
@@ -3258,6 +3423,8 @@ SRXAFS_StoreStatus(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3268,22 +3435,27 @@ SRXAFS_StoreStatus(struct rx_call * acall, struct AFSFid * Fid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_STORESTATUS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_StoreStatus;
 
     code = SAFSS_StoreStatus(acall, Fid, InStatus, OutStatus, Sync);
 
   Bad_StoreStatus:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -3293,10 +3465,13 @@ SRXAFS_StoreStatus(struct rx_call * acall, struct AFSFid * Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, StoreStatusEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, StoreStatusEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_StoreStatus */
@@ -3315,9 +3490,9 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *targetptr = 0;      /* file to be deleted */
     Volume *volptr = 0;                /* pointer to the volume header */
     AFSFid fileFid;            /* area for Fid from the directory */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -3326,21 +3501,22 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     FidZero(&dir);
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_RemoveFile %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_RemoveFile %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.RemoveFile++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get volume/vnode for the parent dir; caller's access rights are
-        * also returned
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, DirFid, &volptr, &parentptr, MustBeDIR,
-                             &parentwhentargetnotdir, &client, WRITE_LOCK,
-                             &rights, &anyrights))) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.RemoveFile++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get volume/vnode for the parent dir; caller's access rights are
+     * also returned
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, DirFid, &volptr, &parentptr, MustBeDIR,
+                         &parentwhentargetnotdir, &client, WRITE_LOCK,
+                         &rights, &anyrights))) {
        goto Bad_RemoveFile;
     }
     /* set volume synchronization information */
@@ -3394,7 +3570,8 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
   Bad_RemoveFile:
     /* Update and store volume/vnode and parent vnodes back */
-    PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr, 
+                    volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_RemoveFile returns %d\n", errorCode));
     return errorCode;
@@ -3409,6 +3586,8 @@ SRXAFS_RemoveFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3419,22 +3598,27 @@ SRXAFS_RemoveFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_REMOVEFILE]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_RemoveFile;
 
     code = SAFSS_RemoveFile(acall, DirFid, Name, OutDirStatus, Sync);
 
   Bad_RemoveFile:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -3444,11 +3628,13 @@ SRXAFS_RemoveFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, RemoveFileEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, RemoveFileEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name, AUD_END);
     return code;
 
 }                              /*SRXAFS_RemoveFile */
@@ -3469,9 +3655,9 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *targetptr = 0;      /* vnode of the new file */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     Volume *volptr = 0;                /* pointer to the volume header */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -3481,13 +3667,15 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_CreateFile %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_CreateFile %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.CreateFile++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (!FileNameOK(Name)) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.CreateFile++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (!FileNameOK(Name)) {
        errorCode = EINVAL;
        goto Bad_CreateFile;
     }
@@ -3531,8 +3719,8 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Update_TargetVnodeStatus(targetptr, TVS_CFILE, client, InStatus,
                             parentptr, volptr, 0);
 
-    /* set up the return status for the parent dir and the newly created file */
-    GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
+    /* set up the return status for the parent dir and the newly created file, and since the newly created file is owned by the creator, give it PRSFS_ADMINISTER to tell the client its the owner of the file */
+    GetStatus(targetptr, OutFidStatus, rights | PRSFS_ADMINISTER, anyrights, parentptr);
     GetStatus(parentptr, OutDirStatus, rights, anyrights, 0);
 
     /* convert the write lock to a read lock before breaking callbacks */
@@ -3548,7 +3736,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_CreateFile:
     /* Update and store volume/vnode and parent vnodes back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_CreateFile returns %d\n", errorCode));
     return errorCode;
@@ -3565,6 +3753,8 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -3575,11 +3765,15 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_CREATEFILE]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    memset(OutFid, 0, sizeof(struct AFSFid));
+
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_CreateFile;
 
     code =
@@ -3587,12 +3781,15 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
                         OutDirStatus, CallBack, Sync);
 
   Bad_CreateFile:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -3602,11 +3799,13 @@ SRXAFS_CreateFile(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, CreateFileEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, CreateFileEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name, AUD_FID, OutFid, AUD_END);
     return code;
 
 }                              /*SRXAFS_CreateFile */
@@ -3628,8 +3827,8 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     Vnode *newfileptr = 0;     /* vnode of the file to delete */
     Vnode *testvptr = 0;       /* used in directory tree walk */
     Vnode *parent = 0;         /* parent for use in SetAccessList */
-    int errorCode = 0;         /* error code */
-    int fileCode = 0;          /* used when writing Vnodes */
+    Error errorCode = 0;               /* error code */
+    Error fileCode = 0;                /* used when writing Vnodes */
     VnodeId testnode;          /* used in directory tree walk */
     AFSFid fileFid;            /* Fid of file to move */
     AFSFid newFileFid;         /* Fid of new file */
@@ -3638,7 +3837,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
     DirHandle filedir;         /* Handle for dir package I/O */
     DirHandle newfiledir;      /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     afs_int32 newrights;       /* rights for this user */
     afs_int32 newanyrights;    /* rights for any user */
@@ -3655,14 +3854,16 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_Rename %s    to %s,  Fid = %u.%u.%u to %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_Rename %s    to %s,  Fid = %u.%u.%u to %u.%u.%u, Host %s:%d, Id %d\n",
             OldName, NewName, OldDirFid->Volume, OldDirFid->Vnode,
             OldDirFid->Unique, NewDirFid->Volume, NewDirFid->Vnode,
-            NewDirFid->Unique, inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.Rename++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (!FileNameOK(NewName)) {
+            NewDirFid->Unique, inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.Rename++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (!FileNameOK(NewName)) {
        errorCode = EINVAL;
        goto Bad_Rename;
     }
@@ -3732,13 +3933,13 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
      */
     if (oldvptr->disk.cloned) {
        ViceLog(25, ("Rename : calling CopyOnWrite on  old dir\n"));
-       if ((errorCode = CopyOnWrite(oldvptr, volptr)))
+       if ((errorCode = CopyOnWrite(oldvptr, volptr, 0, MAXFSIZE)))
            goto Bad_Rename;
     }
     SetDirHandle(&olddir, oldvptr);
     if (newvptr->disk.cloned) {
        ViceLog(25, ("Rename : calling CopyOnWrite on  new dir\n"));
-       if ((errorCode = CopyOnWrite(newvptr, volptr)))
+       if ((errorCode = CopyOnWrite(newvptr, volptr, 0, MAXFSIZE)))
            goto Bad_Rename;
     }
 
@@ -3847,7 +4048,13 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
      * directory structure.  This is to prevent removing a subtree alltogether
      */
     if ((oldvptr != newvptr) && (fileptr->disk.type == vDirectory)) {
-       for (testnode = newvptr->disk.parent; testnode != 0;) {
+        afs_int32 forpass = 0, vnum = 0, top = 0;
+       for (testnode = newvptr->disk.parent; testnode != 0; forpass++) {
+           if (testnode > vnum) vnum = testnode;
+           if (forpass > vnum) {
+               errorCode = FSERR_ELOOP;
+               goto Bad_Rename;
+           }
            if (testnode == oldvptr->vnodeNumber) {
                testnode = oldvptr->disk.parent;
                continue;
@@ -3861,10 +4068,19 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
                errorCode = FSERR_ELOOP;
                goto Bad_Rename;
            }
+           if (testnode == 1) top = 1;
            testvptr = VGetVnode(&errorCode, volptr, testnode, READ_LOCK);
            assert(errorCode == 0);
            testnode = testvptr->disk.parent;
            VPutVnode(&errorCode, testvptr);
+           if ((top == 1) && (testnode != 0)) {
+               VTakeOffline(volptr);
+               ViceLog(0,
+                       ("Volume %u now offline, must be salvaged.\n",
+                        volptr->hashid));
+               errorCode = EIO;
+               goto Bad_Rename;
+           }
            assert(errorCode == 0);
        }
     }
@@ -3873,7 +4089,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
      */
     if ((fileptr->disk.type == vDirectory) && (fileptr->disk.cloned)) {
        ViceLog(25, ("Rename : calling CopyOnWrite on  target dir\n"));
-       if ((errorCode = CopyOnWrite(fileptr, volptr)))
+       if ((errorCode = CopyOnWrite(fileptr, volptr, 0, MAXFSIZE)))
            goto Bad_Rename;
     }
 
@@ -3889,7 +4105,8 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
        if (newfileptr->disk.linkCount == 0) {  /* Link count 0 - delete */
            afs_fsize_t newSize;
            VN_GET_LEN(newSize, newfileptr);
-           VAdjustDiskUsage(&errorCode, volptr, -nBlocks(newSize), 0);
+           VAdjustDiskUsage((Error *) & errorCode, volptr,
+                            (afs_sfsize_t) - nBlocks(newSize), 0);
            if (VN_GET_INO(newfileptr)) {
                IH_REALLYCLOSE(newfileptr->handle);
                errorCode =
@@ -4008,10 +4225,8 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName,
        VPutVnode(&fileCode, newfileptr);
        assert(fileCode == 0);
     }
-    (void)PutVolumePackage(fileptr,
-                          (newvptr
-                           && newvptr != oldvptr ? newvptr : 0), oldvptr,
-                          volptr);
+    (void)PutVolumePackage(fileptr, (newvptr && newvptr != oldvptr ? 
+                                    newvptr : 0), oldvptr, volptr, &client);
     FidZap(&olddir);
     FidZap(&newdir);
     FidZap(&filedir);
@@ -4031,6 +4246,8 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4041,11 +4258,13 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_RENAME]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_Rename;
 
     code =
@@ -4053,12 +4272,15 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
                     OutOldDirStatus, OutNewDirStatus, Sync);
 
   Bad_Rename:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -4068,11 +4290,14 @@ SRXAFS_Rename(struct rx_call * acall, struct AFSFid * OldDirFid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, RenameFileEvent, code, AUD_FID, OldDirFid, AUD_STR,
-              OldName, AUD_FID, NewDirFid, AUD_STR, NewName, AUD_END);
+    osi_auditU(acall, RenameFileEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, OldDirFid, AUD_STR, OldName, 
+               AUD_FID, NewDirFid, AUD_STR, NewName, AUD_END);
     return code;
 
 }                              /*SRXAFS_Rename */
@@ -4091,12 +4316,12 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *parentptr = 0;      /* vnode of input Directory */
     Vnode *targetptr = 0;      /* vnode of the new link */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
-    int errorCode = 0;         /* error code */
-    int code = 0;
+    Error errorCode = 0;               /* error code */
+    int len, code = 0;
     DirHandle dir;             /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
-    afs_int32 rights, anyrights, fd;   /* rights for this and any user */
+    struct client *client = 0; /* pointer to client structure */
+    afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
     FdHandle_t *fdP;
@@ -4106,13 +4331,15 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_Symlink %s to %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_Symlink %s to %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             LinkContents, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.Symlink++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (!FileNameOK(Name)) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.Symlink++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (!FileNameOK(Name)) {
        errorCode = EINVAL;
        goto Bad_SymLink;
     }
@@ -4180,9 +4407,18 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Write the contents of the symbolic link name into the target inode */
     fdP = IH_OPEN(targetptr->handle);
-    assert(fdP != NULL);
-    assert(FDH_WRITE(fdP, (char *)LinkContents, strlen((char *)LinkContents))
-          == strlen((char *)LinkContents));
+    if (fdP == NULL) {
+       (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
+                              volptr, &client);
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
+       return EIO;
+    }    
+    len = strlen((char *) LinkContents);
+    code = (len == FDH_WRITE(fdP, (char *) LinkContents, len)) ? 0 : VDISKFULL;
+    if (code) 
+       ViceLog(0, ("SAFSS_Symlink FDH_WRITE failed for len=%d, Fid=%u.%d.%d\n", len, OutFid->Volume, OutFid->Vnode, OutFid->Unique));
     FDH_CLOSE(fdP);
     /*
      * Set up and return modified status for the parent dir and new symlink
@@ -4201,30 +4437,29 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_SymLink:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_Symlink returns %d\n", errorCode));
-    return errorCode;
+    return ( errorCode ? errorCode : code );
 
 }                              /*SAFSS_Symlink */
 
 
 afs_int32
-SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
-              OutFidStatus, OutDirStatus, Sync)
-     struct AFSVolSync *Sync;
-     struct rx_call *acall;    /* Rx call */
-     struct AFSFid *DirFid;    /* Parent dir's fid */
-     char *Name;               /* File name to create */
-     char *LinkContents;       /* Contents of the new created file */
-     struct AFSStoreStatus *InStatus;  /* Input status for the new symbolic link */
-     struct AFSFid *OutFid;    /* Fid for newly created symbolic link */
-     struct AFSFetchStatus *OutFidStatus;      /* Output status for new symbolic link */
-     struct AFSFetchStatus *OutDirStatus;      /* Output status for parent dir */
-
+SRXAFS_Symlink(struct rx_call *acall,  /* Rx call */
+              struct AFSFid *DirFid,   /* Parent dir's fid */
+              char *Name,              /* File name to create */
+              char *LinkContents,      /* Contents of the new created file */
+              struct AFSStoreStatus *InStatus, /* Input status for the new symbolic link */
+              struct AFSFid *OutFid,   /* Fid for newly created symbolic link */
+              struct AFSFetchStatus *OutFidStatus,     /* Output status for new symbolic link */
+              struct AFSFetchStatus *OutDirStatus,     /* Output status for parent dir */
+              struct AFSVolSync *Sync)
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4235,11 +4470,13 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_SYMLINK]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_Symlink;
 
     code =
@@ -4247,12 +4484,15 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
                      OutFidStatus, OutDirStatus, Sync);
 
   Bad_Symlink:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -4262,11 +4502,14 @@ SRXAFS_Symlink(acall, DirFid, Name, LinkContents, InStatus, OutFid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, SymlinkEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, SymlinkEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, 
+               AUD_FID, DirFid, AUD_STR, Name,
+              AUD_FID, OutFid, AUD_STR, LinkContents, AUD_END);
     return code;
 
 }                              /*SRXAFS_Symlink */
@@ -4285,9 +4528,9 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *targetptr = 0;      /* vnode of the new file */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     Volume *volptr = 0;                /* pointer to the volume header */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -4297,14 +4540,16 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_Link %s,     Did = %u.%u.%u, Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_Link %s,     Did = %u.%u.%u, Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             Name, DirFid->Volume, DirFid->Vnode, DirFid->Unique,
             ExistingFid->Volume, ExistingFid->Vnode, ExistingFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.Link++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (DirFid->Volume != ExistingFid->Volume) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.Link++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (DirFid->Volume != ExistingFid->Volume) {
        errorCode = EXDEV;
        goto Bad_Link;
     }
@@ -4353,7 +4598,7 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     }
     if (parentptr->disk.cloned) {
        ViceLog(25, ("Link : calling CopyOnWrite on  target dir\n"));
-       if ((errorCode = CopyOnWrite(parentptr, volptr)))
+       if ((errorCode = CopyOnWrite(parentptr, volptr, 0, MAXFSIZE)))
            goto Bad_Link;      /* disk full error */
     }
 
@@ -4399,7 +4644,7 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_Link:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_Link returns %d\n", errorCode));
     return errorCode;
@@ -4414,6 +4659,8 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4424,11 +4671,13 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_LINK]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_Link;
 
     code =
@@ -4436,12 +4685,15 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
                   OutDirStatus, Sync);
 
   Bad_Link:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -4451,10 +4703,13 @@ SRXAFS_Link(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, LinkEvent, code, AUD_FID, DirFid, AUD_STR, Name,
+    osi_auditU(acall, LinkEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name,
               AUD_FID, ExistingFid, AUD_END);
     return code;
 
@@ -4476,12 +4731,12 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *targetptr = 0;      /* vnode of the new file */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     Volume *volptr = 0;                /* pointer to the volume header */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     struct acl_accessList *newACL;     /* Access list */
     int newACLSize;            /* Size of access list */
     DirHandle dir;             /* Handle for dir package I/O */
     DirHandle parentdir;       /* Handle for dir package I/O */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -4492,13 +4747,15 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_MakeDir %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_MakeDir %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.MakeDir++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (!FileNameOK(Name)) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.MakeDir++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (!FileNameOK(Name)) {
        errorCode = EINVAL;
        goto Bad_MakeDir;
     }
@@ -4564,9 +4821,9 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Actually create the New directory in the directory package */
     SetDirHandle(&dir, targetptr);
-    assert(!(MakeDir(&dir, OutFid, DirFid)));
+    assert(!(MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid)));
     DFlush();
-    VN_SET_LEN(targetptr, Length(&dir));
+    VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir));
 
     /* set up return status */
     GetStatus(targetptr, OutFidStatus, rights, anyrights, parentptr);
@@ -4585,7 +4842,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_MakeDir:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     FidZap(&parentdir);
     ViceLog(2, ("SAFS_MakeDir returns %d\n", errorCode));
@@ -4603,6 +4860,8 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4613,10 +4872,12 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_MAKEDIR]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_MakeDir;
 
     code =
@@ -4624,12 +4885,15 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
                      OutDirStatus, CallBack, Sync);
 
   Bad_MakeDir:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -4639,11 +4903,14 @@ SRXAFS_MakeDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, MakeDirEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, MakeDirEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name,
+              AUD_FID, OutFid, AUD_END);
     return code;
 
 }                              /*SRXAFS_MakeDir */
@@ -4661,10 +4928,10 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
     Vnode *targetptr = 0;      /* file to be deleted */
     AFSFid fileFid;            /* area for Fid from the directory */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     DirHandle dir;             /* Handle for dir package I/O */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     Vnode debugvnode1, debugvnode2;
     struct client *t_client;   /* tmp ptr to client data */
@@ -4675,21 +4942,22 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_RemoveDir    %s,  Did = %u.%u.%u, Host %s, Id %d\n", Name,
+           ("SAFS_RemoveDir    %s,  Did = %u.%u.%u, Host %s:%d, Id %d\n", Name,
             DirFid->Volume, DirFid->Vnode, DirFid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.RemoveDir++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get the vnode and volume for the parent dir along with the caller's
-        * rights to it
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, DirFid, &volptr, &parentptr, MustBeDIR,
-                             &parentwhentargetnotdir, &client, WRITE_LOCK,
-                             &rights, &anyrights))) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.RemoveDir++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get the vnode and volume for the parent dir along with the caller's
+     * rights to it
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, DirFid, &volptr, &parentptr, MustBeDIR,
+                         &parentwhentargetnotdir, &client, WRITE_LOCK,
+                         &rights, &anyrights))) {
        goto Bad_RemoveDir;
     }
     debugvnode1 = *parentptr;
@@ -4740,7 +5008,7 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name,
   Bad_RemoveDir:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, parentptr,
-                          volptr);
+                          volptr, &client);
     FidZap(&dir);
     ViceLog(2, ("SAFS_RemoveDir        returns %d\n", errorCode));
     return errorCode;
@@ -4755,6 +5023,8 @@ SRXAFS_RemoveDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4765,22 +5035,27 @@ SRXAFS_RemoveDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_REMOVEDIR]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_RemoveDir;
 
     code = SAFSS_RemoveDir(acall, DirFid, Name, OutDirStatus, Sync);
 
   Bad_RemoveDir:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -4790,11 +5065,13 @@ SRXAFS_RemoveDir(struct rx_call * acall, struct AFSFid * DirFid, char *Name,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, RemoveDirEvent, code, AUD_FID, DirFid, AUD_STR, Name,
-              AUD_END);
+    osi_auditU(acall, RemoveDirEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, DirFid, AUD_STR, Name, AUD_END);
     return code;
 
 }                              /*SRXAFS_RemoveDir */
@@ -4810,13 +5087,13 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
 {
     Vnode *targetptr = 0;      /* vnode of input file */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
-    static char *locktype[2] = { "LockRead", "LockWrite" };
+    static char *locktype[4] = { "LockRead", "LockWrite", "LockExtend", "LockRelease" };
     struct rx_connection *tcon = rx_ConnectionOf(acall);
 
     if (type != LockRead && type != LockWrite) {
@@ -4825,21 +5102,22 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
     }
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_SetLock type = %s Fid = %u.%u.%u, Host %s, Id %d\n",
+           ("SAFS_SetLock type = %s Fid = %u.%u.%u, Host %s:%d, Id %d\n",
             locktype[(int)type], Fid->Volume, Fid->Vnode, Fid->Unique,
-            inet_ntoa(logHostAddr), t_client->ViceId));
-    FS_LOCK AFSCallStats.SetLock++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get the vnode and volume for the desired file along with the caller's
-        * rights to it
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
-                             &parentwhentargetnotdir, &client, WRITE_LOCK,
-                             &rights, &anyrights))) {
+            inet_ntoa(logHostAddr), ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.SetLock++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get the vnode and volume for the desired file along with the caller's
+     * rights to it
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
+                         &parentwhentargetnotdir, &client, WRITE_LOCK,
+                         &rights, &anyrights))) {
        goto Bad_SetLock;
     }
 
@@ -4847,12 +5125,12 @@ SAFSS_SetLock(struct rx_call *acall, struct AFSFid *Fid, ViceLockType type,
     SetVolumeSync(Sync, volptr);
 
     /* Handle the particular type of set locking, type */
-    errorCode = HandleLocking(targetptr, rights, type);
+    errorCode = HandleLocking(targetptr, client, rights, type);
 
   Bad_SetLock:
     /* Write the all modified vnodes (parent, new files) and volume back */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
 
     if ((errorCode == VREADONLY) && (type == LockRead))
        errorCode = 0;          /* allow read locks on RO volumes without saving state */
@@ -4868,7 +5146,6 @@ SRXAFS_OldSetLock(struct rx_call * acall, struct AFSFid * Fid,
                  ViceLockType type, struct AFSVolSync * Sync)
 {
     return SRXAFS_SetLock(acall, Fid, type, Sync);
-
 }                              /*SRXAFS_OldSetLock */
 
 
@@ -4878,6 +5155,8 @@ SRXAFS_SetLock(struct rx_call * acall, struct AFSFid * Fid, ViceLockType type,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -4888,22 +5167,27 @@ SRXAFS_SetLock(struct rx_call * acall, struct AFSFid * Fid, ViceLockType type,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_SETLOCK]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_SetLock;
 
     code = SAFSS_SetLock(acall, Fid, type, Sync);
 
   Bad_SetLock:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -4913,13 +5197,14 @@ SRXAFS_SetLock(struct rx_call * acall, struct AFSFid * Fid, ViceLockType type,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, SetLockEvent, code, AUD_FID, Fid, AUD_LONG, type,
-              AUD_END);
+    osi_auditU(acall, SetLockEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, 
+               AUD_FID, Fid, AUD_LONG, type, AUD_END);
     return code;
-
 }                              /*SRXAFS_SetLock */
 
 
@@ -4933,9 +5218,9 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
 {
     Vnode *targetptr = 0;      /* vnode of input file */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -4943,21 +5228,22 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_ExtendLock Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("SAFS_ExtendLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
-    FS_LOCK AFSCallStats.ExtendLock++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get the vnode and volume for the desired file along with the caller's
-        * rights to it
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
-                             &parentwhentargetnotdir, &client, WRITE_LOCK,
-                             &rights, &anyrights))) {
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.ExtendLock++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get the vnode and volume for the desired file along with the caller's
+     * rights to it
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
+                         &parentwhentargetnotdir, &client, WRITE_LOCK,
+                         &rights, &anyrights))) {
        goto Bad_ExtendLock;
     }
 
@@ -4965,12 +5251,12 @@ SAFSS_ExtendLock(struct rx_call *acall, struct AFSFid *Fid,
     SetVolumeSync(Sync, volptr);
 
     /* Handle the actual lock extension */
-    errorCode = HandleLocking(targetptr, rights, LockExtend);
+    errorCode = HandleLocking(targetptr, client, rights, LockExtend);
 
   Bad_ExtendLock:
     /* Put back file's vnode and volume */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
 
     if ((errorCode == VREADONLY))      /* presumably, we already granted this lock */
        errorCode = 0;          /* under our generous policy re RO vols */
@@ -4986,7 +5272,6 @@ SRXAFS_OldExtendLock(struct rx_call * acall, struct AFSFid * Fid,
                     struct AFSVolSync * Sync)
 {
     return SRXAFS_ExtendLock(acall, Fid, Sync);
-
 }                              /*SRXAFS_OldExtendLock */
 
 
@@ -4996,6 +5281,8 @@ SRXAFS_ExtendLock(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5006,22 +5293,27 @@ SRXAFS_ExtendLock(struct rx_call * acall, struct AFSFid * Fid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_EXTENDLOCK]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_ExtendLock;
 
     code = SAFSS_ExtendLock(acall, Fid, Sync);
 
   Bad_ExtendLock:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -5031,10 +5323,13 @@ SRXAFS_ExtendLock(struct rx_call * acall, struct AFSFid * Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, ExtendLockEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, ExtendLockEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_ExtendLock */
@@ -5050,9 +5345,9 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
 {
     Vnode *targetptr = 0;      /* vnode of input file */
     Vnode *parentwhentargetnotdir = 0; /* parent for use in SetAccessList */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client structure */
+    struct client *client = 0; /* pointer to client structure */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     struct client *t_client;   /* tmp ptr to client data */
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
@@ -5060,21 +5355,22 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
 
     /* Get ptr to client data for user Id for logging */
     t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
-    logHostAddr.s_addr = rx_HostOf(rx_PeerOf(tcon));
+    logHostAddr.s_addr = rxr_HostOf(tcon);
     ViceLog(1,
-           ("SAFS_ReleaseLock Fid = %u.%u.%u, Host %s, Id %d\n", Fid->Volume,
+           ("SAFS_ReleaseLock Fid = %u.%u.%u, Host %s:%d, Id %d\n", Fid->Volume,
             Fid->Vnode, Fid->Unique, inet_ntoa(logHostAddr),
-            t_client->ViceId));
-    FS_LOCK AFSCallStats.ReleaseLock++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK
-       /*
-        * Get the vnode and volume for the desired file along with the caller's
-        * rights to it
-        */
-       if ((errorCode =
-            GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
-                             &parentwhentargetnotdir, &client, WRITE_LOCK,
-                             &rights, &anyrights))) {
+            ntohs(rxr_PortOf(tcon)), t_client->ViceId));
+    FS_LOCK;
+    AFSCallStats.ReleaseLock++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    /*
+     * Get the vnode and volume for the desired file along with the caller's
+     * rights to it
+     */
+    if ((errorCode =
+        GetVolumePackage(tcon, Fid, &volptr, &targetptr, DONTCHECK,
+                         &parentwhentargetnotdir, &client, WRITE_LOCK,
+                         &rights, &anyrights))) {
        goto Bad_ReleaseLock;
     }
 
@@ -5082,7 +5378,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
     SetVolumeSync(Sync, volptr);
 
     /* Handle the actual lock release */
-    if ((errorCode = HandleLocking(targetptr, rights, LockRelease)))
+    if ((errorCode = HandleLocking(targetptr, client, rights, LockRelease)))
        goto Bad_ReleaseLock;
 
     /* if no more locks left, a callback would be triggered here */
@@ -5096,7 +5392,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid,
   Bad_ReleaseLock:
     /* Put back file's vnode and volume */
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
 
     if ((errorCode == VREADONLY))      /* presumably, we already granted this lock */
        errorCode = 0;          /* under our generous policy re RO vols */
@@ -5112,7 +5408,6 @@ SRXAFS_OldReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
                      struct AFSVolSync * Sync)
 {
     return SRXAFS_ReleaseLock(acall, Fid, Sync);
-
 }                              /*SRXAFS_OldReleaseLock */
 
 
@@ -5122,6 +5417,8 @@ SRXAFS_ReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5132,22 +5429,27 @@ SRXAFS_ReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_RELEASELOCK]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_ReleaseLock;
 
     code = SAFSS_ReleaseLock(acall, Fid, Sync);
 
   Bad_ReleaseLock:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -5157,10 +5459,13 @@ SRXAFS_ReleaseLock(struct rx_call * acall, struct AFSFid * Fid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, ReleaseLockEvent, code, AUD_FID, Fid, AUD_END);
+    osi_auditU(acall, ReleaseLockEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, 
+               AUD_FID, Fid, AUD_END);
     return code;
 
 }                              /*SRXAFS_ReleaseLock */
@@ -5174,7 +5479,7 @@ SetSystemStats(struct AFSStatistics *stats)
     struct timeval time;
 
     /* this works on all system types */
-    TM_GetTimeOfDay(&time, 0);
+    FT_GetTimeOfDay(&time, 0);
     stats->CurrentTime = time.tv_sec;
 }                              /*SetSystemStats */
 
@@ -5184,7 +5489,8 @@ SetAFSStats(struct AFSStatistics *stats)
     extern afs_int32 StartTime, CurrentConnections;
     int seconds;
 
-    FS_LOCK stats->CurrentMsgNumber = 0;
+    FS_LOCK;
+    stats->CurrentMsgNumber = 0;
     stats->OldestMsgNumber = 0;
     stats->StartTime = StartTime;
     stats->CurrentConnections = CurrentConnections;
@@ -5212,9 +5518,10 @@ SetAFSStats(struct AFSStatistics *stats)
 #else
     stats->ProcessSize = (afs_int32) ((long)sbrk(0) >> 10);
 #endif
-    FS_UNLOCK h_GetWorkStats((int *)&(stats->WorkStations),
-                            (int *)&(stats->ActiveWorkStations), (int *)0,
-                            (afs_int32) (FT_ApproxTime()) - (15 * 60));
+    FS_UNLOCK;
+    h_GetWorkStats((int *)&(stats->WorkStations),
+                  (int *)&(stats->ActiveWorkStations), (int *)0,
+                  (afs_int32) (FT_ApproxTime()) - (15 * 60));
 
 }                              /*SetAFSStats */
 
@@ -5223,13 +5530,13 @@ SetAFSStats(struct AFSStatistics *stats)
 void
 SetVolumeStats(struct AFSStatistics *stats)
 {
-    struct DiskPartition *part;
+    struct DiskPartition64 *part;
     int i = 0;
 
     for (part = DiskPartitionList; part && i < AFS_MSTATDISKS;
         part = part->next) {
-       stats->Disks[i].TotalBlocks = part->totalUsable;
-       stats->Disks[i].BlocksAvailable = part->free;
+       stats->Disks[i].TotalBlocks = RoundInt64ToInt32(part->totalUsable);
+       stats->Disks[i].BlocksAvailable = RoundInt64ToInt32(part->free);
        memset(stats->Disks[i].Name, 0, AFS_DISKNAMESIZE);
        strncpy(stats->Disks[i].Name, part->name, AFS_DISKNAMESIZE);
        i++;
@@ -5244,7 +5551,9 @@ afs_int32
 SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
 {
     afs_int32 code;
-    struct rx_connection *tcon;
+    struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5255,27 +5564,34 @@ SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETSTATISTICS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
        goto Bad_GetStatistics;
 
     ViceLog(1, ("SAFS_GetStatistics Received\n"));
-    FS_LOCK AFSCallStats.GetStatistics++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK memset(Statistics, 0, sizeof(*Statistics));
+    FS_LOCK;
+    AFSCallStats.GetStatistics++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    memset(Statistics, 0, sizeof(*Statistics));
     SetAFSStats((struct AFSStatistics *)Statistics);
     SetVolumeStats((struct AFSStatistics *)Statistics);
     SetSystemStats((struct AFSStatistics *)Statistics);
 
   Bad_GetStatistics:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -5285,11 +5601,124 @@ SRXAFS_GetStatistics(struct rx_call *acall, struct ViceStatistics *Statistics)
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
+    osi_auditU(acall, GetStatisticsEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
     return code;
+}                              /*SRXAFS_GetStatistics */
+
+
+afs_int32
+SRXAFS_GetStatistics64(struct rx_call *acall, afs_int32 statsVersion, ViceStatistics64 *Statistics)
+{
+    extern afs_int32 StartTime, CurrentConnections;
+    int seconds;
+    afs_int32 code;
+    struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
+    struct timeval time;
+#if FS_STATS_DETAILED
+    struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
+    struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
+    struct timeval elapsedTime;        /* Transfer time */
+
+    /*
+     * Set our stats pointer, remember when the RPC operation started, and
+     * tally the operation.
+     */
+    opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETSTATISTICS]);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
+#endif /* FS_STATS_DETAILED */
+
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
+       goto Bad_GetStatistics64;
+
+    ViceLog(1, ("SAFS_GetStatistics64 Received\n"));
+    Statistics->ViceStatistics64_val = 
+       malloc(statsVersion*sizeof(afs_int64));
+    Statistics->ViceStatistics64_len = statsVersion;
+    FS_LOCK;
+    AFSCallStats.GetStatistics++, AFSCallStats.TotalCalls++;
+    Statistics->ViceStatistics64_val[STATS64_STARTTIME] = StartTime;
+    Statistics->ViceStatistics64_val[STATS64_CURRENTCONNECTIONS] =
+       CurrentConnections;
+    Statistics->ViceStatistics64_val[STATS64_TOTALVICECALLS] = 
+       AFSCallStats.TotalCalls;
+    Statistics->ViceStatistics64_val[STATS64_TOTALFETCHES] =
+       AFSCallStats.FetchData + AFSCallStats.FetchACL +
+       AFSCallStats.FetchStatus;
+    Statistics->ViceStatistics64_val[STATS64_FETCHDATAS] = 
+       AFSCallStats.FetchData;
+    Statistics->ViceStatistics64_val[STATS64_FETCHEDBYTES] = 
+       AFSCallStats.TotalFetchedBytes;
+    seconds = AFSCallStats.AccumFetchTime / 1000;
+    if (seconds <= 0)
+        seconds = 1;
+    Statistics->ViceStatistics64_val[STATS64_FETCHDATARATE] = 
+       AFSCallStats.TotalFetchedBytes / seconds;
+    Statistics->ViceStatistics64_val[STATS64_TOTALSTORES] =
+        AFSCallStats.StoreData + AFSCallStats.StoreACL +
+        AFSCallStats.StoreStatus;
+    Statistics->ViceStatistics64_val[STATS64_STOREDATAS] = 
+       AFSCallStats.StoreData;
+    Statistics->ViceStatistics64_val[STATS64_STOREDBYTES] = 
+       AFSCallStats.TotalStoredBytes;
+    seconds = AFSCallStats.AccumStoreTime / 1000;
+    if (seconds <= 0)
+        seconds = 1;
+    Statistics->ViceStatistics64_val[STATS64_STOREDATARATE] = 
+       AFSCallStats.TotalStoredBytes / seconds;
+#ifdef AFS_NT40_ENV
+    Statistics->ViceStatistics64_val[STATS64_PROCESSSIZE] = -1;
+#else
+    Statistics->ViceStatistics64_val[STATS64_PROCESSSIZE] = 
+       (afs_int32) ((long)sbrk(0) >> 10);
+#endif
+    FS_UNLOCK;
+    h_GetWorkStats((int *)&(Statistics->ViceStatistics64_val[STATS64_WORKSTATIONS]),
+                   (int *)&(Statistics->ViceStatistics64_val[STATS64_ACTIVEWORKSTATIONS]), 
+                  (int *)0,
+                   (afs_int32) (FT_ApproxTime()) - (15 * 60));
 
+
+
+    /* this works on all system types */
+    FT_GetTimeOfDay(&time, 0);
+    Statistics->ViceStatistics64_val[STATS64_CURRENTTIME] = time.tv_sec;
+
+  Bad_GetStatistics64:
+    code = CallPostamble(tcon, code, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+
+#if FS_STATS_DETAILED
+    FT_GetTimeOfDay(&opStopTime, 0);
+    if (code == 0) {
+       FS_LOCK;
+       (opP->numSuccesses)++;
+       fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
+       fs_stats_AddTo((opP->sumTime), elapsedTime);
+       fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
+       if (fs_stats_TimeLessThan(elapsedTime, (opP->minTime))) {
+           fs_stats_TimeAssign((opP->minTime), elapsedTime);
+       }
+       if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
+           fs_stats_TimeAssign((opP->maxTime), elapsedTime);
+       }
+       FS_UNLOCK;
+    }
+#endif /* FS_STATS_DETAILED */
+
+    osi_auditU(acall, GetStatisticsEvent, code, 
+               AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
+    return code;
 }                              /*SRXAFS_GetStatistics */
 
 
@@ -5317,6 +5746,8 @@ afs_int32
 SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
 {                              /*SRXAFS_XStatsVersion */
 
+    struct client *t_client = NULL;    /* tmp ptr to client data */
+    struct rx_connection *tcon = rx_ConnectionOf(a_call);
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5327,14 +5758,18 @@ SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_XSTATSVERSION]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     *a_versionP = AFS_XSTAT_VERSION;
 
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
+
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
     fs_stats_AddTo((opP->sumTime), elapsedTime);
     fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -5344,11 +5779,14 @@ SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
     if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
        fs_stats_TimeAssign((opP->maxTime), elapsedTime);
     }
-    FS_LOCK(opP->numSuccesses)++;
-    FS_UNLOCK
+    FS_LOCK;
+    (opP->numSuccesses)++;
+    FS_UNLOCK;
 #endif /* FS_STATS_DETAILED */
-       return (0);
 
+    osi_auditU(a_call, XStatsVersionEvent, 0, 
+               AUD_ID, t_client ? t_client->ViceId : 0, AUD_END);
+    return (0);
 }                              /*SRXAFS_XStatsVersion */
 
 
@@ -5375,7 +5813,7 @@ SRXAFS_XStatsVersion(struct rx_call * a_call, afs_int32 * a_versionP)
 static void
 FillPerfValues(struct afs_PerfStats *a_perfP)
 {                              /*FillPerfValues */
-
+    afs_uint32 hi, lo;
     int dir_Buffers;           /*# buffers in use by dir package */
     int dir_Calls;             /*# read calls in dir package */
     int dir_IOs;               /*# I/O ops in dir package */
@@ -5393,9 +5831,11 @@ FillPerfValues(struct afs_PerfStats *a_perfP)
     a_perfP->vcache_S_Gets = VnodeClassInfo[vSmall].gets;
     a_perfP->vcache_S_Reads = VnodeClassInfo[vSmall].reads;
     a_perfP->vcache_S_Writes = VnodeClassInfo[vSmall].writes;
-    a_perfP->vcache_H_Entries = VolumeCacheSize;
-    a_perfP->vcache_H_Gets = VolumeGets;
-    a_perfP->vcache_H_Replacements = VolumeReplacements;
+    a_perfP->vcache_H_Entries = VStats.hdr_cache_size;
+    SplitInt64(VStats.hdr_gets, hi, lo);
+    a_perfP->vcache_H_Gets = lo;
+    SplitInt64(VStats.hdr_loads, hi, lo);
+    a_perfP->vcache_H_Replacements = lo;
 
     /*
      * Directory section.
@@ -5471,7 +5911,8 @@ FillPerfValues(struct afs_PerfStats *a_perfP)
     a_perfP->host_ClientBlocks = CEBlocks;
 
     a_perfP->sysname_ID = afs_perfstats.sysname_ID;
-
+    a_perfP->rx_nBusies = (afs_int32) rx_stats.nBusies;
+    a_perfP->fs_nBusies = afs_perfstats.fs_nBusies;
 }                              /*FillPerfValues */
 
 
@@ -5521,8 +5962,10 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETXSTATS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     /*
@@ -5625,6 +6068,36 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
 #endif
        break;
 
+    case AFS_XSTATSCOLL_CBSTATS:
+       afs_perfstats.numPerfCalls++;
+
+       dataBytes = sizeof(struct cbcounters);
+       dataBuffP = (afs_int32 *) malloc(dataBytes);
+       {
+           extern struct cbcounters cbstuff;
+           dataBuffP[0]=cbstuff.DeleteFiles;
+           dataBuffP[1]=cbstuff.DeleteCallBacks;
+           dataBuffP[2]=cbstuff.BreakCallBacks;
+           dataBuffP[3]=cbstuff.AddCallBacks;
+           dataBuffP[4]=cbstuff.GotSomeSpaces;
+           dataBuffP[5]=cbstuff.DeleteAllCallBacks;
+           dataBuffP[6]=cbstuff.nFEs;
+           dataBuffP[7]=cbstuff.nCBs;
+           dataBuffP[8]=cbstuff.nblks;
+           dataBuffP[9]=cbstuff.CBsTimedOut;
+           dataBuffP[10]=cbstuff.nbreakers;
+           dataBuffP[11]=cbstuff.GSS1;
+           dataBuffP[12]=cbstuff.GSS2;
+           dataBuffP[13]=cbstuff.GSS3;
+           dataBuffP[14]=cbstuff.GSS4;
+           dataBuffP[15]=cbstuff.GSS5;
+       }
+
+       a_dataP->AFS_CollData_len = dataBytes >> 2;
+       a_dataP->AFS_CollData_val = dataBuffP;
+       break;
+
+
     default:
        /*
         * Illegal collection number.
@@ -5635,9 +6108,10 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
     }                          /*Switch on collection number */
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -5647,7 +6121,8 @@ SRXAFS_GetXStats(struct rx_call *a_call, afs_int32 a_clientVersionNum,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
     return (code);
@@ -5661,8 +6136,9 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
 {
     afs_int32 errorCode = 0;
     register int i;
-    struct client *client;
+    struct client *client = 0;
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5674,8 +6150,10 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
      */
     opP =
        &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GIVEUPCALLBACKS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     if (FidArray)
@@ -5683,8 +6161,10 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
                ("SAFS_GiveUpCallBacks (Noffids=%d)\n",
                 FidArray->AFSCBFids_len));
 
-    FS_LOCK AFSCallStats.GiveUpCallBacks++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    FS_LOCK;
+    AFSCallStats.GiveUpCallBacks++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_GiveUpCallBacks;
 
     if (!FidArray && !CallBackArray) {
@@ -5692,8 +6172,12 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
                ("SAFS_GiveUpAllCallBacks: host=%x\n",
                 (tcon->peer ? tcon->peer->host : 0)));
        errorCode = GetClient(tcon, &client);
-       if (!errorCode)
+       if (!errorCode) {
+           H_LOCK;
            DeleteAllCallBacks_r(client->host, 1);
+           H_UNLOCK;
+           PutClient(&client);
+       }
     } else {
        if (FidArray->AFSCBFids_len < CallBackArray->AFSCBs_len) {
            ViceLog(0,
@@ -5710,16 +6194,18 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
                register struct AFSFid *fid = &(FidArray->AFSCBFids_val[i]);
                DeleteCallBack(client->host, fid);
            }
+           PutClient(&client);
        }
     }
 
   Bad_GiveUpCallBacks:
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -5729,9 +6215,9 @@ common_GiveUpCallBacks(struct rx_call *acall, struct AFSCBFids *FidArray,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
-  out:
     return errorCode;
 
 }                              /*common_GiveUpCallBacks */
@@ -5780,16 +6266,37 @@ SRXAFS_Lookup(struct rx_call * call_p, struct AFSFid * afs_dfid_p,
 afs_int32
 SRXAFS_GetCapabilities(struct rx_call * acall, Capabilities * capabilities)
 {
-    afs_int32 *dataBuffP;
-    afs_int32 *dataP;
+    afs_int32 code;
+    struct rx_connection *tcon;
+    struct host *thost;
+    afs_uint32 *dataBuffP;
     afs_int32 dataBytes;
 
+    FS_LOCK;
+    AFSCallStats.GetCapabilities++, AFSCallStats.TotalCalls++;
+    afs_FullPerfStats.overall.fs_nGetCaps++;
+    FS_UNLOCK;
+    ViceLog(2, ("SAFS_GetCapabilties\n"));
+
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
+       goto Bad_GetCaps;
+
     dataBytes = 1 * sizeof(afs_int32);
-    dataBuffP = (afs_int32 *) malloc(dataBytes);
-    dataBuffP[0] = CAPABILITY_ERRORTRANS;
+    dataBuffP = (afs_uint32 *) malloc(dataBytes);
+    dataBuffP[0] = VICED_CAPABILITY_ERRORTRANS | VICED_CAPABILITY_WRITELOCKACL;
+#if defined(AFS_64BIT_ENV)
+    dataBuffP[0] |= VICED_CAPABILITY_64BITFILES;
+#endif
+    if (saneacls)
+       dataBuffP[0] |= VICED_CAPABILITY_SANEACLS;
+
     capabilities->Capabilities_len = dataBytes / sizeof(afs_int32);
     capabilities->Capabilities_val = dataBuffP;
 
+  Bad_GetCaps:
+    code = CallPostamble(tcon, code, thost);
+
+
     return 0;
 }
 
@@ -5801,13 +6308,14 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
     int i;
     afs_int32 nids, naddrs;
     afs_int32 *vd, *addr;
-    int errorCode = 0;         /* return code to caller */
-    struct client *client;
-    struct rx_connection *tcon = rx_ConnectionOf(acall);
+    Error errorCode = 0;               /* return code to caller */
+    struct client *client = 0;
 
     ViceLog(1, ("SRXAFS_FlushCPS\n"));
-    FS_LOCK AFSCallStats.TotalCalls++;
-    FS_UNLOCK nids = vids->ViceIds_len;        /* # of users in here */
+    FS_LOCK;
+    AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    nids = vids->ViceIds_len;  /* # of users in here */
     naddrs = addrs->IPAddrs_len;       /* # of hosts in here */
     if (nids < 0 || naddrs < 0) {
        errorCode = EINVAL;
@@ -5818,11 +6326,10 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
     for (i = 0; i < nids; i++, vd++) {
        if (!*vd)
            continue;
-       client = h_ID2Client(*vd);      /* returns client locked, or NULL */
+       client = h_ID2Client(*vd);      /* returns write locked and refCounted, or NULL */
        if (!client)
            continue;
 
-       BoostSharedLock(&client->lock);
        client->prfail = 2;     /* Means re-eval client's cps */
 #ifdef notdef
        if (client->tcon) {
@@ -5835,6 +6342,7 @@ SRXAFS_FlushCPS(struct rx_call * acall, struct ViceIds * vids,
            client->CPS.prlist_len = 0;
        }
        ReleaseWriteLock(&client->lock);
+       PutClient(&client);
     }
 
     addr = addrs->IPAddrs_val;
@@ -5977,6 +6485,7 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -5987,14 +6496,18 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETVOLUMEINFO]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_GetVolumeInfo;
 
-    FS_LOCK AFSCallStats.GetVolumeInfo++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK code = TryLocalVLServer(avolid, avolinfo);
+    FS_LOCK;
+    AFSCallStats.GetVolumeInfo++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    code = TryLocalVLServer(avolid, avolinfo);
     ViceLog(1,
            ("SAFS_GetVolumeInfo returns %d, Volume %u, type %x, servers %x %x %x %x...\n",
             code, avolinfo->Vid, avolinfo->Type, avolinfo->Server0,
@@ -6002,12 +6515,13 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
     avolinfo->Type4 = 0xabcd9999;      /* tell us to try new vldb */
 
   Bad_GetVolumeInfo:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -6017,7 +6531,8 @@ SRXAFS_GetVolumeInfo(struct rx_call * acall, char *avolid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
     return code;
@@ -6032,12 +6547,14 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 {
     Vnode *targetptr = 0;      /* vnode of the new file */
     Vnode *parentwhentargetnotdir = 0; /* vnode of parent */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client entry */
+    struct client *client = 0; /* pointer to client entry */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     AFSFid dummyFid;
     struct rx_connection *tcon;
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6049,16 +6566,20 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
      */
     opP =
        &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETVOLUMESTATUS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1, ("SAFS_GetVolumeStatus for volume %u\n", avolid));
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_GetVolumeStatus;
 
-    FS_LOCK AFSCallStats.GetVolumeStatus++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (avolid == 0) {
+    FS_LOCK;
+    AFSCallStats.GetVolumeStatus++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (avolid == 0) {
        errorCode = EINVAL;
        goto Bad_GetVolumeStatus;
     }
@@ -6079,7 +6600,7 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 
   Bad_GetVolumeStatus:
     (void)PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0,
-                          volptr);
+                          volptr, &client);
     ViceLog(2, ("SAFS_GetVolumeStatus returns %d\n", errorCode));
     /* next is to guarantee out strings exist for stub */
     if (*Name == 0) {
@@ -6094,12 +6615,15 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        *OfflineMsg = (char *)malloc(1);
        **OfflineMsg = 0;
     }
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -6109,8 +6633,13 @@ SRXAFS_GetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
+
+    osi_auditU(acall, GetVolumeStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_LONG, avolid, AUD_STR, *Name, AUD_END);
     return (errorCode);
 
 }                              /*SRXAFS_GetVolumeStatus */
@@ -6123,12 +6652,14 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 {
     Vnode *targetptr = 0;      /* vnode of the new file */
     Vnode *parentwhentargetnotdir = 0; /* vnode of parent */
-    int errorCode = 0;         /* error code */
+    Error errorCode = 0;               /* error code */
     Volume *volptr = 0;                /* pointer to the volume header */
-    struct client *client;     /* pointer to client entry */
+    struct client *client = 0; /* pointer to client entry */
     afs_int32 rights, anyrights;       /* rights for this and any user */
     AFSFid dummyFid;
     struct rx_connection *tcon = rx_ConnectionOf(acall);
+    struct host *thost;
+    struct client *t_client = NULL;    /* tmp ptr to client data */
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6140,16 +6671,20 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
      */
     opP =
        &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_SETVOLUMESTATUS]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     ViceLog(1, ("SAFS_SetVolumeStatus for volume %u\n", avolid));
-    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_SetVolumeStatus;
 
-    FS_LOCK AFSCallStats.SetVolumeStatus++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK if (avolid == 0) {
+    FS_LOCK;
+    AFSCallStats.SetVolumeStatus++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    if (avolid == 0) {
        errorCode = EINVAL;
        goto Bad_SetVolumeStatus;
     }
@@ -6175,14 +6710,18 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        RXUpdate_VolumeStatus(volptr, StoreVolStatus, Name, OfflineMsg, Motd);
 
   Bad_SetVolumeStatus:
-    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, volptr);
+    PutVolumePackage(parentwhentargetnotdir, targetptr, (Vnode *) 0, 
+                    volptr, &client);
     ViceLog(2, ("SAFS_SetVolumeStatus returns %d\n", errorCode));
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
+
+    t_client = (struct client *)rx_GetSpecific(tcon, rxcon_client_key);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -6192,13 +6731,14 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
-    osi_auditU(acall, SetVolumeStatusEvent, errorCode, AUD_LONG, avolid,
-              AUD_STR, Name, AUD_END);
+    osi_auditU(acall, SetVolumeStatusEvent, errorCode, 
+               AUD_ID, t_client ? t_client->ViceId : 0,
+               AUD_LONG, avolid, AUD_STR, Name, AUD_END);
     return (errorCode);
-
 }                              /*SRXAFS_SetVolumeStatus */
 
 #define        DEFAULTVOLUME   "root.afs"
@@ -6206,33 +6746,43 @@ SRXAFS_SetVolumeStatus(struct rx_call * acall, afs_int32 avolid,
 afs_int32
 SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
 {
+#ifdef notdef
     int fd;
     int len;
     char *temp;
-    int errorCode = 0;         /* error code */
     struct rx_connection *tcon;
+    struct host *thost;
+    Error errorCode = 0;
+#endif
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
-    struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
+    struct timeval opStartTime;        /* Start time for RPC op */
+#ifdef notdef
+    struct timeval opStopTime;
     struct timeval elapsedTime;        /* Transfer time */
+#endif
 
     /*
      * Set our stats pointer, remember when the RPC operation started, and
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETROOTVOLUME]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
     return FSERR_EOPNOTSUPP;
 
 #ifdef notdef
-    if (errorCode = CallPreamble(acall, ACTIVECALL, &tcon))
+    if (errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &thost))
        goto Bad_GetRootVolume;
-    FS_LOCK AFSCallStats.GetRootVolume++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK temp = malloc(256);
-    fd = open(AFSDIR_SERVER_ROOTVOL_FILEPATH, O_RDONLY, 0666);
+    FS_LOCK;
+    AFSCallStats.GetRootVolume++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    temp = malloc(256);
+    fd = afs_open(AFSDIR_SERVER_ROOTVOL_FILEPATH, O_RDONLY, 0666);
     if (fd <= 0)
        strcpy(temp, DEFAULTVOLUME);
     else {
@@ -6255,12 +6805,13 @@ SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
     *VolumeName = temp;                /* freed by rx server-side stub */
 
   Bad_GetRootVolume:
-    errorCode = CallPostamble(tcon, errorCode);
+    errorCode = CallPostamble(tcon, errorCode, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (errorCode == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -6270,7 +6821,8 @@ SRXAFS_GetRootVolume(struct rx_call * acall, char **VolumeName)
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
     return (errorCode);
@@ -6286,6 +6838,7 @@ SRXAFS_CheckToken(struct rx_call * acall, afs_int32 AfsId,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
     struct timeval opStartTime, opStopTime;    /* Start/stop times for RPC op */
@@ -6296,22 +6849,25 @@ SRXAFS_CheckToken(struct rx_call * acall, afs_int32 AfsId,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_CHECKTOKEN]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, ACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, ACTIVECALL, &tcon, &thost)))
        goto Bad_CheckToken;
 
     code = FSERR_ECONNREFUSED;
 
   Bad_CheckToken:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
@@ -6321,7 +6877,8 @@ SRXAFS_CheckToken(struct rx_call * acall, afs_int32 AfsId,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
     return code;
@@ -6334,6 +6891,7 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
 {
     afs_int32 code;
     struct rx_connection *tcon;
+    struct host *thost;
     struct timeval tpl;
 #if FS_STATS_DETAILED
     struct fs_stats_opTimingData *opP; /* Ptr to this op's timing struct */
@@ -6345,28 +6903,33 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
      * tally the operation.
      */
     opP = &(afs_FullPerfStats.det.rpcOpTimes[FS_STATS_RPCIDX_GETTIME]);
-    FS_LOCK(opP->numOps)++;
-    FS_UNLOCK TM_GetTimeOfDay(&opStartTime, 0);
+    FS_LOCK;
+    (opP->numOps)++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&opStartTime, 0);
 #endif /* FS_STATS_DETAILED */
 
-    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon)))
+    if ((code = CallPreamble(acall, NOTACTIVECALL, &tcon, &thost)))
        goto Bad_GetTime;
 
-    FS_LOCK AFSCallStats.GetTime++, AFSCallStats.TotalCalls++;
-    FS_UNLOCK TM_GetTimeOfDay(&tpl, 0);
+    FS_LOCK;
+    AFSCallStats.GetTime++, AFSCallStats.TotalCalls++;
+    FS_UNLOCK;
+    FT_GetTimeOfDay(&tpl, 0);
     *Seconds = tpl.tv_sec;
     *USeconds = tpl.tv_usec;
 
     ViceLog(2, ("SAFS_GetTime returns %u, %u\n", *Seconds, *USeconds));
 
   Bad_GetTime:
-    code = CallPostamble(tcon, code);
+    code = CallPostamble(tcon, code, thost);
 
 #if FS_STATS_DETAILED
-    TM_GetTimeOfDay(&opStopTime, 0);
+    FT_GetTimeOfDay(&opStopTime, 0);
     fs_stats_GetDiff(elapsedTime, opStartTime, opStopTime);
     if (code == 0) {
-       FS_LOCK(opP->numSuccesses)++;
+       FS_LOCK;
+       (opP->numSuccesses)++;
        fs_stats_AddTo((opP->sumTime), elapsedTime);
        fs_stats_SquareAddTo((opP->sqrTime), elapsedTime);
        if (fs_stats_TimeLessThan(elapsedTime, (opP->minTime))) {
@@ -6375,7 +6938,8 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
        if (fs_stats_TimeGreaterThan(elapsedTime, (opP->maxTime))) {
            fs_stats_TimeAssign((opP->maxTime), elapsedTime);
        }
-    FS_UNLOCK}
+       FS_UNLOCK;
+    }
 #endif /* FS_STATS_DETAILED */
 
     return code;
@@ -6405,16 +6969,16 @@ SRXAFS_GetTime(struct rx_call * acall, afs_uint32 * Seconds,
 
 afs_int32
 FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
-                 register struct rx_call * Call, afs_int32 Pos,
-                 afs_int32 Len, afs_int32 Int64Mode,
+                 register struct rx_call * Call, afs_sfsize_t Pos,
+                 afs_sfsize_t Len, afs_int32 Int64Mode,
 #if FS_STATS_DETAILED
-                 afs_int32 * a_bytesToFetchP, afs_int32 * a_bytesFetchedP
+                 afs_sfsize_t * a_bytesToFetchP,
+                 afs_sfsize_t * a_bytesFetchedP
 #endif                         /* FS_STATS_DETAILED */
     )
 {
     struct timeval StartTime, StopTime;        /* used to calculate file  transfer rates */
-    int errorCode = 0;         /* Returned error code to caller */
-    int code;
+    Error errorCode = 0;               /* Returned error code to caller */
     IHandle_t *ihP;
     FdHandle_t *fdP;
 #ifdef AFS_NT40_ENV
@@ -6423,12 +6987,8 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     struct iovec tiov[RX_MAXIOVECS];
     int tnio;
 #endif /* AFS_NT40_ENV */
-    afs_int32 tlen;
+    afs_sfsize_t tlen;
     afs_int32 optSize;
-    struct stat tstat;
-#ifdef AFS_AIX_ENV
-    struct statfs tstatfs;
-#endif
 
 #if FS_STATS_DETAILED
     /*
@@ -6438,38 +6998,61 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     (*a_bytesFetchedP) = 0;
 #endif /* FS_STATS_DETAILED */
 
+
+    ViceLog(25,
+           ("FetchData_RXStyle: Pos %llu, Len %llu\n", (afs_uintmax_t) Pos,
+            (afs_uintmax_t) Len));
+
     if (!VN_GET_INO(targetptr)) {
+       afs_int32 zero = htonl(0);
        /*
         * This is used for newly created files; we simply send 0 bytes
         * back to make the cache manager happy...
         */
-       tlen = htonl(0);
        if (Int64Mode)
-           rx_Write(Call, (char *)&tlen, sizeof(afs_int32));   /* send 0-length  */
-       rx_Write(Call, (char *)&tlen, sizeof(afs_int32));       /* send 0-length  */
+           rx_Write(Call, (char *)&zero, sizeof(afs_int32));   /* send 0-length  */
+       rx_Write(Call, (char *)&zero, sizeof(afs_int32));       /* send 0-length  */
        return (0);
     }
-    TM_GetTimeOfDay(&StartTime, 0);
+    FT_GetTimeOfDay(&StartTime, 0);
     ihP = targetptr->handle;
     fdP = IH_OPEN(ihP);
-    if (fdP == NULL)
+    if (fdP == NULL) {
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
        return EIO;
+    }
     optSize = sendBufSize;
     tlen = FDH_SIZE(fdP);
+    ViceLog(25,
+           ("FetchData_RXStyle: file size %llu\n", (afs_uintmax_t) tlen));
     if (tlen < 0) {
        FDH_CLOSE(fdP);
+       VTakeOffline(volptr);
+       ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                   volptr->hashid));
        return EIO;
     }
+    if (Pos > tlen) {
+       Len = 0;
+    }
+
+    if (Pos + Len > tlen) /* get length we should send */
+       Len = ((tlen - Pos) < 0) ? 0 : tlen - Pos;
 
-    if (Pos + Len > tlen)
-       Len = tlen - Pos;       /* get length we should send */
     (void)FDH_SEEK(fdP, Pos, 0);
-    tlen = htonl(Len);
-    if (Int64Mode) {
-       afs_int32 zero = 0;
-       rx_Write(Call, (char *)&zero, sizeof(afs_int32));       /* High order bits */
+    {
+       afs_int32 high, low;
+       SplitOffsetOrSize(Len, high, low);
+       assert(Int64Mode || (Len >= 0 && high == 0) || Len < 0);
+       if (Int64Mode) {
+           high = htonl(high);
+           rx_Write(Call, (char *)&high, sizeof(afs_int32));   /* High order bits */
+       }
+       low = htonl(low);
+       rx_Write(Call, (char *)&low, sizeof(afs_int32));        /* send length on fetch */
     }
-    rx_Write(Call, (char *)&tlen, sizeof(afs_int32));  /* send length on fetch */
 #if FS_STATS_DETAILED
     (*a_bytesToFetchP) = Len;
 #endif /* FS_STATS_DETAILED */
@@ -6477,31 +7060,38 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
     tbuffer = AllocSendBuffer();
 #endif /* AFS_NT40_ENV */
     while (Len > 0) {
+       int wlen;
        if (Len > optSize)
-           tlen = optSize;
+           wlen = optSize;
        else
-           tlen = Len;
+           wlen = (int)Len;
 #ifdef AFS_NT40_ENV
-       errorCode = FDH_READ(fdP, tbuffer, tlen);
-       if (errorCode != tlen) {
+       errorCode = FDH_READ(fdP, tbuffer, wlen);
+       if (errorCode != wlen) {
            FDH_CLOSE(fdP);
            FreeSendBuffer((struct afs_buffer *)tbuffer);
+           VTakeOffline(volptr);
+           ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                       volptr->hashid));
            return EIO;
        }
-       errorCode = rx_Write(Call, tbuffer, tlen);
+       errorCode = rx_Write(Call, tbuffer, wlen);
 #else /* AFS_NT40_ENV */
-       errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, tlen);
+       errorCode = rx_WritevAlloc(Call, tiov, &tnio, RX_MAXIOVECS, wlen);
        if (errorCode <= 0) {
            FDH_CLOSE(fdP);
            return EIO;
        }
-       tlen = errorCode;
+       wlen = errorCode;
        errorCode = FDH_READV(fdP, tiov, tnio);
-       if (errorCode != tlen) {
+       if (errorCode != wlen) {
            FDH_CLOSE(fdP);
+           VTakeOffline(volptr);
+           ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                       volptr->hashid));
            return EIO;
        }
-       errorCode = rx_Writev(Call, tiov, tnio, tlen);
+       errorCode = rx_Writev(Call, tiov, tnio, wlen);
 #endif /* AFS_NT40_ENV */
 #if FS_STATS_DETAILED
        /*
@@ -6510,24 +7100,25 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
         */
        (*a_bytesFetchedP) += errorCode;
 #endif /* FS_STATS_DETAILED */
-       if (errorCode != tlen) {
+       if (errorCode != wlen) {
            FDH_CLOSE(fdP);
 #ifdef AFS_NT40_ENV
            FreeSendBuffer((struct afs_buffer *)tbuffer);
 #endif /* AFS_NT40_ENV */
            return -31;
        }
-       Len -= tlen;
+       Len -= wlen;
     }
 #ifdef AFS_NT40_ENV
     FreeSendBuffer((struct afs_buffer *)tbuffer);
 #endif /* AFS_NT40_ENV */
     FDH_CLOSE(fdP);
-    TM_GetTimeOfDay(&StopTime, 0);
+    FT_GetTimeOfDay(&StopTime, 0);
 
     /* Adjust all Fetch Data related stats */
-    FS_LOCK if (AFSCallStats.TotalFetchedBytes > 2000000000)   /* Reset if over 2 billion */
-         AFSCallStats.TotalFetchedBytes = AFSCallStats.AccumFetchTime = 0;
+    FS_LOCK;
+    if (AFSCallStats.TotalFetchedBytes > 2000000000)   /* Reset if over 2 billion */
+       AFSCallStats.TotalFetchedBytes = AFSCallStats.AccumFetchTime = 0;
     AFSCallStats.AccumFetchTime +=
        ((StopTime.tv_sec - StartTime.tv_sec) * 1000) +
        ((StopTime.tv_usec - StartTime.tv_usec) / 1000);
@@ -6545,12 +7136,14 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr,
        else
            AFSCallStats.FetchSize5++;
     }
-    FS_UNLOCK return (0);
+    FS_UNLOCK;
+    return (0);
 
 }                              /*FetchData_RXStyle */
 
 static int
-GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
+GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc,
+                   afs_sfsize_t * size)
 {
 #ifdef AFS_NAMEI_ENV
     FdHandle_t *lhp;
@@ -6568,9 +7161,9 @@ GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
     *size = OS_SIZE(fdP->fd_fd);
     return (*size == -1) ? -1 : 0;
 #else
-    struct stat status;
+    struct afs_stat status;
 
-    if (fstat(fdP->fd_fd, &status) < 0) {
+    if (afs_fstat(fdP->fd_fd, &status) < 0) {
        return -1;
     }
 
@@ -6602,32 +7195,33 @@ GetLinkCountAndSize(Volume * vp, FdHandle_t * fdP, int *lc, int *size)
 afs_int32
 StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
                  struct client * client, register struct rx_call * Call,
-                 afs_uint32 Pos, afs_uint32 Length, afs_uint32 FileLength,
+                 afs_fsize_t Pos, afs_fsize_t Length, afs_fsize_t FileLength,
                  int sync,
 #if FS_STATS_DETAILED
-                 afs_int32 * a_bytesToStoreP, afs_int32 * a_bytesStoredP
+                 afs_sfsize_t * a_bytesToStoreP,
+                 afs_sfsize_t * a_bytesStoredP
 #endif                         /* FS_STATS_DETAILED */
     )
 {
-    int bytesTransfered;       /* number of bytes actually transfered */
+    afs_sfsize_t bytesTransfered;      /* number of bytes actually transfered */
     struct timeval StartTime, StopTime;        /* Used to measure how long the store takes */
-    int errorCode = 0;         /* Returned error code to caller */
+    Error errorCode = 0;               /* Returned error code to caller */
 #ifdef AFS_NT40_ENV
     register char *tbuffer;    /* data copying buffer */
 #else /* AFS_NT40_ENV */
     struct iovec tiov[RX_MAXIOVECS];   /* no data copying with iovec */
     int tnio;                  /* temp for iovec size */
 #endif /* AFS_NT40_ENV */
-    int tlen;                  /* temp for xfr length */
+    afs_sfsize_t tlen;         /* temp for xfr length */
     Inode tinode;              /* inode for I/O */
     afs_int32 optSize;         /* optimal transfer size */
-    int DataLength;            /* size of inode */
-    afs_int32 TruncatedLength; /* size after ftruncate */
-    afs_uint32 NewLength;      /* size after this store completes */
-    afs_int32 adjustSize;      /* bytes to call VAdjust... with */
-    int linkCount;             /* link count on inode */
-    int code;
-    FdHandle_t *fdP;
+    afs_sfsize_t DataLength = 0;       /* size of inode */
+    afs_sfsize_t TruncatedLength;      /* size after ftruncate */
+    afs_fsize_t NewLength;     /* size after this store completes */
+    afs_sfsize_t adjustSize;   /* bytes to call VAdjust... with */
+    int linkCount = 0;         /* link count on inode */
+    afs_fsize_t CoW_off, CoW_len;
+    FdHandle_t *fdP, *origfdP = NULL;
     struct in_addr logHostAddr;        /* host ip holder for inet_ntoa */
 
 #if FS_STATS_DETAILED
@@ -6646,12 +7240,12 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
 
     if (Pos == -1 || VN_GET_INO(targetptr) == 0) {
        /* the inode should have been created in Alloc_NewVnode */
-       logHostAddr.s_addr = rx_HostOf(rx_PeerOf(rx_ConnectionOf(Call)));
+       logHostAddr.s_addr = rxr_HostOf(rx_ConnectionOf(Call));
        ViceLog(0,
-               ("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %d Host %s\n",
+               ("StoreData_RXStyle : Inode non-existent Fid = %u.%u.%u, inode = %llu, Pos %llu Host %s:%d\n",
                 Fid->Volume, Fid->Vnode, Fid->Unique,
-                (afs_uintmax_t) VN_GET_INO(targetptr), Pos,
-                inet_ntoa(logHostAddr)));
+                (afs_uintmax_t) VN_GET_INO(targetptr), (afs_uintmax_t) Pos,
+                inet_ntoa(logHostAddr), ntohs(rxr_PortOf(rx_ConnectionOf(Call)))));
        return ENOENT;          /* is this proper error code? */
     } else {
        /*
@@ -6667,6 +7261,9 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
            return ENOENT;
        if (GetLinkCountAndSize(volptr, fdP, &linkCount, &DataLength) < 0) {
            FDH_CLOSE(fdP);
+           VTakeOffline(volptr);
+           ViceLog(0, ("Volume %u now offline, must be salvaged.\n",
+                       volptr->hashid));
            return EIO;
        }
 
@@ -6683,20 +7280,32 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
             * mechanisms (i.e. copy on write overhead.) Also the right size
             * of the disk will be recorded...
             */
-           FDH_CLOSE(fdP);
+           origfdP = fdP;
            VN_GET_LEN(size, targetptr);
            volptr->partition->flags &= ~PART_DONTUPDATE;
            VSetPartitionDiskUsage(volptr->partition);
            volptr->partition->flags |= PART_DONTUPDATE;
            if ((errorCode = VDiskUsage(volptr, nBlocks(size)))) {
                volptr->partition->flags &= ~PART_DONTUPDATE;
+               FDH_CLOSE(origfdP);
                return (errorCode);
            }
 
-           ViceLog(25, ("StoreData : calling CopyOnWrite on  target dir\n"));
-           if ((errorCode = CopyOnWrite(targetptr, volptr))) {
+           CoW_len = (FileLength >= (Length + Pos)) ? FileLength - Length : Pos;
+           CopyOnWrite_calls++;
+           if (CoW_len == 0) CopyOnWrite_size0++;
+           if (Pos == 0) CopyOnWrite_off0++;
+           if (CoW_len > CopyOnWrite_maxsize) CopyOnWrite_maxsize = CoW_len;
+
+           ViceLog(1, ("StoreData : calling CopyOnWrite on vnode %u.%u (%s) "
+                       "off 0x0 size 0x%llx\n",
+                       afs_printable_VolumeId_u(V_id(volptr)),
+                       afs_printable_VnodeId_u(targetptr->vnodeNumber),
+                       V_name(volptr), Pos));
+           if ((errorCode = CopyOnWrite(targetptr, volptr, 0, Pos))) {
                ViceLog(25, ("StoreData : CopyOnWrite failed\n"));
                volptr->partition->flags &= ~PART_DONTUPDATE;
+               FDH_CLOSE(origfdP);
                return (errorCode);
            }
            volptr->partition->flags &= ~PART_DONTUPDATE;
@@ -6705,12 +7314,18 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
            if (fdP == NULL) {
                ViceLog(25,
                        ("StoreData : Reopen after CopyOnWrite failed\n"));
+               FDH_CLOSE(origfdP);
                return ENOENT;
            }
        }
        tinode = VN_GET_INO(targetptr);
     }
-    assert(VALID_INO(tinode));
+    if (!VALID_INO(tinode)) {
+       VTakeOffline(volptr);
+       ViceLog(0,("Volume %u now offline, must be salvaged.\n",
+                  volptr->hashid));
+       return EIO;
+    }
 
     /* compute new file length */
     NewLength = DataLength;
@@ -6731,6 +7346,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
         AdjustDiskUsage(volptr, adjustSize,
                         adjustSize - SpareComp(volptr)))) {
        FDH_CLOSE(fdP);
+       if (origfdP) FDH_CLOSE(origfdP);
        return (errorCode);
     }
 
@@ -6738,9 +7354,13 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
     /* this bit means that the locks are set and protections are OK */
     rx_SetLocalStatus(Call, 1);
 
-    TM_GetTimeOfDay(&StartTime, 0);
+    FT_GetTimeOfDay(&StartTime, 0);
 
     optSize = sendBufSize;
+    ViceLog(25,
+           ("StoreData_RXStyle: Pos %llu, DataLength %llu, FileLength %llu, Length %llu\n",
+            (afs_uintmax_t) Pos, (afs_uintmax_t) DataLength,
+            (afs_uintmax_t) FileLength, (afs_uintmax_t) Length));
 
     /* truncate the file iff it needs it (ftruncate is slow even when its a noop) */
     if (FileLength < DataLength)
@@ -6772,36 +7392,39 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        (*a_bytesToStoreP) = Length;
 #endif /* FS_STATS_DETAILED */
        while (1) {
+           int rlen;
            if (bytesTransfered >= Length) {
                errorCode = 0;
                break;
            }
            tlen = Length - bytesTransfered;    /* how much more to do */
            if (tlen > optSize)
-               tlen = optSize; /* bound by buffer size */
+               rlen = optSize; /* bound by buffer size */
+           else
+               rlen = (int)tlen;
 #ifdef AFS_NT40_ENV
-           errorCode = rx_Read(Call, tbuffer, tlen);
+           errorCode = rx_Read(Call, tbuffer, rlen);
 #else /* AFS_NT40_ENV */
-           errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, tlen);
+           errorCode = rx_Readv(Call, tiov, &tnio, RX_MAXIOVECS, rlen);
 #endif /* AFS_NT40_ENV */
-#if FS_STATS_DETAILED
-           (*a_bytesStoredP) += errorCode;
-#endif /* FS_STATS_DETAILED */
            if (errorCode <= 0) {
                errorCode = -32;
                break;
            }
-           tlen = errorCode;
+#if FS_STATS_DETAILED
+           (*a_bytesStoredP) += errorCode;
+#endif /* FS_STATS_DETAILED */
+           rlen = errorCode;
 #ifdef AFS_NT40_ENV
-           errorCode = FDH_WRITE(fdP, tbuffer, tlen);
+           errorCode = FDH_WRITE(fdP, tbuffer, rlen);
 #else /* AFS_NT40_ENV */
            errorCode = FDH_WRITEV(fdP, tiov, tnio);
 #endif /* AFS_NT40_ENV */
-           if (errorCode != tlen) {
+           if (errorCode != rlen) {
                errorCode = VDISKFULL;
                break;
            }
-           bytesTransfered += tlen;
+           bytesTransfered += rlen;
        }
     }
   done:
@@ -6812,28 +7435,44 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        FDH_SYNC(fdP);
     }
     if (errorCode) {
-       afs_fsize_t nfSize = FDH_SIZE(fdP);
+       afs_fsize_t nfSize = (afs_fsize_t) FDH_SIZE(fdP);
        /* something went wrong: adjust size and return */
        VN_SET_LEN(targetptr, nfSize);  /* set new file size. */
        /* changed_newTime is tested in StoreData to detemine if we
         * need to update the target vnode.
         */
        targetptr->changed_newTime = 1;
+       if (origfdP && (bytesTransfered < Length))      /* Need to "finish" CopyOnWrite still */
+           CopyOnWrite2(origfdP, fdP, Pos + bytesTransfered, NewLength - Pos - bytesTransfered);
+       if (origfdP) FDH_CLOSE(origfdP);
        FDH_CLOSE(fdP);
        /* set disk usage to be correct */
        VAdjustDiskUsage(&errorCode, volptr,
-                        (int)(nBlocks(nfSize) - nBlocks(NewLength)), 0);
+                        (afs_sfsize_t) (nBlocks(nfSize) -
+                                        nBlocks(NewLength)), 0);
        return errorCode;
     }
+    if (origfdP) {                                     /* finish CopyOnWrite */
+       if ( (CoW_off = Pos + Length) < NewLength) {
+           errorCode = CopyOnWrite2(origfdP, fdP, CoW_off, CoW_len = NewLength - CoW_off);
+           ViceLog(1, ("StoreData : CopyOnWrite2 on vnode %u.%u (%s) "
+                       "off 0x%llx size 0x%llx returns %d\n",
+                        afs_printable_VolumeId_u(V_id(volptr)),
+                       afs_printable_VnodeId_u(targetptr->vnodeNumber),
+                       V_name(volptr), CoW_off, CoW_len, errorCode));
+       }
+       FDH_CLOSE(origfdP);
+    }
     FDH_CLOSE(fdP);
 
-    TM_GetTimeOfDay(&StopTime, 0);
+    FT_GetTimeOfDay(&StopTime, 0);
 
     VN_SET_LEN(targetptr, NewLength);
 
     /* Update all StoreData related stats */
-    FS_LOCK if (AFSCallStats.TotalStoredBytes > 2000000000)    /* reset if over 2 billion */
-         AFSCallStats.TotalStoredBytes = AFSCallStats.AccumStoreTime = 0;
+    FS_LOCK;
+    if (AFSCallStats.TotalStoredBytes > 2000000000)    /* reset if over 2 billion */
+       AFSCallStats.TotalStoredBytes = AFSCallStats.AccumStoreTime = 0;
     AFSCallStats.StoreSize1++; /* Piggybacked data */
     {
        afs_fsize_t targLen;
@@ -6847,7 +7486,8 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid,
        else
            AFSCallStats.StoreSize5++;
     }
-    FS_UNLOCK return (errorCode);
+    FS_UNLOCK;
+    return (errorCode);
 
 }                              /*StoreData_RXStyle */
 
@@ -6895,9 +7535,13 @@ init_sys_error_to_et(void)
     sys2et[ENAMETOOLONG] = UAENAMETOOLONG;
     sys2et[ENOLCK] = UAENOLCK;
     sys2et[ENOSYS] = UAENOSYS;
+#if (ENOTEMPTY != EEXIST)
     sys2et[ENOTEMPTY] = UAENOTEMPTY;
+#endif
     sys2et[ELOOP] = UAELOOP;
+#if (EWOULDBLOCK != EAGAIN)
     sys2et[EWOULDBLOCK] = UAEWOULDBLOCK;
+#endif
     sys2et[ENOMSG] = UAENOMSG;
     sys2et[EIDRM] = UAEIDRM;
     sys2et[ECHRNG] = UAECHRNG;
@@ -6981,6 +7625,105 @@ init_sys_error_to_et(void)
     sys2et[EDQUOT] = UAEDQUOT;
     sys2et[ENOMEDIUM] = UAENOMEDIUM;
     sys2et[EMEDIUMTYPE] = UAEMEDIUMTYPE;
+
+    sys2et[EIO] = UAEIO;
+}
+
+/* NOTE:  2006-03-01                                                     
+ *  SRXAFS_CallBackRxConnAddr should be re-written as follows:           
+ *  - pass back the connection, client, and host from CallPreamble       
+ *  - keep a ref on the client, which we don't now                       
+ *  - keep a hold on the host, which we already do                       
+ *  - pass the connection, client, and host down into SAFSS_*, and use   
+ *    them instead of independently discovering them via rx_ConnectionOf 
+ *    (safe) and rx_GetSpecific (not so safe)                            
+ *  The idea being that we decide what client and host we're going to use
+ *  when CallPreamble is called, and stay consistent throughout the call.
+ *  This change is too invasive for 1.4.1 but should be made in 1.5.x.   
+ */                                                                      
+
+afs_int32
+SRXAFS_CallBackRxConnAddr (struct rx_call * acall, afs_int32 *addr)
+{
+    Error errorCode = 0;
+    struct rx_connection *tcon;
+    struct host *tcallhost;
+#ifdef __EXPERIMENTAL_CALLBACK_CONN_MOVING
+    struct host *thost;
+    struct client *tclient;
+    static struct rx_securityClass *sc = 0;
+    int i,j;
+    struct rx_connection *conn;
+#endif
+    
+    if ((errorCode = CallPreamble(acall, ACTIVECALL, &tcon, &tcallhost)))
+           goto Bad_CallBackRxConnAddr1;
+    
+#ifndef __EXPERIMENTAL_CALLBACK_CONN_MOVING
+    errorCode = 1;
+#else
+    H_LOCK;
+    tclient = h_FindClient_r(tcon);
+    if (!tclient) {
+       errorCode = VBUSY;
+       goto Bad_CallBackRxConnAddr;
+    }
+    thost = tclient->host;
+    
+    /* nothing more can be done */
+    if ( !thost->interface ) 
+       goto Bad_CallBackRxConnAddr;
+    
+    /* the only address is the primary interface */
+    /* can't change when there's only 1 address, anyway */
+    if ( thost->interface->numberOfInterfaces <= 1 ) 
+       goto Bad_CallBackRxConnAddr;
+    
+    /* initialise a security object only once */
+    if ( !sc )
+       sc = (struct rx_securityClass *) rxnull_NewClientSecurityObject();
+    
+    for ( i=0; i < thost->interface->numberOfInterfaces; i++)
+    {
+           if ( *addr == thost->interface->addr[i] ) {
+                   break;
+           }
+    }
+    
+    if ( *addr != thost->interface->addr[i] ) 
+       goto Bad_CallBackRxConnAddr;
+
+    conn = rx_NewConnection (thost->interface->addr[i],
+                            thost->port, 1, sc, 0);
+    rx_SetConnDeadTime(conn, 2); 
+    rx_SetConnHardDeadTime(conn, AFS_HARDDEADTIME); 
+    H_UNLOCK;
+    errorCode = RXAFSCB_Probe(conn);
+    H_LOCK;
+    if (!errorCode) {
+       if ( thost->callback_rxcon )
+           rx_DestroyConnection(thost->callback_rxcon);
+       thost->callback_rxcon = conn;
+       thost->host           = addr;
+       rx_SetConnDeadTime(thost->callback_rxcon, 50);
+       rx_SetConnHardDeadTime(thost->callback_rxcon, AFS_HARDDEADTIME);
+       h_ReleaseClient_r(tclient);
+       /* The hold on thost will be released by CallPostamble */
+       H_UNLOCK;
+       errorCode = CallPostamble(tcon, errorCode, tcallhost);
+       return errorCode;
+    } else {
+       rx_DestroyConnection(conn);
+    }      
+  Bad_CallBackRxConnAddr:
+    h_ReleaseClient_r(tclient);
+    /* The hold on thost will be released by CallPostamble */
+    H_UNLOCK;
+#endif
+
+    errorCode = CallPostamble(tcon, errorCode, tcallhost);
+ Bad_CallBackRxConnAddr1:
+    return errorCode;          /* failure */
 }
 
 afs_int32
@@ -6990,6 +7733,8 @@ sys_error_to_et(afs_int32 in)
        return 0;
     if (in < 0 || in > 511)
        return in;
+    if ((in >= VICE_SPECIAL_ERRORS && in <= VIO) || in == VRESTRICTED)
+       return in;
     if (sys2et[in] != 0)
        return sys2et[in];
     return in;